[PATCH 09/10] ASoC: Intel: sof_sdw: Add support for Cirrus Logic CS35L56

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

 



The CS35L56 is a high-performance mono boosted audio amplifier.

This patch adds the initialization for one, two or four amps.

All amps receive the same 2-channel (stereo) audio. Left/right
channel-to-speaker mapping is not fixed. The CS35L56 on-board DSP
adjusts the mapping based on current posture (orientation).

Each CS35L56 has 6 feedback channels for monitoring but to
remain within limited SoundWire bandwidth only one channel per
amp is enabled.

Signed-off-by: Richard Fitzgerald <rf@xxxxxxxxxxxxxxxxxxxxx>
---
 MAINTAINERS                              |   1 +
 sound/soc/intel/boards/Kconfig           |   1 +
 sound/soc/intel/boards/Makefile          |   1 +
 sound/soc/intel/boards/sof_sdw.c         |   7 ++
 sound/soc/intel/boards/sof_sdw_common.h  |   7 ++
 sound/soc/intel/boards/sof_sdw_cs35l56.c | 115 +++++++++++++++++++++++
 6 files changed, 132 insertions(+)
 create mode 100644 sound/soc/intel/boards/sof_sdw_cs35l56.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 3d7aaa42b854..c40bae5e90ea 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5039,6 +5039,7 @@ F:	include/sound/cs*
 F:	sound/pci/hda/cs*
 F:	sound/pci/hda/hda_cs_dsp_ctl.*
 F:	sound/soc/codecs/cs*
+F:	sound/soc/intel/boards/sof_sdw_cs35l56.c
 
 CIRRUS LOGIC DSP FIRMWARE DRIVER
 M:	Simon Trimmer <simont@xxxxxxxxxxxxxxxxxxxxx>
diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig
index 99308ed85277..3e483bbf3ebe 100644
--- a/sound/soc/intel/boards/Kconfig
+++ b/sound/soc/intel/boards/Kconfig
@@ -662,6 +662,7 @@ config SND_SOC_INTEL_SOUNDWIRE_SOF_MACH
 	depends on MFD_INTEL_LPSS || COMPILE_TEST
 	depends on SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES || COMPILE_TEST
 	depends on SOUNDWIRE
+	select SND_SOC_CS35L56_SDW
 	select SND_SOC_MAX98373_I2C
 	select SND_SOC_MAX98373_SDW
 	select SND_SOC_RT700_SDW
diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile
index d1fd7a2b32db..64e37f8e4a4b 100644
--- a/sound/soc/intel/boards/Makefile
+++ b/sound/soc/intel/boards/Makefile
@@ -37,6 +37,7 @@ snd-soc-sof_da7219_max98373-objs := sof_da7219_max98373.o
 snd-soc-ehl-rt5660-objs := ehl_rt5660.o
 snd-soc-sof-ssp-amp-objs := sof_ssp_amp.o
 snd-soc-sof-sdw-objs += sof_sdw.o				\
+			sof_sdw_cs35l56.o			\
 			sof_sdw_max98373.o sof_sdw_rt_amp.o	\
 			sof_sdw_rt5682.o sof_sdw_rt700.o	\
 			sof_sdw_rt711.o sof_sdw_rt711_sdca.o 	\
diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c
index d2ed807abde9..6c679b4b963f 100644
--- a/sound/soc/intel/boards/sof_sdw.c
+++ b/sound/soc/intel/boards/sof_sdw.c
@@ -544,6 +544,13 @@ static struct sof_sdw_codec_info codec_info_list[] = {
 		.exit = sof_sdw_rt711_exit,
 		.codec_type = SOF_SDW_CODEC_TYPE_JACK,
 	},
