Skip to contentSkip to conversation

ASoC: Add common modules support for ACP hw block

PATCH Superseded Ajit Kumar Pandey 3 participants 14 messages Sep 30, 2021 – Oct 11, 2021 1 message not in the archive

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover ASoC: Add common modules support for ACP hw block

We need to support I2S audio on various different platforms SOC in near future. At present we are creating new folder under soc/amd/ for each platforms support with separate I2S and DMA device modules across each SOC. Actually AMD's audio coprocessor block commonly known as ACP hw IP block consist of I2S controllers registers configuration and registers specs are common across all SOC. This patch series add common folder named acp in soc/amd/ that exposes common driver modules to configure I2S and DMA registers across different platforms. Any platforms specific configurations and dai's will be exposed in separate platform modules. We will use SOF based PCI driver or common PCI driver to register and probe platform device modules.

We also add common and more generic machine driver support within this patch chain. This machine driver can be used across different machines on AMD SOC with just some minor tweaks related to codecs connections.

Ajit Kumar Pandey (8):
ASoC: amd: Add common framework to support I2S on ACP SOC
ASoC: amd: acp: Add I2S support on Renoir platform
ASoC: amd: acp: Add callback for machine driver on ACP
ASoC: amd: acp: Add generic machine driver support for ACP cards
ASoC: amd: acp: Add legacy sound card support for Guybrush board
ASoC: amd: acp: Add SOF sound card support on Guybrush board
ASoC: amd: acp: Add support for Maxim amplifier codec
ASoC: amd: acp: Add support for RT5682-VS codec

 sound/soc/amd/Kconfig                |   2 +
 sound/soc/amd/Makefile               |   1 +
 sound/soc/amd/acp/Kconfig            |  49 +++
 sound/soc/amd/acp/Makefile           |  26 ++
 sound/soc/amd/acp/acp-i2s.c          | 353 +++++++++++++++++
 sound/soc/amd/acp/acp-legacy-mach.c  | 104 +++++
 sound/soc/amd/acp/acp-mach-common.c  | 557 +++++++++++++++++++++++++++
 sound/soc/amd/acp/acp-mach.h         |  57 +++
 sound/soc/amd/acp/acp-platform.c     | 325 ++++++++++++++++
 sound/soc/amd/acp/acp-renoir.c       | 144 +++++++
 sound/soc/amd/acp/acp-sof-mach.c     | 103 +++++
 sound/soc/amd/acp/amd.h              | 146 +++++++
 sound/soc/amd/acp/chip_offset_byte.h |  76 ++++
 13 files changed, 1943 insertions(+)
 create mode 100644 sound/soc/amd/acp/Kconfig
 create mode 100644 sound/soc/amd/acp/Makefile
 create mode 100644 sound/soc/amd/acp/acp-i2s.c
 create mode 100644 sound/soc/amd/acp/acp-legacy-mach.c
 create mode 100644 sound/soc/amd/acp/acp-mach-common.c
 create mode 100644 sound/soc/amd/acp/acp-mach.h
 create mode 100644 sound/soc/amd/acp/acp-platform.c
 create mode 100644 sound/soc/amd/acp/acp-renoir.c
 create mode 100644 sound/soc/amd/acp/acp-sof-mach.c
 create mode 100644 sound/soc/amd/acp/amd.h
 create mode 100644 sound/soc/amd/acp/chip_offset_byte.h
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/8 ASoC: amd: Add common framework to support I2S on ACP SOC

We are using legacy way of exposing dais and DMA configuration that requires separate driver modules for various ACP SOC with almost similar hw configuration. Moreover the legacy approach requires separate I2S and DMA module platform devices registration and need machine specific quirk to control various I2S endpoints. Add generic dai driver and platform driver for I2S controller on ACP hw block. This common framework can be used by various ACP platform devices that shares common specs.

---
 sound/soc/amd/Kconfig                |   2 +
 sound/soc/amd/Makefile               |   1 +
 sound/soc/amd/acp/Kconfig            |  18 ++
 sound/soc/amd/acp/Makefile           |  12 +
 sound/soc/amd/acp/acp-i2s.c          | 340 +++++++++++++++++++++++++++
 sound/soc/amd/acp/acp-platform.c     | 292 +++++++++++++++++++++++
 sound/soc/amd/acp/amd.h              | 140 +++++++++++
 sound/soc/amd/acp/chip_offset_byte.h |  76 ++++++
 8 files changed, 881 insertions(+)
 create mode 100644 sound/soc/amd/acp/Kconfig
 create mode 100644 sound/soc/amd/acp/Makefile
 create mode 100644 sound/soc/amd/acp/acp-i2s.c
 create mode 100644 sound/soc/amd/acp/acp-platform.c
 create mode 100644 sound/soc/amd/acp/amd.h
 create mode 100644 sound/soc/amd/acp/chip_offset_byte.h
sound/soc/amd/Kconfig +2 -0
index 49ff5e73e9ba..78e99cd25c37 100644
@@ -61,3 +61,5 @@ config SND_SOC_AMD_ACP5x
 
 	 By enabling this flag build will trigger for ACP PCI driver,
 	 ACP DMA driver, CPU DAI driver.
+
+source "sound/soc/amd/acp/Kconfig"
sound/soc/amd/Makefile +1 -0
index 07150d26f315..9878907c89a6 100644
@@ -11,3 +11,4 @@ obj-$(CONFIG_SND_SOC_AMD_ACP3x) += raven/
 obj-$(CONFIG_SND_SOC_AMD_RV_RT5682_MACH) += snd-soc-acp-rt5682-mach.o
 obj-$(CONFIG_SND_SOC_AMD_RENOIR) += renoir/
 obj-$(CONFIG_SND_SOC_AMD_ACP5x) += vangogh/
+obj-$(CONFIG_SND_SOC_AMD_ACP_COMMON) += acp/
sound/soc/amd/acp/Kconfig new file +18 -0
new file mode 100644
index 000000000000..1ca815df6f23
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
+# This file is provided under a dual BSD/GPLv2 license. When using or
+# redistributing this file, you may do so under either license.
+#
+# Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved.
+#
+
+config SND_SOC_AMD_ACP_COMMON
+	tristate "AMD Audio ACP Common support"
+	select SND_AMD_ACP_CONFIG
+	help
+	 This option enables ACP support on AMD platform
+
+config SND_SOC_AMD_ACP_I2S
+	tristate
+
+config SND_SOC_AMD_ACP_PCM
+	tristate
sound/soc/amd/acp/Makefile new file +12 -0
new file mode 100644
index 000000000000..b2e12659d97b
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
+# This file is provided under a dual BSD/GPLv2 license. When using or
+# redistributing this file, you may do so under either license.
+#
+# Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved.
+
+#common acp driver
+snd-acp-pcm-objs     := acp-platform.o
+snd-acp-i2s-objs     := acp-i2s.o
+
+obj-$(CONFIG_SND_SOC_AMD_ACP_PCM) += snd-acp-pcm.o
+obj-$(CONFIG_SND_SOC_AMD_ACP_I2S) += snd-acp-i2s.o
sound/soc/amd/acp/acp-i2s.c new file +340 -0

340 lines not on this page · raw message

sound/soc/amd/acp/acp-platform.c new file +292 -0

292 lines not on this page · raw message

sound/soc/amd/acp/amd.h new file +140 -0

140 lines not on this page · raw message

sound/soc/amd/acp/chip_offset_byte.h new file +76 -0

76 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/8 ASoC: amd: acp: Add I2S support on Renoir platform

In reply to Ajit Kumar Pandey

Add I2S dai driver for Renoir platform and register with common acp framework to support non dsp I2S use case on Renoir.

---
 sound/soc/amd/acp/Kconfig      |   8 ++
 sound/soc/amd/acp/Makefile     |   5 ++
 sound/soc/amd/acp/acp-renoir.c | 141 +++++++++++++++++++++++++++++++++
 3 files changed, 154 insertions(+)
 create mode 100644 sound/soc/amd/acp/acp-renoir.c
sound/soc/amd/acp/Kconfig +8 -0
index 1ca815df6f23..a11182861f49 100644
@@ -16,3 +16,11 @@ config SND_SOC_AMD_ACP_I2S
 
 config SND_SOC_AMD_ACP_PCM
 	tristate
+
+config SND_AMD_ASOC_RENOIR
+	tristate "AMD ACP ASOC Renoir Support"
+	select SND_SOC_AMD_ACP_PCM
+	select SND_SOC_AMD_ACP_I2S
+	depends on X86 && PCI
+	help
+	 This option enables Renoir I2S support on AMD platform
sound/soc/amd/acp/Makefile +5 -0
index b2e12659d97b..42bff3515f24 100644
@@ -8,5 +8,10 @@
 snd-acp-pcm-objs     := acp-platform.o
 snd-acp-i2s-objs     := acp-i2s.o
 
+#platform specific driver
+snd-acp-renoir-objs     := acp-renoir.o
+
 obj-$(CONFIG_SND_SOC_AMD_ACP_PCM) += snd-acp-pcm.o
 obj-$(CONFIG_SND_SOC_AMD_ACP_I2S) += snd-acp-i2s.o
+
+obj-$(CONFIG_SND_AMD_ASOC_RENOIR) += snd-acp-renoir.o
sound/soc/amd/acp/acp-renoir.c new file +141 -0

141 lines not on this page · raw message

Signature · 1 line
2.25.1
#3 lore raw

Re: [PATCH 2/8] ASoC: amd: acp: Add I2S support on Renoir platform

Quoted 6 lines · Ajit Kumar Pandey
sound/soc/amd/acp/Kconfig +0 -0
index 1ca815df6f23..a11182861f49 100644
@@ -16,3 +16,11 @@ config SND_SOC_AMD_ACP_I2S
 

sound/soc/amd/acp/Kconfig config SND_SOC_AMD_ACP_I2S · line 26

Quoted 10 lines
sound/soc/amd/acp/Kconfig +8 -0
  config SND_SOC_AMD_ACP_PCM
  	tristate
+
+config SND_AMD_ASOC_RENOIR
+	tristate "AMD ACP ASOC Renoir Support"
+	select SND_SOC_AMD_ACP_PCM
+	select SND_SOC_AMD_ACP_I2S
+	depends on X86 && PCI
+	help
+	 This option enables Renoir I2S support on AMD platform

Please follow coding-style for Kconfig files:

(from Documentation/process/coding-style.rst, section 10):

For all of the Kconfig* configuration files throughout the source tree, the indentation is somewhat different. Lines under a ``config`` definition are indented with one tab, while help text is indented an additional two spaces.

Also end the help sentence with a period (full stop) ('.').

thanks.

Signature · 1 line
~Randy
#4 lore raw

PATCH 3/8 ASoC: amd: acp: Add callback for machine driver on ACP

In reply to Ajit Kumar Pandey

Add method to select and register machine driver for acp platform based on ACPI ID.

---
 sound/soc/amd/acp/acp-platform.c | 23 +++++++++++++++++++++++
 sound/soc/amd/acp/acp-renoir.c   |  3 +++
 sound/soc/amd/acp/amd.h          |  6 ++++++
 3 files changed, 32 insertions(+)
sound/soc/amd/acp/acp-platform.c +23 -0
index 2eec2133b4fc..5d575c06fd9c 100644
@@ -67,6 +67,27 @@ static const struct snd_pcm_hardware acp_pcm_hardware_capture = {
 	.periods_max = CAPTURE_MAX_NUM_PERIODS,
 };
 
+int acp_machine_select(struct acp_dev_data *adata)
+{
+	struct snd_soc_acpi_mach *mach;
+	int size;
+
+	size = sizeof(*adata->machines);
+	mach = snd_soc_acpi_find_machine(adata->machines);
+	if (!mach) {
+		dev_err(adata->dev, "warning: No matching ASoC machine driver found\n");
+		return -EINVAL;
+	}
+
+	adata->mach_dev = platform_device_register_data(adata->dev, mach->drv_name,
+							PLATFORM_DEVID_NONE, mach, size);
+	if (!adata->mach_dev)
+		dev_warn(adata->dev, "Unable to register Machine device\n");
+
+	return 0;
+}
+EXPORT_SYMBOL_NS(acp_machine_select, SND_SOC_ACP_COMMON);
+
 static irqreturn_t i2s_irq_handler(int irq, void *data)
 {
 	struct acp_dev_data *adata = data;
@@ -283,6 +304,8 @@ int acp_platform_unregister(struct device *dev)
 {
 	struct acp_dev_data *adata = dev_get_drvdata(dev);
 
+	if (adata->mach_dev)
+		platform_device_unregister(adata->mach_dev);
 	return 0;
 }
 EXPORT_SYMBOL_NS(acp_platform_unregister, SND_SOC_ACP_COMMON);
sound/soc/amd/acp/acp-renoir.c +3 -0
index c7fbf71e4669..82faae1b110b 100644
@@ -111,6 +111,9 @@ static int renoir_audio_probe(struct platform_device *pdev)
 	adata->dai_driver = acp_renoir_dai;
 	adata->num_dai = ARRAY_SIZE(acp_renoir_dai);
 
+	adata->machines = snd_soc_acpi_amd_acp_machines;
+	acp_machine_select(adata);
+
 	dev_set_drvdata(dev, adata);
 	acp_platform_register(dev);
 
sound/soc/amd/acp/amd.h +6 -0
index ecb53285526c..3532f4d3ccff 100644
@@ -90,6 +90,9 @@ struct acp_dev_data {
 	int num_dai;
 
 	struct acp_stream *stream[ACP_MAX_STREAM];
+
+	struct snd_soc_acpi_mach *machines;
+	struct platform_device *mach_dev;
 };
 
 extern const struct snd_soc_dai_ops asoc_acp_cpu_dai_ops;
@@ -98,6 +101,9 @@ int asoc_acp_i2s_probe(struct snd_soc_dai *dai);
 int acp_platform_register(struct device *dev);
 int acp_platform_unregister(struct device *dev);
 
+int acp_machine_select(struct acp_dev_data *adata);
+extern struct snd_soc_acpi_mach snd_soc_acpi_amd_acp_machines[];
+
 static inline u64 acp_get_byte_count(struct acp_dev_data *adata, int dai_id, int direction)
 {
 	u64 byte_count, low = 0, high = 0;
Signature · 1 line
2.25.1
#5 lore raw

PATCH 4/8 ASoC: amd: acp: Add generic machine driver support for ACP cards

In reply to Ajit Kumar Pandey

We have machines with differents audio endpoints configurations across various distributions. We need to support multiple sound cards for different combinations of I2S instance and codecs hw. Now we also need to support SOF-DSP endpoints based sound cards. All such card combinations slightly differs in terms of machine ops callback. This patch adds ACP generic machine driver module exposes method to create ACP cards dai links and define generic ops for audio endpoints configurations. Initially we have added dailink support for RT5682 and RT1019 codec connection with ACP I2S_SP instance. We will add newer codecs in this module to use this for all AMD's ACP block sound cards supports in future.

---
 sound/soc/amd/acp/Kconfig           |   9 +
 sound/soc/amd/acp/Makefile          |   5 +
 sound/soc/amd/acp/acp-mach-common.c | 511 ++++++++++++++++++++++++++++
 sound/soc/amd/acp/acp-mach.h        |  55 +++
 4 files changed, 580 insertions(+)
 create mode 100644 sound/soc/amd/acp/acp-mach-common.c
 create mode 100644 sound/soc/amd/acp/acp-mach.h
sound/soc/amd/acp/Kconfig +9 -0
index a11182861f49..1ad811707a68 100644
@@ -24,3 +24,12 @@ config SND_AMD_ASOC_RENOIR
 	depends on X86 && PCI
 	help
 	 This option enables Renoir I2S support on AMD platform
+
+config SND_SOC_AMD_MACH_COMMON
+	tristate
+	select SND_SOC_RT5682_I2C
+	select SND_SOC_DMIC
+	select SND_SOC_RT1019
+	depends on X86 && PCI && I2C
+	help
+	 This option enables common Machine driver module for ACP
sound/soc/amd/acp/Makefile +5 -0
index 42bff3515f24..a477a18272bf 100644
@@ -11,7 +11,12 @@ snd-acp-i2s-objs     := acp-i2s.o
 #platform specific driver
 snd-acp-renoir-objs     := acp-renoir.o
 
+#machine specific driver
+snd-acp-mach-objs     := acp-mach-common.o
+
 obj-$(CONFIG_SND_SOC_AMD_ACP_PCM) += snd-acp-pcm.o
 obj-$(CONFIG_SND_SOC_AMD_ACP_I2S) += snd-acp-i2s.o
 
 obj-$(CONFIG_SND_AMD_ASOC_RENOIR) += snd-acp-renoir.o
+
+obj-$(CONFIG_SND_SOC_AMD_MACH_COMMON) += snd-acp-mach.o
sound/soc/amd/acp/acp-mach-common.c new file +511 -0

511 lines not on this page · raw message

sound/soc/amd/acp/acp-mach.h new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
2.25.1
#6 lore raw

Re: [PATCH 4/8] ASoC: amd: acp: Add generic machine driver support for ACP cards

Quoted 7 lines · Ajit Kumar Pandey
sound/soc/amd/acp/Kconfig +0 -0
index a11182861f49..1ad811707a68 100644
@@ -24,3 +24,12 @@ config SND_AMD_ASOC_RENOIR
  	depends on X86 && PCI
  	help

sound/soc/amd/acp/Kconfig config SND_AMD_ASOC_RENOIR · line 35

Quoted 10 lines
sound/soc/amd/acp/Kconfig +9 -0
  	 This option enables Renoir I2S support on AMD platform
+
+config SND_SOC_AMD_MACH_COMMON
+	tristate
+	select SND_SOC_RT5682_I2C
+	select SND_SOC_DMIC
+	select SND_SOC_RT1019
+	depends on X86 && PCI && I2C
+	help
+	 This option enables common Machine driver module for ACP

Same comments for patch 4, 5, and 6 as given for patch 2.

thanks.

Signature · 1 line
~Randy
maintainer
#7 lore raw

Re: [PATCH 4/8] ASoC: amd: acp: Add generic machine driver support for ACP cards

In reply to Ajit Kumar Pandey

On Thu, Sep 30, 2021 at 06:54:14PM +0530, Ajit Kumar Pandey wrote:

A couple of things here, most of these are probably fine for now other than the EXPORT_SYMBOL but I think you're likely to run into issues going forward and need to refactor.

Quoted 4 lines
sound/soc/amd/acp/acp-mach-common.c new file +4 -0
+	switch (drvdata->hs_codec_id) {
+	case RT5682:
+		pll_id = RT5682_PLL2;
+		pll_src = RT5682_PLL2_S_MCLK;

sound/soc/amd/acp/acp-mach-common.c line 129

Quoted 10 lines
sound/soc/amd/acp/acp-mach-common.c new file +10 -0
+		freq_in = PCO_PLAT_CLK;
+		freq_out = RT5682_PLL_FREQ;
+		clk_id = RT5682_SCLK_S_PLL2;
+		clk_freq = RT5682_PLL_FREQ;
+		wclk_name = "rt5682-dai-wclk";
+		bclk_name = "rt5682-dai-bclk";
+		drvdata->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
+				   | SND_SOC_DAIFMT_CBP_CFP;
+		snd_soc_dapm_add_routes(&rtd->card->dapm, rt5682_map, ARRAY_SIZE(rt5682_map));
+		break;

It feels like this is going to run into scaling issues going forward and you're likely to need separate operations for different CODECs rather than just different IDs. Similar issues apply for the amps, it feels like you want to be passing separate ops in rather than having these switch statements.

sound/soc/amd/acp/acp-mach-common.c line 227

Quoted 3 lines
sound/soc/amd/acp/acp-mach-common.c new file +3 -0
+	/* Do nothing for dummy codec */
+	if (!drvdata->hs_codec_id && drvdata->amp_codec_id)
+		return;

Wha the test seems to say is do nothing if there's no CODEC but there is an amp...

sound/soc/amd/acp/acp-mach-common.c line 230

Quoted 3 lines
sound/soc/amd/acp/acp-mach-common.c new file +3 -0
+
+	clk_disable_unprepare(drvdata->wclk);
+}

...though I'd expect that given that the clock API accepts NULL clocks you could just remove these checks and unconditionally use the clocks.

sound/soc/amd/acp/acp-mach-common.c line 509

Quoted 3 lines
sound/soc/amd/acp/acp-mach-common.c new file +3 -0
+	return 0;
+}
+EXPORT_SYMBOL_NS(acp_legacy_dai_links_create, SND_SOC_AMD_MACH);

EXPORT_SYMBOL_GPL_NS() - ASoC is all EXPORT_SYMBOL_GPL.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw

Re: Fwd: [PATCH 4/8] ASoC: amd: acp: Add generic machine driver support for ACP cards

Apologies for corrupted reply format, some issue with thunderbird.

We will update all below review comments in v2 patch series

Quoted 18 lines · Ajit Kumar Pandey

A couple of things here, most of these are probably fine for now other than the EXPORT_SYMBOL but I think you're likely to run into issues going forward and need to refactor.

Quoted 12 lines
sound/soc/amd/acp/acp-mach-common.c new file +12 -0
+	switch (drvdata->hs_codec_id) {
+	case RT5682:
+		pll_id = RT5682_PLL2;
+		pll_src = RT5682_PLL2_S_MCLK;
+		freq_in = PCO_PLAT_CLK;
+		freq_out = RT5682_PLL_FREQ;
+		clk_id = RT5682_SCLK_S_PLL2;
+		clk_freq = RT5682_PLL_FREQ;
+		wclk_name = "rt5682-dai-wclk";
+		bclk_name = "rt5682-dai-bclk";
+		drvdata->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
+				   | SND_SOC_DAIFMT_CBP_CFP;
Quoted 8 lines

sound/soc/amd/acp/acp-mach-common.c line 129

Quoted 2 lines
sound/soc/amd/acp/acp-mach-common.c new file +2 -0
+		snd_soc_dapm_add_routes(&rtd->card->dapm, rt5682_map, ARRAY_SIZE(rt5682_map));
+		break;

It feels like this is going to run into scaling issues going forward and you're likely to need separate operations for different CODECs rather than just different IDs. Similar issues apply for the amps, it feels like you want to be passing separate ops in rather than having these switch statements.

Ok will change to use separate ops in v2 patch series instead of switch statements.

Quoted 8 lines

sound/soc/amd/acp/acp-mach-common.c line 227

Quoted 4 lines
sound/soc/amd/acp/acp-mach-common.c new file +3 -0
+	/* Do nothing for dummy codec */
+	if (!drvdata->hs_codec_id && drvdata->amp_codec_id)
+		return;

Wha the test seems to say is do nothing if there's no CODEC but there is an amp...

Quoted 7 lines

sound/soc/amd/acp/acp-mach-common.c line 230

Quoted 3 lines
sound/soc/amd/acp/acp-mach-common.c new file +3 -0
+
+	clk_disable_unprepare(drvdata->wclk);
+}

...though I'd expect that given that the clock API accepts NULL clocks you could just remove these checks and unconditionally use the clocks.

Ok will remove this check in v2 patch series.

Quoted 7 lines

sound/soc/amd/acp/acp-mach-common.c line 509

Quoted 4 lines
sound/soc/amd/acp/acp-mach-common.c new file +3 -0
+	return 0;
+}
+EXPORT_SYMBOL_NS(acp_legacy_dai_links_create, SND_SOC_AMD_MACH);

