ASoC: core: Move the default regmap I/O setting to snd_soc_register_codec()
Add the default regmap I/O setting to snd_soc_register_codec() while the CODEC is initialising, which will be called by CODEC driver device probe(), and then we can make XXX_set_cache_io() go away entirely from each CODEC ASoC probe. Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com> Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
@@ -754,6 +754,7 @@ struct snd_soc_codec_driver {
|
|||||||
unsigned int freq_in, unsigned int freq_out);
|
unsigned int freq_in, unsigned int freq_out);
|
||||||
|
|
||||||
/* codec IO */
|
/* codec IO */
|
||||||
|
struct regmap *(*get_regmap)(struct device *);
|
||||||
unsigned int (*read)(struct snd_soc_codec *, unsigned int);
|
unsigned int (*read)(struct snd_soc_codec *, unsigned int);
|
||||||
int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
|
int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
|
||||||
int (*display_register)(struct snd_soc_codec *, char *,
|
int (*display_register)(struct snd_soc_codec *, char *,
|
||||||
|
@@ -1137,16 +1137,6 @@ static int soc_probe_codec(struct snd_soc_card *card,
|
|||||||
|
|
||||||
codec->dapm.idle_bias_off = driver->idle_bias_off;
|
codec->dapm.idle_bias_off = driver->idle_bias_off;
|
||||||
|
|
||||||
if (!codec->write && dev_get_regmap(codec->dev, NULL)) {
|
|
||||||
/* Set the default I/O up try regmap */
|
|
||||||
ret = snd_soc_codec_set_cache_io(codec, NULL);
|
|
||||||
if (ret < 0) {
|
|
||||||
dev_err(codec->dev,
|
|
||||||
"Failed to set cache I/O: %d\n", ret);
|
|
||||||
goto err_probe;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (driver->probe) {
|
if (driver->probe) {
|
||||||
ret = driver->probe(codec);
|
ret = driver->probe(codec);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -4263,6 +4253,7 @@ int snd_soc_register_codec(struct device *dev,
|
|||||||
int num_dai)
|
int num_dai)
|
||||||
{
|
{
|
||||||
struct snd_soc_codec *codec;
|
struct snd_soc_codec *codec;
|
||||||
|
struct regmap *regmap;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
|
|
||||||
dev_dbg(dev, "codec register %s\n", dev_name(dev));
|
dev_dbg(dev, "codec register %s\n", dev_name(dev));
|
||||||
@@ -4294,6 +4285,23 @@ int snd_soc_register_codec(struct device *dev,
|
|||||||
codec->num_dai = num_dai;
|
codec->num_dai = num_dai;
|
||||||
mutex_init(&codec->mutex);
|
mutex_init(&codec->mutex);
|
||||||
|
|
||||||
|
if (!codec->write) {
|
||||||
|
if (codec_drv->get_regmap)
|
||||||
|
regmap = codec_drv->get_regmap(dev);
|
||||||
|
else
|
||||||
|
regmap = dev_get_regmap(dev, NULL);
|
||||||
|
|
||||||
|
if (regmap) {
|
||||||
|
ret = snd_soc_codec_set_cache_io(codec, regmap);
|
||||||
|
if (ret && ret != -ENOTSUPP) {
|
||||||
|
dev_err(codec->dev,
|
||||||
|
"Failed to set cache I/O:%d\n",
|
||||||
|
ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
@@ -60,14 +60,11 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Device has made its own regmap arrangements */
|
|
||||||
if (!regmap)
|
if (!regmap)
|
||||||
codec->control_data = dev_get_regmap(codec->dev, NULL);
|
return -EINVAL;
|
||||||
else
|
|
||||||
codec->control_data = regmap;
|
|
||||||
|
|
||||||
if (IS_ERR(codec->control_data))
|
/* Device has made its own regmap arrangements */
|
||||||
return PTR_ERR(codec->control_data);
|
codec->control_data = regmap;
|
||||||
|
|
||||||
codec->write = hw_write;
|
codec->write = hw_write;
|
||||||
codec->read = hw_read;
|
codec->read = hw_read;
|
||||||
|
Reference in New Issue
Block a user