Repository navigation
Conversation
Unlike the other SoCs, t7 names both spdif DAIs, and s4 its spdifa DAI, as the codec of their own link. ASoC then runs every DAI op twice on that DAI, so each start prepares and triggers it twice, and on HDMI hdmitx sets up its audio twice.
The playback pointer reads the FRDDR fetch address, which runs up to one FIFO depth (1 KiB) ahead of what the serializer has sent. ALSA's delay leaves that queue out, so the HDMI output trails the reported delay by 3 to 5.5 ms for PCM 2.0, AC-3 and DTS.
matthane
force-pushed
the
pr/ce-audio-fifo-delay
branch
from
November 30, 2026 03:32
f90fc6d to
cd7d4c1
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.
Depends on no other PR. The CoreELEC/xbmc A/V sync PRs were measured with it.
Problem
On Amlogic boxes ALSA reports less playback delay than the audio really has, so a player that syncs to it plays audio up to 5.6 ms late at the HDMI output.
Change
The playback pointer reports the FRDDR fetch address, which runs up to 1 KiB of FIFO ahead of the serializer, so ALSA's delay leaves out the audio still queued in the chip. The pointers now read the fetch address and the FIFO fill as one consistent pair, and each output's DAI delay callback reports that fill, as davinci-mcasp reports its FIFO use. The ASoC core adds the DAI delay to the playback delay on 5.15, and on 6.12 it builds the delay from these callbacks only, so the change works on both. FRDDR_FIFO_CNT is corrected to bits 16:8.
On t7 both spdif DAIs, and on s4 the spdifa DAI, were named as the codec of their own link, so ASoC ran every op of that DAI twice and would add its delay twice. Those links now use the dummy codec, as on the other SoCs.
Tested with
The A/V offset is measured at the HDMI output at playback start on A/V marker clips (1080p23.976, a frame code and a click every second), six starts per codec on each device. Without this PR is the stock kernel with the amlvideo PR, and both arms run the same Kodi. A value is the median of one device's starts, and a cell gives the range over the four devices. Positive means the audio leaves the box after its picture. Full data in the measurement data. Every sample ran on each device listed under Tested on. The 1 KiB of FIFO holds about 2.7 ms of PCM 2.0, 5.3 ms of AC-3 or DTS, 1.3 ms of E-AC-3 and 0.3 ms of a DTS-HD MA or TrueHD stream, which is about how far each row moves.
Result
Audio leaves the HDMI output when ALSA says it does, with every device's median start within 1 ms of the picture on every codec, so lip sync starts where the player set it. The s4 link change is untested because none of our devices is an S4.
Tested on
CoreELEC 22 nightly of 2026-11-28 with this PR's two commits, the commits of "audio: run the outputs from hifi_pll on g12, sm1, sc2 and t7" (#60), "amlvideo: report the field of each dequeued frame", the CoreELEC/xbmc A/V sync PRs of 2026-11-29 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-11-29. Without this PR is the same build with the stock kernel and the amlvideo commit, so it leaves out this PR and #60. Both kernels carry two capture taps and a snapshot of the audio playback ring, used only for the measurement. 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).