add a capture source select for Revolution 5.1
PATCH 1/1 add a capture source select for Revolution 5.1
Add capture source selection for the M-Audio Revolution 5.1.
The AK5365 ADC, used for the Revolution 5.1 card, allows to choose between different input sources. This patch adds a new mixer element to support this.
---
This addresses the first item in my recent "M-Audio Revolution 5.1 - new hardware information" email. Comments are very welcome. Especially I am not sure whether I feed the list of mixer channel names into 'ak4xxx_capture_source_info' the right way.
I tested the patch and it works for me.
alsa-kernel/i2c/other/ak4xxx-adda.c +74 -0
@@ -513,6 +513,62 @@return change; } +static int ak4xxx_capture_source_info (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_info *uinfo) +{ +struct snd_akm4xxx *ak =snd_kcontrol_chip (kcontrol); +const char **input_names; +int num_names, idx; + + input_names = ak->adc_info[0 ].input_names; + + num_names =0 ; +while (num_names<8 && input_names[num_names]) + ++num_names; + + uinfo->type =SNDRV_CTL_ELEM_TYPE_ENUMERATED ; + uinfo->count =1 ; + uinfo->value.enumerated.items = num_names; + idx = uinfo->value.enumerated.item; +if (idx >= num_names) + idx = num_names -1 ; +strncpy (uinfo->value.enumerated.name, input_names[idx],64 ); +return 0 ; +} + +static int ak4xxx_capture_source_get (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct snd_akm4xxx *ak =snd_kcontrol_chip (kcontrol); +int chip =AK_GET_CHIP (kcontrol->private_value); +int addr =AK_GET_ADDR (kcontrol->private_value); +int shift =AK_GET_SHIFT (kcontrol->private_value); +int mask =AK_GET_MASK (kcontrol->private_value); +unsigned char val; + + val = (snd_akm4xxx_get (ak, chip, addr)&mask) >> shift; + ucontrol->value.enumerated.item[0 ] = val; +return 0 ; +} + +static int ak4xxx_capture_source_put (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct snd_akm4xxx *ak =snd_kcontrol_chip (kcontrol); +int chip =AK_GET_CHIP (kcontrol->private_value); +int addr =AK_GET_ADDR (kcontrol->private_value); +int shift =AK_GET_SHIFT (kcontrol->private_value); +int mask =AK_GET_MASK (kcontrol->private_value); +unsigned char oval, val; + + oval =snd_akm4xxx_get (ak, chip, addr); + val = oval & ~mask; + val |= (ucontrol->value.enumerated.item[0 ] << shift)&mask; +if (val != oval) +snd_akm4xxx_write (ak, chip, addr, val); +return 0 ; +} +/* * build AK4xxx controls */
@@ -662,6 +718,24 @@ err =snd_ctl_add (ak->card,snd_ctl_new1 (&knew, ak));if (err <0 )return err; + +memset (&knew,0 ,sizeof (knew)); + knew.name = ak->adc_info[mixer_ch].selector_name; +if (! knew.name) + knew.name ="Capture Source Select" ; + + knew.index = mixer_ch; + knew.iface =SNDRV_CTL_ELEM_IFACE_MIXER ; + knew.info = ak4xxx_capture_source_info; + knew.get = ak4xxx_capture_source_get; + knew.put = ak4xxx_capture_source_put; + knew.access =0 ; +/* input selector control: reg. 1, bits 0-2 */ + knew.private_value + =AK_COMPOSE (idx/2 ,1 ,0 ,0x07 ); + err =snd_ctl_add (ak->card,snd_ctl_new1 (&knew, ak)); +if (err <0 ) +return err; } idx += num_stereo;
alsa-kernel/include/ak4xxx-adda.h +2 -0
@@ -50,6 +50,8 @@char *name;/* capture gain volume label */ char *switch_name;/* capture switch */ unsigned int num_channels; +char *selector_name;/* capture source select label */ +const char **input_names;/* capture source names (NULL terminated) */ };struct snd_akm4xxx {
alsa-kernel/pci/ice1712/revo.c +9 -1
@@ -107,11 +107,19 @@ AK_DAC("PCM Rear Playback Volume", 2), }; +const char *revo51_adc_input_names[] = { +"Mic" , +"Line" , +"CD" , +NULL +}; +static struct snd_akm4xxx_adc_channel revo51_adc[] = { { .name ="PCM Capture Volume" , .switch_name ="PCM Capture Switch" , - .num_channels =2 + .num_channels =2 , + .input_names = revo51_adc_input_names }, };
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel