[ALSA] hda-codec - Fix SPDIF device number of ALC codecs
authorTakashi Iwai <tiwai@suse.de>
Thu, 7 Sep 2006 15:52:14 +0000 (17:52 +0200)
committerJaroslav Kysela <perex@suse.cz>
Sat, 23 Sep 2006 08:46:46 +0000 (10:46 +0200)
Assign the SPDIF always to the secondary device (dev#1) to keep
the same configuration.  Move the optional capture device to the
third device (dev#2).
hda_intel now just ignores the NULL entries in the pcm arrays
from codecs.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
sound/pci/hda/hda_intel.c
sound/pci/hda/patch_realtek.c

index bfd74a526b8568576adcf880c5f90a6d72ca0c14..6309e0c67e6ae4fd0d7549b199e0f014e89da3b1 100644 (file)
@@ -1242,7 +1242,12 @@ static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec,
        struct snd_pcm *pcm;
        struct azx_pcm *apcm;
 
-       snd_assert(cpcm->stream[0].substreams || cpcm->stream[1].substreams, return -EINVAL);
+       /* if no substreams are defined for both playback and capture,
+        * it's just a placeholder.  ignore it.
+        */
+       if (!cpcm->stream[0].substreams && !cpcm->stream[1].substreams)
+               return 0;
+
        snd_assert(cpcm->name, return -EINVAL);
 
        err = snd_pcm_new(chip->card, cpcm->name, pcm_dev,
@@ -1268,7 +1273,8 @@ static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec,
                                              snd_dma_pci_data(chip->pci),
                                              1024 * 64, 1024 * 128);
        chip->pcm[pcm_dev] = pcm;
-       chip->pcm_devs = pcm_dev + 1;
+       if (chip->pcm_devs < pcm_dev + 1)
+               chip->pcm_devs = pcm_dev + 1;
 
        return 0;
 }
index d037051b66b4012d7b6f6cba4713d101cc3669cb..ba9e050e20124a2caf0b18746ac7b52fe10ccd88 100644 (file)
@@ -1796,25 +1796,9 @@ static int alc_build_pcms(struct hda_codec *codec)
                }
        }
 
-       /* If the use of more than one ADC is requested for the current
-        * model, configure a second analog capture-only PCM.
-        */
-       if (spec->num_adc_nids > 1) {
-               codec->num_pcms++;
-               info++;
-               info->name = spec->stream_name_analog;
-               /* No playback stream for second PCM */
-               info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
-               info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
-               if (spec->stream_analog_capture) {
-                       snd_assert(spec->adc_nids, return -EINVAL);
-                       info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
-                       info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
-               }
-       }
-
+       /* SPDIF for stream index #1 */
        if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
-               codec->num_pcms++;
+               codec->num_pcms = 2;
                info++;
                info->name = spec->stream_name_digital;
                if (spec->multiout.dig_out_nid &&
@@ -1829,6 +1813,24 @@ static int alc_build_pcms(struct hda_codec *codec)
                }
        }
 
+       /* If the use of more than one ADC is requested for the current
+        * model, configure a second analog capture-only PCM.
+        */
+       /* Additional Analaog capture for index #2 */
+       if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
+           spec->adc_nids) {
+               codec->num_pcms = 3;
+               info++;
+               info->name = spec->stream_name_analog;
+               /* No playback stream for second PCM */
+               info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
+               info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
+               if (spec->stream_analog_capture) {
+                       info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
+                       info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
+               }
+       }
+
        return 0;
 }