ASoC: Intel: sof-sdw: Add new code for parsing the snd_soc_acpi structs
authorCharles Keepax <ckeepax@opensource.cirrus.com>
Tue, 26 Mar 2024 16:04:13 +0000 (11:04 -0500)
committerMark Brown <broonie@kernel.org>
Tue, 26 Mar 2024 16:13:36 +0000 (16:13 +0000)
commit27fd36aefa0013bea1cf6948e2e825e9b8cff97a
tree1ff484ce4389555b8b8e3c7239e60ad8878c349f
parent8166bdd2c560e59e9a6ec0c868b996294d8428d1
ASoC: Intel: sof-sdw: Add new code for parsing the snd_soc_acpi structs

The current machine driver code has a lot of loops parsing through
the ACPI structs (snd_soc_acpi_link_adr, snd_soc_acpi_adr_device,
snd_soc_acpi_endpoint), this makes it hard to understand exactly
what information is being extracted and for what purposes. As well
as being slightly inefficient, as the same information is looked
up multiple times. There are also some issues with the handling
of multiple endpoints on a single device, only the first of the
snd_soc_acpi_endpoint structures is currently fully processed by the
driver. This means doing things like aggregating the second endpoint
on a device with another device are not currently possible.

Add new parsing code that will count the devices and endpoints, parse
them into an intermediate datastructure, and then use that to create
the DAI links. This patch does not actually utilise the results of
the parsing, items will be moved across in the following patches.

This parsing is based around two new structures which are temporarily
allocated whilst parsing. Firstly, sof_sdw_endpoint, which represents
a specific endpoint for audio on a device and is more or less directly
equivalent to snd_soc_acpi_endpoint. Secondly, sof_sdw_dailink
which represents a DAI link and contains a linked list of one or
more sof_sdw_endpoints. A single trip through the snd_soc_acpi data
structures is used to populate these.

One important point to note here is the use of the num field in
snd_soc_acpi_endpoint to address sof_sdw_dai_info array in the
sof_sdw_codec_info struct. This expects a one to one mapping between
endpoints on a device and dai infos. It would be fine for a specific
system to not specify an endpoint for all of the dai infos available,
but two endpoints mapping to the same dai info would make not sense.

Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://msgid.link/r/20240326160429.13560-19-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/boards/sof_sdw.c