Skip to content

fixup! ASoC: soc-compress: Provide a runtime for the compressed FE su… - #5917

Open
ujfalusi wants to merge 1 commit into
thesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/compress-fixups-04
Open

fixup! ASoC: soc-compress: Provide a runtime for the compressed FE su…#5917
ujfalusi wants to merge 1 commit into
thesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/compress-fixups-04

Conversation

@ujfalusi

@ujfalusi ujfalusi commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

…bstream

The runtime handed to the BEs is allocated with kzalloc(), but a zeroed snd_pcm_hw_constraints is not the neutral state: every mask is empty and every interval is [0, 0].

snd_pcm_open() runs snd_pcm_hw_constraints_init() to set them to 'anything goes' before any startup callback is called. Without that, a BE codec which refines a constraint directly in its startup() gets an empty result and returns -EINVAL, failing dpcm_be_dai_startup() and with it the compressed open:

  • hdac_hdmi_pcm_open() calls snd_pcm_hw_constraint_mask64() on the format mask, and an empty mask ANDed with anything stays empty
  • cs42l42_dai_startup() calls snd_pcm_hw_constraint_minmax() to limit the rate to [44100, 96000], and refining [0, 0] with it gives min > max

Rule based helpers such as snd_pcm_hw_constraint_list() are not affected, they only append to the rules array, which is why this is not seen with the BE codecs on a cs42l43 playback path.

Initialize the masks and intervals the same way the PCM core does, so the runtime the compressed FE lends out is indistinguishable from one set up by snd_pcm_open().

…bstream

The runtime handed to the BEs is allocated with kzalloc(), but a zeroed
snd_pcm_hw_constraints is not the neutral state: every mask is empty and
every interval is [0, 0].

snd_pcm_open() runs snd_pcm_hw_constraints_init() to set them to 'anything
goes' before any startup callback is called. Without that, a BE codec
which refines a constraint directly in its startup() gets an empty result
and returns -EINVAL, failing dpcm_be_dai_startup() and with it the
compressed open:

 - hdac_hdmi_pcm_open() calls snd_pcm_hw_constraint_mask64() on the format
   mask, and an empty mask ANDed with anything stays empty
 - cs42l42_dai_startup() calls snd_pcm_hw_constraint_minmax() to limit the
   rate to [44100, 96000], and refining [0, 0] with it gives min > max

Rule based helpers such as snd_pcm_hw_constraint_list() are not affected,
they only append to the rules array, which is why this is not seen with
the BE codecs on a cs42l43 playback path.

Initialize the masks and intervals the same way the PCM core does, so the
runtime the compressed FE lends out is indistinguishable from one set up
by snd_pcm_open().

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

ujfalusi commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator Author

this closes a theoretical gap, we don't have devices with such codec afaik, but if we do then the compress would fail to start dues to the zero params.
It hurts nothing, but prepares for the future. Tested on devices.
Already folded into my to be sent series for upstream.

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.

🟡 Changes recommended

The constraints initialization does not fully match the PCM core’s neutral setup (missing integer-only interval flags), which can still lead to divergent constraint refinement behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR fixes compressed FE runtime initialization in ASoC DPCM so that BE startup callbacks see a PCM runtime whose hw constraints start in the same neutral (“anything goes”) state as one created via snd_pcm_open(), avoiding unexpected -EINVAL when codecs refine constraints directly.

Changes:

  • Initialize the FE substream’s runtime->hw_constraints masks and intervals to “any” after allocating the runtime for compressed FEs.
File summaries
File Description
sound/soc/soc-compress.c Initializes compressed FE runtime hw constraints so BE constraint refinement behaves like a normal PCM-opened runtime.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

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

Comment thread sound/soc/soc-compress.c
Comment on lines +173 to +175
for (i = SNDRV_PCM_HW_PARAM_FIRST_INTERVAL; i <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; i++)
snd_interval_any(constrs_interval(constrs, i));

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The integer flag has a single consumer, snd_interval_refine(), where it only collapses openmin/openmax into closed bounds and propagates itself. The immediate helpers a BE startup() can call (snd_pcm_hw_constraint_minmax(), _integer(), _mask64()) all refine against a closed interval, so the result is identical with or without the flag pre-set, and snd_interval_refine() sets it itself for a closed single point interval.

Beyond that it only matters to snd_pcm_hw_refine(), which never runs for this substream, same as the hw rules the comment already mentions.

no followup for the change as of yet planned.

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.

3 participants