/* * Copyright (c) 2015, Freescale Semiconductor, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, this list * of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * o Neither the name of Freescale Semiconductor, Inc. nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 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. */ #ifndef __USB_HOST_AUDIO_H__ #define __USB_HOST_AUDIO_H__ /******************************************************************************* * Audio class private structure, enumerations, macros ******************************************************************************/ /******************************************************************************* * Definitions ******************************************************************************/ /* Structure for an AUDIO class descriptor according to the 6.2.1 in Audio specification*/ #define AUDIO_FU_MUTE 0x01 #define AUDIO_FU_VOLUME 0x02 #define AUDIO_FU_BASS 0x03 #define AUDIO_FU_MID 0x04 #define AUDIO_FU_TREBLE 0x05 #define AUDIO_FU_GRAPHIC_EQ 0x06 #define AUDIO_FU_AGC 0x07 #define AUDIO_FU_DELAY 0x08 #define AUDIO_FU_BASS_BOOST 0x09 /* Audio class codes */ #define SET_COMMAND (0x00) #define GET_COMMAND (0x80) #define CUR_REQUEST (0x01) #define MIN_REQUEST (0x02) #define MAX_REQUEST (0x03) #define RES_REQUEST (0x04) #define MEM_REQUEST (0x05) #define GET_STATUS (0xFF) #define ITF_REQUEST (0x21) #define EP_REQUEST (0x22) #define AUDIO_FU_MUTE_MASK 0x01 #define AUDIO_FU_VOLUME_MASK 0x02 #define AUDIO_FU_BASS_MASK 0x04 #define AUDIO_FU_MID_MASK 0x08 #define AUDIO_FU_TREBLE_MASK 0x10 #define AUDIO_FU_GRAPHIC_EQ_MASK 0x20 #define AUDIO_FU_AGC_MASK 0x40 #define AUDIO_FU_DELAY_MASK 0x80 #define AUDIO_FU_BASS_BOOST_MASK 0x01 /* USB audio Endpoint Control Selectors */ #define AUDIO_EP_CONTROL_UNDEFINED (0x00) #define AUDIO_SAMPLING_FREQ_CONTROL (0x01) #define AUDIO_PITCH_CONTROL (0x02) #define AUDIO_SAMPLING_FREQ_MASK (0x01) #define AUDIO_PITCH_MASK (0x02) typedef enum _fu_request_code { kUSB_AudioCurMute = 0, kUSB_AudioCurVolume, kUSB_AudioMinVolume, kUSB_AudioMaxVolume, kUSB_AudioResVolume, NUMBER_OF_FEATURE_COMMANDS, } fu_request_code_t; typedef enum _ep_request_code { kUSB_AudioCurPitch = 0, kUSB_AudioCurSamplingFreq, kUSB_AudioMinSamplingFreq, kUSB_AudioMaxSamplingFreq, kUSB_AudioResSamplingFreq, NUMBER_OF_ENDPOINT_COMMANDS, } ep_request_code_t; typedef union _audio_descriptor_union { uint8_t *bufr; usb_descriptor_common_t *common; usb_descriptor_device_t *device; usb_descriptor_configuration_t *configuration; usb_descriptor_interface_t *interface; usb_descriptor_endpoint_t *endpoint; } audio_descriptor_union_t; /* Audio command structure */ typedef struct _usb_audio_request { uint8_t controlMask; uint8_t typeRequest; uint8_t codeRequest; uint8_t requestValue; uint8_t length; } usb_audio_request_t; #define USB_DESC_SUBTYPE_AUDIO_CS_HEADER 0x01 #define USB_DESC_SUBTYPE_AUDIO_CS_IT 0x02 #define USB_DESC_SUBTYPE_AUDIO_CS_OT 0x03 #define USB_DESC_SUBTYPE_AUDIO_CS_FU 0x06 #define USB_DESC_CLASS_ENDPOINT_GENERAL 0x01 #define USB_DESC_SUBTYPE_AS_CS_GENERAL 0X01 #define USB_DESC_SUBTYPE_AS_CS_FORMAT_TYPE 0X02 /******************************************************************************* * Audio class public structure, enumeration, macros, functions ******************************************************************************/ /*! * @addtogroup usb_host_audio_drv * @{ */ /*! @brief Audio class code */ #define USB_AUDIO_CLASS_CODE 1 /*! @brief Audio class control interface code*/ #define USB_AUDIO_SUBCLASS_CODE_CONTROL 1 /*! @brief Audio class stream interface code*/ #define USB_AUDIO_SUBCLASS_CODE_AUDIOSTREAMING 2 /*! @brief AUDIO class-specific feature unit get current mute command*/ #define USB_AUDIO_GET_CUR_MUTE 0x80 /*! @brief AUDIO class-specific feature unit set current mute command*/ #define USB_AUDIO_SET_CUR_MUTE 0x00 /*! @brief AUDIO class-specific feature unit get current volume command*/ #define USB_AUDIO_GET_CUR_VOLUME 0x81 /*! @brief AUDIO class-specific feature unit set current volume command*/ #define USB_AUDIO_SET_CUR_VOLUME 0x01 /*! @brief AUDIO class-specific feature unit get minimum volume command*/ #define USB_AUDIO_GET_MIN_VOLUME 0x82 /*! @brief AUDIO class-specific feature unit set minimum volume command*/ #define USB_AUDIO_SET_MIN_VOLUME 0x02 /*! @brief AUDIO class-specific feature unit get maximum volume command*/ #define USB_AUDIO_GET_MAX_VOLUME 0x83 /*! @brief AUDIO class-specific feature unit set maximum volume command*/ #define USB_AUDIO_SET_MAX_VOLUME 0x03 /*! @brief AUDIO class-specific feature unit get resolution volume command*/ #define USB_AUDIO_GET_RES_VOLUME 0x84 /*! @brief AUDIO class-specific feature unit set resolution volume command*/ #define USB_AUDIO_SET_RES_VOLUME 0x04 /*! @brief AUDIO class-specific endpoint get current pitch control command*/ #define USB_AUDIO_GET_CUR_PITCH 0x80 /*! @brief AUDIO class-specific endpoint set current pitch control command*/ #define USB_AUDIO_SET_CUR_PITCH 0x00 /*! @brief AUDIO class-specific endpoint get current sampling frequency command*/ #define USB_AUDIO_GET_CUR_SAMPLING_FREQ 0x81 /*! @brief AUDIO class-specific endpoint set current sampling frequency command*/ #define USB_AUDIO_SET_CUR_SAMPLING_FREQ 0x01 /*! @brief AUDIO class-specific endpoint get minimum sampling frequency command*/ #define USB_AUDIO_GET_MIN_SAMPLING_FREQ 0x82 /*! @brief AUDIO class-specific endpoint set minimum sampling frequency command*/ #define USB_AUDIO_SET_MIN_SAMPLING_FREQ 0x02 /*! @brief AUDIO class-specific endpoint get maximum sampling frequency command*/ #define USB_AUDIO_GET_MAX_SAMPLING_FREQ 0x83 /*! @brief AUDIO class-specific endpoint set maximum sampling frequency command*/ #define USB_AUDIO_SET_MAX_SAMPLING_FREQ 0x03 /*! @brief AUDIO class-specific endpoint get resolution sampling frequency command*/ #define USB_AUDIO_GET_RES_SAMPLING_FREQ 0x84 /*! @brief AUDIO class-specific endpoint set resolution sampling frequency command*/ #define USB_AUDIO_SET_RES_SAMPLING_FREQ 0x04 /*! @brief Audio control interface header descriptor structure */ typedef struct _usb_audio_ctrl_header_desc { uint8_t blength; /*!< Total size of the header descriptor*/ uint8_t bdescriptortype; /*!< Descriptor type of audio header descriptor*/ uint8_t bdescriptorsubtype; /*!< Subtype of an audio header descriptor*/ uint8_t bcdcdc[2]; /*!< Audio Device Class Specification Release Number in Binary-Coded Decimal*/ uint8_t wtotallength[2]; /*!< Total number of bytes returned for the class-specific AudioControl interface descriptor. Includes the combined length of this descriptor header and all unit and terminal descriptors.*/ uint8_t bincollection; /*!< The number of AudioStreaming and MIDIStreaming interfaces in the Audio Interface Collection to which this AudioControl interface belongs to*/ } usb_audio_ctrl_header_desc_t; /*! @brief Audio control interface input terminal descriptor structure */ typedef struct _usb_audio_ctrl_it_desc { uint8_t blength; /*!< Total size of the input terminal descriptor*/ uint8_t bdescriptortype; /*!< Descriptor type of audio input terminal descriptor*/ uint8_t bdescriptorsubtype; /*!< Subtype of audio input terminal descriptor*/ uint8_t bterminalid; /*!< Constant uniquely identifying the Terminal within the audio function. This value is used in all requests to address this Terminal*/ uint8_t wterminaltype[2]; /*!< Constant characterizing the type of Terminal*/ uint8_t bassocterminal; /*!< ID of the Output Terminal to which this Input Terminal is associated*/ uint8_t bnrchannels; /*!< Number of logical output channels in the Terminal's output audio channel cluster*/ uint8_t wchannelconfig[2]; /*!< Describes the spatial location of the logical channels.*/ uint8_t ichannelnames; /*!< Index of a string descriptor, describing the name of the first logical channel*/ uint8_t iterminal; /*!