All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/8] ASoC: tidyup snd_soc_of_parse_daifmt()
@ 2021-06-09  2:07 Kuninori Morimoto
  2021-06-09  2:13 ` [PATCH v2 1/8] ASoC: soc-core: add snd_soc_daifmt_clock_provider_from_bitmap() Kuninori Morimoto
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2021-06-09  2:07 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: Alexandre Belloni, Timur Tabi, Xiubo Li, Martin Blumenstingl,
	Shengjiu Wang, Sameer Pujar, Neil Armstrong, Nicolas Ferre,
	Nicolin Chen, Ludovic Desroches, Kevin Hilman, Codrin Ciubotariu,
	alsa-devel, Fabio Estevam, Jerome Brunet


Hi Mark

These are v2 of parsing for daifmt.

I want to add new audio-graph-card2 sound card driver,
and this is last part of necessary soc-core cleanup for it.

Current some drivers are using DT, and then,
snd_soc_of_parse_daifmt() parses daifmt, but bitclock/frame provider
parsing part is one of headache, because we are assuming below both cases.

A)	node {
		bitclock-master;
		frame-master;
		...
	};
    
B)	link {
		bitclock-master = <&xxx>;
		frame-master = <&xxx>;
		...
	};

The original was style A), and style B) was added later.

snd_soc_of_parse_daifmt() parses A) style as original style,
and user need to update to B) style for clock_provider part if needed.

To handle it more flexibile, this patch-set adds new functions
which separates snd_soc_of_parse_daifmt() helper function.

	snd_soc_daifmt_parse_format()			: format part
	snd_soc_daifmt_parse_clock_provider_as_flag()	: clock part for style A)
	snd_soc_daifmt_parse_clock_provider_as_phandl()	: clock part for style B)
	snd_soc_daifmt_parse_clock_provider_as_bitmap()	: clock part use with _from_bitmap

v1 -> v2
	- tidyup parse_clock_provider functions to _as_flag/phandle/bitmap()
	- don't exchange code style on each drivers.

Link: https://lore.kernel.org/r/875yypdxlm.wl-kuninori.morimoto.gx@renesas.com

Kuninori Morimoto (8):
  ASoC: soc-core: add snd_soc_daifmt_clock_provider_from_bitmap()
  ASoC: soc-core: add snd_soc_daifmt_clock_provider_fliped()
  ASoC: soc-core: add snd_soc_daifmt_parse_format/clock_provider()
  ASoC: atmel: switch to use snd_soc_daifmt_parse_format/clock_provider()
  ASoC: fsl: switch to use snd_soc_daifmt_parse_format/clock_provider()
  ASoC: meson: switch to use snd_soc_daifmt_parse_format/clock_provider()
  ASoC: simple-card-utils: switch to use snd_soc_daifmt_parse_format/clock_provider()
  ASoC: soc-core: remove snd_soc_of_parse_daifmt()

 include/sound/soc.h                   | 21 ++++--
 sound/soc/atmel/mikroe-proto.c        | 16 +++--
 sound/soc/fsl/fsl-asoc-card.c         | 14 ++--
 sound/soc/generic/simple-card-utils.c | 19 ++---
 sound/soc/meson/meson-card-utils.c    | 13 ++--
 sound/soc/soc-core.c                  | 99 +++++++++++++++++----------
 6 files changed, 110 insertions(+), 72 deletions(-)

-- 
2.25.1


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

* [PATCH v2 1/8] ASoC: soc-core: add snd_soc_daifmt_clock_provider_from_bitmap()
  2021-06-09  2:07 [PATCH v2 0/8] ASoC: tidyup snd_soc_of_parse_daifmt() Kuninori Morimoto
@ 2021-06-09  2:13 ` Kuninori Morimoto
  2021-06-09  2:14 ` [PATCH v2 2/8] ASoC: soc-core: add snd_soc_daifmt_clock_provider_fliped() Kuninori Morimoto
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2021-06-09  2:13 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: Alexandre Belloni, Timur Tabi, Xiubo Li, Martin Blumenstingl,
	Shengjiu Wang, Sameer Pujar, Neil Armstrong, Nicolas Ferre,
	Nicolin Chen, Ludovic Desroches, Kevin Hilman, Codrin Ciubotariu,
	alsa-devel, Fabio Estevam, Jerome Brunet

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

This patch adds snd_soc_daifmt_clock_provider_from_bitmap() function
to judge clock/frame master from its bitmap.
This is prepare for snd_soc_of_parse_daifmt() cleanup.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h  |  1 +
 sound/soc/soc-core.c | 33 +++++++++++++++++++--------------
 2 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index e746da996351..ea35e431e04e 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1232,6 +1232,7 @@ void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card,
 int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
 				   const char *propname);
 int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname);
+unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame);
 unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 				     const char *prefix,
 				     struct device_node **bitclkmaster,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 44e65f984a5c..f271202f4049 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3017,6 +3017,24 @@ int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname)
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_aux_devs);
 
+unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame)
+{
+	/* Codec base */
+	switch (bit_frame) {
+	case 0x11:
+		return SND_SOC_DAIFMT_CBP_CFP;
+	case 0x10:
+		return SND_SOC_DAIFMT_CBP_CFC;
+	case 0x01:
+		return SND_SOC_DAIFMT_CBC_CFP;
+	default:
+		return SND_SOC_DAIFMT_CBC_CFC;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_daifmt_clock_provider_from_bitmap);
+
 unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 				     const char *prefix,
 				     struct device_node **bitclkmaster,
@@ -3115,20 +3133,7 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 	if (frame && framemaster)
 		*framemaster = of_parse_phandle(np, prop, 0);
 
-	switch ((bit << 4) + frame) {
-	case 0x11:
-		format |= SND_SOC_DAIFMT_CBM_CFM;
-		break;
-	case 0x10:
-		format |= SND_SOC_DAIFMT_CBM_CFS;
-		break;
-	case 0x01:
-		format |= SND_SOC_DAIFMT_CBS_CFM;
-		break;
-	default:
-		format |= SND_SOC_DAIFMT_CBS_CFS;
-		break;
-	}
+	format |= snd_soc_daifmt_clock_provider_from_bitmap((bit << 4) + frame);
 
 	return format;
 }
-- 
2.25.1


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

* [PATCH v2 2/8] ASoC: soc-core: add snd_soc_daifmt_clock_provider_fliped()
  2021-06-09  2:07 [PATCH v2 0/8] ASoC: tidyup snd_soc_of_parse_daifmt() Kuninori Morimoto
  2021-06-09  2:13 ` [PATCH v2 1/8] ASoC: soc-core: add snd_soc_daifmt_clock_provider_from_bitmap() Kuninori Morimoto
@ 2021-06-09  2:14 ` Kuninori Morimoto
  2021-06-09  2:15 ` [PATCH v2 3/8] ASoC: soc-core: add snd_soc_daifmt_parse_format/clock_provider() Kuninori Morimoto
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2021-06-09  2:14 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: Alexandre Belloni, Timur Tabi, Xiubo Li, Martin Blumenstingl,
	Shengjiu Wang, Sameer Pujar, Neil Armstrong, Nicolas Ferre,
	Nicolin Chen, Ludovic Desroches, Kevin Hilman, Codrin Ciubotariu,
	alsa-devel, Fabio Estevam, Jerome Brunet

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

Sometimes we want to get CLOCK_PROVIDER fliped dai_fmt.
This patch adds new snd_soc_daifmt_clock_provider_fliped() for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h  |  2 ++
 sound/soc/soc-core.c | 40 +++++++++++++++++++++++++---------------
 2 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index ea35e431e04e..45f3da277c5d 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1232,6 +1232,8 @@ void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card,
 int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
 				   const char *propname);
 int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname);
+
+unsigned int snd_soc_daifmt_clock_provider_fliped(unsigned int dai_fmt);
 unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame);
 unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 				     const char *prefix,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index f271202f4049..0a8143e3fcdb 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1249,21 +1249,8 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
 	 * Flip the polarity for the "CPU" end of a CODEC<->CODEC link
 	 * the component which has non_legacy_dai_naming is Codec
 	 */
-	inv_dai_fmt = dai_fmt & ~SND_SOC_DAIFMT_MASTER_MASK;
-	switch (dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) {
-	case SND_SOC_DAIFMT_CBM_CFM:
-		inv_dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
-		break;
-	case SND_SOC_DAIFMT_CBM_CFS:
-		inv_dai_fmt |= SND_SOC_DAIFMT_CBS_CFM;
-		break;
-	case SND_SOC_DAIFMT_CBS_CFM:
-		inv_dai_fmt |= SND_SOC_DAIFMT_CBM_CFS;
-		break;
-	case SND_SOC_DAIFMT_CBS_CFS:
-		inv_dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
-		break;
-	}
+	inv_dai_fmt = snd_soc_daifmt_clock_provider_fliped(dai_fmt);
+
 	for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
 		unsigned int fmt = dai_fmt;
 
@@ -3017,6 +3004,29 @@ int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname)
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_aux_devs);
 
+unsigned int snd_soc_daifmt_clock_provider_fliped(unsigned int dai_fmt)
+{
+	unsigned int inv_dai_fmt = dai_fmt & ~SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK;
+
+	switch (dai_fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) {
+	case SND_SOC_DAIFMT_CBP_CFP:
+		inv_dai_fmt |= SND_SOC_DAIFMT_CBC_CFC;
+		break;
+	case SND_SOC_DAIFMT_CBP_CFC:
+		inv_dai_fmt |= SND_SOC_DAIFMT_CBC_CFP;
+		break;
+	case SND_SOC_DAIFMT_CBC_CFP:
+		inv_dai_fmt |= SND_SOC_DAIFMT_CBP_CFC;
+		break;
+	case SND_SOC_DAIFMT_CBC_CFC:
+		inv_dai_fmt |= SND_SOC_DAIFMT_CBP_CFP;
+		break;
+	}
+
+	return inv_dai_fmt;
+}
+EXPORT_SYMBOL_GPL(snd_soc_daifmt_clock_provider_fliped);
+
 unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame)
 {
 	/* Codec base */
-- 
2.25.1


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

* [PATCH v2 3/8] ASoC: soc-core: add snd_soc_daifmt_parse_format/clock_provider()
  2021-06-09  2:07 [PATCH v2 0/8] ASoC: tidyup snd_soc_of_parse_daifmt() Kuninori Morimoto
  2021-06-09  2:13 ` [PATCH v2 1/8] ASoC: soc-core: add snd_soc_daifmt_clock_provider_from_bitmap() Kuninori Morimoto
  2021-06-09  2:14 ` [PATCH v2 2/8] ASoC: soc-core: add snd_soc_daifmt_clock_provider_fliped() Kuninori Morimoto
@ 2021-06-09  2:15 ` Kuninori Morimoto
  2021-06-09  2:15 ` [PATCH v2 4/8] ASoC: atmel: switch to use snd_soc_daifmt_parse_format/clock_provider() Kuninori Morimoto
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2021-06-09  2:15 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: Alexandre Belloni, Timur Tabi, Xiubo Li, Martin Blumenstingl,
	Shengjiu Wang, Sameer Pujar, Neil Armstrong, Nicolas Ferre,
	Nicolin Chen, Ludovic Desroches, Kevin Hilman, Codrin Ciubotariu,
	alsa-devel, Fabio Estevam, Jerome Brunet

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

snd_soc_of_parse_daifmt() parses daifmt, but bitclock/frame provider
parsing part is one of headacke, because we are assuming below both cases.

A)	node {
		bitclock-master;
		frame-master;
		...
	};

