| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-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: bvdc_cm3d.c $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/13 $ |
|---|
| 12 | * $brcm_Date: 6/18/10 8:51p $ |
|---|
| 13 | * |
|---|
| 14 | * [File Description:] |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/portinginterface/vdc/7038/bvdc_cm3d.c $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/13 6/18/10 8:51p rpan |
|---|
| 21 | * SW7400-2763: Fixed compile errors. |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/12 4/19/10 10:12p tdo |
|---|
| 24 | * SW3548-2814: Improvements to VDC ulBlackMagic. Move |
|---|
| 25 | * BDBG_OBJECT_ID_DECLARE private header files instead of .c. |
|---|
| 26 | * |
|---|
| 27 | * Hydra_Software_Devel/11 4/7/10 11:27a tdo |
|---|
| 28 | * SW3548-2814: Improvements to VDC ulBlackMagic. Rename TLA |
|---|
| 29 | * |
|---|
| 30 | * Hydra_Software_Devel/10 4/5/10 3:59p tdo |
|---|
| 31 | * SW3548-2814: Improvements to VDC ulBlackMagic |
|---|
| 32 | * |
|---|
| 33 | * Hydra_Software_Devel/9 5/13/09 12:31a pntruong |
|---|
| 34 | * PR51108: Coverity Defect ID:13602 OVERRUN_STATIC. |
|---|
| 35 | * |
|---|
| 36 | * Hydra_Software_Devel/8 12/3/08 5:04p jessem |
|---|
| 37 | * PR 48992: Added Chroma Histogram API support. |
|---|
| 38 | * |
|---|
| 39 | * Hydra_Software_Devel/7 11/20/08 12:03p jessem |
|---|
| 40 | * PR 49411: Fixed bounds check on number of CM3D regions. |
|---|
| 41 | * |
|---|
| 42 | * Hydra_Software_Devel/6 10/7/08 11:09a jessem |
|---|
| 43 | * PR 39335: Changed memcpy to simple assignment. |
|---|
| 44 | * |
|---|
| 45 | * Hydra_Software_Devel/5 10/7/08 9:57a jessem |
|---|
| 46 | * PR 39335: Enclosed getting of CM3D settings structure in critical |
|---|
| 47 | * section. |
|---|
| 48 | * |
|---|
| 49 | * Hydra_Software_Devel/4 5/2/08 10:55a jessem |
|---|
| 50 | * PR 39335: Corrected hWindow parameter to BVDC_P_Cm3dStoreRegionInfo and |
|---|
| 51 | * BVDC_P_Cm3dStoreOverlappedRegionInfo. |
|---|
| 52 | * |
|---|
| 53 | * Hydra_Software_Devel/3 3/31/08 5:25p jessem |
|---|
| 54 | * PR 39335: Added conditional compile directives. |
|---|
| 55 | * |
|---|
| 56 | * Hydra_Software_Devel/2 3/31/08 3:17p jessem |
|---|
| 57 | * PR 39335: Modified implementation. |
|---|
| 58 | * |
|---|
| 59 | * Hydra_Software_Devel/1 3/31/08 2:17p jessem |
|---|
| 60 | * PR 39335: Initial version |
|---|
| 61 | * |
|---|
| 62 | ***************************************************************************/ |
|---|
| 63 | #include "bstd.h" |
|---|
| 64 | #include "bdbg.h" |
|---|
| 65 | #include "berr.h" |
|---|
| 66 | |
|---|
| 67 | #include "bvdc.h" |
|---|
| 68 | #include "bvdc_priv.h" |
|---|
| 69 | #include "bvdc_cm3d_priv.h" |
|---|
| 70 | #include "bvdc_window_priv.h" |
|---|
| 71 | |
|---|
| 72 | BDBG_MODULE(BVDC_CM3D); |
|---|
| 73 | |
|---|
| 74 | BERR_Code BVDC_Window_SetCm3dRegion |
|---|
| 75 | ( BVDC_Window_Handle hWindow, |
|---|
| 76 | const BVDC_Cm3dRegion *pstRegion, |
|---|
| 77 | uint32_t ulRegionId ) |
|---|
| 78 | { |
|---|
| 79 | BERR_Code err = BERR_SUCCESS; |
|---|
| 80 | |
|---|
| 81 | BDBG_ENTER(BVDC_Window_SetCm3dRegion); |
|---|
| 82 | |
|---|
| 83 | #if (BVDC_P_SUPPORT_CM3D) |
|---|
| 84 | BDBG_OBJECT_ASSERT(hWindow, BVDC_WIN); |
|---|
| 85 | BDBG_ASSERT(pstRegion); |
|---|
| 86 | BDBG_ASSERT(ulRegionId < BVDC_MAX_CM3D_REGIONS); |
|---|
| 87 | |
|---|
| 88 | err = BVDC_P_Cm3d_ValidateRegion(pstRegion, ulRegionId); |
|---|
| 89 | if (err != BERR_SUCCESS) |
|---|
| 90 | { |
|---|
| 91 | return err; |
|---|
| 92 | } |
|---|
| 93 | else |
|---|
| 94 | { |
|---|
| 95 | /* only support main display's main window */ |
|---|
| 96 | if(hWindow->eId != BVDC_P_WindowId_eComp0_V0) |
|---|
| 97 | { |
|---|
| 98 | return BERR_TRACE(BVDC_ERR_CM3D_WINDOW_NOT_SUPPORTED); |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | BVDC_P_Cm3dStoreRegionInfo(hWindow, pstRegion, ulRegionId); |
|---|
| 102 | } |
|---|
| 103 | #else |
|---|
| 104 | BSTD_UNUSED(hWindow); |
|---|
| 105 | BSTD_UNUSED(pstRegion); |
|---|
| 106 | BSTD_UNUSED(ulRegionId); |
|---|
| 107 | #endif |
|---|
| 108 | |
|---|
| 109 | BDBG_LEAVE(BVDC_Window_SetCm3dRegion); |
|---|
| 110 | return err; |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | BERR_Code BVDC_Window_GetCm3dRegion |
|---|
| 114 | ( BVDC_Window_Handle hWindow, |
|---|
| 115 | BVDC_Cm3dRegion *pstRegion, |
|---|
| 116 | uint32_t ulRegionId ) |
|---|
| 117 | { |
|---|
| 118 | BERR_Code err = BERR_SUCCESS; |
|---|
| 119 | |
|---|
| 120 | BDBG_ENTER(BVDC_Window_GetCm3dRegion); |
|---|
| 121 | |
|---|
| 122 | #if (BVDC_P_SUPPORT_CM3D) |
|---|
| 123 | BDBG_OBJECT_ASSERT(hWindow, BVDC_WIN); |
|---|
| 124 | BDBG_ASSERT(pstRegion); |
|---|
| 125 | |
|---|
| 126 | /* only support main display's main window */ |
|---|
| 127 | if(hWindow->eId != BVDC_P_WindowId_eComp0_V0) |
|---|
| 128 | { |
|---|
| 129 | return BERR_TRACE(BVDC_ERR_CM3D_WINDOW_NOT_SUPPORTED); |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | if(ulRegionId < (sizeof(hWindow->stCurResource.hCm3d->astRegion)/sizeof(BVDC_Cm3dRegion))) |
|---|
| 133 | { |
|---|
| 134 | BKNI_EnterCriticalSection(); |
|---|
| 135 | *pstRegion = hWindow->stCurResource.hCm3d->astRegion[ulRegionId]; |
|---|
| 136 | BKNI_LeaveCriticalSection(); |
|---|
| 137 | } |
|---|
| 138 | else |
|---|
| 139 | { |
|---|
| 140 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 141 | } |
|---|
| 142 | |
|---|
| 143 | #else |
|---|
| 144 | BSTD_UNUSED(hWindow); |
|---|
| 145 | BSTD_UNUSED(pstRegion); |
|---|
| 146 | BSTD_UNUSED(ulRegionId); |
|---|
| 147 | #endif |
|---|
| 148 | |
|---|
| 149 | BDBG_LEAVE(BVDC_Window_GetCm3dRegion); |
|---|
| 150 | return err; |
|---|
| 151 | } |
|---|
| 152 | |
|---|
| 153 | BERR_Code BVDC_Window_SetCm3dOverlappedRegion |
|---|
| 154 | ( BVDC_Window_Handle hWindow, |
|---|
| 155 | const BVDC_Cm3dOverlappedRegion *pstRegion, |
|---|
| 156 | uint32_t ulRegionId ) |
|---|
| 157 | { |
|---|
| 158 | BERR_Code err = BERR_SUCCESS; |
|---|
| 159 | |
|---|
| 160 | BDBG_ENTER(BVDC_Window_SetCm3dOverlappedRegion); |
|---|
| 161 | |
|---|
| 162 | #if (BVDC_P_SUPPORT_CM3D) |
|---|
| 163 | BDBG_OBJECT_ASSERT(hWindow, BVDC_WIN); |
|---|
| 164 | BDBG_ASSERT(pstRegion); |
|---|
| 165 | BDBG_ASSERT(ulRegionId < BVDC_MAX_CM3D_REGIONS); |
|---|
| 166 | |
|---|
| 167 | err = BVDC_P_Cm3d_ValidateOverlappedRegion(pstRegion, ulRegionId); |
|---|
| 168 | if (err != BERR_SUCCESS) |
|---|
| 169 | { |
|---|
| 170 | return err; |
|---|
| 171 | } |
|---|
| 172 | else |
|---|
| 173 | { |
|---|
| 174 | /* only support main display's main window */ |
|---|
| 175 | if(hWindow->eId != BVDC_P_WindowId_eComp0_V0) |
|---|
| 176 | { |
|---|
| 177 | return BERR_TRACE(BVDC_ERR_CM3D_WINDOW_NOT_SUPPORTED); |
|---|
| 178 | } |
|---|
| 179 | |
|---|
| 180 | BVDC_P_Cm3dStoreOverlappedRegionInfo(hWindow, pstRegion, ulRegionId); |
|---|
| 181 | } |
|---|
| 182 | #else |
|---|
| 183 | BSTD_UNUSED(hWindow); |
|---|
| 184 | BSTD_UNUSED(pstRegion); |
|---|
| 185 | BSTD_UNUSED(ulRegionId); |
|---|
| 186 | #endif |
|---|
| 187 | |
|---|
| 188 | BDBG_LEAVE(BVDC_Window_SetCm3dOverlappedRegion); |
|---|
| 189 | return err; |
|---|
| 190 | } |
|---|
| 191 | |
|---|
| 192 | BERR_Code BVDC_Window_GetCm3dOverlappedRegion |
|---|
| 193 | ( BVDC_Window_Handle hWindow, |
|---|
| 194 | BVDC_Cm3dOverlappedRegion *pstRegion, |
|---|
| 195 | uint32_t ulRegionId ) |
|---|
| 196 | { |
|---|
| 197 | BERR_Code err = BERR_SUCCESS; |
|---|
| 198 | |
|---|
| 199 | BDBG_ENTER(BVDC_Window_SetCm3dOverlappedRegion); |
|---|
| 200 | |
|---|
| 201 | #if (BVDC_P_SUPPORT_CM3D) |
|---|
| 202 | BDBG_OBJECT_ASSERT(hWindow, BVDC_WIN); |
|---|
| 203 | BDBG_ASSERT(pstRegion); |
|---|
| 204 | |
|---|
| 205 | /* only support main display's main window */ |
|---|
| 206 | if(hWindow->eId != BVDC_P_WindowId_eComp0_V0) |
|---|
| 207 | { |
|---|
| 208 | return BERR_TRACE(BVDC_ERR_CM3D_WINDOW_NOT_SUPPORTED); |
|---|
| 209 | } |
|---|
| 210 | |
|---|
| 211 | if(ulRegionId < (sizeof(hWindow->stCurResource.hCm3d->astOvlpRegion)/sizeof(BVDC_Cm3dOverlappedRegion))) |
|---|
| 212 | { |
|---|
| 213 | BKNI_EnterCriticalSection(); |
|---|
| 214 | *pstRegion = hWindow->stCurResource.hCm3d->astOvlpRegion[ulRegionId]; |
|---|
| 215 | BKNI_LeaveCriticalSection(); |
|---|
| 216 | } |
|---|
| 217 | else |
|---|
| 218 | { |
|---|
| 219 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 220 | } |
|---|
| 221 | #else |
|---|
| 222 | BSTD_UNUSED(hWindow); |
|---|
| 223 | BSTD_UNUSED(pstRegion); |
|---|
| 224 | BSTD_UNUSED(ulRegionId); |
|---|
| 225 | #endif |
|---|
| 226 | |
|---|
| 227 | BDBG_LEAVE(BVDC_Window_SetCm3dOverlappedRegion); |
|---|
| 228 | return err; |
|---|
| 229 | } |
|---|
| 230 | |
|---|
| 231 | /*************************************************************************** |
|---|
| 232 | * |
|---|
| 233 | */ |
|---|
| 234 | BERR_Code BVDC_Window_SetChromaStatsConfiguration |
|---|
| 235 | ( BVDC_Window_Handle hWindow, |
|---|
| 236 | const BVDC_ChromaSettings *pSettings ) |
|---|
| 237 | { |
|---|
| 238 | BERR_Code err = BERR_SUCCESS; |
|---|
| 239 | |
|---|
| 240 | BDBG_ENTER(BVDC_Window_SetChromaStatsConfiguration); |
|---|
| 241 | |
|---|
| 242 | #if (BVDC_P_SUPPORT_CM3D) |
|---|
| 243 | BDBG_OBJECT_ASSERT(hWindow, BVDC_WIN); |
|---|
| 244 | |
|---|
| 245 | if((hWindow->eId != BVDC_P_WindowId_eComp0_V0) && (!hWindow->bChromaHistAvail)) |
|---|
| 246 | { |
|---|
| 247 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 248 | } |
|---|
| 249 | |
|---|
| 250 | if (!pSettings) |
|---|
| 251 | { |
|---|
| 252 | hWindow->stNewInfo.bChromaHistEnable = false; |
|---|
| 253 | } |
|---|
| 254 | else |
|---|
| 255 | { |
|---|
| 256 | if(pSettings->stRegion.ulLeft > BVDC_P_CLIPRECT_PERCENT || |
|---|
| 257 | pSettings->stRegion.ulRight > BVDC_P_CLIPRECT_PERCENT || |
|---|
| 258 | pSettings->stRegion.ulTop > BVDC_P_CLIPRECT_PERCENT || |
|---|
| 259 | pSettings->stRegion.ulBottom > BVDC_P_CLIPRECT_PERCENT || |
|---|
| 260 | pSettings->stRegion.ulLeft + pSettings->stRegion.ulRight > BVDC_P_CLIPRECT_PERCENT || |
|---|
| 261 | pSettings->stRegion.ulTop + pSettings->stRegion.ulBottom > BVDC_P_CLIPRECT_PERCENT || |
|---|
| 262 | pSettings->ulHueMax > BVDC_P_MAX_CHIST_HUE_ANGLE || |
|---|
| 263 | pSettings->ulHueMin > BVDC_P_MAX_CHIST_HUE_ANGLE) |
|---|
| 264 | { |
|---|
| 265 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 266 | } |
|---|
| 267 | |
|---|
| 268 | hWindow->stNewInfo.stChromaRect = *pSettings; |
|---|
| 269 | hWindow->stNewInfo.bChromaHistEnable = true; |
|---|
| 270 | } |
|---|
| 271 | |
|---|
| 272 | #else |
|---|
| 273 | BSTD_UNUSED(hWindow); |
|---|
| 274 | BSTD_UNUSED(pSettings); |
|---|
| 275 | #endif |
|---|
| 276 | |
|---|
| 277 | BDBG_LEAVE(BVDC_Window_SetChromaStatsConfiguration); |
|---|
| 278 | return err; |
|---|
| 279 | } |
|---|
| 280 | |
|---|
| 281 | /*************************************************************************** |
|---|
| 282 | * |
|---|
| 283 | */ |
|---|
| 284 | BERR_Code BVDC_Window_GetChromaStatsConfiguration |
|---|
| 285 | ( BVDC_Window_Handle hWindow, |
|---|
| 286 | BVDC_ChromaSettings *pSettings ) |
|---|
| 287 | { |
|---|
| 288 | BDBG_ENTER(BVDC_Window_GetChromaStatsConfiguration); |
|---|
| 289 | |
|---|
| 290 | #if (BVDC_P_SUPPORT_CM3D) |
|---|
| 291 | BDBG_OBJECT_ASSERT(hWindow, BVDC_WIN); |
|---|
| 292 | |
|---|
| 293 | if((hWindow->eId != BVDC_P_WindowId_eComp0_V0) && (!hWindow->bChromaHistAvail)) |
|---|
| 294 | { |
|---|
| 295 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 296 | } |
|---|
| 297 | |
|---|
| 298 | if (pSettings) |
|---|
| 299 | { |
|---|
| 300 | *pSettings = hWindow->stCurInfo.stChromaRect; |
|---|
| 301 | } |
|---|
| 302 | |
|---|
| 303 | #else |
|---|
| 304 | BSTD_UNUSED(hWindow); |
|---|
| 305 | BSTD_UNUSED(pSettings); |
|---|
| 306 | #endif |
|---|
| 307 | |
|---|
| 308 | BDBG_LEAVE(BVDC_Window_GetChromaStatsConfiguration); |
|---|
| 309 | return BERR_SUCCESS; |
|---|
| 310 | } |
|---|
| 311 | |
|---|
| 312 | /*************************************************************************** |
|---|
| 313 | * |
|---|
| 314 | */ |
|---|
| 315 | BERR_Code BVDC_Window_GetChromaStatus |
|---|
| 316 | ( const BVDC_Window_Handle hWindow, |
|---|
| 317 | BVDC_ChromaStatus *pStatus ) |
|---|
| 318 | { |
|---|
| 319 | BDBG_ENTER(BVDC_Window_GetChromaStatus); |
|---|
| 320 | |
|---|
| 321 | #if BVDC_P_SUPPORT_CM3D |
|---|
| 322 | BDBG_OBJECT_ASSERT(hWindow, BVDC_WIN); |
|---|
| 323 | |
|---|
| 324 | if((hWindow->eId != BVDC_P_WindowId_eComp0_V0) && (!hWindow->bChromaHistAvail)) |
|---|
| 325 | { |
|---|
| 326 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 327 | } |
|---|
| 328 | |
|---|
| 329 | /* set return value */ |
|---|
| 330 | if (pStatus) |
|---|
| 331 | { |
|---|
| 332 | if ((hWindow->bChromaHistAvail) && (hWindow->stCurInfo.bChromaHistEnable)) |
|---|
| 333 | { |
|---|
| 334 | BVDC_P_Cm3d_GetChromaHistogramData(hWindow->stCurResource.hCm3d, pStatus); |
|---|
| 335 | } |
|---|
| 336 | else |
|---|
| 337 | { |
|---|
| 338 | BDBG_ERR(("Chroma Histogram collection is not enabled, cannot retrieve histogram data")); |
|---|
| 339 | return BERR_TRACE(BERR_NOT_SUPPORTED); |
|---|
| 340 | } |
|---|
| 341 | } |
|---|
| 342 | |
|---|
| 343 | #else |
|---|
| 344 | BSTD_UNUSED(hWindow); |
|---|
| 345 | BSTD_UNUSED(pStatus); |
|---|
| 346 | #endif |
|---|
| 347 | |
|---|
| 348 | BDBG_LEAVE(BVDC_Window_GetChromaStatus); |
|---|
| 349 | return BERR_SUCCESS; |
|---|
| 350 | } |
|---|
| 351 | |
|---|
| 352 | |
|---|
| 353 | /* End of file */ |
|---|