diff options
author | Takashi Iwai <tiwai@suse.de> | 2011-07-09 11:43:04 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-07-09 11:43:04 +0200 |
commit | e320bc42be746b8f006d163b6e340e5fb79ce7b2 (patch) | |
tree | 70cbde5344d0a478c6a514f3f3e45fb9edb1eb0f /sound/soc/soc-core.c | |
parent | f187700c2d769bd3160b52f99cc4e747d5c5014b (diff) | |
parent | b5d5f59be2ac586db2db0ac324215a714961f364 (diff) | |
download | op-kernel-dev-e320bc42be746b8f006d163b6e340e5fb79ce7b2.zip op-kernel-dev-e320bc42be746b8f006d163b6e340e5fb79ce7b2.tar.gz |
Merge branch 'for-3.1' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound-2.6 into topic/asoc
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r-- | sound/soc/soc-core.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index d08abf4..70f4779 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -993,10 +993,15 @@ static int soc_probe_platform(struct snd_soc_card *card, const struct snd_soc_platform_driver *driver = platform->driver; platform->card = card; + platform->dapm.card = card; if (!try_module_get(platform->dev->driver->owner)) return -ENODEV; + if (driver->dapm_widgets) + snd_soc_dapm_new_controls(&platform->dapm, + driver->dapm_widgets, driver->num_dapm_widgets); + if (driver->probe) { ret = driver->probe(platform); if (ret < 0) { @@ -1007,9 +1012,17 @@ static int soc_probe_platform(struct snd_soc_card *card, } } + if (driver->controls) + snd_soc_add_platform_controls(platform, driver->controls, + driver->num_controls); + if (driver->dapm_routes) + snd_soc_dapm_add_routes(&platform->dapm, driver->dapm_routes, + driver->num_dapm_routes); + /* mark platform as probed and add to card platform list */ platform->probed = 1; list_add(&platform->card_list, &card->platform_dev_list); + list_add(&platform->dapm.list, &card->dapm_list); return 0; @@ -1652,6 +1665,7 @@ int snd_soc_platform_read(struct snd_soc_platform *platform, ret = platform->driver->read(platform, reg); dev_dbg(platform->dev, "read %x => %x\n", reg, ret); + trace_snd_soc_preg_read(platform, reg, ret); return ret; } @@ -1666,6 +1680,7 @@ int snd_soc_platform_write(struct snd_soc_platform *platform, } dev_dbg(platform->dev, "write %x = %x\n", reg, val); + trace_snd_soc_preg_write(platform, reg, val); return platform->driver->write(platform, reg, val); } EXPORT_SYMBOL_GPL(snd_soc_platform_write); @@ -1949,6 +1964,36 @@ int snd_soc_add_controls(struct snd_soc_codec *codec, EXPORT_SYMBOL_GPL(snd_soc_add_controls); /** + * snd_soc_add_platform_controls - add an array of controls to a platform. + * Convienience function to add a list of controls. + * + * @platform: platform to add controls to + * @controls: array of controls to add + * @num_controls: number of elements in the array + * + * Return 0 for success, else error. + */ +int snd_soc_add_platform_controls(struct snd_soc_platform *platform, + const struct snd_kcontrol_new *controls, int num_controls) +{ + struct snd_card *card = platform->card->snd_card; + int err, i; + + for (i = 0; i < num_controls; i++) { + const struct snd_kcontrol_new *control = &controls[i]; + err = snd_ctl_add(card, snd_soc_cnew(control, platform, + control->name, NULL)); + if (err < 0) { + dev_err(platform->dev, "Failed to add %s %d\n",control->name, err); + return err; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_add_platform_controls); + +/** * snd_soc_info_enum_double - enumerated double mixer info callback * @kcontrol: mixer control * @uinfo: control element information @@ -3092,6 +3137,8 @@ int snd_soc_register_platform(struct device *dev, platform->dev = dev; platform->driver = platform_drv; + platform->dapm.dev = dev; + platform->dapm.platform = platform; mutex_lock(&client_mutex); list_add(&platform->list, &platform_list); |