From 14bc52b8feaae6cbc88934399f418125ac176399 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 30 Sep 2011 16:35:41 -0500 Subject: ALSA: hda/hdmi: expose ELD control Applications may want to read ELD information to understand what codecs are supported on the HDMI receiver and handle the a-v delay for better lip-sync. ELD information is exposed in a device-specific IFACE_PCM kcontrol. Tested both with amixer and PulseAudio; with a corresponding patch passthrough modes are enabled automagically. ELD control size is set to zero in case of errors or wrong configurations. No notifications are implemented for now, it is expected that jack detection is used to reconfigure the audio outputs. Signed-off-by: Pierre-Louis Bossart Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_eld.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'sound/pci/hda/hda_eld.c') diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c index c34f730f4815..f1c621d2f8e8 100644 --- a/sound/pci/hda/hda_eld.c +++ b/sound/pci/hda/hda_eld.c @@ -318,6 +318,11 @@ int snd_hdmi_get_eld(struct hdmi_eld *eld, int size; unsigned char *buf; + /* + * ELD size is initialized to zero in caller function. If no errors and + * ELD is valid, actual eld_size is assigned in hdmi_update_eld() + */ + if (!eld->eld_valid) return -ENOENT; @@ -327,14 +332,13 @@ int snd_hdmi_get_eld(struct hdmi_eld *eld, snd_printd(KERN_INFO "HDMI: ELD buf size is 0, force 128\n"); size = 128; } - if (size < ELD_FIXED_BYTES || size > PAGE_SIZE) { + if (size < ELD_FIXED_BYTES || size > ELD_MAX_SIZE) { snd_printd(KERN_INFO "HDMI: invalid ELD buf size %d\n", size); return -ERANGE; } - buf = kmalloc(size, GFP_KERNEL); - if (!buf) - return -ENOMEM; + /* set ELD buffer */ + buf = eld->eld_buffer; for (i = 0; i < size; i++) { unsigned int val = hdmi_get_eld_data(codec, nid, i); @@ -356,7 +360,6 @@ int snd_hdmi_get_eld(struct hdmi_eld *eld, ret = hdmi_update_eld(eld, buf, size); error: - kfree(buf); return ret; } -- cgit v1.2.3