Linux-Amlogic Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] ASoC: meson: axg fixes and clean-up
@ 2024-02-23 17:51 Jerome Brunet
  2024-02-23 17:51 ` [PATCH 1/6] ASoC: meson: axg-tdm-interface: fix mclk setup without mclk-fs Jerome Brunet
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Jerome Brunet @ 2024-02-23 17:51 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Jerome Brunet, alsa-devel, linux-kernel, linux-amlogic

This are various fixes and clean up gathered while working on Amlogic audio
support. These help better handle higher and unusual clock configuration
for TDM, SPDIF or PDM.

Jerome Brunet (6):
  ASoC: meson: axg-tdm-interface: fix mclk setup without mclk-fs
  ASoC: meson: axg-tdm-interface: add frame rate constraint
  ASoC: meson: axg-tdm-interface: update error format error traces
  ASoC: meson: axg-spdifin: use max width for rate detection
  ASoC: meson: axg-fifo: take continuous rates
  ASoC: meson: axg-fifo: use FIELD helpers

 sound/soc/meson/axg-fifo.c          | 24 +++++++++++-----------
 sound/soc/meson/axg-fifo.h          | 14 +++++--------
 sound/soc/meson/axg-frddr.c         | 12 +++++++----
 sound/soc/meson/axg-spdifin.c       |  6 +++---
 sound/soc/meson/axg-tdm-interface.c | 31 +++++++++++++++++++----------
 sound/soc/meson/axg-toddr.c         | 29 ++++++++++++++-------------
 6 files changed, 64 insertions(+), 52 deletions(-)

-- 
2.43.0


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* [PATCH 1/6] ASoC: meson: axg-tdm-interface: fix mclk setup without mclk-fs
  2024-02-23 17:51 [PATCH 0/6] ASoC: meson: axg fixes and clean-up Jerome Brunet
@ 2024-02-23 17:51 ` Jerome Brunet
  2024-02-23 17:51 ` [PATCH 2/6] ASoC: meson: axg-tdm-interface: add frame rate constraint Jerome Brunet
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Jerome Brunet @ 2024-02-23 17:51 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Jerome Brunet, alsa-devel, linux-kernel, linux-amlogic

By default, when mclk-fs is not provided, the tdm-interface driver
requests an MCLK that is 4x the bit clock, SCLK.

However there is no justification for this:

* If the codec needs MCLK for its operation, mclk-fs is expected to be set
  according to the codec requirements.
* If the codec does not need MCLK the minimum is 2 * SCLK, because this is
  minimum the divider between SCLK and MCLK can do.

Multiplying by 4 may cause problems because the PLL limit may be reached
sooner than it should, so use 2x instead.

Fixes: d60e4f1e4be5 ("ASoC: meson: add tdm interface driver")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
 sound/soc/meson/axg-tdm-interface.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/meson/axg-tdm-interface.c b/sound/soc/meson/axg-tdm-interface.c
index 1c3d433cefd2..cd5168e826df 100644
--- a/sound/soc/meson/axg-tdm-interface.c
+++ b/sound/soc/meson/axg-tdm-interface.c
@@ -264,8 +264,8 @@ static int axg_tdm_iface_set_sclk(struct snd_soc_dai *dai,
 	srate = iface->slots * iface->slot_width * params_rate(params);
 
 	if (!iface->mclk_rate) {
-		/* If no specific mclk is requested, default to bit clock * 4 */
-		clk_set_rate(iface->mclk, 4 * srate);
+		/* If no specific mclk is requested, default to bit clock * 2 */
+		clk_set_rate(iface->mclk, 2 * srate);
 	} else {
 		/* Check if we can actually get the bit clock from mclk */
 		if (iface->mclk_rate % srate) {
-- 
2.43.0


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* [PATCH 2/6] ASoC: meson: axg-tdm-interface: add frame rate constraint
  2024-02-23 17:51 [PATCH 0/6] ASoC: meson: axg fixes and clean-up Jerome Brunet
  2024-02-23 17:51 ` [PATCH 1/6] ASoC: meson: axg-tdm-interface: fix mclk setup without mclk-fs Jerome Brunet
@ 2024-02-23 17:51 ` Jerome Brunet
  2024-02-23 17:51 ` [PATCH 3/6] ASoC: meson: axg-tdm-interface: update error format error traces Jerome Brunet
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Jerome Brunet @ 2024-02-23 17:51 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Jerome Brunet, alsa-devel, linux-kernel, linux-amlogic

According to Amlogic datasheets for the SoCs supported by this driver, the
maximum bit clock rate is 100MHz.

The tdm interface allows the rates listed by the DAI driver, regardless of
the number slots or their width. However, these will impact the bit clock
rate.

Hitting the 100MHz limit is very unlikely for most use cases but it is
possible.

For example with 32 slots / 32 bits wide, the maximum rate is no longer
384kHz but ~96kHz.

Add the constraint accordingly if the component is not already active.
If it is active, the rate is already constrained by the first stream rate.

Fixes: d60e4f1e4be5 ("ASoC: meson: add tdm interface driver")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
 sound/soc/meson/axg-tdm-interface.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/sound/soc/meson/axg-tdm-interface.c b/sound/soc/meson/axg-tdm-interface.c
index cd5168e826df..2cedbce73837 100644
--- a/sound/soc/meson/axg-tdm-interface.c
+++ b/sound/soc/meson/axg-tdm-interface.c
@@ -12,6 +12,9 @@
 
 #include "axg-tdm.h"
 
+/* Maximum bit clock frequency according the datasheets */
+#define MAX_SCLK 100000000 /* Hz */
+
 enum {
 	TDM_IFACE_PAD,
 	TDM_IFACE_LOOPBACK,
@@ -153,19 +156,27 @@ static int axg_tdm_iface_startup(struct snd_pcm_substream *substream,
 		return -EINVAL;
 	}
 
-	/* Apply component wide rate symmetry */
 	if (snd_soc_component_active(dai->component)) {
+		/* Apply component wide rate symmetry */
 		ret = snd_pcm_hw_constraint_single(substream->runtime,
 						   SNDRV_PCM_HW_PARAM_RATE,
 						   iface->rate);
-		if (ret < 0) {
-			dev_err(dai->dev,
-				"can't set iface rate constraint\n");
-			return ret;
-		}
+
+	} else {
+		/* Limit rate according to the slot number and width */
+		unsigned int max_rate =
+			MAX_SCLK / (iface->slots * iface->slot_width);
+		ret = snd_pcm_hw_constraint_minmax(substream->runtime,
+						   SNDRV_PCM_HW_PARAM_RATE,
+						   0, max_rate);
 	}
 
-	return 0;
+	if (ret < 0)
+		dev_err(dai->dev, "can't set iface rate constraint\n");
+	else
+		ret = 0;
+
+	return ret;
 }
 
 static int axg_tdm_iface_set_stream(struct snd_pcm_substream *substream,
-- 
2.43.0


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* [PATCH 3/6] ASoC: meson: axg-tdm-interface: update error format error traces
  2024-02-23 17:51 [PATCH 0/6] ASoC: meson: axg fixes and clean-up Jerome Brunet
  2024-02-23 17:51 ` [PATCH 1/6] ASoC: meson: axg-tdm-interface: fix mclk setup without mclk-fs Jerome Brunet
  2024-02-23 17:51 ` [PATCH 2/6] ASoC: meson: axg-tdm-interface: add frame rate constraint Jerome Brunet
@ 2024-02-23 17:51 ` Jerome Brunet
  2024-02-23 17:51 ` [PATCH 4/6] ASoC: meson: axg-spdifin: use max width for rate detection Jerome Brunet
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Jerome Brunet @ 2024-02-23 17:51 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Jerome Brunet, alsa-devel, linux-kernel, linux-amlogic

ASoC stopped using CBS_CFS and CBM_CFM a few years ago but the traces in
the amlogic tdm interface driver did not follow.

Update this to match the new format names

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
 sound/soc/meson/axg-tdm-interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/meson/axg-tdm-interface.c b/sound/soc/meson/axg-tdm-interface.c
index 2cedbce73837..bf708717635b 100644
--- a/sound/soc/meson/axg-tdm-interface.c
+++ b/sound/soc/meson/axg-tdm-interface.c
@@ -133,7 +133,7 @@ static int axg_tdm_iface_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 
 	case SND_SOC_DAIFMT_BP_FC:
 	case SND_SOC_DAIFMT_BC_FP:
-		dev_err(dai->dev, "only CBS_CFS and CBM_CFM are supported\n");
+		dev_err(dai->dev, "only BP_FP and BC_FC are supported\n");
 		fallthrough;
 	default:
 		return -EINVAL;
-- 
2.43.0


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* [PATCH 4/6] ASoC: meson: axg-spdifin: use max width for rate detection
  2024-02-23 17:51 [PATCH 0/6] ASoC: meson: axg fixes and clean-up Jerome Brunet
                   ` (2 preceding siblings ...)
  2024-02-23 17:51 ` [PATCH 3/6] ASoC: meson: axg-tdm-interface: update error format error traces Jerome Brunet
@ 2024-02-23 17:51 ` Jerome Brunet
  2024-02-23 17:51 ` [PATCH 5/6] ASoC: meson: axg-fifo: take continuous rates Jerome Brunet
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Jerome Brunet @ 2024-02-23 17:51 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Jerome Brunet, alsa-devel, linux-kernel, linux-amlogic

Use maximum width between 2 edges to setup spdifin thresholds
and detect the input sample rate. This comes from Amlogic SDK and
seems to be marginally more reliable than minimum width.

This is done to align with a future eARC support.
No issue was reported with minimum width so far, this is considered
to be an update so no Fixes tag is set.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
 sound/soc/meson/axg-spdifin.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/meson/axg-spdifin.c b/sound/soc/meson/axg-spdifin.c
index bc2f2849ecfb..e721f579321e 100644
--- a/sound/soc/meson/axg-spdifin.c
+++ b/sound/soc/meson/axg-spdifin.c
@@ -179,9 +179,9 @@ static int axg_spdifin_sample_mode_config(struct snd_soc_dai *dai,
 			   SPDIFIN_CTRL1_BASE_TIMER,
 			   FIELD_PREP(SPDIFIN_CTRL1_BASE_TIMER, rate / 1000));
 
-	/* Threshold based on the minimum width between two edges */
+	/* Threshold based on the maximum width between two edges */
 	regmap_update_bits(priv->map, SPDIFIN_CTRL0,
-			   SPDIFIN_CTRL0_WIDTH_SEL, SPDIFIN_CTRL0_WIDTH_SEL);
+			   SPDIFIN_CTRL0_WIDTH_SEL, 0);
 
 	/* Calculate the last timer which has no threshold */
 	t_next = axg_spdifin_mode_timer(priv, i, rate);
