Skip to contentSkip to conversation

ASOC: dapm: add code to configure dai link parameters

PATCH Superseded Nikesh Oswal 2 participants 2 messages Sep 1, 2014 – Sep 6, 2014

Subsystems (2)

v4 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 ASOC: dapm: add code to configure dai link parameters

dai-link params for codec-codec links were fixed. The fixed link between codec and another chip which may be another codec, baseband, bluetooth codec etc may require run time configuaration changes. This change provides an optional alsa control to select one of the params from a list of params.

---
 include/sound/soc-dapm.h |    3 +
 include/sound/soc.h      |    1 +
 sound/soc/soc-core.c     |    6 +-
 sound/soc/soc-dapm.c     |  139 ++++++++++++++++++++++++++++++++++++++++++++--
 4 files changed, 142 insertions(+), 7 deletions(-)
include/sound/soc-dapm.h +3 -0
index 6b59471..3ee031e 100644
@@ -378,6 +378,7 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card);
 void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card);
 int snd_soc_dapm_new_pcm(struct snd_soc_card *card,
 			 const struct snd_soc_pcm_stream *params,
+			 unsigned int num_params,
 			 struct snd_soc_dapm_widget *source,
 			 struct snd_soc_dapm_widget *sink);
 
@@ -531,6 +532,8 @@ struct snd_soc_dapm_widget {
 	void *priv;				/* widget specific data */
 	struct regulator *regulator;		/* attached regulator */
 	const struct snd_soc_pcm_stream *params; /* params for dai links */
+	unsigned int num_params; /* number of params for dai links */
+	unsigned int params_select; /* currently selected param for dai link */
 
 	/* dapm control */
 	int reg;				/* negative reg = no direct dapm */
include/sound/soc.h +1 -0
index ed9e2d7..51c6c4f 100644
@@ -906,6 +906,7 @@ struct snd_soc_dai_link {
 	int be_id;	/* optional ID for machine driver BE identification */
 
 	const struct snd_soc_pcm_stream *params;
+	unsigned int num_params;
 
 	unsigned int dai_fmt;           /* format to set on init */
 
sound/soc/soc-core.c +4 -2
index b87d7d8..1db2168 100644
@@ -1461,7 +1461,8 @@ static int soc_link_dai_widgets(struct snd_soc_card *card,
 	capture_w = cpu_dai->capture_widget;
 	if (play_w && capture_w) {
 		ret = snd_soc_dapm_new_pcm(card, dai_link->params,
-					   capture_w, play_w);
+					   dai_link->num_params, capture_w,
+					   play_w);
 		if (ret != 0) {
 			dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n",
 				play_w->name, capture_w->name, ret);
@@ -1473,7 +1474,8 @@ static int soc_link_dai_widgets(struct snd_soc_card *card,
 	capture_w = codec_dai->capture_widget;
 	if (play_w && capture_w) {
 		ret = snd_soc_dapm_new_pcm(card, dai_link->params,
-					   capture_w, play_w);
+					   dai_link->num_params, capture_w,
+					   play_w);
 		if (ret != 0) {
 			dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n",
 				play_w->name, capture_w->name, ret);
sound/soc/soc-dapm.c +134 -5

193 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#1 lore raw
Quoted 5 lines · Nikesh Oswal

dai-link params for codec-codec links were fixed. The fixed link between codec and another chip which may be another codec, baseband, bluetooth codec etc may require run time configuaration changes. This change provides an optional alsa control to select one of the params from a list of params.

As I'm fairly sure I've told you several times now please use subject lines matching the style for the subsystem - if your commit logs look different to all the other commit logs that's probably not a good sign. In this specific case "ASOC" and "ASoC" are not the same thing.

sound/soc/soc-dapm.c int snd_soc_dapm_new_pcm(struct snd_soc_card *card, · line 3322

Quoted 9 lines
sound/soc/soc-dapm.c +9 -0
+	for (count = 0 ; count < num_params; count++) {
+		w_param_text[count] = kmemdup((void *)(config->stream_name),
+			strlen(config->stream_name) + 1, GFP_KERNEL);
+		if (!w_param_text[count]) {
+			ret = -ENOMEM;
+			goto  outfree_w_param;
+		}
+		config++;
+	}

This will happily create values with a completely empty name if the user didn't specify one. This doesn't seem great - it's going to be an easy mistake to make and fail to notice. I'd at least expect a warning here.

sound/soc/soc-dapm.c int snd_soc_dapm_new_pcm(struct snd_soc_card *card, · line 3324

Quoted 2 lines
sound/soc/soc-dapm.c +2 -0
+	w_param_enum[0].items = num_params;
+	w_param_enum[0].texts = (const char * const *) w_param_text;

Why the casts? This tends to be a sign that something is wrong.