Skip to contentSkip to conversation

ASoC: dapm - Add API call to query the widgets of valid DAPM paths.

PATCH In review Liam Girdwood 2 participants 6 messages Jul 25, 2011 – Jul 26, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ASoC: dapm - Add API call to query the widgets of valid DAPM paths.

In preparation for Dynamic PCM (AKA DSP) support.

Add a DAPM API call to determine whether a DAPM audio path is valid between source and sink widgets and return the path widgets. This also takes into account all kcontrol mux and mixer settings in between the source and sink widgets to validate the audio path.

This will be used by the Dynamic PCM core to determine the runtime DAI mappings between FE and BE DAIs in order to run PCM operations.

This modifies the existing is_connected_input_ep() and is_connected_output_ep() by adding a new parameter to store any valid widgets in a list. We also add some extra debug to provide further insight into the DAPM path and widget discovery.

---
 include/sound/soc-dapm.h |    6 ++
 sound/soc/soc-dapm.c     |  184 ++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 176 insertions(+), 14 deletions(-)
include/sound/soc-dapm.h +6 -0
index 5833f01..a56ead2 100644
@@ -310,6 +310,7 @@ struct snd_soc_dapm_path;
 struct snd_soc_dapm_pin;
 struct snd_soc_dapm_route;
 struct snd_soc_dapm_context;
+struct snd_soc_dapm_widget_list;
 
 int dapm_reg_event(struct snd_soc_dapm_widget *w,
 		   struct snd_kcontrol *kcontrol, int event);
@@ -375,6 +376,11 @@ int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
 int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm,
 				const char *pin);
 
+/* dapm path query */
+int snd_soc_dapm_get_connected_widgets(struct snd_soc_dapm_context *dapm,
+		const char *stream_name, struct snd_soc_dapm_widget_list **list,
+		int stream);
+
 /* dapm widget types */
 enum snd_soc_dapm_type {
 	snd_soc_dapm_input = 0,		/* input pin */
sound/soc/soc-dapm.c +170 -14

256 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#1 lore raw

sound/soc/soc-dapm.c static int is_connected_input_ep(struct snd_soc_dapm_widget *widget) · line 851

Quoted 13 lines · Liam Girdwood
sound/soc/soc-dapm.c +12 -0
+int snd_soc_dapm_get_connected_widgets(struct snd_soc_dapm_context *dapm,
+	const char *stream_name, struct snd_soc_dapm_widget_list **list,
+	int stream)
 
+	/* get stream root widget AIF from stream string and direction */
+	list_for_each_entry(w, &dapm->card->widgets, list) {
+
+		if (w->id != type)
+			continue;
+
+		if (!strcmp(w->sname, stream_name))
+			goto found;
+	}

Hrm, so I must be missing something here but this still has the issue with only finding the first widget if we've got more than one widget for a stream. For example, the tlv320aic3x driver defines:

SND_SOC_DAPM_DAC("Left DAC", "Left Playback", DAC_PWR, 7, 0), SND_SOC_DAPM_DAC("Right DAC", "Right Playback", DAC_PWR, 6, 0),

and hooks them both up to a single "Playback" stream (most devices don't even have the distinct names at the widget level). This makes sense as DAPM really does want mono streams to work with but if we only look at the first match we'll fail to enumerate some of the widgets connected to the stream. I think the found: block wants to be inside the if statement and probably just drop the dev_err(), or do it by checking to see if the list we come up with is empty.

#2 lore raw
Quoted 20 lines · Mark Brown

sound/soc/soc-dapm.c static int is_connected_input_ep(struct snd_soc_dapm_widget *widget) · line 851

Quoted 13 lines · Liam Girdwood
sound/soc/soc-dapm.c +12 -0
+int snd_soc_dapm_get_connected_widgets(struct snd_soc_dapm_context *dapm,
+	const char *stream_name, struct snd_soc_dapm_widget_list **list,
+	int stream)
 
+	/* get stream root widget AIF from stream string and direction */
+	list_for_each_entry(w, &dapm->card->widgets, list) {
+
+		if (w->id != type)
+			continue;
+
+		if (!strcmp(w->sname, stream_name))
+			goto found;
+	}

Hrm, so I must be missing something here but this still has the issue with only finding the first widget if we've got more than one widget for a stream. For example, the tlv320aic3x driver defines:

Quoted 5 lines
   SND_SOC_DAPM_DAC("Left DAC", "Left Playback", DAC_PWR, 7, 0),
   SND_SOC_DAPM_DAC("Right DAC", "Right Playback", DAC_PWR, 6, 0),

and hooks them both up to a single "Playback" stream (most devices don't even have the distinct names at the widget level).

This will only match on the exact name here. So we can retrieve both left and right stream widgets by making two separate calls. We should also not have two AIF widgets with the same stream name within a DAPM context.

Quoted 4 lines

This makes sense as
DAPM really does want mono streams to work with but if we only look at the first match we'll fail to enumerate some of the widgets connected to the stream.

This will only happen if we have AIF widgets with exactly the same stream names in a dapm context so there should only ever be 1 match.

Liam

#3 lore raw
Quoted 9 lines · Liam Girdwood
Quoted 6 lines · Mark Brown

Hrm, so I must be missing something here but this still has the issue with only finding the first widget if we've got more than one widget for a stream. For example, the tlv320aic3x driver defines:

   SND_SOC_DAPM_DAC("Left DAC", "Left Playback", DAC_PWR, 7, 0),
   SND_SOC_DAPM_DAC("Right DAC", "Right Playback", DAC_PWR, 6, 0),
Quoted 7 lines
Quoted 2 lines

and hooks them both up to a single "Playback" stream (most devices don't even have the distinct names at the widget level).

This will only match on the exact name here. So we can retrieve both left and right stream widgets by making two separate calls. We should also not have two AIF widgets with the same stream name within a DAPM context.

OK, right. If we want to do that then a substantial proportion of the existing CODEC drivers are broken - they're routinely putting in the stream name they want to match against rather than adding extra text to the stream to give unique names that are never used.

It does feel like this ought to be looking things up by widget rather than by stream, though. Widget names are already guaranteed unique and if the users do want to look things up for a single widget only it seems to make sense to ask for that widget rather than ask for a stream as it's not how we're currently using streams. It feels like if we're asking for a stream we should do the same substring multi-match that we do when pushing events into them.

#4 lore raw
Quoted 18 lines · Mark Brown
Quoted 9 lines · Liam Girdwood
Quoted 6 lines · Mark Brown

Hrm, so I must be missing something here but this still has the issue with only finding the first widget if we've got more than one widget for a stream. For example, the tlv320aic3x driver defines:

   SND_SOC_DAPM_DAC("Left DAC", "Left Playback", DAC_PWR, 7, 0),
   SND_SOC_DAPM_DAC("Right DAC", "Right Playback", DAC_PWR, 6, 0),
Quoted 7 lines
Quoted 2 lines

and hooks them both up to a single "Playback" stream (most devices don't even have the distinct names at the widget level).

This will only match on the exact name here. So we can retrieve both left and right stream widgets by making two separate calls. We should also not have two AIF widgets with the same stream name within a DAPM context.

Quoted 5 lines

OK, right. If we want to do that then a substantial proportion of the existing CODEC drivers are broken - they're routinely putting in the stream name they want to match against rather than adding extra text to the stream to give unique names that are never used.

They should all be OK, the stream event performs a strstr() on each stream widget so will match left/right etc streams based on the DAI stream name.

Quoted 7 lines

It does feel like this ought to be looking things up by widget rather than by stream, though. Widget names are already guaranteed unique and if the users do want to look things up for a single widget only it seems to make sense to ask for that widget rather than ask for a stream as it's not how we're currently using streams. It feels like if we're asking for a stream we should do the same substring multi-match that we do when pushing events into them.

V2 did the substring match, although now that more complex hardware is appearing I wonder if we should connect DAIs to widgets with the widget name (rather than just relying on the substring). i.e. each DAI could have a list of AIF widgets (most would have 1 or 2). Both methods could co-exist for a while with the substring method being deprecated.

Liam

#5 lore raw
Quoted 10 lines · Liam Girdwood
Quoted 4 lines · Mark Brown

OK, right. If we want to do that then a substantial proportion of the existing CODEC drivers are broken - they're routinely putting in the stream name they want to match against rather than adding extra text to the stream to give unique names that are never used.

They should all be OK, the stream event performs a strstr() on each stream widget so will match left/right etc streams based on the DAI stream name.

The case I'm worried about is the case where we've got two widgets with identical stream names - left and right AIF both call their playback widget stream "Playback" or whatever.

Quoted 8 lines
Quoted 7 lines

It does feel like this ought to be looking things up by widget rather than by stream, though. Widget names are already guaranteed unique and if the users do want to look things up for a single widget only it seems to make sense to ask for that widget rather than ask for a stream as it's not how we're currently using streams. It feels like if we're asking for a stream we should do the same substring multi-match that we do when pushing events into them.

Quoted 5 lines

V2 did the substring match, although now that more complex hardware is appearing I wonder if we should connect DAIs to widgets with the widget name (rather than just relying on the substring). i.e. each DAI could have a list of AIF widgets (most would have 1 or 2). Both methods could co-exist for a while with the substring method being deprecated.

Yes, there's definitely room to improve here - one thing I'd like to see is a system for mapping individual channels in the played audio so if for example we're playing mono data (or stereo data on a 5.1 CODEC) then we can figure out that lots of the channels aren't actually in use and not power them on.