@@ -199,7 +199,7 @@ static int axg_spdifin_sample_mode_config(struct snd_soc_dai *dai,
 		axg_spdifin_write_timer(priv->map, i, t);
 
 		/* Set the threshold value */
-		axg_spdifin_write_threshold(priv->map, i, t + t_next);
+		axg_spdifin_write_threshold(priv->map, i, 3 * (t + t_next));
 
 		/* Save the current timer for the next threshold calculation */
 		t_next = t;
-- 
2.43.0


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* [PATCH 5/6] ASoC: meson: axg-fifo: take continuous rates
  2024-02-23 17:51 [PATCH 0/6] ASoC: meson: axg fixes and clean-up Jerome Brunet
                   ` (3 preceding siblings ...)
  2024-02-23 17:51 ` [PATCH 4/6] ASoC: meson: axg-spdifin: use max width for rate detection Jerome Brunet
@ 2024-02-23 17:51 ` Jerome Brunet
  2024-02-23 17:51 ` [PATCH 6/6] ASoC: meson: axg-fifo: use FIELD helpers Jerome Brunet
  2024-02-26 19:28 ` [PATCH 0/6] ASoC: meson: axg fixes and clean-up Mark Brown
  6 siblings, 0 replies; 11+ messages in thread
From: Jerome Brunet @ 2024-02-23 17:51 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Jerome Brunet, alsa-devel, linux-kernel, linux-amlogic

The rate of the stream does not matter for the fifos of the axg family.
Fifos will just push or pull data to/from the DDR according to consumption
or production of the downstream element, which is the DPCM backend.

Drop the rate list and allow continuous rates. The lower and upper rate are
set according what is known to work with the different backends

This allows the PDM input backend to also use continuous rates.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
 sound/soc/meson/axg-fifo.h  | 2 --
 sound/soc/meson/axg-frddr.c | 8 ++++++--
 sound/soc/meson/axg-toddr.c | 8 ++++++--
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/sound/soc/meson/axg-fifo.h b/sound/soc/meson/axg-fifo.h
index df528e8cb7c9..a14c31eb06d8 100644
--- a/sound/soc/meson/axg-fifo.h
+++ b/sound/soc/meson/axg-fifo.h
@@ -21,8 +21,6 @@ struct snd_soc_dai_driver;
 struct snd_soc_pcm_runtime;
 
 #define AXG_FIFO_CH_MAX			128
-#define AXG_FIFO_RATES			(SNDRV_PCM_RATE_5512 |		\
-					 SNDRV_PCM_RATE_8000_384000)
 #define AXG_FIFO_FORMATS		(SNDRV_PCM_FMTBIT_S8 |		\
 					 SNDRV_PCM_FMTBIT_S16_LE |	\
 					 SNDRV_PCM_FMTBIT_S20_LE |	\
diff --git a/sound/soc/meson/axg-frddr.c b/sound/soc/meson/axg-frddr.c
index 8c166a5f338c..98140f449eb3 100644
--- a/sound/soc/meson/axg-frddr.c
+++ b/sound/soc/meson/axg-frddr.c
@@ -109,7 +109,9 @@ static struct snd_soc_dai_driver axg_frddr_dai_drv = {
 		.stream_name	= "Playback",
 		.channels_min	= 1,
 		.channels_max	= AXG_FIFO_CH_MAX,
-		.rates		= AXG_FIFO_RATES,
+		.rates		= SNDRV_PCM_RATE_CONTINUOUS,
+		.rate_min	= 5515,
+		.rate_max	= 384000,
 		.formats	= AXG_FIFO_FORMATS,
 	},
 	.ops		= &axg_frddr_ops,
@@ -184,7 +186,9 @@ static struct snd_soc_dai_driver g12a_frddr_dai_drv = {
 		.stream_name	= "Playback",
 		.channels_min	= 1,
 		.channels_max	= AXG_FIFO_CH_MAX,
-		.rates		= AXG_FIFO_RATES,
+		.rates		= SNDRV_PCM_RATE_CONTINUOUS,
+		.rate_min	= 5515,
+		.rate_max	= 384000,
 		.formats	= AXG_FIFO_FORMATS,
 	},
 	.ops		= &g12a_frddr_ops,
diff --git a/sound/soc/meson/axg-toddr.c b/sound/soc/meson/axg-toddr.c
index 1a0be177b8fe..32ee45cce7f8 100644
--- a/sound/soc/meson/axg-toddr.c
+++ b/sound/soc/meson/axg-toddr.c
@@ -131,7 +131,9 @@ static struct snd_soc_dai_driver axg_toddr_dai_drv = {
 		.stream_name	= "Capture",
 		.channels_min	= 1,
 		.channels_max	= AXG_FIFO_CH_MAX,
-		.rates		= AXG_FIFO_RATES,
+		.rates		= SNDRV_PCM_RATE_CONTINUOUS,
+		.rate_min	= 5515,
+		.rate_max	= 384000,
 		.formats	= AXG_FIFO_FORMATS,
 	},
 	.ops		= &axg_toddr_ops,
@@ -226,7 +228,9 @@ static struct snd_soc_dai_driver g12a_toddr_dai_drv = {
 		.stream_name	= "Capture",
 		.channels_min	= 1,
 		.channels_max	= AXG_FIFO_CH_MAX,
-		.rates		= AXG_FIFO_RATES,
+		.rates		= SNDRV_PCM_RATE_CONTINUOUS,
+		.rate_min	= 5515,
+		.rate_max	= 384000,
 		.formats	= AXG_FIFO_FORMATS,
 	},
 	.ops		= &g12a_toddr_ops,
-- 
2.43.0


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* [PATCH 6/6] ASoC: meson: axg-fifo: use FIELD helpers
  2024-02-23 17:51 [PATCH 0/6] ASoC: meson: axg fixes and clean-up Jerome Brunet
                   ` (4 preceding siblings ...)
  2024-02-23 17:51 ` [PATCH 5/6] ASoC: meson: axg-fifo: take continuous rates Jerome Brunet
@ 2024-02-23 17:51 ` Jerome Brunet
  2024-02-26 15:42   ` Mark Brown
  2024-02-26 19:28 ` [PATCH 0/6] ASoC: meson: axg fixes and clean-up Mark Brown
  6 siblings, 1 reply; 11+ messages in thread
From: Jerome Brunet @ 2024-02-23 17:51 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Jerome Brunet, alsa-devel, linux-kernel, linux-amlogic

Use FIELD_GET() and FIELD_PREP() helpers instead of doing it manually.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
 sound/soc/meson/axg-fifo.c  | 24 ++++++++++++------------
 sound/soc/meson/axg-fifo.h  | 12 +++++-------
 sound/soc/meson/axg-frddr.c |  4 ++--
 sound/soc/meson/axg-toddr.c | 21 +++++++++------------
 4 files changed, 28 insertions(+), 33 deletions(-)

diff --git a/sound/soc/meson/axg-fifo.c b/sound/soc/meson/axg-fifo.c
index 65541fdb0038..597fd39e6e48 100644
--- a/sound/soc/meson/axg-fifo.c
+++ b/sound/soc/meson/axg-fifo.c
@@ -145,8 +145,8 @@ int axg_fifo_pcm_hw_params(struct snd_soc_component *component,
 	/* Enable irq if necessary  */
 	irq_en = runtime->no_period_wakeup ? 0 : FIFO_INT_COUNT_REPEAT;
 	regmap_update_bits(fifo->map, FIFO_CTRL0,
-			   CTRL0_INT_EN(FIFO_INT_COUNT_REPEAT),
-			   CTRL0_INT_EN(irq_en));
+			   CTRL0_INT_EN,
+			   FIELD_PREP(CTRL0_INT_EN, irq_en));
 
 	return 0;
 }
