All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] ASoC: atmel: mchp-spdifrx: Fix format handling and MR configuration
@ 2026-11-20  3:59 phucduc.bui
  2026-11-20  3:59 ` [RFC PATCH 1/2] ASoC: atmel: mchp-spdifrx: Fix 16-bit big-endian format check phucduc.bui
  2026-11-20  3:59 ` [RFC PATCH 2/2] ASoC: atmel: mchp-spdifrx: Preserve MR defaults in hw_params phucduc.bui
  0 siblings, 2 replies; 5+ messages in thread
From: phucduc.bui @ 2026-11-20  3:59 UTC (permalink / raw)
  To: Mark Brown, Claudiu Beznea, Andrei Simion, Nicolas Ferre,
	Alexandre Belloni
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linux-sound,
	linux-arm-kernel, linux-kernel, bui duc phuc

From: bui duc phuc <phucduc.bui@gmail.com>

Hi all,

This series addresses two issues in the mchp-spdifrx driver: inconsistent 
handling of the 16-bit big-endian format and MR register updates 
in hw_params().

This series was developed on top of the previous series:
https://lore.kernel.org/all/20261119103413.31729-1-phucduc.bui@gmail.com/

Since this is an RFC series, I have kept it separate rather than including 
these changes in the previous series. The previous series should be 
applied first to avoid conflicts when applying these patches.

The changes are not hardware-tested, and I would appreciate feedback from 
someone with access to the hardware.

In particular, the MR register change needs verification. If the current 
code works as expected, the existing full-register write in hw_params() 
may be intentional, and the actual issue could instead be the default 
configuration in dai_probe().

For the 16-bit big-endian format, the current format check is clearly 
inconsistent with MCHP_SPDIF_FORMATS. However, it is also possible that 
the advertised format should be corrected instead of changing the check 
in hw_params(). Furthermore, I could not find datasheet documentation 
confirming support for big-endian 16-bit and 20-bit formats.

Therefore, hardware testing is needed to determine whether these changes 
are correct.

Compile-tested only.

Best regards,
Phuc

bui duc phuc (2):
  ASoC: atmel: mchp-spdifrx: Fix 16-bit big-endian format check
  ASoC: atmel: mchp-spdifrx: Preserve MR defaults in hw_params

 sound/soc/atmel/mchp-spdifrx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

-- 
2.43.0


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

* [RFC PATCH 1/2] ASoC: atmel: mchp-spdifrx: Fix 16-bit big-endian format check
  2026-11-20  3:59 [RFC PATCH 0/2] ASoC: atmel: mchp-spdifrx: Fix format handling and MR configuration phucduc.bui
@ 2026-11-20  3:59 ` phucduc.bui
  2026-11-20  4:07   ` sashiko-bot
  2026-11-20  3:59 ` [RFC PATCH 2/2] ASoC: atmel: mchp-spdifrx: Preserve MR defaults in hw_params phucduc.bui
  1 sibling, 1 reply; 5+ messages in thread
From: phucduc.bui @ 2026-11-20  3:59 UTC (permalink / raw)
  To: Mark Brown, Claudiu Beznea, Andrei Simion, Nicolas Ferre,
	Alexandre Belloni
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linux-sound,
	linux-arm-kernel, linux-kernel, bui duc phuc

From: bui duc phuc <phucduc.bui@gmail.com>

MCHP_SPDIF_FORMATS advertises SNDRV_PCM_FMTBIT_U16_BE as a
supported format, but mchp_spdifrx_hw_params() checks for
SNDRV_PCM_FORMAT_S16_BE instead.

Replace SNDRV_PCM_FORMAT_S16_BE with SNDRV_PCM_FORMAT_U16_BE
to make the format check consistent with the advertised
supported formats.

Fixes: ef265c55c1ac ("ASoC: mchp-spdifrx: add driver for SPDIF RX")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---

Note: 
The SAMA7G5 datasheet does not explicitly document support for
16-bit and 20-bit big-endian samples. This change only makes
the format check consistent with MCHP_SPDIF_FORMATS.
Hardware testing on SAMA7G5 is needed to confirm whether these
formats are actually supported.

 sound/soc/atmel/mchp-spdifrx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/atmel/mchp-spdifrx.c b/sound/soc/atmel/mchp-spdifrx.c
index 632da8d7bc81..06a2a5a90a63 100644
--- a/sound/soc/atmel/mchp-spdifrx.c
+++ b/sound/soc/atmel/mchp-spdifrx.c
@@ -455,7 +455,7 @@ static int mchp_spdifrx_hw_params(struct snd_pcm_substream *substream,
 	}
 
 	switch (params_format(params)) {
-	case SNDRV_PCM_FORMAT_S16_BE:
+	case SNDRV_PCM_FORMAT_U16_BE:
 	case SNDRV_PCM_FORMAT_S20_3BE:
 	case SNDRV_PCM_FORMAT_S24_3BE:
 	case SNDRV_PCM_FORMAT_S24_BE:
-- 
2.43.0


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

* [RFC PATCH 2/2] ASoC: atmel: mchp-spdifrx: Preserve MR defaults in hw_params
  2026-11-20  3:59 [RFC PATCH 0/2] ASoC: atmel: mchp-spdifrx: Fix format handling and MR configuration phucduc.bui
  2026-11-20  3:59 ` [RFC PATCH 1/2] ASoC: atmel: mchp-spdifrx: Fix 16-bit big-endian format check phucduc.bui
