[alsa-devel] [RFC][PATCH 0/3] Remove set_cache_io entirely from ASoC probe
Xiubo Li (3): ASoC: core: Move the default regmap I/O setting to snd_soc_register_codec() ASoc: codec: remove the set_cache_io() entirely from CODEC ASoC probe. ASoC: core: remove the default regmap I/O setting up from soc_probe_codec()
include/sound/soc.h | 3 +++ sound/soc/codecs/cq93vc.c | 6 ++++-- sound/soc/codecs/mc13783.c | 10 ++-------- sound/soc/codecs/wm5102.c | 6 ++---- sound/soc/codecs/wm5110.c | 6 ++---- sound/soc/codecs/wm8350.c | 6 ++++-- sound/soc/codecs/wm8400.c | 6 ++++-- sound/soc/codecs/wm8994.c | 4 ++-- sound/soc/codecs/wm8997.c | 7 ++----- sound/soc/soc-core.c | 21 +++++++++++---------- 10 files changed, 36 insertions(+), 39 deletions(-)
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 set_cache_io() go away entirely from each CODEC ASoC probe.
Signed-off-by: Xiubo Li Li.Xiubo@freescale.com --- include/sound/soc.h | 3 +++ sound/soc/soc-core.c | 11 +++++++++++ 2 files changed, 14 insertions(+)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 4c4d7e1..94bc1c4 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -749,6 +749,9 @@ struct snd_soc_codec_driver { int (*set_pll)(struct snd_soc_codec *codec, int pll_id, int source, unsigned int freq_in, unsigned int freq_out);
+ /* codec regmap */ + struct regmap *regmap; + /* codec IO */ unsigned int (*read)(struct snd_soc_codec *, unsigned int); int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index a14155b..0fb502f 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -4443,6 +4443,17 @@ int snd_soc_register_codec(struct device *dev, codec->num_dai = num_dai; mutex_init(&codec->mutex);
+ if (!codec->write && (codec_drv->regmap || + dev_get_regmap(codec->dev, NULL))) { + /* Set the default I/O up try regmap */ + ret = snd_soc_codec_set_cache_io(codec, codec_drv->regmap); + if (ret < 0 && ret != -ENOTSUPP) { + dev_err(codec->dev, + "Failed to set cache I/O: %d\n", ret); + goto fail_codec_name; + } + } + for (i = 0; i < num_dai; i++) { fixup_codec_formats(&dai_drv[i].playback); fixup_codec_formats(&dai_drv[i].capture);
On 03/04/2014 09:25 AM, Xiubo Li wrote:
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 set_cache_io() go away entirely from each CODEC ASoC probe.
Signed-off-by: Xiubo Li Li.Xiubo@freescale.com
include/sound/soc.h | 3 +++ sound/soc/soc-core.c | 11 +++++++++++ 2 files changed, 14 insertions(+)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 4c4d7e1..94bc1c4 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -749,6 +749,9 @@ struct snd_soc_codec_driver { int (*set_pll)(struct snd_soc_codec *codec, int pll_id, int source, unsigned int freq_in, unsigned int freq_out);
- /* codec regmap */
- struct regmap *regmap;
Nope. The driver struct is globally shared between all device instances, the regmap struct is device instance specific. The proper way to solve this is to have a function like snd_soc_register_codec_with_io() which takes a pointer to the regmap struct.
Subject: Re: [alsa-devel] [RFC][PATCH 1/3] ASoC: core: Move the default regmap I/O setting to snd_soc_register_codec()
On 03/04/2014 09:25 AM, Xiubo Li wrote:
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 set_cache_io() go away entirely from each CODEC ASoC probe.
Signed-off-by: Xiubo Li Li.Xiubo@freescale.com
include/sound/soc.h | 3 +++ sound/soc/soc-core.c | 11 +++++++++++ 2 files changed, 14 insertions(+)
diff --git a/include/sound/soc.h b/include/sound/soc.h index 4c4d7e1..94bc1c4 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -749,6 +749,9 @@ struct snd_soc_codec_driver { int (*set_pll)(struct snd_soc_codec *codec, int pll_id, int source, unsigned int freq_in, unsigned int freq_out);
- /* codec regmap */
- struct regmap *regmap;
Nope. The driver struct is globally shared between all device instances, the regmap struct is device instance specific. The proper way to solve this is to have a function like snd_soc_register_codec_with_io() which takes a pointer to the regmap struct.
@Lars Yes, this maybe a better choice, and I will think of it.
Thanks very much,
-- Best Regards, Xiubo
As we can set the CODEC I/O while snd_soc_register_codec(), so the calling of set_cache_io() from CODEC ASoC probe could be removed entirely.
Signed-off-by: Xiubo Li Li.Xiubo@freescale.com --- sound/soc/codecs/cq93vc.c | 6 ++++-- sound/soc/codecs/mc13783.c | 10 ++-------- sound/soc/codecs/wm5102.c | 6 ++---- sound/soc/codecs/wm5110.c | 6 ++---- sound/soc/codecs/wm8350.c | 6 ++++-- sound/soc/codecs/wm8400.c | 6 ++++-- sound/soc/codecs/wm8994.c | 4 ++-- sound/soc/codecs/wm8997.c | 7 ++----- 8 files changed, 22 insertions(+), 29 deletions(-)
diff --git a/sound/soc/codecs/cq93vc.c b/sound/soc/codecs/cq93vc.c index 1e25c7a..27e2b7e 100644 --- a/sound/soc/codecs/cq93vc.c +++ b/sound/soc/codecs/cq93vc.c @@ -139,8 +139,6 @@ static int cq93vc_probe(struct snd_soc_codec *codec)
davinci_vc->cq93vc.codec = codec;
- snd_soc_codec_set_cache_io(codec, davinci_vc->regmap); - /* Off, with power on */ cq93vc_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
@@ -165,6 +163,10 @@ static struct snd_soc_codec_driver soc_codec_dev_cq93vc = {
static int cq93vc_platform_probe(struct platform_device *pdev) { + struct davinci_vc *davinci_vc = codec->dev->platform_data; + + soc_codec_dev_cq93vc.regmap = davinci_vc->regmap; + return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_cq93vc, &cq93vc_dai, 1); } diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c index 3331cc7..63b4dcb 100644 --- a/sound/soc/codecs/mc13783.c +++ b/sound/soc/codecs/mc13783.c @@ -612,14 +612,6 @@ static struct snd_kcontrol_new mc13783_control_list[] = { static int mc13783_probe(struct snd_soc_codec *codec) { struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec); - int ret; - - ret = snd_soc_codec_set_cache_io(codec, - dev_get_regmap(codec->dev->parent, NULL)); - if (ret != 0) { - dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); - return ret; - }
/* these are the reset values */ mc13xxx_reg_write(priv->mc13xxx, MC13783_AUDIO_RX0, 0x25893); @@ -770,6 +762,8 @@ static int __init mc13783_codec_probe(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, priv); priv->mc13xxx = dev_get_drvdata(pdev->dev.parent);
+ soc_codec_dev_mc13783.regmap = dev_get_regmap(pdev->dev->parent, NULL); + if (priv->adc_ssi_port == priv->dac_ssi_port) ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_mc13783, mc13783_dai_sync, ARRAY_SIZE(mc13783_dai_sync)); diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index 01b6ee4..4c3ebfd 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c @@ -1760,10 +1760,6 @@ static int wm5102_codec_probe(struct snd_soc_codec *codec) struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec); int ret;
- ret = snd_soc_codec_set_cache_io(codec, priv->core.arizona->regmap); - if (ret != 0) - return ret; - ret = snd_soc_add_codec_controls(codec, wm_adsp2_fw_controls, 2); if (ret != 0) return ret; @@ -1874,6 +1870,8 @@ static int wm5102_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); pm_runtime_idle(&pdev->dev);
+ soc_codec_dev_wm5102.regmap = arizona->regmap; + return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm5102, wm5102_dai, ARRAY_SIZE(wm5102_dai)); } diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index cf5d828f..bfb4597 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c @@ -1589,10 +1589,6 @@ static int wm5110_codec_probe(struct snd_soc_codec *codec)
priv->core.arizona->dapm = &codec->dapm;
- ret = snd_soc_codec_set_cache_io(codec, priv->core.arizona->regmap); - if (ret != 0) - return ret; - arizona_init_spk(codec); arizona_init_gpio(codec);
@@ -1710,6 +1706,8 @@ static int wm5110_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); pm_runtime_idle(&pdev->dev);
+ soc_codec_dev_wm5110.regmap = arizona->regmap; + return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm5110, wm5110_dai, ARRAY_SIZE(wm5110_dai)); } diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index 757256b..9a8f4d4 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c @@ -1505,8 +1505,6 @@ static int wm8350_codec_probe(struct snd_soc_codec *codec) if (ret != 0) return ret;
- snd_soc_codec_set_cache_io(codec, wm8350->regmap); - /* Put the codec into reset if it wasn't already */ wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA);
@@ -1625,6 +1623,10 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8350 = {
static int wm8350_probe(struct platform_device *pdev) { + struct wm8350 *wm8350 = dev_get_platdata(pdev->dev); + + soc_codec_dev_wm8350.regmap = wm8350->regmap; + return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8350, &wm8350_dai, 1); } diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index 146564f..38c0a4a 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c @@ -1318,8 +1318,6 @@ static int wm8400_codec_probe(struct snd_soc_codec *codec) priv->wm8400 = wm8400; priv->codec = codec;
- snd_soc_codec_set_cache_io(codec, wm8400->regmap); - ret = devm_regulator_bulk_get(wm8400->dev, ARRAY_SIZE(power), &power[0]); if (ret != 0) { @@ -1378,6 +1376,10 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8400 = {
static int wm8400_probe(struct platform_device *pdev) { + struct wm8400 *wm8400 = dev_get_platdata(codec->dev); + + soc_codec_dev_wm8400.regmap = wm8400->regmap; + return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8400, &wm8400_dai, 1); } diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index decc3c9..128c50c 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -4000,8 +4000,6 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
wm8994->hubs.codec = codec;
- snd_soc_codec_set_cache_io(codec, control->regmap); - mutex_init(&wm8994->accdet_lock); INIT_DELAYED_WORK(&wm8994->jackdet_bootstrap, wm1811_jackdet_bootstrap); @@ -4458,6 +4456,8 @@ static int wm8994_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); pm_runtime_idle(&pdev->dev);
+ soc_codec_dev_wm8994.regmap = wm8994->wm8994->regmap; + return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8994, wm8994_dai, ARRAY_SIZE(wm8994_dai)); } diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c index 5e1a32e..8ad6537 100644 --- a/sound/soc/codecs/wm8997.c +++ b/sound/soc/codecs/wm8997.c @@ -1051,11 +1051,6 @@ static struct snd_soc_dai_driver wm8997_dai[] = { static int wm8997_codec_probe(struct snd_soc_codec *codec) { struct wm8997_priv *priv = snd_soc_codec_get_drvdata(codec); - int ret; - - ret = snd_soc_codec_set_cache_io(codec, priv->core.arizona->regmap); - if (ret != 0) - return ret;
arizona_init_spk(codec);
@@ -1145,6 +1140,8 @@ static int wm8997_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); pm_runtime_idle(&pdev->dev);
+ soc_codec_dev_wm8997.regmap = arizona->regmap; + return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8997, wm8997_dai, ARRAY_SIZE(wm8997_dai)); }
Since all the CODEC drivers has using the snd_soc_register_codec() to set up the CODEC I/O while the CODEC probing, so this could be removed entirely.
Signed-off-by: Xiubo Li Li.Xiubo@freescale.com --- sound/soc/soc-core.c | 10 ---------- 1 file changed, 10 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 0fb502f..bc3a930 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1137,16 +1137,6 @@ static int soc_probe_codec(struct snd_soc_card *card,
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) { ret = driver->probe(codec); if (ret < 0) {
participants (3)
-
Lars-Peter Clausen
-
Li.Xiubo@freescale.com
-
Xiubo Li