@@ -176,9 +176,9 @@ int axg_fifo_pcm_hw_free(struct snd_soc_component *component,
 {
 	struct axg_fifo *fifo = axg_fifo_data(ss);
 
-	/* Disable the block count irq */
+	/* Disable irqs */
 	regmap_update_bits(fifo->map, FIFO_CTRL0,
-			   CTRL0_INT_EN(FIFO_INT_COUNT_REPEAT), 0);
+			   CTRL0_INT_EN, 0);
 
 	return 0;
 }
@@ -187,13 +187,13 @@ EXPORT_SYMBOL_GPL(axg_fifo_pcm_hw_free);
 static void axg_fifo_ack_irq(struct axg_fifo *fifo, u8 mask)
 {
 	regmap_update_bits(fifo->map, FIFO_CTRL1,
-			   CTRL1_INT_CLR(FIFO_INT_MASK),
-			   CTRL1_INT_CLR(mask));
+			   CTRL1_INT_CLR,
+			   FIELD_PREP(CTRL1_INT_CLR, mask));
 
 	/* Clear must also be cleared */
 	regmap_update_bits(fifo->map, FIFO_CTRL1,
-			   CTRL1_INT_CLR(FIFO_INT_MASK),
-			   0);
+			   CTRL1_INT_CLR,
+			   FIELD_PREP(CTRL1_INT_CLR, 0));
 }
 
 static irqreturn_t axg_fifo_pcm_irq_block(int irq, void *dev_id)