EXPORT_SYMBOL_GPL_NS() - ASoC is all EXPORT_SYMBOL_GPL

sure will update to use NS_GPL() in v2 patch chain

#10 lore raw

PATCH 5/8 ASoC: amd: acp: Add legacy sound card support for Guybrush board

In reply to Ajit Kumar Pandey

Renoir based Guybrush board has RT5682 as primary headset codec and RT1019 Amp device connected to I2SSP ACP i2s controller. Add driver to register legacy sound card devices on guybrush board.

---
 sound/soc/amd/acp/Kconfig           |   6 ++
 sound/soc/amd/acp/Makefile          |   2 +
 sound/soc/amd/acp/acp-legacy-mach.c | 104 ++++++++++++++++++++++++++++
 3 files changed, 112 insertions(+)
 create mode 100644 sound/soc/amd/acp/acp-legacy-mach.c
sound/soc/amd/acp/Kconfig +6 -0
index 1ad811707a68..aea8766d20a0 100644
@@ -33,3 +33,9 @@ config SND_SOC_AMD_MACH_COMMON
 	depends on X86 && PCI && I2C
 	help
 	 This option enables common Machine driver module for ACP
+
+config SND_SOC_AMD_LEGACY_MACH
+	tristate "AMD Legacy Machine Driver Support"
+	select SND_SOC_AMD_MACH_COMMON
+	help
+	 This option enables legacy sound card support for ACP audio
sound/soc/amd/acp/Makefile +2 -0
index a477a18272bf..aef6f981c770 100644
@@ -13,6 +13,7 @@ snd-acp-renoir-objs     := acp-renoir.o
 
 #machine specific driver
 snd-acp-mach-objs     := acp-mach-common.o
+snd-acp-legacy-mach-objs     := acp-legacy-mach.o
 
 obj-$(CONFIG_SND_SOC_AMD_ACP_PCM) += snd-acp-pcm.o
 obj-$(CONFIG_SND_SOC_AMD_ACP_I2S) += snd-acp-i2s.o
@@ -20,3 +21,4 @@ obj-$(CONFIG_SND_SOC_AMD_ACP_I2S) += snd-acp-i2s.o
 obj-$(CONFIG_SND_AMD_ASOC_RENOIR) += snd-acp-renoir.o
 
 obj-$(CONFIG_SND_SOC_AMD_MACH_COMMON) += snd-acp-mach.o
+obj-$(CONFIG_SND_SOC_AMD_LEGACY_MACH) += snd-acp-legacy-mach.o
sound/soc/amd/acp/acp-legacy-mach.c new file +104 -0

104 lines not on this page · raw message

Signature · 1 line
2.25.1
#11 lore raw

PATCH 6/8 ASoC: amd: acp: Add SOF sound card support on Guybrush board

In reply to Ajit Kumar Pandey

Guybrush board has RT5682 codec and RT1019 amp connected to I2S SP controller on ACP hw. Also it support DMIC capture endpoints with inbuilt pdm controller on ACP hw block. Add driver module to create backend dai links for sof dsp core. We pass driver data with audio end points configuration to register sound cards and create device nodes for all audio endpoints.

---
 sound/soc/amd/acp/Kconfig        |   6 ++
 sound/soc/amd/acp/Makefile       |   2 +
 sound/soc/amd/acp/acp-sof-mach.c | 103 +++++++++++++++++++++++++++++++
 3 files changed, 111 insertions(+)
 create mode 100644 sound/soc/amd/acp/acp-sof-mach.c
sound/soc/amd/acp/Kconfig +6 -0
index aea8766d20a0..55dda516a0d0 100644
@@ -39,3 +39,9 @@ config SND_SOC_AMD_LEGACY_MACH
 	select SND_SOC_AMD_MACH_COMMON
 	help
 	 This option enables legacy sound card support for ACP audio
+
+config SND_SOC_AMD_SOF_MACH
+	tristate "AMD SOF Machine Driver Support"
+	select SND_SOC_AMD_MACH_COMMON
+	help
+	 This option enables SOF sound card support for ACP audio
sound/soc/amd/acp/Makefile +2 -0
index aef6f981c770..16c144c2965c 100644
@@ -14,6 +14,7 @@ snd-acp-renoir-objs     := acp-renoir.o
 #machine specific driver
 snd-acp-mach-objs     := acp-mach-common.o
 snd-acp-legacy-mach-objs     := acp-legacy-mach.o
+snd-acp-sof-mach-objs     := acp-sof-mach.o
 
 obj-$(CONFIG_SND_SOC_AMD_ACP_PCM) += snd-acp-pcm.o
 obj-$(CONFIG_SND_SOC_AMD_ACP_I2S) += snd-acp-i2s.o
