1
|
/* ----------------------------------------------------------------------------
|
2
|
* ATMEL Microcontroller Software Support
|
3
|
* ----------------------------------------------------------------------------
|
4
|
* Copyright (c) 2008, Atmel Corporation
|
5
|
*
|
6
|
* All rights reserved.
|
7
|
*
|
8
|
* Redistribution and use in source and binary forms, with or without
|
9
|
* modification, are permitted provided that the following conditions are met:
|
10
|
*
|
11
|
* - Redistributions of source code must retain the above copyright notice,
|
12
|
* this list of conditions and the disclaimer below.
|
13
|
*
|
14
|
* Atmel's name may not be used to endorse or promote products derived from
|
15
|
* this software without specific prior written permission.
|
16
|
*
|
17
|
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
18
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
19
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
20
|
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
21
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
23
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
24
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
26
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
* ----------------------------------------------------------------------------
|
28
|
*/
|
29
|
|
30
|
//------------------------------------------------------------------------------
|
31
|
// Headers
|
32
|
//------------------------------------------------------------------------------
|
33
|
|
34
|
#include "fast_source_descr.h"
|
35
|
#include <board.h>
|
36
|
#include <usb/common/core/USBGenericDescriptor.h>
|
37
|
#include <usb/common/core/USBDeviceDescriptor.h>
|
38
|
#include <usb/common/core/USBConfigurationDescriptor.h>
|
39
|
#include <usb/common/core/USBInterfaceDescriptor.h>
|
40
|
#include <usb/common/core/USBEndpointDescriptor.h>
|
41
|
#include <usb/common/core/USBStringDescriptor.h>
|
42
|
#include <usb/common/audio/AUDGenericDescriptor.h>
|
43
|
#include <usb/common/audio/AUDDeviceDescriptor.h>
|
44
|
#include <usb/common/audio/AUDControlInterfaceDescriptor.h>
|
45
|
#include <usb/common/audio/AUDStreamingInterfaceDescriptor.h>
|
46
|
#include <usb/common/audio/AUDEndpointDescriptor.h>
|
47
|
#include <usb/common/audio/AUDDataEndpointDescriptor.h>
|
48
|
#include <usb/common/audio/AUDFormatTypeOneDescriptor.h>
|
49
|
#include <usb/common/audio/AUDHeaderDescriptor.h>
|
50
|
#include <usb/common/audio/AUDFeatureUnitDescriptor.h>
|
51
|
#include <usb/common/audio/AUDInputTerminalDescriptor.h>
|
52
|
#include <usb/common/audio/AUDOutputTerminalDescriptor.h>
|
53
|
|
54
|
#include <usb/device/dfu/dfu.h>
|
55
|
|
56
|
// #define AUDIOSOURCE 1
|
57
|
#undef AUDIOSOURCE
|
58
|
|
59
|
|
60
|
//------------------------------------------------------------------------------
|
61
|
// Definitions
|
62
|
//------------------------------------------------------------------------------
|
63
|
|
64
|
//------------------------------------------------------------------------------
|
65
|
/// \page "Audio Loop Record Device Codes"
|
66
|
///
|
67
|
/// This page lists the %device IDs and release number of the USB Audio Loop Record
|
68
|
/// %device.
|
69
|
///
|
70
|
/// !Codes
|
71
|
/// - AUDDLoopRecDriverDescriptors_VENDORID
|
72
|
/// - AUDDLoopRecDriverDescriptors_PRODUCTID
|
73
|
/// - AUDDLoopRecDriverDescriptors_RELEASE
|
74
|
|
75
|
/// Device vendor ID.
|
76
|
#define AUDDLoopRecDriverDescriptors_VENDORID 0x16C0
|
77
|
/// Device product ID.
|
78
|
#define AUDDLoopRecDriverDescriptors_PRODUCTID 0x0763
|
79
|
/// Device release number in BCD format.
|
80
|
#define AUDDLoopRecDriverDescriptors_RELEASE 0x0100
|
81
|
//------------------------------------------------------------------------------
|
82
|
|
83
|
|
84
|
#ifdef AUDIOSOURCE
|
85
|
//------------------------------------------------------------------------------
|
86
|
// Internal types
|
87
|
//------------------------------------------------------------------------------
|
88
|
|
89
|
//------------------------------------------------------------------------------
|
90
|
/// Audio control header descriptor with one slave interface.
|
91
|
//------------------------------------------------------------------------------
|
92
|
#ifdef __ICCARM__ // IAR
|
93
|
#pragma pack(1) // IAR
|
94
|
#define __attribute__(...) // IAR
|
95
|
#endif // IAR
|
96
|
|
97
|
//------------------------------------------------------------------------------
|
98
|
/// Header descriptor with 1 interface.
|
99
|
//------------------------------------------------------------------------------
|
100
|
typedef struct {
|
101
|
|
102
|
/// Header descriptor.
|
103
|
AUDHeaderDescriptor header;
|
104
|
/// Id of the first grouped interface - Speaker.
|
105
|
unsigned char bInterface0;
|
106
|
/// Id of the second grouped interface - Speakerphone.
|
107
|
unsigned char bInterface1;
|
108
|
|
109
|
} __attribute__ ((packed)) AUDHeaderDescriptor2; // GCC
|
110
|
|
111
|
//------------------------------------------------------------------------------
|
112
|
/// Feature unit descriptor with 3 channel controls (master, right, left).
|
113
|
//------------------------------------------------------------------------------
|
114
|
typedef struct {
|
115
|
|
116
|
/// Feature unit descriptor.
|
117
|
AUDFeatureUnitDescriptor feature;
|
118
|
/// Available controls for each channel.
|
119
|
unsigned char bmaControls[3];
|
120
|
/// Index of a string descriptor for the feature unit.
|
121
|
unsigned char iFeature;
|
122
|
|
123
|
} __attribute__ ((packed)) AUDFeatureUnitDescriptor3; // GCC
|
124
|
|
125
|
//------------------------------------------------------------------------------
|
126
|
/// List of descriptors for detailling the audio control interface of a
|
127
|
/// device using a USB Audio Loop Recorder driver.
|
128
|
//------------------------------------------------------------------------------
|
129
|
typedef struct {
|
130
|
|
131
|
/// Header descriptor (with one slave interface).
|
132
|
AUDHeaderDescriptor2 header;
|
133
|
/// Input terminal descriptor.
|
134
|
AUDInputTerminalDescriptor inputLoopRec;
|
135
|
/// Output terminal descriptor.
|
136
|
AUDOutputTerminalDescriptor outputLoopRec;
|
137
|
/// Feature unit descriptor - LoopRec.
|
138
|
AUDFeatureUnitDescriptor3 featureLoopRec;
|
139
|
/// Input terminal descriptor.
|
140
|
AUDInputTerminalDescriptor inputRec;
|
141
|
/// Output terminal descriptor.
|
142
|
AUDOutputTerminalDescriptor outputRec;
|
143
|
/// Feature unit descriptor - LoopRecphone.
|
144
|
AUDFeatureUnitDescriptor3 featureRec;
|
145
|
|
146
|
} __attribute__ ((packed)) AUDDLoopRecDriverAudioControlDescriptors; // GCC
|
147
|
|
148
|
//------------------------------------------------------------------------------
|
149
|
/// Format type I descriptor with one discrete sampling frequency.
|
150
|
//------------------------------------------------------------------------------
|
151
|
typedef struct {
|
152
|
|
153
|
/// Format type I descriptor.
|
154
|
AUDFormatTypeOneDescriptor formatType;
|
155
|
/// Sampling frequency in Hz.
|
156
|
unsigned char tSamFreq[3];
|
157
|
|
158
|
} __attribute__ ((packed)) AUDFormatTypeOneDescriptor1; // GCC
|
159
|
|
160
|
//------------------------------------------------------------------------------
|
161
|
/// Holds a list of descriptors returned as part of the configuration of
|
162
|
/// a USB Audio Loop Record device.
|
163
|
//------------------------------------------------------------------------------
|
164
|
typedef struct {
|
165
|
|
166
|
/// Standard configuration.
|
167
|
USBConfigurationDescriptor configuration;
|
168
|
/// Audio control interface.
|
169
|
USBInterfaceDescriptor control;
|
170
|
/// Descriptors for the audio control interface.
|
171
|
AUDDLoopRecDriverAudioControlDescriptors controlDescriptors;
|
172
|
//- AUDIO OUT
|
173
|
/// Streaming out interface descriptor (with no endpoint, required).
|
174
|
USBInterfaceDescriptor streamingOutNoIsochronous;
|
175
|
/// Streaming out interface descriptor.
|
176
|
USBInterfaceDescriptor streamingOut;
|
177
|
/// Audio class descriptor for the streaming out interface.
|
178
|
AUDStreamingInterfaceDescriptor streamingOutClass;
|
179
|
/// Stream format descriptor.
|
180
|
AUDFormatTypeOneDescriptor1 streamingOutFormatType;
|
181
|
/// Streaming out endpoint descriptor.
|
182
|
AUDEndpointDescriptor streamingOutEndpoint;
|
183
|
/// Audio class descriptor for the streaming out endpoint.
|
184
|
AUDDataEndpointDescriptor streamingOutDataEndpoint;
|
185
|
//- AUDIO IN
|
186
|
/// Streaming in interface descriptor (with no endpoint, required).
|
187
|
USBInterfaceDescriptor streamingInNoIsochronous;
|
188
|
/// Streaming in interface descriptor.
|
189
|
USBInterfaceDescriptor streamingIn;
|
190
|
/// Audio class descriptor for the streaming in interface.
|
191
|
AUDStreamingInterfaceDescriptor streamingInClass;
|
192
|
/// Stream format descriptor.
|
193
|
AUDFormatTypeOneDescriptor1 streamingInFormatType;
|
194
|
/// Streaming in endpoint descriptor.
|
195
|
AUDEndpointDescriptor streamingInEndpoint;
|
196
|
/// Audio class descriptor for the streaming in endpoint.
|
197
|
AUDDataEndpointDescriptor streamingInDataEndpoint;
|
198
|
// DFU Runtime
|
199
|
DFURT_IF_DESCRIPTOR_STRUCT
|
200
|
} __attribute__ ((packed)) AUDDLoopRecDriverConfigurationDescriptors; // GCC
|
201
|
|
202
|
#ifdef __ICCARM__ // IAR
|
203
|
#pragma pack() // IAR
|
204
|
#endif // IAR
|
205
|
|
206
|
//------------------------------------------------------------------------------
|
207
|
// Exported variables
|
208
|
//------------------------------------------------------------------------------
|
209
|
|
210
|
/// Device descriptor for a USB Audio Loop Record driver.
|
211
|
const USBDeviceDescriptor deviceDescriptor = {
|
212
|
|
213
|
sizeof(USBDeviceDescriptor),
|
214
|
USBGenericDescriptor_DEVICE,
|
215
|
USBDeviceDescriptor_USB2_00,
|
216
|
AUDDeviceDescriptor_CLASS,
|
217
|
AUDDeviceDescriptor_SUBCLASS,
|
218
|
AUDDeviceDescriptor_PROTOCOL,
|
219
|
CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
|
220
|
AUDDLoopRecDriverDescriptors_VENDORID,
|
221
|
AUDDLoopRecDriverDescriptors_PRODUCTID,
|
222
|
AUDDLoopRecDriverDescriptors_RELEASE,
|
223
|
1, // Manufacturer string descriptor index
|
224
|
2, // Product string descriptor index
|
225
|
3, // Index of serial number string descriptor
|
226
|
1 // One possible configuration
|
227
|
};
|
228
|
|
229
|
#if defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS)
|
230
|
|
231
|
/// USB device qualifier descriptor.
|
232
|
const USBDeviceQualifierDescriptor qualifierDescriptor = {
|
233
|
|
234
|
sizeof(USBDeviceQualifierDescriptor),
|
235
|
USBGenericDescriptor_DEVICEQUALIFIER,
|
236
|
USBDeviceDescriptor_USB2_00,
|
237
|
AUDDeviceDescriptor_CLASS,
|
238
|
AUDDeviceDescriptor_SUBCLASS,
|
239
|
AUDDeviceDescriptor_PROTOCOL,
|
240
|
CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
|
241
|
1, // Device has one possible configuration
|
242
|
0 // Reserved
|
243
|
};
|
244
|
|
245
|
/// HS Configuration descriptors for a USB Audio Loop Record driver.
|
246
|
const AUDDLoopRecDriverConfigurationDescriptors hsConfigurationDescriptors = {
|
247
|
|
248
|
// Configuration descriptor
|
249
|
{
|
250
|
sizeof(USBConfigurationDescriptor),
|
251
|
USBGenericDescriptor_CONFIGURATION,
|
252
|
sizeof(AUDDLoopRecDriverConfigurationDescriptors),
|
253
|
3+DFURT_NUM_IF, // This configuration has 3 interfaces
|
254
|
1, // This is configuration #1
|
255
|
0, // No string descriptor
|
256
|
BOARD_USB_BMATTRIBUTES,
|
257
|
USBConfigurationDescriptor_POWER(100)
|
258
|
},
|
259
|
// Audio control interface standard descriptor
|
260
|
{
|
261
|
sizeof(USBInterfaceDescriptor),
|
262
|
USBGenericDescriptor_INTERFACE,
|
263
|
AUDDLoopRecDriverDescriptors_CONTROL,
|
264
|
0, // This is alternate setting #0
|
265
|
0, // This interface uses no endpoint
|
266
|
AUDControlInterfaceDescriptor_CLASS,
|
267
|
AUDControlInterfaceDescriptor_SUBCLASS,
|
268
|
AUDControlInterfaceDescriptor_PROTOCOL,
|
269
|
0 // No string descriptor
|
270
|
},
|
271
|
// Audio control interface descriptors
|
272
|
{
|
273
|
// Header descriptor
|
274
|
{
|
275
|
{
|
276
|
sizeof(AUDHeaderDescriptor2),
|
277
|
AUDGenericDescriptor_INTERFACE,
|
278
|
AUDGenericDescriptor_HEADER,
|
279
|
AUDHeaderDescriptor_AUD1_00,
|
280
|
sizeof(AUDDLoopRecDriverAudioControlDescriptors),
|
281
|
2 // Two streaming interface
|
282
|
},
|
283
|
AUDDLoopRecDriverDescriptors_STREAMING,
|
284
|
AUDDLoopRecDriverDescriptors_STREAMINGIN
|
285
|
},
|
286
|
// Input terminal descriptor ( speaker )
|
287
|
{
|
288
|
sizeof(AUDInputTerminalDescriptor),
|
289
|
AUDGenericDescriptor_INTERFACE,
|
290
|
AUDGenericDescriptor_INPUTTERMINAL,
|
291
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
|
292
|
AUDInputTerminalDescriptor_USBSTREAMING,
|
293
|
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
|
294
|
AUDDLoopRecDriver_NUMCHANNELS,
|
295
|
#if AUDDLoopRecDriver_NUMCHANNELS > 1
|
296
|
AUDInputTerminalDescriptor_LEFTFRONT
|
297
|
| AUDInputTerminalDescriptor_RIGHTFRONT,
|
298
|
#else
|
299
|
0, // Mono sets no position bits.
|
300
|
#endif
|
301
|
0, // No string descriptor for channels
|
302
|
0 // No string descriptor for input terminal
|
303
|
},
|
304
|
// Output terminal descriptor ( speaker )
|
305
|
{
|
306
|
sizeof(AUDOutputTerminalDescriptor),
|
307
|
AUDGenericDescriptor_INTERFACE,
|
308
|
AUDGenericDescriptor_OUTPUTTERMINAL,
|
309
|
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
|
310
|
AUDOutputTerminalDescriptor_SPEAKER,
|
311
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
|
312
|
AUDDLoopRecDriverDescriptors_FEATUREUNIT,
|
313
|
0 // No string descriptor
|
314
|
},
|
315
|
// Feature unit descriptor ( speaker )
|
316
|
{
|
317
|
{
|
318
|
sizeof(AUDFeatureUnitDescriptor3),
|
319
|
AUDGenericDescriptor_INTERFACE,
|
320
|
AUDGenericDescriptor_FEATUREUNIT,
|
321
|
AUDDLoopRecDriverDescriptors_FEATUREUNIT,
|
322
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
|
323
|
1, // 1 byte per channel for controls
|
324
|
},
|
325
|
{
|
326
|
AUDFeatureUnitDescriptor_MUTE, // Master channel controls
|
327
|
0, // Right channel controls
|
328
|
0 // Left channel controls
|
329
|
},
|
330
|
0 // No string descriptor
|
331
|
},
|
332
|
// Input terminal descriptor ( speakerphone )
|
333
|
{
|
334
|
sizeof(AUDInputTerminalDescriptor),
|
335
|
AUDGenericDescriptor_INTERFACE,
|
336
|
AUDGenericDescriptor_INPUTTERMINAL,
|
337
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
|
338
|
AUDInputTerminalDescriptor_SPEAKERPHONE,
|
339
|
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
|
340
|
AUDDLoopRecDriver_NUMCHANNELS,
|
341
|
#if AUDDLoopRecDriver_NUMCHANNELS > 1
|
342
|
AUDInputTerminalDescriptor_LEFTFRONT
|
343
|
| AUDInputTerminalDescriptor_RIGHTFRONT,
|
344
|
#else
|
345
|
0, // Mono sets no position bits.
|
346
|
#endif
|
347
|
0, // No string descriptor for channels
|
348
|
0 // No string descriptor for input terminal
|
349
|
},
|
350
|
// Output terminal descriptor ( speakerphone )
|
351
|
{
|
352
|
sizeof(AUDOutputTerminalDescriptor),
|
353
|
AUDGenericDescriptor_INTERFACE,
|
354
|
AUDGenericDescriptor_OUTPUTTERMINAL,
|
355
|
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
|
356
|
AUDOutputTerminalDescriptor_USBTREAMING,
|
357
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
|
358
|
AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
|
359
|
0 // No string descriptor
|
360
|
},
|
361
|
// Feature unit descriptor ( speakerphone )
|
362
|
{
|
363
|
{
|
364
|
sizeof(AUDFeatureUnitDescriptor3),
|
365
|
AUDGenericDescriptor_INTERFACE,
|
366
|
AUDGenericDescriptor_FEATUREUNIT,
|
367
|
AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
|
368
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
|
369
|
1
|
370
|
},
|
371
|
{
|
372
|
AUDFeatureUnitDescriptor_MUTE, // Mic controls
|
373
|
0,
|
374
|
0
|
375
|
},
|
376
|
0 // No string descriptor
|
377
|
}
|
378
|
},
|
379
|
// - AUIDO OUT
|
380
|
// Audio streaming interface with 0 endpoints
|
381
|
{
|
382
|
sizeof(USBInterfaceDescriptor),
|
383
|
USBGenericDescriptor_INTERFACE,
|
384
|
AUDDLoopRecDriverDescriptors_STREAMING,
|
385
|
0, // This is alternate setting #0
|
386
|
0, // This interface uses no endpoints
|
387
|
AUDStreamingInterfaceDescriptor_CLASS,
|
388
|
AUDStreamingInterfaceDescriptor_SUBCLASS,
|
389
|
AUDStreamingInterfaceDescriptor_PROTOCOL,
|
390
|
0 // No string descriptor
|
391
|
},
|
392
|
// Audio streaming interface with data endpoint
|
393
|
{
|
394
|
sizeof(USBInterfaceDescriptor),
|
395
|
USBGenericDescriptor_INTERFACE,
|
396
|
AUDDLoopRecDriverDescriptors_STREAMING,
|
397
|
1, // This is alternate setting #1
|
398
|
1, // This interface uses 1 endpoint
|
399
|
AUDStreamingInterfaceDescriptor_CLASS,
|
400
|
AUDStreamingInterfaceDescriptor_SUBCLASS,
|
401
|
AUDStreamingInterfaceDescriptor_PROTOCOL,
|
402
|
0 // No string descriptor
|
403
|
},
|
404
|
// Audio streaming class-specific descriptor
|
405
|
{
|
406
|
sizeof(AUDStreamingInterfaceDescriptor),
|
407
|
AUDGenericDescriptor_INTERFACE,
|
408
|
AUDStreamingInterfaceDescriptor_GENERAL,
|
409
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
|
410
|
0, // No internal delay because of data path
|
411
|
AUDFormatTypeOneDescriptor_PCM
|
412
|
},
|
413
|
// Format type I descriptor
|
414
|
{
|
415
|
{
|
416
|
sizeof(AUDFormatTypeOneDescriptor1),
|
417
|
AUDGenericDescriptor_INTERFACE,
|
418
|
AUDStreamingInterfaceDescriptor_FORMATTYPE,
|
419
|
AUDFormatTypeOneDescriptor_FORMATTYPEONE,
|
420
|
AUDDLoopRecDriver_NUMCHANNELS,
|
421
|
AUDDLoopRecDriver_BYTESPERSAMPLE,
|
422
|
AUDDLoopRecDriver_BYTESPERSAMPLE*8,
|
423
|
1 // One discrete frequency supported
|
424
|
},
|
425
|
{
|
426
|
AUDDLoopRecDriver_SAMPLERATE & 0xFF,
|
427
|
(AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
|
428
|
(AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
|
429
|
}
|
430
|
},
|
431
|
// Audio streaming endpoint standard descriptor
|
432
|
{
|
433
|
sizeof(AUDEndpointDescriptor),
|
434
|
USBGenericDescriptor_ENDPOINT,
|
435
|
USBEndpointDescriptor_ADDRESS(
|
436
|
USBEndpointDescriptor_OUT,
|
437
|
AUDDLoopRecDriverDescriptors_DATAOUT),
|
438
|
USBEndpointDescriptor_ISOCHRONOUS,
|
439
|
AUDDLoopRecDriver_BYTESPERFRAME,
|
440
|
AUDDLoopRecDriverDescriptors_HS_INTERVAL, // Polling interval = 1 ms
|
441
|
0, // This is not a synchronization endpoint
|
442
|
0 // No associated synchronization endpoint
|
443
|
},
|
444
|
// Audio streaming endpoint class-specific descriptor
|
445
|
{
|
446
|
sizeof(AUDDataEndpointDescriptor),
|
447
|
AUDGenericDescriptor_ENDPOINT,
|
448
|
AUDDataEndpointDescriptor_SUBTYPE,
|
449
|
0, // No attributes
|
450
|
0, // Endpoint is not synchronized
|
451
|
0 // Endpoint is not synchronized
|
452
|
},
|
453
|
//- AUDIO IN
|
454
|
// Audio streaming interface with 0 endpoints
|
455
|
{
|
456
|
sizeof(USBInterfaceDescriptor),
|
457
|
USBGenericDescriptor_INTERFACE,
|
458
|
AUDDLoopRecDriverDescriptors_STREAMINGIN,
|
459
|
0, // This is alternate setting #0
|
460
|
0, // This interface uses no endpoints
|
461
|
AUDStreamingInterfaceDescriptor_CLASS,
|
462
|
AUDStreamingInterfaceDescriptor_SUBCLASS,
|
463
|
AUDStreamingInterfaceDescriptor_PROTOCOL,
|
464
|
0 // No string descriptor
|
465
|
},
|
466
|
// Audio streaming interface with data endpoint
|
467
|
{
|
468
|
sizeof(USBInterfaceDescriptor),
|
469
|
USBGenericDescriptor_INTERFACE,
|
470
|
AUDDLoopRecDriverDescriptors_STREAMINGIN,
|
471
|
1, // This is alternate setting #1
|
472
|
1, // This interface uses 1 endpoint
|
473
|
AUDStreamingInterfaceDescriptor_CLASS,
|
474
|
AUDStreamingInterfaceDescriptor_SUBCLASS,
|
475
|
AUDStreamingInterfaceDescriptor_PROTOCOL,
|
476
|
0 // No string descriptor
|
477
|
},
|
478
|
// Audio streaming class-specific descriptor
|
479
|
{
|
480
|
sizeof(AUDStreamingInterfaceDescriptor),
|
481
|
AUDGenericDescriptor_INTERFACE,
|
482
|
AUDStreamingInterfaceDescriptor_GENERAL,
|
483
|
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
|
484
|
0, // No internal delay because of data path
|
485
|
AUDFormatTypeOneDescriptor_PCM
|
486
|
},
|
487
|
// Format type I descriptor
|
488
|
{
|
489
|
{
|
490
|
sizeof(AUDFormatTypeOneDescriptor1),
|
491
|
AUDGenericDescriptor_INTERFACE,
|
492
|
AUDStreamingInterfaceDescriptor_FORMATTYPE,
|
493
|
AUDFormatTypeOneDescriptor_FORMATTYPEONE,
|
494
|
AUDDLoopRecDriver_NUMCHANNELS,
|
495
|
AUDDLoopRecDriver_BYTESPERSAMPLE,
|
496
|
AUDDLoopRecDriver_BYTESPERSAMPLE*8,
|
497
|
1 // One discrete frequency supported
|
498
|
},
|
499
|
{
|
500
|
AUDDLoopRecDriver_SAMPLERATE & 0xFF,
|
501
|
(AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
|
502
|
(AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
|
503
|
}
|
504
|
},
|
505
|
// Audio streaming endpoint standard descriptor
|
506
|
{
|
507
|
sizeof(AUDEndpointDescriptor),
|
508
|
USBGenericDescriptor_ENDPOINT,
|
509
|
USBEndpointDescriptor_ADDRESS(
|
510
|
USBEndpointDescriptor_IN,
|
511
|
AUDDLoopRecDriverDescriptors_DATAIN),
|
512
|
USBEndpointDescriptor_ISOCHRONOUS,
|
513
|
AUDDLoopRecDriver_BYTESPERFRAME,
|
514
|
AUDDLoopRecDriverDescriptors_HS_INTERVAL, // Polling interval = 1 ms
|
515
|
0, // This is not a synchronization endpoint
|
516
|
0 // No associated synchronization endpoint
|
517
|
},
|
518
|
// Audio streaming endpoint class-specific descriptor
|
519
|
{
|
520
|
sizeof(AUDDataEndpointDescriptor),
|
521
|
AUDGenericDescriptor_ENDPOINT,
|
522
|
AUDDataEndpointDescriptor_SUBTYPE,
|
523
|
0, // No attributes
|
524
|
0, // Endpoint is not synchronized
|
525
|
0 // Endpoint is not synchronized
|
526
|
},
|
527
|
DFURT_IF_DESCRIPTOR(3, 0),
|
528
|
};
|
529
|
|
530
|
/// HS Other Speed Configuration descriptors for a USB Audio Loop Record driver.
|
531
|
const AUDDLoopRecDriverConfigurationDescriptors
|
532
|
fsOtherSpeedConfigurationDescriptors = {
|
533
|
|
534
|
// Configuration descriptor
|
535
|
{
|
536
|
sizeof(USBConfigurationDescriptor),
|
537
|
USBGenericDescriptor_OTHERSPEEDCONFIGURATION,
|
538
|
sizeof(AUDDLoopRecDriverConfigurationDescriptors),
|
539
|
3+DFURT_NUM_IF, // This configuration has 3 interfaces
|
540
|
1, // This is configuration #1
|
541
|
0, // No string descriptor
|
542
|
BOARD_USB_BMATTRIBUTES,
|
543
|
USBConfigurationDescriptor_POWER(100)
|
544
|
},
|
545
|
// Audio control interface standard descriptor
|
546
|
{
|
547
|
sizeof(USBInterfaceDescriptor),
|
548
|
USBGenericDescriptor_INTERFACE,
|
549
|
AUDDLoopRecDriverDescriptors_CONTROL,
|
550
|
0, // This is alternate setting #0
|
551
|
0, // This interface uses no endpoint
|
552
|
AUDControlInterfaceDescriptor_CLASS,
|
553
|
AUDControlInterfaceDescriptor_SUBCLASS,
|
554
|
AUDControlInterfaceDescriptor_PROTOCOL,
|
555
|
0 // No string descriptor
|
556
|
},
|
557
|
// Audio control interface descriptors
|
558
|
{
|
559
|
// Header descriptor
|
560
|
{
|
561
|
{
|
562
|
sizeof(AUDHeaderDescriptor2),
|
563
|
AUDGenericDescriptor_INTERFACE,
|
564
|
AUDGenericDescriptor_HEADER,
|
565
|
AUDHeaderDescriptor_AUD1_00,
|
566
|
sizeof(AUDDLoopRecDriverAudioControlDescriptors),
|
567
|
2 // Two streaming interface
|
568
|
},
|
569
|
AUDDLoopRecDriverDescriptors_STREAMING,
|
570
|
AUDDLoopRecDriverDescriptors_STREAMINGIN
|
571
|
},
|
572
|
// Input terminal descriptor ( speaker )
|
573
|
{
|
574
|
sizeof(AUDInputTerminalDescriptor),
|
575
|
AUDGenericDescriptor_INTERFACE,
|
576
|
AUDGenericDescriptor_INPUTTERMINAL,
|
577
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
|
578
|
AUDInputTerminalDescriptor_USBSTREAMING,
|
579
|
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
|
580
|
AUDDLoopRecDriver_NUMCHANNELS,
|
581
|
#if AUDDLoopRecDriver_NUMCHANNELS > 1
|
582
|
AUDInputTerminalDescriptor_LEFTFRONT
|
583
|
| AUDInputTerminalDescriptor_RIGHTFRONT,
|
584
|
#else
|
585
|
0, // Mono sets no position bits.
|
586
|
#endif
|
587
|
0, // No string descriptor for channels
|
588
|
0 // No string descriptor for input terminal
|
589
|
},
|
590
|
// Output terminal descriptor ( speaker )
|
591
|
{
|
592
|
sizeof(AUDOutputTerminalDescriptor),
|
593
|
AUDGenericDescriptor_INTERFACE,
|
594
|
AUDGenericDescriptor_OUTPUTTERMINAL,
|
595
|
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
|
596
|
AUDOutputTerminalDescriptor_SPEAKER,
|
597
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
|
598
|
AUDDLoopRecDriverDescriptors_FEATUREUNIT,
|
599
|
0 // No string descriptor
|
600
|
},
|
601
|
// Feature unit descriptor ( speaker )
|
602
|
{
|
603
|
{
|
604
|
sizeof(AUDFeatureUnitDescriptor3),
|
605
|
AUDGenericDescriptor_INTERFACE,
|
606
|
AUDGenericDescriptor_FEATUREUNIT,
|
607
|
AUDDLoopRecDriverDescriptors_FEATUREUNIT,
|
608
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
|
609
|
1, // 1 byte per channel for controls
|
610
|
},
|
611
|
{
|
612
|
AUDFeatureUnitDescriptor_MUTE, // Master channel controls
|
613
|
0, // Right channel controls
|
614
|
0 // Left channel controls
|
615
|
},
|
616
|
0 // No string descriptor
|
617
|
},
|
618
|
// Input terminal descriptor ( speakerphone )
|
619
|
{
|
620
|
sizeof(AUDInputTerminalDescriptor),
|
621
|
AUDGenericDescriptor_INTERFACE,
|
622
|
AUDGenericDescriptor_INPUTTERMINAL,
|
623
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
|
624
|
AUDInputTerminalDescriptor_SPEAKERPHONE,
|
625
|
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
|
626
|
AUDDLoopRecDriver_NUMCHANNELS,
|
627
|
#if AUDDLoopRecDriver_NUMCHANNELS > 1
|
628
|
AUDInputTerminalDescriptor_LEFTFRONT
|
629
|
| AUDInputTerminalDescriptor_RIGHTFRONT,
|
630
|
#else
|
631
|
0, // Mono sets no position bits.
|
632
|
#endif
|
633
|
0, // No string descriptor for channels
|
634
|
0 // No string descriptor for input terminal
|
635
|
},
|
636
|
// Output terminal descriptor ( speakerphone )
|
637
|
{
|
638
|
sizeof(AUDOutputTerminalDescriptor),
|
639
|
AUDGenericDescriptor_INTERFACE,
|
640
|
AUDGenericDescriptor_OUTPUTTERMINAL,
|
641
|
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
|
642
|
AUDOutputTerminalDescriptor_USBTREAMING,
|
643
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
|
644
|
AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
|
645
|
0 // No string descriptor
|
646
|
},
|
647
|
// Feature unit descriptor ( speakerphone )
|
648
|
{
|
649
|
{
|
650
|
sizeof(AUDFeatureUnitDescriptor3),
|
651
|
AUDGenericDescriptor_INTERFACE,
|
652
|
AUDGenericDescriptor_FEATUREUNIT,
|
653
|
AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
|
654
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
|
655
|
1
|
656
|
},
|
657
|
{
|
658
|
AUDFeatureUnitDescriptor_MUTE, // Mic controls
|
659
|
0,
|
660
|
0
|
661
|
},
|
662
|
0 // No string descriptor
|
663
|
}
|
664
|
},
|
665
|
// - AUIDO OUT
|
666
|
// Audio streaming interface with 0 endpoints
|
667
|
{
|
668
|
sizeof(USBInterfaceDescriptor),
|
669
|
USBGenericDescriptor_INTERFACE,
|
670
|
AUDDLoopRecDriverDescriptors_STREAMING,
|
671
|
0, // This is alternate setting #0
|
672
|
0, // This interface uses no endpoints
|
673
|
AUDStreamingInterfaceDescriptor_CLASS,
|
674
|
AUDStreamingInterfaceDescriptor_SUBCLASS,
|
675
|
AUDStreamingInterfaceDescriptor_PROTOCOL,
|
676
|
0 // No string descriptor
|
677
|
},
|
678
|
// Audio streaming interface with data endpoint
|
679
|
{
|
680
|
sizeof(USBInterfaceDescriptor),
|
681
|
USBGenericDescriptor_INTERFACE,
|
682
|
AUDDLoopRecDriverDescriptors_STREAMING,
|
683
|
1, // This is alternate setting #1
|
684
|
1, // This interface uses 1 endpoint
|
685
|
AUDStreamingInterfaceDescriptor_CLASS,
|
686
|
AUDStreamingInterfaceDescriptor_SUBCLASS,
|
687
|
AUDStreamingInterfaceDescriptor_PROTOCOL,
|
688
|
0 // No string descriptor
|
689
|
},
|
690
|
// Audio streaming class-specific descriptor
|
691
|
{
|
692
|
sizeof(AUDStreamingInterfaceDescriptor),
|
693
|
AUDGenericDescriptor_INTERFACE,
|
694
|
AUDStreamingInterfaceDescriptor_GENERAL,
|
695
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
|
696
|
0, // No internal delay because of data path
|
697
|
AUDFormatTypeOneDescriptor_PCM
|
698
|
},
|
699
|
// Format type I descriptor
|
700
|
{
|
701
|
{
|
702
|
sizeof(AUDFormatTypeOneDescriptor1),
|
703
|
AUDGenericDescriptor_INTERFACE,
|
704
|
AUDStreamingInterfaceDescriptor_FORMATTYPE,
|
705
|
AUDFormatTypeOneDescriptor_FORMATTYPEONE,
|
706
|
AUDDLoopRecDriver_NUMCHANNELS,
|
707
|
AUDDLoopRecDriver_BYTESPERSAMPLE,
|
708
|
AUDDLoopRecDriver_BYTESPERSAMPLE*8,
|
709
|
1 // One discrete frequency supported
|
710
|
},
|
711
|
{
|
712
|
AUDDLoopRecDriver_SAMPLERATE & 0xFF,
|
713
|
(AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
|
714
|
(AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
|
715
|
}
|
716
|
},
|
717
|
// Audio streaming endpoint standard descriptor
|
718
|
{
|
719
|
sizeof(AUDEndpointDescriptor),
|
720
|
USBGenericDescriptor_ENDPOINT,
|
721
|
USBEndpointDescriptor_ADDRESS(
|
722
|
USBEndpointDescriptor_OUT,
|
723
|
AUDDLoopRecDriverDescriptors_DATAOUT),
|
724
|
USBEndpointDescriptor_ISOCHRONOUS,
|
725
|
AUDDLoopRecDriver_BYTESPERFRAME,
|
726
|
AUDDLoopRecDriverDescriptors_HS_INTERVAL, // Polling interval = 1 ms
|
727
|
0, // This is not a synchronization endpoint
|
728
|
0 // No associated synchronization endpoint
|
729
|
},
|
730
|
// Audio streaming endpoint class-specific descriptor
|
731
|
{
|
732
|
sizeof(AUDDataEndpointDescriptor),
|
733
|
AUDGenericDescriptor_ENDPOINT,
|
734
|
AUDDataEndpointDescriptor_SUBTYPE,
|
735
|
0, // No attributes
|
736
|
0, // Endpoint is not synchronized
|
737
|
0 // Endpoint is not synchronized
|
738
|
},
|
739
|
//- AUDIO IN
|
740
|
// Audio streaming interface with 0 endpoints
|
741
|
{
|
742
|
sizeof(USBInterfaceDescriptor),
|
743
|
USBGenericDescriptor_INTERFACE,
|
744
|
AUDDLoopRecDriverDescriptors_STREAMINGIN,
|
745
|
0, // This is alternate setting #0
|
746
|
0, // This interface uses no endpoints
|
747
|
AUDStreamingInterfaceDescriptor_CLASS,
|
748
|
AUDStreamingInterfaceDescriptor_SUBCLASS,
|
749
|
AUDStreamingInterfaceDescriptor_PROTOCOL,
|
750
|
0 // No string descriptor
|
751
|
},
|
752
|
// Audio streaming interface with data endpoint
|
753
|
{
|
754
|
sizeof(USBInterfaceDescriptor),
|
755
|
USBGenericDescriptor_INTERFACE,
|
756
|
AUDDLoopRecDriverDescriptors_STREAMINGIN,
|
757
|
1, // This is alternate setting #1
|
758
|
1, // This interface uses 1 endpoint
|
759
|
AUDStreamingInterfaceDescriptor_CLASS,
|
760
|
AUDStreamingInterfaceDescriptor_SUBCLASS,
|
761
|
AUDStreamingInterfaceDescriptor_PROTOCOL,
|
762
|
0 // No string descriptor
|
763
|
},
|
764
|
// Audio streaming class-specific descriptor
|
765
|
{
|
766
|
sizeof(AUDStreamingInterfaceDescriptor),
|
767
|
AUDGenericDescriptor_INTERFACE,
|
768
|
AUDStreamingInterfaceDescriptor_GENERAL,
|
769
|
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
|
770
|
0, // No internal delay because of data path
|
771
|
AUDFormatTypeOneDescriptor_PCM
|
772
|
},
|
773
|
// Format type I descriptor
|
774
|
{
|
775
|
{
|
776
|
sizeof(AUDFormatTypeOneDescriptor1),
|
777
|
AUDGenericDescriptor_INTERFACE,
|
778
|
AUDStreamingInterfaceDescriptor_FORMATTYPE,
|
779
|
AUDFormatTypeOneDescriptor_FORMATTYPEONE,
|
780
|
AUDDLoopRecDriver_NUMCHANNELS,
|
781
|
AUDDLoopRecDriver_BYTESPERSAMPLE,
|
782
|
AUDDLoopRecDriver_BYTESPERSAMPLE*8,
|
783
|
1 // One discrete frequency supported
|
784
|
},
|
785
|
{
|
786
|
AUDDLoopRecDriver_SAMPLERATE & 0xFF,
|
787
|
(AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
|
788
|
(AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
|
789
|
}
|
790
|
},
|
791
|
// Audio streaming endpoint standard descriptor
|
792
|
{
|
793
|
sizeof(AUDEndpointDescriptor),
|
794
|
USBGenericDescriptor_ENDPOINT,
|
795
|
USBEndpointDescriptor_ADDRESS(
|
796
|
USBEndpointDescriptor_IN,
|
797
|
AUDDLoopRecDriverDescriptors_DATAIN),
|
798
|
USBEndpointDescriptor_ISOCHRONOUS,
|
799
|
AUDDLoopRecDriver_BYTESPERFRAME,
|
800
|
AUDDLoopRecDriverDescriptors_HS_INTERVAL, // Polling interval = 1 ms
|
801
|
0, // This is not a synchronization endpoint
|
802
|
0 // No associated synchronization endpoint
|
803
|
},
|
804
|
// Audio streaming endpoint class-specific descriptor
|
805
|
{
|
806
|
sizeof(AUDDataEndpointDescriptor),
|
807
|
AUDGenericDescriptor_ENDPOINT,
|
808
|
AUDDataEndpointDescriptor_SUBTYPE,
|
809
|
0, // No attributes
|
810
|
0, // Endpoint is not synchronized
|
811
|
0 // Endpoint is not synchronized
|
812
|
},
|
813
|
DFURT_IF_DESCRIPTOR(3, 0),
|
814
|
};
|
815
|
|
816
|
/// HS Other Speed Configuration descriptors.
|
817
|
const AUDDLoopRecDriverConfigurationDescriptors
|
818
|
hsOtherSpeedConfigurationDescriptors = {
|
819
|
|
820
|
// Configuration descriptor
|
821
|
{
|
822
|
sizeof(USBConfigurationDescriptor),
|
823
|
USBGenericDescriptor_OTHERSPEEDCONFIGURATION,
|
824
|
sizeof(AUDDLoopRecDriverConfigurationDescriptors),
|
825
|
3+DFURT_NUM_IF, // This configuration has 3 interfaces
|
826
|
1, // This is configuration #1
|
827
|
0, // No string descriptor
|
828
|
BOARD_USB_BMATTRIBUTES,
|
829
|
USBConfigurationDescriptor_POWER(100)
|
830
|
},
|
831
|
// Audio control interface standard descriptor
|
832
|
{
|
833
|
sizeof(USBInterfaceDescriptor),
|
834
|
USBGenericDescriptor_INTERFACE,
|
835
|
AUDDLoopRecDriverDescriptors_CONTROL,
|
836
|
0, // This is alternate setting #0
|
837
|
0, // This interface uses no endpoint
|
838
|
AUDControlInterfaceDescriptor_CLASS,
|
839
|
AUDControlInterfaceDescriptor_SUBCLASS,
|
840
|
AUDControlInterfaceDescriptor_PROTOCOL,
|
841
|
0 // No string descriptor
|
842
|
},
|
843
|
// Audio control interface descriptors
|
844
|
{
|
845
|
// Header descriptor
|
846
|
{
|
847
|
{
|
848
|
sizeof(AUDHeaderDescriptor2),
|
849
|
AUDGenericDescriptor_INTERFACE,
|
850
|
AUDGenericDescriptor_HEADER,
|
851
|
AUDHeaderDescriptor_AUD1_00,
|
852
|
sizeof(AUDDLoopRecDriverAudioControlDescriptors),
|
853
|
2 // Two streaming interface
|
854
|
},
|
855
|
AUDDLoopRecDriverDescriptors_STREAMING,
|
856
|
AUDDLoopRecDriverDescriptors_STREAMINGIN
|
857
|
},
|
858
|
// Input terminal descriptor ( speaker )
|
859
|
{
|
860
|
sizeof(AUDInputTerminalDescriptor),
|
861
|
AUDGenericDescriptor_INTERFACE,
|
862
|
AUDGenericDescriptor_INPUTTERMINAL,
|
863
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
|
864
|
AUDInputTerminalDescriptor_USBSTREAMING,
|
865
|
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
|
866
|
AUDDLoopRecDriver_NUMCHANNELS,
|
867
|
#if AUDDLoopRecDriver_NUMCHANNELS > 1
|
868
|
AUDInputTerminalDescriptor_LEFTFRONT
|
869
|
| AUDInputTerminalDescriptor_RIGHTFRONT,
|
870
|
#else
|
871
|
0, // Mono sets no position bits.
|
872
|
#endif
|
873
|
0, // No string descriptor for channels
|
874
|
0 // No string descriptor for input terminal
|
875
|
},
|
876
|
// Output terminal descriptor ( speaker )
|
877
|
{
|
878
|
sizeof(AUDOutputTerminalDescriptor),
|
879
|
AUDGenericDescriptor_INTERFACE,
|
880
|
AUDGenericDescriptor_OUTPUTTERMINAL,
|
881
|
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
|
882
|
AUDOutputTerminalDescriptor_SPEAKER,
|
883
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
|
884
|
AUDDLoopRecDriverDescriptors_FEATUREUNIT,
|
885
|
0 // No string descriptor
|
886
|
},
|
887
|
// Feature unit descriptor ( speaker )
|
888
|
{
|
889
|
{
|
890
|
sizeof(AUDFeatureUnitDescriptor3),
|
891
|
AUDGenericDescriptor_INTERFACE,
|
892
|
AUDGenericDescriptor_FEATUREUNIT,
|
893
|
AUDDLoopRecDriverDescriptors_FEATUREUNIT,
|
894
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
|
895
|
1, // 1 byte per channel for controls
|
896
|
},
|
897
|
{
|
898
|
AUDFeatureUnitDescriptor_MUTE, // Master channel controls
|
899
|
0, // Right channel controls
|
900
|
0 // Left channel controls
|
901
|
},
|
902
|
0 // No string descriptor
|
903
|
},
|
904
|
// Input terminal descriptor ( speakerphone )
|
905
|
{
|
906
|
sizeof(AUDInputTerminalDescriptor),
|
907
|
AUDGenericDescriptor_INTERFACE,
|
908
|
AUDGenericDescriptor_INPUTTERMINAL,
|
909
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
|
910
|
AUDInputTerminalDescriptor_SPEAKERPHONE,
|
911
|
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
|
912
|
AUDDLoopRecDriver_NUMCHANNELS,
|
913
|
#if AUDDLoopRecDriver_NUMCHANNELS > 1
|
914
|
AUDInputTerminalDescriptor_LEFTFRONT
|
915
|
| AUDInputTerminalDescriptor_RIGHTFRONT,
|
916
|
#else
|
917
|
0, // Mono sets no position bits.
|
918
|
#endif
|
919
|
0, // No string descriptor for channels
|
920
|
0 // No string descriptor for input terminal
|
921
|
},
|
922
|
// Output terminal descriptor ( speakerphone )
|
923
|
{
|
924
|
sizeof(AUDOutputTerminalDescriptor),
|
925
|
AUDGenericDescriptor_INTERFACE,
|
926
|
AUDGenericDescriptor_OUTPUTTERMINAL,
|
927
|
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
|
928
|
AUDOutputTerminalDescriptor_USBTREAMING,
|
929
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
|
930
|
AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
|
931
|
0 // No string descriptor
|
932
|
},
|
933
|
// Feature unit descriptor ( speakerphone )
|
934
|
{
|
935
|
{
|
936
|
sizeof(AUDFeatureUnitDescriptor3),
|
937
|
AUDGenericDescriptor_INTERFACE,
|
938
|
AUDGenericDescriptor_FEATUREUNIT,
|
939
|
AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
|
940
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
|
941
|
1
|
942
|
},
|
943
|
{
|
944
|
AUDFeatureUnitDescriptor_MUTE, // Mic controls
|
945
|
0,
|
946
|
0
|
947
|
},
|
948
|
0 // No string descriptor
|
949
|
}
|
950
|
},
|
951
|
// - AUIDO OUT
|
952
|
// Audio streaming interface with 0 endpoints
|
953
|
{
|
954
|
sizeof(USBInterfaceDescriptor),
|
955
|
USBGenericDescriptor_INTERFACE,
|
956
|
AUDDLoopRecDriverDescriptors_STREAMING,
|
957
|
0, // This is alternate setting #0
|
958
|
0, // This interface uses no endpoints
|
959
|
AUDStreamingInterfaceDescriptor_CLASS,
|
960
|
AUDStreamingInterfaceDescriptor_SUBCLASS,
|
961
|
AUDStreamingInterfaceDescriptor_PROTOCOL,
|
962
|
0 // No string descriptor
|
963
|
},
|
964
|
// Audio streaming interface with data endpoint
|
965
|
{
|
966
|
sizeof(USBInterfaceDescriptor),
|
967
|
USBGenericDescriptor_INTERFACE,
|
968
|
AUDDLoopRecDriverDescriptors_STREAMING,
|
969
|
1, // This is alternate setting #1
|
970
|
1, // This interface uses 1 endpoint
|
971
|
AUDStreamingInterfaceDescriptor_CLASS,
|
972
|
AUDStreamingInterfaceDescriptor_SUBCLASS,
|
973
|
AUDStreamingInterfaceDescriptor_PROTOCOL,
|
974
|
0 // No string descriptor
|
975
|
},
|
976
|
// Audio streaming class-specific descriptor
|
977
|
{
|
978
|
sizeof(AUDStreamingInterfaceDescriptor),
|
979
|
AUDGenericDescriptor_INTERFACE,
|
980
|
AUDStreamingInterfaceDescriptor_GENERAL,
|
981
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
|
982
|
0, // No internal delay because of data path
|
983
|
AUDFormatTypeOneDescriptor_PCM
|
984
|
},
|
985
|
// Format type I descriptor
|
986
|
{
|
987
|
{
|
988
|
sizeof(AUDFormatTypeOneDescriptor1),
|
989
|
AUDGenericDescriptor_INTERFACE,
|
990
|
AUDStreamingInterfaceDescriptor_FORMATTYPE,
|
991
|
AUDFormatTypeOneDescriptor_FORMATTYPEONE,
|
992
|
AUDDLoopRecDriver_NUMCHANNELS,
|
993
|
AUDDLoopRecDriver_BYTESPERSAMPLE,
|
994
|
AUDDLoopRecDriver_BYTESPERSAMPLE*8,
|
995
|
1 // One discrete frequency supported
|
996
|
},
|
997
|
{
|
998
|
AUDDLoopRecDriver_SAMPLERATE & 0xFF,
|
999
|
(AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
|
1000
|
(AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
|
1001
|
}
|
1002
|
},
|
1003
|
// Audio streaming endpoint standard descriptor
|
1004
|
{
|
1005
|
sizeof(AUDEndpointDescriptor),
|
1006
|
USBGenericDescriptor_ENDPOINT,
|
1007
|
USBEndpointDescriptor_ADDRESS(
|
1008
|
USBEndpointDescriptor_OUT,
|
1009
|
AUDDLoopRecDriverDescriptors_DATAOUT),
|
1010
|
USBEndpointDescriptor_ISOCHRONOUS,
|
1011
|
AUDDLoopRecDriver_BYTESPERFRAME,
|
1012
|
AUDDLoopRecDriverDescriptors_FS_INTERVAL, // Polling interval = 1 ms
|
1013
|
0, // This is not a synchronization endpoint
|
1014
|
0 // No associated synchronization endpoint
|
1015
|
},
|
1016
|
// Audio streaming endpoint class-specific descriptor
|
1017
|
{
|
1018
|
sizeof(AUDDataEndpointDescriptor),
|
1019
|
AUDGenericDescriptor_ENDPOINT,
|
1020
|
AUDDataEndpointDescriptor_SUBTYPE,
|
1021
|
0, // No attributes
|
1022
|
0, // Endpoint is not synchronized
|
1023
|
0 // Endpoint is not synchronized
|
1024
|
},
|
1025
|
//- AUDIO IN
|
1026
|
// Audio streaming interface with 0 endpoints
|
1027
|
{
|
1028
|
sizeof(USBInterfaceDescriptor),
|
1029
|
USBGenericDescriptor_INTERFACE,
|
1030
|
AUDDLoopRecDriverDescriptors_STREAMINGIN,
|
1031
|
0, // This is alternate setting #0
|
1032
|
0, // This interface uses no endpoints
|
1033
|
AUDStreamingInterfaceDescriptor_CLASS,
|
1034
|
AUDStreamingInterfaceDescriptor_SUBCLASS,
|
1035
|
AUDStreamingInterfaceDescriptor_PROTOCOL,
|
1036
|
0 // No string descriptor
|
1037
|
},
|
1038
|
// Audio streaming interface with data endpoint
|
1039
|
{
|
1040
|
sizeof(USBInterfaceDescriptor),
|
1041
|
USBGenericDescriptor_INTERFACE,
|
1042
|
AUDDLoopRecDriverDescriptors_STREAMINGIN,
|
1043
|
1, // This is alternate setting #1
|
1044
|
1, // This interface uses 1 endpoint
|
1045
|
AUDStreamingInterfaceDescriptor_CLASS,
|
1046
|
AUDStreamingInterfaceDescriptor_SUBCLASS,
|
1047
|
AUDStreamingInterfaceDescriptor_PROTOCOL,
|
1048
|
0 // No string descriptor
|
1049
|
},
|
1050
|
// Audio streaming class-specific descriptor
|
1051
|
{
|
1052
|
sizeof(AUDStreamingInterfaceDescriptor),
|
1053
|
AUDGenericDescriptor_INTERFACE,
|
1054
|
AUDStreamingInterfaceDescriptor_GENERAL,
|
1055
|
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
|
1056
|
0, // No internal delay because of data path
|
1057
|
AUDFormatTypeOneDescriptor_PCM
|
1058
|
},
|
1059
|
// Format type I descriptor
|
1060
|
{
|
1061
|
{
|
1062
|
sizeof(AUDFormatTypeOneDescriptor1),
|
1063
|
AUDGenericDescriptor_INTERFACE,
|
1064
|
AUDStreamingInterfaceDescriptor_FORMATTYPE,
|
1065
|
AUDFormatTypeOneDescriptor_FORMATTYPEONE,
|
1066
|
AUDDLoopRecDriver_NUMCHANNELS,
|
1067
|
AUDDLoopRecDriver_BYTESPERSAMPLE,
|
1068
|
AUDDLoopRecDriver_BYTESPERSAMPLE*8,
|
1069
|
1 // One discrete frequency supported
|
1070
|
},
|
1071
|
{
|
1072
|
AUDDLoopRecDriver_SAMPLERATE & 0xFF,
|
1073
|
(AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
|
1074
|
(AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
|
1075
|
}
|
1076
|
},
|
1077
|
// Audio streaming endpoint standard descriptor
|
1078
|
{
|
1079
|
sizeof(AUDEndpointDescriptor),
|
1080
|
USBGenericDescriptor_ENDPOINT,
|
1081
|
USBEndpointDescriptor_ADDRESS(
|
1082
|
USBEndpointDescriptor_IN,
|
1083
|
AUDDLoopRecDriverDescriptors_DATAIN),
|
1084
|
USBEndpointDescriptor_ISOCHRONOUS,
|
1085
|
AUDDLoopRecDriver_BYTESPERFRAME,
|
1086
|
AUDDLoopRecDriverDescriptors_FS_INTERVAL, // Polling interval = 1 ms
|
1087
|
0, // This is not a synchronization endpoint
|
1088
|
0 // No associated synchronization endpoint
|
1089
|
},
|
1090
|
// Audio streaming endpoint class-specific descriptor
|
1091
|
{
|
1092
|
sizeof(AUDDataEndpointDescriptor),
|
1093
|
AUDGenericDescriptor_ENDPOINT,
|
1094
|
AUDDataEndpointDescriptor_SUBTYPE,
|
1095
|
0, // No attributes
|
1096
|
0, // Endpoint is not synchronized
|
1097
|
0 // Endpoint is not synchronized
|
1098
|
},
|
1099
|
DFURT_IF_DESCRIPTOR(3, 0),
|
1100
|
};
|
1101
|
|
1102
|
#endif // defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS)
|
1103
|
|
1104
|
/// FS Configuration descriptors for a USB Audio Loop Record driver.
|
1105
|
const AUDDLoopRecDriverConfigurationDescriptors fsConfigurationDescriptors = {
|
1106
|
|
1107
|
// Configuration descriptor
|
1108
|
{
|
1109
|
sizeof(USBConfigurationDescriptor),
|
1110
|
USBGenericDescriptor_CONFIGURATION,
|
1111
|
sizeof(AUDDLoopRecDriverConfigurationDescriptors),
|
1112
|
3+DFURT_NUM_IF, // This configuration has 3 interfaces
|
1113
|
1, // This is configuration #1
|
1114
|
0, // No string descriptor
|
1115
|
BOARD_USB_BMATTRIBUTES,
|
1116
|
USBConfigurationDescriptor_POWER(100)
|
1117
|
},
|
1118
|
// Audio control interface standard descriptor
|
1119
|
{
|
1120
|
sizeof(USBInterfaceDescriptor),
|
1121
|
USBGenericDescriptor_INTERFACE,
|
1122
|
AUDDLoopRecDriverDescriptors_CONTROL,
|
1123
|
0, // This is alternate setting #0
|
1124
|
0, // This interface uses no endpoint
|
1125
|
AUDControlInterfaceDescriptor_CLASS,
|
1126
|
AUDControlInterfaceDescriptor_SUBCLASS,
|
1127
|
AUDControlInterfaceDescriptor_PROTOCOL,
|
1128
|
0 // No string descriptor
|
1129
|
},
|
1130
|
// Audio control interface descriptors
|
1131
|
{
|
1132
|
// Header descriptor
|
1133
|
{
|
1134
|
{
|
1135
|
sizeof(AUDHeaderDescriptor2),
|
1136
|
AUDGenericDescriptor_INTERFACE,
|
1137
|
AUDGenericDescriptor_HEADER,
|
1138
|
AUDHeaderDescriptor_AUD1_00,
|
1139
|
sizeof(AUDDLoopRecDriverAudioControlDescriptors),
|
1140
|
2 // Two streaming interface
|
1141
|
},
|
1142
|
AUDDLoopRecDriverDescriptors_STREAMING,
|
1143
|
AUDDLoopRecDriverDescriptors_STREAMINGIN
|
1144
|
},
|
1145
|
// Input terminal descriptor ( speaker )
|
1146
|
{
|
1147
|
sizeof(AUDInputTerminalDescriptor),
|
1148
|
AUDGenericDescriptor_INTERFACE,
|
1149
|
AUDGenericDescriptor_INPUTTERMINAL,
|
1150
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
|
1151
|
AUDInputTerminalDescriptor_USBSTREAMING,
|
1152
|
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
|
1153
|
AUDDLoopRecDriver_NUMCHANNELS,
|
1154
|
#if AUDDLoopRecDriver_NUMCHANNELS > 1
|
1155
|
AUDInputTerminalDescriptor_LEFTFRONT
|
1156
|
| AUDInputTerminalDescriptor_RIGHTFRONT,
|
1157
|
#else
|
1158
|
0, // Mono sets no position bits.
|
1159
|
#endif
|
1160
|
0, // No string descriptor for channels
|
1161
|
0 // No string descriptor for input terminal
|
1162
|
},
|
1163
|
// Output terminal descriptor ( speaker )
|
1164
|
{
|
1165
|
sizeof(AUDOutputTerminalDescriptor),
|
1166
|
AUDGenericDescriptor_INTERFACE,
|
1167
|
AUDGenericDescriptor_OUTPUTTERMINAL,
|
1168
|
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
|
1169
|
AUDOutputTerminalDescriptor_SPEAKER,
|
1170
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
|
1171
|
AUDDLoopRecDriverDescriptors_FEATUREUNIT,
|
1172
|
0 // No string descriptor
|
1173
|
},
|
1174
|
// Feature unit descriptor ( speaker )
|
1175
|
{
|
1176
|
{
|
1177
|
sizeof(AUDFeatureUnitDescriptor3),
|
1178
|
AUDGenericDescriptor_INTERFACE,
|
1179
|
AUDGenericDescriptor_FEATUREUNIT,
|
1180
|
AUDDLoopRecDriverDescriptors_FEATUREUNIT,
|
1181
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
|
1182
|
1, // 1 byte per channel for controls
|
1183
|
},
|
1184
|
{
|
1185
|
AUDFeatureUnitDescriptor_MUTE, // Master channel controls
|
1186
|
0, // Right channel controls
|
1187
|
0 // Left channel controls
|
1188
|
},
|
1189
|
0 // No string descriptor
|
1190
|
},
|
1191
|
// Input terminal descriptor ( speakerphone )
|
1192
|
{
|
1193
|
sizeof(AUDInputTerminalDescriptor),
|
1194
|
AUDGenericDescriptor_INTERFACE,
|
1195
|
AUDGenericDescriptor_INPUTTERMINAL,
|
1196
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
|
1197
|
AUDInputTerminalDescriptor_SPEAKERPHONE,
|
1198
|
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
|
1199
|
AUDDLoopRecDriver_NUMCHANNELS,
|
1200
|
#if AUDDLoopRecDriver_NUMCHANNELS > 1
|
1201
|
AUDInputTerminalDescriptor_LEFTFRONT
|
1202
|
| AUDInputTerminalDescriptor_RIGHTFRONT,
|
1203
|
#else
|
1204
|
0, // Mono sets no position bits.
|
1205
|
#endif
|
1206
|
0, // No string descriptor for channels
|
1207
|
0 // No string descriptor for input terminal
|
1208
|
},
|
1209
|
// Output terminal descriptor ( speakerphone )
|
1210
|
{
|
1211
|
sizeof(AUDOutputTerminalDescriptor),
|
1212
|
AUDGenericDescriptor_INTERFACE,
|
1213
|
AUDGenericDescriptor_OUTPUTTERMINAL,
|
1214
|
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
|
1215
|
AUDOutputTerminalDescriptor_USBTREAMING,
|
1216
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
|
1217
|
AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
|
1218
|
0 // No string descriptor
|
1219
|
},
|
1220
|
// Feature unit descriptor ( speakerphone )
|
1221
|
{
|
1222
|
{
|
1223
|
sizeof(AUDFeatureUnitDescriptor3),
|
1224
|
AUDGenericDescriptor_INTERFACE,
|
1225
|
AUDGenericDescriptor_FEATUREUNIT,
|
1226
|
AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
|
1227
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
|
1228
|
1
|
1229
|
},
|
1230
|
{
|
1231
|
AUDFeatureUnitDescriptor_MUTE, // Mic controls
|
1232
|
0,
|
1233
|
0
|
1234
|
},
|
1235
|
0 // No string descriptor
|
1236
|
}
|
1237
|
},
|
1238
|
// - AUIDO OUT
|
1239
|
// Audio streaming interface with 0 endpoints
|
1240
|
{
|
1241
|
sizeof(USBInterfaceDescriptor),
|
1242
|
USBGenericDescriptor_INTERFACE,
|
1243
|
AUDDLoopRecDriverDescriptors_STREAMING,
|
1244
|
0, // This is alternate setting #0
|
1245
|
0, // This interface uses no endpoints
|
1246
|
AUDStreamingInterfaceDescriptor_CLASS,
|
1247
|
AUDStreamingInterfaceDescriptor_SUBCLASS,
|
1248
|
AUDStreamingInterfaceDescriptor_PROTOCOL,
|
1249
|
0 // No string descriptor
|
1250
|
},
|
1251
|
// Audio streaming interface with data endpoint
|
1252
|
{
|
1253
|
sizeof(USBInterfaceDescriptor),
|
1254
|
USBGenericDescriptor_INTERFACE,
|
1255
|
AUDDLoopRecDriverDescriptors_STREAMING,
|
1256
|
1, // This is alternate setting #1
|
1257
|
1, // This interface uses 1 endpoint
|
1258
|
AUDStreamingInterfaceDescriptor_CLASS,
|
1259
|
AUDStreamingInterfaceDescriptor_SUBCLASS,
|
1260
|
AUDStreamingInterfaceDescriptor_PROTOCOL,
|
1261
|
0 // No string descriptor
|
1262
|
},
|
1263
|
// Audio streaming class-specific descriptor
|
1264
|
{
|
1265
|
sizeof(AUDStreamingInterfaceDescriptor),
|
1266
|
AUDGenericDescriptor_INTERFACE,
|
1267
|
AUDStreamingInterfaceDescriptor_GENERAL,
|
1268
|
AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
|
1269
|
0, // No internal delay because of data path
|
1270
|
AUDFormatTypeOneDescriptor_PCM
|
1271
|
},
|
1272
|
// Format type I descriptor
|
1273
|
{
|
1274
|
{
|
1275
|
sizeof(AUDFormatTypeOneDescriptor1),
|
1276
|
AUDGenericDescriptor_INTERFACE,
|
1277
|
AUDStreamingInterfaceDescriptor_FORMATTYPE,
|
1278
|
AUDFormatTypeOneDescriptor_FORMATTYPEONE,
|
1279
|
AUDDLoopRecDriver_NUMCHANNELS,
|
1280
|
AUDDLoopRecDriver_BYTESPERSAMPLE,
|
1281
|
AUDDLoopRecDriver_BYTESPERSAMPLE*8,
|
1282
|
1 // One discrete frequency supported
|
1283
|
},
|
1284
|
{
|
1285
|
AUDDLoopRecDriver_SAMPLERATE & 0xFF,
|
1286
|
(AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
|
1287
|
(AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
|
1288
|
}
|
1289
|
},
|
1290
|
// Audio streaming endpoint standard descriptor
|
1291
|
{
|
1292
|
sizeof(AUDEndpointDescriptor),
|
1293
|
USBGenericDescriptor_ENDPOINT,
|
1294
|
USBEndpointDescriptor_ADDRESS(
|
1295
|
USBEndpointDescriptor_OUT,
|
1296
|
AUDDLoopRecDriverDescriptors_DATAOUT),
|
1297
|
USBEndpointDescriptor_ISOCHRONOUS,
|
1298
|
AUDDLoopRecDriver_BYTESPERFRAME,
|
1299
|
AUDDLoopRecDriverDescriptors_FS_INTERVAL, // Polling interval = 1 ms
|
1300
|
0, // This is not a synchronization endpoint
|
1301
|
0 // No associated synchronization endpoint
|
1302
|
},
|
1303
|
// Audio streaming endpoint class-specific descriptor
|
1304
|
{
|
1305
|
sizeof(AUDDataEndpointDescriptor),
|
1306
|
AUDGenericDescriptor_ENDPOINT,
|
1307
|
AUDDataEndpointDescriptor_SUBTYPE,
|
1308
|
0, // No attributes
|
1309
|
0, // Endpoint is not synchronized
|
1310
|
0 // Endpoint is not synchronized
|
1311
|
},
|
1312
|
//- AUDIO IN
|
1313
|
// Audio streaming interface with 0 endpoints
|
1314
|
{
|
1315
|
sizeof(USBInterfaceDescriptor),
|
1316
|
USBGenericDescriptor_INTERFACE,
|
1317
|
AUDDLoopRecDriverDescriptors_STREAMINGIN,
|
1318
|
0, // This is alternate setting #0
|
1319
|
0, // This interface uses no endpoints
|
1320
|
AUDStreamingInterfaceDescriptor_CLASS,
|
1321
|
AUDStreamingInterfaceDescriptor_SUBCLASS,
|
1322
|
AUDStreamingInterfaceDescriptor_PROTOCOL,
|
1323
|
0 // No string descriptor
|
1324
|
},
|
1325
|
// Audio streaming interface with data endpoint
|
1326
|
{
|
1327
|
sizeof(USBInterfaceDescriptor),
|
1328
|
USBGenericDescriptor_INTERFACE,
|
1329
|
AUDDLoopRecDriverDescriptors_STREAMINGIN,
|
1330
|
1, // This is alternate setting #1
|
1331
|
1, // This interface uses 1 endpoint
|
1332
|
AUDStreamingInterfaceDescriptor_CLASS,
|
1333
|
AUDStreamingInterfaceDescriptor_SUBCLASS,
|
1334
|
AUDStreamingInterfaceDescriptor_PROTOCOL,
|
1335
|
0 // No string descriptor
|
1336
|
},
|
1337
|
// Audio streaming class-specific descriptor
|
1338
|
{
|
1339
|
sizeof(AUDStreamingInterfaceDescriptor),
|
1340
|
AUDGenericDescriptor_INTERFACE,
|
1341
|
AUDStreamingInterfaceDescriptor_GENERAL,
|
1342
|
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
|
1343
|
0, // No internal delay because of data path
|
1344
|
AUDFormatTypeOneDescriptor_PCM
|
1345
|
},
|
1346
|
// Format type I descriptor
|
1347
|
{
|
1348
|
{
|
1349
|
sizeof(AUDFormatTypeOneDescriptor1),
|
1350
|
AUDGenericDescriptor_INTERFACE,
|
1351
|
AUDStreamingInterfaceDescriptor_FORMATTYPE,
|
1352
|
AUDFormatTypeOneDescriptor_FORMATTYPEONE,
|
1353
|
AUDDLoopRecDriver_NUMCHANNELS,
|
1354
|
AUDDLoopRecDriver_BYTESPERSAMPLE,
|
1355
|
AUDDLoopRecDriver_BYTESPERSAMPLE*8,
|
1356
|
1 // One discrete frequency supported
|
1357
|
},
|
1358
|
{
|
1359
|
AUDDLoopRecDriver_SAMPLERATE & 0xFF,
|
1360
|
(AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
|
1361
|
(AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
|
1362
|
}
|
1363
|
},
|
1364
|
// Audio streaming endpoint standard descriptor
|
1365
|
{
|
1366
|
sizeof(AUDEndpointDescriptor),
|
1367
|
USBGenericDescriptor_ENDPOINT,
|
1368
|
USBEndpointDescriptor_ADDRESS(
|
1369
|
USBEndpointDescriptor_IN,
|
1370
|
AUDDLoopRecDriverDescriptors_DATAIN),
|
1371
|
USBEndpointDescriptor_ISOCHRONOUS,
|
1372
|
AUDDLoopRecDriver_BYTESPERFRAME,
|
1373
|
AUDDLoopRecDriverDescriptors_FS_INTERVAL, // Polling interval = 1 ms
|
1374
|
0, // This is not a synchronization endpoint
|
1375
|
0 // No associated synchronization endpoint
|
1376
|
},
|
1377
|
// Audio streaming endpoint class-specific descriptor
|
1378
|
{
|
1379
|
sizeof(AUDDataEndpointDescriptor),
|
1380
|
AUDGenericDescriptor_ENDPOINT,
|
1381
|
AUDDataEndpointDescriptor_SUBTYPE,
|
1382
|
0, // No attributes
|
1383
|
0, // Endpoint is not synchronized
|
1384
|
0 // Endpoint is not synchronized
|
1385
|
},
|
1386
|
DFURT_IF_DESCRIPTOR(3, 0),
|
1387
|
};
|
1388
|
|
1389
|
/// String descriptor with the supported languages.
|
1390
|
const unsigned char languageIdDescriptor[] = {
|
1391
|
|
1392
|
USBStringDescriptor_LENGTH(1),
|
1393
|
USBGenericDescriptor_STRING,
|
1394
|
USBStringDescriptor_ENGLISH_US
|
1395
|
};
|
1396
|
|
1397
|
/// Manufacturer name.
|
1398
|
const unsigned char manufacturerDescriptor[] = {
|
1399
|
|
1400
|
USBStringDescriptor_LENGTH(8),
|
1401
|
USBGenericDescriptor_STRING,
|
1402
|
USBStringDescriptor_UNICODE('s'),
|
1403
|
USBStringDescriptor_UNICODE('y'),
|
1404
|
USBStringDescriptor_UNICODE('s'),
|
1405
|
USBStringDescriptor_UNICODE('m'),
|
1406
|
USBStringDescriptor_UNICODE('o'),
|
1407
|
USBStringDescriptor_UNICODE('c'),
|
1408
|
USBStringDescriptor_UNICODE('o'),
|
1409
|
USBStringDescriptor_UNICODE('m'),
|
1410
|
};
|
1411
|
|
1412
|
/// Product name.
|
1413
|
const unsigned char productDescriptor[] = {
|
1414
|
|
1415
|
USBStringDescriptor_LENGTH(7),
|
1416
|
USBGenericDescriptor_STRING,
|
1417
|
USBStringDescriptor_UNICODE('O'),
|
1418
|
USBStringDescriptor_UNICODE('s'),
|
1419
|
USBStringDescriptor_UNICODE('m'),
|
1420
|
USBStringDescriptor_UNICODE('o'),
|
1421
|
USBStringDescriptor_UNICODE('S'),
|
1422
|
USBStringDescriptor_UNICODE('D'),
|
1423
|
USBStringDescriptor_UNICODE('R'),
|
1424
|
};
|
1425
|
|
1426
|
/// Product serial number.
|
1427
|
const unsigned char serialNumberDescriptor[] = {
|
1428
|
|
1429
|
USBStringDescriptor_LENGTH(4),
|
1430
|
USBGenericDescriptor_STRING,
|
1431
|
USBStringDescriptor_UNICODE('0'),
|
1432
|
USBStringDescriptor_UNICODE('1'),
|
1433
|
USBStringDescriptor_UNICODE('2'),
|
1434
|
USBStringDescriptor_UNICODE('3')
|
1435
|
};
|
1436
|
|
1437
|
/// Array of pointers to the four string descriptors.
|
1438
|
const unsigned char *stringDescriptors[] = {
|
1439
|
|
1440
|
languageIdDescriptor,
|
1441
|
manufacturerDescriptor,
|
1442
|
productDescriptor,
|
1443
|
serialNumberDescriptor,
|
1444
|
};
|
1445
|
|
1446
|
//------------------------------------------------------------------------------
|
1447
|
// Exported functions
|
1448
|
//------------------------------------------------------------------------------
|
1449
|
|
1450
|
/// List of descriptors required by an USB Audio Loop Recorder device driver.
|
1451
|
const USBDDriverDescriptors auddFastSourceDriverDescriptors = {
|
1452
|
|
1453
|
&deviceDescriptor,
|
1454
|
(const USBConfigurationDescriptor *) &fsConfigurationDescriptors,
|
1455
|
#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS)
|
1456
|
&qualifierDescriptor,
|
1457
|
(const USBConfigurationDescriptor *) &fsOtherSpeedConfigurationDescriptors,
|
1458
|
&deviceDescriptor,
|
1459
|
(const USBConfigurationDescriptor *) &hsConfigurationDescriptors,
|
1460
|
&qualifierDescriptor,
|
1461
|
(const USBConfigurationDescriptor *) &hsOtherSpeedConfigurationDescriptors,
|
1462
|
#else
|
1463
|
0, 0, 0, 0, 0, 0,
|
1464
|
#endif
|
1465
|
stringDescriptors,
|
1466
|
4 // Number of string descriptors
|
1467
|
};
|
1468
|
|
1469
|
#else
|
1470
|
|
1471
|
typedef struct {
|
1472
|
/// Size of the descriptor in bytes.
|
1473
|
unsigned char bLength;
|
1474
|
/// Descriptor type (USBGenericDescriptor_ENDPOINT).
|
1475
|
unsigned char bDescriptorType;
|
1476
|
/// Address and direction of the endpoint.
|
1477
|
unsigned char bEndpointAddress;
|
1478
|
/// Endpoint type and additional characteristics (for isochronous endpoints).
|
1479
|
unsigned char bmAttributes;
|
1480
|
/// Maximum packet size (in bytes) of the endpoint.
|
1481
|
unsigned short wMaxPacketSize;
|
1482
|
/// Polling rate of the endpoint.
|
1483
|
unsigned char bInterval;
|
1484
|
} __attribute__ ((packed)) BulkEndpointDescriptor; // GCC
|
1485
|
|
1486
|
typedef struct {
|
1487
|
|
1488
|
/// Standard configuration.
|
1489
|
USBConfigurationDescriptor configuration;
|
1490
|
/// Audio stream interface.
|
1491
|
USBInterfaceDescriptor stream;
|
1492
|
/// Streaming out endpoint descriptor.
|
1493
|
BulkEndpointDescriptor bulkInEndpoint;
|
1494
|
} __attribute__ ((packed)) BulkDriverConfigurationDescriptors; // GCC
|
1495
|
|
1496
|
|
1497
|
const USBDeviceDescriptor deviceDescriptor = {
|
1498
|
sizeof(USBDeviceDescriptor),
|
1499
|
USBGenericDescriptor_DEVICE,
|
1500
|
USBDeviceDescriptor_USB2_00,
|
1501
|
0, // class - all defined at interface level
|
1502
|
0, // subclass
|
1503
|
0, // protocol
|
1504
|
CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
|
1505
|
AUDDLoopRecDriverDescriptors_VENDORID,
|
1506
|
AUDDLoopRecDriverDescriptors_PRODUCTID,
|
1507
|
AUDDLoopRecDriverDescriptors_RELEASE,
|
1508
|
1, // Manufacturer string descriptor index
|
1509
|
2, // Product string descriptor index
|
1510
|
3, // Index of serial number string descriptor
|
1511
|
1 // One possible configuration
|
1512
|
};
|
1513
|
|
1514
|
/// configuration descriptors for bulk
|
1515
|
const BulkDriverConfigurationDescriptors configurationDescriptors = {
|
1516
|
|
1517
|
// Configuration descriptor
|
1518
|
{
|
1519
|
sizeof(USBConfigurationDescriptor),
|
1520
|
USBGenericDescriptor_CONFIGURATION,
|
1521
|
sizeof(BulkDriverConfigurationDescriptors),
|
1522
|
1, // This configuration has 1 interfaces
|
1523
|
1, // This is configuration #1
|
1524
|
0, // No string descriptor
|
1525
|
BOARD_USB_BMATTRIBUTES,
|
1526
|
USBConfigurationDescriptor_POWER(100)
|
1527
|
},
|
1528
|
// Bulk interface standard descriptor
|
1529
|
{
|
1530
|
sizeof(USBInterfaceDescriptor),
|
1531
|
USBGenericDescriptor_INTERFACE,
|
1532
|
0, // interface number
|
1533
|
0, // This is alternate setting #0
|
1534
|
1, // This interface uses one endpoint
|
1535
|
254, // class
|
1536
|
0, // subclass
|
1537
|
0, // protocol
|
1538
|
0 // No string descriptor
|
1539
|
},
|
1540
|
{
|
1541
|
sizeof(BulkEndpointDescriptor),
|
1542
|
USBGenericDescriptor_ENDPOINT,
|
1543
|
USBEndpointDescriptor_ADDRESS(
|
1544
|
USBEndpointDescriptor_IN,
|
1545
|
AUDDLoopRecDriverDescriptors_DATAIN),
|
1546
|
USBEndpointDescriptor_BULK,
|
1547
|
0x200, // packet size
|
1548
|
0 // Polling interval = 0 ms
|
1549
|
},
|
1550
|
};
|
1551
|
|
1552
|
/// configuration descriptors for bulk
|
1553
|
const BulkDriverConfigurationDescriptors otherConfigurationDescriptors = {
|
1554
|
|
1555
|
// Configuration descriptor
|
1556
|
{
|
1557
|
sizeof(USBConfigurationDescriptor),
|
1558
|
USBGenericDescriptor_OTHERSPEEDCONFIGURATION,
|
1559
|
sizeof(BulkDriverConfigurationDescriptors),
|
1560
|
1, // This configuration has 1 interface
|
1561
|
1, // This is configuration #1
|
1562
|
0, // No string descriptor
|
1563
|
BOARD_USB_BMATTRIBUTES,
|
1564
|
USBConfigurationDescriptor_POWER(100)
|
1565
|
},
|
1566
|
// Bulk interface standard descriptor
|
1567
|
{
|
1568
|
sizeof(USBInterfaceDescriptor),
|
1569
|
USBGenericDescriptor_INTERFACE,
|
1570
|
0, // interface number
|
1571
|
0, // This is alternate setting #0
|
1572
|
1, // This interface uses one endpoint
|
1573
|
254, // class
|
1574
|
0, // subclass
|
1575
|
0, // protocol
|
1576
|
0 // No string descriptor
|
1577
|
},
|
1578
|
{
|
1579
|
sizeof(BulkEndpointDescriptor),
|
1580
|
USBGenericDescriptor_ENDPOINT,
|
1581
|
USBEndpointDescriptor_ADDRESS(
|
1582
|
USBEndpointDescriptor_IN,
|
1583
|
AUDDLoopRecDriverDescriptors_DATAIN),
|
1584
|
USBEndpointDescriptor_BULK,
|
1585
|
0x200, // packet size
|
1586
|
0 // Polling interval = 0 ms
|
1587
|
},
|
1588
|
};
|
1589
|
|
1590
|
|
1591
|
/// String descriptor with the supported languages.
|
1592
|
const unsigned char languageIdDescriptor[] = {
|
1593
|
|
1594
|
USBStringDescriptor_LENGTH(1),
|
1595
|
USBGenericDescriptor_STRING,
|
1596
|
USBStringDescriptor_ENGLISH_US
|
1597
|
};
|
1598
|
|
1599
|
/// USB device qualifier descriptor.
|
1600
|
const USBDeviceQualifierDescriptor qualifierDescriptor = {
|
1601
|
|
1602
|
sizeof(USBDeviceQualifierDescriptor),
|
1603
|
USBGenericDescriptor_DEVICEQUALIFIER,
|
1604
|
USBDeviceDescriptor_USB2_00,
|
1605
|
0, // class
|
1606
|
0, // subclass
|
1607
|
0, // protocol
|
1608
|
CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
|
1609
|
1, // Device has one possible configuration
|
1610
|
0 // Reserved
|
1611
|
};
|
1612
|
|
1613
|
/// Manufacturer name.
|
1614
|
const unsigned char manufacturerDescriptor[] = {
|
1615
|
|
1616
|
USBStringDescriptor_LENGTH(8),
|
1617
|
USBGenericDescriptor_STRING,
|
1618
|
USBStringDescriptor_UNICODE('s'),
|
1619
|
USBStringDescriptor_UNICODE('y'),
|
1620
|
USBStringDescriptor_UNICODE('s'),
|
1621
|
USBStringDescriptor_UNICODE('m'),
|
1622
|
USBStringDescriptor_UNICODE('o'),
|
1623
|
USBStringDescriptor_UNICODE('c'),
|
1624
|
USBStringDescriptor_UNICODE('o'),
|
1625
|
USBStringDescriptor_UNICODE('m'),
|
1626
|
};
|
1627
|
|
1628
|
/// Product name.
|
1629
|
const unsigned char productDescriptor[] = {
|
1630
|
|
1631
|
USBStringDescriptor_LENGTH(7),
|
1632
|
USBGenericDescriptor_STRING,
|
1633
|
USBStringDescriptor_UNICODE('O'),
|
1634
|
USBStringDescriptor_UNICODE('s'),
|
1635
|
USBStringDescriptor_UNICODE('m'),
|
1636
|
USBStringDescriptor_UNICODE('o'),
|
1637
|
USBStringDescriptor_UNICODE('S'),
|
1638
|
USBStringDescriptor_UNICODE('D'),
|
1639
|
USBStringDescriptor_UNICODE('R'),
|
1640
|
};
|
1641
|
|
1642
|
/// Product serial number.
|
1643
|
const unsigned char serialNumberDescriptor[] = {
|
1644
|
|
1645
|
USBStringDescriptor_LENGTH(3),
|
1646
|
USBGenericDescriptor_STRING,
|
1647
|
USBStringDescriptor_UNICODE('6'),
|
1648
|
USBStringDescriptor_UNICODE('6'),
|
1649
|
USBStringDescriptor_UNICODE('6')
|
1650
|
};
|
1651
|
|
1652
|
/// Array of pointers to the four string descriptors.
|
1653
|
const unsigned char *stringDescriptors[] = {
|
1654
|
|
1655
|
languageIdDescriptor,
|
1656
|
manufacturerDescriptor,
|
1657
|
productDescriptor,
|
1658
|
serialNumberDescriptor,
|
1659
|
};
|
1660
|
|
1661
|
const USBDDriverDescriptors auddFastSourceDriverDescriptors = {
|
1662
|
&deviceDescriptor,
|
1663
|
(const USBConfigurationDescriptor *) &configurationDescriptors,
|
1664
|
#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS)
|
1665
|
&qualifierDescriptor,
|
1666
|
(const USBConfigurationDescriptor *) &otherConfigurationDescriptors,
|
1667
|
&deviceDescriptor,
|
1668
|
(const USBConfigurationDescriptor *) &configurationDescriptors,
|
1669
|
&qualifierDescriptor,
|
1670
|
(const USBConfigurationDescriptor *) &otherConfigurationDescriptors,
|
1671
|
#else
|
1672
|
0, 0, 0, 0, 0, 0,
|
1673
|
#endif
|
1674
|
stringDescriptors,
|
1675
|
4 // Number of string descriptors
|
1676
|
};
|
1677
|
#endif
|