summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorBard Liao <yung-chuan.liao@linux.intel.com>2023-04-19 14:55:24 -0500
committerMark Brown <broonie@kernel.org>2023-04-20 12:51:53 +0100
commitdc5a3e60a4b5974a0cb5bf2c5df70a490dce9df2 (patch)
tree6aa0ca34332903eff3c69e3dc00d18155fe607d3 /sound
parentc8db7b50128b8cc61a5ca6e4717cf8158fca302a (diff)
downloadlinux-dc5a3e60a4b5974a0cb5bf2c5df70a490dce9df2.tar.gz
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>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/intel/boards/sof_sdw.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c
index 6a6c81df72bd..6faf4a43eaf5 100644
--- a/sound/soc/intel/boards/sof_sdw.c
+++ b/sound/soc/intel/boards/sof_sdw.c
@@ -1022,6 +1022,8 @@ static int get_slave_info(const struct snd_soc_acpi_link_adr *adr_link,
return 0;
}
+static const char * const type_strings[] = {"SimpleJack", "SmartAmp", "SmartMic"};
+
static int create_sdw_dailink(struct snd_soc_card *card,
struct device *dev, int *link_index,
struct snd_soc_dai_link *dai_links,
@@ -1033,6 +1035,7 @@ static int create_sdw_dailink(struct snd_soc_card *card,
int codec_count, int *link_id,
int *codec_conf_index,
bool *ignore_pch_dmic,
+ bool append_codec_type,
int adr_index)
{
const struct snd_soc_acpi_link_adr *link_next;
@@ -1109,14 +1112,22 @@ static int create_sdw_dailink(struct snd_soc_card *card,
static const char * const sdw_stream_name[] = {
"SDW%d-Playback",
"SDW%d-Capture",
+ "SDW%d-Playback-%s",
+ "SDW%d-Capture-%s",
};
if (!codec_info_list[codec_index].direction[stream])
continue;
/* create stream name according to first link id */
- name = devm_kasprintf(dev, GFP_KERNEL,
- sdw_stream_name[stream], cpu_dai_id[0]);
+ if (append_codec_type) {
+ name = devm_kasprintf(dev, GFP_KERNEL,
+ sdw_stream_name[stream + 2], cpu_dai_id[0],
+ type_strings[codec_info_list[codec_index].codec_type]);
+ } else {
+ name = devm_kasprintf(dev, GFP_KERNEL,
+ sdw_stream_name[stream], cpu_dai_id[0]);
+ }
if (!name)
return -ENOMEM;
@@ -1232,6 +1243,7 @@ static int sof_card_dai_links_create(struct device *dev,
const struct snd_soc_acpi_link_adr *adr_link;
struct snd_soc_dai_link_component *cpus;
struct snd_soc_codec_conf *codec_conf;
+ bool append_codec_type = false;
bool ignore_pch_dmic = false;
int codec_conf_count;
int codec_conf_index = 0;
@@ -1323,8 +1335,29 @@ static int sof_card_dai_links_create(struct device *dev,
for (i = 0; i < SDW_MAX_GROUPS; i++)
group_generated[i] = false;
- /* generate DAI links by each sdw link */
for (; adr_link->num_adr; adr_link++) {
+ /*
+ * If there are two or more different devices on the same sdw link, we have to
+ * append the codec type to the dai link name to prevent duplicated dai link name.
+ * The same type devices on the same sdw link will be in the same
+ * snd_soc_acpi_adr_device array. They won't be described in different adr_links.
+ */
+ for (i = 0; i < adr_link->num_adr; i++) {
+ for (j = 0; j < i; j++) {
+ if ((SDW_PART_ID(adr_link->adr_d[i].adr) !=
+ SDW_PART_ID(adr_link->adr_d[j].adr)) ||
+ (SDW_MFG_ID(adr_link->adr_d[i].adr) !=
+ SDW_MFG_ID(adr_link->adr_d[i].adr))) {
+ append_codec_type = true;
+ goto out;
+ }
+ }
+ }
+ }
+out:
+
+ /* generate DAI links by each sdw link */
+ for (adr_link = mach_params->links ; adr_link->num_adr; adr_link++) {
for (i = 0; i < adr_link->num_adr; i++) {
const struct snd_soc_acpi_endpoint *endpoint;
@@ -1345,7 +1378,7 @@ static int sof_card_dai_links_create(struct device *dev,
&cpu_id, group_generated,
codec_conf, codec_conf_count,
&be_id, &codec_conf_index,
- &ignore_pch_dmic, i);
+ &ignore_pch_dmic, append_codec_type, i);
if (ret < 0) {
dev_err(dev, "failed to create dai link %d", link_index);
return ret;