/*************************************************************************** * 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/11 $ * $brcm_Date: 9/9/11 3:47p $ * * Module Description: * * Revision History: * * $brcm_Log: /magnum/commonutils/vdb/35233/A0/bvdb.c $ * * Hydra_Software_Devel/11 9/9/11 3:47p jerrylim * SWDTV-8623: Enabled RR * * Hydra_Software_Devel/10 9/7/11 7:57p yingh * SWDTV-8499: Increased the supported height of source resolution from * 1080 to 1088 for MFD * * Hydra_Software_Devel/9 9/7/11 4:58p jerrylim * SWDTV-8574: Display a warning message if an obsolete or a test-purpose * RTS configuration is used * * Hydra_Software_Devel/8 7/20/11 1:44p jerrylim * SWDTV-7684: Selectively choose VDC buffer heap based on 3D display * * Hydra_Software_Devel/7 7/4/11 5:44p jerrylim * SWDTV-7267: Added the secondary display for VDB match * * Hydra_Software_Devel/6 6/23/11 12:06p jerrylim * SWDTV-7568: removed setting grpahics size to 0 for PIP because it'll * share graphics with main * * Hydra_Software_Devel/5 6/22/11 11:07p jerrylim * SWDTV-7593, SWDTV-7587: Force CAP-SCL for RP1080p and Corrected * blockout for FRC clients to support 3D * * Hydra_Software_Devel/4 6/15/11 1:30p jerrylim * SWDTV-7385, SWDTV-6738: Added 3D support to config23301 * * Hydra_Software_Devel/3 6/3/11 3:23p jerrylim * SWDTV-7358, SWDTV-7300, SWDTV-7132, SWDTV-5753: Restructured VDB for * 35233 * * Hydra_Software_Devel/2 5/10/11 6:59p jerrylim * SWDTV-6973: Updated PDP worst case based on the worst case of the usage * modes * * Hydra_Software_Devel/1 3/17/11 7:22p jerrylim * SWDTV-5980: Added 35233 VDB * ***************************************************************************/ #include "bstd.h" #include "berr.h" #include "bkni.h" #include "bfmt.h" #include "bdbg.h" #include "bvdb.h" #include "bvdb_priv.h" #include "bchp_memc_arb_0.h" BDBG_MODULE(BVDB); #define BVDB_P_ENABLE_MEM_CLIENT_RR 1 /* A big number so SCL-CAP orientation can be forced. This will be made obsolete */ #define BVDB_P_BIG_THRESHOLD 100000 /* 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 */ /* This is a list of PC formats that are detected as PC, meaning that a source * with one of the following formats is allowed to have 444 processing. However, * application can force the processing either to 422 or 444 */ static BVDB_P_SourceResolution astPcFormats[] = { {160, 120}, {240, 160}, {320, 200}, {320, 240}, {432, 240}, {480, 320}, {640, 350}, {640, 400}, {640, 480}, {720, 400}, {800, 480}, {800, 600}, {848, 480}, {832, 624}, {854, 480}, {1024, 576}, {1024, 600}, {1024, 768}, {1152, 768}, {1152, 864}, {1280, 768}, {1280, 800}, {1280, 854}, {1280, 960}, {1280, 1024}, {1340, 725}, {1360, 765}, {1360, 768}, {1366, 768}, {1400, 1050}, {1440, 900}, {1600, 900}, {1600, 1200}, {1680, 1050}, {1680, 1050}, /* by default 1920x1080 from HDMI will be handled as non-PC (i.e., 422). * However application is given an option to force it. Refer to * BVDB_PixelMode */ #if BVDB_P_HANDLE_FHD_AS_PC {1920, 1080}, #endif {1920, 1200}, {0, 0} /* mark end of table */ }; /* Source format to source group conversion table. PC source is coverted in a * different table above - astPcFormats[] */ static BVDB_P_SourceFormat astSourceFormats[] = { /* input type w h scan(p) fr 3d source group */ {BVDB_Input_eMfd, 720, 576, false, 60000, false, BVDB_SourceGroup_Avc_e576i2d}, {BVDB_Input_eMfd, 1280, 720, true, 60000, false, BVDB_SourceGroup_Avc_e720p2d}, {BVDB_Input_eMfd, 1920, 1088, false, 60000, false, BVDB_SourceGroup_Avc_e1080i2d}, {BVDB_Input_eMfd, 1920, 1088, true, 30000, false, BVDB_SourceGroup_Avc_e1080psf2d}, {BVDB_Input_eMfd, 1920, 1088, true, 60000, false, BVDB_SourceGroup_Avc_e1080p2d}, /* if BVDB_P_EXPAND_3D_SOURCES is true, 3D sources will have finer splits */ #if BVDB_P_EXPAND_3D_SOURCES {BVDB_Input_eMfd, 720, 576, false, 60000, true, BVDB_SourceGroup_Avc_e576i3d}, {BVDB_Input_eMfd, 1280, 720, true, 60000, true, BVDB_SourceGroup_Avc_e720p3d}, {BVDB_Input_eMfd, 1920, 1088, false, 60000, true, BVDB_SourceGroup_Avc_e1080i3d}, {BVDB_Input_eMfd, 1920, 1088, true, 30000, true, BVDB_SourceGroup_Avc_e1080psf3d}, {BVDB_Input_eMfd, 1920, 1088, true, 60000, true, BVDB_SourceGroup_Avc_e1080p3d}, #else {BVDB_Input_eMfd, BIG_NUM, BIG_NUM, false, BIG_NUM, true, BVDB_SourceGroup_Avc_e3d}, {BVDB_Input_eMfd, BIG_NUM, BIG_NUM, true, BIG_NUM, true, BVDB_SourceGroup_Avc_e3d}, #endif {BVDB_Input_Rp, 720, 576, false, 60000, false, BVDB_SourceGroup_Rp_e576i2d}, {BVDB_Input_Rp, 1280, 720, true, 60000, false, BVDB_SourceGroup_Rp_e720p2d}, {BVDB_Input_Rp, 1920, 1080, false, 60000, false, BVDB_SourceGroup_Rp_e1080i2d}, {BVDB_Input_Rp, 1920, 1080, true, 30000, false, BVDB_SourceGroup_Rp_e1080psf2d}, {BVDB_Input_Rp, 1920, 1080, true, 60000, false, BVDB_SourceGroup_Rp_e1080p2d}, #if BVDB_P_EXPAND_3D_SOURCES {BVDB_Input_Rp, 720, 576, false, 60000, true, BVDB_SourceGroup_Rp_e576i3d}, {BVDB_Input_Rp, 1280, 720, true, 60000, true, BVDB_SourceGroup_Rp_e720p3d}, {BVDB_Input_Rp, 1920, 1080, false, 60000, true, BVDB_SourceGroup_Rp_e1080i3d}, {BVDB_Input_Rp, 1920, 1080, true, 30000, true, BVDB_SourceGroup_Rp_e1080psf3d}, {BVDB_Input_Rp, 1920, 1080, true, 60000, true, BVDB_SourceGroup_Rp_e1080p3d}, #else {BVDB_Input_Rp, BIG_NUM, BIG_NUM, false, BIG_NUM, true, BVDB_SourceGroup_Rp_e3d}, {BVDB_Input_Rp, BIG_NUM, BIG_NUM, true, BIG_NUM, true, BVDB_SourceGroup_Rp_e3d}, #endif /* Any source which doesn't fall under known groups will use worst */ {BVDB_Input_All, BIG_NUM, BIG_NUM, false, BIG_NUM, true, BVDB_SourceGroup_eWorst}, {BVDB_Input_All, BIG_NUM, BIG_NUM, true, BIG_NUM, true, BVDB_SourceGroup_eWorst}, {BVDB_Input_All, BIG_NUM, BIG_NUM, false, BIG_NUM, false, BVDB_SourceGroup_eWorst}, {BVDB_Input_All, BIG_NUM, BIG_NUM, true, BIG_NUM, false, BVDB_SourceGroup_eWorst}, }; /******************************************************************************* * * BVDB_CreateVdb - creates VDB context and initialize them. This function must * be called first before using any of VDB public functions * * Input: phVdb - VDB hanle to return * Output: N/A * Return: BERR_Code */ BERR_Code BVDB_CreateVdb (BVDB_Handle *phVdb) { BERR_Code err = BERR_SUCCESS; BVDB_P_Context *pVdb; /* Allocate VDB Context */ pVdb = (BVDB_P_Context *) BKNI_Malloc(sizeof(BVDB_P_Context)); if (NULL == pVdb) { BDBG_ERR(("Out of memory")); return BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY); } *phVdb = (BVDB_Handle) pVdb; BKNI_Memset(pVdb, 0, sizeof(BVDB_P_Context)); /* Initialize VDB context */ pVdb->curUsageMode.main.sourceGroup = BVDB_SourceGroup_None; pVdb->curUsageMode.sec.sourceGroup = BVDB_SourceGroup_None; pVdb->main.winHeight = 100; pVdb->main.winWidth = 100; pVdb->sec.winHeight = 100; pVdb->sec.winWidth = 100; BDBG_MSG(("VDB Created")); return BERR_TRACE(err); } /******************************************************************************* * BVDB_DestroyVdb - free memory previously allocated for VDB context * * Input: hVdb - VDB handle * Output: N/A * Return: BERR_Code */ BERR_Code BVDB_DestroyVdb (BVDB_Handle hVdb) { BVDB_P_Context *pVdb; pVdb = (BVDB_P_Context *) hVdb; if (NULL == pVdb) { BDBG_ERR(("NULL pointer")); return BERR_TRACE(BERR_INVALID_PARAMETER); } BKNI_Free(pVdb); BDBG_MSG(("VDB Destroyed")); return BERR_TRACE(BERR_SUCCESS); } #if BDBG_DEBUG_BUILD /******************************************************************************* * BVDB_PrintUsageMode - is a debugging function which is built with DEBUG build * option. It prints usage mode information which is currently being used. * * Input: hVdb - VDB handle * pstUsageMode - a pointer poiting to the current usage mode * Output: N/A * Return: BERR_Code */ BERR_Code BVDB_PrintUsageMode (BVDB_Handle hVdb, const BVDB_UsageMode *pstUsageMode ) { BERR_Code err = BERR_SUCCESS; BVDB_P_Context *pVdb; if (NULL == pstUsageMode) { BDBG_ERR(("NULL usage mode pointer")); return BERR_TRACE(BERR_INVALID_PARAMETER); } pVdb = (BVDB_P_Context *) hVdb; if (NULL == pVdb) { BDBG_ERR(("NULL VDB Context pointer")); return BERR_TRACE(BERR_INVALID_PARAMETER); } /* ID */ BDBG_ASSERT(NULL != pVdb->pRtsConfig); BDBG_P_PrintString("\n* RTS Configuration %d, ver %d.%1d\n", pVdb->pRtsConfig->ulConfigId, pVdb->pRtsConfig->ulVdbVer / 10, pVdb->pRtsConfig->ulVdbVer % 10); BDBG_P_PrintString("\tCurrent VDB ID: %d\n", pstUsageMode->usageId); /* Input format */ BDBG_P_PrintString("\tInput type: %s, ", pstUsageMode->eInput == BVDB_Input_eCvbsSvidIfd ? "CVBS/SVID/IFD" : pstUsageMode->eInput == BVDB_Input_eComponent ? "Component" : pstUsageMode->eInput == BVDB_Input_eHdmi ? "HDMI" : pstUsageMode->eInput == BVDB_Input_eMfd ? "MFD" : pstUsageMode->eInput == BVDB_Input_eVga ? "VGA" : pstUsageMode->eInput == BVDB_Input_e656 ? "656" : "Invalid"); BDBG_P_PrintString("Format: %s\n", pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e576i2d ? "Avc_e576i2d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e720p2d ? "Avc_e720p2d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e1080i2d ? "Avc_e1080i2d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e1080psf2d ? "Avc_e1080psf2d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e1080p2d ? "Avc_e1080p2d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e576i2d ? "Rp_e576i2d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e720p2d ? "Rp_e720p2d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e1080i2d ? "Rp_e1080i2d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e1080psf2d ? "Rp_e1080psf2d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e1080p2d ? "Rp_e1080p2d" : #if BVDB_P_EXPAND_3D_SOURCES pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e576i3d ? "Avc_e576i3d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e720p3d ? "Avc_e720p3d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e1080i3d ? "Avc_e1080i3d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e1080psf3d ? "Avc_e1080psf3d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e1080p3d ? "Avc_e1080p3d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e576i3d ? "Rp_e576i3d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e720p3d ? "Rp_e720p3d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e1080i3d ? "Rp_e1080i3d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e1080psf3d ? "Rp_e1080psf3d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e1080p3d ? "Rp_e1080p3d" : #else pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e3d ? "Avc_e3d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e3d ? "Rp_e3d" : #endif pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_ePc2d ? "ePc2d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_eJpeg2d ? "eJpeg2d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_eAdcCalibration2d ? "eAdcCalibration2d" : pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_eWorst ? "eWorst" : "Invalid"); /* Display */ BDBG_P_PrintString("\tDisplay: %s, ", pstUsageMode->stDisplay.eType == BVDB_Display_ePrimary24 ? "Primary@24" : pstUsageMode->stDisplay.eType == BVDB_Display_ePrimary48 ? "Primary@48" : pstUsageMode->stDisplay.eType == BVDB_Display_ePrimary50 ? "Primary@50" : pstUsageMode->stDisplay.eType == BVDB_Display_ePrimary60 ? "Primary@60" : pstUsageMode->stDisplay.eType == BVDB_Display_eSecondary50 ? "Secondary@50" : pstUsageMode->stDisplay.eType == BVDB_Display_eSecondary60 ? "Secondary@60" : "Invalid display"); BDBG_P_PrintString("resolution: %s, ", pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_e1080p ? "1080p" : pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_eWxga ? "WXGA" : pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_e1080i ? "1080i" : pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_e720p ? "720p" : pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_eXga ? "XGA" : pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_e480p ? "480p" : pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_e576p ? "576p" : pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_e480i ? "480i" : pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_e576i ? "576i" : pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_e1920x2160i ? "1920x2160i" : pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_e1280x1440p ? "1280x1440p" : "Invalid output resolution"); BDBG_P_PrintString("Orientation: %s\n", pstUsageMode->stDisplay.eOrientation == BVDB_DisplayOrientation_e3d ? "3D" : "2D"); /* Window */ BDBG_P_PrintString("\tWindow: %s\n", pstUsageMode->eWindow == BVDB_Window_eMain ? "Main" : pstUsageMode->eWindow == BVDB_Window_ePip ? "PIP" : pstUsageMode->eWindow == BVDB_Window_eMonitor ? "MON_out" : "Invalid window"); /* OSD size */ BDBG_P_PrintString("\tOSD: width = %d, height = %d, bpp = %d\n", pstUsageMode->stOsd.ulWidth, pstUsageMode->stOsd.ulHeight, pstUsageMode->stOsd.ulBpp); /* 3D comb */ BDBG_P_PrintString("\t3D Comb: %s\n", pstUsageMode->e3dComb == BVDB_State_eNo ? "no" : pstUsageMode->e3dComb == BVDB_State_eYes ? "yes" : "n/a"); /* oversampling */ BDBG_P_PrintString("\tOversampling: %s\n", pstUsageMode->eOversample == BVDB_State_eNo ? "no" : pstUsageMode->eOversample == BVDB_State_eYes ? "yes" : "n/a"); /* DNR */ BDBG_P_PrintString("\tDNR: %s\n", pstUsageMode->eDnr == BVDB_State_eNo ? "no" : pstUsageMode->eDnr == BVDB_State_eYes ? "yes" : "n/a"); /* CAP/VFD */ BDBG_P_PrintString("\tCAP/VFD: %s ", pstUsageMode->stCapVfd.eState == BVDB_State_eYes ? "yes" : "no"); if (pstUsageMode->stCapVfd.eState == BVDB_State_eYes) { BDBG_P_PrintString("%s ", pstUsageMode->stCapVfd.ePixelFormat == BVDB_PixelFmt_e8Bit422 ? "8-bit 422" : pstUsageMode->stCapVfd.ePixelFormat == BVDB_PixelFmt_e10Bit422 ? "10-bit 422" : pstUsageMode->stCapVfd.ePixelFormat == BVDB_PixelFmt_e10Bit444 ? "10-bit 444" : "n/a"); BDBG_P_PrintString("(reserved %d)\n", pstUsageMode->stCapVfd.ulReserved); } else { BDBG_P_PrintString("\n"); } /* MCVP */ BDBG_P_PrintString("\tMCVP: %s ", pstUsageMode->stMad.eState == BVDB_State_eYes ? "yes" : "no"); if (pstUsageMode->stMad.eState == BVDB_State_eYes) { BDBG_P_PrintString("%s ", pstUsageMode->stMad.ePixelFormat == BVDB_PixelFmt_e8Bit422 ? "8-bit 422" : pstUsageMode->stMad.ePixelFormat == BVDB_PixelFmt_e10Bit422 ? "10-bit 422" : pstUsageMode->stMad.ePixelFormat == BVDB_PixelFmt_e10Bit444 ? "10-bit 444" : "n/a"); BDBG_P_PrintString("\t%s ", pstUsageMode->stMad.eFieldStore == BVDB_FieldStore_e3Fields ? "3-field" : pstUsageMode->stMad.eFieldStore == BVDB_FieldStore_e4Fields ? "4-field" : pstUsageMode->stMad.eFieldStore == BVDB_FieldStore_e5Fields ? "5-field" : "n/a"); BDBG_P_PrintString("(reserved %d)\n", pstUsageMode->stMad.ulReserved); } else { BDBG_P_PrintString("\n"); } /* PDP */ BDBG_P_PrintString("\tPDP: %s ", pstUsageMode->stPdp.eState == BVDB_State_eYes ? "yes" : "no"); if (pstUsageMode->stPdp.eState == BVDB_State_eYes) { BDBG_P_PrintString("(reserved %d)\n", pstUsageMode->stPdp.ulReserved); } else { BDBG_P_PrintString("\n"); } #if BVDB_P_VDB_VER >= BVDB_P_VDB_VER_3 /* RTC */ BDBG_P_PrintString("\tRTC: %s ", pstUsageMode->stRtc.eState == BVDB_State_eYes ? "yes" : "no"); if (pstUsageMode->stRtc.eState == BVDB_State_eYes) { BDBG_P_PrintString("(reserved %d)\n", pstUsageMode->stRtc.ulReserved); } else { BDBG_P_PrintString("\n"); } #endif /* FRC */ BDBG_P_PrintString("\tFRC: %s ", pstUsageMode->stFrc.eState == BVDB_State_eYes ? "yes" : "no"); if (pstUsageMode->stFrc.eState == BVDB_State_eYes) { BDBG_P_PrintString("(reserved %d)\n", pstUsageMode->stFrc.ulReserved); } else { BDBG_P_PrintString("\n"); } /* SCL-CAP tolerance and bias */ BDBG_P_PrintString("\tSCL-CAP tolerance: %d, bias: %s\n", pstUsageMode->ulSclCapTolerance, pstUsageMode->eSclCapBias == BVDB_SclCapBias_eAuto ? "auto" : pstUsageMode->eSclCapBias == BVDB_SclCapBias_eSclCap ? "scl-cap" : pstUsageMode->eSclCapBias == BVDB_SclCapBias_eCapScl ? "cap-scl" : "Invalid"); return BERR_TRACE(err); } #endif /* BDBG_DEBUG_BUILD */ /******************************************************************************* * BVDB_GetInputFormatGroup - Convert the given source inforamtion such as * width, height etc, to a source group that the usage mode table is using. * * Input: hVdb - VDB handle * ulHeight - source height * ulWidth - source width * ulFrameRate - source frame rate x 1000 * bProgressive - true if source is progressive * bJpeg - true if source is JPEG image * bAdcCalibration - true if the mode is in ADC Calibration * b3dSource - true if source is 3D * eInput - tells where the source comes through * Output: N/A * Return: BVDB_SourceGroup (Mapped Source Group) * * Note that if a given source doesn't fall under any source group, "Worst" case * source will be used. We want to handle any source. */ BVDB_SourceGroup BVDB_GetInputFormatGroup (BVDB_Handle hVdb, uint32_t ulHeight, uint32_t ulWidth, uint32_t ulFrameRate, bool bProgressive, bool bJpeg, bool bAdcCalibration, bool b3dSource, BVDB_Input eInput) { BVDB_P_Context *pVdb; uint32_t numEntry; uint32_t i; pVdb = (BVDB_P_Context *) hVdb; if (NULL == pVdb) { BDBG_ERR(("NULL pointer")); return BERR_TRACE(BERR_INVALID_PARAMETER); } BDBG_MSG(("Input Source Format")); BDBG_MSG(("Input Port: %s", eInput == BVDB_Input_eMfd ? "MFD" : eInput == BVDB_Input_eVga ? "VGA" : eInput == BVDB_Input_eHdmi ? "HDMI" : eInput == BVDB_Input_eComponent ? "Component" : eInput == BVDB_Input_eCvbsSvidIfd ? "Composite/S-Vid" : eInput == BVDB_Input_e656 ? "656" : "Unknown")); BDBG_MSG(("3D: %s", b3dSource ? "yes" : "no")); BDBG_MSG(("JPEG: %s", bJpeg ? "yes" : "no")); BDBG_MSG(("ADC: %s", bAdcCalibration ? "yes" : "no")); BDBG_MSG(("Width: %d", ulWidth)); BDBG_MSG(("Height: %d", ulHeight)); BDBG_MSG(("Frame Rate: %d", ulFrameRate)); BDBG_MSG(("Progressive:%s", bProgressive ? "yes" : "no")); /* We have cases where 3D mode is not allowed. We are checking the cases * here */ if (b3dSource) { if (bJpeg || bAdcCalibration || ((BVDB_Input_eMfd != eInput) && (BVDB_Input_eComponent != eInput) && (BVDB_Input_eHdmi != eInput))) { BDBG_WRN(("3D source flag set for non-HDMI, non-MFD input, or in modes where 3D is not allowed")); BDBG_WRN(("3D source flag will be forced off in VDB")); b3dSource = false; } } /* JPEG Source */ if (bJpeg) { return BVDB_SourceGroup_eJpeg2d; } /* ADC Calibration */ if (bAdcCalibration) { return BVDB_SourceGroup_eAdcCalibration2d; } /* Any progressive source from VGA connector is taken as a PC source */ if (BVDB_Input_eVga == eInput) { if (bProgressive) { return BVDB_SourceGroup_ePc2d; } else { BDBG_WRN(("A VGA source has interalced flag on. HDMI is forced")); eInput = BVDB_Input_eHdmi; } } /* Any PC resolution from HDMI is taken as a PC source */ if (BVDB_Input_eHdmi == eInput) { /* PC sources from HDMI */ if (BVDB_P_IsPcFormat(ulWidth, ulHeight, bProgressive, astPcFormats)) { return BVDB_SourceGroup_ePc2d; } } /* Some adjustments for boolean comparison */ if (bProgressive) {bProgressive = true;} if (b3dSource) {b3dSource = true;} numEntry = sizeof(astSourceFormats) / sizeof(BVDB_P_SourceFormat); for (i = 0; i < numEntry; i++) { if ((astSourceFormats[i].inputType & eInput) && (astSourceFormats[i].width >= ulWidth) && (astSourceFormats[i].height >= ulHeight) && (astSourceFormats[i].bProgressive == bProgressive) && (astSourceFormats[i].frameRate >= ulFrameRate) && (astSourceFormats[i].b3dSource == b3dSource)) { if (astSourceFormats[i].eSourceGroup == BVDB_SourceGroup_eWorst) { BDBG_WRN(("No source match found. Worst case source is forced")); } return astSourceFormats[i].eSourceGroup; } } /* Shouldn't reach here */ BDBG_WRN(("No source match found. Worst case source is forced")); return BVDB_SourceGroup_eWorst; } /******************************************************************************* * BVDB_GetVdbEntry - returns a matching usage mode. And Nexus VDB/VDC will * configure BVN based on the retured usage mode. * * Input: hVdb - VDB handle * pstUsageMode - usage mode pointer and some of the structure members * are used as input * pstSysConfig - current system configuration * Output: pstUsageMode - usage mode pointer and some of the structure members * are used as Output (i.e., to be filled by * BVDB_GetVdbEntry()) * Return: BERR_Code */ BERR_Code BVDB_GetVdbEntry (BVDB_Handle hVdb, BVDB_UsageMode *pstUsageMode, BVDB_System_Configurations *pstSysConfig) { BERR_Code err = BERR_SUCCESS; BVDB_P_Context *pVdb; BVDB_SourceGroup sourceGroup; BVDB_SourceGroup mainSourceToMatch; BVDB_SourceGroup subSourceToMatch; BVDB_P_RtsData tmpUsageMode; bool bMainDispModeMatch; bool bSubDispModeMatch; bool bDontCareMainWinClipSize; bool bDontCareSubWinClipSize; bool bDontCareMain; bool bDontCareSub; bool bUsageModeMatchFound; BVDB_P_BvnTopology * pBvn; uint32_t i; pVdb = (BVDB_P_Context *) hVdb; /* Sanity checking */ BDBG_ASSERT(NULL != pVdb); BDBG_ASSERT(NULL != pstUsageMode); BDBG_ASSERT(NULL != pstSysConfig); BDBG_ASSERT(NULL != pVdb->pRtsConfig); BDBG_ASSERT(NULL != pVdb->pRtsConfig->pUsageMode); /* If the current RTS configration doesn't support PIP, PIP window cannot be * used */ if (pstUsageMode->eWindow == BVDB_Window_ePip && !pVdb->pRtsConfig->bPipSupport) { BDBG_ERR(("PIP Window is used for a configuration which doesn't support PIP")); return BERR_TRACE(BERR_INVALID_PARAMETER); } /* If the current RTS configration doesn't support Monitor, Monitor window cannot be * used */ if (pstUsageMode->eWindow == BVDB_Window_eMonitor && !pVdb->pRtsConfig->bMonitorSupport) { BDBG_ERR(("Monitor is used for a configuration which doesn't support PIP")); return BERR_TRACE(BERR_INVALID_PARAMETER); } bUsageModeMatchFound = false; sourceGroup = pstUsageMode->eInputFormatGroup; BDBG_MSG(("Source = 0x%x for %s window", sourceGroup, pstUsageMode->eWindow == BVDB_Window_eMain ? "Main": pstUsageMode->eWindow == BVDB_Window_ePip ? "Pip" : pstUsageMode->eWindow == BVDB_Window_eMonitor ? "Monitor" : "Invalid")); /* Just to avoid build warning messages */ tmpUsageMode = pVdb->pRtsConfig->pUsageMode[0]; /* 1. Find main match - group, win, clipping * 2. Find the sec match - group, win, clipping * 3. 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 Secondary Source = 0x%x, PIP visible = %s\n", pstUsageMode->eWindow == BVDB_Window_eMain ? "main" : pstUsageMode->eWindow == BVDB_Window_ePip ? "pip" : "monitor", pVdb->curUsageMode.main.sourceGroup, pVdb->curUsageMode.sec.sourceGroup, pstSysConfig->bPipVisible ? "Yes" : "No")); if (pstUsageMode->eWindow == BVDB_Window_eMain) { /* There are cases where PC sources are forced to be captured as 422 and * vice versa. */ if ((pstSysConfig->ePixelMode == BVDB_PixelMode_e444Forced) && (sourceGroup & BVDB_SourceGroup_RpAll)) { if (sourceGroup & BVDB_SourceGroup_Rp2d) { sourceGroup = BVDB_SourceGroup_ePc2d; BDBG_MSG(("444 forced (RP 2D source mapped to PC)")); } else { BDBG_WRN(("RP 3D source cannot be mapped to PC")); } } else if ((pstSysConfig->ePixelMode == BVDB_PixelMode_e422Forced) && (sourceGroup & BVDB_SourceGroup_PcAll)) { sourceGroup = BVDB_SourceGroup_Rp2d; BDBG_MSG(("422 forced (PC source mapped to 2D RP Progressive)")); } /* Now if the given source is PC, but if the display is in 3D, PC * processing cannot be kept because of 444 nature being lost by FRC */ if ((pstUsageMode->stDisplay.eOrientation == BVDB_DisplayOrientation_e3d) && (sourceGroup & BVDB_SourceGroup_PcAll)) { sourceGroup = BVDB_SourceGroup_Rp2d; BDBG_MSG(("PC is mapeed to RP because of 3D display mode")); } /* If PIP is not supported or no source connected to sec path, do not * check sec source */ bDontCareMain = false; /* we don't care about the secondary path if PIP is invisible if the * system supports PIP, if the system doesn't support PIP and * Monitor, and if there's no secondary source applied */ bDontCareSub = (!pstSysConfig->bPipVisible && pVdb->pRtsConfig->bPipSupport) || (!pVdb->pRtsConfig->bPipSupport && !pVdb->pRtsConfig->bMonitorSupport) || (pVdb->curUsageMode.sec.sourceGroup == BVDB_SourceGroup_None); /* Do not check clipping and window size for certain cases */ bDontCareMainWinClipSize = pVdb->main.bAutomaticAspectRatioBoxMode; bDontCareSubWinClipSize = bDontCareSub || pVdb->sec.bAutomaticAspectRatioBoxMode; mainSourceToMatch = sourceGroup; subSourceToMatch = pVdb->curUsageMode.sec.sourceGroup; } else { bDontCareMain = (pVdb->curUsageMode.main.sourceGroup == BVDB_SourceGroup_None); bDontCareSub = false; /* Do not check clipping and window size if Automatic Aspect ratio is * used */ bDontCareSubWinClipSize = bDontCareMain || pVdb->sec.bAutomaticAspectRatioBoxMode; bDontCareMainWinClipSize = pVdb->main.bAutomaticAspectRatioBoxMode; mainSourceToMatch = pVdb->curUsageMode.main.sourceGroup; subSourceToMatch = sourceGroup; } BDBG_MSG(("Don't care main = %d, Don't care main win/clip size = %d", bDontCareMain, bDontCareMainWinClipSize)); BDBG_MSG(("Don't care sec = %d, Don't care sec win/clip size = %d", bDontCareSub, bDontCareSubWinClipSize)); for (i = 0; i < pVdb->pRtsConfig->usageModeNum; i++) { BDBG_MSG(("Checking ID = %d, Looking for matches for Main: 0x%x = 0x%x (dispRes), 0x%x = 0x%x (main source), 0x%x = 0x%x (pip source)", pVdb->pRtsConfig->pUsageMode[i].id, pVdb->pRtsConfig->ulMainDisplayResolution, pstUsageMode->stDisplay.eResolution, pVdb->pRtsConfig->pUsageMode[i].main.sourceGroup, mainSourceToMatch, pVdb->pRtsConfig->pUsageMode[i].sec.sourceGroup, subSourceToMatch)); if (pstUsageMode->eWindow == BVDB_Window_eMonitor && pVdb->pRtsConfig->bMonitorSupport) { pVdb->pRtsConfig->ulMainDisplayResolution |= BVDB_OutputResolution_e480i | BVDB_OutputResolution_e576i; } if ((pVdb->pRtsConfig->ulMainDisplayResolution & pstUsageMode->stDisplay.eResolution) && (pstUsageMode->stDisplay.eOrientation & pVdb->pRtsConfig->pUsageMode[i].common.displayOrientation) && (bDontCareMain || (pVdb->pRtsConfig->pUsageMode[i].main.sourceGroup & mainSourceToMatch)) && (bDontCareSub || (pVdb->pRtsConfig->pUsageMode[i].sec.sourceGroup & subSourceToMatch))) { /* Now we have main and sec match. Then find the matching display * mode. */ bMainDispModeMatch = bDontCareMainWinClipSize || ((pVdb->main.winHeight + 1 >= (pVdb->pRtsConfig->pUsageMode[i].main.minWinHeight)) && (pVdb->main.winHeight <= (pVdb->pRtsConfig->pUsageMode[i].main.maxWinHeight + 1)) && (pVdb->main.winWidth + 1 >= (pVdb->pRtsConfig->pUsageMode[i].main.minWinWidth)) && (pVdb->main.winWidth <= (pVdb->pRtsConfig->pUsageMode[i].main.maxWinWidth + 1)) && (pVdb->main.clipHeight <= (pVdb->pRtsConfig->pUsageMode[i].main.maxClippingHeight + 1)) && (pVdb->main.clipWidth <= (pVdb->pRtsConfig->pUsageMode[i].main.maxClippingWidth + 1))); bSubDispModeMatch = bDontCareSubWinClipSize || ((pVdb->sec.winHeight + 1 >= (pVdb->pRtsConfig->pUsageMode[i].sec.minWinHeight)) && (pVdb->sec.winHeight <= (pVdb->pRtsConfig->pUsageMode[i].sec.maxWinHeight + 1)) && (pVdb->sec.winWidth + 1 >= (pVdb->pRtsConfig->pUsageMode[i].sec.minWinWidth)) && (pVdb->sec.winWidth <= (pVdb->pRtsConfig->pUsageMode[i].sec.maxWinWidth + 1)) && (pVdb->sec.clipHeight <= (pVdb->pRtsConfig->pUsageMode[i].sec.maxClippingHeight + 1)) && (pVdb->sec.clipWidth <= (pVdb->pRtsConfig->pUsageMode[i].sec.maxClippingWidth + 1))); BDBG_MSG(("ID (%d) for Main (DontCareMain = %d): Looking for \"%d>=%d(minH), %d<=%d(maxH), %d>=%d(minW), %d<=%d(maxW), %d<=%d(MaxClipH), %d<=%d(MaxClipW)\"", pVdb->pRtsConfig->pUsageMode[i].id, bDontCareMainWinClipSize, pVdb->main.winHeight , pVdb->pRtsConfig->pUsageMode[i].main.minWinHeight - 1, pVdb->main.winHeight , pVdb->pRtsConfig->pUsageMode[i].main.maxWinHeight + 1, pVdb->main.winWidth , pVdb->pRtsConfig->pUsageMode[i].main.minWinWidth - 1, pVdb->main.winWidth , pVdb->pRtsConfig->pUsageMode[i].main.maxWinWidth + 1, pVdb->main.clipHeight, pVdb->pRtsConfig->pUsageMode[i].main.maxClippingHeight + 1, pVdb->main.clipWidth , pVdb->pRtsConfig->pUsageMode[i].main.maxClippingWidth + 1)); BDBG_MSG(("ID (%d) for Secondary (DontCareSub = %d): Looking for \"%d>=%d(minH), %d<=%d(maxH), %d>=%d(minW), %d<=%d(maxW), %d<=%d(MaxClipH), %d<=%d(MaxClipW)\"", pVdb->pRtsConfig->pUsageMode[i].id, bDontCareSubWinClipSize, pVdb->sec.winHeight , pVdb->pRtsConfig->pUsageMode[i].sec.minWinHeight - 1, pVdb->sec.winHeight , pVdb->pRtsConfig->pUsageMode[i].sec.maxWinHeight + 1, pVdb->sec.winWidth , pVdb->pRtsConfig->pUsageMode[i].sec.minWinWidth - 1, pVdb->sec.winWidth , pVdb->pRtsConfig->pUsageMode[i].sec.maxWinWidth + 1, pVdb->sec.clipHeight, pVdb->pRtsConfig->pUsageMode[i].sec.maxClippingHeight + 1, pVdb->sec.clipWidth , pVdb->pRtsConfig->pUsageMode[i].sec.maxClippingWidth + 1)); BDBG_MSG(("Main disp match = %d, Secondary disp match =%d", bMainDispModeMatch, bSubDispModeMatch)); if (bMainDispModeMatch && bSubDispModeMatch) { /* Copy usage mode, but update source group with real ones */ tmpUsageMode = pVdb->pRtsConfig->pUsageMode[i]; BDBG_MSG(("ID \"%d\" is picked", pVdb->pRtsConfig->pUsageMode[i].id)); if (pstUsageMode->eWindow == BVDB_Window_eMain) { /* update main source */ tmpUsageMode.main.sourceGroup = sourceGroup; /* and update sec source */ if (bDontCareSub) { tmpUsageMode.sec.sourceGroup = BVDB_SourceGroup_None; } else { tmpUsageMode.sec.sourceGroup = pVdb->curUsageMode.sec.sourceGroup; } } else { /* update sec source */ tmpUsageMode.sec.sourceGroup = sourceGroup; if (bDontCareMain) { tmpUsageMode.main.sourceGroup = BVDB_SourceGroup_None; } else { tmpUsageMode.main.sourceGroup = pVdb->curUsageMode.main.sourceGroup; } } bUsageModeMatchFound = true; 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->usageId = tmpUsageMode.id; if (pstUsageMode->eWindow == BVDB_Window_eMain) { pBvn = &tmpUsageMode.main; } else { pBvn = &tmpUsageMode.sec; } /* 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 */ if (pstUsageMode->eWindow == BVDB_Window_eInvalid) { /* PIP has no OSD, and main OSD will cover it */ pstUsageMode->stOsd.ulWidth = 0; pstUsageMode->stOsd.ulHeight = 0; pstUsageMode->stOsd.ulBpp = 0; } else if (pstUsageMode->eWindow == BVDB_Window_eMonitor) { pstUsageMode->stOsd = pVdb->pRtsConfig->eVcrOsdResolution; } else { pstUsageMode->stOsd = pVdb->pRtsConfig->eMainOsdResolution; } /* e3dComb for composite signal and eOverampling for main path only */ if (pstUsageMode->eInput == BVDB_Input_eCvbsSvidIfd) { pstUsageMode->e3dComb = tmpUsageMode.common.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 ? BVDB_State_eYes : BVDB_State_eNo; /* CAP/VFD */ pstUsageMode->stCapVfd.eState = pBvn->bcap ? BVDB_State_eYes : BVDB_State_eNo; if (pBvn->bcap) { /* Check if the current RTS configuration support panel reversal */ if (pstSysConfig->bPanelReversed && !pVdb->pRtsConfig->bPanelReversalSupport) { BDBG_ERR(("Panel reversal is not supported in this configuration")); return BERR_TRACE(BERR_INVALID_PARAMETER); } /* Decide CAP/VFD capture format */ if (pstUsageMode->eWindow == BVDB_Window_ePip || pstUsageMode->eWindow == BVDB_Window_eMonitor) { pstUsageMode->stCapVfd.ePixelFormat = BVDB_PixelFmt_e8Bit422; } else { if (sourceGroup == BVDB_SourceGroup_ePc2d) { pstUsageMode->stCapVfd.ePixelFormat = BVDB_PixelFmt_e10Bit444; } else { pstUsageMode->stCapVfd.ePixelFormat = BVDB_PixelFmt_e10Bit422; } } /* Select correct bpp based on the selected capture format */ if (pstUsageMode->stCapVfd.ePixelFormat == BVDB_PixelFmt_e10Bit422) { pstUsageMode->stCapVfd.ulReserved = pBvn->c422; } else { pstUsageMode->stCapVfd.ulReserved = pBvn->c444; } } else { pstUsageMode->stCapVfd.ePixelFormat = BVDB_PixelFmt_eInvalid; pstUsageMode->stCapVfd.ulReserved = 0; } /* MAD - it actually refers to MCVP in DTV chips, and must be in bypass for * PC processing */ pstUsageMode->stMad.eState = (pBvn->bmcvp && (sourceGroup != BVDB_SourceGroup_ePc2d)) ? BVDB_State_eYes : BVDB_State_eNo; /* Determine MCVP capture format based on the current RTS configuration */ if (pstUsageMode->stMad.eState == BVDB_State_eYes) { pstUsageMode->stMad.eFieldStore = BVDB_FieldStore_e5Fields; if (pVdb->pRtsConfig->bMcvpCompromise) { pstUsageMode->stMad.ePixelFormat = BVDB_PixelFmt_e8Bit422; } else { 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 - PDP always on */ pstUsageMode->stPdp.eState = BVDB_State_eYes; pstUsageMode->stPdp.ulReserved = tmpUsageMode.common.dc; /* FRC - must be in bypass mode for PC processing. Don't need to worry about * 3D display cases because source group is already modified and taken care * of based on 3D display mode above */ pstUsageMode->stFrc.eState = (pBvn->bfrc && (sourceGroup != BVDB_SourceGroup_ePc2d)) ? BVDB_State_eYes : BVDB_State_eNo; /* If a system supports FRC, FRC on/off of each usage mode depends on * whether it needs PC processing or not */ if (pstUsageMode->stFrc.eState == BVDB_State_eYes) { pstUsageMode->stFrc.ulReserved = pBvn->frcc; } else { pstUsageMode->stFrc.ulReserved = 0; } /* CAP-SCL bias and orientation */ pstUsageMode->eSclCapBias = pBvn->eSclCap; #if BVDB_P_VDB_VER <= BVDB_P_VDB_VER_2 /* Need to force CAP-SCL in case of RP 1080p source with full window for VDB * version <= 2 */ { bool bMainRpFhdDotByDot; bMainRpFhdDotByDot = ((pstUsageMode->eWindow == BVDB_Window_eMain) && ((sourceGroup == BVDB_SourceGroup_Rp_e1080p2d) || (sourceGroup == BVDB_SourceGroup_Rp_e1080p3d)) && (pVdb->main.winHeight == 100) && (pVdb->main.winWidth == 100)); if (bMainRpFhdDotByDot) { pstUsageMode->eSclCapBias = BVDB_SclCapBias_eCapScl; } } #endif /* TODO Make threshold obsolete */ if (pstUsageMode->eSclCapBias == BVDB_SclCapBias_eAuto) { pstUsageMode->ulSclCapTolerance = 0; } else { pstUsageMode->ulSclCapTolerance = BVDB_P_BIG_THRESHOLD; } pstUsageMode->pRtsSet = tmpUsageMode.pRtsRegisterTable; pVdb->curUsageMode = tmpUsageMode; /* End of filling in "Usage Mode" */ #if BVDB_P_ENABLE_PDP_RR /* Enable round robin in PDP RD enough bandwidth to cover spike */ if ((err == BERR_SUCCESS) && (pstUsageMode->pRtsSet != NULL) && (pVdb->pRtsConfig->ulConfigId != 100)) { uint32_t i; for (i = 0; i < pstUsageMode->pRtsSet->ulValidTableEntries; i++) { /* PDP RD 0 or 1 */ if ((pstUsageMode->pRtsSet->astRts[i].ulId == BVDB_P_CLIENT_ID_BVN_PDP_RD0) || (pstUsageMode->pRtsSet->astRts[i].ulId == BVDB_P_CLIENT_ID_BVN_PDP_RD1)) { pstUsageMode->pRtsSet->astRts[i].ulRegValue |= BVDB_P_CLIENT_INFO_RR_EN; } } } #endif #if BVDB_P_ENABLE_MEM_CLIENT_RR /* Enable round robin in PDP RD enough bandwidth to cover spike */ if ((err == BERR_SUCCESS) && (pstUsageMode->pRtsSet != NULL) && (pVdb->pRtsConfig->ulConfigId != 100) && (pVdb->pRtsConfig->ulConfigId != 101)) { uint32_t i; for (i = 0; i < pstUsageMode->pRtsSet->ulValidTableEntries; i++) { if (pstUsageMode->pRtsSet->astRts[i].ulId != BVDB_P_CLIENT_ID_REFRESH) { pstUsageMode->pRtsSet->astRts[i].ulRegValue |= BVDB_P_CLIENT_INFO_RR_EN; } } } #endif return BERR_TRACE(err); } /******************************************************************************* * BVDB_ValidateConfigId - sets RTS configration ID to use. This must be called * right after VDB Creation. * * Input: hVdb - VDB handle * ulConfigId - RTS configuration ID to set * Output: N/A * Return: BERR_Code */ BERR_Code BVDB_ValidateConfigId (BVDB_Handle hVdb, const uint32_t ulConfigId) { BERR_Code err = BERR_SUCCESS; BVDB_P_Context *pVdb; pVdb = (BVDB_P_Context *) hVdb; if (NULL == pVdb) { BDBG_ERR(("NULL pointer")); return BERR_TRACE(BERR_INVALID_PARAMETER); } /* Copy RTS configuration context pointer to VDB context */ pVdb->pRtsConfig = BVDB_P_GetRtsConfigInfo(ulConfigId); if (NULL == pVdb->pRtsConfig) { BDBG_ERR(("Can't find RTS configuration %d", ulConfigId)); return BERR_TRACE(err); } /* This is to warn a user if an obsolete or a test purpose RTS is used */ if (ulConfigId == 100 || ulConfigId == 101 || ulConfigId == 23301 || ulConfigId == 23302) { BDBG_WRN(("RTS Configuration ID %d that you are attempting to use is either obsolete or test-purpose only!", ulConfigId)); } return BERR_SUCCESS; } /******************************************************************************* * BVDB_GetFeatures - returns the features of the current RTS configuration. * This function will be extended and exposed as a Nexus API * so application can support new RTS configuration without * modifying application. * * Input: hVdb - VDB hanlde * Output: pConfigFetures - a pointer poiting to RTS features to return * Return: BERR_Code */ BERR_Code BVDB_GetFeatures (BVDB_Handle hVdb, BVDB_Config_Features *pConfigFeatures) { BVDB_P_Context *pVdb; pVdb = (BVDB_P_Context *) hVdb; if (NULL == pVdb) { BDBG_ERR(("NULL VDB Context pointer")); return BERR_TRACE(BERR_INVALID_PARAMETER); } BDBG_ASSERT(NULL != pVdb->pRtsConfig); if (pVdb->pRtsConfig->ulConfigId == 0) { BDBG_ERR(("RTS configuration is not set\n")); return BERR_TRACE(BERR_INVALID_PARAMETER); } if (NULL == pConfigFeatures) { BDBG_ERR(("NULL config feature pointer")); return BERR_TRACE(BERR_INVALID_PARAMETER); } /* Copy the features of the current RTS configuration */ pConfigFeatures->bPipSupport = pVdb->pRtsConfig->bPipSupport; pConfigFeatures->bMonitorSupport = pVdb->pRtsConfig->bMonitorSupport; pConfigFeatures->bFrcSupport = pVdb->pRtsConfig->bFrcSupport; pConfigFeatures->bRtcSupport = pVdb->pRtsConfig->bRtcSupport; pConfigFeatures->bPanelReversalSupport = pVdb->pRtsConfig->bPanelReversalSupport; pConfigFeatures->worstPdpBpp = pVdb->pRtsConfig->worstPdpBpp; pConfigFeatures->maxPipWinHeight = pVdb->pRtsConfig->maxPipWinHeight; pConfigFeatures->maxPipWinWidth = pVdb->pRtsConfig->maxPipWinWidth; return BERR_SUCCESS; } /******************************************************************************* * BVDB_GetMemoryAllocation - get memory allocation of the current RTS * configuration * * Input: configId - RTS configuration ID * eWindow - window type such as main, PIP or monitor * eInput - input type such as MFD or non-MFD * b3dDisplay - true if the system uses 3D panel * Output: pstHeapSettings - a pointer pointing to Heap configuration * pulheapSize - heap size * Return: BERR_Code */ BERR_Code BVDB_GetMemoryAllocation (uint32_t configId, BVDB_Window eWindow, BVDB_Input eInput, bool b3dDisplay, BVDB_Heap_Settings *pstHeapSettings, uint32_t *pulHeapSize) { BVDB_P_Config_Info *pConfigInfo; BERR_Code err = BERR_SUCCESS; uint32_t i, j; bool bFound = false; BVDB_P_Config_MemAlloc *pConfigMemAlloc; BDBG_ASSERT(NULL != pstHeapSettings); BDBG_ASSERT(NULL != pulHeapSize); BDBG_MSG(("3D mode = %d VDC Heap to select", b3dDisplay)); /* Use a different VDC heap size depending on display type because 3D TV requires * almost 2x memory footprint compared to 2D TV and memory footrprint for 2D TV * can be reduced by half by choosing VDC heap size based on display type */ pConfigInfo = BVDB_P_GetRtsConfigInfo(configId); pConfigMemAlloc = b3dDisplay ? pConfigInfo->p3dVdcHeap : pConfigInfo->p2dVdcHeap; if (NULL == pConfigMemAlloc) { err = BERR_INVALID_PARAMETER; BDBG_ERR(("RTS Config %% doesn't support %s", configId, b3dDisplay ? "3D memory" : "2D memory")); return BERR_TRACE(err); } /* Search for window */ for (i = 0; i < BVDB_P_NUM_WINDOW_HEAPS; i++) { if (eWindow == pConfigMemAlloc[i].eWindow) { bFound = true; break; } } if (!bFound) { err = BERR_INVALID_PARAMETER; BDBG_ERR(("Invalid window type, or VDC corresponding to the given widnow is not found")); return BERR_TRACE(err); } /* Input type must be valid */ BDBG_ASSERT(eInput != BVDB_Input_eInvalid); if (eInput != BVDB_Input_eMfd) { /* Force all valid non-MPEG inputs to make search simpler */ eInput = BVDB_Input_eComponent; } if (eWindow == BVDB_Window_eMain) { BDBG_MSG(("Found MAIN window")); bFound = false; /* Search for input. Is it MPEG or no? */ for (j = 0; j < 2; j++) { if (eInput == pConfigMemAlloc[i + j].eInput) { *pstHeapSettings = pConfigMemAlloc[i + j].stHeapSettings; *pulHeapSize = pConfigMemAlloc[i + j].ulHeapSize; bFound = true; break; } } } else /* PIP or Monitor */ { *pstHeapSettings = pConfigMemAlloc[i].stHeapSettings; *pulHeapSize = pConfigMemAlloc[i].ulHeapSize; } return BERR_TRACE(err); } /******************************************************************************* * BVDB_SetVideoDisplayMode - sets window size and clipping * * Input: hVdb - VDB handle * pstDisplay - a pointer pointing to current display configuration * eWindow - current window type such as main, PIP, monitor * ulSrcHeight - source height * ulSrcWidth - source width * ulSrcHeightClipAmount - source height clip * ulSrcWidthClipAmount - source width clip * ulDestHeight - window height * ulDestWidth - window width * bAutomaticAspectRatioBoxMode - true if automatic aspect ratio box * mode is used * Output: N/A * Return: BERR_Code */ BERR_Code BVDB_SetVideoDisplayMode (BVDB_Handle hVdb, const BVDB_Display *pstDisplay, const BVDB_Window eWindow, const uint32_t ulSrcHeight, const uint32_t ulSrcWidth, const uint32_t ulSrcHeightClipAmount, const uint32_t ulSrcWidthClipAmount, const uint32_t ulDestHeight, const uint32_t ulDestWidth, const bool bAutomaticAspectRatioBoxMode) { BERR_Code err = BERR_SUCCESS; BVDB_P_Context *pVdb; uint32_t ulHeightClipAmount, ulWidthClipAmount; uint32_t ulDisplayHeight, ulDisplayWidth; pVdb = (BVDB_P_Context *) hVdb; if (NULL == pVdb) { BDBG_ERR(("NULL pointer")); return BERR_TRACE(BERR_INVALID_PARAMETER); } if (NULL == pstDisplay) { BDBG_ERR(("NULL Display pointer")); return BERR_TRACE(BERR_INVALID_PARAMETER); } /* Get display panel info */ err = BVDB_P_GetDisplaySize(pstDisplay->eResolution, &ulDisplayHeight, &ulDisplayWidth); if (BERR_SUCCESS != err) { return BERR_TRACE(err); } /* Get clip amount percentage */ ulHeightClipAmount = (ulSrcHeightClipAmount * 100) / ulSrcHeight; ulWidthClipAmount = (ulSrcWidthClipAmount * 100) / ulSrcWidth; if (eWindow == BVDB_Window_eMain) { pVdb->main.clipHeight = BVDB_P_MIN(ulHeightClipAmount, 100); pVdb->main.clipWidth = BVDB_P_MIN(ulWidthClipAmount, 100); pVdb->main.winHeight = BVDB_P_MIN((ulDestHeight * 100) / ulDisplayHeight, 100); pVdb->main.winWidth = BVDB_P_MIN((ulDestWidth * 100) / ulDisplayWidth, 100); pVdb->main.bAutomaticAspectRatioBoxMode = bAutomaticAspectRatioBoxMode; } else { pVdb->sec.clipHeight = BVDB_P_MIN(ulHeightClipAmount, 100); pVdb->sec.clipWidth = BVDB_P_MIN(ulWidthClipAmount, 100); pVdb->sec.winHeight = BVDB_P_MIN((ulDestHeight * 100) / ulDisplayHeight, 100); pVdb->sec.winWidth = BVDB_P_MIN((ulDestWidth * 100) / ulDisplayWidth, 100); pVdb->sec.bAutomaticAspectRatioBoxMode = bAutomaticAspectRatioBoxMode; } BDBG_MSG(("%s Window Info: disp size (%d, %d) 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", ulDisplayWidth, ulDisplayHeight, ulSrcWidth, ulSrcHeight, ulSrcWidthClipAmount, ulSrcHeightClipAmount, ulDestWidth, ulDestHeight, bAutomaticAspectRatioBoxMode ? "On" : "Off")); return BERR_TRACE(err); }