Message ID | 20211012071939.97002-6-AjitKumar.Pandey@amd.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | ASoC: Add common modules support for ACP hw block | expand |
Hi Ajit, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on broonie-sound/for-next] [also build test WARNING on v5.15-rc5 next-20211013] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Ajit-Kumar-Pandey/ASoC-Add-common-modules-support-for-ACP-hw-block/20211012-152408 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next config: x86_64-randconfig-m031-20211013 (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> New smatch warnings: sound/soc/amd/acp/acp-mach-common.c:153 acp_card_hs_startup() warn: unsigned 'ret' is never less than zero. Old smatch warnings: sound/soc/amd/acp/acp-mach-common.c:165 acp_card_hs_startup() warn: unsigned 'ret' is never less than zero. vim +/ret +153 sound/soc/amd/acp/acp-mach-common.c f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 141 f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 142 static int acp_card_hs_startup(struct snd_pcm_substream *substream) f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 143 { f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 144 struct snd_pcm_runtime *runtime = substream->runtime; f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 145 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 146 struct snd_soc_card *card = rtd->card; f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 147 struct acp_card_drvdata *drvdata = card->drvdata; f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 148 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 149 unsigned int ret = 0; f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 150 f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 151 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 152 | SND_SOC_DAIFMT_CBP_CFP); f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 @153 if (ret < 0) { f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 154 dev_err(rtd->card->dev, "Failed to set dai fmt: %d\n", ret); f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 155 return ret; f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 156 } f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 157 f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 158 runtime->hw.channels_max = DUAL_CHANNEL; f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 159 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 160 &constraints_channels); f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 161 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 162 &constraints_rates); f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 163 f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 164 ret = acp_clk_enable(drvdata); f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 165 if (ret < 0) f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 166 dev_err(rtd->card->dev, "Failed to enable HS clk: %d\n", ret); f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 167 f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 168 return ret; f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 169 } f6032c9a69e5df Ajit Kumar Pandey 2021-10-12 170 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Hi Ajit, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on broonie-sound/for-next] [also build test WARNING on v5.15-rc5 next-20211013] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Ajit-Kumar-Pandey/ASoC-Add-common-modules-support-for-ACP-hw-block/20211012-152408 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next config: x86_64-randconfig-m031-20211013 (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> New smatch warnings: sound/soc/amd/acp/acp-mach-common.c:153 acp_card_hs_startup() warn: unsigned 'ret' is never less than zero. Old smatch warnings: sound/soc/amd/acp/acp-mach-common.c:165 acp_card_hs_startup() warn: unsigned 'ret' is never less than zero. vim +/ret +153 sound/soc/amd/acp/acp-mach-common.c f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 141 f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 142 static int acp_card_hs_startup(struct snd_pcm_substream *substream) f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 143 { f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 144 struct snd_pcm_runtime *runtime = substream->runtime; f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 145 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 146 struct snd_soc_card *card = rtd->card; f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 147 struct acp_card_drvdata *drvdata = card->drvdata; f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 148 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 149 unsigned int ret = 0; f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 150 f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 151 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 152 | SND_SOC_DAIFMT_CBP_CFP); f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 @153 if (ret < 0) { f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 154 dev_err(rtd->card->dev, "Failed to set dai fmt: %d\n", ret); f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 155 return ret; f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 156 } f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 157 f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 158 runtime->hw.channels_max = DUAL_CHANNEL; f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 159 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 160 &constraints_channels); f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 161 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 162 &constraints_rates); f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 163 f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 164 ret = acp_clk_enable(drvdata); f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 165 if (ret < 0) f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 166 dev_err(rtd->card->dev, "Failed to enable HS clk: %d\n", ret); f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 167 f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 168 return ret; f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 169 } f6032c9a69e5dfb Ajit Kumar Pandey 2021-10-12 170 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff --git a/sound/soc/amd/acp/Kconfig b/sound/soc/amd/acp/Kconfig index 7ce43e393643..d8d49d04fe41 100644 --- a/sound/soc/amd/acp/Kconfig +++ b/sound/soc/amd/acp/Kconfig @@ -35,3 +35,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. diff --git a/sound/soc/amd/acp/Makefile b/sound/soc/amd/acp/Makefile index a477a18272bf..aef6f981c770 100644 --- a/sound/soc/amd/acp/Makefile +++ b/sound/soc/amd/acp/Makefile @@ -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 diff --git a/sound/soc/amd/acp/acp-legacy-mach.c b/sound/soc/amd/acp/acp-legacy-mach.c new file mode 100644 index 000000000000..de0f8024e2fb --- /dev/null +++ b/sound/soc/amd/acp/acp-legacy-mach.c @@ -0,0 +1,104 @@ +// 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. +// +// Authors: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com> +// + +/* + * Machine Driver Legacy Support for ACP HW block + */ + +#include <sound/core.h> +#include <sound/pcm_params.h> +#include <sound/soc-acpi.h> +#include <sound/soc-dapm.h> +#include <linux/module.h> + +#include "acp-mach.h" + +static struct acp_card_drvdata rt5682_rt1019_data = { + .hs_cpu_id = I2S_SP, + .amp_cpu_id = I2S_SP, + .dmic_cpu_id = NONE, + .hs_codec_id = RT5682, + .amp_codec_id = RT1019, + .dmic_codec_id = NONE, +}; + +static const struct snd_kcontrol_new acp_controls[] = { + SOC_DAPM_PIN_SWITCH("Headphone Jack"), + SOC_DAPM_PIN_SWITCH("Headset Mic"), + SOC_DAPM_PIN_SWITCH("Spk"), + SOC_DAPM_PIN_SWITCH("Left Spk"), + SOC_DAPM_PIN_SWITCH("Right Spk"), + +}; + +static const struct snd_soc_dapm_widget acp_widgets[] = { + SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_SPK("Spk", NULL), + SND_SOC_DAPM_SPK("Left Spk", NULL), + SND_SOC_DAPM_SPK("Right Spk", NULL), +}; + +static int acp_asoc_probe(struct platform_device *pdev) +{ + struct snd_soc_card *card = NULL; + struct device *dev = &pdev->dev; + int ret; + + if (!pdev->id_entry) + return -EINVAL; + + card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); + if (!card) + return -ENOMEM; + + card->dev = dev; + card->owner = THIS_MODULE; + card->name = pdev->id_entry->name; + card->dapm_widgets = acp_widgets; + card->num_dapm_widgets = ARRAY_SIZE(acp_widgets); + card->controls = acp_controls; + card->num_controls = ARRAY_SIZE(acp_controls); + card->drvdata = (struct acp_card_drvdata *)pdev->id_entry->driver_data; + + acp_legacy_dai_links_create(card); + + ret = devm_snd_soc_register_card(&pdev->dev, card); + if (ret) { + dev_err(&pdev->dev, + "devm_snd_soc_register_card(%s) failed: %d\n", + card->name, ret); + return ret; + } + + return 0; +} + +static const struct platform_device_id board_ids[] = { + { + .name = "rn_rt5682_rt1019", + .driver_data = (kernel_ulong_t)&rt5682_rt1019_data, + }, + { } +}; +static struct platform_driver acp_asoc_audio = { + .driver = { + .name = "acp_mach", + }, + .probe = acp_asoc_probe, + .id_table = board_ids, +}; + +module_platform_driver(acp_asoc_audio); + +MODULE_IMPORT_NS(SND_SOC_AMD_MACH); +MODULE_DESCRIPTION("ACP chrome audio support"); +MODULE_ALIAS("platform:rn_rt5682_rt1019"); +MODULE_LICENSE("GPL v2");
Renoir based Chrome 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 Chrome board. Signed-off-by: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com> --- 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