Skip to content

ALSA/ASoC: Fix HDMI ELD/capability loss on SOF DPCM backends via hw_constraints - #5913

Open
ujfalusi wants to merge 2 commits into
thesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/hdmi-constraint
Open

ALSA/ASoC: Fix HDMI ELD/capability loss on SOF DPCM backends via hw_constraints#5913
ujfalusi wants to merge 2 commits into
thesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/hdmi-constraint

Conversation

@ujfalusi

@ujfalusi ujfalusi commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

When an HDA HDMI codec is exposed as an ASoC dynamic PCM backend (as all codecs under sound/soc/sof/intel/hda-codec.c are), the ASoC core rebuilds the DPCM frontend's runtime->hw from topology after backend .open() runs, silently discarding whatever the codec wrote there. In practice this means the HDMI sink's ELD (its actual supported rate/format/channel combinations) never reaches the frontend that userspace negotiates against — a mismatch either surfaces late as a failing hw_params(), or doesn't surface at all.

hw_constraints, unlike runtime->hw, are not touched by the core and are correctly merged with the final topology-derived runtime->hw in snd_pcm_hw_constraints_complete(). This series adds an opt-in constrain_pcms flag so the HDMI codec can additionally express its FORMAT/CHANNELS/ELD limits as constraints, and turns that flag on for every codec SOF probes, since they're all DPCM backends.

hdmi_pcm_open() reports what the converter and the sink's ELD allow by
updating substream->runtime->hw. That works for a codec driven by the
HDA controller, but not for one exposed by a DSP driver as an ASoC
dynamic PCM backend: the ASoC core sets up the runtime->hw of the
frontend from topology after the backends have been opened, overwriting
everything the codec placed there. Userspace then negotiates against
topology and only finds out at hw_params time, or not at all, that the
sink cannot do what it asked for.

The hw_constraints are not overwritten, and the final runtime->hw is
merged into them by snd_pcm_hw_constraints_complete(), so a constraint
added at open time composes with topology instead of being lost. Repeat
the narrowing there for a codec which asks for it with the new
constrain_pcms flag, which no codec sets yet.

The ELD is applied with snd_pcm_hw_constraint_eld(), which keeps the
correlation between the rates and the channel count of each SAD, so it
is a finer restriction than struct hda_pcm_stream can express. The rates
a converter supports are a mask, which no constraint can take, so those
are left to the caps the PCM was created with.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Every HDA codec probed here is exposed as an ASoC dynamic PCM backend, so
the runtime->hw a codec sets up at open time is overwritten by the core
with what topology says about the frontend, and the codec's own view of
what the hardware can do is lost.

Set constrain_pcms so that the codec adds it as hw_constraints as well,
which survive and are merged with the topology capabilities. For HDMI
this means the sink's ELD finally reaches the frontend that userspace
negotiates against, instead of the mismatch showing up as a failing
hw_params.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Copilot AI lite review requested due to automatic review settings September 3, 2026 13:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The change affects PCM capability negotiation across HDA↔ASoC DPCM integration paths and is hardware/topology dependent, making it difficult to validate correctness and regressions without targeted platform testing.

Pull request overview

This PR ensures HDMI sink ELD-driven capabilities (formats/channels and ELD-derived rate/channel coupling) are preserved when an HDA HDMI codec is exposed as an ASoC dynamic PCM backend (e.g., SOF), by expressing those restrictions via hw_constraints rather than relying solely on runtime->hw (which ASoC DPCM topology rebuilding can overwrite).

Changes:

  • Introduces an opt-in struct hda_codec::constrain_pcms flag to request codec-side PCM narrowing via hw_constraints.
  • Applies HDMI PCM constraints (format mask, channel min/max, and optional ELD constraint) in sound/hda/codecs/hdmi/hdmi.c when constrain_pcms is set.
  • Enables constrain_pcms for SOF-probed HDA codecs in sound/soc/sof/intel/hda-codec.c.
File summaries
File Description
sound/soc/sof/intel/hda-codec.c Enables opt-in PCM constraining for SOF-exposed HDA codecs used as ASoC DPCM backends.
sound/hda/codecs/hdmi/hdmi.c Adds conditional HDMI-format/channel/ELD constraints via hw_constraints during PCM open.
include/sound/hda_codec.h Adds the constrain_pcms flag to struct hda_codec for cross-driver coordination.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

2 participants