Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH 0/1] clk/ASoC: sunxi: fix H616 audio PLL and codec clock rates
@ 2026-11-27 21:42 Daniel Golle
  2026-11-27 21:42 ` [PATCH 1/1] clk: sunxi-ng: h616: fix " Daniel Golle
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Golle @ 2026-11-27 21:42 UTC (permalink / raw)
  To: Stephen Boyd, Brian Masney, Jerome Brunet, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, bui duc phuc, Kees Cook,
	Daniel Golle, Ryan Walklin, Andre Przywara, linux-clk,
	linux-arm-kernel, linux-sunxi, linux-sound
  Cc: stable, Marcus Cooper, Philippe Simons, Krzysztof Kozlowski

The H616 CCU reports the audio PLL at half its real frequency since its
sigma-delta table was added, and the H616 codec support was tuned on
top of that, so the two errors cancel for the analogue codec. Other
users of the audio PLL run at the wrong rate: sun4i-spdif plays at
twice the requested rate once the codec has moved the PLL to its
sigma-delta setting, and an I2S driver for the Audio Hub that asks for
24.576 MHz gets 49.152 MHz.

The fix is a single patch spanning clk and ASoC. Correcting the CCU
alone halves the codec rate, and doubling the codec request alone makes
the codec run at twice its rate on the current CCU, so a two-patch
series would leave one commit with broken audio for bisection and for
stable backports, which need both halves together. I would suggest the
patch goes through the sunxi clk tree with an ack from Mark for the
sun4i-codec hunk; taking it through ASoC with an ack for the CCU hunk
works just as well.

Tool use: the root cause analysis, the patch and the text of both mails
were produced with an AI coding assistant (Claude Code) during a longer
session, which was asked to bring up HDMI audio on an H618 TV box, then
to find out why the analogue codec played at half speed after the CCU
correction, and to prepare this fix. It measured the PLL, the module
clock and the DAC drain rate on the hardware with devmem and the
AC_DAC_CNT counter, and checked them against the PLL formula of the
H616 manual and against the vendor-derived H616 codec driver carried by
Armbian, which requests twice the table rate. The measurements in the
notes of the patch come from those runs; pitch and channel order were
checked by ear.

Daniel Golle (1):
  clk: sunxi-ng: h616: fix audio PLL and codec clock rates

 drivers/clk/sunxi-ng/ccu-sun50i-h616.c | 4 ++--
 sound/soc/sunxi/sun4i-codec.c          | 8 ++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)


base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
-- 
2.56.1

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

end of thread, other threads:[~2026-11-27 21:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 21:42 [PATCH 0/1] clk/ASoC: sunxi: fix H616 audio PLL and codec clock rates Daniel Golle
2026-11-27 21:42 ` [PATCH 1/1] clk: sunxi-ng: h616: fix " Daniel Golle

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