[alsa-devel] [PATCH] ASoC: core: Add support for DAI driver DAI widgets.
Liam Girdwood
lrg at ti.com
Wed Mar 7 12:47:42 CET 2012
Automatically create DAI widgets for DAI drivers. This allows us to connect
CPU DAIs into the DAPM graph. The widgets use the DAI driver dev name with
a "Playback" or "Capture" suffix.
i.e. "mcbsp.1 Playback"
Also add a snd_soc_dai member to snd_soc_widget so that we dont have to
use the widget private data.
Signed-off-by: Liam Girdwood <lrg at ti.com>
---
include/sound/soc-dapm.h | 1 +
sound/soc/soc-dapm.c | 56 +++++++++++++++++++++++++++-------------------
2 files changed, 34 insertions(+), 23 deletions(-)
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index 6727384..8cd3c74 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -482,6 +482,7 @@ struct snd_soc_dapm_widget {
const char *sname; /* stream name */
struct snd_soc_codec *codec;
struct snd_soc_platform *platform;
+ struct snd_soc_dai *dai;
struct list_head list;
struct snd_soc_dapm_context *dapm;
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 5c83b83..d15a703 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -44,6 +44,7 @@
#include <trace/events/asoc.h>
+#define NAME_SIZE 32
#define DAPM_UPDATE_STAT(widget, val) widget->dapm->card->dapm_stats.val++;
/* dapm power sequences - make this per codec in the future */
@@ -2911,6 +2912,7 @@ int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
{
struct snd_soc_dapm_widget template;
struct snd_soc_dapm_widget *w;
+ char name[NAME_SIZE];
WARN_ON(dapm->dev != dai->dev);
@@ -2918,41 +2920,49 @@ int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
template.reg = SND_SOC_NOPM;
if (dai->driver->playback.stream_name) {
- template.id = snd_soc_dapm_dai;
template.name = dai->driver->playback.stream_name;
template.sname = dai->driver->playback.stream_name;
+ } else {
+ snprintf(name, NAME_SIZE, "%s %s", dev_name(dai->dev), "Playback");
+ template.name = name;
+ template.sname = name;
+ }
- dev_dbg(dai->dev, "adding %s widget\n",
- template.name);
+ template.id = snd_soc_dapm_dai;
+ dev_dbg(dai->dev, "adding %s widget\n",
+ template.name);
- w = snd_soc_dapm_new_control(dapm, &template);
- if (!w) {
- dev_err(dapm->dev, "Failed to create %s widget\n",
- dai->driver->playback.stream_name);
- }
-
- w->priv = dai;
- dai->playback_widget = w;
+ w = snd_soc_dapm_new_control(dapm, &template);
+ if (!w) {
+ dev_err(dapm->dev, "Failed to create %s widget\n",
+ dai->driver->playback.stream_name);
}
+ dai->playback_widget = w;
+ w->dai = dai;
+
if (dai->driver->capture.stream_name) {
- template.id = snd_soc_dapm_dai;
template.name = dai->driver->capture.stream_name;
template.sname = dai->driver->capture.stream_name;
+ } else {
+ snprintf(name, NAME_SIZE, "%s %s", dev_name(dai->dev), "Capture");
+ template.name = name;
+ template.sname = name;
+ }
+ template.id = snd_soc_dapm_dai;
- dev_dbg(dai->dev, "adding %s widget\n",
- template.name);
+ dev_dbg(dai->dev, "adding %s widget\n",
+ template.name);
- w = snd_soc_dapm_new_control(dapm, &template);
- if (!w) {
- dev_err(dapm->dev, "Failed to create %s widget\n",
- dai->driver->capture.stream_name);
- }
-
- w->priv = dai;
- dai->capture_widget = w;
+ w = snd_soc_dapm_new_control(dapm, &template);
+ if (!w) {
+ dev_err(dapm->dev, "Failed to create %s widget\n",
+ dai->driver->capture.stream_name);
}
+ dai->capture_widget = w;
+ w->dai = dai;
+
return 0;
}
@@ -2969,7 +2979,7 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
if (dai_w->id != snd_soc_dapm_dai)
continue;
- dai = dai_w->priv;
+ dai = dai_w->dai;
/* ...find all widgets with the same stream and link them */
list_for_each_entry(w, &card->widgets, list) {
--
1.7.5.4
More information about the Alsa-devel
mailing list