snd-usb-6fire: add analog input volume control
PATCH v2 5/5 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 <[email protected]>
sound/usb/6fire/control.c +66 -0
@@ -55,6 +55,7 @@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
@@ -79,6 +80,17 @@ 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++) + comm_rt->write8 (comm_rt,0x12 ,0x1c + i, + rt->input_vol[i] &0x3f ); +} +static void usb6fire_control_line_phono_update (struct control_runtime *rt) {struct comm_runtime *comm_rt = rt->chip->comm;
@@ -256,6 +268,48 @@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 ; + changed =1 ; + } +if (rt->input_vol[1 ] != ucontrol->value.integer.value[1 ]) { + rt->input_vol[1 ] = ucontrol->value.integer.value[1 ] -15 ; + 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) {
@@ -449,6 +503,17 @@ .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 } + }, {} };
@@ -512,6 +577,7 @@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,
sound/usb/6fire/control.h +1 -0
@@ -45,6 +45,7 @@bool usb_streaming;u8 output_vol[6 ];u8 output_mute; +s8 input_vol[2 ]; };int __devinit usb6fire_control_init (struct sfire_chip *chip);