@@ -204,7 +204,7 @@ static irqreturn_t axg_fifo_pcm_irq_block(int irq, void *dev_id)
 
 	regmap_read(fifo->map, FIFO_STATUS1, &status);
 
-	status = STATUS1_INT_STS(status) & FIFO_INT_MASK;
+	status = FIELD_GET(STATUS1_INT_STS, status);
 	if (status & FIFO_INT_COUNT_REPEAT)
 		snd_pcm_period_elapsed(ss);
 	else
@@ -254,15 +254,15 @@ int axg_fifo_pcm_open(struct snd_soc_component *component,
 
 	/* Setup status2 so it reports the memory pointer */
 	regmap_update_bits(fifo->map, FIFO_CTRL1,
-			   CTRL1_STATUS2_SEL_MASK,
-			   CTRL1_STATUS2_SEL(STATUS2_SEL_DDR_READ));
+			   CTRL1_STATUS2_SEL,
+			   FIELD_PREP(CTRL1_STATUS2_SEL, STATUS2_SEL_DDR_READ));
 
 	/* Make sure the dma is initially disabled */
 	__dma_enable(fifo, false);
 
 	/* Disable irqs until params are ready */
 	regmap_update_bits(fifo->map, FIFO_CTRL0,
-			   CTRL0_INT_EN(FIFO_INT_MASK), 0);
+			   CTRL0_INT_EN, 0);
 
 	/* Clear any pending interrupt */
 	axg_fifo_ack_irq(fifo, FIFO_INT_MASK);
diff --git a/sound/soc/meson/axg-fifo.h b/sound/soc/meson/axg-fifo.h
index a14c31eb06d8..4c48c0a08481 100644
--- a/sound/soc/meson/axg-fifo.h
+++ b/sound/soc/meson/axg-fifo.h
@@ -40,21 +40,19 @@ struct snd_soc_pcm_runtime;
 
 #define FIFO_CTRL0			0x00
 #define  CTRL0_DMA_EN			BIT(31)
-#define  CTRL0_INT_EN(x)		((x) << 16)
+#define  CTRL0_INT_EN			GENMASK(23, 16)
 #define  CTRL0_SEL_MASK			GENMASK(2, 0)
 #define  CTRL0_SEL_SHIFT		0
 #define FIFO_CTRL1			0x04
-#define  CTRL1_INT_CLR(x)		((x) << 0)
-#define  CTRL1_STATUS2_SEL_MASK		GENMASK(11, 8)
-#define  CTRL1_STATUS2_SEL(x)		((x) << 8)
+#define  CTRL1_INT_CLR			GENMASK(7, 0)
+#define  CTRL1_STATUS2_SEL		GENMASK(11, 8)
 #define   STATUS2_SEL_DDR_READ		0
