* [PATCH] ASoC: soc-core: Ensure codec_reg has fixed length fields
@ 2011-02-01 12:24 Dimitris Papastamos
2011-02-01 14:25 ` Liam Girdwood
2011-02-01 14:31 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Dimitris Papastamos @ 2011-02-01 12:24 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood; +Cc: alsa-devel, patches
Make the format of the codec_reg file more easily parsable. Remove
the header field which gives the codec name. These changes are important
when it comes to extend the debugfs codec_reg file to dump more than
PAGE_SIZE bytes to make it easier to calculate offsets within the
file.
We still need to handle the case when the snd_soc_read() call fails
and <no data: %d> is outputted.
Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
---
sound/soc/soc-core.c | 27 ++++++++++++++++++++++++---
1 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 3feddd9..205cbd7 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -69,10 +69,32 @@ static int pmdown_time = 5000;
module_param(pmdown_time, int, 0);
MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)");
+/* returns the minimum number of bytes needed to represent
+ * a particular given value */
+static int min_bytes_needed(unsigned long val)
+{
+ int c = 0;
+ int i;
+
+ for (i = (sizeof val * 8) - 1; i >= 0; --i, ++c)
+ if (val & (1UL << i))
+ break;
+ c = (sizeof val * 8) - c;
+ if (!c || (c % 8))
+ c = (c + 8) / 8;
+ else
+ c /= 8;
+ return c;
+}
+
/* codec register dump */
static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf)
{
int ret, i, step = 1, count = 0;
+ int wordsize, regsize;
+
+ wordsize = codec->driver->reg_word_size * 2;
+ regsize = min_bytes_needed(codec->driver->reg_cache_size) * 2;
if (!codec->driver->reg_cache_size)
return 0;
@@ -80,12 +102,11 @@ static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf)
if (codec->driver->reg_cache_step)
step = codec->driver->reg_cache_step;
- count += sprintf(buf, "%s registers\n", codec->name);
for (i = 0; i < codec->driver->reg_cache_size; i += step) {
if (codec->readable_register && !codec->readable_register(codec, i))
continue;
- count += sprintf(buf + count, "%2x: ", i);
+ count += sprintf(buf + count, "%.*x: ", regsize, i);
if (count >= PAGE_SIZE - 1)
break;
@@ -101,7 +122,7 @@ static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf)
if (ret >= 0)
count += snprintf(buf + count,
PAGE_SIZE - count,
- "%4x", ret);
+ "%.*x", wordsize, ret);
else
count += snprintf(buf + count,
PAGE_SIZE - count,
--
1.7.3.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: soc-core: Ensure codec_reg has fixed length fields
2011-02-01 12:24 [PATCH] ASoC: soc-core: Ensure codec_reg has fixed length fields Dimitris Papastamos
@ 2011-02-01 14:25 ` Liam Girdwood
2011-02-01 14:31 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Liam Girdwood @ 2011-02-01 14:25 UTC (permalink / raw)
To: Dimitris Papastamos; +Cc: alsa-devel, Mark Brown, patches
On Tue, 2011-02-01 at 12:24 +0000, Dimitris Papastamos wrote:
> Make the format of the codec_reg file more easily parsable. Remove
> the header field which gives the codec name. These changes are important
> when it comes to extend the debugfs codec_reg file to dump more than
> PAGE_SIZE bytes to make it easier to calculate offsets within the
> file.
>
> We still need to handle the case when the snd_soc_read() call fails
> and <no data: %d> is outputted.
>
> Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
--
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: soc-core: Ensure codec_reg has fixed length fields
2011-02-01 12:24 [PATCH] ASoC: soc-core: Ensure codec_reg has fixed length fields Dimitris Papastamos
2011-02-01 14:25 ` Liam Girdwood
@ 2011-02-01 14:31 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2011-02-01 14:31 UTC (permalink / raw)
To: Dimitris Papastamos; +Cc: alsa-devel, patches, Liam Girdwood
On Tue, Feb 01, 2011 at 12:24:08PM +0000, Dimitris Papastamos wrote:
> Make the format of the codec_reg file more easily parsable. Remove
> the header field which gives the codec name. These changes are important
> when it comes to extend the debugfs codec_reg file to dump more than
> PAGE_SIZE bytes to make it easier to calculate offsets within the
> file.
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-02-01 14:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-01 12:24 [PATCH] ASoC: soc-core: Ensure codec_reg has fixed length fields Dimitris Papastamos
2011-02-01 14:25 ` Liam Girdwood
2011-02-01 14:31 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).