alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Sameer Pujar <spujar@nvidia.com>
To: <broonie@kernel.org>, <lgirdwood@gmail.com>, <robh+dt@kernel.org>,
	<kuninori.morimoto.gx@renesas.com>,
	<pierre-louis.bossart@linux.intel.com>, <perex@perex.cz>,
	<tiwai@suse.com>, <p.zabel@pengutronix.de>,
	<thierry.reding@gmail.com>, <jonathanh@nvidia.com>
Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
	nicoleotsuka@gmail.com, swarren@nvidia.com,
	Sameer Pujar <spujar@nvidia.com>,
	linux-kernel@vger.kernel.org, atalambedu@nvidia.com,
	viswanathl@nvidia.com, sharadg@nvidia.com, nwartikar@nvidia.com,
	linux-tegra@vger.kernel.org, rlokhande@nvidia.com,
	mkumard@nvidia.com, dramesh@nvidia.com
Subject: [PATCH v4 06/15] ASoC: audio-graph: Expose new members for asoc_simple_priv
Date: Fri, 16 Oct 2020 20:12:53 +0530	[thread overview]
Message-ID: <1602859382-19505-7-git-send-email-spujar@nvidia.com> (raw)
In-Reply-To: <1602859382-19505-1-git-send-email-spujar@nvidia.com>

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


  parent reply	other threads:[~2020-10-16 14:47 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-16 14:42 [PATCH v4 00/15] Audio graph card updates and usage with Tegra210 audio Sameer Pujar
2020-10-16 14:42 ` [PATCH v4 01/15] ASoC: soc-core: Fix component name_prefix parsing Sameer Pujar
2020-10-16 14:42 ` [PATCH v4 02/15] ASoC: soc-pcm: Get all BEs along DAPM path Sameer Pujar
2020-10-16 14:42 ` [PATCH v4 03/15] ASoC: audio-graph: Use of_node and DAI for DPCM DAI link names Sameer Pujar
2020-10-16 14:42 ` [PATCH v4 04/15] ASoC: audio-graph: Identify 'no_pcm' DAI links for DPCM Sameer Pujar
2020-10-16 14:42 ` [PATCH v4 05/15] ASoC: audio-graph: Support empty Codec endpoint Sameer Pujar
2020-10-16 14:42 ` Sameer Pujar [this message]
2020-10-16 14:42 ` [PATCH v4 07/15] ASoC: audio-graph: Expose helpers from audio graph Sameer Pujar
2020-10-16 14:42 ` [PATCH v4 08/15] Documentation: of: Convert graph bindings to json-schema Sameer Pujar
2020-10-19 21:56   ` Rob Herring
2020-10-20  5:34     ` Sameer Pujar
2020-10-20  8:30     ` Philipp Zabel
2020-10-23 13:45       ` Sameer Pujar
2020-10-16 14:42 ` [PATCH v4 09/15] ASoC: dt-bindings: audio-graph: Convert " Sameer Pujar
2020-10-19  2:50   ` Kuninori Morimoto
2020-10-19  4:30     ` Sameer Pujar
2020-10-19  4:41       ` Kuninori Morimoto
2020-10-19 22:11         ` Rob Herring
2020-10-16 14:42 ` [PATCH v4 10/15] ASoC: dt-bindings: tegra: Add graph bindings Sameer Pujar
2020-10-19 22:11   ` Rob Herring
2020-10-20  6:03     ` Sameer Pujar
2020-10-16 14:42 ` [PATCH v4 11/15] ASoC: dt-bindings: tegra: Add json-schema for Tegra audio graph card Sameer Pujar
2020-10-19 22:16   ` Rob Herring
2020-10-20  6:16     ` Sameer Pujar
2020-10-20 13:24       ` Rob Herring
2020-10-16 14:42 ` [PATCH v4 12/15] ASoC: tegra: Add audio graph based card driver Sameer Pujar
2020-10-16 14:43 ` [PATCH v4 13/15] arm64: defconfig: Enable Tegra audio graph " Sameer Pujar
2020-10-16 14:43 ` [PATCH v4 14/15] arm64: tegra: Audio graph header for Tegra210 Sameer Pujar
2020-10-16 14:43 ` [PATCH v4 15/15] arm64: tegra: Audio graph sound card for Jetson Nano and TX1 Sameer Pujar
2020-10-30  6:34 ` [PATCH v4 00/15] Audio graph card updates and usage with Tegra210 audio Sameer Pujar
2020-10-30 13:58   ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1602859382-19505-7-git-send-email-spujar@nvidia.com \
    --to=spujar@nvidia.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=atalambedu@nvidia.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dramesh@nvidia.com \
    --cc=jonathanh@nvidia.com \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mkumard@nvidia.com \
    --cc=nicoleotsuka@gmail.com \
    --cc=nwartikar@nvidia.com \
    --cc=p.zabel@pengutronix.de \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=rlokhande@nvidia.com \
    --cc=robh+dt@kernel.org \
    --cc=sharadg@nvidia.com \
    --cc=swarren@nvidia.com \
    --cc=thierry.reding@gmail.com \
    --cc=tiwai@suse.com \
    --cc=viswanathl@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).