Skip to content

Commit dc5a3e6

Browse files
bardliaobroonie
authored andcommitted
ASoC: Intel: sof_sdw: append codec type to dai link name
The existing sdw_sof machine driver constructs two SoundWire interfaces by direction and sdw link id. It means that we will have exactly the same dai link name if two dai links are on the same sdw link with the same direction. The new Realtek codec has two SoundWire interfaces for jack and DMIC functions and they are treated as different codecs. To create two dai links for jack and DMIC, we need to have different dai link names. This patch suggests to append codec type if there are two or more different types of devices on the same sdw bus. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Link: https://lore.kernel.org/r/20230419195524.46995-8-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent c8db7b5 commit dc5a3e6

1 file changed

Lines changed: 37 additions & 4 deletions

File tree

sound/soc/intel/boards/sof_sdw.c

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,8 @@ static int get_slave_info(const struct snd_soc_acpi_link_adr *adr_link,
10221022
return 0;
10231023
}
10241024

1025+
static const char * const type_strings[] = {"SimpleJack", "SmartAmp", "SmartMic"};
1026+
10251027
static int create_sdw_dailink(struct snd_soc_card *card,
10261028
struct device *dev, int *link_index,
10271029
struct snd_soc_dai_link *dai_links,
@@ -1033,6 +1035,7 @@ static int create_sdw_dailink(struct snd_soc_card *card,
10331035
int codec_count, int *link_id,
10341036
int *codec_conf_index,
10351037
bool *ignore_pch_dmic,
1038+
bool append_codec_type,
10361039
int adr_index)
10371040
{
10381041
const struct snd_soc_acpi_link_adr *link_next;
@@ -1109,14 +1112,22 @@ static int create_sdw_dailink(struct snd_soc_card *card,
11091112
static const char * const sdw_stream_name[] = {
11101113
"SDW%d-Playback",
11111114
"SDW%d-Capture",
1115+
"SDW%d-Playback-%s",
1116+
"SDW%d-Capture-%s",
11121117
};
11131118

11141119
if (!codec_info_list[codec_index].direction[stream])
11151120
continue;
11161121

11171122
/* create stream name according to first link id */
1118-
name = devm_kasprintf(dev, GFP_KERNEL,
1119-
sdw_stream_name[stream], cpu_dai_id[0]);
1123+
if (append_codec_type) {
1124+
name = devm_kasprintf(dev, GFP_KERNEL,
1125+
sdw_stream_name[stream + 2], cpu_dai_id[0],
1126+
type_strings[codec_info_list[codec_index].codec_type]);
1127+
} else {
1128+
name = devm_kasprintf(dev, GFP_KERNEL,
1129+
sdw_stream_name[stream], cpu_dai_id[0]);
1130+
}
11201131
if (!name)
11211132
return -ENOMEM;
11221133

@@ -1232,6 +1243,7 @@ static int sof_card_dai_links_create(struct device *dev,
12321243
const struct snd_soc_acpi_link_adr *adr_link;
12331244
struct snd_soc_dai_link_component *cpus;
12341245
struct snd_soc_codec_conf *codec_conf;
1246+
bool append_codec_type = false;
12351247
bool ignore_pch_dmic = false;
12361248
int codec_conf_count;
12371249
int codec_conf_index = 0;
@@ -1323,8 +1335,29 @@ static int sof_card_dai_links_create(struct device *dev,
13231335
for (i = 0; i < SDW_MAX_GROUPS; i++)
13241336
group_generated[i] = false;
13251337

1326-
/* generate DAI links by each sdw link */
13271338
for (; adr_link->num_adr; adr_link++) {
1339+
/*
1340+
* If there are two or more different devices on the same sdw link, we have to
1341+
* append the codec type to the dai link name to prevent duplicated dai link name.
1342+
* The same type devices on the same sdw link will be in the same
1343+
* snd_soc_acpi_adr_device array. They won't be described in different adr_links.
1344+
*/
1345+
for (i = 0; i < adr_link->num_adr; i++) {
1346+
for (j = 0; j < i; j++) {
1347+
if ((SDW_PART_ID(adr_link->adr_d[i].adr) !=
1348+
SDW_PART_ID(adr_link->adr_d[j].adr)) ||
1349+
(SDW_MFG_ID(adr_link->adr_d[i].adr) !=
1350+
SDW_MFG_ID(adr_link->adr_d[i].adr))) {
1351+
append_codec_type = true;
1352+
goto out;
1353+
}
1354+
}
1355+
}
1356+
}
1357+
out:
1358+
1359+
/* generate DAI links by each sdw link */
1360+
for (adr_link = mach_params->links ; adr_link->num_adr; adr_link++) {
13281361
for (i = 0; i < adr_link->num_adr; i++) {
13291362
const struct snd_soc_acpi_endpoint *endpoint;
13301363

@@ -1345,7 +1378,7 @@ static int sof_card_dai_links_create(struct device *dev,
13451378
&cpu_id, group_generated,
13461379
codec_conf, codec_conf_count,
13471380
&be_id, &codec_conf_index,
1348-
&ignore_pch_dmic, i);
1381+
&ignore_pch_dmic, append_codec_type, i);
13491382
if (ret < 0) {
13501383
dev_err(dev, "failed to create dai link %d", link_index);
13511384
return ret;

0 commit comments

Comments
 (0)