Devicetree
 help / color / mirror / Atom feed
* [PATCH 0/2] ASoC: codecs: nau8360: Add DSP fallback and PEQ band initialization
@ 2026-09-04  2:44 Neo Chang
  2026-09-04  2:44 ` [PATCH 1/2] ASoC: codecs: nau8360: Set DAC path to bypass mode when DSP firmware load fails Neo Chang
  2026-09-04  2:44 ` [PATCH 2/2] ASoC: codecs: nau8360: Add default PEQ band number for DSP init Neo Chang
  0 siblings, 2 replies; 5+ messages in thread
From: Neo Chang @ 2026-09-04  2:44 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, perex, robh, krzk+dt, linux-sound, devicetree,
	alsa-devel, neo.chang70, kchsu0, sjlin0, Neo Chang

This patch series adds a fallback mechanism for the NAU8360 DSP during 
firmware load failure and ensures proper initialization for PEQ bands.

It includes the following changes:
- Fallback to bypass mode automatically when DSP firmware fails to load,
  ensuring basic audio playback remains functional.
- Set a default PEQ band number during DSP initialization to prevent
  invalid state or uninitialized parameters before user configuration
  is applied.

Neo Chang (2):
  ASoC: codecs: nau8360: Set DAC path to bypass mode when DSP firmware
    load fails
  ASoC: codecs: nau8360: Add default PEQ band number for DSP init

 sound/soc/codecs/nau8360.c | 3 +++
 1 file changed, 3 insertions(+)

-- 
2.25.1


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

* [PATCH 1/2] ASoC: codecs: nau8360: Set DAC path to bypass mode when DSP firmware load fails
  2026-09-04  2:44 [PATCH 0/2] ASoC: codecs: nau8360: Add DSP fallback and PEQ band initialization Neo Chang
@ 2026-09-04  2:44 ` Neo Chang
  2026-09-04  2:55   ` sashiko-bot
  2026-09-04  2:44 ` [PATCH 2/2] ASoC: codecs: nau8360: Add default PEQ band number for DSP init Neo Chang
  1 sibling, 1 reply; 5+ messages in thread
From: Neo Chang @ 2026-09-04  2:44 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, perex, robh, krzk+dt, linux-sound, devicetree,
	alsa-devel, neo.chang70, kchsu0, sjlin0, Neo Chang

Automatically route the DAC path to bypass mode if DSP firmware fails
to load, ensuring basic audio playback remains functional.

Signed-off-by: Neo Chang <YLCHANG2@nuvoton.com>
---
 sound/soc/codecs/nau8360.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/codecs/nau8360.c b/sound/soc/codecs/nau8360.c
index d7af2dffb749..b3cf207eea86 100644
--- a/sound/soc/codecs/nau8360.c
+++ b/sound/soc/codecs/nau8360.c
@@ -1702,6 +1702,7 @@ static void nau8360_load_fw_work(struct work_struct *work)
 	if (ret) {
 		dev_err(nau8360->dev, "Failed to initialize DSP: %d\n", ret);
 		nau8360_dsp_enable(nau8360->regmap, false);
+		snd_soc_component_write(cp, NAU8360_R12_PATH_CTRL, NAU8360_DAC_SEL_BYP);
 		return;
 	}
 	nau8360->load_fw_done = true;
-- 
2.25.1


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

* [PATCH 2/2] ASoC: codecs: nau8360: Add default PEQ band number for DSP init
  2026-09-04  2:44 [PATCH 0/2] ASoC: codecs: nau8360: Add DSP fallback and PEQ band initialization Neo Chang
  2026-09-04  2:44 ` [PATCH 1/2] ASoC: codecs: nau8360: Set DAC path to bypass mode when DSP firmware load fails Neo Chang
@ 2026-09-04  2:44 ` Neo Chang
  2026-09-04  2:51   ` sashiko-bot
  1 sibling, 1 reply; 5+ messages in thread
