Commit 4b38d639 authored by Brent Lu's avatar Brent Lu Committed by Mark Brown

ASoC: Intel: ssp-common: support codec detection

Create a new common module to host functions which could be shared
among SSP machine drivers. Add functions to detect headphone codec and
speaker amplifier via ACPI system at runtime in order to remove codec
type quirks in machine drivers.
Signed-off-by: default avatarBrent Lu <brent.lu@intel.com>
Reviewed-by: default avatarRander Wang <rander.wang@intel.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20230915124852.1696857-3-yung-chuan.liao@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 95409545
......@@ -38,6 +38,9 @@ config SND_SOC_INTEL_SOF_REALTEK_COMMON
config SND_SOC_INTEL_SOF_CIRRUS_COMMON
tristate
config SND_SOC_INTEL_SOF_SSP_COMMON
tristate
if SND_SOC_INTEL_CATPT
config SND_SOC_INTEL_HASWELL_MACH
......
......@@ -95,3 +95,6 @@ obj-$(CONFIG_SND_SOC_INTEL_SOF_REALTEK_COMMON) += snd-soc-intel-sof-realtek-comm
snd-soc-intel-sof-cirrus-common-objs += sof_cirrus_common.o
obj-$(CONFIG_SND_SOC_INTEL_SOF_CIRRUS_COMMON) += snd-soc-intel-sof-cirrus-common.o
snd-soc-intel-sof-ssp-common-objs += sof_ssp_common.o
obj-$(CONFIG_SND_SOC_INTEL_SOF_SSP_COMMON) += snd-soc-intel-sof-ssp-common.o
// SPDX-License-Identifier: GPL-2.0-only
//
// Copyright(c) 2023 Intel Corporation. All rights reserved.
#include <linux/device.h>
#include <sound/soc-acpi.h>
#include "sof_ssp_common.h"
/*
* Codec probe function
*/
#define CODEC_MAP_ENTRY(n, h, t) \
{ \
.name = n, \
.acpi_hid = h, \
.codec_type = t, \
}
struct codec_map {
const char *name;
const char *acpi_hid;
enum sof_ssp_codec codec_type;
};
static const struct codec_map codecs[] = {
/* Cirrus Logic */
CODEC_MAP_ENTRY("CS42L42", CS42L42_ACPI_HID, CODEC_CS42L42),
/* Dialog */
CODEC_MAP_ENTRY("DA7219", DA7219_ACPI_HID, CODEC_DA7219),
/* Everest */
CODEC_MAP_ENTRY("ES8316", ES8316_ACPI_HID, CODEC_ES8316),
CODEC_MAP_ENTRY("ES8326", ES8326_ACPI_HID, CODEC_ES8326),
CODEC_MAP_ENTRY("ES8336", ES8336_ACPI_HID, CODEC_ES8336),
/* Nuvoton */
CODEC_MAP_ENTRY("NAU8825", NAU8825_ACPI_HID, CODEC_NAU8825),
/* Realtek */
CODEC_MAP_ENTRY("RT5650", RT5650_ACPI_HID, CODEC_RT5650),
CODEC_MAP_ENTRY("RT5682", RT5682_ACPI_HID, CODEC_RT5682),
CODEC_MAP_ENTRY("RT5682S", RT5682S_ACPI_HID, CODEC_RT5682S),
};
static const struct codec_map amps[] = {
/* Cirrus Logic */
CODEC_MAP_ENTRY("CS35L41", CS35L41_ACPI_HID, CODEC_CS35L41),
/* Maxim */
CODEC_MAP_ENTRY("MAX98357A", MAX_98357A_ACPI_HID, CODEC_MAX98357A),
CODEC_MAP_ENTRY("MAX98360A", MAX_98360A_ACPI_HID, CODEC_MAX98360A),
CODEC_MAP_ENTRY("MAX98373", MAX_98373_ACPI_HID, CODEC_MAX98373),
CODEC_MAP_ENTRY("MAX98390", MAX_98390_ACPI_HID, CODEC_MAX98390),
/* Nuvoton */
CODEC_MAP_ENTRY("NAU8318", NAU8318_ACPI_HID, CODEC_NAU8318),
/* Realtek */
CODEC_MAP_ENTRY("RT1011", RT1011_ACPI_HID, CODEC_RT1011),
CODEC_MAP_ENTRY("RT1015", RT1015_ACPI_HID, CODEC_RT1015),
CODEC_MAP_ENTRY("RT1015P", RT1015P_ACPI_HID, CODEC_RT1015P),
CODEC_MAP_ENTRY("RT1019P", RT1019P_ACPI_HID, CODEC_RT1019P),
CODEC_MAP_ENTRY("RT1308", RT1308_ACPI_HID, CODEC_RT1308),
};
enum sof_ssp_codec sof_ssp_detect_codec_type(struct device *dev)
{
int i;
for (i = 0; i < ARRAY_SIZE(codecs); i++) {
if (!acpi_dev_present(codecs[i].acpi_hid, NULL, -1))
continue;
dev_dbg(dev, "codec %s found\n", codecs[i].name);
return codecs[i].codec_type;
}
return CODEC_NONE;
}
EXPORT_SYMBOL_NS(sof_ssp_detect_codec_type, SND_SOC_INTEL_SOF_SSP_COMMON);
enum sof_ssp_codec sof_ssp_detect_amp_type(struct device *dev)
{
int i;
for (i = 0; i < ARRAY_SIZE(amps); i++) {
if (!acpi_dev_present(amps[i].acpi_hid, NULL, -1))
continue;
dev_dbg(dev, "amp %s found\n", amps[i].name);
return amps[i].codec_type;
}
return CODEC_NONE;
}
EXPORT_SYMBOL_NS(sof_ssp_detect_amp_type, SND_SOC_INTEL_SOF_SSP_COMMON);
MODULE_DESCRIPTION("ASoC Intel SOF Common Machine Driver Helpers");
MODULE_AUTHOR("Brent Lu <brent.lu@intel.com>");
MODULE_LICENSE("GPL");
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright(c) 2023 Intel Corporation.
*/
#ifndef __SOF_SSP_COMMON_H
#define __SOF_SSP_COMMON_H
/* Cirrus Logic */
#define CS35L41_ACPI_HID "CSC3541"
#define CS42L42_ACPI_HID "10134242"
/* Dialog */
#define DA7219_ACPI_HID "DLGS7219"
/* Everest */
#define ES8316_ACPI_HID "ESSX8316"
#define ES8326_ACPI_HID "ESSX8326"
#define ES8336_ACPI_HID "ESSX8336"
#define MAX_98357A_ACPI_HID "MX98357A"
#define MAX_98360A_ACPI_HID "MX98360A"
#define MAX_98373_ACPI_HID "MX98373"
#define MAX_98390_ACPI_HID "MX98390"
/* Nuvoton */
#define NAU8318_ACPI_HID "NVTN2012"
#define NAU8825_ACPI_HID "10508825"
/* Realtek */
#define RT1011_ACPI_HID "10EC1011"
#define RT1015_ACPI_HID "10EC1015"
#define RT1015P_ACPI_HID "RTL1015"
#define RT1019P_ACPI_HID "RTL1019"
#define RT1308_ACPI_HID "10EC1308"
#define RT5650_ACPI_HID "10EC5650"
#define RT5682_ACPI_HID "10EC5682"
#define RT5682S_ACPI_HID "RTL5682"
enum sof_ssp_codec {
CODEC_NONE,
/* headphone codec */
CODEC_CS42L42,
CODEC_DA7219,
CODEC_ES8316,
CODEC_ES8326,
CODEC_ES8336,
CODEC_NAU8825,
CODEC_RT5650,
CODEC_RT5682,
CODEC_RT5682S,
/* speaker amplifier */
CODEC_CS35L41,
CODEC_MAX98357A,
CODEC_MAX98360A,
CODEC_MAX98373,
CODEC_MAX98390,
CODEC_NAU8318,
CODEC_RT1011,
CODEC_RT1015,
CODEC_RT1015P,
CODEC_RT1019P,
CODEC_RT1308,
};
enum sof_ssp_codec sof_ssp_detect_codec_type(struct device *dev);
enum sof_ssp_codec sof_ssp_detect_amp_type(struct device *dev);
#endif /* __SOF_SSP_COMMON_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment