Remove set_cache_io entirely from ASoC probe
Subsystems (3)
cover 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(-)
Signature · 1 line
1.8.4
RFC PATCH 1/3 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 set_cache_io() go away entirely from each CODEC ASoC probe.
--- include/sound/soc.h | 3 +++ sound/soc/soc-core.c | 11 +++++++++++ 2 files changed, 14 insertions(+)
include/sound/soc.h +3 -0
@@ -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 );
sound/soc/soc-core.c +11 -0
@@ -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);
Signature · 1 line
1.8.4
Re: [alsa-devel] [RFC][PATCH 1/3] ASoC: core: Move the default regmap I/O setting to snd_soc_register_codec()
Quoted 16 lines · Xiubo Li
Add the default regmap I/O setting to
snd_soc_register_codec()while the CODEC is initialising, which will be called by CODEC driver deviceprobe(), and then we can makeset_cache_io()go away entirely from each CODEC ASoC probe.Signed-off-by Xiubo Li <[email protected]>--- include/sound/soc.h | 3 +++ sound/soc/soc-core.c | 11 +++++++++++ 2 files changed, 14 insertions(+)include/sound/soc.h +0
-0
include/sound/soc.h struct snd_soc_codec_driver { · line 754
Quoted 6 lines
include/sound/soc.h +3
-0@@ -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.
RE: [alsa-devel] [RFC][PATCH 1/3] ASoC: core: Move the default regmap I/O setting to snd_soc_register_codec()
Quoted 24 lines
Subject: Re: [alsa-devel] [RFC][PATCH 1/3] ASoC: core: Move the default regmap I/O setting to
snd_soc_register_codec()Quoted 19 lines · Xiubo Li
Add the default regmap I/O setting to
snd_soc_register_codec()while the CODEC is initialising, which will be called by CODEC driver deviceprobe(), and then we can makeset_cache_io()go away entirely from each CODEC ASoC probe.Signed-off-by Xiubo Li <[email protected]>--- include/sound/soc.h | 3 +++ sound/soc/soc-core.c | 11 +++++++++++ 2 files changed, 14 insertions(+)include/sound/soc.h +0
-0@@ -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);
Quoted 9 lines
include/sound/soc.h struct snd_soc_codec_driver { · line 754
Quoted 3 lines
include/sound/soc.h +3
-0+/* 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
RFC PATCH 2/3 ASoc: codec: remove the set_cache_io() entirely from CODEC ASoC probe.
In reply to Xiubo LiAs 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.
--- 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(-)
sound/soc/codecs/cq93vc.c +4 -2
@@ -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 ); }
sound/soc/codecs/mc13783.c +2 -8
@@ -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));
sound/soc/codecs/wm5102.c +2 -4
@@ -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)); }
sound/soc/codecs/wm5110.c +2 -4
@@ -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)); }
sound/soc/codecs/wm8350.c +4 -2
@@ -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 ); }
sound/soc/codecs/wm8400.c +4 -2
@@ -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 ); }
sound/soc/codecs/wm8994.c +2 -2
@@ -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)); }
sound/soc/codecs/wm8997.c +2 -5
@@ -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)); }
Signature · 1 line
1.8.4
RFC PATCH 3/3 ASoC: core: remove the default regmap I/O setting up from soc_probe_codec()
In reply to Xiubo LiSince 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.
--- sound/soc/soc-core.c | 10 ---------- 1 file changed, 10 deletions(-)
sound/soc/soc-core.c +0 -10
@@ -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 ) {
Signature · 1 line
1.8.4