| 1 | /*************************************************************************** |
|---|
| 2 | * (c)2007-2011 Broadcom Corporation |
|---|
| 3 | * |
|---|
| 4 | * This program is the proprietary software of Broadcom Corporation and/or its licensors, |
|---|
| 5 | * and may only be used, duplicated, modified or distributed pursuant to the terms and |
|---|
| 6 | * conditions of a separate, written license agreement executed between you and Broadcom |
|---|
| 7 | * (an "Authorized License"). Except as set forth in an Authorized License, Broadcom grants |
|---|
| 8 | * no license (express or implied), right to use, or waiver of any kind with respect to the |
|---|
| 9 | * Software, and Broadcom expressly reserves all rights in and to the Software and all |
|---|
| 10 | * intellectual property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU |
|---|
| 11 | * HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY |
|---|
| 12 | * NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. |
|---|
| 13 | * |
|---|
| 14 | * Except as expressly set forth in the Authorized License, |
|---|
| 15 | * |
|---|
| 16 | * 1. This program, including its structure, sequence and organization, constitutes the valuable trade |
|---|
| 17 | * secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof, |
|---|
| 18 | * and to use this information only in connection with your use of Broadcom integrated circuit products. |
|---|
| 19 | * |
|---|
| 20 | * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" |
|---|
| 21 | * AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR |
|---|
| 22 | * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO |
|---|
| 23 | * THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES |
|---|
| 24 | * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, |
|---|
| 25 | * LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION |
|---|
| 26 | * OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF |
|---|
| 27 | * USE OR PERFORMANCE OF THE SOFTWARE. |
|---|
| 28 | * |
|---|
| 29 | * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS |
|---|
| 30 | * LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR |
|---|
| 31 | * EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR |
|---|
| 32 | * USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF |
|---|
| 33 | * THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT |
|---|
| 34 | * ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE |
|---|
| 35 | * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF |
|---|
| 36 | * ANY LIMITED REMEDY. |
|---|
| 37 | * |
|---|
| 38 | * $brcm_Workfile: nexus_video_adj.c $ |
|---|
| 39 | * $brcm_Revision: 34 $ |
|---|
| 40 | * $brcm_Date: 11/15/11 3:27p $ |
|---|
| 41 | * |
|---|
| 42 | * Module Description: |
|---|
| 43 | * |
|---|
| 44 | * Revision History: |
|---|
| 45 | * |
|---|
| 46 | * $brcm_Log: /nexus/modules/display/7400/src/nexus_video_adj.c $ |
|---|
| 47 | * |
|---|
| 48 | * 34 11/15/11 3:27p erickson |
|---|
| 49 | * SW7425-1747: remove old code |
|---|
| 50 | * |
|---|
| 51 | * 33 4/20/11 6:12p jtna |
|---|
| 52 | * SW7425-365: fix build warnings for 2.6.37 kernel |
|---|
| 53 | * |
|---|
| 54 | * 32 9/17/10 12:07p mward |
|---|
| 55 | * SW7125-424: Add NEXUS_DISPLAY_DEINTERLACER_HALFBITS_PER_PIXEL to |
|---|
| 56 | * nexus_platform_features.h to use deinterlacer compression on platforms |
|---|
| 57 | * that need it, such as 97125. |
|---|
| 58 | * |
|---|
| 59 | * 31 5/13/10 10:55a erickson |
|---|
| 60 | * SW3548-2921: add pq_disabled=y support |
|---|
| 61 | * |
|---|
| 62 | * 30 3/26/10 12:26p erickson |
|---|
| 63 | * SW3548-2858: functions that malloc/free custom data for VDC need to |
|---|
| 64 | * |
|---|
| 65 | * 29 2/11/10 1:38p erickson |
|---|
| 66 | * SW7405-3829: change impl to new vdc bShrinkWidth api |
|---|
| 67 | * |
|---|
| 68 | * 28 2/10/10 2:35p erickson |
|---|
| 69 | * SW7405-3829: refactor internal functions to create/destroy VDC window. |
|---|
| 70 | * NEXUS_VideoWindowMadSettings.shrinkWidth requires window to be |
|---|
| 71 | * recreated. |
|---|
| 72 | * |
|---|
| 73 | * 27 8/10/09 8:39a gmohile |
|---|
| 74 | * PR 56400 : Fix legacy vdc mad settings |
|---|
| 75 | * |
|---|
| 76 | * 26 8/10/09 8:17a gmohile |
|---|
| 77 | * PR 56400 : Merge legacy vdc support to main line |
|---|
| 78 | * |
|---|
| 79 | * 25 7/31/09 11:17a gmohile |
|---|
| 80 | * PR 56512 : Add 7403 support |
|---|
| 81 | * |
|---|
| 82 | * 24 3/19/09 10:57a erickson |
|---|
| 83 | * PR52461: get rid of BVDC_Source_Get/SetAnrConfiguration |
|---|
| 84 | * |
|---|
| 85 | * 23 3/17/09 2:00p erickson |
|---|
| 86 | * PR53331: check return code on NEXUS_VideoInput_P_Get |
|---|
| 87 | * |
|---|
| 88 | * 22 2/24/09 6:08p nickh |
|---|
| 89 | * PR52461: Merge 7420 ANR Nexus changes to main branch |
|---|
| 90 | * |
|---|
| 91 | * 7420_mcvp/2 2/24/09 5:58p nickh |
|---|
| 92 | * PR52461: Restrict ANR changes to 7420 |
|---|
| 93 | * |
|---|
| 94 | * 7420_mcvp/1 2/5/09 9:51a syang |
|---|
| 95 | * PR 45785, PR 45789: get rid of BVDC_Source_Get/SetAnrConfiguration |
|---|
| 96 | * |
|---|
| 97 | * 21 12/1/08 2:24p erickson |
|---|
| 98 | * PR49499: consolidate CUSTOM_VIDEO_ADJ code into |
|---|
| 99 | * NEXUS_VideoAdj_P_SetCustomValues function |
|---|
| 100 | * |
|---|
| 101 | * 20 10/29/08 11:38a erickson |
|---|
| 102 | * PR48028: added deringing and dejagging options to |
|---|
| 103 | * NEXUS_VideoWindowScalerSettings |
|---|
| 104 | * |
|---|
| 105 | * 19 9/25/08 9:45a erickson |
|---|
| 106 | * PR47113: replace NEXUS_VideoWindow_SetScalerCoefficientIndex with |
|---|
| 107 | * NEXUS_VideoWindow_SetCoefficientIndexSettings |
|---|
| 108 | * |
|---|
| 109 | * 18 9/16/08 5:17p erickson |
|---|
| 110 | * PR46967: fix naming of NEXUS_VideoWindowScalerSettings |
|---|
| 111 | * |
|---|
| 112 | * 17 7/17/08 9:34a erickson |
|---|
| 113 | * PR44764: update for BVDC_Window_SetBandwidthEquationParams api change |
|---|
| 114 | * |
|---|
| 115 | * 16 7/11/08 5:05p erickson |
|---|
| 116 | * PR44764: VDC API changing. commenting out for now. |
|---|
| 117 | * |
|---|
| 118 | * 15 6/18/08 10:04a erickson |
|---|
| 119 | * PR43617: extended NEXUS_VideoWindowScalerSettings with bandwidth equation |
|---|
| 120 | * params |
|---|
| 121 | * |
|---|
| 122 | * 14 6/16/08 12:17p erickson |
|---|
| 123 | * PR43699: Remove VDC Get's from NEXUS GetSettings calls to avoid race |
|---|
| 124 | * conditions |
|---|
| 125 | * |
|---|
| 126 | * 13 6/12/08 12:49p erickson |
|---|
| 127 | * PR43488: merge |
|---|
| 128 | * |
|---|
| 129 | * PR43488/1 6/10/08 4:36p dyzhang |
|---|
| 130 | * PR43488: anr need to be set in both source and window |
|---|
| 131 | * |
|---|
| 132 | * 12 5/23/08 10:49a erickson |
|---|
| 133 | * PR42982: rework PQ Dirty logic to reapply settings on channel change |
|---|
| 134 | * |
|---|
| 135 | * 11 5/21/08 9:39a erickson |
|---|
| 136 | * PR40567: remove unneeded BCHP_CHIP != 7405 wrappers |
|---|
| 137 | * |
|---|
| 138 | * 10 4/7/08 10:37a vsilyaev |
|---|
| 139 | * PR 40567: Partially revert back pixelformat settings, removed in main/6 |
|---|
| 140 | * |
|---|
| 141 | * 9 4/3/08 10:47a erickson |
|---|
| 142 | * PR41122: fix B_HAS_LEGACY_VDC |
|---|
| 143 | * |
|---|
| 144 | * 8 4/3/08 10:17a erickson |
|---|
| 145 | * PR41122: move picture quality code to 7400 |
|---|
| 146 | * |
|---|
| 147 | * 7 3/31/08 12:32p erickson |
|---|
| 148 | * PR41073: check result of malloc and fail graciously |
|---|
| 149 | * |
|---|
| 150 | * 6 3/27/08 4:51p vsilyaev |
|---|
| 151 | * PR 40818: Improved internal API to allow source private heaps |
|---|
| 152 | * |
|---|
| 153 | * 5 3/26/08 2:37p erickson |
|---|
| 154 | * PR40950: set custom ANR/DNR data in custom function |
|---|
| 155 | * |
|---|
| 156 | * 4 3/26/08 12:54p erickson |
|---|
| 157 | * PR40567: add MAD and ANR pixel format |
|---|
| 158 | * |
|---|
| 159 | * PR40567/2 3/26/08 6:22p dyzhang |
|---|
| 160 | * PR40567: use pixel format transfer function |
|---|
| 161 | * |
|---|
| 162 | * PR40567/1 3/26/08 4:20p xhuang |
|---|
| 163 | * PR40567:add pixel format set in Nexus |
|---|
| 164 | * |
|---|
| 165 | * 3 3/24/08 10:39a erickson |
|---|
| 166 | * PR39202: merge |
|---|
| 167 | * |
|---|
| 168 | * PR39202/1 3/21/08 1:37p xhuang |
|---|
| 169 | * PR39202: temp to add default setting for MAD pixel format to remove |
|---|
| 170 | * runtime error |
|---|
| 171 | * |
|---|
| 172 | * 2 1/25/08 9:42a erickson |
|---|
| 173 | * PR39003: adapt to latest VDC |
|---|
| 174 | * |
|---|
| 175 | * 1 1/18/08 2:20p jgarrett |
|---|
| 176 | * PR 38808: Merging to main branch |
|---|
| 177 | * |
|---|
| 178 | * Nexus_Devel/9 1/8/08 3:52p erickson |
|---|
| 179 | * PR36159: rename DNR/ANR/MAD functions to be VideoWindow |
|---|
| 180 | * |
|---|
| 181 | * Nexus_Devel/8 1/8/08 10:57a erickson |
|---|
| 182 | * PR36159: refactor some 3563 Display API's |
|---|
| 183 | * |
|---|
| 184 | * Nexus_Devel/7 11/29/07 2:23p vsilyaev |
|---|
| 185 | * PR 36159: All XXX_GetYYYSettings functions shall return void |
|---|
| 186 | * |
|---|
| 187 | * Nexus_Devel/6 11/29/07 1:10p vsilyaev |
|---|
| 188 | * PR 36159: Reworked capture function to return the Nexus Surface |
|---|
| 189 | * |
|---|
| 190 | * Nexus_Devel/5 11/29/07 11:41a vsilyaev |
|---|
| 191 | * PR 36159: Another renaming of structre members |
|---|
| 192 | * |
|---|
| 193 | * Nexus_Devel/4 11/29/07 11:34a vsilyaev |
|---|
| 194 | * PR 36159: Flatten structure to control noise removal |
|---|
| 195 | * |
|---|
| 196 | * Nexus_Devel/3 11/28/07 1:44p vsilyaev |
|---|
| 197 | * PR 36159: Added global UpdateMode, removed per-function ApplyChanges |
|---|
| 198 | * |
|---|
| 199 | * Nexus_Devel/2 11/28/07 9:34a vsilyaev |
|---|
| 200 | * PR36159: Renamed structure members in new API's |
|---|
| 201 | * |
|---|
| 202 | * Nexus_Devel/1 11/26/07 12:46p vsilyaev |
|---|
| 203 | * PR36159: Merged 3563 code |
|---|
| 204 | * |
|---|
| 205 | * Nexus_Devel/PR36159/1 11/26/07 10:06a gezhang |
|---|
| 206 | * PR36159: Bring up Nexus on 93563 platform |
|---|
| 207 | * |
|---|
| 208 | * Nexus_Devel/1 10/18/07 9:59p gezhang |
|---|
| 209 | * PR36159: Bring up Nexus on 93563 platform |
|---|
| 210 | * |
|---|
| 211 | **************************************************************************/ |
|---|
| 212 | #include "nexus_base.h" |
|---|
| 213 | #include "nexus_display_module.h" |
|---|
| 214 | |
|---|
| 215 | BDBG_MODULE(nexus_video_adj); |
|---|
| 216 | |
|---|
| 217 | /*============================private methods====================================*/ |
|---|
| 218 | |
|---|
| 219 | /*************************************************************************** |
|---|
| 220 | Apply stored settings after the VDC window is created. |
|---|
| 221 | |
|---|
| 222 | In Nexus, the window handle exists w/ or w/o a source. |
|---|
| 223 | In VDC, the window exists only if there's a connected source. |
|---|
| 224 | Therefore, Nexus must store the settings. After the VDC window is created, these settings can be applied. |
|---|
| 225 | ****************************************************************************/ |
|---|
| 226 | NEXUS_Error |
|---|
| 227 | NEXUS_VideoAdj_P_ApplySetSettings( NEXUS_VideoWindowHandle window ) |
|---|
| 228 | { |
|---|
| 229 | NEXUS_Error rc = NEXUS_SUCCESS; |
|---|
| 230 | NEXUS_VideoAdjContext *pContext; |
|---|
| 231 | BVDC_Window_Handle windowVDC; |
|---|
| 232 | |
|---|
| 233 | BDBG_OBJECT_ASSERT(window, NEXUS_VideoWindow); |
|---|
| 234 | windowVDC = window->vdcState.window; |
|---|
| 235 | pContext = &(window->adjContext); |
|---|
| 236 | |
|---|
| 237 | /* Apply DNR settings */ |
|---|
| 238 | if (pContext->bDnrSet) |
|---|
| 239 | { |
|---|
| 240 | rc = NEXUS_VideoWindow_SetCustomDnrSettings(window, |
|---|
| 241 | &pContext->stDnrSettings, pContext->customDnrData, 0 ); |
|---|
| 242 | if (rc != NEXUS_SUCCESS) return BERR_TRACE(rc); |
|---|
| 243 | } |
|---|
| 244 | |
|---|
| 245 | /* Apply ANR settings */ |
|---|
| 246 | if (pContext->bAnrSet) |
|---|
| 247 | { |
|---|
| 248 | rc = NEXUS_VideoWindow_SetCustomAnrSettings(window, |
|---|
| 249 | &pContext->stAnrSettings, pContext->customAnrData, 0 ); |
|---|
| 250 | if (rc != NEXUS_SUCCESS) return BERR_TRACE(rc); |
|---|
| 251 | } |
|---|
| 252 | |
|---|
| 253 | /* Apply MAD settings */ |
|---|
| 254 | if (pContext->bMadSet ) |
|---|
| 255 | { |
|---|
| 256 | rc = NEXUS_VideoWindow_SetMadSettings(window, &pContext->stMadSettings ); |
|---|
| 257 | if (rc != NEXUS_SUCCESS) return BERR_TRACE(rc); |
|---|
| 258 | } |
|---|
| 259 | |
|---|
| 260 | /* Apply Scaler settings */ |
|---|
| 261 | if (pContext->bSclSet) |
|---|
| 262 | { |
|---|
| 263 | rc = NEXUS_VideoWindow_SetScalerSettings(window, |
|---|
| 264 | &pContext->stSclSettings |
|---|
| 265 | ); |
|---|
| 266 | if (rc != NEXUS_SUCCESS) return BERR_TRACE(rc); |
|---|
| 267 | } |
|---|
| 268 | |
|---|
| 269 | if (pContext->bGameModeDelaySet) |
|---|
| 270 | { |
|---|
| 271 | rc = NEXUS_VideoWindow_SetGameModeDelay(window, &pContext->stGameModeDelaySettings ); |
|---|
| 272 | if (rc != NEXUS_SUCCESS) return BERR_TRACE(rc); |
|---|
| 273 | } |
|---|
| 274 | |
|---|
| 275 | if (pContext->bCoefficientIndexSettingsSet) |
|---|
| 276 | { |
|---|
| 277 | rc = NEXUS_VideoWindow_SetCoefficientIndexSettings(window, &pContext->coefficientIndexSettings); |
|---|
| 278 | if (rc != NEXUS_SUCCESS) return BERR_TRACE(rc); |
|---|
| 279 | } |
|---|
| 280 | |
|---|
| 281 | return NEXUS_SUCCESS; |
|---|
| 282 | } |
|---|
| 283 | |
|---|
| 284 | |
|---|
| 285 | /*============================public methods====================================*/ |
|---|
| 286 | |
|---|
| 287 | /*************************************************************************** |
|---|
| 288 | * |
|---|
| 289 | * DNR |
|---|
| 290 | * |
|---|
| 291 | ****************************************************************************/ |
|---|
| 292 | void |
|---|
| 293 | NEXUS_VideoWindow_GetDnrSettings( |
|---|
| 294 | NEXUS_VideoWindowHandle window, |
|---|
| 295 | NEXUS_VideoWindowDnrSettings *pSettings) |
|---|
| 296 | { |
|---|
| 297 | BDBG_OBJECT_ASSERT(window, NEXUS_VideoWindow); |
|---|
| 298 | *pSettings = window->adjContext.stDnrSettings; |
|---|
| 299 | } |
|---|
| 300 | |
|---|
| 301 | NEXUS_Error NEXUS_VideoWindow_SetDnrSettings( NEXUS_VideoWindowHandle window, const NEXUS_VideoWindowDnrSettings *pSettings ) |
|---|
| 302 | { |
|---|
| 303 | return NEXUS_VideoWindow_SetCustomDnrSettings(window, pSettings, NULL, 0); |
|---|
| 304 | } |
|---|
| 305 | |
|---|
| 306 | NEXUS_Error NEXUS_VideoWindow_SetCustomDnrSettings( NEXUS_VideoWindowHandle window, const NEXUS_VideoWindowDnrSettings *pSettings, |
|---|
| 307 | const uint8_t *pData, unsigned numEntries ) |
|---|
| 308 | { |
|---|
| 309 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 310 | NEXUS_VideoAdjContext *pContext; |
|---|
| 311 | #ifdef B_HAS_LEGACY_VDC |
|---|
| 312 | /* mosquito noise reduction */ |
|---|
| 313 | BVDC_DnrFilterLevel mnr_level = BVDC_DnrFilterLevel_eDisable; |
|---|
| 314 | /* block noise reduction */ |
|---|
| 315 | BVDC_DnrFilterLevel bnr_level = BVDC_DnrFilterLevel_eDisable; |
|---|
| 316 | /* digital contour removal */ |
|---|
| 317 | BVDC_DnrFilterLevel dcr_level = BVDC_DnrFilterLevel_eDisable; |
|---|
| 318 | #else |
|---|
| 319 | BVDC_Dnr_Settings DnrSettings; |
|---|
| 320 | #endif |
|---|
| 321 | BVDC_Window_Handle windowVDC; |
|---|
| 322 | NEXUS_VideoInput_P_Link *pLink; |
|---|
| 323 | void *freeAfter = NULL; |
|---|
| 324 | |
|---|
| 325 | BDBG_OBJECT_ASSERT(window, NEXUS_VideoWindow); |
|---|
| 326 | windowVDC = window->vdcState.window; |
|---|
| 327 | pContext = &(window->adjContext); |
|---|
| 328 | BDBG_ASSERT(pSettings); |
|---|
| 329 | |
|---|
| 330 | pContext->bDnrSet = true; |
|---|
| 331 | pContext->stDnrSettings = *pSettings; |
|---|
| 332 | |
|---|
| 333 | /* NEXUS_VideoAdj_P_ApplySetSettings might call this function using the already-saved data */ |
|---|
| 334 | if (pContext->customDnrData != pData || numEntries != 0) { |
|---|
| 335 | if (pContext->customDnrData) { |
|---|
| 336 | /* we cannot free pContext->customDnrData because VDC still has the memory. free after BVDC_ApplyChanges. |
|---|
| 337 | if freeAfter is set, we must execute the "done:" code to avoid a KNI leak. */ |
|---|
| 338 | freeAfter = pContext->customDnrData; |
|---|
| 339 | pContext->customDnrData = NULL; |
|---|
| 340 | } |
|---|
| 341 | if (pData) { |
|---|
| 342 | /* VDC does not copy the data, so we have to. */ |
|---|
| 343 | pContext->customDnrData = BKNI_Malloc(numEntries * sizeof(pData[0])); |
|---|
| 344 | if (!pContext->customDnrData) { |
|---|
| 345 | rc = BERR_TRACE(NEXUS_OUT_OF_SYSTEM_MEMORY); |
|---|
| 346 | goto done; |
|---|
| 347 | } |
|---|
| 348 | BKNI_Memcpy(pContext->customDnrData, pData, numEntries * sizeof(pData[0])); |
|---|
| 349 | } |
|---|
| 350 | } |
|---|
| 351 | |
|---|
| 352 | if (NULL == windowVDC || g_NEXUS_DisplayModule_State.pqDisabled) /* Window not connected */ |
|---|
| 353 | { |
|---|
| 354 | rc = NEXUS_SUCCESS; |
|---|
| 355 | goto done; |
|---|
| 356 | } |
|---|
| 357 | |
|---|
| 358 | pLink = NEXUS_VideoInput_P_Get(window->input); |
|---|
| 359 | if (!pLink) { |
|---|
| 360 | rc = BERR_TRACE(NEXUS_UNKNOWN); |
|---|
| 361 | goto done; |
|---|
| 362 | } |
|---|
| 363 | |
|---|
| 364 | #ifdef B_HAS_LEGACY_VDC |
|---|
| 365 | mnr_level = pSettings->mnr.level + BVDC_DnrFilterLevel_eBypass; |
|---|
| 366 | bnr_level = pSettings->bnr.level + BVDC_DnrFilterLevel_eBypass; |
|---|
| 367 | dcr_level = pSettings->dcr.level + BVDC_DnrFilterLevel_eBypass; |
|---|
| 368 | rc = BVDC_Window_SetDnrFilterLevel(windowVDC, mnr_level, bnr_level, dcr_level); |
|---|
| 369 | if (rc) { |
|---|
| 370 | rc = BERR_TRACE(rc); |
|---|
| 371 | goto done; |
|---|
| 372 | } |
|---|
| 373 | #else |
|---|
| 374 | BVDC_Source_GetDnrConfiguration(pLink->sourceVdc, &DnrSettings); |
|---|
| 375 | DnrSettings.eBnrMode = pSettings->bnr.mode; |
|---|
| 376 | DnrSettings.eDcrMode = pSettings->dcr.mode; |
|---|
| 377 | DnrSettings.eMnrMode = pSettings->mnr.mode; |
|---|
| 378 | DnrSettings.iBnrLevel = pSettings->bnr.level; |
|---|
| 379 | DnrSettings.iMnrLevel = pSettings->mnr.level; |
|---|
| 380 | DnrSettings.iDcrLevel = pSettings->dcr.level; |
|---|
| 381 | DnrSettings.pvUserInfo = pContext->customDnrData; |
|---|
| 382 | DnrSettings.ulQp = pSettings->qp; |
|---|
| 383 | rc = BVDC_Source_SetDnrConfiguration(pLink->sourceVdc, &DnrSettings); |
|---|
| 384 | if (rc) { |
|---|
| 385 | rc = BERR_TRACE(rc); |
|---|
| 386 | goto done; |
|---|
| 387 | } |
|---|
| 388 | #endif |
|---|
| 389 | |
|---|
| 390 | if (freeAfter) { |
|---|
| 391 | /* This NEXUS_Display_P_ApplyChanges must take effect if freeAfter is set. */ |
|---|
| 392 | if(g_NEXUS_DisplayModule_State.updateMode != NEXUS_DisplayUpdateMode_eAuto) { rc = BERR_TRACE(NEXUS_NOT_SUPPORTED);} /* fall through */ |
|---|
| 393 | |
|---|
| 394 | rc = BVDC_ApplyChanges(g_NEXUS_DisplayModule_State.vdc); |
|---|
| 395 | if (rc) { |
|---|
| 396 | rc = BERR_TRACE(rc); |
|---|
| 397 | goto done; |
|---|
| 398 | } |
|---|
| 399 | } |
|---|
| 400 | else { |
|---|
| 401 | rc = NEXUS_Display_P_ApplyChanges(); |
|---|
| 402 | if (rc) { |
|---|
| 403 | rc = BERR_TRACE(rc); |
|---|
| 404 | goto done; |
|---|
| 405 | } |
|---|
| 406 | } |
|---|
| 407 | |
|---|
| 408 | done: |
|---|
| 409 | if (freeAfter) { |
|---|
| 410 | BKNI_Free(freeAfter); |
|---|
| 411 | } |
|---|
| 412 | return rc; |
|---|
| 413 | } /* NEXUS_VideoWindow_SetDnrSettings() */ |
|---|
| 414 | |
|---|
| 415 | /*************************************************************************** |
|---|
| 416 | Summary: |
|---|
| 417 | Get current MAD configurations. |
|---|
| 418 | ****************************************************************************/ |
|---|
| 419 | void |
|---|
| 420 | NEXUS_VideoWindow_GetMadSettings( |
|---|
| 421 | NEXUS_VideoWindowHandle window, |
|---|
| 422 | NEXUS_VideoWindowMadSettings *pSettings) |
|---|
| 423 | { |
|---|
| 424 | BDBG_OBJECT_ASSERT(window, NEXUS_VideoWindow); |
|---|
| 425 | *pSettings = window->adjContext.stMadSettings; |
|---|
| 426 | } |
|---|
| 427 | |
|---|
| 428 | /*************************************************************************** |
|---|
| 429 | Summary: |
|---|
| 430 | Set MAD configurations. |
|---|
| 431 | ****************************************************************************/ |
|---|
| 432 | NEXUS_Error |
|---|
| 433 | NEXUS_VideoWindow_SetMadSettings( |
|---|
| 434 | NEXUS_VideoWindowHandle window, |
|---|
| 435 | const NEXUS_VideoWindowMadSettings *pSettings |
|---|
| 436 | ) |
|---|
| 437 | { |
|---|
| 438 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 439 | NEXUS_VideoAdjContext *pContext; |
|---|
| 440 | BVDC_Window_Handle windowVDC; |
|---|
| 441 | #ifdef B_HAS_LEGACY_VDC |
|---|
| 442 | |
|---|
| 443 | BDBG_OBJECT_ASSERT(window, NEXUS_VideoWindow); |
|---|
| 444 | |
|---|
| 445 | windowVDC = window->vdcState.window; |
|---|
| 446 | pContext = &(window->adjContext); |
|---|
| 447 | BDBG_ASSERT(pSettings); |
|---|
| 448 | |
|---|
| 449 | pContext->bMadSet = true; |
|---|
| 450 | pContext->stMadSettings = *pSettings; |
|---|
| 451 | |
|---|
| 452 | if (NULL == windowVDC || g_NEXUS_DisplayModule_State.pqDisabled) |
|---|
| 453 | { |
|---|
| 454 | return NEXUS_SUCCESS; |
|---|
| 455 | } |
|---|
| 456 | |
|---|
| 457 | rc = BVDC_Window_SetDeinterlace(windowVDC, pSettings->deinterlace); |
|---|
| 458 | if (rc) return BERR_TRACE(rc); |
|---|
| 459 | #else |
|---|
| 460 | BVDC_Deinterlace_Settings madSettings; |
|---|
| 461 | BVDC_Deinterlace_Reverse22Settings Reverse22Setting; |
|---|
| 462 | BVDC_Deinterlace_Reverse32Settings Reverse32Setting; |
|---|
| 463 | BVDC_Deinterlace_ChromaSettings ChromaSettings; |
|---|
| 464 | BVDC_Deinterlace_MotionSettings MotionSettings; |
|---|
| 465 | BVDC_422To444UpSampler upSampler; |
|---|
| 466 | BVDC_444To422DnSampler downSampler; |
|---|
| 467 | BVDC_Deinterlace_LowAngleSettings lowAngles; |
|---|
| 468 | |
|---|
| 469 | BDBG_OBJECT_ASSERT(window, NEXUS_VideoWindow); |
|---|
| 470 | windowVDC = window->vdcState.window; |
|---|
| 471 | pContext = &(window->adjContext); |
|---|
| 472 | BDBG_ASSERT(pSettings); |
|---|
| 473 | |
|---|
| 474 | pContext->bMadSet = true; |
|---|
| 475 | pContext->stMadSettings = *pSettings; |
|---|
| 476 | |
|---|
| 477 | if (NULL == windowVDC || g_NEXUS_DisplayModule_State.pqDisabled) |
|---|
| 478 | { |
|---|
| 479 | return NEXUS_SUCCESS; |
|---|
| 480 | } |
|---|
| 481 | |
|---|
| 482 | /* must hook up substructures before getting a default from VDC. |
|---|
| 483 | there is a risk here that a new substructure is added and not defaults, therefore we memset. */ |
|---|
| 484 | BKNI_Memset(&madSettings, 0, sizeof(madSettings)); |
|---|
| 485 | madSettings.pReverse22Settings = &Reverse22Setting; |
|---|
| 486 | madSettings.pReverse32Settings = &Reverse32Setting; |
|---|
| 487 | madSettings.pChromaSettings = &ChromaSettings; |
|---|
| 488 | madSettings.pMotionSettings = &MotionSettings; |
|---|
| 489 | madSettings.pUpSampler = &upSampler; |
|---|
| 490 | madSettings.pDnSampler = &downSampler; |
|---|
| 491 | madSettings.pLowAngles = &lowAngles; |
|---|
| 492 | BVDC_Window_GetDeinterlaceDefaultConfiguration(windowVDC, &madSettings); |
|---|
| 493 | |
|---|
| 494 | madSettings.bReverse32Pulldown = pSettings->enable32Pulldown; |
|---|
| 495 | madSettings.bReverse22Pulldown = pSettings->enable22Pulldown; |
|---|
| 496 | BDBG_CASSERT(NEXUS_VideoWindowGameMode_eMax == (NEXUS_VideoWindowGameMode)BVDC_MadGameMode_eMaxCount); |
|---|
| 497 | madSettings.eGameMode = pSettings->gameMode; |
|---|
| 498 | madSettings.bShrinkWidth = pSettings->shrinkWidth; |
|---|
| 499 | |
|---|
| 500 | if (pSettings->pixelFormat != NEXUS_PixelFormat_eUnknown) { |
|---|
| 501 | rc = NEXUS_P_PixelFormat_ToMagnum(pSettings->pixelFormat, &madSettings.ePxlFormat); |
|---|
| 502 | if (rc) return BERR_TRACE(rc); |
|---|
| 503 | } |
|---|
| 504 | |
|---|
| 505 | #ifdef NEXUS_DISPLAY_DEINTERLACER_HALFBITS_PER_PIXEL |
|---|
| 506 | madSettings.stVideoTestFeature1.bEnable = (NEXUS_DISPLAY_DEINTERLACER_HALFBITS_PER_PIXEL>0); |
|---|
| 507 | madSettings.stVideoTestFeature1.ulBitsPerPixel = NEXUS_DISPLAY_DEINTERLACER_HALFBITS_PER_PIXEL; |
|---|
| 508 | #endif |
|---|
| 509 | rc = BVDC_Window_SetDeinterlaceConfiguration(windowVDC, pSettings->deinterlace, &madSettings); |
|---|
| 510 | if (rc) return BERR_TRACE(rc); |
|---|
| 511 | |
|---|
| 512 | #endif |
|---|
| 513 | rc = NEXUS_Display_P_ApplyChanges(); |
|---|
| 514 | if (rc) return BERR_TRACE(rc); |
|---|
| 515 | |
|---|
| 516 | return NEXUS_SUCCESS; |
|---|
| 517 | } /* NEXUS_VideoWindow_SetMadSettings() */ |
|---|
| 518 | |
|---|
| 519 | /*************************************************************************** |
|---|
| 520 | Summary: |
|---|
| 521 | Get scaler configurations. |
|---|
| 522 | ****************************************************************************/ |
|---|
| 523 | void |
|---|
| 524 | NEXUS_VideoWindow_GetScalerSettings( |
|---|
| 525 | NEXUS_VideoWindowHandle window, |
|---|
| 526 | NEXUS_VideoWindowScalerSettings *pSettings) |
|---|
| 527 | { |
|---|
| 528 | BDBG_OBJECT_ASSERT(window, NEXUS_VideoWindow); |
|---|
| 529 | *pSettings = window->adjContext.stSclSettings; |
|---|
| 530 | } |
|---|
| 531 | |
|---|
| 532 | /*************************************************************************** |
|---|
| 533 | Summary: |
|---|
| 534 | Set scaler configurations. |
|---|
| 535 | ****************************************************************************/ |
|---|
| 536 | NEXUS_Error |
|---|
| 537 | NEXUS_VideoWindow_SetScalerSettings( |
|---|
| 538 | NEXUS_VideoWindowHandle window, |
|---|
| 539 | const NEXUS_VideoWindowScalerSettings *pSettings |
|---|
| 540 | ) |
|---|
| 541 | { |
|---|
| 542 | #ifdef B_HAS_LEGACY_VDC |
|---|
| 543 | /*TODO : Add scaler support*/ |
|---|
| 544 | BSTD_UNUSED(window); |
|---|
| 545 | BSTD_UNUSED(pSettings); |
|---|
| 546 | #else |
|---|
| 547 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 548 | NEXUS_VideoAdjContext *pContext; |
|---|
| 549 | BVDC_Window_Handle windowVDC; |
|---|
| 550 | |
|---|
| 551 | BDBG_OBJECT_ASSERT(window, NEXUS_VideoWindow); |
|---|
| 552 | windowVDC = window->vdcState.window; |
|---|
| 553 | pContext = &(window->adjContext); |
|---|
| 554 | BDBG_ASSERT(pSettings); |
|---|
| 555 | |
|---|
| 556 | pContext->bSclSet = true; |
|---|
| 557 | pContext->stSclSettings = *pSettings; |
|---|
| 558 | if (pSettings->nonLinearScaling == false) { |
|---|
| 559 | /* clear the setting to be zero after turning off non-linear. */ |
|---|
| 560 | pContext->stSclSettings.nonLinearSourceWidth = 0; |
|---|
| 561 | pContext->stSclSettings.nonLinearScalerOutWidth = 0; |
|---|
| 562 | } |
|---|
| 563 | |
|---|
| 564 | if (NULL == windowVDC || g_NEXUS_DisplayModule_State.pqDisabled) /* window not connected */ |
|---|
| 565 | { |
|---|
| 566 | return NEXUS_SUCCESS; |
|---|
| 567 | } |
|---|
| 568 | |
|---|
| 569 | /* set scaler mode */ |
|---|
| 570 | if (pSettings->nonLinearScaling == true) |
|---|
| 571 | { |
|---|
| 572 | /* TODO - do we need to add in a restriction here to force the |
|---|
| 573 | * nonLinearSourceWidth and nonLinearScalerOutWidth to be larger than one |
|---|
| 574 | * quarter of the source/display width? */ |
|---|
| 575 | BDBG_MSG(("Turn on non-linear, nonLinearSourceWidth=%d, nonLinearScalerOutWidth=%d", |
|---|
| 576 | pSettings->nonLinearSourceWidth, |
|---|
| 577 | pSettings->nonLinearScalerOutWidth)); |
|---|
| 578 | |
|---|
| 579 | rc = BVDC_Window_SetNonLinearScl(windowVDC, |
|---|
| 580 | pSettings->nonLinearSourceWidth, |
|---|
| 581 | pSettings->nonLinearScalerOutWidth); |
|---|
| 582 | if (rc) return BERR_TRACE(rc); |
|---|
| 583 | } |
|---|
| 584 | else |
|---|
| 585 | { |
|---|
| 586 | /* set both source/scl output width to turn off non-linear. If non-linear |
|---|
| 587 | * is turned off, the source/scl output width val in SCL settings will be |
|---|
| 588 | * ignored. */ |
|---|
| 589 | BDBG_MSG(("Turn off non-linear")); |
|---|
| 590 | |
|---|
| 591 | rc = BVDC_Window_SetNonLinearScl(windowVDC, 0, 0); |
|---|
| 592 | if (rc) return BERR_TRACE(rc); |
|---|
| 593 | } |
|---|
| 594 | |
|---|
| 595 | BDBG_CASSERT(BVDC_SclCapBias_eSclAfterCap == (BVDC_SclCapBias)NEXUS_ScalerCaptureBias_eScalerAfterCapture); |
|---|
| 596 | rc = BVDC_Window_SetBandwidthEquationParams(windowVDC, pSettings->bandwidthEquationParams.delta, pSettings->bandwidthEquationParams.bias); |
|---|
| 597 | if (rc) return BERR_TRACE(rc); |
|---|
| 598 | |
|---|
| 599 | rc = NEXUS_Display_P_ApplyChanges(); |
|---|
| 600 | if (rc) return BERR_TRACE(rc); |
|---|
| 601 | #endif |
|---|
| 602 | return NEXUS_SUCCESS; |
|---|
| 603 | } |
|---|
| 604 | |
|---|
| 605 | /*************************************************************************** |
|---|
| 606 | * |
|---|
| 607 | * ANR |
|---|
| 608 | * |
|---|
| 609 | ****************************************************************************/ |
|---|
| 610 | void |
|---|
| 611 | NEXUS_VideoWindow_GetAnrSettings( |
|---|
| 612 | NEXUS_VideoWindowHandle window, |
|---|
| 613 | NEXUS_VideoWindowAnrSettings *pSettings) |
|---|
| 614 | { |
|---|
| 615 | BDBG_OBJECT_ASSERT(window, NEXUS_VideoWindow); |
|---|
| 616 | *pSettings = window->adjContext.stAnrSettings; |
|---|
| 617 | } |
|---|
| 618 | |
|---|
| 619 | NEXUS_Error NEXUS_VideoWindow_SetAnrSettings( NEXUS_VideoWindowHandle window, const NEXUS_VideoWindowAnrSettings *pSettings ) |
|---|
| 620 | { |
|---|
| 621 | return NEXUS_VideoWindow_SetCustomAnrSettings(window, pSettings, NULL, 0); |
|---|
| 622 | } |
|---|
| 623 | |
|---|
| 624 | NEXUS_Error NEXUS_VideoWindow_SetCustomAnrSettings( NEXUS_VideoWindowHandle window, const NEXUS_VideoWindowAnrSettings *pSettings, |
|---|
| 625 | const uint8_t *pData, unsigned numEntries ) |
|---|
| 626 | { |
|---|
| 627 | #ifdef B_HAS_LEGACY_VDC |
|---|
| 628 | /*TODO : Add ANR support*/ |
|---|
| 629 | BDBG_OBJECT_ASSERT(window, NEXUS_VideoWindow); |
|---|
| 630 | BSTD_UNUSED(pSettings); |
|---|
| 631 | BSTD_UNUSED(pData); |
|---|
| 632 | BSTD_UNUSED(numEntries); |
|---|
| 633 | return 0; |
|---|
| 634 | #else |
|---|
| 635 | NEXUS_VideoAdjContext *pContext; |
|---|
| 636 | BVDC_Window_Handle windowVDC; |
|---|
| 637 | NEXUS_VideoInput_P_Link *pLink; |
|---|
| 638 | BERR_Code rc = NEXUS_SUCCESS; |
|---|
| 639 | BVDC_Anr_Settings anrCfg; |
|---|
| 640 | void *freeAfter = NULL; |
|---|
| 641 | |
|---|
| 642 | BDBG_OBJECT_ASSERT(window, NEXUS_VideoWindow); |
|---|
| 643 | windowVDC = window->vdcState.window; |
|---|
| 644 | pContext = &(window->adjContext); |
|---|
| 645 | BDBG_ASSERT(pSettings); |
|---|
| 646 | |
|---|
| 647 | pContext->bAnrSet = true; |
|---|
| 648 | pContext->stAnrSettings = *pSettings; |
|---|
| 649 | |
|---|
| 650 | /* NEXUS_VideoAdj_P_ApplySetSettings might call this function using the already-saved data */ |
|---|
| 651 | if (pContext->customAnrData != pData || numEntries != 0) { |
|---|
| 652 | if (pContext->customAnrData) { |
|---|
| 653 | /* we cannot free pContext->customAnrData because VDC still has the memory. free after BVDC_ApplyChanges. |
|---|
| 654 | if freeAfter is set, we must execute the "done:" code to avoid a KNI leak. */ |
|---|
| 655 | freeAfter = pContext->customAnrData; |
|---|
| 656 | pContext->customAnrData = NULL; |
|---|
| 657 | } |
|---|
| 658 | if (pData) { |
|---|
| 659 | /* VDC does not copy the data, so we have to. */ |
|---|
| 660 | pContext->customAnrData = BKNI_Malloc(numEntries * sizeof(pData[0])); |
|---|
| 661 | if (!pContext->customAnrData) { |
|---|
| 662 | rc = BERR_TRACE(NEXUS_OUT_OF_SYSTEM_MEMORY); |
|---|
| 663 | goto done; |
|---|
| 664 | } |
|---|
| 665 | BKNI_Memcpy(pContext->customAnrData, pData, numEntries * sizeof(pData[0])); |
|---|
| 666 | } |
|---|
| 667 | } |
|---|
| 668 | |
|---|
| 669 | if (NULL == windowVDC || g_NEXUS_DisplayModule_State.pqDisabled) /* window not connected */ |
|---|
| 670 | { |
|---|
| 671 | rc = NEXUS_SUCCESS; |
|---|
| 672 | goto done; |
|---|
| 673 | } |
|---|
| 674 | |
|---|
| 675 | pLink = NEXUS_VideoInput_P_Get(window->input); |
|---|
| 676 | if (!pLink) { |
|---|
| 677 | rc = BERR_TRACE(NEXUS_UNKNOWN); |
|---|
| 678 | goto done; |
|---|
| 679 | } |
|---|
| 680 | |
|---|
| 681 | BVDC_Window_GetAnrConfiguration(windowVDC, &anrCfg); |
|---|
| 682 | anrCfg.eMode = pSettings->anr.mode; |
|---|
| 683 | anrCfg.iSnDbAdjust = pSettings->anr.level; |
|---|
| 684 | anrCfg.pvUserInfo = pContext->customAnrData; |
|---|
| 685 | |
|---|
| 686 | if (pSettings->pixelFormat != NEXUS_PixelFormat_eUnknown) { |
|---|
| 687 | rc = NEXUS_P_PixelFormat_ToMagnum(pSettings->pixelFormat, &anrCfg.ePxlFormat); |
|---|
| 688 | if (rc) { |
|---|
| 689 | rc = BERR_TRACE(rc); |
|---|
| 690 | goto done; |
|---|
| 691 | } |
|---|
| 692 | } |
|---|
| 693 | |
|---|
| 694 | rc = BVDC_Window_SetAnrConfiguration(windowVDC, &anrCfg); |
|---|
| 695 | if (rc) { |
|---|
| 696 | rc = BERR_TRACE(rc); |
|---|
| 697 | goto done; |
|---|
| 698 | } |
|---|
| 699 | |
|---|
| 700 | if (freeAfter) { |
|---|
| 701 | /* This NEXUS_Display_P_ApplyChanges must take effect if freeAfter is set. */ |
|---|
| 702 | if(g_NEXUS_DisplayModule_State.updateMode != NEXUS_DisplayUpdateMode_eAuto) { rc = BERR_TRACE(NEXUS_NOT_SUPPORTED);} /* fall through */ |
|---|
| 703 | |
|---|
| 704 | rc = BVDC_ApplyChanges(g_NEXUS_DisplayModule_State.vdc); |
|---|
| 705 | if (rc) { |
|---|
| 706 | rc = BERR_TRACE(rc); |
|---|
| 707 | goto done; |
|---|
| 708 | } |
|---|
| 709 | } |
|---|
| 710 | else { |
|---|
| 711 | rc = NEXUS_Display_P_ApplyChanges(); |
|---|
| 712 | if (rc) { |
|---|
| 713 | rc = BERR_TRACE(rc); |
|---|
| 714 | goto done; |
|---|
| 715 | } |
|---|
| 716 | } |
|---|
| 717 | |
|---|
| 718 | done: |
|---|
| 719 | if (freeAfter) { |
|---|
| 720 | BKNI_Free(freeAfter); |
|---|
| 721 | } |
|---|
| 722 | return rc; |
|---|
| 723 | #endif |
|---|
| 724 | } |
|---|
| 725 | |
|---|
| 726 | void NEXUS_VideoWindow_GetCoefficientIndexSettings( NEXUS_VideoWindowHandle window, NEXUS_VideoWindowCoefficientIndexSettings *pSettings ) |
|---|
| 727 | { |
|---|
| 728 | BDBG_OBJECT_ASSERT(window, NEXUS_VideoWindow); |
|---|
| 729 | *pSettings = window->adjContext.coefficientIndexSettings; |
|---|
| 730 | } |
|---|
| 731 | |
|---|
| 732 | NEXUS_Error NEXUS_VideoWindow_SetCoefficientIndexSettings( NEXUS_VideoWindowHandle window, const NEXUS_VideoWindowCoefficientIndexSettings *pSettings ) |
|---|
| 733 | { |
|---|
| 734 | #if !B_HAS_LEGACY_VDC && BCHP_CHIP != 7403 |
|---|
| 735 | BERR_Code rc; |
|---|
| 736 | |
|---|
| 737 | BDBG_OBJECT_ASSERT(window, NEXUS_VideoWindow); |
|---|
| 738 | window->adjContext.coefficientIndexSettings = *pSettings; |
|---|
| 739 | window->adjContext.bCoefficientIndexSettingsSet = true; |
|---|
| 740 | |
|---|
| 741 | if (NULL == window->vdcState.window || g_NEXUS_DisplayModule_State.pqDisabled) { |
|---|
| 742 | /* they will get applied when the window is created */ |
|---|
| 743 | return BERR_SUCCESS; |
|---|
| 744 | } |
|---|
| 745 | |
|---|
| 746 | BDBG_CASSERT(sizeof(NEXUS_VideoWindowCoefficientIndexSettings) == sizeof(BVDC_CoefficientIndex)); |
|---|
| 747 | |
|---|
| 748 | rc = BVDC_Window_SetCoefficientIndex(window->vdcState.window, (const BVDC_CoefficientIndex *)pSettings); |
|---|
| 749 | if (rc) return BERR_TRACE(rc); |
|---|
| 750 | |
|---|
| 751 | rc = NEXUS_Display_P_ApplyChanges(); |
|---|
| 752 | if (rc) return BERR_TRACE(rc); |
|---|
| 753 | #else |
|---|
| 754 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 755 | BSTD_UNUSED(window); |
|---|
| 756 | BSTD_UNUSED(pSettings); |
|---|
| 757 | #endif |
|---|
| 758 | |
|---|
| 759 | return rc; |
|---|
| 760 | } |
|---|
| 761 | |
|---|
| 762 | NEXUS_Error NEXUS_VideoWindow_SetGameModeDelay( NEXUS_VideoWindowHandle window, const NEXUS_VideoWindowGameModeDelay *pSettings ) |
|---|
| 763 | { |
|---|
| 764 | #ifdef B_HAS_LEGACY_VDC |
|---|
| 765 | /*TODO : Add Game mode support*/ |
|---|
| 766 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 767 | BSTD_UNUSED(window); |
|---|
| 768 | BSTD_UNUSED(pSettings); |
|---|
| 769 | #else |
|---|
| 770 | BERR_Code rc = BERR_SUCCESS; |
|---|
| 771 | NEXUS_VideoAdjContext *pContext; |
|---|
| 772 | BVDC_Window_Handle windowVDC; |
|---|
| 773 | BVDC_Window_GameModeSettings GameModeDelaySettings; |
|---|
| 774 | |
|---|
| 775 | BDBG_OBJECT_ASSERT(window, NEXUS_VideoWindow); |
|---|
| 776 | windowVDC = window->vdcState.window; |
|---|
| 777 | pContext = &(window->adjContext); |
|---|
| 778 | BDBG_ASSERT(pSettings); |
|---|
| 779 | |
|---|
| 780 | pContext->bGameModeDelaySet = true; |
|---|
| 781 | pContext->stGameModeDelaySettings = *pSettings; |
|---|
| 782 | |
|---|
| 783 | if (NULL == windowVDC || g_NEXUS_DisplayModule_State.pqDisabled) { |
|---|
| 784 | /* they will get applied when the window is created */ |
|---|
| 785 | return BERR_SUCCESS; |
|---|
| 786 | } |
|---|
| 787 | |
|---|
| 788 | /* get a default to prevent uninitialized memory when new params are added */ |
|---|
| 789 | (void)BVDC_Window_GetGameModeDelay(windowVDC, &GameModeDelaySettings); |
|---|
| 790 | |
|---|
| 791 | GameModeDelaySettings.bEnable = pSettings->enable; |
|---|
| 792 | GameModeDelaySettings.bForceCoarseTrack = pSettings->forceCoarseTrack; |
|---|
| 793 | GameModeDelaySettings.ulBufferDelayTarget = pSettings->bufferDelayTarget; |
|---|
| 794 | GameModeDelaySettings.ulBufferDelayTolerance = pSettings->bufferDelayTolerance; |
|---|
| 795 | |
|---|
| 796 | rc = BVDC_Window_SetGameModeDelay(windowVDC, &GameModeDelaySettings); |
|---|
| 797 | if (rc) return BERR_TRACE(rc); |
|---|
| 798 | |
|---|
| 799 | rc = NEXUS_Display_P_ApplyChanges(); |
|---|
| 800 | if (rc) return BERR_TRACE(rc); |
|---|
| 801 | #endif |
|---|
| 802 | |
|---|
| 803 | return rc; |
|---|
| 804 | } |
|---|
| 805 | |
|---|
| 806 | void NEXUS_VideoWindow_GetGameModeDelay( NEXUS_VideoWindowHandle window, NEXUS_VideoWindowGameModeDelay *pSettings) |
|---|
| 807 | { |
|---|
| 808 | BDBG_OBJECT_ASSERT(window, NEXUS_VideoWindow); |
|---|
| 809 | *pSettings = window->adjContext.stGameModeDelaySettings; |
|---|
| 810 | } |
|---|