]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[ALSA] oxygen: use SPDIF input only if present
authorClemens Ladisch <clemens@ladisch.de>
Wed, 9 Apr 2008 07:16:33 +0000 (09:16 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 24 Apr 2008 10:00:32 +0000 (12:00 +0200)
If the card model does not have a digital input or an AC97 codec,
disable the respective interrupt and mixer controls.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/oxygen/hifier.c
sound/pci/oxygen/oxygen_lib.c
sound/pci/oxygen/oxygen_mixer.c
sound/pci/oxygen/virtuoso.c

index 1e54a3cd721e3b715d030a4c582c5c26b7f922b2..50551ae0b3b41ecdd790212f967aeb6bd5e47928 100644 (file)
@@ -132,11 +132,6 @@ static int hifier_control_filter(struct snd_kcontrol_new *template)
                template->tlv.p = ak4396_db_scale;
        } else if (!strcmp(template->name, "Stereo Upmixing")) {
                return 1; /* stereo only - we don't need upmixing */
-       } else if (!strcmp(template->name,
-                          SNDRV_CTL_NAME_IEC958("", CAPTURE, MASK)) ||
-                  !strcmp(template->name,
-                          SNDRV_CTL_NAME_IEC958("", CAPTURE, DEFAULT))) {
-               return 1; /* no digital input */
        }
        return 0;
 }
index 4f3d9e5fc5db79772009e8b7f0938d663a3fc470..39e4b7a5174007ec447b515a53aaa0eaaa027b16 100644 (file)
@@ -291,20 +291,27 @@ static void oxygen_init(struct oxygen *chip)
                               OXYGEN_I2S_MASTER | OXYGEN_I2S_MUTE_MCLK);
        oxygen_write16(chip, OXYGEN_I2S_C_FORMAT,
                       OXYGEN_I2S_MASTER | OXYGEN_I2S_MUTE_MCLK);
-       oxygen_write32_masked(chip, OXYGEN_SPDIF_CONTROL,
-                             OXYGEN_SPDIF_SENSE_MASK |
-                             OXYGEN_SPDIF_LOCK_MASK |
-                             OXYGEN_SPDIF_RATE_MASK |
-                             OXYGEN_SPDIF_LOCK_PAR |
-                             OXYGEN_SPDIF_IN_CLOCK_96,
-                             OXYGEN_SPDIF_OUT_ENABLE |
-                             OXYGEN_SPDIF_LOOPBACK |
-                             OXYGEN_SPDIF_SENSE_MASK |
-                             OXYGEN_SPDIF_LOCK_MASK |
-                             OXYGEN_SPDIF_RATE_MASK |
-                             OXYGEN_SPDIF_SENSE_PAR |
-                             OXYGEN_SPDIF_LOCK_PAR |
-                             OXYGEN_SPDIF_IN_CLOCK_MASK);
+       oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL,
+                           OXYGEN_SPDIF_OUT_ENABLE |
+                           OXYGEN_SPDIF_LOOPBACK);
+       if (chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF)
+               oxygen_write32_masked(chip, OXYGEN_SPDIF_CONTROL,
+                                     OXYGEN_SPDIF_SENSE_MASK |
+                                     OXYGEN_SPDIF_LOCK_MASK |
+                                     OXYGEN_SPDIF_RATE_MASK |
+                                     OXYGEN_SPDIF_LOCK_PAR |
+                                     OXYGEN_SPDIF_IN_CLOCK_96,
+                                     OXYGEN_SPDIF_SENSE_MASK |
+                                     OXYGEN_SPDIF_LOCK_MASK |
+                                     OXYGEN_SPDIF_RATE_MASK |
+                                     OXYGEN_SPDIF_SENSE_PAR |
+                                     OXYGEN_SPDIF_LOCK_PAR |
+                                     OXYGEN_SPDIF_IN_CLOCK_MASK);
+       else
+               oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL,
+                                   OXYGEN_SPDIF_SENSE_MASK |
+                                   OXYGEN_SPDIF_LOCK_MASK |
+                                   OXYGEN_SPDIF_RATE_MASK);
        oxygen_write32(chip, OXYGEN_SPDIF_OUTPUT_BITS, chip->spdif_bits);
        oxygen_clear_bits8(chip, OXYGEN_MPU401_CONTROL, OXYGEN_MPU401_LOOPBACK);
        oxygen_write8(chip, OXYGEN_GPI_INTERRUPT_MASK, 0);
@@ -327,9 +334,12 @@ static void oxygen_init(struct oxygen *chip)
                      (2 << OXYGEN_A_MONITOR_ROUTE_2_SHIFT) |
                      (3 << OXYGEN_A_MONITOR_ROUTE_3_SHIFT));
 
-       oxygen_write8(chip, OXYGEN_AC97_INTERRUPT_MASK,
-                     OXYGEN_AC97_INT_READ_DONE |
-                     OXYGEN_AC97_INT_WRITE_DONE);
+       if (chip->has_ac97_0 | chip->has_ac97_1)
+               oxygen_write8(chip, OXYGEN_AC97_INTERRUPT_MASK,
+                             OXYGEN_AC97_INT_READ_DONE |
+                             OXYGEN_AC97_INT_WRITE_DONE);
+       else
+               oxygen_write8(chip, OXYGEN_AC97_INTERRUPT_MASK, 0);
        oxygen_write32(chip, OXYGEN_AC97_OUT_CONFIG, 0);
        oxygen_write32(chip, OXYGEN_AC97_IN_CONFIG, 0);
        if (!(chip->has_ac97_0 | chip->has_ac97_1))
@@ -495,7 +505,10 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
        oxygen_proc_init(chip);
 
        spin_lock_irq(&chip->reg_lock);
-       chip->interrupt_mask |= OXYGEN_INT_SPDIF_IN_DETECT | OXYGEN_INT_AC97;
+       if (chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF)
+               chip->interrupt_mask |= OXYGEN_INT_SPDIF_IN_DETECT;
+       if (chip->has_ac97_0 | chip->has_ac97_1)
+               chip->interrupt_mask |= OXYGEN_INT_AC97;
        oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask);
        spin_unlock_irq(&chip->reg_lock);
 
index d0bef09a6999bfa2cbce9aece2be6b60da1df857..2cb914498a19ff7c601df48a9ea5b79218b4b67f 100644 (file)
@@ -742,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,
@@ -961,6 +964,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;
index b678e2de4adf3a5671b29f131dee35f6673730d3..07d7e9b6afbbdd7ba4cd97595228615251e8820e 100644 (file)
@@ -506,11 +506,6 @@ static int xonar_dx_control_filter(struct snd_kcontrol_new *template)
                template->tlv.p = cs4362a_db_scale;
        } else if (!strncmp(template->name, "CD Capture ", 11)) {
                return 1; /* no CD input */
-       } else if (!strcmp(template->name,
-                          SNDRV_CTL_NAME_IEC958("", CAPTURE, MASK)) ||
-                  !strcmp(template->name,
-                          SNDRV_CTL_NAME_IEC958("", CAPTURE, DEFAULT))) {
-               return 1; /* no digital input */
        }
        return 0;
 }