Skip to contentSkip to conversation

ASoC: Allow DAPM pin operations to match any context

PATCH In review Mark Brown 2 participants 2 messages Apr 8, 2011

Subsystems (2)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 ASoC: Allow DAPM pin operations to match any context

The DAPM pin operations currently require that the specific DAPM context that the pin being operated in is contained in be specified. With multi component and especially with the addition of a per-card DAPM context this isn't ideal as it means that things like disabling unused pins on CODECs require looking up the CODEC DAPM context.

Fix this by falling back to matching a widget in any context if there isn't a match in the current context. The code isn't ideal currently but will do the job.

---
 sound/soc/soc-dapm.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
sound/soc/soc-dapm.c +24 -0
index 14dbba7..5fe750c 100644
@@ -1477,6 +1477,19 @@ static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
 		}
 	}
 
+	/* Try again in other contexts */
+	list_for_each_entry(w, &dapm->card->widgets, list) {
+		if (!strcmp(w->name, pin)) {
+			dev_dbg(w->dapm->dev, "dapm: pin %s = %d\n",
+				pin, status);
+			w->connected = status;
+			/* Allow disabling of forced pins */
+			if (status == 0)
+				w->force = 0;
+			return 0;
+		}
+	}
+
 	dev_err(dapm->dev, "dapm: unknown pin %s\n", pin);
 	return -EINVAL;
 }
@@ -2332,6 +2345,17 @@ int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
 		}
 	}
 
+	/* Try again with other contexts */
+	list_for_each_entry(w, &dapm->card->widgets, list) {
+		if (!strcmp(w->name, pin)) {
+			dev_dbg(w->dapm->dev,
+				"dapm: force enable pin %s\n", pin);
+			w->connected = 1;
+			w->force = 1;
+			return 0;
+		}
+	}
+
 	dev_err(dapm->dev, "dapm: unknown pin %s\n", pin);
 	return -EINVAL;
 }
Signature · 1 line
1.7.4.1
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Mark Brown

The DAPM pin operations currently require that the specific DAPM context that the pin being operated in is contained in be specified. With multi component and especially with the addition of a per-card DAPM context this isn't ideal as it means that things like disabling unused pins on CODECs require looking up the CODEC DAPM context.

Fix this by falling back to matching a widget in any context if there isn't a match in the current context. The code isn't ideal currently but will do the job.