B)	link {
		bitclock-master = <&xxx>;
		frame-master = <&xxx>;
		...
	};

The original was style A), and style B) was added later
by commit b3ca11ff59bc ("ASoC: simple-card: Move dai-link level
properties away from dai subnodes").

snd_soc_of_parse_daifmt() parses it as style A),
and user need to update it to style B) if needed.

To handle it more flexibile, this patch adds new functions
which separates snd_soc_of_parse_daifmt() helper function.

	snd_soc_daifmt_parse_format()			: for DAI format
	snd_soc_daifmt_parse_clock_provider_as_flag()	: for style A)
	snd_soc_daifmt_parse_clock_provider_as_phandl()	: for style B)
	snd_soc_daifmt_parse_clock_provider_as_bitmap()	: use with _from_bitmap

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h  |  14 ++++++
 sound/soc/soc-core.c | 114 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 128 insertions(+)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 45f3da277c5d..63194a8773cd 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1235,6 +1235,20 @@ int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname);
 
 unsigned int snd_soc_daifmt_clock_provider_fliped(unsigned int dai_fmt);
 unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame);
+
+unsigned int snd_soc_daifmt_parse_format(struct device_node *np, const char *prefix);
+unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np,
+						     const char *prefix,
+						     struct device_node **bitclkmaster,
+						     struct device_node **framemaster);
+#define snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix)	\
+	snd_soc_daifmt_parse_clock_provider_raw(np, prefix, NULL, NULL)
+#define snd_soc_daifmt_parse_clock_provider_as_phandle			\
+	snd_soc_daifmt_parse_clock_provider_raw
+#define snd_soc_daifmt_parse_clock_provider_as_flag(np, prefix)		\
+	snd_soc_daifmt_clock_provider_from_bitmap(			\
+		snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix))
+
 unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 				     const char *prefix,
 				     struct device_node **bitclkmaster,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 0a8143e3fcdb..b6790d2a0447 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3045,6 +3045,120 @@ unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame)
 }
 EXPORT_SYMBOL_GPL(snd_soc_daifmt_clock_provider_from_bitmap);
 
+unsigned int snd_soc_daifmt_parse_format(struct device_node *np,
+					 const char *prefix)
+{
+	int ret, i;
+	char prop[128];
+	unsigned int format = 0;
+	int bit, frame;
+	const char *str;
+	struct {
+		char *name;
+		unsigned int val;
+	} of_fmt_table[] = {
+		{ "i2s",	SND_SOC_DAIFMT_I2S },
+		{ "right_j",	SND_SOC_DAIFMT_RIGHT_J },
+		{ "left_j",	SND_SOC_DAIFMT_LEFT_J },
+		{ "dsp_a",	SND_SOC_DAIFMT_DSP_A },
+		{ "dsp_b",	SND_SOC_DAIFMT_DSP_B },
+		{ "ac97",	SND_SOC_DAIFMT_AC97 },
+		{ "pdm",	SND_SOC_DAIFMT_PDM},
+		{ "msb",	SND_SOC_DAIFMT_MSB },
+		{ "lsb",	SND_SOC_DAIFMT_LSB },
+	};
+
+	if (!prefix)
+		prefix = "";
+
+	/*
+	 * check "dai-format = xxx"
+	 * or    "[prefix]format = xxx"
+	 * SND_SOC_DAIFMT_FORMAT_MASK area
+	 */
+	ret = of_property_read_string(np, "dai-format", &str);
+	if (ret < 0) {
+		snprintf(prop, sizeof(prop), "%sformat", prefix);
+		ret = of_property_read_string(np, prop, &str);
+	}
+	if (ret == 0) {
+		for (i = 0; i < ARRAY_SIZE(of_fmt_table); i++) {
+			if (strcmp(str, of_fmt_table[i].name) == 0) {
+				format |= of_fmt_table[i].val;
+				break;
+			}
+		}
+	}
+
+	/*
+	 * check "[prefix]continuous-clock"
+	 * SND_SOC_DAIFMT_CLOCK_MASK area
+	 */
+	snprintf(prop, sizeof(prop), "%scontinuous-clock", prefix);
+	if (of_property_read_bool(np, prop))
+		format |= SND_SOC_DAIFMT_CONT;
+	else
+		format |= SND_SOC_DAIFMT_GATED;
+
+	/*
+	 * check "[prefix]bitclock-inversion"
+	 * check "[prefix]frame-inversion"
+	 * SND_SOC_DAIFMT_INV_MASK area
+	 */
+	snprintf(prop, sizeof(prop), "%sbitclock-inversion", prefix);
+	bit = !!of_get_property(np, prop, NULL);
+
+	snprintf(prop, sizeof(prop), "%sframe-inversion", prefix);
+	frame = !!of_get_property(np, prop, NULL);
+
+	switch ((bit << 4) + frame) {
+	case 0x11:
+		format |= SND_SOC_DAIFMT_IB_IF;
+		break;
+	case 0x10:
+		format |= SND_SOC_DAIFMT_IB_NF;
+		break;
+	case 0x01:
+		format |= SND_SOC_DAIFMT_NB_IF;
+		break;
+	default:
+		/* SND_SOC_DAIFMT_NB_NF is default */
+		break;
+	}
+
+	return format;
+}
+EXPORT_SYMBOL_GPL(snd_soc_daifmt_parse_format);
+
+unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np,
+						     const char *prefix,
+						     struct device_node **bitclkmaster,
+						     struct device_node **framemaster)
+{
+	char prop[128];
+	unsigned int bit, frame;
+
+	if (!prefix)
+		prefix = "";
+
+	/*
+	 * check "[prefix]bitclock-master"
+	 * check "[prefix]frame-master"
+	 */
+	snprintf(prop, sizeof(prop), "%sbitclock-master", prefix);
+	bit = !!of_get_property(np, prop, NULL);
+	if (bit && bitclkmaster)
+		*bitclkmaster = of_parse_phandle(np, prop, 0);
+
+	snprintf(prop, sizeof(prop), "%sframe-master", prefix);
+	frame = !!of_get_property(np, prop, NULL);
+	if (frame && framemaster)
+		*framemaster = of_parse_phandle(np, prop, 0);
+
+	return (bit << 4) + frame;
+}
+EXPORT_SYMBOL_GPL(snd_soc_daifmt_parse_clock_provider_raw);
+
 unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 				     const char *prefix,
 				     struct device_node **bitclkmaster,
-- 
2.25.1


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

* [PATCH v2 4/8] ASoC: atmel: switch to use snd_soc_daifmt_parse_format/clock_provider()
  2021-06-09  2:07 [PATCH v2 0/8] ASoC: tidyup snd_soc_of_parse_daifmt() Kuninori Morimoto
                   ` (2 preceding siblings ...)
  2021-06-09  2:15 ` [PATCH v2 3/8] ASoC: soc-core: add snd_soc_daifmt_parse_format/clock_provider() Kuninori Morimoto
@ 2021-06-09  2:15 ` Kuninori Morimoto
  2021-06-09  2:16 ` [PATCH v2 5/8] ASoC: fsl: " Kuninori Morimoto
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2021-06-09  2:15 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: Alexandre Belloni, Timur Tabi, Xiubo Li, Martin Blumenstingl,
	Shengjiu Wang, Sameer Pujar, Neil Armstrong, Nicolas Ferre,
	Nicolin Chen, Ludovic Desroches, Kevin Hilman, Codrin Ciubotariu,
	alsa-devel, Fabio Estevam, Jerome Brunet

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

This patch switch to use snd_soc_daifmt_parse_format/clock_provider() from
snd_soc_of_parse_daifmt().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/atmel/mikroe-proto.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/sound/soc/atmel/mikroe-proto.c b/sound/soc/atmel/mikroe-proto.c
index f9a85fd01b79..5bdba38ec408 100644
--- a/sound/soc/atmel/mikroe-proto.c
+++ b/sound/soc/atmel/mikroe-proto.c
@@ -69,6 +69,7 @@ static int snd_proto_probe(struct platform_device *pdev)
 	struct device_node *bitclkmaster = NULL;
 	struct device_node *framemaster = NULL;
 	unsigned int dai_fmt;
+	unsigned int dai_clk;
 	int ret = 0;
 
 	if (!np) {
@@ -120,22 +121,25 @@ static int snd_proto_probe(struct platform_device *pdev)
 	dai->cpus->of_node = cpu_np;
 	dai->platforms->of_node = cpu_np;
 
-	dai_fmt = snd_soc_of_parse_daifmt(np, NULL,
-					  &bitclkmaster, &framemaster);
+	dai_fmt = snd_soc_daifmt_parse_format(np, NULL);
+	snd_soc_daifmt_parse_clock_provider_as_phandle(np, NULL,
+						       &bitclkmaster, &framemaster);
 	if (bitclkmaster != framemaster) {
 		dev_err(&pdev->dev, "Must be the same bitclock and frame master\n");
 		return -EINVAL;
 	}
 	if (bitclkmaster) {
-		dai_fmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
 		if (codec_np == bitclkmaster)
-			dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
+			dai_clk = SND_SOC_DAIFMT_CBM_CFM;
 		else
-			dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
+			dai_clk = SND_SOC_DAIFMT_CBS_CFS;
+	} else {
+		dai_clk = snd_soc_daifmt_parse_clock_provider_as_flag(np, NULL);
 	}
+
 	of_node_put(bitclkmaster);
 	of_node_put(framemaster);
-	dai->dai_fmt = dai_fmt;
+	dai->dai_fmt = dai_fmt | dai_clk;
 
 	of_node_put(codec_np);
 	of_node_put(cpu_np);
-- 
2.25.1


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

* [PATCH v2 5/8] ASoC: fsl: switch to use snd_soc_daifmt_parse_format/clock_provider()
  2021-06-09  2:07 [PATCH v2 0/8] ASoC: tidyup snd_soc_of_parse_daifmt() Kuninori Morimoto
                   ` (3 preceding siblings ...)
  2021-06-09  2:15 ` [PATCH v2 4/8] ASoC: atmel: switch to use snd_soc_daifmt_parse_format/clock_provider() Kuninori Morimoto
@ 2021-06-09  2:16 ` Kuninori Morimoto
  2021-06-09  2:16 ` [PATCH v2 6/8] ASoC: meson: " Kuninori Morimoto
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2021-06-09  2:16 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: Alexandre Belloni, Timur Tabi, Xiubo Li, Martin Blumenstingl,
	Shengjiu Wang, Sameer Pujar, Neil Armstrong, Nicolas Ferre,
	Nicolin Chen, Ludovic Desroches, Kevin Hilman, Codrin Ciubotariu,
	alsa-devel, Fabio Estevam, Jerome Brunet

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

This patch switch to use snd_soc_daifmt_parse_format/clock_provider() from
snd_soc_of_parse_daifmt().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/fsl/fsl-asoc-card.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index c62bfd1c3ac7..d28d9c1ea659 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -540,7 +540,6 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
 	struct device *codec_dev = NULL;
 	const char *codec_dai_name;
 	const char *codec_dev_name;
-	unsigned int daifmt;
 	u32 width;
 	int ret;
 
@@ -684,19 +683,20 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
 	}
 
 	/* Format info from DT is optional. */
-	daifmt = snd_soc_of_parse_daifmt(np, NULL,
-					 &bitclkmaster, &framemaster);
-	daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
+	snd_soc_daifmt_parse_clock_provider_as_phandle(np, NULL, &bitclkmaster, &framemaster);
 	if (bitclkmaster || framemaster) {
+		unsigned int daifmt = snd_soc_daifmt_parse_format(np, NULL);
+		unsigned int daiclk;
+
 		if (codec_np == bitclkmaster)
-			daifmt |= (codec_np == framemaster) ?
+			daiclk = (codec_np == framemaster) ?
 				SND_SOC_DAIFMT_CBM_CFM : SND_SOC_DAIFMT_CBM_CFS;
 		else
-			daifmt |= (codec_np == framemaster) ?
+			daiclk = (codec_np == framemaster) ?
 				SND_SOC_DAIFMT_CBS_CFM : SND_SOC_DAIFMT_CBS_CFS;
 
 		/* Override dai_fmt with value from DT */
-		priv->dai_fmt = daifmt;
+		priv->dai_fmt = daifmt | daiclk;
 	}
 
 	/* Change direction according to format */
-- 
2.25.1


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

* [PATCH v2 6/8] ASoC: meson: switch to use snd_soc_daifmt_parse_format/clock_provider()
  2021-06-09  2:07 [PATCH v2 0/8] ASoC: tidyup snd_soc_of_parse_daifmt() Kuninori Morimoto
                   ` (4 preceding siblings ...)
  2021-06-09  2:16 ` [PATCH v2 5/8] ASoC: fsl: " Kuninori Morimoto
@ 2021-06-09  2:16 ` Kuninori Morimoto
  2021-06-09  7:11   ` Jerome Brunet
  2021-06-09  2:16 ` [PATCH v2 7/8] ASoC: simple-card-utils: " Kuninori Morimoto
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 12+ messages in thread
From: Kuninori Morimoto @ 2021-06-09  2:16 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: Alexandre Belloni, Timur Tabi, Xiubo Li, Martin Blumenstingl,
	Shengjiu Wang, Sameer Pujar, Neil Armstrong, Nicolas Ferre,
	Nicolin Chen, Ludovic Desroches, Kevin Hilman, Codrin Ciubotariu,
	alsa-devel, Fabio Estevam, Jerome Brunet

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

This patch switch to use snd_soc_daifmt_parse_format/clock_provider() from
snd_soc_of_parse_daifmt().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/meson/meson-card-utils.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/sound/soc/meson/meson-card-utils.c b/sound/soc/meson/meson-card-utils.c
index 300ac8be46ef..779ac282e36d 100644
--- a/sound/soc/meson/meson-card-utils.c
+++ b/sound/soc/meson/meson-card-utils.c
@@ -118,24 +118,25 @@ unsigned int meson_card_parse_daifmt(struct device_node *node,
 	struct device_node *bitclkmaster = NULL;
 	struct device_node *framemaster = NULL;
 	unsigned int daifmt;
+	unsigned int daiclk;
 
-	daifmt = snd_soc_of_parse_daifmt(node, "",
-					 &bitclkmaster, &framemaster);
-	daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
+	daifmt = snd_soc_daifmt_parse_format(node, NULL);
+
+	snd_soc_daifmt_parse_clock_provider_as_phandle(node, NULL, &bitclkmaster, &framemaster);
 
 	/* If no master is provided, default to cpu master */
 	if (!bitclkmaster || bitclkmaster == cpu_node) {
-		daifmt |= (!framemaster || framemaster == cpu_node) ?
+		daiclk = (!framemaster || framemaster == cpu_node) ?
 			SND_SOC_DAIFMT_CBS_CFS : SND_SOC_DAIFMT_CBS_CFM;
 	} else {
-		daifmt |= (!framemaster || framemaster == cpu_node) ?
+		daiclk = (!framemaster || framemaster == cpu_node) ?
 			SND_SOC_DAIFMT_CBM_CFS : SND_SOC_DAIFMT_CBM_CFM;
 	}
 
 	of_node_put(bitclkmaster);
 	of_node_put(framemaster);
 
-	return daifmt;
+	return daifmt | daiclk;
 }
 EXPORT_SYMBOL_GPL(meson_card_parse_daifmt);
 
-- 
2.25.1


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

* [PATCH v2 7/8] ASoC: simple-card-utils: switch to use snd_soc_daifmt_parse_format/clock_provider()
  2021-06-09  2:07 [PATCH v2 0/8] ASoC: tidyup snd_soc_of_parse_daifmt() Kuninori Morimoto
                   ` (5 preceding siblings ...)
  2021-06-09  2:16 ` [PATCH v2 6/8] ASoC: meson: " Kuninori Morimoto
@ 2021-06-09  2:16 ` Kuninori Morimoto
  2021-06-09  2:17 ` [PATCH v2 8/8] ASoC: soc-core: remove snd_soc_of_parse_daifmt() Kuninori Morimoto
  2021-06-09  5:27 ` [PATCH v2 9/8] ASoC: soc-core: add comment of return value for snd_soc_daifmt_parse_clock_provider_raw() Kuninori Morimoto
  8 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2021-06-09  2:16 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: Alexandre Belloni, Timur Tabi, Xiubo Li, Martin Blumenstingl,
	Shengjiu Wang, Sameer Pujar, Neil Armstrong, Nicolas Ferre,
	Nicolin Chen, Ludovic Desroches, Kevin Hilman, Codrin Ciubotariu,
	alsa-devel, Fabio Estevam, Jerome Brunet

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

This patch switch to use snd_soc_daifmt_parse_format/clock_provider() from
snd_soc_of_parse_daifmt().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/simple-card-utils.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index fa1247f0dda1..2475f269497b 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -60,11 +60,11 @@ int asoc_simple_parse_daifmt(struct device *dev,
 	struct device_node *bitclkmaster = NULL;
 	struct device_node *framemaster = NULL;
 	unsigned int daifmt;
+	unsigned int daiclk;
 
-	daifmt = snd_soc_of_parse_daifmt(node, prefix,
-					 &bitclkmaster, &framemaster);
-	daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
+	daifmt = snd_soc_daifmt_parse_format(node, prefix);
 
+	snd_soc_daifmt_parse_clock_provider_as_phandle(node, prefix, &bitclkmaster, &framemaster);
 	if (!bitclkmaster && !framemaster) {
 		/*
 		 * No dai-link level and master setting was not found from
@@ -73,21 +73,16 @@ int asoc_simple_parse_daifmt(struct device *dev,
 		 */
 		dev_dbg(dev, "Revert to legacy daifmt parsing\n");
 
-		daifmt = snd_soc_of_parse_daifmt(codec, NULL, NULL, NULL) |
-			(daifmt & ~SND_SOC_DAIFMT_CLOCK_MASK);
+		daiclk = snd_soc_daifmt_parse_clock_provider_as_flag(codec, NULL);
 	} else {
-		if (codec == bitclkmaster)
-			daifmt |= (codec == framemaster) ?
-				SND_SOC_DAIFMT_CBM_CFM : SND_SOC_DAIFMT_CBM_CFS;
-		else
-			daifmt |= (codec == framemaster) ?
-				SND_SOC_DAIFMT_CBS_CFM : SND_SOC_DAIFMT_CBS_CFS;
+		daiclk = snd_soc_daifmt_clock_provider_from_bitmap(
+				((codec == bitclkmaster) << 4) | (codec == framemaster));
 	}
 
 	of_node_put(bitclkmaster);
 	of_node_put(framemaster);
 
-	*retfmt = daifmt;
+	*retfmt = daifmt | daiclk;
 
 	return 0;
 }
-- 
2.25.1


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

* [PATCH v2 8/8] ASoC: soc-core: remove snd_soc_of_parse_daifmt()
  2021-06-09  2:07 [PATCH v2 0/8] ASoC: tidyup snd_soc_of_parse_daifmt() Kuninori Morimoto
                   ` (6 preceding siblings ...)
  2021-06-09  2:16 ` [PATCH v2 7/8] ASoC: simple-card-utils: " Kuninori Morimoto
@ 2021-06-09  2:17 ` Kuninori Morimoto
  2021-06-09  5:27 ` [PATCH v2 9/8] ASoC: soc-core: add comment of return value for snd_soc_daifmt_parse_clock_provider_raw() Kuninori Morimoto
  8 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2021-06-09  2:17 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: Alexandre Belloni, Timur Tabi, Xiubo Li, Martin Blumenstingl,
	Shengjiu Wang, Sameer Pujar, Neil Armstrong, Nicolas Ferre,
	Nicolin Chen, Ludovic Desroches, Kevin Hilman, Codrin Ciubotariu,
	alsa-devel, Fabio Estevam, Jerome Brunet


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

No driver is using snd_soc_of_parse_daifmt().
This patch removes it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h  |   4 --
 sound/soc/soc-core.c | 104 -------------------------------------------
 2 files changed, 108 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 63194a8773cd..675849d07284 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1249,10 +1249,6 @@ unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np,
 	snd_soc_daifmt_clock_provider_from_bitmap(			\
 		snd_soc_daifmt_parse_clock_provider_as_bitmap(np, prefix))
 
-unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
-				     const char *prefix,
-				     struct device_node **bitclkmaster,
-				     struct device_node **framemaster);
 int snd_soc_get_dai_id(struct device_node *ep);
 int snd_soc_get_dai_name(const struct of_phandle_args *args,
 			 const char **dai_name);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index b6790d2a0447..70361e8da258 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3159,110 +3159,6 @@ unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(snd_soc_daifmt_parse_clock_provider_raw);
 
-unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
-				     const char *prefix,
-				     struct device_node **bitclkmaster,
-				     struct device_node **framemaster)
-{
-	int ret, i;
-	char prop[128];
-	unsigned int format = 0;
-	int bit, frame;
-	const char *str;
-	struct {
-		char *name;
-		unsigned int val;
-	} of_fmt_table[] = {
-		{ "i2s",	SND_SOC_DAIFMT_I2S },
-		{ "right_j",	SND_SOC_DAIFMT_RIGHT_J },
-		{ "left_j",	SND_SOC_DAIFMT_LEFT_J },
-		{ "dsp_a",	SND_SOC_DAIFMT_DSP_A },
-		{ "dsp_b",	SND_SOC_DAIFMT_DSP_B },
-		{ "ac97",	SND_SOC_DAIFMT_AC97 },
-		{ "pdm",	SND_SOC_DAIFMT_PDM},
-		{ "msb",	SND_SOC_DAIFMT_MSB },
-		{ "lsb",	SND_SOC_DAIFMT_LSB },
-	};
-
-	if (!prefix)
-		prefix = "";
-
-	/*
-	 * check "dai-format = xxx"
-	 * or    "[prefix]format = xxx"
-	 * SND_SOC_DAIFMT_FORMAT_MASK area
-	 */
-	ret = of_property_read_string(np, "dai-format", &str);
-	if (ret < 0) {
-		snprintf(prop, sizeof(prop), "%sformat", prefix);
-		ret = of_property_read_string(np, prop, &str);
-	}
-	if (ret == 0) {
-		for (i = 0; i < ARRAY_SIZE(of_fmt_table); i++) {
-			if (strcmp(str, of_fmt_table[i].name) == 0) {
-				format |= of_fmt_table[i].val;
-				break;
-			}
-		}
-	}
-
-	/*
-	 * check "[prefix]continuous-clock"
-	 * SND_SOC_DAIFMT_CLOCK_MASK area
-	 */
-	snprintf(prop, sizeof(prop), "%scontinuous-clock", prefix);
-	if (of_property_read_bool(np, prop))
-		format |= SND_SOC_DAIFMT_CONT;
-	else
-		format |= SND_SOC_DAIFMT_GATED;
-
-	/*
-	 * check "[prefix]bitclock-inversion"
-	 * check "[prefix]frame-inversion"
-	 * SND_SOC_DAIFMT_INV_MASK area
-	 */
-	snprintf(prop, sizeof(prop), "%sbitclock-inversion", prefix);
-	bit = !!of_get_property(np, prop, NULL);
-
-	snprintf(prop, sizeof(prop), "%sframe-inversion", prefix);
-	frame = !!of_get_property(np, prop, NULL);
-
-	switch ((bit << 4) + frame) {
-	case 0x11:
-		format |= SND_SOC_DAIFMT_IB_IF;
-		break;
-	case 0x10:
-		format |= SND_SOC_DAIFMT_IB_NF;
-		break;
-	case 0x01:
-		format |= SND_SOC_DAIFMT_NB_IF;
-		break;
-	default:
-		/* SND_SOC_DAIFMT_NB_NF is default */
-		break;
-	}
-
-	/*
-	 * check "[prefix]bitclock-master"
-	 * check "[prefix]frame-master"
-	 * SND_SOC_DAIFMT_MASTER_MASK area
-	 */
-	snprintf(prop, sizeof(prop), "%sbitclock-master", prefix);
-	bit = !!of_get_property(np, prop, NULL);
-	if (bit && bitclkmaster)
-		*bitclkmaster = of_parse_phandle(np, prop, 0);
-
-	snprintf(prop, sizeof(prop), "%sframe-master", prefix);
-	frame = !!of_get_property(np, prop, NULL);
-	if (frame && framemaster)
-		*framemaster = of_parse_phandle(np, prop, 0);
-
-	format |= snd_soc_daifmt_clock_provider_from_bitmap((bit << 4) + frame);
-
-	return format;
-}
-EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt);
-
 int snd_soc_get_dai_id(struct device_node *ep)
 {
 	struct snd_soc_component *component;
-- 
2.25.1


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

* [PATCH v2 9/8] ASoC: soc-core: add comment of return value for snd_soc_daifmt_parse_clock_provider_raw()
  2021-06-09  2:07 [PATCH v2 0/8] ASoC: tidyup snd_soc_of_parse_daifmt() Kuninori Morimoto
                   ` (7 preceding siblings ...)
  2021-06-09  2:17 ` [PATCH v2 8/8] ASoC: soc-core: remove snd_soc_of_parse_daifmt() Kuninori Morimoto
@ 2021-06-09  5:27 ` Kuninori Morimoto
  8 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2021-06-09  5:27 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: Alexandre Belloni, Timur Tabi, Xiubo Li, Martin Blumenstingl,
	Shengjiu Wang, Sameer Pujar, Neil Armstrong, Nicolas Ferre,
	Nicolin Chen, Ludovic Desroches, Kevin Hilman, Codrin Ciubotariu,
	alsa-devel, Fabio Estevam, Jerome Brunet

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

return value from snd_soc_daifmt_parse_clock_provider_raw() will
be used at snd_soc_daifmt_clock_provider_from_bitmap().
But it is very difficult to know that without any comments.
This patch adds it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
Hi Mark

snd_soc_daifmt_clock_provider_from_bitmap() was used from
snd_soc_of_parse_daifmt() too.
[8/8] patch removes it, and this patch was postponed until it.
But I forgot to include this. Thus this patch has strange numbering [9/8].

sound/soc/soc-core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 638dc6beecdd..0fa4966eddfc 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3021,6 +3021,11 @@ EXPORT_SYMBOL_GPL(snd_soc_daifmt_clock_provider_fliped);
 
 unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame)
 {
+	/*
+	 * bit_frame is return value from
+	 *	snd_soc_daifmt_parse_clock_provider_raw()
+	 */
+
 	/* Codec base */
 	switch (bit_frame) {
 	case 0x11:
@@ -3149,6 +3154,11 @@ unsigned int snd_soc_daifmt_parse_clock_provider_raw(struct device_node *np,
 	if (frame && framemaster)
 		*framemaster = of_parse_phandle(np, prop, 0);
 
+	/*
+	 * return bitmap.
+	 * It will be parameter of
+	 *	snd_soc_daifmt_clock_provider_from_bitmap()
+	 */
 	return (bit << 4) + frame;
 }
 EXPORT_SYMBOL_GPL(snd_soc_daifmt_parse_clock_provider_raw);
-- 
2.25.1


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

* Re: [PATCH v2 6/8] ASoC: meson: switch to use snd_soc_daifmt_parse_format/clock_provider()
  2021-06-09  2:16 ` [PATCH v2 6/8] ASoC: meson: " Kuninori Morimoto
@ 2021-06-09  7:11   ` Jerome Brunet
  2021-06-09 23:02     ` Kuninori Morimoto
  0 siblings, 1 reply; 12+ messages in thread
From: Jerome Brunet @ 2021-06-09  7:11 UTC (permalink / raw)
  To: Kuninori Morimoto, Liam Girdwood, Mark Brown
  Cc: Alexandre Belloni, Timur Tabi, Xiubo Li, Martin Blumenstingl,
	Shengjiu Wang, Sameer Pujar, Neil Armstrong, Nicolas Ferre,
	Nicolin Chen, Ludovic Desroches, Kevin Hilman, Codrin Ciubotariu,
	alsa-devel, Fabio Estevam


On Wed 09 Jun 2021 at 04:16, Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> wrote:

> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>
> This patch switch to use snd_soc_daifmt_parse_format/clock_provider() from
> snd_soc_of_parse_daifmt().
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  sound/soc/meson/meson-card-utils.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/sound/soc/meson/meson-card-utils.c b/sound/soc/meson/meson-card-utils.c
> index 300ac8be46ef..779ac282e36d 100644
> --- a/sound/soc/meson/meson-card-utils.c
> +++ b/sound/soc/meson/meson-card-utils.c
> @@ -118,24 +118,25 @@ unsigned int meson_card_parse_daifmt(struct device_node *node,
>  	struct device_node *bitclkmaster = NULL;
>  	struct device_node *framemaster = NULL;
>  	unsigned int daifmt;
> +	unsigned int daiclk;

Why did you need to add this local ? 

>  
> -	daifmt = snd_soc_of_parse_daifmt(node, "",
> -					 &bitclkmaster, &framemaster);
> -	daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
> +	daifmt = snd_soc_daifmt_parse_format(node, NULL);
> +
> +	snd_soc_daifmt_parse_clock_provider_as_phandle(node, NULL, &bitclkmaster, &framemaster);
>

Thanks for this

>  	/* If no master is provided, default to cpu master */
>  	if (!bitclkmaster || bitclkmaster == cpu_node) {
> -		daifmt |= (!framemaster || framemaster == cpu_node) ?
> +		daiclk = (!framemaster || framemaster == cpu_node) ?
>  			SND_SOC_DAIFMT_CBS_CFS : SND_SOC_DAIFMT_CBS_CFM;
>  	} else {
> -		daifmt |= (!framemaster || framemaster == cpu_node) ?
> +		daiclk = (!framemaster || framemaster == cpu_node) ?
>  			SND_SOC_DAIFMT_CBM_CFS : SND_SOC_DAIFMT_CBM_CFM;
>  	}
>  
>  	of_node_put(bitclkmaster);
>  	of_node_put(framemaster);
>  
> -	return daifmt;
> +	return daifmt | daiclk;

These 3 last changes does seem to necessary

>  }
>  EXPORT_SYMBOL_GPL(meson_card_parse_daifmt);


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

* Re: [PATCH v2 6/8] ASoC: meson: switch to use snd_soc_daifmt_parse_format/clock_provider()
  2021-06-09  7:11   ` Jerome Brunet
@ 2021-06-09 23:02     ` Kuninori Morimoto
  0 siblings, 0 replies; 12+ messages in thread
From: Kuninori Morimoto @ 2021-06-09 23:02 UTC (permalink / raw)
  To: Jerome Brunet
  Cc: alsa-devel, Alexandre Belloni, Timur Tabi, Xiubo Li,
	Martin Blumenstingl, Shengjiu Wang, Sameer Pujar, Neil Armstrong,
	Nicolas Ferre, Liam Girdwood, Nicolin Chen, Ludovic Desroches,
	Mark Brown, Kevin Hilman, Codrin Ciubotariu, Fabio Estevam


Hi Jerome

Thank you for your feedback

> > @@ -118,24 +118,25 @@ unsigned int meson_card_parse_daifmt(struct device_node *node,
> >  	struct device_node *bitclkmaster = NULL;
> >  	struct device_node *framemaster = NULL;
> >  	unsigned int daifmt;
> > +	unsigned int daiclk;
> 
> Why did you need to add this local ?

If you don't like using daiclk here,
I can merge these into daifmt.
I will wait other feedback, and will post patch next week.

Thank you for your help !!

Best regards
---
Kuninori Morimoto

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

end of thread, other threads:[~2021-06-09 23:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09  2:07 [PATCH v2 0/8] ASoC: tidyup snd_soc_of_parse_daifmt() Kuninori Morimoto
2021-06-09  2:13 ` [PATCH v2 1/8] ASoC: soc-core: add snd_soc_daifmt_clock_provider_from_bitmap() Kuninori Morimoto
2021-06-09  2:14 ` [PATCH v2 2/8] ASoC: soc-core: add snd_soc_daifmt_clock_provider_fliped() Kuninori Morimoto
2021-06-09  2:15 ` [PATCH v2 3/8] ASoC: soc-core: add snd_soc_daifmt_parse_format/clock_provider() Kuninori Morimoto
2021-06-09  2:15 ` [PATCH v2 4/8] ASoC: atmel: switch to use snd_soc_daifmt_parse_format/clock_provider() Kuninori Morimoto
2021-06-09  2:16 ` [PATCH v2 5/8] ASoC: fsl: " Kuninori Morimoto
2021-06-09  2:16 ` [PATCH v2 6/8] ASoC: meson: " Kuninori Morimoto
2021-06-09  7:11   ` Jerome Brunet
2021-06-09 23:02     ` Kuninori Morimoto
2021-06-09  2:16 ` [PATCH v2 7/8] ASoC: simple-card-utils: " Kuninori Morimoto
2021-06-09  2:17 ` [PATCH v2 8/8] ASoC: soc-core: remove snd_soc_of_parse_daifmt() Kuninori Morimoto
2021-06-09  5:27 ` [PATCH v2 9/8] ASoC: soc-core: add comment of return value for snd_soc_daifmt_parse_clock_provider_raw() Kuninori Morimoto

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.