forked from gregkh/usbutils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
desc-defs.c
1131 lines (1011 loc) · 45.8 KB
/
desc-defs.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// SPDX-License-Identifier: GPL-2.0+
/*
* USB descriptor definitions
*
* Copyright (C) 2017-2018 Michael Drake <[email protected]>
*/
#include "config.h"
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include "desc-defs.h"
/** Macro for computing number of elements in array. */
#define ARRAY_LEN(a) ((sizeof(a)) / (sizeof(a[0])))
/**
* Undefined descriptor
*
* Ensures remaining data is dumped as garbage at end of descriptor.
*/
const struct desc desc_undefined[] = {
{ .field = NULL }
};
/** USB Audio Device Class 1 Channel Names. (Note: Order matters.) */
static const char * const uac1_channel_names[] = {
"Left Front (L)", "Right Front (R)", "Center Front (C)",
"Low Frequency Enhancement (LFE)", "Left Surround (LS)",
"Right Surround (RS)", "Left of Center (LC)", "Right of Center (RC)",
"Surround (S)", "Side Left (SL)", "Side Right (SR)", "Top (T)"
};
/** USB Audio Device Class 2 Channel Names. (Note: Order matters.) */
static const char * const uac2_channel_names[] = {
"Front Left (FL)", "Front Right (FR)", "Front Center (FC)",
"Low Frequency Effects (LFE)", "Back Left (BL)", "Back Right (BR)",
"Front Left of Center (FLC)", "Front Right of Center (FRC)",
"Back Center (BC)", "Side Left (SL)", "Side Right (SR)",
"Top Center (TC)", "Top Front Left (TFL)", "Top Front Center (TFC)",
"Top Front Right (TFR)", "Top Back Left (TBL)", "Top Back Center (TBC)",
"Top Back Right (TBR)", "Top Front Left of Center (TFLC)",
"Top Front Right of Center (TFRC)", "Left Low Frequency Effects (LLFE)",
"Right Low Frequency Effects (RLFE)", "Top Side Left (TSL)",
"Top Side Right (TSR)", "Bottom Center (BC)",
"Back Left of Center (BLC)", "Back Right of Center (BRC)"
};
/** Audio Control Interface Header bmControls; Human readable bit meanings. */
static const char * const uac2_interface_header_bmcontrols[] = {
[0] = "Latency control",
[1] = NULL
};
/** UAC1: 4.3.2 Class-Specific AC Interface Descriptor; Table 4-2. */
static const struct desc desc_audio_1_ac_header[] = {
{ .field = "bcdADC", .size = 2, .type = DESC_BCD },
{ .field = "wTotalLength", .size = 2, .type = DESC_CONSTANT },
{ .field = "bInCollection", .size = 1, .type = DESC_CONSTANT },
{ .field = "baInterfaceNr", .size = 1, .type = DESC_NUMBER,
.array = { .array = true } },
{ .field = NULL }
};
/** UAC2: 4.7.2 Class-Specific AC Interface Descriptor; Table 4-5. */
static const struct desc desc_audio_2_ac_header[] = {
{ .field = "bcdADC", .size = 2, .type = DESC_BCD },
{ .field = "bCategory", .size = 1, .type = DESC_CONSTANT },
{ .field = "wTotalLength", .size = 2, .type = DESC_NUMBER },
{ .field = "bmControls", .size = 1, .type = DESC_BMCONTROL_2,
.bmcontrol = uac2_interface_header_bmcontrols },
{ .field = NULL }
};
/** UAC3: 4.5.2 Class-Specific AC Interface Descriptor; Table 4-15. */
static const struct desc desc_audio_3_ac_header[] = {
{ .field = "bCategory", .size = 1, .type = DESC_CONSTANT },
{ .field = "wTotalLength", .size = 2, .type = DESC_NUMBER },
{ .field = "bmControls", .size = 4, .type = DESC_BMCONTROL_2,
.bmcontrol = uac2_interface_header_bmcontrols },
{ .field = NULL }
};
/** AudioControl Header descriptor definitions for the three Audio Device Class protocols */
const struct desc * const desc_audio_ac_header[3] = {
desc_audio_1_ac_header,
desc_audio_2_ac_header,
desc_audio_3_ac_header,
};
/** UAC2: 4.7.2.10 Effect Unit Descriptor; Table 4-15. */
static const struct desc desc_audio_2_ac_effect_unit[] = {
{ .field = "bUnitID", .size = 1, .type = DESC_NUMBER },
{ .field = "wEffectType", .size = 2, .type = DESC_CONSTANT },
{ .field = "bSourceID", .size = 1, .type = DESC_CONSTANT },
{ .field = "bmaControls", .size = 4, .type = DESC_BITMAP,
.array = { .array = true } },
{ .field = "iEffects", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = NULL }
};
/** UAC3: 4.5.2.9 Effect Unit Descriptor; Table 4-33. */
static const struct desc desc_audio_3_ac_effect_unit[] = {
{ .field = "bUnitID", .size = 1, .type = DESC_NUMBER },
{ .field = "wEffectType", .size = 2, .type = DESC_CONSTANT },
{ .field = "bSourceID", .size = 1, .type = DESC_CONSTANT },
{ .field = "bmaControls", .size = 4, .type = DESC_BITMAP,
.array = { .array = true } },
{ .field = "wEffectsDescrStr", .size = 2, .type = DESC_CS_STR_DESC_ID },
{ .field = NULL }
};
/** Effect Unit descriptor definitions for the three Audio Device Class protocols */
const struct desc * const desc_audio_ac_effect_unit[3] = {
NULL, /* UAC1 not supported */
desc_audio_2_ac_effect_unit,
desc_audio_3_ac_effect_unit,
};
/** UAC2 Input Terminal bmControls; Human readable bit meanings. */
static const char * const uac2_input_term_bmcontrols[] = {
[0] = "Copy Protect",
[1] = "Connector",
[2] = "Overload",
[3] = "Cluster",
[4] = "Underflow",
[5] = "Overflow",
[6] = NULL
};
/** UAC3 Input Terminal bmControls; Human readable bit meanings. */
static const char * const uac3_input_term_bmcontrols[] = {
[0] = "Insertion",
[1] = "Overload",
[2] = "Underflow",
[3] = "Overflow",
[4] = "Underflow",
[5] = NULL
};
/** UAC1: 4.3.2.1 Input Terminal Descriptor; Table 4-3. */
static const struct desc desc_audio_1_ac_input_terminal[] = {
{ .field = "bTerminalID", .size = 1, .type = DESC_NUMBER },
{ .field = "wTerminalType", .size = 2, .type = DESC_TERMINAL_STR },
{ .field = "bAssocTerminal", .size = 1, .type = DESC_CONSTANT },
{ .field = "bNrChannels", .size = 1, .type = DESC_NUMBER },
{ .field = "wChannelConfig", .size = 2, .type = DESC_BITMAP_STRINGS,
.bitmap_strings = { .strings = uac1_channel_names, .count = 12 } },
{ .field = "iChannelNames", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = "iTerminal", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = NULL }
};
/** UAC2: 4.7.2.4 Input Terminal Descriptor; Table 4-9. */
static const struct desc desc_audio_2_ac_input_terminal[] = {
{ .field = "bTerminalID", .size = 1, .type = DESC_NUMBER },
{ .field = "wTerminalType", .size = 2, .type = DESC_TERMINAL_STR },
{ .field = "bAssocTerminal", .size = 1, .type = DESC_CONSTANT },
{ .field = "bCSourceID", .size = 1, .type = DESC_CONSTANT },
{ .field = "bNrChannels", .size = 1, .type = DESC_NUMBER },
{ .field = "bmChannelConfig", .size = 4, .type = DESC_BITMAP_STRINGS,
.bitmap_strings = { .strings = uac2_channel_names, .count = 26 } },
{ .field = "iChannelNames", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = "bmControls", .size = 2, .type = DESC_BMCONTROL_2,
.bmcontrol = uac2_input_term_bmcontrols },
{ .field = "iTerminal", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = NULL }
};
/** UAC3: 4.5.2.1 Input Terminal Descriptor; Table 4-16. */
static const struct desc desc_audio_3_ac_input_terminal[] = {
{ .field = "bTerminalID", .size = 1, .type = DESC_NUMBER },
{ .field = "wTerminalType", .size = 2, .type = DESC_TERMINAL_STR },
{ .field = "bAssocTerminal", .size = 1, .type = DESC_NUMBER },
{ .field = "bCSourceID", .size = 1, .type = DESC_NUMBER },
{ .field = "bmControls", .size = 4, .type = DESC_BMCONTROL_2,
.bmcontrol = uac3_input_term_bmcontrols },
{ .field = "wClusterDescrID", .size = 2, .type = DESC_NUMBER },
{ .field = "wExTerminalDescrID", .size = 2, .type = DESC_NUMBER },
{ .field = "wConnectorsDescrID", .size = 2, .type = DESC_NUMBER },
{ .field = "wTerminalDescrStr", .size = 2, .type = DESC_CS_STR_DESC_ID },
{ .field = NULL }
};
/** Input Terminal descriptor definitions for the three Audio Device Class protocols */
const struct desc * const desc_audio_ac_input_terminal[3] = {
desc_audio_1_ac_input_terminal,
desc_audio_2_ac_input_terminal,
desc_audio_3_ac_input_terminal,
};
/** UAC2 Output Terminal bmControls; Human readable bit meanings. */
static const char * const uac2_output_term_bmcontrols[] = {
[0] = "Copy Protect",
[1] = "Connector",
[2] = "Overload",
[3] = "Underflow",
[4] = "Overflow",
[5] = NULL
};
/** UAC3 Output Terminal bmControls; Human readable bit meanings. */
static const char * const uac3_output_term_bmcontrols[] = {
[0] = "Insertion",
[1] = "Overload",
[2] = "Underflow",
[3] = "Overflow",
[4] = NULL
};
/** UAC1: 4.3.2.2 Output Terminal Descriptor; Table 4-4. */
static const struct desc desc_audio_1_ac_output_terminal[] = {
{ .field = "bTerminalID", .size = 1, .type = DESC_NUMBER },
{ .field = "wTerminalType", .size = 2, .type = DESC_TERMINAL_STR },
{ .field = "bAssocTerminal", .size = 1, .type = DESC_NUMBER },
{ .field = "bSourceID", .size = 1, .type = DESC_NUMBER },
{ .field = "iTerminal", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = NULL }
};
/** UAC2: 4.7.2.5 Output Terminal Descriptor; Table 4-10. */
static const struct desc desc_audio_2_ac_output_terminal[] = {
{ .field = "bTerminalID", .size = 1, .type = DESC_NUMBER },
{ .field = "wTerminalType", .size = 2, .type = DESC_TERMINAL_STR },
{ .field = "bAssocTerminal", .size = 1, .type = DESC_NUMBER },
{ .field = "bSourceID", .size = 1, .type = DESC_NUMBER },
{ .field = "bCSourceID", .size = 1, .type = DESC_NUMBER },
{ .field = "bmControls", .size = 2, .type = DESC_BMCONTROL_2,
.bmcontrol = uac2_output_term_bmcontrols },
{ .field = "iTerminal", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = NULL }
};
/** UAC3: 4.5.2.2 Output Terminal Descriptor; Table 4-17. */
static const struct desc desc_audio_3_ac_output_terminal[] = {
{ .field = "bTerminalID", .size = 1, .type = DESC_NUMBER },
{ .field = "wTerminalType", .size = 2, .type = DESC_TERMINAL_STR },
{ .field = "bAssocTerminal", .size = 1, .type = DESC_NUMBER },
{ .field = "bSourceID", .size = 1, .type = DESC_NUMBER },
{ .field = "bCSourceID", .size = 1, .type = DESC_NUMBER },
{ .field = "bmControls", .size = 4, .type = DESC_BMCONTROL_2,
.bmcontrol = uac3_output_term_bmcontrols },
{ .field = "wExTerminalDescrID", .size = 2, .type = DESC_NUMBER },
{ .field = "wConnectorsDescrID", .size = 2, .type = DESC_NUMBER },
{ .field = "wTerminalDescrStr", .size = 2, .type = DESC_CS_STR_DESC_ID },
{ .field = NULL }
};
/** Output Terminal descriptor definitions for the three Audio Device Class protocols */
const struct desc * const desc_audio_ac_output_terminal[3] = {
desc_audio_1_ac_output_terminal,
desc_audio_2_ac_output_terminal,
desc_audio_3_ac_output_terminal,
};
/** UAC3: 4.5.2.3.1 Extended Terminal Header Descriptor; Table 4-18. */
static const struct desc desc_audio_3_ac_extended_terminal_header[] = {
{ .field = "wDescriptorID", .size = 2, .type = DESC_NUMBER },
{ .field = "bNrChannels", .size = 1, .type = DESC_NUMBER },
{ .field = NULL }
};
/** Extended Terminal descriptor definitions for the three Audio Device Class protocols */
const struct desc * const desc_audio_ac_extended_terminal[3] = {
NULL, /* UAC1 not supported */
NULL, /* UAC2 not supported */
desc_audio_3_ac_extended_terminal_header,
};
/** UAC3: 4.5.2.15 Power Domain Descriptor; Table 4-46. */
static const struct desc desc_audio_3_ac_power_domain[] = {
{ .field = "bPowerDomainID", .size = 1, .type = DESC_NUMBER },
{ .field = "waRecoveryTime(1)", .size = 2, .type = DESC_NUMBER },
{ .field = "waRecoveryTime(2)", .size = 2, .type = DESC_NUMBER },
{ .field = "bNrEntities", .size = 1, .type = DESC_NUMBER },
{ .field = "baEntityID", .size = 1, .type = DESC_NUMBER,
.array = { .array = true, .length_field1 = "bNrEntities" } },
{ .field = "wPDomainDescrStr", .size = 2, .type = DESC_CS_STR_DESC_ID },
{ .field = NULL }
};
/** Power Domain descriptor definitions for the three Audio Device Class protocols */
const struct desc * const desc_audio_ac_power_domain[3] = {
NULL, /* UAC1 not supported */
NULL, /* UAC2 not supported */
desc_audio_3_ac_power_domain,
};
/** UAC2 Mixer Unit bmControls; Human readable bit meanings. */
static const char * const uac2_mixer_unit_bmcontrols[] = {
[0] = "Cluster",
[1] = "Underflow",
[2] = "Overflow",
[3] = NULL
};
/** UAC3 Mixer Unit bmControls; Human readable bit meanings. */
static const char * const uac3_mixer_unit_bmcontrols[] = {
[0] = "Underflow",
[1] = "Overflow",
[2] = NULL
};
/** UAC1: 4.3.2.3 Mixer Unit Descriptor; Table 4-5. */
static const struct desc desc_audio_1_ac_mixer_unit[] = {
{ .field = "bUnitID", .size = 1, .type = DESC_NUMBER },
{ .field = "bNrInPins", .size = 1, .type = DESC_NUMBER },
{ .field = "baSourceID", .size = 1, .type = DESC_NUMBER,
.array = { .array = true, .length_field1 = "bNrInPins" } },
{ .field = "bNrChannels", .size = 1, .type = DESC_NUMBER },
{ .field = "wChannelConfig", .size = 2, .type = DESC_BITMAP_STRINGS,
.bitmap_strings = { .strings = uac1_channel_names, .count = 12 } },
{ .field = "iChannelNames", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = "bmControls", .size = 1, .type = DESC_BITMAP,
.array = { .array = true, .bits = true,
.length_field1 = "bNrInPins",
.length_field2 = "bNrChannels" } },
{ .field = "iMixer", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = NULL }
};
/** UAC2: 4.7.2.6 Mixer Unit Descriptor; Table 4-11. */
static const struct desc desc_audio_2_ac_mixer_unit[] = {
{ .field = "bUnitID", .size = 1, .type = DESC_NUMBER },
{ .field = "bNrInPins", .size = 1, .type = DESC_NUMBER },
{ .field = "baSourceID", .size = 1, .type = DESC_NUMBER,
.array = { .array = true, .length_field1 = "bNrInPins" } },
{ .field = "bNrChannels", .size = 1, .type = DESC_NUMBER },
{ .field = "bmChannelConfig",.size = 4, .type = DESC_BITMAP_STRINGS,
.bitmap_strings = { .strings = uac2_channel_names, .count = 26 } },
{ .field = "iChannelNames", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = "bmMixerControls",.size = 1, .type = DESC_BITMAP,
.array = { .array = true, .bits = true,
.length_field1 = "bNrInPins",
.length_field2 = "bNrChannels" } },
{ .field = "bmControls", .size = 1, .type = DESC_BMCONTROL_2,
.bmcontrol = uac2_mixer_unit_bmcontrols },
{ .field = "iMixer", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = NULL }
};
/** UAC3: 4.5.2.5 Mixer Unit Descriptor; Table 4-29. */
static const struct desc desc_audio_3_ac_mixer_unit[] = {
{ .field = "bUnitID", .size = 1, .type = DESC_NUMBER },
{ .field = "bNrInPins", .size = 1, .type = DESC_NUMBER },
{ .field = "baSourceID", .size = 1, .type = DESC_NUMBER,
.array = { .array = true, .length_field1 = "bNrInPins" } },
{ .field = "wClusterDescrID",.size = 2, .type = DESC_NUMBER },
{ .field = "bmMixerControls",.size = 1, .type = DESC_BITMAP,
.array = { .array = true } },
{ .field = "bmControls", .size = 4, .type = DESC_BMCONTROL_2,
.bmcontrol = uac3_mixer_unit_bmcontrols },
{ .field = "wMixerDescrStr", .size = 2, .type = DESC_CS_STR_DESC_ID },
{ .field = NULL }
};
/** Mixer Unit descriptor definitions for the three Audio Device Class protocols */
const struct desc * const desc_audio_ac_mixer_unit[3] = {
desc_audio_1_ac_mixer_unit,
desc_audio_2_ac_mixer_unit,
desc_audio_3_ac_mixer_unit,
};
/** Selector Unit bmControls; Human readable bit meanings. */
static const char * const uac2_selector_unit_bmcontrols[] = {
[0] = "Selector",
[1] = NULL
};
/** UAC1: 4.3.2.4 Selector Unit Descriptor; Table 4-6. */
static const struct desc desc_audio_1_ac_selector_unit[] = {
{ .field = "bUnitID", .size = 1, .type = DESC_NUMBER },
{ .field = "bNrInPins", .size = 1, .type = DESC_NUMBER },
{ .field = "baSourceID", .size = 1, .type = DESC_NUMBER,
.array = { .array = true, .length_field1 = "bNrInPins" } },
{ .field = "iSelector", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = NULL }
};
/** UAC2: 4.7.2.7 Selector Unit Descriptor; Table 4-12. */
static const struct desc desc_audio_2_ac_selector_unit[] = {
{ .field = "bUnitID", .size = 1, .type = DESC_NUMBER },
{ .field = "bNrInPins", .size = 1, .type = DESC_NUMBER },
{ .field = "baSourceID", .size = 1, .type = DESC_NUMBER,
.array = { .array = true, .length_field1 = "bNrInPins" } },
{ .field = "bmControls", .size = 1, .type = DESC_BMCONTROL_2,
.bmcontrol = uac2_selector_unit_bmcontrols },
{ .field = "iSelector", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = NULL }
};
/** UAC3: 4.5.2.6 Selector Unit Descriptor; Table 4-30. */
static const struct desc desc_audio_3_ac_selector_unit[] = {
{ .field = "bUnitID", .size = 1, .type = DESC_NUMBER },
{ .field = "bNrInPins", .size = 1, .type = DESC_NUMBER },
{ .field = "baSourceID", .size = 1, .type = DESC_NUMBER,
.array = { .array = true, .length_field1 = "bNrInPins" } },
{ .field = "bmControls", .size = 4, .type = DESC_BMCONTROL_2,
.bmcontrol = uac2_selector_unit_bmcontrols },
{ .field = "wSelectorDescrStr", .size = 2, .type = DESC_CS_STR_DESC_ID },
{ .field = NULL }
};
/** Selector Unit descriptor definitions for the three Audio Device Class protocols */
const struct desc * const desc_audio_ac_selector_unit[3] = {
desc_audio_1_ac_selector_unit,
desc_audio_2_ac_selector_unit,
desc_audio_3_ac_selector_unit,
};
/** UAC1: Table A-7: Processing Unit Process Types */
static const char * const uac1_proc_unit_types[] = {
[0] = "Undefined",
[1] = "Up/Down-mix",
[2] = "Dolby Prologic",
[3] = "3D Stereo Extender",
[4] = "Reverberation",
[5] = "Chorus",
[6] = "Dyn Range Comp",
[7] = NULL
};
/** UAC1: Up/Down-mix and Dolby Prologic proc unit descriptor extensions Table 4-9, Table 4-10. */
static const struct desc desc_audio_1_ac_proc_unit_extended[] = {
{ .field = "bNrModes", .size = 1, .type = DESC_NUMBER },
{ .field = "waModes", .size = 2, .type = DESC_BITMAP,
.array = { .array = true, .length_field1 = "bNrModes" } },
{ .field = NULL }
};
/** UAC1: Table A-7: Processing Unit Process Types */
static const struct desc_ext desc_audio_1_ac_proc_unit_specific[] = {
{ .type = 1, .desc = desc_audio_1_ac_proc_unit_extended },
{ .type = 2, .desc = desc_audio_1_ac_proc_unit_extended },
{ .desc = NULL }
};
/** UAC1: 4.3.2.6 Processing Unit Descriptor; Table 4-8. */
static const struct desc desc_audio_1_ac_processing_unit[] = {
{ .field = "bUnitID", .size = 1, .type = DESC_NUMBER },
{ .field = "wProcessType", .size = 2, .type = DESC_NUMBER_STRINGS,
.number_strings = uac1_proc_unit_types },
{ .field = "bNrInPins", .size = 1, .type = DESC_NUMBER },
{ .field = "baSourceID", .size = 1, .type = DESC_NUMBER,
.array = { .array = true, .length_field1 = "bNrInPins" } },
{ .field = "bNrChannels", .size = 1, .type = DESC_NUMBER },
{ .field = "wChannelConfig", .size = 2, .type = DESC_BITMAP_STRINGS,
.bitmap_strings = { .strings = uac1_channel_names, .count = 12 } },
{ .field = "iChannelNames", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = "bControlSize", .size = 1, .type = DESC_NUMBER },
{ .field = "bmControls", .size = 1, .type = DESC_BITMAP,
.array = { .array = true, .length_field1 = "bControlSize" } },
{ .field = "iProcessing", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = "Process-specific", .size = 1, .type = DESC_EXTENSION,
.extension = { .type_field = "wProcessType", .d = desc_audio_1_ac_proc_unit_specific } },
{ .field = NULL }
};
/** UAC2: 4.7.2.11.1 Up/Down-mix Processing Unit Descriptor; Table 4-21. */
static const struct desc desc_audio_2_ac_proc_unit_up_down_mix[] = {
{ .field = "bNrModes", .size = 1, .type = DESC_NUMBER },
{ .field = "daModes", .size = 4, .type = DESC_BITMAP,
.array = { .array = true, .length_field1 = "bNrModes" } },
{ .field = NULL }
};
/** UAC2: 4.7.2.11.2 Dolby prologic Processing Unit Descriptor; Table 4-22. */
static const struct desc desc_audio_2_ac_proc_unit_dolby_prologic[] = {
{ .field = "bNrModes", .size = 1, .type = DESC_NUMBER },
{ .field = "daModes", .size = 4, .type = DESC_BITMAP,
.array = { .array = true, .length_field1 = "bNrModes" } },
{ .field = NULL }
};
/** UAC2: Table A-12: Processing Unit Process Types */
static const struct desc_ext desc_audio_2_ac_proc_unit_specific[] = {
{ .type = 1, .desc = desc_audio_2_ac_proc_unit_up_down_mix },
{ .type = 2, .desc = desc_audio_2_ac_proc_unit_dolby_prologic },
{ .desc = NULL }
};
/** UAC2: Table A-12: Processing Unit Process Types */
static const char * const uac2_proc_unit_types[] = {
[0] = "Undefined",
[1] = "Up/Down-mix",
[2] = "Dolby Prologic",
[3] = "Stereo Extender",
[4] = NULL
};
/** UAC2: 4.7.2.11 Processing Unit Descriptor; Table 4-20. */
static const struct desc desc_audio_2_ac_processing_unit[] = {
{ .field = "bUnitID", .size = 1, .type = DESC_NUMBER },
{ .field = "wProcessType", .size = 2, .type = DESC_NUMBER_STRINGS,
.number_strings = uac2_proc_unit_types },
{ .field = "bNrInPins", .size = 1, .type = DESC_NUMBER },
{ .field = "baSourceID", .size = 1, .type = DESC_NUMBER,
.array = { .array = true, .length_field1 = "bNrInPins" } },
{ .field = "bNrChannels", .size = 1, .type = DESC_NUMBER },
{ .field = "bmChannelConfig", .size = 4, .type = DESC_BITMAP_STRINGS,
.bitmap_strings = { .strings = uac2_channel_names, .count = 26 } },
{ .field = "iChannelNames", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = "bmControls", .size = 2, .type = DESC_BITMAP },
{ .field = "iProcessing", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = "Process-specific", .size = 1, .type = DESC_EXTENSION,
.extension = { .type_field = "wProcessType", .d = desc_audio_2_ac_proc_unit_specific } },
{ .field = NULL }
};
/** Processor unit Up/Down-mix bmControls; Human readable bit meanings. */
static const char * const uac3_proc_unit_up_down_mix_bmcontrols[] = {
[0] = "Mode Select",
[1] = "Underflow",
[2] = "Overflow",
[3] = NULL
};
/** UAC3: 4.5.2.10.1 Up/Down-mix Processing Unit Descriptor; Table 4-39. */
static const struct desc desc_audio_3_ac_proc_unit_up_down_mix[] = {
{ .field = "bmControls", .size = 4, .type = DESC_BMCONTROL_2,
.bmcontrol = uac3_proc_unit_up_down_mix_bmcontrols },
{ .field = "bNrModes", .size = 1, .type = DESC_NUMBER },
{ .field = "waClusterDescrID", .size = 2, .type = DESC_NUMBER,
.array = { .array = true, .length_field1 = "bNrModes" } },
{ .field = NULL }
};
/** Processor unit stereo extender bmControls; Human readable bit meanings. */
static const char * const uac3_proc_unit_stereo_extender_bmcontrols[] = {
[0] = "Width",
[1] = "Underflow",
[2] = "Overflow",
[3] = NULL
};
/** UAC3: 4.5.2.10.2 Stereo Extender Processing Unit Descriptor; Table 4-40. */
static const struct desc desc_audio_3_ac_proc_unit_stereo_extender[] = {
{ .field = "bmControls", .size = 4, .type = DESC_BMCONTROL_2,
.bmcontrol = uac3_proc_unit_stereo_extender_bmcontrols },
{ .field = NULL }
};
/** UAC3: 4.5.2.10.3 Multi Func Proc Unit Descriptor; Algorithms; Table 4-41. */
static const char *uac3_proc_unit_multi_func_algorithms[] = {
[0] = "Algorithm Undefined.",
[1] = "Beam Forming.",
[2] = "Acoustic Echo Cancellation.",
[3] = "Active Noise Cancellation.",
[4] = "Blind Source Separation.",
[5] = "Noise Suppression/Reduction.",
[6] = NULL
};
/** Processor unit Multi Func bmControls; Human readable bit meanings. */
static const char * const uac3_proc_unit_multi_func_bmcontrols[] = {
[0] = "Underflow",
[1] = "Overflow",
[2] = NULL
};
/** UAC3: 4.5.2.10.3 Multi Function Processing Unit Descriptor; Table 4-41. */
static const struct desc desc_audio_3_ac_proc_unit_multi_function[] = {
{ .field = "bmControls", .size = 4, .type = DESC_BMCONTROL_2,
.bmcontrol = uac3_proc_unit_multi_func_bmcontrols },
{ .field = "wClusterDescrID", .size = 2, .type = DESC_NUMBER, },
{ .field = "bmAlgorithms", .size = 4, .type = DESC_BITMAP_STRINGS,
.bitmap_strings = {
.strings = uac3_proc_unit_multi_func_algorithms,
.count = 6
} },
{ .field = NULL }
};
/** UAC3: Table A-20: Processing Unit Process Types */
static const char * const uac3_proc_unit_types[] = {
[0] = "Undefined",
[1] = "Up/Down-mix",
[2] = "Stereo Extender",
[3] = "Multi-Function",
[4] = NULL
};
/** UAC3: Table A-20: Processing Unit Process Types */
static const struct desc_ext desc_audio_3_ac_proc_unit_specific[] = {
{ .type = 1, .desc = desc_audio_3_ac_proc_unit_up_down_mix },
{ .type = 2, .desc = desc_audio_3_ac_proc_unit_stereo_extender },
{ .type = 3, .desc = desc_audio_3_ac_proc_unit_multi_function },
{ .desc = NULL }
};
/** UAC3: 4.5.2.10 Processing Unit Descriptor; Table 4-38. */
static const struct desc desc_audio_3_ac_processing_unit[] = {
{ .field = "bUnitID", .size = 1, .type = DESC_NUMBER },
{ .field = "wProcessType", .size = 2, .type = DESC_NUMBER_STRINGS,
.number_strings = uac3_proc_unit_types },
{ .field = "bNrInPins", .size = 1, .type = DESC_NUMBER },
{ .field = "baSourceID", .size = 1, .type = DESC_NUMBER,
.array = { .array = true, .length_field1 = "bNrInPins" } },
{ .field = "wProcessingDescrStr", .size = 2, .type = DESC_CS_STR_DESC_ID },
{ .field = "Process-specific", .size = 1, .type = DESC_EXTENSION,
.extension = { .type_field = "wProcessType", .d = desc_audio_3_ac_proc_unit_specific } },
{ .field = NULL }
};
/** Processing Unit descriptor definitions for the three Audio Device Class protocols */
const struct desc * const desc_audio_ac_processing_unit[3] = {
desc_audio_1_ac_processing_unit,
desc_audio_2_ac_processing_unit,
desc_audio_3_ac_processing_unit,
};
/** Audio Control Feature Unit bmControls; Human readable bit meanings. */
static const char * const uac_feature_unit_bmcontrols[] = {
[ 0] = "Mute",
[ 1] = "Volume",
[ 2] = "Bass",
[ 3] = "Mid",
[ 4] = "Treble",
[ 5] = "Graphic Equalizer",
[ 6] = "Automatic Gain",
[ 7] = "Delay",
[ 8] = "Bass Boost",
[ 9] = "Loudness",
[10] = "Input gain",
[11] = "Input gain pad",
[12] = "Phase inverter",
[13] = NULL
};
/** UAC1: 4.3.2.5 Feature Unit Descriptor; Table 4-7. */
static const struct desc desc_audio_1_ac_feature_unit[] = {
{ .field = "bUnitID", .size = 1, .type = DESC_NUMBER },
{ .field = "bSourceID", .size = 1, .type = DESC_CONSTANT },
{ .field = "bControlSize", .size = 1, .type = DESC_NUMBER },
{ .field = "bmaControls", .size_field = "bControlSize", .type = DESC_BMCONTROL_1,
.bmcontrol = uac_feature_unit_bmcontrols, .array = { .array = true } },
{ .field = "iFeature", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = NULL }
};
/** UAC2: 4.7.2.8 Feature Unit Descriptor; Table 4-13. */
static const struct desc desc_audio_2_ac_feature_unit[] = {
{ .field = "bUnitID", .size = 1, .type = DESC_NUMBER },
{ .field = "bSourceID", .size = 1, .type = DESC_CONSTANT },
{ .field = "bmaControls", .size = 4, .type = DESC_BMCONTROL_2,
.bmcontrol = uac_feature_unit_bmcontrols, .array = { .array = true } },
{ .field = "iFeature", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = NULL }
};
/** UAC3: 4.5.2.7 Feature Unit Descriptor; Table 4-31. */
static const struct desc desc_audio_3_ac_feature_unit[] = {
{ .field = "bUnitID", .size = 1, .type = DESC_NUMBER },
{ .field = "bSourceID", .size = 1, .type = DESC_NUMBER },
{ .field = "bmaControls", .size = 4, .type = DESC_BMCONTROL_2,
.bmcontrol = uac_feature_unit_bmcontrols, .array = { .array = true } },
{ .field = "wFeatureDescrStr", .size = 2, .type = DESC_CS_STR_DESC_ID },
{ .field = NULL }
};
/** Feature Unit descriptor definitions for the three Audio Device Class protocols */
const struct desc * const desc_audio_ac_feature_unit[3] = {
desc_audio_1_ac_feature_unit,
desc_audio_2_ac_feature_unit,
desc_audio_3_ac_feature_unit,
};
/** UAC2 Extension Unit bmControls; Human readable bit meanings. */
static const char * const uac2_extension_unit_bmcontrols[] = {
[0] = "Enable",
[1] = "Cluster",
[2] = "Underflow",
[3] = "Overflow",
[4] = NULL
};
/** UAC3 Extension Unit bmControls; Human readable bit meanings. */
static const char * const uac3_extension_unit_bmcontrols[] = {
[0] = "Underflow",
[1] = "Overflow",
[2] = NULL
};
/** UAC1: 4.3.2.7 Extension Unit Descriptor; Table 4-15. */
static const struct desc desc_audio_1_ac_extension_unit[] = {
{ .field = "bUnitID", .size = 1, .type = DESC_NUMBER },
{ .field = "wExtensionCode", .size = 2, .type = DESC_CONSTANT },
{ .field = "bNrInPins", .size = 1, .type = DESC_NUMBER },
{ .field = "baSourceID", .size = 1, .type = DESC_NUMBER,
.array = { .array = true, .length_field1 = "bNrInPins" } },
{ .field = "bNrChannels", .size = 1, .type = DESC_NUMBER },
{ .field = "wChannelConfig", .size = 2, .type = DESC_BITMAP_STRINGS,
.bitmap_strings = { .strings = uac1_channel_names, .count = 12 } },
{ .field = "iChannelNames", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = "bControlSize", .size = 1, .type = DESC_NUMBER },
{ .field = "bmControls", .size = 1, .type = DESC_BITMAP,
.array = { .array = true, .length_field1 = "bControlSize" } },
{ .field = "iExtension", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = NULL }
};
/** UAC2: 4.7.2.12 Extension Unit Descriptor; Table 4-24. */
static const struct desc desc_audio_2_ac_extension_unit[] = {
{ .field = "bUnitID", .size = 1, .type = DESC_NUMBER },
{ .field = "wExtensionCode", .size = 2, .type = DESC_CONSTANT },
{ .field = "bNrInPins", .size = 1, .type = DESC_NUMBER },
{ .field = "baSourceID", .size = 1, .type = DESC_NUMBER,
.array = { .array = true, .length_field1 = "bNrInPins" } },
{ .field = "bNrChannels", .size = 1, .type = DESC_NUMBER },
{ .field = "bmChannelConfig", .size = 4, .type = DESC_BITMAP_STRINGS,
.bitmap_strings = { .strings = uac2_channel_names, .count = 26 } },
{ .field = "iChannelNames", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = "bmControls", .size = 1, .type = DESC_BMCONTROL_2,
.bmcontrol = uac2_extension_unit_bmcontrols },
{ .field = "iExtension", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = NULL }
};
/** UAC3: 4.5.2.11 Extension Unit Descriptor; Table 4-42. */
static const struct desc desc_audio_3_ac_extension_unit[] = {
{ .field = "bUnitID", .size = 1, .type = DESC_NUMBER },
{ .field = "wExtensionCode", .size = 2, .type = DESC_CONSTANT },
{ .field = "bNrInPins", .size = 1, .type = DESC_NUMBER },
{ .field = "baSourceID", .size = 1, .type = DESC_NUMBER,
.array = { .array = true, .length_field1 = "bNrInPins" } },
{ .field = "wExtensionDescrStr", .size = 2, .type = DESC_CS_STR_DESC_ID },
{ .field = "bmControls", .size = 4, .type = DESC_BMCONTROL_2,
.bmcontrol = uac3_extension_unit_bmcontrols },
{ .field = "wClusterDescrID", .size = 2, .type = DESC_NUMBER },
{ .field = NULL }
};
/** Extension Unit descriptor definitions for the three Audio Device Class protocols */
const struct desc * const desc_audio_ac_extension_unit[3] = {
desc_audio_1_ac_extension_unit,
desc_audio_2_ac_extension_unit,
desc_audio_3_ac_extension_unit,
};
/** UAC2 Clock Source bmControls; Human readable bit meanings. */
static const char * const uac2_clock_source_bmcontrols[] = {
[0] = "Clock Frequency",
[1] = "Clock Validity",
[2] = NULL
};
static const char * const uac2_clk_src_bmattr[] = {
[0] = "External",
[1] = "Internal fixed",
[2] = "Internal variable",
[3] = "Internal programmable"
};
static const char * const uac3_clk_src_bmattr[] = {
[0] = "External",
[1] = "Internal",
[2] = "(asynchronous)",
[3] = "(synchronized to SOF)"
};
/** Special rendering function for UAC2 clock source bmAttributes */
static void desc_snowflake_dump_uac2_clk_src_bmattr(
unsigned long long value,
unsigned int indent)
{
printf(" %s clock %s\n",
uac2_clk_src_bmattr[value & 0x3],
(value & 0x4) ? uac3_clk_src_bmattr[3] : "");
}
/** Special rendering function for UAC3 clock source bmAttributes */
static void desc_snowflake_dump_uac3_clk_src_bmattr(
unsigned long long value,
unsigned int indent)
{
printf(" %s clock %s\n",
uac3_clk_src_bmattr[(value & 0x1)],
uac3_clk_src_bmattr[0x2 | ((value & 0x2) >> 1)]);
}
/** UAC2: 4.7.2.1 Clock Source Descriptor; Table 4-6. */
static const struct desc desc_audio_2_ac_clock_source[] = {
{ .field = "bClockID", .size = 1, .type = DESC_CONSTANT },
{ .field = "bmAttributes", .size = 1, .type = DESC_SNOWFLAKE,
.snowflake = desc_snowflake_dump_uac2_clk_src_bmattr },
{ .field = "bmControls", .size = 1, .type = DESC_BMCONTROL_2,
.bmcontrol = uac2_clock_source_bmcontrols },
{ .field = "bAssocTerminal", .size = 1, .type = DESC_CONSTANT },
{ .field = "iClockSource", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = NULL }
};
/** UAC3: 4.5.2.12 Clock Source Descriptor; Table 4-43. */
static const struct desc desc_audio_3_ac_clock_source[] = {
{ .field = "bClockID", .size = 1, .type = DESC_NUMBER },
{ .field = "bmAttributes", .size = 1, .type = DESC_SNOWFLAKE,
.snowflake = desc_snowflake_dump_uac3_clk_src_bmattr },
{ .field = "bmControls", .size = 4, .type = DESC_BMCONTROL_2,
.bmcontrol = uac2_clock_source_bmcontrols },
{ .field = "bReferenceTerminal", .size = 1, .type = DESC_NUMBER },
{ .field = "wClockSourceStr", .size = 2, .type = DESC_CS_STR_DESC_ID },
{ .field = NULL }
};
/** Clock Source descriptor definitions for the three Audio Device Class protocols */
const struct desc * const desc_audio_ac_clock_source[3] = {
NULL, /* UAC1 not supported */
desc_audio_2_ac_clock_source,
desc_audio_3_ac_clock_source,
};
/** UAC2 Clock Selector bmControls; Human readable bit meanings. */
static const char * const uac2_clock_selector_bmcontrols[] = {
[0] = "Clock Selector",
[1] = NULL
};
/** UAC2: 4.7.2.2 Clock Selector Descriptor; Table 4-7. */
static const struct desc desc_audio_2_ac_clock_selector[] = {
{ .field = "bClockID", .size = 1, .type = DESC_NUMBER },
{ .field = "bNrInPins", .size = 1, .type = DESC_NUMBER },
{ .field = "baCSourceID", .size = 1, .type = DESC_NUMBER,
.array = { .array = true, .length_field1 = "bNrInPins" } },
{ .field = "bmControls", .size = 1, .type = DESC_BMCONTROL_2,
.bmcontrol = uac2_clock_selector_bmcontrols },
{ .field = "iClockSelector", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = NULL }
};
/** UAC3: 4.5.2.13 Clock Selector Descriptor; Table 4-44. */
static const struct desc desc_audio_3_ac_clock_selector[] = {
{ .field = "bClockID", .size = 1, .type = DESC_NUMBER },
{ .field = "bNrInPins", .size = 1, .type = DESC_NUMBER },
{ .field = "baCSourceID", .size = 1, .type = DESC_NUMBER,
.array = { .array = true, .length_field1 = "bNrInPins" } },
{ .field = "bmControls", .size = 4, .type = DESC_BMCONTROL_2,
.bmcontrol = uac2_clock_selector_bmcontrols },
{ .field = "wCSelectorDescrStr", .size = 2, .type = DESC_CS_STR_DESC_ID },
{ .field = NULL }
};
/** Clock Selector descriptor definitions for the three Audio Device Class protocols */
const struct desc * const desc_audio_ac_clock_selector[3] = {
NULL, /* UAC1 not supported */
desc_audio_2_ac_clock_selector,
desc_audio_3_ac_clock_selector,
};
/** UAC2 Clock Multiplier bmControls; Human readable bit meanings. */
static const char * const uac2_clock_multiplier_bmcontrols[] = {
[0] = "Clock Numerator",
[1] = "Clock Denominator",
[2] = NULL
};
/** UAC2: 4.7.2.3 Clock Multiplier Descriptor; Table 4-8. */
static const struct desc desc_audio_2_ac_clock_multiplier[] = {
{ .field = "bClockID", .size = 1, .type = DESC_CONSTANT },
{ .field = "bCSourceID", .size = 1, .type = DESC_NUMBER },
{ .field = "bmControls", .size = 1, .type = DESC_BMCONTROL_2,
.bmcontrol = uac2_clock_multiplier_bmcontrols },
{ .field = "iClockMultiplier", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = NULL }
};
/** UAC3: 4.5.2.14 Clock Multiplier Descriptor; Table 4-45. */
static const struct desc desc_audio_3_ac_clock_multiplier[] = {
{ .field = "bClockID", .size = 1, .type = DESC_NUMBER },
{ .field = "bCSourceID", .size = 1, .type = DESC_NUMBER },
{ .field = "bmControls", .size = 4, .type = DESC_BMCONTROL_2,
.bmcontrol = uac2_clock_multiplier_bmcontrols },
{ .field = "wCMultiplierDescrStr", .size = 2, .type = DESC_CS_STR_DESC_ID },
{ .field = NULL }
};
/** Clock Multiplier descriptor definitions for the three Audio Device Class protocols */
const struct desc * const desc_audio_ac_clock_multiplier[3] = {
NULL, /* UAC1 not supported */
desc_audio_2_ac_clock_multiplier,
desc_audio_3_ac_clock_multiplier,
};
/** UAC2: 4.7.2.9 Sampling Rate Converter Descriptor; Table 4-14. */
static const struct desc desc_audio_2_ac_sample_rate_converter[] = {
{ .field = "bUnitID", .size = 1, .type = DESC_CONSTANT },
{ .field = "bSourceID", .size = 1, .type = DESC_CONSTANT },
{ .field = "bCSourceInID", .size = 1, .type = DESC_CONSTANT },
{ .field = "bCSourceOutID", .size = 1, .type = DESC_CONSTANT },
{ .field = "iSRC", .size = 1, .type = DESC_STR_DESC_INDEX },
{ .field = NULL }
};
/** UAC3: 4.5.2.8 Sampling Rate Converter Descriptor; Table 4-32. */
static const struct desc desc_audio_3_ac_sample_rate_converter[] = {
{ .field = "bUnitID", .size = 1, .type = DESC_NUMBER },
{ .field = "bSourceID", .size = 1, .type = DESC_NUMBER },
{ .field = "bCSourceInID", .size = 1, .type = DESC_NUMBER },
{ .field = "bCSourceOutID", .size = 1, .type = DESC_NUMBER },
{ .field = "wSRCDescrStr", .size = 2, .type = DESC_CS_STR_DESC_ID },
{ .field = NULL }
};
/** Sample Rate Converter descriptor definitions for the three Audio Device Class protocols */
const struct desc * const desc_audio_ac_sample_rate_converter[3] = {
NULL, /* UAC1 not supported */
desc_audio_2_ac_sample_rate_converter,
desc_audio_3_ac_sample_rate_converter,
};
/** UAC2 AudioStreaming Interface bmControls; Human readable bit meanings. */
static const char * const uac2_as_interface_bmcontrols[] = {
[0] = "Active Alternate Setting",
[1] = "Valid Alternate Setting",
[2] = NULL
};
/** UAC3 AudioStreaming Interface bmControls; Human readable bit meanings. */
static const char * const uac3_as_interface_bmcontrols[] = {
[0] = "Active Alternate Setting",
[1] = "Valid Alternate Setting",
[2] = "Audio Data Format Control",
[3] = NULL
};
/* wFormatTag hex prefix for format type */
#define UAC_FORMAT_TYPE_I 0x0
#define UAC_FORMAT_TYPE_II 0x1
#define UAC_FORMAT_TYPE_III 0x2
/** Format type I codes; Human-readable values. */
static const char * const audio_data_format_type_i[] = {
[0] = "TYPE_I_UNDEFINED",
[1] = "PCM",
[2] = "PCM8",
[3] = "IEEE_FLOAT",
[4] = "ALAW",
[5] = "MULAW"
};
/** Format type II codes; Human-readable values. */
static const char * const audio_data_format_type_ii[] = {
[0] = "TYPE_II_UNDEFINED",
[1] = "MPEG",
[2] = "AC-3"
};
/** Format type III codes; Human-readable values. */
static const char * const audio_data_format_type_iii[] = {
[0] = "TYPE_III_UNDEFINED",
[1] = "IEC1937_AC-3",
[2] = "IEC1937_MPEG-1_Layer1",
[3] = "IEC1937_MPEG-Layer2/3/NOEXT",
[4] = "IEC1937_MPEG-2_EXT",
[5] = "IEC1937_MPEG-2_Layer1_LS",
[6] = "IEC1937_MPEG-2_Layer2/3_LS"
};
/** Special rendering function for UAC1 AS interface wFormatTag */
static void desc_snowflake_dump_uac1_as_interface_wformattag(
unsigned long long value,
unsigned int indent)
{
const char *format_string = "undefined";
/* Format codes are 0xTNNN, where T=Type prefix, NNN = format code. */
if (value <= ((UAC_FORMAT_TYPE_I << 12) +
ARRAY_LEN(audio_data_format_type_i))) {
format_string = audio_data_format_type_i[value];
} else if ((value >= (UAC_FORMAT_TYPE_II << 12)) &&
(value <= ((UAC_FORMAT_TYPE_II << 12) +
ARRAY_LEN(audio_data_format_type_ii)))) {
format_string = audio_data_format_type_ii[value & 0xfff];
} else if ((value >= (UAC_FORMAT_TYPE_III << 12)) &&
(value <= ((UAC_FORMAT_TYPE_III << 12) +
ARRAY_LEN(audio_data_format_type_iii)))) {
format_string = audio_data_format_type_iii[value & 0xfff];
}
printf(" %s\n", format_string);
}
/** Special rendering function for UAC2 AS interface bmFormats */
static void desc_snowflake_dump_uac2_as_interface_bmformats(
unsigned long long value,
unsigned int indent)
{
unsigned int i;
printf("\n");
for (i = 0; i < 5; i++) {
if ((value >> i) & 0x1) {
printf("%*s%s\n", indent * 2, "",
audio_data_format_type_i[i + 1]);
}
}