aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorDimitris Papastamos <dp@opensource.wolfsonmicro.com>2011-02-01 07:24:08 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-02-01 09:26:11 -0500
commit2bc9a81e2aa3c95b1e709f3109c3bbc6d969cc06 (patch)
tree59f4ce4b3f5b437a109893e597e438505b426ec2 /sound
parent2cfec93fecc086c5af3c58ad15b7841f36af205c (diff)
ASoC: soc-core: Ensure codec_reg has fixed length fields
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> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/soc-core.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 3feddd91b973..205cbd7b149f 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -69,10 +69,32 @@ static int pmdown_time = 5000;
69module_param(pmdown_time, int, 0); 69module_param(pmdown_time, int, 0);
70MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)"); 70MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)");
71 71
72/* returns the minimum number of bytes needed to represent
73 * a particular given value */
74static int min_bytes_needed(unsigned long val)
75{
76 int c = 0;
77 int i;
78
79 for (i = (sizeof val * 8) - 1; i >= 0; --i, ++c)
80 if (val & (1UL << i))
81 break;
82 c = (sizeof val * 8) - c;
83 if (!c || (c % 8))
84 c = (c + 8) / 8;
85 else
86 c /= 8;
87 return c;
88}
89
72/* codec register dump */ 90/* codec register dump */
73static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf) 91static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf)
74{ 92{
75 int ret, i, step = 1, count = 0; 93 int ret, i, step = 1, count = 0;
94 int wordsize, regsize;
95
96 wordsize = codec->driver->reg_word_size * 2;
97 regsize = min_bytes_needed(codec->driver->reg_cache_size) * 2;
76 98
77 if (!codec->driver->reg_cache_size) 99 if (!codec->driver->reg_cache_size)
78 return 0; 100 return 0;
@@ -80,12 +102,11 @@ static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf)
80 if (codec->driver->reg_cache_step) 102 if (codec->driver->reg_cache_step)
81 step = codec->driver->reg_cache_step; 103 step = codec->driver->reg_cache_step;
82 104
83 count += sprintf(buf, "%s registers\n", codec->name);
84 for (i = 0; i < codec->driver->reg_cache_size; i += step) { 105 for (i = 0; i < codec->driver->reg_cache_size; i += step) {
85 if (codec->readable_register && !codec->readable_register(codec, i)) 106 if (codec->readable_register && !codec->readable_register(codec, i))
86 continue; 107 continue;
87 108
88 count += sprintf(buf + count, "%2x: ", i); 109 count += sprintf(buf + count, "%.*x: ", regsize, i);
89 if (count >= PAGE_SIZE - 1) 110 if (count >= PAGE_SIZE - 1)
90 break; 111 break;
91 112
@@ -101,7 +122,7 @@ static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf)
101 if (ret >= 0) 122 if (ret >= 0)
102 count += snprintf(buf + count, 123 count += snprintf(buf + count,
103 PAGE_SIZE - count, 124 PAGE_SIZE - count,
104 "%4x", ret); 125 "%.*x", wordsize, ret);
105 else 126 else
106 count += snprintf(buf + count, 127 count += snprintf(buf + count,
107 PAGE_SIZE - count, 128 PAGE_SIZE - count,