+	{
+		.part_id = 0x3556,
+		.direction = {true, true},
+		.dai_name = "cs35l56-sdw1",
+		.init = sof_sdw_cs35l56_init,
+		.codec_type = SOF_SDW_CODEC_TYPE_AMP,
+	},
 	{
 		.part_id = 0x1308,
 		.acpi_id = "10EC1308",
diff --git a/sound/soc/intel/boards/sof_sdw_common.h b/sound/soc/intel/boards/sof_sdw_common.h
index 350010b0e5f4..1bb8e4a34c56 100644
--- a/sound/soc/intel/boards/sof_sdw_common.h
+++ b/sound/soc/intel/boards/sof_sdw_common.h
@@ -102,6 +102,13 @@ int sof_sdw_hdmi_card_late_probe(struct snd_soc_card *card);
 /* DMIC support */
 int sof_sdw_dmic_init(struct snd_soc_pcm_runtime *rtd);
 
+/* CS35L56 support */
+int sof_sdw_cs35l56_init(struct snd_soc_card *card,
+			 const struct snd_soc_acpi_link_adr *link,
+			 struct snd_soc_dai_link *dai_links,
+			 struct sof_sdw_codec_info *info,
+			 bool playback);
+
 /* RT711 support */
 int sof_sdw_rt711_init(struct snd_soc_card *card,
 		       const struct snd_soc_acpi_link_adr *link,
diff --git a/sound/soc/intel/boards/sof_sdw_cs35l56.c b/sound/soc/intel/boards/sof_sdw_cs35l56.c
new file mode 100644
index 000000000000..b862567fd9e2
--- /dev/null
+++ b/sound/soc/intel/boards/sof_sdw_cs35l56.c
@@ -0,0 +1,115 @@
+// SPDX-License-Identifier: GPL-2.0-only
+// Based on sof_sdw_rt5682.c
+// Copyright (c) 2020 Intel Corporation
+
+/*
+ *  sof_sdw_cs35l56 - Helpers to handle CS35L56 from generic machine driver
+ */
+
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <sound/soc.h>
+#include <sound/soc-acpi.h>
+#include <sound/soc-dai.h>
+#include "sof_sdw_common.h"
+
+static const struct snd_soc_dapm_widget cs35l56_sof_widgets[] = {
+	SND_SOC_DAPM_SPK("Speaker", NULL),
+	SND_SOC_DAPM_LINE("Monitor", NULL),
+};
+
+static const struct snd_soc_dapm_route cs35l56_sof_map[] = {
+	{ "Speaker", NULL, "AMP1 SPK" },
+	{ "Speaker", NULL, "AMP2 SPK" },
+	{ "Speaker", NULL, "AMP3 SPK" },
+	{ "Speaker", NULL, "AMP4 SPK" },
+};
+
+static int cs35l56_init_multiple(struct snd_soc_pcm_runtime *rtd, int count)
+{
+	struct snd_soc_card *card = rtd->card;
+	struct snd_soc_dai *codec_dai;
+	int i, ret;
+
+	card->components = devm_kasprintf(card->dev, GFP_KERNEL,
+					  "%s hs:cs35l56",
+					  card->components);
+	if (!card->components)
+		return -ENOMEM;
+
+	ret = snd_soc_dapm_new_controls(&card->dapm,
+					cs35l56_sof_widgets, ARRAY_SIZE(cs35l56_sof_widgets));
+	if (ret) {
+		dev_err(card->dev, "Widgets add failed: %d\n", ret);
+		return ret;
+	}
+
+	ret = snd_soc_dapm_add_routes(&card->dapm, cs35l56_sof_map, count);
+	if (ret) {
+		dev_err(card->dev, "Map add %d failed: %d\n", count, ret);
+		return ret;
+	}
+
+	/* Enable one feedback TX per amp on different slots */
+	for_each_rtd_codec_dais(rtd, i, codec_dai) {
+		ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x3, 1 << i, 4, 16);
+		if (ret < 0)
+			return ret;
+	}
+
+	return 0;
+}
+
+static int cs35l56_init_one(struct snd_soc_pcm_runtime *rtd)
+{
+	return cs35l56_init_multiple(rtd, 1);
+}
+
+static int cs35l56_init_two(struct snd_soc_pcm_runtime *rtd)
+{
+	return cs35l56_init_multiple(rtd, 2);
+}
+
+static int cs35l56_init_three(struct snd_soc_pcm_runtime *rtd)
+{
+	return cs35l56_init_multiple(rtd, 3);
+}
+
+static int cs35l56_init_four(struct snd_soc_pcm_runtime *rtd)
+{
+	return cs35l56_init_multiple(rtd, 4);
+}
+
+int sof_sdw_cs35l56_init(struct snd_soc_card *card,
+			 const struct snd_soc_acpi_link_adr *link,
+			 struct snd_soc_dai_link *dai_links,
+			 struct sof_sdw_codec_info *info,
+			 bool playback)
+{
+	/* Init with playback dai link only. */
+	if (!playback)
+		return 0;
+
+	info->amp_num++;
+
+	switch (info->amp_num) {
+	case 1:
+		dai_links->init = cs35l56_init_one;
+		break;
+	case 2:
+		dai_links->init = cs35l56_init_two;
+		break;
+	case 3:
+		dai_links->init = cs35l56_init_three;
+		break;
+	case 4:
+		dai_links->init = cs35l56_init_four;
+		break;
+	default:
+		dev_err(card->dev, "%s: Unexpected number of amps %d\n", __func__, info->amp_num);
+		dai_links->init = cs35l56_init_four;
+		break;
+	}
+
+	return 0;
+}
-- 
2.30.2




[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