Commit 296c789c authored by Bard Liao's avatar Bard Liao Committed by Mark Brown

ASoC: intel: sof_sdw: add link adr order check

We assume the adr order described in a snd_soc_acpi_link_adr array is
jack -> amp -> mic. We follow the same order to implement the topology.
We will need a special topology if we configure a snd_soc_acpi_link_adr
array with different order. Adding a check and a warning message can
remind people to keep the order when adding a new snd_soc_acpi_link_adr
array.
Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20211027021824.24776-11-yung-chuan.liao@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 4ed65d6e
...@@ -599,10 +599,11 @@ static inline int find_codec_info_acpi(const u8 *acpi_id) ...@@ -599,10 +599,11 @@ static inline int find_codec_info_acpi(const u8 *acpi_id)
* Since some sdw slaves may be aggregated, the CPU DAI number * Since some sdw slaves may be aggregated, the CPU DAI number
* may be larger than the number of BE dailinks. * may be larger than the number of BE dailinks.
*/ */
static int get_sdw_dailink_info(const struct snd_soc_acpi_link_adr *links, static int get_sdw_dailink_info(struct device *dev, const struct snd_soc_acpi_link_adr *links,
int *sdw_be_num, int *sdw_cpu_dai_num) int *sdw_be_num, int *sdw_cpu_dai_num)
{ {
const struct snd_soc_acpi_link_adr *link; const struct snd_soc_acpi_link_adr *link;
int _codec_type = SOF_SDW_CODEC_TYPE_JACK;
bool group_visited[SDW_MAX_GROUPS]; bool group_visited[SDW_MAX_GROUPS];
bool no_aggregation; bool no_aggregation;
int i; int i;
...@@ -628,6 +629,12 @@ static int get_sdw_dailink_info(const struct snd_soc_acpi_link_adr *links, ...@@ -628,6 +629,12 @@ static int get_sdw_dailink_info(const struct snd_soc_acpi_link_adr *links,
if (codec_index < 0) if (codec_index < 0)
return codec_index; return codec_index;
if (codec_info_list[codec_index].codec_type < _codec_type)
dev_warn(dev,
"Unexpected address table ordering. Expected order: jack -> amp -> mic\n");
_codec_type = codec_info_list[codec_index].codec_type;
endpoint = link->adr_d->endpoints; endpoint = link->adr_d->endpoints;
/* count DAI number for playback and capture */ /* count DAI number for playback and capture */
...@@ -1136,7 +1143,7 @@ static int sof_card_dai_links_create(struct device *dev, ...@@ -1136,7 +1143,7 @@ static int sof_card_dai_links_create(struct device *dev,
ssp_num = ssp_codec_index >= 0 ? hweight_long(ssp_mask) : 0; ssp_num = ssp_codec_index >= 0 ? hweight_long(ssp_mask) : 0;
comp_num = hdmi_num + ssp_num; comp_num = hdmi_num + ssp_num;
ret = get_sdw_dailink_info(mach_params->links, ret = get_sdw_dailink_info(dev, mach_params->links,
&sdw_be_num, &sdw_cpu_dai_num); &sdw_be_num, &sdw_cpu_dai_num);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "failed to get sdw link info %d", ret); dev_err(dev, "failed to get sdw link info %d", ret);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment