ASoC: Add DAPM widget and path data to CODEC driver structure
Subsystems (3)
PATCH 1/2 ASoC: Add DAPM widget and path data to CODEC driver structure
Allow a slight simplification of CODEC drivers by allowing DAPM routes and widgets to be provided in a table. They will be instantiated at the end of CODEC probe.
Signed-off-by Mark Brown <[email protected]>
--- include/sound/soc.h | 6 ++++++ sound/soc/soc-core.c | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-)
include/sound/soc.h +6 -0
@@ -563,6 +563,12 @@ struct snd_soc_codec_driver { pm_message_t state);int (*resume)(struct snd_soc_codec *); +/* Default DAPM setup, added after probe() is run */ +const struct snd_soc_dapm_widget *dapm_widgets; +int num_dapm_widgets; +const struct snd_soc_dapm_route *dapm_routes; +int num_dapm_routes; +/* 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 +10 -2
@@ -1464,6 +1464,7 @@ static int soc_probe_codec(struct snd_soc_card *card, struct snd_soc_codec *codec) {int ret =0 ; +const struct snd_soc_codec_driver *driver = codec->driver; codec->card = card; codec->dapm.card = card;
@@ -1472,8 +1473,8 @@ static int soc_probe_codec(struct snd_soc_card *card,if (!try_module_get (codec->dev->driver->owner))return -ENODEV ; -if (codec->driver->probe) { - ret = codec->driver->probe (codec); +if (driver->probe) { + ret = driver->probe (codec);if (ret <0 ) { dev_err(codec->dev, "asoc: failed to probe CODEC %s: %d\n",
@@ -1482,6 +1483,13 @@ static int soc_probe_codec(struct snd_soc_card *card, } } +if (driver->dapm_widgets) +snd_soc_dapm_new_controls (&codec->dapm, driver->dapm_widgets, + driver->num_dapm_widgets); +if (driver->dapm_routes) +snd_soc_dapm_add_routes (&codec->dapm, driver->dapm_routes, + driver->num_dapm_routes); +soc_init_codec_debugfs (codec);/* mark codec as probed and add to card codec list */
Signature · 1 line
1.7.2.3
PATCH 2/2 ASoC: Use data base init for WM9081 DAPM
Signed-off-by Mark Brown <[email protected]>
--- sound/soc/codecs/wm9081.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-)
sound/soc/codecs/wm9081.c +5 -6
@@ -762,7 +762,7 @@ SND_SOC_DAPM_SUPPLY("TOCLK", WM9081_CLOCK_CONTROL_3, 2, 0, NULL, 0), }; -static const struct snd_soc_dapm_route audio_paths[] = { +static const struct snd_soc_dapm_route wm9081_audio_paths[] = { {"DAC" ,NULL ,"CLK_SYS" }, {"DAC" ,NULL ,"CLK_DSP" },
@@ -1232,7 +1232,6 @@ static struct snd_soc_dai_driver wm9081_dai = {static int wm9081_probe (struct snd_soc_codec *codec) {struct wm9081_priv *wm9081 =snd_soc_codec_get_drvdata (codec); -struct snd_soc_dapm_context *dapm = &codec->dapm;int ret;u16 reg;
@@ -1282,10 +1281,6 @@ static int wm9081_probe(struct snd_soc_codec *codec) ARRAY_SIZE(wm9081_eq_controls)); } -snd_soc_dapm_new_controls (dapm, wm9081_dapm_widgets, -ARRAY_SIZE (wm9081_dapm_widgets)); -snd_soc_dapm_add_routes (dapm, audio_paths,ARRAY_SIZE (audio_paths)); -return ret; }
@@ -1334,6 +1329,10 @@ static struct snd_soc_codec_driver soc_codec_dev_wm9081 = { .reg_word_size = sizeof(u16), .reg_cache_default = wm9081_reg_defaults, .volatile_register = wm9081_volatile_register, + .dapm_widgets = wm9081_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm9081_dapm_widgets), + .dapm_routes = wm9081_audio_paths, + .num_dapm_routes = ARRAY_SIZE(wm9081_audio_paths), };#if defined(CONFIG_I2C ) || defined(CONFIG_I2C_MODULE )
Signature · 1 line
1.7.2.3
Re: [PATCH 2/2] ASoC: Use data base init for WM9081 DAPM
Quoted 5 lines · Mark Brown
Signed-off-by Mark Brown <[email protected]>--- sound/soc/codecs/wm9081.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-)
Acked-by Liam Girdwood <[email protected]>
Quoted 5 lines · Mark Brown
Allow a slight simplification of CODEC drivers by allowing DAPM routes and widgets to be provided in a table. They will be instantiated at the end of CODEC probe.
Signed-off-by Mark Brown <[email protected]>
Acked-by Liam Girdwood <[email protected]>