Commit b6acf013 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda - Don't spew too many ELD errors

Currently HD-audio driver shows the all error ELD byte as an error
in the kernel message.  This is annoying when the video driver doesn't
set the correct ELD from the beginning. e.g. radeon sends a zero-byte
data, but we still check ELD with the fixed 128 byte as a workaround
for some broken devices, it spews 128-times errors.

For avoiding this, the driver aborts reading when the first byte is
invalid.  In such a case, the whole data is certainly invalid.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 38b65190
...@@ -144,25 +144,17 @@ static int cea_sampling_frequencies[8] = { ...@@ -144,25 +144,17 @@ static int cea_sampling_frequencies[8] = {
SNDRV_PCM_RATE_192000, /* 7: 192000Hz */ SNDRV_PCM_RATE_192000, /* 7: 192000Hz */
}; };
static unsigned char hdmi_get_eld_byte(struct hda_codec *codec, hda_nid_t nid, static unsigned int hdmi_get_eld_data(struct hda_codec *codec, hda_nid_t nid,
int byte_index) int byte_index)
{ {
unsigned int val; unsigned int val;
val = snd_hda_codec_read(codec, nid, 0, val = snd_hda_codec_read(codec, nid, 0,
AC_VERB_GET_HDMI_ELDD, byte_index); AC_VERB_GET_HDMI_ELDD, byte_index);
#ifdef BE_PARANOID #ifdef BE_PARANOID
printk(KERN_INFO "HDMI: ELD data byte %d: 0x%x\n", byte_index, val); printk(KERN_INFO "HDMI: ELD data byte %d: 0x%x\n", byte_index, val);
#endif #endif
return val;
if ((val & AC_ELDD_ELD_VALID) == 0) {
snd_printd(KERN_INFO "HDMI: invalid ELD data byte %d\n",
byte_index);
val = 0;
}
return val & AC_ELDD_ELD_DATA;
} }
#define GRAB_BITS(buf, byte, lowbit, bits) \ #define GRAB_BITS(buf, byte, lowbit, bits) \
...@@ -344,11 +336,26 @@ int snd_hdmi_get_eld(struct hdmi_eld *eld, ...@@ -344,11 +336,26 @@ int snd_hdmi_get_eld(struct hdmi_eld *eld,
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < size; i++) for (i = 0; i < size; i++) {
buf[i] = hdmi_get_eld_byte(codec, nid, i); unsigned int val = hdmi_get_eld_data(codec, nid, i);
if (!(val & AC_ELDD_ELD_VALID)) {
if (!i) {
snd_printd(KERN_INFO
"HDMI: invalid ELD data\n");
ret = -EINVAL;
goto error;
}
snd_printd(KERN_INFO
"HDMI: invalid ELD data byte %d\n", i);
val = 0;
} else
val &= AC_ELDD_ELD_DATA;
buf[i] = val;
}
ret = hdmi_update_eld(eld, buf, size); ret = hdmi_update_eld(eld, buf, size);
error:
kfree(buf); kfree(buf);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment