[ALSA] ice1724 - Add PCM Playback Switch to Revo 7.1
authorPavel Hofman <dustin@seznam.cz>
Sat, 19 May 2007 15:21:04 +0000 (17:21 +0200)
committerJaroslav Kysela <perex@suse.cz>
Fri, 20 Jul 2007 09:11:18 +0000 (11:11 +0200)
This patch adds the support of mute for front channels of M-Audio
Revolution 7.1 (the DAC AK4381 features a mute bit).

Signed-off-by: Pavel Hofman <dustin@seznam.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
include/sound/ak4xxx-adda.h
sound/i2c/other/ak4xxx-adda.c
sound/pci/ice1712/revo.c

index aa49dda4f4104b4a58032516e72f690b94191627..fd0a6c46f497e69946137621a4f5ae7cf049125c 100644 (file)
@@ -43,6 +43,7 @@ struct snd_ak4xxx_ops {
 struct snd_akm4xxx_dac_channel {
        char *name;             /* mixer volume name */
        unsigned int num_channels;
 struct snd_akm4xxx_dac_channel {
        char *name;             /* mixer volume name */
        unsigned int num_channels;
+       char *switch_name;              /* mixer switch*/
 };
 
 /* ADC labels and channels */
 };
 
 /* ADC labels and channels */
index 8805110017a7ece661d519a2e19d737089245849..fd335159f8499ee9f5b50ed7fb8ccee9fc9fd7b0 100644 (file)
@@ -481,8 +481,8 @@ static int ak4xxx_switch_get(struct snd_kcontrol *kcontrol,
        int addr = AK_GET_ADDR(kcontrol->private_value);
        int shift = AK_GET_SHIFT(kcontrol->private_value);
        int invert = AK_GET_INVERT(kcontrol->private_value);
        int addr = AK_GET_ADDR(kcontrol->private_value);
        int shift = AK_GET_SHIFT(kcontrol->private_value);
        int invert = AK_GET_INVERT(kcontrol->private_value);
-       unsigned char val = snd_akm4xxx_get(ak, chip, addr);
-
+       /* we observe the (1<<shift) bit only */
+       unsigned char val = snd_akm4xxx_get(ak, chip, addr) & (1<<shift);
        if (invert)
                val = ! val;
        ucontrol->value.integer.value[0] = (val & (1<<shift)) != 0;
        if (invert)
                val = ! val;
        ucontrol->value.integer.value[0] = (val & (1<<shift)) != 0;
@@ -585,6 +585,26 @@ static int build_dac_controls(struct snd_akm4xxx *ak)
 
        mixer_ch = 0;
        for (idx = 0; idx < ak->num_dacs; ) {
 
        mixer_ch = 0;
        for (idx = 0; idx < ak->num_dacs; ) {
+               /* mute control for Revolution 7.1 - AK4381 */
+               if (ak->type == SND_AK4381 
+                               &&  ak->dac_info[mixer_ch].switch_name) {
+                       memset(&knew, 0, sizeof(knew));
+                       knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
+                       knew.count = 1;
+                       knew.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
+                       knew.name = ak->dac_info[mixer_ch].switch_name;
+                       knew.info = ak4xxx_switch_info;
+                       knew.get = ak4xxx_switch_get;
+                       knew.put = ak4xxx_switch_put;
+                       knew.access = 0;
+                       /* register 1, bit 0 (SMUTE): 0 = normal operation,
+                          1 = mute */
+                       knew.private_value =
+                               AK_COMPOSE(idx/2, 1, 0, 0) | AK_INVERT;
+                       err = snd_ctl_add(ak->card, snd_ctl_new1(&knew, ak));
+                       if (err < 0)
+                               return err;
+               }
                memset(&knew, 0, sizeof(knew));
                if (! ak->dac_info || ! ak->dac_info[mixer_ch].name) {
                        knew.name = "DAC Volume";
                memset(&knew, 0, sizeof(knew));
                if (! ak->dac_info || ! ak->dac_info[mixer_ch].name) {
                        knew.name = "DAC Volume";
index 690ceb34064444575578a982a04e1b51d428f9ed..d18a31e188a9a594ccbe8b0ed22a487bec783703 100644 (file)
@@ -186,7 +186,12 @@ static int revo51_i2c_init(struct snd_ice1712 *ice,
 #define AK_DAC(xname,xch) { .name = xname, .num_channels = xch }
 
 static const struct snd_akm4xxx_dac_channel revo71_front[] = {
 #define AK_DAC(xname,xch) { .name = xname, .num_channels = xch }
 
 static const struct snd_akm4xxx_dac_channel revo71_front[] = {
-       AK_DAC("PCM Playback Volume", 2)
+       {
+               .name = "PCM Playback Volume",
+               .num_channels = 2,
+               /* front channels DAC supports muting */
+               .switch_name = "PCM Playback Switch",
+       },
 };
 
 static const struct snd_akm4xxx_dac_channel revo71_surround[] = {
 };
 
 static const struct snd_akm4xxx_dac_channel revo71_surround[] = {