Path: blob/master/sound/soc/intel/common/soc-acpi-intel-ssp-common.c
53349 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/* Texas Instruments */68CODEC_MAP_ENTRY("TAS2563", "tas2563", TAS2563_ACPI_HID, CODEC_TAS2563),6970/*71* Monolithic components72*73* Only put components that can serve as both the amp and the codec below this line.74* This will ensure that if the part is used just as a codec and there is an amp as well75* then the amp will be selected properly.76*/77CODEC_MAP_ENTRY("RT5650", "rt5650", RT5650_ACPI_HID, CODEC_RT5650),78};7980enum snd_soc_acpi_intel_codec81snd_soc_acpi_intel_detect_codec_type(struct device *dev)82{83int i;8485for (i = 0; i < ARRAY_SIZE(codecs); i++) {86if (!acpi_dev_present(codecs[i].acpi_hid, NULL, -1))87continue;8889dev_dbg(dev, "codec %s found\n", codecs[i].name);90return codecs[i].codec_type;91}9293return CODEC_NONE;94}95EXPORT_SYMBOL_NS(snd_soc_acpi_intel_detect_codec_type, "SND_SOC_ACPI_INTEL_MATCH");9697enum snd_soc_acpi_intel_codec98snd_soc_acpi_intel_detect_amp_type(struct device *dev)99{100int i;101102for (i = 0; i < ARRAY_SIZE(amps); i++) {103if (!acpi_dev_present(amps[i].acpi_hid, NULL, -1))104continue;105106dev_dbg(dev, "amp %s found\n", amps[i].name);107return amps[i].codec_type;108}109110return CODEC_NONE;111}112EXPORT_SYMBOL_NS(snd_soc_acpi_intel_detect_amp_type, "SND_SOC_ACPI_INTEL_MATCH");113114const char *115snd_soc_acpi_intel_get_codec_name(enum snd_soc_acpi_intel_codec codec_type)116{117int i;118119for (i = 0; i < ARRAY_SIZE(codecs); i++) {120if (codecs[i].codec_type != codec_type)121continue;122123return codecs[i].name;124}125for (i = 0; i < ARRAY_SIZE(amps); i++) {126if (amps[i].codec_type != codec_type)127continue;128129return amps[i].name;130}131132return NULL;133}134EXPORT_SYMBOL_NS(snd_soc_acpi_intel_get_codec_name, "SND_SOC_ACPI_INTEL_MATCH");135136const char *137snd_soc_acpi_intel_get_codec_tplg_suffix(enum snd_soc_acpi_intel_codec codec_type)138{139int i;140141for (i = 0; i < ARRAY_SIZE(codecs); i++) {142if (codecs[i].codec_type != codec_type)143continue;144145return codecs[i].tplg_suffix;146}147148return NULL;149}150EXPORT_SYMBOL_NS(snd_soc_acpi_intel_get_codec_tplg_suffix, "SND_SOC_ACPI_INTEL_MATCH");151152const char *153snd_soc_acpi_intel_get_amp_tplg_suffix(enum snd_soc_acpi_intel_codec codec_type)154{155int i;156157for (i = 0; i < ARRAY_SIZE(amps); i++) {158if (amps[i].codec_type != codec_type)159continue;160161return amps[i].tplg_suffix;162}163164return NULL;165}166EXPORT_SYMBOL_NS(snd_soc_acpi_intel_get_amp_tplg_suffix, "SND_SOC_ACPI_INTEL_MATCH");167168MODULE_DESCRIPTION("ASoC Intel SOF Common Machine Driver Helpers");169MODULE_AUTHOR("Brent Lu <[email protected]>");170MODULE_LICENSE("GPL");171172173