| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2007-2010, 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: bxvd_status.c $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/7 $ |
|---|
| 12 | * $brcm_Date: 2/25/10 4:24p $ |
|---|
| 13 | * |
|---|
| 14 | * [File Description:] |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/portinginterface/xvd/7401/bxvd_status.c $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/7 2/25/10 4:24p nilesh |
|---|
| 21 | * SW7405-2993: XDM Merge |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/6 1/23/09 10:15a nilesh |
|---|
| 24 | * PR51470: Fixed compilation warning when DEBUG=n |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/5 11/4/08 4:37p nilesh |
|---|
| 27 | * PR48591: Moved BINT_Stats support to static helper functions. |
|---|
| 28 | * BINT_Stats are now reset/printed during start/stop decode. |
|---|
| 29 | * |
|---|
| 30 | * Hydra_Software_Devel/4 11/4/08 3:47p nilesh |
|---|
| 31 | * PR48591: Added XVD interrupt profiling information via BINT_Stats |
|---|
| 32 | * |
|---|
| 33 | * Hydra_Software_Devel/3 4/1/08 2:39p davidp |
|---|
| 34 | * PR27168: Add routine summaries to comment header. |
|---|
| 35 | * |
|---|
| 36 | * Hydra_Software_Devel/2 1/24/08 11:40a nilesh |
|---|
| 37 | * PR38570: Merge CABAC worklist API changes to mainline |
|---|
| 38 | * |
|---|
| 39 | * Hydra_Software_Devel/PR38570/1 1/22/08 3:57p nilesh |
|---|
| 40 | * PR36741: Added "Begin Printing Status" and "End Printing Status" |
|---|
| 41 | * message markers in BXVD_STATUS message printout |
|---|
| 42 | * |
|---|
| 43 | * Hydra_Software_Devel/1 11/6/07 12:36p nilesh |
|---|
| 44 | * PR36741: Added XVD status reporting via BDBG console messages |
|---|
| 45 | * |
|---|
| 46 | ***************************************************************************/ |
|---|
| 47 | |
|---|
| 48 | #include "bxvd_status.h" |
|---|
| 49 | #include "bxvd_status_priv.h" |
|---|
| 50 | #include "bint_stats.h" |
|---|
| 51 | |
|---|
| 52 | BDBG_MODULE(BXVD_STATUS); |
|---|
| 53 | |
|---|
| 54 | static void BXVD_Status_S_InterruptStatsReset( |
|---|
| 55 | BXVD_StatusHandle hXvdStatus |
|---|
| 56 | ) |
|---|
| 57 | { |
|---|
| 58 | #ifdef BINT_STATS_ENABLE |
|---|
| 59 | /* Reset XVD interrupt stats */ |
|---|
| 60 | if (hXvdStatus->hXvd->stDecoderContext.pCbAVC_MBX_ISR) |
|---|
| 61 | { |
|---|
| 62 | BINT_Stats_Reset(hXvdStatus->hXvd->stDecoderContext.pCbAVC_MBX_ISR); |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | if (hXvdStatus->hXvd->stDecoderContext.pCbAVC_StillPicRdy_ISR) |
|---|
| 66 | { |
|---|
| 67 | BINT_Stats_Reset(hXvdStatus->hXvd->stDecoderContext.pCbAVC_StillPicRdy_ISR); |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | if (hXvdStatus->hXvd->stDecoderContext.pCbAVC_Watchdog_ISR) |
|---|
| 71 | { |
|---|
| 72 | BINT_Stats_Reset(hXvdStatus->hXvd->stDecoderContext.pCbAVC_Watchdog_ISR); |
|---|
| 73 | } |
|---|
| 74 | #else |
|---|
| 75 | BSTD_UNUSED(hXvdStatus); |
|---|
| 76 | #endif |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | static void BXVD_Status_S_InterruptStatsPrint( |
|---|
| 80 | BXVD_StatusHandle hXvdStatus |
|---|
| 81 | ) |
|---|
| 82 | { |
|---|
| 83 | #ifdef BINT_STATS_ENABLE |
|---|
| 84 | BINT_Stats_CallbackStats *pMBXCallbackStats; |
|---|
| 85 | BINT_Stats_CallbackStats *pStillPicRdyCallbackStats; |
|---|
| 86 | BINT_Stats_CallbackStats *pWatchdogCallbackStats; |
|---|
| 87 | |
|---|
| 88 | /* Retrieve XVD interrupt stats */ |
|---|
| 89 | if (hXvdStatus->hXvd->stDecoderContext.pCbAVC_MBX_ISR) |
|---|
| 90 | { |
|---|
| 91 | BINT_Stats_Get(hXvdStatus->hXvd->stDecoderContext.pCbAVC_MBX_ISR, |
|---|
| 92 | &pMBXCallbackStats); |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | if (hXvdStatus->hXvd->stDecoderContext.pCbAVC_StillPicRdy_ISR) |
|---|
| 96 | { |
|---|
| 97 | BINT_Stats_Get(hXvdStatus->hXvd->stDecoderContext.pCbAVC_StillPicRdy_ISR, |
|---|
| 98 | &pStillPicRdyCallbackStats); |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | if (hXvdStatus->hXvd->stDecoderContext.pCbAVC_Watchdog_ISR) |
|---|
| 102 | { |
|---|
| 103 | BINT_Stats_Get(hXvdStatus->hXvd->stDecoderContext.pCbAVC_Watchdog_ISR, |
|---|
| 104 | &pWatchdogCallbackStats); |
|---|
| 105 | } |
|---|
| 106 | |
|---|
| 107 | /* Print XVD interrupt stats */ |
|---|
| 108 | BKNI_EnterCriticalSection(); |
|---|
| 109 | if (hXvdStatus->hXvd->stDecoderContext.pCbAVC_MBX_ISR) |
|---|
| 110 | { |
|---|
| 111 | BDBG_MSG(("Device[%d]: Mailbox ISR = 0x%08x (0x%08x - 0x%08x) [0x%08x]", |
|---|
| 112 | hXvdStatus->hXvd->uDecoderInstance, |
|---|
| 113 | pMBXCallbackStats->ulTimeAvg, |
|---|
| 114 | pMBXCallbackStats->ulTimeMin, |
|---|
| 115 | pMBXCallbackStats->ulTimeMax, |
|---|
| 116 | pMBXCallbackStats->ulCbHitCount)); |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | if (hXvdStatus->hXvd->stDecoderContext.pCbAVC_StillPicRdy_ISR) |
|---|
| 120 | { |
|---|
| 121 | BDBG_MSG(("Device[%d]: StillPictureReady ISR = 0x%08x (0x%08x - 0x%08x) [0x%08x]", |
|---|
| 122 | hXvdStatus->hXvd->uDecoderInstance, |
|---|
| 123 | pStillPicRdyCallbackStats->ulTimeAvg, |
|---|
| 124 | pStillPicRdyCallbackStats->ulTimeMin, |
|---|
| 125 | pStillPicRdyCallbackStats->ulTimeMax, |
|---|
| 126 | pStillPicRdyCallbackStats->ulCbHitCount)); |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | if (hXvdStatus->hXvd->stDecoderContext.pCbAVC_Watchdog_ISR) |
|---|
| 130 | { |
|---|
| 131 | BDBG_MSG(("Device[%d]: Watchdog ISR = 0x%08x (0x%08x - 0x%08x) [0x%08x]", |
|---|
| 132 | hXvdStatus->hXvd->uDecoderInstance, |
|---|
| 133 | pWatchdogCallbackStats->ulTimeAvg, |
|---|
| 134 | pWatchdogCallbackStats->ulTimeMin, |
|---|
| 135 | pWatchdogCallbackStats->ulTimeMax, |
|---|
| 136 | pWatchdogCallbackStats->ulCbHitCount)); |
|---|
| 137 | } |
|---|
| 138 | BKNI_LeaveCriticalSection(); |
|---|
| 139 | #else |
|---|
| 140 | BSTD_UNUSED(hXvdStatus); |
|---|
| 141 | #endif |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | /* Create the XVD Status Handle */ |
|---|
| 145 | BERR_Code BXVD_Status_Open( |
|---|
| 146 | BXVD_Handle hXvd, |
|---|
| 147 | BXVD_StatusHandle *phXvdStatus |
|---|
| 148 | ) |
|---|
| 149 | { |
|---|
| 150 | BXVD_P_Status_Context *pXvdStatus = NULL; |
|---|
| 151 | |
|---|
| 152 | BDBG_ENTER(BXVD_Status_Open); |
|---|
| 153 | |
|---|
| 154 | BDBG_ASSERT(hXvd); |
|---|
| 155 | BDBG_ASSERT(phXvdStatus); |
|---|
| 156 | |
|---|
| 157 | /* Set handle to NULL in case the allocation fails */ |
|---|
| 158 | *phXvdStatus = NULL; |
|---|
| 159 | |
|---|
| 160 | pXvdStatus = (BXVD_P_Status_Context *) BKNI_Malloc(sizeof(BXVD_P_Status_Context)); |
|---|
| 161 | if (!pXvdStatus) |
|---|
| 162 | { |
|---|
| 163 | return BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY); |
|---|
| 164 | } |
|---|
| 165 | |
|---|
| 166 | /* Zero out the newly allocated context */ |
|---|
| 167 | BKNI_Memset((void*)pXvdStatus, 0, sizeof(BXVD_P_Status_Context)); |
|---|
| 168 | |
|---|
| 169 | pXvdStatus->hXvd = hXvd; |
|---|
| 170 | |
|---|
| 171 | *phXvdStatus = pXvdStatus; |
|---|
| 172 | |
|---|
| 173 | BDBG_LEAVE(BXVD_Status_Open); |
|---|
| 174 | |
|---|
| 175 | return BERR_TRACE(BERR_SUCCESS); |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | /* Destroy the XVD Status Handle */ |
|---|
| 179 | BERR_Code BXVD_Status_Close( |
|---|
| 180 | BXVD_StatusHandle hXvdStatus |
|---|
| 181 | ) |
|---|
| 182 | { |
|---|
| 183 | BDBG_ENTER(BXVD_Status_Close); |
|---|
| 184 | |
|---|
| 185 | BDBG_ASSERT(hXvdStatus); |
|---|
| 186 | |
|---|
| 187 | /* Print Status */ |
|---|
| 188 | BXVD_Status_Print(hXvdStatus); |
|---|
| 189 | |
|---|
| 190 | /* Release the status context */ |
|---|
| 191 | BKNI_Free(hXvdStatus); |
|---|
| 192 | |
|---|
| 193 | BDBG_LEAVE(BXVD_Status_Close); |
|---|
| 194 | |
|---|
| 195 | return BERR_TRACE(BERR_SUCCESS); |
|---|
| 196 | } |
|---|
| 197 | |
|---|
| 198 | /* Increment the number of times this channel has been opened */ |
|---|
| 199 | BERR_Code BXVD_Status_OpenChannel( |
|---|
| 200 | BXVD_StatusHandle hXvdStatus, |
|---|
| 201 | BXVD_ChannelHandle hXvdCh |
|---|
| 202 | ) |
|---|
| 203 | { |
|---|
| 204 | BDBG_ENTER(BXVD_Status_OpenChannel); |
|---|
| 205 | |
|---|
| 206 | BDBG_ASSERT(hXvdStatus); |
|---|
| 207 | BDBG_ASSERT(hXvdCh); |
|---|
| 208 | |
|---|
| 209 | hXvdStatus->auiOpenChannelCount[hXvdCh->ulChannelNum]++; |
|---|
| 210 | |
|---|
| 211 | BDBG_LEAVE(BXVD_Status_OpenChannel); |
|---|
| 212 | |
|---|
| 213 | return BERR_TRACE(BERR_SUCCESS); |
|---|
| 214 | } |
|---|
| 215 | |
|---|
| 216 | /* Increment the number of times this channel has been closed */ |
|---|
| 217 | BERR_Code BXVD_Status_CloseChannel( |
|---|
| 218 | BXVD_StatusHandle hXvdStatus, |
|---|
| 219 | BXVD_ChannelHandle hXvdCh |
|---|
| 220 | ) |
|---|
| 221 | { |
|---|
| 222 | BDBG_ENTER(BXVD_Status_CloseChannel); |
|---|
| 223 | |
|---|
| 224 | BDBG_ASSERT(hXvdStatus); |
|---|
| 225 | BDBG_ASSERT(hXvdCh); |
|---|
| 226 | |
|---|
| 227 | hXvdStatus->auiCloseChannelCount[hXvdCh->ulChannelNum]++; |
|---|
| 228 | |
|---|
| 229 | BDBG_LEAVE(BXVD_Status_CloseChannel); |
|---|
| 230 | |
|---|
| 231 | return BERR_TRACE(BERR_SUCCESS); |
|---|
| 232 | } |
|---|
| 233 | |
|---|
| 234 | /* Increment the number of times a decode has been started on this channel */ |
|---|
| 235 | BERR_Code BXVD_Status_StartDecode( |
|---|
| 236 | BXVD_StatusHandle hXvdStatus, |
|---|
| 237 | BXVD_ChannelHandle hXvdCh |
|---|
| 238 | ) |
|---|
| 239 | { |
|---|
| 240 | BDBG_ENTER(BXVD_Status_StartDecode); |
|---|
| 241 | |
|---|
| 242 | BDBG_ASSERT(hXvdStatus); |
|---|
| 243 | BDBG_ASSERT(hXvdCh); |
|---|
| 244 | |
|---|
| 245 | hXvdStatus->auiStartDecodeCount[hXvdCh->ulChannelNum]++; |
|---|
| 246 | |
|---|
| 247 | BXVD_Status_S_InterruptStatsReset(hXvdStatus); |
|---|
| 248 | |
|---|
| 249 | BDBG_LEAVE(BXVD_Status_StartDecode); |
|---|
| 250 | |
|---|
| 251 | return BERR_TRACE(BERR_SUCCESS); |
|---|
| 252 | } |
|---|
| 253 | |
|---|
| 254 | /* Copy and Accumulate Channel Status */ |
|---|
| 255 | BERR_Code BXVD_Status_StopDecode( |
|---|
| 256 | BXVD_StatusHandle hXvdStatus, |
|---|
| 257 | BXVD_ChannelHandle hXvdCh |
|---|
| 258 | ) |
|---|
| 259 | { |
|---|
| 260 | BERR_Code rc; |
|---|
| 261 | |
|---|
| 262 | BXVD_ChannelStatus stCurrentChannelStatus; |
|---|
| 263 | BXVD_ChannelStatus *pstChannelStatus = NULL; |
|---|
| 264 | |
|---|
| 265 | BDBG_ENTER(BXVD_Status_StopDecode); |
|---|
| 266 | |
|---|
| 267 | BDBG_ASSERT(hXvdStatus); |
|---|
| 268 | BDBG_ASSERT(hXvdCh); |
|---|
| 269 | |
|---|
| 270 | pstChannelStatus = &hXvdStatus->astChannelStatus[hXvdCh->ulChannelNum]; |
|---|
| 271 | |
|---|
| 272 | BDBG_ASSERT(pstChannelStatus); |
|---|
| 273 | |
|---|
| 274 | hXvdStatus->auiStopDecodeCount[hXvdCh->ulChannelNum]++; |
|---|
| 275 | |
|---|
| 276 | /* Get Channel Status for this channel */ |
|---|
| 277 | rc = BXVD_GetChannelStatus(hXvdCh, |
|---|
| 278 | &stCurrentChannelStatus); |
|---|
| 279 | if (rc != BERR_SUCCESS) |
|---|
| 280 | { |
|---|
| 281 | return BERR_TRACE(rc); |
|---|
| 282 | } |
|---|
| 283 | |
|---|
| 284 | /* Add up the stats from this stop decode to our running channel |
|---|
| 285 | * status totals */ |
|---|
| 286 | |
|---|
| 287 | |
|---|
| 288 | pstChannelStatus->ulUnderflowCount += stCurrentChannelStatus.ulUnderflowCount; |
|---|
| 289 | pstChannelStatus->ulPictureDeliveryCount += stCurrentChannelStatus.ulPictureDeliveryCount; |
|---|
| 290 | pstChannelStatus->uiDisplayManagerDroppedCount += stCurrentChannelStatus.uiDisplayManagerDroppedCount; |
|---|
| 291 | pstChannelStatus->uiDecoderDroppedCount += stCurrentChannelStatus.uiDecoderDroppedCount; |
|---|
| 292 | pstChannelStatus->uiDisplayedParityFailureCount += stCurrentChannelStatus.uiDisplayedParityFailureCount; |
|---|
| 293 | pstChannelStatus->uiDisplayedCount += stCurrentChannelStatus.uiDisplayedCount; |
|---|
| 294 | pstChannelStatus->uiPicturesDecodedCount += stCurrentChannelStatus.uiPicturesDecodedCount; |
|---|
| 295 | pstChannelStatus->uiVsyncUnderflowCount += stCurrentChannelStatus.uiVsyncUnderflowCount; |
|---|
| 296 | pstChannelStatus->uiDecodeErrorCount += stCurrentChannelStatus.uiDecodeErrorCount; |
|---|
| 297 | pstChannelStatus->uiVsyncCount += stCurrentChannelStatus.uiVsyncCount; |
|---|
| 298 | |
|---|
| 299 | BXVD_Status_S_InterruptStatsPrint(hXvdStatus); |
|---|
| 300 | |
|---|
| 301 | BDBG_LEAVE(BXVD_Status_StopDecode); |
|---|
| 302 | |
|---|
| 303 | return BERR_TRACE(BERR_SUCCESS); |
|---|
| 304 | } |
|---|
| 305 | |
|---|
| 306 | BERR_Code BXVD_Status_Print( |
|---|
| 307 | BXVD_StatusHandle hXvdStatus |
|---|
| 308 | ) |
|---|
| 309 | { |
|---|
| 310 | uint32_t i; |
|---|
| 311 | BXVD_ChannelStatus *pstChannelStatus = NULL; |
|---|
| 312 | |
|---|
| 313 | BDBG_ASSERT(hXvdStatus); |
|---|
| 314 | |
|---|
| 315 | BDBG_MSG(("Begin Printing Status")); |
|---|
| 316 | |
|---|
| 317 | for (i = 0; i < BXVD_MAX_VIDEO_CHANNELS; i++) |
|---|
| 318 | { |
|---|
| 319 | pstChannelStatus = &hXvdStatus->astChannelStatus[i]; |
|---|
| 320 | if (hXvdStatus->auiOpenChannelCount[i]) |
|---|
| 321 | { |
|---|
| 322 | BDBG_MSG(("Channel[%d][%02d]: uiOpenChannelCount = %d", hXvdStatus->hXvd->uDecoderInstance, i, hXvdStatus->auiOpenChannelCount[i])); |
|---|
| 323 | BDBG_MSG(("Channel[%d][%02d]: uiCloseChannelCount = %d", hXvdStatus->hXvd->uDecoderInstance, i, hXvdStatus->auiCloseChannelCount[i])); |
|---|
| 324 | BDBG_MSG(("Channel[%d][%02d]: uiStartDecodeCount = %d", hXvdStatus->hXvd->uDecoderInstance, i, hXvdStatus->auiStartDecodeCount[i])); |
|---|
| 325 | BDBG_MSG(("Channel[%d][%02d]: uiStopDecodeCount = %d", hXvdStatus->hXvd->uDecoderInstance, i, hXvdStatus->auiStopDecodeCount[i])); |
|---|
| 326 | |
|---|
| 327 | BDBG_MSG(("Channel[%d][%02d]: ulUnderflowCount = %d", hXvdStatus->hXvd->uDecoderInstance, i, pstChannelStatus->ulUnderflowCount)); |
|---|
| 328 | BDBG_MSG(("Channel[%d][%02d]: ulPictureDeliveryCount = %d", hXvdStatus->hXvd->uDecoderInstance, i, pstChannelStatus->ulPictureDeliveryCount)); |
|---|
| 329 | BDBG_MSG(("Channel[%d][%02d]: uiDisplayManagerDroppedCount = %d", hXvdStatus->hXvd->uDecoderInstance, i, pstChannelStatus->uiDisplayManagerDroppedCount)); |
|---|
| 330 | BDBG_MSG(("Channel[%d][%02d]: uiDecoderDroppedCount = %d", hXvdStatus->hXvd->uDecoderInstance, i, pstChannelStatus->uiDecoderDroppedCount)); |
|---|
| 331 | BDBG_MSG(("Channel[%d][%02d]: uiDisplayedParityFailureCount = %d", hXvdStatus->hXvd->uDecoderInstance, i, pstChannelStatus->uiDisplayedParityFailureCount)); |
|---|
| 332 | BDBG_MSG(("Channel[%d][%02d]: uiDisplayedCount = %d", hXvdStatus->hXvd->uDecoderInstance, i, pstChannelStatus->uiDisplayedCount)); |
|---|
| 333 | BDBG_MSG(("Channel[%d][%02d]: uiPicturesDecodedCount = %d", hXvdStatus->hXvd->uDecoderInstance, i, pstChannelStatus->uiPicturesDecodedCount)); |
|---|
| 334 | BDBG_MSG(("Channel[%d][%02d]: uiVsyncUnderflowCount = %d", hXvdStatus->hXvd->uDecoderInstance, i, pstChannelStatus->uiVsyncUnderflowCount)); |
|---|
| 335 | BDBG_MSG(("Channel[%d][%02d]: uiDecodeErrorCount = %d", hXvdStatus->hXvd->uDecoderInstance, i, pstChannelStatus->uiDecodeErrorCount)); |
|---|
| 336 | BDBG_MSG(("Channel[%d][%02d]: uiVsyncCount = %d", hXvdStatus->hXvd->uDecoderInstance, i, pstChannelStatus->uiVsyncCount)); |
|---|
| 337 | } |
|---|
| 338 | } |
|---|
| 339 | |
|---|
| 340 | BDBG_MSG(("End Printing Status")); |
|---|
| 341 | |
|---|
| 342 | return BERR_TRACE(BERR_SUCCESS); |
|---|
| 343 | } |
|---|