Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/sound/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ struct snd_soc_component *snd_soc_lookup_component_nolocked(struct device *dev,
const char *driver_name);
struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
const char *driver_name);
struct snd_soc_component *snd_soc_lookup_component_by_name(const char *component_name);

int soc_new_pcm(struct snd_soc_pcm_runtime *rtd);
#ifdef CONFIG_SND_SOC_COMPRESS
Expand Down
32 changes: 26 additions & 6 deletions sound/soc/sdw_utils/soc_sdw_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ struct asoc_sdw_codec_info codec_info_list[] = {
.dais = {
{
.direction = {true, false},
.codec_name = "snd_soc_sdca.UAJ.1",
.codec_name = "snd_soc_sdca.UAJ",
.dai_name = "IT 41",
.dai_type = SOC_SDW_DAI_TYPE_JACK,
.dailink = {SOC_SDW_JACK_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID},
Expand All @@ -745,7 +745,7 @@ struct asoc_sdw_codec_info codec_info_list[] = {
},
{
.direction = {false, true},
.codec_name = "snd_soc_sdca.UAJ.1",
.codec_name = "snd_soc_sdca.UAJ",
.dai_name = "OT 36",
.dai_type = SOC_SDW_DAI_TYPE_JACK,
.dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_JACK_IN_DAI_ID},
Expand All @@ -754,7 +754,7 @@ struct asoc_sdw_codec_info codec_info_list[] = {
.dai_num = 3,
.auxs = {
{
.codec_name = "snd_soc_sdca.HID.2",
.codec_name = "snd_soc_sdca.HID",
},
},
.aux_num = 1,
Expand Down Expand Up @@ -1215,8 +1215,18 @@ const char *asoc_sdw_get_codec_name(struct device *dev,
const struct snd_soc_acpi_link_adr *adr_link,
int adr_index)
{
if (dai_info->codec_name)
return devm_kstrdup(dev, dai_info->codec_name, GFP_KERNEL);
if (dai_info->codec_name) {
struct snd_soc_component *component;

component = snd_soc_lookup_component_by_name(dai_info->codec_name);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we be sure the component exists by this point?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we be sure the component exists by this point?

No, but in theory, the function will be called again when the component probed and be registered.

if (component) {
dev_dbg(dev, "%s found component %s for codec_name %s\n",
__func__, component->name, dai_info->codec_name);
return devm_kstrdup(dev, component->name, GFP_KERNEL);
} else {
return devm_kstrdup(dev, dai_info->codec_name, GFP_KERNEL);
}
}

return _asoc_sdw_get_codec_name(dev, adr_link, adr_index);
}
Expand Down Expand Up @@ -1528,7 +1538,17 @@ int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card,
return -EINVAL;

for (j = 0; j < codec_info->aux_num; j++) {
soc_aux->dlc.name = codec_info->auxs[j].codec_name;
struct snd_soc_component *component;

component = snd_soc_lookup_component_by_name(codec_info->auxs[j].
codec_name);
if (component) {
dev_dbg(dev, "%s found component %s for aux name %s\n",
__func__, component->name, codec_info->auxs[j].codec_name);
soc_aux->dlc.name = component->name;
} else {
soc_aux->dlc.name = codec_info->auxs[j].codec_name;
}
soc_aux++;
}

Expand Down
24 changes: 24 additions & 0 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,30 @@ struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
}
EXPORT_SYMBOL_GPL(snd_soc_lookup_component);

static struct snd_soc_component
*snd_soc_lookup_component_by_name_nolocked(const char *component_name)
{
struct snd_soc_component *component;

for_each_component(component)
if (strstr(component->name, component_name))
return component;

return NULL;
}

struct snd_soc_component *snd_soc_lookup_component_by_name(const char *component_name)
{
struct snd_soc_component *component;

mutex_lock(&client_mutex);
component = snd_soc_lookup_component_by_name_nolocked(component_name);
mutex_unlock(&client_mutex);

return component;
}
EXPORT_SYMBOL_GPL(snd_soc_lookup_component_by_name);

struct snd_soc_pcm_runtime
*snd_soc_get_pcm_runtime(struct snd_soc_card *card,
struct snd_soc_dai_link *dai_link)
Expand Down
Loading