[alsa-devel] [PATCH 04/14] ASoC: Allow codecs to override register display
Takashi Iwai
tiwai at suse.de
Fri Aug 1 11:42:28 CEST 2008
At Thu, 31 Jul 2008 21:41:48 -0400,
Jon Smirl wrote:
>
> Mark, I see this patch is already in your tree. I have rewritten it a
> little differently to ensure that too many results can't be returned.
> This is in my system and tested. I had a bug too so I know the
> limiting it to pagesize code works.
Mark's patch was already applied. Could you re-generated your change
based on that?
thanks,
Takashi
>
> Signed-off-by: Jon Smirl <jonsmirl at gmail.com>
> ---
>
> include/sound/soc.h | 1 +
> sound/soc/soc-core.c | 19 +++++++++++++------
> 2 files changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/include/sound/soc.h b/include/sound/soc.h
> index 1890d87..b95c0c2 100644
> --- a/include/sound/soc.h
> +++ b/include/sound/soc.h
> @@ -410,6 +410,7 @@ struct snd_soc_codec {
> void *control_data; /* codec control (i2c/3wire) data */
> unsigned int (*read)(struct snd_soc_codec *, unsigned int);
> int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
> + int (*display_register)(struct snd_soc_codec *, char *, unsigned
> int, unsigned int);
> hw_write_t hw_write;
> hw_read_t hw_read;
> void *reg_cache;
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index 83f1190..55f7559 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -961,7 +961,7 @@ static ssize_t codec_reg_show(struct device *dev,
> {
> struct snd_soc_device *devdata = dev_get_drvdata(dev);
> struct snd_soc_codec *codec = devdata->codec;
> - int i, step = 1, count = 0;
> + int i, step = 1, count;
>
> if (!codec->reg_cache_size)
> return 0;
> @@ -969,11 +969,18 @@ static ssize_t codec_reg_show(struct device *dev,
> if (codec->reg_cache_step)
> step = codec->reg_cache_step;
>
> - count += sprintf(buf, "%s registers\n", codec->name);
> - for (i = 0; i < codec->reg_cache_size; i += step)
> - count += sprintf(buf + count, "%2x: %4x\n", i,
> - codec->read(codec, i));
> -
> + count = sprintf(buf, "%s registers\n", codec->name);
> + for (i = 0; i < codec->reg_cache_size; i += step) {
> + if (codec->display_register)
> + count += codec->display_register(codec,
> + buf + count, PAGE_SIZE - count, i);
> + else {
> + count += snprintf(buf + count, PAGE_SIZE - count, "%2x: ", i);
> + count += snprintf(buf + count, PAGE_SIZE - count, "%4x",
> + codec->read(codec, i));
> + count += snprintf(buf + count, PAGE_SIZE - count, "\n");
> + }
> + }
> return count;
> }
> static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL);
>
>
> --
> Jon Smirl
> jonsmirl at gmail.com
>
More information about the Alsa-devel
mailing list