]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - sound/pci/oxygen/oxygen_mixer.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[karo-tx-linux.git] / sound / pci / oxygen / oxygen_mixer.c
index 6b5ff6e0fadd529186cfbd3c9949564ac6163c48..cc0cddadd589b259d0a4ff13334c70ce8f7e681f 100644 (file)
@@ -32,8 +32,8 @@ static int dac_volume_info(struct snd_kcontrol *ctl,
 
        info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
        info->count = chip->model->dac_channels;
-       info->value.integer.min = 0;
-       info->value.integer.max = 0xff;
+       info->value.integer.min = chip->model->dac_volume_min;
+       info->value.integer.max = chip->model->dac_volume_max;
        return 0;
 }
 
@@ -510,6 +510,21 @@ static int ac97_switch_get(struct snd_kcontrol *ctl,
        return 0;
 }
 
+static void mute_ac97_ctl(struct oxygen *chip, unsigned int control)
+{
+       unsigned int priv_idx = chip->controls[control]->private_value & 0xff;
+       u16 value;
+
+       value = oxygen_read_ac97(chip, 0, priv_idx);
+       if (!(value & 0x8000)) {
+               oxygen_write_ac97(chip, 0, priv_idx, value | 0x8000);
+               if (chip->model->ac97_switch)
+                       chip->model->ac97_switch(chip, priv_idx, 0x8000);
+               snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
+                              &chip->controls[control]->id);
+       }
+}
+
 static int ac97_switch_put(struct snd_kcontrol *ctl,
                           struct snd_ctl_elem_value *value)
 {
@@ -531,9 +546,24 @@ static int ac97_switch_put(struct snd_kcontrol *ctl,
        change = newreg != oldreg;
        if (change) {
                oxygen_write_ac97(chip, codec, index, newreg);
-               if (bitnr == 15 && chip->model->ac97_switch_hook)
-                       chip->model->ac97_switch_hook(chip, codec, index,
-                                                     newreg & 0x8000);
+               if (codec == 0 && chip->model->ac97_switch)
+                       chip->model->ac97_switch(chip, index, newreg & 0x8000);
+               if (index == AC97_LINE) {
+                       oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
+                                                newreg & 0x8000 ?
+                                                CM9780_GPO0 : 0, CM9780_GPO0);
+                       if (!(newreg & 0x8000)) {
+                               mute_ac97_ctl(chip, CONTROL_MIC_CAPTURE_SWITCH);
+                               mute_ac97_ctl(chip, CONTROL_CD_CAPTURE_SWITCH);
+                               mute_ac97_ctl(chip, CONTROL_AUX_CAPTURE_SWITCH);
+                       }
+               } else if ((index == AC97_MIC || index == AC97_CD ||
+                           index == AC97_VIDEO || index == AC97_AUX) &&
+                          bitnr == 15 && !(newreg & 0x8000)) {
+                       mute_ac97_ctl(chip, CONTROL_LINE_CAPTURE_SWITCH);
+                       oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
+                                                CM9780_GPO0, CM9780_GPO0);
+               }
        }
        mutex_unlock(&chip->mutex);
        return change;
@@ -712,6 +742,9 @@ static const struct snd_kcontrol_new controls[] = {
                .get = spdif_pcm_get,
                .put = spdif_pcm_put,
        },
+};
+
+static const struct snd_kcontrol_new spdif_input_controls[] = {
        {
                .iface = SNDRV_CTL_ELEM_IFACE_PCM,
                .device = 1,
@@ -849,7 +882,6 @@ static const struct snd_kcontrol_new ac97_controls[] = {
        AC97_VOLUME("Mic Capture Volume", 0, AC97_MIC),
        AC97_SWITCH("Mic Capture Switch", 0, AC97_MIC, 15, 1),
        AC97_SWITCH("Mic Boost (+20dB)", 0, AC97_MIC, 6, 0),
-       AC97_VOLUME("Line Capture Volume", 0, AC97_LINE),
        AC97_SWITCH("Line Capture Switch", 0, AC97_LINE, 15, 1),
        AC97_VOLUME("CD Capture Volume", 0, AC97_CD),
        AC97_SWITCH("CD Capture Switch", 0, AC97_CD, 15, 1),
@@ -909,6 +941,11 @@ static int add_controls(struct oxygen *chip,
                        return err;
                if (err == 1)
                        continue;
+               if (!strcmp(template.name, "Master Playback Volume") &&
+                   chip->model->dac_tlv) {
+                       template.tlv.p = chip->model->dac_tlv;
+                       template.access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
+               }
                ctl = snd_ctl_new1(&template, chip);
                if (!ctl)
                        return -ENOMEM;
@@ -932,6 +969,12 @@ int oxygen_mixer_init(struct oxygen *chip)
        err = add_controls(chip, controls, ARRAY_SIZE(controls));
        if (err < 0)
                return err;
+       if (chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF) {
+               err = add_controls(chip, spdif_input_controls,
+                                  ARRAY_SIZE(spdif_input_controls));
+               if (err < 0)
+                       return err;
+       }
        for (i = 0; i < ARRAY_SIZE(monitor_controls); ++i) {
                if (!(chip->model->pcm_dev_cfg & monitor_controls[i].pcm_dev))
                        continue;