fixup! ASoC: soc-compress: Provide a runtime for the compressed FE su… - #5917
fixup! ASoC: soc-compress: Provide a runtime for the compressed FE su…#5917ujfalusi wants to merge 1 commit into
Conversation
…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>
|
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. |
There was a problem hiding this comment.
🟡 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_constraintsmasks 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.
| for (i = SNDRV_PCM_HW_PARAM_FIRST_INTERVAL; i <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; i++) | ||
| snd_interval_any(constrs_interval(constrs, i)); | ||
|
|
There was a problem hiding this comment.
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.
…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:
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().