| 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: bdsp.c $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/5 $ |
|---|
| 12 | * $brcm_Date: 2/22/12 7:21p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: Host DSP Interface |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/basemodules/dsp/common/bdsp.c $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/5 2/22/12 7:21p ashoky |
|---|
| 21 | * SW7231-585: Adding APIs to expose interrupt bits to interrupt DSP. |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/4 7/4/11 6:35p gprasad |
|---|
| 24 | * SW7422-373: Add GetInfo routines for AudioType, AudioProcessing, and |
|---|
| 25 | * AudioEncode in BDSP |
|---|
| 26 | * |
|---|
| 27 | * Hydra_Software_Devel/3 6/17/11 3:49p gautamk |
|---|
| 28 | * SW7422-373: [7422] Adding GetInfo routines for AudioType, |
|---|
| 29 | * AudioProcessing, and AudioEncode support in BDSP |
|---|
| 30 | * |
|---|
| 31 | * Hydra_Software_Devel/2 6/15/11 5:47p gautamk |
|---|
| 32 | * SW7425-683: [7425] Adding support for Power management in BDSP |
|---|
| 33 | * |
|---|
| 34 | * Hydra_Software_Devel/1 4/6/11 2:15p srajapur |
|---|
| 35 | * SW7425-291: [7425]BDSP directory structure changes |
|---|
| 36 | * |
|---|
| 37 | * Hydra_Software_Devel/3 1/13/11 5:55a gautamk |
|---|
| 38 | * SW7422-191:[7422]Adding DSP support for Audio decode in Basemodule It |
|---|
| 39 | * includes - DSP Booting - Open time Download : - Start Time Audio |
|---|
| 40 | * Decode algorithm download - Message buffer interaction with DSP: - |
|---|
| 41 | * Synchronized Interrupt: - Async interrupts: - Config Commands for |
|---|
| 42 | * Decode/TSM/IDS: - Status Buffer for Decode/TSM/IDS: - Start AC3 Audio |
|---|
| 43 | * Decode: - Pause/Resume Command: - Frame Advance command: - Device |
|---|
| 44 | * level interrupt |
|---|
| 45 | * |
|---|
| 46 | * Hydra_Software_Devel/2 12/15/10 6:47p jgarrett |
|---|
| 47 | * SW7422-146: Initial compileable prototype |
|---|
| 48 | * |
|---|
| 49 | * Hydra_Software_Devel/1 12/15/10 2:00p jgarrett |
|---|
| 50 | * SW7422-146: Adding initial BDSP files |
|---|
| 51 | * |
|---|
| 52 | ***************************************************************************/ |
|---|
| 53 | |
|---|
| 54 | #include "bdsp.h" |
|---|
| 55 | #include "bdsp_priv.h" |
|---|
| 56 | |
|---|
| 57 | BDBG_MODULE(bdsp); |
|---|
| 58 | |
|---|
| 59 | void BDSP_Close( |
|---|
| 60 | BDSP_Handle handle /* Handle to be closed */ |
|---|
| 61 | ) |
|---|
| 62 | { |
|---|
| 63 | BDBG_OBJECT_ASSERT(handle, BDSP_Device); |
|---|
| 64 | BDBG_ASSERT(NULL != handle->close); |
|---|
| 65 | handle->close(handle->pDeviceHandle); |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | void BDSP_GetStatus( |
|---|
| 69 | BDSP_Handle handle, |
|---|
| 70 | BDSP_Status *pStatus /* [out] Current Status */ |
|---|
| 71 | ) |
|---|
| 72 | { |
|---|
| 73 | |
|---|
| 74 | BDBG_OBJECT_ASSERT(handle, BDSP_Device); |
|---|
| 75 | |
|---|
| 76 | if ( handle->getStatus ) |
|---|
| 77 | { |
|---|
| 78 | handle->getStatus(handle->pDeviceHandle, pStatus); |
|---|
| 79 | } |
|---|
| 80 | else |
|---|
| 81 | { |
|---|
| 82 | BKNI_Memset(pStatus, 0, sizeof(BDSP_Status)); |
|---|
| 83 | } |
|---|
| 84 | return; |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | BERR_Code BDSP_GetDebugLog( |
|---|
| 88 | BDSP_Handle handle, |
|---|
| 89 | char *pBuffer, |
|---|
| 90 | size_t bufferLength |
|---|
| 91 | ) |
|---|
| 92 | { |
|---|
| 93 | BDBG_OBJECT_ASSERT(handle, BDSP_Device); |
|---|
| 94 | if ( handle->getDebugLog ) |
|---|
| 95 | { |
|---|
| 96 | return handle->getDebugLog(handle->pDeviceHandle, pBuffer, bufferLength); |
|---|
| 97 | } |
|---|
| 98 | else |
|---|
| 99 | { |
|---|
| 100 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 101 | } |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | BERR_Code BDSP_Standby( |
|---|
| 105 | BDSP_Handle handle, /* [in] DSP device handle */ |
|---|
| 106 | BDSP_StandbySettings *pSettings /* [in] standby settings */ |
|---|
| 107 | ) |
|---|
| 108 | { |
|---|
| 109 | |
|---|
| 110 | BDBG_OBJECT_ASSERT(handle, BDSP_Device); |
|---|
| 111 | |
|---|
| 112 | if ( handle->powerStandby) |
|---|
| 113 | { |
|---|
| 114 | handle->powerStandby(handle->pDeviceHandle, pSettings); |
|---|
| 115 | } |
|---|
| 116 | else |
|---|
| 117 | { |
|---|
| 118 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 119 | } |
|---|
| 120 | return BERR_SUCCESS; |
|---|
| 121 | } |
|---|
| 122 | |
|---|
| 123 | BERR_Code BDSP_Resume( |
|---|
| 124 | BDSP_Handle handle /* [in] DSP device handle */ |
|---|
| 125 | ) |
|---|
| 126 | { |
|---|
| 127 | |
|---|
| 128 | BDBG_OBJECT_ASSERT(handle, BDSP_Device); |
|---|
| 129 | |
|---|
| 130 | if ( handle->powerResume) |
|---|
| 131 | { |
|---|
| 132 | handle->powerResume(handle->pDeviceHandle); |
|---|
| 133 | } |
|---|
| 134 | else |
|---|
| 135 | { |
|---|
| 136 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 137 | } |
|---|
| 138 | return BERR_SUCCESS; |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | BERR_Code BDSP_GetAudioTypeInfo( |
|---|
| 142 | BDSP_Handle handle, |
|---|
| 143 | BDSP_AudioType type, /* [in] */ |
|---|
| 144 | const BDSP_AudioTypeInfo **pInfo /* [out] */ |
|---|
| 145 | ) |
|---|
| 146 | { |
|---|
| 147 | |
|---|
| 148 | BDBG_OBJECT_ASSERT(handle, BDSP_Device); |
|---|
| 149 | |
|---|
| 150 | if ( handle->getAudioTypeInfo) |
|---|
| 151 | { |
|---|
| 152 | handle->getAudioTypeInfo(type, pInfo); |
|---|
| 153 | } |
|---|
| 154 | else |
|---|
| 155 | { |
|---|
| 156 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 157 | } |
|---|
| 158 | return BERR_SUCCESS; |
|---|
| 159 | } |
|---|
| 160 | |
|---|
| 161 | BERR_Code BDSP_GetAudioProcessingInfo( |
|---|
| 162 | BDSP_Handle handle, |
|---|
| 163 | BDSP_AudioProcessing type, /* [in] */ |
|---|
| 164 | const BDSP_AudioProcessingInfo **pInfo /* [out] */ |
|---|
| 165 | ) |
|---|
| 166 | { |
|---|
| 167 | |
|---|
| 168 | BDBG_OBJECT_ASSERT(handle, BDSP_Device); |
|---|
| 169 | |
|---|
| 170 | if ( handle->getAudioProcessingInfo) |
|---|
| 171 | { |
|---|
| 172 | handle->getAudioProcessingInfo(type, pInfo); |
|---|
| 173 | } |
|---|
| 174 | else |
|---|
| 175 | { |
|---|
| 176 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 177 | } |
|---|
| 178 | return BERR_SUCCESS; |
|---|
| 179 | } |
|---|
| 180 | |
|---|
| 181 | |
|---|
| 182 | BERR_Code BDSP_GetAudioEncodeInfo( |
|---|
| 183 | BDSP_Handle handle, |
|---|
| 184 | BDSP_AudioEncode type, /* [in] */ |
|---|
| 185 | const BDSP_AudioEncodeInfo **pInfo /* [out] */ |
|---|
| 186 | ) |
|---|
| 187 | { |
|---|
| 188 | |
|---|
| 189 | BDBG_OBJECT_ASSERT(handle, BDSP_Device); |
|---|
| 190 | |
|---|
| 191 | if ( handle->getAudioEncodeInfo) |
|---|
| 192 | { |
|---|
| 193 | handle->getAudioEncodeInfo(type, pInfo); |
|---|
| 194 | } |
|---|
| 195 | else |
|---|
| 196 | { |
|---|
| 197 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 198 | } |
|---|
| 199 | return BERR_SUCCESS; |
|---|
| 200 | } |
|---|
| 201 | |
|---|
| 202 | |
|---|
| 203 | /*************************************************************************** |
|---|
| 204 | Summary: |
|---|
| 205 | Allocate an external interrupt. |
|---|
| 206 | |
|---|
| 207 | Description: |
|---|
| 208 | This function allocates one interrupt handle that can be used to interrupt DSP. |
|---|
| 209 | |
|---|
| 210 | Returns: |
|---|
| 211 | BERR_SUCCESS - If allocation is successful, otherwise error |
|---|
| 212 | |
|---|
| 213 | See Also: |
|---|
| 214 | BDSP_FreeExternalInterrupt |
|---|
| 215 | BDSP_GetExternalInterruptInfo |
|---|
| 216 | ***************************************************************************/ |
|---|
| 217 | BERR_Code BDSP_AllocateExternalInterrupt( |
|---|
| 218 | BDSP_Handle hDsp, |
|---|
| 219 | uint32_t dspIndex, |
|---|
| 220 | BDSP_ExternalInterruptHandle *pInterruptHandle /* [out] */ |
|---|
| 221 | ) |
|---|
| 222 | { |
|---|
| 223 | BERR_Code ErrCode = BERR_SUCCESS; |
|---|
| 224 | BDBG_OBJECT_ASSERT(hDsp, BDSP_Device); |
|---|
| 225 | |
|---|
| 226 | if ( hDsp->allocateExternalInterrupt) |
|---|
| 227 | { |
|---|
| 228 | ErrCode = hDsp->allocateExternalInterrupt(hDsp->pDeviceHandle, dspIndex, pInterruptHandle); |
|---|
| 229 | } |
|---|
| 230 | else |
|---|
| 231 | { |
|---|
| 232 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 233 | } |
|---|
| 234 | return ErrCode; |
|---|
| 235 | } |
|---|
| 236 | |
|---|
| 237 | |
|---|
| 238 | /*************************************************************************** |
|---|
| 239 | Summary: |
|---|
| 240 | Frees an allocated external interrupt. |
|---|
| 241 | |
|---|
| 242 | Description: |
|---|
| 243 | This function frees one interrupt handle that was already allocated. |
|---|
| 244 | |
|---|
| 245 | Returns: |
|---|
| 246 | BERR_SUCCESS if sucessful else error |
|---|
| 247 | |
|---|
| 248 | See Also: |
|---|
| 249 | BDSP_AllocateExternalInterrupt |
|---|
| 250 | BDSP_GetExternalInterruptInfo |
|---|
| 251 | ***************************************************************************/ |
|---|
| 252 | BERR_Code BDSP_FreeExternalInterrupt( |
|---|
| 253 | BDSP_ExternalInterruptHandle hInterrupt |
|---|
| 254 | ) |
|---|
| 255 | { |
|---|
| 256 | BDSP_Handle handle; |
|---|
| 257 | BERR_Code ErrCode = BERR_SUCCESS; |
|---|
| 258 | |
|---|
| 259 | BDBG_OBJECT_ASSERT(hInterrupt, BDSP_ExternalInterrupt); |
|---|
| 260 | |
|---|
| 261 | handle = hInterrupt->hDsp; |
|---|
| 262 | |
|---|
| 263 | if(handle->freeExternalInterrupt) |
|---|
| 264 | { |
|---|
| 265 | ErrCode = handle->freeExternalInterrupt(hInterrupt->pExtInterruptHandle); |
|---|
| 266 | } |
|---|
| 267 | else |
|---|
| 268 | { |
|---|
| 269 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 270 | } |
|---|
| 271 | |
|---|
| 272 | return ErrCode; |
|---|
| 273 | } |
|---|
| 274 | |
|---|
| 275 | /*************************************************************************** |
|---|
| 276 | Summary: |
|---|
| 277 | Retrieve external interrupt information. |
|---|
| 278 | |
|---|
| 279 | Description: |
|---|
| 280 | This function provides the interrupt register and the bit that can be used to interrupt DSP. |
|---|
| 281 | |
|---|
| 282 | Returns: |
|---|
| 283 | BERR_SUCCESS - If successful, otherwise error |
|---|
| 284 | |
|---|
| 285 | See Also: |
|---|
| 286 | BDSP_FreeExternalInterrupt |
|---|
| 287 | BDSP_AllocateExternalInterrupt |
|---|
| 288 | ***************************************************************************/ |
|---|
| 289 | BERR_Code BDSP_GetExternalInterruptInfo( |
|---|
| 290 | BDSP_ExternalInterruptHandle hInterrupt, |
|---|
| 291 | BDSP_ExternalInterruptInfo **pInfo /* [out] */ |
|---|
| 292 | ) |
|---|
| 293 | { |
|---|
| 294 | BDSP_Handle handle; |
|---|
| 295 | BERR_Code ErrCode = BERR_SUCCESS; |
|---|
| 296 | |
|---|
| 297 | BDBG_OBJECT_ASSERT(hInterrupt, BDSP_ExternalInterrupt); |
|---|
| 298 | |
|---|
| 299 | handle = hInterrupt->hDsp; |
|---|
| 300 | |
|---|
| 301 | if(handle->getExternalInterruptInfo) |
|---|
| 302 | { |
|---|
| 303 | ErrCode = handle->getExternalInterruptInfo(hInterrupt->pExtInterruptHandle, pInfo); |
|---|
| 304 | } |
|---|
| 305 | else |
|---|
| 306 | { |
|---|
| 307 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 308 | } |
|---|
| 309 | |
|---|
| 310 | return ErrCode; |
|---|
| 311 | |
|---|
| 312 | } |
|---|
| 313 | |
|---|
| 314 | /*************************************************************************** |
|---|
| 315 | Summary: |
|---|
| 316 | Allocate RDB registers from dsp page for upper SW layer |
|---|
| 317 | |
|---|
| 318 | Description: |
|---|
| 319 | This function allocates RDB registers handle that can be used to send msg etc to DSP. |
|---|
| 320 | |
|---|
| 321 | Returns: |
|---|
| 322 | BERR_SUCCESS - If allocation is successful, otherwise error |
|---|
| 323 | |
|---|
| 324 | See Also: |
|---|
| 325 | BDSP_FreeRdbRegisters |
|---|
| 326 | BDSP_GetRdbRegistersInfo |
|---|
| 327 | ***************************************************************************/ |
|---|
| 328 | BERR_Code BDSP_AllocateRdbRegisters( |
|---|
| 329 | BDSP_Handle hDsp, |
|---|
| 330 | uint32_t dspIndex, |
|---|
| 331 | uint32_t numRdbToAllocate, |
|---|
| 332 | BDSP_RdbRegisterHandle *pRdbRegisterHandle /* [out] */ |
|---|
| 333 | ) |
|---|
| 334 | { |
|---|
| 335 | BERR_Code ErrCode = BERR_SUCCESS; |
|---|
| 336 | BDBG_OBJECT_ASSERT(hDsp, BDSP_Device); |
|---|
| 337 | |
|---|
| 338 | if ( hDsp->allocateRdbRegister) |
|---|
| 339 | { |
|---|
| 340 | ErrCode = hDsp->allocateRdbRegister(hDsp->pDeviceHandle, dspIndex, numRdbToAllocate, pRdbRegisterHandle); |
|---|
| 341 | } |
|---|
| 342 | else |
|---|
| 343 | { |
|---|
| 344 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 345 | } |
|---|
| 346 | return ErrCode; |
|---|
| 347 | } |
|---|
| 348 | |
|---|
| 349 | |
|---|
| 350 | /*************************************************************************** |
|---|
| 351 | Summary: |
|---|
| 352 | Frees an allocated Rdb Registers handle. |
|---|
| 353 | |
|---|
| 354 | Description: |
|---|
| 355 | This function frees an Rdb Registers handle that was already allocated. |
|---|
| 356 | |
|---|
| 357 | Returns: |
|---|
| 358 | BERR_SUCCESS if sucessful else error |
|---|
| 359 | |
|---|
| 360 | See Also: |
|---|
| 361 | BDSP_AllocateRdbRegisters |
|---|
| 362 | BDSP_GetRdbRegistersInfo |
|---|
| 363 | ***************************************************************************/ |
|---|
| 364 | BERR_Code BDSP_FreeRdbRegisters( |
|---|
| 365 | BDSP_RdbRegisterHandle hRdbRegister |
|---|
| 366 | ) |
|---|
| 367 | { |
|---|
| 368 | BDSP_Handle handle; |
|---|
| 369 | BERR_Code ErrCode = BERR_SUCCESS; |
|---|
| 370 | |
|---|
| 371 | BDBG_OBJECT_ASSERT(hRdbRegister, BDSP_RdbRegister); |
|---|
| 372 | |
|---|
| 373 | handle = hRdbRegister->hDsp; |
|---|
| 374 | |
|---|
| 375 | if(handle->freeRdbRegister) |
|---|
| 376 | { |
|---|
| 377 | ErrCode = handle->freeRdbRegister(hRdbRegister->pRdbRegisterHandle); |
|---|
| 378 | } |
|---|
| 379 | else |
|---|
| 380 | { |
|---|
| 381 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 382 | } |
|---|
| 383 | |
|---|
| 384 | return ErrCode; |
|---|
| 385 | } |
|---|
| 386 | |
|---|
| 387 | /*************************************************************************** |
|---|
| 388 | Summary: |
|---|
| 389 | Retrieve Rdb Registers information. |
|---|
| 390 | |
|---|
| 391 | Description: |
|---|
| 392 | This function provides the address (offset) of base RDB register. |
|---|
| 393 | |
|---|
| 394 | Returns: |
|---|
| 395 | BERR_SUCCESS - If successful, otherwise error |
|---|
| 396 | |
|---|
| 397 | See Also: |
|---|
| 398 | BDSP_FreeRdbRegisters |
|---|
| 399 | BDSP_AllocateRdbRegisters |
|---|
| 400 | ***************************************************************************/ |
|---|
| 401 | BERR_Code BDSP_GetRdbRegistersInfo( |
|---|
| 402 | BDSP_RdbRegisterHandle hRdbRegister, |
|---|
| 403 | BDSP_RdbRegisterInfo **pInfo /* [out] */ |
|---|
| 404 | ) |
|---|
| 405 | { |
|---|
| 406 | BDSP_Handle handle; |
|---|
| 407 | BERR_Code ErrCode = BERR_SUCCESS; |
|---|
| 408 | |
|---|
| 409 | BDBG_OBJECT_ASSERT(hRdbRegister, BDSP_RdbRegister); |
|---|
| 410 | |
|---|
| 411 | handle = hRdbRegister->hDsp; |
|---|
| 412 | |
|---|
| 413 | if(handle->getRdbRegisterInfo) |
|---|
| 414 | { |
|---|
| 415 | ErrCode = handle->getRdbRegisterInfo(hRdbRegister->pRdbRegisterHandle, pInfo); |
|---|
| 416 | } |
|---|
| 417 | else |
|---|
| 418 | { |
|---|
| 419 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 420 | } |
|---|
| 421 | |
|---|
| 422 | return ErrCode; |
|---|
| 423 | |
|---|
| 424 | } |
|---|
| 425 | |
|---|
| 426 | |
|---|