Warning: This file is not a C or C++ file. It does not have highlighting.
1 | /* SPDX-License-Identifier: GPL-2.0-only |
---|---|
2 | * |
3 | * Copyright (C) 2013-15, Intel Corporation |
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 | #include <linux/soundwire/sdw.h> |
13 | #include <sound/soc.h> |
14 | |
15 | struct snd_soc_acpi_package_context { |
16 | char *name; /* package name */ |
17 | int length; /* number of elements */ |
18 | struct acpi_buffer *format; |
19 | struct acpi_buffer *state; |
20 | bool data_valid; |
21 | }; |
22 | |
23 | /* codec name is used in DAIs is i2c-<HID>:00 with HID being 8 chars */ |
24 | #define SND_ACPI_I2C_ID_LEN (4 + ACPI_ID_LEN + 3 + 1) |
25 | |
26 | #if IS_ENABLED(CONFIG_ACPI) |
27 | /* acpi match */ |
28 | struct snd_soc_acpi_mach * |
29 | snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines); |
30 | |
31 | bool snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN], |
32 | struct snd_soc_acpi_package_context *ctx); |
33 | |
34 | /* check all codecs */ |
35 | struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg); |
36 | |
37 | #else |
38 | /* acpi match */ |
39 | static inline struct snd_soc_acpi_mach * |
40 | snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines) |
41 | { |
42 | return NULL; |
43 | } |
44 | |
45 | static inline bool |
46 | snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN], |
47 | struct snd_soc_acpi_package_context *ctx) |
48 | { |
49 | return false; |
50 | } |
51 | |
52 | /* check all codecs */ |
53 | static inline struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg) |
54 | { |
55 | return NULL; |
56 | } |
57 | #endif |
58 | |
59 | /** |
60 | * snd_soc_acpi_mach_params: interface for machine driver configuration |
61 | * |
62 | * @acpi_ipc_irq_index: used for BYT-CR detection |
63 | * @platform: string used for HDAudio codec support |
64 | * @codec_mask: used for HDAudio support |
65 | * @dmic_num: number of SoC- or chipset-attached PDM digital microphones |
66 | * @link_mask: SoundWire links enabled on the board |
67 | * @links: array of SoundWire link _ADR descriptors, null terminated |
68 | * @i2s_link_mask: I2S/TDM links enabled on the board |
69 | * @num_dai_drivers: number of elements in @dai_drivers |
70 | * @dai_drivers: pointer to dai_drivers, used e.g. in nocodec mode |
71 | * @subsystem_vendor: optional PCI SSID vendor value |
72 | * @subsystem_device: optional PCI SSID device value |
73 | * @subsystem_rev: optional PCI SSID revision value |
74 | * @subsystem_id_set: true if a value has been written to |
75 | * subsystem_vendor and subsystem_device. |
76 | * @bt_link_mask: BT offload link enabled on the board |
77 | */ |
78 | struct snd_soc_acpi_mach_params { |
79 | u32 acpi_ipc_irq_index; |
80 | const char *platform; |
81 | u32 codec_mask; |
82 | u32 dmic_num; |
83 | u32 link_mask; |
84 | const struct snd_soc_acpi_link_adr *links; |
85 | u32 i2s_link_mask; |
86 | u32 num_dai_drivers; |
87 | struct snd_soc_dai_driver *dai_drivers; |
88 | unsigned short subsystem_vendor; |
89 | unsigned short subsystem_device; |
90 | unsigned short subsystem_rev; |
91 | bool subsystem_id_set; |
92 | u32 bt_link_mask; |
93 | }; |
94 | |
95 | /** |
96 | * snd_soc_acpi_endpoint - endpoint descriptor |
97 | * @num: endpoint number (mandatory, unique per device) |
98 | * @aggregated: 0 (independent) or 1 (logically grouped) |
99 | * @group_position: zero-based order (only when @aggregated is 1) |
100 | * @group_id: platform-unique group identifier (only when @aggregrated is 1) |
101 | */ |
102 | struct snd_soc_acpi_endpoint { |
103 | u8 num; |
104 | u8 aggregated; |
105 | u8 group_position; |
106 | u8 group_id; |
107 | }; |
108 | |
109 | /** |
110 | * snd_soc_acpi_adr_device - descriptor for _ADR-enumerated device |
111 | * @adr: 64 bit ACPI _ADR value |
112 | * @num_endpoints: number of endpoints for this device |
113 | * @endpoints: array of endpoints |
114 | * @name_prefix: string used for codec controls |
115 | */ |
116 | struct snd_soc_acpi_adr_device { |
117 | const u64 adr; |
118 | const u8 num_endpoints; |
119 | const struct snd_soc_acpi_endpoint *endpoints; |
120 | const char *name_prefix; |
121 | }; |
122 | |
123 | /** |
124 | * snd_soc_acpi_link_adr - ACPI-based list of _ADR enumerated devices |
125 | * @mask: one bit set indicates the link this list applies to |
126 | * @num_adr: ARRAY_SIZE of devices |
127 | * @adr_d: array of devices |
128 | * |
129 | * The number of devices per link can be more than 1, e.g. in SoundWire |
130 | * multi-drop configurations. |
131 | */ |
132 | |
133 | struct snd_soc_acpi_link_adr { |
134 | const u32 mask; |
135 | const u32 num_adr; |
136 | const struct snd_soc_acpi_adr_device *adr_d; |
137 | }; |
138 | |
139 | /* |
140 | * when set the topology uses the -ssp<N> suffix, where N is determined based on |
141 | * BIOS or DMI information |
142 | */ |
143 | #define SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER BIT(0) |
144 | |
145 | /* |
146 | * when more than one SSP is reported in the link mask, use the most significant. |
147 | * This choice was found to be valid on platforms with ES8336 codecs. |
148 | */ |
149 | #define SND_SOC_ACPI_TPLG_INTEL_SSP_MSB BIT(1) |
150 | |
151 | /* |
152 | * when set the topology uses the -dmic<N>ch suffix, where N is determined based on |
153 | * BIOS or DMI information |
154 | */ |
155 | #define SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER BIT(2) |
156 | |
157 | /* |
158 | * when set the speaker amplifier name suffix (i.e. "-max98360a") will be |
159 | * appended to topology file name |
160 | */ |
161 | #define SND_SOC_ACPI_TPLG_INTEL_AMP_NAME BIT(3) |
162 | |
163 | /* |
164 | * when set the headphone codec name suffix (i.e. "-rt5682") will be appended to |
165 | * topology file name |
166 | */ |
167 | #define SND_SOC_ACPI_TPLG_INTEL_CODEC_NAME BIT(4) |
168 | |
169 | /** |
170 | * snd_soc_acpi_mach: ACPI-based machine descriptor. Most of the fields are |
171 | * related to the hardware, except for the firmware and topology file names. |
172 | * A platform supported by legacy and Sound Open Firmware (SOF) would expose |
173 | * all firmware/topology related fields. |
174 | * |
175 | * @id: ACPI ID (usually the codec's) used to find a matching machine driver. |
176 | * @uid: ACPI Unique ID, can be used to disambiguate matches. |
177 | * @comp_ids: list of compatible audio codecs using the same machine driver, |
178 | * firmware and topology |
179 | * @link_mask: describes required board layout, e.g. for SoundWire. |
180 | * @links: array of link _ADR descriptors, null terminated. |
181 | * @drv_name: machine driver name |
182 | * @fw_filename: firmware file name. Used when SOF is not enabled. |
183 | * @tplg_filename: topology file name. Used when SOF is not enabled. |
184 | * @board: board name |
185 | * @machine_quirk: pointer to quirk, usually based on DMI information when |
186 | * ACPI ID alone is not sufficient, wrong or misleading |
187 | * @quirk_data: data used to uniquely identify a machine, usually a list of |
188 | * audio codecs whose presence if checked with ACPI |
189 | * @machine_check: pointer to quirk function. The functionality is similar to |
190 | * the use of @machine_quirk, except that the return value is a boolean: the intent |
191 | * is to skip a machine if the additional hardware/firmware verification invalidates |
192 | * the initial selection in the snd_soc_acpi_mach table. |
193 | * @pdata: intended for platform data or machine specific-ops. This structure |
194 | * is not constant since this field may be updated at run-time |
195 | * @sof_tplg_filename: Sound Open Firmware topology file name, if enabled |
196 | * @tplg_quirk_mask: quirks to select different topology files dynamically |
197 | * @get_function_tplg_files: This is an optional callback, if specified then instead of |
198 | * the single sof_tplg_filename the callback will return the list of function topology |
199 | * files to be loaded. |
200 | * Return value: The number of the files or negative ERRNO. 0 means that the single topology |
201 | * file should be used, no function topology split can be used on the machine. |
202 | * @card: the pointer of the card |
203 | * @mach: the pointer of the machine driver |
204 | * @prefix: the prefix of the topology file name. Typically, it is the path. |
205 | * @tplg_files: the pointer of the array of the topology file names. |
206 | */ |
207 | /* Descriptor for SST ASoC machine driver */ |
208 | struct snd_soc_acpi_mach { |
209 | u8 id[ACPI_ID_LEN]; |
210 | const char *uid; |
211 | const struct snd_soc_acpi_codecs *comp_ids; |
212 | const u32 link_mask; |
213 | const struct snd_soc_acpi_link_adr *links; |
214 | const char *drv_name; |
215 | const char *fw_filename; |
216 | const char *tplg_filename; |
217 | const char *board; |
218 | struct snd_soc_acpi_mach * (*machine_quirk)(void *arg); |
219 | const void *quirk_data; |
220 | bool (*machine_check)(void *arg); |
221 | void *pdata; |
222 | struct snd_soc_acpi_mach_params mach_params; |
223 | const char *sof_tplg_filename; |
224 | const u32 tplg_quirk_mask; |
225 | int (*get_function_tplg_files)(struct snd_soc_card *card, |
226 | const struct snd_soc_acpi_mach *mach, |
227 | const char *prefix, const char ***tplg_files); |
228 | }; |
229 | |
230 | #define SND_SOC_ACPI_MAX_CODECS 3 |
231 | |
232 | /** |
233 | * struct snd_soc_acpi_codecs: Structure to hold secondary codec information |
234 | * apart from the matched one, this data will be passed to the quirk function |
235 | * to match with the ACPI detected devices |
236 | * |
237 | * @num_codecs: number of secondary codecs used in the platform |
238 | * @codecs: holds the codec IDs |
239 | * |
240 | */ |
241 | struct snd_soc_acpi_codecs { |
242 | int num_codecs; |
243 | u8 codecs[SND_SOC_ACPI_MAX_CODECS][ACPI_ID_LEN]; |
244 | }; |
245 | |
246 | static inline bool snd_soc_acpi_sof_parent(struct device *dev) |
247 | { |
248 | return dev->parent && dev->parent->driver && dev->parent->driver->name && |
249 | !strncmp(dev->parent->driver->name, "sof-audio-acpi", strlen("sof-audio-acpi")); |
250 | } |
251 | |
252 | bool snd_soc_acpi_sdw_link_slaves_found(struct device *dev, |
253 | const struct snd_soc_acpi_link_adr *link, |
254 | struct sdw_peripherals *peripherals); |
255 | |
256 | #endif |
257 |
Warning: This file is not a C or C++ file. It does not have highlighting.