@ 2026-11-20  3:59 ` phucduc.bui
  1 sibling, 0 replies; 5+ messages in thread
From: phucduc.bui @ 2026-11-20  3:59 UTC (permalink / raw)
  To: Mark Brown, Claudiu Beznea, Andrei Simion, Nicolas Ferre,
	Alexandre Belloni
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linux-sound,
	linux-arm-kernel, linux-kernel, bui duc phuc

From: bui duc phuc <phucduc.bui@gmail.com>

hw_params() overwrites the entire MR register, clearing the
VBMODE and SBMODE bits configured in dai_probe().

Use regmap_update_bits() to update only the ENDIAN and DATAWIDTH
fields, preserving the other MR bits.

Fixes: fa09fa60385a ("ASoC: mchp-spdifrx: fix controls which rely on rsr register")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---

Note: 
Hardware testing on SAMA7G5 is needed to verify this change.
If the current full-register write is intentional, the issue
may instead be in the default MR configuration in dai_probe().

 sound/soc/atmel/mchp-spdifrx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/atmel/mchp-spdifrx.c b/sound/soc/atmel/mchp-spdifrx.c
index 06a2a5a90a63..e37470165717 100644
--- a/sound/soc/atmel/mchp-spdifrx.c
+++ b/sound/soc/atmel/mchp-spdifrx.c
@@ -502,7 +502,9 @@ static int mchp_spdifrx_hw_params(struct snd_pcm_substream *substream,
 	dev_dbg(dev->dev, "GCLK range min set to %d\n",
 		params_rate(params) * SPDIFRX_GCLK_RATIO_MIN + 1);
 
-	ret = regmap_write(dev->regmap, SPDIFRX_MR, mr);
+	ret = regmap_update_bits(dev->regmap, SPDIFRX_MR,
+				 SPDIFRX_MR_ENDIAN_MASK | SPDIFRX_MR_DATAWIDTH_MASK,
+				 mr);
 
 unlock:
 	mutex_unlock(&dev->mlock);
-- 
2.43.0


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

* Re: [RFC PATCH 1/2] ASoC: atmel: mchp-spdifrx: Fix 16-bit big-endian format check
  2026-11-20  3:59 ` [RFC PATCH 1/2] ASoC: atmel: mchp-spdifrx: Fix 16-bit big-endian format check phucduc.bui
@ 2026-11-20  4:07   ` sashiko-bot
  2026-11-20 10:30     ` Bui Duc Phuc
  0 siblings, 1 reply; 5+ messages in thread
From: sashiko-bot @ 2026-11-20  4:07 UTC (permalink / raw)
  To: phucduc.bui; +Cc: linux-sound

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ASoC: atmel: mchp-spdifrx: wrong 16-bit BE format in
  mchp_spdifrx_hw_params()
--

commit 35438546e4acb88091a245628184b5c5fc916afd
Author: bui duc phuc <phucduc.bui@gmail.com>

ASoC: atmel: mchp-spdifrx: Fix 16-bit big-endian format check

This commit replaces SNDRV_PCM_FORMAT_S16_BE with SNDRV_PCM_FORMAT_U16_BE
in mchp_spdifrx_hw_params() to match MCHP_SPDIF_FORMATS.

> diff --git a/sound/soc/atmel/mchp-spdifrx.c b/sound/soc/atmel/mchp-spdifrx.c
> index 63089ac3ebdc9..80a64af0878b5 100644
> --- a/sound/soc/atmel/mchp-spdifrx.c
> +++ b/sound/soc/atmel/mchp-spdifrx.c
> @@ -455,7 +455,7 @@ static int mchp_spdifrx_hw_params(struct snd_pcm_substream *substream,
>  	}
>  
>  	switch (params_format(params)) {
> -	case SNDRV_PCM_FORMAT_S16_BE:
> +	case SNDRV_PCM_FORMAT_U16_BE:
>  	case SNDRV_PCM_FORMAT_S20_3BE:
>  	case SNDRV_PCM_FORMAT_S24_3BE:
>  	case SNDRV_PCM_FORMAT_S24_BE:

[Severity: Medium]
Should MCHP_SPDIF_FORMATS be changed from SNDRV_PCM_FMTBIT_U16_BE to
SNDRV_PCM_FMTBIT_S16_BE instead?

IEC-60958 linear PCM samples are signed two's-complement values, and
SPDIFRX_MR_ENDIAN_BIG only switches the byte order in SPDIFRX_MR without
converting signed samples to unsigned.  All other format pairs in
MCHP_SPDIF_FORMATS are signed, and the companion linux,spdif-dir codec
(sound/soc/codecs/spdif_receiver.c) used with this controller only
supports S16_LE and S16_BE, so advertising U16_BE prevents 16-bit
big-endian capture from being negotiated (or delivers signed samples into
an unsigned stream if paired with a codec that permits U16_BE).

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120035939.12774-1-phucduc.bui@gmail.com?part=1

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

* Re: [RFC PATCH 1/2] ASoC: atmel: mchp-spdifrx: Fix 16-bit big-endian format check
  2026-11-20  4:07   ` sashiko-bot
@ 2026-11-20 10:30     ` Bui Duc Phuc
  0 siblings, 0 replies; 5+ messages in thread
From: Bui Duc Phuc @ 2026-11-20 10:30 UTC (permalink / raw)
  To: sashiko-reviews; +Cc: linux-sound

>
> [Severity: Medium]
> Should MCHP_SPDIF_FORMATS be changed from SNDRV_PCM_FMTBIT_U16_BE to
> SNDRV_PCM_FMTBIT_S16_BE instead?
>
> IEC-60958 linear PCM samples are signed two's-complement values, and
> SPDIFRX_MR_ENDIAN_BIG only switches the byte order in SPDIFRX_MR without
> converting signed samples to unsigned.  All other format pairs in
> MCHP_SPDIF_FORMATS are signed, and the companion linux,spdif-dir codec
> (sound/soc/codecs/spdif_receiver.c) used with this controller only
> supports S16_LE and S16_BE, so advertising U16_BE prevents 16-bit
> big-endian capture from being negotiated (or delivers signed samples into
> an unsigned stream if paired with a codec that permits U16_BE).
>


The SAMA7G5 datasheet does not explicitly document support for 16-bit
big-endian samples in the SPDIFRX block.
I think hardware testing is needed to confirm this before changing
MCHP_SPDIF_FORMATS.

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

end of thread, other threads:[~2026-11-20 10:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20  3:59 [RFC PATCH 0/2] ASoC: atmel: mchp-spdifrx: Fix format handling and MR configuration phucduc.bui
2026-11-20  3:59 ` [RFC PATCH 1/2] ASoC: atmel: mchp-spdifrx: Fix 16-bit big-endian format check phucduc.bui
2026-11-20  4:07   ` sashiko-bot
2026-11-20 10:30     ` Bui Duc Phuc
2026-11-20  3:59 ` [RFC PATCH 2/2] ASoC: atmel: mchp-spdifrx: Preserve MR defaults in hw_params phucduc.bui

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.