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 01/15] ASoC: rsnd: check whether playback/capture property exists
Date: Wed, 1 Feb 2023 01:59:46 +0000	[thread overview]
Message-ID: <878rhi6t7x.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87a61y6t8e.wl-kuninori.morimoto.gx@renesas.com>

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

Current rsnd sets "channels_min" which is used from
snd_soc_dai_stream_valid() without checking DT playback/capture property.
Thus, "aplay -l" or "arecord -l" will indicate un-exising device.
This patch checks DT proerty and do nothing playback/capture settings if
not exist.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/sh/rcar/core.c | 42 +++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 16 deletions(-)

diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 2d269ac8c137..ca3a0f285092 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -1343,6 +1343,7 @@ static void __rsnd_dai_probe(struct rsnd_priv *priv,
 	struct snd_soc_dai_driver *drv;
 	struct rsnd_dai *rdai;
 	struct device *dev = rsnd_priv_to_dev(priv);
+	int playback_exist = 0, capture_exist = 0;
 	int io_i;
 
 	rdai		= rsnd_rdai_get(priv, dai_i);
@@ -1357,22 +1358,6 @@ static void __rsnd_dai_probe(struct rsnd_priv *priv,
 	drv->ops	= &rsnd_soc_dai_ops;
 	drv->pcm_new	= rsnd_pcm_new;
 
-	snprintf(io_playback->name, RSND_DAI_NAME_SIZE,
-		 "DAI%d Playback", dai_i);
-	drv->playback.rates		= RSND_RATES;
-	drv->playback.formats		= RSND_FMTS;
-	drv->playback.channels_min	= 2;
-	drv->playback.channels_max	= 8;
-	drv->playback.stream_name	= io_playback->name;
-
-	snprintf(io_capture->name, RSND_DAI_NAME_SIZE,
-		 "DAI%d Capture", dai_i);
-	drv->capture.rates		= RSND_RATES;
-	drv->capture.formats		= RSND_FMTS;
-	drv->capture.channels_min	= 2;
-	drv->capture.channels_max	= 8;
-	drv->capture.stream_name	= io_capture->name;
-
 	io_playback->rdai		= rdai;
 	io_capture->rdai		= rdai;
 	rsnd_rdai_channels_set(rdai, 2); /* default 2ch */
@@ -1386,6 +1371,14 @@ static void __rsnd_dai_probe(struct rsnd_priv *priv,
 		if (!playback && !capture)
 			break;
 
+		if (io_i == 0) {
+			/* check whether playback/capture property exists */
+			if (playback)
+				playback_exist = 1;
+			if (capture)
+				capture_exist = 1;
+		}
+
 		rsnd_parse_connect_ssi(rdai, playback, capture);
 		rsnd_parse_connect_ssiu(rdai, playback, capture);
 		rsnd_parse_connect_src(rdai, playback, capture);
@@ -1397,6 +1390,23 @@ static void __rsnd_dai_probe(struct rsnd_priv *priv,
 		of_node_put(capture);
 	}
 
+	if (playback_exist) {
+		snprintf(io_playback->name, RSND_DAI_NAME_SIZE, "DAI%d Playback", dai_i);
+		drv->playback.rates		= RSND_RATES;
+		drv->playback.formats		= RSND_FMTS;
+		drv->playback.channels_min	= 2;
+		drv->playback.channels_max	= 8;
+		drv->playback.stream_name	= io_playback->name;
+	}
+	if (capture_exist) {
+		snprintf(io_capture->name, RSND_DAI_NAME_SIZE, "DAI%d Capture", dai_i);
+		drv->capture.rates		= RSND_RATES;
+		drv->capture.formats		= RSND_FMTS;
+		drv->capture.channels_min	= 2;
+		drv->capture.channels_max	= 8;
+		drv->capture.stream_name	= io_capture->name;
+	}
+
 	if (rsnd_ssi_is_pin_sharing(io_capture) ||
 	    rsnd_ssi_is_pin_sharing(io_playback)) {
 		/* should have symmetric_rate if pin sharing */
-- 
2.25.1


  reply	other threads:[~2023-02-01  2:01 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-01  1:59 [PATCH 00/15] ASoC: rsnd: cleanup add R-Car Gen4 Sound support Kuninori Morimoto
2023-02-01  1:59 ` Kuninori Morimoto [this message]
2023-02-01  1:59 ` [PATCH 02/15] ASoC: rsnd: fixup #endif position Kuninori Morimoto
2023-02-01  1:59 ` [PATCH 03/15] ASoC: rsnd: Remove unnecessary rsnd_dbg_dai_call() Kuninori Morimoto
2023-02-01  2:00 ` [PATCH 04/15] ASoC: rsnd: indicate necessary error when clock start failed Kuninori Morimoto
2023-02-01  2:00 ` [PATCH 05/15] ASoC: rsnd: indicate warning once if it can't handle requested rule Kuninori Morimoto
2023-02-01  2:00 ` [PATCH 06/15] ASoC: rsnd: use same debug message format on clkout Kuninori Morimoto
2023-02-01  2:00 ` [PATCH 07/15] ASoC: rsnd: remove unnecessary ADG flags Kuninori Morimoto
2023-02-01  2:00 ` [PATCH 08/15] ASoC: rsnd: rename clk to clkin Kuninori Morimoto
2023-02-01  2:00 ` [PATCH 09/15] ASoC: rsnd: moves clkout_name to top of the file Kuninori Morimoto
2023-02-01  2:00 ` [PATCH 10/15] ASoC: rsnd: use clkin/out_size Kuninori Morimoto
2023-02-01  2:00 ` [PATCH 11/15] ASoC: rsnd: use array for 44.1kHz/48kHz rate handling Kuninori Morimoto
2023-02-01  2:00 ` [PATCH 12/15] ASoC: rsnd: tidyup rsnd_dma_addr() Kuninori Morimoto
2023-02-01  2:00 ` [PATCH 13/15] ASoC: rsnd: dma.c: tidyup rsnd_dma_probe() Kuninori Morimoto
2023-02-01  2:02 ` [PATCH 14/15] ASoC: dt-bindings: renesas: add R8A779G0 V4H Kuninori Morimoto
2023-02-01  2:02   ` Kuninori Morimoto
2023-02-01  7:11   ` Krzysztof Kozlowski
2023-02-01  7:11     ` Krzysztof Kozlowski
2023-02-01 10:19     ` Mark Brown
2023-02-01 10:19       ` Mark Brown
2023-02-02  8:53   ` Geert Uytterhoeven
2023-02-02  8:53     ` Geert Uytterhoeven
2023-02-03  1:18     ` Kuninori Morimoto
2023-02-03  1:18       ` Kuninori Morimoto
2023-02-01  2:02 ` [PATCH 15/15] ASoC: rsnd: add R-Car Gen4 Sound support Kuninori Morimoto
2023-02-01 15:23 ` [PATCH 00/15] ASoC: rsnd: cleanup " 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=878rhi6t7x.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.