Commit 2e2d287b authored by Bard Liao's avatar Bard Liao Committed by Mark Brown

ASoC: Intel: sof_sdw: check SoundWire version when matching codec

Some codecs with the same part id but different SoundWire versions
have different configurations. So we have to separate them in
codec_info_list[].
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/20200821195603.215535-9-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 65fae64d
......@@ -253,18 +253,25 @@ static struct sof_sdw_codec_info codec_info_list[] = {
},
};
static inline int find_codec_info_part(unsigned int part_id)
static inline int find_codec_info_part(u64 adr)
{
unsigned int part_id, sdw_version;
int i;
part_id = SDW_PART_ID(adr);
sdw_version = SDW_VERSION(adr);
for (i = 0; i < ARRAY_SIZE(codec_info_list); i++)
if (part_id == codec_info_list[i].id)
break;
/*
* A codec info is for all sdw version with the part id if
* version_id is not specified in the codec info.
*/
if (part_id == codec_info_list[i].id &&
(!codec_info_list[i].version_id ||
sdw_version == codec_info_list[i].version_id))
return i;
if (i == ARRAY_SIZE(codec_info_list))
return -EINVAL;
return -EINVAL;
return i;
}
static inline int find_codec_info_acpi(const u8 *acpi_id)
......@@ -310,13 +317,12 @@ static int get_sdw_dailink_info(const struct snd_soc_acpi_link_adr *links,
for (link = links; link->num_adr; link++) {
const struct snd_soc_acpi_endpoint *endpoint;
int part_id, codec_index;
int codec_index;
int stream;
u64 adr;
adr = link->adr_d->adr;
part_id = SDW_PART_ID(adr);
codec_index = find_codec_info_part(part_id);
codec_index = find_codec_info_part(adr);
if (codec_index < 0)
return codec_index;
......@@ -444,7 +450,7 @@ static int create_codec_dai_name(struct device *dev,
if (!codec[comp_index].name)
return -ENOMEM;
codec_index = find_codec_info_part(part_id);
codec_index = find_codec_info_part(adr);
if (codec_index < 0)
return codec_index;
......@@ -468,11 +474,9 @@ static int set_codec_init_func(const struct snd_soc_acpi_link_adr *link,
* same group.
*/
for (i = 0; i < link->num_adr; i++) {
unsigned int part_id;
int codec_index;
part_id = SDW_PART_ID(link->adr_d[i].adr);
codec_index = find_codec_info_part(part_id);
codec_index = find_codec_info_part(link->adr_d[i].adr);
if (codec_index < 0)
return codec_index;
......@@ -576,7 +580,7 @@ static int create_sdw_dailink(struct device *dev, int *be_index,
struct snd_soc_dai_link_component *codecs;
int cpu_dai_id[SDW_MAX_CPU_DAIS];
int cpu_dai_num, cpu_dai_index;
unsigned int part_id, group_id;
unsigned int group_id;
int codec_idx = 0;
int i = 0, j = 0;
int codec_index;
......@@ -618,8 +622,7 @@ static int create_sdw_dailink(struct device *dev, int *be_index,
}
/* find codec info to create BE DAI */
part_id = SDW_PART_ID(link->adr_d[0].adr);
codec_index = find_codec_info_part(part_id);
codec_index = find_codec_info_part(link->adr_d[0].adr);
if (codec_index < 0)
return codec_index;
......
......@@ -52,6 +52,7 @@ enum {
struct sof_sdw_codec_info {
const int id;
const int version_id;
int amp_num;
const u8 acpi_id[ACPI_ID_LEN];
const bool direction[2]; // playback & capture support
......
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