alsa: hda: add alsa ctl to query max channels
Nikesh Oswal [Thu, 26 Jul 2012 10:28:46 +0000 (15:28 +0530)]
add alsa ctl to query maximum supported
channels

Bug: 998697

Signed-off-by: Nikesh Oswal <noswal@nvidia.com>
Change-Id: Id2f0e6a62d2413615f13a0c18757c05610ef0c2c
Reviewed-on: http://git-master/r/118602
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Scott Peterson <speterson@nvidia.com>

sound/pci/hda/hda_codec.c
sound/pci/hda/hda_codec.h
sound/pci/hda/hda_eld.c

index 91b2e46..ff10a63 100644 (file)
@@ -2840,6 +2840,16 @@ static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol,
        return change;
 }
 
+int snd_hda_max_pcm_ch_info(struct snd_kcontrol *kcontrol,
+               struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+       uinfo->count = 1;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = 0xFFFFFFFF;
+       return 0;
+}
+
 int snd_hda_hdmi_decode_info(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_info *uinfo)
 {
@@ -2850,6 +2860,15 @@ int snd_hda_hdmi_decode_info(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
+static int snd_hda_max_pcm_ch_get(struct snd_kcontrol *kcontrol,
+               struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+
+       ucontrol->value.integer.value[0] = codec->max_pcm_channels;
+       return 0;
+}
+
 static int snd_hda_hdmi_decode_get(struct snd_kcontrol *kcontrol,
                                        struct snd_ctl_elem_value *ucontrol)
 {
@@ -2894,6 +2913,12 @@ static struct snd_kcontrol_new dig_mixes[] = {
                .info = snd_hda_hdmi_decode_info,
                .get = snd_hda_hdmi_decode_get,
        },
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "HDA Maximum PCM Channels",
+               .info = snd_hda_max_pcm_ch_info,
+               .get = snd_hda_max_pcm_ch_get,
+       },
        { } /* end */
 };
 
index 1c5dc6d..6cba73c 100644 (file)
@@ -868,6 +868,7 @@ struct hda_codec {
 #endif
 
        unsigned int recv_dec_cap;
+       unsigned int max_pcm_channels;
        /* codec-specific additional proc output */
        void (*proc_widget_hook)(struct snd_info_buffer *buffer,
                                 struct hda_codec *codec, hda_nid_t nid);
index a8042e1..862dd35 100644 (file)
@@ -427,6 +427,10 @@ int snd_hdmi_get_eld(struct hdmi_eld *eld,
                        codec->recv_dec_cap |= (1 << AUDIO_CODING_TYPE_AC3);
                } else if (eld->sad[i].format == AUDIO_CODING_TYPE_DTS) {
                        codec->recv_dec_cap |= (1 << AUDIO_CODING_TYPE_DTS);
+               } else if (eld->sad[i].format == AUDIO_CODING_TYPE_LPCM) {
+                       codec->max_pcm_channels =
+                               eld->sad[i].channels > codec->max_pcm_channels ?
+                               eld->sad[i].channels : codec->max_pcm_channels;
                }
        }