Commit 64e5310a authored by Andy Owen's avatar Andy Owen Committed by Takashi Iwai

ALSA: ca0106: Use card specific dac id for mute controls.

Signed-off-by: default avatarAndy Owen <andy-alsa@ultra-premium.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 6fef153a
...@@ -676,28 +676,65 @@ static struct snd_kcontrol_new snd_ca0106_volume_i2c_adc_ctls[] __devinitdata = ...@@ -676,28 +676,65 @@ static struct snd_kcontrol_new snd_ca0106_volume_i2c_adc_ctls[] __devinitdata =
I2C_VOLUME("Aux Capture Volume", 3), I2C_VOLUME("Aux Capture Volume", 3),
}; };
#define SPI_SWITCH(xname,reg,bit) \ static const int spi_dmute_reg[] = {
{ \ SPI_DMUTE0_REG,
.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ SPI_DMUTE1_REG,
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ SPI_DMUTE2_REG,
.info = spi_mute_info, \ 0,
.get = spi_mute_get, \ SPI_DMUTE4_REG,
.put = spi_mute_put, \ };
.private_value = (reg<<SPI_REG_SHIFT) | (bit) \ static const int spi_dmute_bit[] = {
} SPI_DMUTE0_BIT,
SPI_DMUTE1_BIT,
static struct snd_kcontrol_new snd_ca0106_volume_spi_dac_ctls[] SPI_DMUTE2_BIT,
__devinitdata = { 0,
SPI_SWITCH("Analog Front Playback Switch", SPI_DMUTE4_BIT,
SPI_DMUTE4_REG, SPI_DMUTE4_BIT),
SPI_SWITCH("Analog Rear Playback Switch",
SPI_DMUTE0_REG, SPI_DMUTE0_BIT),
SPI_SWITCH("Analog Center/LFE Playback Switch",
SPI_DMUTE2_REG, SPI_DMUTE2_BIT),
SPI_SWITCH("Analog Side Playback Switch",
SPI_DMUTE1_REG, SPI_DMUTE1_BIT),
}; };
static struct snd_kcontrol_new __devinit
snd_ca0106_volume_spi_dac_ctl(struct snd_ca0106_details *details,
int channel_id)
{
struct snd_kcontrol_new spi_switch = {0};
int reg, bit;
int dac_id;
spi_switch.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
spi_switch.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
spi_switch.info = spi_mute_info;
spi_switch.get = spi_mute_get;
spi_switch.put = spi_mute_put;
switch (channel_id) {
case PCM_FRONT_CHANNEL:
spi_switch.name = "Analog Front Playback Switch";
dac_id = (details->spi_dac & 0xf000) >> (4 * 3);
break;
case PCM_REAR_CHANNEL:
spi_switch.name = "Analog Rear Playback Switch";
dac_id = (details->spi_dac & 0x0f00) >> (4 * 2);
break;
case PCM_CENTER_LFE_CHANNEL:
spi_switch.name = "Analog Center/LFE Playback Switch";
dac_id = (details->spi_dac & 0x00f0) >> (4 * 1);
break;
case PCM_UNKNOWN_CHANNEL:
spi_switch.name = "Analog Side Playback Switch";
dac_id = (details->spi_dac & 0x000f) >> (4 * 0);
break;
default:
/* Unused channel */
spi_switch.name = NULL;
dac_id = 0;
}
reg = spi_dmute_reg[dac_id];
bit = spi_dmute_bit[dac_id];
spi_switch.private_value = (reg << SPI_REG_SHIFT) | bit;
return spi_switch;
}
static int __devinit remove_ctl(struct snd_card *card, const char *name) static int __devinit remove_ctl(struct snd_card *card, const char *name)
{ {
struct snd_ctl_elem_id id; struct snd_ctl_elem_id id;
...@@ -832,8 +869,18 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu) ...@@ -832,8 +869,18 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu)
if (err < 0) if (err < 0)
return err; return err;
} }
if (emu->details->spi_dac) if (emu->details->spi_dac) {
ADD_CTLS(emu, snd_ca0106_volume_spi_dac_ctls); int i;
for (i = 0;; i++) {
struct snd_kcontrol_new ctl;
ctl = snd_ca0106_volume_spi_dac_ctl(emu->details, i);
if (!ctl.name)
break;
err = snd_ctl_add(card, snd_ctl_new1(&ctl, emu));
if (err < 0)
return err;
}
}
/* Create virtual master controls */ /* Create virtual master controls */
vmaster = snd_ctl_make_virtual_master("Master Playback Volume", vmaster = snd_ctl_make_virtual_master("Master Playback Volume",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment