Project

General

Profile

Download (56 KB) Statistics
| Branch: | Tag: | Revision:
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 "AUDDFastSourceDescriptors.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
//------------------------------------------------------------------------------
57
//         Definitions
58
//------------------------------------------------------------------------------
59

    
60
//------------------------------------------------------------------------------
61
/// \page "Audio Loop Record Device Codes"
62
///
63
/// This page lists the %device IDs and release number of the USB Audio Loop Record
64
/// %device.
65
///
66
/// !Codes
67
/// - AUDDLoopRecDriverDescriptors_VENDORID
68
/// - AUDDLoopRecDriverDescriptors_PRODUCTID
69
/// - AUDDLoopRecDriverDescriptors_RELEASE
70

    
71
/// Device vendor ID.
72
#define AUDDLoopRecDriverDescriptors_VENDORID            0x16C0
73
/// Device product ID.
74
#define AUDDLoopRecDriverDescriptors_PRODUCTID           0x0763
75
/// Device release number in BCD format.
76
#define AUDDLoopRecDriverDescriptors_RELEASE             0x0100
77
//------------------------------------------------------------------------------
78

    
79
//------------------------------------------------------------------------------
80
//         Internal types
81
//------------------------------------------------------------------------------
82

    
83
//------------------------------------------------------------------------------
84
/// Audio control header descriptor with one slave interface.
85
//------------------------------------------------------------------------------
86
#ifdef __ICCARM__          // IAR
87
#pragma pack(1)            // IAR
88
#define __attribute__(...) // IAR
89
#endif                     // IAR
90

    
91
//------------------------------------------------------------------------------
92
/// Header descriptor with 1 interface.
93
//------------------------------------------------------------------------------
94
typedef struct {
95

    
96
    /// Header descriptor.
97
    AUDHeaderDescriptor header;
98
    /// Id of the first grouped interface - Speaker.
99
    unsigned char bInterface0;
100
    /// Id of the second grouped interface - Speakerphone.
101
    unsigned char bInterface1;
102

    
103
} __attribute__ ((packed)) AUDHeaderDescriptor2; // GCC
104

    
105
//------------------------------------------------------------------------------
106
/// Feature unit descriptor with 3 channel controls (master, right, left).
107
//------------------------------------------------------------------------------
108
typedef struct {
109

    
110
    /// Feature unit descriptor.
111
    AUDFeatureUnitDescriptor feature;
112
    /// Available controls for each channel.
113
    unsigned char bmaControls[3];
114
    /// Index of a string descriptor for the feature unit.
115
    unsigned char iFeature;
116

    
117
} __attribute__ ((packed)) AUDFeatureUnitDescriptor3; // GCC
118

    
119
//------------------------------------------------------------------------------
120
/// List of descriptors for detailling the audio control interface of a
121
/// device using a USB Audio Loop Recorder driver.
122
//------------------------------------------------------------------------------
123
typedef struct {
124

    
125
    /// Header descriptor (with one slave interface).
126
    AUDHeaderDescriptor2 header;
127
    /// Input terminal descriptor.
128
    AUDInputTerminalDescriptor inputLoopRec;
129
    /// Output terminal descriptor.
130
    AUDOutputTerminalDescriptor outputLoopRec;
131
    /// Feature unit descriptor - LoopRec.
132
    AUDFeatureUnitDescriptor3 featureLoopRec;
133
    /// Input terminal descriptor.
134
    AUDInputTerminalDescriptor inputRec;
135
    /// Output terminal descriptor.
136
    AUDOutputTerminalDescriptor outputRec;
137
    /// Feature unit descriptor - LoopRecphone.
138
    AUDFeatureUnitDescriptor3 featureRec;
139

    
140
} __attribute__ ((packed)) AUDDLoopRecDriverAudioControlDescriptors; // GCC
141

    
142
//------------------------------------------------------------------------------
143
/// Format type I descriptor with one discrete sampling frequency.
144
//------------------------------------------------------------------------------
145
typedef struct {
146

    
147
    /// Format type I descriptor.
148
    AUDFormatTypeOneDescriptor formatType;
149
    /// Sampling frequency in Hz.
150
    unsigned char tSamFreq[3];
151

    
152
} __attribute__ ((packed)) AUDFormatTypeOneDescriptor1; // GCC
153

    
154
//------------------------------------------------------------------------------
155
/// Holds a list of descriptors returned as part of the configuration of
156
/// a USB Audio Loop Record device.
157
//------------------------------------------------------------------------------
158
typedef struct {
159

    
160
    /// Standard configuration.
161
    USBConfigurationDescriptor configuration;
162
    /// Audio control interface.
163
    USBInterfaceDescriptor control;
164
    /// Descriptors for the audio control interface.
165
    AUDDLoopRecDriverAudioControlDescriptors controlDescriptors;
166
    //- AUDIO OUT
167
    /// Streaming out interface descriptor (with no endpoint, required).
168
    USBInterfaceDescriptor streamingOutNoIsochronous;
169
    /// Streaming out interface descriptor.
170
    USBInterfaceDescriptor streamingOut;
171
    /// Audio class descriptor for the streaming out interface.
172
    AUDStreamingInterfaceDescriptor streamingOutClass;
173
    /// Stream format descriptor.
174
    AUDFormatTypeOneDescriptor1 streamingOutFormatType;
175
    /// Streaming out endpoint descriptor.
176
    AUDEndpointDescriptor streamingOutEndpoint;
177
    /// Audio class descriptor for the streaming out endpoint.
178
    AUDDataEndpointDescriptor streamingOutDataEndpoint; 
179
    //- AUDIO IN
180
    /// Streaming in interface descriptor (with no endpoint, required).
181
    USBInterfaceDescriptor streamingInNoIsochronous;
182
    /// Streaming in interface descriptor.
183
    USBInterfaceDescriptor streamingIn;
184
    /// Audio class descriptor for the streaming in interface.
185
    AUDStreamingInterfaceDescriptor streamingInClass;
186
    /// Stream format descriptor.
187
    AUDFormatTypeOneDescriptor1 streamingInFormatType;
188
    /// Streaming in endpoint descriptor.
189
    AUDEndpointDescriptor streamingInEndpoint;
190
    /// Audio class descriptor for the streaming in endpoint.
191
    AUDDataEndpointDescriptor streamingInDataEndpoint;
192
    // DFU Runtime
193
    DFURT_IF_DESCRIPTOR_STRUCT
194
} __attribute__ ((packed)) AUDDLoopRecDriverConfigurationDescriptors; // GCC
195

    
196
#ifdef __ICCARM__          // IAR
197
#pragma pack()             // IAR
198
#endif                     // IAR
199

    
200
//------------------------------------------------------------------------------
201
//         Exported variables
202
//------------------------------------------------------------------------------
203

    
204
/// Device descriptor for a USB Audio Loop Record driver.
205
const USBDeviceDescriptor deviceDescriptor = {
206

    
207
    sizeof(USBDeviceDescriptor),
208
    USBGenericDescriptor_DEVICE,
209
    USBDeviceDescriptor_USB2_00,
210
    AUDDeviceDescriptor_CLASS,
211
    AUDDeviceDescriptor_SUBCLASS,
212
    AUDDeviceDescriptor_PROTOCOL,
213
    CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
214
    AUDDLoopRecDriverDescriptors_VENDORID,
215
    AUDDLoopRecDriverDescriptors_PRODUCTID,
216
    AUDDLoopRecDriverDescriptors_RELEASE,
217
    1, // Manufacturer string descriptor index
218
    2, // Product string descriptor index
219
    3, // Index of serial number string descriptor
220
    1  // One possible configuration
221
};
222

    
223
#if defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS)
224

    
225
/// USB device qualifier descriptor.
226
const USBDeviceQualifierDescriptor qualifierDescriptor = {
227

    
228
    sizeof(USBDeviceQualifierDescriptor),
229
    USBGenericDescriptor_DEVICEQUALIFIER,
230
    USBDeviceDescriptor_USB2_00,
231
    AUDDeviceDescriptor_CLASS,
232
    AUDDeviceDescriptor_SUBCLASS,
233
    AUDDeviceDescriptor_PROTOCOL,
234
    CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
235
    1, // Device has one possible configuration
236
    0 // Reserved
237
};
238

    
239
/// HS Configuration descriptors for a USB Audio Loop Record driver.
240
const AUDDLoopRecDriverConfigurationDescriptors hsConfigurationDescriptors = {
241

    
242
    // Configuration descriptor
243
    {
244
        sizeof(USBConfigurationDescriptor),
245
        USBGenericDescriptor_CONFIGURATION,
246
        sizeof(AUDDLoopRecDriverConfigurationDescriptors),
247
        3+DFURT_NUM_IF, // This configuration has 3 interfaces
248
        1, // This is configuration #1
249
        0, // No string descriptor
250
        BOARD_USB_BMATTRIBUTES,
251
        USBConfigurationDescriptor_POWER(100)
252
    },
253
    // Audio control interface standard descriptor
254
    {
255
        sizeof(USBInterfaceDescriptor),
256
        USBGenericDescriptor_INTERFACE,
257
        AUDDLoopRecDriverDescriptors_CONTROL,
258
        0, // This is alternate setting #0
259
        0, // This interface uses no endpoint
260
        AUDControlInterfaceDescriptor_CLASS,
261
        AUDControlInterfaceDescriptor_SUBCLASS,
262
        AUDControlInterfaceDescriptor_PROTOCOL,
263
        0 // No string descriptor
264
    },
265
    // Audio control interface descriptors
266
    {
267
        // Header descriptor
268
        {
269
            {
270
                sizeof(AUDHeaderDescriptor2),
271
                AUDGenericDescriptor_INTERFACE,
272
                AUDGenericDescriptor_HEADER,
273
                AUDHeaderDescriptor_AUD1_00,
274
                sizeof(AUDDLoopRecDriverAudioControlDescriptors),
275
                2 // Two streaming interface
276
            },
277
            AUDDLoopRecDriverDescriptors_STREAMING,
278
            AUDDLoopRecDriverDescriptors_STREAMINGIN
279
        },
280
        // Input terminal descriptor ( speaker )
281
        {
282
            sizeof(AUDInputTerminalDescriptor),
283
            AUDGenericDescriptor_INTERFACE,
284
            AUDGenericDescriptor_INPUTTERMINAL,
285
            AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
286
            AUDInputTerminalDescriptor_USBSTREAMING,
287
            AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
288
            AUDDLoopRecDriver_NUMCHANNELS,
289
          #if AUDDLoopRecDriver_NUMCHANNELS > 1
290
            AUDInputTerminalDescriptor_LEFTFRONT
291
            | AUDInputTerminalDescriptor_RIGHTFRONT,
292
          #else
293
            0, // Mono sets no position bits.
294
          #endif
295
            0, // No string descriptor for channels
296
            0 // No string descriptor for input terminal
297
        },
298
        // Output terminal descriptor ( speaker )
299
        {
300
            sizeof(AUDOutputTerminalDescriptor),
301
            AUDGenericDescriptor_INTERFACE,
302
            AUDGenericDescriptor_OUTPUTTERMINAL,
303
            AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
304
            AUDOutputTerminalDescriptor_SPEAKER,
305
            AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
306
            AUDDLoopRecDriverDescriptors_FEATUREUNIT,
307
            0 // No string descriptor
308
        },
309
        // Feature unit descriptor ( speaker )
310
        {
311
            {
312
                sizeof(AUDFeatureUnitDescriptor3),
313
                AUDGenericDescriptor_INTERFACE,
314
                AUDGenericDescriptor_FEATUREUNIT,
315
                AUDDLoopRecDriverDescriptors_FEATUREUNIT,
316
                AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
317
                1, // 1 byte per channel for controls
318
            },
319
            {
320
                AUDFeatureUnitDescriptor_MUTE, // Master channel controls
321
                0, // Right channel controls
322
                0  // Left channel controls
323
            },
324
            0 // No string descriptor
325
        },
326
        // Input terminal descriptor ( speakerphone )
327
        {
328
            sizeof(AUDInputTerminalDescriptor),
329
            AUDGenericDescriptor_INTERFACE,
330
            AUDGenericDescriptor_INPUTTERMINAL,
331
            AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
332
            AUDInputTerminalDescriptor_SPEAKERPHONE,
333
            AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
334
            AUDDLoopRecDriver_NUMCHANNELS,
335
          #if AUDDLoopRecDriver_NUMCHANNELS > 1
336
            AUDInputTerminalDescriptor_LEFTFRONT
337
            | AUDInputTerminalDescriptor_RIGHTFRONT,
338
          #else
339
            0, // Mono sets no position bits.
340
          #endif
341
            0, // No string descriptor for channels
342
            0 // No string descriptor for input terminal
343
        },
344
        // Output terminal descriptor ( speakerphone )
345
        {
346
            sizeof(AUDOutputTerminalDescriptor),
347
            AUDGenericDescriptor_INTERFACE,
348
            AUDGenericDescriptor_OUTPUTTERMINAL,
349
            AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
350
            AUDOutputTerminalDescriptor_USBTREAMING,
351
            AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
352
            AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
353
            0 // No string descriptor
354
        },
355
        // Feature unit descriptor ( speakerphone )
356
        {
357
            {
358
                sizeof(AUDFeatureUnitDescriptor3),
359
                AUDGenericDescriptor_INTERFACE,
360
                AUDGenericDescriptor_FEATUREUNIT,
361
                AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
362
                AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
363
                1
364
            },
365
            {
366
                AUDFeatureUnitDescriptor_MUTE, // Mic controls
367
                0,
368
                0
369
            },
370
            0 // No string descriptor
371
        }
372
    },
373
    // - AUIDO OUT
374
    // Audio streaming interface with 0 endpoints
375
    {
376
        sizeof(USBInterfaceDescriptor),
377
        USBGenericDescriptor_INTERFACE,
378
        AUDDLoopRecDriverDescriptors_STREAMING,
379
        0, // This is alternate setting #0
380
        0, // This interface uses no endpoints
381
        AUDStreamingInterfaceDescriptor_CLASS,
382
        AUDStreamingInterfaceDescriptor_SUBCLASS,
383
        AUDStreamingInterfaceDescriptor_PROTOCOL,
384
        0 // No string descriptor
385
    },
386
    // Audio streaming interface with data endpoint
387
    {
388
        sizeof(USBInterfaceDescriptor),
389
        USBGenericDescriptor_INTERFACE,
390
        AUDDLoopRecDriverDescriptors_STREAMING,
391
        1, // This is alternate setting #1
392
        1, // This interface uses 1 endpoint
393
        AUDStreamingInterfaceDescriptor_CLASS,
394
        AUDStreamingInterfaceDescriptor_SUBCLASS,
395
        AUDStreamingInterfaceDescriptor_PROTOCOL,
396
        0 // No string descriptor
397
    },
398
    // Audio streaming class-specific descriptor
399
    {
400
        sizeof(AUDStreamingInterfaceDescriptor),
401
        AUDGenericDescriptor_INTERFACE,
402
        AUDStreamingInterfaceDescriptor_GENERAL,
403
        AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
404
        0, // No internal delay because of data path
405
        AUDFormatTypeOneDescriptor_PCM
406
    },
407
    // Format type I descriptor
408
    {
409
        {
410
            sizeof(AUDFormatTypeOneDescriptor1),
411
            AUDGenericDescriptor_INTERFACE,
412
            AUDStreamingInterfaceDescriptor_FORMATTYPE,
413
            AUDFormatTypeOneDescriptor_FORMATTYPEONE,
414
            AUDDLoopRecDriver_NUMCHANNELS,
415
            AUDDLoopRecDriver_BYTESPERSAMPLE,
416
            AUDDLoopRecDriver_BYTESPERSAMPLE*8,
417
            1 // One discrete frequency supported
418
        },
419
        {
420
            AUDDLoopRecDriver_SAMPLERATE & 0xFF,
421
            (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
422
            (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
423
        }
424
    },
425
    // Audio streaming endpoint standard descriptor
426
    {
427
        sizeof(AUDEndpointDescriptor),
428
        USBGenericDescriptor_ENDPOINT,
429
        USBEndpointDescriptor_ADDRESS(
430
            USBEndpointDescriptor_OUT,
431
            AUDDLoopRecDriverDescriptors_DATAOUT),
432
        USBEndpointDescriptor_ISOCHRONOUS,
433
        AUDDLoopRecDriver_BYTESPERFRAME,
434
        AUDDLoopRecDriverDescriptors_HS_INTERVAL, // Polling interval = 1 ms
435
        0, // This is not a synchronization endpoint
436
        0 // No associated synchronization endpoint
437
    },
438
    // Audio streaming endpoint class-specific descriptor
439
    {
440
        sizeof(AUDDataEndpointDescriptor),
441
        AUDGenericDescriptor_ENDPOINT,
442
        AUDDataEndpointDescriptor_SUBTYPE,
443
        0, // No attributes
444
        0, // Endpoint is not synchronized
445
        0 // Endpoint is not synchronized
446
    },
447
    //- AUDIO IN
448
    // Audio streaming interface with 0 endpoints
449
    {
450
        sizeof(USBInterfaceDescriptor),
451
        USBGenericDescriptor_INTERFACE,
452
        AUDDLoopRecDriverDescriptors_STREAMINGIN,
453
        0, // This is alternate setting #0
454
        0, // This interface uses no endpoints
455
        AUDStreamingInterfaceDescriptor_CLASS,
456
        AUDStreamingInterfaceDescriptor_SUBCLASS,
457
        AUDStreamingInterfaceDescriptor_PROTOCOL,
458
        0 // No string descriptor
459
    },
460
    // Audio streaming interface with data endpoint
461
    {
462
        sizeof(USBInterfaceDescriptor),
463
        USBGenericDescriptor_INTERFACE,
464
        AUDDLoopRecDriverDescriptors_STREAMINGIN,
465
        1, // This is alternate setting #1
466
        1, // This interface uses 1 endpoint
467
        AUDStreamingInterfaceDescriptor_CLASS,
468
        AUDStreamingInterfaceDescriptor_SUBCLASS,
469
        AUDStreamingInterfaceDescriptor_PROTOCOL,
470
        0 // No string descriptor
471
    },
472
    // Audio streaming class-specific descriptor
473
    {
474
        sizeof(AUDStreamingInterfaceDescriptor),
475
        AUDGenericDescriptor_INTERFACE,
476
        AUDStreamingInterfaceDescriptor_GENERAL,
477
        AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
478
        0, // No internal delay because of data path
479
        AUDFormatTypeOneDescriptor_PCM
480
    },
481
    // Format type I descriptor
482
    {
483
        {
484
            sizeof(AUDFormatTypeOneDescriptor1),
485
            AUDGenericDescriptor_INTERFACE,
486
            AUDStreamingInterfaceDescriptor_FORMATTYPE,
487
            AUDFormatTypeOneDescriptor_FORMATTYPEONE,
488
            AUDDLoopRecDriver_NUMCHANNELS,
489
            AUDDLoopRecDriver_BYTESPERSAMPLE,
490
            AUDDLoopRecDriver_BYTESPERSAMPLE*8,
491
            1 // One discrete frequency supported
492
        },
493
        {
494
            AUDDLoopRecDriver_SAMPLERATE & 0xFF,
495
            (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
496
            (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
497
        }
498
    },
499
    // Audio streaming endpoint standard descriptor
500
    {
501
        sizeof(AUDEndpointDescriptor),
502
        USBGenericDescriptor_ENDPOINT,
503
        USBEndpointDescriptor_ADDRESS(
504
            USBEndpointDescriptor_IN,
505
            AUDDLoopRecDriverDescriptors_DATAIN),
506
        USBEndpointDescriptor_ISOCHRONOUS,
507
        AUDDLoopRecDriver_BYTESPERFRAME,
508
        AUDDLoopRecDriverDescriptors_HS_INTERVAL, // Polling interval = 1 ms
509
        0, // This is not a synchronization endpoint
510
        0 // No associated synchronization endpoint
511
    },
512
    // Audio streaming endpoint class-specific descriptor
513
    {
514
        sizeof(AUDDataEndpointDescriptor),
515
        AUDGenericDescriptor_ENDPOINT,
516
        AUDDataEndpointDescriptor_SUBTYPE,
517
        0, // No attributes
518
        0, // Endpoint is not synchronized
519
        0 // Endpoint is not synchronized
520
    },
521
    DFURT_IF_DESCRIPTOR(3, 0),
522
};
523

    
524
/// HS Other Speed Configuration descriptors for a USB Audio Loop Record driver.
525
const AUDDLoopRecDriverConfigurationDescriptors
526
    fsOtherSpeedConfigurationDescriptors = {
527

    
528
    // Configuration descriptor
529
    {
530
        sizeof(USBConfigurationDescriptor),
531
        USBGenericDescriptor_OTHERSPEEDCONFIGURATION,
532
        sizeof(AUDDLoopRecDriverConfigurationDescriptors),
533
        3+DFURT_NUM_IF, // This configuration has 3 interfaces
534
        1, // This is configuration #1
535
        0, // No string descriptor
536
        BOARD_USB_BMATTRIBUTES,
537
        USBConfigurationDescriptor_POWER(100)
538
    },
539
    // Audio control interface standard descriptor
540
    {
541
        sizeof(USBInterfaceDescriptor),
542
        USBGenericDescriptor_INTERFACE,
543
        AUDDLoopRecDriverDescriptors_CONTROL,
544
        0, // This is alternate setting #0
545
        0, // This interface uses no endpoint
546
        AUDControlInterfaceDescriptor_CLASS,
547
        AUDControlInterfaceDescriptor_SUBCLASS,
548
        AUDControlInterfaceDescriptor_PROTOCOL,
549
        0 // No string descriptor
550
    },
551
    // Audio control interface descriptors
552
    {
553
        // Header descriptor
554
        {
555
            {
556
                sizeof(AUDHeaderDescriptor2),
557
                AUDGenericDescriptor_INTERFACE,
558
                AUDGenericDescriptor_HEADER,
559
                AUDHeaderDescriptor_AUD1_00,
560
                sizeof(AUDDLoopRecDriverAudioControlDescriptors),
561
                2 // Two streaming interface
562
            },
563
            AUDDLoopRecDriverDescriptors_STREAMING,
564
            AUDDLoopRecDriverDescriptors_STREAMINGIN
565
        },
566
        // Input terminal descriptor ( speaker )
567
        {
568
            sizeof(AUDInputTerminalDescriptor),
569
            AUDGenericDescriptor_INTERFACE,
570
            AUDGenericDescriptor_INPUTTERMINAL,
571
            AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
572
            AUDInputTerminalDescriptor_USBSTREAMING,
573
            AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
574
            AUDDLoopRecDriver_NUMCHANNELS,
575
          #if AUDDLoopRecDriver_NUMCHANNELS > 1
576
            AUDInputTerminalDescriptor_LEFTFRONT
577
            | AUDInputTerminalDescriptor_RIGHTFRONT,
578
          #else
579
            0, // Mono sets no position bits.
580
          #endif
581
            0, // No string descriptor for channels
582
            0 // No string descriptor for input terminal
583
        },
584
        // Output terminal descriptor ( speaker )
585
        {
586
            sizeof(AUDOutputTerminalDescriptor),
587
            AUDGenericDescriptor_INTERFACE,
588
            AUDGenericDescriptor_OUTPUTTERMINAL,
589
            AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
590
            AUDOutputTerminalDescriptor_SPEAKER,
591
            AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
592
            AUDDLoopRecDriverDescriptors_FEATUREUNIT,
593
            0 // No string descriptor
594
        },
595
        // Feature unit descriptor ( speaker )
596
        {
597
            {
598
                sizeof(AUDFeatureUnitDescriptor3),
599
                AUDGenericDescriptor_INTERFACE,
600
                AUDGenericDescriptor_FEATUREUNIT,
601
                AUDDLoopRecDriverDescriptors_FEATUREUNIT,
602
                AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
603
                1, // 1 byte per channel for controls
604
            },
605
            {
606
                AUDFeatureUnitDescriptor_MUTE, // Master channel controls
607
                0, // Right channel controls
608
                0  // Left channel controls
609
            },
610
            0 // No string descriptor
611
        },
612
        // Input terminal descriptor ( speakerphone )
613
        {
614
            sizeof(AUDInputTerminalDescriptor),
615
            AUDGenericDescriptor_INTERFACE,
616
            AUDGenericDescriptor_INPUTTERMINAL,
617
            AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
618
            AUDInputTerminalDescriptor_SPEAKERPHONE,
619
            AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
620
            AUDDLoopRecDriver_NUMCHANNELS,
621
          #if AUDDLoopRecDriver_NUMCHANNELS > 1
622
            AUDInputTerminalDescriptor_LEFTFRONT
623
            | AUDInputTerminalDescriptor_RIGHTFRONT,
624
          #else
625
            0, // Mono sets no position bits.
626
          #endif
627
            0, // No string descriptor for channels
628
            0 // No string descriptor for input terminal
629
        },
630
        // Output terminal descriptor ( speakerphone )
631
        {
632
            sizeof(AUDOutputTerminalDescriptor),
633
            AUDGenericDescriptor_INTERFACE,
634
            AUDGenericDescriptor_OUTPUTTERMINAL,
635
            AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
636
            AUDOutputTerminalDescriptor_USBTREAMING,
637
            AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
638
            AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
639
            0 // No string descriptor
640
        },
641
        // Feature unit descriptor ( speakerphone )
642
        {
643
            {
644
                sizeof(AUDFeatureUnitDescriptor3),
645
                AUDGenericDescriptor_INTERFACE,
646
                AUDGenericDescriptor_FEATUREUNIT,
647
                AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
648
                AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
649
                1
650
            },
651
            {
652
                AUDFeatureUnitDescriptor_MUTE, // Mic controls
653
                0,
654
                0
655
            },
656
            0 // No string descriptor
657
        }
658
    },
659
    // - AUIDO OUT
660
    // Audio streaming interface with 0 endpoints
661
    {
662
        sizeof(USBInterfaceDescriptor),
663
        USBGenericDescriptor_INTERFACE,
664
        AUDDLoopRecDriverDescriptors_STREAMING,
665
        0, // This is alternate setting #0
666
        0, // This interface uses no endpoints
667
        AUDStreamingInterfaceDescriptor_CLASS,
668
        AUDStreamingInterfaceDescriptor_SUBCLASS,
669
        AUDStreamingInterfaceDescriptor_PROTOCOL,
670
        0 // No string descriptor
671
    },
672
    // Audio streaming interface with data endpoint
673
    {
674
        sizeof(USBInterfaceDescriptor),
675
        USBGenericDescriptor_INTERFACE,
676
        AUDDLoopRecDriverDescriptors_STREAMING,
677
        1, // This is alternate setting #1
678
        1, // This interface uses 1 endpoint
679
        AUDStreamingInterfaceDescriptor_CLASS,
680
        AUDStreamingInterfaceDescriptor_SUBCLASS,
681
        AUDStreamingInterfaceDescriptor_PROTOCOL,
682
        0 // No string descriptor
683
    },
684
    // Audio streaming class-specific descriptor
685
    {
686
        sizeof(AUDStreamingInterfaceDescriptor),
687
        AUDGenericDescriptor_INTERFACE,
688
        AUDStreamingInterfaceDescriptor_GENERAL,
689
        AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
690
        0, // No internal delay because of data path
691
        AUDFormatTypeOneDescriptor_PCM
692
    },
693
    // Format type I descriptor
694
    {
695
        {
696
            sizeof(AUDFormatTypeOneDescriptor1),
697
            AUDGenericDescriptor_INTERFACE,
698
            AUDStreamingInterfaceDescriptor_FORMATTYPE,
699
            AUDFormatTypeOneDescriptor_FORMATTYPEONE,
700
            AUDDLoopRecDriver_NUMCHANNELS,
701
            AUDDLoopRecDriver_BYTESPERSAMPLE,
702
            AUDDLoopRecDriver_BYTESPERSAMPLE*8,
703
            1 // One discrete frequency supported
704
        },
705
        {
706
            AUDDLoopRecDriver_SAMPLERATE & 0xFF,
707
            (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
708
            (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
709
        }
710
    },
711
    // Audio streaming endpoint standard descriptor
712
    {
713
        sizeof(AUDEndpointDescriptor),
714
        USBGenericDescriptor_ENDPOINT,
715
        USBEndpointDescriptor_ADDRESS(
716
            USBEndpointDescriptor_OUT,
717
            AUDDLoopRecDriverDescriptors_DATAOUT),
718
        USBEndpointDescriptor_ISOCHRONOUS,
719
        AUDDLoopRecDriver_BYTESPERFRAME,
720
        AUDDLoopRecDriverDescriptors_HS_INTERVAL, // Polling interval = 1 ms
721
        0, // This is not a synchronization endpoint
722
        0 // No associated synchronization endpoint
723
    },
724
    // Audio streaming endpoint class-specific descriptor
725
    {
726
        sizeof(AUDDataEndpointDescriptor),
727
        AUDGenericDescriptor_ENDPOINT,
728
        AUDDataEndpointDescriptor_SUBTYPE,
729
        0, // No attributes
730
        0, // Endpoint is not synchronized
731
        0 // Endpoint is not synchronized
732
    },
733
    //- AUDIO IN
734
    // Audio streaming interface with 0 endpoints
735
    {
736
        sizeof(USBInterfaceDescriptor),
737
        USBGenericDescriptor_INTERFACE,
738
        AUDDLoopRecDriverDescriptors_STREAMINGIN,
739
        0, // This is alternate setting #0
740
        0, // This interface uses no endpoints
741
        AUDStreamingInterfaceDescriptor_CLASS,
742
        AUDStreamingInterfaceDescriptor_SUBCLASS,
743
        AUDStreamingInterfaceDescriptor_PROTOCOL,
744
        0 // No string descriptor
745
    },
746
    // Audio streaming interface with data endpoint
747
    {
748
        sizeof(USBInterfaceDescriptor),
749
        USBGenericDescriptor_INTERFACE,
750
        AUDDLoopRecDriverDescriptors_STREAMINGIN,
751
        1, // This is alternate setting #1
752
        1, // This interface uses 1 endpoint
753
        AUDStreamingInterfaceDescriptor_CLASS,
754
        AUDStreamingInterfaceDescriptor_SUBCLASS,
755
        AUDStreamingInterfaceDescriptor_PROTOCOL,
756
        0 // No string descriptor
757
    },
758
    // Audio streaming class-specific descriptor
759
    {
760
        sizeof(AUDStreamingInterfaceDescriptor),
761
        AUDGenericDescriptor_INTERFACE,
762
        AUDStreamingInterfaceDescriptor_GENERAL,
763
        AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
764
        0, // No internal delay because of data path
765
        AUDFormatTypeOneDescriptor_PCM
766
    },
767
    // Format type I descriptor
768
    {
769
        {
770
            sizeof(AUDFormatTypeOneDescriptor1),
771
            AUDGenericDescriptor_INTERFACE,
772
            AUDStreamingInterfaceDescriptor_FORMATTYPE,
773
            AUDFormatTypeOneDescriptor_FORMATTYPEONE,
774
            AUDDLoopRecDriver_NUMCHANNELS,
775
            AUDDLoopRecDriver_BYTESPERSAMPLE,
776
            AUDDLoopRecDriver_BYTESPERSAMPLE*8,
777
            1 // One discrete frequency supported
778
        },
779
        {
780
            AUDDLoopRecDriver_SAMPLERATE & 0xFF,
781
            (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
782
            (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
783
        }
784
    },
785
    // Audio streaming endpoint standard descriptor
786
    {
787
        sizeof(AUDEndpointDescriptor),
788
        USBGenericDescriptor_ENDPOINT,
789
        USBEndpointDescriptor_ADDRESS(
790
            USBEndpointDescriptor_IN,
791
            AUDDLoopRecDriverDescriptors_DATAIN),
792
        USBEndpointDescriptor_ISOCHRONOUS,
793
        AUDDLoopRecDriver_BYTESPERFRAME,
794
        AUDDLoopRecDriverDescriptors_HS_INTERVAL, // Polling interval = 1 ms
795
        0, // This is not a synchronization endpoint
796
        0 // No associated synchronization endpoint
797
    },
798
    // Audio streaming endpoint class-specific descriptor
799
    {
800
        sizeof(AUDDataEndpointDescriptor),
801
        AUDGenericDescriptor_ENDPOINT,
802
        AUDDataEndpointDescriptor_SUBTYPE,
803
        0, // No attributes
804
        0, // Endpoint is not synchronized
805
        0 // Endpoint is not synchronized
806
    },
807
    DFURT_IF_DESCRIPTOR(3, 0),
808
};
809

    
810
/// HS Other Speed Configuration descriptors.
811
const AUDDLoopRecDriverConfigurationDescriptors
812
    hsOtherSpeedConfigurationDescriptors = {
813

    
814
    // Configuration descriptor
815
    {
816
        sizeof(USBConfigurationDescriptor),
817
        USBGenericDescriptor_OTHERSPEEDCONFIGURATION,
818
        sizeof(AUDDLoopRecDriverConfigurationDescriptors),
819
        3+DFURT_NUM_IF, // This configuration has 3 interfaces
820
        1, // This is configuration #1
821
        0, // No string descriptor
822
        BOARD_USB_BMATTRIBUTES,
823
        USBConfigurationDescriptor_POWER(100)
824
    },
825
    // Audio control interface standard descriptor
826
    {
827
        sizeof(USBInterfaceDescriptor),
828
        USBGenericDescriptor_INTERFACE,
829
        AUDDLoopRecDriverDescriptors_CONTROL,
830
        0, // This is alternate setting #0
831
        0, // This interface uses no endpoint
832
        AUDControlInterfaceDescriptor_CLASS,
833
        AUDControlInterfaceDescriptor_SUBCLASS,
834
        AUDControlInterfaceDescriptor_PROTOCOL,
835
        0 // No string descriptor
836
    },
837
    // Audio control interface descriptors
838
    {
839
        // Header descriptor
840
        {
841
            {
842
                sizeof(AUDHeaderDescriptor2),
843
                AUDGenericDescriptor_INTERFACE,
844
                AUDGenericDescriptor_HEADER,
845
                AUDHeaderDescriptor_AUD1_00,
846
                sizeof(AUDDLoopRecDriverAudioControlDescriptors),
847
                2 // Two streaming interface
848
            },
849
            AUDDLoopRecDriverDescriptors_STREAMING,
850
            AUDDLoopRecDriverDescriptors_STREAMINGIN
851
        },
852
        // Input terminal descriptor ( speaker )
853
        {
854
            sizeof(AUDInputTerminalDescriptor),
855
            AUDGenericDescriptor_INTERFACE,
856
            AUDGenericDescriptor_INPUTTERMINAL,
857
            AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
858
            AUDInputTerminalDescriptor_USBSTREAMING,
859
            AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
860
            AUDDLoopRecDriver_NUMCHANNELS,
861
          #if AUDDLoopRecDriver_NUMCHANNELS > 1
862
            AUDInputTerminalDescriptor_LEFTFRONT
863
            | AUDInputTerminalDescriptor_RIGHTFRONT,
864
          #else
865
            0, // Mono sets no position bits.
866
          #endif
867
            0, // No string descriptor for channels
868
            0 // No string descriptor for input terminal
869
        },
870
        // Output terminal descriptor ( speaker )
871
        {
872
            sizeof(AUDOutputTerminalDescriptor),
873
            AUDGenericDescriptor_INTERFACE,
874
            AUDGenericDescriptor_OUTPUTTERMINAL,
875
            AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
876
            AUDOutputTerminalDescriptor_SPEAKER,
877
            AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
878
            AUDDLoopRecDriverDescriptors_FEATUREUNIT,
879
            0 // No string descriptor
880
        },
881
        // Feature unit descriptor ( speaker )
882
        {
883
            {
884
                sizeof(AUDFeatureUnitDescriptor3),
885
                AUDGenericDescriptor_INTERFACE,
886
                AUDGenericDescriptor_FEATUREUNIT,
887
                AUDDLoopRecDriverDescriptors_FEATUREUNIT,
888
                AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
889
                1, // 1 byte per channel for controls
890
            },
891
            {
892
                AUDFeatureUnitDescriptor_MUTE, // Master channel controls
893
                0, // Right channel controls
894
                0  // Left channel controls
895
            },
896
            0 // No string descriptor
897
        },
898
        // Input terminal descriptor ( speakerphone )
899
        {
900
            sizeof(AUDInputTerminalDescriptor),
901
            AUDGenericDescriptor_INTERFACE,
902
            AUDGenericDescriptor_INPUTTERMINAL,
903
            AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
904
            AUDInputTerminalDescriptor_SPEAKERPHONE,
905
            AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
906
            AUDDLoopRecDriver_NUMCHANNELS,
907
          #if AUDDLoopRecDriver_NUMCHANNELS > 1
908
            AUDInputTerminalDescriptor_LEFTFRONT
909
            | AUDInputTerminalDescriptor_RIGHTFRONT,
910
          #else
911
            0, // Mono sets no position bits.
912
          #endif
913
            0, // No string descriptor for channels
914
            0 // No string descriptor for input terminal
915
        },
916
        // Output terminal descriptor ( speakerphone )
917
        {
918
            sizeof(AUDOutputTerminalDescriptor),
919
            AUDGenericDescriptor_INTERFACE,
920
            AUDGenericDescriptor_OUTPUTTERMINAL,
921
            AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
922
            AUDOutputTerminalDescriptor_USBTREAMING,
923
            AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
924
            AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
925
            0 // No string descriptor
926
        },
927
        // Feature unit descriptor ( speakerphone )
928
        {
929
            {
930
                sizeof(AUDFeatureUnitDescriptor3),
931
                AUDGenericDescriptor_INTERFACE,
932
                AUDGenericDescriptor_FEATUREUNIT,
933
                AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
934
                AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
935
                1
936
            },
937
            {
938
                AUDFeatureUnitDescriptor_MUTE, // Mic controls
939
                0,
940
                0
941
            },
942
            0 // No string descriptor
943
        }
944
    },
945
    // - AUIDO OUT
946
    // Audio streaming interface with 0 endpoints
947
    {
948
        sizeof(USBInterfaceDescriptor),
949
        USBGenericDescriptor_INTERFACE,
950
        AUDDLoopRecDriverDescriptors_STREAMING,
951
        0, // This is alternate setting #0
952
        0, // This interface uses no endpoints
953
        AUDStreamingInterfaceDescriptor_CLASS,
954
        AUDStreamingInterfaceDescriptor_SUBCLASS,
955
        AUDStreamingInterfaceDescriptor_PROTOCOL,
956
        0 // No string descriptor
957
    },
958
    // Audio streaming interface with data endpoint
959
    {
960
        sizeof(USBInterfaceDescriptor),
961
        USBGenericDescriptor_INTERFACE,
962
        AUDDLoopRecDriverDescriptors_STREAMING,
963
        1, // This is alternate setting #1
964
        1, // This interface uses 1 endpoint
965
        AUDStreamingInterfaceDescriptor_CLASS,
966
        AUDStreamingInterfaceDescriptor_SUBCLASS,
967
        AUDStreamingInterfaceDescriptor_PROTOCOL,
968
        0 // No string descriptor
969
    },
970
    // Audio streaming class-specific descriptor
971
    {
972
        sizeof(AUDStreamingInterfaceDescriptor),
973
        AUDGenericDescriptor_INTERFACE,
974
        AUDStreamingInterfaceDescriptor_GENERAL,
975
        AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
976
        0, // No internal delay because of data path
977
        AUDFormatTypeOneDescriptor_PCM
978
    },
979
    // Format type I descriptor
980
    {
981
        {
982
            sizeof(AUDFormatTypeOneDescriptor1),
983
            AUDGenericDescriptor_INTERFACE,
984
            AUDStreamingInterfaceDescriptor_FORMATTYPE,
985
            AUDFormatTypeOneDescriptor_FORMATTYPEONE,
986
            AUDDLoopRecDriver_NUMCHANNELS,
987
            AUDDLoopRecDriver_BYTESPERSAMPLE,
988
            AUDDLoopRecDriver_BYTESPERSAMPLE*8,
989
            1 // One discrete frequency supported
990
        },
991
        {
992
            AUDDLoopRecDriver_SAMPLERATE & 0xFF,
993
            (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
994
            (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
995
        }
996
    },
997
    // Audio streaming endpoint standard descriptor
998
    {
999
        sizeof(AUDEndpointDescriptor),
1000
        USBGenericDescriptor_ENDPOINT,
1001
        USBEndpointDescriptor_ADDRESS(
1002
            USBEndpointDescriptor_OUT,
1003
            AUDDLoopRecDriverDescriptors_DATAOUT),
1004
        USBEndpointDescriptor_ISOCHRONOUS,
1005
        AUDDLoopRecDriver_BYTESPERFRAME,
1006
        AUDDLoopRecDriverDescriptors_FS_INTERVAL, // Polling interval = 1 ms
1007
        0, // This is not a synchronization endpoint
1008
        0 // No associated synchronization endpoint
1009
    },
1010
    // Audio streaming endpoint class-specific descriptor
1011
    {
1012
        sizeof(AUDDataEndpointDescriptor),
1013
        AUDGenericDescriptor_ENDPOINT,
1014
        AUDDataEndpointDescriptor_SUBTYPE,
1015
        0, // No attributes
1016
        0, // Endpoint is not synchronized
1017
        0 // Endpoint is not synchronized
1018
    },
1019
    //- AUDIO IN
1020
    // Audio streaming interface with 0 endpoints
1021
    {
1022
        sizeof(USBInterfaceDescriptor),
1023
        USBGenericDescriptor_INTERFACE,
1024
        AUDDLoopRecDriverDescriptors_STREAMINGIN,
1025
        0, // This is alternate setting #0
1026
        0, // This interface uses no endpoints
1027
        AUDStreamingInterfaceDescriptor_CLASS,
1028
        AUDStreamingInterfaceDescriptor_SUBCLASS,
1029
        AUDStreamingInterfaceDescriptor_PROTOCOL,
1030
        0 // No string descriptor
1031
    },
1032
    // Audio streaming interface with data endpoint
1033
    {
1034
        sizeof(USBInterfaceDescriptor),
1035
        USBGenericDescriptor_INTERFACE,
1036
        AUDDLoopRecDriverDescriptors_STREAMINGIN,
1037
        1, // This is alternate setting #1
1038
        1, // This interface uses 1 endpoint
1039
        AUDStreamingInterfaceDescriptor_CLASS,
1040
        AUDStreamingInterfaceDescriptor_SUBCLASS,
1041
        AUDStreamingInterfaceDescriptor_PROTOCOL,
1042
        0 // No string descriptor
1043
    },
1044
    // Audio streaming class-specific descriptor
1045
    {
1046
        sizeof(AUDStreamingInterfaceDescriptor),
1047
        AUDGenericDescriptor_INTERFACE,
1048
        AUDStreamingInterfaceDescriptor_GENERAL,
1049
        AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
1050
        0, // No internal delay because of data path
1051
        AUDFormatTypeOneDescriptor_PCM
1052
    },
1053
    // Format type I descriptor
1054
    {
1055
        {
1056
            sizeof(AUDFormatTypeOneDescriptor1),
1057
            AUDGenericDescriptor_INTERFACE,
1058
            AUDStreamingInterfaceDescriptor_FORMATTYPE,
1059
            AUDFormatTypeOneDescriptor_FORMATTYPEONE,
1060
            AUDDLoopRecDriver_NUMCHANNELS,
1061
            AUDDLoopRecDriver_BYTESPERSAMPLE,
1062
            AUDDLoopRecDriver_BYTESPERSAMPLE*8,
1063
            1 // One discrete frequency supported
1064
        },
1065
        {
1066
            AUDDLoopRecDriver_SAMPLERATE & 0xFF,
1067
            (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
1068
            (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
1069
        }
1070
    },
1071
    // Audio streaming endpoint standard descriptor
1072
    {
1073
        sizeof(AUDEndpointDescriptor),
1074
        USBGenericDescriptor_ENDPOINT,
1075
        USBEndpointDescriptor_ADDRESS(
1076
            USBEndpointDescriptor_IN,
1077
            AUDDLoopRecDriverDescriptors_DATAIN),
1078
        USBEndpointDescriptor_ISOCHRONOUS,
1079
        AUDDLoopRecDriver_BYTESPERFRAME,
1080
        AUDDLoopRecDriverDescriptors_FS_INTERVAL, // Polling interval = 1 ms
1081
        0, // This is not a synchronization endpoint
1082
        0 // No associated synchronization endpoint
1083
    },
1084
    // Audio streaming endpoint class-specific descriptor
1085
    {
1086
        sizeof(AUDDataEndpointDescriptor),
1087
        AUDGenericDescriptor_ENDPOINT,
1088
        AUDDataEndpointDescriptor_SUBTYPE,
1089
        0, // No attributes
1090
        0, // Endpoint is not synchronized
1091
        0 // Endpoint is not synchronized
1092
    },
1093
    DFURT_IF_DESCRIPTOR(3, 0),
1094
};
1095

    
1096
#endif // defined(CHIP_USB_UDPHS)  || defined(CHIP_USB_OTGHS)
1097

    
1098
/// FS Configuration descriptors for a USB Audio Loop Record driver.
1099
const AUDDLoopRecDriverConfigurationDescriptors fsConfigurationDescriptors = {
1100

    
1101
    // Configuration descriptor
1102
    {
1103
        sizeof(USBConfigurationDescriptor),
1104
        USBGenericDescriptor_CONFIGURATION,
1105
        sizeof(AUDDLoopRecDriverConfigurationDescriptors),
1106
        3+DFURT_NUM_IF, // This configuration has 3 interfaces
1107
        1, // This is configuration #1
1108
        0, // No string descriptor
1109
        BOARD_USB_BMATTRIBUTES,
1110
        USBConfigurationDescriptor_POWER(100)
1111
    },
1112
    // Audio control interface standard descriptor
1113
    {
1114
        sizeof(USBInterfaceDescriptor),
1115
        USBGenericDescriptor_INTERFACE,
1116
        AUDDLoopRecDriverDescriptors_CONTROL,
1117
        0, // This is alternate setting #0
1118
        0, // This interface uses no endpoint
1119
        AUDControlInterfaceDescriptor_CLASS,
1120
        AUDControlInterfaceDescriptor_SUBCLASS,
1121
        AUDControlInterfaceDescriptor_PROTOCOL,
1122
        0 // No string descriptor
1123
    },
1124
    // Audio control interface descriptors
1125
    {
1126
        // Header descriptor
1127
        {
1128
            {
1129
                sizeof(AUDHeaderDescriptor2),
1130
                AUDGenericDescriptor_INTERFACE,
1131
                AUDGenericDescriptor_HEADER,
1132
                AUDHeaderDescriptor_AUD1_00,
1133
                sizeof(AUDDLoopRecDriverAudioControlDescriptors),
1134
                2 // Two streaming interface
1135
            },
1136
            AUDDLoopRecDriverDescriptors_STREAMING,
1137
            AUDDLoopRecDriverDescriptors_STREAMINGIN
1138
        },
1139
        // Input terminal descriptor ( speaker )
1140
        {
1141
            sizeof(AUDInputTerminalDescriptor),
1142
            AUDGenericDescriptor_INTERFACE,
1143
            AUDGenericDescriptor_INPUTTERMINAL,
1144
            AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
1145
            AUDInputTerminalDescriptor_USBSTREAMING,
1146
            AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
1147
            AUDDLoopRecDriver_NUMCHANNELS,
1148
          #if AUDDLoopRecDriver_NUMCHANNELS > 1
1149
            AUDInputTerminalDescriptor_LEFTFRONT
1150
            | AUDInputTerminalDescriptor_RIGHTFRONT,
1151
          #else
1152
            0, // Mono sets no position bits.
1153
          #endif
1154
            0, // No string descriptor for channels
1155
            0 // No string descriptor for input terminal
1156
        },
1157
        // Output terminal descriptor ( speaker )
1158
        {
1159
            sizeof(AUDOutputTerminalDescriptor),
1160
            AUDGenericDescriptor_INTERFACE,
1161
            AUDGenericDescriptor_OUTPUTTERMINAL,
1162
            AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL,
1163
            AUDOutputTerminalDescriptor_SPEAKER,
1164
            AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
1165
            AUDDLoopRecDriverDescriptors_FEATUREUNIT,
1166
            0 // No string descriptor
1167
        },
1168
        // Feature unit descriptor ( speaker )
1169
        {
1170
            {
1171
                sizeof(AUDFeatureUnitDescriptor3),
1172
                AUDGenericDescriptor_INTERFACE,
1173
                AUDGenericDescriptor_FEATUREUNIT,
1174
                AUDDLoopRecDriverDescriptors_FEATUREUNIT,
1175
                AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
1176
                1, // 1 byte per channel for controls
1177
            },
1178
            {
1179
                AUDFeatureUnitDescriptor_MUTE, // Master channel controls
1180
                0, // Right channel controls
1181
                0  // Left channel controls
1182
            },
1183
            0 // No string descriptor
1184
        },
1185
        // Input terminal descriptor ( speakerphone )
1186
        {
1187
            sizeof(AUDInputTerminalDescriptor),
1188
            AUDGenericDescriptor_INTERFACE,
1189
            AUDGenericDescriptor_INPUTTERMINAL,
1190
            AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
1191
            AUDInputTerminalDescriptor_SPEAKERPHONE,
1192
            AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
1193
            AUDDLoopRecDriver_NUMCHANNELS,
1194
          #if AUDDLoopRecDriver_NUMCHANNELS > 1
1195
            AUDInputTerminalDescriptor_LEFTFRONT
1196
            | AUDInputTerminalDescriptor_RIGHTFRONT,
1197
          #else
1198
            0, // Mono sets no position bits.
1199
          #endif
1200
            0, // No string descriptor for channels
1201
            0 // No string descriptor for input terminal
1202
        },
1203
        // Output terminal descriptor ( speakerphone )
1204
        {
1205
            sizeof(AUDOutputTerminalDescriptor),
1206
            AUDGenericDescriptor_INTERFACE,
1207
            AUDGenericDescriptor_OUTPUTTERMINAL,
1208
            AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
1209
            AUDOutputTerminalDescriptor_USBTREAMING,
1210
            AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
1211
            AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
1212
            0 // No string descriptor
1213
        },
1214
        // Feature unit descriptor ( speakerphone )
1215
        {
1216
            {
1217
                sizeof(AUDFeatureUnitDescriptor3),
1218
                AUDGenericDescriptor_INTERFACE,
1219
                AUDGenericDescriptor_FEATUREUNIT,
1220
                AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC,
1221
                AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC,
1222
                1
1223
            },
1224
            {
1225
                AUDFeatureUnitDescriptor_MUTE, // Mic controls
1226
                0,
1227
                0
1228
            },
1229
            0 // No string descriptor
1230
        }
1231
    },
1232
    // - AUIDO OUT
1233
    // Audio streaming interface with 0 endpoints
1234
    {
1235
        sizeof(USBInterfaceDescriptor),
1236
        USBGenericDescriptor_INTERFACE,
1237
        AUDDLoopRecDriverDescriptors_STREAMING,
1238
        0, // This is alternate setting #0
1239
        0, // This interface uses no endpoints
1240
        AUDStreamingInterfaceDescriptor_CLASS,
1241
        AUDStreamingInterfaceDescriptor_SUBCLASS,
1242
        AUDStreamingInterfaceDescriptor_PROTOCOL,
1243
        0 // No string descriptor
1244
    },
1245
    // Audio streaming interface with data endpoint
1246
    {
1247
        sizeof(USBInterfaceDescriptor),
1248
        USBGenericDescriptor_INTERFACE,
1249
        AUDDLoopRecDriverDescriptors_STREAMING,
1250
        1, // This is alternate setting #1
1251
        1, // This interface uses 1 endpoint
1252
        AUDStreamingInterfaceDescriptor_CLASS,
1253
        AUDStreamingInterfaceDescriptor_SUBCLASS,
1254
        AUDStreamingInterfaceDescriptor_PROTOCOL,
1255
        0 // No string descriptor
1256
    },
1257
    // Audio streaming class-specific descriptor
1258
    {
1259
        sizeof(AUDStreamingInterfaceDescriptor),
1260
        AUDGenericDescriptor_INTERFACE,
1261
        AUDStreamingInterfaceDescriptor_GENERAL,
1262
        AUDDLoopRecDriverDescriptors_INPUTTERMINAL,
1263
        0, // No internal delay because of data path
1264
        AUDFormatTypeOneDescriptor_PCM
1265
    },
1266
    // Format type I descriptor
1267
    {
1268
        {
1269
            sizeof(AUDFormatTypeOneDescriptor1),
1270
            AUDGenericDescriptor_INTERFACE,
1271
            AUDStreamingInterfaceDescriptor_FORMATTYPE,
1272
            AUDFormatTypeOneDescriptor_FORMATTYPEONE,
1273
            AUDDLoopRecDriver_NUMCHANNELS,
1274
            AUDDLoopRecDriver_BYTESPERSAMPLE,
1275
            AUDDLoopRecDriver_BYTESPERSAMPLE*8,
1276
            1 // One discrete frequency supported
1277
        },
1278
        {
1279
            AUDDLoopRecDriver_SAMPLERATE & 0xFF,
1280
            (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
1281
            (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
1282
        }
1283
    },
1284
    // Audio streaming endpoint standard descriptor
1285
    {
1286
        sizeof(AUDEndpointDescriptor),
1287
        USBGenericDescriptor_ENDPOINT,
1288
        USBEndpointDescriptor_ADDRESS(
1289
            USBEndpointDescriptor_OUT,
1290
            AUDDLoopRecDriverDescriptors_DATAOUT),
1291
        USBEndpointDescriptor_ISOCHRONOUS,
1292
        AUDDLoopRecDriver_BYTESPERFRAME,
1293
        AUDDLoopRecDriverDescriptors_FS_INTERVAL, // Polling interval = 1 ms
1294
        0, // This is not a synchronization endpoint
1295
        0 // No associated synchronization endpoint
1296
    },
1297
    // Audio streaming endpoint class-specific descriptor
1298
    {
1299
        sizeof(AUDDataEndpointDescriptor),
1300
        AUDGenericDescriptor_ENDPOINT,
1301
        AUDDataEndpointDescriptor_SUBTYPE,
1302
        0, // No attributes
1303
        0, // Endpoint is not synchronized
1304
        0 // Endpoint is not synchronized
1305
    },
1306
    //- AUDIO IN
1307
    // Audio streaming interface with 0 endpoints
1308
    {
1309
        sizeof(USBInterfaceDescriptor),
1310
        USBGenericDescriptor_INTERFACE,
1311
        AUDDLoopRecDriverDescriptors_STREAMINGIN,
1312
        0, // This is alternate setting #0
1313
        0, // This interface uses no endpoints
1314
        AUDStreamingInterfaceDescriptor_CLASS,
1315
        AUDStreamingInterfaceDescriptor_SUBCLASS,
1316
        AUDStreamingInterfaceDescriptor_PROTOCOL,
1317
        0 // No string descriptor
1318
    },
1319
    // Audio streaming interface with data endpoint
1320
    {
1321
        sizeof(USBInterfaceDescriptor),
1322
        USBGenericDescriptor_INTERFACE,
1323
        AUDDLoopRecDriverDescriptors_STREAMINGIN,
1324
        1, // This is alternate setting #1
1325
        1, // This interface uses 1 endpoint
1326
        AUDStreamingInterfaceDescriptor_CLASS,
1327
        AUDStreamingInterfaceDescriptor_SUBCLASS,
1328
        AUDStreamingInterfaceDescriptor_PROTOCOL,
1329
        0 // No string descriptor
1330
    },
1331
    // Audio streaming class-specific descriptor
1332
    {
1333
        sizeof(AUDStreamingInterfaceDescriptor),
1334
        AUDGenericDescriptor_INTERFACE,
1335
        AUDStreamingInterfaceDescriptor_GENERAL,
1336
        AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC,
1337
        0, // No internal delay because of data path
1338
        AUDFormatTypeOneDescriptor_PCM
1339
    },
1340
    // Format type I descriptor
1341
    {
1342
        {
1343
            sizeof(AUDFormatTypeOneDescriptor1),
1344
            AUDGenericDescriptor_INTERFACE,
1345
            AUDStreamingInterfaceDescriptor_FORMATTYPE,
1346
            AUDFormatTypeOneDescriptor_FORMATTYPEONE,
1347
            AUDDLoopRecDriver_NUMCHANNELS,
1348
            AUDDLoopRecDriver_BYTESPERSAMPLE,
1349
            AUDDLoopRecDriver_BYTESPERSAMPLE*8,
1350
            1 // One discrete frequency supported
1351
        },
1352
        {
1353
            AUDDLoopRecDriver_SAMPLERATE & 0xFF,
1354
            (AUDDLoopRecDriver_SAMPLERATE >> 8) & 0xFF,
1355
            (AUDDLoopRecDriver_SAMPLERATE >> 16) & 0xFF
1356
        }
1357
    },
1358
    // Audio streaming endpoint standard descriptor
1359
    {
1360
        sizeof(AUDEndpointDescriptor),
1361
        USBGenericDescriptor_ENDPOINT,
1362
        USBEndpointDescriptor_ADDRESS(
1363
            USBEndpointDescriptor_IN,
1364
            AUDDLoopRecDriverDescriptors_DATAIN),
1365
        USBEndpointDescriptor_ISOCHRONOUS,
1366
        AUDDLoopRecDriver_BYTESPERFRAME,
1367
        AUDDLoopRecDriverDescriptors_FS_INTERVAL, // Polling interval = 1 ms
1368
        0, // This is not a synchronization endpoint
1369
        0 // No associated synchronization endpoint
1370
    },
1371
    // Audio streaming endpoint class-specific descriptor
1372
    {
1373
        sizeof(AUDDataEndpointDescriptor),
1374
        AUDGenericDescriptor_ENDPOINT,
1375
        AUDDataEndpointDescriptor_SUBTYPE,
1376
        0, // No attributes
1377
        0, // Endpoint is not synchronized
1378
        0 // Endpoint is not synchronized
1379
    },
1380
    DFURT_IF_DESCRIPTOR(3, 0),
1381
};
1382

    
1383
/// String descriptor with the supported languages.
1384
const unsigned char languageIdDescriptor[] = {
1385

    
1386
    USBStringDescriptor_LENGTH(1),
1387
    USBGenericDescriptor_STRING,
1388
    USBStringDescriptor_ENGLISH_US
1389
};
1390

    
1391
/// Manufacturer name.
1392
const unsigned char manufacturerDescriptor[] = {
1393

    
1394
    USBStringDescriptor_LENGTH(8),
1395
    USBGenericDescriptor_STRING,
1396
    USBStringDescriptor_UNICODE('s'),
1397
    USBStringDescriptor_UNICODE('y'),
1398
    USBStringDescriptor_UNICODE('s'),
1399
    USBStringDescriptor_UNICODE('m'),
1400
    USBStringDescriptor_UNICODE('o'),
1401
    USBStringDescriptor_UNICODE('c'),
1402
    USBStringDescriptor_UNICODE('o'),
1403
    USBStringDescriptor_UNICODE('m'),
1404
};
1405

    
1406
/// Product name.
1407
const unsigned char productDescriptor[] = {
1408

    
1409
    USBStringDescriptor_LENGTH(7),
1410
    USBGenericDescriptor_STRING,
1411
    USBStringDescriptor_UNICODE('O'),
1412
    USBStringDescriptor_UNICODE('s'),
1413
    USBStringDescriptor_UNICODE('m'),
1414
    USBStringDescriptor_UNICODE('o'),
1415
    USBStringDescriptor_UNICODE('S'),
1416
    USBStringDescriptor_UNICODE('D'),
1417
    USBStringDescriptor_UNICODE('R'),
1418
};
1419

    
1420
/// Product serial number.
1421
const unsigned char serialNumberDescriptor[] = {
1422

    
1423
    USBStringDescriptor_LENGTH(4),
1424
    USBGenericDescriptor_STRING,
1425
    USBStringDescriptor_UNICODE('0'),
1426
    USBStringDescriptor_UNICODE('1'),
1427
    USBStringDescriptor_UNICODE('2'),
1428
    USBStringDescriptor_UNICODE('3')
1429
};
1430

    
1431
/// Array of pointers to the four string descriptors.
1432
const unsigned char *stringDescriptors[] = {
1433

    
1434
    languageIdDescriptor,
1435
    manufacturerDescriptor,
1436
    productDescriptor,
1437
    serialNumberDescriptor,
1438
};
1439

    
1440
//------------------------------------------------------------------------------
1441
//         Exported functions
1442
//------------------------------------------------------------------------------
1443

    
1444
/// List of descriptors required by an USB Audio Loop Recorder device driver.
1445
const USBDDriverDescriptors auddFastSourceDriverDescriptors = {
1446

    
1447
    &deviceDescriptor,
1448
    (const USBConfigurationDescriptor *) &fsConfigurationDescriptors,
1449
#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS)
1450
    &qualifierDescriptor,
1451
    (const USBConfigurationDescriptor *) &fsOtherSpeedConfigurationDescriptors,
1452
    &deviceDescriptor,
1453
    (const USBConfigurationDescriptor *) &hsConfigurationDescriptors,
1454
    &qualifierDescriptor,
1455
    (const USBConfigurationDescriptor *) &hsOtherSpeedConfigurationDescriptors,
1456
#else
1457
    0, 0, 0, 0, 0, 0,
1458
#endif
1459
    stringDescriptors,
1460
    4 // Number of string descriptors
1461
};
1462

    
(1-1/7)
Add picture from clipboard (Maximum size: 48.8 MB)