From: Neo Chang @ 2026-09-04  2:44 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, perex, robh, krzk+dt, linux-sound, devicetree,
	alsa-devel, neo.chang70, kchsu0, sjlin0, Neo Chang

Set a default PEQ band number during DSP initialization to prevent
invalid state or uninitialized parameters before user configuration
is applied.

Signed-off-by: Neo Chang <YLCHANG2@nuvoton.com>
---
 sound/soc/codecs/nau8360.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/soc/codecs/nau8360.c b/sound/soc/codecs/nau8360.c
index b3cf207eea86..5a94e9a3072a 100644
--- a/sound/soc/codecs/nau8360.c
+++ b/sound/soc/codecs/nau8360.c
@@ -1602,6 +1602,8 @@ static void nau8360_coeff_set_def(struct nau8360 *nau8360)
 			i * NAU8360_TOT_BAND_COE_RANGE, 0x20);
 	}
 	nau8360_peq_mem_enable(regmap, false);
+	regmap_update_bits(regmap, NAU8360_R9D_PEQ_CTL, NAU8360_PEQ_BAND_MASK,
+		NAU8360_PEQ_BAND_8);
 	mutex_unlock(&nau8360->lock);
 }
 
-- 
2.25.1


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

* Re: [PATCH 2/2] ASoC: codecs: nau8360: Add default PEQ band number for DSP init
  2026-09-04  2:44 ` [PATCH 2/2] ASoC: codecs: nau8360: Add default PEQ band number for DSP init Neo Chang
@ 2026-09-04  2:51   ` sashiko-bot
  0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-09-04  2:51 UTC (permalink / raw)
  To: Neo Chang; +Cc: devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Missing bit shift for NAU8360_PEQ_BAND_8 causes the PEQ band field to be incorrectly cleared to 0 instead of being set to 8.
--

commit dcc017a933844c3bdb0f174e1e0108fe17fff20e
Author: Neo Chang <YLCHANG2@nuvoton.com>

ASoC: codecs: nau8360: Add default PEQ band number for DSP init

This commit sets a default PEQ band number during DSP initialization in the
nau8360 codec. The goal is to prevent invalid states or uninitialized
parameters before user configuration is applied.

> diff --git a/sound/soc/codecs/nau8360.c b/sound/soc/codecs/nau8360.c
> index b3cf207eea86d..5a94e9a3072a5 100644
> --- a/sound/soc/codecs/nau8360.c
> +++ b/sound/soc/codecs/nau8360.c
> @@ -1602,6 +1602,8 @@ static void nau8360_coeff_set_def(struct nau8360 *nau8360)
>  			i * NAU8360_TOT_BAND_COE_RANGE, 0x20);
>  	}
>  	nau8360_peq_mem_enable(regmap, false);
> +	regmap_update_bits(regmap, NAU8360_R9D_PEQ_CTL, NAU8360_PEQ_BAND_MASK,
> +		NAU8360_PEQ_BAND_8);

[Severity: High]
Does this code clear the band field to 0 instead of setting it to 8?

In sound/soc/codecs/nau8360.h, NAU8360_PEQ_BAND_MASK is shifted:

#define NAU8360_PEQ_BAND_MASK (0xf << NAU8360_PEQ_BAND_SFT)

But NAU8360_PEQ_BAND_8 evaluates to 8 unshifted. Because it is passed
without the shift here, the value applied against the shifted mask becomes
zero.

Other uses of this field in the driver explicitly shift the value,
such as:

regmap_update_bits(regmap, NAU8360_R9D_PEQ_CTL, NAU8360_PEQ_BAND_MASK,
	value << NAU8360_PEQ_BAND_SFT);

Could this regression in the bit shift cause incorrect DSP initialization?

>  	mutex_unlock(&nau8360->lock);
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260904024456.193528-1-YLCHANG2@nuvoton.com?part=2

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

* Re: [PATCH 1/2] ASoC: codecs: nau8360: Set DAC path to bypass mode when DSP firmware load fails
  2026-09-04  2:44 ` [PATCH 1/2] ASoC: codecs: nau8360: Set DAC path to bypass mode when DSP firmware load fails Neo Chang
@ 2026-09-04  2:55   ` sashiko-bot
  0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-09-04  2:55 UTC (permalink / raw)
  To: Neo Chang; +Cc: robh, devicetree, conor+dt

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Using `snd_soc_component_write` overwrites the entire `NAU8360_R12_PATH_CTRL` register, unintentionally clearing other critical audio path routing configurations.
- [Medium] Modifying a DAPM-controlled hardware mux register directly bypasses ASoC DAPM state tracking and locking.
--

commit 6a6b1e851a10df0446b789100342efda63bba458
Author: Neo Chang <YLCHANG2@nuvoton.com>
ASoC: codecs: nau8360: Set DAC path to bypass mode when DSP firmware load fails

This commit automatically routes the DAC path to bypass mode if the DSP
firmware fails to load. This is intended to keep basic audio playback
functional as a fallback mechanism.

> diff --git a/sound/soc/codecs/nau8360.c b/sound/soc/codecs/nau8360.c
> index d7af2dffb749a..b3cf207eea86d 100644
> --- a/sound/soc/codecs/nau8360.c
> +++ b/sound/soc/codecs/nau8360.c
> @@ -1702,6 +1702,7 @@ static void nau8360_load_fw_work(struct work_struct *work)
>  	if (ret) {
>  		dev_err(nau8360->dev, "Failed to initialize DSP: %d\n", ret);
>  		nau8360_dsp_enable(nau8360->regmap, false);
> +		snd_soc_component_write(cp, NAU8360_R12_PATH_CTRL, NAU8360_DAC_SEL_BYP);

[Severity: High]
Does this overwrite the entire NAU8360_R12_PATH_CTRL register?

Since NAU8360_DAC_SEL_BYP evaluates to 0, using snd_soc_component_write()
writes 0x0000 to the entire 16-bit register instead of selectively masking
the target bits. This would unintentionally clear other critical hardware
audio routing configurations (such as NAU8360_SEL_HW1_OUT,
NAU8360_AUD_SEL_SINCOUT, etc.) initialized during probe, completely breaking
audio playback rather than falling back to bypass mode.

Should this use snd_soc_component_update_bits() instead to safely update
only the DAC selection bits without clobbering the rest of the register?

[Severity: Medium]
Does modifying this hardware mux register directly circumvent ASoC DAPM state
tracking and locking?

The DAC selection bits in NAU8360_R12_PATH_CTRL are exposed to userspace
and managed by DAPM as a mux control (nau8360_dac_mux). Writing to this
register directly from a background worker introduces race conditions against
concurrent userspace ALSA control changes. Additionally, the software DAPM
graph falls out of sync with the physical hardware, which could cause DAPM
to incorrectly leave DSP widgets powered up and fail to apply power to the
bypass path widgets.

Should this hardware path change be routed through the appropriate kcontrol
or DAPM interfaces to ensure the graph and power states are correctly
re-evaluated?

>  		return;
>  	}
>  	nau8360->load_fw_done = true;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260904024456.193528-1-YLCHANG2@nuvoton.com?part=1

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

end of thread, other threads:[~2026-09-04  2:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04  2:44 [PATCH 0/2] ASoC: codecs: nau8360: Add DSP fallback and PEQ band initialization Neo Chang
2026-09-04  2:44 ` [PATCH 1/2] ASoC: codecs: nau8360: Set DAC path to bypass mode when DSP firmware load fails Neo Chang
2026-09-04  2:55   ` sashiko-bot
2026-09-04  2:44 ` [PATCH 2/2] ASoC: codecs: nau8360: Add default PEQ band number for DSP init Neo Chang
2026-09-04  2:51   ` sashiko-bot

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