From 044ad7c3987460ede48ff27afd6bdb0ca05a0432 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Mon, 4 Jul 2011 20:52:54 +0200 Subject: import at91lib from at91lib_20100901_softpack_1_9_v_1_0_svn_v15011 it's sad to see that atmel doesn't publish their svn repo or has a centralized location or even puts proper version/release info into the library itself --- usb/common/audio/AUDControlInterfaceDescriptor.h | 72 +++++++++++ usb/common/audio/AUDDataEndpointDescriptor.h | 104 +++++++++++++++ usb/common/audio/AUDDeviceDescriptor.h | 72 +++++++++++ usb/common/audio/AUDEndpointDescriptor.h | 86 +++++++++++++ usb/common/audio/AUDFeatureUnitDescriptor.h | 116 +++++++++++++++++ usb/common/audio/AUDFeatureUnitRequest.c | 60 +++++++++ usb/common/audio/AUDFeatureUnitRequest.h | 81 ++++++++++++ usb/common/audio/AUDFormatTypeOneDescriptor.h | 101 +++++++++++++++ usb/common/audio/AUDGenericDescriptor.h | 121 ++++++++++++++++++ usb/common/audio/AUDGenericRequest.c | 57 +++++++++ usb/common/audio/AUDGenericRequest.h | 94 ++++++++++++++ usb/common/audio/AUDHeaderDescriptor.h | 100 +++++++++++++++ usb/common/audio/AUDInputTerminalDescriptor.h | 139 +++++++++++++++++++++ usb/common/audio/AUDOutputTerminalDescriptor.h | 112 +++++++++++++++++ usb/common/audio/AUDStreamingInterfaceDescriptor.h | 129 +++++++++++++++++++ usb/common/audio/audio.dir | 40 ++++++ 16 files changed, 1484 insertions(+) create mode 100644 usb/common/audio/AUDControlInterfaceDescriptor.h create mode 100644 usb/common/audio/AUDDataEndpointDescriptor.h create mode 100644 usb/common/audio/AUDDeviceDescriptor.h create mode 100644 usb/common/audio/AUDEndpointDescriptor.h create mode 100644 usb/common/audio/AUDFeatureUnitDescriptor.h create mode 100644 usb/common/audio/AUDFeatureUnitRequest.c create mode 100644 usb/common/audio/AUDFeatureUnitRequest.h create mode 100644 usb/common/audio/AUDFormatTypeOneDescriptor.h create mode 100644 usb/common/audio/AUDGenericDescriptor.h create mode 100644 usb/common/audio/AUDGenericRequest.c create mode 100644 usb/common/audio/AUDGenericRequest.h create mode 100644 usb/common/audio/AUDHeaderDescriptor.h create mode 100644 usb/common/audio/AUDInputTerminalDescriptor.h create mode 100644 usb/common/audio/AUDOutputTerminalDescriptor.h create mode 100644 usb/common/audio/AUDStreamingInterfaceDescriptor.h create mode 100644 usb/common/audio/audio.dir (limited to 'usb/common/audio') diff --git a/usb/common/audio/AUDControlInterfaceDescriptor.h b/usb/common/audio/AUDControlInterfaceDescriptor.h new file mode 100644 index 0000000..ada2f1e --- /dev/null +++ b/usb/common/audio/AUDControlInterfaceDescriptor.h @@ -0,0 +1,72 @@ +/* ---------------------------------------------------------------------------- + * ATMEL Microcontroller Software Support + * ---------------------------------------------------------------------------- + * Copyright (c) 2008, Atmel Corporation + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer below. + * + * Atmel's name may not be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ---------------------------------------------------------------------------- + */ + +//------------------------------------------------------------------------------ +/// \unit +/// +/// !!!Purpose +/// +/// Definitions for using USB %audio control interfaces. +/// +/// !!!Usage +/// +/// -# When declaring a standard USB interface descriptor for an %audio control +/// interface, use the "USB Audio control interface codes" constants. +//------------------------------------------------------------------------------ + +#ifndef AUDCONTROLINTERFACEDESCRIPTOR_H +#define AUDCONTROLINTERFACEDESCRIPTOR_H + +//------------------------------------------------------------------------------ +// Definitions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "USB Audio control interface codes" +/// +/// This page lists the class, subclass and protocol codes that a USB Audio +/// Control interface descriptor should display. +/// +/// !Codes +/// - AUDControlInterfaceDescriptor_CLASS +/// - AUDControlInterfaceDescriptor_SUBCLASS +/// - AUDControlInterfaceDescriptor_PROTOCOL + +/// Class code for an audio control interface. +#define AUDControlInterfaceDescriptor_CLASS 0x01 + +/// Subclass code for an audio control interface. +#define AUDControlInterfaceDescriptor_SUBCLASS 0x01 + +/// Protocol code for an audio control interface. +#define AUDControlInterfaceDescriptor_PROTOCOL 0x00 +//------------------------------------------------------------------------------ + +#endif //#ifndef AUDCONTROLINTERFACEDESCRIPTOR_H + diff --git a/usb/common/audio/AUDDataEndpointDescriptor.h b/usb/common/audio/AUDDataEndpointDescriptor.h new file mode 100644 index 0000000..5963546 --- /dev/null +++ b/usb/common/audio/AUDDataEndpointDescriptor.h @@ -0,0 +1,104 @@ +/* ---------------------------------------------------------------------------- + * ATMEL Microcontroller Software Support + * ---------------------------------------------------------------------------- + * Copyright (c) 2008, Atmel Corporation + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer below. + * + * Atmel's name may not be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ---------------------------------------------------------------------------- + */ + +//------------------------------------------------------------------------------ +/// \unit +/// +/// !!!Purpose +/// +/// Definition of the USB audio-specific data endpoint descriptor. +/// +/// !!!Usage +/// +/// -# Declare an AUDDataEndpointDescriptor instance as part of the +/// configuration descriptors of a USB %audio %device. +//------------------------------------------------------------------------------ + +#ifndef AUDDATAENDPOINTDESCRIPTOR_H +#define AUDDATAENDPOINTDESCRIPTOR_H + +//------------------------------------------------------------------------------ +// Definitions +//------------------------------------------------------------------------------ + +/// Descriptor subtype for an Audio data endpoint. +#define AUDDataEndpointDescriptor_SUBTYPE 0x01 + +//------------------------------------------------------------------------------ +/// \page "USB Audio Lock delay units" +/// +/// This page lists the valid lock delay unit types. +/// +/// !Units +/// - AUDDataEndpointDescriptor_MILLISECONDS +/// - AUDDataEndpointDescriptor_PCMSAMPLES + +/// Lock delay is expressed in milliseconds. +#define AUDDataEndpointDescriptor_MILLISECONDS 1 + +/// Lock delay is expressed in decoded PCM samples. +#define AUDDataEndpointDescriptor_PCMSAMPLES 2 +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +// Types +//------------------------------------------------------------------------------ + +#ifdef __ICCARM__ // IAR +#pragma pack(1) // IAR +#define __attribute__(...) // IAR +#endif // IAR + +//------------------------------------------------------------------------------ +/// Gives additional information about an USB endpoint used to transmit audio +/// data to or from the host. +//------------------------------------------------------------------------------ +typedef struct { + + /// Size of descriptor in bytes. + unsigned char bLength; + /// Descriptor type (AUDGenericDescriptor_ENDPOINT). + unsigned char bDescriptorType; + /// Descriptor subtype (AUDDataEndpointDescriptor_SUBTYPE). + unsigned char bDescriptorSubType; + /// Indicates available controls and requirement on packet sizes. + unsigned char bmAttributes; + /// Indicates the units of the wLockDelay fields. + /// \sa "USB Audio Lock delay units" + unsigned char bLockDelayUnits; + /// Time it takes for the endpoint to lock its internal clock circuitry. + unsigned short wLockDelay; + +} __attribute__ ((packed)) AUDDataEndpointDescriptor; // GCC + +#ifdef __ICCARM__ // IAR +#pragma pack() // IAR +#endif // IAR + +#endif //#ifndef AUDDATAENDPOINTDESCRIPTOR_H diff --git a/usb/common/audio/AUDDeviceDescriptor.h b/usb/common/audio/AUDDeviceDescriptor.h new file mode 100644 index 0000000..f33523a --- /dev/null +++ b/usb/common/audio/AUDDeviceDescriptor.h @@ -0,0 +1,72 @@ +/* ---------------------------------------------------------------------------- + * ATMEL Microcontroller Software Support + * ---------------------------------------------------------------------------- + * Copyright (c) 2008, Atmel Corporation + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer below. + * + * Atmel's name may not be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ---------------------------------------------------------------------------- + */ + +//------------------------------------------------------------------------------ +/// \unit +/// +/// !!!Purpose +/// +/// Fields values for an USB Audio %device descriptor. +/// +/// !!!Usage +/// +/// -# When declaring the %device descriptor of a USB %audio %device, use +/// "USB Audio device descriptor values" defined here. +//------------------------------------------------------------------------------ + +#ifndef AUDDEVICEDESCRIPTOR_H +#define AUDDEVICEDESCRIPTOR_H + +//------------------------------------------------------------------------------ +// Definitions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "USB Audio device descriptor values" +/// +/// This page lists the class, subclass & protocol codes that a USB audio +/// device should display in its device descriptor. +/// +/// !Codes +/// - AUDDeviceDescriptor_CLASS +/// - AUDDeviceDescriptor_SUBCLASS +/// - AUDDeviceDescriptor_PROTOCOL + +/// Class code for a USB audio device. +#define AUDDeviceDescriptor_CLASS 0x00 + +/// Subclass code for a USB audio device. +#define AUDDeviceDescriptor_SUBCLASS 0x00 + +/// Protocol code for a USB audio device. +#define AUDDeviceDescriptor_PROTOCOL 0x00 +//------------------------------------------------------------------------------ + +#endif //#ifndef AUDDEVICEDESCRIPTOR_H + diff --git a/usb/common/audio/AUDEndpointDescriptor.h b/usb/common/audio/AUDEndpointDescriptor.h new file mode 100644 index 0000000..9dce6ab --- /dev/null +++ b/usb/common/audio/AUDEndpointDescriptor.h @@ -0,0 +1,86 @@ +/* ---------------------------------------------------------------------------- + * ATMEL Microcontroller Software Support + * ---------------------------------------------------------------------------- + * Copyright (c) 2008, Atmel Corporation + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer below. + * + * Atmel's name may not be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ---------------------------------------------------------------------------- + */ + +//------------------------------------------------------------------------------ +/// \unit +/// +/// !!!Purpose +/// +/// Re-definition of the standard USB endpoint descriptor with two additional +/// fields. This is required by the USB audio 1.00 specification. +/// +/// !!!Usage +/// +/// -# Declare an AUDEndpointDescriptor instance as part of the configuration +/// descriptors of an USB %audio %device. +//------------------------------------------------------------------------------ + +#ifndef AUDENDPOINTDESCRIPTOR_H +#define AUDENDPOINTDESCRIPTOR_H + +//------------------------------------------------------------------------------ +// Types +//------------------------------------------------------------------------------ + +#ifdef __ICCARM__ // IAR +#pragma pack(1) // IAR +#define __attribute__(...) // IAR +#endif // IAR + +//------------------------------------------------------------------------------ +/// Modified endpoint descriptor with two additional fields, with are +/// USB audio specific. +//------------------------------------------------------------------------------ +typedef struct { + + /// Size of the descriptor in bytes. + unsigned char bLength; + /// Descriptor type (USBGenericDescriptor_ENDPOINT). + unsigned char bDescriptorType; + /// Address and direction of the endpoint. + unsigned char bEndpointAddress; + /// Endpoint type and additional characteristics (for isochronous endpoints). + unsigned char bmAttributes; + /// Maximum packet size (in bytes) of the endpoint. + unsigned short wMaxPacketSize; + /// Polling rate of the endpoint. + unsigned char bInterval; + /// Refresh rate for a feedback endpoint. + unsigned char bRefresh; + /// Address of the associated feedback endpoint if any. + unsigned char bSyncAddress; + +} __attribute__ ((packed)) AUDEndpointDescriptor; // GCC + +#ifdef __ICCARM__ // IAR +#pragma pack() // IAR +#endif // IAR + +#endif //#ifndef AUDENDPOINTDESCRIPTOR_H + diff --git a/usb/common/audio/AUDFeatureUnitDescriptor.h b/usb/common/audio/AUDFeatureUnitDescriptor.h new file mode 100644 index 0000000..a1ba45f --- /dev/null +++ b/usb/common/audio/AUDFeatureUnitDescriptor.h @@ -0,0 +1,116 @@ +/* ---------------------------------------------------------------------------- + * ATMEL Microcontroller Software Support + * ---------------------------------------------------------------------------- + * Copyright (c) 2008, Atmel Corporation + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer below. + * + * Atmel's name may not be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ---------------------------------------------------------------------------- + */ + +//------------------------------------------------------------------------------ +/// \unit +/// +/// !!!Purpose +/// +/// Class for manipulating USB %audio feature unit descriptor. +/// +/// !!!Usage +/// +/// -# Declare an AUDFeatureUnitDescriptor instance as part of the +/// configuration descriptors returned by a USB %audio %device. +//------------------------------------------------------------------------------ + +#ifndef AUDFEATUREUNITDESCRIPTOR_H +#define AUDFEATUREUNITDESCRIPTOR_H + +//------------------------------------------------------------------------------ +// Definitions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "USB Audio Channel controls" +/// +/// This page lists the available controls for each channel of the audio +/// interface. Each channel can have any control combination; simply perform +/// a bitwise OR ('|') to combine several values. +/// +/// !Controls +/// -# AUDFeatureUnitDescriptor_MUTE +/// -# AUDFeatureUnitDescriptor_VOLUME +/// -# AUDFeatureUnitDescriptor_BASS +/// -# AUDFeatureUnitDescriptor_MID +/// -# AUDFeatureUnitDescriptor_TREBLE + +/// Channel mute control. +#define AUDFeatureUnitDescriptor_MUTE (1 << 0) + +/// Channel volume control. +#define AUDFeatureUnitDescriptor_VOLUME (1 << 1) + +/// Channel bass control. +#define AUDFeatureUnitDescriptor_BASS (1 << 2) + +/// Channel middle control. +#define AUDFeatureUnitDescriptor_MID (1 << 3) + +/// Channel treble control. +#define AUDFeatureUnitDescriptor_TREBLE (1 << 4) +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +// Types +//------------------------------------------------------------------------------ + +#ifdef __ICCARM__ // IAR +#pragma pack(1) // IAR +#define __attribute__(...) // IAR +#endif // IAR + +//------------------------------------------------------------------------------ +/// Describes available controls for each channel of the unit or terminal +/// it is connected to. This type must be augmented with the relevant number +/// of bmaControls fields and the iFeature field. +//------------------------------------------------------------------------------ +typedef struct { + + /// Size of descriptor in bytes. + unsigned char bLength; + /// Descriptor type (AUDGenericDescriptor_INTERFACE). + unsigned char bDescriptorType; + /// Descriptor subtype (AUDGenericDescriptor_FEATURE). + unsigned char bDescriptorSubType; + /// Identifier of this feature unit. + unsigned char bUnitID; + /// Identifier of the unit or terminal this feature unit is connected to. + unsigned char bSourceID; + /// Size in bytes of a channel controls field. + unsigned char bControlSize; + +} __attribute__ ((packed)) AUDFeatureUnitDescriptor; // GCC + +#ifdef __ICCARM__ // IAR +#pragma pack() // IAR +#endif // IAR + +#endif //#ifndef AUDFEATUREUNITDESCRIPTOR_H + diff --git a/usb/common/audio/AUDFeatureUnitRequest.c b/usb/common/audio/AUDFeatureUnitRequest.c new file mode 100644 index 0000000..bc6c642 --- /dev/null +++ b/usb/common/audio/AUDFeatureUnitRequest.c @@ -0,0 +1,60 @@ +/* ---------------------------------------------------------------------------- + * ATMEL Microcontroller Software Support + * ---------------------------------------------------------------------------- + * Copyright (c) 2008, Atmel Corporation + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer below. + * + * Atmel's name may not be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ---------------------------------------------------------------------------- + */ + +//------------------------------------------------------------------------------ +// Headers +//------------------------------------------------------------------------------ + +#include "AUDFeatureUnitRequest.h" + +//------------------------------------------------------------------------------ +// Exported functions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// Returns the control selector value indicating the target of a Feature Unit +/// request. +/// \param request Pointer to a USBGenericRequest instance. +/// \sa "USB Audio Control selector values" +//------------------------------------------------------------------------------ +unsigned char AUDFeatureUnitRequest_GetControl(const USBGenericRequest *request) +{ + return ((USBGenericRequest_GetValue(request) >> 8) & 0xFF); +} + +//------------------------------------------------------------------------------ +/// Returns the channel number of a Feature unit which should be altered by the +/// given request. +/// \param request Pointer to a USBGenericRequest instance. +//------------------------------------------------------------------------------ +unsigned char AUDFeatureUnitRequest_GetChannel(const USBGenericRequest *request) +{ + return (USBGenericRequest_GetValue(request) & 0xFF); +} + diff --git a/usb/common/audio/AUDFeatureUnitRequest.h b/usb/common/audio/AUDFeatureUnitRequest.h new file mode 100644 index 0000000..289f598 --- /dev/null +++ b/usb/common/audio/AUDFeatureUnitRequest.h @@ -0,0 +1,81 @@ +/* ---------------------------------------------------------------------------- + * ATMEL Microcontroller Software Support + * ---------------------------------------------------------------------------- + * Copyright (c) 2008, Atmel Corporation + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer below. + * + * Atmel's name may not be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ---------------------------------------------------------------------------- + */ + +//------------------------------------------------------------------------------ +/// \unit +/// +/// !!!Purpose +/// +/// Definitions of constants and methods for using USB %audio requests +/// targetted at a Feature unit. +/// +/// !!!Usage +/// +/// - For a USB %device: +/// -# Use AUDFeatureUnitRequest_GetControl to determine which control +/// shall be tweaked following a host request. +// -# Use AUDFeatureUnitRequest_GetChannel to identify the channel which +// will have its control altered. +//------------------------------------------------------------------------------ + +#ifndef AUDFEATUREUNITREQUEST_H +#define AUDFEATUREUNITREQUEST_H + +//------------------------------------------------------------------------------ +// Headers +//------------------------------------------------------------------------------ + +#include + +//------------------------------------------------------------------------------ +// Constants +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "USB Audio Control selector values" +/// +/// This page lists the available control selectors for a Feature Unit request. +/// +/// !Controls +/// - AUDFeatureUnitRequest_MUTE + +/// Mute control selector. +#define AUDFeatureUnitRequest_MUTE 0x01 +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +// Exported functions +//------------------------------------------------------------------------------ +extern unsigned char AUDFeatureUnitRequest_GetControl( + const USBGenericRequest *request); +extern unsigned char AUDFeatureUnitRequest_GetChannel( + const USBGenericRequest *request); + +#endif //#ifndef AUDFEATUREUNITREQUEST_H + diff --git a/usb/common/audio/AUDFormatTypeOneDescriptor.h b/usb/common/audio/AUDFormatTypeOneDescriptor.h new file mode 100644 index 0000000..0aa6b63 --- /dev/null +++ b/usb/common/audio/AUDFormatTypeOneDescriptor.h @@ -0,0 +1,101 @@ +/* ---------------------------------------------------------------------------- + * ATMEL Microcontroller Software Support + * ---------------------------------------------------------------------------- + * Copyright (c) 2008, Atmel Corporation + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer below. + * + * Atmel's name may not be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ---------------------------------------------------------------------------- + */ + +//------------------------------------------------------------------------------ +/// \unit +/// +/// !!!Purpose +/// +/// Definitions for using USB %audio format type I descriptors. +/// +/// !!!Usage +/// +/// -# Declare an instance of AUDFormatTypeOneDescriptor as part of the +/// configuration descriptors of an audio device. +//------------------------------------------------------------------------------ + +#ifndef AUDFORMATTYPEONEDESCRIPTOR_H +#define AUDFORMATTYPEONEDESCRIPTOR_H + +//------------------------------------------------------------------------------ +// Definitions +//------------------------------------------------------------------------------ + +/// Format type for a format type I descriptor. +#define AUDFormatTypeOneDescriptor_FORMATTYPEONE 0x01 + +/// AUDFormatTypeOneDescriptor_PCM - PCM format. +#define AUDFormatTypeOneDescriptor_PCM 0x0001 + +/// Indicates the sampling frequency can have any value in the provided range. +#define AUDFormatTypeOneDescriptor_CONTINUOUS 0 + +//------------------------------------------------------------------------------ +// Types +//------------------------------------------------------------------------------ + +#ifdef __ICCARM__ // IAR +#pragma pack(1) // IAR +#define __attribute__(...) // IAR +#endif // IAR + +//------------------------------------------------------------------------------ +/// Describes an audio data stream that is constructed on a sample-by-sample +/// basis. This type must be augmented with either the continuous sampling +/// frequency range (if bSamFreqType = ) +/// or with an array containing the possible discrete frequencies. +//------------------------------------------------------------------------------ +typedef struct { + + /// Size of descriptor in bytes. + unsigned char bLength; + /// Descriptor type (AUDGenericDescriptor_INTERFACE). + unsigned char bDescriptorType; + /// Descriptor subtype (AUDStreamingInterfaceDescriptor_FORMATTYPE). + unsigned char bDescriptorSubType; + /// Format type (AUDFormatTypeOneDescriptor_FORMATTYPEONE). + unsigned char bFormatType; + /// Number of physical channels in the audio stream. + unsigned char bNrChannels; + /// Number of bytes occupied by one audio subframe. + unsigned char bSubFrameSize; + /// Number of bits effectively used in an audio subframe. + unsigned char bBitResolution; + /// Number of supported discrete sampling frequencies, or + /// AUDFormatTypeOneDescriptor_CONTINUOUS. + unsigned char bSamFreqType; + +} __attribute__ ((packed)) AUDFormatTypeOneDescriptor; // GCC + +#ifdef __ICCARM__ // IAR +#pragma pack() // IAR +#endif // IAR + +#endif //#ifndef AUDFORMATTYPEONEDESCRIPTOR_H + diff --git a/usb/common/audio/AUDGenericDescriptor.h b/usb/common/audio/AUDGenericDescriptor.h new file mode 100644 index 0000000..8758a92 --- /dev/null +++ b/usb/common/audio/AUDGenericDescriptor.h @@ -0,0 +1,121 @@ +/* ---------------------------------------------------------------------------- + * ATMEL Microcontroller Software Support + * ---------------------------------------------------------------------------- + * Copyright (c) 2008, Atmel Corporation + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer below. + * + * Atmel's name may not be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ---------------------------------------------------------------------------- + */ + +//------------------------------------------------------------------------------ +/// \unit +/// +/// !!!Purpose +/// +/// Constants for manipulating USB audio-specific descriptors. +/// +/// !!!Usage +/// +/// - For a USB %device: +/// -# When declaring an Audio-specific descriptor, use the descriptor types +/// and subtypes defined in this unit (see "USB Audio descriptor types" +/// and "USB Audio descriptor subtypes"). +//------------------------------------------------------------------------------ + +#ifndef AUDGENERICDESCRIPTOR_H +#define AUDGENERICDESCRIPTOR_H + +//------------------------------------------------------------------------------ +// Definitions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "USB Audio descriptor types" +/// +/// This page lists the available types for USB audio-specific descriptors. +/// +/// !Types +/// - AUDGenericDescriptor_DEVICE +/// - AUDGenericDescriptor_CONFIGURATION +/// - AUDGenericDescriptor_STRING +/// - AUDGenericDescriptor_INTERFACE +/// - AUDGenericDescriptor_ENDPOINT + +/// Descriptor gives detail about the whole device. +#define AUDGenericDescriptor_DEVICE 0x21 + +/// Descriptor gives detail about a configuration. +#define AUDGenericDescriptor_CONFIGURATION 0x22 + +/// Descriptor gives detail about a string. +#define AUDGenericDescriptor_STRING 0x23 + +/// Descriptor gives detail about an interface. +#define AUDGenericDescriptor_INTERFACE 0x24 + +/// Descriptor gives detail about an endpoint. +#define AUDGenericDescriptor_ENDPOINT 0x25 +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "USB Audio descriptor subtypes" +/// +/// This page lists the possible subtypes for USB audio-specific descriptors. +/// +/// !Subtypes +/// - AUDGenericDescriptor_HEADER +/// - AUDGenericDescriptor_INPUTTERMINAL +/// - AUDGenericDescriptor_OUTPUTTERMINAL +/// - AUDGenericDescriptor_MIXERUNIT +/// - AUDGenericDescriptor_SELECTORUNIT +/// - AUDGenericDescriptor_FEATUREUNIT +/// - AUDGenericDescriptor_PROCESSINGUNIT +/// - AUDGenericDescriptor_EXTENSIONUNIT + +/// Header descriptor subtype. +#define AUDGenericDescriptor_HEADER 0x01 + +/// Input terminal descriptor subtype. +#define AUDGenericDescriptor_INPUTTERMINAL 0x02 + +/// Output terminal descriptor subtype. +#define AUDGenericDescriptor_OUTPUTTERMINAL 0x03 + +/// Mixer unit descriptor subtype. +#define AUDGenericDescriptor_MIXERUNIT 0x04 + +/// Selector unit descriptor subtype. +#define AUDGenericDescriptor_SELECTORUNIT 0x05 + +/// Feature unit descriptor subtype. +#define AUDGenericDescriptor_FEATUREUNIT 0x06 + +/// Processing unit descriptor subtype. +#define AUDGenericDescriptor_PROCESSINGUNIT 0x07 + +///Extension unit descriptor subtype. +#define AUDGenericDescriptor_EXTENSIONUNIT 0x08 +//------------------------------------------------------------------------------ + +#endif //#ifndef AUDGENERICDESCRIPTOR_H + diff --git a/usb/common/audio/AUDGenericRequest.c b/usb/common/audio/AUDGenericRequest.c new file mode 100644 index 0000000..c9c6e87 --- /dev/null +++ b/usb/common/audio/AUDGenericRequest.c @@ -0,0 +1,57 @@ +/* ---------------------------------------------------------------------------- + * ATMEL Microcontroller Software Support + * ---------------------------------------------------------------------------- + * Copyright (c) 2008, Atmel Corporation + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer below. + * + * Atmel's name may not be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ---------------------------------------------------------------------------- + */ + +//------------------------------------------------------------------------------ +// Headers +//------------------------------------------------------------------------------ + +#include "AUDGenericRequest.h" + +//------------------------------------------------------------------------------ +// Exported functions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// Returns the ID of the unit or terminal targetted by an USB audio request. +/// \param request Pointer to a USBGenericRequest instance. +//------------------------------------------------------------------------------ +unsigned char AUDGenericRequest_GetEntity(const USBGenericRequest *request) +{ + return ((USBGenericRequest_GetIndex(request) >> 8) & 0xFF); +} + +//------------------------------------------------------------------------------ +/// Returns the ID of the interface targetted by an USB audio request. +/// \param request Pointer to a USBGenericRequest instance. +//------------------------------------------------------------------------------ +unsigned char AUDGenericRequest_GetInterface(const USBGenericRequest *request) +{ + return (USBGenericRequest_GetIndex(request) & 0xFF); +} + diff --git a/usb/common/audio/AUDGenericRequest.h b/usb/common/audio/AUDGenericRequest.h new file mode 100644 index 0000000..b0b8527 --- /dev/null +++ b/usb/common/audio/AUDGenericRequest.h @@ -0,0 +1,94 @@ +/* ---------------------------------------------------------------------------- + * ATMEL Microcontroller Software Support + * ---------------------------------------------------------------------------- + * Copyright (c) 2008, Atmel Corporation + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer below. + * + * Atmel's name may not be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ---------------------------------------------------------------------------- + */ + +//------------------------------------------------------------------------------ +/// \unit +/// +/// !!!Purpose +/// +/// Constants for using USB %audio SETUP requests. +/// +/// !!!Usage +/// +/// - For a USB %device: +/// -# After receiving an Audio request from the host, use +/// AUDGenericRequest_GetEntity to determine the target Unit or Terminal. +/// -# After receiving an Audio request from the host, use +/// AUDGenericRequest_GetInterface to know which interface is referenced. +//------------------------------------------------------------------------------ + +#ifndef AUDGENERICREQUEST_H +#define AUDGENERICREQUEST_H + +//------------------------------------------------------------------------------ +// Headers +//------------------------------------------------------------------------------ + +#include + +//------------------------------------------------------------------------------ +// Definitions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "USB Audio request codes" +/// +/// This page lists the codes of the existing Audio requests. +/// +/// !Requests +/// - AUDGenericRequest_SETCUR +/// - AUDGenericRequest_GETCUR + +/// SET_CUR request code. +#define AUDGenericRequest_SETCUR 0x01 + +/// GET_CUR request code. +#define AUDGenericRequest_GETCUR 0x81 + +/// GET_MIN request code. +#define AUDGenericRequest_GETMIN 0x82 + +/// GET_MAX request code. +#define AUDGenericRequest_GETMAX 0x83 + +/// GET_RES request code. +#define AUDGenericRequest_GETRES 0x84 +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +// Exported functions +//------------------------------------------------------------------------------ + +extern unsigned char AUDGenericRequest_GetEntity( + const USBGenericRequest *request); +extern unsigned char AUDGenericRequest_GetInterface( + const USBGenericRequest *request); + +#endif //#ifndef AUDGENERICREQUEST_H + diff --git a/usb/common/audio/AUDHeaderDescriptor.h b/usb/common/audio/AUDHeaderDescriptor.h new file mode 100644 index 0000000..ca30a0b --- /dev/null +++ b/usb/common/audio/AUDHeaderDescriptor.h @@ -0,0 +1,100 @@ +/* ---------------------------------------------------------------------------- + * ATMEL Microcontroller Software Support + * ---------------------------------------------------------------------------- + * Copyright (c) 2008, Atmel Corporation + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer below. + * + * Atmel's name may not be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ---------------------------------------------------------------------------- + */ + +//------------------------------------------------------------------------------ +/// \unit +/// +/// !!!Purpose +/// +/// Class for manipulating USB %audio header descriptors. +/// +/// !!!Usage +/// +/// - For a USB %device: +/// -# Declare a AUDHeaderDescriptor as part of the configuration +/// descriptors of the %device. +//------------------------------------------------------------------------------ + +#ifndef AUDHEADERDESCRIPTOR_H +#define AUDHEADERDESCRIPTOR_H + +//------------------------------------------------------------------------------ +// Definitions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "USB Audio class releases" +/// This page lists the existing versions of the Audio class specification. +/// +/// +/// !Versions +/// - AUDHeaderDescriptor_AUD1_00 + +/// Indentifies the USB audio specification release 1.00. +#define AUDHeaderDescriptor_AUD1_00 0x0100 +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +// Types +//------------------------------------------------------------------------------ + +#ifdef __ICCARM__ // IAR +#pragma pack(1) // IAR +#define __attribute__(...) // IAR +#endif // IAR + +//------------------------------------------------------------------------------ +/// Groups the various audio interfaces to display one single function to +/// the USB host. Subclass this structure to add a particular number of +/// slave interface descriptors. +//------------------------------------------------------------------------------ +typedef struct { + + /// Size of descriptor in bytes. + unsigned char bLength; + /// Descriptor type (AUDGenericDescriptor_INTERFACE). + unsigned char bDescriptorType; + /// Descriptor subtype (AUDGenericDescriptor_HEADER). + unsigned char bDescriptorSubType; + /// Audio class release number in BCD format + /// \sa "USB Audio class releases" + unsigned short bcdADC; + /// Length of all descriptors used to qualify the Audio Control interface. + unsigned short wTotalLength; + /// Number of Streaming interfaces contained in this collection. + unsigned char bInCollection; + +} __attribute__ ((packed)) AUDHeaderDescriptor; // GCC + +#ifdef __ICCARM__ // IAR +#pragma pack() // IAR +#endif // IAR + +#endif //#ifndef AUDHEADERDESCRIPTOR_H + diff --git a/usb/common/audio/AUDInputTerminalDescriptor.h b/usb/common/audio/AUDInputTerminalDescriptor.h new file mode 100644 index 0000000..e0895fb --- /dev/null +++ b/usb/common/audio/AUDInputTerminalDescriptor.h @@ -0,0 +1,139 @@ +/* ---------------------------------------------------------------------------- + * ATMEL Microcontroller Software Support + * ---------------------------------------------------------------------------- + * Copyright (c) 2008, Atmel Corporation + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer below. + * + * Atmel's name may not be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ---------------------------------------------------------------------------- + */ + +//------------------------------------------------------------------------------ +/// \unit +/// +/// !!!Purpose +/// +/// Class for manipulating input terminal descriptors. +/// +/// !!!Usage +/// +/// - For a USB %device: +/// -# Declare an AUDInputTerminalDescriptor instance as part of the +/// configuration of the %device. +//------------------------------------------------------------------------------ + +#ifndef AUDINPUTTERMINALDESCRIPTOR_H +#define AUDINPUTTERMINALDESCRIPTOR_H + +//------------------------------------------------------------------------------ +// Definitions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "USB Audio Input terminal types" +/// +/// This page lists the available types for an Input terminal. +/// +/// !Types +/// +/// - AUDInputTerminalDescriptor_USBSTREAMING +/// - AUDInputTerminalDescriptor_MICROPHONE +/// - AUDInputTerminalDescriptor_SPEAKERPHONE +/// - AUDInputTerminalDescriptor_LINEIN + +/// A terminal receiving its data from a USB isochronous endpoint. +#define AUDInputTerminalDescriptor_USBSTREAMING 0x0101 +/// A terminal sampling data from a microphone. +#define AUDInputTerminalDescriptor_MICROPHONE 0x0201 +/// A terminal sampling data from a Handset In. +#define AUDInputTerminalDescriptor_HANDSETIN 0x0401 +/// A terminal sampling data from a speakerphone +#define AUDInputTerminalDescriptor_SPEAKERPHONE 0x0403 +/// A terminal sampling data from a Phone Line In. +#define AUDInputTerminalDescriptor_LINEIN 0x0501 +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "USB Audio Channel spatial locations" +/// +/// This page lists the possible spatial locations for audio channels. +/// +/// !Locations +/// +/// - AUDInputTerminalDescriptor_LEFTFRONT +/// - AUDInputTerminalDescriptor_RIGHTFRONT +/// - AUDInputTerminalDescriptor_CENTERFRONT + +/// Front left channel. +#define AUDInputTerminalDescriptor_LEFTFRONT (1 << 0) + +/// Front right channel. +#define AUDInputTerminalDescriptor_RIGHTFRONT (1 << 1) + +/// Front center channel. +#define AUDInputTerminalDescriptor_CENTERFRONT (1 << 2) +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +// Types +//------------------------------------------------------------------------------ + +#ifdef __ICCARM__ // IAR +#pragma pack(1) // IAR +#define __attribute__(...) // IAR +#endif // IAR + +//------------------------------------------------------------------------------ +/// Describes an input of a USB audio device. +//------------------------------------------------------------------------------ +typedef struct { + + /// Size of descriptor in bytes. + unsigned char bLength; + /// Descriptor type (AUDGenericDescriptor_INTERFACE). + unsigned char bDescriptorType; + /// Descriptor subtype (AUDGenericDescriptor_INPUTTERMINAL). + unsigned char bDescriptorSubType; + /// ID of the terminal in the audio function. + unsigned char bTerminalID; + /// Terminal type. + /// \sa "USB Audio Input terminal types" + unsigned short wTerminalType; + /// ID of the output terminal to which this input terminal is associated. + unsigned char bAssocTerminal; + /// Number of logical output channels in this terminal. + unsigned char bNrChannels; + /// Spatial configuration of the logical channels. + unsigned short wChannelConfig; + /// Index of a string descriptor for the first logical channel. + unsigned char iChannelNames; + /// Index of a string descriptor for this terminal. + unsigned char iTerminal; + +} __attribute__ ((packed)) AUDInputTerminalDescriptor; // GCC + +#ifdef __ICCARM__ // IAR +#pragma pack() // IAR +#endif // IAR + +#endif //#ifndef AUDINPUTTERMINALDESCRIPTOR_H + diff --git a/usb/common/audio/AUDOutputTerminalDescriptor.h b/usb/common/audio/AUDOutputTerminalDescriptor.h new file mode 100644 index 0000000..6ba3156 --- /dev/null +++ b/usb/common/audio/AUDOutputTerminalDescriptor.h @@ -0,0 +1,112 @@ +/* ---------------------------------------------------------------------------- + * ATMEL Microcontroller Software Support + * ---------------------------------------------------------------------------- + * Copyright (c) 2008, Atmel Corporation + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer below. + * + * Atmel's name may not be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ---------------------------------------------------------------------------- + */ + +//------------------------------------------------------------------------------ +/// \unit +/// +/// !!!Purpose +/// +/// Definition of a class for using USB %audio output terminal descriptors. +/// +/// !!!Usage +/// +/// - For a USB %device: +/// -# Declare a AUDOutputTerminalDescriptor instance as part of the +/// configuration descriptors of a USB %audio %device. +//------------------------------------------------------------------------------ + +#ifndef AUDOUTPUTTERMINALDESCRIPTOR_H +#define AUDOUTPUTTERMINALDESCRIPTOR_H + +//------------------------------------------------------------------------------ +// Definitions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "USB Audio Output terminal types" +/// +/// This page lists the available types for an output terminal. +/// +/// !Types +/// - AUDOutputTerminalDescriptor_USBTREAMING +/// - AUDOutputTerminalDescriptor_SPEAKER +/// - AUDOutputTerminalDescriptor_HANDSETOUT +/// - AUDOutputTerminalDescriptor_LINEOUT + +/// A terminal sending data through USB isochronous endpoint. +#define AUDOutputTerminalDescriptor_USBTREAMING 0x0101 +/// A terminal sending data to a USB host through an Isochronous endpoint. +#define AUDOutputTerminalDescriptor_SPEAKER 0x0301 +/// A terminal sending data to Handset Out. +#define AUDOutputTerminalDescriptor_HANDSETOUT 0x0401 +/// A terminal sending data to Phone Line Out. +#define AUDOutputTerminalDescriptor_LINEOUT 0x0501 +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +// Types +//------------------------------------------------------------------------------ + +#ifdef __ICCARM__ // IAR +#pragma pack(1) // IAR +#define __attribute__(...) // IAR +#endif // IAR + +//------------------------------------------------------------------------------ +/// \typedef AUDOutputTerminalDescriptor +/// Describes an output of the USB audio function. +//------------------------------------------------------------------------------ +typedef struct { + + /// Size of descriptor in bytes. + unsigned char bLength; + /// Descriptor type (AUDGenericDescriptor_INTERFACE). + unsigned char bDescriptorType; + /// Descriptor subtype (AUDGenericDescriptor_OUTPUTTERMINAL). + unsigned char bDescriptorSubType; + /// Identifier for this terminal. + unsigned char bTerminalID; + /// Terminal type. + /// \sa "USB Audio Output terminal types" + unsigned short wTerminalType; + /// Identifier of the associated input terminal. + unsigned char bAssocTerminal; + /// Identifier of the unit or terminal to which this terminal is connected. + unsigned char bSourceID; + /// Index of a string descriptor for this terminal. + unsigned char iTerminal; + +} __attribute__ ((packed)) AUDOutputTerminalDescriptor; // GCC + +#ifdef __ICCARM__ // IAR +#pragma pack() // IAR +#endif // IAR + +#endif //#ifndef AUDOUTPUTTERMINALDESCRIPTOR_H + diff --git a/usb/common/audio/AUDStreamingInterfaceDescriptor.h b/usb/common/audio/AUDStreamingInterfaceDescriptor.h new file mode 100644 index 0000000..80c9cfd --- /dev/null +++ b/usb/common/audio/AUDStreamingInterfaceDescriptor.h @@ -0,0 +1,129 @@ +/* ---------------------------------------------------------------------------- + * ATMEL Microcontroller Software Support + * ---------------------------------------------------------------------------- + * Copyright (c) 2008, Atmel Corporation + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer below. + * + * Atmel's name may not be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ---------------------------------------------------------------------------- + */ + +//------------------------------------------------------------------------------ +/// \unit +/// +/// !!!Purpose +/// +/// Definition of a class for manipulating USB %audio streaming interface +/// descriptors. +/// +/// !!!Usage +/// +/// - For a USB %device: +/// -# Declare an AUDStreamingInterfaceDescriptor instance as part of the +/// configuration descriptors returned by a USB %audio %device. +//------------------------------------------------------------------------------ + +#ifndef AUDSTREAMINGINTERFACEDESCRIPTOR_H +#define AUDSTREAMINGINTERFACEDESCRIPTOR_H + +//------------------------------------------------------------------------------ +// Definitions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "USB Audio streaming interface codes" +/// +/// This page lists the class, subclass and protocol codes that an Audio +/// Streaming interface should display in its descriptor. +/// +/// !Codes +/// - AUDStreamingInterfaceDescriptor_CLASS +/// - AUDStreamingInterfaceDescriptor_SUBCLASS +/// - AUDStreamingInterfaceDescriptor_PROTOCOL + +/// Class code for an USB audio streaming interface. +#define AUDStreamingInterfaceDescriptor_CLASS 0x01 + +/// Subclass code for an audio streaming interface. +#define AUDStreamingInterfaceDescriptor_SUBCLASS 0x02 + +/// Protocol code for an audio streaming interface. +#define AUDStreamingInterfaceDescriptor_PROTOCOL 0x00 +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "USB Audio streaming descriptor subtypes" +/// +/// This page lists the possible subtypes for audio-specific descriptor appended +/// to an Audio Streaming interface. +/// +/// !Subtypes +/// - AUDStreamingInterfaceDescriptor_GENERAL +/// - AUDStreamingInterfaceDescriptor_FORMATTYPE +/// - AUDStreamingInterfaceDescriptor_FORMATSPECIFIC + +/// General descriptor subtype. +#define AUDStreamingInterfaceDescriptor_GENERAL 0x01 + +/// Format type descriptor subtype. +#define AUDStreamingInterfaceDescriptor_FORMATTYPE 0x02 + +/// Format specific descriptor subtype. +#define AUDStreamingInterfaceDescriptor_FORMATSPECIFIC 0x03 +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +// Types +//------------------------------------------------------------------------------ + +#ifdef __ICCARM__ // IAR +#pragma pack(1) // IAR +#define __attribute__(...) // IAR +#endif // IAR + +//------------------------------------------------------------------------------ +/// Provides additional information about an audio streaming interface to +/// the USB host. +//------------------------------------------------------------------------------ +typedef struct { + + /// Size of descriptor in bytes. + unsigned char bLength; + /// Descriptor type (AUDGenericDescriptor_INTERFACE). + unsigned char bDescriptorType; + /// Descriptor subtype (AUDStreamingInterfaceDescriptor_GENERAL). + unsigned char bDescriptorSubType; + /// Terminal ID to which the interface is connected. + unsigned char bTerminalLink; + /// Delay introduced by the data path, in number of frames. + unsigned char bDelay; + /// Audio data format used by this interface. + unsigned short wFormatTag; + +} __attribute__ ((packed)) AUDStreamingInterfaceDescriptor; // GCC + +#ifdef __ICCARM__ // IAR +#pragma pack() // IAR +#endif // IAR + +#endif //#ifndef AUDSTREAMINGINTERFACEDESCRIPTOR_H + diff --git a/usb/common/audio/audio.dir b/usb/common/audio/audio.dir new file mode 100644 index 0000000..2bc574f --- /dev/null +++ b/usb/common/audio/audio.dir @@ -0,0 +1,40 @@ +/* ---------------------------------------------------------------------------- + * ATMEL Microcontroller Software Support + * ---------------------------------------------------------------------------- + * Copyright (c) 2008, Atmel Corporation + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer below. + * + * Atmel's name may not be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ---------------------------------------------------------------------------- + */ + +//------------------------------------------------------------------------------ +/// \dir +/// !!!Purpose +/// +/// This directory contains definitions, structures and funcions related to the +/// USB Audio Class specification. They can be divided into two groups: +/// - Audio-specific descriptors, prefixed with AUD and suffixed with +/// Descriptor. +/// - Audio-specific requests, prefixed with AUD and suffixed with Request. +//------------------------------------------------------------------------------ + -- cgit v1.2.3