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 Device Streaming interface with controls. |
| 32 | * (3 channels (including master) supported). |
| 33 | */ |
| 34 | |
| 35 | /** \addtogroup usbd_audio_speakerphone |
| 36 | *@{ |
| 37 | * Implement speakerphone function that combine 1 AC interface, 1 AS interface |
| 38 | * for speaker and 1 AS interface for microphone. |
| 39 | */ |
| 40 | |
| 41 | #ifndef _AUDD_STREAM_H_ |
| 42 | #define _AUDD_STREAM_H_ |
| 43 | |
| 44 | /*------------------------------------------------------------------------------ |
| 45 | * Headers |
| 46 | *------------------------------------------------------------------------------*/ |
| 47 | |
| 48 | #include <stdint.h> |
| 49 | |
| 50 | #include <USBD.h> |
| 51 | #include <USBDDriver.h> |
| 52 | |
| 53 | /*------------------------------------------------------------------------------ |
| 54 | * Defines |
| 55 | *------------------------------------------------------------------------------*/ |
| 56 | |
| 57 | /** \addtopage usbd_audio_ec Audio Device Event codes |
| 58 | * @{ |
| 59 | */ |
| 60 | /** Mute status changed */ |
| 61 | #define AUDD_EC_MuteChanged 1 |
| 62 | /** Volume status changed */ |
| 63 | #define AUDD_EC_VolumeChanged 2 |
| 64 | /** @}*/ |
| 65 | |
| 66 | /*------------------------------------------------------------------------------ |
| 67 | * Types |
| 68 | *------------------------------------------------------------------------------*/ |
| 69 | |
| 70 | /** Callback function for Audio Stream Event */ |
| 71 | typedef void (*AUDDStreamEventCallback)(uint32_t ec, |
| 72 | uint8_t channel, |
| 73 | void* pArg); |
| 74 | |
| 75 | /** |
| 76 | * Struct of USB Audio Stream Interface. |
| 77 | * Support 1 control interface, with I & O stream. |
| 78 | * Unit ID 0xFF is reserved for not implemented. |
| 79 | */ |
| 80 | typedef struct _AUDDStream { |
| 81 | /** AudioControl Interface number */ |
| 82 | uint8_t bAcInterface; |
| 83 | /** AudioControl Feature Unit ID for IN */ |
| 84 | uint8_t bFeatureUnitOut; |
| 85 | /** AudioControl Feature Unit ID for OUT */ |
| 86 | uint8_t bFeatureUnitIn; |
| 87 | /** AudioStreaming Interface number */ |
| 88 | uint8_t bAsInterface; |
| 89 | /** Streaming OUT endpoint address */ |
| 90 | uint8_t bEndpointOut; |
| 91 | /** Streaming IN endpoint address */ |
| 92 | uint8_t bEndpointIn; |
| 93 | /** Number of channels (<=8) */ |
| 94 | uint8_t bNumChannels; |
| 95 | /** Mute control bits (8b) */ |
| 96 | uint8_t bmMute; |
| 97 | /** Volume control data */ |
| 98 | uint16_t *pwVolumes; |
| 99 | |
| 100 | /** Audio Streaming Events Callback */ |
| 101 | AUDDStreamEventCallback fCallback; |
| 102 | /** Callback arguments */ |
| 103 | void* pArg; |
| 104 | } AUDDStream; |
| 105 | |
| 106 | /*------------------------------------------------------------------------------ |
| 107 | * Functions |
| 108 | *------------------------------------------------------------------------------*/ |
| 109 | |
| 110 | extern void AUDDStream_Initialize( |
| 111 | AUDDStream * pAuds, |
| 112 | uint8_t numChannels, |
| 113 | uint16_t wChannelVolumes [ ], |
| 114 | AUDDStreamEventCallback fCallback, |
| 115 | void * pArg); |
| 116 | |
| 117 | extern uint32_t AUDDStream_ChangeMute( |
| 118 | AUDDStream * pAuds, |
| 119 | uint8_t bChannel, |
| 120 | uint8_t bMute); |
| 121 | |
| 122 | extern uint32_t AUDDStream_SetVolume( |
| 123 | AUDDStream * pAuds, |
| 124 | uint8_t bChannel, |
| 125 | uint16_t wVolume); |
| 126 | |
| 127 | extern uint32_t AUDDStream_IsRequestAccepted( |
| 128 | AUDDStream *pAuds, |
| 129 | const USBGenericRequest *pReq); |
| 130 | |
| 131 | extern uint32_t AUDDStream_Read( |
| 132 | AUDDStream * pAuds, |
| 133 | void * pData, uint32_t dwSize, |
| 134 | TransferCallback fCallback,void * pArg); |
| 135 | |
| 136 | extern uint32_t AUDDStream_SetupWrite( |
| 137 | AUDDStream * pAuds, |
| 138 | void * pListInit, void * pDmaInit, uint16_t listSize, |
| 139 | uint16_t delaySize, |
| 140 | TransferCallback callback,void * argument); |
| 141 | |
| 142 | extern uint32_t AUDDStream_Write( |
| 143 | AUDDStream * pAuds, |
| 144 | void * pBuffer,uint16_t wLength); |
| 145 | |
| 146 | extern uint32_t AUDDStream_Close(AUDDStream * pStream); |
| 147 | |
| 148 | #endif /* _AUDD_STREAM_H_ */ |
| 149 | |