All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Mark Brown <broonie@kernel.org>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>
Subject: [PATCH 2/6] ASoC: audio-graph-card2.c: make Codec2Codec settings optional
Date: Fri, 1 Jul 2022 05:18:21 +0000	[thread overview]
Message-ID: <87fsjls95u.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87ilohs96p.wl-kuninori.morimoto.gx@renesas.com>

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Current audio-graph-card2 can use Codec2Codec, and having its
original parameter (= rate) on DT is mandatory for now.

But simple-card-utils.c has asoc_simple_init_for_codec2codec() to
setup *default* Codec2Codec settings.

This patch makes Audio Graph Card2 Codec2Codec rate settings
optional.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 .../audio-graph-card2-custom-sample.dtsi      |  3 +-
 sound/soc/generic/audio-graph-card2.c         | 36 +++++++++++--------
 2 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/sound/soc/generic/audio-graph-card2-custom-sample.dtsi b/sound/soc/generic/audio-graph-card2-custom-sample.dtsi
index 8eee7b821ff7..053d987a1fec 100644
--- a/sound/soc/generic/audio-graph-card2-custom-sample.dtsi
+++ b/sound/soc/generic/audio-graph-card2-custom-sample.dtsi
@@ -154,11 +154,12 @@ ports@1 {
 
 		codec2codec {
 			ports@0 {
-				rate = <48000>;
+				/* use default settings */
 			c2c:	port@0 { c2cf_ep: endpoint { remote-endpoint = <&codec6_ep>; }; };
 				port@1 { c2cb_ep: endpoint { remote-endpoint = <&codec7_ep>; }; };
 			};
 			ports@1 {
+				/* use original settings */
 				rate = <48000>;
 			c2c_m:	port@0 { c2cmf_ep: endpoint { remote-endpoint = <&mc2c0_ep>; }; };
 				port@1 { c2cmb_ep: endpoint { remote-endpoint = <&mc2c1_ep>; }; };
diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c
index 8e0628e6f2a0..510058c47a92 100644
--- a/sound/soc/generic/audio-graph-card2.c
+++ b/sound/soc/generic/audio-graph-card2.c
@@ -851,8 +851,6 @@ int audio_graph2_link_c2c(struct asoc_simple_priv *priv,
 			  struct link_info *li)
 {
 	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 snd_soc_pcm_stream *c2c_conf = dai_props->c2c_conf;
 	struct device_node *port0, *port1, *ports;
 	struct device_node *codec0_port, *codec1_port;
 	struct device_node *ep0, *ep1;
@@ -880,21 +878,30 @@ int audio_graph2_link_c2c(struct asoc_simple_priv *priv,
 	ports = of_get_parent(port0);
 	port1 = of_get_next_child(ports, lnk);
 
+	/*
+	 * Card2 can use original Codec2Codec settings if DT has.
+	 * It will use default settings if no settings on DT.
+	 * see
+	 *	asoc_simple_init_for_codec2codec()
+	 *
+	 * Add more settings here if needed
+	 */
 	of_property_read_u32(ports, "rate", &val);
-	if (!val) {
-		struct device *dev = simple_priv_to_dev(priv);
-
-		dev_err(dev, "Codec2Codec needs rate settings\n");
-		goto err1;
+	if (val) {
+		struct simple_dai_props *dai_props = simple_priv_to_props(priv, li->link);
+		struct snd_soc_pcm_stream *c2c_conf = dai_props->c2c_conf;
+
+		c2c_conf->formats	= SNDRV_PCM_FMTBIT_S32_LE; /* update ME */
+		c2c_conf->rates		= SNDRV_PCM_RATE_8000_384000;
+		c2c_conf->rate_min	=
+		c2c_conf->rate_max	= val;
+		c2c_conf->channels_min	=
+		c2c_conf->channels_max	= 2; /* update ME */
+
+		dai_link->params	= c2c_conf;
+		dai_link->num_params	= 1;
 	}
 
-	c2c_conf->formats	= SNDRV_PCM_FMTBIT_S32_LE; /* update ME */
-	c2c_conf->rate_min	=
-	c2c_conf->rate_max	= val;
-	c2c_conf->channels_min	=
-	c2c_conf->channels_max	= 2; /* update ME */
-	dai_link->params	= c2c_conf;
-
 	ep0 = port_to_endpoint(port0);
 	ep1 = port_to_endpoint(port1);
 
@@ -923,7 +930,6 @@ int audio_graph2_link_c2c(struct asoc_simple_priv *priv,
 	of_node_put(ep1);
 	of_node_put(codec0_port);
 	of_node_put(codec1_port);
-err1:
 	of_node_put(ports);
 	of_node_put(port0);
 	of_node_put(port1);
-- 
2.25.1


  parent reply	other threads:[~2022-07-01  5:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-01  5:17 [PATCH 0/6] ASoC: audio-graph-card2.c: make Codec2Codec settings optional Kuninori Morimoto
2022-07-01  5:18 ` [PATCH 1/6] ASoC: audio-graph-card2.c: use of_property_read_u32() for rate Kuninori Morimoto
2022-07-01  5:18 ` Kuninori Morimoto [this message]
2022-07-01  5:18 ` [PATCH 3/6] ASoC: audio-graph-card2.c: remove pre-alloced Codec2Codec space Kuninori Morimoto
2022-07-01  5:18 ` [PATCH 4/6] ASoC: audio-graph-card2-custom-sample.dtsi: add verbose explanation Kuninori Morimoto
2022-07-01  5:18 ` [PATCH 5/6] ASoC: simple-card-utils.c: ignore Codec2Codec setting if it already have Kuninori Morimoto
2022-07-01  5:18 ` [PATCH 6/6] ASoC: simple-card-utils.c: care Codec2Codec vs DPCM:BE Kuninori Morimoto
2022-07-08 20:47 ` [PATCH 0/6] ASoC: audio-graph-card2.c: make Codec2Codec settings optional 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=87fsjls95u.wl-kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.