[SDK] One step further towards ReactOS source code tree restructure: the sdk folder...
[reactos.git] / reactos / sdk / lib / drivers / sound / libusbaudio / priv.h
1 #pragma once
2
3 #include <pseh/pseh2.h>
4 #include <ntddk.h>
5
6 #include <windef.h>
7 #define NOBITMAP
8 #include <mmreg.h>
9 #include <ks.h>
10 #include <ksmedia.h>
11 #include <mmreg.h>
12 #include <mmsystem.h>
13 #include "Usb100.h"
14 #include <debug.h>
15
16 #include "libusbaudio.h"
17
18 #define USB_AUDIO_CONTROL_TERMINAL_DESCRIPTOR_TYPE (0x24)
19 #define USB_AUDIO_STREAMING_INTERFACE_INTERFACE_DESCRIPTOR_TYPE (0x24)
20
21 #define USB_AUDIO_INPUT_TERMINAL (0x02)
22 #define USB_AUDIO_OUTPUT_TERMINAL (0x03)
23
24 /* Universal Serial Bus Device Class Definition for Terminal Types Section A 1.1 */
25 #define USB_AUDIO_PCM_DATA_FORMAT (0x01)
26 #define USB_AUDIO_PCM8_DATA_FORMAT (0x02)
27 #define USB_AUDIO_IEEE_FLOAT_DATA_FORMAT (0x03)
28 #define USB_AUDIO_ALAW_DATA_FORMAT (0x04)
29 #define USB_AUDIO_MULAW_DATA_FORMAT (0x05)
30
31 /* Universal Serial Bus Device Class Definition for Terminal Types Section A 1.1 */
32 #define USB_AUDIO_DATA_FORMAT_TYPE_1 (0x01)
33 #define USB_AUDIO_DATA_FORMAT_TYPE_2 (0x02)
34 #define USB_AUDIO_DATA_FORMAT_TYPE_3 (0x03)
35
36
37
38 /* Universal Serial Bus Device Class Definition for Terminal Types Section 2.2 */
39 #define USB_AUDIO_STREAMING_TERMINAL_TYPE (0x0101)
40
41 #define USB_AUDIO_MICROPHONE_TERMINAL_TYPE (0x0201)
42 #define USB_AUDIO_DESKTOP_MICROPHONE_TERMINAL_TYPE (0x0202)
43 #define USB_AUDIO_PERSONAL_MICROPHONE_TERMINAL_TYPE (0x0203)
44 #define USB_AUDIO_OMMNI_MICROPHONE_TERMINAL_TYPE (0x0204)
45 #define USB_AUDIO_ARRAY_MICROPHONE_TERMINAL_TYPE (0x0205)
46 #define USB_AUDIO_ARRAY_PROCESSING_MICROPHONE_TERMINAL_TYPE (0x0206)
47
48 #define USB_AUDIO_SPEAKER_TERMINAL_TYPE (0x0301)
49 #define USB_HEADPHONES_SPEAKER_TERMINAL_TYPE (0x0302)
50 #define USB_AUDIO_HMDA_TERMINAL_TYPE (0x0303)
51 #define USB_AUDIO_DESKTOP_SPEAKER_TERMINAL_TYPE (0x0304)
52 #define USB_AUDIO_ROOM_SPEAKER_TERMINAL_TYPE (0x0305)
53 #define USB_AUDIO_COMMUNICATION_SPEAKER_TERMINAL_TYPE (0x0306)
54 #define USB_AUDIO_SUBWOOFER_TERMINAL_TYPE (0x0307)
55 #define USB_AUDIO_UNDEFINED_TERMINAL_TYPE (0xFFFF)
56
57 #define HTONS(x) ( ( (((unsigned short)(x)) >>8) & 0xff) | \
58 ((((unsigned short)(x)) & 0xff)<<8) )
59
60 #include <pshpack1.h>
61
62 typedef struct
63 {
64 UCHAR bLength;
65 UCHAR bDescriptorType;
66 UCHAR bDescriptorSubtype;
67 UCHAR bTerminalID;
68 USHORT wTerminalType;
69 UCHAR bAssocTerminal;
70 UCHAR bSourceID;
71 UCHAR iTerminal;
72 }USB_AUDIO_CONTROL_OUTPUT_TERMINAL_DESCRIPTOR, *PUSB_AUDIO_CONTROL_OUTPUT_TERMINAL_DESCRIPTOR;
73
74
75 typedef struct
76 {
77 UCHAR bLength;
78 UCHAR bDescriptorType;
79 UCHAR bDescriptorSubtype;
80 UCHAR bTerminalID;
81 USHORT wTerminalType;
82 UCHAR bAssocTerminal;
83 UCHAR bNrChannels;
84 USHORT wChannelConfig;
85 UCHAR iChannelNames;
86 UCHAR iTerminal;
87 }USB_AUDIO_CONTROL_INPUT_TERMINAL_DESCRIPTOR, *PUSB_AUDIO_CONTROL_INPUT_TERMINAL_DESCRIPTOR;
88
89 typedef struct
90 {
91 UCHAR bLength;
92 UCHAR bDescriptorType;
93 UCHAR bDescriptorSubtype;
94 UCHAR bTerminalLink;
95 UCHAR bDelay;
96 USHORT wFormatTag;
97 }USB_AUDIO_STREAMING_INTERFACE_DESCRIPTOR, *PUSB_AUDIO_STREAMING_INTERFACE_DESCRIPTOR;
98 C_ASSERT(sizeof(USB_AUDIO_STREAMING_INTERFACE_DESCRIPTOR) == 0x07);
99
100 typedef struct
101 {
102 UCHAR bLength;
103 UCHAR bDescriptorType;
104 UCHAR bDescriptorSubtype;
105 UCHAR bFormatType;
106 UCHAR bNrChannels;
107 UCHAR bSubframeSize;
108 UCHAR bBitResolution;
109 UCHAR bSamFreqType;
110 UCHAR tSamFreq[3];
111 }USB_AUDIO_STREAMING_FORMAT_TYPE_1, *PUSB_AUDIO_STREAMING_FORMAT_TYPE_1;
112 C_ASSERT(sizeof(USB_AUDIO_STREAMING_FORMAT_TYPE_1) == 0x0B);
113
114 /* format.c */
115
116 USBAUDIO_STATUS
117 UsbAudio_AssignDataRanges(
118 IN PUSBAUDIO_CONTEXT Context,
119 IN PUCHAR ConfigurationDescriptor,
120 IN ULONG ConfigurationDescriptorSize,
121 IN PKSFILTER_DESCRIPTOR FilterDescriptor,
122 IN PUSB_COMMON_DESCRIPTOR * InterfaceDescriptors,
123 IN ULONG InterfaceCount,
124 IN ULONG InterfaceIndex,
125 IN PULONG TerminalIds);
126
127
128 /* parser.c */
129
130 USBAUDIO_STATUS
131 UsbAudio_CountInterfaceDescriptors(
132 IN PUCHAR ConfigurationDescriptor,
133 IN ULONG ConfigurationDescriptorLength,
134 OUT PULONG DescriptorCount);
135
136 USBAUDIO_STATUS
137 UsbAudio_CreateInterfaceDescriptorsArray(
138 IN PUSBAUDIO_CONTEXT Context,
139 IN PUCHAR ConfigurationDescriptor,
140 IN ULONG ConfigurationDescriptorLength,
141 IN ULONG ArrayLength,
142 OUT PUSB_COMMON_DESCRIPTOR ** Array);
143
144 ULONG
145 UsbAudio_GetAudioControlInterfaceIndex(
146 IN PUSB_COMMON_DESCRIPTOR * InterfaceDescriptors,
147 IN ULONG DescriptorCount);
148
149 USBAUDIO_STATUS
150 UsbAudio_CountAudioDescriptors(
151 IN PUCHAR ConfigurationDescriptor,
152 IN ULONG ConfigurationDescriptorLength,
153 IN PUSB_COMMON_DESCRIPTOR * InterfaceDescriptors,
154 IN ULONG InterfaceDescriptorCount,
155 IN ULONG InterfaceDescriptorIndex,
156 OUT PULONG DescriptorCount);
157
158 USBAUDIO_STATUS
159 UsbAudio_CreateAudioDescriptorArray(
160 IN PUSBAUDIO_CONTEXT Context,
161 IN PUCHAR ConfigurationDescriptor,
162 IN ULONG ConfigurationDescriptorLength,
163 IN PUSB_COMMON_DESCRIPTOR * InterfaceDescriptors,
164 IN ULONG InterfaceDescriptorCount,
165 IN ULONG InterfaceDescriptorIndex,
166 IN ULONG ArrayLength,
167 OUT PUSB_COMMON_DESCRIPTOR ** Array);
168
169 USBAUDIO_STATUS
170 UsbAudio_AssignTerminalIds(
171 IN PUSBAUDIO_CONTEXT Context,
172 IN ULONG TerminalIdsLength,
173 IN PUSB_COMMON_DESCRIPTOR * TerminalIds,
174 OUT PULONG PinArray,
175 OUT PULONG PinArrayCount);
176
177 PUSB_AUDIO_CONTROL_INPUT_TERMINAL_DESCRIPTOR
178 UsbAudio_GetTerminalDescriptorById(
179 IN PUSB_COMMON_DESCRIPTOR *Descriptors,
180 IN ULONG DescriptorCount,
181 IN ULONG TerminalId);
182