Skip to contentSkip to conversation

Audio Graph Updates

PATCH In review Sameer Pujar 3 participants 11 messages Nov 2, 2020 – Nov 10, 2020

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

v5 cover Audio Graph Updates

This series is a prepraration for using generic graph driver for Tegra210 audio. Tegra audio graph series will be sent in a separate series because it has some dependency over other series for documentation work. This series can focus on the generic ASoC driver updates. Below are the summary of changes done.

* Support multiple instances of a component. For example there can be multiple I2S devices which can use the same component driver.

* Support open platforms with empty Codec endpoint. Customers can plug their own HW and can populate codec endpoint.

* In a component model there can be many components which can be connected together. In such cases Identify no-pcm DPCM DAI links which can be used in BE<->BE connections.

* Expose structures or helpers to be re-used by other similar graph drivers.

The series is based on following references where DPCM usgae for Tegra Audio and simple-card driver proposal were discussed.

* https://lkml.org/lkml/2020/4/30/519 (DPCM for Tegra)
* https://lkml.org/lkml/2020/6/27/4 (simple-card driver)

Changelog
=========

v4 -> v5
--------
* No changes in the core/audio-graph driver patches which are part of the current series.
* Dropped Tegra audio patches and doc patches. This will be sent separately once the doc depdendencies are resolved.

v3 -> v4
--------
* Added new patches to convert graph.txt and audio-graph-card.txt to corresponding json-schema files. Later these references are used in Tegra audio graph schema.

* AHUB component binding docs are updated to reflect the usage of ports/port/endpoint

* More common stuff is moved into graph_parse_of() and this is used by both generic and Tegra audio graph.

* DT binding for Tegra audio graph is updated to included "ports { }"

* As per the suggestion 'void *data' member is dropped from 'asoc_simple_priv' and instead container method is used to maintain required custom data internal to Tegra audio graph.

v2 -> v3
--------
* Dropped new compatible addition in generic graph driver after reviewing it with Morimoto-san. Instead added Tegra audio graph driver and new compatibles are added in the same.
* Added new patches to expose new members for customization in audio graph driver.
* Added new patch for Tegra audio graph driver and related documentation.
* Minor change in below commit where mutex version of helper is used "ASoC: audio-graph: Identify 'no_pcm' DAI links for DPCM"
* DT binding is updated to use the newly exposed compatibles
* No changes in other patches

v1 -> v2
--------
* Re-organized ports/endpoints description for ADMAIF and XBAR. Updated DT patches accordingly.
* After above change, multiple Codec endpoint support is not required and hence dropped for now. This will be considered separately if at all required in future.
* Re-ordered patches in the series.

Sameer Pujar (7):
ASoC: soc-core: Fix component name_prefix parsing
ASoC: soc-pcm: Get all BEs along DAPM path
ASoC: audio-graph: Use of_node and DAI for DPCM DAI link names
ASoC: audio-graph: Identify 'no_pcm' DAI links for DPCM
ASoC: audio-graph: Support empty Codec endpoint
ASoC: audio-graph: Expose new members for asoc_simple_priv
ASoC: audio-graph: Expose helpers from audio graph

 include/sound/graph_card.h           |  16 ++++
 include/sound/simple_card_utils.h    |   3 +
 include/sound/soc.h                  |   1 +
 sound/soc/generic/audio-graph-card.c | 175 ++++++++++++++++++++++++-----------
 sound/soc/soc-core.c                 |   3 +-
 sound/soc/soc-pcm.c                  |   3 +-
 6 files changed, 143 insertions(+), 58 deletions(-)
 create mode 100644 include/sound/graph_card.h
Signature · 1 line
2.7.4
#1 lore raw

PATCH v5 1/7 ASoC: soc-core: Fix component name_prefix parsing

The "prefix" can be defined in DAI link node or it can be specified as part of the component node itself. Currently "sound-name-prefix" defined in a component is not taking effect. Actually the property is not getting parsed. It can be fixed by parsing "sound-name-prefix" property whenever "prefix" is missing in DAI link Codec node.

---
 sound/soc/soc-core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/soc-core.c +2 -1
index 05a085f..9b3eaec 100644
@@ -1124,7 +1124,8 @@ static void soc_set_name_prefix(struct snd_soc_card *card,
 	for (i = 0; i < card->num_configs; i++) {
 		struct snd_soc_codec_conf *map = &card->codec_conf[i];
 
-		if (snd_soc_is_matching_component(&map->dlc, component)) {
+		if (snd_soc_is_matching_component(&map->dlc, component) &&
+		    map->name_prefix) {
 			component->name_prefix = map->name_prefix;
 			return;
 		}
Signature · 1 line
2.7.4
#2 lore raw

PATCH v5 2/7 ASoC: soc-pcm: Get all BEs along DAPM path

In reply to Sameer Pujar

dpcm_end_walk_at_be() stops the graph walk when first BE is found for the given FE component. In a component model we may want to connect multiple DAIs from different components. A new flag is introduced in 'snd_soc_card', which when set allows DAI/component chaining. Later PCM operations can be called for all these listed components for a valid DAPM path.

---
 include/sound/soc.h | 1 +
 sound/soc/soc-pcm.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
include/sound/soc.h +1 -0
index 5ac578c..4a9958b 100644
@@ -1084,6 +1084,7 @@ struct snd_soc_card {
 	unsigned int fully_routed:1;
 	unsigned int disable_route_checks:1;
 	unsigned int probed:1;
+	unsigned int component_chaining:1;
 
 	void *drvdata;
 };
sound/soc/soc-pcm.c +2 -1
index 17ff3a3..51d98ff5 100644
@@ -1259,7 +1259,8 @@ int dpcm_path_get(struct snd_soc_pcm_runtime *fe,
 
 	/* get number of valid DAI paths and their widgets */
 	paths = snd_soc_dapm_dai_get_connected_widgets(cpu_dai, stream, list,
-			dpcm_end_walk_at_be);
+			fe->card->component_chaining ?
+				NULL : dpcm_end_walk_at_be);
 
 	dev_dbg(fe->dev, "ASoC: found %d audio %s paths\n", paths,
 			stream ? "capture" : "playback");
Signature · 1 line
2.7.4
#3 lore raw

PATCH v5 3/7 ASoC: audio-graph: Use of_node and DAI for DPCM DAI link names

In reply to Sameer Pujar

For multiple instances of components, using DAI name alone for DAI links is causing conflicts. Components can define multiple DAIs and hence using just a device name won't help either. Thus DT device node reference and DAI names are used to uniquely represent DAI link names.

---
 sound/soc/generic/audio-graph-card.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
sound/soc/generic/audio-graph-card.c +4 -2
index 97b4f54..1e20562 100644
@@ -253,7 +253,8 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 			goto out_put_node;
 
 		ret = asoc_simple_set_dailink_name(dev, dai_link,
-						   "fe.%s",
+						   "fe.%pOFP.%s",
+						   cpus->of_node,
 						   cpus->dai_name);
 		if (ret < 0)
 			goto out_put_node;
@@ -287,7 +288,8 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 			goto out_put_node;
 
 		ret = asoc_simple_set_dailink_name(dev, dai_link,
-						   "be.%s",
+						   "be.%pOFP.%s",
+						   codecs->of_node,
 						   codecs->dai_name);
 		if (ret < 0)
 			goto out_put_node;
Signature · 1 line
2.7.4
#4 lore raw

PATCH v5 4/7 ASoC: audio-graph: Identify 'no_pcm' DAI links for DPCM

In reply to Sameer Pujar

PCM devices are created for FE dai links with 'no-pcm' flag as '0'. Such DAI links have CPU component which implement either pcm_construct() or pcm_new() at component or dai level respectively. Based on this, current patch exposes a helper function to identify such components and populate 'no_pcm' flag for DPCM DAI link.

This helps to have BE<->BE component links where PCM devices need not be created for CPU component involved in such links.

Cc Kuninori Morimoto <[email protected]>
---
 sound/soc/generic/audio-graph-card.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
sound/soc/generic/audio-graph-card.c +25 -0
index 1e20562..9b06841 100644
@@ -111,6 +111,17 @@ static int graph_get_dai_id(struct device_node *ep)
 	return id;
 }
 
+static bool soc_component_is_pcm(struct snd_soc_dai_link_component *dlc)
+{
+	struct snd_soc_dai *dai = snd_soc_find_dai_with_mutex(dlc);
+
+	if (dai && (dai->component->driver->pcm_construct ||
+		    dai->driver->pcm_new))
+		return true;
+
+	return false;
+}
+
 static int asoc_simple_parse_dai(struct device_node *ep,
 				 struct snd_soc_dai_link_component *dlc,
 				 int *is_single_link)
@@ -205,6 +216,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 				  int dup_codec)
 {
 	struct device *dev = simple_priv_to_dev(priv);
+	struct snd_soc_card *card = simple_priv_to_card(priv);
 	struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link);
 	struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link);
 	struct device_node *top = dev->of_node;
@@ -259,6 +271,19 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 		if (ret < 0)
 			goto out_put_node;
 
+		/*
+		 * In BE<->BE connections it is not required to create
+		 * PCM devices at CPU end of the dai link and thus 'no_pcm'
+		 * flag needs to be set. It is useful when there are many
+		 * BE components and some of these have to be connected to
+		 * form a valid audio path.
+		 *
+		 * For example: FE <-> BE1 <-> BE2 <-> ... <-> BEn where
+		 * there are 'n' BE components in the path.
+		 */
+		if (card->component_chaining && !soc_component_is_pcm(cpus))
+			dai_link->no_pcm = 1;
+
 		/* card->num_links includes Codec */
 		asoc_simple_canonicalize_cpu(dai_link, is_single_links);
 	} else {
Signature · 1 line
2.7.4
#5 lore raw

PATCH v5 5/7 ASoC: audio-graph: Support empty Codec endpoint

In reply to Sameer Pujar

For open platforms, which can support pluggable audio cards, Codec endpoint is not fixed always. It actually depends on the compatible HW module that is going to be connected. From SoC side the given I/O interface is always available. Hence such links have fixed CPU endpoint but no Codec endpoint. This patch helps to support such links where user can populate Codec endpoint only and its fields in Platform DT depending on the plugged HW.

Cc Kuninori Morimoto <[email protected]>
---
 sound/soc/generic/audio-graph-card.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
sound/soc/generic/audio-graph-card.c +9 -1
index 9b06841..0ba50be9 100644
@@ -229,6 +229,14 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 	struct snd_soc_dai_link_component *codecs = dai_link->codecs;
 	int ret;
 
+	/*
+	 * Codec endpoint can be NULL for pluggable audio HW.
+	 * Platform DT can populate the Codec endpoint depending on the
+	 * plugged HW.
+	 */
+	if (!li->cpu && !codec_ep)
+		return 0;
+
 	/* Do it all CPU endpoint, and 1st Codec endpoint */
 	if (!li->cpu && dup_codec)
 		return 0;
@@ -565,7 +573,7 @@ static int graph_count_dpcm(struct asoc_simple_priv *priv,
 	li->link++; /* 1xCPU-dummy */
 	li->dais++; /* 1xCPU */
 
-	if (!dup_codec) {
+	if (!dup_codec && codec_ep) {
 		li->link++; /* 1xdummy-Codec */
 		li->conf++; /* 1xdummy-Codec */
 		li->dais++; /* 1xCodec */
Signature · 1 line
2.7.4
#6 lore raw

PATCH v5 6/7 ASoC: audio-graph: Expose new members for asoc_simple_priv

In reply to Sameer Pujar

Add new members in struct 'asoc_simple_priv'. Idea is to leverage simple or graph card driver as much as possible and vendor can maintain a thin driver to control the behavior by populating these newly exposed members.

Following are the members added in 'asoc_simple_priv':

- 'ops' struct: In some cases SoC vendor drivers may want to implement 'snd_soc_ops' callbacks differently. In such cases custom callbacks would be used.

- 'force_dpcm' flag: Right now simple or graph card drivers detect DAI links as DPCM links if:

* The dpcm_selectable is set AND
* Codec is connected to multiple CPU endpoints or aconvert property is used for rate/channels.

So there is no way to directly specify usage of DPCM alone. So a flag is exposed to mark all links as DPCM. Vendor driver can set this if required.

- 'dpcm_selectable': Currently simple or audio graph drivers provide a way to enable this for specific compatibles. However vendor driver may want to define some additional info. Thus expose this variable where vendor drivers can set this if required.

Audio graph driver is updated to consider above flags or callbacks. Subsequent patches in the series illustrate usage for above.

Cc Kuninori Morimoto <[email protected]>
---
 include/sound/simple_card_utils.h    |  3 +++
 sound/soc/generic/audio-graph-card.c | 41 ++++++++++++++++++++++++++++--------
 2 files changed, 35 insertions(+), 9 deletions(-)
include/sound/simple_card_utils.h +3 -0
index 86a1e95..ba4a3e1 100644
@@ -56,6 +56,9 @@ struct asoc_simple_priv {
 	struct asoc_simple_dai *dais;
 	struct snd_soc_codec_conf *codec_conf;
 	struct gpio_desc *pa_gpio;
+	const struct snd_soc_ops *ops;
+	unsigned int dpcm_selectable:1;
+	unsigned int force_dpcm:1;
 };
 #define simple_priv_to_card(priv)	(&(priv)->snd_card)
 #define simple_priv_to_props(priv, i)	((priv)->dai_props + (i))
sound/soc/generic/audio-graph-card.c +32 -9

71 lines not on this page · raw message

Signature · 1 line
2.7.4
#7 lore raw

PATCH v5 7/7 ASoC: audio-graph: Expose helpers from audio graph

In reply to Sameer Pujar

This commit exposes following functions which can be used by a sound card driver based on generic audio graph driver. Idea is vendors can have a thin driver and re-use common stuff from audio graph driver.

- graph_card_probe()
- graph_parse_of()

In doing so a new header file is added for above. The graph_probe() function is simplified by moving more common stuff to graph_parse_of().

Cc Kuninori Morimoto <[email protected]>
---
 include/sound/graph_card.h           | 16 ++++++
 sound/soc/generic/audio-graph-card.c | 95 +++++++++++++++++++-----------------
 2 files changed, 66 insertions(+), 45 deletions(-)
 create mode 100644 include/sound/graph_card.h
include/sound/graph_card.h new file +16 -0
new file mode 100644
index 0000000..bbb5a13
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * ASoC audio graph card support
+ *
+ */
+
+#ifndef __GRAPH_CARD_H
+#define __GRAPH_CARD_H
+
+#include <sound/simple_card_utils.h>
+
+int graph_card_probe(struct snd_soc_card *card);
+
+int graph_parse_of(struct asoc_simple_priv *priv, struct device *dev);
+
+#endif /* __GRAPH_CARD_H */
sound/soc/generic/audio-graph-card.c +50 -45

151 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#8 lore raw
In reply to Sameer Pujar
Quoted 5 lines · Sameer Pujar

This series is a prepraration for using generic graph driver for Tegra210 audio. Tegra audio graph series will be sent in a separate series because it has some dependency over other series for documentation work. This series can focus on the generic ASoC driver updates. Below are the summary of changes done.

Morimoto-san, are you OK with these?

maintainer Acked-by
#9 lore raw

Hi Mark

Quoted 7 lines
Quoted 5 lines

This series is a prepraration for using generic graph driver for Tegra210 audio. Tegra audio graph series will be sent in a separate series because it has some dependency over other series for documentation work. This series can focus on the generic ASoC driver updates. Below are the summary of changes done.

Morimoto-san, are you OK with these?

Yes. For audio-graph part

Thank you for your help !!

Best regards
---
Kuninori Morimoto

maintainer
#10 lore raw
In reply to Sameer Pujar
Quoted 10 lines · Sameer Pujar

This series is a prepraration for using generic graph driver for Tegra210 audio. Tegra audio graph series will be sent in a separate series because it has some dependency over other series for documentation work. This series can focus on the generic ASoC driver updates. Below are the summary of changes done.

* Support multiple instances of a component. For example there can be multiple I2S devices which can use the same component driver.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/7] ASoC: soc-core: Fix component name_prefix parsing

      commit: 3256ef984b016fc8491f34cad594168b4b500317
[2/7] ASoC: soc-pcm: Get all BEs along DAPM path
      commit: aa293777bfeb75fb8872565ef99cc0e8b98b5c7d
[3/7] ASoC: audio-graph: Use of_node and DAI for DPCM DAI link names
      commit: e6aeb375d25dba56c4089b1d6aa0a77fe218ef3b
[4/7] ASoC: audio-graph: Identify 'no_pcm' DAI links for DPCM
      commit: c21cbb526c0a105d582299839a9c4244dd6bf38a
[5/7] ASoC: audio-graph: Support empty Codec endpoint
      commit: 930dd47d74023e7c94a7c256279e12924c14475d
[6/7] ASoC: audio-graph: Expose new members for asoc_simple_priv
      commit: d09c774f2f9ff25817866b70f1fb9603e5196971
[7/7] ASoC: audio-graph: Expose helpers from audio graph
      commit: e32b100bc6ecbc390aae728fc7d2a3e247faa8a7

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark