mirror of
https://git.proxmox.com/git/mirror_ubuntu-kernels.git
synced 2025-11-23 20:39:30 +00:00
Commit7ac3404c2e("ASoC: amd: acp: Map missing jack kcontrols") adds card kcontrols and DAPM widgets corresponding to jacks for Headphone and Headset Mic. But these were already being added in acp-legacy-mach.c and acp-sof-mach.c, so this causes a probe error: sof_mach rt5682s-hs-rt1019: control 2:0:0:Headphone Jack Switch:0 is already present sof_mach rt5682s-hs-rt1019: ASoC: Failed to add Headphone Jack Switch: -16 sof_mach rt5682s-hs-rt1019: devm_snd_soc_register_card(sof-rt5682s-hs-rt1019) failed: -16 sof_mach: probe of rt5682s-hs-rt1019 failed with error -16 Removing the new duplicates from the common code might be enough to fix the issue. But some of the codecs use different kcontrols and widgets. NAU8821 alone has an "Int Mic". MAX98360A has a single "Spk", while RT1019 has "Left Spk" and "Right Spk" (and two codec instances with name prefixes). Since there are per-codec differences, add the kcontrols and widgets in the common code as each dai-link is being initialized, instead of in the two machine drivers' probe(). Also, MAX98388 has Left and Right instances, but uses a single "SPK" widget. That seems weird, so normalize it to use two widgets (one per each instance like RT1019) while we're adding controls. Fixes:7ac3404c2e("ASoC: amd: acp: Map missing jack kcontrols") Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Link: https://lore.kernel.org/r/20230818080314.32991-1-alpernebiyasak@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
188 lines
4.3 KiB
C
188 lines
4.3 KiB
C
// 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>
|
|
//
|
|
|
|
/*
|
|
* SOF Machine Driver 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/dmi.h>
|
|
#include <linux/module.h>
|
|
|
|
#include "acp-mach.h"
|
|
|
|
static struct acp_card_drvdata sof_rt5682_rt1019_data = {
|
|
.hs_cpu_id = I2S_SP,
|
|
.amp_cpu_id = I2S_SP,
|
|
.dmic_cpu_id = DMIC,
|
|
.hs_codec_id = RT5682,
|
|
.amp_codec_id = RT1019,
|
|
.dmic_codec_id = DMIC,
|
|
.tdm_mode = false,
|
|
};
|
|
|
|
static struct acp_card_drvdata sof_rt5682_max_data = {
|
|
.hs_cpu_id = I2S_SP,
|
|
.amp_cpu_id = I2S_SP,
|
|
.dmic_cpu_id = DMIC,
|
|
.hs_codec_id = RT5682,
|
|
.amp_codec_id = MAX98360A,
|
|
.dmic_codec_id = DMIC,
|
|
.tdm_mode = false,
|
|
};
|
|
|
|
static struct acp_card_drvdata sof_rt5682s_rt1019_data = {
|
|
.hs_cpu_id = I2S_SP,
|
|
.amp_cpu_id = I2S_SP,
|
|
.dmic_cpu_id = DMIC,
|
|
.hs_codec_id = RT5682S,
|
|
.amp_codec_id = RT1019,
|
|
.dmic_codec_id = DMIC,
|
|
.tdm_mode = false,
|
|
};
|
|
|
|
static struct acp_card_drvdata sof_rt5682s_max_data = {
|
|
.hs_cpu_id = I2S_SP,
|
|
.amp_cpu_id = I2S_SP,
|
|
.dmic_cpu_id = DMIC,
|
|
.hs_codec_id = RT5682S,
|
|
.amp_codec_id = MAX98360A,
|
|
.dmic_codec_id = DMIC,
|
|
.tdm_mode = false,
|
|
};
|
|
|
|
static struct acp_card_drvdata sof_nau8825_data = {
|
|
.hs_cpu_id = I2S_HS,
|
|
.amp_cpu_id = I2S_HS,
|
|
.dmic_cpu_id = DMIC,
|
|
.hs_codec_id = NAU8825,
|
|
.amp_codec_id = MAX98360A,
|
|
.dmic_codec_id = DMIC,
|
|
.soc_mclk = true,
|
|
.tdm_mode = false,
|
|
};
|
|
|
|
static struct acp_card_drvdata sof_rt5682s_hs_rt1019_data = {
|
|
.hs_cpu_id = I2S_HS,
|
|
.amp_cpu_id = I2S_HS,
|
|
.dmic_cpu_id = DMIC,
|
|
.hs_codec_id = RT5682S,
|
|
.amp_codec_id = RT1019,
|
|
.dmic_codec_id = DMIC,
|
|
.soc_mclk = true,
|
|
.tdm_mode = false,
|
|
};
|
|
|
|
static struct acp_card_drvdata sof_nau8821_max98388_data = {
|
|
.hs_cpu_id = I2S_SP,
|
|
.amp_cpu_id = I2S_HS,
|
|
.dmic_cpu_id = NONE,
|
|
.hs_codec_id = NAU8821,
|
|
.amp_codec_id = MAX98388,
|
|
.dmic_codec_id = NONE,
|
|
.soc_mclk = true,
|
|
.tdm_mode = false,
|
|
};
|
|
|
|
static int acp_sof_probe(struct platform_device *pdev)
|
|
{
|
|
struct snd_soc_card *card = NULL;
|
|
struct device *dev = &pdev->dev;
|
|
const struct dmi_system_id *dmi_id;
|
|
struct acp_card_drvdata *acp_card_drvdata;
|
|
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->drvdata = (struct acp_card_drvdata *)pdev->id_entry->driver_data;
|
|
/* Widgets and controls added per-codec in acp-mach-common.c */
|
|
|
|
acp_card_drvdata = card->drvdata;
|
|
dmi_id = dmi_first_match(acp_quirk_table);
|
|
if (dmi_id && dmi_id->driver_data)
|
|
acp_card_drvdata->tdm_mode = dmi_id->driver_data;
|
|
|
|
acp_sofdsp_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 = "rt5682-rt1019",
|
|
.driver_data = (kernel_ulong_t)&sof_rt5682_rt1019_data
|
|
},
|
|
{
|
|
.name = "rt5682-max",
|
|
.driver_data = (kernel_ulong_t)&sof_rt5682_max_data
|
|
},
|
|
{
|
|
.name = "rt5682s-max",
|
|
.driver_data = (kernel_ulong_t)&sof_rt5682s_max_data
|
|
},
|
|
{
|
|
.name = "rt5682s-rt1019",
|
|
.driver_data = (kernel_ulong_t)&sof_rt5682s_rt1019_data
|
|
},
|
|
{
|
|
.name = "nau8825-max",
|
|
.driver_data = (kernel_ulong_t)&sof_nau8825_data
|
|
},
|
|
{
|
|
.name = "rt5682s-hs-rt1019",
|
|
.driver_data = (kernel_ulong_t)&sof_rt5682s_hs_rt1019_data
|
|
},
|
|
{
|
|
.name = "nau8821-max",
|
|
.driver_data = (kernel_ulong_t)&sof_nau8821_max98388_data
|
|
},
|
|
{ }
|
|
};
|
|
static struct platform_driver acp_asoc_audio = {
|
|
.driver = {
|
|
.name = "sof_mach",
|
|
.pm = &snd_soc_pm_ops,
|
|
},
|
|
.probe = acp_sof_probe,
|
|
.id_table = board_ids,
|
|
};
|
|
|
|
module_platform_driver(acp_asoc_audio);
|
|
|
|
MODULE_IMPORT_NS(SND_SOC_AMD_MACH);
|
|
MODULE_DESCRIPTION("ACP chrome SOF audio support");
|
|
MODULE_ALIAS("platform:rt5682-rt1019");
|
|
MODULE_ALIAS("platform:rt5682-max");
|
|
MODULE_ALIAS("platform:rt5682s-max");
|
|
MODULE_ALIAS("platform:rt5682s-rt1019");
|
|
MODULE_ALIAS("platform:nau8825-max");
|
|
MODULE_ALIAS("platform:rt5682s-hs-rt1019");
|
|
MODULE_ALIAS("platform:nau8821-max");
|
|
MODULE_LICENSE("GPL v2");
|