ASoC: Intel: sdw_sof: append dai_type and remove codec_type
authorBard Liao <yung-chuan.liao@linux.intel.com>
Fri, 2 Jun 2023 20:22:02 +0000 (15:22 -0500)
committerMark Brown <broonie@kernel.org>
Mon, 5 Jun 2023 13:00:12 +0000 (14:00 +0100)
We append codec type to dailink name to distinguish different dailink
on the same sdw link and direction. But we could create multi dailinks
for a codec and the dailink name will be duplicated if we append codec
type to the dailink name.
Appending dai type instead of codec type can solve the issue.
For example, if a codec supports JACK on dai 0 and AMP on dai 1, the
existing code will create dailinks
SDW0-Playback-SimpleJack or SDW0-Playback-SmartAmp for both dailinks,
and it will be SDW0-Playback-SimpleJack for dailink 0 and
SDW0-Playback-SmartAmp for dailink 1 after this change.
Then codec type is not used any more and can be removed.

Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230602202225.249209-6-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/boards/sof_sdw.c
sound/soc/intel/boards/sof_sdw_common.h

index b197c2920e805d3088a678505f3fc2d92dc9845f..6c4c05addb5071ed0461b4744f6a5eff3d23abbd 100644 (file)
@@ -573,7 +573,6 @@ static struct sof_sdw_codec_info codec_info_list[] = {
                        },
                },
                .dai_num = 1,
-               .codec_type = SOF_SDW_CODEC_TYPE_JACK,
        },
        {
                .part_id = 0x711,
@@ -589,7 +588,6 @@ static struct sof_sdw_codec_info codec_info_list[] = {
                        },
                },
                .dai_num = 1,
-               .codec_type = SOF_SDW_CODEC_TYPE_JACK,
        },
        {
                .part_id = 0x711,
@@ -605,7 +603,6 @@ static struct sof_sdw_codec_info codec_info_list[] = {
                        },
                },
                .dai_num = 1,
-               .codec_type = SOF_SDW_CODEC_TYPE_JACK,
        },
        {
                .part_id = 0x1308,
@@ -622,7 +619,6 @@ static struct sof_sdw_codec_info codec_info_list[] = {
                },
                .dai_num = 1,
                .ops = &sof_sdw_rt1308_i2s_ops,
-               .codec_type = SOF_SDW_CODEC_TYPE_AMP,
        },
        {
                .part_id = 0x1316,
@@ -637,7 +633,6 @@ static struct sof_sdw_codec_info codec_info_list[] = {
                        },
                },
                .dai_num = 1,
-               .codec_type = SOF_SDW_CODEC_TYPE_AMP,
        },
        {
                .part_id = 0x1318,
@@ -652,7 +647,6 @@ static struct sof_sdw_codec_info codec_info_list[] = {
                        },
                },
                .dai_num = 1,
-               .codec_type = SOF_SDW_CODEC_TYPE_AMP,
        },
        {
                .part_id = 0x714,
@@ -668,7 +662,6 @@ static struct sof_sdw_codec_info codec_info_list[] = {
                        },
                },
                .dai_num = 1,
-               .codec_type = SOF_SDW_CODEC_TYPE_MIC,
        },
        {
                .part_id = 0x715,
@@ -684,7 +677,6 @@ static struct sof_sdw_codec_info codec_info_list[] = {
                        },
                },
                .dai_num = 1,
-               .codec_type = SOF_SDW_CODEC_TYPE_MIC,
        },
        {
                .part_id = 0x714,
@@ -700,7 +692,6 @@ static struct sof_sdw_codec_info codec_info_list[] = {
                        },
                },
                .dai_num = 1,
-               .codec_type = SOF_SDW_CODEC_TYPE_MIC,
        },
        {
                .part_id = 0x715,
@@ -716,7 +707,6 @@ static struct sof_sdw_codec_info codec_info_list[] = {
                        },
                },
                .dai_num = 1,
-               .codec_type = SOF_SDW_CODEC_TYPE_MIC,
        },
        {
                .part_id = 0x8373,
@@ -730,7 +720,6 @@ static struct sof_sdw_codec_info codec_info_list[] = {
                        },
                },
                .dai_num = 1,
-               .codec_type = SOF_SDW_CODEC_TYPE_AMP,
        },
        {
                .part_id = 0x5682,
@@ -744,7 +733,6 @@ static struct sof_sdw_codec_info codec_info_list[] = {
                        },
                },
                .dai_num = 1,
-               .codec_type = SOF_SDW_CODEC_TYPE_JACK,
        },
        {
                .part_id = 0xaaaa, /* generic codec mockup */
@@ -759,7 +747,6 @@ static struct sof_sdw_codec_info codec_info_list[] = {
                        },
                },
                .dai_num = 1,
-               .codec_type = SOF_SDW_CODEC_TYPE_JACK,
        },
        {
                .part_id = 0xaa55, /* headset codec mockup */
@@ -774,7 +761,6 @@ static struct sof_sdw_codec_info codec_info_list[] = {
                        },
                },
                .dai_num = 1,
-               .codec_type = SOF_SDW_CODEC_TYPE_JACK,
        },
        {
                .part_id = 0x55aa, /* amplifier mockup */
@@ -789,7 +775,6 @@ static struct sof_sdw_codec_info codec_info_list[] = {
                        },
                },
                .dai_num = 1,
-               .codec_type = SOF_SDW_CODEC_TYPE_AMP,
        },
        {
                .part_id = 0x5555,
@@ -804,7 +789,6 @@ static struct sof_sdw_codec_info codec_info_list[] = {
                        },
                },
                .dai_num = 1,
-               .codec_type = SOF_SDW_CODEC_TYPE_MIC,
        },
 };
 
@@ -1181,7 +1165,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,
+                             bool append_dai_type,
                              int adr_index)
 {
        const struct snd_soc_acpi_link_adr *link_next;
@@ -1261,10 +1245,10 @@ static int create_sdw_dailink(struct snd_soc_card *card,
                }
 
                /* create stream name according to first link id */
-               if (append_codec_type) {
+               if (append_dai_type) {
                        name = devm_kasprintf(dev, GFP_KERNEL,
                                              sdw_stream_name[stream + 2], cpu_dai_id[0],
-                                             type_strings[codec_info->codec_type]);
+                                             type_strings[codec_info->dais[0].dai_type]);
                } else {
                        name = devm_kasprintf(dev, GFP_KERNEL,
                                              sdw_stream_name[stream], cpu_dai_id[0]);
@@ -1384,7 +1368,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 append_dai_type = false;
        bool ignore_pch_dmic = false;
        int codec_conf_count;
        int codec_conf_index = 0;
@@ -1489,7 +1473,7 @@ static int sof_card_dai_links_create(struct device *dev,
                                    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;
+                                       append_dai_type = true;
                                        goto out;
                                }
                        }
@@ -1519,7 +1503,7 @@ out:
                                                 &cpu_id, group_generated,
                                                 codec_conf, codec_conf_count,
                                                 &be_id, &codec_conf_index,
-                                                &ignore_pch_dmic, append_codec_type, i);
+                                                &ignore_pch_dmic, append_dai_type, i);
                        if (ret < 0) {
                                dev_err(dev, "failed to create dai link %d", link_index);
                                return ret;
index def2d47323bf048474b641cc6df919d0d9606033..65b3f6eee92438e64903ca555220efd34ae23fd0 100644 (file)
@@ -56,10 +56,6 @@ enum {
        (((quirk) << SOF_BT_OFFLOAD_SSP_SHIFT) & SOF_BT_OFFLOAD_SSP_MASK)
 #define SOF_SSP_BT_OFFLOAD_PRESENT     BIT(18)
 
-#define SOF_SDW_CODEC_TYPE_JACK                0
-#define SOF_SDW_CODEC_TYPE_AMP         1
-#define SOF_SDW_CODEC_TYPE_MIC         2
-
 #define SOF_SDW_DAI_TYPE_JACK          0
 #define SOF_SDW_DAI_TYPE_AMP           1
 #define SOF_SDW_DAI_TYPE_MIC           2
@@ -84,7 +80,6 @@ struct sof_sdw_dai_info {
 struct sof_sdw_codec_info {
        const int part_id;
        const int version_id;
-       const int codec_type;
        int amp_num;
        const u8 acpi_id[ACPI_ID_LEN];
        const bool ignore_pch_dmic;