Skip to contentSkip to conversation

ASoC: wm8962: Enable oscillator if selecting WM8962_FLL_OSC

PATCH In review Stuart Henderson 2 participants 9 messages Mar 6, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/5 ASoC: wm8962: Enable oscillator if selecting WM8962_FLL_OSC

---
 sound/soc/codecs/wm8962.c | 4 ++++
 1 file changed, 4 insertions(+)
sound/soc/codecs/wm8962.c +4 -0
index fb90ae6a8a34..6d7bb696b135 100644
@@ -2914,8 +2914,12 @@ static int wm8962_set_fll(struct snd_soc_component *component, int fll_id, int s
 	switch (fll_id) {
 	case WM8962_FLL_MCLK:
 	case WM8962_FLL_BCLK:
+		fll1 |= (fll_id - 1) << WM8962_FLL_REFCLK_SRC_SHIFT;
+		break;
 	case WM8962_FLL_OSC:
 		fll1 |= (fll_id - 1) << WM8962_FLL_REFCLK_SRC_SHIFT;
+		snd_soc_component_update_bits(component, WM8962_PLL2,
+					      WM8962_OSC_ENA, WM8962_OSC_ENA);
 		break;
 	case WM8962_FLL_INT:
 		snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1,
Signature · 1 line
2.39.2
#1 lore raw

PATCH 2/5 ASoC: wm8962: Enable both SPKOUTR_ENA and SPKOUTL_ENA in mono mode

---
 sound/soc/codecs/wm8962.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
sound/soc/codecs/wm8962.c +14 -9
index 6d7bb696b135..2256cc0a37eb 100644
@@ -2229,6 +2229,9 @@ SND_SOC_DAPM_PGA_E("HPOUT", SND_SOC_NOPM, 0, 0, NULL, 0, hp_event,
 
 SND_SOC_DAPM_OUTPUT("HPOUTL"),
 SND_SOC_DAPM_OUTPUT("HPOUTR"),
+
+SND_SOC_DAPM_PGA("SPKOUTL Output", WM8962_CLASS_D_CONTROL_1, 6, 0, NULL, 0),
+SND_SOC_DAPM_PGA("SPKOUTR Output", WM8962_CLASS_D_CONTROL_1, 7, 0, NULL, 0),
 };
 
 static const struct snd_soc_dapm_widget wm8962_dapm_spk_mono_widgets[] = {
@@ -2236,7 +2239,6 @@ SND_SOC_DAPM_MIXER("Speaker Mixer", WM8962_MIXER_ENABLES, 1, 0,
 		   spkmixl, ARRAY_SIZE(spkmixl)),
 SND_SOC_DAPM_MUX_E("Speaker PGA", WM8962_PWR_MGMT_2, 4, 0, &spkoutl_mux,
 		   out_pga_event, SND_SOC_DAPM_POST_PMU),
-SND_SOC_DAPM_PGA("Speaker Output", WM8962_CLASS_D_CONTROL_1, 7, 0, NULL, 0),
 SND_SOC_DAPM_OUTPUT("SPKOUT"),
 };
 
@@ -2251,9 +2253,6 @@ SND_SOC_DAPM_MUX_E("SPKOUTL PGA", WM8962_PWR_MGMT_2, 4, 0, &spkoutl_mux,
 SND_SOC_DAPM_MUX_E("SPKOUTR PGA", WM8962_PWR_MGMT_2, 3, 0, &spkoutr_mux,
 		   out_pga_event, SND_SOC_DAPM_POST_PMU),
 
-SND_SOC_DAPM_PGA("SPKOUTR Output", WM8962_CLASS_D_CONTROL_1, 7, 0, NULL, 0),
-SND_SOC_DAPM_PGA("SPKOUTL Output", WM8962_CLASS_D_CONTROL_1, 6, 0, NULL, 0),
-
 SND_SOC_DAPM_OUTPUT("SPKOUTL"),
 SND_SOC_DAPM_OUTPUT("SPKOUTR"),
 };
@@ -2366,12 +2365,18 @@ static const struct snd_soc_dapm_route wm8962_spk_mono_intercon[] = {
 	{ "Speaker PGA", "Mixer", "Speaker Mixer" },
 	{ "Speaker PGA", "DAC", "DACL" },
 
-	{ "Speaker Output", NULL, "Speaker PGA" },
-	{ "Speaker Output", NULL, "SYSCLK" },
-	{ "Speaker Output", NULL, "TOCLK" },
-	{ "Speaker Output", NULL, "TEMP_SPK" },
+	{ "SPKOUTL Output", NULL, "Speaker PGA" },
+	{ "SPKOUTL Output", NULL, "SYSCLK" },
+	{ "SPKOUTL Output", NULL, "TOCLK" },
+	{ "SPKOUTL Output", NULL, "TEMP_SPK" },
+
+	{ "SPKOUTR Output", NULL, "Speaker PGA" },
+	{ "SPKOUTR Output", NULL, "SYSCLK" },
+	{ "SPKOUTR Output", NULL, "TOCLK" },
+	{ "SPKOUTR Output", NULL, "TEMP_SPK" },
 
-	{ "SPKOUT", NULL, "Speaker Output" },
+	{ "SPKOUT", NULL, "SPKOUTL Output" },
+	{ "SPKOUT", NULL, "SPKOUTR Output" },
 };
 
 static const struct snd_soc_dapm_route wm8962_spk_stereo_intercon[] = {
Signature · 1 line
2.39.2
#3 lore raw

PATCH 3/5 ASoC: fsl: Fix up mclk_id for fsl,imx-audio-wm8962

In reply to Stuart Henderson

wm8962_set_fll is currently incorrect, and largely ignores the source parameter. This patch fixes this use of wm8962_set_fll in preparation for fixing this. Previously we were using WM8962_SYSCLK_MCLK (0), but wm8962_set_fll ends up using the fll_id (in this case WM8962_FLL = 1). Change this to WM8962_FLL_MCLK (1) instead.

---
 sound/soc/fsl/fsl-asoc-card.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/fsl/fsl-asoc-card.c +1 -1
index bc07f26ba303..2781fd8d198e 100644
@@ -656,7 +656,7 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
 		priv->card.num_dapm_routes = ARRAY_SIZE(audio_map_tx);
 	} else if (of_device_is_compatible(np, "fsl,imx-audio-wm8962")) {
 		codec_dai_name = "wm8962";
-		priv->codec_priv.mclk_id = WM8962_SYSCLK_MCLK;
+		priv->codec_priv.mclk_id = WM8962_FLL_MCLK;
 		priv->codec_priv.fll_id = WM8962_SYSCLK_FLL;
 		priv->codec_priv.pll_id = WM8962_FLL;
 		priv->dai_fmt |= SND_SOC_DAIFMT_CBP_CFP;
Signature · 1 line
2.39.2
#4 lore raw

PATCH 4/5 ASoC: wm8962: Fix wm8962_set_fll to use source instead of fll_id

In reply to Stuart Henderson

Previously wm8962_set_fll was using fll_id to configure the source. This change is problematic, but it looks like there's limited users of this driver, and luckily they all seem to be intending to use WM8962_FLL_MCLK as the source which happens to have the same value as WM8962_FLL.

---
 sound/soc/codecs/wm8962.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
sound/soc/codecs/wm8962.c +11 -3
index 2256cc0a37eb..24bd818c3345 100644
@@ -2890,6 +2890,14 @@ static int wm8962_set_fll(struct snd_soc_component *component, int fll_id, int s
 	int ret;
 	int fll1 = 0;
 
+	switch (fll_id) {
+	case WM8962_FLL:
+		break;
+	default:
+		dev_err(component->dev, "Unknown FLL ID %d\n", fll_id);
+		return -EINVAL;
+	}
+
 	/* Any change? */
 	if (source == wm8962->fll_src && Fref == wm8962->fll_fref &&
 	    Fout == wm8962->fll_fout)
@@ -2916,13 +2924,13 @@ static int wm8962_set_fll(struct snd_soc_component *component, int fll_id, int s
 	/* Parameters good, disable so we can reprogram */
 	snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0);
 
-	switch (fll_id) {
+	switch (source) {
 	case WM8962_FLL_MCLK:
 	case WM8962_FLL_BCLK:
-		fll1 |= (fll_id - 1) << WM8962_FLL_REFCLK_SRC_SHIFT;
+		fll1 |= (source - 1) << WM8962_FLL_REFCLK_SRC_SHIFT;
 		break;
 	case WM8962_FLL_OSC:
-		fll1 |= (fll_id - 1) << WM8962_FLL_REFCLK_SRC_SHIFT;
+		fll1 |= (source - 1) << WM8962_FLL_REFCLK_SRC_SHIFT;
 		snd_soc_component_update_bits(component, WM8962_PLL2,
 					      WM8962_OSC_ENA, WM8962_OSC_ENA);
 		break;
Signature · 1 line
2.39.2
maintainer
#5 lore raw

Re: [PATCH 4/5] ASoC: wm8962: Fix wm8962_set_fll to use source instead of fll_id

Quoted 1 line · Stuart Henderson

Previously wm8962_set_fll was using fll_id to configure the source.

Which was a problem because...?

Quoted 4 lines

This change is problematic, but it looks like there's limited users of this driver, and luckily they all seem to be intending to use WM8962_FLL_MCLK as the source which happens to have the same value as WM8962_FLL.

If the change is problematic why make it at all?

#6 lore raw

PATCH 5/5 ASoC: wm8962: Fix up incorrect error message in wm8962_set_fll

In reply to Stuart Henderson

Use source instead of ret, which seems to be unrelated and will always be zero.

---
 sound/soc/codecs/wm8962.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8962.c +1 -1
index 24bd818c3345..5ad6850c591f 100644
@@ -2941,7 +2941,7 @@ static int wm8962_set_fll(struct snd_soc_component *component, int fll_id, int s
 				    WM8962_FLL_FRC_NCO, WM8962_FLL_FRC_NCO);
 		break;
 	default:
-		dev_err(component->dev, "Unknown FLL source %d\n", ret);
+		dev_err(component->dev, "Unknown FLL source %d\n", source);
 		return -EINVAL;
 	}
 
Signature · 1 line
2.39.2
maintainer
#8 lore raw

Re: (subset) [PATCH 1/5] ASoC: wm8962: Enable oscillator if selecting WM8962_FLL_OSC

In reply to Stuart Henderson
Quoted 1 line · Stuart Henderson

Applied to

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

Thanks!

[1/5] ASoC: wm8962: Enable oscillator if selecting WM8962_FLL_OSC

      commit: 03c7874106ca5032a312626b927b1c35f07b1f35
[2/5] ASoC: wm8962: Enable both SPKOUTR_ENA and SPKOUTL_ENA in mono mode
      commit: 6fa849e4d78b880e878138bf238e4fd2bac3c4fa
[5/5] ASoC: wm8962: Fix up incorrect error message in wm8962_set_fll
      commit: 96e202f8c52ac49452f83317cf3b34cd1ad81e18

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