ALSA: Implement channel maps for standard onboard AC97 drivers
authorTakashi Iwai <tiwai@suse.de>
Fri, 3 Aug 2012 16:01:40 +0000 (18:01 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 6 Sep 2012 16:08:31 +0000 (18:08 +0200)
Just set the channel maps depending on the hardware availability.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/atiixp.c
sound/pci/fm801.c
sound/pci/intel8x0.c
sound/pci/via82xx.c

index c744df5bb1c65d1a0eb30f884f668ed0986e1d5f..368df8b0853e218ca48b92553ccd653d8b406195 100644 (file)
@@ -1250,6 +1250,7 @@ static struct atiixp_dma_ops snd_atiixp_spdif_dma_ops = {
 static int __devinit snd_atiixp_pcm_new(struct atiixp *chip)
 {
        struct snd_pcm *pcm;
+       struct snd_pcm_chmap *chmap;
        struct snd_ac97_bus *pbus = chip->ac97_bus;
        int err, i, num_pcms;
 
@@ -1293,6 +1294,14 @@ static int __devinit snd_atiixp_pcm_new(struct atiixp *chip)
                                              snd_dma_pci_data(chip->pci),
                                              64*1024, 128*1024);
 
+       err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
+                                    snd_pcm_alt_chmaps, chip->max_channels, 0,
+                                    &chmap);
+       if (err < 0)
+               return err;
+       chmap->channel_mask = SND_PCM_CHMAP_MASK_2468;
+       chip->ac97[0]->chmaps[SNDRV_PCM_STREAM_PLAYBACK] = chmap;
+
        /* no SPDIF support on codec? */
        if (chip->pcms[ATI_PCM_SPDIF] && ! chip->pcms[ATI_PCM_SPDIF]->rates)
                return 0;
index ce3e548de41da10012f6661cecb6089c698578d3..cc2e91d1553822699251c15baf950e406243df8d 100644 (file)
@@ -711,6 +711,13 @@ static int __devinit snd_fm801_pcm(struct fm801 *chip, int device, struct snd_pc
                                              snd_dma_pci_data(chip->pci),
                                              chip->multichannel ? 128*1024 : 64*1024, 128*1024);
 
+       err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
+                                    snd_pcm_alt_chmaps,
+                                    chip->multichannel ? 6 : 2, 0,
+                                    NULL);
+       if (err < 0)
+               return err;
+
        if (rpcm)
                *rpcm = pcm;
        return 0;
index 5c4115289a9a1c15f56e20e1e5345cdfe6f04b7b..848102e5d864d6d1ac5007af668737ca087aced3 100644 (file)
@@ -1541,6 +1541,26 @@ static int __devinit snd_intel8x0_pcm1(struct intel8x0 *chip, int device,
                                              snd_dma_pci_data(chip->pci),
                                              rec->prealloc_size, rec->prealloc_max_size);
 
+       if (rec->ac97_idx == ICHD_PCMOUT && rec->playback_ops) {
+               struct snd_pcm_chmap *chmap;
+               int chs = 2;
+               if (rec->ac97_idx == ICHD_PCMOUT) {
+                       if (chip->multi8)
+                               chs = 8;
+                       else if (chip->multi6)
+                               chs = 6;
+                       else if (chip->multi4)
+                               chs = 4;
+               }
+               err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
+                                            snd_pcm_alt_chmaps, chs, 0,
+                                            &chmap);
+               if (err < 0)
+                       return err;
+               chmap->channel_mask = SND_PCM_CHMAP_MASK_2468;
+               chip->ac97[0]->chmaps[SNDRV_PCM_STREAM_PLAYBACK] = chmap;
+       }
+
        return 0;
 }
 
index e3d32e2d574e9021368e449b46db8b6674762cd8..f0b4efdb483c3ea627cb8a544b9a8b9c6ff2bc58 100644 (file)
@@ -1440,6 +1440,7 @@ static void init_viadev(struct via82xx *chip, int idx, unsigned int reg_offset,
 static int __devinit snd_via8233_pcm_new(struct via82xx *chip)
 {
        struct snd_pcm *pcm;
+       struct snd_pcm_chmap *chmap;
        int i, err;
 
        chip->playback_devno = 0;       /* x 4 */
@@ -1467,6 +1468,12 @@ static int __devinit snd_via8233_pcm_new(struct via82xx *chip)
                                              snd_dma_pci_data(chip->pci),
                                              64*1024, VIA_MAX_BUFSIZE);
 
+       err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
+                                    snd_pcm_std_chmaps, 2, 0,
+                                    &chmap);
+       if (err < 0)
+               return err;
+
        /* PCM #1:  multi-channel playback and 2nd capture */
        err = snd_pcm_new(chip->card, chip->card->shortname, 1, 1, 1, &pcm);
        if (err < 0)
@@ -1484,6 +1491,14 @@ static int __devinit snd_via8233_pcm_new(struct via82xx *chip)
        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
                                              snd_dma_pci_data(chip->pci),
                                              64*1024, VIA_MAX_BUFSIZE);
+
+       err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
+                                    snd_pcm_alt_chmaps, 6, 0,
+                                    &chmap);
+       if (err < 0)
+               return err;
+       chip->ac97->chmaps[SNDRV_PCM_STREAM_PLAYBACK] = chmap;
+
        return 0;
 }
 
@@ -1493,6 +1508,7 @@ static int __devinit snd_via8233_pcm_new(struct via82xx *chip)
 static int __devinit snd_via8233a_pcm_new(struct via82xx *chip)
 {
        struct snd_pcm *pcm;
+       struct snd_pcm_chmap *chmap;
        int err;
 
        chip->multi_devno = 0;
@@ -1519,6 +1535,13 @@ static int __devinit snd_via8233a_pcm_new(struct via82xx *chip)
                                              snd_dma_pci_data(chip->pci),
                                              64*1024, VIA_MAX_BUFSIZE);
 
+       err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
+                                    snd_pcm_alt_chmaps, 6, 0,
+                                    &chmap);
+       if (err < 0)
+               return err;
+       chip->ac97->chmaps[SNDRV_PCM_STREAM_PLAYBACK] = chmap;
+
        /* SPDIF supported? */
        if (! ac97_can_spdif(chip->ac97))
                return 0;