Path: blob/master/sound/soc/intel/common/soc-acpi-intel-ssp-common.c
26493 views
// SPDX-License-Identifier: GPL-2.0-only1//2// Copyright(c) 2023 Intel Corporation34#include <linux/device.h>5#include <sound/soc-acpi.h>6#include <sound/soc-acpi-intel-ssp-common.h>78/*9* Codec probe function10*/11#define CODEC_MAP_ENTRY(n, s, h, t) \12{ \13.name = n, \14.tplg_suffix = s, \15.acpi_hid = h, \16.codec_type = t, \17}1819struct codec_map {20const char *name;21const char *tplg_suffix;22const char *acpi_hid;23enum snd_soc_acpi_intel_codec codec_type;24};2526static const struct codec_map codecs[] = {27/* Cirrus Logic */28CODEC_MAP_ENTRY("CS42L42", "cs42l42", CS42L42_ACPI_HID, CODEC_CS42L42),2930/* Dialog */31CODEC_MAP_ENTRY("DA7219", "da7219", DA7219_ACPI_HID, CODEC_DA7219),3233/* Everest */34CODEC_MAP_ENTRY("ES8316", "es8336", ES8316_ACPI_HID, CODEC_ES8316),35CODEC_MAP_ENTRY("ES8326", "es8336", ES8326_ACPI_HID, CODEC_ES8326),36CODEC_MAP_ENTRY("ES8336", "es8336", ES8336_ACPI_HID, CODEC_ES8336),3738/* Nuvoton */39CODEC_MAP_ENTRY("NAU8825", "nau8825", NAU8825_ACPI_HID, CODEC_NAU8825),4041/* Realtek */42CODEC_MAP_ENTRY("RT5650", "rt5650", RT5650_ACPI_HID, CODEC_RT5650),43CODEC_MAP_ENTRY("RT5682", "rt5682", RT5682_ACPI_HID, CODEC_RT5682),44CODEC_MAP_ENTRY("RT5682S", "rt5682", RT5682S_ACPI_HID, CODEC_RT5682S),45};4647static const struct codec_map amps[] = {48/* Cirrus Logic */49CODEC_MAP_ENTRY("CS35L41", "cs35l41", CS35L41_ACPI_HID, CODEC_CS35L41),5051/* Maxim */52CODEC_MAP_ENTRY("MAX98357A", "max98357a", MAX_98357A_ACPI_HID, CODEC_MAX98357A),53CODEC_MAP_ENTRY("MAX98360A", "max98360a", MAX_98360A_ACPI_HID, CODEC_MAX98360A),54CODEC_MAP_ENTRY("MAX98373", "max98373", MAX_98373_ACPI_HID, CODEC_MAX98373),55CODEC_MAP_ENTRY("MAX98390", "max98390", MAX_98390_ACPI_HID, CODEC_MAX98390),5657/* Nuvoton */58CODEC_MAP_ENTRY("NAU8318", "nau8318", NAU8318_ACPI_HID, CODEC_NAU8318),5960/* Realtek */61CODEC_MAP_ENTRY("RT1011", "rt1011", RT1011_ACPI_HID, CODEC_RT1011),62CODEC_MAP_ENTRY("RT1015", "rt1015", RT1015_ACPI_HID, CODEC_RT1015),63CODEC_MAP_ENTRY("RT1015P", "rt1015", RT1015P_ACPI_HID, CODEC_RT1015P),64CODEC_MAP_ENTRY("RT1019P", "rt1019", RT1019P_ACPI_HID, CODEC_RT1019P),65CODEC_MAP_ENTRY("RT1308", "rt1308", RT1308_ACPI_HID, CODEC_RT1308),6667/*68* Monolithic components69*70* Only put components that can serve as both the amp and the codec below this line.71* This will ensure that if the part is used just as a codec and there is an amp as well72* then the amp will be selected properly.73*/74CODEC_MAP_ENTRY("RT5650", "rt5650", RT5650_ACPI_HID, CODEC_RT5650),75};7677enum snd_soc_acpi_intel_codec78snd_soc_acpi_intel_detect_codec_type(struct device *dev)79{80int i;8182for (i = 0; i < ARRAY_SIZE(codecs); i++) {83if (!acpi_dev_present(codecs[i].acpi_hid, NULL, -1))84continue;8586dev_dbg(dev, "codec %s found\n", codecs[i].name);87return codecs[i].codec_type;88}8990return CODEC_NONE;91}92EXPORT_SYMBOL_NS(snd_soc_acpi_intel_detect_codec_type, "SND_SOC_ACPI_INTEL_MATCH");9394enum snd_soc_acpi_intel_codec95snd_soc_acpi_intel_detect_amp_type(struct device *dev)96{97int i;9899for (i = 0; i < ARRAY_SIZE(amps); i++) {100if (!acpi_dev_present(amps[i].acpi_hid, NULL, -1))101continue;102103dev_dbg(dev, "amp %s found\n", amps[i].name);104return amps[i].codec_type;105}106107return CODEC_NONE;108}109EXPORT_SYMBOL_NS(snd_soc_acpi_intel_detect_amp_type, "SND_SOC_ACPI_INTEL_MATCH");110111const char *112snd_soc_acpi_intel_get_codec_name(enum snd_soc_acpi_intel_codec codec_type)113{114int i;115116for (i = 0; i < ARRAY_SIZE(codecs); i++) {117if (codecs[i].codec_type != codec_type)118continue;119120return codecs[i].name;121}122for (i = 0; i < ARRAY_SIZE(amps); i++) {123if (amps[i].codec_type != codec_type)124continue;125126return amps[i].name;127}128129return NULL;130}131EXPORT_SYMBOL_NS(snd_soc_acpi_intel_get_codec_name, "SND_SOC_ACPI_INTEL_MATCH");132133const char *134snd_soc_acpi_intel_get_codec_tplg_suffix(enum snd_soc_acpi_intel_codec codec_type)135{136int i;137138for (i = 0; i < ARRAY_SIZE(codecs); i++) {139if (codecs[i].codec_type != codec_type)140continue;141142return codecs[i].tplg_suffix;143}144145return NULL;146}147EXPORT_SYMBOL_NS(snd_soc_acpi_intel_get_codec_tplg_suffix, "SND_SOC_ACPI_INTEL_MATCH");148149const char *150snd_soc_acpi_intel_get_amp_tplg_suffix(enum snd_soc_acpi_intel_codec codec_type)151{152int i;153154for (i = 0; i < ARRAY_SIZE(amps); i++) {155if (amps[i].codec_type != codec_type)156continue;157158return amps[i].tplg_suffix;159}160161return NULL;162}163EXPORT_SYMBOL_NS(snd_soc_acpi_intel_get_amp_tplg_suffix, "SND_SOC_ACPI_INTEL_MATCH");164165MODULE_DESCRIPTION("ASoC Intel SOF Common Machine Driver Helpers");166MODULE_AUTHOR("Brent Lu <[email protected]>");167MODULE_LICENSE("GPL");168169170