linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/7] Audio Graph Updates
@ 2020-11-02 15:10 Sameer Pujar
  2020-11-02 15:10 ` [PATCH v5 1/7] ASoC: soc-core: Fix component name_prefix parsing Sameer Pujar
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Sameer Pujar @ 2020-11-02 15:10 UTC (permalink / raw)
  To: broonie, lgirdwood, kuninori.morimoto.gx, pierre-louis.bossart,
	perex, tiwai
  Cc: thierry.reding, jonathanh, alsa-devel, linux-tegra, linux-kernel,
	sharadg, 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.

 * 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

-- 
2.7.4


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v5 1/7] ASoC: soc-core: Fix component name_prefix parsing
  2020-11-02 15:10 [PATCH v5 0/7] Audio Graph Updates Sameer Pujar
@ 2020-11-02 15:10 ` Sameer Pujar
  2020-11-02 15:10 ` [PATCH v5 2/7] ASoC: soc-pcm: Get all BEs along DAPM path Sameer Pujar
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Sameer Pujar @ 2020-11-02 15:10 UTC (permalink / raw)
  To: broonie, lgirdwood, kuninori.morimoto.gx, pierre-louis.bossart,
	perex, tiwai
  Cc: thierry.reding, jonathanh, alsa-devel, linux-tegra, linux-kernel,
	sharadg, Sameer Pujar

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.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
---
 sound/soc/soc-core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 05a085f..9b3eaec 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -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;
 		}
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v5 2/7] ASoC: soc-pcm: Get all BEs along DAPM path
  2020-11-02 15:10 [PATCH v5 0/7] Audio Graph Updates Sameer Pujar
  2020-11-02 15:10 ` [PATCH v5 1/7] ASoC: soc-core: Fix component name_prefix parsing Sameer Pujar
@ 2020-11-02 15:10 ` Sameer Pujar
  2020-11-02 15:10 ` [PATCH v5 3/7] ASoC: audio-graph: Use of_node and DAI for DPCM DAI link names Sameer Pujar
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Sameer Pujar @ 2020-11-02 15:10 UTC (permalink / raw)
  To: broonie, lgirdwood, kuninori.morimoto.gx, pierre-louis.bossart,
	perex, tiwai
  Cc: thierry.reding, jonathanh, alsa-devel, linux-tegra, linux-kernel,
	sharadg, 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.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
---
 include/sound/soc.h | 1 +
 sound/soc/soc-pcm.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 5ac578c..4a9958b 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -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;
 };
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 17ff3a3..51d98ff5 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -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");
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v5 3/7] ASoC: audio-graph: Use of_node and DAI for DPCM DAI link names
  2020-11-02 15:10 [PATCH v5 0/7] Audio Graph Updates Sameer Pujar
  2020-11-02 15:10 ` [PATCH v5 1/7] ASoC: soc-core: Fix component name_prefix parsing Sameer Pujar
  2020-11-02 15:10 ` [PATCH v5 2/7] ASoC: soc-pcm: Get all BEs along DAPM path Sameer Pujar
@ 2020-11-02 15:10 ` Sameer Pujar
  2020-11-02 15:10 ` [PATCH v5 4/7] ASoC: audio-graph: Identify 'no_pcm' DAI links for DPCM Sameer Pujar
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Sameer Pujar @ 2020-11-02 15:10 UTC (permalink / raw)
  To: broonie, lgirdwood, kuninori.morimoto.gx, pierre-louis.bossart,
	perex, tiwai
  Cc: thierry.reding, jonathanh, alsa-devel, linux-tegra, linux-kernel,
	sharadg, 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.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/audio-graph-card.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
index 97b4f54..1e20562 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -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;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v5 4/7] ASoC: audio-graph: Identify 'no_pcm' DAI links for DPCM
  2020-11-02 15:10 [PATCH v5 0/7] Audio Graph Updates Sameer Pujar
                   ` (2 preceding siblings ...)
  2020-11-02 15:10 ` [PATCH v5 3/7] ASoC: audio-graph: Use of_node and DAI for DPCM DAI link names Sameer Pujar
@ 2020-11-02 15:10 ` Sameer Pujar
  2020-11-02 15:10 ` [PATCH v5 5/7] ASoC: audio-graph: Support empty Codec endpoint Sameer Pujar
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Sameer Pujar @ 2020-11-02 15:10 UTC (permalink / raw)
  To: broonie, lgirdwood, kuninori.morimoto.gx, pierre-louis.bossart,
	perex, tiwai
  Cc: thierry.reding, jonathanh, alsa-devel, linux-tegra, linux-kernel,
	sharadg, 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.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/audio-graph-card.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
index 1e20562..9b06841 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -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 {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v5 5/7] ASoC: audio-graph: Support empty Codec endpoint
  2020-11-02 15:10 [PATCH v5 0/7] Audio Graph Updates Sameer Pujar
                   ` (3 preceding siblings ...)
  2020-11-02 15:10 ` [PATCH v5 4/7] ASoC: audio-graph: Identify 'no_pcm' DAI links for DPCM Sameer Pujar
@ 2020-11-02 15:10 ` Sameer Pujar
  2020-11-02 15:10 ` [PATCH v5 6/7] ASoC: audio-graph: Expose new members for asoc_simple_priv Sameer Pujar
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Sameer Pujar @ 2020-11-02 15:10 UTC (permalink / raw)
  To: broonie, lgirdwood, kuninori.morimoto.gx, pierre-louis.bossart,
	perex, tiwai
  Cc: thierry.reding, jonathanh, alsa-devel, linux-tegra, linux-kernel,
	sharadg, 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.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/audio-graph-card.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
index 9b06841..0ba50be9 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -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 */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v5 6/7] ASoC: audio-graph: Expose new members for asoc_simple_priv
  2020-11-02 15:10 [PATCH v5 0/7] Audio Graph Updates Sameer Pujar
                   ` (4 preceding siblings ...)
  2020-11-02 15:10 ` [PATCH v5 5/7] ASoC: audio-graph: Support empty Codec endpoint Sameer Pujar
@ 2020-11-02 15:10 ` Sameer Pujar
  2020-11-02 15:10 ` [PATCH v5 7/7] ASoC: audio-graph: Expose helpers from audio graph Sameer Pujar
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Sameer Pujar @ 2020-11-02 15:10 UTC (permalink / raw)
  To: broonie, lgirdwood, kuninori.morimoto.gx, pierre-louis.bossart,
	perex, tiwai
  Cc: thierry.reding, jonathanh, alsa-devel, linux-tegra, linux-kernel,
	sharadg, 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.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/simple_card_utils.h    |  3 +++
 sound/soc/generic/audio-graph-card.c | 41 ++++++++++++++++++++++++++++--------
 2 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index 86a1e95..ba4a3e1 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -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))
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
index 0ba50be9..4db9c0e 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -355,6 +355,11 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 	snd_soc_dai_link_set_capabilities(dai_link);
 
 	dai_link->ops			= &graph_ops;
+
+	/* Use custom snd_soc_ops callbacks if available */
+	if (priv->ops)
+		dai_link->ops = priv->ops;
+
 	dai_link->init			= asoc_simple_dai_init;
 
 out_put_node:
@@ -439,6 +444,28 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv,
 	return 0;
 }
 
+static inline bool parse_as_dpcm_link(struct asoc_simple_priv *priv,
+				      struct device_node *codec_port,
+				      struct asoc_simple_data *adata)
+{
+	if (priv->force_dpcm)
+		return true;
+
+	if (!priv->dpcm_selectable)
+		return false;
+
+	/*
+	 * It is DPCM
+	 * if Codec port has many endpoints,
+	 * or has convert-xxx property
+	 */
+	if ((of_get_child_count(codec_port) > 1) ||
+	    (adata->convert_rate || adata->convert_channels))
+		return true;
+
+	return false;
+}
+
 static int graph_for_each_link(struct asoc_simple_priv *priv,
 			struct link_info *li,
 			int (*func_noml)(struct asoc_simple_priv *priv,
@@ -459,7 +486,6 @@ static int graph_for_each_link(struct asoc_simple_priv *priv,
 	struct device_node *codec_port;
 	struct device_node *codec_port_old = NULL;
 	struct asoc_simple_data adata;
-	uintptr_t dpcm_selectable = (uintptr_t)of_device_get_match_data(dev);
 	int rc, ret;
 
 	/* loop for all listed CPU port */
@@ -482,14 +508,8 @@ static int graph_for_each_link(struct asoc_simple_priv *priv,
 			graph_parse_convert(dev, codec_ep, &adata);
 			graph_parse_convert(dev, cpu_ep,   &adata);
 
-			/*
-			 * It is DPCM
-			 * if Codec port has many endpoints,
-			 * or has convert-xxx property
-			 */
-			if (dpcm_selectable &&
-			    ((of_get_child_count(codec_port) > 1) ||
-			     adata.convert_rate || adata.convert_channels))
+			/* check if link requires DPCM parsing */
+			if (parse_as_dpcm_link(priv, codec_port, &adata))
 				ret = func_dpcm(priv, cpu_ep, codec_ep, li,
 						(codec_port_old == codec_port));
 			/* else normal sound */
@@ -678,6 +698,9 @@ static int graph_probe(struct platform_device *pdev)
 	card->num_dapm_widgets	= ARRAY_SIZE(graph_dapm_widgets);
 	card->probe		= graph_card_probe;
 
+	if (of_device_get_match_data(dev))
+		priv->dpcm_selectable = 1;
+
 	memset(&li, 0, sizeof(li));
 	graph_get_dais_count(priv, &li);
 	if (!li.link || !li.dais)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v5 7/7] ASoC: audio-graph: Expose helpers from audio graph
  2020-11-02 15:10 [PATCH v5 0/7] Audio Graph Updates Sameer Pujar
                   ` (5 preceding siblings ...)
  2020-11-02 15:10 ` [PATCH v5 6/7] ASoC: audio-graph: Expose new members for asoc_simple_priv Sameer Pujar
@ 2020-11-02 15:10 ` Sameer Pujar
  2020-11-09 20:30 ` [PATCH v5 0/7] Audio Graph Updates Mark Brown
  2020-11-10 21:38 ` Mark Brown
  8 siblings, 0 replies; 11+ messages in thread
From: Sameer Pujar @ 2020-11-02 15:10 UTC (permalink / raw)
  To: broonie, lgirdwood, kuninori.morimoto.gx, pierre-louis.bossart,
	perex, tiwai
  Cc: thierry.reding, jonathanh, alsa-devel, linux-tegra, linux-kernel,
	sharadg, 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().

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 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

diff --git a/include/sound/graph_card.h b/include/sound/graph_card.h
new file mode 100644
index 0000000..bbb5a13
--- /dev/null
+++ b/include/sound/graph_card.h
@@ -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 */
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
index 4db9c0e..16a04a6 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -18,7 +18,7 @@
 #include <linux/of_graph.h>
 #include <linux/platform_device.h>
 #include <linux/string.h>
-#include <sound/simple_card_utils.h>
+#include <sound/graph_card.h>
 
 #define DPCM_SELECTABLE 1
 
@@ -529,12 +529,34 @@ static int graph_for_each_link(struct asoc_simple_priv *priv,
 	return 0;
 }
 
-static int graph_parse_of(struct asoc_simple_priv *priv)
+static void graph_get_dais_count(struct asoc_simple_priv *priv,
+				 struct link_info *li);
+
+int graph_parse_of(struct asoc_simple_priv *priv, struct device *dev)
 {
 	struct snd_soc_card *card = simple_priv_to_card(priv);
 	struct link_info li;
 	int ret;
 
+	card->owner = THIS_MODULE;
+	card->dev = dev;
+
+	memset(&li, 0, sizeof(li));
+	graph_get_dais_count(priv, &li);
+	if (!li.link || !li.dais)
+		return -EINVAL;
+
+	ret = asoc_simple_init_priv(priv, &li);
+	if (ret < 0)
+		return ret;
+
+	priv->pa_gpio = devm_gpiod_get_optional(dev, "pa", GPIOD_OUT_LOW);
+	if (IS_ERR(priv->pa_gpio)) {
+		ret = PTR_ERR(priv->pa_gpio);
+		dev_err(dev, "failed to get amplifier gpio: %d\n", ret);
+		return ret;
+	}
+
 	ret = asoc_simple_parse_widgets(card, NULL);
 	if (ret < 0)
 		return ret;
@@ -561,11 +583,32 @@ static int graph_parse_of(struct asoc_simple_priv *priv)
 					  graph_dai_link_of,
 					  graph_dai_link_of_dpcm);
 		if (ret < 0)
-			return ret;
+			goto err;
 	}
 
-	return asoc_simple_parse_card_name(card, NULL);
+	ret = asoc_simple_parse_card_name(card, NULL);
+	if (ret < 0)
+		goto err;
+
+	snd_soc_card_set_drvdata(card, priv);
+
+	asoc_simple_debug_info(priv);
+
+	ret = devm_snd_soc_register_card(dev, card);
+	if (ret < 0)
+		goto err;
+
+	return 0;
+
+err:
+	asoc_simple_clean_reference(card);
+
+	if (ret != -EPROBE_DEFER)
+		dev_err(dev, "parse error %d\n", ret);
+
+	return ret;
 }
+EXPORT_SYMBOL_GPL(graph_parse_of);
 
 static int graph_count_noml(struct asoc_simple_priv *priv,
 			    struct device_node *cpu_ep,
@@ -662,7 +705,7 @@ static void graph_get_dais_count(struct asoc_simple_priv *priv,
 		li->link, li->dais, li->conf);
 }
 
-static int graph_card_probe(struct snd_soc_card *card)
+int graph_card_probe(struct snd_soc_card *card)
 {
 	struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(card);
 	int ret;
@@ -677,14 +720,13 @@ static int graph_card_probe(struct snd_soc_card *card)
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(graph_card_probe);
 
 static int graph_probe(struct platform_device *pdev)
 {
 	struct asoc_simple_priv *priv;
 	struct device *dev = &pdev->dev;
 	struct snd_soc_card *card;
-	struct link_info li;
-	int ret;
 
 	/* Allocate the private data and the DAI link array */
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -692,8 +734,6 @@ static int graph_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	card = simple_priv_to_card(priv);
-	card->owner		= THIS_MODULE;
-	card->dev		= dev;
 	card->dapm_widgets	= graph_dapm_widgets;
 	card->num_dapm_widgets	= ARRAY_SIZE(graph_dapm_widgets);
 	card->probe		= graph_card_probe;
@@ -701,42 +741,7 @@ static int graph_probe(struct platform_device *pdev)
 	if (of_device_get_match_data(dev))
 		priv->dpcm_selectable = 1;
 
-	memset(&li, 0, sizeof(li));
-	graph_get_dais_count(priv, &li);
-	if (!li.link || !li.dais)
-		return -EINVAL;
-
-	ret = asoc_simple_init_priv(priv, &li);
-	if (ret < 0)
-		return ret;
-
-	priv->pa_gpio = devm_gpiod_get_optional(dev, "pa", GPIOD_OUT_LOW);
-	if (IS_ERR(priv->pa_gpio)) {
-		ret = PTR_ERR(priv->pa_gpio);
-		dev_err(dev, "failed to get amplifier gpio: %d\n", ret);
-		return ret;
-	}
-
-	ret = graph_parse_of(priv);
-	if (ret < 0) {
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "parse error %d\n", ret);
-		goto err;
-	}
-
-	snd_soc_card_set_drvdata(card, priv);
-
-	asoc_simple_debug_info(priv);
-
-	ret = devm_snd_soc_register_card(dev, card);
-	if (ret < 0)
-		goto err;
-
-	return 0;
-err:
-	asoc_simple_clean_reference(card);
-
-	return ret;
+	return graph_parse_of(priv, dev);
 }
 
 static int graph_remove(struct platform_device *pdev)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v5 0/7] Audio Graph Updates
  2020-11-02 15:10 [PATCH v5 0/7] Audio Graph Updates Sameer Pujar
                   ` (6 preceding siblings ...)
  2020-11-02 15:10 ` [PATCH v5 7/7] ASoC: audio-graph: Expose helpers from audio graph Sameer Pujar
@ 2020-11-09 20:30 ` Mark Brown
  2020-11-09 23:19   ` Kuninori Morimoto
  2020-11-10 21:38 ` Mark Brown
  8 siblings, 1 reply; 11+ messages in thread
From: Mark Brown @ 2020-11-09 20:30 UTC (permalink / raw)
  To: Sameer Pujar
  Cc: lgirdwood, kuninori.morimoto.gx, pierre-louis.bossart, perex,
	tiwai, thierry.reding, jonathanh, alsa-devel, linux-tegra,
	linux-kernel, sharadg

[-- Attachment #1: Type: text/plain, Size: 420 bytes --]

On Mon, Nov 02, 2020 at 08:40:07PM +0530, Sameer Pujar wrote:
> 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?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v5 0/7] Audio Graph Updates
  2020-11-09 20:30 ` [PATCH v5 0/7] Audio Graph Updates Mark Brown
@ 2020-11-09 23:19   ` Kuninori Morimoto
  0 siblings, 0 replies; 11+ messages in thread
From: Kuninori Morimoto @ 2020-11-09 23:19 UTC (permalink / raw)
  To: Mark Brown
  Cc: Sameer Pujar, lgirdwood, pierre-louis.bossart, perex, tiwai,
	thierry.reding, jonathanh, alsa-devel, linux-tegra, linux-kernel,
	sharadg


Hi Mark

> > 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

	Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Thank you for your help !!

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v5 0/7] Audio Graph Updates
  2020-11-02 15:10 [PATCH v5 0/7] Audio Graph Updates Sameer Pujar
                   ` (7 preceding siblings ...)
  2020-11-09 20:30 ` [PATCH v5 0/7] Audio Graph Updates Mark Brown
@ 2020-11-10 21:38 ` Mark Brown
  8 siblings, 0 replies; 11+ messages in thread
From: Mark Brown @ 2020-11-10 21:38 UTC (permalink / raw)
  To: tiwai, pierre-louis.bossart, lgirdwood, kuninori.morimoto.gx,
	perex, Sameer Pujar
  Cc: linux-tegra, alsa-devel, thierry.reding, jonathanh, sharadg,
	linux-kernel

On Mon, 2 Nov 2020 20:40:07 +0530, Sameer Pujar wrote:
> 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

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-11-10 21:38 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-02 15:10 [PATCH v5 0/7] Audio Graph Updates Sameer Pujar
2020-11-02 15:10 ` [PATCH v5 1/7] ASoC: soc-core: Fix component name_prefix parsing Sameer Pujar
2020-11-02 15:10 ` [PATCH v5 2/7] ASoC: soc-pcm: Get all BEs along DAPM path Sameer Pujar
2020-11-02 15:10 ` [PATCH v5 3/7] ASoC: audio-graph: Use of_node and DAI for DPCM DAI link names Sameer Pujar
2020-11-02 15:10 ` [PATCH v5 4/7] ASoC: audio-graph: Identify 'no_pcm' DAI links for DPCM Sameer Pujar
2020-11-02 15:10 ` [PATCH v5 5/7] ASoC: audio-graph: Support empty Codec endpoint Sameer Pujar
2020-11-02 15:10 ` [PATCH v5 6/7] ASoC: audio-graph: Expose new members for asoc_simple_priv Sameer Pujar
2020-11-02 15:10 ` [PATCH v5 7/7] ASoC: audio-graph: Expose helpers from audio graph Sameer Pujar
2020-11-09 20:30 ` [PATCH v5 0/7] Audio Graph Updates Mark Brown
2020-11-09 23:19   ` Kuninori Morimoto
2020-11-10 21:38 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).