ASoC: dapm - Add API call to query the widgets of valid DAPM paths.
PATCH v2 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, 178 insertions(+), 12 deletions(-)
include/sound/soc-dapm.h +6 -0
@@ -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 +172 -12
258 lines not on this page · raw message
Signature · 1 line
1.7.4.1
sound/soc/soc-dapm.c static int is_connected_output_ep(struct snd_soc_dapm_widget *widget) · line 693
Quoted 3 lines · Liam Girdwood
sound/soc/soc-dapm.c +3
-0+dev_dbg (widget->dapm->dev," %c : %s -> %s -> %s\n" , + path->sink && path->connect ?'*' :' ' , + widget->name, path->name, path->sink->name);
We should fix the debugfs stuff to include unconnected paths too, only showing currently active paths was a mistake. Might be worth dialing down to vdbg too, we look at DAPM a *lot* during scenario changes and on big systems it can obscure what's going on.
Quoted 9 lines
+/**
+ *snd_soc_dapm_get_connected_widgets- query audio path and it's widgets.
+ * @dapm: the dapm context.
+ * @stream_name: stream name.
+ * @list: list of active widgets for this stream.
+ * @stream: stream direction.
+ *
+ * Queries DAPM graph as to whether an valid audio stream path exists for
+ * the initial widget specified by name. This takes into account
s/initial widget/stream/
sound/soc/soc-dapm.c static int is_connected_input_ep(struct snd_soc_dapm_widget *widget) · line 856
Quoted 10 lines
sound/soc/soc-dapm.c +10
-0+/* 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 (strstr (w->sname, stream_name)) + goto found; + } +dev_err (dapm->dev,"root widget for %s not found\n" , stream_name);
Hrm, this will only check the widgets connected to the first widget it sees for an AIF. For streams with multiple widgets connected (eg, left and right channel) it's only going to see things on the first widget it comes across which probably isn't what we were expecting. Unless we change to match the comment and query by widget name in which case we're already requiring uniqueness.
Quoted 8 lines · Mark Brown
sound/soc/soc-dapm.c static int is_connected_output_ep(struct snd_soc_dapm_widget *widget) · line 693
Quoted 3 lines · Liam Girdwood
sound/soc/soc-dapm.c +3
-0+dev_dbg (widget->dapm->dev," %c : %s -> %s -> %s\n" , + path->sink && path->connect ?'*' :' ' , + widget->name, path->name, path->sink->name);We should fix the debugfs stuff to include unconnected paths too, only showing currently active paths was a mistake.
This will show the unconnected paths but not weak paths. I can update to include a flag for weak though.
Might be worth dialing
Quoted 2 lines
down to vdbg too, we look at DAPM a *lot* during scenario changes and on big systems it can obscure what's going on.
Ok, that would make sense. I can think of a few other areas for dev_vdbg too...
Quoted 22 lines
Quoted 10 lines
+/**
+ *snd_soc_dapm_get_connected_widgets- query audio path and it's widgets.
+ * @dapm: the dapm context.
+ * @stream_name: stream name.
+ * @list: list of active widgets for this stream.
+ * @stream: stream direction.
+ *
+ * Queries DAPM graph as to whether an valid audio stream path exists for
+ * the initial widget specified by name. This takes into accounts/initial widget/stream/
Quoted 9 lines
sound/soc/soc-dapm.c +9
-0+/* 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 (strstr (w->sname, stream_name)) + goto found; + }
Quoted 8 lines
sound/soc/soc-dapm.c static int is_connected_input_ep(struct snd_soc_dapm_widget *widget) · line 856
Quoted 1 line
sound/soc/soc-dapm.c +1
-0+dev_err (dapm->dev,"root widget for %s not found\n" , stream_name);Hrm, this will only check the widgets connected to the first widget it sees for an AIF. For streams with multiple widgets connected (eg, left and right channel) it's only going to see things on the first widget it comes across which probably isn't what we were expecting. Unless we change to match the comment and query by widget name in which case we're already requiring uniqueness.
Yes, but I cant think of any single channel AIFs atm, unless Wolfson has some ?
Liam
Quoted 10 lines · Liam Girdwood
Quoted 6 lines · Mark Brown
Hrm, this will only check the widgets connected to the first widget it sees for an AIF. For streams with multiple widgets connected (eg, left and right channel) it's only going to see things on the first widget it comes across which probably isn't what we were expecting. Unless we change to match the comment and query by widget name in which case we're already requiring uniqueness.
Yes, but I cant think of any single channel AIFs atm, unless Wolfson has some ?
Some of the older devices have mono voice AIFs but nothing current. I do think working by stream name is better.