| 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_raaga.c $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/17 $ |
|---|
| 12 | * $brcm_Date: 2/22/12 7:25p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: Host DSP Interface |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/basemodules/dsp/raaga/api/bdsp_raaga.c $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/17 2/22/12 7:25p ashoky |
|---|
| 21 | * SW7231-585: Adding APIs to expose interrupt bits to interrupt DSP. |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/16 12/5/11 5:50p rshijith |
|---|
| 24 | * FWRAA-365 :Disabling target print by default. |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/15 12/5/11 5:41p rshijith |
|---|
| 27 | * FWRAA-365 : Adding Target print support to raaga subsystem. |
|---|
| 28 | * |
|---|
| 29 | * Hydra_Software_Devel/14 11/10/11 11:06a gprasad |
|---|
| 30 | * SW7422-400: Please add hooks to support dumping the UART debug buffer |
|---|
| 31 | * into DRAM |
|---|
| 32 | * |
|---|
| 33 | * Hydra_Software_Devel/13 10/20/11 5:43p gprasad |
|---|
| 34 | * FWRAA-359: Add support for ring buffer capture for cert testing |
|---|
| 35 | * |
|---|
| 36 | * Hydra_Software_Devel/12 8/25/11 4:05p gprasad |
|---|
| 37 | * SW7422-400: Updating the APIs with review comments |
|---|
| 38 | * |
|---|
| 39 | * Hydra_Software_Devel/11 8/18/11 12:53p gprasad |
|---|
| 40 | * SW7422-400: Updating the APIs with review comments |
|---|
| 41 | * |
|---|
| 42 | * Hydra_Software_Devel/10 7/4/11 6:34p gprasad |
|---|
| 43 | * SW7422-400: Please add hooks to support dumping the UART debug buffer |
|---|
| 44 | * into DRAM |
|---|
| 45 | * |
|---|
| 46 | * Hydra_Software_Devel/9 6/17/11 3:41p gautamk |
|---|
| 47 | * SW7422-373: [7422] Adding GetInfo routines for AudioType, |
|---|
| 48 | * AudioProcessing, and AudioEncode support in BDSP |
|---|
| 49 | * |
|---|
| 50 | * Hydra_Software_Devel/8 6/15/11 5:53p gautamk |
|---|
| 51 | * SW7425-683: [7425] Adding support for Power management in BDSP |
|---|
| 52 | * |
|---|
| 53 | * Hydra_Software_Devel/7 5/19/11 10:19a srajapur |
|---|
| 54 | * SW7231-145 : [7231] Adding BCHP_PWR support to BDSP |
|---|
| 55 | * |
|---|
| 56 | * Hydra_Software_Devel/6 5/11/11 5:30p srajapur |
|---|
| 57 | * SW7422-374 : [7425] Incorporate changes to BDSP "details" structures |
|---|
| 58 | * from code review feedback. |
|---|
| 59 | * |
|---|
| 60 | * Hydra_Software_Devel/5 4/29/11 11:45a srajapur |
|---|
| 61 | * SW7422-368 : [7422] BDSP_AudioTask_GetDefaultXxxSettings is Raaga- |
|---|
| 62 | * specific ---------> Moved raaga specific API from common files to |
|---|
| 63 | * raaga files and renamed the API's accordingly. |
|---|
| 64 | * |
|---|
| 65 | * Hydra_Software_Devel/4 4/27/11 5:08p srajapur |
|---|
| 66 | * SW7422-419 : [7425] Added BDSP_Raaga_GetDownloadStatus and |
|---|
| 67 | * BDSP_Raaga_Initialize API to support authentication |
|---|
| 68 | * |
|---|
| 69 | * Hydra_Software_Devel/3 4/14/11 6:52p srajapur |
|---|
| 70 | * SW7425-291: [7425] BDSP directory structure changes |
|---|
| 71 | * |
|---|
| 72 | * Hydra_Software_Devel/2 4/12/11 2:24p srajapur |
|---|
| 73 | * SW7422-419:[7425]Adding BDSP_Raaga_GetFwDwnldInfo and |
|---|
| 74 | * BDSP_Raaga_StartDsp API to support authentication |
|---|
| 75 | * |
|---|
| 76 | * Hydra_Software_Devel/1 4/6/11 2:27p srajapur |
|---|
| 77 | * SW7425-291: [7425]BDSP directory structure changes |
|---|
| 78 | * |
|---|
| 79 | * Hydra_Software_Devel/9 3/24/11 5:25p jgarrett |
|---|
| 80 | * SW7422-146: Fixes for kernel mode and big endian |
|---|
| 81 | * |
|---|
| 82 | * Hydra_Software_Devel/8 1/26/11 3:17a gautamk |
|---|
| 83 | * SW7422-191: Allocating FW debug buffer on basis of runtime Parrameter |
|---|
| 84 | * enableDebugLog of BDSP_RaagaSettings. |
|---|
| 85 | * |
|---|
| 86 | * Hydra_Software_Devel/7 1/25/11 2:22a gautamk |
|---|
| 87 | * SW7422-191:Adding error recovery code for Raaga Open |
|---|
| 88 | * |
|---|
| 89 | * Hydra_Software_Devel/6 1/20/11 8:09a gautamk |
|---|
| 90 | * SW7422-191: Implementing code review comments |
|---|
| 91 | * |
|---|
| 92 | * Hydra_Software_Devel/5 1/19/11 7:13a gautamk |
|---|
| 93 | * SW7422-191: Various DSP Basmodules features and review comment |
|---|
| 94 | * implementation |
|---|
| 95 | * |
|---|
| 96 | * Hydra_Software_Devel/4 1/18/11 4:22a gautamk |
|---|
| 97 | * SW7125-766: Added code for review comments. |
|---|
| 98 | * |
|---|
| 99 | * Hydra_Software_Devel/3 1/13/11 5:26a gautamk |
|---|
| 100 | * SW7422-191:[7422]Adding DSP support for Audio decode in Basemodule It |
|---|
| 101 | * includes - DSP Booting - Open time Download : - Start Time Audio |
|---|
| 102 | * Decode algorithm download - Message buffer interaction with DSP: - |
|---|
| 103 | * Synchronized Interrupt: - Async interrupts: - Config Commands for |
|---|
| 104 | * Decode/TSM/IDS: - Status Buffer for Decode/TSM/IDS: - Start AC3 Audio |
|---|
| 105 | * Decode: - Pause/Resume Command: - Frame Advance command: - Device |
|---|
| 106 | * level interrupt |
|---|
| 107 | * |
|---|
| 108 | * Hydra_Software_Devel/2 12/15/10 6:47p jgarrett |
|---|
| 109 | * SW7422-146: Initial compileable prototype |
|---|
| 110 | * |
|---|
| 111 | * Hydra_Software_Devel/1 12/15/10 2:01p jgarrett |
|---|
| 112 | * SW7422-146: Adding initial BDSP files |
|---|
| 113 | * |
|---|
| 114 | ***************************************************************************/ |
|---|
| 115 | |
|---|
| 116 | #include "bdsp.h" |
|---|
| 117 | #include "bdsp_priv.h" |
|---|
| 118 | #include "bdsp_raaga.h" |
|---|
| 119 | #include "bdsp_raaga_priv.h" |
|---|
| 120 | |
|---|
| 121 | #if BCHP_PWR_SUPPORT |
|---|
| 122 | #include "bchp_pwr.h" |
|---|
| 123 | #endif |
|---|
| 124 | |
|---|
| 125 | BDBG_MODULE(bdsp_raaga); |
|---|
| 126 | |
|---|
| 127 | #ifdef BDSP_FW_RBUF_CAPTURE |
|---|
| 128 | /* Settings for Firmware Ring Buffer Capture.Initialized in BRAP_RB_CBSetup() */ |
|---|
| 129 | BDSP_P_RbufCapture Rbuf_Setting = { NULL, NULL, NULL, NULL }; |
|---|
| 130 | #endif |
|---|
| 131 | |
|---|
| 132 | void BDSP_Raaga_GetDefaultSettings( |
|---|
| 133 | BDSP_RaagaSettings *pSettings /* [out] */ |
|---|
| 134 | ) |
|---|
| 135 | { |
|---|
| 136 | BDBG_ASSERT(NULL != pSettings); |
|---|
| 137 | BKNI_Memset(pSettings, 0, sizeof(*pSettings)); |
|---|
| 138 | #if BDSP_IMG_SUPPORT |
|---|
| 139 | pSettings->pImageContext = BDSP_IMG_Context; |
|---|
| 140 | pSettings->pImageInterface = &BDSP_IMG_Interface; |
|---|
| 141 | #endif |
|---|
| 142 | pSettings->preloadImages = false; |
|---|
| 143 | pSettings->authenticationEnabled =false; |
|---|
| 144 | |
|---|
| 145 | /* All debug features will be disabled by default */ |
|---|
| 146 | pSettings->debugSettings[BDSP_Raaga_DebugType_eUart].enabled = false; |
|---|
| 147 | pSettings->debugSettings[BDSP_Raaga_DebugType_eDramMsg].enabled = false; |
|---|
| 148 | pSettings->debugSettings[BDSP_Raaga_DebugType_eCoreDump].enabled = false; |
|---|
| 149 | pSettings->debugSettings[BDSP_Raaga_DebugType_eTargetPrintf].enabled = false; |
|---|
| 150 | |
|---|
| 151 | pSettings->debugSettings[BDSP_Raaga_DebugType_eUart].bufferSize = 0x1000; /* 4 KB by default */ |
|---|
| 152 | pSettings->debugSettings[BDSP_Raaga_DebugType_eDramMsg ].bufferSize = 0x40000; /* 256 KB by default */ |
|---|
| 153 | pSettings->debugSettings[BDSP_Raaga_DebugType_eCoreDump].bufferSize = 0x80000; /* 512 KB by default */ |
|---|
| 154 | pSettings->debugSettings[BDSP_Raaga_DebugType_eTargetPrintf].bufferSize = 0x40000; /* 256 KB by default */ |
|---|
| 155 | |
|---|
| 156 | /*pSettings->enableDebugLog = false;*/ |
|---|
| 157 | } |
|---|
| 158 | |
|---|
| 159 | BERR_Code BDSP_Raaga_Open( |
|---|
| 160 | BDSP_Handle *pDsp, /* [out] */ |
|---|
| 161 | BCHP_Handle chpHandle, |
|---|
| 162 | BREG_Handle regHandle, |
|---|
| 163 | BMEM_Handle memHandle, |
|---|
| 164 | BINT_Handle intHandle, |
|---|
| 165 | BTMR_Handle tmrHandle, |
|---|
| 166 | const BDSP_RaagaSettings *pSettings |
|---|
| 167 | ) |
|---|
| 168 | { |
|---|
| 169 | BDSP_Raaga *pRaaga; |
|---|
| 170 | BERR_Code ret= BERR_SUCCESS; |
|---|
| 171 | |
|---|
| 172 | BDBG_ASSERT(NULL != pDsp); |
|---|
| 173 | BDBG_ASSERT(NULL != chpHandle); |
|---|
| 174 | BDBG_ASSERT(NULL != regHandle); |
|---|
| 175 | BDBG_ASSERT(NULL != memHandle); |
|---|
| 176 | BDBG_ASSERT(NULL != intHandle); |
|---|
| 177 | /* tmr is not required */ |
|---|
| 178 | BSTD_UNUSED(tmrHandle); |
|---|
| 179 | BDBG_ASSERT(NULL != pSettings); |
|---|
| 180 | BDBG_ENTER(BDSP_Raaga_Open); |
|---|
| 181 | /* Alloc raaga device */ |
|---|
| 182 | pRaaga = BKNI_Malloc(sizeof(BDSP_Raaga)); |
|---|
| 183 | if ( NULL == pRaaga ) |
|---|
| 184 | { |
|---|
| 185 | return BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY); |
|---|
| 186 | } |
|---|
| 187 | BKNI_Memset(pRaaga, 0, sizeof(BDSP_Raaga)); |
|---|
| 188 | |
|---|
| 189 | /* Init device */ |
|---|
| 190 | BDSP_P_InitDevice(&pRaaga->device, pRaaga); |
|---|
| 191 | pRaaga->device.close = BDSP_Raaga_P_Close; |
|---|
| 192 | pRaaga->device.getDefaultContextSettings = BDSP_Raaga_P_GetDefaultContextSettings; |
|---|
| 193 | pRaaga->device.createContext = BDSP_Raaga_P_CreateContext; |
|---|
| 194 | pRaaga->device.getStatus= BDSP_Raaga_P_GetStatus; |
|---|
| 195 | pRaaga->device.powerStandby= BDSP_Raaga_P_PowerStandby; |
|---|
| 196 | pRaaga->device.powerResume= BDSP_Raaga_P_PowerResume; |
|---|
| 197 | pRaaga->device.getAudioTypeInfo= BDSP_Raaga_P_GetAudioTypeInfo; |
|---|
| 198 | pRaaga->device.getAudioProcessingInfo= BDSP_Raaga_P_GetAudioProcessingInfo; |
|---|
| 199 | pRaaga->device.getAudioEncodeInfo= BDSP_Raaga_P_GetAudioEncodeInfo; |
|---|
| 200 | pRaaga->device.allocateExternalInterrupt = BDSP_Raaga_P_AllocateExternalInterrupt; |
|---|
| 201 | pRaaga->device.freeExternalInterrupt = BDSP_Raaga_P_FreeExternalInterrupt; |
|---|
| 202 | pRaaga->device.getExternalInterruptInfo = BDSP_Raaga_P_GetExternalInterruptInfo; |
|---|
| 203 | pRaaga->device.allocateRdbRegister = BDSP_Raaga_P_AllocateRdbRegisters; |
|---|
| 204 | pRaaga->device.freeRdbRegister = BDSP_Raaga_P_FreeRdbRegisters; |
|---|
| 205 | pRaaga->device.getRdbRegisterInfo = BDSP_Raaga_P_GetRdbRegistersInfo; |
|---|
| 206 | |
|---|
| 207 | /* Init context lists */ |
|---|
| 208 | BLST_S_INIT(&pRaaga->contextList); |
|---|
| 209 | |
|---|
| 210 | /* Init interrupt list */ |
|---|
| 211 | BLST_S_INIT(&pRaaga->interruptList); |
|---|
| 212 | |
|---|
| 213 | /* Init Rdb register list */ |
|---|
| 214 | BLST_S_INIT(&pRaaga->rdbRegisterList); |
|---|
| 215 | |
|---|
| 216 | /* Save Settings and params */ |
|---|
| 217 | pRaaga->settings = *pSettings; |
|---|
| 218 | pRaaga->chpHandle = chpHandle; |
|---|
| 219 | pRaaga->regHandle = regHandle; |
|---|
| 220 | pRaaga->memHandle = memHandle; |
|---|
| 221 | pRaaga->intHandle = intHandle; |
|---|
| 222 | |
|---|
| 223 | #ifdef BDSP_FW_RBUF_CAPTURE |
|---|
| 224 | /* Specific to FW Ring Buffer capture required for their unit testing */ |
|---|
| 225 | if(Rbuf_Setting.rbuf_init != NULL && Rbuf_Setting.rbuf_uninit != NULL) |
|---|
| 226 | { |
|---|
| 227 | Rbuf_Setting.rbuf_init((BREG_Handle)regHandle, (BMEM_Handle)memHandle); |
|---|
| 228 | } |
|---|
| 229 | #endif |
|---|
| 230 | |
|---|
| 231 | /* Done, mark object as valid */ |
|---|
| 232 | BDBG_OBJECT_SET(pRaaga, BDSP_Raaga); |
|---|
| 233 | /* power up */ |
|---|
| 234 | #ifdef BCHP_PWR_RESOURCE_RAAGA_SRAM |
|---|
| 235 | BCHP_PWR_AcquireResource(chpHandle, BCHP_PWR_RESOURCE_RAAGA_SRAM); |
|---|
| 236 | #endif |
|---|
| 237 | #ifdef BCHP_PWR_RESOURCE_RAAGA |
|---|
| 238 | BCHP_PWR_AcquireResource(chpHandle, BCHP_PWR_RESOURCE_RAAGA); |
|---|
| 239 | #endif |
|---|
| 240 | |
|---|
| 241 | |
|---|
| 242 | ret = BDSP_Raaga_P_Open(pRaaga->device.pDeviceHandle); |
|---|
| 243 | if(ret != BERR_SUCCESS) |
|---|
| 244 | { |
|---|
| 245 | ret = BERR_TRACE(ret); |
|---|
| 246 | goto err_open; |
|---|
| 247 | } |
|---|
| 248 | |
|---|
| 249 | *pDsp = &pRaaga->device; |
|---|
| 250 | goto open_success; |
|---|
| 251 | |
|---|
| 252 | err_open: |
|---|
| 253 | BDBG_OBJECT_DESTROY(pRaaga, BDSP_Raaga); |
|---|
| 254 | BKNI_Free(pRaaga); |
|---|
| 255 | #ifdef BCHP_PWR_RESOURCE_RAAGA_SRAM |
|---|
| 256 | BCHP_PWR_ReleaseResource(chpHandle, BCHP_PWR_RESOURCE_RAAGA_SRAM); |
|---|
| 257 | #endif |
|---|
| 258 | #ifdef BCHP_PWR_RESOURCE_RAAGA |
|---|
| 259 | BCHP_PWR_ReleaseResource(chpHandle, BCHP_PWR_RESOURCE_RAAGA); |
|---|
| 260 | #endif |
|---|
| 261 | |
|---|
| 262 | open_success: |
|---|
| 263 | return ret; |
|---|
| 264 | } |
|---|
| 265 | |
|---|
| 266 | #ifdef BDSP_FW_RBUF_CAPTURE |
|---|
| 267 | void BDSP_P_RbufSetup( |
|---|
| 268 | BDSP_P_RbufCapture sRbufCap |
|---|
| 269 | ) |
|---|
| 270 | { |
|---|
| 271 | Rbuf_Setting.rbuf_init = sRbufCap.rbuf_init; |
|---|
| 272 | Rbuf_Setting.rbuf_uninit = sRbufCap.rbuf_uninit; |
|---|
| 273 | Rbuf_Setting.rbuf_capture_channel_start = sRbufCap.rbuf_capture_channel_start; |
|---|
| 274 | Rbuf_Setting.rbuf_capture_stop_channel = sRbufCap.rbuf_capture_stop_channel; |
|---|
| 275 | } |
|---|
| 276 | #endif |
|---|
| 277 | |
|---|
| 278 | /****************************************************************************** |
|---|
| 279 | Summary: |
|---|
| 280 | This Function returns true, If the Processing algorithm having AlgoId passed as |
|---|
| 281 | argument is supported or not. |
|---|
| 282 | *******************************************************************************/ |
|---|
| 283 | bool BDSP_Raaga_IsAudioProcessingSupported( |
|---|
| 284 | BDSP_AudioProcessing audioProcessing) |
|---|
| 285 | { |
|---|
| 286 | return BDSP_Raaga_P_IsAudioProcessingSupported(audioProcessing); |
|---|
| 287 | } |
|---|
| 288 | |
|---|
| 289 | /****************************************************************************** |
|---|
| 290 | Summary: |
|---|
| 291 | This Function returns true, If the audio processing algorithm having AlgoId |
|---|
| 292 | passed as argument is supported or not. |
|---|
| 293 | *******************************************************************************/ |
|---|
| 294 | bool BDSP_Raaga_IsAudioTypeSupported( |
|---|
| 295 | BDSP_AudioType audioType) |
|---|
| 296 | { |
|---|
| 297 | return BDSP_Raaga_P_IsAudioTypeSupported(audioType); |
|---|
| 298 | } |
|---|
| 299 | /****************************************************************************** |
|---|
| 300 | Summary: |
|---|
| 301 | This Function returns true, If the Encode algorithm having AlgoId passed as |
|---|
| 302 | argument is supported or not. |
|---|
| 303 | *******************************************************************************/ |
|---|
| 304 | bool BDSP_Raaga_IsAudioEncodeSupported( |
|---|
| 305 | BDSP_AudioEncode audioEncode) |
|---|
| 306 | { |
|---|
| 307 | return BDSP_Raaga_P_IsAudioEncodeSupported(audioEncode); |
|---|
| 308 | } |
|---|
| 309 | |
|---|
| 310 | BERR_Code BDSP_Raaga_GetDownloadStatus( |
|---|
| 311 | BDSP_Handle handle, |
|---|
| 312 | BDSP_Raaga_DownloadStatus *pStatus /* [out] */ |
|---|
| 313 | ) |
|---|
| 314 | { |
|---|
| 315 | |
|---|
| 316 | BDSP_Raaga *pDevice = (BDSP_Raaga *)handle->pDeviceHandle; |
|---|
| 317 | |
|---|
| 318 | BDBG_ENTER(BDSP_Raaga_GetDownloadStatus); |
|---|
| 319 | /* Assert the function arguments*/ |
|---|
| 320 | BDBG_ASSERT(handle->pDeviceHandle); |
|---|
| 321 | |
|---|
| 322 | /*If Firmware Firmware authentication is Disabled*/ |
|---|
| 323 | if(pDevice->settings.authenticationEnabled==false) |
|---|
| 324 | { |
|---|
| 325 | BDBG_ERR(("BDSP_Raaga_GetDownloadStatus should be called only if bFwAuthEnable is true")); |
|---|
| 326 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 327 | } |
|---|
| 328 | |
|---|
| 329 | /*Logical address*/ |
|---|
| 330 | pStatus->pBaseAddress = (void *)(pDevice->memInfo.sOpenTimeMemInfo.ui32BaseAddr); |
|---|
| 331 | /*Physical Address */ |
|---|
| 332 | BMEM_ConvertAddressToOffset(pDevice->memHandle,(void *)(pStatus->pBaseAddress),&(pStatus->physicalAddress)); |
|---|
| 333 | /*Size of the executable download */ |
|---|
| 334 | pStatus->length =pDevice->memInfo.sOpenTimeMemInfo.ui32Size; |
|---|
| 335 | |
|---|
| 336 | |
|---|
| 337 | BDBG_LEAVE(BDSP_Raaga_GetDownloadStatus); |
|---|
| 338 | return BERR_SUCCESS; |
|---|
| 339 | } |
|---|
| 340 | |
|---|
| 341 | |
|---|
| 342 | BERR_Code BDSP_Raaga_Initialize(BDSP_Handle handle) |
|---|
| 343 | { |
|---|
| 344 | |
|---|
| 345 | BERR_Code rc = BERR_SUCCESS ; |
|---|
| 346 | unsigned int uiDspIndex = 0; |
|---|
| 347 | BDSP_Raaga *pDevice = (BDSP_Raaga *)handle->pDeviceHandle; |
|---|
| 348 | |
|---|
| 349 | BDBG_ENTER(BDSP_Raaga_StartDsp); |
|---|
| 350 | /* Assert the function arguments*/ |
|---|
| 351 | BDBG_ASSERT(handle->pDeviceHandle); |
|---|
| 352 | |
|---|
| 353 | /*If Firmware Firmware authentication is Disabled*/ |
|---|
| 354 | if(pDevice->settings.authenticationEnabled==false) |
|---|
| 355 | { |
|---|
| 356 | BDBG_ERR(("BDSP_Raaga_StartDsp should be called only if bFwAuthEnable is true")); |
|---|
| 357 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 358 | } |
|---|
| 359 | |
|---|
| 360 | for(uiDspIndex = 0; uiDspIndex < BDSP_RAAGA_MAX_DSP; uiDspIndex++) |
|---|
| 361 | { |
|---|
| 362 | /* Initializing the Hardware */ |
|---|
| 363 | rc = BDSP_Raaga_P_InitHardware(pDevice,uiDspIndex); |
|---|
| 364 | if (rc!=BERR_SUCCESS) |
|---|
| 365 | { |
|---|
| 366 | BDBG_MSG(("BDSP_Raaga_P_InitHardware::Error returned %x!",rc)); |
|---|
| 367 | return BERR_TRACE(rc); |
|---|
| 368 | } |
|---|
| 369 | } |
|---|
| 370 | BDBG_LEAVE(BDSP_Raaga_StartDsp); |
|---|
| 371 | return rc; |
|---|
| 372 | } |
|---|
| 373 | |
|---|
| 374 | BERR_Code BDSP_Raaga_GetDefaultAudioTypeSettings( |
|---|
| 375 | BDSP_AudioType audioType, |
|---|
| 376 | void *pSettingsBuffer, /* [out] */ |
|---|
| 377 | size_t settingsBufferSize /*[In]*/ |
|---|
| 378 | ) |
|---|
| 379 | { |
|---|
| 380 | if ( audioType >= BDSP_AudioType_eMax ) |
|---|
| 381 | { |
|---|
| 382 | BDBG_ASSERT(audioType < BDSP_AudioType_eMax); |
|---|
| 383 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 384 | } |
|---|
| 385 | if(BDSP_sAudioCodecDetails[audioType]->userConfigSize != settingsBufferSize) |
|---|
| 386 | { |
|---|
| 387 | BDBG_ERR(("settingsBufferSize (%d) is not equal to Config size (%d) of Audio type %d", |
|---|
| 388 | settingsBufferSize,BDSP_sAudioCodecDetails[audioType]->userConfigSize, |
|---|
| 389 | audioType)); |
|---|
| 390 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 391 | } |
|---|
| 392 | BKNI_Memcpy((void *)(volatile void *)pSettingsBuffer,(void *)BDSP_sAudioCodecDetails[audioType]->pDefaultUserConfig,settingsBufferSize); |
|---|
| 393 | |
|---|
| 394 | return BERR_SUCCESS; |
|---|
| 395 | } |
|---|
| 396 | |
|---|
| 397 | BERR_Code BDSP_Raaga_GetDefaultAudioProcessingSettings( |
|---|
| 398 | BDSP_AudioProcessing audioProcessingType, |
|---|
| 399 | void *pSettingsBuffer, /* [out] */ |
|---|
| 400 | size_t settingsBufferSize /*[In]*/ |
|---|
| 401 | ) |
|---|
| 402 | { |
|---|
| 403 | if ( audioProcessingType >= BDSP_AudioProcessing_eMax ) |
|---|
| 404 | { |
|---|
| 405 | BDBG_ASSERT(audioProcessingType < BDSP_AudioProcessing_eMax); |
|---|
| 406 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 407 | } |
|---|
| 408 | if(BDSP_sAudioProcessingDetails[audioProcessingType]->userConfigSize != settingsBufferSize) |
|---|
| 409 | { |
|---|
| 410 | BDBG_ERR(("settingsBufferSize (%d) is not equal to Config size (%d) of Processing type %d", |
|---|
| 411 | settingsBufferSize,BDSP_sAudioProcessingDetails[audioProcessingType]->userConfigSize, |
|---|
| 412 | audioProcessingType)); |
|---|
| 413 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 414 | } |
|---|
| 415 | BKNI_Memcpy((void *)(volatile void *)pSettingsBuffer,(void *)BDSP_sAudioProcessingDetails[audioProcessingType]->pDefaultUserConfig,settingsBufferSize); |
|---|
| 416 | |
|---|
| 417 | return BERR_SUCCESS; |
|---|
| 418 | } |
|---|
| 419 | |
|---|
| 420 | BERR_Code BDSP_Raaga_GetDefaultAudioEncodeSettings( |
|---|
| 421 | BDSP_AudioEncode audioEncodeType, |
|---|
| 422 | void *pSettingsBuffer, /* [out] */ |
|---|
| 423 | size_t settingsBufferSize /*[In]*/ |
|---|
| 424 | ) |
|---|
| 425 | { |
|---|
| 426 | if ( audioEncodeType >= BDSP_AudioEncode_eMax ) |
|---|
| 427 | { |
|---|
| 428 | BDBG_ASSERT(audioEncodeType < BDSP_AudioEncode_eMax); |
|---|
| 429 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 430 | } |
|---|
| 431 | if(BDSP_sAudioEncodeDetails[audioEncodeType]->userConfigSize != settingsBufferSize) |
|---|
| 432 | { |
|---|
| 433 | BDBG_ERR(("settingsBufferSize (%d) is not equal to Config size (%d) of Encode type %d", |
|---|
| 434 | settingsBufferSize,BDSP_sAudioEncodeDetails[audioEncodeType]->userConfigSize, |
|---|
| 435 | audioEncodeType)); |
|---|
| 436 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 437 | } |
|---|
| 438 | BKNI_Memcpy((void *)(volatile void *)pSettingsBuffer,(void *)BDSP_sAudioEncodeDetails[audioEncodeType]->pDefaultUserConfig,settingsBufferSize); |
|---|
| 439 | |
|---|
| 440 | return BERR_SUCCESS; |
|---|
| 441 | } |
|---|
| 442 | |
|---|
| 443 | /*************************************************************************** |
|---|
| 444 | Summary: |
|---|
| 445 | Get Raaga Firmware Debug Data |
|---|
| 446 | ***************************************************************************/ |
|---|
| 447 | BERR_Code BDSP_Raaga_GetDebugBuffer( |
|---|
| 448 | BDSP_Handle handle, |
|---|
| 449 | BDSP_Raaga_DebugType debugType, /* [in] Gives the type of debug buffer for which the Base address is required ... UART, DRAM, CoreDump ... */ |
|---|
| 450 | uint32_t dspIndex, /* [in] Gives the DSP Id for which the debug buffer info is required */ |
|---|
| 451 | void **pBuffer, /* [out] Base address of the debug buffer data */ |
|---|
| 452 | size_t *pSize /* [out] Contiguous length of the debug buffer data in bytes */ |
|---|
| 453 | ) |
|---|
| 454 | { |
|---|
| 455 | BERR_Code rc = BERR_SUCCESS ; |
|---|
| 456 | BDSP_Raaga *pDevice; |
|---|
| 457 | |
|---|
| 458 | uint32_t ui32BaseAddr=0, ui32ReadAddr=0,ui32WriteAddr=0, |
|---|
| 459 | ui32EndAddr=0, ui32ReadSize=0, uiOffset=0, |
|---|
| 460 | ui32DebugFifoOffset=0; |
|---|
| 461 | |
|---|
| 462 | BDBG_ENTER(BDSP_Raaga_GetDebugBuffer); |
|---|
| 463 | /* Assert the function arguments*/ |
|---|
| 464 | BDBG_ASSERT(handle->pDeviceHandle); |
|---|
| 465 | BDBG_ASSERT(pBuffer); |
|---|
| 466 | BDBG_ASSERT(pSize); |
|---|
| 467 | |
|---|
| 468 | pDevice = (BDSP_Raaga *)handle->pDeviceHandle; |
|---|
| 469 | |
|---|
| 470 | uiOffset = pDevice->dspOffset[dspIndex] ; |
|---|
| 471 | ui32DebugFifoOffset = (BCHP_RAAGA_DSP_FW_CFG_BASE_ADDR_FIFO_1 - BCHP_RAAGA_DSP_FW_CFG_BASE_ADDR_FIFO_0) |
|---|
| 472 | *(BDSP_RAAGA_DEBUG_FIFO_START_INDEX + debugType); |
|---|
| 473 | |
|---|
| 474 | ui32BaseAddr = BDSP_Read32(pDevice->regHandle, |
|---|
| 475 | BCHP_RAAGA_DSP_FW_CFG_BASE_ADDR_FIFO_0 + ui32DebugFifoOffset + uiOffset); |
|---|
| 476 | ui32ReadAddr = BDSP_Read32(pDevice->regHandle, |
|---|
| 477 | BCHP_RAAGA_DSP_FW_CFG_READ_PTR_FIFO_0 + ui32DebugFifoOffset + uiOffset); |
|---|
| 478 | ui32WriteAddr = BDSP_Read32(pDevice->regHandle, |
|---|
| 479 | BCHP_RAAGA_DSP_FW_CFG_WRITE_PTR_FIFO_0 + ui32DebugFifoOffset + uiOffset); |
|---|
| 480 | ui32EndAddr = BDSP_Read32(pDevice->regHandle, |
|---|
| 481 | BCHP_RAAGA_DSP_FW_CFG_END_ADDR_FIFO_0 + ui32DebugFifoOffset + uiOffset); |
|---|
| 482 | |
|---|
| 483 | BMEM_ConvertOffsetToAddress(pDevice->memHandle, ui32ReadAddr, pBuffer); |
|---|
| 484 | |
|---|
| 485 | ui32ReadSize = ui32WriteAddr - ui32ReadAddr ; |
|---|
| 486 | if( ui32ReadAddr > ui32WriteAddr ) |
|---|
| 487 | { |
|---|
| 488 | /* Bottom Chunk only - Contiguous data*/ |
|---|
| 489 | ui32ReadSize = (ui32EndAddr - ui32ReadAddr); |
|---|
| 490 | } |
|---|
| 491 | |
|---|
| 492 | *pSize = ui32ReadSize; |
|---|
| 493 | BDBG_LEAVE(BDSP_Raaga_GetDebugBuffer); |
|---|
| 494 | |
|---|
| 495 | return rc; |
|---|
| 496 | } |
|---|
| 497 | |
|---|
| 498 | /*************************************************************************** |
|---|
| 499 | Summary: |
|---|
| 500 | Consume debug data from the debug ringbuffer. |
|---|
| 501 | ***************************************************************************/ |
|---|
| 502 | BERR_Code BDSP_Raaga_ConsumeDebugData( |
|---|
| 503 | BDSP_Handle handle, |
|---|
| 504 | BDSP_Raaga_DebugType debugType, /* [in] Gives the type of debug buffer for which the Base address is required ... UART, DRAM, CoreDump ... */ |
|---|
| 505 | uint32_t dspIndex, /* [in] Gives the DSP Id for which the debug data needs to be consumed */ |
|---|
| 506 | size_t bytesConsumed /* [in] Number of bytes consumed from the debug buffer */ |
|---|
| 507 | ) |
|---|
| 508 | { |
|---|
| 509 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 510 | BDSP_Raaga *pDevice; |
|---|
| 511 | |
|---|
| 512 | uint32_t ui32BaseAddr=0, ui32ReadAddr=0,ui32WriteAddr=0, |
|---|
| 513 | ui32EndAddr=0, ui32ReadSize=0, uiOffset=0, |
|---|
| 514 | ui32DebugFifoOffset=0; |
|---|
| 515 | |
|---|
| 516 | BDBG_ENTER(BDSP_Raaga_ConsumeDebugData); |
|---|
| 517 | /* Assert the function arguments*/ |
|---|
| 518 | BDBG_ASSERT(handle->pDeviceHandle); |
|---|
| 519 | |
|---|
| 520 | pDevice = (BDSP_Raaga *)handle->pDeviceHandle; |
|---|
| 521 | |
|---|
| 522 | uiOffset = pDevice->dspOffset[dspIndex] ; |
|---|
| 523 | ui32DebugFifoOffset = (BCHP_RAAGA_DSP_FW_CFG_BASE_ADDR_FIFO_1 - BCHP_RAAGA_DSP_FW_CFG_BASE_ADDR_FIFO_0) |
|---|
| 524 | *(BDSP_RAAGA_DEBUG_FIFO_START_INDEX + debugType); |
|---|
| 525 | |
|---|
| 526 | ui32BaseAddr = BDSP_Read32(pDevice->regHandle, |
|---|
| 527 | BCHP_RAAGA_DSP_FW_CFG_BASE_ADDR_FIFO_0 + ui32DebugFifoOffset + uiOffset); |
|---|
| 528 | ui32ReadAddr = BDSP_Read32(pDevice->regHandle, |
|---|
| 529 | BCHP_RAAGA_DSP_FW_CFG_READ_PTR_FIFO_0 + ui32DebugFifoOffset + uiOffset); |
|---|
| 530 | ui32WriteAddr = BDSP_Read32(pDevice->regHandle, |
|---|
| 531 | BCHP_RAAGA_DSP_FW_CFG_WRITE_PTR_FIFO_0 + ui32DebugFifoOffset + uiOffset); |
|---|
| 532 | ui32EndAddr = BDSP_Read32(pDevice->regHandle, |
|---|
| 533 | BCHP_RAAGA_DSP_FW_CFG_END_ADDR_FIFO_0 + ui32DebugFifoOffset + uiOffset); |
|---|
| 534 | |
|---|
| 535 | /* Get the amount data available in the buffer*/ |
|---|
| 536 | ui32ReadSize = ui32WriteAddr - ui32ReadAddr ; |
|---|
| 537 | if( ui32ReadAddr > ui32WriteAddr ) |
|---|
| 538 | { |
|---|
| 539 | /* Bottom Chunk + Top Chunk */ |
|---|
| 540 | ui32ReadSize = (ui32EndAddr - ui32ReadAddr) + (ui32WriteAddr - ui32BaseAddr); |
|---|
| 541 | } |
|---|
| 542 | |
|---|
| 543 | if (bytesConsumed <= ui32ReadSize) |
|---|
| 544 | { |
|---|
| 545 | ui32ReadAddr += bytesConsumed; |
|---|
| 546 | if(ui32ReadAddr >= ui32EndAddr) |
|---|
| 547 | { |
|---|
| 548 | ui32ReadAddr = ui32BaseAddr + (ui32ReadAddr - ui32EndAddr); |
|---|
| 549 | } |
|---|
| 550 | |
|---|
| 551 | BDSP_Write32(pDevice->regHandle, BCHP_RAAGA_DSP_FW_CFG_READ_PTR_FIFO_0 + ui32DebugFifoOffset + |
|---|
| 552 | uiOffset, ui32ReadAddr); |
|---|
| 553 | } |
|---|
| 554 | else |
|---|
| 555 | { |
|---|
| 556 | /* Return error if bytesConsumed is more |
|---|
| 557 | than the data available in the buffer */ |
|---|
| 558 | rc = BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 559 | } |
|---|
| 560 | |
|---|
| 561 | BDBG_LEAVE(BDSP_Raaga_ConsumeDebugData); |
|---|
| 562 | |
|---|
| 563 | return rc; |
|---|
| 564 | } |
|---|
| 565 | |
|---|
| 566 | /*************************************************************************** |
|---|
| 567 | Summary: |
|---|
| 568 | Returns the Status of the DSP |
|---|
| 569 | ***************************************************************************/ |
|---|
| 570 | BDSP_Raaga_FwStatus BDSP_Raaga_GetCoreDumpStatus ( |
|---|
| 571 | BDSP_Handle handle, |
|---|
| 572 | uint32_t dspIndex) /* [in] Gives the DSP Id for which the core dump status is required */ |
|---|
| 573 | { |
|---|
| 574 | uint32_t uiOffset; |
|---|
| 575 | |
|---|
| 576 | BDSP_Raaga *pDevice; |
|---|
| 577 | BDSP_Raaga_FwStatus eStatus; |
|---|
| 578 | |
|---|
| 579 | BDBG_ASSERT(handle->pDeviceHandle); |
|---|
| 580 | |
|---|
| 581 | pDevice = (BDSP_Raaga *)handle->pDeviceHandle; |
|---|
| 582 | |
|---|
| 583 | uiOffset = pDevice->dspOffset[dspIndex]; |
|---|
| 584 | eStatus = BDSP_Read32 (pDevice->regHandle, BCHP_RAAGA_DSP_FW_CFG_SW_UNDEFINED_SPAREi_ARRAY_BASE + uiOffset + 20*4); |
|---|
| 585 | |
|---|
| 586 | return eStatus; |
|---|
| 587 | } |
|---|
| 588 | |
|---|