Commit 6308c125 authored by Brent Lu's avatar Brent Lu Committed by Mark Brown

ASoC: Intel: sof_ssp_amp: use ssp-common module to detect codec

Use ssp-common module to detect codec and amplifier type in driver
probe function and remove all quirks about codec and amplifier type.
Signed-off-by: default avatarBrent Lu <brent.lu@intel.com>
Reviewed-by: default avatarRander Wang <rander.wang@intel.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20230915124852.1696857-7-yung-chuan.liao@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 811e874d
...@@ -637,6 +637,7 @@ config SND_SOC_INTEL_SOF_SSP_AMP_MACH ...@@ -637,6 +637,7 @@ config SND_SOC_INTEL_SOF_SSP_AMP_MACH
select SND_SOC_INTEL_HDA_DSP_COMMON select SND_SOC_INTEL_HDA_DSP_COMMON
select SND_SOC_INTEL_SOF_REALTEK_COMMON select SND_SOC_INTEL_SOF_REALTEK_COMMON
select SND_SOC_INTEL_SOF_CIRRUS_COMMON select SND_SOC_INTEL_SOF_CIRRUS_COMMON
select SND_SOC_INTEL_SOF_SSP_COMMON
help help
This adds support for ASoC machine driver for SOF platforms This adds support for ASoC machine driver for SOF platforms
with RT1308/CS35L41 I2S audio codec. with RT1308/CS35L41 I2S audio codec.
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "hda_dsp_common.h" #include "hda_dsp_common.h"
#include "sof_realtek_common.h" #include "sof_realtek_common.h"
#include "sof_cirrus_common.h" #include "sof_cirrus_common.h"
#include "sof_ssp_common.h"
#define NAME_SIZE 32 #define NAME_SIZE 32
...@@ -59,10 +60,6 @@ ...@@ -59,10 +60,6 @@
#define SOF_BT_OFFLOAD_SSP(quirk) \ #define SOF_BT_OFFLOAD_SSP(quirk) \
(((quirk) << SOF_BT_OFFLOAD_SSP_SHIFT) & SOF_BT_OFFLOAD_SSP_MASK) (((quirk) << SOF_BT_OFFLOAD_SSP_SHIFT) & SOF_BT_OFFLOAD_SSP_MASK)
/* Speaker amplifiers */
#define SOF_RT1308_SPEAKER_AMP_PRESENT BIT(21)
#define SOF_CS35L41_SPEAKER_AMP_PRESENT BIT(22)
/* Default: SSP2 */ /* Default: SSP2 */
static unsigned long sof_ssp_amp_quirk = SOF_AMPLIFIER_SSP(2); static unsigned long sof_ssp_amp_quirk = SOF_AMPLIFIER_SSP(2);
...@@ -77,6 +74,7 @@ struct sof_card_private { ...@@ -77,6 +74,7 @@ struct sof_card_private {
struct list_head hdmi_pcm_list; struct list_head hdmi_pcm_list;
bool common_hdmi_codec_drv; bool common_hdmi_codec_drv;
bool idisp_codec; bool idisp_codec;
enum sof_ssp_codec amp_type;
}; };
static const struct dmi_system_id chromebook_platforms[] = { static const struct dmi_system_id chromebook_platforms[] = {
...@@ -188,10 +186,9 @@ static int sof_hdmi_init(struct snd_soc_pcm_runtime *rtd) ...@@ -188,10 +186,9 @@ static int sof_hdmi_init(struct snd_soc_pcm_runtime *rtd)
#define IDISP_CODEC_MASK 0x4 #define IDISP_CODEC_MASK 0x4
static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, static struct snd_soc_dai_link *
int ssp_codec, sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
int dmic_be_num, int ssp_codec, int dmic_be_num, int hdmi_num,
int hdmi_num,
bool idisp_codec) bool idisp_codec)
{ {
struct snd_soc_dai_link_component *idisp_components; struct snd_soc_dai_link_component *idisp_components;
...@@ -243,11 +240,19 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, ...@@ -243,11 +240,19 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
return NULL; return NULL;
links[id].id = id; links[id].id = id;
if (sof_ssp_amp_quirk & SOF_RT1308_SPEAKER_AMP_PRESENT) {
sof_rt1308_dai_link(&links[id]); switch (amp_type) {
} else if (sof_ssp_amp_quirk & SOF_CS35L41_SPEAKER_AMP_PRESENT) { case CODEC_CS35L41:
cs35l41_set_dai_link(&links[id]); 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].platforms = platform_component; links[id].platforms = platform_component;
links[id].num_platforms = ARRAY_SIZE(platform_component); links[id].num_platforms = ARRAY_SIZE(platform_component);
links[id].dpcm_playback = 1; links[id].dpcm_playback = 1;
...@@ -385,6 +390,8 @@ static int sof_ssp_amp_probe(struct platform_device *pdev) ...@@ -385,6 +390,8 @@ static int sof_ssp_amp_probe(struct platform_device *pdev)
mach = pdev->dev.platform_data; mach = pdev->dev.platform_data;
ctx->amp_type = sof_ssp_detect_amp_type(&pdev->dev);
if (dmi_check_system(chromebook_platforms) || mach->mach_params.dmic_num > 0) if (dmi_check_system(chromebook_platforms) || mach->mach_params.dmic_num > 0)
dmic_be_num = 2; dmic_be_num = 2;
...@@ -413,15 +420,26 @@ static int sof_ssp_amp_probe(struct platform_device *pdev) ...@@ -413,15 +420,26 @@ static int sof_ssp_amp_probe(struct platform_device *pdev)
if (sof_ssp_amp_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) if (sof_ssp_amp_quirk & SOF_SSP_BT_OFFLOAD_PRESENT)
sof_ssp_amp_card.num_links++; sof_ssp_amp_card.num_links++;
dai_links = sof_card_dai_links_create(&pdev->dev, ssp_codec, dmic_be_num, hdmi_num, ctx->idisp_codec); dai_links = sof_card_dai_links_create(&pdev->dev, ctx->amp_type,
ssp_codec, dmic_be_num, hdmi_num,
ctx->idisp_codec);
if (!dai_links) if (!dai_links)
return -ENOMEM; return -ENOMEM;
sof_ssp_amp_card.dai_link = dai_links; sof_ssp_amp_card.dai_link = dai_links;
/* update codec_conf */ /* update codec_conf */
if (sof_ssp_amp_quirk & SOF_CS35L41_SPEAKER_AMP_PRESENT) { switch (ctx->amp_type) {
case CODEC_CS35L41:
cs35l41_set_codec_conf(&sof_ssp_amp_card); cs35l41_set_codec_conf(&sof_ssp_amp_card);
break;
case CODEC_NONE:
case CODEC_RT1308:
/* no codec conf required */
break;
default:
dev_err(&pdev->dev, "invalid amp type %d\n", ctx->amp_type);
return -EINVAL;
} }
INIT_LIST_HEAD(&ctx->hdmi_pcm_list); INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
...@@ -451,8 +469,7 @@ static const struct platform_device_id board_ids[] = { ...@@ -451,8 +469,7 @@ static const struct platform_device_id board_ids[] = {
SOF_NO_OF_HDMI_CAPTURE_SSP(2) | SOF_NO_OF_HDMI_CAPTURE_SSP(2) |
SOF_HDMI_CAPTURE_1_SSP(1) | SOF_HDMI_CAPTURE_1_SSP(1) |
SOF_HDMI_CAPTURE_2_SSP(5) | SOF_HDMI_CAPTURE_2_SSP(5) |
SOF_SSP_HDMI_CAPTURE_PRESENT | SOF_SSP_HDMI_CAPTURE_PRESENT),
SOF_RT1308_SPEAKER_AMP_PRESENT),
}, },
{ {
.name = "adl_cs35l41", .name = "adl_cs35l41",
...@@ -460,8 +477,7 @@ static const struct platform_device_id board_ids[] = { ...@@ -460,8 +477,7 @@ static const struct platform_device_id board_ids[] = {
SOF_NO_OF_HDMI_PLAYBACK(4) | SOF_NO_OF_HDMI_PLAYBACK(4) |
SOF_HDMI_PLAYBACK_PRESENT | SOF_HDMI_PLAYBACK_PRESENT |
SOF_BT_OFFLOAD_SSP(2) | SOF_BT_OFFLOAD_SSP(2) |
SOF_SSP_BT_OFFLOAD_PRESENT | SOF_SSP_BT_OFFLOAD_PRESENT),
SOF_CS35L41_SPEAKER_AMP_PRESENT),
}, },
{ {
.name = "adl_lt6911_hdmi_ssp", .name = "adl_lt6911_hdmi_ssp",
...@@ -502,3 +518,4 @@ MODULE_LICENSE("GPL"); ...@@ -502,3 +518,4 @@ MODULE_LICENSE("GPL");
MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_REALTEK_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_REALTEK_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_CIRRUS_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_CIRRUS_COMMON);
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON);
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