| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2006-2012, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bape_playback.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/5 $ |
|---|
| 12 | * $brcm_Date: 2/8/12 11:52a $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: Audio Playback Interface |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/portinginterface/ape/7422/bape_playback.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/5 2/8/12 11:52a jgarrett |
|---|
| 21 | * SW7346-672: Adding support for changing the playback sample rate on the |
|---|
| 22 | * fly |
|---|
| 23 | * |
|---|
| 24 | * Hydra_Software_Devel/4 5/12/11 4:39p piyushg |
|---|
| 25 | * SW7425-401: Added PCM playback support for non-interleaved and |
|---|
| 26 | * multichannel data |
|---|
| 27 | * |
|---|
| 28 | * Hydra_Software_Devel/3 2/22/11 5:43p jgarrett |
|---|
| 29 | * SW7422-146: Implemented type renaming based on filter graph review |
|---|
| 30 | * comments |
|---|
| 31 | * |
|---|
| 32 | * Hydra_Software_Devel/2 12/17/10 3:58p jgarrett |
|---|
| 33 | * SW7422-146: Nexus APE integration on 7422 |
|---|
| 34 | * |
|---|
| 35 | * Hydra_Software_Devel/1 12/14/10 2:16p jgarrett |
|---|
| 36 | * SW7422-146: Adding initial API for APE/DSP |
|---|
| 37 | * |
|---|
| 38 | ***************************************************************************/ |
|---|
| 39 | |
|---|
| 40 | #ifndef BAPE_PLAYBACK_H_ |
|---|
| 41 | #define BAPE_PLAYBACK_H_ |
|---|
| 42 | |
|---|
| 43 | /*************************************************************************** |
|---|
| 44 | Summary: |
|---|
| 45 | Playback Handle |
|---|
| 46 | ***************************************************************************/ |
|---|
| 47 | typedef struct BAPE_Playback *BAPE_PlaybackHandle; |
|---|
| 48 | |
|---|
| 49 | /*************************************************************************** |
|---|
| 50 | Summary: |
|---|
| 51 | Playback Open settings |
|---|
| 52 | ***************************************************************************/ |
|---|
| 53 | typedef struct BAPE_PlaybackOpenSettings |
|---|
| 54 | { |
|---|
| 55 | unsigned numBuffers; /* Number of buffers to allocate. For mono or interleaved stereo, |
|---|
| 56 | one buffer is required. For non-interleaved 7.1 data 8 buffers |
|---|
| 57 | are required. For interleaved 7.1 data, 4 buffers are required. */ |
|---|
| 58 | unsigned bufferSize; /* Buffer size in bytes, must be a multiple of 256. If more than one |
|---|
| 59 | buffer is allocated, all buffers will be this size. If this size |
|---|
| 60 | is 0, buffers will be allocated from the internal buffer pool. */ |
|---|
| 61 | unsigned watermarkThreshold; /* FIFO interrupt threshold in bytes. |
|---|
| 62 | When an amuont <= this threshold is available, |
|---|
| 63 | an interrupt will be raised. This value should |
|---|
| 64 | be a multiple of 256. */ |
|---|
| 65 | } BAPE_PlaybackOpenSettings; |
|---|
| 66 | |
|---|
| 67 | /*************************************************************************** |
|---|
| 68 | Summary: |
|---|
| 69 | Get Default Playback Open Settings |
|---|
| 70 | ***************************************************************************/ |
|---|
| 71 | void BAPE_Playback_GetDefaultOpenSettings( |
|---|
| 72 | BAPE_PlaybackOpenSettings *pSettings |
|---|
| 73 | ); |
|---|
| 74 | |
|---|
| 75 | /*************************************************************************** |
|---|
| 76 | Summary: |
|---|
| 77 | Open a playback channel |
|---|
| 78 | ***************************************************************************/ |
|---|
| 79 | BERR_Code BAPE_Playback_Open( |
|---|
| 80 | BAPE_Handle deviceHandle, |
|---|
| 81 | unsigned index, |
|---|
| 82 | const BAPE_PlaybackOpenSettings *pSettings, |
|---|
| 83 | BAPE_PlaybackHandle *pHandle /* [out] */ |
|---|
| 84 | ); |
|---|
| 85 | |
|---|
| 86 | /*************************************************************************** |
|---|
| 87 | Summary: |
|---|
| 88 | Close a playback channel |
|---|
| 89 | ***************************************************************************/ |
|---|
| 90 | void BAPE_Playback_Close( |
|---|
| 91 | BAPE_PlaybackHandle handle |
|---|
| 92 | ); |
|---|
| 93 | |
|---|
| 94 | /*************************************************************************** |
|---|
| 95 | Summary: |
|---|
| 96 | Audio playback settings |
|---|
| 97 | ***************************************************************************/ |
|---|
| 98 | typedef struct BAPE_PlaybackSettings |
|---|
| 99 | { |
|---|
| 100 | BAPE_MultichannelFormat multichannelFormat; /* Controls whether the playback channel outputs 2.0, 5.1, or 7.1 data. |
|---|
| 101 | This is not changeable on the fly. */ |
|---|
| 102 | bool compressedData; /* If true, compressed data will be fed in IEC61937 format. |
|---|
| 103 | This is not changeable on the fly. Compressed data should be |
|---|
| 104 | fed as 16-bit stereo interleaved data. */ |
|---|
| 105 | unsigned sampleRate; /* Sample Rate in Hz. This is only used if BAPE_PlaybackStartSettings.sampleRate is |
|---|
| 106 | set to 0 and allows changing of the sampleRate on the fly to permit pitch-shifting, |
|---|
| 107 | or similar effects. */ |
|---|
| 108 | } BAPE_PlaybackSettings; |
|---|
| 109 | |
|---|
| 110 | /*************************************************************************** |
|---|
| 111 | Summary: |
|---|
| 112 | Get current audio playback settings |
|---|
| 113 | ***************************************************************************/ |
|---|
| 114 | void BAPE_Playback_GetSettings( |
|---|
| 115 | BAPE_PlaybackHandle handle, |
|---|
| 116 | BAPE_PlaybackSettings *pSettings /* [out] */ |
|---|
| 117 | ); |
|---|
| 118 | |
|---|
| 119 | /*************************************************************************** |
|---|
| 120 | Summary: |
|---|
| 121 | Set current audio playback settings |
|---|
| 122 | ***************************************************************************/ |
|---|
| 123 | BERR_Code BAPE_Playback_SetSettings( |
|---|
| 124 | BAPE_PlaybackHandle handle, |
|---|
| 125 | const BAPE_PlaybackSettings *pSettings |
|---|
| 126 | ); |
|---|
| 127 | |
|---|
| 128 | /*************************************************************************** |
|---|
| 129 | Summary: |
|---|
| 130 | Playback Start Settings |
|---|
| 131 | ***************************************************************************/ |
|---|
| 132 | typedef struct BAPE_PlaybackStartSettings |
|---|
| 133 | { |
|---|
| 134 | unsigned sampleRate; /* Sample Rate in Hz. If set to 0, the value from BAPE_PlaybackSettings.sampleRate will be used instead. */ |
|---|
| 135 | unsigned bitsPerSample; /* Supports 8, 16, or 32 */ |
|---|
| 136 | bool isStereo; /* If true, data will be treated as stereo. If false, data will be treated as mono. */ |
|---|
| 137 | bool isSigned; /* If true, data will be treated as signed. If false, data will be treated as unsigned. */ |
|---|
| 138 | bool reverseEndian; /* If true, data will be endian-swapped in hardware. Otherwise, data should match host endian mode. */ |
|---|
| 139 | bool loopEnabled; /* If true, data will loop continuously without requiring host intervention. */ |
|---|
| 140 | bool interleaved; /* If true, data for a channel pair is interleaved into a single buffer */ |
|---|
| 141 | unsigned startThreshold; /* Size in bytes that must be committed to the hardware before data will flow into the mixer. |
|---|
| 142 | Must be a multiple of 256. */ |
|---|
| 143 | } BAPE_PlaybackStartSettings; |
|---|
| 144 | |
|---|
| 145 | /*************************************************************************** |
|---|
| 146 | Summary: |
|---|
| 147 | Get Default Playback Start Settings |
|---|
| 148 | ***************************************************************************/ |
|---|
| 149 | void BAPE_Playback_GetDefaultStartSettings( |
|---|
| 150 | BAPE_PlaybackStartSettings *pSettings /* [out] */ |
|---|
| 151 | ); |
|---|
| 152 | |
|---|
| 153 | /*************************************************************************** |
|---|
| 154 | Summary: |
|---|
| 155 | Start Playback |
|---|
| 156 | ***************************************************************************/ |
|---|
| 157 | BERR_Code BAPE_Playback_Start( |
|---|
| 158 | BAPE_PlaybackHandle handle, |
|---|
| 159 | const BAPE_PlaybackStartSettings *pSettings |
|---|
| 160 | ); |
|---|
| 161 | |
|---|
| 162 | /*************************************************************************** |
|---|
| 163 | Summary: |
|---|
| 164 | Stop Playback |
|---|
| 165 | ***************************************************************************/ |
|---|
| 166 | void BAPE_Playback_Stop( |
|---|
| 167 | BAPE_PlaybackHandle handle |
|---|
| 168 | ); |
|---|
| 169 | |
|---|
| 170 | /*************************************************************************** |
|---|
| 171 | Summary: |
|---|
| 172 | Flush Playback Buffer |
|---|
| 173 | ***************************************************************************/ |
|---|
| 174 | void BAPE_Playback_Flush( |
|---|
| 175 | BAPE_PlaybackHandle handle |
|---|
| 176 | ); |
|---|
| 177 | |
|---|
| 178 | /*************************************************************************** |
|---|
| 179 | Summary: |
|---|
| 180 | Get Playback Buffer |
|---|
| 181 | |
|---|
| 182 | Description: |
|---|
| 183 | This routine will return the next contiguous buffer address and size. If |
|---|
| 184 | interrupts are enabled, the caller should call this routine and commit data |
|---|
| 185 | until the size returned from this function is zero. |
|---|
| 186 | ***************************************************************************/ |
|---|
| 187 | BERR_Code BAPE_Playback_GetBuffer( |
|---|
| 188 | BAPE_PlaybackHandle handle, |
|---|
| 189 | BAPE_BufferDescriptor *pBuffers /* [out] */ |
|---|
| 190 | ); |
|---|
| 191 | |
|---|
| 192 | /*************************************************************************** |
|---|
| 193 | Summary: |
|---|
| 194 | Commit Data to the playback hardware |
|---|
| 195 | ***************************************************************************/ |
|---|
| 196 | BERR_Code BAPE_Playback_CommitData( |
|---|
| 197 | BAPE_PlaybackHandle handle, |
|---|
| 198 | unsigned numBytes /* Number of bytes written into the buffer */ |
|---|
| 199 | ); |
|---|
| 200 | |
|---|
| 201 | /*************************************************************************** |
|---|
| 202 | Summary: |
|---|
| 203 | Playback Status |
|---|
| 204 | ***************************************************************************/ |
|---|
| 205 | typedef struct BAPE_PlaybackStatus |
|---|
| 206 | { |
|---|
| 207 | unsigned queuedBytes; |
|---|
| 208 | unsigned fifoSize; |
|---|
| 209 | } BAPE_PlaybackStatus; |
|---|
| 210 | |
|---|
| 211 | /*************************************************************************** |
|---|
| 212 | Summary: |
|---|
| 213 | Get Playback Status |
|---|
| 214 | ***************************************************************************/ |
|---|
| 215 | void BAPE_Playback_GetStatus( |
|---|
| 216 | BAPE_PlaybackHandle handle, |
|---|
| 217 | BAPE_PlaybackStatus *pStatus /* [out] */ |
|---|
| 218 | ); |
|---|
| 219 | |
|---|
| 220 | /*************************************************************************** |
|---|
| 221 | Summary: |
|---|
| 222 | Get Audio Source Connector for output data |
|---|
| 223 | ***************************************************************************/ |
|---|
| 224 | void BAPE_Playback_GetConnector( |
|---|
| 225 | BAPE_PlaybackHandle handle, |
|---|
| 226 | BAPE_Connector *pConnector /* [out] */ |
|---|
| 227 | ); |
|---|
| 228 | |
|---|
| 229 | /*************************************************************************** |
|---|
| 230 | Summary: |
|---|
| 231 | Playback Interrupt Handlers |
|---|
| 232 | ***************************************************************************/ |
|---|
| 233 | typedef struct BAPE_PlaybackInterruptHandlers |
|---|
| 234 | { |
|---|
| 235 | struct |
|---|
| 236 | { |
|---|
| 237 | void (*pCallback_isr)(void *pParam1, int param2); |
|---|
| 238 | void *pParam1; |
|---|
| 239 | int param2; |
|---|
| 240 | } watermark; |
|---|
| 241 | } BAPE_PlaybackInterruptHandlers; |
|---|
| 242 | |
|---|
| 243 | /*************************************************************************** |
|---|
| 244 | Summary: |
|---|
| 245 | Get Playback Interrupt Handlers |
|---|
| 246 | ***************************************************************************/ |
|---|
| 247 | void BAPE_Playback_GetInterruptHandlers( |
|---|
| 248 | BAPE_PlaybackHandle handle, |
|---|
| 249 | BAPE_PlaybackInterruptHandlers *pInterrupts /* [out] */ |
|---|
| 250 | ); |
|---|
| 251 | |
|---|
| 252 | /*************************************************************************** |
|---|
| 253 | Summary: |
|---|
| 254 | Set Playback Interrupt Handlers |
|---|
| 255 | ***************************************************************************/ |
|---|
| 256 | BERR_Code BAPE_Playback_SetInterruptHandlers( |
|---|
| 257 | BAPE_PlaybackHandle handle, |
|---|
| 258 | const BAPE_PlaybackInterruptHandlers *pInterrupts |
|---|
| 259 | ); |
|---|
| 260 | |
|---|
| 261 | #endif /* #ifndef BAPE_PLAYBACK_H_ */ |
|---|
| 262 | |
|---|