diff options
| -rw-r--r-- | sound/pci/hda/hda_eld.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c index 28ce17d09c33..c34f730f4815 100644 --- a/sound/pci/hda/hda_eld.c +++ b/sound/pci/hda/hda_eld.c | |||
| @@ -144,25 +144,17 @@ static int cea_sampling_frequencies[8] = { | |||
| 144 | SNDRV_PCM_RATE_192000, /* 7: 192000Hz */ | 144 | SNDRV_PCM_RATE_192000, /* 7: 192000Hz */ |
| 145 | }; | 145 | }; |
| 146 | 146 | ||
| 147 | static unsigned char hdmi_get_eld_byte(struct hda_codec *codec, hda_nid_t nid, | 147 | static unsigned int hdmi_get_eld_data(struct hda_codec *codec, hda_nid_t nid, |
| 148 | int byte_index) | 148 | int byte_index) |
| 149 | { | 149 | { |
| 150 | unsigned int val; | 150 | unsigned int val; |
| 151 | 151 | ||
| 152 | val = snd_hda_codec_read(codec, nid, 0, | 152 | val = snd_hda_codec_read(codec, nid, 0, |
| 153 | AC_VERB_GET_HDMI_ELDD, byte_index); | 153 | AC_VERB_GET_HDMI_ELDD, byte_index); |
| 154 | |||
| 155 | #ifdef BE_PARANOID | 154 | #ifdef BE_PARANOID |
| 156 | printk(KERN_INFO "HDMI: ELD data byte %d: 0x%x\n", byte_index, val); | 155 | printk(KERN_INFO "HDMI: ELD data byte %d: 0x%x\n", byte_index, val); |
| 157 | #endif | 156 | #endif |
| 158 | 157 | return val; | |
| 159 | if ((val & AC_ELDD_ELD_VALID) == 0) { | ||
| 160 | snd_printd(KERN_INFO "HDMI: invalid ELD data byte %d\n", | ||
| 161 | byte_index); | ||
| 162 | val = 0; | ||
| 163 | } | ||
| 164 | |||
| 165 | return val & AC_ELDD_ELD_DATA; | ||
| 166 | } | 158 | } |
| 167 | 159 | ||
| 168 | #define GRAB_BITS(buf, byte, lowbit, bits) \ | 160 | #define GRAB_BITS(buf, byte, lowbit, bits) \ |
| @@ -344,11 +336,26 @@ int snd_hdmi_get_eld(struct hdmi_eld *eld, | |||
| 344 | if (!buf) | 336 | if (!buf) |
| 345 | return -ENOMEM; | 337 | return -ENOMEM; |
| 346 | 338 | ||
| 347 | for (i = 0; i < size; i++) | 339 | for (i = 0; i < size; i++) { |
| 348 | buf[i] = hdmi_get_eld_byte(codec, nid, i); | 340 | unsigned int val = hdmi_get_eld_data(codec, nid, i); |
| 341 | if (!(val & AC_ELDD_ELD_VALID)) { | ||
| 342 | if (!i) { | ||
| 343 | snd_printd(KERN_INFO | ||
| 344 | "HDMI: invalid ELD data\n"); | ||
| 345 | ret = -EINVAL; | ||
| 346 | goto error; | ||
| 347 | } | ||
| 348 | snd_printd(KERN_INFO | ||
| 349 | "HDMI: invalid ELD data byte %d\n", i); | ||
| 350 | val = 0; | ||
| 351 | } else | ||
| 352 | val &= AC_ELDD_ELD_DATA; | ||
| 353 | buf[i] = val; | ||
| 354 | } | ||
| 349 | 355 | ||
| 350 | ret = hdmi_update_eld(eld, buf, size); | 356 | ret = hdmi_update_eld(eld, buf, size); |
| 351 | 357 | ||
| 358 | error: | ||
| 352 | kfree(buf); | 359 | kfree(buf); |
| 353 | return ret; | 360 | return ret; |
| 354 | } | 361 | } |
