Commit 8020454c authored by Dimitris Papastamos's avatar Dimitris Papastamos Committed by Mark Brown

ASoC: Add default snd_soc_default_writable_register() callback

By using struct snd_soc_reg_access for the read/write/vol attributes
of the registers, we provide callbacks that automatically determine whether
a given register is readable/writable or volatile.
Signed-off-by: default avatarDimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: default avatarLiam Girdwood <lrg@ti.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent acd61451
...@@ -292,6 +292,8 @@ int snd_soc_default_volatile_register(struct snd_soc_codec *codec, ...@@ -292,6 +292,8 @@ int snd_soc_default_volatile_register(struct snd_soc_codec *codec,
unsigned int reg); unsigned int reg);
int snd_soc_default_readable_register(struct snd_soc_codec *codec, int snd_soc_default_readable_register(struct snd_soc_codec *codec,
unsigned int reg); unsigned int reg);
int snd_soc_default_writable_register(struct snd_soc_codec *codec,
unsigned int reg);
/* Utility functions to get clock rates from various things */ /* Utility functions to get clock rates from various things */
int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots); int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
...@@ -523,6 +525,7 @@ struct snd_soc_codec { ...@@ -523,6 +525,7 @@ struct snd_soc_codec {
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 (*volatile_register)(struct snd_soc_codec *, unsigned int);
int (*readable_register)(struct snd_soc_codec *, unsigned int); int (*readable_register)(struct snd_soc_codec *, unsigned int);
int (*writable_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 */
...@@ -589,6 +592,7 @@ struct snd_soc_codec_driver { ...@@ -589,6 +592,7 @@ struct snd_soc_codec_driver {
size_t, unsigned int); size_t, unsigned int);
int (*volatile_register)(struct snd_soc_codec *, unsigned int); int (*volatile_register)(struct snd_soc_codec *, unsigned int);
int (*readable_register)(struct snd_soc_codec *, unsigned int); int (*readable_register)(struct snd_soc_codec *, unsigned int);
int (*writable_register)(struct snd_soc_codec *, unsigned int);
short reg_cache_size; short reg_cache_size;
short reg_cache_step; short reg_cache_step;
short reg_word_size; short reg_word_size;
......
...@@ -1449,3 +1449,17 @@ int snd_soc_default_readable_register(struct snd_soc_codec *codec, ...@@ -1449,3 +1449,17 @@ int snd_soc_default_readable_register(struct snd_soc_codec *codec,
return codec->driver->reg_access_default[index].read; return codec->driver->reg_access_default[index].read;
} }
EXPORT_SYMBOL_GPL(snd_soc_default_readable_register); EXPORT_SYMBOL_GPL(snd_soc_default_readable_register);
int snd_soc_default_writable_register(struct snd_soc_codec *codec,
unsigned int reg)
{
int index;
if (reg >= codec->driver->reg_cache_size)
return 1;
index = snd_soc_get_reg_access_index(codec, reg);
if (index < 0)
return 0;
return codec->driver->reg_access_default[index].write;
}
EXPORT_SYMBOL_GPL(snd_soc_default_writable_register);
...@@ -3673,6 +3673,7 @@ int snd_soc_register_codec(struct device *dev, ...@@ -3673,6 +3673,7 @@ int snd_soc_register_codec(struct device *dev,
codec->read = codec_drv->read; codec->read = codec_drv->read;
codec->volatile_register = codec_drv->volatile_register; codec->volatile_register = codec_drv->volatile_register;
codec->readable_register = codec_drv->readable_register; codec->readable_register = codec_drv->readable_register;
codec->writable_register = codec_drv->writable_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;
...@@ -3707,6 +3708,8 @@ int snd_soc_register_codec(struct device *dev, ...@@ -3707,6 +3708,8 @@ int snd_soc_register_codec(struct device *dev,
codec->volatile_register = snd_soc_default_volatile_register; codec->volatile_register = snd_soc_default_volatile_register;
if (!codec->readable_register) if (!codec->readable_register)
codec->readable_register = snd_soc_default_readable_register; codec->readable_register = snd_soc_default_readable_register;
if (!codec->writable_register)
codec->writable_register = snd_soc_default_writable_register;
} }
for (i = 0; i < num_dai; i++) { for (i = 0; i < num_dai; i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment