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 <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@ti.com>
This commit is contained in:
parent
f9c540456a
commit
89b95ac09e
|
@ -562,6 +562,12 @@ struct snd_soc_codec_driver {
|
||||||
pm_message_t state);
|
pm_message_t state);
|
||||||
int (*resume)(struct snd_soc_codec *);
|
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 */
|
/* codec IO */
|
||||||
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);
|
||||||
|
|
|
@ -1464,6 +1464,7 @@ static int soc_probe_codec(struct snd_soc_card *card,
|
||||||
struct snd_soc_codec *codec)
|
struct snd_soc_codec *codec)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
const struct snd_soc_codec_driver *driver = codec->driver;
|
||||||
|
|
||||||
codec->card = card;
|
codec->card = card;
|
||||||
codec->dapm.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))
|
if (!try_module_get(codec->dev->driver->owner))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
if (codec->driver->probe) {
|
if (driver->probe) {
|
||||||
ret = codec->driver->probe(codec);
|
ret = driver->probe(codec);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(codec->dev,
|
dev_err(codec->dev,
|
||||||
"asoc: failed to probe CODEC %s: %d\n",
|
"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);
|
soc_init_codec_debugfs(codec);
|
||||||
|
|
||||||
/* mark codec as probed and add to card codec list */
|
/* mark codec as probed and add to card codec list */
|
||||||
|
|
Loading…
Reference in New Issue