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