Christina Quast | b123d74 | 2014-12-23 13:03:36 +0100 | [diff] [blame] | 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 | /** \file |
| 31 | * USB Audio Speaker & Microphone Function. |
| 32 | */ |
| 33 | |
| 34 | /** \addtogroup usbd_audio_speakerphone |
| 35 | *@{ |
| 36 | * Implement speakerphone function that combine 1 AC interface, 1 AS interface |
| 37 | * for speaker and 1 AS interface for microphone. |
| 38 | */ |
| 39 | |
| 40 | #ifndef _AUDD_SPEAKERPHONE_H_ |
| 41 | #define _AUDD_SPEAKERPHONE_H_ |
| 42 | |
| 43 | /*------------------------------------------------------------------------------ |
| 44 | * Headers |
| 45 | *------------------------------------------------------------------------------*/ |
| 46 | |
| 47 | #include <stdint.h> |
| 48 | |
| 49 | #include <AUDDStream.h> |
| 50 | |
| 51 | #include <USBD.h> |
| 52 | #include <USBDDriver.h> |
| 53 | |
| 54 | /*------------------------------------------------------------------------------ |
| 55 | * Defines |
| 56 | *------------------------------------------------------------------------------*/ |
| 57 | |
| 58 | /** \addtogroup usbd_audio_ids Audio Device IDs required by driver |
| 59 | * @{ |
| 60 | * The driver uses following fixed entity IDs, use them to define your |
| 61 | * descriptor. |
| 62 | * \ref AUDD_ID_SpeakerIT |
| 63 | * \ref AUDD_ID_SpeakerOT |
| 64 | * \ref AUDD_ID_SpeakerFU |
| 65 | * \ref AUDD_ID_MicrophoneIT |
| 66 | * \ref AUDD_ID_MicrophoneOT |
| 67 | * \ref AUDD_ID_MicrophoneFU |
| 68 | */ |
| 69 | /** Speaker input terminal ID */ |
| 70 | #define AUDD_ID_SpeakerIT 0x01 |
| 71 | /** Speaker output terminal ID */ |
| 72 | #define AUDD_ID_SpeakerOT 0x02 |
| 73 | /** Speaker feature unit ID */ |
| 74 | #define AUDD_ID_SpeakerFU 0x03 |
| 75 | /** Microphone input terminal ID */ |
| 76 | #define AUDD_ID_MicrophoneIT 0x04 |
| 77 | /** Microphone output terminal ID */ |
| 78 | #define AUDD_ID_MicrophoneOT 0x05 |
| 79 | /** Microphone feature unit ID */ |
| 80 | #define AUDD_ID_MicrophoneFU 0x06 |
| 81 | /** @}*/ |
| 82 | |
| 83 | /** \addtogroup usbd_audio_chs Audio Device Channels |
| 84 | * @{ |
| 85 | */ |
| 86 | /** Master channel ID */ |
| 87 | #define AUDD_CH_Master 0x0 |
| 88 | /** Left channel ID */ |
| 89 | #define AUDD_CH_L 0x1 |
| 90 | /** Right channel ID */ |
| 91 | #define AUDD_CH_R 0x2 |
| 92 | /** @}*/ |
| 93 | |
| 94 | /*------------------------------------------------------------------------------ |
| 95 | * Types |
| 96 | *------------------------------------------------------------------------------*/ |
| 97 | |
| 98 | /** |
| 99 | * Struct of USB Audio Speakerphone Function, with |
| 100 | * - 1 control interface for features, |
| 101 | * - 1 input stream for microphone (Audio IN), |
| 102 | * - 1 output stream for speaker (Audio OUT). |
| 103 | */ |
| 104 | typedef struct _AUDDSpeakerPhone { |
| 105 | /** Pointer to USBD Driver Interface */ |
| 106 | USBDDriver *pUsbd; |
| 107 | /** Pointer to AUDDStream Instance */ |
| 108 | AUDDStream *pSpeaker; |
| 109 | /** Pointer to AUDDStream Instance */ |
| 110 | AUDDStream *pMicrophone; |
| 111 | } AUDDSpeakerPhone; |
| 112 | |
| 113 | /*------------------------------------------------------------------------------ |
| 114 | * Functions |
| 115 | *------------------------------------------------------------------------------*/ |
| 116 | |
| 117 | extern void AUDDSpeakerPhone_InitializeStream( |
| 118 | AUDDStream * pAuds, |
| 119 | uint8_t numChannels,uint16_t wChannelVolumes [ ], |
| 120 | AUDDStreamEventCallback fCallback,void * pArg); |
| 121 | |
| 122 | extern void AUDDSpeakerPhone_Initialize( |
| 123 | AUDDSpeakerPhone * pAudf, |
| 124 | USBDDriver * pUsbd, |
| 125 | AUDDStream * pSpeaker,AUDDStream * pMicrophone); |
| 126 | |
| 127 | extern USBGenericDescriptor* AUDDSpeakerPhone_ParseInterfaces( |
| 128 | AUDDSpeakerPhone * pAudf, |
| 129 | USBGenericDescriptor * pDescriptors, |
| 130 | uint32_t dwLength); |
| 131 | |
| 132 | extern uint32_t AUDDSpeakerPhone_RequestHandler( |
| 133 | AUDDSpeakerPhone * pAudf, |
| 134 | const USBGenericRequest * pRequest); |
| 135 | |
| 136 | extern uint32_t AUDDSpeakerPhone_CloseStream( |
| 137 | AUDDSpeakerPhone * pAudf, |
| 138 | uint32_t bInterface); |
| 139 | |
| 140 | extern uint32_t AUDDSpeakerPhone_SetupWrite( |
| 141 | AUDDSpeakerPhone * pAudf, |
| 142 | void * pListInit, void * pDmaInit, uint16_t listSize, uint16_t delaySize, |
| 143 | TransferCallback callback,void * argument); |
| 144 | |
| 145 | extern uint32_t AUDDSpeakerPhone_Write( |
| 146 | AUDDSpeakerPhone * pAudf, |
| 147 | void * pBuffer,uint16_t wLength); |
| 148 | |
| 149 | extern uint32_t AUDDSpeakerPhone_Read( |
| 150 | AUDDSpeakerPhone * pAudf, |
| 151 | void * pData, uint32_t dwSize, |
| 152 | TransferCallback fCallback,void * pArg); |
| 153 | |
| 154 | /**@}*/ |
| 155 | #endif /* _AUDD_SPEAKERPHONE_H_ */ |
| 156 | |