xref: /linux/include/sound/sdca_function.h (revision 2aa680df68062e4e0c356ec2aa7100c13654907b)
1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
2 /*
3  * The MIPI SDCA specification is available for public downloads at
4  * https://www.mipi.org/mipi-sdca-v1-0-download
5  *
6  * Copyright(c) 2024 Intel Corporation
7  */
8 
9 #ifndef __SDCA_FUNCTION_H__
10 #define __SDCA_FUNCTION_H__
11 
12 #include <linux/bits.h>
13 #include <linux/types.h>
14 #include <linux/hid.h>
15 
16 struct acpi_table_swft;
17 struct device;
18 struct sdca_entity;
19 struct sdca_function_desc;
20 
21 #define SDCA_NO_INTERRUPT -1
22 
23 /*
24  * The addressing space for SDCA relies on 7 bits for Entities, so a
25  * maximum of 128 Entities per function can be represented.
26  */
27 #define SDCA_MAX_ENTITY_COUNT 128
28 
29 /*
30  * Sanity check on number of initialization writes, can be expanded if needed.
31  */
32 #define SDCA_MAX_INIT_COUNT 2048
33 
34 /*
35  * The Cluster IDs are 16-bit, so a maximum of 65535 Clusters per
36  * function can be represented, however limit this to a slightly
37  * more reasonable value. Can be expanded if needed.
38  */
39 #define SDCA_MAX_CLUSTER_COUNT 256
40 
41 /*
42  * Sanity check on number of channels per Cluster, can be expanded if needed.
43  */
44 #define SDCA_MAX_CHANNEL_COUNT 32
45 
46 /*
47  * Sanity check on number of PDE delays, can be expanded if needed.
48  */
49 #define SDCA_MAX_DELAY_COUNT 256
50 
51 /*
52  * Sanity check on size of affected controls data, can be expanded if needed.
53  */
54 #define SDCA_MAX_AFFECTED_COUNT 2048
55 
56 /**
57  * enum sdca_function_type - SDCA Function Type codes
58  * @SDCA_FUNCTION_TYPE_SMART_AMP: Amplifier with protection features.
59  * @SDCA_FUNCTION_TYPE_SIMPLE_AMP: Subset of SmartAmp.
60  * @SDCA_FUNCTION_TYPE_SMART_MIC: Smart microphone with acoustic triggers.
61  * @SDCA_FUNCTION_TYPE_SIMPLE_MIC: Subset of SmartMic.
62  * @SDCA_FUNCTION_TYPE_SPEAKER_MIC: Combination of SmartMic and SmartAmp.
63  * @SDCA_FUNCTION_TYPE_UAJ: 3.5mm Universal Audio jack.
64  * @SDCA_FUNCTION_TYPE_RJ: Retaskable jack.
65  * @SDCA_FUNCTION_TYPE_SIMPLE_JACK: Subset of UAJ.
66  * @SDCA_FUNCTION_TYPE_HID: Human Interface Device, for e.g. buttons.
67  * @SDCA_FUNCTION_TYPE_COMPANION_AMP: Sources audio from another amp.
68  * @SDCA_FUNCTION_TYPE_IMP_DEF: Implementation-defined function.
69  *
70  * SDCA Function Types from SDCA specification v1.0a Section 5.1.2
71  * all Function types not described are reserved.
72  *
73  * Note that SIMPLE_AMP, SIMPLE_MIC and SIMPLE_JACK Function Types
74  * are NOT defined in SDCA 1.0a, but they were defined in earlier
75  * drafts and are planned for 1.1.
76  */
77 enum sdca_function_type {
78 	SDCA_FUNCTION_TYPE_SMART_AMP			= 0x01,
79 	SDCA_FUNCTION_TYPE_SIMPLE_AMP			= 0x02,
80 	SDCA_FUNCTION_TYPE_SMART_MIC			= 0x03,
81 	SDCA_FUNCTION_TYPE_SIMPLE_MIC			= 0x04,
82 	SDCA_FUNCTION_TYPE_SPEAKER_MIC			= 0x05,
83 	SDCA_FUNCTION_TYPE_UAJ				= 0x06,
84 	SDCA_FUNCTION_TYPE_RJ				= 0x07,
85 	SDCA_FUNCTION_TYPE_SIMPLE_JACK			= 0x08,
86 	SDCA_FUNCTION_TYPE_HID				= 0x0A,
87 	SDCA_FUNCTION_TYPE_COMPANION_AMP		= 0x0B,
88 	SDCA_FUNCTION_TYPE_IMP_DEF			= 0x1F,
89 };
90 
91 /* Human-readable names used for kernel logs and Function device registration/bind */
92 #define	SDCA_FUNCTION_TYPE_SMART_AMP_NAME		"SmartAmp"
93 #define	SDCA_FUNCTION_TYPE_SIMPLE_AMP_NAME		"SimpleAmp"
94 #define	SDCA_FUNCTION_TYPE_SMART_MIC_NAME		"SmartMic"
95 #define	SDCA_FUNCTION_TYPE_SIMPLE_MIC_NAME		"SimpleMic"
96 #define	SDCA_FUNCTION_TYPE_SPEAKER_MIC_NAME		"SpeakerMic"
97 #define	SDCA_FUNCTION_TYPE_UAJ_NAME			"UAJ"
98 #define	SDCA_FUNCTION_TYPE_RJ_NAME			"RJ"
99 #define	SDCA_FUNCTION_TYPE_SIMPLE_NAME			"SimpleJack"
100 #define	SDCA_FUNCTION_TYPE_HID_NAME			"HID"
101 #define	SDCA_FUNCTION_TYPE_COMPANION_AMP_NAME		"CompanionAmp"
102 #define	SDCA_FUNCTION_TYPE_IMP_DEF_NAME			"ImplementationDefined"
103 
104 /**
105  * struct sdca_init_write - a single initialization write
106  * @addr: Register address to be written
107  * @val: Single byte value to be written
108  */
109 struct sdca_init_write {
110 	u32 addr;
111 	u8 val;
112 };
113 
114 /**
115  * define SDCA_CTL_TYPE - create a unique identifier for an SDCA Control
116  * @ent: Entity Type code.
117  * @sel: Control Selector code.
118  *
119  * Sometimes there is a need to identify a type of Control, for example to
120  * determine what name the control should have. SDCA Selectors are reused
121  * across Entity types, as such it is necessary to combine both the Entity
122  * Type and the Control Selector to obtain a unique identifier.
123  */
124 #define SDCA_CTL_TYPE(ent, sel) ((ent) << 8 | (sel))
125 
126 /**
127  * define SDCA_CTL_TYPE_S - static version of SDCA_CTL_TYPE
128  * @ent: Entity name, for example IT, MFPU, etc. this string can be read
129  * from the last characters of the SDCA_ENTITY_TYPE_* macros.
130  * @sel: Control Selector name, for example MIC_BIAS, MUTE, etc. this
131  * string can be read from the last characters of the SDCA_CTL_*_*
132  * macros.
133  *
134  * Short hand to specific a Control type statically for example:
135  * SDCA_CTL_TYPE_S(IT, MIC_BIAS).
136  */
137 #define SDCA_CTL_TYPE_S(ent, sel) SDCA_CTL_TYPE(SDCA_ENTITY_TYPE_##ent, \
138 						SDCA_CTL_##ent##_##sel)
139 
140 /**
141  * enum sdca_messageoffset_range - Column definitions UMP MessageOffset
142  */
143 enum sdca_messageoffset_range {
144 	SDCA_MESSAGEOFFSET_BUFFER_START_ADDRESS		= 0,
145 	SDCA_MESSAGEOFFSET_BUFFER_LENGTH		= 1,
146 	SDCA_MESSAGEOFFSET_UMP_MODE			= 2,
147 	SDCA_MESSAGEOFFSET_NCOLS			= 3,
148 };
149 
150 /**
151  * enum sdca_ump_mode - SDCA UMP Mode
152  */
153 enum sdca_ump_mode {
154 	SDCA_UMP_MODE_DIRECT				= 0x00,
155 	SDCA_UMP_MODE_INDIRECT				= 0x01,
156 };
157 
158 /**
159  * enum sdca_ump_owner - SDCA UMP Owner
160  */
161 enum sdca_ump_owner {
162 	SDCA_UMP_OWNER_HOST				= 0x00,
163 	SDCA_UMP_OWNER_DEVICE				= 0x01,
164 };
165 
166 /**
167  * enum sdca_it_controls - SDCA Controls for Input Terminal
168  *
169  * Control Selectors for Input Terminal from SDCA specification v1.0
170  * section 6.2.1.3.
171  */
172 enum sdca_it_controls {
173 	SDCA_CTL_IT_MIC_BIAS				= 0x03,
174 	SDCA_CTL_IT_USAGE				= 0x04,
175 	SDCA_CTL_IT_LATENCY				= 0x08,
176 	SDCA_CTL_IT_CLUSTERINDEX			= 0x10,
177 	SDCA_CTL_IT_DATAPORT_SELECTOR			= 0x11,
178 	SDCA_CTL_IT_MATCHING_GUID			= 0x12,
179 	SDCA_CTL_IT_KEEP_ALIVE				= 0x13,
180 	SDCA_CTL_IT_NDAI_STREAM				= 0x14,
181 	SDCA_CTL_IT_NDAI_CATEGORY			= 0x15,
182 	SDCA_CTL_IT_NDAI_CODINGTYPE			= 0x16,
183 	SDCA_CTL_IT_NDAI_PACKETTYPE			= 0x17,
184 };
185 
186 /**
187  * enum sdca_ot_controls - SDCA Controls for Output Terminal
188  *
189  * Control Selectors for Output Terminal from SDCA specification v1.0
190  * section 6.2.2.3.
191  */
192 enum sdca_ot_controls {
193 	SDCA_CTL_OT_USAGE				= 0x04,
194 	SDCA_CTL_OT_LATENCY				= 0x08,
195 	SDCA_CTL_OT_DATAPORT_SELECTOR			= 0x11,
196 	SDCA_CTL_OT_MATCHING_GUID			= 0x12,
197 	SDCA_CTL_OT_KEEP_ALIVE				= 0x13,
198 	SDCA_CTL_OT_NDAI_STREAM				= 0x14,
199 	SDCA_CTL_OT_NDAI_CATEGORY			= 0x15,
200 	SDCA_CTL_OT_NDAI_CODINGTYPE			= 0x16,
201 	SDCA_CTL_OT_NDAI_PACKETTYPE			= 0x17,
202 };
203 
204 /**
205  * enum sdca_usage_range - Column definitions for Usage
206  */
207 enum sdca_usage_range {
208 	SDCA_USAGE_NUMBER				= 0,
209 	SDCA_USAGE_CBN					= 1,
210 	SDCA_USAGE_SAMPLE_RATE				= 2,
211 	SDCA_USAGE_SAMPLE_WIDTH				= 3,
212 	SDCA_USAGE_FULL_SCALE				= 4,
213 	SDCA_USAGE_NOISE_FLOOR				= 5,
214 	SDCA_USAGE_TAG					= 6,
215 	SDCA_USAGE_NCOLS				= 7,
216 };
217 
218 /**
219  * enum sdca_dataport_selector_range - Column definitions for DataPort_Selector
220  */
221 enum sdca_dataport_selector_range {
222 	SDCA_DATAPORT_SELECTOR_NCOLS			= 16,
223 	SDCA_DATAPORT_SELECTOR_NROWS			= 4,
224 };
225 
226 /**
227  * enum sdca_mu_controls - SDCA Controls for Mixer Unit
228  *
229  * Control Selectors for Mixer Unit from SDCA specification v1.0
230  * section 6.3.4.2.
231  */
232 enum sdca_mu_controls {
233 	SDCA_CTL_MU_MIXER				= 0x01,
234 	SDCA_CTL_MU_LATENCY				= 0x06,
235 };
236 
237 /**
238  * enum sdca_su_controls - SDCA Controls for Selector Unit
239  *
240  * Control Selectors for Selector Unit from SDCA specification v1.0
241  * section 6.3.8.3.
242  */
243 enum sdca_su_controls {
244 	SDCA_CTL_SU_SELECTOR				= 0x01,
245 	SDCA_CTL_SU_LATENCY				= 0x02,
246 };
247 
248 /**
249  * enum sdca_fu_controls - SDCA Controls for Feature Unit
250  *
251  * Control Selectors for Feature Unit from SDCA specification v1.0
252  * section 6.3.2.3.
253  */
254 enum sdca_fu_controls {
255 	SDCA_CTL_FU_MUTE				= 0x01,
256 	SDCA_CTL_FU_CHANNEL_VOLUME			= 0x02,
257 	SDCA_CTL_FU_AGC					= 0x07,
258 	SDCA_CTL_FU_BASS_BOOST				= 0x09,
259 	SDCA_CTL_FU_LOUDNESS				= 0x0A,
260 	SDCA_CTL_FU_GAIN				= 0x0B,
261 	SDCA_CTL_FU_LATENCY				= 0x10,
262 };
263 
264 /**
265  * enum sdca_volume_range - Column definitions for Q7.8dB volumes/gains
266  */
267 enum sdca_volume_range {
268 	SDCA_VOLUME_LINEAR_MIN				= 0,
269 	SDCA_VOLUME_LINEAR_MAX				= 1,
270 	SDCA_VOLUME_LINEAR_STEP				= 2,
271 	SDCA_VOLUME_LINEAR_NCOLS			= 3,
272 };
273 
274 /**
275  * enum sdca_xu_controls - SDCA Controls for Extension Unit
276  *
277  * Control Selectors for Extension Unit from SDCA specification v1.0
278  * section 6.3.10.3.
279  */
280 enum sdca_xu_controls {
281 	SDCA_CTL_XU_BYPASS				= 0x01,
282 	SDCA_CTL_XU_LATENCY				= 0x06,
283 	SDCA_CTL_XU_XU_ID				= 0x07,
284 	SDCA_CTL_XU_XU_VERSION				= 0x08,
285 	SDCA_CTL_XU_FDL_CURRENTOWNER			= 0x10,
286 	SDCA_CTL_XU_FDL_MESSAGEOFFSET			= 0x12,
287 	SDCA_CTL_XU_FDL_MESSAGELENGTH			= 0x13,
288 	SDCA_CTL_XU_FDL_STATUS				= 0x14,
289 	SDCA_CTL_XU_FDL_SET_INDEX			= 0x15,
290 	SDCA_CTL_XU_FDL_HOST_REQUEST			= 0x16,
291 
292 	/* FDL Status Host->Device bit definitions */
293 	SDCA_CTL_XU_FDLH_TRANSFERRED_CHUNK		= BIT(0),
294 	SDCA_CTL_XU_FDLH_TRANSFERRED_FILE		= BIT(1),
295 	SDCA_CTL_XU_FDLH_SET_IN_PROGRESS		= BIT(2),
296 	SDCA_CTL_XU_FDLH_RESET_ACK			= BIT(4),
297 	SDCA_CTL_XU_FDLH_REQ_ABORT			= BIT(5),
298 	/* FDL Status Device->Host bit definitions */
299 	SDCA_CTL_XU_FDLD_REQ_RESET			= BIT(4),
300 	SDCA_CTL_XU_FDLD_REQ_ABORT			= BIT(5),
301 	SDCA_CTL_XU_FDLD_ACK_TRANSFER			= BIT(6),
302 	SDCA_CTL_XU_FDLD_NEEDS_SET			= BIT(7),
303 };
304 
305 /**
306  * enum sdca_set_index_range - Column definitions UMP SetIndex
307  */
308 enum sdca_fdl_set_index_range {
309 	SDCA_FDL_SET_INDEX_SET_NUMBER			= 0,
310 	SDCA_FDL_SET_INDEX_FILE_SET_ID			= 1,
311 	SDCA_FDL_SET_INDEX_NCOLS			= 2,
312 };
313 
314 /**
315  * enum sdca_cs_controls - SDCA Controls for Clock Source
316  *
317  * Control Selectors for Clock Source from SDCA specification v1.0
318  * section 6.4.1.3.
319  */
320 enum sdca_cs_controls {
321 	SDCA_CTL_CS_CLOCK_VALID				= 0x02,
322 	SDCA_CTL_CS_SAMPLERATEINDEX			= 0x10,
323 };
324 
325 /**
326  * enum sdca_samplerateindex_range - Column definitions for SampleRateIndex
327  */
328 enum sdca_samplerateindex_range {
329 	SDCA_SAMPLERATEINDEX_INDEX			= 0,
330 	SDCA_SAMPLERATEINDEX_RATE			= 1,
331 	SDCA_SAMPLERATEINDEX_NCOLS			= 2,
332 };
333 
334 /**
335  * enum sdca_cx_controls - SDCA Controls for Clock Selector
336  *
337  * Control Selectors for Clock Selector from SDCA specification v1.0
338  * section 6.4.2.3.
339  */
340 enum sdca_cx_controls {
341 	SDCA_CTL_CX_CLOCK_SELECT			= 0x01,
342 };
343 
344 /**
345  * enum sdca_pde_controls - SDCA Controls for Power Domain Entity
346  *
347  * Control Selectors for Power Domain Entity from SDCA specification
348  * v1.0 section 6.5.2.2.
349  */
350 enum sdca_pde_controls {
351 	SDCA_CTL_PDE_REQUESTED_PS			= 0x01,
352 	SDCA_CTL_PDE_ACTUAL_PS				= 0x10,
353 };
354 
355 /**
356  * enum sdca_requested_ps_range - Column definitions for Requested PS
357  */
358 enum sdca_requested_ps_range {
359 	SDCA_REQUESTED_PS_STATE				= 0,
360 	SDCA_REQUESTED_PS_NCOLS				= 1,
361 };
362 
363 /**
364  * enum sdca_ge_controls - SDCA Controls for Group Unit
365  *
366  * Control Selectors for Group Unit from SDCA specification v1.0
367  * section 6.5.1.4.
368  */
369 enum sdca_ge_controls {
370 	SDCA_CTL_GE_SELECTED_MODE			= 0x01,
371 	SDCA_CTL_GE_DETECTED_MODE			= 0x02,
372 };
373 
374 /**
375  * enum sdca_selected_mode_range - Column definitions for Selected Mode
376  */
377 enum sdca_selected_mode_range {
378 	SDCA_SELECTED_MODE_INDEX			= 0,
379 	SDCA_SELECTED_MODE_TERM_TYPE			= 1,
380 	SDCA_SELECTED_MODE_NCOLS			= 2,
381 };
382 
383 /**
384  * enum sdca_detected_mode_values - Predefined GE Detected Mode values
385  */
386 enum sdca_detected_mode_values {
387 	SDCA_DETECTED_MODE_JACK_UNPLUGGED		= 0,
388 	SDCA_DETECTED_MODE_JACK_UNKNOWN			= 1,
389 	SDCA_DETECTED_MODE_DETECTION_IN_PROGRESS	= 2,
390 };
391 
392 /**
393  * enum sdca_spe_controls - SDCA Controls for Security & Privacy Unit
394  *
395  * Control Selectors for Security & Privacy Unit from SDCA
396  * specification v1.0 Section 6.5.3.2.
397  */
398 enum sdca_spe_controls {
399 	SDCA_CTL_SPE_PRIVATE				= 0x01,
400 	SDCA_CTL_SPE_PRIVACY_POLICY			= 0x02,
401 	SDCA_CTL_SPE_PRIVACY_LOCKSTATE			= 0x03,
402 	SDCA_CTL_SPE_PRIVACY_OWNER			= 0x04,
403 	SDCA_CTL_SPE_AUTHTX_CURRENTOWNER		= 0x10,
404 	SDCA_CTL_SPE_AUTHTX_MESSAGEOFFSET		= 0x12,
405 	SDCA_CTL_SPE_AUTHTX_MESSAGELENGTH		= 0x13,
406 	SDCA_CTL_SPE_AUTHRX_CURRENTOWNER		= 0x14,
407 	SDCA_CTL_SPE_AUTHRX_MESSAGEOFFSET		= 0x16,
408 	SDCA_CTL_SPE_AUTHRX_MESSAGELENGTH		= 0x17,
409 };
410 
411 /**
412  * enum sdca_cru_controls - SDCA Controls for Channel Remapping Unit
413  *
414  * Control Selectors for Channel Remapping Unit from SDCA
415  * specification v1.0 Section 6.3.1.3.
416  */
417 enum sdca_cru_controls {
418 	SDCA_CTL_CRU_LATENCY				= 0x06,
419 	SDCA_CTL_CRU_CLUSTERINDEX			= 0x10,
420 };
421 
422 /**
423  * enum sdca_udmpu_controls - SDCA Controls for Up-Down Mixer Processing Unit
424  *
425  * Control Selectors for Up-Down Mixer Processing Unit from SDCA
426  * specification v1.0 Section 6.3.9.3.
427  */
428 enum sdca_udmpu_controls {
429 	SDCA_CTL_UDMPU_LATENCY				= 0x06,
430 	SDCA_CTL_UDMPU_CLUSTERINDEX			= 0x10,
431 	SDCA_CTL_UDMPU_ACOUSTIC_ENERGY_LEVEL_MONITOR	= 0x11,
432 	SDCA_CTL_UDMPU_ULTRASOUND_LOOP_GAIN		= 0x12,
433 	SDCA_CTL_UDMPU_OPAQUESET_0			= 0x18,
434 	SDCA_CTL_UDMPU_OPAQUESET_1			= 0x19,
435 	SDCA_CTL_UDMPU_OPAQUESET_2			= 0x1A,
436 	SDCA_CTL_UDMPU_OPAQUESET_3			= 0x1B,
437 	SDCA_CTL_UDMPU_OPAQUESET_4			= 0x1C,
438 	SDCA_CTL_UDMPU_OPAQUESET_5			= 0x1D,
439 	SDCA_CTL_UDMPU_OPAQUESET_6			= 0x1E,
440 	SDCA_CTL_UDMPU_OPAQUESET_7			= 0x1F,
441 	SDCA_CTL_UDMPU_OPAQUESET_8			= 0x20,
442 	SDCA_CTL_UDMPU_OPAQUESET_9			= 0x21,
443 	SDCA_CTL_UDMPU_OPAQUESET_10			= 0x22,
444 	SDCA_CTL_UDMPU_OPAQUESET_11			= 0x23,
445 	SDCA_CTL_UDMPU_OPAQUESET_12			= 0x24,
446 	SDCA_CTL_UDMPU_OPAQUESET_13			= 0x25,
447 	SDCA_CTL_UDMPU_OPAQUESET_14			= 0x26,
448 	SDCA_CTL_UDMPU_OPAQUESET_15			= 0x27,
449 	SDCA_CTL_UDMPU_OPAQUESET_16			= 0x28,
450 	SDCA_CTL_UDMPU_OPAQUESET_17			= 0x29,
451 	SDCA_CTL_UDMPU_OPAQUESET_18			= 0x2A,
452 	SDCA_CTL_UDMPU_OPAQUESET_19			= 0x2B,
453 	SDCA_CTL_UDMPU_OPAQUESET_20			= 0x2C,
454 	SDCA_CTL_UDMPU_OPAQUESET_21			= 0x2D,
455 	SDCA_CTL_UDMPU_OPAQUESET_22			= 0x2E,
456 	SDCA_CTL_UDMPU_OPAQUESET_23			= 0x2F,
457 };
458 
459 /**
460  * enum sdca_mfpu_controls - SDCA Controls for Multi-Function Processing Unit
461  *
462  * Control Selectors for Multi-Function Processing Unit from SDCA
463  * specification v1.0 Section 6.3.3.4.
464  */
465 enum sdca_mfpu_controls {
466 	SDCA_CTL_MFPU_BYPASS				= 0x01,
467 	SDCA_CTL_MFPU_ALGORITHM_READY			= 0x04,
468 	SDCA_CTL_MFPU_ALGORITHM_ENABLE			= 0x05,
469 	SDCA_CTL_MFPU_LATENCY				= 0x08,
470 	SDCA_CTL_MFPU_ALGORITHM_PREPARE			= 0x09,
471 	SDCA_CTL_MFPU_CLUSTERINDEX			= 0x10,
472 	SDCA_CTL_MFPU_CENTER_FREQUENCY_INDEX		= 0x11,
473 	SDCA_CTL_MFPU_ULTRASOUND_LEVEL			= 0x12,
474 	SDCA_CTL_MFPU_AE_NUMBER				= 0x13,
475 	SDCA_CTL_MFPU_AE_CURRENTOWNER			= 0x14,
476 	SDCA_CTL_MFPU_AE_MESSAGEOFFSET			= 0x16,
477 	SDCA_CTL_MFPU_AE_MESSAGELENGTH			= 0x17,
478 };
479 
480 /**
481  * enum sdca_smpu_controls - SDCA Controls for Smart Mic Processing Unit
482  *
483  * Control Selectors for Smart Mic Processing Unit from SDCA
484  * specification v1.0 Section 6.3.7.3.
485  */
486 enum sdca_smpu_controls {
487 	SDCA_CTL_SMPU_LATENCY				= 0x06,
488 	SDCA_CTL_SMPU_TRIGGER_ENABLE			= 0x10,
489 	SDCA_CTL_SMPU_TRIGGER_STATUS			= 0x11,
490 	SDCA_CTL_SMPU_HIST_BUFFER_MODE			= 0x12,
491 	SDCA_CTL_SMPU_HIST_BUFFER_PREAMBLE		= 0x13,
492 	SDCA_CTL_SMPU_HIST_ERROR			= 0x14,
493 	SDCA_CTL_SMPU_TRIGGER_EXTENSION			= 0x15,
494 	SDCA_CTL_SMPU_TRIGGER_READY			= 0x16,
495 	SDCA_CTL_SMPU_HIST_CURRENTOWNER			= 0x18,
496 	SDCA_CTL_SMPU_HIST_MESSAGEOFFSET		= 0x1A,
497 	SDCA_CTL_SMPU_HIST_MESSAGELENGTH		= 0x1B,
498 	SDCA_CTL_SMPU_DTODTX_CURRENTOWNER		= 0x1C,
499 	SDCA_CTL_SMPU_DTODTX_MESSAGEOFFSET		= 0x1E,
500 	SDCA_CTL_SMPU_DTODTX_MESSAGELENGTH		= 0x1F,
501 	SDCA_CTL_SMPU_DTODRX_CURRENTOWNER		= 0x20,
502 	SDCA_CTL_SMPU_DTODRX_MESSAGEOFFSET		= 0x22,
503 	SDCA_CTL_SMPU_DTODRX_MESSAGELENGTH		= 0x23,
504 };
505 
506 /**
507  * enum sdca_sapu_controls - SDCA Controls for Smart Amp Processing Unit
508  *
509  * Control Selectors for Smart Amp Processing Unit from SDCA
510  * specification v1.0 Section 6.3.6.3.
511  */
512 enum sdca_sapu_controls {
513 	SDCA_CTL_SAPU_LATENCY				= 0x05,
514 	SDCA_CTL_SAPU_PROTECTION_MODE			= 0x10,
515 	SDCA_CTL_SAPU_PROTECTION_STATUS			= 0x11,
516 	SDCA_CTL_SAPU_OPAQUESETREQ_INDEX		= 0x12,
517 	SDCA_CTL_SAPU_DTODTX_CURRENTOWNER		= 0x14,
518 	SDCA_CTL_SAPU_DTODTX_MESSAGEOFFSET		= 0x16,
519 	SDCA_CTL_SAPU_DTODTX_MESSAGELENGTH		= 0x17,
520 	SDCA_CTL_SAPU_DTODRX_CURRENTOWNER		= 0x18,
521 	SDCA_CTL_SAPU_DTODRX_MESSAGEOFFSET		= 0x1A,
522 	SDCA_CTL_SAPU_DTODRX_MESSAGELENGTH		= 0x1B,
523 };
524 
525 /**
526  * enum sdca_ppu_controls - SDCA Controls for Post Processing Unit
527  *
528  * Control Selectors for Post Processing Unit from SDCA specification
529  * v1.0 Section 6.3.5.3.
530  */
531 enum sdca_ppu_controls {
532 	SDCA_CTL_PPU_LATENCY				= 0x06,
533 	SDCA_CTL_PPU_POSTURENUMBER			= 0x10,
534 	SDCA_CTL_PPU_POSTUREEXTENSION			= 0x11,
535 	SDCA_CTL_PPU_HORIZONTALBALANCE			= 0x12,
536 	SDCA_CTL_PPU_VERTICALBALANCE			= 0x13,
537 };
538 
539 /**
540  * enum sdca_tg_controls - SDCA Controls for Tone Generator Entity
541  *
542  * Control Selectors for Tone Generator from SDCA specification v1.0
543  * Section 6.5.4.4.
544  */
545 enum sdca_tg_controls {
546 	SDCA_CTL_TG_TONE_DIVIDER			= 0x10,
547 };
548 
549 /**
550  * enum sdca_hide_controls - SDCA Controls for HIDE Entity
551  *
552  * Control Selectors for HIDE from SDCA specification v1.0 Section
553  * 6.6.1.2.
554  */
555 enum sdca_hide_controls {
556 	SDCA_CTL_HIDE_HIDTX_CURRENTOWNER		= 0x10,
557 	SDCA_CTL_HIDE_HIDTX_MESSAGEOFFSET		= 0x12,
558 	SDCA_CTL_HIDE_HIDTX_MESSAGELENGTH		= 0x13,
559 	SDCA_CTL_HIDE_HIDRX_CURRENTOWNER		= 0x14,
560 	SDCA_CTL_HIDE_HIDRX_MESSAGEOFFSET		= 0x16,
561 	SDCA_CTL_HIDE_HIDRX_MESSAGELENGTH		= 0x17,
562 };
563 
564 /**
565  * enum sdca_entity0_controls - SDCA Controls for Entity 0
566  *
567  * Control Selectors for Entity 0 from SDCA specification v1.0 Section
568  * 6.7.1.1.
569  */
570 enum sdca_entity0_controls {
571 	SDCA_CTL_ENTITY_0_COMMIT_GROUP_MASK		= 0x01,
572 	SDCA_CTL_ENTITY_0_FUNCTION_SDCA_VERSION		= 0x04,
573 	SDCA_CTL_ENTITY_0_FUNCTION_TYPE			= 0x05,
574 	SDCA_CTL_ENTITY_0_FUNCTION_MANUFACTURER_ID	= 0x06,
575 	SDCA_CTL_ENTITY_0_FUNCTION_ID			= 0x07,
576 	SDCA_CTL_ENTITY_0_FUNCTION_VERSION		= 0x08,
577 	SDCA_CTL_ENTITY_0_FUNCTION_EXTENSION_ID		= 0x09,
578 	SDCA_CTL_ENTITY_0_FUNCTION_EXTENSION_VERSION	= 0x0A,
579 	SDCA_CTL_ENTITY_0_FUNCTION_STATUS		= 0x10,
580 	SDCA_CTL_ENTITY_0_FUNCTION_ACTION		= 0x11,
581 	SDCA_CTL_ENTITY_0_MATCHING_GUID			= 0x12,
582 	SDCA_CTL_ENTITY_0_DEVICE_MANUFACTURER_ID	= 0x2C,
583 	SDCA_CTL_ENTITY_0_DEVICE_PART_ID		= 0x2D,
584 	SDCA_CTL_ENTITY_0_DEVICE_VERSION		= 0x2E,
585 	SDCA_CTL_ENTITY_0_DEVICE_SDCA_VERSION		= 0x2F,
586 
587 	/* Function Status Bits */
588 	SDCA_CTL_ENTITY_0_DEVICE_NEWLY_ATTACHED		= BIT(0),
589 	SDCA_CTL_ENTITY_0_INTS_DISABLED_ABNORMALLY	= BIT(1),
590 	SDCA_CTL_ENTITY_0_STREAMING_STOPPED_ABNORMALLY	= BIT(2),
591 	SDCA_CTL_ENTITY_0_FUNCTION_FAULT		= BIT(3),
592 	SDCA_CTL_ENTITY_0_UMP_SEQUENCE_FAULT		= BIT(4),
593 	SDCA_CTL_ENTITY_0_FUNCTION_NEEDS_INITIALIZATION	= BIT(5),
594 	SDCA_CTL_ENTITY_0_FUNCTION_HAS_BEEN_RESET	= BIT(6),
595 	SDCA_CTL_ENTITY_0_FUNCTION_BUSY			= BIT(7),
596 
597 	/* Function Action Bits */
598 	SDCA_CTL_ENTITY_0_RESET_FUNCTION_NOW		= BIT(0),
599 };
600 
601 #define SDCA_CTL_MIC_BIAS_NAME				"Mic Bias"
602 #define SDCA_CTL_USAGE_NAME				"Usage"
603 #define SDCA_CTL_LATENCY_NAME				"Latency"
604 #define SDCA_CTL_CLUSTERINDEX_NAME			"Cluster Index"
605 #define SDCA_CTL_DATAPORT_SELECTOR_NAME			"Dataport Selector"
606 #define SDCA_CTL_MATCHING_GUID_NAME			"Matching GUID"
607 #define SDCA_CTL_KEEP_ALIVE_NAME			"Keep Alive"
608 #define SDCA_CTL_NDAI_STREAM_NAME			"NDAI Stream"
609 #define SDCA_CTL_NDAI_CATEGORY_NAME			"NDAI Category"
610 #define SDCA_CTL_NDAI_CODINGTYPE_NAME			"NDAI Coding Type"
611 #define SDCA_CTL_NDAI_PACKETTYPE_NAME			"NDAI Packet Type"
612 #define SDCA_CTL_MIXER_NAME				"Mixer"
613 #define SDCA_CTL_SELECTOR_NAME				"Selector"
614 #define SDCA_CTL_MUTE_NAME				"Channel"
615 #define SDCA_CTL_CHANNEL_VOLUME_NAME			"Channel Volume"
616 #define SDCA_CTL_AGC_NAME				"AGC"
617 #define SDCA_CTL_BASS_BOOST_NAME			"Bass Boost"
618 #define SDCA_CTL_LOUDNESS_NAME				"Loudness"
619 #define SDCA_CTL_GAIN_NAME				"Gain"
620 #define SDCA_CTL_BYPASS_NAME				"Bypass"
621 #define SDCA_CTL_XU_ID_NAME				"XU ID"
622 #define SDCA_CTL_XU_VERSION_NAME			"XU Version"
623 #define SDCA_CTL_FDL_CURRENTOWNER_NAME			"FDL Current Owner"
624 #define SDCA_CTL_FDL_MESSAGEOFFSET_NAME			"FDL Message Offset"
625 #define SDCA_CTL_FDL_MESSAGELENGTH_NAME			"FDL Message Length"
626 #define SDCA_CTL_FDL_STATUS_NAME			"FDL Status"
627 #define SDCA_CTL_FDL_SET_INDEX_NAME			"FDL Set Index"
628 #define SDCA_CTL_FDL_HOST_REQUEST_NAME			"FDL Host Request"
629 #define SDCA_CTL_CLOCK_VALID_NAME			"Clock Valid"
630 #define SDCA_CTL_SAMPLERATEINDEX_NAME			"Sample Rate Index"
631 #define SDCA_CTL_CLOCK_SELECT_NAME			"Clock Select"
632 #define SDCA_CTL_REQUESTED_PS_NAME			"Requested PS"
633 #define SDCA_CTL_ACTUAL_PS_NAME				"Actual PS"
634 #define SDCA_CTL_SELECTED_MODE_NAME			"Selected Mode"
635 #define SDCA_CTL_DETECTED_MODE_NAME			"Detected Mode"
636 #define SDCA_CTL_PRIVATE_NAME				"Private"
637 #define SDCA_CTL_PRIVACY_POLICY_NAME			"Privacy Policy"
638 #define SDCA_CTL_PRIVACY_LOCKSTATE_NAME			"Privacy Lockstate"
639 #define SDCA_CTL_PRIVACY_OWNER_NAME			"Privacy Owner"
640 #define SDCA_CTL_AUTHTX_CURRENTOWNER_NAME		"AuthTX Current Owner"
641 #define SDCA_CTL_AUTHTX_MESSAGEOFFSET_NAME		"AuthTX Message Offset"
642 #define SDCA_CTL_AUTHTX_MESSAGELENGTH_NAME		"AuthTX Message Length"
643 #define SDCA_CTL_AUTHRX_CURRENTOWNER_NAME		"AuthRX Current Owner"
644 #define SDCA_CTL_AUTHRX_MESSAGEOFFSET_NAME		"AuthRX Message Offset"
645 #define SDCA_CTL_AUTHRX_MESSAGELENGTH_NAME		"AuthRX Message Length"
646 #define SDCA_CTL_ACOUSTIC_ENERGY_LEVEL_MONITOR_NAME	"Acoustic Energy Level Monitor"
647 #define SDCA_CTL_ULTRASOUND_LOOP_GAIN_NAME		"Ultrasound Loop Gain"
648 #define SDCA_CTL_OPAQUESET_0_NAME			"Opaqueset 0"
649 #define SDCA_CTL_OPAQUESET_1_NAME			"Opaqueset 1"
650 #define SDCA_CTL_OPAQUESET_2_NAME			"Opaqueset 2"
651 #define SDCA_CTL_OPAQUESET_3_NAME			"Opaqueset 3"
652 #define SDCA_CTL_OPAQUESET_4_NAME			"Opaqueset 4"
653 #define SDCA_CTL_OPAQUESET_5_NAME			"Opaqueset 5"
654 #define SDCA_CTL_OPAQUESET_6_NAME			"Opaqueset 6"
655 #define SDCA_CTL_OPAQUESET_7_NAME			"Opaqueset 7"
656 #define SDCA_CTL_OPAQUESET_8_NAME			"Opaqueset 8"
657 #define SDCA_CTL_OPAQUESET_9_NAME			"Opaqueset 9"
658 #define SDCA_CTL_OPAQUESET_10_NAME			"Opaqueset 10"
659 #define SDCA_CTL_OPAQUESET_11_NAME			"Opaqueset 11"
660 #define SDCA_CTL_OPAQUESET_12_NAME			"Opaqueset 12"
661 #define SDCA_CTL_OPAQUESET_13_NAME			"Opaqueset 13"
662 #define SDCA_CTL_OPAQUESET_14_NAME			"Opaqueset 14"
663 #define SDCA_CTL_OPAQUESET_15_NAME			"Opaqueset 15"
664 #define SDCA_CTL_OPAQUESET_16_NAME			"Opaqueset 16"
665 #define SDCA_CTL_OPAQUESET_17_NAME			"Opaqueset 17"
666 #define SDCA_CTL_OPAQUESET_18_NAME			"Opaqueset 18"
667 #define SDCA_CTL_OPAQUESET_19_NAME			"Opaqueset 19"
668 #define SDCA_CTL_OPAQUESET_20_NAME			"Opaqueset 20"
669 #define SDCA_CTL_OPAQUESET_21_NAME			"Opaqueset 21"
670 #define SDCA_CTL_OPAQUESET_22_NAME			"Opaqueset 22"
671 #define SDCA_CTL_OPAQUESET_23_NAME			"Opaqueset 23"
672 #define SDCA_CTL_ALGORITHM_READY_NAME			"Algorithm Ready"
673 #define SDCA_CTL_ALGORITHM_ENABLE_NAME			"Algorithm Enable"
674 #define SDCA_CTL_ALGORITHM_PREPARE_NAME			"Algorithm Prepare"
675 #define SDCA_CTL_CENTER_FREQUENCY_INDEX_NAME		"Center Frequency Index"
676 #define SDCA_CTL_ULTRASOUND_LEVEL_NAME			"Ultrasound Level"
677 #define SDCA_CTL_AE_NUMBER_NAME				"AE Number"
678 #define SDCA_CTL_AE_CURRENTOWNER_NAME			"AE Current Owner"
679 #define SDCA_CTL_AE_MESSAGEOFFSET_NAME			"AE Message Offset"
680 #define SDCA_CTL_AE_MESSAGELENGTH_NAME			"AE Message Length"
681 #define SDCA_CTL_TRIGGER_ENABLE_NAME			"Trigger Enable"
682 #define SDCA_CTL_TRIGGER_STATUS_NAME			"Trigger Status"
683 #define SDCA_CTL_HIST_BUFFER_MODE_NAME			"Hist Buffer Mode"
684 #define SDCA_CTL_HIST_BUFFER_PREAMBLE_NAME		"Hist Buffer Preamble"
685 #define SDCA_CTL_HIST_ERROR_NAME			"Hist Error"
686 #define SDCA_CTL_TRIGGER_EXTENSION_NAME			"Trigger Extension"
687 #define SDCA_CTL_TRIGGER_READY_NAME			"Trigger Ready"
688 #define SDCA_CTL_HIST_CURRENTOWNER_NAME			"Hist Current Owner"
689 #define SDCA_CTL_HIST_MESSAGEOFFSET_NAME		"Hist Message Offset"
690 #define SDCA_CTL_HIST_MESSAGELENGTH_NAME		"Hist Message Length"
691 #define SDCA_CTL_DTODTX_CURRENTOWNER_NAME		"DTODTX Current Owner"
692 #define SDCA_CTL_DTODTX_MESSAGEOFFSET_NAME		"DTODTX Message Offset"
693 #define SDCA_CTL_DTODTX_MESSAGELENGTH_NAME		"DTODTX Message Length"
694 #define SDCA_CTL_DTODRX_CURRENTOWNER_NAME		"DTODRX Current Owner"
695 #define SDCA_CTL_DTODRX_MESSAGEOFFSET_NAME		"DTODRX Message Offset"
696 #define SDCA_CTL_DTODRX_MESSAGELENGTH_NAME		"DTODRX Message Length"
697 #define SDCA_CTL_PROTECTION_MODE_NAME			"Protection Mode"
698 #define SDCA_CTL_PROTECTION_STATUS_NAME			"Protection Status"
699 #define SDCA_CTL_OPAQUESETREQ_INDEX_NAME		"Opaqueset Req Index"
700 #define SDCA_CTL_DTODTX_CURRENTOWNER_NAME		"DTODTX Current Owner"
701 #define SDCA_CTL_DTODTX_MESSAGEOFFSET_NAME		"DTODTX Message Offset"
702 #define SDCA_CTL_DTODTX_MESSAGELENGTH_NAME		"DTODTX Message Length"
703 #define SDCA_CTL_DTODRX_CURRENTOWNER_NAME		"DTODRX Current Owner"
704 #define SDCA_CTL_DTODRX_MESSAGEOFFSET_NAME		"DTODRX Message Offset"
705 #define SDCA_CTL_DTODRX_MESSAGELENGTH_NAME		"DTODRX Message Length"
706 #define SDCA_CTL_POSTURENUMBER_NAME			"Posture Number"
707 #define SDCA_CTL_POSTUREEXTENSION_NAME			"Posture Extension"
708 #define SDCA_CTL_HORIZONTALBALANCE_NAME			"Horizontal Balance"
709 #define SDCA_CTL_VERTICALBALANCE_NAME			"Vertical Balance"
710 #define SDCA_CTL_TONE_DIVIDER_NAME			"Tone Divider"
711 #define SDCA_CTL_HIDTX_CURRENTOWNER_NAME		"HIDTX Current Owner"
712 #define SDCA_CTL_HIDTX_MESSAGEOFFSET_NAME		"HIDTX Message Offset"
713 #define SDCA_CTL_HIDTX_MESSAGELENGTH_NAME		"HIDTX Message Length"
714 #define SDCA_CTL_HIDRX_CURRENTOWNER_NAME		"HIDRX Current Owner"
715 #define SDCA_CTL_HIDRX_MESSAGEOFFSET_NAME		"HIDRX Message Offset"
716 #define SDCA_CTL_HIDRX_MESSAGELENGTH_NAME		"HIDRX Message Length"
717 #define SDCA_CTL_COMMIT_GROUP_MASK_NAME			"Commit Group Mask"
718 #define SDCA_CTL_FUNCTION_SDCA_VERSION_NAME		"Function SDCA Version"
719 #define SDCA_CTL_FUNCTION_TYPE_NAME			"Function Type"
720 #define SDCA_CTL_FUNCTION_MANUFACTURER_ID_NAME		"Function Manufacturer ID"
721 #define SDCA_CTL_FUNCTION_ID_NAME			"Function ID"
722 #define SDCA_CTL_FUNCTION_VERSION_NAME			"Function Version"
723 #define SDCA_CTL_FUNCTION_EXTENSION_ID_NAME		"Function Extension ID"
724 #define SDCA_CTL_FUNCTION_EXTENSION_VERSION_NAME	"Function Extension Version"
725 #define SDCA_CTL_FUNCTION_STATUS_NAME			"Function Status"
726 #define SDCA_CTL_FUNCTION_ACTION_NAME			"Function Action"
727 #define SDCA_CTL_DEVICE_MANUFACTURER_ID_NAME		"Device Manufacturer ID"
728 #define SDCA_CTL_DEVICE_PART_ID_NAME			"Device Part ID"
729 #define SDCA_CTL_DEVICE_VERSION_NAME			"Device Version"
730 #define SDCA_CTL_DEVICE_SDCA_VERSION_NAME		"Device SDCA Version"
731 
732 /**
733  * enum sdca_control_datatype - SDCA Control Data Types
734  *
735  * Data Types as described in the SDCA specification v1.0 section
736  * 7.3.
737  */
738 enum sdca_control_datatype {
739 	SDCA_CTL_DATATYPE_ONEBIT,
740 	SDCA_CTL_DATATYPE_INTEGER,
741 	SDCA_CTL_DATATYPE_SPEC_ENCODED_VALUE,
742 	SDCA_CTL_DATATYPE_BCD,
743 	SDCA_CTL_DATATYPE_Q7P8DB,
744 	SDCA_CTL_DATATYPE_BYTEINDEX,
745 	SDCA_CTL_DATATYPE_POSTURENUMBER,
746 	SDCA_CTL_DATATYPE_DP_INDEX,
747 	SDCA_CTL_DATATYPE_BITINDEX,
748 	SDCA_CTL_DATATYPE_BITMAP,
749 	SDCA_CTL_DATATYPE_GUID,
750 	SDCA_CTL_DATATYPE_IMPDEF,
751 };
752 
753 /**
754  * enum sdca_access_mode - SDCA Control access mode
755  *
756  * Access modes as described in the SDCA specification v1.0 section
757  * 7.1.8.2.
758  */
759 enum sdca_access_mode {
760 	SDCA_ACCESS_MODE_RW				= 0x0,
761 	SDCA_ACCESS_MODE_DUAL				= 0x1,
762 	SDCA_ACCESS_MODE_RW1C				= 0x2,
763 	SDCA_ACCESS_MODE_RO				= 0x3,
764 	SDCA_ACCESS_MODE_RW1S				= 0x4,
765 	SDCA_ACCESS_MODE_DC				= 0x5,
766 };
767 
768 /**
769  * enum sdca_access_layer - SDCA Control access layer
770  *
771  * Access layers as described in the SDCA specification v1.0 section
772  * 7.1.9.
773  */
774 enum sdca_access_layer {
775 	SDCA_ACCESS_LAYER_USER				= 1 << 0,
776 	SDCA_ACCESS_LAYER_APPLICATION			= 1 << 1,
777 	SDCA_ACCESS_LAYER_CLASS				= 1 << 2,
778 	SDCA_ACCESS_LAYER_PLATFORM			= 1 << 3,
779 	SDCA_ACCESS_LAYER_DEVICE			= 1 << 4,
780 	SDCA_ACCESS_LAYER_EXTENSION			= 1 << 5,
781 };
782 
783 /**
784  * struct sdca_control_range - SDCA Control range table
785  * @cols: Number of columns in the range table.
786  * @rows: Number of rows in the range table.
787  * @data: Array of values contained in the range table.
788  */
789 struct sdca_control_range {
790 	unsigned int cols;
791 	unsigned int rows;
792 	u32 *data;
793 };
794 
795 /**
796  * struct sdca_control - information for one SDCA Control
797  * @label: Name for the Control, from SDCA Specification v1.0, section 7.1.7.
798  * @sel: Identifier used for addressing.
799  * @nbits: Number of bits used in the Control.
800  * @values: Holds the Control value for constants and defaults.
801  * @cn_list: A bitmask showing the valid Control Numbers within this Control,
802  * Control Numbers typically represent channels.
803  * @interrupt_position: SCDA interrupt line that will alert to changes on this
804  * Control.
805  * @type: Format of the data in the Control.
806  * @range: Buffer describing valid range of values for the Control.
807  * @mode: Access mode of the Control.
808  * @layers: Bitmask of access layers of the Control.
809  * @deferrable: Indicates if the access to the Control can be deferred.
810  * @has_default: Indicates the Control has a default value to be written.
811  * @has_fixed: Indicates the Control only supports a single value.
812  */
813 struct sdca_control {
814 	const char *label;
815 	int sel;
816 
817 	int nbits;
818 	int *values;
819 	u64 cn_list;
820 	int interrupt_position;
821 
822 	enum sdca_control_datatype type;
823 	struct sdca_control_range range;
824 	enum sdca_access_mode mode;
825 	u8 layers;
826 
827 	bool deferrable;
828 	bool is_volatile;
829 	bool has_default;
830 	bool has_fixed;
831 };
832 
833 /**
834  * enum sdca_terminal_type - SDCA Terminal Types
835  *
836  * Indicate what a Terminal Entity is used for, see in section 6.2.3
837  * of the SDCA v1.0 specification.
838  */
839 enum sdca_terminal_type {
840 	/* Table 77 - Data Port*/
841 	SDCA_TERM_TYPE_GENERIC				= 0x101,
842 	SDCA_TERM_TYPE_ULTRASOUND			= 0x180,
843 	SDCA_TERM_TYPE_CAPTURE_DIRECT_PCM_MIC		= 0x181,
844 	SDCA_TERM_TYPE_RAW_PDM_MIC			= 0x182,
845 	SDCA_TERM_TYPE_SPEECH				= 0x183,
846 	SDCA_TERM_TYPE_VOICE				= 0x184,
847 	SDCA_TERM_TYPE_SECONDARY_PCM_MIC		= 0x185,
848 	SDCA_TERM_TYPE_ACOUSTIC_CONTEXT_AWARENESS	= 0x186,
849 	SDCA_TERM_TYPE_DTOD_STREAM			= 0x187,
850 	SDCA_TERM_TYPE_REFERENCE_STREAM			= 0x188,
851 	SDCA_TERM_TYPE_SENSE_CAPTURE			= 0x189,
852 	SDCA_TERM_TYPE_STREAMING_MIC			= 0x18A,
853 	SDCA_TERM_TYPE_OPTIMIZATION_STREAM		= 0x190,
854 	SDCA_TERM_TYPE_PDM_RENDER_STREAM		= 0x191,
855 	SDCA_TERM_TYPE_COMPANION_DATA			= 0x192,
856 	/* Table 78 - Transducer */
857 	SDCA_TERM_TYPE_MICROPHONE_TRANSDUCER		= 0x201,
858 	SDCA_TERM_TYPE_MICROPHONE_ARRAY_TRANSDUCER	= 0x205,
859 	SDCA_TERM_TYPE_PRIMARY_FULL_RANGE_SPEAKER	= 0x380,
860 	SDCA_TERM_TYPE_PRIMARY_LFE_SPEAKER		= 0x381,
861 	SDCA_TERM_TYPE_PRIMARY_TWEETER_SPEAKER		= 0x382,
862 	SDCA_TERM_TYPE_PRIMARY_ULTRASOUND_SPEAKER	= 0x383,
863 	SDCA_TERM_TYPE_SECONDARY_FULL_RANGE_SPEAKER	= 0x390,
864 	SDCA_TERM_TYPE_SECONDARY_LFE_SPEAKER		= 0x391,
865 	SDCA_TERM_TYPE_SECONDARY_TWEETER_SPEAKER	= 0x392,
866 	SDCA_TERM_TYPE_SECONDARY_ULTRASOUND_SPEAKER	= 0x393,
867 	SDCA_TERM_TYPE_TERTIARY_FULL_RANGE_SPEAKER	= 0x3A0,
868 	SDCA_TERM_TYPE_TERTIARY_LFE_SPEAKER		= 0x3A1,
869 	SDCA_TERM_TYPE_TERTIARY_TWEETER_SPEAKER		= 0x3A2,
870 	SDCA_TERM_TYPE_TERTIARY_ULTRASOUND_SPEAKER	= 0x3A3,
871 	SDCA_TERM_TYPE_SPDIF				= 0x605,
872 	SDCA_TERM_TYPE_NDAI_DISPLAY_AUDIO		= 0x610,
873 	SDCA_TERM_TYPE_NDAI_USB				= 0x612,
874 	SDCA_TERM_TYPE_NDAI_BLUETOOTH_MAIN		= 0x614,
875 	SDCA_TERM_TYPE_NDAI_BLUETOOTH_ALTERNATE		= 0x615,
876 	SDCA_TERM_TYPE_NDAI_BLUETOOTH_BOTH		= 0x616,
877 	SDCA_TERM_TYPE_LINEIN_STEREO			= 0x680,
878 	SDCA_TERM_TYPE_LINEIN_FRONT_LR			= 0x681,
879 	SDCA_TERM_TYPE_LINEIN_CENTER_LFE		= 0x682,
880 	SDCA_TERM_TYPE_LINEIN_SURROUND_LR		= 0x683,
881 	SDCA_TERM_TYPE_LINEIN_REAR_LR			= 0x684,
882 	SDCA_TERM_TYPE_LINEOUT_STEREO			= 0x690,
883 	SDCA_TERM_TYPE_LINEOUT_FRONT_LR			= 0x691,
884 	SDCA_TERM_TYPE_LINEOUT_CENTER_LFE		= 0x692,
885 	SDCA_TERM_TYPE_LINEOUT_SURROUND_LR		= 0x693,
886 	SDCA_TERM_TYPE_LINEOUT_REAR_LR			= 0x694,
887 	SDCA_TERM_TYPE_MIC_JACK				= 0x6A0,
888 	SDCA_TERM_TYPE_STEREO_JACK			= 0x6B0,
889 	SDCA_TERM_TYPE_FRONT_LR_JACK			= 0x6B1,
890 	SDCA_TERM_TYPE_CENTER_LFE_JACK			= 0x6B2,
891 	SDCA_TERM_TYPE_SURROUND_LR_JACK			= 0x6B3,
892 	SDCA_TERM_TYPE_REAR_LR_JACK			= 0x6B4,
893 	SDCA_TERM_TYPE_HEADPHONE_JACK			= 0x6C0,
894 	SDCA_TERM_TYPE_HEADSET_JACK			= 0x6D0,
895 	/* Table 79 - System */
896 	SDCA_TERM_TYPE_SENSE_DATA			= 0x280,
897 	SDCA_TERM_TYPE_PRIVACY_SIGNALING		= 0x741,
898 	SDCA_TERM_TYPE_PRIVACY_INDICATORS		= 0x747,
899 };
900 
901 #define SDCA_TERM_TYPE_LINEIN_STEREO_NAME		"LineIn Stereo"
902 #define SDCA_TERM_TYPE_LINEIN_FRONT_LR_NAME		"LineIn Front-LR"
903 #define SDCA_TERM_TYPE_LINEIN_CENTER_LFE_NAME		"LineIn Center-LFE"
904 #define SDCA_TERM_TYPE_LINEIN_SURROUND_LR_NAME		"LineIn Surround-LR"
905 #define SDCA_TERM_TYPE_LINEIN_REAR_LR_NAME		"LineIn Rear-LR"
906 #define SDCA_TERM_TYPE_LINEOUT_STEREO_NAME		"LineOut Stereo"
907 #define SDCA_TERM_TYPE_LINEOUT_FRONT_LR_NAME		"LineOut Front-LR"
908 #define SDCA_TERM_TYPE_LINEOUT_CENTER_LFE_NAME		"LineOut Center-LFE"
909 #define SDCA_TERM_TYPE_LINEOUT_SURROUND_LR_NAME		"LineOut Surround-LR"
910 #define SDCA_TERM_TYPE_LINEOUT_REAR_LR_NAME		"LineOut Rear-LR"
911 #define SDCA_TERM_TYPE_MIC_JACK_NAME			"Microphone"
912 #define SDCA_TERM_TYPE_STEREO_JACK_NAME			"Speaker Stereo"
913 #define SDCA_TERM_TYPE_FRONT_LR_JACK_NAME		"Speaker Front-LR"
914 #define SDCA_TERM_TYPE_CENTER_LFE_JACK_NAME		"Speaker Center-LFE"
915 #define SDCA_TERM_TYPE_SURROUND_LR_JACK_NAME		"Speaker Surround-LR"
916 #define SDCA_TERM_TYPE_REAR_LR_JACK_NAME		"Speaker Rear-LR"
917 #define SDCA_TERM_TYPE_HEADPHONE_JACK_NAME		"Headphone"
918 #define SDCA_TERM_TYPE_HEADSET_JACK_NAME		"Headset"
919 
920 /**
921  * enum sdca_connector_type - SDCA Connector Types
922  *
923  * Indicate the type of Connector that a Terminal Entity represents,
924  * see section 6.2.4 of the SDCA v1.0 specification.
925  */
926 enum sdca_connector_type {
927 	SDCA_CONN_TYPE_UNKNOWN				= 0x00,
928 	SDCA_CONN_TYPE_2P5MM_JACK			= 0x01,
929 	SDCA_CONN_TYPE_3P5MM_JACK			= 0x02,
930 	SDCA_CONN_TYPE_QUARTER_INCH_JACK		= 0x03,
931 	SDCA_CONN_TYPE_XLR				= 0x05,
932 	SDCA_CONN_TYPE_SPDIF_OPTICAL			= 0x06,
933 	SDCA_CONN_TYPE_RCA				= 0x07,
934 	SDCA_CONN_TYPE_DIN				= 0x0E,
935 	SDCA_CONN_TYPE_MINI_DIN				= 0x0F,
936 	SDCA_CONN_TYPE_EIAJ_OPTICAL			= 0x13,
937 	SDCA_CONN_TYPE_HDMI				= 0x14,
938 	SDCA_CONN_TYPE_DISPLAYPORT			= 0x17,
939 	SDCA_CONN_TYPE_LIGHTNING			= 0x1B,
940 	SDCA_CONN_TYPE_USB_C				= 0x1E,
941 	SDCA_CONN_TYPE_OTHER				= 0xFF,
942 };
943 
944 /**
945  * struct sdca_entity_iot - information specific to Input/Output Entities
946  * @clock: Pointer to the Entity providing this Terminal's clock.
947  * @type: Usage of the Terminal Entity.
948  * @connector: Physical Connector of the Terminal Entity.
949  * @reference: Physical Jack number of the Terminal Entity.
950  * @num_transducer: Number of transducers attached to the Terminal Entity.
951  * @is_dataport: Boolean indicating if this Terminal represents a Dataport.
952  */
953 struct sdca_entity_iot {
954 	struct sdca_entity *clock;
955 
956 	enum sdca_terminal_type type;
957 	enum sdca_connector_type connector;
958 	int reference;
959 	int num_transducer;
960 
961 	bool is_dataport;
962 };
963 
964 /**
965  * enum sdca_clock_type - SDCA Clock Types
966  *
967  * Indicate the synchronicity of an Clock Entity, see section 6.4.1.3
968  * of the SDCA v1.0 specification.
969  */
970 enum sdca_clock_type {
971 	SDCA_CLOCK_TYPE_EXTERNAL			= 0x00,
972 	SDCA_CLOCK_TYPE_INTERNAL_ASYNC			= 0x01,
973 	SDCA_CLOCK_TYPE_INTERNAL_SYNC			= 0x02,
974 	SDCA_CLOCK_TYPE_INTERNAL_SOURCE_SYNC		= 0x03,
975 };
976 
977 /**
978  * struct sdca_entity_cs - information specific to Clock Source Entities
979  * @type: Synchronicity of the Clock Source.
980  * @max_delay: The maximum delay in microseconds before the clock is stable.
981  */
982 struct sdca_entity_cs {
983 	enum sdca_clock_type type;
984 	unsigned int max_delay;
985 };
986 
987 /**
988  * enum sdca_pde_power_state - SDCA Power States
989  *
990  * SDCA Power State values from SDCA specification v1.0 Section 7.12.4.
991  */
992 enum sdca_pde_power_state {
993 	SDCA_PDE_PS0					= 0x0,
994 	SDCA_PDE_PS1					= 0x1,
995 	SDCA_PDE_PS2					= 0x2,
996 	SDCA_PDE_PS3					= 0x3,
997 	SDCA_PDE_PS4					= 0x4,
998 };
999 
1000 /**
1001  * struct sdca_pde_delay - describes the delay changing between 2 power states
1002  * @from_ps: The power state being exited.
1003  * @to_ps: The power state being entered.
1004  * @us: The delay in microseconds switching between the two states.
1005  */
1006 struct sdca_pde_delay {
1007 	int from_ps;
1008 	int to_ps;
1009 	unsigned int us;
1010 };
1011 
1012 /**
1013  * struct sdca_entity_pde - information specific to Power Domain Entities
1014  * @managed: Dynamically allocated array pointing to each Entity
1015  * controlled by this PDE.
1016  * @max_delay: Dynamically allocated array of delays for switching
1017  * between power states.
1018  * @num_managed: Number of Entities controlled by this PDE.
1019  * @num_max_delay: Number of delays specified for state changes.
1020  */
1021 struct sdca_entity_pde {
1022 	struct sdca_entity **managed;
1023 	struct sdca_pde_delay *max_delay;
1024 	int num_managed;
1025 	int num_max_delay;
1026 };
1027 
1028 /**
1029  * enum sdca_entity_type - SDCA Entity Type codes
1030  * @SDCA_ENTITY_TYPE_ENTITY_0: Entity 0, not actually from the
1031  * specification but useful internally as an Entity structure
1032  * is allocated for Entity 0, to hold Entity 0 controls.
1033  * @SDCA_ENTITY_TYPE_IT: Input Terminal.
1034  * @SDCA_ENTITY_TYPE_OT: Output Terminal.
1035  * @SDCA_ENTITY_TYPE_MU: Mixer Unit.
1036  * @SDCA_ENTITY_TYPE_SU: Selector Unit.
1037  * @SDCA_ENTITY_TYPE_FU: Feature Unit.
1038  * @SDCA_ENTITY_TYPE_XU: Extension Unit.
1039  * @SDCA_ENTITY_TYPE_CS: Clock Source.
1040  * @SDCA_ENTITY_TYPE_CX: Clock selector.
1041  * @SDCA_ENTITY_TYPE_PDE: Power-Domain Entity.
1042  * @SDCA_ENTITY_TYPE_GE: Group Entity.
1043  * @SDCA_ENTITY_TYPE_SPE: Security & Privacy Entity.
1044  * @SDCA_ENTITY_TYPE_CRU: Channel Remapping Unit.
1045  * @SDCA_ENTITY_TYPE_UDMPU: Up-Down Mixer Processing Unit.
1046  * @SDCA_ENTITY_TYPE_MFPU: Multi-Function Processing Unit.
1047  * @SDCA_ENTITY_TYPE_SMPU: Smart Microphone Processing Unit.
1048  * @SDCA_ENTITY_TYPE_SAPU: Smart Amp Processing Unit.
1049  * @SDCA_ENTITY_TYPE_PPU: Posture Processing Unit.
1050  * @SDCA_ENTITY_TYPE_TG: Tone Generator.
1051  * @SDCA_ENTITY_TYPE_HIDE: Human Interface Device Entity.
1052  *
1053  * SDCA Entity Types from SDCA specification v1.0 Section 6.1.2
1054  * all Entity Types not described are reserved.
1055  */
1056 enum sdca_entity_type {
1057 	SDCA_ENTITY_TYPE_ENTITY_0			= 0x00,
1058 	SDCA_ENTITY_TYPE_IT				= 0x02,
1059 	SDCA_ENTITY_TYPE_OT				= 0x03,
1060 	SDCA_ENTITY_TYPE_MU				= 0x05,
1061 	SDCA_ENTITY_TYPE_SU				= 0x06,
1062 	SDCA_ENTITY_TYPE_FU				= 0x07,
1063 	SDCA_ENTITY_TYPE_XU				= 0x0A,
1064 	SDCA_ENTITY_TYPE_CS				= 0x0B,
1065 	SDCA_ENTITY_TYPE_CX				= 0x0C,
1066 	SDCA_ENTITY_TYPE_PDE				= 0x11,
1067 	SDCA_ENTITY_TYPE_GE				= 0x12,
1068 	SDCA_ENTITY_TYPE_SPE				= 0x13,
1069 	SDCA_ENTITY_TYPE_CRU				= 0x20,
1070 	SDCA_ENTITY_TYPE_UDMPU				= 0x21,
1071 	SDCA_ENTITY_TYPE_MFPU				= 0x22,
1072 	SDCA_ENTITY_TYPE_SMPU				= 0x23,
1073 	SDCA_ENTITY_TYPE_SAPU				= 0x24,
1074 	SDCA_ENTITY_TYPE_PPU				= 0x25,
1075 	SDCA_ENTITY_TYPE_TG				= 0x30,
1076 	SDCA_ENTITY_TYPE_HIDE				= 0x31,
1077 };
1078 
1079 /**
1080  * struct sdca_ge_control - control entry in the affected controls list
1081  * @id: Entity ID of the Control affected.
1082  * @sel: Control Selector of the Control affected.
1083  * @cn: Control Number of the Control affected.
1084  * @val: Value written to Control for this Mode.
1085  */
1086 struct sdca_ge_control {
1087 	int id;
1088 	int sel;
1089 	int cn;
1090 	int val;
1091 };
1092 
1093 /**
1094  * struct sdca_ge_mode - mode entry in the affected controls list
1095  * @controls: Dynamically allocated array of controls written for this Mode.
1096  * @num_controls: Number of controls written in this Mode.
1097  * @val: GE Selector Mode value.
1098  */
1099 struct sdca_ge_mode {
1100 	struct sdca_ge_control *controls;
1101 	int num_controls;
1102 	int val;
1103 };
1104 
1105 /**
1106  * struct sdca_entity_ge - information specific to Group Entities
1107  * @kctl: ALSA control pointer that can be used by linked Entities.
1108  * @modes: Dynamically allocated array of Modes and the Controls written
1109  * in each mode.
1110  * @num_modes: Number of Modes.
1111  */
1112 struct sdca_entity_ge {
1113 	struct snd_kcontrol_new *kctl;
1114 	struct sdca_ge_mode *modes;
1115 	int num_modes;
1116 };
1117 
1118 /**
1119  * struct sdca_entity_hide - information specific to HIDE Entities
1120  * @hid: HID device structure
1121  * @num_hidtx_ids: number of HIDTx Report ID
1122  * @num_hidrx_ids: number of HIDRx Report ID
1123  * @hidtx_ids: HIDTx Report ID
1124  * @hidrx_ids: HIDRx Report ID
1125  * @af_number_list: which Audio Function Numbers within this Device are
1126  * sending/receiving the messages in this HIDE
1127  * @hide_reside_function_num: indicating which Audio Function Numbers
1128  * within this Device
1129  * @max_delay: the maximum time in microseconds allowed for the Device
1130  * to change the ownership from Device to Host
1131  * @hid_report_desc: HID Report Descriptor for the HIDE Entity
1132  * @hid_desc: HID descriptor for the HIDE Entity
1133  */
1134 struct sdca_entity_hide {
1135 	struct hid_device *hid;
1136 	unsigned int *hidtx_ids;
1137 	unsigned int *hidrx_ids;
1138 	int num_hidtx_ids;
1139 	int num_hidrx_ids;
1140 	unsigned int af_number_list[SDCA_MAX_FUNCTION_COUNT];
1141 	unsigned int hide_reside_function_num;
1142 	unsigned int max_delay;
1143 	unsigned char *hid_report_desc;
1144 	struct hid_descriptor hid_desc;
1145 };
1146 
1147 /**
1148  * enum sdca_xu_reset_machanism - SDCA FDL Resets
1149  */
1150 enum sdca_xu_reset_mechanism {
1151 	SDCA_XU_RESET_FUNCTION				= 0x0,
1152 	SDCA_XU_RESET_DEVICE				= 0x1,
1153 	SDCA_XU_RESET_BUS				= 0x2,
1154 };
1155 
1156 /**
1157  * struct sdca_entity_xu - information specific to XU Entities
1158  * @max_delay: the maximum time in microseconds allowed for the Device
1159  * to change the ownership from Device to Host
1160  * @reset_mechanism: indicates the type of reset that can be requested
1161  * the end of an FDL.
1162  */
1163 struct sdca_entity_xu {
1164 	unsigned int max_delay;
1165 	enum sdca_xu_reset_mechanism reset_mechanism;
1166 };
1167 
1168 /**
1169  * struct sdca_entity - information for one SDCA Entity
1170  * @label: String such as "OT 12".
1171  * @id: Identifier used for addressing.
1172  * @type: Type code for the Entity.
1173  * @group: Pointer to Group Entity controlling this one, NULL if N/A.
1174  * @sources: Dynamically allocated array pointing to each input Entity
1175  * connected to this Entity.
1176  * @controls: Dynamically allocated array of Controls.
1177  * @num_sources: Number of sources for the Entity.
1178  * @num_controls: Number of Controls for the Entity.
1179  * @iot: Input/Output Terminal specific Entity properties.
1180  * @cs: Clock Source specific Entity properties.
1181  * @pde: Power Domain Entity specific Entity properties.
1182  * @ge: Group Entity specific Entity properties.
1183  * @hide: HIDE Entity specific Entity properties.
1184  * @xu: XU Entity specific Entity properties.
1185  */
1186 struct sdca_entity {
1187 	const char *label;
1188 	int id;
1189 	enum sdca_entity_type type;
1190 
1191 	struct sdca_entity *group;
1192 	struct sdca_entity **sources;
1193 	struct sdca_control *controls;
1194 	int num_sources;
1195 	int num_controls;
1196 	union {
1197 		struct sdca_entity_iot iot;
1198 		struct sdca_entity_cs cs;
1199 		struct sdca_entity_pde pde;
1200 		struct sdca_entity_ge ge;
1201 		struct sdca_entity_hide hide;
1202 		struct sdca_entity_xu xu;
1203 	};
1204 };
1205 
1206 /**
1207  * enum sdca_channel_purpose - SDCA Channel Purpose code
1208  *
1209  * Channel Purpose codes as described in the SDCA specification v1.0
1210  * section 11.4.3.
1211  */
1212 enum sdca_channel_purpose {
1213 	/* Table 210 - Purpose */
1214 	SDCA_CHAN_PURPOSE_GENERIC_AUDIO			= 0x01,
1215 	SDCA_CHAN_PURPOSE_VOICE				= 0x02,
1216 	SDCA_CHAN_PURPOSE_SPEECH			= 0x03,
1217 	SDCA_CHAN_PURPOSE_AMBIENT			= 0x04,
1218 	SDCA_CHAN_PURPOSE_REFERENCE			= 0x05,
1219 	SDCA_CHAN_PURPOSE_ULTRASOUND			= 0x06,
1220 	SDCA_CHAN_PURPOSE_SENSE				= 0x08,
1221 	SDCA_CHAN_PURPOSE_SILENCE			= 0xFE,
1222 	SDCA_CHAN_PURPOSE_NON_AUDIO			= 0xFF,
1223 	/* Table 211 - Amp Sense */
1224 	SDCA_CHAN_PURPOSE_SENSE_V1			= 0x09,
1225 	SDCA_CHAN_PURPOSE_SENSE_V2			= 0x0A,
1226 	SDCA_CHAN_PURPOSE_SENSE_V12_INTERLEAVED		= 0x10,
1227 	SDCA_CHAN_PURPOSE_SENSE_V21_INTERLEAVED		= 0x11,
1228 	SDCA_CHAN_PURPOSE_SENSE_V12_PACKED		= 0x12,
1229 	SDCA_CHAN_PURPOSE_SENSE_V21_PACKED		= 0x13,
1230 	SDCA_CHAN_PURPOSE_SENSE_V1212_INTERLEAVED	= 0x14,
1231 	SDCA_CHAN_PURPOSE_SENSE_V2121_INTERLEAVED	= 0x15,
1232 	SDCA_CHAN_PURPOSE_SENSE_V1122_INTERLEAVED	= 0x16,
1233 	SDCA_CHAN_PURPOSE_SENSE_V2211_INTERLEAVED	= 0x17,
1234 	SDCA_CHAN_PURPOSE_SENSE_V1212_PACKED		= 0x18,
1235 	SDCA_CHAN_PURPOSE_SENSE_V2121_PACKED		= 0x19,
1236 	SDCA_CHAN_PURPOSE_SENSE_V1122_PACKED		= 0x1A,
1237 	SDCA_CHAN_PURPOSE_SENSE_V2211_PACKED		= 0x1B,
1238 };
1239 
1240 /**
1241  * enum sdca_channel_relationship - SDCA Channel Relationship code
1242  *
1243  * Channel Relationship codes as described in the SDCA specification
1244  * v1.0 section 11.4.2.
1245  */
1246 enum sdca_channel_relationship {
1247 	/* Table 206 - Streaming */
1248 	SDCA_CHAN_REL_UNDEFINED				= 0x00,
1249 	SDCA_CHAN_REL_GENERIC_MONO			= 0x01,
1250 	SDCA_CHAN_REL_GENERIC_LEFT			= 0x02,
1251 	SDCA_CHAN_REL_GENERIC_RIGHT			= 0x03,
1252 	SDCA_CHAN_REL_GENERIC_TOP			= 0x48,
1253 	SDCA_CHAN_REL_GENERIC_BOTTOM			= 0x49,
1254 	SDCA_CHAN_REL_CAPTURE_DIRECT			= 0x4E,
1255 	SDCA_CHAN_REL_RENDER_DIRECT			= 0x4F,
1256 	SDCA_CHAN_REL_FRONT_LEFT			= 0x0B,
1257 	SDCA_CHAN_REL_FRONT_RIGHT			= 0x0C,
1258 	SDCA_CHAN_REL_FRONT_CENTER			= 0x0D,
1259 	SDCA_CHAN_REL_SIDE_LEFT				= 0x12,
1260 	SDCA_CHAN_REL_SIDE_RIGHT			= 0x13,
1261 	SDCA_CHAN_REL_BACK_LEFT				= 0x16,
1262 	SDCA_CHAN_REL_BACK_RIGHT			= 0x17,
1263 	SDCA_CHAN_REL_LOW_FREQUENCY_EFFECTS		= 0x43,
1264 	SDCA_CHAN_REL_SOUNDWIRE_MIC			= 0x55,
1265 	SDCA_CHAN_REL_SENSE_TRANSDUCER_1		= 0x58,
1266 	SDCA_CHAN_REL_SENSE_TRANSDUCER_2		= 0x59,
1267 	SDCA_CHAN_REL_SENSE_TRANSDUCER_12		= 0x5A,
1268 	SDCA_CHAN_REL_SENSE_TRANSDUCER_21		= 0x5B,
1269 	SDCA_CHAN_REL_ECHOREF_NONE			= 0x70,
1270 	SDCA_CHAN_REL_ECHOREF_1				= 0x71,
1271 	SDCA_CHAN_REL_ECHOREF_2				= 0x72,
1272 	SDCA_CHAN_REL_ECHOREF_3				= 0x73,
1273 	SDCA_CHAN_REL_ECHOREF_4				= 0x74,
1274 	SDCA_CHAN_REL_ECHOREF_ALL			= 0x75,
1275 	SDCA_CHAN_REL_ECHOREF_LFE_ALL			= 0x76,
1276 	/* Table 207 - Speaker */
1277 	SDCA_CHAN_REL_PRIMARY_TRANSDUCER		= 0x50,
1278 	SDCA_CHAN_REL_SECONDARY_TRANSDUCER		= 0x51,
1279 	SDCA_CHAN_REL_TERTIARY_TRANSDUCER		= 0x52,
1280 	SDCA_CHAN_REL_LOWER_LEFT_ALLTRANSDUCER		= 0x60,
1281 	SDCA_CHAN_REL_LOWER_RIGHT_ALLTRANSDUCER		= 0x61,
1282 	SDCA_CHAN_REL_UPPER_LEFT_ALLTRANSDUCER		= 0x62,
1283 	SDCA_CHAN_REL_UPPER_RIGHT_ALLTRANSDUCER		= 0x63,
1284 	SDCA_CHAN_REL_LOWER_LEFT_PRIMARY		= 0x64,
1285 	SDCA_CHAN_REL_LOWER_RIGHT_PRIMARY		= 0x65,
1286 	SDCA_CHAN_REL_UPPER_LEFT_PRIMARY		= 0x66,
1287 	SDCA_CHAN_REL_UPPER_RIGHT_PRIMARY		= 0x67,
1288 	SDCA_CHAN_REL_LOWER_LEFT_SECONDARY		= 0x68,
1289 	SDCA_CHAN_REL_LOWER_RIGHT_SECONDARY		= 0x69,
1290 	SDCA_CHAN_REL_UPPER_LEFT_SECONDARY		= 0x6A,
1291 	SDCA_CHAN_REL_UPPER_RIGHT_SECONDARY		= 0x6B,
1292 	SDCA_CHAN_REL_LOWER_LEFT_TERTIARY		= 0x6C,
1293 	SDCA_CHAN_REL_LOWER_RIGHT_TERTIARY		= 0x6D,
1294 	SDCA_CHAN_REL_UPPER_LEFT_TERTIARY		= 0x6E,
1295 	SDCA_CHAN_REL_UPPER_RIGHT_TERTIARY		= 0x6F,
1296 	SDCA_CHAN_REL_DERIVED_LOWER_LEFT_PRIMARY	= 0x94,
1297 	SDCA_CHAN_REL_DERIVED_LOWER_RIGHT_PRIMARY	= 0x95,
1298 	SDCA_CHAN_REL_DERIVED_UPPER_LEFT_PRIMARY	= 0x96,
1299 	SDCA_CHAN_REL_DERIVED_UPPER_RIGHT_PRIMARY	= 0x97,
1300 	SDCA_CHAN_REL_DERIVED_LOWER_LEFT_SECONDARY	= 0x98,
1301 	SDCA_CHAN_REL_DERIVED_LOWER_RIGHT_SECONDARY	= 0x99,
1302 	SDCA_CHAN_REL_DERIVED_UPPER_LEFT_SECONDARY	= 0x9A,
1303 	SDCA_CHAN_REL_DERIVED_UPPER_RIGHT_SECONDARY	= 0x9B,
1304 	SDCA_CHAN_REL_DERIVED_LOWER_LEFT_TERTIARY	= 0x9C,
1305 	SDCA_CHAN_REL_DERIVED_LOWER_RIGHT_TERTIARY	= 0x9D,
1306 	SDCA_CHAN_REL_DERIVED_UPPER_LEFT_TERTIARY	= 0x9E,
1307 	SDCA_CHAN_REL_DERIVED_UPPER_RIGHT_TERTIARY	= 0x9F,
1308 	SDCA_CHAN_REL_DERIVED_MONO_PRIMARY		= 0xA0,
1309 	SDCA_CHAN_REL_DERIVED_MONO_SECONDARY		= 0xAB,
1310 	SDCA_CHAN_REL_DERIVED_MONO_TERTIARY		= 0xAC,
1311 	/* Table 208 - Equipment */
1312 	SDCA_CHAN_REL_EQUIPMENT_LEFT			= 0x02,
1313 	SDCA_CHAN_REL_EQUIPMENT_RIGHT			= 0x03,
1314 	SDCA_CHAN_REL_EQUIPMENT_COMBINED		= 0x47,
1315 	SDCA_CHAN_REL_EQUIPMENT_TOP			= 0x48,
1316 	SDCA_CHAN_REL_EQUIPMENT_BOTTOM			= 0x49,
1317 	SDCA_CHAN_REL_EQUIPMENT_TOP_LEFT		= 0x4A,
1318 	SDCA_CHAN_REL_EQUIPMENT_BOTTOM_LEFT		= 0x4B,
1319 	SDCA_CHAN_REL_EQUIPMENT_TOP_RIGHT		= 0x4C,
1320 	SDCA_CHAN_REL_EQUIPMENT_BOTTOM_RIGHT		= 0x4D,
1321 	SDCA_CHAN_REL_EQUIPMENT_SILENCED_OUTPUT		= 0x57,
1322 	/* Table 209 - Other */
1323 	SDCA_CHAN_REL_ARRAY				= 0x04,
1324 	SDCA_CHAN_REL_MIC				= 0x53,
1325 	SDCA_CHAN_REL_RAW				= 0x54,
1326 	SDCA_CHAN_REL_SILENCED_MIC			= 0x56,
1327 	SDCA_CHAN_REL_MULTI_SOURCE_1			= 0x78,
1328 	SDCA_CHAN_REL_MULTI_SOURCE_2			= 0x79,
1329 	SDCA_CHAN_REL_MULTI_SOURCE_3			= 0x7A,
1330 	SDCA_CHAN_REL_MULTI_SOURCE_4			= 0x7B,
1331 };
1332 
1333 /**
1334  * struct sdca_channel - a single Channel with a Cluster
1335  * @id: Identifier used for addressing.
1336  * @purpose: Indicates the purpose of the Channel, usually to give
1337  * semantic meaning to the audio, eg. voice, ultrasound.
1338  * @relationship: Indicates the relationship of this Channel to others
1339  * in the Cluster, often used to identify the physical position of the
1340  * Channel eg. left.
1341  */
1342 struct sdca_channel {
1343 	int id;
1344 	enum sdca_channel_purpose purpose;
1345 	enum sdca_channel_relationship relationship;
1346 };
1347 
1348 /**
1349  * struct sdca_cluster - information about an SDCA Channel Cluster
1350  * @id: Identifier used for addressing.
1351  * @num_channels: Number of Channels within this Cluster.
1352  * @channels: Dynamically allocated array of Channels.
1353  */
1354 struct sdca_cluster {
1355 	int id;
1356 	int num_channels;
1357 	struct sdca_channel *channels;
1358 };
1359 
1360 /**
1361  * enum sdca_cluster_range - SDCA Range column definitions for ClusterIndex
1362  */
1363 enum sdca_cluster_range {
1364 	SDCA_CLUSTER_BYTEINDEX				= 0,
1365 	SDCA_CLUSTER_CLUSTERID				= 1,
1366 	SDCA_CLUSTER_NCOLS				= 2,
1367 };
1368 
1369 /**
1370  * struct sdca_fdl_file - information about a file from a fileset used in FDL
1371  * @vendor_id: Vendor ID of the file.
1372  * @file_id: File ID of the file.
1373  * @fdl_offset: Offset information for FDL.
1374  */
1375 struct sdca_fdl_file {
1376 	u16 vendor_id;
1377 	u32 file_id;
1378 	u32 fdl_offset;
1379 };
1380 
1381 /**
1382  * struct sdca_fdl_set - information about a set of files used in FDL
1383  * @files: Array of files in this FDL set.
1384  * @num_files: Number of files in this FDL set.
1385  * @id: ID of the FDL set.
1386  */
1387 struct sdca_fdl_set {
1388 	struct sdca_fdl_file *files;
1389 	int num_files;
1390 	u32 id;
1391 };
1392 
1393 /**
1394  * struct sdca_fdl_data - information about a function's FDL data
1395  * @swft: Pointer to the SoundWire File Table.
1396  * @sets: Array of FDL sets used by this function.
1397  * @num_sets: Number of FDL sets used by this function.
1398  */
1399 struct sdca_fdl_data {
1400 	struct acpi_table_swft *swft;
1401 	struct sdca_fdl_set *sets;
1402 	int num_sets;
1403 };
1404 
1405 /**
1406  * struct sdca_function_data - top-level information for one SDCA function
1407  * @desc: Pointer to short descriptor from initial parsing.
1408  * @init_table: Pointer to a table of initialization writes.
1409  * @entities: Dynamically allocated array of Entities.
1410  * @clusters: Dynamically allocated array of Channel Clusters.
1411  * @num_init_table: Number of initialization writes.
1412  * @num_entities: Number of Entities reported in this Function.
1413  * @num_clusters: Number of Channel Clusters reported in this Function.
1414  * @busy_max_delay: Maximum Function busy delay in microseconds, before an
1415  * error should be reported.
1416  * @reset_max_delay: Maximum Function reset delay in microseconds, before an
1417  * error should be reported.
1418  * @fdl_data: FDL data for this Function, if available.
1419  */
1420 struct sdca_function_data {
1421 	struct sdca_function_desc *desc;
1422 
1423 	struct sdca_init_write *init_table;
1424 	struct sdca_entity *entities;
1425 	struct sdca_cluster *clusters;
1426 	int num_init_table;
1427 	int num_entities;
1428 	int num_clusters;
1429 
1430 	unsigned int busy_max_delay;
1431 	unsigned int reset_max_delay;
1432 
1433 	struct sdca_fdl_data fdl_data;
1434 };
1435 
1436 static inline u32 sdca_range(struct sdca_control_range *range,
1437 			     unsigned int col, unsigned int row)
1438 {
1439 	return range->data[(row * range->cols) + col];
1440 }
1441 
1442 static inline u32 sdca_range_search(struct sdca_control_range *range,
1443 				    int search_col, int value, int result_col)
1444 {
1445 	int i;
1446 
1447 	for (i = 0; i < range->rows; i++) {
1448 		if (sdca_range(range, search_col, i) == value)
1449 			return sdca_range(range, result_col, i);
1450 	}
1451 
1452 	return 0;
1453 }
1454 
1455 int sdca_parse_function(struct device *dev, struct sdw_slave *sdw,
1456 			struct sdca_function_desc *desc,
1457 			struct sdca_function_data *function);
1458 
1459 const char *sdca_find_terminal_name(enum sdca_terminal_type type);
1460 
1461 struct sdca_control *sdca_selector_find_control(struct device *dev,
1462 						struct sdca_entity *entity,
1463 						const int sel);
1464 struct sdca_control_range *sdca_control_find_range(struct device *dev,
1465 						   struct sdca_entity *entity,
1466 						   struct sdca_control *control,
1467 						   int cols, int rows);
1468 struct sdca_control_range *sdca_selector_find_range(struct device *dev,
1469 						    struct sdca_entity *entity,
1470 						    int sel, int cols, int rows);
1471 struct sdca_cluster *sdca_id_find_cluster(struct device *dev,
1472 					  struct sdca_function_data *function,
1473 					  const int id);
1474 
1475 #endif
1476