Re: [PATCH v4 2/4] media: synopsys: hdmirx: add HDMI audio capture support

From: Dmitry Osipenko

Date: Thu Jul 23 2026 - 16:51:00 EST


On 7/21/26 09:41, Igor Paunovic wrote:
> The Synopsys DesignWare HDMI RX controller extracts the audio stream
> embedded in the incoming HDMI signal and feeds it to an on-SoC I2S
> controller. Expose it as an ALSA capture device by registering the
> generic hdmi-codec as a child of the controller, so that a
> simple-audio-card in the device tree can bind the HDMI RX audio DAI.
>
> The sample rate is recovered from the ACR N/CTS values together with the
> measured TMDS character rate. A periodic worker keeps the local audio
> reference clock locked to the source by nudging it in small ppm steps to
> hold the audio FIFO fill level near its target, which avoids FIFO
> under/overflow and the resulting dropped samples.
>
> Across system suspend the worker is stopped before the controller
> clocks are gated. Resume fully resets the controller, wiping the audio
> configuration, so when a capture stream is active it re-programs the
> audio path from the last known sample rate and re-arms the worker,
> whose rate change and FIFO error paths resynchronize once the source
> delivers audio again.
>
> Signed-off-by: Igor Paunovic <royalnet026@xxxxxxxxx>
> ---
> Changes in v4:
> - use swab32() for the ACR word reversal: readl() already abstracts
> bus endianness, so the reversal must be unconditional (be32_to_cpu
> is a no-op on big-endian)
> - support system suspend: stop the worker in suspend before the
> clocks are gated; resume fully resets the controller, so re-program
> the audio path and re-arm the worker while a capture stream is
> active, through a hdmirx_audio_setup() helper shared with
> hw_params() (Dmitry Osipenko; validated with an active capture
> stream across suspend/resume)
>
> Changes in v3:
> - restore the v1 audio teardown in remove(): audio_shutdown() already
> stops the worker when the stream closes, so the extra flag clear
> and trailing cancel added in v2 were redundant (Dmitry Osipenko)
> - rename the ACR read locals and add a comment documenting the
> register byte packing
> - drop the get_dai_id stub so OF-graph cards resolve the DAI index
> from the reg property
>
> Changes in v2:
> - register the S/PDIF DAI so the indexes match the binding and reject
> it with -EOPNOTSUPP until wired up (Sebastian Reichel)
> - use platform_device_register_data() and drop the fixed 32-bit DMA
> mask (Dmitry Osipenko)
> - don't leave an ERR_PTR in audio_pdev on registration failure
> - fix teardown ordering in remove()
> - stop the worker before reprogramming shared state in hw_params()
> - look up the "audio" clock by name instead of indexing clks[1]
> - keep the worker on system_unbound_wq when re-arming
> .../platform/synopsys/hdmirx/snps_hdmirx.c | 306 ++++++++++++++++++
> .../platform/synopsys/hdmirx/snps_hdmirx.h | 8 +
> 2 files changed, 314 insertions(+)

Note: Current variant of audio support requires userspace to manually
select appropriate audio freq on capture. This needs to be improved
later on for regular userspace apps by dynamically registering audio
CODEC on HDMI cable plug event and reading out actual audio freq on the
wire, restricting the CODEC's rate, which might require extension of the
hdmi_codec_ops.

Reviewed-by: Dmitry Osipenko <dmitry.osipenko@xxxxxxxxxxxxx>
Tested-by: Dmitry Osipenko <dmitry.osipenko@xxxxxxxxxxxxx>

--
Best regards,
Dmitry