-#define  CTRL1_FRDDR_DEPTH_MASK		GENMASK(31, 24)
-#define  CTRL1_FRDDR_DEPTH(x)		((x) << 24)
+#define  CTRL1_FRDDR_DEPTH		GENMASK(31, 24)
 #define FIFO_START_ADDR			0x08
 #define FIFO_FINISH_ADDR		0x0c
 #define FIFO_INT_ADDR			0x10
 #define FIFO_STATUS1			0x14
-#define  STATUS1_INT_STS(x)		((x) << 0)
+#define  STATUS1_INT_STS		GENMASK(7, 0)
 #define FIFO_STATUS2			0x18
 #define FIFO_INIT_ADDR			0x24
 #define FIFO_CTRL2			0x28
diff --git a/sound/soc/meson/axg-frddr.c b/sound/soc/meson/axg-frddr.c
index 98140f449eb3..97ca0ea5faa5 100644
--- a/sound/soc/meson/axg-frddr.c
+++ b/sound/soc/meson/axg-frddr.c
@@ -59,8 +59,8 @@ static int axg_frddr_dai_hw_params(struct snd_pcm_substream *substream,
 	/* Trim the FIFO depth if the period is small to improve latency */
 	depth = min(period, fifo->depth);
 	val = (depth / AXG_FIFO_BURST) - 1;
-	regmap_update_bits(fifo->map, FIFO_CTRL1, CTRL1_FRDDR_DEPTH_MASK,
-			   CTRL1_FRDDR_DEPTH(val));
+	regmap_update_bits(fifo->map, FIFO_CTRL1, CTRL1_FRDDR_DEPTH,
+			   FIELD_PREP(CTRL1_FRDDR_DEPTH, val));
 
 	return 0;
 }
diff --git a/sound/soc/meson/axg-toddr.c b/sound/soc/meson/axg-toddr.c
index 32ee45cce7f8..5b08b4e841ad 100644
--- a/sound/soc/meson/axg-toddr.c
+++ b/sound/soc/meson/axg-toddr.c
@@ -19,12 +19,9 @@
 #define CTRL0_TODDR_EXT_SIGNED		BIT(29)
 #define CTRL0_TODDR_PP_MODE		BIT(28)
 #define CTRL0_TODDR_SYNC_CH		BIT(27)
-#define CTRL0_TODDR_TYPE_MASK		GENMASK(15, 13)
-#define CTRL0_TODDR_TYPE(x)		((x) << 13)
-#define CTRL0_TODDR_MSB_POS_MASK	GENMASK(12, 8)
-#define CTRL0_TODDR_MSB_POS(x)		((x) << 8)
-#define CTRL0_TODDR_LSB_POS_MASK	GENMASK(7, 3)
-#define CTRL0_TODDR_LSB_POS(x)		((x) << 3)
+#define CTRL0_TODDR_TYPE		GENMASK(15, 13)
+#define CTRL0_TODDR_MSB_POS		GENMASK(12, 8)
+#define CTRL0_TODDR_LSB_POS		GENMASK(7, 3)
 #define CTRL1_TODDR_FORCE_FINISH	BIT(25)
 #define CTRL1_SEL_SHIFT			28
 
@@ -76,12 +73,12 @@ static int axg_toddr_dai_hw_params(struct snd_pcm_substream *substream,
 	width = params_width(params);
 
 	regmap_update_bits(fifo->map, FIFO_CTRL0,
-			   CTRL0_TODDR_TYPE_MASK |
-			   CTRL0_TODDR_MSB_POS_MASK |
-			   CTRL0_TODDR_LSB_POS_MASK,
-			   CTRL0_TODDR_TYPE(type) |
-			   CTRL0_TODDR_MSB_POS(TODDR_MSB_POS) |
-			   CTRL0_TODDR_LSB_POS(TODDR_MSB_POS - (width - 1)));
+			   CTRL0_TODDR_TYPE |
+			   CTRL0_TODDR_MSB_POS |
+			   CTRL0_TODDR_LSB_POS,
+			   FIELD_PREP(CTRL0_TODDR_TYPE, type) |
+			   FIELD_PREP(CTRL0_TODDR_MSB_POS, TODDR_MSB_POS) |
+			   FIELD_PREP(CTRL0_TODDR_LSB_POS, TODDR_MSB_POS - (width - 1)));
 
 	return 0;
 }
-- 
2.43.0


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH 6/6] ASoC: meson: axg-fifo: use FIELD helpers
  2024-02-23 17:51 ` [PATCH 6/6] ASoC: meson: axg-fifo: use FIELD helpers Jerome Brunet
@ 2024-02-26 15:42   ` Mark Brown
  2024-02-26 18:15     ` Jerome Brunet
  0 siblings, 1 reply; 11+ messages in thread
From: Mark Brown @ 2024-02-26 15:42 UTC (permalink / raw)
  To: Jerome Brunet; +Cc: Liam Girdwood, alsa-devel, linux-kernel, linux-amlogic


[-- Attachment #1.1: Type: text/plain, Size: 925 bytes --]

On Fri, Feb 23, 2024 at 06:51:12PM +0100, Jerome Brunet wrote:

> Use FIELD_GET() and FIELD_PREP() helpers instead of doing it manually.

This breaks the build for me:

/build/stage/linux/sound/soc/meson/axg-fifo.c: In function ‘axg_fifo_pcm_hw_para
ms’:
/build/stage/linux/sound/soc/meson/axg-fifo.c:149:28: error: implicit declaratio
n of function ‘FIELD_PREP’ [-Werror=implicit-function-declaration]
  149 |                            FIELD_PREP(CTRL0_INT_EN, irq_en));
      |                            ^~~~~~~~~~
/build/stage/linux/sound/soc/meson/axg-fifo.c: In function ‘axg_fifo_pcm_irq_blo
ck’:
/build/stage/linux/sound/soc/meson/axg-fifo.c:207:18: error: implicit declaratio
n of function ‘FIELD_GET’ [-Werror=implicit-function-declaration]
  207 |         status = FIELD_GET(STATUS1_INT_STS, status);
      |                  ^~~~~~~~~
cc1: all warnings being treated as errors

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 167 bytes --]

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH 6/6] ASoC: meson: axg-fifo: use FIELD helpers
  2024-02-26 15:42   ` Mark Brown
@ 2024-02-26 18:15     ` Jerome Brunet
  2024-02-26 18:22       ` Mark Brown
  0 siblings, 1 reply; 11+ messages in thread
From: Jerome Brunet @ 2024-02-26 18:15 UTC (permalink / raw)
  To: Mark Brown
  Cc: Jerome Brunet, Liam Girdwood, alsa-devel, linux-kernel,
	linux-amlogic


On Mon 26 Feb 2024 at 15:42, Mark Brown <broonie@kernel.org> wrote:

> [[PGP Signed Part:Undecided]]
> On Fri, Feb 23, 2024 at 06:51:12PM +0100, Jerome Brunet wrote:
>
>> Use FIELD_GET() and FIELD_PREP() helpers instead of doing it manually.
>
> This breaks the build for me:
>
> /build/stage/linux/sound/soc/meson/axg-fifo.c: In function ‘axg_fifo_pcm_hw_para
> ms’:
> /build/stage/linux/sound/soc/meson/axg-fifo.c:149:28: error: implicit declaratio
> n of function ‘FIELD_PREP’ [-Werror=implicit-function-declaration]
>   149 |                            FIELD_PREP(CTRL0_INT_EN, irq_en));
>       |                            ^~~~~~~~~~
> /build/stage/linux/sound/soc/meson/axg-fifo.c: In function ‘axg_fifo_pcm_irq_blo
> ck’:
> /build/stage/linux/sound/soc/meson/axg-fifo.c:207:18: error: implicit declaratio
> n of function ‘FIELD_GET’ [-Werror=implicit-function-declaration]
>   207 |         status = FIELD_GET(STATUS1_INT_STS, status);
>       |                  ^~~~~~~~~
> cc1: all warnings being treated as errors

Ah, I forgot to include <linux/bitfield.h>. Thanks for letting me know.
I'll fix it

It was fine when I tested with ARCH=arm64 and the default defconfig so
most likely it got indirectly included.

Could you tell me which ARCH/defconfig triggered this ?

>
> [[End of PGP Signed Part]]


-- 
Jerome

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH 6/6] ASoC: meson: axg-fifo: use FIELD helpers
  2024-02-26 18:15     ` Jerome Brunet
@ 2024-02-26 18:22       ` Mark Brown
  0 siblings, 0 replies; 11+ messages in thread
From: Mark Brown @ 2024-02-26 18:22 UTC (permalink / raw)
  To: Jerome Brunet; +Cc: Liam Girdwood, alsa-devel, linux-kernel, linux-amlogic


