Skip to content

Commit 3ef4c73

Browse files
committed
ASoC: sdw_utils: add dai_type_mask filtering for multi-card support
Add dai_type_mask field filtering in asoc_sdw_count_sdw_endpoints() and asoc_sdw_parse_sdw_endpoints() to allow multi-card configurations to include only specific DAI types. When dai_type_mask is non-zero, only codec endpoints with matching dai_type bits are counted and parsed. Auxiliary devices for codecs without matching endpoints are also skipped. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent cc75c5e commit 3ef4c73

1 file changed

Lines changed: 68 additions & 21 deletions

File tree

sound/soc/sdw_utils/soc_sdw_utils.c

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ struct asoc_sdw_codec_info codec_info_list[] = {
8282
.direction = {true, false},
8383
.dai_name = "tac5xx2-aif1",
8484
.dai_type = SOC_SDW_DAI_TYPE_AMP,
85-
.dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID},
85+
.dailink = {
86+
SOC_SDW_AMP_OUT_DAI_ID,
87+
SOC_SDW_UNUSED_DAI_ID,
88+
},
8689
.init = asoc_sdw_ti_amp_init,
8790
.rtd_init = asoc_sdw_ti_tac5xx2_spk_rtd_init,
8891
.controls = lr_spk_controls,
@@ -103,7 +106,10 @@ struct asoc_sdw_codec_info codec_info_list[] = {
103106
.direction = {true, true},
104107
.dai_name = "tac5xx2-aif3",
105108
.dai_type = SOC_SDW_DAI_TYPE_JACK,
106-
.dailink = {SOC_SDW_JACK_OUT_DAI_ID, SOC_SDW_JACK_IN_DAI_ID},
109+
.dailink = {
110+
SOC_SDW_JACK_OUT_DAI_ID,
111+
SOC_SDW_JACK_IN_DAI_ID,
112+
},
107113
.controls = generic_jack_controls,
108114
.num_controls = ARRAY_SIZE(generic_jack_controls),
109115
.widgets = generic_jack_widgets,
@@ -1829,6 +1835,29 @@ static int is_sdca_aux_dev_present(struct device *dev,
18291835
return ret;
18301836
}
18311837

1838+
/*
1839+
* Check if a codec device has any endpoints matching the dai_type_mask.
1840+
* Returns true if no filtering (mask == 0) or at least one endpoint matches.
1841+
*/
1842+
static bool adr_dev_matches_dai_type_mask(const struct snd_soc_acpi_adr_device *adr_dev,
1843+
struct asoc_sdw_codec_info *codec_info,
1844+
u32 dai_type_mask)
1845+
{
1846+
int j;
1847+
1848+
if (!dai_type_mask)
1849+
return true;
1850+
1851+
for (j = 0; j < adr_dev->num_endpoints; j++) {
1852+
int ep_num = adr_dev->endpoints[j].num;
1853+
1854+
if (ep_num < codec_info->dai_num &&
1855+
(dai_type_mask & BIT(codec_info->dais[ep_num].dai_type)))
1856+
return true;
1857+
}
1858+
return false;
1859+
}
1860+
18321861
int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card,
18331862
int *num_devs, int *num_ends, int *num_aux)
18341863
{
@@ -1851,6 +1880,11 @@ int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card,
18511880
if (!codec_info)
18521881
return -EINVAL;
18531882

1883+
/* Skip aux devices for codecs with no matching endpoints */
1884+
if (!adr_dev_matches_dai_type_mask(adr_dev, codec_info,
1885+
mach_params->dai_type_mask))
1886+
continue;
1887+
18541888
for (j = 0; j < codec_info->aux_num; j++) {
18551889
ret = is_sdca_aux_dev_present(dev, codec_info->auxs[j].codec_name,
18561890
adr_link, i);
@@ -2015,29 +2049,34 @@ int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card,
20152049
if (!codec_info)
20162050
return -EINVAL;
20172051

2018-
for (j = 0; j < codec_info->aux_num; j++) {
2019-
struct snd_soc_component *component;
2052+
/* Skip aux devices for codecs with no matching endpoints */
2053+
if (adr_dev_matches_dai_type_mask(adr_dev, codec_info,
2054+
mach_params->dai_type_mask)) {
2055+
for (j = 0; j < codec_info->aux_num; j++) {
2056+
struct snd_soc_component *component;
2057+
const char *aux_name = codec_info->auxs[j].codec_name;
20202058

2021-
ret = is_sdca_aux_dev_present(dev, codec_info->auxs[j].codec_name,
2022-
adr_link, i);
2023-
if (ret < 0)
2024-
return ret;
2059+
ret = is_sdca_aux_dev_present(dev, aux_name, adr_link, i);
2060+
if (ret < 0)
2061+
return ret;
20252062

2026-
if (ret == 0)
2027-
continue;
2063+
if (ret == 0)
2064+
continue;
20282065

2029-
component = snd_soc_lookup_component_by_name(codec_info->auxs[j].codec_name);
2030-
if (component) {
2031-
dev_dbg(dev, "%s found component %s for aux name %s\n",
2032-
__func__, component->name,
2033-
codec_info->auxs[j].codec_name);
2034-
soc_aux->dlc.name = component->name;
2035-
} else {
2036-
dev_dbg(dev, "%s the aux component %s is not registered yet\n",
2037-
__func__, codec_info->auxs[j].codec_name);
2038-
return -EPROBE_DEFER;
2066+
component = snd_soc_lookup_component_by_name(aux_name);
2067+
if (component) {
2068+
dev_dbg(dev,
2069+
"found component %s for aux name %s\n",
2070+
component->name, aux_name);
2071+
soc_aux->dlc.name = component->name;
2072+
} else {
2073+
dev_dbg(dev,
2074+
"aux component %s is not registered yet\n",
2075+
aux_name);
2076+
return -EPROBE_DEFER;
2077+
}
2078+
soc_aux++;
20392079
}
2040-
soc_aux++;
20412080
}
20422081

20432082
ctx->ignore_internal_dmic |= codec_info->ignore_internal_dmic;
@@ -2061,6 +2100,14 @@ int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card,
20612100

20622101
adr_end = &adr_dev->endpoints[j];
20632102
dai_info = &codec_info->dais[adr_end->num];
2103+
2104+
/* Filter by DAI type if mask is set */
2105+
if (mach_params->dai_type_mask &&
2106+
!(mach_params->dai_type_mask & BIT(dai_info->dai_type))) {
2107+
(*num_devs)--;
2108+
continue;
2109+
}
2110+
20642111
soc_dai = asoc_sdw_find_dailink(soc_dais, adr_end);
20652112

20662113
/*

0 commit comments

Comments
 (0)