ASoC: mediatek: common: revise SOF common code
authorTrevor Wu <trevor.wu@mediatek.com>
Fri, 25 Aug 2023 02:49:34 +0000 (10:49 +0800)
committerMark Brown <broonie@kernel.org>
Mon, 11 Sep 2023 00:18:55 +0000 (01:18 +0100)
commit4047b35c836ff9f8bf1f57c4ab871136899267e9
tree01ad55bb60ffe3330110bf952009e44fd3479dcf
parentd601bb78f06b9e3cbb52e6b87b88add9920a11b6
ASoC: mediatek: common: revise SOF common code

Originally, normal dai link fixup callback is overwritten by sof fixup
callback on mtk_sof_card_late_probe and it relies on the mapping defined
on struct sof_conn_stream.

It's not flexible. When a new hardware connection is adopted, user needs
to update struct sof_conn_stream defined in machine driver which is used
to specify the mapping relationship of normal BE and SOF BE.

In the patch, mtk_sof_check_tplg_be_dai_link_fixup() is introduced for
all normal BEs. In mtk_sof_late_probe, back up normal BE fixup if it
exists and then overwrite be_hw_params_fixup by the new callback.

There are two cases for FE and BE connection.

case 1:
SOF FE -> normal BE
       -> SOF_BE

case 2:
normal FE -> normal BE

In the new fixup callback, it tries to find SOF_BE which connects to the
same FE, and then reuses the fixup of SOF_BE. If no SOF_BE exists,
it must be case 2, so rollback to the original fixup if it exists.

As a result, the predefined relation is not needed anymore. Hardware
connection can be controlled by the mixer control for AFE interconn.
Then, DPCM finds the BE mapping at runtime.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20230825024935.10878-3-trevor.wu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/mediatek/common/mtk-dsp-sof-common.c
sound/soc/mediatek/common/mtk-dsp-sof-common.h