ALSA:hda: add alsa control for query of device
Sayak Ghosh Choudhury [Tue, 31 Jan 2012 15:35:05 +0000 (20:35 +0530)]
alsa control is added to facilitate querying ac3 decode capability of
connected device. ac3 decode capability of the connected device is
updated in the ELD buffer. That information is updated in the
ALSA control structure.

Bug 909141
Bug 904553
Bug 920831

Change-Id: I81af196fc5dd85c5c87691393cf2f079611f9b47
Signed-off-by: Sayak Ghosh Choudhury <sayakc@nvidia.com>
Reviewed-on: http://git-master/r/83067
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Scott Peterson <speterson@nvidia.com>
Reviewed-by: Sumit Bhattacharya <sumitb@nvidia.com>

Rebase-Id: R70cf80867ed43840fa8f5549e00613cd25ae9508

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

index d769eba..bd2c84a 100644 (file)
@@ -2844,6 +2844,15 @@ static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol,
        return change;
 }
 
+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;
+       return 0;
+}
+
 static struct snd_kcontrol_new dig_mixes[] = {
        {
                .access = SNDRV_CTL_ELEM_ACCESS_READ,
@@ -2873,6 +2882,12 @@ static struct snd_kcontrol_new dig_mixes[] = {
                .get = snd_hda_spdif_out_switch_get,
                .put = snd_hda_spdif_out_switch_put,
        },
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "AC3 Decode Capability",
+               .info = snd_ctl_boolean_mono_info,
+               .get = snd_hda_hdmi_decode_get,
+       },
        { } /* end */
 };
 
index 02003a1..f02a220 100644 (file)
@@ -868,6 +868,7 @@ struct hda_codec {
        unsigned long power_jiffies;
 #endif
 
+       bool ac3dec_capable;
        /* codec-specific additional proc output */
        void (*proc_widget_hook)(struct snd_info_buffer *buffer,
                                 struct hda_codec *codec, hda_nid_t nid);
index c1da422..9c78d83 100644 (file)
@@ -373,6 +373,11 @@ 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:
        return ret;