Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Daniel Golle <daniel@makrotopia.org>
To: Stephen Boyd <sboyd@kernel.org>,
	Brian Masney <bmasney+clk@redhat.com>,
	Jerome Brunet <jbrunet+clk@baylibre.com>,
	Chen-Yu Tsai <wens@kernel.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	bui duc phuc <phucduc.bui@gmail.com>,
	Kees Cook <kees+treewide@kernel.org>,
	Daniel Golle <daniel@makrotopia.org>,
	Ryan Walklin <ryan@testtoast.com>,
	Andre Przywara <andre.przywara@arm.com>,
	linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev, linux-sound@vger.kernel.org
Cc: stable@vger.kernel.org, Marcus Cooper <codekipper@gmail.com>,
	Philippe Simons <simons.philippe@gmail.com>,
	Krzysztof Kozlowski <krzk@kernel.org>
Subject: [PATCH 0/1] clk/ASoC: sunxi: fix H616 audio PLL and codec clock rates
Date: Fri, 27 Nov 2026 21:42:18 +0000	[thread overview]
Message-ID: <cover.1795815223.git.daniel@makrotopia.org> (raw)

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

             reply	other threads:[~2026-11-27 21:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 21:42 Daniel Golle [this message]
2026-11-27 21:42 ` [PATCH 1/1] clk: sunxi-ng: h616: fix audio PLL and codec clock rates Daniel Golle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1795815223.git.daniel@makrotopia.org \
    --to=daniel@makrotopia.org \
    --cc=andre.przywara@arm.com \
    --cc=bmasney+clk@redhat.com \
    --cc=broonie@kernel.org \
    --cc=codekipper@gmail.com \
    --cc=jbrunet+clk@baylibre.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=kees+treewide@kernel.org \
    --cc=krzk@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=perex@perex.cz \
    --cc=phucduc.bui@gmail.com \
    --cc=ryan@testtoast.com \
    --cc=samuel@sholland.org \
    --cc=sboyd@kernel.org \
    --cc=simons.philippe@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.com \
    --cc=wens@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox