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