Skip to content

Commit

Permalink
ASoC: Intel: sof_ssp_amp: do not create amp link for nocodec board
Browse files Browse the repository at this point in the history
A BE DAI link for speaker amplifier is always created even a board
quirk specifies there is no amplifier. Modify the driver to check
amplifier type before creating corresponding DAI link.

Signed-off-by: Brent Lu <[email protected]>
  • Loading branch information
brentlu committed Aug 29, 2023
1 parent 3229e13 commit 2e8cc59
Showing 1 changed file with 45 additions and 33 deletions.
78 changes: 45 additions & 33 deletions sound/soc/intel/boards/sof_ssp_amp.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
struct snd_soc_dai_link_component *idisp_components;
struct snd_soc_dai_link_component *cpus;
struct snd_soc_dai_link *links;
int i, id = 0;
int i, id = 0, be_id = 0;

links = devm_kcalloc(dev, sof_ssp_amp_card.num_links,
sizeof(struct snd_soc_dai_link), GFP_KERNEL);
Expand Down Expand Up @@ -222,7 +222,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
links[id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-HDMI", port);
if (!links[id].name)
return NULL;
links[id].id = id;
links[id].id = be_id;
links[id].codecs = &asoc_dummy_dlc;
links[id].num_codecs = 1;
links[id].platforms = platform_component;
Expand All @@ -231,41 +231,47 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
links[id].no_pcm = 1;
links[id].num_cpus = 1;
id++;
be_id++;
}
}

/* codec SSP */
links[id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_codec);
if (!links[id].name)
return NULL;
if (amp_type != CODEC_NONE) {
links[id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_codec);
if (!links[id].name)
return NULL;

links[id].id = be_id;

switch (amp_type) {
case CODEC_CS35L41:
cs35l41_set_dai_link(&links[id]);
break;
case CODEC_RT1308:
sof_rt1308_dai_link(&links[id]);
break;
default:
dev_err(dev, "invalid amp type %d\n", amp_type);
return NULL;
}

links[id].id = id;
links[id].platforms = platform_component;
links[id].num_platforms = ARRAY_SIZE(platform_component);
links[id].dpcm_playback = 1;
/* feedback from amplifier or firmware-generated echo reference */
links[id].dpcm_capture = 1;
links[id].no_pcm = 1;
links[id].cpus = &cpus[id];
links[id].num_cpus = 1;
links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_codec);
if (!links[id].cpus->dai_name)
return NULL;

switch (amp_type) {
case CODEC_CS35L41:
cs35l41_set_dai_link(&links[id]);
break;
case CODEC_RT1308:
sof_rt1308_dai_link(&links[id]);
break;
default:
dev_err(dev, "invalid amp type %d\n", amp_type);
return NULL;
id++;
}

links[id].platforms = platform_component;
links[id].num_platforms = ARRAY_SIZE(platform_component);
links[id].dpcm_playback = 1;
/* feedback from amplifier or firmware-generated echo reference */
links[id].dpcm_capture = 1;
links[id].no_pcm = 1;
links[id].cpus = &cpus[id];
links[id].num_cpus = 1;
links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_codec);
if (!links[id].cpus->dai_name)
return NULL;

id++;
/* hdmi-in topology preserves this id with or without amplifier attached */
be_id++;

/* dmic */
if (dmic_be_num > 0) {
Expand All @@ -283,7 +289,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
}

for (i = 0; i < dmic_be_num; i++) {
links[id].id = id;
links[id].id = be_id;
links[id].num_cpus = 1;
links[id].codecs = dmic_component;
links[id].num_codecs = ARRAY_SIZE(dmic_component);
Expand All @@ -293,6 +299,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
links[id].dpcm_capture = 1;
links[id].no_pcm = 1;
id++;
be_id++;
}

/* HDMI playback */
Expand All @@ -312,7 +319,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
if (!links[id].name)
goto devm_err;

links[id].id = id;
links[id].id = be_id;
links[id].cpus = &cpus[id];
links[id].num_cpus = 1;
links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
Expand Down Expand Up @@ -340,6 +347,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
links[id].dpcm_playback = 1;
links[id].no_pcm = 1;
id++;
be_id++;
}
}

Expand All @@ -348,7 +356,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
int port = (sof_ssp_amp_quirk & SOF_BT_OFFLOAD_SSP_MASK) >>
SOF_BT_OFFLOAD_SSP_SHIFT;

links[id].id = id;
links[id].id = be_id;
links[id].cpus = &cpus[id];
links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
"SSP%d Pin", port);
Expand All @@ -366,6 +374,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
links[id].no_pcm = 1;
links[id].num_cpus = 1;
id++;
be_id++;
}

return links;
Expand Down Expand Up @@ -398,7 +407,10 @@ static int sof_ssp_amp_probe(struct platform_device *pdev)
ssp_codec = sof_ssp_amp_quirk & SOF_AMPLIFIER_SSP_MASK;

/* set number of dai links */
sof_ssp_amp_card.num_links = 1 + dmic_be_num;
sof_ssp_amp_card.num_links = dmic_be_num;

This comment has been minimized.

Copy link
@CBala21

CBala21 Aug 29, 2023

Doesn't require to account SSP codec link which has been preserved for with or without codec amplifier case?


if (ctx->amp_type != CODEC_NONE)
sof_ssp_amp_card.num_links++;

if (sof_ssp_amp_quirk & SOF_SSP_HDMI_CAPTURE_PRESENT)
sof_ssp_amp_card.num_links += (sof_ssp_amp_quirk & SOF_NO_OF_HDMI_CAPTURE_SSP_MASK) >>
Expand Down

1 comment on commit 2e8cc59

@CBala21
Copy link

Choose a reason for hiding this comment

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

With these new changes we are able to test without topology modification. So we need BE id retention to avoid topology changes.

Please sign in to comment.