/*************************************************************************** * Copyright (c) 2003-2010, Broadcom Corporation * All Rights Reserved * Confidential Property of Broadcom Corporation * * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. * * $brcm_Workfile: bvdb.c $ * $brcm_Revision: Hydra_Software_Devel/73 $ * $brcm_Date: 9/13/10 9:11p $ * * Module Description: * * Revision History: * * $brcm_Log: /magnum/commonutils/vdb/3548/B0/bvdb.c $ * * Hydra_Software_Devel/73 9/13/10 9:11p vineetr * SW3548-3079: Temporarily holding off on this change, until Jerry can * re-confirm. * * Hydra_Software_Devel/72 9/13/10 8:47p vineetr * SW3548-3079: Adding support for top bottom half res to side by side * half res. * * Hydra_Software_Devel/71 7/13/10 5:11p vineetr * SW3548-2987: Preliminary changes to support new 1080p@30Hz format. The * final update to the usage modes in the VDB table are still pending, * since I am waiting for the RTS to be re-analyzed. Until then, these * changes are 'harmless'. * Hydra_Software_Devel/70 6/2/10 4:18p vineetr * SW3548-2962: There is now an officially supported way (in Nexus) to * change the BVN configuration at run time. Whenever that API is called, * BVDB_ValidateConfigId() is called and we now clear the cached info * when that happens. * * Hydra_Software_Devel/67 4/15/10 2:33p jerrylim * SW3556-1096: Added BERR_TRACE in all return cases for easier error * tracking and added unknown * * Hydra_Software_Devel/66 3/31/10 10:32a jerrylim * SW3548-2828: Added a new 3D format - 2160i48 * * Hydra_Software_Devel/65 1/29/10 4:52p jerrylim * SW3548-2744: Add 3D RTS support to config 2 * * Hydra_Software_Devel/64 1/27/10 11:06a jerrylim * SW3548-2726: Set clipping max to real maximu so the first comparison * can be alwasys passed. And messages added in PIP display search * function for easier debugging * * Hydra_Software_Devel/63 1/19/10 8:34p jerrylim * SW3548-2726: Added 3D support to config 14. The changes were made based * on 3548_Usage_Modes.xls Rev.2.74 * * Hydra_Software_Devel/62 1/8/10 4:43p jerrylim * SW3556-968, SW3548-2683: Added one more buffer to config 14 to support * 50Hz <-> 60Hz. Disabled MNR/BNR for the secondary window in config 11. * # of lines of 3D signal changed to 2205. The changes are based on * 3548_Usage_Modes.xls Rev.2.69 8-Jan-10 * * Hydra_Software_Devel/61 12/24/09 3:08p jerrylim * SW3548-2683: Changed cropping size to 36% in FULL.8 and recalculated * PBP mode. The changes were maded based on 3548_Usage_Modes.xls * Rev.2.65 2009.12.24 * * Hydra_Software_Devel/60 12/18/09 6:47p jerrylim * SW3556-933: added 1440x480p@60 to BVDB_GetInputFormatGroup() * * Hydra_Software_Devel/59 12/16/09 5:36p jerrylim * SW3548-2668: bpb will be changed to support none/pbp/pip modes, and * this is a temporary change in order not to break the build * * Hydra_Software_Devel/58 12/14/09 6:52p jerrylim * SW3556-915: The purpose of havging PC groups in VDB is not to indicate * support PC formats, but to do format grouping so RTS settings can be * applied to a proper group. VDB function should not block other modules * by returning invalid format as long as its RTS settings can be found * * Hydra_Software_Devel/57 12/10/09 11:04a jerrylim * SW3556-871: Video window rectangle setting is slow in MHEG * certification -> A concept so called *cached usage modes* is * introduced where it returns usage mode in the cached in case of cache * hit * * Hydra_Software_Devel/56 11/2/09 12:45p jessem * SW3548-2574: Corrected determination of pDisplayedAspectRatio when * eAspectRatioCorrection is BVDB_AspectRatio_eAllSrc. * * Hydra_Software_Devel/55 10/9/09 10:59a jessem * SW3556-821: Modified algorithm to find interlaced formats in * BVDB_GetInputFormatGroup. * * Hydra_Software_Devel/54 10/1/09 1:56p jessem * SW3548-2506, SW3556-818: * 1. Added config 14 support (SW3548-2506). * 2. Added WXGA and XGA support for config 7 (SW3556-818). * 3. Added 1024x768_PC@60 and 1024x768_PC@85 input format groups. * 4. Modified algorithm to search for progressive input formats in * BVDB_GetInputFormatGroup. * * Hydra_Software_Devel/53 9/23/09 11:36a jessem * SW3548-2497: Added additional support for certain DivX streams. * * Hydra_Software_Devel/52 9/22/09 6:13p jessem * SW3548-2495: Added support for DivX formats. * * Hydra_Software_Devel/51 9/22/09 10:25a jessem * SW3548-2491: Added missing break for 720p60 case in * BDV_GetInputFormatGroup. * * Hydra_Software_Devel/50 9/21/09 2:31p jessem * SW3548-2451, SW3548-2481: Removed checks for MFD input type for SD, * 480p, 576p and 720p sources in BVDB_GetInputFormatGroup. * * Hydra_Software_Devel/49 9/11/09 2:58p jessem * SW3548-2463, SW3548-2465: * 1. Fixed algorithm for checking 4:3 and 16:9 sources as displayed in * 4:3 or 16:9 panels. * 2. Fixed FULL.12 check to include source's aspect ratio. * * Hydra_Software_Devel/48 9/3/09 3:39p jessem * SW3548-2451: Modified BVDB_GetInputFormatGroup to handle MPEG streams * with non-standard framerates. This is only limited to formats with * dimensions less than 1280x720. * * Hydra_Software_Devel/47 8/28/09 6:44p jessem * SW3548-2378: Changed BDBG_ERR to BDBG_MSG in BVDB_GetVideoDisplayMode * * Hydra_Software_Devel/46 8/28/09 3:59p jessem * SW3548-2378: Added check to validate clip amount for dot-by-dot mode in * BVDB_GetVideoDisplayMode. * * Hydra_Software_Devel/45 8/27/09 3:41p jessem * SW3548-2419: * 1. Added config 13 support. * 2. Added RTS tables 241 to 255 for config 13 support. * 3. Added bJpeg parameter to BVDB_GetInputFormatGroup. * 4. Added BVDB_InputFormatGroup_eJpeg_540 and replaced * BVDB_InputFormatGroup_eJpeg with BVDB_InputFormatGroup_eJpeg_1080. * 5. Added BVDB_Osd_e960_540p_32bpp. * * Hydra_Software_Devel/44 8/25/09 5:30p jessem * SW3548-2374: Fixed comparison of full mode clip amount limits against * user clip amounts. * * Hydra_Software_Devel/43 8/17/09 10:44a jessem * PR 57390: Corrected checks for minimum and maximum FULL window sizes in * BVDB_GetVideoDisplayMode. * * Hydra_Software_Devel/42 8/12/09 5:45p jessem * PR 57101, PR 57604: Updated config 9 RTS and usage modes. * * Hydra_Software_Devel/41 8/5/09 5:57p jessem * PR 57391, PR 57392: * 1. Added 1920x1080 PC @ 60 Group. Renamed 1024x768_PC@60 Group to * 1366x768_PC@60 Group , 1280x768_PC@85 Group to 1366x768_PC@85 Group. * Added 1920x1080_PC@60 usage mdoes to all configurations (57391). * 2. Removed and modified certain invalid PC formats (57392). * * Hydra_Software_Devel/40 7/28/09 2:28p jessem * PR 57101: Modified logic to check display modes for FULL and PIG modes * in BVDB_GetVideoDisplayMode. * * Hydra_Software_Devel/39 7/21/09 4:33p jessem * PR 52453, PR 55504, PR 56585: * 1. Modified config 10's RTS, tolerance and bias for 480i/576i usage * modes to use CAP-SCL orientation for all main window modes and inputs. * 2. Separated FULL.7 from usage modes that have this as part of all FULL * display modes. This applies to configs 1, 2, 3, 6, 7, 10, 11, 12. * 3. Recategorized formats with H and W that are less than or equal to * 1366x768 to either 1024x768 PC @ 60 Group or 1280x768 PC @ 85 Group. * 4. Added OSD support for monitor modes in config 3 (PR 56585). * * Hydra_Software_Devel/38 7/14/09 2:39p jessem * PR 56794: Changed BVDB_Handle to BVDB_P_Context in BVDB_CreateVdb. * * Hydra_Software_Devel/37 5/27/09 11:07a jessem * PR 52226: Modified conditionals for BVDB_InputFormatGroup_e1280_768_PC * and BVDB_InputFormatGroup_e1400_1050_75_PC in * BVDB_GetInputFormatGroup(). * * Hydra_Software_Devel/36 4/27/09 11:17a jessem * PR 51743: Added bPbp parameter to BVDB_GetVideoDisplayMode to * distinguish Main PBP from Main PIG use. RTS needs to distinguish * between Main PBP and Main PIG. See DTV_Questionnaire.xls PIP.2 mode. * * Hydra_Software_Devel/35 4/24/09 2:06p jessem * PR 51709, PR 53506, PR 54578: * 1. Modified Config 9 support and associated RTS tables. Added RTS 177 * to 180 (51709). * 2. Added config 10 support and RTS tables 201 to 215 (53506). * 3. Added struct BVDB_OsdInfo and replaced BVDB_eOsd field in * BVDB_UsageMode with this new struct to accommodate ulReserved values * for OSD(51709 and 53506). * 4. Modified BVDB_VideoGetDisplayMode to handle unknown * BFMT_AspectRatio_eUnknown (54578). * * Hydra_Software_Devel/34 4/21/09 4:46p jessem * PR 51743: Added correct conditional for FULL vs PIG modes in * BVDB_GetVideoDisplayMode. * * Hydra_Software_Devel/33 4/14/09 3:58p jessem * PR 51743: Removed goto dones. Check of pstTempMode is non-NULL before * freeing. * * Hydra_Software_Devel/32 4/13/09 3:38p jessem * PR 51743: Modified BVDB_GetDisplaySrcAs and BVDB_GetVideoDisplayModes * to handle source aspect ratio and aspect ratio correction. * * Hydra_Software_Devel/31 4/7/09 10:37a jessem * PR 53682: Added stringent check for MPEG formats in * BVDB_GetInputFormatGroup. * * Hydra_Software_Devel/30 4/6/09 3:15p jessem * PR 53902: Modified BVDB_GetInputFormatGroup to ignore frame rate of * ATSC/SMPTE formats when input is MFD. * * Hydra_Software_Devel/29 4/3/09 3:50p jessem * PR 53783: Moved BVDB_P_MAX/MIN macro to bvdc_priv.h. * * Hydra_Software_Devel/28 4/2/09 4:21p pntruong * PR53783: VDB: Unable to look up MFD 1920x1088i source. * * Hydra_Software_Devel/27 3/30/09 2:53p jessem * PR 53682: Added lookup for 1080p24/25/30 in BVDB_GetInputFormatGroup. * Also added helper macro to determine if a given value is within * tolerance of nominal. * * Hydra_Software_Devel/26 3/30/09 11:32a jessem * PR 53682: Added check for HDDVI input in BVDB_GetInputFormatGroup. * * Hydra_Software_Devel/25 3/27/09 11:33a jessem * PR 52818: Corrected conditional checks for NTSC and PAL input format * groups. * * Hydra_Software_Devel/24 3/24/09 5:48p jessem * PR 53388: Added BFMT_AspectRatio param to BVDB_GetInputFormatGroup. * * Hydra_Software_Devel/23 3/24/09 3:35p jessem * PR 53388: Changed implementation of BVDB_GetInputFormatGroup. * * Hydra_Software_Devel/22 3/19/09 3:39p jessem * PR 53388: Modified BVDB_GetInputFormatGroup()'s parameter list and * implementation. * * Hydra_Software_Devel/21 3/18/09 11:27p jessem * PR 53395: Added BFMT_VideoFmt_eDVI_848x480p_60Hz and * BFMT_VideoFmt_eDVI_1064x600p_60Hz to BVDB_GetInputFormatGroup. * * Hydra_Software_Devel/20 3/16/09 2:24p jessem * PR 53008, PR 53261: * 1. Made condition to check for dot-by-dot stricter (53008). * 2. Made condition to check for full mode to include checking the * requested window size against the minimum and maximum size allowed. * * Hydra_Software_Devel/19 3/12/09 2:36p jessem * PR 52226: Reclassified BFMT_VideoFmt_eDVI_1280x768p_Red and * BFMT_VideoFmt_eDVI_1400x1050p_60Hz_Red to * BVDB_InputFormatGroup_e1400_1050_75_PC. * * Hydra_Software_Devel/18 3/9/09 7:32p jessem * PR 52940: Fixed incorrect array dereference in * BVDB_GetMemoryAllocation. * * Hydra_Software_Devel/17 3/6/09 4:14p jessem * PR 52520: Added BVDB_Input parameter to BVDB_GetVideoDisplayMode to * handle monitor out cases. Corrected ulMinWinHeight field for all * monitor modes for all configs in astConfigVideoDispModeInfo. * * Hydra_Software_Devel/16 3/4/09 5:52p jessem * PR 52520: Fixed determination of error condition when no display modes * are found. Added placeholder for config 7 in * astConfigVideoDispModeInfo array. * * Hydra_Software_Devel/15 3/4/09 11:55a jessem * PR 52568: Removed support for custom format 1340x725p@60hz. * * Hydra_Software_Devel/14 3/3/09 4:14p jessem * PR 52568, PR 51472, PR 52520: * 1. Added support for custom format 1340x725p@60hz (52568). 2. Added * suuport for modified config 2 RTS to eliminate CAP compression support * and increase compression level for MAD for 1080psf and 1080i MFD PIG * usage modes ( 51472). * 3. Added error return value if video display mode is not found (52520). * * Hydra_Software_Devel/13 2/25/09 5:45p jessem * PR 46299, PR 52479, PR 52520: Added PAL B, B1, D, D1, G, H, I, K. * Added BFMT_VideoFmt_eDVI_1280x768p_Red. Added * BVDB_GetVideoDisplayMode. * * Hydra_Software_Devel/12 2/20/09 4:16p jessem * PR 51709: Added config 9 support. Removed BVDB_GetNumberOfConfigs and * replaced it wth BVDB_ValidateConfigId. Removed BVDB_Handle parameter * from BVDB_GetMemoryAllocation. Added RTS 161 to 177. * * Hydra_Software_Devel/11 2/18/09 11:47a jessem * PR 51848: Removed references to VDC. Removed global access to config * info. Added helper functions to access these instead. * * Hydra_Software_Devel/10 2/17/09 6:49p jessem * PR 50031, PR 51848: Added config 8. Added BVDB_GetNumberOfConfigs() and * BVDB_GetMemoryAllocation() functions to VDB API and support for these * new functions. * * Hydra_Software_Devel/9 1/14/09 2:39p jessem * PR 51109: Allocated correct size for acStr. * * Hydra_Software_Devel/8 1/5/09 12:37p jessem * PR 50327: Added features to config 3. * * Hydra_Software_Devel/7 12/9/08 3:58p jessem * PR 49051, PR 46591, PR 48974, PR 49929, PR 49870, PR 49932: Added * support for dot-by-dot in configs 1 and 2. Added config for 1066Mhz * x16 (demo). Added config 6. Added features to config 1 and 2. * * Hydra_Software_Devel/6 11/20/08 5:01p jessem * PR49373, PR49374, PR49375, PR49388, PR 49402, PR 49403, PR 49404, PR * 49406, PR49427, PR49428, PR49429, PR49431, PR49432, PR49433, PR49434, * PR49435, PR49435, PR49436, PR49437, PR49438, PR49440: Updated PR list * in checkin comments. * * Hydra_Software_Devel/5 11/19/08 5:55p jessem * PR49373, PR49374, PR49375, PR49388, PR 49402, PR 49403, PR 49404, PR 49406, * PR49427, PR49428, PR49429, PR49431, PR49432, PR49433, PR49434, PR49435, * PR49435, PR49436, PR49437, PR49438, PR49440: Fixed strcpy and strcat Coverity * issues. * * Hydra_Software_Devel/4 11/13/08 7:05p jessem * PR 48588: Added config 4 for 1080p/1080i/720p switchable output format. * * Hydra_Software_Devel/3 10/21/08 11:00a jessem * PR 46299: Split BVDB_InputFormatGroup_e1400_1050_PC to * BVDB_InputFormatGroup_e1400_1050_75_PC and * BVDB_InputFormatGroup_e1400_1050_60_PC. * * Hydra_Software_Devel/2 10/17/08 2:53p jessem * PR 46299: Replaced old A0 config support with 800MHZ WXGA and 1080P * configs support. * * Hydra_Software_Devel/1 10/2/08 3:48p jessem * PR 46299: Initial version * ***************************************************************************/ #include #include #include #include "bstd.h" #include "berr.h" #include "bkni.h" #include "bfmt.h" #include "blst_circleq.h" #include "bdbg.h" #include "bvdb.h" #include "bvdb_priv.h" #include "bvdb_viddispmode_priv.h" BDBG_MODULE(BVDB); /* In case a matched input format is not found, then it tries search this table * if there's any match. This table is a collection of formats which cannot be * grouped using the standard decision making process. The input format group * used in this table is based on the RTS analysis tool. Note that this table * contains non-PC formats only * * ********** NOTE ********** * Each group of sources must be in the order from low to high frame rate where * a group means sources which have same width, height and progressiveness */ static BVDB_P_NonPcNonStandardFomat stNonPcNonStandardFormats[] = { /* EIA/CEA-861-B (aslo in HDMI) 1440x480p without pixel repetition */ {1440, 480, true, 60000, false, BVDB_InputFormatGroup_e720p_60}, /* HDMI1.4 3D Video VIC 32 */ {1920, 2205, true, 23976, true, BVDB_InputFormatGroup_e1080p3d_24}, {1920, 2205, true, 24000, true, BVDB_InputFormatGroup_e1080p3d_24}, /* HDMI1.4 3D Video VIC 34 */ {1920, 2205, true, 30000, true, BVDB_InputFormatGroup_e1080p3d_30}, /* HDMI1.4 3D Video VIC 19 */ {1280, 1470, true, 50000, true, BVDB_InputFormatGroup_e720p3d_50}, /* HDMI1.4 3D Video VIC 4 */ {1280, 1470, true, 59940, true, BVDB_InputFormatGroup_e720p3d_60}, {1280, 1470, true, 60000, true, BVDB_InputFormatGroup_e720p3d_60}, /* wireless 3D Video 2160i48 */ {1920, 2160, false, 47952, true, BVDB_InputFormatGroup_e1080p3d_24}, {1920, 2160, false, 48000, true, BVDB_InputFormatGroup_e1080p3d_24}, }; /* Public Functions */ BERR_Code BVDB_CreateVdb ( BVDB_Handle *phVdb, uint32_t *pulEntries) { BERR_Code err = BERR_SUCCESS; BVDB_P_Context *pVdb; BVDB_UsageMode *pstVdbEntries; uint32_t i, ulVdbTableSize; /* create head */ pVdb = (BVDB_P_Context *)BKNI_Malloc(sizeof(BVDB_P_Context)); if (pVdb == NULL) { BDBG_ERR(("Out of memory")); return BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY); } BLST_CQ_INIT(pVdb); err = BVDB_P_GetVdbTableSize(&ulVdbTableSize); if (err != BERR_SUCCESS) { return BERR_TRACE(err); } pstVdbEntries = (BVDB_UsageMode *)BKNI_Malloc(sizeof(BVDB_UsageMode) * ulVdbTableSize); if (pstVdbEntries == NULL) { BDBG_ERR(("Out of memory.")); err = BERR_OUT_OF_SYSTEM_MEMORY; return BERR_TRACE(err); } err = BVDB_P_GetVdbEntries(pstVdbEntries); if (err != BERR_SUCCESS) { return BERR_TRACE(err); } for (i=0; iacId)) { err |= BVDB_P_ValidateVdbEntry(pVdb, pMode); } pMode = BVDB_P_UsageMode_GetNextNode(pMode); } while (pMode != BLST_CQ_FIRST(pVdb)); } return BERR_TRACE(err); } BERR_Code BVDB_DestroyVdb ( BVDB_Handle hVdb ) { BVDB_UsageMode *pMode; BVDB_P_Context *pVdb; BVDB_P_GET_CONTEXT(hVdb, pVdb); while (!BLST_CQ_EMPTY(pVdb)) { pMode = BLST_CQ_FIRST(pVdb); BLST_CQ_REMOVE_HEAD(pVdb, link); BKNI_Free(pMode); } BKNI_Free((void*)pVdb); pVdb = NULL; return BERR_TRACE(BERR_SUCCESS); } BERR_Code BVDB_PrintUsageMode ( const BVDB_UsageMode *pstUsageMode ) { BERR_Code err = BERR_SUCCESS; char acStr[BVDB_MAX_STRLEN+1]; char acStr1[BVDB_MAX_STRLEN+1]; char acStr2[BVDB_MAX_STRLEN+1]; BVDB_VideoDisplayMode stDispMode = pstUsageMode->stDisplayMode; BDBG_ASSERT(pstUsageMode); /* ID */ BDBG_P_PrintString("VDB ID: %s\n", pstUsageMode->acId); /* Input format */ BVDB_P_GetInputStr(pstUsageMode->eInput, acStr); BVDB_P_GetInputFormatGroupStr(pstUsageMode->eInputFormatGroup, acStr1); BDBG_P_PrintString("\tInput type: %s, format: %s\n", acStr, acStr1); /* Display */ BVDB_P_GetDisplayTypeStr(pstUsageMode->stDisplay.eType, acStr); BVDB_P_GetOutputResolutionStr(pstUsageMode->stDisplay.eResolution, acStr1); BVDB_P_GetAspectRatioStr(pstUsageMode->stDisplay.eAspectRatio, acStr2); BDBG_P_PrintString("\tDisplay: %s, resolution: %s, aspect ratio: %s\n", acStr, acStr1, acStr2); /* Window */ BVDB_P_GetWindowStr(pstUsageMode->eWindow, acStr); BDBG_P_PrintString("\tWindow: %s\n", acStr); /* display usage mode */ BVDB_P_GetVideoDisplayModeStr(&stDispMode, acStr); BDBG_P_PrintString("\tVideo Display Usage Mode: %s\n", acStr); /* OSD size */ BDBG_P_PrintString("\tOSD: %dx%d@%dbpp (reserved %d)\n", pstUsageMode->stOsd.ulWidth, pstUsageMode->stOsd.ulHeight, pstUsageMode->stOsd.ulBitsPerPixel, pstUsageMode->stOsd.ulReserved); /* 3D comb */ BVDB_P_GetStateStr(pstUsageMode->e3dComb, acStr); BDBG_P_PrintString("\t3D Comb: %s\n", acStr); /* oversample */ BVDB_P_GetStateStr(pstUsageMode->eOversample, acStr); BDBG_P_PrintString("\tOversample: %s\n", acStr); BVDB_P_GetStateStr(pstUsageMode->eMnrBnr, acStr); BVDB_P_GetStateStr(pstUsageMode->eDcr, acStr1); BVDB_P_GetPixelFormatStr(pstUsageMode->stAnr.ePixelFormat, pstUsageMode->stAnr.eState, acStr2); BDBG_P_PrintString("\tMNR/BNR: %s, DCR %s, ANR: %s (reserved %d)\n", acStr, acStr1, acStr2, pstUsageMode->stAnr.ulReserved); /* CAP/VFD */ BVDB_P_GetPixelFormatStr(pstUsageMode->stCapVfd.ePixelFormat, pstUsageMode->stCapVfd.eState, acStr); BDBG_P_PrintString("\tCAP/VFD: %s (reserved %d)\n", acStr, pstUsageMode->stCapVfd.ulReserved); /* MAD */ BVDB_P_GetPixelFormatStr(pstUsageMode->stMad.ePixelFormat, pstUsageMode->stMad.eState, acStr); if (pstUsageMode->stMad.eState == BVDB_State_eYes) { char acTemp[BVDB_MAX_STRLEN]; BVDB_P_GetFieldStoreCntStr(pstUsageMode->stMad.eFieldStore, acTemp); BVDB_P_STRCAT(acTemp, "\t"); BVDB_P_STRCAT(acTemp, acStr); BVDB_P_STRCPY(acStr, acTemp); } else { if (pstUsageMode->stMad.ePixelFormat == BVDB_PixelFmt_eInvalid) BVDB_P_STRCAT(acStr, "\tn/a"); else BVDB_P_STRCPY(acStr, "\tno"); } BDBG_P_PrintString("\tMAD: %s (reserved %d)\n", acStr, pstUsageMode->stMad.ulReserved); /* RTS */ BVDB_P_GetRtsSetStr(pstUsageMode->eRtsSet, acStr); BDBG_P_PrintString("\tRTS: %s\n", acStr); /* SCL-CAP tolerance and bias */ BVDB_P_GetSclCapBiasStr(pstUsageMode->eSclCapBias, acStr); BDBG_P_PrintString("\tSCL-CAP tolerance: %d, bias: %s\n", pstUsageMode->ulSclCapTolerance, acStr); return BERR_TRACE(err); } BERR_Code BVDB_PrintVdb ( BVDB_Handle hVdb ) { BVDB_UsageMode *pstTemp; BVDB_P_Context *pVdb; BVDB_P_GET_CONTEXT(hVdb, pVdb); pstTemp = BLST_CQ_FIRST(pVdb); do { BVDB_PrintUsageMode(pstTemp); pstTemp = BVDB_P_UsageMode_GetNextNode(pstTemp); } while(pstTemp != BLST_CQ_FIRST(pVdb)); return BERR_TRACE(BERR_SUCCESS); } BERR_Code BVDB_GetInputFormatGroup ( const BVDB_Handle hVdb, const uint32_t ulHeight, const uint32_t ulWidth, const uint32_t ulFrameRate, const bool bProgressive, const bool bJpeg, const BVDB_Input eInput, BVDB_InputFormatGroup *peInputFormatGroup ) { BERR_Code err = BERR_SUCCESS; BVDB_P_Context *pVdb; uint32_t ulTempHeight = ulHeight; BVDB_InputFormatGroup eNonPcInputFormatGroup; BVDB_P_GET_CONTEXT(hVdb, pVdb); *peInputFormatGroup = BVDB_InputFormatGroup_eInvalid; eNonPcInputFormatGroup = BVDB_InputFormatGroup_eInvalid; if(BVDB_Input_eMfd == eInput) { ulTempHeight = BVDB_P_MIN(ulHeight, BFMT_1080I_HEIGHT); } if (bJpeg) { *peInputFormatGroup = (ulTempHeight <= BFMT_1080I_HEIGHT/2) ? BVDB_InputFormatGroup_eJpeg_540 : BVDB_InputFormatGroup_eJpeg_1080; } else { /* Let's see if we have a match in the non-standard format list. This list * grows on-demand basis. Note that frame rates are compared for a match * using "range". In case we haven't found a match using the standard * way, they we'll use this match if there's a match here */ if (*peInputFormatGroup == BVDB_InputFormatGroup_eInvalid) { /* For non-PC formats */ if (eInput != BVDB_Input_eVga) { uint32_t i; uint32_t numEntry; numEntry = sizeof(stNonPcNonStandardFormats) / sizeof(BVDB_P_NonPcNonStandardFomat); for (i = 0; i < numEntry; i++) { if ((ulHeight == stNonPcNonStandardFormats[i].height) && (ulWidth == stNonPcNonStandardFormats[i].width) && (bProgressive == stNonPcNonStandardFormats[i].bProgressive) && (ulFrameRate <= stNonPcNonStandardFormats[i].frameRate)) { eNonPcInputFormatGroup = stNonPcNonStandardFormats[i].eInputFormatGroup; /* Now we have a match in the non-standard format array. * If the matched format is a 3D source, return right * away because the following search does not consider * the 3D sources */ if (stNonPcNonStandardFormats[i].b3dSource && (eInput == BVDB_Input_eHdDvi)) { * peInputFormatGroup = eNonPcInputFormatGroup; return BERR_TRACE(BERR_SUCCESS); } break; } } } } if (!bProgressive) { /* the only interlaced VESA format! */ if ((ulWidth == 1024 && ulTempHeight == 768 && (eInput == BVDB_Input_eVga || eInput == BVDB_Input_eHdDvi) && ulFrameRate == 86958) && *peInputFormatGroup == BVDB_InputFormatGroup_eInvalid) { *peInputFormatGroup = BVDB_InputFormatGroup_e1366_768_85_PC; } if (((ulFrameRate >= 59940 && ulFrameRate <= 60000) || (ulFrameRate >= 23976 && ulFrameRate <= 24000) || (ulFrameRate >= 29970 && ulFrameRate <= 30000)) && *peInputFormatGroup == BVDB_InputFormatGroup_eInvalid) { if (ulTempHeight <= BFMT_NTSC_HEIGHT) { if (ulWidth <= 544) { *peInputFormatGroup = BVDB_InputFormatGroup_e544_480i_60; } else if (ulWidth <= BFMT_NTSC_WIDTH) { *peInputFormatGroup = BVDB_InputFormatGroup_eNtsc; } } if (ulTempHeight <= BFMT_PAL_HEIGHT && ulWidth <= BFMT_PAL_WIDTH && *peInputFormatGroup == BVDB_InputFormatGroup_eInvalid) { *peInputFormatGroup = BVDB_InputFormatGroup_ePal_60; } if (ulTempHeight <= BFMT_1080I_HEIGHT && *peInputFormatGroup == BVDB_InputFormatGroup_eInvalid) { if (ulWidth <= 1440) { *peInputFormatGroup = BVDB_InputFormatGroup_e1440_1080i_60; } else if (ulWidth <= BFMT_1080I_WIDTH) { *peInputFormatGroup = BVDB_InputFormatGroup_e1080i_60; } } } if ((ulFrameRate == 50000 || ulFrameRate == 25000) && *peInputFormatGroup == BVDB_InputFormatGroup_eInvalid) { if (ulTempHeight <= BFMT_PAL_HEIGHT) { if (ulWidth <= 544) { *peInputFormatGroup = BVDB_InputFormatGroup_e544_576i_50; } else if (ulWidth <= BFMT_PAL_WIDTH) { *peInputFormatGroup = BVDB_InputFormatGroup_ePal; } } if (ulTempHeight <= BFMT_1080I_HEIGHT && *peInputFormatGroup == BVDB_InputFormatGroup_eInvalid) { if (ulWidth <= 1440) { *peInputFormatGroup = BVDB_InputFormatGroup_e1440_1080i_50; } else if (ulWidth <= BFMT_1080I_WIDTH) { *peInputFormatGroup = BVDB_InputFormatGroup_e1080i_50; } } } /* In case there's no match, use the non standard match if any */ if (*peInputFormatGroup == BVDB_InputFormatGroup_eInvalid) { *peInputFormatGroup = eNonPcInputFormatGroup; } } else { if (ulFrameRate >= 59934 && ulFrameRate <= 60000 && *peInputFormatGroup == BVDB_InputFormatGroup_eInvalid) { if (ulWidth <= BFMT_480P_WIDTH && ulTempHeight <= BFMT_480P_HEIGHT) { *peInputFormatGroup = BVDB_InputFormatGroup_e480p; } else if (ulWidth <= BFMT_720P_WIDTH && ulTempHeight <= BFMT_720P_HEIGHT) { *peInputFormatGroup = BVDB_InputFormatGroup_e720p_60; } else if (ulTempHeight == BFMT_1080P_HEIGHT && ulWidth == BFMT_1080P_WIDTH) { *peInputFormatGroup = (eInput != BVDB_Input_eVga) ? BVDB_InputFormatGroup_e1080p_60 : BVDB_InputFormatGroup_e1920_1080_60_PC; } else if (ulTempHeight <= BFMT_1080P_HEIGHT && ulWidth < BFMT_1080P_WIDTH && eInput == BVDB_Input_eMfd) { *peInputFormatGroup = BVDB_InputFormatGroup_e1440_1080p_30; } } if (ulFrameRate == 50000 && *peInputFormatGroup == BVDB_InputFormatGroup_eInvalid) { if (ulWidth <= BFMT_576P_WIDTH && ulTempHeight <= BFMT_576P_HEIGHT) { *peInputFormatGroup = BVDB_InputFormatGroup_e576p; } else if (ulWidth <= BFMT_720P_WIDTH && ulTempHeight <= BFMT_720P_HEIGHT) { *peInputFormatGroup = BVDB_InputFormatGroup_e720p_50; } else if (ulTempHeight == BFMT_1080P_HEIGHT && ulWidth == BFMT_1080P_WIDTH) { *peInputFormatGroup = BVDB_InputFormatGroup_e1080p_50; } else if (ulTempHeight <= BFMT_1080P_HEIGHT && ulWidth < BFMT_1080P_WIDTH && eInput == BVDB_Input_eMfd) { *peInputFormatGroup = BVDB_InputFormatGroup_e1440_1080p_25; } } if ((ulFrameRate == 23976 || ulFrameRate == 24000) && *peInputFormatGroup == BVDB_InputFormatGroup_eInvalid) { if (ulWidth <= BFMT_720P_WIDTH && ulTempHeight <= BFMT_720P_HEIGHT) { *peInputFormatGroup = BVDB_InputFormatGroup_e720p_24; } else if (ulTempHeight == BFMT_1080P_HEIGHT) { if (ulWidth == BFMT_1080P_WIDTH) { *peInputFormatGroup = BVDB_InputFormatGroup_e1080p_24; } else if (ulWidth < BFMT_1080P_WIDTH) { *peInputFormatGroup = BVDB_InputFormatGroup_e1440_1080p_24; } } else if (ulTempHeight <= BFMT_1080P_HEIGHT && ulWidth < BFMT_1080P_WIDTH && eInput == BVDB_Input_eMfd) { *peInputFormatGroup = BVDB_InputFormatGroup_e1440_1080p_24; } } if (ulFrameRate == 25000 && *peInputFormatGroup == BVDB_InputFormatGroup_eInvalid) { if (ulWidth <= BFMT_720P_WIDTH && ulTempHeight <= BFMT_720P_HEIGHT) { *peInputFormatGroup = BVDB_InputFormatGroup_e720p_25; } else if (ulTempHeight == BFMT_1080P_HEIGHT) { if (ulWidth == BFMT_1080P_WIDTH) { *peInputFormatGroup = BVDB_InputFormatGroup_e1080p_25; } else if (ulWidth < BFMT_1080P_WIDTH) { *peInputFormatGroup = BVDB_InputFormatGroup_e1440_1080p_25; } } else if (ulTempHeight <= BFMT_1080P_HEIGHT && ulWidth < BFMT_1080P_WIDTH && eInput == BVDB_Input_eMfd) { *peInputFormatGroup = BVDB_InputFormatGroup_e1440_1080p_25; } } if ((ulFrameRate == 29970 || ulFrameRate == 30000) && *peInputFormatGroup == BVDB_InputFormatGroup_eInvalid) { if (ulWidth <= BFMT_720P_WIDTH && ulTempHeight <= BFMT_720P_HEIGHT) { *peInputFormatGroup = BVDB_InputFormatGroup_e720p_30; } else if (ulTempHeight == BFMT_1080P_HEIGHT) { if (ulWidth == BFMT_1080P_WIDTH) { *peInputFormatGroup = BVDB_InputFormatGroup_e1080p_30; } else if (ulWidth < BFMT_1080P_WIDTH) { *peInputFormatGroup = BVDB_InputFormatGroup_e1440_1080p_30; } } else if (ulTempHeight <= BFMT_1080P_HEIGHT && ulWidth < BFMT_1080P_WIDTH && eInput == BVDB_Input_eMfd) { *peInputFormatGroup = BVDB_InputFormatGroup_e1440_1080p_30; } } /* In case there's no match, use the non standard match if any */ if (*peInputFormatGroup == BVDB_InputFormatGroup_eInvalid) { *peInputFormatGroup = eNonPcInputFormatGroup; } /* The purpose here is not to tell where the input PC format is * supported or not. The purpose is to pick a PC group so a proper * RTS settings can be applied. Currently, RTS analysis * differentiates PC input whether its numbers of line are greater * than 700. We try to find the PC group more accurately, and if not * found, then the PC ground is picked based on number of lines. * There is not reason to block other modules by returning the * invalid format as long as the RTS settings cover it. */ if (*peInputFormatGroup == BVDB_InputFormatGroup_eInvalid) { if (ulFrameRate <= 60000 + ((60000 * 1)/10)/100) { if (ulWidth <= 1024 && ulTempHeight <= 768) { *peInputFormatGroup = BVDB_InputFormatGroup_e1024_768_60_PC; } else if (ulWidth <= 1366 && ulTempHeight <= 768) { *peInputFormatGroup = BVDB_InputFormatGroup_e1366_768_60_PC; } else if (ulWidth >= 1280 && ulTempHeight >= 960 && ulWidth <= 1400 && ulTempHeight <= 1050) { *peInputFormatGroup = BVDB_InputFormatGroup_e1400_1050_60_PC; } else if (ulWidth == 1920 && ulTempHeight == 1080) { *peInputFormatGroup = BVDB_InputFormatGroup_e1920_1080_60_PC; } else if (ulWidth == 1600 && ulTempHeight == 1200) { *peInputFormatGroup = BVDB_InputFormatGroup_e1600_1200_60_PC; } /* accurate search failed. Pick a group based on # of lines */ if (ulTempHeight <=768) { *peInputFormatGroup = BVDB_InputFormatGroup_e1024_768_60_PC; } else if (ulTempHeight <= 1050) { *peInputFormatGroup = BVDB_InputFormatGroup_e1400_1050_60_PC; } else if (ulTempHeight <= 1080) { *peInputFormatGroup = BVDB_InputFormatGroup_e1920_1080_60_PC; } else if (ulTempHeight <= 1200) { *peInputFormatGroup = BVDB_InputFormatGroup_e1600_1200_60_PC; } } else /* odd rates */ { if (ulWidth <= 1024 && ulTempHeight <= 768) { *peInputFormatGroup = BVDB_InputFormatGroup_e1024_768_85_PC; } else if (ulWidth <= 1366 && ulTempHeight <= 768) { *peInputFormatGroup = BVDB_InputFormatGroup_e1366_768_85_PC; } else if (ulWidth >= 1152 && ulTempHeight >= 864 && ulWidth <= 1400 && ulTempHeight <= 1050) { *peInputFormatGroup = BVDB_InputFormatGroup_e1400_1050_75_PC; } /* accurate search failed. Pick a group based on # of lines */ if (ulTempHeight <=768) { *peInputFormatGroup = BVDB_InputFormatGroup_e1366_768_85_PC; } else if (ulTempHeight <= 1050) { *peInputFormatGroup = BVDB_InputFormatGroup_e1400_1050_75_PC; } } } } } if (*peInputFormatGroup == BVDB_InputFormatGroup_eInvalid) err = BERR_NOT_SUPPORTED; return BERR_TRACE(err); } BERR_Code BVDB_AddVdbEntry ( BVDB_Handle hVdb, const BVDB_UsageMode *pstUsageMode ) { BERR_Code err = BERR_SUCCESS; BVDB_P_Context *pVdb; BVDB_VideoDisplayMode stDispMode = pstUsageMode->stDisplayMode; BVDB_UsageMode stUsageMode; BVDB_P_GET_CONTEXT(hVdb, pVdb); BKNI_Memcpy((void*)&stUsageMode, (void *)pstUsageMode, sizeof(BVDB_UsageMode)); /* Create ID based on given parameters */ if (BVDB_P_CreateId(pVdb, &stUsageMode) == BERR_SUCCESS) { BVDB_UsageMode *pCurr, *pNext, *pPrev = NULL, *pInsert = NULL; bool bInsertPointBefore = false, bInsertPointAfter = false; BVDB_P_DispModeType eDispMode, eInsertDispMode; /* Validate Entry */ err = BVDB_P_ValidateVdbEntry(NULL, &stUsageMode); if (err == BERR_SUCCESS) { pCurr = BLST_CQ_FIRST(pVdb); do { /* search for similar input format, display and window */ if ((pCurr->eInputFormatGroup == stUsageMode.eInputFormatGroup) && (pCurr->stDisplay.eType == stUsageMode.stDisplay.eType) && (pCurr->stDisplay.eResolution == stUsageMode.stDisplay.eResolution) && (pCurr->stDisplay.eAspectRatio == stUsageMode.stDisplay.eAspectRatio) && (pCurr->eWindow == stUsageMode.eWindow)) { eDispMode = BVDB_P_GetVideoDisplayModeType(&pCurr->stDisplayMode); eInsertDispMode = BVDB_P_GetVideoDisplayModeType(&stDispMode); pNext = BVDB_P_UsageMode_GetNextNode(pCurr); pPrev = BVDB_P_UsageMode_GetPrevNode(pCurr); if (((pCurr->eInput == stUsageMode.eInput) && (eDispMode < eInsertDispMode)) || /* compare inputs and display mode */ ((pCurr->eInput < stUsageMode.eInput) && (stUsageMode.eInput < pNext->eInput))) /* compare inputs */ { bInsertPointAfter = true; break; } else if (((pCurr->eInput == stUsageMode.eInput) && (eDispMode > eInsertDispMode)) || /* compare inputs and display mode */ ((pCurr->eInput > stUsageMode.eInput) && (stUsageMode.eInput > pPrev->eInput))) /* compare inputs */ { bInsertPointBefore = true; break; } } pCurr = BVDB_P_UsageMode_GetNextNode(pCurr); } while (pCurr != BLST_CQ_FIRST(pVdb)); pInsert = (BVDB_UsageMode *)BKNI_Malloc(sizeof(BVDB_UsageMode)); if (pInsert == NULL) { BDBG_ERR(("Out of memory")); return BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY); } BKNI_Memcpy((void *)pInsert, (void *)&stUsageMode, sizeof(BVDB_UsageMode)); /* compare input of above usage mode with to be inserted usage mode. */ if (bInsertPointAfter) { BLST_CQ_INSERT_AFTER(pVdb, pCurr, pInsert, link); } else if (bInsertPointBefore) { BLST_CQ_INSERT_BEFORE(pVdb, pCurr, pInsert, link); } else /* add at tail */ { BLST_CQ_INSERT_TAIL(pVdb, pInsert, link); } BDBG_MSG(("Added usage mode %s", stUsageMode.acId)); } } else { BDBG_ERR(("Failed to add usage mode due to bad parameters entered")); err = BERR_INVALID_PARAMETER; } return BERR_TRACE(err); } BERR_Code BVDB_RemoveVdbEntry ( BVDB_Handle hVdb, const BVDB_UsageMode *pstUsageMode ) { BERR_Code err = BERR_SUCCESS; BVDB_P_Context *pVdb; BVDB_UsageMode *pCurr; bool bFound = false; BVDB_P_GET_CONTEXT(hVdb, pVdb); pCurr = BLST_CQ_FIRST(pVdb); do { if (strcmp(pCurr->acId, pstUsageMode->acId) == 0) { bFound = true; break; } pCurr = BVDB_P_UsageMode_GetNextNode(pCurr); } while (pCurr != BLST_CQ_FIRST(pVdb)); if (bFound) { /* remove entry */ BLST_CQ_REMOVE(pVdb, pCurr, link); BKNI_Free(pCurr); } else { BDBG_ERR(("ID not found")); err = BERR_INVALID_PARAMETER; } return BERR_TRACE(err); } static bool bCacheFilled[BVDB_Window_eMonitor + 1]; BERR_Code BVDB_GetVdbEntry ( BVDB_Handle hVdb, BVDB_UsageMode *pstUsageMode ) { BERR_Code err = BERR_SUCCESS; BVDB_P_Context *pVdb; BVDB_UsageMode *pstTemp; bool bFound = false; BVDB_VideoDisplayMode *pMode, *pSearchMode; uint32_t ulUsrId, ulTempId; BVDB_UsageMode *pTempUsageMode; static BVDB_UsageMode stCachedUsageMode[BVDB_Window_eMonitor + 1]; BVDB_P_GET_CONTEXT(hVdb, pVdb); ulUsrId = BVDB_P_GetConfigId(pstUsageMode->acId); /* Find a cache hit: * * As the entire table search may take long, which may affect real time * operation, a concept so called "cached VDB mode" is introduced here. * VDB usage mode cache holds the latest VDB usage mode for each window * (i.e., Main, Pip, Monitor). And whenever there's a new query for the * VDB usage mode, it looks at the cached mode first because it's very * likely that the match is there. If it matches (Cache hit), then it * simply returns the* cached VDB usage mode. Otherwise, (Cache miss) it * has to search the entire usage mode table. * * Note: Of course the larger cache, the better performance. The # of cached * Usage mode can be extended if faster response is required. */ /* See if there's a match with the cached usage mode info */ pTempUsageMode = &stCachedUsageMode[pstUsageMode->eWindow]; /* Make sure size of BVDB_VideoDisplayMode is 4 bytes */ BDBG_ASSERT(sizeof(BVDB_VideoDisplayMode) == sizeof(uint32_t)); pMode = &pTempUsageMode->stDisplayMode; pSearchMode = &(pstUsageMode->stDisplayMode); if (bCacheFilled[pstUsageMode->eWindow]) { BDBG_ASSERT(BVDB_P_GetConfigId(pstUsageMode->acId) == BVDB_P_GetConfigId(pTempUsageMode->acId)); /* Matched! Return immediately without searching the whole usage mode array */ if ((pstUsageMode->eInputFormatGroup == pTempUsageMode->eInputFormatGroup) && (pstUsageMode->stDisplay.eType == pTempUsageMode->stDisplay.eType) && (pstUsageMode->stDisplay.eResolution == pTempUsageMode->stDisplay.eResolution) && (pstUsageMode->stDisplay.eAspectRatio == pTempUsageMode->stDisplay.eAspectRatio) && (pstUsageMode->eWindow == pTempUsageMode->eWindow) && (pstUsageMode->eInput == pTempUsageMode->eInput) && ((*(uint32_t*)pMode) & (*(uint32_t *)pSearchMode))) { BKNI_Memcpy(pstUsageMode, pTempUsageMode, sizeof(BVDB_UsageMode)); return BERR_TRACE(err); } } /* Unfortunately the cached usage mode doesn't match. Must search the whole usage * modes for the match */ pstTemp = BLST_CQ_FIRST(pVdb); do { pMode = &pstTemp->stDisplayMode; pSearchMode = &(pstUsageMode->stDisplayMode); ulTempId = BVDB_P_GetConfigId(pstTemp->acId); if ((ulUsrId == ulTempId) && (pstUsageMode->eInputFormatGroup == pstTemp->eInputFormatGroup) && (pstUsageMode->stDisplay.eType == pstTemp->stDisplay.eType) && (pstUsageMode->stDisplay.eResolution == pstTemp->stDisplay.eResolution) && (pstUsageMode->stDisplay.eAspectRatio == pstTemp->stDisplay.eAspectRatio) && (pstUsageMode->eWindow == pstTemp->eWindow) && (pstUsageMode->eInput == pstTemp->eInput) && ((*(uint32_t*)pMode) & (*(uint32_t *)pSearchMode))) { bFound = true; break; } pstTemp = BVDB_P_UsageMode_GetNextNode(pstTemp); } while (pstTemp != BLST_CQ_FIRST(pVdb)); if (bFound == false) err = BERR_INVALID_PARAMETER; else { BKNI_Memcpy(pstUsageMode, pstTemp, sizeof(BVDB_UsageMode)); BKNI_Memcpy(pTempUsageMode, pstTemp, sizeof(BVDB_UsageMode)); bCacheFilled[pstUsageMode->eWindow] = true; } return BERR_TRACE(err); } BERR_Code BVDB_GetVdbEntryById ( BVDB_Handle hVdb, BVDB_UsageMode *pstUsageMode ) { BERR_Code err = BERR_SUCCESS; BVDB_P_Context *pVdb; BVDB_UsageMode *pstTemp; bool bFound = false; BVDB_P_GET_CONTEXT(hVdb, pVdb); pstTemp = BLST_CQ_FIRST(pVdb); do { if (strcmp(pstUsageMode->acId, pstTemp->acId) == 0) { BKNI_Memcpy((void *)pstUsageMode, (void *)pstTemp, sizeof(BVDB_UsageMode)); bFound = true; break; } pstTemp = BVDB_P_UsageMode_GetNextNode(pstTemp); } while (pstTemp != BLST_CQ_FIRST(pVdb)); if (bFound == false) err = BERR_INVALID_PARAMETER; return BERR_TRACE(err); } BERR_Code BVDB_GetClippedSize ( BVDB_Handle hVdb, BVDB_VideoDisplayMode *pstDispMode, uint32_t *pulHeight, uint32_t *pulWidth ) { BERR_Code err = BERR_SUCCESS; uint32_t ulH, ulW; BVDB_VideoDisplayModeInfo stInfo; BSTD_UNUSED(hVdb); err = BVDB_P_GetVideoDispModeInfo(pstDispMode, &stInfo); if (err != BERR_SUCCESS) { return BERR_TRACE(err); } /* get new active size */ if (stInfo.ulSrcHeightClipAmount != 0) { ulH = (*pulHeight * (100 - stInfo.ulSrcHeightClipAmount))/100; if (((*pulHeight * (100 - stInfo.ulSrcHeightClipAmount))%100) >= 5) *pulHeight = ulH + 1; else *pulHeight = ulH; } if (stInfo.ulSrcWidthClipAmount != 0) { ulW = (*pulWidth * (100 - stInfo.ulSrcWidthClipAmount))/100; if (((*pulWidth * (100 - stInfo.ulSrcWidthClipAmount))%100) >= 5) *pulWidth = ulW + 1; else *pulWidth = ulW; } return BERR_TRACE(err); } BERR_Code BVDB_GetDisplaySourceAs ( BVDB_Handle hVdb, BVDB_VideoDisplayMode *pstDispMode, const uint32_t ulSrcHeight, const uint32_t ulSrcWidth, const BVDB_Display *pstDisplay, const BFMT_AspectRatio eSrcAspectRatio, const uint16_t uiSampleAspectRatioX, const uint16_t uiSampleAspectRatioY, const BVDB_AspectRatio eAspectRatioCorrection, BVDB_DisplaySourceAs *peDisplaySourceAs ) { BERR_Code err = BERR_SUCCESS; BVDB_VideoDisplayModeInfo stInfo; BFMT_AspectRatio eLocalSrcAspectRatio; uint32_t ulFrameAspectRatio = 0; BSTD_UNUSED(hVdb); eLocalSrcAspectRatio = eSrcAspectRatio; /* Handle unknown source aspect ratio */ if (BFMT_AspectRatio_eUnknown == eLocalSrcAspectRatio) { uint32_t ulHVRatio = (ulSrcWidth * 100) / ulSrcHeight; eLocalSrcAspectRatio = BVDB_P_EQ_DELTA(ulHVRatio, 130, 25) ? BFMT_AspectRatio_e4_3 : BFMT_AspectRatio_eSquarePxl; BDBG_MSG(("changing eLocalSrcAspectRatio from eUnknown to %d", eLocalSrcAspectRatio)); } if (eAspectRatioCorrection == BVDB_AspectRatio_eAllSrc) { /* Get the frame aspect ratio based on the clipped dimensions. */ if (eLocalSrcAspectRatio == BFMT_AspectRatio_eSAR) { if (0 == uiSampleAspectRatioX || 0 == uiSampleAspectRatioY) { uint32_t ulHVRatio = (ulSrcWidth * 100) / ulSrcHeight; eLocalSrcAspectRatio = BVDB_P_EQ_DELTA(ulHVRatio, 130, 25) ? BFMT_AspectRatio_e4_3 : BFMT_AspectRatio_eSquarePxl; ulFrameAspectRatio = (eLocalSrcAspectRatio == BFMT_AspectRatio_e4_3) ? (4 * 100)/3 : ulHVRatio; } else { /* Get frame aspect ratio based on clipped size */ ulFrameAspectRatio = (uiSampleAspectRatioX * ulSrcWidth * 100) / (uiSampleAspectRatioY * ulSrcHeight); } } else { uint32_t ulPixelAspectRatio; uint32_t ulFrameAspectRatioX, ulFrameAspectRatioY; uint32_t ulConvFactor; switch(eLocalSrcAspectRatio) { case BFMT_AspectRatio_e16_9: ulFrameAspectRatioX = 16; ulFrameAspectRatioY = 9; break; case BFMT_AspectRatio_e15_9: ulFrameAspectRatioX = 15; ulFrameAspectRatioY = 9; break; case BFMT_AspectRatio_e4_3: ulFrameAspectRatioX = 4; ulFrameAspectRatioY = 3; break; case BFMT_AspectRatio_e221_1: ulFrameAspectRatioX = 221; ulFrameAspectRatioY = 1; break; case BFMT_AspectRatio_eSquarePxl: ulFrameAspectRatioX = 1; ulFrameAspectRatioY = 1; break; default: BDBG_ERR(("BVDB_AspectRatio_eAllSrc failed because eLocalSrcAspectRatio=%d", eLocalSrcAspectRatio)); return BERR_TRACE(BERR_INVALID_PARAMETER); } if ((ulFrameAspectRatioX * 100)/ulFrameAspectRatioY == (ulSrcWidth * 100)/ulSrcHeight) { ulPixelAspectRatio = 1; ulConvFactor = 100; } else { ulPixelAspectRatio = (((ulFrameAspectRatioX * 100)/ulFrameAspectRatioY) * 100)/((ulSrcWidth * 100)/ulSrcHeight); ulConvFactor = 1; } /* Get frame aspect ratio based on clipped size */ ulFrameAspectRatio = (ulPixelAspectRatio * ulSrcWidth * ulConvFactor) / (1 * ulSrcHeight); BDBG_MSG(("eAspectRatioCorrection = %d", eAspectRatioCorrection)); BDBG_MSG(("ulPixelAspectRatio = %d", ulPixelAspectRatio)); BDBG_MSG(("ulFrameAspectRatioX = %d", ulFrameAspectRatioX)); BDBG_MSG(("ulFrameAspectRatioY = %d", ulFrameAspectRatioY)); BDBG_MSG(("ulSrcWidth = %d", ulSrcWidth)); BDBG_MSG(("ulSrcHeight = %d", ulSrcHeight)); } } else if (eAspectRatioCorrection == BVDB_AspectRatio_eAllDest) { switch (pstDisplay->eAspectRatio) { case BVDB_AspectRatio_e16_9: ulFrameAspectRatio = BVDB_P_ASPECT_RATIO_16_9; break; case BVDB_AspectRatio_e4_3: ulFrameAspectRatio = BVDB_P_ASPECT_RATIO_4_3; break; default: BDBG_ERR(("Display panel aspect ratio is not supported.")); err = BERR_INVALID_PARAMETER; } } else if (eAspectRatioCorrection == BVDB_AspectRatio_eBypass) { if (eLocalSrcAspectRatio == BFMT_AspectRatio_eSAR) { if (0 == uiSampleAspectRatioX || 0 == uiSampleAspectRatioY) { uint32_t ulHVRatio = (ulSrcWidth * 100) / ulSrcHeight; eLocalSrcAspectRatio = BVDB_P_EQ_DELTA(ulHVRatio, 130, 25) ? BFMT_AspectRatio_e4_3 : BFMT_AspectRatio_eSquarePxl; ulFrameAspectRatio = (eLocalSrcAspectRatio == BFMT_AspectRatio_e4_3) ? (4 * 100)/3 : ulHVRatio; } else { ulFrameAspectRatio = (uiSampleAspectRatioX * ulSrcWidth * 100) / (uiSampleAspectRatioY * ulSrcHeight); } } else { switch (eLocalSrcAspectRatio) { case BFMT_AspectRatio_e16_9: ulFrameAspectRatio = BVDB_P_ASPECT_RATIO_16_9; break; case BFMT_AspectRatio_e15_9: ulFrameAspectRatio = BVDB_P_ASPECT_RATIO_15_9; break; case BFMT_AspectRatio_e4_3: ulFrameAspectRatio = BVDB_P_ASPECT_RATIO_4_3; break; case BFMT_AspectRatio_e221_1: ulFrameAspectRatio = BVDB_P_ASPECT_RATIO_221; break; case BFMT_AspectRatio_eSquarePxl: ulFrameAspectRatio = (ulSrcWidth * 100) / ulSrcHeight; break; default: BDBG_ERR(("BVDB_AspectRatio_eBypass failed because eLocalSrcAspectRatio=%d", eLocalSrcAspectRatio)); return BERR_TRACE(BERR_INVALID_PARAMETER); } } } else { BDBG_ERR(("Specified aspect ratio correction %d is not supported.", eAspectRatioCorrection)); return BERR_TRACE(BERR_INVALID_PARAMETER); } BDBG_MSG(("Display is %s", (pstDisplay->eAspectRatio == BVDB_AspectRatio_e16_9) ? "16:9" : ((pstDisplay->eAspectRatio == BVDB_AspectRatio_e4_3) ? "4:3" : "unknown"))); BDBG_MSG(("Source AR is %s", (ulFrameAspectRatio == BVDB_P_ASPECT_RATIO_16_9) ? "16:9" : (ulFrameAspectRatio <= BVDB_P_ASPECT_RATIO_16_9) ? "4:3" : "other")); err = BVDB_P_GetVideoDispModeInfo(pstDispMode, &stInfo); if (err != BERR_SUCCESS) { return BERR_TRACE(err); } if (pstDisplay->eAspectRatio == BVDB_AspectRatio_e16_9) { *peDisplaySourceAs = (ulFrameAspectRatio >= BVDB_P_ASPECT_RATIO_16_9) ? stInfo.eDisplay16_9SrcOn16_9Display : stInfo.eDisplay4_3SrcOn16_9dDisplay; } else if (pstDisplay->eAspectRatio == BVDB_AspectRatio_e4_3) { *peDisplaySourceAs = (ulFrameAspectRatio <= BVDB_P_ASPECT_RATIO_16_9) ? stInfo.eDisplay16_9SrcOn4_3Display : stInfo.eDisplay4_3SrcOn4_3Display; } else { BDBG_ERR(("Invalid display aspect ratio %d.", pstDisplay->eAspectRatio)); err = BERR_INVALID_PARAMETER; } return BERR_TRACE(err); } BERR_Code BVDB_ValidateConfigId ( BVDB_Handle hVdb, const uint32_t ulConfigId ) { BERR_Code err = BERR_SUCCESS; bool bFound = false; BVDB_UsageMode *pstUsageMode; BVDB_P_Context *pVdb; BVDB_P_GET_CONTEXT(hVdb, pVdb); pstUsageMode = BLST_CQ_FIRST(pVdb); do { if (ulConfigId == BVDB_P_GetConfigId(pstUsageMode->acId)) { bFound = true; break; } pstUsageMode = BVDB_P_UsageMode_GetNextNode(pstUsageMode); } while (pstUsageMode != BLST_CQ_FIRST(pVdb)); if (bFound == false) err = BERR_INVALID_PARAMETER; /* need some way to clear the cache when switching id's. BVDB_ValidateConfigId could be repurposed to that end. */ BKNI_Memset(bCacheFilled, 0, sizeof(bCacheFilled)); return BERR_TRACE(err); } BERR_Code BVDB_ValidateSourceClipAmount ( BVDB_Handle hVdb, const BVDB_UsageMode *pstUsageMode, const uint32_t ulSrcHeight, const uint32_t ulSrcWidth, const uint32_t ulHeightClipAmount, const uint32_t ulWidthClipAmount ) { BERR_Code err = BERR_SUCCESS; BVDB_P_Context *pVdb; BVDB_VideoDisplayModeInfo stInfo; BVDB_VideoDisplayMode stDispMode = pstUsageMode->stDisplayMode; BVDB_P_GET_CONTEXT(hVdb, pVdb); err = BVDB_P_GetVideoDispModeInfo(&stDispMode, &stInfo ); if (err == BERR_SUCCESS) { /* validate */ if ((pstUsageMode->stDisplay.eType == BVDB_Display_eSecondary50 || pstUsageMode->stDisplay.eType == BVDB_Display_eSecondary60) && (BVDB_DISP_MODE_IS_MON_1(&pstUsageMode->stDisplayMode) || BVDB_DISP_MODE_IS_MON_3(&pstUsageMode->stDisplayMode))) { if (((ulHeightClipAmount * 100)/ulSrcHeight) < stInfo.ulSrcHeightClipAmount && ((ulHeightClipAmount * 100)/ulSrcHeight) > 0) { BDBG_ERR(("Total source height clip[%d percent] amount for secondary display must follow main window.", ((ulHeightClipAmount * 100)/ulSrcHeight))); err = BERR_INVALID_PARAMETER; } if (((ulWidthClipAmount * 100)/ulSrcWidth) < stInfo.ulSrcWidthClipAmount && ((ulWidthClipAmount * 100)/ulSrcWidth) > 0) { BDBG_ERR(("Total source width clip[%d percent] amount for secondary display must follow main window.", ((ulWidthClipAmount * 100)/ulSrcWidth))); err = BERR_INVALID_PARAMETER; } } else { if (((ulHeightClipAmount * 100)/ulSrcHeight) > stInfo.ulSrcHeightClipAmount) { BDBG_ERR(("Total source height clip amount [%d percent] exceeds max[%d percent] allowed.", ((ulHeightClipAmount * 100)/ulSrcHeight), stInfo.ulSrcHeightClipAmount)); err = BERR_INVALID_PARAMETER; } if (((ulWidthClipAmount * 100)/ulSrcWidth) > stInfo.ulSrcWidthClipAmount) { BDBG_ERR(("Total source width clip[%d percent] amount exceeds max[%d percent] allowed.", ((ulWidthClipAmount * 100)/ulSrcWidth), stInfo.ulSrcWidthClipAmount)); err = BERR_INVALID_PARAMETER; } } } return BERR_TRACE(err); } BERR_Code BVDB_GetMemoryAllocation (const uint32_t ulConfigId, const BVDB_Window eWindow, const BVDB_Input eInput, BVDB_Heap_Settings *pstHeapSettings, uint32_t *pulHeapSize ) { BERR_Code err = BERR_SUCCESS; uint32_t i, j, k; bool bFound = false; uint32_t ulNumConfigs; BVDB_P_Config_MemAlloc *pstConfigMemAlloc; BDBG_ASSERT(pstHeapSettings); err = BVDB_P_GetNumConfigs(&ulNumConfigs); if (err != BERR_SUCCESS) { return BERR_TRACE(err); } pstConfigMemAlloc = (BVDB_P_Config_MemAlloc *)BKNI_Malloc(sizeof(BVDB_P_Config_MemAlloc) * ulNumConfigs * BVDB_P_NUM_WINDOW_HEAPS); if (pstConfigMemAlloc == NULL) { BDBG_ERR(("Out of memory.")); err = BERR_OUT_OF_SYSTEM_MEMORY; return BERR_TRACE(err); } err = BVDB_P_GetConfigMemAllocArray(pstConfigMemAlloc); if (err != BERR_SUCCESS) { return BERR_TRACE(err); } /* Search for config */ for (k=0; keResolution, &ulDisplayHeight, &ulDisplayWidth); if (err != BERR_SUCCESS) { return BERR_TRACE(err); } /* Get config's video display mode information */ err = BVDB_P_GetConfigVideoDisplayModeInfo(ulConfigId, &stCfgVidDispModes); if (err != BERR_SUCCESS) { return BERR_TRACE(err); } /* Get clip amount percentage */ ulHeightClipAmount = (ulSrcHeightClipAmount * 100)/ulSrcHeight; ulWidthClipAmount = (ulSrcWidthClipAmount * 100)/ulSrcWidth; /* Get clipped dimensions */ ulClippedHeight = ulSrcHeight - ulSrcHeightClipAmount; ulClippedWidth = ulSrcWidth - ulSrcWidthClipAmount; eLocalSrcAspectRatio = eSrcAspectRatio; /* Handle unknown source aspect ratio */ if (BFMT_AspectRatio_eUnknown == eLocalSrcAspectRatio) { uint32_t ulHVRatio = (ulSrcWidth * 100) / ulSrcHeight; eLocalSrcAspectRatio = BVDB_P_EQ_DELTA(ulHVRatio, 130, 25) ? BFMT_AspectRatio_e4_3 : BFMT_AspectRatio_eSquarePxl; BDBG_MSG(("changing eLocalSrcAspectRatio from eUnknown to %d", eLocalSrcAspectRatio)); } if (eAspectRatioCorrection == BVDB_AspectRatio_eAllSrc) { /* Get the frame aspect ratio based on the clipped dimensions. */ if (eLocalSrcAspectRatio == BFMT_AspectRatio_eSAR) { if (0 == uiSampleAspectRatioX || 0 == uiSampleAspectRatioY) { uint32_t ulHVRatio = (ulClippedWidth * 100) / ulClippedHeight; eLocalSrcAspectRatio = BVDB_P_EQ_DELTA(ulHVRatio, 130, 25) ? BFMT_AspectRatio_e4_3 : BFMT_AspectRatio_eSquarePxl; ulFrameAspectRatio = (eLocalSrcAspectRatio == BFMT_AspectRatio_e4_3) ? (4 * 100)/3 : ulHVRatio; } else { /* Get frame aspect ratio based on clipped size */ ulFrameAspectRatio = (uiSampleAspectRatioX * ulClippedWidth * 100) / (uiSampleAspectRatioY * ulClippedHeight); } } else { uint32_t ulPixelAspectRatio; uint32_t ulFrameAspectRatioX, ulFrameAspectRatioY; uint32_t ulConvFactor; switch(eLocalSrcAspectRatio) { case BFMT_AspectRatio_e16_9: ulFrameAspectRatioX = 16; ulFrameAspectRatioY = 9; break; case BFMT_AspectRatio_e15_9: ulFrameAspectRatioX = 15; ulFrameAspectRatioY = 9; break; case BFMT_AspectRatio_e4_3: ulFrameAspectRatioX = 4; ulFrameAspectRatioY = 3; break; case BFMT_AspectRatio_e221_1: ulFrameAspectRatioX = 221; ulFrameAspectRatioY = 1; break; case BFMT_AspectRatio_eSquarePxl: ulFrameAspectRatioX = 1; ulFrameAspectRatioY = 1; break; default: err = BERR_INVALID_PARAMETER; return BERR_TRACE(err); } if ((ulFrameAspectRatioX * 100)/ulFrameAspectRatioY == (ulSrcWidth * 100)/ulSrcHeight) { ulPixelAspectRatio = 1; ulConvFactor = 100; } else { ulPixelAspectRatio = (((ulFrameAspectRatioX * 100)/ulFrameAspectRatioY) * 100)/((ulSrcWidth * 100)/ulSrcHeight); ulConvFactor = 1; } /* Get frame aspect ratio based on clipped size */ ulFrameAspectRatio = (ulPixelAspectRatio * ulClippedWidth * ulConvFactor) / (1 * ulClippedHeight); BDBG_MSG(("eAspectRatioCorrection = %d", eAspectRatioCorrection)); BDBG_MSG(("ulPixelAspectRatio = %d", ulPixelAspectRatio)); BDBG_MSG(("ulFrameAspectRatioX = %d", ulFrameAspectRatioX)); BDBG_MSG(("ulFrameAspectRatioY = %d", ulFrameAspectRatioY)); BDBG_MSG(("ulSrcWidth = %d", ulSrcWidth)); BDBG_MSG(("ulSrcHeight = %d", ulSrcHeight)); } } else if (eAspectRatioCorrection == BVDB_AspectRatio_eAllDest) { switch (pstDisplay->eAspectRatio) { case BVDB_AspectRatio_e16_9: ulFrameAspectRatio = BVDB_P_ASPECT_RATIO_16_9; break; case BVDB_AspectRatio_e4_3: ulFrameAspectRatio = BVDB_P_ASPECT_RATIO_4_3; break; default: BDBG_ERR(("Display panel aspect ratio is not supported.")); err = BERR_INVALID_PARAMETER; } } else if (eAspectRatioCorrection == BVDB_AspectRatio_eBypass) { if (eLocalSrcAspectRatio == BFMT_AspectRatio_eSAR) { if (0 == uiSampleAspectRatioX || 0 == uiSampleAspectRatioY) { uint32_t ulHVRatio = (ulSrcWidth * 100) / ulSrcHeight; eLocalSrcAspectRatio = BVDB_P_EQ_DELTA(ulHVRatio, 130, 25) ? BFMT_AspectRatio_e4_3 : BFMT_AspectRatio_eSquarePxl; ulFrameAspectRatio = (eLocalSrcAspectRatio == BFMT_AspectRatio_e4_3) ? (4 * 100)/3 : ulHVRatio; } else { ulFrameAspectRatio = (uiSampleAspectRatioX * ulSrcWidth * 100) / (uiSampleAspectRatioY * ulSrcHeight); } } else { switch (eLocalSrcAspectRatio) { case BFMT_AspectRatio_e16_9: ulFrameAspectRatio = BVDB_P_ASPECT_RATIO_16_9; break; case BFMT_AspectRatio_e15_9: ulFrameAspectRatio = BVDB_P_ASPECT_RATIO_15_9; break; case BFMT_AspectRatio_e4_3: ulFrameAspectRatio = BVDB_P_ASPECT_RATIO_4_3; break; case BFMT_AspectRatio_e221_1: ulFrameAspectRatio = BVDB_P_ASPECT_RATIO_221; break; case BFMT_AspectRatio_eSquarePxl: ulFrameAspectRatio = (ulSrcWidth * 100) / ulSrcHeight; break; default: err = BERR_INVALID_PARAMETER; return BERR_TRACE(err); } } } else { BDBG_ERR(("Specified aspect ratio correction is not supported.")); err = BERR_INVALID_PARAMETER; return BERR_TRACE(err); } /* Get dest window aspect ratio */ ulDestAspectRatio = (ulDestWidth * 100)/ulDestHeight; if (ulDestAspectRatio < BVDB_P_ASPECT_RATIO_16_9) { eDestAspectRatio = BVDB_AspectRatio_e4_3; } else if (ulDestAspectRatio == BVDB_P_ASPECT_RATIO_16_9) { eDestAspectRatio = BVDB_AspectRatio_e16_9; } else { eDestAspectRatio = BVDB_AspectRatio_eCustom; } if (eAspectRatioCorrection == BVDB_AspectRatio_eAllDest) { if (pstDisplay->eAspectRatio == BVDB_AspectRatio_e16_9) { *pDisplayedAspectRatio = BFMT_AspectRatio_e16_9; } else if (pstDisplay->eAspectRatio == BVDB_AspectRatio_e4_3) { *pDisplayedAspectRatio = BFMT_AspectRatio_e4_3; } else { *pDisplayedAspectRatio = BFMT_AspectRatio_eUnknown; } } else if (eAspectRatioCorrection == BVDB_AspectRatio_eBypass) { if (eDestAspectRatio == BVDB_AspectRatio_e4_3) { *pDisplayedAspectRatio = BFMT_AspectRatio_e4_3; } else if (eDestAspectRatio == BVDB_AspectRatio_e16_9) { *pDisplayedAspectRatio = BFMT_AspectRatio_e16_9; } else { if (ulDestAspectRatio > BVDB_P_ASPECT_RATIO_16_9) *pDisplayedAspectRatio = BFMT_AspectRatio_e16_9; else *pDisplayedAspectRatio = BFMT_AspectRatio_eUnknown; } } else if (eAspectRatioCorrection == BVDB_AspectRatio_eAllSrc) { /* any AR less than 16:9 is a pillarbox on a 16:9 panel */ if (ulFrameAspectRatio < BVDB_P_ASPECT_RATIO_16_9) { *pDisplayedAspectRatio = BFMT_AspectRatio_e4_3; } else if (ulFrameAspectRatio == BVDB_P_ASPECT_RATIO_16_9) { *pDisplayedAspectRatio = BFMT_AspectRatio_e16_9; } else { /* aspect ratio > 16:9 is unsupported in RTS */ if (ulDestAspectRatio == BVDB_P_ASPECT_RATIO_16_9) *pDisplayedAspectRatio = BFMT_AspectRatio_e16_9; /* cap it at 16:9 */ else *pDisplayedAspectRatio = BFMT_AspectRatio_eUnknown; } } /* Get eDisplaySrcAs given the src and dest apsect ratios */ if (ulFrameAspectRatio < BVDB_P_ASPECT_RATIO_16_9) { if (pstDisplay->eAspectRatio == BVDB_AspectRatio_e16_9) { if (*pDisplayedAspectRatio == BFMT_AspectRatio_e16_9) { eDisplaySrcAs = BVDB_DisplaySourceAs_eFull; } else if (*pDisplayedAspectRatio == BFMT_AspectRatio_e4_3) { eDisplaySrcAs = BVDB_DisplaySourceAs_ePillarbox; } else { eDisplaySrcAs = BVDB_DisplaySourceAs_eInvalid; } } else if (pstDisplay->eAspectRatio == BVDB_AspectRatio_e4_3) { if (*pDisplayedAspectRatio == BFMT_AspectRatio_e16_9) { eDisplaySrcAs = BVDB_DisplaySourceAs_eLetterbox; } else if (*pDisplayedAspectRatio == BFMT_AspectRatio_e4_3) { eDisplaySrcAs = BVDB_DisplaySourceAs_eFull; } else { eDisplaySrcAs = BVDB_DisplaySourceAs_eInvalid; } } else { eDisplaySrcAs = BVDB_DisplaySourceAs_eInvalid; } } else if (ulFrameAspectRatio == BVDB_P_ASPECT_RATIO_16_9) { if (pstDisplay->eAspectRatio == BVDB_AspectRatio_e16_9) { if (*pDisplayedAspectRatio == BFMT_AspectRatio_e16_9) { eDisplaySrcAs = BVDB_DisplaySourceAs_eFull; } else if (*pDisplayedAspectRatio == BFMT_AspectRatio_e4_3) { eDisplaySrcAs = BVDB_DisplaySourceAs_ePillarbox; } else { eDisplaySrcAs = BVDB_DisplaySourceAs_eInvalid; } } else if (pstDisplay->eAspectRatio == BVDB_AspectRatio_e4_3) { if (*pDisplayedAspectRatio == BFMT_AspectRatio_e16_9) { eDisplaySrcAs = BVDB_DisplaySourceAs_eLetterbox; } else if (*pDisplayedAspectRatio == BFMT_AspectRatio_e4_3) { eDisplaySrcAs = BVDB_DisplaySourceAs_eFull; } else { eDisplaySrcAs = BVDB_DisplaySourceAs_eInvalid; } } else { eDisplaySrcAs = BVDB_DisplaySourceAs_eInvalid; } } else { if (pstDisplay->eAspectRatio == BVDB_AspectRatio_e16_9) { if (*pDisplayedAspectRatio == BFMT_AspectRatio_e16_9) { eDisplaySrcAs = BVDB_DisplaySourceAs_eFull; } else if (*pDisplayedAspectRatio == BFMT_AspectRatio_e4_3) { eDisplaySrcAs = BVDB_DisplaySourceAs_ePillarbox; } else { eDisplaySrcAs = BVDB_DisplaySourceAs_eInvalid; } } else if (pstDisplay->eAspectRatio == BVDB_AspectRatio_e4_3) { if (*pDisplayedAspectRatio == BFMT_AspectRatio_e16_9) { eDisplaySrcAs = BVDB_DisplaySourceAs_eLetterbox; } else if (*pDisplayedAspectRatio == BFMT_AspectRatio_e4_3) { eDisplaySrcAs = BVDB_DisplaySourceAs_eFull; } else { eDisplaySrcAs = BVDB_DisplaySourceAs_eInvalid; } } else { eDisplaySrcAs = BVDB_DisplaySourceAs_eInvalid; } } BDBG_MSG(("ulFrameAspectRatio = %d", ulFrameAspectRatio)); BDBG_MSG(("ulDestAspectRatio = %d (%d)", ulDestAspectRatio, BVDB_P_ASPECT_RATIO_16_9)); BDBG_MSG(("eDestAspectRatio = %d", eDestAspectRatio)); BDBG_MSG(("*pDisplayedAspectRatio = %s", (*pDisplayedAspectRatio == BFMT_AspectRatio_e16_9) ? "16:9" : (*pDisplayedAspectRatio == BFMT_AspectRatio_e4_3) ? "4:3" : "other")); BDBG_MSG(("eDisplaySrcAs = %s", (eDisplaySrcAs == BVDB_DisplaySourceAs_eFull) ? "FULL": (eDisplaySrcAs == BVDB_DisplaySourceAs_eLetterbox) ? "LBOX" : (eDisplaySrcAs == BVDB_DisplaySourceAs_ePillarbox) ? "PBOX" : "other")); BDBG_MSG(("Source AR is %s", (ulFrameAspectRatio == BVDB_P_ASPECT_RATIO_16_9) ? "16:9" : (ulFrameAspectRatio <= BVDB_P_ASPECT_RATIO_16_9) ? "4:3" : "other")); BDBG_MSG(("Display is %s", (pstDisplay->eAspectRatio == BVDB_AspectRatio_e16_9) ? "16:9" : ((pstDisplay->eAspectRatio == BVDB_AspectRatio_e4_3) ? "4:3" : "unknown"))); BDBG_MSG(("Display size (wxh) = %d x %d", ulDisplayWidth, ulDisplayHeight)); BDBG_MSG(("Clipped source (wxh) = %d x %d", ulClippedWidth, ulClippedHeight)); BDBG_MSG(("Destination window size (wxh) = %d x %d", ulDestWidth, ulDestHeight)); BDBG_MSG(("Clip Amount(in percent, wxh) = %d x %d", ulWidthClipAmount, ulHeightClipAmount)); /* evaluate if display is primary */ if (BVDB_P_IsDisplayPrimary(pstDisplay->eType)) { /* In case of 3D sources, searching a matched display mode does not make * sense because RTS is calculated for and fixed to one predefined * display mode which is FULL.1 for main and PIP.1 for secondary window * with an assumption of no cropping and (min window size == max window * size) */ if (eInput == BVDB_Input_eHdDvi) { uint32_t i; uint32_t numEntry; numEntry = sizeof(stNonPcNonStandardFormats) / sizeof(BVDB_P_NonPcNonStandardFomat); for (i = 0; i < numEntry; i++) { if ((ulSrcHeight == stNonPcNonStandardFormats[i].height) && (ulSrcWidth == stNonPcNonStandardFormats[i].width) && stNonPcNonStandardFormats[i].b3dSource) { if (eWindow == BVDB_Window_eMain) { st3dDispMode.ulFull1 = 1; st3dDispMode.ulFull2 = 1; st3dDispMode.ulFull3 = 1; st3dDispMode.ulFull4 = 1; st3dDispMode.ulFull5 = 1; st3dDispMode.ulFull6 = 1; st3dDispMode.ulFull8 = 1; st3dDispMode.ulFull9 = 1; BDBG_MSG(("Could be 3D main and set to FULL.1/FULL.2/FULL.3/FULL.4/FULL.5/FULL.6/FULL.8/FULL.9"));; } else { st3dDispMode.ulPip1 = 1; BDBG_MSG(("Could be 3D PIP and set to PIP.1"));; } break; } } } /* evaluate if window is main or pip */ if (eWindow == BVDB_Window_eMain) { /* Check for cases that satisfies dot-by-dot and return FULL.7. The RTS should satisfy * PIG.2 as well for most configs. * * Note, that there are some configs that have different RTS for dot-by-dot and * PIG.2. However, the PIG size for those configs are different than the dot-by-dot * size hence the display mode will be returned accordingly. */ if (ulDestWidth == ulClippedWidth && ulDestHeight == ulClippedHeight && ulClippedWidth <= ulDisplayWidth && ulClippedHeight <= ulDisplayHeight && ulHeightClipAmount <= stCfgVidDispModes.astFullModes[6].stVideoDisplayMode.ulSrcHeightClipAmount && ulWidthClipAmount <= stCfgVidDispModes.astFullModes[6].stVideoDisplayMode.ulSrcWidthClipAmount && stCfgVidDispModes.astFullModes[6].bEnabled) { pstDispMode->ulFull7 = 1; } /* Check for PBP case */ else if (((BVDB_PipType) ePipType == BVDB_PipType_ePbp) && stCfgVidDispModes.astPipModes[1].bEnabled) { pstDispMode->ulPip2 = 1; } else /* Check for FULL modes */ { for (k=0; k= ulDispMinH && ulDestHeight <= ulDispMaxH && ulDestWidth >= ulDispMinW && ulDestWidth <= ulDispMaxW && stCfgVidDispModes.astFullModes[k].bEnabled) { BDBG_MSG(("Primary display %d's FULL window for FULL.%d", pstDisplay->eType, k+1)); /* compare clip amounts and display source as */ ulModeSrcHeightClipAmount = stCfgVidDispModes.astFullModes[k].stVideoDisplayMode.ulSrcHeightClipAmount; ulModeSrcWidthClipAmount = stCfgVidDispModes.astFullModes[k].stVideoDisplayMode.ulSrcWidthClipAmount; BDBG_MSG(("ulModeSrcHeightClipAmount = %d", ulModeSrcHeightClipAmount)); BDBG_MSG(("ulHeightClipAmount = %d", ulHeightClipAmount)); BDBG_MSG(("ulModeSrcWidthClipAmount = %d", ulModeSrcWidthClipAmount)); BDBG_MSG(("ulWidthClipAmount = %d", ulWidthClipAmount)); if (ulHeightClipAmount <= ulModeSrcHeightClipAmount && ulWidthClipAmount <= ulModeSrcWidthClipAmount) { BVDB_VideoDisplayModeInfo stInfo = stCfgVidDispModes.astFullModes[k].stVideoDisplayMode; ulClipHeightDiff = ulModeSrcHeightClipAmount - ulHeightClipAmount; ulClipWidthDiff = ulModeSrcWidthClipAmount - ulWidthClipAmount; BDBG_MSG(("ulClipHeightDiff = %d", ulClipHeightDiff)); BDBG_MSG(("ulClipWidthDiff = %d", ulClipWidthDiff)); BDBG_MSG(("ulPrevClipHeightDiff = %d", ulPrevClipHeightDiff)); BDBG_MSG(("ulPrevClipWidthDiff = %d", ulPrevClipWidthDiff)); /* get closest clip amount match */ if (ulClipHeightDiff <= ulPrevClipHeightDiff && ulClipWidthDiff <= ulPrevClipWidthDiff) { bool bFoundMode = false; if (ulFrameAspectRatio >= BVDB_P_ASPECT_RATIO_16_9) { if (pstDisplay->eAspectRatio == BVDB_AspectRatio_e16_9) { if ((*pDisplayedAspectRatio == BFMT_AspectRatio_e16_9 || *pDisplayedAspectRatio == BFMT_AspectRatio_e4_3) && eDisplaySrcAs == stInfo.eDisplay16_9SrcOn16_9Display) { *((uint32_t *)pstDispMode) = (0x1 << k); bFoundMode = true; } } else if (pstDisplay->eAspectRatio == BVDB_AspectRatio_e4_3) { if ((*pDisplayedAspectRatio == BFMT_AspectRatio_e16_9 || *pDisplayedAspectRatio == BFMT_AspectRatio_e4_3) && eDisplaySrcAs == stInfo.eDisplay16_9SrcOn4_3Display) { *((uint32_t *)pstDispMode) = (0x1 << k); bFoundMode = true; } } } else if (ulFrameAspectRatio < BVDB_P_ASPECT_RATIO_16_9) { if (pstDisplay->eAspectRatio == BVDB_AspectRatio_e16_9) { if ((*pDisplayedAspectRatio == BFMT_AspectRatio_e16_9 || *pDisplayedAspectRatio == BFMT_AspectRatio_e4_3) && eDisplaySrcAs == stInfo.eDisplay4_3SrcOn16_9dDisplay) { *((uint32_t *)pstDispMode) = (0x1 << k); bFoundMode = true; } } else if (pstDisplay->eAspectRatio == BVDB_AspectRatio_e4_3) { if ((*pDisplayedAspectRatio == BFMT_AspectRatio_e16_9 || *pDisplayedAspectRatio == BFMT_AspectRatio_e4_3) && eDisplaySrcAs == stInfo.eDisplay4_3SrcOn4_3Display) { *((uint32_t *)pstDispMode) = (0x1 << k); bFoundMode = true; } } } if (bFoundMode) { ulPrevClipHeightDiff = ulClipHeightDiff; ulPrevClipWidthDiff = ulClipWidthDiff; } } } } } /* Check for PIG Modes */ if (*((uint32_t *)pstDispMode) == 0) { /* reset */ ulPrevClipHeightDiff = BVDB_P_MAX_SRC_CLIP_HEIGHT_AMOUNT; ulPrevClipWidthDiff = BVDB_P_MAX_SRC_CLIP_WIDTH_AMOUNT; for (k = BVDB_P_NUM_FULL_MODES; k < BVDB_P_NUM_FULL_MODES + BVDB_P_NUM_PIG_MODES; k++) { BDBG_MSG(("Primary display %d's PIG.%d window", pstDisplay->eType, (k+1)-BVDB_P_NUM_FULL_MODES)); ulModeSrcHeightClipAmount = stCfgVidDispModes.astPigModes[k-BVDB_P_NUM_FULL_MODES].stVideoDisplayMode.ulSrcHeightClipAmount; ulModeSrcWidthClipAmount = stCfgVidDispModes.astPigModes[k-BVDB_P_NUM_FULL_MODES].stVideoDisplayMode.ulSrcWidthClipAmount; BDBG_MSG(("ulModeSrcHeightClipAmount = %d", ulModeSrcHeightClipAmount)); BDBG_MSG(("ulHeightClipAmount = %d", ulHeightClipAmount)); BDBG_MSG(("ulModeSrcWidthClipAmount = %d", ulModeSrcWidthClipAmount)); BDBG_MSG(("ulWidthClipAmount = %d", ulWidthClipAmount)); if (ulHeightClipAmount <= ulModeSrcHeightClipAmount && ulWidthClipAmount <= ulModeSrcWidthClipAmount) { uint32_t ulTempMinH, ulTempMinW, ulTempMaxH, ulTempMaxW; BDBG_MSG(("ulClipHeightDiff = %d", ulClipHeightDiff)); BDBG_MSG(("ulClipWidthDiff = %d", ulClipWidthDiff)); BDBG_MSG(("ulPrevClipHeightDiff = %d", ulPrevClipHeightDiff)); BDBG_MSG(("ulPrevClipWidthDiff = %d", ulPrevClipWidthDiff)); ulTempMinH = (ulDisplayHeight * stCfgVidDispModes.astPigModes[k-BVDB_P_NUM_FULL_MODES].stVideoDisplayMode.ulMinWinHeight)/100; ulTempMinW = (ulDisplayWidth * stCfgVidDispModes.astPigModes[k-BVDB_P_NUM_FULL_MODES].stVideoDisplayMode.ulMinWinWidth)/100; ulTempMaxH = (ulDisplayHeight * stCfgVidDispModes.astPigModes[k-BVDB_P_NUM_FULL_MODES].stVideoDisplayMode.ulMaxWinHeight)/100; ulTempMaxW = (ulDisplayWidth * stCfgVidDispModes.astPigModes[k-BVDB_P_NUM_FULL_MODES].stVideoDisplayMode.ulMaxWinWidth)/100; BDBG_MSG(("ulTempMinH = %d", ulTempMinH)); BDBG_MSG(("ulTempMinW = %d", ulTempMinW)); BDBG_MSG(("ulTempMaxH = %d", ulTempMaxH)); BDBG_MSG(("ulTempMaxW = %d", ulTempMaxW)); if (ulDestHeight >= ulTempMinH && ulDestWidth >= ulTempMinW && ulDestHeight <= ulTempMaxH && ulDestWidth <= ulTempMaxW) { ulClipHeightDiff = ulModeSrcHeightClipAmount - ulHeightClipAmount; ulClipWidthDiff = ulModeSrcWidthClipAmount - ulWidthClipAmount; /* get closest clip amount match */ if (ulClipHeightDiff <= ulPrevClipHeightDiff && ulClipWidthDiff <= ulPrevClipWidthDiff && stCfgVidDispModes.astPigModes[k-BVDB_P_NUM_FULL_MODES].bEnabled) { ulPrevClipHeightDiff = ulClipHeightDiff; ulPrevClipWidthDiff = ulClipWidthDiff; *((uint32_t *)pstDispMode) = (0x1 << k); *pDisplayedAspectRatio = BFMT_AspectRatio_eUnknown; } } } } } } } else /* PIP */ { for (k = BVDB_P_NUM_FULL_MODES + BVDB_P_NUM_PIG_MODES; k < BVDB_P_NUM_FULL_MODES + BVDB_P_NUM_PIG_MODES + BVDB_P_NUM_PIP_MODES; k++) { BDBG_MSG(("Primary display %d's PIP.%d window", pstDisplay->eType, (k+1)-BVDB_P_NUM_FULL_MODES-BVDB_P_NUM_PIG_MODES)); /* compare clip amounts and if PIP2, destination size as well */ ulModeSrcHeightClipAmount = stCfgVidDispModes.astPipModes[k-(BVDB_P_NUM_FULL_MODES + BVDB_P_NUM_PIG_MODES)].stVideoDisplayMode.ulSrcHeightClipAmount; ulModeSrcWidthClipAmount = stCfgVidDispModes.astPipModes[k-(BVDB_P_NUM_FULL_MODES + BVDB_P_NUM_PIG_MODES)].stVideoDisplayMode.ulSrcWidthClipAmount; BDBG_MSG(("ulModeSrcHeightClipAmount = %d, ulModeSrcWidthClipAmount = %d", ulModeSrcHeightClipAmount, ulModeSrcWidthClipAmount)); BDBG_MSG(("ulHeightClipAmount = %d, ulWidthClipAmount = %d", ulHeightClipAmount, ulWidthClipAmount)); if (ulHeightClipAmount <= ulModeSrcHeightClipAmount && ulWidthClipAmount <= ulModeSrcWidthClipAmount) { ulClipHeightDiff = ulModeSrcHeightClipAmount - ulHeightClipAmount; ulClipWidthDiff = ulModeSrcWidthClipAmount - ulWidthClipAmount; /* get closest clip amount match */ if (ulClipHeightDiff < ulPrevClipHeightDiff && ulClipWidthDiff < ulPrevClipWidthDiff && stCfgVidDispModes.astPipModes[k-(BVDB_P_NUM_FULL_MODES + BVDB_P_NUM_PIG_MODES)].bEnabled) { ulPrevClipHeightDiff = ulClipHeightDiff; ulPrevClipWidthDiff = ulClipWidthDiff; *((uint32_t *)pstDispMode) = (0x1 << k); *pDisplayedAspectRatio = BFMT_AspectRatio_eUnknown; } } } } * pulDispMode |= * pul3dDispMode; } else /* Secondary display */ { for (k = BVDB_P_NUM_FULL_MODES + BVDB_P_NUM_PIG_MODES + BVDB_P_NUM_PIP_MODES; k < BVDB_P_NUM_FULL_MODES + BVDB_P_NUM_PIG_MODES + BVDB_P_NUM_PIP_MODES + BVDB_P_NUM_MON_MODES; k++) { BDBG_MSG(("Secondary display, MONITOR.%d window", (k+1)-(BVDB_P_NUM_FULL_MODES + BVDB_P_NUM_PIG_MODES + BVDB_P_NUM_PIP_MODES))); /* compare clip amounts */ ulModeSrcHeightClipAmount = stCfgVidDispModes.astMonitorModes[k-(BVDB_P_NUM_FULL_MODES + BVDB_P_NUM_PIG_MODES + BVDB_P_NUM_PIP_MODES)].stVideoDisplayMode.ulSrcHeightClipAmount; ulModeSrcWidthClipAmount = stCfgVidDispModes.astMonitorModes[k-(BVDB_P_NUM_FULL_MODES + BVDB_P_NUM_PIG_MODES + BVDB_P_NUM_PIP_MODES)].stVideoDisplayMode.ulSrcWidthClipAmount; if (ulHeightClipAmount <= ulModeSrcHeightClipAmount && ulWidthClipAmount <= ulModeSrcWidthClipAmount) { ulClipHeightDiff = ulModeSrcHeightClipAmount - ulHeightClipAmount; ulClipWidthDiff = ulModeSrcWidthClipAmount - ulWidthClipAmount; /* get closest clip amount match */ if (ulClipHeightDiff <= ulPrevClipHeightDiff && ulClipWidthDiff <= ulPrevClipWidthDiff && stCfgVidDispModes.astMonitorModes[k-(BVDB_P_NUM_FULL_MODES + BVDB_P_NUM_PIG_MODES + BVDB_P_NUM_PIP_MODES)].bEnabled) { bool bFoundMode = false; BVDB_VideoDisplayModeInfo stInfo = stCfgVidDispModes.astMonitorModes[k-(BVDB_P_NUM_FULL_MODES + BVDB_P_NUM_PIG_MODES + BVDB_P_NUM_PIP_MODES)].stVideoDisplayMode; if (*pDisplayedAspectRatio == BFMT_AspectRatio_e4_3 && eDisplaySrcAs == stInfo.eDisplay4_3SrcOn4_3Display) { if (eInput == BVDB_Input_eMfd) { pstDispMode->ulMon1 = 1; } else { *((uint32_t *)pstDispMode) |= (0x1 << k); } bFoundMode = true; } else if (*pDisplayedAspectRatio == BFMT_AspectRatio_e16_9 && eDisplaySrcAs == stInfo.eDisplay16_9SrcOn4_3Display) { if (eInput == BVDB_Input_eMfd) { pstDispMode->ulMon3 = 1; } else { *((uint32_t *)pstDispMode) |= (0x1 << k); } bFoundMode = true; } if (bFoundMode) { ulPrevClipHeightDiff = ulClipHeightDiff; ulPrevClipWidthDiff = ulClipWidthDiff; } } } } } BDBG_MSG(("\tVideo Display Mode = 0x%x", *((uint32_t *)pstDispMode))); if (BVDB_DISP_MODE_IS_FULL(pstDispMode) == 0 && BVDB_DISP_MODE_IS_PIG(pstDispMode) == 0 && BVDB_DISP_MODE_IS_PIP(pstDispMode) == 0 && BVDB_DISP_MODE_IS_MON(pstDispMode) == 0) { *pDisplayedAspectRatio = BFMT_AspectRatio_eUnknown; BDBG_ERR(("No video display mode found.")); err = BERR_INVALID_PARAMETER; } return BERR_TRACE(err); }