17730bb13SKuninori Morimoto /* SPDX-License-Identifier: GPL-2.0 27730bb13SKuninori Morimoto * 37feb2f78SPierre-Louis Bossart * Copyright (C) 2013-15, Intel Corporation. All rights reserved. 47feb2f78SPierre-Louis Bossart */ 57feb2f78SPierre-Louis Bossart 67feb2f78SPierre-Louis Bossart #ifndef __LINUX_SND_SOC_ACPI_H 77feb2f78SPierre-Louis Bossart #define __LINUX_SND_SOC_ACPI_H 87feb2f78SPierre-Louis Bossart 97feb2f78SPierre-Louis Bossart #include <linux/stddef.h> 107feb2f78SPierre-Louis Bossart #include <linux/acpi.h> 11845ab400SPierre-Louis Bossart #include <linux/mod_devicetable.h> 127feb2f78SPierre-Louis Bossart 137feb2f78SPierre-Louis Bossart struct snd_soc_acpi_package_context { 147feb2f78SPierre-Louis Bossart char *name; /* package name */ 157feb2f78SPierre-Louis Bossart int length; /* number of elements */ 167feb2f78SPierre-Louis Bossart struct acpi_buffer *format; 177feb2f78SPierre-Louis Bossart struct acpi_buffer *state; 187feb2f78SPierre-Louis Bossart bool data_valid; 197feb2f78SPierre-Louis Bossart }; 207feb2f78SPierre-Louis Bossart 212be2d579SPierre-Louis Bossart /* codec name is used in DAIs is i2c-<HID>:00 with HID being 8 chars */ 222be2d579SPierre-Louis Bossart #define SND_ACPI_I2C_ID_LEN (4 + ACPI_ID_LEN + 3 + 1) 232be2d579SPierre-Louis Bossart 247feb2f78SPierre-Louis Bossart #if IS_ENABLED(CONFIG_ACPI) 255e484ec1SPierre-Louis Bossart /* acpi match */ 265e484ec1SPierre-Louis Bossart struct snd_soc_acpi_mach * 275e484ec1SPierre-Louis Bossart snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines); 285e484ec1SPierre-Louis Bossart 297feb2f78SPierre-Louis Bossart bool snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN], 307feb2f78SPierre-Louis Bossart struct snd_soc_acpi_package_context *ctx); 315e484ec1SPierre-Louis Bossart 325e484ec1SPierre-Louis Bossart /* check all codecs */ 335e484ec1SPierre-Louis Bossart struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg); 345e484ec1SPierre-Louis Bossart 357feb2f78SPierre-Louis Bossart #else 365e484ec1SPierre-Louis Bossart /* acpi match */ 375e484ec1SPierre-Louis Bossart static inline struct snd_soc_acpi_mach * 385e484ec1SPierre-Louis Bossart snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines) 395e484ec1SPierre-Louis Bossart { 405e484ec1SPierre-Louis Bossart return NULL; 415e484ec1SPierre-Louis Bossart } 425e484ec1SPierre-Louis Bossart 437feb2f78SPierre-Louis Bossart static inline bool 447feb2f78SPierre-Louis Bossart snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN], 457feb2f78SPierre-Louis Bossart struct snd_soc_acpi_package_context *ctx) 467feb2f78SPierre-Louis Bossart { 477feb2f78SPierre-Louis Bossart return false; 487feb2f78SPierre-Louis Bossart } 497feb2f78SPierre-Louis Bossart 505e484ec1SPierre-Louis Bossart /* check all codecs */ 515e484ec1SPierre-Louis Bossart static inline struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg) 525e484ec1SPierre-Louis Bossart { 535e484ec1SPierre-Louis Bossart return NULL; 545e484ec1SPierre-Louis Bossart } 555e484ec1SPierre-Louis Bossart #endif 567feb2f78SPierre-Louis Bossart 577feb2f78SPierre-Louis Bossart /** 588679284bSPierre-Louis Bossart * snd_soc_acpi_mach_params: interface for machine driver configuration 598679284bSPierre-Louis Bossart * 608679284bSPierre-Louis Bossart * @acpi_ipc_irq_index: used for BYT-CR detection 618679284bSPierre-Louis Bossart * @platform: string used for HDaudio codec support 628679284bSPierre-Louis Bossart * @codec_mask: used for HDAudio support 63*7de9a47cSKai Vehmanen * @common_hdmi_codec_drv: use commom HDAudio HDMI codec driver 648679284bSPierre-Louis Bossart */ 658679284bSPierre-Louis Bossart struct snd_soc_acpi_mach_params { 668679284bSPierre-Louis Bossart u32 acpi_ipc_irq_index; 678679284bSPierre-Louis Bossart const char *platform; 688679284bSPierre-Louis Bossart u32 codec_mask; 69b92826faSPierre-Louis Bossart u32 dmic_num; 70*7de9a47cSKai Vehmanen bool common_hdmi_codec_drv; 718679284bSPierre-Louis Bossart }; 728679284bSPierre-Louis Bossart 738679284bSPierre-Louis Bossart /** 747feb2f78SPierre-Louis Bossart * snd_soc_acpi_mach: ACPI-based machine descriptor. Most of the fields are 757feb2f78SPierre-Louis Bossart * related to the hardware, except for the firmware and topology file names. 76976b5a0eSPierre-Louis Bossart * A platform supported by legacy and Sound Open Firmware (SOF) would expose 77976b5a0eSPierre-Louis Bossart * all firmware/topology related fields. 787feb2f78SPierre-Louis Bossart * 797feb2f78SPierre-Louis Bossart * @id: ACPI ID (usually the codec's) used to find a matching machine driver. 80af78cec4SPierre-Louis Bossart * @link_mask: describes required board layout, e.g. for SoundWire. 817feb2f78SPierre-Louis Bossart * @drv_name: machine driver name 82976b5a0eSPierre-Louis Bossart * @fw_filename: firmware file name. Used when SOF is not enabled. 837feb2f78SPierre-Louis Bossart * @board: board name 847feb2f78SPierre-Louis Bossart * @machine_quirk: pointer to quirk, usually based on DMI information when 857feb2f78SPierre-Louis Bossart * ACPI ID alone is not sufficient, wrong or misleading 867feb2f78SPierre-Louis Bossart * @quirk_data: data used to uniquely identify a machine, usually a list of 877feb2f78SPierre-Louis Bossart * audio codecs whose presence if checked with ACPI 887feb2f78SPierre-Louis Bossart * @pdata: intended for platform data or machine specific-ops. This structure 897feb2f78SPierre-Louis Bossart * is not constant since this field may be updated at run-time 90976b5a0eSPierre-Louis Bossart * @sof_fw_filename: Sound Open Firmware file name, if enabled 91976b5a0eSPierre-Louis Bossart * @sof_tplg_filename: Sound Open Firmware topology file name, if enabled 927feb2f78SPierre-Louis Bossart */ 937feb2f78SPierre-Louis Bossart /* Descriptor for SST ASoC machine driver */ 947feb2f78SPierre-Louis Bossart struct snd_soc_acpi_mach { 957feb2f78SPierre-Louis Bossart const u8 id[ACPI_ID_LEN]; 96af78cec4SPierre-Louis Bossart const u32 link_mask; 977feb2f78SPierre-Louis Bossart const char *drv_name; 987feb2f78SPierre-Louis Bossart const char *fw_filename; 997feb2f78SPierre-Louis Bossart const char *board; 1007feb2f78SPierre-Louis Bossart struct snd_soc_acpi_mach * (*machine_quirk)(void *arg); 1017feb2f78SPierre-Louis Bossart const void *quirk_data; 1027feb2f78SPierre-Louis Bossart void *pdata; 1038679284bSPierre-Louis Bossart struct snd_soc_acpi_mach_params mach_params; 104976b5a0eSPierre-Louis Bossart const char *sof_fw_filename; 105976b5a0eSPierre-Louis Bossart const char *sof_tplg_filename; 1067feb2f78SPierre-Louis Bossart }; 1077feb2f78SPierre-Louis Bossart 1087feb2f78SPierre-Louis Bossart #define SND_SOC_ACPI_MAX_CODECS 3 1097feb2f78SPierre-Louis Bossart 1107feb2f78SPierre-Louis Bossart /** 1117feb2f78SPierre-Louis Bossart * struct snd_soc_acpi_codecs: Structure to hold secondary codec information 1127feb2f78SPierre-Louis Bossart * apart from the matched one, this data will be passed to the quirk function 1137feb2f78SPierre-Louis Bossart * to match with the ACPI detected devices 1147feb2f78SPierre-Louis Bossart * 1157feb2f78SPierre-Louis Bossart * @num_codecs: number of secondary codecs used in the platform 1167feb2f78SPierre-Louis Bossart * @codecs: holds the codec IDs 1177feb2f78SPierre-Louis Bossart * 1187feb2f78SPierre-Louis Bossart */ 1197feb2f78SPierre-Louis Bossart struct snd_soc_acpi_codecs { 1207feb2f78SPierre-Louis Bossart int num_codecs; 1217feb2f78SPierre-Louis Bossart u8 codecs[SND_SOC_ACPI_MAX_CODECS][ACPI_ID_LEN]; 1227feb2f78SPierre-Louis Bossart }; 1237feb2f78SPierre-Louis Bossart 1247feb2f78SPierre-Louis Bossart #endif 125