soc-acpi.h (6595B)
1/* SPDX-License-Identifier: GPL-2.0-only 2 * 3 * Copyright (C) 2013-15, Intel Corporation. All rights reserved. 4 */ 5 6#ifndef __LINUX_SND_SOC_ACPI_H 7#define __LINUX_SND_SOC_ACPI_H 8 9#include <linux/stddef.h> 10#include <linux/acpi.h> 11#include <linux/mod_devicetable.h> 12 13struct snd_soc_acpi_package_context { 14 char *name; /* package name */ 15 int length; /* number of elements */ 16 struct acpi_buffer *format; 17 struct acpi_buffer *state; 18 bool data_valid; 19}; 20 21/* codec name is used in DAIs is i2c-<HID>:00 with HID being 8 chars */ 22#define SND_ACPI_I2C_ID_LEN (4 + ACPI_ID_LEN + 3 + 1) 23 24#if IS_ENABLED(CONFIG_ACPI) 25/* acpi match */ 26struct snd_soc_acpi_mach * 27snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines); 28 29bool snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN], 30 struct snd_soc_acpi_package_context *ctx); 31 32/* check all codecs */ 33struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg); 34 35#else 36/* acpi match */ 37static inline struct snd_soc_acpi_mach * 38snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines) 39{ 40 return NULL; 41} 42 43static inline bool 44snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN], 45 struct snd_soc_acpi_package_context *ctx) 46{ 47 return false; 48} 49 50/* check all codecs */ 51static inline struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg) 52{ 53 return NULL; 54} 55#endif 56 57/** 58 * snd_soc_acpi_mach_params: interface for machine driver configuration 59 * 60 * @acpi_ipc_irq_index: used for BYT-CR detection 61 * @platform: string used for HDAudio codec support 62 * @codec_mask: used for HDAudio support 63 * @dmic_num: number of SoC- or chipset-attached PDM digital microphones 64 * @common_hdmi_codec_drv: use commom HDAudio HDMI codec driver 65 * @link_mask: SoundWire links enabled on the board 66 * @links: array of SoundWire link _ADR descriptors, null terminated 67 * @i2s_link_mask: I2S/TDM links enabled on the board 68 * @num_dai_drivers: number of elements in @dai_drivers 69 * @dai_drivers: pointer to dai_drivers, used e.g. in nocodec mode 70 */ 71struct snd_soc_acpi_mach_params { 72 u32 acpi_ipc_irq_index; 73 const char *platform; 74 u32 codec_mask; 75 u32 dmic_num; 76 bool common_hdmi_codec_drv; 77 u32 link_mask; 78 const struct snd_soc_acpi_link_adr *links; 79 u32 i2s_link_mask; 80 u32 num_dai_drivers; 81 struct snd_soc_dai_driver *dai_drivers; 82}; 83 84/** 85 * snd_soc_acpi_endpoint - endpoint descriptor 86 * @num: endpoint number (mandatory, unique per device) 87 * @aggregated: 0 (independent) or 1 (logically grouped) 88 * @group_position: zero-based order (only when @aggregated is 1) 89 * @group_id: platform-unique group identifier (only when @aggregrated is 1) 90 */ 91struct snd_soc_acpi_endpoint { 92 u8 num; 93 u8 aggregated; 94 u8 group_position; 95 u8 group_id; 96}; 97 98/** 99 * snd_soc_acpi_adr_device - descriptor for _ADR-enumerated device 100 * @adr: 64 bit ACPI _ADR value 101 * @num_endpoints: number of endpoints for this device 102 * @endpoints: array of endpoints 103 * @name_prefix: string used for codec controls 104 */ 105struct snd_soc_acpi_adr_device { 106 const u64 adr; 107 const u8 num_endpoints; 108 const struct snd_soc_acpi_endpoint *endpoints; 109 const char *name_prefix; 110}; 111 112/** 113 * snd_soc_acpi_link_adr - ACPI-based list of _ADR enumerated devices 114 * @mask: one bit set indicates the link this list applies to 115 * @num_adr: ARRAY_SIZE of devices 116 * @adr_d: array of devices 117 * 118 * The number of devices per link can be more than 1, e.g. in SoundWire 119 * multi-drop configurations. 120 */ 121 122struct snd_soc_acpi_link_adr { 123 const u32 mask; 124 const u32 num_adr; 125 const struct snd_soc_acpi_adr_device *adr_d; 126}; 127 128/* 129 * when set the topology uses the -ssp<N> suffix, where N is determined based on 130 * BIOS or DMI information 131 */ 132#define SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER BIT(0) 133 134/* 135 * when more than one SSP is reported in the link mask, use the most significant. 136 * This choice was found to be valid on platforms with ES8336 codecs. 137 */ 138#define SND_SOC_ACPI_TPLG_INTEL_SSP_MSB BIT(1) 139 140/* 141 * when set the topology uses the -dmic<N>ch suffix, where N is determined based on 142 * BIOS or DMI information 143 */ 144#define SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER BIT(2) 145 146/** 147 * snd_soc_acpi_mach: ACPI-based machine descriptor. Most of the fields are 148 * related to the hardware, except for the firmware and topology file names. 149 * A platform supported by legacy and Sound Open Firmware (SOF) would expose 150 * all firmware/topology related fields. 151 * 152 * @id: ACPI ID (usually the codec's) used to find a matching machine driver. 153 * @comp_ids: list of compatible audio codecs using the same machine driver, 154 * firmware and topology 155 * @link_mask: describes required board layout, e.g. for SoundWire. 156 * @links: array of link _ADR descriptors, null terminated. 157 * @drv_name: machine driver name 158 * @fw_filename: firmware file name. Used when SOF is not enabled. 159 * @tplg_filename: topology file name. Used when SOF is not enabled. 160 * @board: board name 161 * @machine_quirk: pointer to quirk, usually based on DMI information when 162 * ACPI ID alone is not sufficient, wrong or misleading 163 * @quirk_data: data used to uniquely identify a machine, usually a list of 164 * audio codecs whose presence if checked with ACPI 165 * @pdata: intended for platform data or machine specific-ops. This structure 166 * is not constant since this field may be updated at run-time 167 * @sof_tplg_filename: Sound Open Firmware topology file name, if enabled 168 * @tplg_quirk_mask: quirks to select different topology files dynamically 169 */ 170/* Descriptor for SST ASoC machine driver */ 171struct snd_soc_acpi_mach { 172 u8 id[ACPI_ID_LEN]; 173 const struct snd_soc_acpi_codecs *comp_ids; 174 const u32 link_mask; 175 const struct snd_soc_acpi_link_adr *links; 176 const char *drv_name; 177 const char *fw_filename; 178 const char *tplg_filename; 179 const char *board; 180 struct snd_soc_acpi_mach * (*machine_quirk)(void *arg); 181 const void *quirk_data; 182 void *pdata; 183 struct snd_soc_acpi_mach_params mach_params; 184 const char *sof_tplg_filename; 185 const u32 tplg_quirk_mask; 186}; 187 188#define SND_SOC_ACPI_MAX_CODECS 3 189 190/** 191 * struct snd_soc_acpi_codecs: Structure to hold secondary codec information 192 * apart from the matched one, this data will be passed to the quirk function 193 * to match with the ACPI detected devices 194 * 195 * @num_codecs: number of secondary codecs used in the platform 196 * @codecs: holds the codec IDs 197 * 198 */ 199struct snd_soc_acpi_codecs { 200 int num_codecs; 201 u8 codecs[SND_SOC_ACPI_MAX_CODECS][ACPI_ID_LEN]; 202}; 203 204static inline bool snd_soc_acpi_sof_parent(struct device *dev) 205{ 206 return dev->parent && dev->parent->driver && dev->parent->driver->name && 207 !strncmp(dev->parent->driver->name, "sof-audio-acpi", strlen("sof-audio-acpi")); 208} 209 210#endif