ALSA: hda - Add standard channel maps
authorTakashi Iwai <tiwai@suse.de>
Tue, 31 Jul 2012 09:35:35 +0000 (11:35 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 6 Sep 2012 16:01:18 +0000 (18:01 +0200)
Although HD-audio allows pair-wise channel configurations, only the
fixed channel positions are used in this version.  In future, this can
be changed and allow user to modify the channel positions.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_codec.h
sound/pci/hda/patch_realtek.c

index ff97cf3..c4c62ed 100644 (file)
@@ -3688,6 +3688,36 @@ int /*__devinit*/ snd_hda_build_controls(struct hda_bus *bus)
 }
 EXPORT_SYMBOL_HDA(snd_hda_build_controls);
 
 }
 EXPORT_SYMBOL_HDA(snd_hda_build_controls);
 
+/*
+ * add standard channel maps if not specified
+ */
+static int add_std_chmaps(struct hda_codec *codec)
+{
+       int i, str, err;
+
+       for (i = 0; i < codec->num_pcms; i++) {
+               for (str = 0; str < 2; str++) {
+                       struct snd_pcm *pcm = codec->pcm_info[i].pcm;
+                       struct hda_pcm_stream *hinfo =
+                               &codec->pcm_info[i].stream[str];
+                       struct snd_pcm_chmap *chmap;
+
+                       if (codec->pcm_info[i].own_chmap)
+                               continue;
+                       if (!pcm || !hinfo->substreams)
+                               continue;
+                       err = snd_pcm_add_chmap_ctls(pcm, str,
+                                                    snd_pcm_std_chmaps,
+                                                    hinfo->channels_max,
+                                                    0, &chmap);
+                       if (err < 0)
+                               return err;
+                       chmap->channel_mask = SND_PCM_CHMAP_MASK_2468;
+               }
+       }
+       return 0;
+}
+
 int snd_hda_codec_build_controls(struct hda_codec *codec)
 {
        int err = 0;
 int snd_hda_codec_build_controls(struct hda_codec *codec)
 {
        int err = 0;
@@ -3699,6 +3729,12 @@ int snd_hda_codec_build_controls(struct hda_codec *codec)
                err = codec->patch_ops.build_controls(codec);
        if (err < 0)
                return err;
                err = codec->patch_ops.build_controls(codec);
        if (err < 0)
                return err;
+
+       /* we create chmaps here instead of build_pcms */
+       err = add_std_chmaps(codec);
+       if (err < 0)
+               return err;
+
        snd_hda_jack_report_sync(codec); /* call at the last init point */
        return 0;
 }
        snd_hda_jack_report_sync(codec); /* call at the last init point */
        return 0;
 }
index 8fd9f63..ed3de8d 100644 (file)
@@ -776,6 +776,7 @@ struct hda_pcm {
        unsigned int pcm_type;  /* HDA_PCM_TYPE_XXX */
        int device;             /* device number to assign */
        struct snd_pcm *pcm;    /* assigned PCM instance */
        unsigned int pcm_type;  /* HDA_PCM_TYPE_XXX */
        int device;             /* device number to assign */
        struct snd_pcm *pcm;    /* assigned PCM instance */
+       bool own_chmap;         /* codec driver provides own channel maps */
 };
 
 /* codec information */
 };
 
 /* codec information */
index 6134999..1907dda 100644 (file)
@@ -2287,6 +2287,8 @@ static int alc_build_pcms(struct hda_codec *codec)
                        p = &alc_pcm_analog_playback;
                info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p;
                info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
                        p = &alc_pcm_analog_playback;
                info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p;
                info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
+               info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max =
+                       spec->multiout.max_channels;
        }
        if (spec->adc_nids) {
                p = spec->stream_analog_capture;
        }
        if (spec->adc_nids) {
                p = spec->stream_analog_capture;