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_sdw_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct asoc_sdw_codec_info;
struct asoc_sdw_dai_info {
const bool direction[2]; /* playback & capture support */
const char *dai_name;
const char *component_name;
const int dai_type;
const int dailink[2]; /* dailink id for each direction */
const struct snd_kcontrol_new *controls;
Expand Down
10 changes: 0 additions & 10 deletions sound/soc/sdw_utils/soc_sdw_cs_amp.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <sound/soc-dai.h>
#include <sound/soc_sdw_utils.h>

#define CODEC_NAME_SIZE 8
#define CS_AMP_CHANNELS_PER_AMP 4
#define CS35L56_SPK_VOLUME_0DB 400 /* 0dB Max */

Expand All @@ -38,21 +37,12 @@ EXPORT_SYMBOL_NS(asoc_sdw_cs35l56_volume_limit, "SND_SOC_SDW_UTILS");

int asoc_sdw_cs_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai)
{
const char *dai_name = rtd->dai_link->codecs->dai_name;
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you have a link for the suggestion? Out of curiosity

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

struct snd_soc_card *card = rtd->card;
char codec_name[CODEC_NAME_SIZE];
char widget_name[16];
struct snd_soc_dapm_route route = { "Speaker", NULL, widget_name };
struct snd_soc_dai *codec_dai;
int i, ret;

snprintf(codec_name, CODEC_NAME_SIZE, "%s", dai_name);
card->components = devm_kasprintf(card->dev, GFP_KERNEL,
"%s spk:%s",
card->components, codec_name);
if (!card->components)
return -ENOMEM;

for_each_rtd_codec_dais(rtd, i, codec_dai) {
if (!strstr(codec_dai->name, "cs35l56"))
continue;
Expand Down
9 changes: 0 additions & 9 deletions sound/soc/sdw_utils/soc_sdw_maxim.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ int asoc_sdw_maxim_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_
struct snd_soc_card *card = rtd->card;
int ret;

card->components = devm_kasprintf(card->dev, GFP_KERNEL,
"%s spk:mx%04x",
card->components, maxim_part_id);
if (!card->components)
return -ENOMEM;

dev_dbg(card->dev, "soundwire maxim card components assigned : %s\n",
card->components);

ret = snd_soc_dapm_add_routes(&card->dapm, max_98373_dapm_routes, 2);
if (ret)
dev_err(rtd->dev, "failed to add first SPK map: %d\n", ret);
Expand Down
6 changes: 0 additions & 6 deletions sound/soc/sdw_utils/soc_sdw_rt_amp.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,6 @@ int asoc_sdw_rt_amp_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc

rt_amp_map = get_codec_name_and_route(dai, codec_name);

card->components = devm_kasprintf(card->dev, GFP_KERNEL,
"%s spk:%s",
card->components, codec_name);
if (!card->components)
return -ENOMEM;

for_each_rtd_codec_dais(rtd, i, codec_dai) {
if (strstr(codec_dai->component->name_prefix, "-1"))
ret = snd_soc_dapm_add_routes(&card->dapm, rt_amp_map, 2);
Expand Down
7 changes: 0 additions & 7 deletions sound/soc/sdw_utils/soc_sdw_rt_mf_sdca.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@ int asoc_sdw_rt_mf_sdca_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd
return -EINVAL;
}

/* Update card components */
card->components = devm_kasprintf(card->dev, GFP_KERNEL,
"%s spk:%s",
card->components, codec_name);
if (!card->components)
return -ENOMEM;

/* Add routes */
ret = snd_soc_dapm_add_routes(&card->dapm, route_map->route_map, route_map->route_size);
if (ret)
Expand Down
33 changes: 33 additions & 0 deletions sound/soc/sdw_utils/soc_sdw_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ struct asoc_sdw_codec_info codec_info_list[] = {
{
.direction = {true, false},
.dai_name = "rt712-sdca-aif2",
.component_name = "rt712",
.dai_type = SOC_SDW_DAI_TYPE_AMP,
.dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID},
.init = asoc_sdw_rt_amp_init,
Expand Down Expand Up @@ -275,6 +276,7 @@ struct asoc_sdw_codec_info codec_info_list[] = {
{
.direction = {true, false},
.dai_name = "rt1320-aif1",
.component_name = "rt1320",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would update the commit message and reword/sentence it as these:
extracted from DAI name. And different codecs
without rely on the rtd_init. And can combine different
Sentences are not really easy to follow.

I would also mention why you only add the component_name to SOC_SDW_DAI_TYPE_AMP only (as far as I can see).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

commit message updated.

.dai_type = SOC_SDW_DAI_TYPE_AMP,
.dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID},
.init = asoc_sdw_rt_amp_init,
Expand Down Expand Up @@ -409,6 +411,7 @@ struct asoc_sdw_codec_info codec_info_list[] = {
{
.direction = {true, false},
.dai_name = "rt722-sdca-aif2",
.component_name = "rt722",
.dai_type = SOC_SDW_DAI_TYPE_AMP,
/* No feedback capability is provided by rt722-sdca codec driver*/
.dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID},
Expand Down Expand Up @@ -438,6 +441,7 @@ struct asoc_sdw_codec_info codec_info_list[] = {
{
.direction = {true, true},
.dai_name = "max98373-aif1",
.component_name = "mx8373",
Copy link
Collaborator

@ujfalusi ujfalusi Jun 4, 2025

Choose a reason for hiding this comment

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

is it max98373 or mx8373 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

According to https://github.com/thesofproject/linux/blob/topic/sof-dev/sound/soc/sdw_utils/soc_sdw_maxim.c#L31, I think it should be mx8373.

	card->components = devm_kasprintf(card->dev, GFP_KERNEL,
					  "%s spk:mx%04x",
					  card->components, maxim_part_id);

.dai_type = SOC_SDW_DAI_TYPE_AMP,
.dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_AMP_IN_DAI_ID},
.init = asoc_sdw_maxim_init,
Expand All @@ -456,6 +460,7 @@ struct asoc_sdw_codec_info codec_info_list[] = {
{
.direction = {true, false},
.dai_name = "max98363-aif1",
.component_name = "mx8363",
.dai_type = SOC_SDW_DAI_TYPE_AMP,
.dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID},
.init = asoc_sdw_maxim_init,
Expand Down Expand Up @@ -491,6 +496,7 @@ struct asoc_sdw_codec_info codec_info_list[] = {
{
.direction = {true, false},
.dai_name = "cs35l56-sdw1",
.component_name = "cs35l56",
.dai_type = SOC_SDW_DAI_TYPE_AMP,
.dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID},
.init = asoc_sdw_cs_amp_init,
Expand All @@ -516,6 +522,7 @@ struct asoc_sdw_codec_info codec_info_list[] = {
{
.direction = {true, false},
.dai_name = "cs35l56-sdw1",
.component_name = "cs35l56",
.dai_type = SOC_SDW_DAI_TYPE_AMP,
.dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID},
.init = asoc_sdw_cs_amp_init,
Expand Down Expand Up @@ -733,6 +740,7 @@ int asoc_sdw_rtd_init(struct snd_soc_pcm_runtime *rtd)
struct snd_soc_card *card = rtd->card;
struct asoc_sdw_codec_info *codec_info;
struct snd_soc_dai *dai;
const char *spk_components="";
int dai_index;
int ret;
int i;
Expand Down Expand Up @@ -785,7 +793,32 @@ int asoc_sdw_rtd_init(struct snd_soc_pcm_runtime *rtd)
if (ret)
return ret;
}

/* Generate the spk component string for card->components string */
if (codec_info->dais[dai_index].dai_type == SOC_SDW_DAI_TYPE_AMP &&
codec_info->dais[dai_index].component_name) {
if (strlen (spk_components) == 0)
spk_components =
devm_kasprintf(card->dev, GFP_KERNEL, "%s",
codec_info->dais[dai_index].component_name);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess we need a human readable (UCM readable) name here, right?
iow, "spk:rt722+rt1320" and "spk:0x722+0x1320" (printing the part_id as %#x) would not work here, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right, it will be "spk:rt722+rt1320" as it is "spk:rt722 spk:rt1320" now.

else
/* Append component name to spk_components */
spk_components =
devm_kasprintf(card->dev, GFP_KERNEL,
"%s+%s", spk_components,
codec_info->dais[dai_index].component_name);
}

codec_info->dais[dai_index].rtd_init_done = true;

}

if (strlen (spk_components) > 0) {
/* Update card components for speaker components */
card->components = devm_kasprintf(card->dev, GFP_KERNEL, "%s spk:%s",
card->components, spk_components);
if (!card->components)
return -ENOMEM;
}

return 0;
Expand Down
Loading