diff options
Diffstat (limited to 'sound/pci/hda/hda_eld.c')
-rw-r--r-- | sound/pci/hda/hda_eld.c | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c index c34f730f4815..1c8ddf547a2d 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, | |||
318 | int size; | 318 | int size; |
319 | unsigned char *buf; | 319 | unsigned char *buf; |
320 | 320 | ||
321 | /* | ||
322 | * ELD size is initialized to zero in caller function. If no errors and | ||
323 | * ELD is valid, actual eld_size is assigned in hdmi_update_eld() | ||
324 | */ | ||
325 | |||
321 | if (!eld->eld_valid) | 326 | if (!eld->eld_valid) |
322 | return -ENOENT; | 327 | return -ENOENT; |
323 | 328 | ||
@@ -327,14 +332,13 @@ int snd_hdmi_get_eld(struct hdmi_eld *eld, | |||
327 | snd_printd(KERN_INFO "HDMI: ELD buf size is 0, force 128\n"); | 332 | snd_printd(KERN_INFO "HDMI: ELD buf size is 0, force 128\n"); |
328 | size = 128; | 333 | size = 128; |
329 | } | 334 | } |
330 | if (size < ELD_FIXED_BYTES || size > PAGE_SIZE) { | 335 | if (size < ELD_FIXED_BYTES || size > ELD_MAX_SIZE) { |
331 | snd_printd(KERN_INFO "HDMI: invalid ELD buf size %d\n", size); | 336 | snd_printd(KERN_INFO "HDMI: invalid ELD buf size %d\n", size); |
332 | return -ERANGE; | 337 | return -ERANGE; |
333 | } | 338 | } |
334 | 339 | ||
335 | buf = kmalloc(size, GFP_KERNEL); | 340 | /* set ELD buffer */ |
336 | if (!buf) | 341 | buf = eld->eld_buffer; |
337 | return -ENOMEM; | ||
338 | 342 | ||
339 | for (i = 0; i < size; i++) { | 343 | for (i = 0; i < size; i++) { |
340 | unsigned int val = hdmi_get_eld_data(codec, nid, i); | 344 | unsigned int val = hdmi_get_eld_data(codec, nid, i); |
@@ -356,10 +360,31 @@ int snd_hdmi_get_eld(struct hdmi_eld *eld, | |||
356 | ret = hdmi_update_eld(eld, buf, size); | 360 | ret = hdmi_update_eld(eld, buf, size); |
357 | 361 | ||
358 | error: | 362 | error: |
359 | kfree(buf); | ||
360 | return ret; | 363 | return ret; |
361 | } | 364 | } |
362 | 365 | ||
366 | /** | ||
367 | * SNDRV_PCM_RATE_* and AC_PAR_PCM values don't match, print correct rates with | ||
368 | * hdmi-specific routine. | ||
369 | */ | ||
370 | static void hdmi_print_pcm_rates(int pcm, char *buf, int buflen) | ||
371 | { | ||
372 | static unsigned int alsa_rates[] = { | ||
373 | 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200, | ||
374 | 96000, 176400, 192000, 384000 | ||
375 | }; | ||
376 | int i, j; | ||
377 | |||
378 | for (i = 0, j = 0; i < ARRAY_SIZE(alsa_rates); i++) | ||
379 | if (pcm & (1 << i)) | ||
380 | j += snprintf(buf + j, buflen - j, " %d", | ||
381 | alsa_rates[i]); | ||
382 | |||
383 | buf[j] = '\0'; /* necessary when j == 0 */ | ||
384 | } | ||
385 | |||
386 | #define SND_PRINT_RATES_ADVISED_BUFSIZE 80 | ||
387 | |||
363 | static void hdmi_show_short_audio_desc(struct cea_sad *a) | 388 | static void hdmi_show_short_audio_desc(struct cea_sad *a) |
364 | { | 389 | { |
365 | char buf[SND_PRINT_RATES_ADVISED_BUFSIZE]; | 390 | char buf[SND_PRINT_RATES_ADVISED_BUFSIZE]; |
@@ -368,7 +393,7 @@ static void hdmi_show_short_audio_desc(struct cea_sad *a) | |||
368 | if (!a->format) | 393 | if (!a->format) |
369 | return; | 394 | return; |
370 | 395 | ||
371 | snd_print_pcm_rates(a->rates, buf, sizeof(buf)); | 396 | hdmi_print_pcm_rates(a->rates, buf, sizeof(buf)); |
372 | 397 | ||
373 | if (a->format == AUDIO_CODING_TYPE_LPCM) | 398 | if (a->format == AUDIO_CODING_TYPE_LPCM) |
374 | snd_print_pcm_bits(a->sample_bits, buf2 + 8, sizeof(buf2) - 8); | 399 | snd_print_pcm_bits(a->sample_bits, buf2 + 8, sizeof(buf2) - 8); |
@@ -427,7 +452,7 @@ static void hdmi_print_sad_info(int i, struct cea_sad *a, | |||
427 | i, a->format, cea_audio_coding_type_names[a->format]); | 452 | i, a->format, cea_audio_coding_type_names[a->format]); |
428 | snd_iprintf(buffer, "sad%d_channels\t\t%d\n", i, a->channels); | 453 | snd_iprintf(buffer, "sad%d_channels\t\t%d\n", i, a->channels); |
429 | 454 | ||
430 | snd_print_pcm_rates(a->rates, buf, sizeof(buf)); | 455 | hdmi_print_pcm_rates(a->rates, buf, sizeof(buf)); |
431 | snd_iprintf(buffer, "sad%d_rates\t\t[0x%x]%s\n", i, a->rates, buf); | 456 | snd_iprintf(buffer, "sad%d_rates\t\t[0x%x]%s\n", i, a->rates, buf); |
432 | 457 | ||
433 | if (a->format == AUDIO_CODING_TYPE_LPCM) { | 458 | if (a->format == AUDIO_CODING_TYPE_LPCM) { |