@@ -22,3 +23,4 @@ obj-$(CONFIG_SND_AMD_ASOC_RENOIR) += snd-acp-renoir.o
 
 obj-$(CONFIG_SND_SOC_AMD_MACH_COMMON) += snd-acp-mach.o
 obj-$(CONFIG_SND_SOC_AMD_LEGACY_MACH) += snd-acp-legacy-mach.o
+obj-$(CONFIG_SND_SOC_AMD_SOF_MACH) += snd-acp-sof-mach.o
sound/soc/amd/acp/acp-sof-mach.c new file +103 -0

103 lines not on this page · raw message

Signature · 1 line
2.25.1
#12 lore raw

PATCH 7/8 ASoC: amd: acp: Add support for Maxim amplifier codec

In reply to Ajit Kumar Pandey

Add a new codec id for MAX98360A amplifier in codec list and define maxim components and audio route in common machine driver code.

---
 sound/soc/amd/acp/Kconfig           |  1 +
 sound/soc/amd/acp/acp-mach-common.c | 21 +++++++++++++++++++++
 sound/soc/amd/acp/acp-mach.h        |  1 +
 3 files changed, 23 insertions(+)
sound/soc/amd/acp/Kconfig +1 -0
index 55dda516a0d0..8257b8e1e7cc 100644
@@ -30,6 +30,7 @@ config SND_SOC_AMD_MACH_COMMON
 	select SND_SOC_RT5682_I2C
 	select SND_SOC_DMIC
 	select SND_SOC_RT1019
+	select SND_SOC_MAX98357A
 	depends on X86 && PCI && I2C
 	help
 	 This option enables common Machine driver module for ACP
sound/soc/amd/acp/acp-mach-common.c +21 -0
index cc507c520317..80c6cd220674 100644
@@ -91,6 +91,14 @@ static struct snd_soc_codec_conf rt1019_conf[] = {
 	},
 };
 
+/* Declare Maxim codec components */
+SND_SOC_DAILINK_DEF(max98360a,
+	DAILINK_COMP_ARRAY(COMP_CODEC("MX98360A:00", "HiFi")));
+
+static const struct snd_soc_dapm_route max98360a_map[] = {
+	{"Spk", NULL, "Speaker"},
+};
+
 /* Declare DMIC codec components */
 SND_SOC_DAILINK_DEF(dmic_codec,
 		DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
@@ -248,6 +256,9 @@ static int acp_asoc_amp_init(struct snd_soc_pcm_runtime *rtd)
 	case RT1019:
 		return snd_soc_dapm_add_routes(&rtd->card->dapm, rt1019_map_lr,
 					       ARRAY_SIZE(rt1019_map_lr));
+	case MAX98360A:
+		return snd_soc_dapm_add_routes(&rtd->card->dapm, max98360a_map,
+					       ARRAY_SIZE(max98360a_map));
 	default:
 		dev_err(card->dev, "Invalid AMP id: %d\n", drvdata->amp_codec_id);
 		return -EINVAL;
@@ -286,6 +297,8 @@ static int acp_card_amp_hw_params(struct snd_pcm_substream *substream,
 				return ret;
 			}
 		break;
+	case MAX98360A:
+		break;
 	default:
 		dev_err(card->dev, "Invalid AMP id: %d\n", drvdata->amp_codec_id);
 		return -EINVAL;
@@ -414,6 +427,10 @@ int acp_sofdsp_dai_links_create(struct snd_soc_card *card)
 			card->codec_conf = rt1019_conf;
 			card->num_configs = ARRAY_SIZE(rt1019_conf);
 		}
+		if (drv_data->amp_codec_id == MAX98360A) {
+			links[i].codecs = max98360a;
+			links[i].num_codecs = ARRAY_SIZE(max98360a);
+		}
 		i++;
 	}
 
@@ -499,6 +516,10 @@ int acp_legacy_dai_links_create(struct snd_soc_card *card)
 			card->codec_conf = rt1019_conf;
 			card->num_configs = ARRAY_SIZE(rt1019_conf);
 		}
+		if (drv_data->amp_codec_id == MAX98360A) {
+			links[i].codecs = max98360a;
+			links[i].num_codecs = ARRAY_SIZE(max98360a);
+		}
 	}
 
 	card->dai_link = links;
