ALSA:hda: add alsa control for query of device
Sayak Ghosh Choudhury [Thu, 22 Mar 2012 14:03:19 +0000 (19:03 +0530)]
alsa control is added to facilitate querying dts decode capability of
connected device. dts decode capability of the connected device is
updated in the ELD buffer. That information is updated in the
ALSA control structure. In addition to that, the code is amended to
handle other pass through decoder mode support.

Bug 943017

Change-Id: If8da7dfb24be3b86592191f5586b70492282b438
Signed-off-by: Sayak Ghosh Choudhury <sayakc@nvidia.com>
Reviewed-on: http://git-master/r/91813
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 6e171ee..91b2e46 100644 (file)
@@ -2840,12 +2840,22 @@ static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol,
        return change;
 }
 
+int snd_hda_hdmi_decode_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;
+}
+
 static int snd_hda_hdmi_decode_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->ac3dec_capable;
+       ucontrol->value.integer.value[0] = codec->recv_dec_cap;
        return 0;
 }
 
@@ -2880,8 +2890,8 @@ static struct snd_kcontrol_new dig_mixes[] = {
        },
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-               .name = "AC3 Decode Capability",
-               .info = snd_ctl_boolean_mono_info,
+               .name = "HDA Decode Capability",
+               .info = snd_hda_hdmi_decode_info,
                .get = snd_hda_hdmi_decode_get,
        },
        { } /* end */
index 59d4cbe..1c5dc6d 100644 (file)
@@ -867,7 +867,7 @@ struct hda_codec {
        unsigned long power_jiffies;
 #endif
 
-       bool ac3dec_capable;
+       unsigned int recv_dec_cap;
        /* codec-specific additional proc output */
        void (*proc_widget_hook)(struct snd_info_buffer *buffer,
                                 struct hda_codec *codec, hda_nid_t nid);
index f3d204f..ad760f9 100644 (file)
@@ -421,6 +421,15 @@ int snd_hdmi_get_eld(struct hdmi_eld *eld,
        if (!eld->lpcm_sad_ready)
                hdmi_update_lpcm_sad_eld(codec, nid, eld, size);
 
+       codec->recv_dec_cap = 0;
+       for (i = 0; i < eld->sad_count; i++) {
+               if (eld->sad[i].format == AUDIO_CODING_TYPE_AC3) {
+                       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);
+               }
+       }
+
        buf = kmalloc(size, GFP_KERNEL);
        if (!buf)
                return -ENOMEM;
@@ -443,11 +452,6 @@ int snd_hdmi_get_eld(struct hdmi_eld *eld,
        }
 
        ret = hdmi_update_eld(eld, buf, size);
-       codec->ac3dec_capable = false;
-       for (i = 0; i < eld->sad_count; i++) {
-               if (eld->sad[i].format == AUDIO_CODING_TYPE_AC3)
-                       codec->ac3dec_capable = true;
-       }
 
 error:
        kfree(buf);