[-- Attachment #1.1: Type: text/plain, Size: 756 bytes --]

On Mon, Feb 26, 2024 at 07:15:41PM +0100, Jerome Brunet wrote:
> On Mon 26 Feb 2024 at 15:42, Mark Brown <broonie@kernel.org> wrote:

> > /build/stage/linux/sound/soc/meson/axg-fifo.c:207:18: error: implicit declaratio
> > n of function ‘FIELD_GET’ [-Werror=implicit-function-declaration]
> >   207 |         status = FIELD_GET(STATUS1_INT_STS, status);
> >       |                  ^~~~~~~~~
> > cc1: all warnings being treated as errors

> Ah, I forgot to include <linux/bitfield.h>. Thanks for letting me know.
> I'll fix it

> It was fine when I tested with ARCH=arm64 and the default defconfig so
> most likely it got indirectly included.

> Could you tell me which ARCH/defconfig triggered this ?

Probably an x86 allmodconfig.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 167 bytes --]

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH 0/6] ASoC: meson: axg fixes and clean-up
  2024-02-23 17:51 [PATCH 0/6] ASoC: meson: axg fixes and clean-up Jerome Brunet
                   ` (5 preceding siblings ...)
  2024-02-23 17:51 ` [PATCH 6/6] ASoC: meson: axg-fifo: use FIELD helpers Jerome Brunet
@ 2024-02-26 19:28 ` Mark Brown
  6 siblings, 0 replies; 11+ messages in thread
From: Mark Brown @ 2024-02-26 19:28 UTC (permalink / raw)
  To: Liam Girdwood, Jerome Brunet; +Cc: alsa-devel, linux-kernel, linux-amlogic

On Fri, 23 Feb 2024 18:51:06 +0100, Jerome Brunet wrote:
> This are various fixes and clean up gathered while working on Amlogic audio
> support. These help better handle higher and unusual clock configuration
> for TDM, SPDIF or PDM.
> 
> Jerome Brunet (6):
>   ASoC: meson: axg-tdm-interface: fix mclk setup without mclk-fs
>   ASoC: meson: axg-tdm-interface: add frame rate constraint
>   ASoC: meson: axg-tdm-interface: update error format error traces
>   ASoC: meson: axg-spdifin: use max width for rate detection
>   ASoC: meson: axg-fifo: take continuous rates
>   ASoC: meson: axg-fifo: use FIELD helpers
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/6] ASoC: meson: axg-tdm-interface: fix mclk setup without mclk-fs
      commit: e3741a8d28a1137f8b19ae6f3d6e3be69a454a0a
[2/6] ASoC: meson: axg-tdm-interface: add frame rate constraint
      commit: 59c6a3a43b221cc2a211181b1298e43b2c2df782
[3/6] ASoC: meson: axg-tdm-interface: update error format error traces
      commit: 48bbec092e4cf2fe1d3f81a889ec176e83aee695
[4/6] ASoC: meson: axg-spdifin: use max width for rate detection
      commit: a2417b6c0f9c3cc914c88face9abd6e9b9d76c00
[5/6] ASoC: meson: axg-fifo: take continuous rates
      commit: 8b410b3c46128f1eee78f1182731b84d9d2e79ef
[6/6] ASoC: meson: axg-fifo: use FIELD helpers
      (no commit info)

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

end of thread, other threads:[~2024-02-26 19:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-23 17:51 [PATCH 0/6] ASoC: meson: axg fixes and clean-up Jerome Brunet
2024-02-23 17:51 ` [PATCH 1/6] ASoC: meson: axg-tdm-interface: fix mclk setup without mclk-fs Jerome Brunet
2024-02-23 17:51 ` [PATCH 2/6] ASoC: meson: axg-tdm-interface: add frame rate constraint Jerome Brunet
2024-02-23 17:51 ` [PATCH 3/6] ASoC: meson: axg-tdm-interface: update error format error traces Jerome Brunet
2024-02-23 17:51 ` [PATCH 4/6] ASoC: meson: axg-spdifin: use max width for rate detection Jerome Brunet
2024-02-23 17:51 ` [PATCH 5/6] ASoC: meson: axg-fifo: take continuous rates Jerome Brunet
2024-02-23 17:51 ` [PATCH 6/6] ASoC: meson: axg-fifo: use FIELD helpers Jerome Brunet
2024-02-26 15:42   ` Mark Brown
2024-02-26 18:15     ` Jerome Brunet
2024-02-26 18:22       ` Mark Brown
2024-02-26 19:28 ` [PATCH 0/6] ASoC: meson: axg fixes and clean-up Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox