ALSA: snd-usb-6fire: add analog input volume control

Add a stereo volume control for analog input channel pair 1/2.

Signed-off-by: Torsten Schenk <torsten.schenk@zoho.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Torsten Schenk 2012-02-22 15:21:30 +01:00 committed by Takashi Iwai
parent d97c735a10
commit 06bb4e7435
2 changed files with 73 additions and 0 deletions

View file

@ -55,6 +55,7 @@ static const u16 rates_6fire_vl[] = {0x00, 0x01, 0x00, 0x01, 0x00, 0x01};
static const u16 rates_6fire_vh[] = {0x11, 0x11, 0x10, 0x10, 0x00, 0x00};
static DECLARE_TLV_DB_MINMAX(tlv_output, -9000, 0);
static DECLARE_TLV_DB_MINMAX(tlv_input, -1500, 1500);
enum {
DIGITAL_THRU_ONLY_SAMPLERATE = 3
@ -82,6 +83,20 @@ static void usb6fire_control_output_mute_update(struct control_runtime *rt)
comm_rt->write8(comm_rt, 0x12, 0x0e, ~rt->output_mute);
}
static void usb6fire_control_input_vol_update(struct control_runtime *rt)
{
struct comm_runtime *comm_rt = rt->chip->comm;
int i;
if (comm_rt)
for (i = 0; i < 2; i++)
if (!(rt->ivol_updated & (1 << i))) {
comm_rt->write8(comm_rt, 0x12, 0x1c + i,
rt->input_vol[i] & 0x3f);
rt->ivol_updated |= 1 << i;
}
}
static void usb6fire_control_line_phono_update(struct control_runtime *rt)
{
struct comm_runtime *comm_rt = rt->chip->comm;
@ -261,6 +276,50 @@ static int usb6fire_control_output_mute_get(struct snd_kcontrol *kcontrol,
return 0;
}
static int usb6fire_control_input_vol_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = 2;
uinfo->value.integer.min = 0;
uinfo->value.integer.max = 30;
return 0;
}
static int usb6fire_control_input_vol_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct control_runtime *rt = snd_kcontrol_chip(kcontrol);
int changed = 0;
if (rt->input_vol[0] != ucontrol->value.integer.value[0]) {
rt->input_vol[0] = ucontrol->value.integer.value[0] - 15;
rt->ivol_updated &= ~(1 << 0);
changed = 1;
}
if (rt->input_vol[1] != ucontrol->value.integer.value[1]) {
rt->input_vol[1] = ucontrol->value.integer.value[1] - 15;
rt->ivol_updated &= ~(1 << 1);
changed = 1;
}
if (changed)
usb6fire_control_input_vol_update(rt);
return changed;
}
static int usb6fire_control_input_vol_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct control_runtime *rt = snd_kcontrol_chip(kcontrol);
ucontrol->value.integer.value[0] = rt->input_vol[0] + 15;
ucontrol->value.integer.value[1] = rt->input_vol[1] + 15;
return 0;
}
static int usb6fire_control_line_phono_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
@ -454,6 +513,17 @@ static struct __devinitdata snd_kcontrol_new elements[] = {
.get = usb6fire_control_digital_thru_get,
.put = usb6fire_control_digital_thru_put
},
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Analog Capture Volume",
.index = 0,
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
SNDRV_CTL_ELEM_ACCESS_TLV_READ,
.info = usb6fire_control_input_vol_info,
.get = usb6fire_control_input_vol_get,
.put = usb6fire_control_input_vol_put,
.tlv = { .p = tlv_input }
},
{}
};
@ -518,6 +588,7 @@ int __devinit usb6fire_control_init(struct sfire_chip *chip)
usb6fire_control_line_phono_update(rt);
usb6fire_control_output_vol_update(rt);
usb6fire_control_output_mute_update(rt);
usb6fire_control_input_vol_update(rt);
usb6fire_control_streaming_update(rt);
ret = usb6fire_control_add_virtual(rt, chip->card,

View file

@ -46,6 +46,8 @@ struct control_runtime {
u8 output_vol[6];
u8 ovol_updated;
u8 output_mute;
s8 input_vol[2];
u8 ivol_updated;
};
int __devinit usb6fire_control_init(struct sfire_chip *chip);