Commit 48bc32d9 authored by Brent Lu's avatar Brent Lu Committed by Mark Brown

ASoC: Intel: sof_ssp_amp: do not create amp link for nocodec board

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.

The topology (sof-tgl-rt1308-hdmi-ssp.m4) which supports HDMI-IN is
using fixed BE ID for each DAI link. Therefore we also uses fixed ID
in machine driver side.
Signed-off-by: default avatarBrent Lu <brent.lu@intel.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarBalamurugan C <balamurugan.c@intel.com>
Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20230915124852.1696857-13-yung-chuan.liao@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 14b7ed66
...@@ -186,6 +186,12 @@ static int sof_hdmi_init(struct snd_soc_pcm_runtime *rtd) ...@@ -186,6 +186,12 @@ static int sof_hdmi_init(struct snd_soc_pcm_runtime *rtd)
#define IDISP_CODEC_MASK 0x4 #define IDISP_CODEC_MASK 0x4
/* BE ID defined in sof-tgl-rt1308-hdmi-ssp.m4 */
#define HDMI_IN_BE_ID 0
#define SPK_BE_ID 2
#define DMIC01_BE_ID 3
#define INTEL_HDMI_BE_ID 5
static struct snd_soc_dai_link * static struct snd_soc_dai_link *
sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
int ssp_codec, int dmic_be_num, int hdmi_num, int ssp_codec, int dmic_be_num, int hdmi_num,
...@@ -195,6 +201,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, ...@@ -195,6 +201,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
struct snd_soc_dai_link_component *cpus; struct snd_soc_dai_link_component *cpus;
struct snd_soc_dai_link *links; struct snd_soc_dai_link *links;
int i, id = 0; int i, id = 0;
bool fixed_be = false;
links = devm_kcalloc(dev, sof_ssp_amp_card.num_links, links = devm_kcalloc(dev, sof_ssp_amp_card.num_links,
sizeof(struct snd_soc_dai_link), GFP_KERNEL); sizeof(struct snd_soc_dai_link), GFP_KERNEL);
...@@ -208,6 +215,9 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, ...@@ -208,6 +215,9 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
int num_of_hdmi_ssp = (sof_ssp_amp_quirk & SOF_NO_OF_HDMI_CAPTURE_SSP_MASK) >> int num_of_hdmi_ssp = (sof_ssp_amp_quirk & SOF_NO_OF_HDMI_CAPTURE_SSP_MASK) >>
SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT; SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT;
/* the topology supports HDMI-IN uses fixed BE ID for DAI links */
fixed_be = true;
for (i = 1; i <= num_of_hdmi_ssp; i++) { for (i = 1; i <= num_of_hdmi_ssp; i++) {
int port = (i == 1 ? (sof_ssp_amp_quirk & SOF_HDMI_CAPTURE_1_SSP_MASK) >> int port = (i == 1 ? (sof_ssp_amp_quirk & SOF_HDMI_CAPTURE_1_SSP_MASK) >>
SOF_HDMI_CAPTURE_1_SSP_SHIFT : SOF_HDMI_CAPTURE_1_SSP_SHIFT :
...@@ -222,7 +232,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, ...@@ -222,7 +232,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); links[id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-HDMI", port);
if (!links[id].name) if (!links[id].name)
return NULL; return NULL;
links[id].id = id; links[id].id = fixed_be ? (HDMI_IN_BE_ID + i - 1) : id;
links[id].codecs = &asoc_dummy_dlc; links[id].codecs = &asoc_dummy_dlc;
links[id].num_codecs = 1; links[id].num_codecs = 1;
links[id].platforms = platform_component; links[id].platforms = platform_component;
...@@ -235,11 +245,12 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, ...@@ -235,11 +245,12 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
} }
/* codec SSP */ /* codec SSP */
if (amp_type != CODEC_NONE) {
links[id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_codec); links[id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_codec);
if (!links[id].name) if (!links[id].name)
return NULL; return NULL;
links[id].id = id; links[id].id = fixed_be ? SPK_BE_ID : id;
switch (amp_type) { switch (amp_type) {
case CODEC_CS35L41: case CODEC_CS35L41:
...@@ -266,6 +277,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, ...@@ -266,6 +277,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
return NULL; return NULL;
id++; id++;
}
/* dmic */ /* dmic */
if (dmic_be_num > 0) { if (dmic_be_num > 0) {
...@@ -283,7 +295,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, ...@@ -283,7 +295,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
} }
for (i = 0; i < dmic_be_num; i++) { for (i = 0; i < dmic_be_num; i++) {
links[id].id = id; links[id].id = fixed_be ? (DMIC01_BE_ID + i) : id;
links[id].num_cpus = 1; links[id].num_cpus = 1;
links[id].codecs = dmic_component; links[id].codecs = dmic_component;
links[id].num_codecs = ARRAY_SIZE(dmic_component); links[id].num_codecs = ARRAY_SIZE(dmic_component);
...@@ -312,7 +324,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, ...@@ -312,7 +324,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
if (!links[id].name) if (!links[id].name)
goto devm_err; goto devm_err;
links[id].id = id; links[id].id = fixed_be ? (INTEL_HDMI_BE_ID + i - 1) : id;
links[id].cpus = &cpus[id]; links[id].cpus = &cpus[id];
links[id].num_cpus = 1; links[id].num_cpus = 1;
links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
...@@ -398,7 +410,10 @@ static int sof_ssp_amp_probe(struct platform_device *pdev) ...@@ -398,7 +410,10 @@ static int sof_ssp_amp_probe(struct platform_device *pdev)
ssp_codec = sof_ssp_amp_quirk & SOF_AMPLIFIER_SSP_MASK; ssp_codec = sof_ssp_amp_quirk & SOF_AMPLIFIER_SSP_MASK;
/* set number of dai links */ /* set number of dai links */
sof_ssp_amp_card.num_links = 1 + dmic_be_num; sof_ssp_amp_card.num_links = dmic_be_num;
if (ctx->amp_type != CODEC_NONE)
sof_ssp_amp_card.num_links++;
if (sof_ssp_amp_quirk & SOF_SSP_HDMI_CAPTURE_PRESENT) 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) >> sof_ssp_amp_card.num_links += (sof_ssp_amp_quirk & SOF_NO_OF_HDMI_CAPTURE_SSP_MASK) >>
......
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