sound/soc/amd/acp/acp-mach.h +1 -0
index 464fb7eb802d..b6a43d1b9ad4 100644
@@ -35,6 +35,7 @@ enum codec_endpoints {
 	DUMMY = 0,
 	RT5682,
 	RT1019,
+	MAX98360A,
 };
 
 struct acp_card_drvdata {
Signature · 1 line
2.25.1
#13 lore raw

PATCH 8/8 ASoC: amd: acp: Add support for RT5682-VS codec

In reply to Ajit Kumar Pandey

Add new codec endpoints and define components to support RT5682-VS variants of codec with ACP machines.

---
 sound/soc/amd/acp/Kconfig           |  1 +
 sound/soc/amd/acp/acp-mach-common.c | 25 +++++++++++++++++++++++++
 sound/soc/amd/acp/acp-mach.h        |  1 +
 3 files changed, 27 insertions(+)
sound/soc/amd/acp/Kconfig +1 -0
index 8257b8e1e7cc..7e3c32f5b982 100644
@@ -31,6 +31,7 @@ config SND_SOC_AMD_MACH_COMMON
 	select SND_SOC_DMIC
 	select SND_SOC_RT1019
 	select SND_SOC_MAX98357A
+	select SND_SOC_RT5682S
 	depends on X86 && PCI && I2C
 	help
 	 This option enables common Machine driver module for ACP
sound/soc/amd/acp/acp-mach-common.c +25 -0
index 80c6cd220674..5e7da4515e5e 100644
@@ -23,6 +23,7 @@
 
 #include "../../codecs/rt5682.h"
 #include "../../codecs/rt1019.h"
+#include "../../codecs/rt5682s.h"
 #include "acp-mach.h"
 
 #define PCO_PLAT_CLK 48000000
@@ -64,6 +65,9 @@ static int acp_clk_enable(struct acp_card_drvdata *drvdata)
 SND_SOC_DAILINK_DEF(rt5682,
 	DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC5682:00", "rt5682-aif1")));
 
+SND_SOC_DAILINK_DEF(rt5682s,
+		    DAILINK_COMP_ARRAY(COMP_CODEC("i2c-RTL5682:00", "rt5682s-aif1")));
+
 static const struct snd_soc_dapm_route rt5682_map[] = {
 	{ "Headphone Jack", NULL, "HPOL" },
 	{ "Headphone Jack", NULL, "HPOR" },
@@ -135,6 +139,19 @@ static int acp_asoc_hs_init(struct snd_soc_pcm_runtime *rtd)
 				   | SND_SOC_DAIFMT_CBP_CFP;
 		snd_soc_dapm_add_routes(&rtd->card->dapm, rt5682_map, ARRAY_SIZE(rt5682_map));
 		break;
+	case RT5682S:
+		pll_id = RT5682S_PLL2;
+		pll_src = RT5682S_PLL_S_MCLK;
+		freq_in = PCO_PLAT_CLK;
+		freq_out = RT5682_PLL_FREQ;
+		clk_id = RT5682S_SCLK_S_PLL2;
+		clk_freq = RT5682_PLL_FREQ;
+		wclk_name = "rt5682-dai-wclk";
+		bclk_name = "rt5682-dai-bclk";
+		drvdata->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
+				   | SND_SOC_DAIFMT_CBM_CFM;
+		snd_soc_dapm_add_routes(&rtd->card->dapm, rt5682_map, ARRAY_SIZE(rt5682_map));
+		break;
 	default:
 		dev_err(rtd->dev, "Invalid codec id %d\n", drvdata->hs_codec_id);
 		return -EINVAL;
@@ -401,6 +418,10 @@ int acp_sofdsp_dai_links_create(struct snd_soc_card *card)
 			links[i].codecs = rt5682;
 			links[i].num_codecs = ARRAY_SIZE(rt5682);
 		}
+		if (drv_data->hs_codec_id == RT5682S) {
+			links[i].codecs = rt5682s;
+			links[i].num_codecs = ARRAY_SIZE(rt5682s);
+		}
 		i++;
 	}
 
@@ -492,6 +513,10 @@ int acp_legacy_dai_links_create(struct snd_soc_card *card)
 			links[i].codecs = rt5682;
 			links[i].num_codecs = ARRAY_SIZE(rt5682);
 		}
+		if (drv_data->hs_codec_id == RT5682S) {
+			links[i].codecs = rt5682s;
+			links[i].num_codecs = ARRAY_SIZE(rt5682s);
+		}
 		i++;
 	}
 
sound/soc/amd/acp/acp-mach.h +1 -0
index b6a43d1b9ad4..5dc47cfbff10 100644
@@ -36,6 +36,7 @@ enum codec_endpoints {
 	RT5682,
 	RT1019,
 	MAX98360A,
+	RT5682S,
 };
 
 struct acp_card_drvdata {
Signature · 1 line
2.25.1
maintainer
#14 lore raw
In reply to Ajit Kumar Pandey
Quoted 4 lines · Ajit Kumar Pandey

We need to support I2S audio on various different platforms SOC in near future. At present we are creating new folder under soc/amd/ for each platforms support with separate I2S and DMA device modules across each SOC. Actually AMD's audio coprocessor block commonly known as ACP hw IP

This seems basically fine - I do think you're likely to run into issues going forward if you get much more board/device variation but only one trivial issue with not using a GPL symbol export that really needs looking at now, otherwise it looks good for merging.