ALSA: hdmi: fix printout of SAD sampling rates
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Wed, 5 Oct 2011 20:14:20 +0000 (15:14 -0500)
committerTakashi Iwai <tiwai@suse.de>
Thu, 6 Oct 2011 06:08:53 +0000 (08:08 +0200)
SAD sampling rate information reported in
/proc/asound/cardX/eldX is incorrect due to a mismatch
between HDA and HDMI frequencies. Add new routine to provide
relevant values.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_eld.c

index 8b046a10b42b860ba54d2ef8bdcff41de4fcf951..d2f41b1446e1688703a0ca16b659fd1250648ea7 100644 (file)
@@ -5205,7 +5205,7 @@ EXPORT_SYMBOL_HDA(snd_array_free);
  * @buf: the string buffer to write
  * @buflen: the max buffer length
  *
- * used by hda_proc.c and hda_eld.c
+ * used by hda_proc.c
  */
 void snd_print_pcm_rates(int pcm, char *buf, int buflen)
 {
index f1c621d2f8e8277014690bc9ab8f19e0fbc000fc..bc1ac2940c5eeba4b98d5377cfd5e3405d307c04 100644 (file)
@@ -363,6 +363,26 @@ error:
        return ret;
 }
 
+/**
+ * SNDRV_PCM_RATE_* and AC_PAR_PCM values don't match, print correct rates with
+ * hdmi-specific routine.
+ */
+static void hdmi_print_pcm_rates(int pcm, char *buf, int buflen)
+{
+       static unsigned int alsa_rates[] = {
+               5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200,
+               96000, 176400, 192000, 384000
+       };
+       int i, j;
+
+       for (i = 0, j = 0; i < ARRAY_SIZE(alsa_rates); i++)
+               if (pcm & (1 << i))
+                       j += snprintf(buf + j, buflen - j,  " %d",
+                               alsa_rates[i]);
+
+       buf[j] = '\0'; /* necessary when j == 0 */
+}
+
 static void hdmi_show_short_audio_desc(struct cea_sad *a)
 {
        char buf[SND_PRINT_RATES_ADVISED_BUFSIZE];
@@ -371,7 +391,7 @@ static void hdmi_show_short_audio_desc(struct cea_sad *a)
        if (!a->format)
                return;
 
-       snd_print_pcm_rates(a->rates, buf, sizeof(buf));
+       hdmi_print_pcm_rates(a->rates, buf, sizeof(buf));
 
        if (a->format == AUDIO_CODING_TYPE_LPCM)
                snd_print_pcm_bits(a->sample_bits, buf2 + 8, sizeof(buf2) - 8);
@@ -430,7 +450,7 @@ static void hdmi_print_sad_info(int i, struct cea_sad *a,
                        i, a->format, cea_audio_coding_type_names[a->format]);
        snd_iprintf(buffer, "sad%d_channels\t\t%d\n", i, a->channels);
 
-       snd_print_pcm_rates(a->rates, buf, sizeof(buf));
+       hdmi_print_pcm_rates(a->rates, buf, sizeof(buf));
        snd_iprintf(buffer, "sad%d_rates\t\t[0x%x]%s\n", i, a->rates, buf);
 
        if (a->format == AUDIO_CODING_TYPE_LPCM) {