/*************************************************************************** * Copyright (c) 2003-2011, 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/9 $ * $brcm_Date: 7/21/11 8:19p $ * * Module Description: * * Revision History: * * $brcm_Log: /magnum/commonutils/vdb/35125/C0/bvdb.c $ * * Hydra_Software_Devel/9 7/21/11 8:19p yingh * SWDTV-6459: removed enforcing Capture to 422 format * * Hydra_Software_Devel/8 6/13/11 10:50a yingh * SWDTV-6977: Set GFX plane to 1920x1080 for config402 * * Hydra_Software_Devel/7 5/5/11 1:22p yingh * SWDTV-6549: Added config401 with RTS supported * * Hydra_Software_Devel/6 4/19/11 3:33p yingh * SWDTV-2538: Added config400 with RTS supported * * Hydra_Software_Devel/5 4/8/11 2:56p yingh * SW35125-102: Added PDP buffer allocation flag * * Hydra_Software_Devel/4 4/5/11 11:21a yingh * SW35125-102: Added config402 with RTS supported * * Hydra_Software_Devel/3 2/16/11 8:32p zhang * SW35125-73: Use 10-bit 422 pixel format for CAP / VFD to workaround * memory issues. * * Hydra_Software_Devel/2 11/17/10 3:33p jerrylim * SW35125-22: Removed all 35230 configs except config100 * * Hydra_Software_Devel/1 11/17/10 2:52p jerrylim * SW35125-22: Added 35125 VDB files * ***************************************************************************/ #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 "bchp_memc_arb_0.h" BDBG_MODULE(BVDB); #define BVDB_P_FRC_PIXEL_PADDING_PDP_WORKAROUND 1 /* Giving 100 max will make first comparison to get passed, so each display mode * will be free to pick up any clipping size in percentage */ #define BVDB_P_MAX_SRC_CLIP_HEIGHT_AMOUNT 100 /* percent */ #define BVDB_P_MAX_SRC_CLIP_WIDTH_AMOUNT 100 /* percent */ /* 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_SourceFormat stNonPcNonStandardFormats[] = { /* EIA/CEA-861-B (also 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}, }; static BVDB_P_SourceFormat stMfdFormats[] = { { 720, 576, false, 60000, false, BVDB_InputFormatGroup_ePal}, { 720, 576, true, 60000, false, BVDB_InputFormatGroup_e576p}, {1280, 720, true, 60000, false, BVDB_InputFormatGroup_e720p_60}, {1920, 1080, false, 60000, false, BVDB_InputFormatGroup_e1080i_60}, {1920, 1080, true, 30000, false, BVDB_InputFormatGroup_e1080p_30}, {1920, 1080, true, 60000, false, BVDB_InputFormatGroup_e1080p_60}, }; /* This is an interim solution to map an old source format to a new source * format */ static BVDB_P_MapToNewSourceGroup stMapToNewSourceGroup[] = { {BVDB_InputFormatGroup_eNtsc, false, BVDB_SourceGroup_Rp_e576i}, {BVDB_InputFormatGroup_ePal, false, BVDB_SourceGroup_Rp_e576i}, {BVDB_InputFormatGroup_e480p, false, BVDB_SourceGroup_Rp_e720p}, {BVDB_InputFormatGroup_e576p, false, BVDB_SourceGroup_Rp_e720p}, {BVDB_InputFormatGroup_e720p_50, false, BVDB_SourceGroup_Rp_e720p}, {BVDB_InputFormatGroup_e720p_60, false, BVDB_SourceGroup_Rp_e720p}, {BVDB_InputFormatGroup_e1080i_50, false, BVDB_SourceGroup_Rp_e1080i}, {BVDB_InputFormatGroup_e1080i_60, false, BVDB_SourceGroup_Rp_e1080i}, {BVDB_InputFormatGroup_e1080p_24, false, BVDB_SourceGroup_Rp_e1080psf}, {BVDB_InputFormatGroup_e1080p_25, false, BVDB_SourceGroup_Rp_e1080psf}, {BVDB_InputFormatGroup_e1080p_30, false, BVDB_SourceGroup_Rp_e1080psf}, {BVDB_InputFormatGroup_e1080p_50, false, BVDB_SourceGroup_Rp_e1080p}, {BVDB_InputFormatGroup_e1080p_60, false, BVDB_SourceGroup_Rp_e1080p}, {BVDB_InputFormatGroup_ePal_60, false, BVDB_SourceGroup_Rp_e576i}, {BVDB_InputFormatGroup_e720p_24, false, BVDB_SourceGroup_Rp_e720p}, {BVDB_InputFormatGroup_e720p_25, false, BVDB_SourceGroup_Rp_e720p}, {BVDB_InputFormatGroup_e720p_30, false, BVDB_SourceGroup_Rp_e720p}, {BVDB_InputFormatGroup_e544_576i_50, false, BVDB_SourceGroup_Rp_e576i}, {BVDB_InputFormatGroup_e1440_1080i_50, false, BVDB_SourceGroup_Rp_e1080i}, {BVDB_InputFormatGroup_e1440_1080p_25, false, BVDB_SourceGroup_Rp_e1080psf}, {BVDB_InputFormatGroup_e544_480i_60, false, BVDB_SourceGroup_Rp_e576i}, {BVDB_InputFormatGroup_e1440_1080i_60, false, BVDB_SourceGroup_Rp_e1080i}, {BVDB_InputFormatGroup_e1440_1080p_30, false, BVDB_SourceGroup_Rp_e1080psf}, {BVDB_InputFormatGroup_e1440_1080p_24, false, BVDB_SourceGroup_Rp_e1080psf}, {BVDB_InputFormatGroup_e1024_768_60_PC, false, BVDB_SourceGroup_ePc}, {BVDB_InputFormatGroup_e1024_768_85_PC, false, BVDB_SourceGroup_ePc}, {BVDB_InputFormatGroup_e1366_768_60_PC, false, BVDB_SourceGroup_ePc}, {BVDB_InputFormatGroup_e1366_768_85_PC, false, BVDB_SourceGroup_ePc}, {BVDB_InputFormatGroup_e1400_1050_60_PC, false, BVDB_SourceGroup_ePc}, {BVDB_InputFormatGroup_e1400_1050_75_PC, false, BVDB_SourceGroup_ePc}, {BVDB_InputFormatGroup_e1920_1080_60_PC, false, BVDB_SourceGroup_ePc}, {BVDB_InputFormatGroup_e1600_1200_60_PC, false, BVDB_SourceGroup_ePc}, {BVDB_InputFormatGroup_eAdcCalibration, false, BVDB_SourceGroup_eAdcCalibration}, {BVDB_InputFormatGroup_eJpeg_540, false, BVDB_SourceGroup_eJpeg}, {BVDB_InputFormatGroup_eJpeg_1080, false, BVDB_SourceGroup_eJpeg}, {BVDB_InputFormatGroup_e1080p3d_24, false, BVDB_SourceGroup_Rp_e1080p3d}, {BVDB_InputFormatGroup_e1080p3d_30, false, BVDB_SourceGroup_Rp_e1080p3d}, {BVDB_InputFormatGroup_e720p3d_60, false, BVDB_SourceGroup_Rp_e720p3d}, {BVDB_InputFormatGroup_e720p3d_50, false, BVDB_SourceGroup_Rp_e720p3d}, {BVDB_InputFormatGroup_eNtsc, true, BVDB_SourceGroup_Avc_e576i}, {BVDB_InputFormatGroup_ePal, true, BVDB_SourceGroup_Avc_e576i}, {BVDB_InputFormatGroup_e480p, true, BVDB_SourceGroup_Avc_e720p}, {BVDB_InputFormatGroup_e576p, true, BVDB_SourceGroup_Avc_e720p}, {BVDB_InputFormatGroup_e720p_50, true, BVDB_SourceGroup_Avc_e720p}, {BVDB_InputFormatGroup_e720p_60, true, BVDB_SourceGroup_Avc_e720p}, {BVDB_InputFormatGroup_e1080i_50, true, BVDB_SourceGroup_Avc_e1080i}, {BVDB_InputFormatGroup_e1080i_60, true, BVDB_SourceGroup_Avc_e1080i}, {BVDB_InputFormatGroup_e1080p_24, true, BVDB_SourceGroup_Avc_e1080psf}, {BVDB_InputFormatGroup_e1080p_25, true, BVDB_SourceGroup_Avc_e1080psf}, {BVDB_InputFormatGroup_e1080p_30, true, BVDB_SourceGroup_Avc_e1080psf}, {BVDB_InputFormatGroup_e1080p_50, true, BVDB_SourceGroup_Avc_e1080p}, {BVDB_InputFormatGroup_e1080p_60, true, BVDB_SourceGroup_Avc_e1080p}, {BVDB_InputFormatGroup_e1024_768_60_PC, true, BVDB_SourceGroup_Avc_e1080p}, {BVDB_InputFormatGroup_e1024_768_85_PC, true, BVDB_SourceGroup_Avc_e1080p}, {BVDB_InputFormatGroup_ePal_60, true, BVDB_SourceGroup_Avc_e576i}, {BVDB_InputFormatGroup_e720p_24, true, BVDB_SourceGroup_Avc_e720p}, {BVDB_InputFormatGroup_e720p_25, true, BVDB_SourceGroup_Avc_e720p}, {BVDB_InputFormatGroup_e720p_30, true, BVDB_SourceGroup_Avc_e720p}, {BVDB_InputFormatGroup_e544_576i_50, true, BVDB_SourceGroup_Avc_e576i}, {BVDB_InputFormatGroup_e1440_1080i_50, true, BVDB_SourceGroup_Avc_e1080i}, {BVDB_InputFormatGroup_e1440_1080p_25, true, BVDB_SourceGroup_Avc_e1080psf}, {BVDB_InputFormatGroup_e544_480i_60, true, BVDB_SourceGroup_Avc_e576i}, {BVDB_InputFormatGroup_e1440_1080i_60, true, BVDB_SourceGroup_Avc_e1080i}, {BVDB_InputFormatGroup_e1440_1080p_30, true, BVDB_SourceGroup_Avc_e1080psf}, {BVDB_InputFormatGroup_e1440_1080p_24, true, BVDB_SourceGroup_Avc_e1080psf}, {BVDB_InputFormatGroup_eJpeg_540, true, BVDB_SourceGroup_eJpeg}, {BVDB_InputFormatGroup_eJpeg_1080, true, BVDB_SourceGroup_eJpeg} }; static BVDB_P_TContext tvdb; /* Public Functions */ BERR_Code BVDB_CreateVdb ( BVDB_Handle *phVdb, uint32_t *pulEntries) { BERR_Code err = BERR_SUCCESS; BVDB_P_Context *pVdb; 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); } *phVdb = (BVDB_Handle) pVdb; *pulEntries = sizeof( BVDB_Handle ); tvdb.ulConfigId = 0; tvdb.main.clipHeight = 0; tvdb.main.clipWidth = 0; tvdb.main.winHeight = 100; tvdb.main.winWidth = 100; tvdb.sub.clipHeight = 0; tvdb.sub.clipWidth = 0; tvdb.sub.winHeight = 100; tvdb.sub.winWidth = 100; return BERR_TRACE( err ); } BERR_Code BVDB_DestroyVdb ( BVDB_Handle hVdb ) { BVDB_P_Context *pVdb; BVDB_P_GET_CONTEXT(hVdb, pVdb); BKNI_Free(pVdb); 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]; BDBG_ASSERT(pstUsageMode); /* ID */ BDBG_P_PrintString("\n* RTS Configuration %d, %s\n", tvdb.ulConfigId, tvdb.vdbVerString); if (pstUsageMode->eWindow == BVDB_Window_eMonitor) { BDBG_P_PrintString("\tCurrent VDB ID: Same as Main Window\n"); } else { BDBG_P_PrintString("\tCurrent VDB ID: %d\n", pstUsageMode->usageId); } /* 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); if (pstUsageMode->eWindow == BVDB_Window_eMonitor) { BDBG_P_PrintString("\tVideo Display Usage Mode: n/a\n"); } else { BDBG_P_PrintString("\tVideo Display Usage Mode: %s.%d\n", pstUsageMode->eDisplayMode == BVDB_DisplayMode_Any ? "any" : pstUsageMode->eDisplayMode == BVDB_DisplayMode_Full ? "full" : pstUsageMode->eDisplayMode == BVDB_DisplayMode_Pig ? "pig" : pstUsageMode->eDisplayMode == BVDB_DisplayMode_Mheg ? "mheg" : pstUsageMode->eDisplayMode == BVDB_DisplayMode_Pbp ? "pbp/pip" : "unknown", pstUsageMode->ulDisplayModeNum); } /* OSD size */ BVDB_P_GetOsdStr(pstUsageMode->stOsd.eOsd, acStr); BDBG_P_PrintString("\tOSD: %s (reserved %d)\n", acStr, 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->eDnr, acStr); BVDB_P_GetPixelFormatStr(pstUsageMode->stAnr.ePixelFormat, pstUsageMode->stAnr.eState, acStr1); BDBG_P_PrintString("\tDNR %s, ANR: %s (reserved %d)\n", acStr, acStr1, 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); /* 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_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 && !bJpeg) { uint32_t ulMfdHeight; uint32_t ulMfdWidth; uint32_t ulMfdFrameRate; uint32_t i; uint32_t numEntry; /* Limit max values to make sure all MFD formats fall under a * predefined source format group */ ulMfdHeight = BVDB_P_MIN(ulHeight, BFMT_1080I_HEIGHT); ulMfdWidth = BVDB_P_MIN(ulWidth, BFMT_1080I_WIDTH); ulMfdFrameRate = BVDB_P_MIN(ulFrameRate, 60000); numEntry = sizeof(stMfdFormats) / sizeof(BVDB_P_SourceFormat); for (i = 0; i < numEntry; i++) { if ((ulMfdHeight <= stMfdFormats[i].height) && (ulMfdWidth <= stMfdFormats[i].width) && ((bProgressive && stMfdFormats[i].bProgressive) || (!bProgressive && !stMfdFormats[i].bProgressive)) && (ulMfdFrameRate <= stMfdFormats[i].frameRate)) { *peInputFormatGroup = stMfdFormats[i].eInputFormatGroup; return BERR_TRACE(BERR_SUCCESS); } } return BERR_TRACE(BERR_INVALID_PARAMETER); } 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_SourceFormat); 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 whether 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; } else { *peInputFormatGroup = BVDB_InputFormatGroup_e1920_1080_60_PC; } } } } } if (*peInputFormatGroup == BVDB_InputFormatGroup_eInvalid) err = BERR_NOT_SUPPORTED; return BERR_TRACE(err); } BERR_Code BVDB_GetVdbEntry ( BVDB_Handle hVdb, BVDB_UsageMode *pstUsageMode, bool bPipVisible, bool bPanelReversed) { BERR_Code err = BERR_SUCCESS; BVDB_P_Context *pVdb; BVDB_SourceGroup mappedSource; BVDB_SourceGroup mainSourceToMatch; BVDB_SourceGroup subSourceToMatch; BVDB_P_RtsData tmpUsageMode; bool bMainDispModeMatch; bool bSubDispModeMatch; bool bSourceMapped = false; bool bDontCareMainWinClipSize; bool bDontCareSubWinClipSize; bool bDontCareMain; bool bDontCareSub; bool bMfdSource; bool bUsageModeMatchFound; uint32_t dispModeToMatch; uint32_t numEntry; BVDB_P_BvnTopology * pBvn; uint32_t i; uint32_t j; bool bDotByDot = false; BVDB_P_GET_CONTEXT(hVdb, pVdb); /* Now get the new source format from the mapping table */ bMfdSource = pstUsageMode->eInput == BVDB_Input_eMfd; numEntry = sizeof(stMapToNewSourceGroup) / sizeof(BVDB_P_MapToNewSourceGroup); for (i = 0; i < numEntry; i++) { if ((stMapToNewSourceGroup[i].oldFormat == pstUsageMode->eInputFormatGroup) && ((stMapToNewSourceGroup[i].bMfdSource && bMfdSource) || (!stMapToNewSourceGroup[i].bMfdSource && !bMfdSource))) { mappedSource = stMapToNewSourceGroup[i].newFormat; bSourceMapped = true; break; } } if (!bSourceMapped) { BDBG_ERR(("No new source format found!:")); BDBG_ERR(("MFD source = %s, Old Source Group = %d", bMfdSource, pstUsageMode->eInputFormatGroup)); return BERR_TRACE(BERR_INVALID_PARAMETER); } /* AVC 1080i is treated as 1080psf because from VDB point of view, there's * no way to differentiate them. So take the superset which is 1080psf */ if (mappedSource == BVDB_SourceGroup_Avc_e1080i) { BDBG_MSG(("AVC1080i is mapped to AVC1080psf")); mappedSource = BVDB_SourceGroup_Avc_e1080psf; } BDBG_MSG(("Mapped source = %d for %s window", mappedSource, pstUsageMode->eWindow == BVDB_Window_eMain ? "Main": pstUsageMode->eWindow == BVDB_Window_ePip ? "Pip" : "Monitor")); bUsageModeMatchFound = false; /* Just to avoid build warning messages */ tmpUsageMode = tvdb.pUsageMode[0]; if (pstUsageMode->eWindow == BVDB_Window_eMain || pstUsageMode->eWindow == BVDB_Window_ePip) { /* find main match - group, win, clipping * then find the sub or vcr match - group, wind clipping * use that RTS. The only exception is adcCalibration. If source is * adc then find rp | pc in pip or vcr */ BDBG_MSG(("Window %s: Prev Main Source = 0x%x, Prev Sub Source = 0x%x, PIP visible = %s\n", pstUsageMode->eWindow == BVDB_Window_eMain ? "main" : "pip", tvdb.curUsageMode.main.sourceGroup, tvdb.curUsageMode.sub.sourceGroup, bPipVisible ? "Yes" : "No")); /* If PIP is not supported or no source connected to sub path, do not check sub source */ if (pstUsageMode->eWindow == BVDB_Window_eMain) { bDontCareMain = false; bDontCareSub = !bPipVisible || !tvdb.bPipSupport || (tvdb.curUsageMode.sub.sourceGroup == BVDB_SourceGroup_None); /* Do not check clipping and window size for ADC and JPEG */ bDontCareMainWinClipSize = (mappedSource == BVDB_SourceGroup_eJpeg) || (mappedSource == BVDB_SourceGroup_eAdcCalibration) || tvdb.main.bAutomaticAspectRatioBoxMode; bDontCareSubWinClipSize = bDontCareSub || (tvdb.curUsageMode.sub.sourceGroup == BVDB_SourceGroup_eJpeg) || (tvdb.curUsageMode.sub.sourceGroup == BVDB_SourceGroup_eAdcCalibration) || tvdb.sub.bAutomaticAspectRatioBoxMode; mainSourceToMatch = mappedSource; subSourceToMatch = tvdb.curUsageMode.sub.sourceGroup; } else { if (!tvdb.bPipSupport) { BDBG_ERR(("PIP is not supported in this configuration")); return BERR_TRACE(BERR_INVALID_PARAMETER); } bDontCareMain = (tvdb.curUsageMode.main.sourceGroup == BVDB_SourceGroup_None); bDontCareSub = false; /* Do not check clipping and window size for ADC and JPEG */ bDontCareSubWinClipSize = bDontCareMain || (mappedSource == BVDB_SourceGroup_eJpeg) || (mappedSource == BVDB_SourceGroup_eAdcCalibration) || tvdb.sub.bAutomaticAspectRatioBoxMode; bDontCareMainWinClipSize = (tvdb.curUsageMode.main.sourceGroup == BVDB_SourceGroup_eJpeg) || (tvdb.curUsageMode.main.sourceGroup == BVDB_SourceGroup_eAdcCalibration) || tvdb.main.bAutomaticAspectRatioBoxMode; mainSourceToMatch = tvdb.curUsageMode.main.sourceGroup; subSourceToMatch = mappedSource; } BDBG_MSG(("Don't care main = %d, Don't care main win/clip size = %d", bDontCareMain, bDontCareMainWinClipSize)); BDBG_MSG(("Don't care sub = %d, Don't care sub win/clip size = %d", bDontCareSub, bDontCareSubWinClipSize)); /* If it's not both vertically and horizontally full, do not use full mode */ if (((tvdb.main.winHeight != 100 && tvdb.main.winWidth != 100) || ((tvdb.main.winHeight != 100 || tvdb.main.winWidth != 100) && tvdb.main.bAutomaticAspectRatioBoxMode)) && !tvdb.main.bDotByDot) { BDBG_MSG(("Pick one from non-full mode")); dispModeToMatch = ~BVDB_DisplayMode_Full; } else { dispModeToMatch = BVDB_DisplayMode_Any; } BDBG_ASSERT(tvdb.pUsageMode != NULL); for (j = 0; j < 2; j++) { for (i = 0; i < tvdb.usageModeNum; i++) { BDBG_MSG(("Checking ID = %d, Looking for matches for Main: 0x%x = 0x%x (dispMode), 0x%x = 0x%x (dispRes), 0x%x = 0x%x (main source), 0x%x = 0x%x (pip source)", tvdb.pUsageMode[i].id, tvdb.pUsageMode[i].eDisplayMode, dispModeToMatch, tvdb.pUsageMode[i].ulMainOutputResolution, pstUsageMode->stDisplay.eResolution, tvdb.pUsageMode[i].main.sourceGroup, mainSourceToMatch, tvdb.pUsageMode[i].sub.sourceGroup, subSourceToMatch)); if ((tvdb.pUsageMode[i].eDisplayMode & dispModeToMatch) && (tvdb.pUsageMode[i].ulMainOutputResolution & pstUsageMode->stDisplay.eResolution) && (bDontCareMain || (tvdb.pUsageMode[i].main.sourceGroup & mainSourceToMatch)) && (bDontCareSub || (tvdb.pUsageMode[i].sub.sourceGroup & subSourceToMatch))) { /* Now we have main and sub match. Then find the matching display * mode. */ bMainDispModeMatch = bDontCareMainWinClipSize || (bDotByDot && (tvdb.pUsageMode[i].eDisplayMode == BVDB_DisplayMode_Full)) || ((tvdb.main.winHeight + 1 >= (tvdb.pUsageMode[i].main.minWinHeight)) && (tvdb.main.winHeight <= (tvdb.pUsageMode[i].main.maxWinHeight + 1)) && (tvdb.main.winWidth + 1 >= (tvdb.pUsageMode[i].main.minWinWidth)) && (tvdb.main.winWidth <= (tvdb.pUsageMode[i].main.maxWinWidth + 1)) && (tvdb.main.clipHeight <= (tvdb.pUsageMode[i].main.maxClippingHeight + 1)) && (tvdb.main.clipWidth <= (tvdb.pUsageMode[i].main.maxClippingWidth + 1))); bSubDispModeMatch = bDontCareSubWinClipSize || ((tvdb.sub.winHeight + 1 >= (tvdb.pUsageMode[i].sub.minWinHeight)) && (tvdb.sub.winHeight <= (tvdb.pUsageMode[i].sub.maxWinHeight + 1)) && (tvdb.sub.winWidth + 1 >= (tvdb.pUsageMode[i].sub.minWinWidth)) && (tvdb.sub.winWidth <= (tvdb.pUsageMode[i].sub.maxWinWidth + 1)) && (tvdb.sub.clipHeight <= (tvdb.pUsageMode[i].sub.maxClippingHeight + 1)) && (tvdb.sub.clipWidth <= (tvdb.pUsageMode[i].sub.maxClippingWidth + 1))); BDBG_MSG(("ID (%d) for Main (DontCareMain = %d): Looking for \"%d >= %d, %d <= %d, %d >= %d, %d <= %d, %d <= %d, %d <=%d\"", tvdb.pUsageMode[i].id, bDontCareMainWinClipSize, tvdb.main.winHeight , tvdb.pUsageMode[i].main.minWinHeight - 1, tvdb.main.winHeight , tvdb.pUsageMode[i].main.maxWinHeight + 1, tvdb.main.winWidth , tvdb.pUsageMode[i].main.minWinWidth - 1, tvdb.main.winWidth , tvdb.pUsageMode[i].main.maxWinWidth + 1, tvdb.main.clipHeight, tvdb.pUsageMode[i].main.maxClippingHeight + 1, tvdb.main.clipWidth , tvdb.pUsageMode[i].main.maxClippingWidth + 1)); BDBG_MSG(("ID (%d) for Sub (DontCareSub = %d): Looking for \"%d >= %d, %d <= %d, %d >= %d, %d <= %d, %d <= %d, %d <=%d\"", tvdb.pUsageMode[i].id, bDontCareSubWinClipSize, tvdb.sub.winHeight , tvdb.pUsageMode[i].sub.minWinHeight - 1, tvdb.sub.winHeight , tvdb.pUsageMode[i].sub.maxWinHeight + 1, tvdb.sub.winWidth , tvdb.pUsageMode[i].sub.minWinWidth - 1, tvdb.sub.winWidth , tvdb.pUsageMode[i].sub.maxWinWidth + 1, tvdb.sub.clipHeight, tvdb.pUsageMode[i].sub.maxClippingHeight + 1, tvdb.sub.clipWidth , tvdb.pUsageMode[i].sub.maxClippingWidth + 1)); BDBG_MSG(("Main disp match = %d, Sub disp match =%d", bMainDispModeMatch, bSubDispModeMatch)); if (bMainDispModeMatch && bSubDispModeMatch) { /* If it's a first time match, or we have a previous match, but the new * match has a higher priority, then update the match */ if (!bUsageModeMatchFound || (bUsageModeMatchFound && (tmpUsageMode.priority > tvdb.pUsageMode[i].priority))) { /* Copy usage mode, but update source group with real ones */ tmpUsageMode = tvdb.pUsageMode[i]; BDBG_MSG(("ID \"%d\" is picked", tvdb.pUsageMode[i].id)); if (pstUsageMode->eWindow == BVDB_Window_eMain) { /* update main source */ tmpUsageMode.main.sourceGroup = mappedSource; /* and update sub source */ if (bDontCareSub) { tmpUsageMode.sub.sourceGroup = BVDB_SourceGroup_None; } else { tmpUsageMode.sub.sourceGroup = tvdb.curUsageMode.sub.sourceGroup; } } else { /* update sub source */ tmpUsageMode.sub.sourceGroup = mappedSource; if (bDontCareMain) { tmpUsageMode.main.sourceGroup = BVDB_SourceGroup_None; } else { tmpUsageMode.main.sourceGroup = tvdb.curUsageMode.main.sourceGroup; } } bUsageModeMatchFound = true; } } } } /* If a match found, immediately exit, and if dot by dot mode and a * match not found, try to use full mode because full is designed to * support dot by dot for another loop. Otherwise we fail to find a * match */ if (bUsageModeMatchFound) break; else if (tvdb.main.bDotByDot) bDotByDot = true; else break; } } else /* Monitor */ { /* Just find sub group match */ for (i = 0; i < tvdb.usageModeNum; i++) { BDBG_MSG(("Looking for matches for Sub: 0x%x = 0x%x (source)", tvdb.pUsageMode[i].sub.sourceGroup , mappedSource)); if (tvdb.pUsageMode[i].sub.sourceGroup & mappedSource) { bUsageModeMatchFound = true; tmpUsageMode = tvdb.pUsageMode[i]; /* Use RTS which belongs to main */ if (tvdb.curUsageMode.pRtsRegisterTable != NULL) { tmpUsageMode.pRtsRegisterTable = tvdb.curUsageMode.pRtsRegisterTable; } break; } } } if (!bUsageModeMatchFound) { BDBG_ERR(("VDB Can't find a match. Video will be muted")); return BERR_TRACE(BERR_INVALID_PARAMETER); } /* There's a matching usage mode. Now fill up the Usage Mode */ BDBG_MSG(("Matching VDB ID: %d", tmpUsageMode.id)); pstUsageMode->eDisplayMode = tmpUsageMode.eDisplayMode; pstUsageMode->ulDisplayModeNum = tmpUsageMode.ulDisplayModeNum; pstUsageMode->usageId = tmpUsageMode.id; if (pstUsageMode->eWindow == BVDB_Window_eMain) { pBvn = &tmpUsageMode.main; } else { pBvn = &tmpUsageMode.sub; } /* Fill in Usage Mode Structure so Nexus can populate relative parameters * to magnum */ /* Each RTS configuration has a different OSD size to support and it * should be from each configuration context */ pstUsageMode->stOsd.ulReserved = 0; if (pstUsageMode->eWindow == BVDB_Window_ePip || pstUsageMode->eWindow == BVDB_Window_eInvalid) { /* PIP has no OSD, and main OSD will cover it */ pstUsageMode->stOsd.eOsd = BVDB_Osd_eInvalid; } else if (pstUsageMode->eWindow == BVDB_Window_eMonitor) { pstUsageMode->stOsd.eOsd = tvdb.eVcrOsdResolution; } else { pstUsageMode->stOsd.eOsd = tvdb.eMainOsdResolution; } /* e3dComb for composite signal and eOverampling for main path only */ if (pstUsageMode->eInput == BVDB_Input_eCvbsSvidIfd) { pstUsageMode->e3dComb = pBvn->b3dcomb; if (pstUsageMode->eWindow == BVDB_Window_eMain) { pstUsageMode->eOversample = true; } else { pstUsageMode->eOversample = false; } } else { pstUsageMode->e3dComb = false; pstUsageMode->eOversample = false; } /* Set DNR based on the usage mode */ pstUsageMode->eDnr = pBvn->bdnr; /* ANR */ pstUsageMode->stAnr.eState = pBvn->banr; if (pBvn->banr) { pstUsageMode->stAnr.ePixelFormat = BVDB_PixelFmt_e10Bit422; pstUsageMode->stAnr.ulReserved = pBvn->mc; } else { pstUsageMode->stAnr.ePixelFormat = BVDB_PixelFmt_eInvalid; pstUsageMode->stAnr.ulReserved = 0; } /* CAP/VFD */ pstUsageMode->stCapVfd.eState = pBvn->bcap; if (pBvn->bcap) { pstUsageMode->stCapVfd.ulReserved = pBvn->c; if (bPanelReversed && !tvdb.bPanelReversalSupport) { BDBG_ERR(("Panel reversal is not supported in this configuration")); return BERR_TRACE(BERR_INVALID_PARAMETER); } if (!bPanelReversed && (pBvn->c > tvdb.panelReversalCompensation)) { pstUsageMode->stCapVfd.ulReserved -= tvdb.panelReversalCompensation; BDBG_MSG(("Panel Reversal Compensation: %d -> %d", pBvn->c, pstUsageMode->stCapVfd.ulReserved)); } if (pstUsageMode->eWindow == BVDB_Window_ePip || pstUsageMode->eWindow == BVDB_Window_eMonitor) { pstUsageMode->stCapVfd.ePixelFormat = BVDB_PixelFmt_e8Bit422; } else { if ((pstUsageMode->eInput == BVDB_Input_eHdDvi && mappedSource == BVDB_SourceGroup_ePc) || pstUsageMode->eInput == BVDB_Input_eVga) { pstUsageMode->stCapVfd.ePixelFormat = BVDB_PixelFmt_e10Bit444; } else { pstUsageMode->stCapVfd.ePixelFormat = BVDB_PixelFmt_e10Bit422; } } } else { pstUsageMode->stCapVfd.ePixelFormat = BVDB_PixelFmt_eInvalid; pstUsageMode->stCapVfd.ulReserved = 0; } /* MAD - it actually refers to MCVP in 35230 */ pstUsageMode->stMad.eState = pBvn->bmad || pBvn->banr; if (pstUsageMode->stMad.eState) { pstUsageMode->stMad.eFieldStore = BVDB_FieldStore_e5Fields; pstUsageMode->stMad.ePixelFormat = BVDB_PixelFmt_e10Bit422; pstUsageMode->stMad.ulReserved = pBvn->mc; } else { pstUsageMode->stMad.eFieldStore = BVDB_FieldStore_eNotApplicable; pstUsageMode->stMad.ePixelFormat = BVDB_PixelFmt_eInvalid; pstUsageMode->stMad.ulReserved = 0; } /* PDP */ pstUsageMode->stPdp.eState = BVDB_State_eYes; pstUsageMode->stPdp.ulReserved = pBvn->dc; /* FRC */ pstUsageMode->stFrc.eState = pBvn->bfrc; pstUsageMode->stFrc.ulReserved = pBvn->frcc; /* CAP-SCL bias and orientation */ pstUsageMode->ulSclCapTolerance = pBvn->bias; pstUsageMode->eSclCapBias = pBvn->eSclCap; /* We are updating the current usage mode only when the path is main or * pip because monitor will depend on the main source anyway */ if (pstUsageMode->eWindow == BVDB_Window_eMonitor) { pstUsageMode->pRtsSet = NULL; } else { pstUsageMode->pRtsSet = tmpUsageMode.pRtsRegisterTable; tvdb.curUsageMode = tmpUsageMode; } /* End of filling in "Usage Mode" */ return BERR_TRACE(err); } /* Configuration ID is passed from upper layer */ BERR_Code BVDB_ValidateConfigId ( BVDB_Handle hVdb, const uint32_t ulConfigId ) { BERR_Code err = BERR_SUCCESS; BVDB_P_Context *pVdb; char * pVerString; BVDB_P_GET_CONTEXT(hVdb, pVdb); if (ulConfigId == 100 || ulConfigId == 400 || ulConfigId == 401 || ulConfigId == 402) { tvdb.ulConfigId = ulConfigId; err = BVDB_P_GetRtsData(ulConfigId, &tvdb.pUsageMode, &tvdb.usageModeNum); if (err != BERR_SUCCESS) { BDBG_ERR(("Can't find RTS configuration %d", ulConfigId)); return BERR_TRACE(err); } /* TODO: To be moved to config context */ switch (ulConfigId) { default: case 100: pVerString = BVDB_USAGE_MODE_VER_STRING_CFG100; tvdb.eMainOsdResolution = BVDB_Osd_e1920_2205p_32bpp; tvdb.eVcrOsdResolution = BVDB_Osd_e576i_8bpp; tvdb.panelReversalCompensation = 0; tvdb.bPipSupport = true; tvdb.bMonitorSupport = true; tvdb.bFrcSupport = false; tvdb.bRtcSupport = true; tvdb.bPanelReversalSupport = true; tvdb.bBacklightSupport = true; tvdb.worstPdpBpp = 20; tvdb.maxPipWinHeight = 100; tvdb.maxPipWinWidth = 100; break; case 400: pVerString = BVDB_USAGE_MODE_VER_STRING_CFG400; tvdb.eMainOsdResolution = BVDB_Osd_e960_540p_32bpp; tvdb.eVcrOsdResolution = BVDB_Osd_eNone; tvdb.panelReversalCompensation = 0; tvdb.bPipSupport = false; tvdb.bMonitorSupport = false; tvdb.bFrcSupport = false; tvdb.bRtcSupport = false; tvdb.bPanelReversalSupport = false; tvdb.bBacklightSupport = true; tvdb.worstPdpBpp = 0; tvdb.maxPipWinHeight = 0; tvdb.maxPipWinWidth = 0; break; case 401: pVerString = BVDB_USAGE_MODE_VER_STRING_CFG401; tvdb.eMainOsdResolution = BVDB_Osd_e960_540p_32bpp; tvdb.eVcrOsdResolution = BVDB_Osd_eNone; tvdb.panelReversalCompensation = 0; tvdb.bPipSupport = false; tvdb.bMonitorSupport = false; tvdb.bFrcSupport = false; tvdb.bRtcSupport = true; tvdb.bPanelReversalSupport = true; tvdb.bBacklightSupport = true; tvdb.worstPdpBpp = 0; tvdb.maxPipWinHeight = 0; tvdb.maxPipWinWidth = 0; break; case 402: pVerString = BVDB_USAGE_MODE_VER_STRING_CFG402; tvdb.eMainOsdResolution = BVDB_Osd_e1920_1080p_32bpp; tvdb.eVcrOsdResolution = BVDB_Osd_eNone; tvdb.panelReversalCompensation = 0; tvdb.bPipSupport = false; tvdb.bMonitorSupport = true; tvdb.bFrcSupport = false; tvdb.bRtcSupport = false; tvdb.bPanelReversalSupport = false; tvdb.bBacklightSupport = false; tvdb.worstPdpBpp = 30; tvdb.maxPipWinHeight = 0; tvdb.maxPipWinWidth = 0; break; } BDBG_ASSERT(strlen(pVerString) <= BVDB_MAX_VER_STRING); strcpy(tvdb.vdbVerString, pVerString); return BERR_SUCCESS; } else { return BERR_TRACE(BERR_INVALID_PARAMETER); } } BERR_Code BVDB_GetFeatures ( BVDB_Handle hVdb, BVDB_Config_Features *pConfigFeatures) { BVDB_P_Context *pVdb; BVDB_P_GET_CONTEXT(hVdb, pVdb); if (tvdb.ulConfigId == 0) { BDBG_ERR(("RTS configuration is not set\n")); return BERR_TRACE(BERR_INVALID_PARAMETER); } BDBG_ASSERT(pConfigFeatures); pConfigFeatures->bPipSupport = tvdb.bPipSupport; pConfigFeatures->bMonitorSupport = tvdb.bMonitorSupport; pConfigFeatures->bFrcSupport = tvdb.bFrcSupport; pConfigFeatures->bRtcSupport = tvdb.bRtcSupport; pConfigFeatures->bPanelReversalSupport = tvdb.bPanelReversalSupport; pConfigFeatures->bPdpBufAllocat = (tvdb.bBacklightSupport) || (tvdb.bRtcSupport); pConfigFeatures->worstPdpBpp = tvdb.worstPdpBpp; pConfigFeatures->maxPipWinHeight = tvdb.maxPipWinHeight; pConfigFeatures->maxPipWinWidth = tvdb.maxPipWinWidth; return BERR_SUCCESS; } 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 clip amount percentage */ ulHeightClipAmount = (ulSrcHeightClipAmount * 100)/ulSrcHeight; ulWidthClipAmount = (ulSrcWidthClipAmount * 100)/ulSrcWidth; if (eWindow == BVDB_Window_eMain) { tvdb.main.bDotByDot = (ulSrcHeight == ulDestHeight) && (ulSrcWidth == ulDestWidth); tvdb.main.clipHeight = BVDB_P_MIN(ulHeightClipAmount, 100); tvdb.main.clipWidth = BVDB_P_MIN(ulWidthClipAmount, 100); tvdb.main.winHeight = BVDB_P_MIN((ulDestHeight * 100) / ulDisplayHeight, 100); tvdb.main.winWidth = BVDB_P_MIN((ulDestWidth * 100) / ulDisplayWidth, 100); tvdb.main.bAutomaticAspectRatioBoxMode = bAutomaticAspectRatioBoxMode; } else { tvdb.sub.bDotByDot = (ulSrcHeight == ulDestHeight) && (ulSrcWidth == ulDestWidth); tvdb.sub.clipHeight = BVDB_P_MIN(ulHeightClipAmount, 100); tvdb.sub.clipWidth = BVDB_P_MIN(ulWidthClipAmount, 100); tvdb.sub.winHeight = BVDB_P_MIN((ulDestHeight * 100) / ulDisplayHeight, 100); tvdb.sub.winWidth = BVDB_P_MIN((ulDestWidth * 100) / ulDisplayWidth, 100); tvdb.sub.bAutomaticAspectRatioBoxMode = bAutomaticAspectRatioBoxMode; } BDBG_MSG(("%s Window Info: source size (%d, %d), clip size (%d, %d), win size (%d, %d), with Box mode %s, Dot-by-Dot %s", eWindow == BVDB_Window_eMain ? "main" : eWindow == BVDB_Window_ePip ? "pip" : "monitor", ulSrcWidth, ulSrcHeight, ulSrcWidthClipAmount, ulSrcHeightClipAmount, ulDestWidth, ulDestHeight, bAutomaticAspectRatioBoxMode ? "On" : "Off", tvdb.main.bDotByDot ? "On" : "Off")); return BERR_TRACE(err); }