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 v2 5/7] ASoC: rsnd: add .get_fmt support
Date: 12 May 2021 09:45:50 +0900	[thread overview]
Message-ID: <87tun8aif5.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <871racbx0w.wl-kuninori.morimoto.gx@renesas.com>


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

rsnd supports .get_fmt by this patch

Link: https://lore.kernel.org/r/871rb3hypy.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v1 -> v2
	- possible to be clock/frame master is depends on board settings.

 sound/soc/sh/rcar/adg.c  |  8 ++++++++
 sound/soc/sh/rcar/core.c | 24 ++++++++++++++++++++++--
 sound/soc/sh/rcar/rsnd.h |  1 +
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c
index 0b8ae3eee148..f7773c41085b 100644
--- a/sound/soc/sh/rcar/adg.c
+++ b/sound/soc/sh/rcar/adg.c
@@ -557,6 +557,14 @@ static void rsnd_adg_get_clkout(struct rsnd_priv *priv,
 	adg->rbgb = rbgb;
 }
 
+int rsnd_adg_clk_can_be_provider(struct rsnd_priv *priv)
+{
+	struct rsnd_adg *adg = rsnd_priv_to_adg(priv);
+
+	return (adg->rbga_rate_for_441khz &&
+		adg->rbgb_rate_for_48khz);
+}
+
 #ifdef DEBUG
 static void rsnd_adg_clk_dbg_info(struct rsnd_priv *priv, struct rsnd_adg *adg)
 {
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 8696a993c478..11b1e6f3ae40 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -754,16 +754,35 @@ static int rsnd_soc_dai_trigger(struct snd_pcm_substream *substream, int cmd,
 	return ret;
 }
 
+static u64 rsnd_soc_dai_get_fmt(struct snd_soc_dai *dai)
+{
+	struct rsnd_priv *priv = rsnd_dai_to_priv(dai);
+	u64 cbc_cfc = rsnd_adg_clk_can_be_provider(priv) ?
+		SND_SOC_POSSIBLE_DAIFMT_CBC_CFC	: 0;
+
+	return	SND_SOC_POSSIBLE_DAIFMT_I2S	|
+		SND_SOC_POSSIBLE_DAIFMT_RIGHT_J	|
+		SND_SOC_POSSIBLE_DAIFMT_LEFT_J	|
+		SND_SOC_POSSIBLE_DAIFMT_DSP_A	|
+		SND_SOC_POSSIBLE_DAIFMT_DSP_B	|
+		SND_SOC_POSSIBLE_DAIFMT_NB_NF	|
+		SND_SOC_POSSIBLE_DAIFMT_NB_IF	|
+		SND_SOC_POSSIBLE_DAIFMT_IB_NF	|
+		SND_SOC_POSSIBLE_DAIFMT_IB_IF	|
+		SND_SOC_POSSIBLE_DAIFMT_CBP_CFP	|
+		cbc_cfc;
+}
+
 static int rsnd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 {
 	struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
 
 	/* set clock master for audio interface */
 	switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
-	case SND_SOC_DAIFMT_CBM_CFM:
+	case SND_SOC_DAIFMT_CBP_CFP:
 		rdai->clk_master = 0;
 		break;
-	case SND_SOC_DAIFMT_CBS_CFS:
+	case SND_SOC_DAIFMT_CBC_CFC:
 		rdai->clk_master = 1; /* cpu is master */
 		break;
 	default:
@@ -1047,6 +1066,7 @@ static const struct snd_soc_dai_ops rsnd_soc_dai_ops = {
 	.startup	= rsnd_soc_dai_startup,
 	.shutdown	= rsnd_soc_dai_shutdown,
 	.trigger	= rsnd_soc_dai_trigger,
+	.get_fmt	= rsnd_soc_dai_get_fmt,
 	.set_fmt	= rsnd_soc_dai_set_fmt,
 	.set_tdm_slot	= rsnd_soc_set_dai_tdm_slot,
 	.prepare	= rsnd_soc_dai_prepare,
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h
index 1255a85151db..c8c7691f7426 100644
--- a/sound/soc/sh/rcar/rsnd.h
+++ b/sound/soc/sh/rcar/rsnd.h
@@ -610,6 +610,7 @@ int rsnd_adg_set_cmd_timsel_gen2(struct rsnd_mod *cmd_mod,
 #define rsnd_adg_clk_enable(priv)	rsnd_adg_clk_control(priv, 1)
 #define rsnd_adg_clk_disable(priv)	rsnd_adg_clk_control(priv, 0)
 void rsnd_adg_clk_control(struct rsnd_priv *priv, int enable);
+int rsnd_adg_clk_can_be_provider(struct rsnd_priv *priv);
 
 /*
  *	R-Car sound priv
-- 
2.25.1


  parent reply	other threads:[~2021-05-12  0:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-12  0:45 [PATCH v2 0/7] ASoC: adds new .get_fmt support Kuninori Morimoto
2021-05-12  0:45 ` [PATCH v2 1/7] ASoC: soc-core: move snd_soc_runtime_set_dai_fmt() to upside Kuninori Morimoto
2021-05-12  0:45 ` [PATCH v2 2/7] ASoC: soc-core: add snd_soc_runtime_get_dai_fmt() Kuninori Morimoto
2021-05-25 23:20   ` Mark Brown
2021-05-26  2:46     ` Kuninori Morimoto
2021-05-26 22:54       ` Kuninori Morimoto
2021-05-26 23:19         ` Mark Brown
2021-05-12  0:45 ` [PATCH v2 3/7] ASoC: ak4613: add .get_fmt support Kuninori Morimoto
2021-05-12  0:45 ` [PATCH v2 4/7] ASoC: pcm3168a: " Kuninori Morimoto
2021-05-12  0:45 ` Kuninori Morimoto [this message]
2021-05-12  0:45 ` [PATCH v2 6/7] ASoC: fsi: " Kuninori Morimoto
2021-05-12  0:45 ` [PATCH v2 7/7] ASoC: hdmi-codec: " Kuninori Morimoto

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=87tun8aif5.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.