Repository navigation
Conversation
hdac_hda_dai_open() takes a reference to the HDA PCM with snd_hda_codec_pcm_get() before calling the codec stream open callback. If the callback fails, the error is returned to ASoC, which does not call the DAI .shutdown callback for a DAI whose .startup failed. The PCM reference is thus never released. Drop the reference on the error path. Fixes: 6bae5ea ("ASoC: hdac_hda: add asoc extension for legacy HDA codec drivers") Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
The hdac_hda DAIs are registered with static stub capabilities (SNDRV_PCM_RATE_8000_192000, 1-16 channels), and the actual codec stream capabilities queried by snd_hda_query_supported_pcm() and adjusted by the codec stream open callback are never checked. hdac_hda_dai_hw_params() only rejects parameters that have no HDA stream format encoding. As a result, a BE configuration using unsupported sampling rate is accepted instead of raising an error. Applying the codec capabilities as hw constraints in the DAI startup callback, like the legacy HDA driver does in azx_pcm_open(), is not an option. In DPCM, the BE substream shares the FE runtime, so the constraints would restrict the FE as well. This is wrong when the BE rate is fixed in topology and differs from the FE rate (with an SRC in the pipeline), as the codec then only sees the fixed BE rate. Instead, validate the BE rate and channel count in hw_params, which is called with the parameters after the BE fixup. The format is not checked, as the codec reports 24-bit support as S32_LE while the DAIs also accept S24_LE, which is handled by snd_hdac_stream_format_bits(). Fixes: 6bae5ea ("ASoC: hdac_hda: add asoc extension for legacy HDA codec drivers") Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
The playback and capture DAI widgets of a bidirectional DAI link have separate copiers, each with their own set of audio formats, but both are registered as a snd_sof_dai named after the DAI link. sof_ipc4_pcm_dai_link_fixup() looks up the DAI by the link name, so it always gets the copier that was registered last, regardless of the stream being configured, and uses its formats to fix up the BE rate, channels and bit depth. If the formats differ, the BE is configured with the formats of the other direction. For example with a topology where the playback HDA DAI copier supports 22050Hz and 48000Hz, but the capture DAI copier only 48000Hz, a 22050Hz playback stream gets its BE rate forced to 48000Hz, while the playback DAI copier is configured for 22050Hz. The HDA link and codec run at 48000Hz and the audio is played back at the wrong rate. The BE fixup callback is not told the stream direction. Find it using the same test dpcm_be_dai_hw_params() uses to select the BEs to update, and use the copier of the DAI widget for that direction. Fall back to the old behaviour if the direction cannot be determined. Fixes: 26dfc43 ("ASoC: SOF: ipc4-pcm: fixup dailink based on copier format") Fixes: 279e52d ("ASoC: SOF: ipc4-pcm: support multiple configs for BE DAIs") Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
kv2019i
requested review from
bardliao,
dbaluta,
lgirdwood,
plbossart,
ranj063 and
ujfalusi
as code owners
November 30, 2026 09:01
kv2019i
marked this pull request as draft
November 30, 2026 09:01
There was a problem hiding this comment.
🟡 Changes recommended
Capture configuration overlapping a playback trigger can make both directions match, forcing a name-based copier fallback that may incorrectly apply playback rates and channels to capture.
1 open issue
What changed in this PR
This draft adds codec-side parameter validation to SOF HDA, supporting work toward native sample rates in topologies without resamplers.
Changes:
- Rejects backend rates and channel counts outside HDA codec capabilities.
- Uses inferred stream direction to select the corresponding IPC4 copier.
- Releases the HDA PCM reference when codec stream startup fails.
| File | Description |
|---|---|
sound/soc/sof/ipc4-pcm.c |
Adds direction inference and stream-specific copier selection during parameter fixup. |
sound/soc/codecs/hdac_hda.c |
Validates codec parameters and fixes reference cleanup on startup failure. |
Review effort: Balanced
Comment on lines
+810
to
+813
| if (update == SND_SOC_DPCM_UPDATE_FE || | ||
| (update == SND_SOC_DPCM_UPDATE_BE && rtd->dpcm[dir].runtime_update)) { | ||
| if (stream >= 0) | ||
| return -EINVAL; |
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.

In topologies with no resamplers, it would be nice to allow use of native codec sampling rates (see thesofproject/sof#11541 ). This works well if crafting a topology for a specific machine, but looking at possibility to enable all rates with a generic HDA topology, this hits some issues with the HDA driver stack.
This kernel PR adds basic support to raise errors from the codec driver. I.e. you configure machine with topology that allows a full set of sampling rates. @ujfalusi @bardliao please take a look and see whether thi is overlapping with some existing work.
Posting as a draft for now. The upstream sof-hda-generic does have processing on the capture path and mixing for playback, so the fixed BE rate will probably be the solution in the generic case.