ASoC: wm8962: don't clear a SYSCLK_ENA that DAPM owns in configure_bclk (fixes silent audio on Surface RT / Surface 2) - #142
Open
zefr0g wants to merge 1 commit into
Open
Conversation
wm8962_configure_bclk() provisionally sets SYSCLK_ENA so that the read-only DSPCLK_DIV field becomes valid, then clears it again whenever the bias level is below SND_SOC_BIAS_ON. It never checks whether the bit was already set. It can be: the "SYSCLK" DAPM supply widget owns that bit, and wm8962_mic_detect() force-enables the pin. On boards that call it (the Tegra machine driver, i.e. Microsoft Surface RT and Surface 2) DAPM sets SYSCLK_ENA once at card init and, because the widget then never changes power state, never writes it again. The first stream's transition to SND_SOC_BIAS_PREPARE runs configure_bclk(), which clears the bit behind DAPM's back. From then on every stream plays with SYSCLK off: the DACs do not run, CP_ENA refuses to latch, hp_event() reports "DC servo timed out", and the codec is silent although every register DAPM believes in looks right. Remember whether SYSCLK_ENA was set on entry and only undo our own provisional enable. Verified on a Microsoft Surface 2 (Tegra 4, WM8962 rev F): with the bit forced on over I2C during a stream the DC servo completes in ~56 ms and audio is heard; with this patch applied the DC servo completes on every stream and there is no more "DC servo timed out". Fixes: 75704ec ("ASoC: wm8962: Enable SYSCLK provisonally before fetching generated DSPCLK_DIV") Cc: stable@vger.kernel.org Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Maxime Douailin <maxime.douailin@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #141 and, I expect, the silence reported in #140 too.
The bug
wm8962_configure_bclk()provisionally setsSYSCLK_ENAto read the read-onlyDSPCLK_DIV, then clears it unconditionally when the bias level is belowSND_SOC_BIAS_ON. But that bit is owned by theSYSCLKDAPM supply widget, andwm8962_mic_detect()force-enables that pin. The Tegra machine driver callswm8962_mic_detect(), so on Surface RT / Surface 2 DAPM writesSYSCLK_ENA = 1once at card init and never again (the widget never changes power state). The first stream'sBIAS_PREPARErunsconfigure_bclk(), which clears the bit behind DAPM's back. Every stream then plays with SYSCLK off: DACs idle,CP_ENAwill not latch,hp_event()logsDC servo timed out, total silence while every DAPM-visible register looks right.Only boards calling
wm8962_mic_detect()are affected, which is exactly the two Surfaces.Verification
Microsoft Surface 2 (T114, WM8962 rev F), libre-tegra
stable7.0.1 + this patch: DC servo completes on every stream,SYSCLK_ENA/CP_ENAread 1 over I2C during playback, zero wm8962 errors in dmesg, speakers audible. Before the patch, forcing bit 5 of R8 over I2C during a stream produced sound immediately; that is how it was found (regmap cache vs. raw I2C register diff).Notes
Fixes: 75704ecfbb41andCc: stable, is going to linux-sound / alsa-devel: https://gist.github.com/zefr0g/97ff52172502ccde6a23dfd6c71608fcti,palmas-override-powerhold, microSD slot, audio pinmux + codec supplies) targetcodeberg.org/libre-tegra/linuxstable, which this repo'smasterdoes not carry. They are on branch https://github.com/zefr0g/linux/tree/surface2-fixes (top 4 commits) for whoever can land them there.🤖 Generated with Claude Code