提交 1500b7b5 编写于 作者: D Dimitris Papastamos 提交者: Mark Brown

ASoC: Automatically assign the default readable()/volatile() functions

Ensure that all calls to readable_register()/volatile_register() go via
the snd_soc_codec function pointers.

If the default register access table has been given but no functions
for handling readable()/volatile() registers, use the default ones provided
by soc-cache.
Signed-off-by: NDimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: NLiam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 d4754ec9
...@@ -480,6 +480,8 @@ struct snd_soc_codec { ...@@ -480,6 +480,8 @@ struct snd_soc_codec {
int num_dai; int num_dai;
enum snd_soc_compress_type compress_type; enum snd_soc_compress_type compress_type;
size_t reg_size; /* reg_cache_size * reg_word_size */ size_t reg_size; /* reg_cache_size * reg_word_size */
int (*volatile_register)(struct snd_soc_codec *, unsigned int);
int (*readable_register)(struct snd_soc_codec *, unsigned int);
/* runtime */ /* runtime */
struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */
......
...@@ -84,7 +84,7 @@ static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf) ...@@ -84,7 +84,7 @@ static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf)
count += sprintf(buf, "%s registers\n", codec->name); count += sprintf(buf, "%s registers\n", codec->name);
for (i = 0; i < codec->driver->reg_cache_size; i += step) { for (i = 0; i < codec->driver->reg_cache_size; i += step) {
if (codec->driver->readable_register && !codec->driver->readable_register(codec, i)) if (codec->readable_register && !codec->readable_register(codec, i))
continue; continue;
count += sprintf(buf + count, "%2x: ", i); count += sprintf(buf + count, "%2x: ", i);
...@@ -2029,8 +2029,8 @@ static int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) ...@@ -2029,8 +2029,8 @@ static int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
*/ */
int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, int reg) int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, int reg)
{ {
if (codec->driver->volatile_register) if (codec->volatile_register)
return codec->driver->volatile_register(codec, reg); return codec->volatile_register(codec, reg);
else else
return 0; return 0;
} }
...@@ -3489,6 +3489,8 @@ int snd_soc_register_codec(struct device *dev, ...@@ -3489,6 +3489,8 @@ int snd_soc_register_codec(struct device *dev,
codec->write = codec_drv->write; codec->write = codec_drv->write;
codec->read = codec_drv->read; codec->read = codec_drv->read;
codec->volatile_register = codec_drv->volatile_register;
codec->readable_register = codec_drv->readable_register;
codec->dapm.bias_level = SND_SOC_BIAS_OFF; codec->dapm.bias_level = SND_SOC_BIAS_OFF;
codec->dapm.dev = dev; codec->dapm.dev = dev;
codec->dapm.codec = codec; codec->dapm.codec = codec;
...@@ -3517,6 +3519,13 @@ int snd_soc_register_codec(struct device *dev, ...@@ -3517,6 +3519,13 @@ int snd_soc_register_codec(struct device *dev,
} }
} }
if (codec_drv->reg_access_size && codec_drv->reg_access_default) {
if (!codec->volatile_register)
codec->volatile_register = snd_soc_default_volatile_register;
if (!codec->readable_register)
codec->readable_register = snd_soc_default_readable_register;
}
for (i = 0; i < num_dai; i++) { for (i = 0; i < num_dai; i++) {
fixup_codec_formats(&dai_drv[i].playback); fixup_codec_formats(&dai_drv[i].playback);
fixup_codec_formats(&dai_drv[i].capture); fixup_codec_formats(&dai_drv[i].capture);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册