[PATCH 06/19] ASoC: Intel: sof_ssp_amp: use ssp-common module to detect codec

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Brent Lu <brent.lu@xxxxxxxxx>

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: Brent Lu <brent.lu@xxxxxxxxx>
Reviewed-by: Rander Wang <rander.wang@xxxxxxxxx>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxxxxxxxx>
Signed-off-by: Bard Liao <yung-chuan.liao@xxxxxxxxxxxxxxx>
---
 sound/soc/intel/boards/Kconfig       |  1 +
 sound/soc/intel/boards/sof_ssp_amp.c | 53 ++++++++++++++++++----------
 2 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig
index 1bc47f7c502a..857bb8628a4c 100644
--- a/sound/soc/intel/boards/Kconfig
+++ b/sound/soc/intel/boards/Kconfig
@@ -637,6 +637,7 @@ config SND_SOC_INTEL_SOF_SSP_AMP_MACH
 	select SND_SOC_INTEL_HDA_DSP_COMMON
 	select SND_SOC_INTEL_SOF_REALTEK_COMMON
 	select SND_SOC_INTEL_SOF_CIRRUS_COMMON
+	select SND_SOC_INTEL_SOF_SSP_COMMON
 	help
 	   This adds support for ASoC machine driver for SOF platforms
 	   with RT1308/CS35L41 I2S audio codec.
diff --git a/sound/soc/intel/boards/sof_ssp_amp.c b/sound/soc/intel/boards/sof_ssp_amp.c
index 5aa16fd3939b..e2b3553dbc65 100644
--- a/sound/soc/intel/boards/sof_ssp_amp.c
+++ b/sound/soc/intel/boards/sof_ssp_amp.c
@@ -21,6 +21,7 @@
 #include "hda_dsp_common.h"
 #include "sof_realtek_common.h"
 #include "sof_cirrus_common.h"
+#include "sof_ssp_common.h"
 
 #define NAME_SIZE 32
 
@@ -59,10 +60,6 @@
 #define SOF_BT_OFFLOAD_SSP(quirk)	\
 	(((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  */
 static unsigned long sof_ssp_amp_quirk = SOF_AMPLIFIER_SSP(2);
 
@@ -77,6 +74,7 @@ struct sof_card_private {
 	struct list_head hdmi_pcm_list;
 	bool common_hdmi_codec_drv;
 	bool idisp_codec;
+	enum sof_ssp_codec amp_type;
 };
 
 static const struct dmi_system_id chromebook_platforms[] = {
@@ -188,11 +186,10 @@ static int sof_hdmi_init(struct snd_soc_pcm_runtime *rtd)
 
 #define IDISP_CODEC_MASK	0x4
 
-static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
-							  int ssp_codec,
-							  int dmic_be_num,
-							  int hdmi_num,
-							  bool idisp_codec)
+static struct snd_soc_dai_link *
+sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type,
+			  int ssp_codec, int dmic_be_num, int hdmi_num,
+			  bool idisp_codec)
 {
 	struct snd_soc_dai_link_component *idisp_components;
 	struct snd_soc_dai_link_component *cpus;
@@ -243,11 +240,19 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
 		return NULL;
 
 	links[id].id = id;
-	if (sof_ssp_amp_quirk & SOF_RT1308_SPEAKER_AMP_PRESENT) {
-		sof_rt1308_dai_link(&links[id]);
-	} else if (sof_ssp_amp_quirk & SOF_CS35L41_SPEAKER_AMP_PRESENT) {
+
+	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].platforms = platform_component;
 	links[id].num_platforms = ARRAY_SIZE(platform_component);
 	links[id].dpcm_playback = 1;
@@ -385,6 +390,8 @@ static int sof_ssp_amp_probe(struct platform_device *pdev)
 
 	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)
 		dmic_be_num = 2;
 
@@ -413,15 +420,26 @@ static int sof_ssp_amp_probe(struct platform_device *pdev)
 	if (sof_ssp_amp_quirk & SOF_SSP_BT_OFFLOAD_PRESENT)
 		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)
 		return -ENOMEM;
 
 	sof_ssp_amp_card.dai_link = dai_links;
 
 	/* 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);
+		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);
@@ -451,8 +469,7 @@ static const struct platform_device_id board_ids[] = {
 					SOF_NO_OF_HDMI_CAPTURE_SSP(2) |
 					SOF_HDMI_CAPTURE_1_SSP(1) |
 					SOF_HDMI_CAPTURE_2_SSP(5) |
-					SOF_SSP_HDMI_CAPTURE_PRESENT |
-					SOF_RT1308_SPEAKER_AMP_PRESENT),
+					SOF_SSP_HDMI_CAPTURE_PRESENT),
 	},
 	{
 		.name = "adl_cs35l41",
@@ -460,8 +477,7 @@ static const struct platform_device_id board_ids[] = {
 					SOF_NO_OF_HDMI_PLAYBACK(4) |
 					SOF_HDMI_PLAYBACK_PRESENT |
 					SOF_BT_OFFLOAD_SSP(2) |
-					SOF_SSP_BT_OFFLOAD_PRESENT |
-					SOF_CS35L41_SPEAKER_AMP_PRESENT),
+					SOF_SSP_BT_OFFLOAD_PRESENT),
 	},
 	{
 		.name = "adl_lt6911_hdmi_ssp",
@@ -502,3 +518,4 @@ MODULE_LICENSE("GPL");
 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_CIRRUS_COMMON);
+MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON);
-- 
2.25.1




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux