Repository navigation
Conversation
matthane
force-pushed
the
pr/ce-audio-hifipll
branch
2 times, most recently
from
November 30, 2026 03:32
f1a4ca4 to
84ce833
Compare
matthane
force-pushed
the
pr/ce-audio-hifipll
branch
from
November 30, 2026 20:46
84ce833 to
cdd1e3a
Compare
The t7 hifi_pll takes its rate from a one-entry table that fixes the DCO near 3932.16 MHz, so it only makes the 48 kHz family and cannot reach the 44.1 kHz family (451584000 Hz). The g12a and sc2 hifi_pll take m from a range and make both families.
The outputs set their rate on the source PLL without holding it, so outputs that share one retune it under each other. On sc2, HDMI PCM and 44.1 kHz passthrough share MPLL2, and a passthrough start slows a running 48 kHz PCM stream by 8%. hifi_pll makes both rate families within 0.03 ppm, but every output would share it.
The g12a audio outputs run from MPLLs for both rate families. The MPLLs run about 20 ppm slow, so audio drifts against video by about 1.2 ms a minute. hifi_pll makes both families within 0.03 ppm. g12a has no free MPLL for a private spare on spdif_b.
The g12b audio outputs run from MPLLs for both rate families. The MPLLs run about 20 ppm slow, so audio drifts against video by about 1.2 ms a minute. hifi_pll makes both families within 0.03 ppm.
The sm1 audio outputs run from MPLLs for both rate families. The MPLLs run about 20 ppm slow, so audio drifts against video by about 1.2 ms a minute. hifi_pll makes both families within 0.03 ppm.
The sc2 HDMI PCM output runs from an MPLL for both rate families, the other outputs for the 44.1 kHz family. The MPLLs run about 20 ppm slow, so that audio drifts against video by about 1.2 ms a minute. hifi_pll makes both families within 0.03 ppm.
The t7 audio outputs run from MPLLs for the 44.1 kHz family. The MPLLs run about 20 ppm slow, so 44.1 kHz audio drifts against video by about 1.2 ms a minute. hifi_pll makes both families exactly.
matthane
force-pushed
the
pr/ce-audio-hifipll
branch
from
December 3, 2026 14:54
cdd1e3a to
6b558cd
Compare
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.
On t7 it needs the spdif links to the dummy codec from #59. Without them, while another output holds hifi_pll at the other rate family, the card's own spdif clock set is refused and logged before the output claims its spare. The commits are split as asked in review, into the t7 PLL range, the output clock claim and one device tree commit per SoC. The device tree commits need the claim, and the t7 one also needs the PLL range.
Problem
On G12A, G12B, SM1, SC2, T7 and T7C audio outputs run from MPLL clocks for one or both rate families, and those run 20 to 23 ppm slow, so the audio clock loses 70 to 84 ms per hour. On SC2, HDMI PCM and 44.1 kHz passthrough share one MPLL, so a 48 kHz PCM title after a 44.1 kHz passthrough title plays 0.7% slow, and a 44.1 kHz passthrough stream opened beside a 48 kHz PCM stream slows the PCM stream by 8%.
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
"clk: t7: set hifi_pll from an m range" lets T7's hifi_pll take m from 125 to 250 on 64-bit, as G12A and SC2 do, instead of a one-entry 48 kHz table, so it makes both rate families. "audio: let an output claim a pll both rate families share" makes an open stream hold its PLL at its rate with clk_set_rate_exclusive. A stream at the other family then runs from the spare MPLL the device tree names as clk_src_mpll. Other rate sets, such as the card's own clock set and the fine-tune controls, still set the PLL directly. If another output holds it at the other family, such a set is refused and logged as a kernel warning instead of retuning the PLL under the running stream. Boards without a spare set the rate as before. The S/PDIF shared-buffer path now passes the clock it holds. The five device tree commits move every output (HDMI PCM, HDMI passthrough, optical and analog) of G12A, G12B, SM1, SC2 and T7 to hifi_pll, which makes 491.52 MHz and 451.584 MHz to within 0.03 ppm on G12A, G12B, SM1 and SC2 and exactly on T7. Boards whose own device tree sets the TDM-B clocks (Ugoos AM7 and X4, the 2nd-generation Fire TV Cube) keep TDM-B on their own PLL, as on stock. On the AM7 and X4, the S/PDIF output that mirrors a 44.1 kHz TDM-B stream now runs from that PLL too, as it already did at 48 kHz.
Tested with
The output rate is the hardware playback position fitted against the box's raw monotonic clock over 150 s, in ppm. The position moves in 512-byte fetches, so a value is the middle of the rates that fit every reading, which reach 1.3 to 4.8 ppm either side of it. Without this PR is the stock nightly 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.5 to -23.2 ppm is an output on an MPLL. With this PR the clock tree shows every output of the AM6B+, R 4K Plus and Fire TV Cube on hifi_pll. The AM9 Pro, whose device tree this PR does not change, runs within 0.7 ppm on both kernels. Full data in the measurement data. Every sample ran on each device listed under Tested on, without this PR on the stock nightly of 2026-11-27 and with it on the nightly of 2026-12-01.
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. A cell gives each clock's distance from its nominal rate, 12288000 or 11289600 Hz for PCM and 6144000 or 5644800 Hz for S/PDIF at 48 and 44.1 kHz. The tree gives whole Hz, so a clock within 10 ppm of nominal runs at the rate its stream set. Without this PR is again the stock nightly of 2026-11-27. The first two rows are cases the stock kernel already gets right.
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, T7C shares T7's, and the output clock claim also changes the TDM shared-buffer parent on S4 with force_mpll at 48 kHz, but we have none of these boxes to run them on.
Tested on
CoreELEC 22 nightly of 2026-12-01 with this PR's commits, "DT: t7 and s4: link the spdif outputs to the dummy codec", "audio: report the FRDDR FIFO fill as playback delay", "amlvideo: report the field of each dequeued frame", the CoreELEC/xbmc A/V sync PRs and the ffmpeg patch "ffmpeg: add patch to time a TrueHD major sync after skipped units", common_drivers on Linux 5.15.196, tested 2026-12-02 and 2026-12-03. Without this PR ran on the stock nightly of 2026-11-27, tested 2026-11-29. Both kernels carry two audio capture taps and a snapshot of the audio playback ring, which these readings do not use. This PR needs no library change and no CoreELEC patch. AM9 Pro (S905X5), AM6B+ (S922X), R 4K Plus (S905X4), Fire TV Cube 3rd gen (T7).