-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdispaud.c
1164 lines (850 loc) · 33.2 KB
/
dispaud.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
/*++
Copyright (c) 1997-2008 Microsoft Corporation
Module Name:
DISPAUD.C
Abstract:
This source file contains routines which update the edit control
to display information about USB Audio descriptors.
Environment:
user mode
Revision History:
03-07-1998 : created
--*/
/*****************************************************************************
I N C L U D E S
*****************************************************************************/
#include "uvcview.h"
/*****************************************************************************
G L O B A L S P R I V A T E T O T H I S F I L E
*****************************************************************************/
//
// USB Device Class Definition for Terminal Types 0.9 Draft Revision
//
STRINGLIST slAudioTerminalTypes [] =
{
//
// 2.1 USB Terminal Types
//
{0x0100, "USB Undefined", ""},
{0x0101, "USB streaming", ""},
{0x01FF, "USB vendor specific", ""},
//
// 2.2 Input Terminal Types
//
{0x0200, "Input Undefined", ""},
{0x0201, "Microphone", ""},
{0x0202, "Desktop microphone", ""},
{0x0203, "Personal microphone", ""},
{0x0204, "Omni-directional microphone", ""},
{0x0205, "Microphone array", ""},
{0x0206, "Processing microphone array", ""},
//
// 2.3 Output Terminal Types
//
{0x0300, "Output Undefined", ""},
{0x0301, "Speaker", ""},
{0x0302, "Headphones", ""},
{0x0303, "Head Mounted Display Audio", ""},
{0x0304, "Desktop speaker", ""},
{0x0305, "Room speaker", ""},
{0x0306, "Communication speaker", ""},
{0x0307, "Low frequency effects speaker", ""},
//
// 2.4 Bi-directional Terminal Types
//
{0x0400, "Bi-directional Undefined", ""},
{0x0401, "Handset", ""},
{0x0402, "Headset", ""},
{0x0403, "Speakerphone, no echo reduction", ""},
{0x0404, "Echo-suppressing speakerphone", ""},
{0x0405, "Echo-canceling speakerphone", ""},
//
// 2.5 Telephony Terminal Types
//
{0x0500, "Telephony Undefined", ""},
{0x0501, "Phone line", ""},
{0x0502, "Telephone", ""},
{0x0503, "Down Line Phone", ""},
//
// 2.6 External Terminal Types
//
{0x0600, "External Undefined", ""},
{0x0601, "Analog connector", ""},
{0x0602, "Digital audio interface", ""},
{0x0603, "Line connector", ""},
{0x0604, "Legacy audio connector", ""},
{0x0605, "S/PDIF interface", ""},
{0x0606, "1394 DA stream", ""},
{0x0607, "1394 DV stream soundtrack", ""},
//
// Embedded Function Terminal Types
//
{0x0700, "Embedded Undefined", ""},
{0x0701, "Level Calibration Noise Source", ""},
{0x0702, "Equalization Noise", ""},
{0x0703, "CD player", ""},
{0x0704, "DAT", ""},
{0x0705, "DCC", ""},
{0x0706, "MiniDisk", ""},
{0x0707, "Analog Tape", ""},
{0x0708, "Phonograph", ""},
{0x0709, "VCR Audio", ""},
{0x070A, "Video Disc Audio", ""},
{0x070B, "DVD Audio", ""},
{0x070C, "TV Tuner Audio", ""},
{0x070D, "Satellite Receiver Audio", ""},
{0x070E, "Cable Tuner Audio", ""},
{0x070F, "DSS Audio", ""},
{0x0710, "Radio Receiver", ""},
{0x0711, "Radio Transmitter", ""},
{0x0712, "Multi-track Recorder", ""},
{0x0713, "Synthesizer", ""},
};
STRINGLIST slAudioFormatTypes [] =
{
//
// A.1.1 Audio Data Format Type I Codes
//
{0x0000, "TYPE_I_UNDEFINED", ""},
{0x0001, "PCM", ""},
{0x0002, "PCM8", ""},
{0x0003, "IEEE_FLOAT", ""},
{0x0004, "ALAW", ""},
{0x0005, "MULAW", ""},
//
// A.1.2 Audio Data Format Type II Codes
//
{0x1000, "TYPE_II_UNDEFINED", ""},
{0x1001, "MPEG", ""},
{0x1002, "AC-3", ""},
//
// A.1.3 Audio Data Format Type III Codes
//
{0x2000, "TYPE_III_UNDEFINED", ""},
{0x2001, "IEC1937_AC-3", ""},
{0x2002, "IEC1937_MPEG-1_Layer1", ""},
{0x2003, "IEC1937_MPEG-1_Layer2/3 or IEC1937_MPEG-2_NOEXT", ""},
{0x2004, "IEC1937_MPEG-2_EXT", ""},
{0x2005, "IEC1937_MPEG-2_Layer1_LS", ""},
{0x2006, "IEC1937_MPEG-2_Layer2/3_LS", ""},
};
/*****************************************************************************
L O C A L F U N C T I O N P R O T O T Y P E S
*****************************************************************************/
BOOL
DisplayACHeader (
PUSB_AUDIO_AC_INTERFACE_HEADER_DESCRIPTOR HeaderDesc
);
BOOL
DisplayACInputTerminal (
PUSB_AUDIO_INPUT_TERMINAL_DESCRIPTOR ITDesc
);
BOOL
DisplayACOutputTerminal (
PUSB_AUDIO_OUTPUT_TERMINAL_DESCRIPTOR OTDesc
);
BOOL
DisplayACMixerUnit (
PUSB_AUDIO_MIXER_UNIT_DESCRIPTOR MixerDesc
);
BOOL
DisplayACSelectorUnit (
PUSB_AUDIO_SELECTOR_UNIT_DESCRIPTOR SelectorDesc
);
BOOL
DisplayACFeatureUnit (
PUSB_AUDIO_FEATURE_UNIT_DESCRIPTOR FeatureDesc
);
BOOL
DisplayACProcessingUnit (
PUSB_AUDIO_PROCESSING_UNIT_DESCRIPTOR ProcessingDesc
);
BOOL
DisplayACExtensionUnit (
PUSB_AUDIO_EXTENSION_UNIT_DESCRIPTOR ExtensionDesc
);
BOOL
DisplayASGeneral (
PUSB_AUDIO_GENERAL_DESCRIPTOR GeneralDesc
);
BOOL
DisplayCSEndpoint (
PUSB_AUDIO_ENDPOINT_DESCRIPTOR EndpointDesc
);
BOOL
DisplayASFormatType (
PUSB_AUDIO_COMMON_FORMAT_DESCRIPTOR FormatDesc
);
BOOL
DisplayASFormatSpecific (
PUSB_AUDIO_COMMON_DESCRIPTOR CommonDesc
);
VOID
DisplayBytes (
PUCHAR Data,
USHORT Len
);
/*****************************************************************************
L O C A L F U N C T I O N S
*****************************************************************************/
/*****************************************************************************
DisplayAudioDescriptor()
CommonDesc - An Audio Class Descriptor
bInterfaceSubClass - The SubClass of the Interface containing the descriptor
*****************************************************************************/
BOOL
DisplayAudioDescriptor (
PUSB_AUDIO_COMMON_DESCRIPTOR CommonDesc,
UCHAR bInterfaceSubClass
)
{
switch (CommonDesc->bDescriptorType)
{
case USB_AUDIO_CS_INTERFACE:
switch (bInterfaceSubClass)
{
case USB_AUDIO_SUBCLASS_AUDIOCONTROL:
switch (CommonDesc->bDescriptorSubtype)
{
case USB_AUDIO_AC_HEADER:
return DisplayACHeader((PUSB_AUDIO_AC_INTERFACE_HEADER_DESCRIPTOR)CommonDesc);
case USB_AUDIO_AC_INPUT_TERMINAL:
return DisplayACInputTerminal((PUSB_AUDIO_INPUT_TERMINAL_DESCRIPTOR)CommonDesc);
case USB_AUDIO_AC_OUTPUT_TERMINAL:
return DisplayACOutputTerminal((PUSB_AUDIO_OUTPUT_TERMINAL_DESCRIPTOR)CommonDesc);
case USB_AUDIO_AC_MIXER_UNIT:
return DisplayACMixerUnit((PUSB_AUDIO_MIXER_UNIT_DESCRIPTOR)CommonDesc);
case USB_AUDIO_AC_SELECTOR_UNIT:
return DisplayACSelectorUnit((PUSB_AUDIO_SELECTOR_UNIT_DESCRIPTOR)CommonDesc);
case USB_AUDIO_AC_FEATURE_UNIT:
return DisplayACFeatureUnit((PUSB_AUDIO_FEATURE_UNIT_DESCRIPTOR)CommonDesc);
case USB_AUDIO_AC_PROCESSING_UNIT:
return DisplayACProcessingUnit((PUSB_AUDIO_PROCESSING_UNIT_DESCRIPTOR)CommonDesc);
case USB_AUDIO_AC_EXTENSION_UNIT:
return DisplayACExtensionUnit((PUSB_AUDIO_EXTENSION_UNIT_DESCRIPTOR)CommonDesc);
default:
break;
}
break;
case USB_AUDIO_SUBCLASS_AUDIOSTREAMING:
switch (CommonDesc->bDescriptorSubtype)
{
case USB_AUDIO_AS_GENERAL:
return DisplayASGeneral((PUSB_AUDIO_GENERAL_DESCRIPTOR)CommonDesc);
case USB_AUDIO_AS_FORMAT_TYPE:
return DisplayASFormatType((PUSB_AUDIO_COMMON_FORMAT_DESCRIPTOR)CommonDesc);
break;
case USB_AUDIO_AS_FORMAT_SPECIFIC:
return DisplayASFormatSpecific(CommonDesc);
default:
break;
}
break;
default:
break;
}
break;
case USB_AUDIO_CS_ENDPOINT:
return DisplayCSEndpoint((PUSB_AUDIO_ENDPOINT_DESCRIPTOR)CommonDesc);
default:
break;
}
return FALSE;
}
/*****************************************************************************
DisplayACHeader()
*****************************************************************************/
BOOL
DisplayACHeader (
PUSB_AUDIO_AC_INTERFACE_HEADER_DESCRIPTOR HeaderDesc
)
{
UINT i = 0;
if (HeaderDesc->bLength < sizeof(USB_AUDIO_AC_INTERFACE_HEADER_DESCRIPTOR))
{
OOPS();
return FALSE;
}
AppendTextBuffer("\r\n ===>Audio Control Interface Header Descriptor<===\r\n");
AppendTextBuffer("bLength: 0x%02X\r\n",
HeaderDesc->bLength);
AppendTextBuffer("bDescriptorType: 0x%02X\r\n",
HeaderDesc->bDescriptorType);
AppendTextBuffer("bDescriptorSubtype: 0x%02X\r\n",
HeaderDesc->bDescriptorSubtype);
AppendTextBuffer("bcdADC: 0x%04X\r\n",
HeaderDesc->bcdADC);
AppendTextBuffer("wTotalLength: 0x%04X\r\n",
HeaderDesc->wTotalLength);
AppendTextBuffer("bInCollection: 0x%02X\r\n",
HeaderDesc->bInCollection);
for (i=0; i<HeaderDesc->bInCollection; i++)
{
AppendTextBuffer("baInterfaceNr[%d]: 0x%02X\r\n",
i+1,
HeaderDesc->baInterfaceNr[i]);
}
return TRUE;
}
/*****************************************************************************
DisplayACInputTerminal()
*****************************************************************************/
BOOL
DisplayACInputTerminal (
PUSB_AUDIO_INPUT_TERMINAL_DESCRIPTOR ITDesc
)
{
PCHAR pStr = NULL;
if (ITDesc->bLength != sizeof(USB_AUDIO_INPUT_TERMINAL_DESCRIPTOR))
{
OOPS();
return FALSE;
}
AppendTextBuffer("\r\n ===>Audio Control Input Terminal Descriptor<===\r\n");
AppendTextBuffer("bLength: 0x%02X\r\n",
ITDesc->bLength);
AppendTextBuffer("bDescriptorType: 0x%02X\r\n",
ITDesc->bDescriptorType);
AppendTextBuffer("bDescriptorSubtype: 0x%02X\r\n",
ITDesc->bDescriptorSubtype);
AppendTextBuffer("bTerminalID: 0x%02X\r\n",
ITDesc->bTerminalID);
AppendTextBuffer("wTerminalType: 0x%04X",
ITDesc->wTerminalType);
pStr = GetStringFromList(slAudioTerminalTypes,
sizeof(slAudioTerminalTypes) / sizeof(STRINGLIST),
ITDesc->wTerminalType,
"Invalid AC Input Terminal Type");
AppendTextBuffer(" (%s)\r\n", pStr);
AppendTextBuffer("bAssocTerminal: 0x%02X\r\n",
ITDesc->bAssocTerminal);
AppendTextBuffer("bNrChannels: 0x%02X\r\n",
ITDesc->bNrChannels);
AppendTextBuffer("wChannelConfig: 0x%04X\r\n",
ITDesc->wChannelConfig);
AppendTextBuffer("iChannelNames: 0x%02X\r\n",
ITDesc->iChannelNames);
AppendTextBuffer("iTerminal: 0x%02X\r\n",
ITDesc->iTerminal);
return TRUE;
}
/*****************************************************************************
DisplayACOutputTerminal()
*****************************************************************************/
BOOL
DisplayACOutputTerminal (
PUSB_AUDIO_OUTPUT_TERMINAL_DESCRIPTOR OTDesc
)
{
PCHAR pStr = NULL;
if (OTDesc->bLength != sizeof(USB_AUDIO_OUTPUT_TERMINAL_DESCRIPTOR))
{
OOPS();
return FALSE;
}
AppendTextBuffer("\r\n ===>Audio Control Output Terminal Descriptor<===\r\n");
AppendTextBuffer("bLength: 0x%02X\r\n",
OTDesc->bLength);
AppendTextBuffer("bDescriptorType: 0x%02X\r\n",
OTDesc->bDescriptorType);
AppendTextBuffer("bDescriptorSubtype: 0x%02X\r\n",
OTDesc->bDescriptorSubtype);
AppendTextBuffer("bTerminalID: 0x%02X\r\n",
OTDesc->bTerminalID);
AppendTextBuffer("wTerminalType: 0x%04X",
OTDesc->wTerminalType);
pStr = GetStringFromList(slAudioTerminalTypes,
sizeof(slAudioTerminalTypes) / sizeof(STRINGLIST),
OTDesc->wTerminalType,
"Invalid AC Output Terminal Type");
AppendTextBuffer(" (%s)\r\n", pStr);
AppendTextBuffer("bAssocTerminal: 0x%02X\r\n",
OTDesc->bAssocTerminal);
AppendTextBuffer("bSourceID: 0x%02X\r\n",
OTDesc->bSourceID);
AppendTextBuffer("iTerminal: 0x%02X\r\n",
OTDesc->iTerminal);
return TRUE;
}
/*****************************************************************************
DisplayACMixerUnit()
*****************************************************************************/
BOOL
DisplayACMixerUnit (
PUSB_AUDIO_MIXER_UNIT_DESCRIPTOR MixerDesc
)
{
UCHAR i = 0;
PUCHAR data = NULL;
if (MixerDesc->bLength < 10)
{
OOPS();
return FALSE;
}
AppendTextBuffer("\r\n ===>Audio Control Mixer Unit Descriptor<===\r\n");
AppendTextBuffer("bLength: 0x%02X\r\n",
MixerDesc->bLength);
AppendTextBuffer("bDescriptorType: 0x%02X\r\n",
MixerDesc->bDescriptorType);
AppendTextBuffer("bDescriptorSubtype: 0x%02X\r\n",
MixerDesc->bDescriptorSubtype);
AppendTextBuffer("bUnitID: 0x%02X\r\n",
MixerDesc->bUnitID);
AppendTextBuffer("bNrInPins: 0x%02X\r\n",
MixerDesc->bNrInPins);
for (i=0; i<MixerDesc->bNrInPins; i++)
{
AppendTextBuffer("baSourceID[%d]: 0x%02X\r\n",
i+1,
MixerDesc->baSourceID[i]);
}
data = &MixerDesc->baSourceID[MixerDesc->bNrInPins];
AppendTextBuffer("bNrChannels: 0x%02X\r\n",
*data++);
AppendTextBuffer("wChannelConfig: 0x%04X\r\n",
*(PUSHORT)data);
data = (PUCHAR) ((PUSHORT) data + 1);
AppendTextBuffer("iChannelNames: 0x%02X\r\n",
*data++);
AppendTextBuffer("bmControls:\r\n");
i = MixerDesc->bLength - 10 - MixerDesc->bNrInPins;
DisplayBytes(data, i);
data += i;
AppendTextBuffer("iMixer: 0x%02X\r\n",
*data);
return TRUE;
}
/*****************************************************************************
DisplayACSelectorUnit()
*****************************************************************************/
BOOL
DisplayACSelectorUnit (
PUSB_AUDIO_SELECTOR_UNIT_DESCRIPTOR SelectorDesc
)
{
UCHAR i = 0;
PUCHAR data = NULL;
if (SelectorDesc->bLength < 6)
{
OOPS();
return FALSE;
}
AppendTextBuffer("\r\n ===>Audio Control Selector Unit Descriptor<===\r\n");
AppendTextBuffer("bLength: 0x%02X\r\n",
SelectorDesc->bLength);
AppendTextBuffer("bDescriptorType: 0x%02X\r\n",
SelectorDesc->bDescriptorType);
AppendTextBuffer("bDescriptorSubtype: 0x%02X\r\n",
SelectorDesc->bDescriptorSubtype);
AppendTextBuffer("bUnitID: 0x%02X\r\n",
SelectorDesc->bUnitID);
AppendTextBuffer("bNrInPins: 0x%02X\r\n",
SelectorDesc->bNrInPins);
for (i=0; i<SelectorDesc->bNrInPins; i++)
{
AppendTextBuffer("baSourceID[%d]: 0x%02X\r\n",
i+1,
SelectorDesc->baSourceID[i]);
}
data = &SelectorDesc->baSourceID[SelectorDesc->bNrInPins];
AppendTextBuffer("iSelector: 0x%02X\r\n",
*data);
return TRUE;
}
/*****************************************************************************
DisplayACFeatureUnit()
*****************************************************************************/
BOOL
DisplayACFeatureUnit (
PUSB_AUDIO_FEATURE_UNIT_DESCRIPTOR FeatureDesc
)
{
UCHAR i = 0;
UCHAR n = 0;
UCHAR ch = 0;
PUCHAR data = NULL;
AppendTextBuffer("\r\n ===>Audio Control Feature Unit Descriptor<===\r\n");
AppendTextBuffer("bLength: 0x%02X\r\n",
FeatureDesc->bLength);
AppendTextBuffer("bDescriptorType: 0x%02X\r\n",
FeatureDesc->bDescriptorType);
AppendTextBuffer("bDescriptorSubtype: 0x%02X\r\n",
FeatureDesc->bDescriptorSubtype);
AppendTextBuffer("bUnitID: 0x%02X\r\n",
FeatureDesc->bUnitID);
AppendTextBuffer("bSourceID: 0x%02X\r\n",
FeatureDesc->bSourceID);
AppendTextBuffer("bControlSize: 0x%02X\r\n",
FeatureDesc->bControlSize);
if (FeatureDesc->bLength < 7)
{
AppendTextBuffer("*!*WARNING: bLength is invalid (< 7)\r\n");
OOPS();
return FALSE;
}
else if(FeatureDesc->bLength == 7)
{
AppendTextBuffer("Audio controls are not available (bLength = 7)\r\n");
return TRUE;
}
n = FeatureDesc->bControlSize;
if(n == 0)
{
AppendTextBuffer("Audio controls are not available (bControlSize = 0)\r\n");
return TRUE;
}
ch = ((FeatureDesc->bLength - 7) / n) - 1;
// Check if there are extra bytes in descriptor based on formula in Spec
if (FeatureDesc->bLength != (7 + (ch + 1) * n))
{
// The descriptor length is greater than number of bmaControls
AppendTextBuffer("*!*WARNING: bLength is greater than number of bmaControls (bLength > ( 7 + (ch + 1) * n)\r\n");
}
data = &FeatureDesc->bmaControls[0];
if (ch == (UCHAR) -1)
{
// This should not happen, but this check is put in place so we don't loop for a long time below
AppendTextBuffer("*!*WARNING: Either bLength or bControlSize are invalid. The calculated logical channel count is -1. ((bLength - 7)/ n) - 1\r\n");
OOPS();
return FALSE;
}
for (i=0; i<=ch; i++)
{
AppendTextBuffer("bmaControls[%d]: ", i);
DisplayBytes(data, n);
data += n;
}
AppendTextBuffer("iFeature: 0x%02X\r\n",
*data);
return TRUE;
}
/*****************************************************************************
DisplayACProcessingUnit()
*****************************************************************************/
BOOL
DisplayACProcessingUnit (
PUSB_AUDIO_PROCESSING_UNIT_DESCRIPTOR ProcessingDesc
)
{
UCHAR i = 0;
PUCHAR data = NULL;
if (ProcessingDesc->bLength < sizeof(USB_AUDIO_PROCESSING_UNIT_DESCRIPTOR))
{
OOPS();
return FALSE;
}
AppendTextBuffer("\r\n ===>Audio Control Processing Unit Descriptor<===\r\n");
AppendTextBuffer("bLength: 0x%02X\r\n",
ProcessingDesc->bLength);
AppendTextBuffer("bDescriptorType: 0x%02X\r\n",
ProcessingDesc->bDescriptorType);
AppendTextBuffer("bDescriptorSubtype: 0x%02X\r\n",
ProcessingDesc->bDescriptorSubtype);
AppendTextBuffer("bUnitID: 0x%02X\r\n",
ProcessingDesc->bUnitID);
AppendTextBuffer("wProcessType: 0x%04X",
ProcessingDesc->wProcessType);
switch (ProcessingDesc->wProcessType)
{
case USB_AUDIO_PROCESS_UNDEFINED:
AppendTextBuffer("(Undefined Process)\r\n");
break;
case USB_AUDIO_PROCESS_UPDOWNMIX:
AppendTextBuffer("(Up / Down Mix Process)\r\n");
break;
case USB_AUDIO_PROCESS_DOLBYPROLOGIC:
AppendTextBuffer("(Dolby Prologic Process)\r\n");
break;
case USB_AUDIO_PROCESS_3DSTEREOEXTENDER:
AppendTextBuffer("(3D-Stereo Extender Process)\r\n");
break;
case USB_AUDIO_PROCESS_REVERBERATION:
AppendTextBuffer("(Reverberation Process)\r\n");
break;
case USB_AUDIO_PROCESS_CHORUS:
AppendTextBuffer("(Chorus Process)\r\n");
break;
case USB_AUDIO_PROCESS_DYNRANGECOMP:
AppendTextBuffer("(Dynamic Range Compressor Process)\r\n");
break;
default:
AppendTextBuffer("\r\n");
break;
}
AppendTextBuffer("bNrInPins: 0x%02X\r\n",
ProcessingDesc->bNrInPins);
for (i=0; i<ProcessingDesc->bNrInPins; i++)
{
AppendTextBuffer("baSourceID[%d]: 0x%02X\r\n",
i+1,
ProcessingDesc->baSourceID[i]);
}
data = &ProcessingDesc->baSourceID[ProcessingDesc->bNrInPins];
AppendTextBuffer("bNrChannels: 0x%02X\r\n",
*data++);
AppendTextBuffer("wChannelConfig: 0x%04X\r\n",
*(PUSHORT)data);
data = (PUCHAR) ((PUSHORT) data + 1);
AppendTextBuffer("iChannelNames: 0x%02X\r\n",
*data++);
i = *data++;
AppendTextBuffer("bControlSize: 0x%02X\r\n",
i);
AppendTextBuffer("bmControls:\r\n");
DisplayBytes(data, i);
data += i;
AppendTextBuffer("iProcessing: 0x%02X\r\n",
*data++);
i = ProcessingDesc->bLength - 13 - ProcessingDesc->bNrInPins - i;
if (i)
{
AppendTextBuffer("Process Specific:\r\n");
DisplayBytes(data, i);
}
return TRUE;
}
/*****************************************************************************
DisplayACExtensionUnit()
*****************************************************************************/
BOOL
DisplayACExtensionUnit (
PUSB_AUDIO_EXTENSION_UNIT_DESCRIPTOR ExtensionDesc
)
{
UCHAR i = 0;
PUCHAR data = NULL;
if (ExtensionDesc->bLength < 13)
{
OOPS();
return FALSE;
}
AppendTextBuffer("\r\n ===>Audio Control Extension Unit Descriptor<===\r\n");
AppendTextBuffer("bLength: 0x%02X\r\n",
ExtensionDesc->bLength);
AppendTextBuffer("bDescriptorType: 0x%02X\r\n",
ExtensionDesc->bDescriptorType);
AppendTextBuffer("bDescriptorSubtype: 0x%02X\r\n",
ExtensionDesc->bDescriptorSubtype);
AppendTextBuffer("bUnitID: 0x%02X\r\n",
ExtensionDesc->bUnitID);
AppendTextBuffer("wExtensionCode: 0x%04X\r\n",
ExtensionDesc->wExtensionCode);
AppendTextBuffer("bNrInPins: 0x%02X\r\n",
ExtensionDesc->bNrInPins);
for (i=0; i<ExtensionDesc->bNrInPins; i++)
{
AppendTextBuffer("baSourceID[%d]: 0x%02X\r\n",
i+1,
ExtensionDesc->baSourceID[i]);
}
data = &ExtensionDesc->baSourceID[ExtensionDesc->bNrInPins];
AppendTextBuffer("bNrChannels: 0x%02X\r\n",
*data++);
AppendTextBuffer("wChannelConfig: 0x%04X\r\n",
*(PUSHORT)data);
data = (PUCHAR) ((PUSHORT) data + 1);
AppendTextBuffer("iChannelNames: 0x%02X\r\n",
*data++);
i = *data++;
AppendTextBuffer("bControlSize: 0x%02X\r\n",
i);
AppendTextBuffer("bmControls:\r\n");
DisplayBytes(data, i);
data += i;
AppendTextBuffer("iExtension: 0x%02X\r\n",
*data);
return TRUE;
}
/*****************************************************************************
DisplayASGeneral()
*****************************************************************************/
BOOL
DisplayASGeneral (
PUSB_AUDIO_GENERAL_DESCRIPTOR GeneralDesc
)
{
PCHAR pStr = NULL;
if (GeneralDesc->bLength != sizeof(USB_AUDIO_GENERAL_DESCRIPTOR))
{
OOPS();
return FALSE;
}
AppendTextBuffer("\r\n ===>Audio Streaming Class Specific Interface Descriptor<===\r\n");
AppendTextBuffer("bLength: 0x%02X\r\n",
GeneralDesc->bLength);
AppendTextBuffer("bDescriptorType: 0x%02X\r\n",
GeneralDesc->bDescriptorType);
AppendTextBuffer("bDescriptorSubtype: 0x%02X\r\n",
GeneralDesc->bDescriptorSubtype);
AppendTextBuffer("bTerminalLink: 0x%02X\r\n",
GeneralDesc->bTerminalLink);
AppendTextBuffer("bDelay: 0x%02X\r\n",
GeneralDesc->bDelay);
AppendTextBuffer("wFormatTag: 0x%04X",
GeneralDesc->wFormatTag);
pStr = GetStringFromList(slAudioFormatTypes,
sizeof(slAudioFormatTypes) / sizeof(STRINGLIST),
GeneralDesc->wFormatTag,
"Invalid AC Format Type");
AppendTextBuffer(" (%s)\r\n", pStr);
return TRUE;
}
/*****************************************************************************
DisplayCSEndpoint()
*****************************************************************************/
BOOL
DisplayCSEndpoint (
PUSB_AUDIO_ENDPOINT_DESCRIPTOR EndpointDesc
)
{
if (EndpointDesc->bLength != sizeof(USB_AUDIO_ENDPOINT_DESCRIPTOR))
{
OOPS();
return FALSE;
}
AppendTextBuffer("\r\n ===>Audio Streaming Class Specific Audio Data Endpoint Descriptor<===\r\n");
AppendTextBuffer("bLength: 0x%02X\r\n",
EndpointDesc->bLength);
AppendTextBuffer("bDescriptorType: 0x%02X\r\n",
EndpointDesc->bDescriptorType);
AppendTextBuffer("bDescriptorSubtype: 0x%02X\r\n",
EndpointDesc->bDescriptorSubtype);
AppendTextBuffer("bmAttributes: 0x%02X\r\n",
EndpointDesc->bmAttributes);
AppendTextBuffer("bLockDelayUnits: 0x%02X\r\n",
EndpointDesc->bLockDelayUnits);
AppendTextBuffer("wLockDelay: 0x%04X\r\n",
EndpointDesc->wLockDelay);
return TRUE;
}
/*****************************************************************************
DisplayASFormatType()
*****************************************************************************/
BOOL
DisplayASFormatType (
PUSB_AUDIO_COMMON_FORMAT_DESCRIPTOR FormatDesc
)
{
UCHAR i = 0;
UCHAR n = 0;
ULONG freq = 0;
PUCHAR data = NULL;
if (FormatDesc->bLength < sizeof(USB_AUDIO_COMMON_FORMAT_DESCRIPTOR))