Commit b2745865 authored by Bard Liao's avatar Bard Liao Committed by Mark Brown

ASoC: Intel: sof_sdw: use predefine dailink id

Currently, we assign dailink ids in order, and shift with codec type.
The purpose is to have consistent dailink ids for topologies.
This can be simplified if we have a predefined dailink id in
sof_sdw_dai_info.
We reuse the existing ids as the predefine ids. So the dailink ids will
not be changed by this commit.
With this change, we no longer need to check the adr order described in a
snd_soc_acpi_link_adr array.
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230602202225.249209-4-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 07140abb
...@@ -568,6 +568,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -568,6 +568,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.direction = {true, true}, .direction = {true, true},
.dai_name = "rt700-aif1", .dai_name = "rt700-aif1",
.dai_type = SOF_SDW_DAI_TYPE_JACK, .dai_type = SOF_SDW_DAI_TYPE_JACK,
.dailink = {SDW_JACK_OUT_DAI_ID, SDW_JACK_IN_DAI_ID},
.init = sof_sdw_rt700_init, .init = sof_sdw_rt700_init,
}, },
}, },
...@@ -582,6 +583,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -582,6 +583,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.direction = {true, true}, .direction = {true, true},
.dai_name = "rt711-sdca-aif1", .dai_name = "rt711-sdca-aif1",
.dai_type = SOF_SDW_DAI_TYPE_JACK, .dai_type = SOF_SDW_DAI_TYPE_JACK,
.dailink = {SDW_JACK_OUT_DAI_ID, SDW_JACK_IN_DAI_ID},
.init = sof_sdw_rt711_sdca_init, .init = sof_sdw_rt711_sdca_init,
.exit = sof_sdw_rt711_sdca_exit, .exit = sof_sdw_rt711_sdca_exit,
}, },
...@@ -597,6 +599,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -597,6 +599,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.direction = {true, true}, .direction = {true, true},
.dai_name = "rt711-aif1", .dai_name = "rt711-aif1",
.dai_type = SOF_SDW_DAI_TYPE_JACK, .dai_type = SOF_SDW_DAI_TYPE_JACK,
.dailink = {SDW_JACK_OUT_DAI_ID, SDW_JACK_IN_DAI_ID},
.init = sof_sdw_rt711_init, .init = sof_sdw_rt711_init,
.exit = sof_sdw_rt711_exit, .exit = sof_sdw_rt711_exit,
}, },
...@@ -612,6 +615,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -612,6 +615,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.direction = {true, false}, .direction = {true, false},
.dai_name = "rt1308-aif", .dai_name = "rt1308-aif",
.dai_type = SOF_SDW_DAI_TYPE_AMP, .dai_type = SOF_SDW_DAI_TYPE_AMP,
.dailink = {SDW_AMP_OUT_DAI_ID, SDW_UNUSED_DAI_ID},
.init = sof_sdw_rt_amp_init, .init = sof_sdw_rt_amp_init,
.exit = sof_sdw_rt_amp_exit, .exit = sof_sdw_rt_amp_exit,
}, },
...@@ -627,6 +631,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -627,6 +631,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.direction = {true, true}, .direction = {true, true},
.dai_name = "rt1316-aif", .dai_name = "rt1316-aif",
.dai_type = SOF_SDW_DAI_TYPE_AMP, .dai_type = SOF_SDW_DAI_TYPE_AMP,
.dailink = {SDW_AMP_OUT_DAI_ID, SDW_AMP_IN_DAI_ID},
.init = sof_sdw_rt_amp_init, .init = sof_sdw_rt_amp_init,
.exit = sof_sdw_rt_amp_exit, .exit = sof_sdw_rt_amp_exit,
}, },
...@@ -641,6 +646,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -641,6 +646,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.direction = {true, true}, .direction = {true, true},
.dai_name = "rt1318-aif", .dai_name = "rt1318-aif",
.dai_type = SOF_SDW_DAI_TYPE_AMP, .dai_type = SOF_SDW_DAI_TYPE_AMP,
.dailink = {SDW_AMP_OUT_DAI_ID, SDW_AMP_IN_DAI_ID},
.init = sof_sdw_rt_amp_init, .init = sof_sdw_rt_amp_init,
.exit = sof_sdw_rt_amp_exit, .exit = sof_sdw_rt_amp_exit,
}, },
...@@ -657,6 +663,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -657,6 +663,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.direction = {false, true}, .direction = {false, true},
.dai_name = "rt715-aif2", .dai_name = "rt715-aif2",
.dai_type = SOF_SDW_DAI_TYPE_MIC, .dai_type = SOF_SDW_DAI_TYPE_MIC,
.dailink = {SDW_UNUSED_DAI_ID, SDW_DMIC_DAI_ID},
.init = sof_sdw_rt715_sdca_init, .init = sof_sdw_rt715_sdca_init,
}, },
}, },
...@@ -672,6 +679,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -672,6 +679,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.direction = {false, true}, .direction = {false, true},
.dai_name = "rt715-aif2", .dai_name = "rt715-aif2",
.dai_type = SOF_SDW_DAI_TYPE_MIC, .dai_type = SOF_SDW_DAI_TYPE_MIC,
.dailink = {SDW_UNUSED_DAI_ID, SDW_DMIC_DAI_ID},
.init = sof_sdw_rt715_sdca_init, .init = sof_sdw_rt715_sdca_init,
}, },
}, },
...@@ -687,6 +695,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -687,6 +695,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.direction = {false, true}, .direction = {false, true},
.dai_name = "rt715-aif2", .dai_name = "rt715-aif2",
.dai_type = SOF_SDW_DAI_TYPE_MIC, .dai_type = SOF_SDW_DAI_TYPE_MIC,
.dailink = {SDW_UNUSED_DAI_ID, SDW_DMIC_DAI_ID},
.init = sof_sdw_rt715_init, .init = sof_sdw_rt715_init,
}, },
}, },
...@@ -702,6 +711,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -702,6 +711,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.direction = {false, true}, .direction = {false, true},
.dai_name = "rt715-aif2", .dai_name = "rt715-aif2",
.dai_type = SOF_SDW_DAI_TYPE_MIC, .dai_type = SOF_SDW_DAI_TYPE_MIC,
.dailink = {SDW_UNUSED_DAI_ID, SDW_DMIC_DAI_ID},
.init = sof_sdw_rt715_init, .init = sof_sdw_rt715_init,
}, },
}, },
...@@ -715,6 +725,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -715,6 +725,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.direction = {true, true}, .direction = {true, true},
.dai_name = "max98373-aif1", .dai_name = "max98373-aif1",
.dai_type = SOF_SDW_DAI_TYPE_AMP, .dai_type = SOF_SDW_DAI_TYPE_AMP,
.dailink = {SDW_AMP_OUT_DAI_ID, SDW_AMP_IN_DAI_ID},
.init = sof_sdw_mx8373_init, .init = sof_sdw_mx8373_init,
}, },
}, },
...@@ -728,6 +739,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -728,6 +739,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.direction = {true, true}, .direction = {true, true},
.dai_name = "rt5682-sdw", .dai_name = "rt5682-sdw",
.dai_type = SOF_SDW_DAI_TYPE_JACK, .dai_type = SOF_SDW_DAI_TYPE_JACK,
.dailink = {SDW_JACK_OUT_DAI_ID, SDW_JACK_IN_DAI_ID},
.init = sof_sdw_rt5682_init, .init = sof_sdw_rt5682_init,
}, },
}, },
...@@ -742,6 +754,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -742,6 +754,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.direction = {true, true}, .direction = {true, true},
.dai_name = "sdw-mockup-aif1", .dai_name = "sdw-mockup-aif1",
.dai_type = SOF_SDW_DAI_TYPE_JACK, .dai_type = SOF_SDW_DAI_TYPE_JACK,
.dailink = {SDW_JACK_OUT_DAI_ID, SDW_JACK_IN_DAI_ID},
.init = NULL, .init = NULL,
}, },
}, },
...@@ -756,6 +769,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -756,6 +769,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.direction = {true, true}, .direction = {true, true},
.dai_name = "sdw-mockup-aif1", .dai_name = "sdw-mockup-aif1",
.dai_type = SOF_SDW_DAI_TYPE_JACK, .dai_type = SOF_SDW_DAI_TYPE_JACK,
.dailink = {SDW_JACK_OUT_DAI_ID, SDW_JACK_IN_DAI_ID},
.init = NULL, .init = NULL,
}, },
}, },
...@@ -770,6 +784,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -770,6 +784,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.direction = {true, false}, .direction = {true, false},
.dai_name = "sdw-mockup-aif1", .dai_name = "sdw-mockup-aif1",
.dai_type = SOF_SDW_DAI_TYPE_AMP, .dai_type = SOF_SDW_DAI_TYPE_AMP,
.dailink = {SDW_AMP_OUT_DAI_ID, SDW_UNUSED_DAI_ID},
.init = NULL, .init = NULL,
}, },
}, },
...@@ -784,6 +799,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { ...@@ -784,6 +799,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.dai_name = "sdw-mockup-aif1", .dai_name = "sdw-mockup-aif1",
.direction = {false, true}, .direction = {false, true},
.dai_type = SOF_SDW_DAI_TYPE_MIC, .dai_type = SOF_SDW_DAI_TYPE_MIC,
.dailink = {SDW_UNUSED_DAI_ID, SDW_DMIC_DAI_ID},
.init = NULL, .init = NULL,
}, },
}, },
...@@ -840,7 +856,6 @@ static int get_sdw_dailink_info(struct device *dev, const struct snd_soc_acpi_li ...@@ -840,7 +856,6 @@ static int get_sdw_dailink_info(struct device *dev, const struct snd_soc_acpi_li
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;
...@@ -867,12 +882,6 @@ static int get_sdw_dailink_info(struct device *dev, const struct snd_soc_acpi_li ...@@ -867,12 +882,6 @@ static int get_sdw_dailink_info(struct device *dev, const struct snd_soc_acpi_li
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[i].endpoints; endpoint = link->adr_d[i].endpoints;
/* count DAI number for playback and capture */ /* count DAI number for playback and capture */
...@@ -1227,19 +1236,6 @@ static int create_sdw_dailink(struct snd_soc_card *card, ...@@ -1227,19 +1236,6 @@ static int create_sdw_dailink(struct snd_soc_card *card,
if (codec_info_list[codec_index].ignore_pch_dmic) if (codec_info_list[codec_index].ignore_pch_dmic)
*ignore_pch_dmic = true; *ignore_pch_dmic = true;
/* Shift the first amplifier's *link_id to SDW_AMP_DAI_ID */
if (codec_info_list[codec_index].codec_type == SOF_SDW_CODEC_TYPE_AMP &&
*link_id < SDW_AMP_DAI_ID)
*link_id = SDW_AMP_DAI_ID;
/*
* DAI ID is fixed at SDW_DMIC_DAI_ID for MICs to
* keep sdw DMIC and HDMI setting static in UCM
*/
if (codec_info_list[codec_index].codec_type == SOF_SDW_CODEC_TYPE_MIC &&
*link_id < SDW_DMIC_DAI_ID)
*link_id = SDW_DMIC_DAI_ID;
cpu_dai_index = *cpu_id; cpu_dai_index = *cpu_id;
for_each_pcm_streams(stream) { for_each_pcm_streams(stream) {
char *name, *cpu_name; char *name, *cpu_name;
...@@ -1254,6 +1250,12 @@ static int create_sdw_dailink(struct snd_soc_card *card, ...@@ -1254,6 +1250,12 @@ static int create_sdw_dailink(struct snd_soc_card *card,
if (!codec_info_list[codec_index].dais[0].direction[stream]) if (!codec_info_list[codec_index].dais[0].direction[stream])
continue; continue;
*link_id = codec_info_list[codec_index].dais[0].dailink[stream];
if (*link_id < 0) {
dev_err(dev, "Invalid dailink id %d\n", *link_id);
return -EINVAL;
}
/* create stream name according to first link id */ /* create stream name according to first link id */
if (append_codec_type) { if (append_codec_type) {
name = devm_kasprintf(dev, GFP_KERNEL, name = devm_kasprintf(dev, GFP_KERNEL,
......
...@@ -15,7 +15,11 @@ ...@@ -15,7 +15,11 @@
#define MAX_NO_PROPS 2 #define MAX_NO_PROPS 2
#define MAX_HDMI_NUM 4 #define MAX_HDMI_NUM 4
#define SDW_AMP_DAI_ID 2 #define SDW_UNUSED_DAI_ID -1
#define SDW_JACK_OUT_DAI_ID 0
#define SDW_JACK_IN_DAI_ID 1
#define SDW_AMP_OUT_DAI_ID 2
#define SDW_AMP_IN_DAI_ID 3
#define SDW_DMIC_DAI_ID 4 #define SDW_DMIC_DAI_ID 4
#define SDW_MAX_CPU_DAIS 16 #define SDW_MAX_CPU_DAIS 16
#define SDW_INTEL_BIDIR_PDI_BASE 2 #define SDW_INTEL_BIDIR_PDI_BASE 2
...@@ -68,6 +72,7 @@ struct sof_sdw_dai_info { ...@@ -68,6 +72,7 @@ struct sof_sdw_dai_info {
const bool direction[2]; /* playback & capture support */ const bool direction[2]; /* playback & capture support */
const char *dai_name; const char *dai_name;
const int dai_type; const int dai_type;
const int dailink[2]; /* dailink id for each direction */
int (*init)(struct snd_soc_card *card, int (*init)(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link, const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links, struct snd_soc_dai_link *dai_links,
......
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