Skip to content
Merged
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) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is the "partial match" you mention in your commit in the code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed the index from the codec_name, and use the partial codec name to match the component 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);
Copy link
Member

Choose a reason for hiding this comment

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

it'd be worth having a real example to show the old behavior and the new behavior...

In the next path you use "snd_soc_sdca.UAJ.1" and remove the trailing index, but that doesn't tell us how the component->name is brought in the picture on line 1225

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@plbossart The codec name will be "snd_soc_sdca.SmartMic.0", "snd_soc_sdca.UAJ.1", and "snd_soc_sdca.HID.2" if all SDCA functions are present. But if the Smart Mic is not present, the codec name will be "snd_soc_sdca.UAJ.0", and "snd_soc_sdca.HID.1". The sound card will not probe because it can't find the "snd_soc_sdca.UAJ.1" component which is required by the DAI link.
With the PR, the driver will look for the "snd_soc_sdca.HID" component from the component list and use the component name as the DAI link codec component name which is "snd_soc_sdca.UAJ.0" in the no Smart Mic case. Then, the sound card will probe because it can find the required codec component.
In other words, the commit looks for the component that partial matches the given name and use the component name as the codec name of the DAI link.

}
}

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
13 changes: 13 additions & 0 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,19 @@ struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
}
EXPORT_SYMBOL_GPL(snd_soc_lookup_component);

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

guard(mutex)(&client_mutex);
for_each_component(component)
if (strstr(component->name, component_name))
return component;

return NULL;
}
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