[PATCH] ASoC: Intel: avs: Initialize private data for subsequent HDA FEs
HDAudio implementation found in sound/pci/hda expects a valid stream pointer in substream->runtime->private_data location. For ASoC users, that should point to a valid link stream which is assigned when BE opens.
As BE borrows its runtime from FE, the information may be lost when reparenting comes into picture - see dpcm_be_reparent(). To support the DPCM reparenting functionality for HDAudio scenarios while still fulfilling expectations of HDAudio common code, have all FEs point to the same private data.
Signed-off-by: Cezary Rojewski cezary.rojewski@intel.com ---
This is a tough one and spawned a range of patches. Some of the discussion is present at thesofproject/linux [1]. In the end decided to drop any soc-core/pcm.c modifications for now, instead addressing the problem directly in the avs-driver. Long term - perhaps BE should have a separate runtime so there is no ambiguity between FE and BE.
[1]: https://github.com/thesofproject/linux/pull/3987
sound/soc/intel/avs/pcm.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c index e237ab23fef9..41030aaae02d 100644 --- a/sound/soc/intel/avs/pcm.c +++ b/sound/soc/intel/avs/pcm.c @@ -1507,9 +1507,29 @@ static int avs_component_hda_open(struct snd_soc_component *component,
if (!rtd->dai_link->no_pcm) { struct snd_pcm_hardware hwparams = avs_pcm_hardware; + struct snd_soc_pcm_runtime *be; + struct snd_soc_dpcm *dpcm; + int dir = substream->stream; + + /* + * Support the DPCM reparenting while still fulfilling expectations of HDAudio + * common code - a valid stream pointer at substream->runtime->private_data - + * by having all FEs point to the same private data. + */ + for_each_dpcm_be(rtd, dir, dpcm) { + struct snd_pcm_substream *be_substream; + + be = dpcm->be; + if (be->dpcm[dir].users == 1) + break; + + be_substream = snd_soc_dpcm_get_substream(be, dir); + substream->runtime->private_data = be_substream->runtime->private_data; + break; + }
/* RESUME unsupported for de-coupled HD-Audio capture. */ - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) + if (dir == SNDRV_PCM_STREAM_CAPTURE) hwparams.info &= ~SNDRV_PCM_INFO_RESUME;
return snd_soc_set_runtime_hwparams(substream, &hwparams);
On Fri, 18 Nov 2022 12:30:52 +0100, Cezary Rojewski wrote:
HDAudio implementation found in sound/pci/hda expects a valid stream pointer in substream->runtime->private_data location. For ASoC users, that should point to a valid link stream which is assigned when BE opens.
As BE borrows its runtime from FE, the information may be lost when reparenting comes into picture - see dpcm_be_reparent(). To support the DPCM reparenting functionality for HDAudio scenarios while still fulfilling expectations of HDAudio common code, have all FEs point to the same private data.
[...]
Applied to
broonie/sound.git for-next
Thanks!
[1/1] ASoC: Intel: avs: Initialize private data for subsequent HDA FEs commit: f38d4c72cb2d68e73d3e54feb68febd6b7c4bfd2
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
participants (2)
-
Cezary Rojewski
-
Mark Brown