From: Wu Fengguang <wfg@linux.intel.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel <alsa-devel@alsa-project.org>
Subject: [PATCH 1/3] introduce snd_print_pcm_rates()
Date: Tue, 18 Nov 2008 11:47:51 +0800 [thread overview]
Message-ID: <20081118042642.195987946@linux.intel.com> (raw)
In-Reply-To: 20081118034750.445933681@linux.intel.com
[-- Attachment #1: alsa-print-rates.patch --]
[-- Type: text/plain, Size: 1832 bytes --]
We want to share some code with print_pcm_rates(),
so extract a common routine snd_print_pcm_rates() from it.
Signed-off-by: Wu Fengguang <wfg@linux.intel.com>
---
sound/pci/hda/hda_local.h | 3 +++
sound/pci/hda/hda_proc.c | 20 ++++++++++++++------
2 files changed, 17 insertions(+), 6 deletions(-)
--- sound-2.6.orig/sound/pci/hda/hda_local.h
+++ sound-2.6/sound/pci/hda/hda_local.h
@@ -284,6 +284,9 @@ int snd_hda_codec_proc_new(struct hda_co
static inline int snd_hda_codec_proc_new(struct hda_codec *codec) { return 0; }
#endif
+#define SND_PRINT_RATES_ADVISED_BUFSIZE 80
+void snd_print_pcm_rates(int pcm, char *buf, int buflen);
+
/*
* Misc
*/
--- sound-2.6.orig/sound/pci/hda/hda_proc.c
+++ sound-2.6/sound/pci/hda/hda_proc.c
@@ -89,20 +89,28 @@ static void print_amp_vals(struct snd_in
snd_iprintf(buffer, "\n");
}
-static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm)
+void snd_print_pcm_rates(int pcm, char *buf, int buflen)
{
static unsigned int rates[] = {
8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200,
96000, 176400, 192000, 384000
};
- int i;
+ int i, j;
+
+ for (i = 0, j = 0; i < ARRAY_SIZE(rates); i++)
+ if (pcm & (1 << i))
+ j += snprintf(buf + j, buflen - j, " %d", rates[i]);
+
+ buf[j] = '\0'; /* necessary when j == 0 */
+}
+static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm)
+{
+ char buf[SND_PRINT_RATES_ADVISED_BUFSIZE];
pcm &= AC_SUPPCM_RATES;
snd_iprintf(buffer, " rates [0x%x]:", pcm);
- for (i = 0; i < ARRAY_SIZE(rates); i++)
- if (pcm & (1 << i))
- snd_iprintf(buffer, " %d", rates[i]);
- snd_iprintf(buffer, "\n");
+ snd_print_pcm_rates(pcm, buf, sizeof(buf));
+ snd_iprintf(buffer, "%s\n", buf);
}
static void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm)
--
next prev parent reply other threads:[~2008-11-18 4:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-18 3:47 [PATCH 0/3] HDMI ELD routines and proc interface Wu Fengguang
2008-11-18 3:47 ` Wu Fengguang [this message]
2008-11-18 3:47 ` [PATCH 2/3] create hda_eld.c for " Wu Fengguang
2008-11-18 3:47 ` [PATCH 3/3] ELD proc interface for HDMI sinks Wu Fengguang
2008-11-18 7:18 ` [PATCH 0/3] HDMI ELD routines and proc interface Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081118042642.195987946@linux.intel.com \
--to=wfg@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox