提交 d39b4352 编写于 作者: W Wu Fengguang 提交者: Takashi Iwai

ALSA: hda: make global snd_print_pcm_bits()

Introduce a global function snd_print_pcm_bits() and use it in the ELD code.
Signed-off-by: NWu Fengguang <wfg@linux.intel.com>
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
上级 06f69d17
...@@ -455,7 +455,7 @@ void snd_hdmi_show_eld(struct hdmi_eld *e) ...@@ -455,7 +455,7 @@ void snd_hdmi_show_eld(struct hdmi_eld *e)
static void hdmi_print_sad_info(int i, struct cea_sad *a, static void hdmi_print_sad_info(int i, struct cea_sad *a,
struct snd_info_buffer *buffer) struct snd_info_buffer *buffer)
{ {
char buf[80]; char buf[SND_PRINT_RATES_ADVISED_BUFSIZE];
snd_iprintf(buffer, "sad%d_coding_type\t[0x%x] %s\n", snd_iprintf(buffer, "sad%d_coding_type\t[0x%x] %s\n",
i, a->format, cea_audio_coding_type_names[a->format]); i, a->format, cea_audio_coding_type_names[a->format]);
...@@ -464,9 +464,11 @@ static void hdmi_print_sad_info(int i, struct cea_sad *a, ...@@ -464,9 +464,11 @@ static void hdmi_print_sad_info(int i, struct cea_sad *a,
snd_print_pcm_rates(a->rates, buf, sizeof(buf)); snd_print_pcm_rates(a->rates, buf, sizeof(buf));
snd_iprintf(buffer, "sad%d_rates\t\t[0x%x]%s\n", i, a->rates, buf); snd_iprintf(buffer, "sad%d_rates\t\t[0x%x]%s\n", i, a->rates, buf);
if (a->format == AUDIO_CODING_TYPE_LPCM) if (a->format == AUDIO_CODING_TYPE_LPCM) {
snd_iprintf(buffer, "sad%d_bits\t\t0x%x\n", snd_print_pcm_bits(a->sample_bits, buf, sizeof(buf));
i, a->sample_bits); snd_iprintf(buffer, "sad%d_bits\t\t[0x%x]%s\n",
i, a->sample_bits, buf);
}
if (a->max_bitrate) if (a->max_bitrate)
snd_iprintf(buffer, "sad%d_max_bitrate\t%d\n", snd_iprintf(buffer, "sad%d_max_bitrate\t%d\n",
......
...@@ -287,6 +287,9 @@ static inline int snd_hda_codec_proc_new(struct hda_codec *codec) { return 0; } ...@@ -287,6 +287,9 @@ static inline int snd_hda_codec_proc_new(struct hda_codec *codec) { return 0; }
#define SND_PRINT_RATES_ADVISED_BUFSIZE 80 #define SND_PRINT_RATES_ADVISED_BUFSIZE 80
void snd_print_pcm_rates(int pcm, char *buf, int buflen); void snd_print_pcm_rates(int pcm, char *buf, int buflen);
#define SND_PRINT_BITS_ADVISED_BUFSIZE 16
void snd_print_pcm_bits(int pcm, char *buf, int buflen);
/* /*
* Misc * Misc
*/ */
......
...@@ -107,23 +107,33 @@ void snd_print_pcm_rates(int pcm, char *buf, int buflen) ...@@ -107,23 +107,33 @@ void snd_print_pcm_rates(int pcm, char *buf, int buflen)
static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm) static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm)
{ {
char buf[SND_PRINT_RATES_ADVISED_BUFSIZE]; char buf[SND_PRINT_RATES_ADVISED_BUFSIZE];
pcm &= AC_SUPPCM_RATES; pcm &= AC_SUPPCM_RATES;
snd_iprintf(buffer, " rates [0x%x]:", pcm); snd_iprintf(buffer, " rates [0x%x]:", pcm);
snd_print_pcm_rates(pcm, buf, sizeof(buf)); snd_print_pcm_rates(pcm, buf, sizeof(buf));
snd_iprintf(buffer, "%s\n", buf); snd_iprintf(buffer, "%s\n", buf);
} }
static void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm) void snd_print_pcm_bits(int pcm, char *buf, int buflen)
{ {
static unsigned int bits[] = { 8, 16, 20, 24, 32 }; static unsigned int bits[] = { 8, 16, 20, 24, 32 };
int i; int i, j;
for (i = 0, j = 0; i < ARRAY_SIZE(bits); i++)
if (pcm & (1 << i))
j += snprintf(buf + j, buflen - j, " %d", bits[i]);
buf[j] = '\0'; /* necessary when j == 0 */
}
static void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm)
{
char buf[SND_PRINT_BITS_ADVISED_BUFSIZE];
pcm = (pcm >> 16) & 0xff; pcm = (pcm >> 16) & 0xff;
snd_iprintf(buffer, " bits [0x%x]:", pcm); snd_iprintf(buffer, " bits [0x%x]:", pcm);
for (i = 0; i < ARRAY_SIZE(bits); i++) snd_print_pcm_bits(pcm, buf, sizeof(buf));
if (pcm & (1 << i)) snd_iprintf(buffer, "%s\n", buf);
snd_iprintf(buffer, " %d", bits[i]);
snd_iprintf(buffer, "\n");
} }
static void print_pcm_formats(struct snd_info_buffer *buffer, static void print_pcm_formats(struct snd_info_buffer *buffer,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册