Block the DSP path selection if the firmware fails to load to prevent
invalid routing states.
If the firmware is not ready, nau8360_dac_mux_put_enum() will print
a rate-limited warning and return -EBUSY. This rejects the invalid
userspace request and maintains the original hardware state without
causing audio wrong status.
Reported-by: Dan Carpenter <redacted>
Closes: https://lore.kernel.org/linux-sound/aqK_oOpMAXVhxkHJ@stanley.mountain/ (local)
Suggested-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Neo Chang <redacted>
---
sound/soc/codecs/nau8360.c | 9 +++++++--
sound/soc/codecs/nau8360.h | 6 ++++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/nau8360.c b/sound/soc/codecs/nau8360.c
index 89b8ee80d6c8..f5dee12127cd 100644
--- a/sound/soc/codecs/nau8360.c
+++ b/sound/soc/codecs/nau8360.c
@@ -715,8 +715,13 @@ static int nau8360_dac_mux_put_enum(struct snd_kcontrol *kcontrol,
int ret = 0;
if (snd_soc_dapm_get_bias_level(dapm) > SND_SOC_BIAS_STANDBY) {
- dev_warn(nau8360->dev, "changing path is not allowed during playback");
- return ret;
+ dev_warn_ratelimited(nau8360->dev, "changing path is not allowed during playback");
+ return -EBUSY;
+ }
+
+ if (item[0] == NAU8360_DAC_SRC_DSP && !nau8360->load_fw_done) {
+ dev_warn_ratelimited(nau8360->dev, "Cannot enable DSP: Firmware not ready or disabled\n");
+ return -EBUSY;
}
mutex_lock(&nau8360->lock);diff --git a/sound/soc/codecs/nau8360.h b/sound/soc/codecs/nau8360.h
index cc640ba8c838..71396747c0fa 100644
--- a/sound/soc/codecs/nau8360.h
+++ b/sound/soc/codecs/nau8360.h
@@ -870,6 +870,12 @@ enum {
NAU8360_TDM_TXN,
};
+/* DAC Source Path*/
+enum {
+ NAU8360_DAC_SRC_HW1 = 0,
+ NAU8360_DAC_SRC_DSP,
+};
+
/* PLL Source */
enum {
NAU8360_PLL_MCLK,--
2.25.1