Skip to content

audio: run the outputs from hifi_pll on g12, sm1, sc2 and t7 - #60

Open
matthane wants to merge 1 commit into
CoreELEC:5.15.196_20260225from
matthane:pr/ce-audio-hifipll
Open

matthane wants to merge 1 commit into
CoreELEC:5.15.196_20260225from
matthane:pr/ce-audio-hifipll

Conversation

@matthane

Copy link
Copy Markdown
Contributor

Depends on no other PR.

Problem

On G12A, G12B, SM1, SC2, T7 and T7C audio outputs run from MPLL clocks for one or both rate families, and those run 19 to 23 ppm slow, so audio drifts 69 to 83 ms per hour behind the picture. On SC2 a 48 kHz PCM title after a 44.1 kHz passthrough title can also play 0.7% slow, because HDMI PCM and passthrough share one MPLL.

SamuriHL found that the G12B MPLL runs the 48 kHz audio clock about 20 ppm slow, in the real_player branch of his CoreELEC Kodi fork (https://github.com/SamuriHL/coreelec-xbmc).

Change

Every output (HDMI PCM, HDMI passthrough, optical and analog) now takes both rate families from hifi_pll, which makes 491.52 MHz and 451.584 MHz to within 0.1 ppm. An open stream holds hifi_pll at its rate with clk_set_rate_exclusive. A stream at the other family runs from the spare MPLL the device tree names as clk_src_mpll, and without a spare the drivers set the rate as before. T7's hifi_pll took its rate from a one-entry 48 kHz table, and on 64-bit it now takes T3's multiplier range.

Tested with

The output rate is the hardware playback position fitted against the box's raw monotonic clock over 150 s, in ppm, and each fit carries an error of 0.04 to 0.74 ppm. Without this PR is the PR base kernel, with neither this PR nor "audio: report the FRDDR FIFO fill as playback delay". Kodi plays the HDMI rows, and optical and analog play through aplay with Kodi idle. A cell gives the range over the four devices and names a device that stands apart. Every value of -19 to -23 ppm is an output on an MPLL. With this PR every output runs from hifi_pll, or from hifi1_pll at 44.1 kHz on the AM9 Pro as before. The R 4K Plus row for 48 kHz PCM on HDMI without this PR ran after a 44.1 kHz passthrough row and stayed at the 44.1 kHz rate, the case of the second table. A clean start there reads -19.7 to -20.0 ppm. Full data in the measurement data. Every sample ran on each device listed under Tested on.

Sample Without this PR, output rate (ppm) With this PR, output rate (ppm)
PCM 2.0 48 kHz, HDMI +0.3, AM6B+ -19.9, R 4K Plus -6779.1 (after a 44.1 kHz row) -0.1 to +0.1
PCM 2.0 44.1 kHz, HDMI -22.8 to -22.5, AM9 Pro -0.2 +0.1 to +0.4
AC-3 48 kHz passthrough, HDMI -0.1 to +0.1, AM6B+ -19.6 +0.1 to +0.4
AC-3 44.1 kHz passthrough, HDMI -22.8 to -22.4, AM9 Pro +0.1 -0.3 to +0.5
TrueHD passthrough (HBR), HDMI -0.1 to +0.1, AM6B+ -20.0 -0.1 to +0.1
PCM 2.0 48 kHz, optical -0.1 to +0.2, AM6B+ -19.1 -0.2 to +0.3
PCM 2.0 44.1 kHz, optical -23.1 to -20.6, AM9 Pro +0.2 -0.1 to +0.1
PCM 2.0 48 kHz, analog -0.2 to +0.1, AM6B+ -20.1 -0.2 to +0.3
PCM 2.0 44.1 kHz, analog -22.6 to -21.1, AM9 Pro -0.3 -0.4 to +0.3

The second table reads each stream's output clock in the clock tree while two streams play at once on different outputs (aplay), and while Kodi plays 44.1 kHz PCM, 44.1 kHz AC-3 passthrough and then 48 kHz PCM. Nominal is 12288000 or 11289600 Hz for PCM and 6144000 or 5644800 Hz for S/PDIF at 48 and 44.1 kHz, read to within 10 ppm. The first two rows are cases the base kernel already gets right.

Sample Without this PR, output clocks (Hz) With this PR, output clocks (Hz)
Optical 48 kHz, then HDMI PCM 44.1 kHz at once both at the rate the stream set both at the rate the stream set
HDMI PCM 44.1 kHz, then optical 48 kHz at once both at the rate the stream set both at the rate the stream set
HDMI PCM 48 kHz, then HDMI AC-3 44.1 kHz at once both at the rate the stream set, R 4K Plus 48 kHz PCM at 11289500 (8% slow) both at the rate the stream set
Kodi playing 44.1 kHz PCM, 44.1 kHz AC-3, then 48 kHz PCM 48 kHz PCM at the rate it set, R 4K Plus 12204865 (0.68% slow) 48 kHz PCM at the rate it set

Result

Audio keeps its rate through a whole film at both rate families, also after a passthrough title, and a second program on another output no longer changes the first stream's speed. G12A and SM1 share G12B's clock driver and T7C shares T7's, but we have no such box to run them.

Tested on

CoreELEC 22 nightly 20261124 with this PR's commit, "audio: report the FRDDR FIFO fill as playback delay" and an earlier build of the CoreELEC/xbmc A/V sync PRs, common_drivers on Linux 5.15.196, tested 2026-11-24. No library change and no CoreELEC patch needed. AM9 Pro (S905X5), AM6B+ (S922X), Dune/Homatics R 4K Plus (S905X4), Fire TV Cube 3rd gen (T7).

The card outputs run from MPLLs for one or both rate families, and the
MPLLs run 19 to 23 ppm slow, so audio drifts against video. hifi_pll
makes both families exactly, but one PLL serves every output, so two
streams at different families cannot both run from it. The t7 hifi_pll
took its rate from a one-entry 48k table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant