/*************************************************************************** * 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/73 $ * $brcm_Date: 7/20/11 4:05p $ * * Module Description: * * Revision History: * * $brcm_Log: /magnum/commonutils/vdb/35230/A0/bvdb.c $ * * Hydra_Software_Devel/73 7/20/11 4:05p jerrylim * SWDTV-8009: Prevent memory leakage * * Hydra_Software_Devel/72 6/28/11 6:09p jerrylim * SWDTV-7243: Added config205 * * Hydra_Software_Devel/71 5/2/11 12:40p yingh * SWDTV-6375: Added config204 with RTS supported * * Hydra_Software_Devel/70 4/6/11 10:45a jerrylim * SWDTV-5931: Added config101 for CAP1 buffer capture * * Hydra_Software_Devel/69 3/16/11 5:26p yingh * SWDTV-5403: Added config402 with RTS supported * * Hydra_Software_Devel/68 2/22/11 3:39p jerrylim * SWDTV-5417: Added config203 with RTS supported * * Hydra_Software_Devel/67 2/14/11 12:11p jerrylim * SW35230-2804: Added PC processing option (422 or 444) * * Hydra_Software_Devel/66 2/9/11 7:31p jerrylim * SW35230-3000: Print source mapping table for debug * * Hydra_Software_Devel/65 2/9/11 4:28p jerrylim * SW35230-2843: Added config202 * * Hydra_Software_Devel/64 2/4/11 3:30p jerrylim * SW35230-1724: Added a 3D dual path processing to config200 * * Hydra_Software_Devel/63 1/28/11 2:12p jerrylim * SW35230-2895: config100 does not need global RTS settings * * Hydra_Software_Devel/62 1/27/11 5:55p jerrylim * SW35230-1170: moved 3D OSD support to common * * Hydra_Software_Devel/61 1/27/11 11:58a jerrylim * SW35230-2162: updated config300/301 in MCVP0_RWC2 to allocate proper BW * * Hydra_Software_Devel/60 1/13/11 6:25p jerrylim * SW35230-2674: Added RTC support to config200 * * Hydra_Software_Devel/59 1/11/11 5:55p jerrylim * SW35230-2630, SW35230-2301: VDEC memory clients are always given * necessary memory bandwidth which ensures that there's no hole and 3D * comb always works * * Hydra_Software_Devel/58 12/24/10 11:32a jerrylim * SW35230-2526: Force CAP-SCL if a 1080p RP source is in dot-by-dot view * mode * * Hydra_Software_Devel/57 12/20/10 3:51p jerrylim * SW35230-2613, SW35230-2594: Updated config401 to support high bitrate * streams and wider range of window and clipping size * * Hydra_Software_Devel/56 12/16/10 2:29p jerrylim * SW35230-2579: Replaced user mode functions with kernel mode functions * * Hydra_Software_Devel/55 12/15/10 11:08a jerrylim * SW35230-2579: Made VDB kernel mode safe * * Hydra_Software_Devel/54 12/14/10 10:14p jhaberf * SW35230-2565: Removed includes of stdio.h/stdlib.h as these cause build * errors when building for kernel mode * * Hydra_Software_Devel/53 12/14/10 2:48p jerrylim * SWGERRARD-1145: Removed config400 (config401 covers it) and increased * OSD size to 1920x1080 in config401 * * Hydra_Software_Devel/52 12/3/10 3:49p jerrylim * SW35230-2132, SW35230-2182: use round robin for PDP WR to cover spike * at the last line * * Hydra_Software_Devel/51 11/22/10 8:10p jerrylim * SW35230-2346: Force 422 for non-PC sources * * Hydra_Software_Devel/50 11/22/10 3:11p jerrylim * SW35230-2132, SW35230-2182: Go back to the original PDP workaround for * dimming to correctly work * * Hydra_Software_Devel/49 11/19/10 1:29p jerrylim * SW35230-2132, SW35230-2182: Removed PDP workaourd because a fix is * available in PDP * * Hydra_Software_Devel/48 11/17/10 11:23a jerrylim * SW35230-2131: Need to consider ADC Calibaration * * Hydra_Software_Devel/47 11/16/10 5:38p jerrylim * SW35230-2132, SW35230-2182: Give enough bw to PDP WR to cover the spike * at the end of line * * Hydra_Software_Devel/46 11/12/10 10:21a jerrylim * SW35230-2131: handle NULL cases for monitor output * * Hydra_Software_Devel/45 11/10/10 8:15p jerrylim * SW35230-2131, SW35230-1910, SW35230-1889: make sure CAP/VFD is not * starting * * Hydra_Software_Devel/44 11/8/10 7:14p jerrylim * SW35230-2067: Check PIG mode first, if a match found, then use the * mode. Otherwise stick to full mode for dot by dot display * * Hydra_Software_Devel/43 11/5/10 4:59p jerrylim * SW35230-1278: Adjust PDP worst case for 300/301/400/401 * * Hydra_Software_Devel/42 10/19/10 9:40a jerrylim * SWGERRARD-790: Support OSD size for 3D video mode * * Hydra_Software_Devel/41 10/7/10 6:21p jerrylim * SW35230-1192: No compensation for panel reversal * * Hydra_Software_Devel/40 10/7/10 6:10p jerrylim * SW35230-1192: No compensation for panel reversal * * Hydra_Software_Devel/39 10/7/10 4:25p jerrylim * SW35230-1610, SW35230-1607: Put back panel reversal support and * extended cropping size to 32% * * Hydra_Software_Devel/38 9/29/10 4:12p jerrylim * SW35230-1530: Added dot-by-dot mode * * Hydra_Software_Devel/37 9/28/10 6:53p jerrylim * SW35230-1514: Added MFD 1080p @ 60 usage cases * * Hydra_Software_Devel/36 9/28/10 6:41p jerrylim * SW35230-1514: Added MFD 1080p @ 60 usage cases * * Hydra_Software_Devel/35 9/20/10 4:31p jerrylim * SW35230-765: Assume a max PC resolution if a matching format not found * * Hydra_Software_Devel/34 9/16/10 3:50p jerrylim * SW35230-1335: Add config400, 401 * * Hydra_Software_Devel/33 9/15/10 11:17a jerrylim * SW35230-1359: freed an allocated memory chunk when closing * * Hydra_Software_Devel/32 9/10/10 5:57p jerrylim * SW35230-1332: Add VDB support for PDP and FRC * * Hydra_Software_Devel/31 8/31/10 12:07p jerrylim * SW35230-1231: Added MFD JPEG source to get mapped to the new source * group * * Hydra_Software_Devel/30 8/26/10 5:55p jerrylim * SW35230-1170: Added support for OSD size for 3D sources * * Hydra_Software_Devel/29 8/24/10 2:02p jerrylim * SW35230-785: Added support for auto aspect ratio correction * * Hydra_Software_Devel/28 8/23/10 6:21p jerrylim * SW35230-785: Added support for Auto Aspect Ratio Correction * * Hydra_Software_Devel/27 8/13/10 4:06p jerrylim * SW35230-224: Added a get function which returns feature set that each * RTS configuration supports * * Hydra_Software_Devel/26 8/4/10 5:40a jerrylim * SW35230-842: Adjusted MFD bo in a576i pig mode * * Hydra_Software_Devel/25 8/2/10 12:06a jerrylim * SW35230-778: Make sure that all MFD formats fall under a predefined * source format group * * Hydra_Software_Devel/24 7/30/10 6:05p jerrylim * SW35230-785: Allowed any main win size when PIP is configured * * Hydra_Software_Devel/23 7/29/10 5:38p jerrylim * SW35230-817: Added 3D support to config200 * * Hydra_Software_Devel/22 7/29/10 12:46p jerrylim * SW35230-778: Added AVC 1920x720 @ 25 * * Hydra_Software_Devel/21 7/23/10 5:47p jerrylim * SW35230-670: CAP bpp with panel reversal compensated * * Hydra_Software_Devel/20 7/23/10 9:58a jerrylim * SW35230-744: Added the missing error checking. Set the proper OSD size * to make OSD size checking valid * * Hydra_Software_Devel/19 7/22/10 7:51p jerrylim * SW35230-742: Modified config200 with 667Mhz support w/o FRC, Added * initial revision of config201 * * Hydra_Software_Devel/18 7/15/10 7:48p jerrylim * SW35230-297: Added more debug prints * * Hydra_Software_Devel/17 7/15/10 5:39p jerrylim * SW35230-320: Added initial revision of config300 and config301 * * Hydra_Software_Devel/16 7/15/10 4:58p jerrylim * SW35230-663: Eanble MAD if ANR is enabled because MAD is tied to ANR * * Hydra_Software_Devel/15 7/12/10 3:51p jerrylim * SW35230-297: Added PIP support. Added more message for easier problem * identification * * Hydra_Software_Devel/14 7/8/10 1:11p jerrylim * SW35230-297: Simplified display modes * * Hydra_Software_Devel/13 7/7/10 4:16p jerrylim * SW35230-297: Simplified Get display Mode * * Hydra_Software_Devel/12 7/6/10 4:03p jerrylim * SW35230-297: Made usage mode obey VDB * * Hydra_Software_Devel/11 7/2/10 5:44p jerrylim * SW35230-297: Changed config100 to the new design style * * Hydra_Software_Devel/10 7/2/10 3:49p jerrylim * SW35230-297: Added RTS status print, Added usagemode version print, * Removed cfg101(obsolete), Added RTS table ID, Adjusted win to max * * Hydra_Software_Devel/9 6/29/10 11:18a jerrylim * SW35230-297: cleaned up old design. Corrected VDB dump * * Hydra_Software_Devel/8 6/25/10 5:18p jerrylim * SW35230-309: Treat AVC 1080i as 1080psf * * Hydra_Software_Devel/7 6/25/10 1:56p jerrylim * SW35230-309: Handle ADC calibration differently * * Hydra_Software_Devel/6 6/23/10 8:27p jerrylim * SW35230-309: Always use main RTS setting for sub * * Hydra_Software_Devel/5 6/23/10 6:50p jerrylim * SW35230-309: Initialized win size and clipping size * * Hydra_Software_Devel/4 6/23/10 5:53p jerrylim * SW35230-309: Added config 200 based on Usage Mode Rev.2.0 * * Hydra_Software_Devel/3 5/21/10 2:16p jerrylim * SW35230-205: Merged all VDB changes checked into the SW23230-205 sub * branch * * Hydra_Software_Devel/SW35230-205/5 5/19/10 6:00p jerrylim * SW35230-205: Corrected some of usage modes * * Hydra_Software_Devel/SW35230-205/4 5/10/10 3:26p jerrylim * SW35230-205: moved the default configs from 1/2 to 100/101 because * nexus has some dependencies on configs and especially WXGA displayr * resolution is forced with config 1. And client 127 is a special * register which controls the DRAM refresh rate, and should be * differently programmed * * Hydra_Software_Devel/SW35230-205/3 5/7/10 5:26p jerrylim * SW35230-205: Capture forced except for MFD JPEG sources * * Hydra_Software_Devel/SW35230-205/2 5/7/10 4:22p jerrylim * SW35230-205: dynamically compose the usage mode and return one of the * two default RTS settings - hardware default for config1 and ASIC team * simultation default fo rconfig2 * * Hydra_Software_Devel/SW35230-205/1 5/5/10 11:57a jerrylim * SW35230-205: Test checkin. No functional change * * Hydra_Software_Devel/1 4/30/10 3:06p jerrylim * SW35230-99: Added real VDB files * ***************************************************************************/ #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 #define BVDB_P_SCL_CAP_WORKAOURND 1 #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 */ /* 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; #define BVDB_P_PRINT_SOURCE_MAPPING 0 #if (BDBG_DEBUG_BUILD && BVDB_P_PRINT_SOURCE_MAPPING) typedef struct { uint32_t ulWidth; uint32_t ulHeight; uint32_t ulFrameRate; uint32_t bProgressive; } BVDB_P_DebugSourceFormat; static BVDB_P_DebugSourceFormat astSourceFormat[] = { /* DTV SD */ {720, 480, 50000, false}, {720, 480, 60000, false}, {720, 480, 50000, true}, {720, 480, 60000, true}, {720, 576, 50000, false}, {720, 576, 60000, false}, {720, 576, 50000, true}, {720, 576, 60000, true}, /* DTV HD */ {1280, 720, 50000, true}, {1280, 720, 60000, true}, {1920, 1080, 50000, false}, {1920, 1080, 60000, false}, {1920, 1080, 50000, true}, {1920, 1080, 60000, true}, /* PC formats */ {640, 350, 85000, true}, {640, 400, 85000, true}, {640, 480, 59940, true}, {640, 480, 66667, true}, {640, 480, 72000, true}, {640, 480, 75000, true}, {640, 480, 85000, true}, {720, 400, 85000, true}, {800, 600, 56000, true}, {800, 600, 56250, true}, {800, 600, 59862, true}, {800, 600, 60000, true}, {800, 600, 60317, true}, {800, 600, 72000, true}, {800, 600, 72188, true}, {800, 600, 75000, true}, {800, 600, 85000, true}, {800, 600, 85061, true}, {848, 480, 60000, true}, {848, 480, 60000, true}, {832, 624, 74546, true}, {832, 624, 75000, true}, {1024, 768, 59920, true}, {1024, 768, 60004, true}, {1024, 768, 66110, true}, {1024, 768, 70069, true}, {1024, 768, 75029, true}, {1024, 768, 84997, true}, {1152, 864, 75000, true}, {1280, 768, 59995, true}, {1280, 768, 59870, true}, {1280, 768, 74893, true}, {1280, 768, 84837, true}, {1280, 800, 59910, true}, {1280, 800, 59810, true}, {1280, 800, 74934, true}, {1280, 800, 84880, true}, {1280, 960, 60000, true}, {1280, 960, 85002, true}, {1280, 1024, 59895, true}, {1280, 1024, 60020, true}, {1280, 1024, 69995, true}, {1280, 1024, 75025, true}, {1280, 1024, 85024, true}, {1340, 725, 60000, true}, {1360, 768, 59799, true}, {1360, 768, 60015, true}, {1366, 768, 59650, true}, {1366, 768, 59658, true}, {1400, 1050, 59948, true}, {1400, 1050, 59978, true}, {1400, 1050, 74867, true}, {1440, 900, 59901, true}, {1440, 900, 59887, true}, {1440, 900, 74984, true}, {1440, 900, 84842, true}, {1600, 1200, 60000, true}, {1680, 1050, 59883, true}, {1680, 1050, 59954, true}, {1920, 1080, 59988, true}, {1920, 1080, 60000, true}, {1920, 1200, 60000, true}, {0, 0, 0, false} }; #endif /* BDBG_DEBUG_BUILD && BVDB_P_PRINT_SOURCE_MAPPING */ /* 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; /* Test source mapping of all possible formats */ #if (BDBG_DEBUG_BUILD && BVDB_P_PRINT_SOURCE_MAPPING) { BVDB_InputFormatGroup eInputFormatGroup; uint32_t uiInputType; uint32_t i; BERR_Code rc; for (uiInputType = BVDB_Input_eCvbsSvidIfd; uiInputType <= BVDB_Input_e656; uiInputType++) { i = 0; for (;;) { if (astSourceFormat[i].ulWidth == 0) { break; } rc = BVDB_GetInputFormatGroup(*phVdb, astSourceFormat[i].ulHeight, astSourceFormat[i].ulWidth, astSourceFormat[i].ulFrameRate, astSourceFormat[i].bProgressive, false, (BVDB_Input) uiInputType, &eInputFormatGroup ); BDBG_P_PrintString("%s%s: %dx%d%s@%d -> %s\n", rc == BERR_SUCCESS ? " " : "!", uiInputType == BVDB_Input_eCvbsSvidIfd ? "BVDB_Input_eCvbsSvidIfd" : uiInputType == BVDB_Input_eComponent ? "BVDB_Input_eComponent " : uiInputType == BVDB_Input_eHdDvi ? "BVDB_Input_eHdDvi " : uiInputType == BVDB_Input_eMfd ? "BVDB_Input_eMfd " : uiInputType == BVDB_Input_eVga ? "BVDB_Input_eVga " : uiInputType == BVDB_Input_e656 ? "BVDB_Input_e656 " : "Unknown Source ", astSourceFormat[i].ulWidth, astSourceFormat[i].ulHeight, astSourceFormat[i].bProgressive ? "p" : "i", astSourceFormat[i].ulFrameRate, eInputFormatGroup == BVDB_InputFormatGroup_eNtsc ? "BVDB_InputFormatGroup_eNtsc" : eInputFormatGroup == BVDB_InputFormatGroup_ePal ? "BVDB_InputFormatGroup_ePal" : eInputFormatGroup == BVDB_InputFormatGroup_e480p ? "BVDB_InputFormatGroup_e480p" : eInputFormatGroup == BVDB_InputFormatGroup_e576p ? "BVDB_InputFormatGroup_e576p" : eInputFormatGroup == BVDB_InputFormatGroup_e720p_50 ? "BVDB_InputFormatGroup_e720p_50" : eInputFormatGroup == BVDB_InputFormatGroup_e720p_60 ? "BVDB_InputFormatGroup_e720p_60" : eInputFormatGroup == BVDB_InputFormatGroup_e1080i_50 ? "BVDB_InputFormatGroup_e1080i_50" : eInputFormatGroup == BVDB_InputFormatGroup_e1080i_60 ? "BVDB_InputFormatGroup_e1080i_60" : eInputFormatGroup == BVDB_InputFormatGroup_e1080p_24 ? "BVDB_InputFormatGroup_e1080p_24" : eInputFormatGroup == BVDB_InputFormatGroup_e1080p_25 ? "BVDB_InputFormatGroup_e1080p_25" : eInputFormatGroup == BVDB_InputFormatGroup_e1080p_30 ? "BVDB_InputFormatGroup_e1080p_30" : eInputFormatGroup == BVDB_InputFormatGroup_e1080p_50 ? "BVDB_InputFormatGroup_e1080p_50" : eInputFormatGroup == BVDB_InputFormatGroup_e1080p_60 ? "BVDB_InputFormatGroup_e1080p_60" : eInputFormatGroup == BVDB_InputFormatGroup_ePal_60 ? "BVDB_InputFormatGroup_ePal_60" : eInputFormatGroup == BVDB_InputFormatGroup_e720p_24 ? "BVDB_InputFormatGroup_e720p_24" : eInputFormatGroup == BVDB_InputFormatGroup_e720p_25 ? "BVDB_InputFormatGroup_e720p_25" : eInputFormatGroup == BVDB_InputFormatGroup_e720p_30 ? "BVDB_InputFormatGroup_e720p_30" : eInputFormatGroup == BVDB_InputFormatGroup_e544_576i_50 ? "BVDB_InputFormatGroup_e544_576i_50" : eInputFormatGroup == BVDB_InputFormatGroup_e1440_1080i_50 ? "BVDB_InputFormatGroup_e1440_1080i_50" : eInputFormatGroup == BVDB_InputFormatGroup_e1440_1080p_25 ? "BVDB_InputFormatGroup_e1440_1080p_25" : eInputFormatGroup == BVDB_InputFormatGroup_e544_480i_60 ? "BVDB_InputFormatGroup_e544_480i_60" : eInputFormatGroup == BVDB_InputFormatGroup_e1440_1080i_60 ? "BVDB_InputFormatGroup_e1440_1080i_60" : eInputFormatGroup == BVDB_InputFormatGroup_e1440_1080p_30 ? "BVDB_InputFormatGroup_e1440_1080p_30" : eInputFormatGroup == BVDB_InputFormatGroup_e1440_1080p_24 ? "BVDB_InputFormatGroup_e1440_1080p_24" : eInputFormatGroup == BVDB_InputFormatGroup_e1024_768_60_PC ? "BVDB_InputFormatGroup_e1024_768_60_PC" : eInputFormatGroup == BVDB_InputFormatGroup_e1024_768_85_PC ? "BVDB_InputFormatGroup_e1024_768_85_PC" : eInputFormatGroup == BVDB_InputFormatGroup_e1366_768_60_PC ? "BVDB_InputFormatGroup_e1366_768_60_PC" : eInputFormatGroup == BVDB_InputFormatGroup_e1366_768_85_PC ? "BVDB_InputFormatGroup_e1366_768_85_PC" : eInputFormatGroup == BVDB_InputFormatGroup_e1400_1050_60_PC ? "BVDB_InputFormatGroup_e1400_1050_60_PC" : eInputFormatGroup == BVDB_InputFormatGroup_e1400_1050_75_PC ? "BVDB_InputFormatGroup_e1400_1050_75_PC" : eInputFormatGroup == BVDB_InputFormatGroup_e1920_1080_60_PC ? "BVDB_InputFormatGroup_e1920_1080_60_PC" : eInputFormatGroup == BVDB_InputFormatGroup_e1600_1200_60_PC ? "BVDB_InputFormatGroup_e1600_1200_60_PC" : eInputFormatGroup == BVDB_InputFormatGroup_eAdcCalibration ? "BVDB_InputFormatGroup_eAdcCalibration" : eInputFormatGroup == BVDB_InputFormatGroup_eJpeg_540 ? "BVDB_InputFormatGroup_eJpeg_540" : eInputFormatGroup == BVDB_InputFormatGroup_eJpeg_1080 ? "BVDB_InputFormatGroup_eJpeg_1080" : eInputFormatGroup == BVDB_InputFormatGroup_e1080p3d_24 ? "BVDB_InputFormatGroup_e1080p3d_24" : eInputFormatGroup == BVDB_InputFormatGroup_e1080p3d_30 ? "BVDB_InputFormatGroup_e1080p3d_30" : eInputFormatGroup == BVDB_InputFormatGroup_e720p3d_60 ? "BVDB_InputFormatGroup_e720p3d_60" : eInputFormatGroup == BVDB_InputFormatGroup_e720p3d_50 ? "BVDB_InputFormatGroup_e720p3d_50" : "BVDB_InputFormatGroup_eInvalid" ); i++; } } } #endif /* BDBG_DEBUG_BUILD && BVDB_P_PRINT_SOURCE_MAPPING */ 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]; char acStrAux[BVDB_MAX_STRLEN]; BDBG_ASSERT(pstUsageMode); /* ID */ BDBG_P_PrintString("\n* RTS Configuration %d, ver %d.%1d\n", tvdb.ulConfigId, tvdb.ulVdbVer / 10, tvdb.ulVdbVer % 10); 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%s\n", acStr, acStr1, pstUsageMode->b3dDualPathProcessing ? " (3D Dual Path Processing)" : "" ); /* 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) { BVDB_P_GetFieldStoreCntStr(pstUsageMode->stMad.eFieldStore, acStrAux); } else { if (pstUsageMode->stMad.ePixelFormat == BVDB_PixelFmt_eInvalid) BVDB_P_STRCPY(acStrAux, "n/a"); else BVDB_P_STRCPY(acStrAux, "no"); } BDBG_P_PrintString("\tMAD: %s\t%s (reserved %d)\n", acStr, acStrAux, 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, BVDB_System_Configurations *pstSysConfig) { 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; } /* If a 3D dual path processing is active, 3D source names will be remapped * to find correct usage modes */ pstUsageMode->b3dDualPathProcessing = pstSysConfig->b3dDualPathProcessing; if (pstSysConfig->b3dDualPathProcessing) { switch (mappedSource) { case BVDB_SourceGroup_Rp_e720p3d: mappedSource = BVDB_SourceGroup_Rp_e720p3dDual; break; case BVDB_SourceGroup_Rp_e1080p3d: mappedSource = BVDB_SourceGroup_Rp_e1080p3dDual; break; case BVDB_SourceGroup_Rp_e1080i3d: mappedSource = BVDB_SourceGroup_Rp_e1080i3dDual; break; default: BDBG_ERR(("3D Dual Path Enabled, but the current source is not a 3D source (Source = 0x%x", mappedSource)); return BERR_TRACE(BERR_INVALID_PARAMETER); break; } } BDBG_MSG(("Mapped source = 0x%x 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, 3D Dual Path =%d\n", pstUsageMode->eWindow == BVDB_Window_eMain ? "main" : "pip", tvdb.curUsageMode.main.sourceGroup, tvdb.curUsageMode.sub.sourceGroup, pstSysConfig->bPipVisible ? "Yes" : "No", pstSysConfig->b3dDualPathProcessing)); /* If PIP is not supported or no source connected to sub path, do not check sub source */ if (pstUsageMode->eWindow == BVDB_Window_eMain) { /* There are cases where PC sources are forced to be captured as 422 * and RP sources are forced to be captured as 444 */ if ((pstSysConfig->ePixelMode == BVDB_PixelMode_e444Forced) && (mappedSource & BVDB_SourceGroup_Rp)) { mappedSource = BVDB_SourceGroup_ePc; BDBG_MSG(("444 forced (RP source mapped PC)")); } else if ((pstSysConfig->ePixelMode == BVDB_PixelMode_e422Forced) && (mappedSource == BVDB_SourceGroup_ePc)) { mappedSource = BVDB_SourceGroup_Rp_e1080p; BDBG_MSG(("422 forced (PC source mapped 1080p RP)")); } bDontCareMain = false; bDontCareSub = !pstSysConfig->bPipVisible || !tvdb.bPipSupport || (tvdb.curUsageMode.sub.sourceGroup == BVDB_SourceGroup_None) || (pstSysConfig->b3dDualPathProcessing && (mappedSource & BVDB_SourceGroup_3dDual)) || (!pstSysConfig->b3dDualPathProcessing && (tvdb.curUsageMode.sub.sourceGroup & BVDB_SourceGroup_3dDual)); /* 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 { /* PIP source cannot be used if the current RTS config doesn't * support PIP and 3D dual processing */ if (!tvdb.bPipSupport && !(tvdb.b3dDualPathProcessingSupport && pstSysConfig->b3dDualPathProcessing && (mappedSource & BVDB_SourceGroup_3dDual))) { BDBG_ERR(("PIP is not supported in this configuration")); return BERR_TRACE(BERR_INVALID_PARAMETER); } bDontCareMain = (tvdb.curUsageMode.main.sourceGroup == BVDB_SourceGroup_None) || (!pstSysConfig->b3dDualPathProcessing && (tvdb.curUsageMode.main.sourceGroup & BVDB_SourceGroup_3dDual)) || (pstSysConfig->b3dDualPathProcessing && (mappedSource & BVDB_SourceGroup_3dDual)); 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 && !pstSysConfig->b3dDualPathProcessing) { 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(minH), %d<=%d(maxH), %d>=%d(minW), %d<=%d(maxW), %d<=%d(MaxClipH), %d<=%d(MaxClipW)\"", 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(minH), %d<=%d(maxH), %d>=%d(minW), %d<=%d(maxW), %d<=%d(MaxClipH), %d<=%d(MaxClipW)\"", 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 (pstSysConfig->bPanelReversed && !tvdb.bPanelReversalSupport) { BDBG_ERR(("Panel reversal is not supported in this configuration")); return BERR_TRACE(BERR_INVALID_PARAMETER); } if (!pstSysConfig->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 (mappedSource == BVDB_SourceGroup_ePc) { pstUsageMode->stCapVfd.ePixelFormat = BVDB_PixelFmt_e10Bit444; } else if (mappedSource & BVDB_SourceGroup_3dDual) { pstUsageMode->stCapVfd.ePixelFormat = BVDB_PixelFmt_e8Bit422; } 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; #if BVDB_P_SCL_CAP_WORKAOURND /* When there's no scaling, scl-cap orientation is meaningless, but there is * a line artifact on top if scl-cap is used if a source 1080p @ 50/60 RP */ if ((pstUsageMode->eWindow == BVDB_Window_eMain) && (mappedSource == BVDB_SourceGroup_Rp_e1080p) && tvdb.main.bDotByDot) { pstUsageMode->ulSclCapTolerance = BVDB_P_BIG_THRESHOLD; pstUsageMode->eSclCapBias = BVDB_SclCapBias_eCapScl; } #endif /* 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" */ #if BVDB_P_FRC_PIXEL_PADDING_PDP_WORKAROUND /* Give CAP/VFD maximum bandwidth because there may be bandwidth starvation * in CAP/VFD due to the pixel padding */ if ((err == BERR_SUCCESS) && (pstUsageMode->pRtsSet != NULL) && (tvdb.ulConfigId != 100) && (tvdb.ulConfigId != 101)) { uint32_t i; uint32_t blockout; for (i = 0; i < pstUsageMode->pRtsSet->ulValidTableEntries; i++) { blockout = (pstUsageMode->pRtsSet->astRts[i].ulRegValue & ~0xff) >> 8; /* CAP/VFD Needs more bandwidth as much as 1080p to support pixel * padding */ if ((pstUsageMode->pRtsSet->astRts[i].ulId == BVDB_P_CLIENT_ID_BVN_CAP0) || (pstUsageMode->pRtsSet->astRts[i].ulId == BVDB_P_CLIENT_ID_BVN_VFD0)) { /* CAP 0 and VFD 0 */ if (blockout > 96) { pstUsageMode->pRtsSet->astRts[i].ulRegValue = (pstUsageMode->pRtsSet->astRts[i].ulRegValue & 0xff) | (96 << 8); } } /* AVFE_VDEC_MD_RD needs to be backward compatible to support A0/B0 */ if (pstUsageMode->pRtsSet->astRts[i].ulId == BVDB_P_CLIENT_ID_AVFE_VDEC_MD_RD) { pstUsageMode->pRtsSet->astRts[i].ulRegValue = (pstUsageMode->pRtsSet->astRts[i].ulRegValue & 0xff) | (0x358 << 8); } /* "Keep VDEC memory clients always given necessary bandwidth": There * are cases where 3D filter doesn't work well if there's a brief * bandwidth starvation in a initial time, and it doesn't recover. * To prevent this, VDEC memory clients are always given memory * bandwidth. And it doesn't affect system performance because they * won't access memory in off state even though memory bandwidth is * given. */ if (pstUsageMode->pRtsSet->astRts[i].ulId == BVDB_P_CLIENT_ID_AVFE_VDEC_MD_WR) { pstUsageMode->pRtsSet->astRts[i].ulRegValue = (pstUsageMode->pRtsSet->astRts[i].ulRegValue & 0xff) | (0x1abf << 8); } if (pstUsageMode->pRtsSet->astRts[i].ulId == BVDB_P_CLIENT_ID_AVFE_VDEC_VD_RD) { pstUsageMode->pRtsSet->astRts[i].ulRegValue = (pstUsageMode->pRtsSet->astRts[i].ulRegValue & 0xff) | (0xe2 << 8); } if (pstUsageMode->pRtsSet->astRts[i].ulId == BVDB_P_CLIENT_ID_AVFE_VDEC_VD_WR) { pstUsageMode->pRtsSet->astRts[i].ulRegValue = (pstUsageMode->pRtsSet->astRts[i].ulRegValue & 0xff) | (0x2a9 << 8); } /* End if "Keep VDEC memory clients always given necessary bandwidth" */ /* Enable round robin in XPT RD0/WR0 enough bandwidth to cover high * bitrate */ if ((pstUsageMode->pRtsSet->astRts[i].ulId == BVDB_P_CLIENT_ID_XPT_RD0) || (pstUsageMode->pRtsSet->astRts[i].ulId == BVDB_P_CLIENT_ID_XPT_WR0)) { pstUsageMode->pRtsSet->astRts[i].ulRegValue |= BVDB_P_CLIENT_INFO_RR_EN; } /* Enable round robin in PDP WR enough bandwidth to cover spike */ /* PDP WR 0 or 1 */ if ((pstUsageMode->pRtsSet->astRts[i].ulId == BVDB_P_CLIENT_ID_BVN_PDP_WR0) || (pstUsageMode->pRtsSet->astRts[i].ulId == BVDB_P_CLIENT_ID_BVN_PDP_WR1)) { pstUsageMode->pRtsSet->astRts[i].ulRegValue |= BVDB_P_CLIENT_INFO_RR_EN; } /* The code enables 120Hz display in PDP even in case that it's not * supported in RTS, which allows to use 120Hz panel with an RTS * configuration with 60Hz support for convenience. Note that * the operation is not guaranteed and it must be used for * development purpose only, and a 60Hz display must be used for * evaluation. */ #ifdef BVDB_P_PDP_120HZ_SUPPORT /* Enable round robin in PDP RD to support 120Hz if needed at app * own risk */ 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 = 0x80; } #endif } /* Give enough bpp for slice mode */ if (tvdb.bFrcSupport && (pstUsageMode->stCapVfd.ulReserved < 30) && (pstUsageMode->stCapVfd.ulReserved != 0)) { pstUsageMode->stCapVfd.ulReserved = 30; } } #endif /* BVDB_P_FRC_PIXEL_PADDING_WORKAROUND */ 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; uint32_t ulVer; BVDB_P_GET_CONTEXT(hVdb, pVdb); if (ulConfigId == 100 || ulConfigId == 101 || ulConfigId == 200 || ulConfigId == 201 || ulConfigId == 202 || ulConfigId == 203 || ulConfigId == 204 || ulConfigId == 205 || ulConfigId == 300 || ulConfigId == 301 || 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: ulVer = BVDB_USAGE_MODE_VER_CFG100; tvdb.eMainOsdResolution = BVDB_Osd_e1920_2205p_32bpp; tvdb.eVcrOsdResolution = BVDB_Osd_e576i_8bpp; tvdb.panelReversalCompensation = 0; tvdb.bPipSupport = true; tvdb.b3dDualPathProcessingSupport = true; tvdb.bMonitorSupport = true; tvdb.bFrcSupport = true; tvdb.bRtcSupport = true; tvdb.bPanelReversalSupport = true; tvdb.worstPdpBpp = 20; tvdb.maxPipWinHeight = 100; tvdb.maxPipWinWidth = 100; break; case 101: ulVer = BVDB_USAGE_MODE_VER_CFG101; tvdb.eMainOsdResolution = BVDB_Osd_e1920_2205p_32bpp; tvdb.eVcrOsdResolution = BVDB_Osd_e576i_8bpp; tvdb.panelReversalCompensation = 0; tvdb.bPipSupport = true; tvdb.b3dDualPathProcessingSupport = true; tvdb.bMonitorSupport = true; tvdb.bFrcSupport = true; tvdb.bRtcSupport = true; tvdb.bPanelReversalSupport = true; tvdb.worstPdpBpp = 20; tvdb.maxPipWinHeight = 100; tvdb.maxPipWinWidth = 100; break; case 200: ulVer = BVDB_USAGE_MODE_VER_CFG200; tvdb.eMainOsdResolution = BVDB_Osd_e1920_2205p_32bpp; tvdb.panelReversalCompensation = 0; tvdb.bPipSupport = false; tvdb.b3dDualPathProcessingSupport = true; tvdb.bMonitorSupport = true; tvdb.bFrcSupport = false; tvdb.bRtcSupport = false; tvdb.bPanelReversalSupport = true; tvdb.worstPdpBpp = 30; tvdb.maxPipWinHeight = 0; tvdb.maxPipWinWidth = 0; break; case 201: ulVer = BVDB_USAGE_MODE_VER_CFG201; tvdb.eMainOsdResolution = BVDB_Osd_e1920_2205p_32bpp; tvdb.panelReversalCompensation = 0; tvdb.bPipSupport = false; tvdb.b3dDualPathProcessingSupport = false; tvdb.bMonitorSupport = true; tvdb.bFrcSupport = true; tvdb.bRtcSupport = false; tvdb.bPanelReversalSupport = true; tvdb.worstPdpBpp = 30; tvdb.maxPipWinHeight = 0; tvdb.maxPipWinWidth = 0; break; case 202: ulVer = BVDB_USAGE_MODE_VER_CFG202; tvdb.eMainOsdResolution = BVDB_Osd_e1920_2205p_32bpp; tvdb.panelReversalCompensation = 0; tvdb.bPipSupport = false; tvdb.b3dDualPathProcessingSupport = true; tvdb.bMonitorSupport = false; tvdb.bFrcSupport = false; tvdb.bRtcSupport = false; tvdb.bPanelReversalSupport = false; tvdb.worstPdpBpp = 30; tvdb.maxPipWinHeight = 0; tvdb.maxPipWinWidth = 0; break; case 203: ulVer = BVDB_USAGE_MODE_VER_CFG203; tvdb.eMainOsdResolution = BVDB_Osd_e1920_2205p_32bpp; tvdb.panelReversalCompensation = 0; tvdb.bPipSupport = false; tvdb.b3dDualPathProcessingSupport = true; tvdb.bMonitorSupport = true; tvdb.bFrcSupport = false; tvdb.bRtcSupport = true; tvdb.bPanelReversalSupport = true; tvdb.worstPdpBpp = 30; tvdb.maxPipWinHeight = 0; tvdb.maxPipWinWidth = 0; break; case 204: ulVer = BVDB_USAGE_MODE_VER_CFG204; tvdb.eMainOsdResolution = BVDB_Osd_e1280_800p_32bpp; tvdb.panelReversalCompensation = 0; tvdb.bPipSupport = false; tvdb.b3dDualPathProcessingSupport = false; tvdb.bMonitorSupport = true; tvdb.bFrcSupport = false; tvdb.bRtcSupport = true; tvdb.bPanelReversalSupport = false; tvdb.worstPdpBpp = 30; tvdb.maxPipWinHeight = 0; tvdb.maxPipWinWidth = 0; break; case 205: ulVer = BVDB_USAGE_MODE_VER_CFG205; tvdb.eMainOsdResolution = BVDB_Osd_e1366_768p_32bpp; tvdb.panelReversalCompensation = 0; tvdb.bPipSupport = true; tvdb.b3dDualPathProcessingSupport = false; tvdb.bMonitorSupport = false; tvdb.bFrcSupport = false; tvdb.bRtcSupport = true; tvdb.bPanelReversalSupport = true; tvdb.worstPdpBpp = 30; tvdb.maxPipWinHeight = 50; tvdb.maxPipWinWidth = 40; break; case 300: ulVer = BVDB_USAGE_MODE_VER_CFG300; tvdb.eMainOsdResolution = BVDB_Osd_e1920_1080p_32bpp; tvdb.eVcrOsdResolution = BVDB_Osd_eNone; tvdb.panelReversalCompensation = 0; tvdb.bPipSupport = true; tvdb.b3dDualPathProcessingSupport = false; tvdb.bMonitorSupport = false; tvdb.bFrcSupport = false; tvdb.bRtcSupport = false; tvdb.bPanelReversalSupport = false; tvdb.worstPdpBpp = 30; tvdb.maxPipWinHeight = 83; tvdb.maxPipWinWidth = 46; break; case 301: ulVer = BVDB_USAGE_MODE_VER_CFG301; tvdb.eMainOsdResolution = BVDB_Osd_e1280_720p_32bpp, tvdb.eVcrOsdResolution = BVDB_Osd_eNone; tvdb.panelReversalCompensation = 0; tvdb.bPipSupport = true; tvdb.b3dDualPathProcessingSupport = false; tvdb.bMonitorSupport = false; tvdb.bFrcSupport = true; tvdb.bRtcSupport = false; tvdb.bPanelReversalSupport = false; tvdb.worstPdpBpp = 30; tvdb.maxPipWinHeight = 64; tvdb.maxPipWinWidth = 45; break; case 401: ulVer = BVDB_USAGE_MODE_VER_CFG401; tvdb.eMainOsdResolution = BVDB_Osd_e1920_2205p_32bpp; tvdb.eVcrOsdResolution = BVDB_Osd_eNone; tvdb.panelReversalCompensation = 0; tvdb.bPipSupport = true; tvdb.b3dDualPathProcessingSupport = false; tvdb.bMonitorSupport = false; tvdb.bFrcSupport = true; tvdb.bRtcSupport = false; tvdb.bPanelReversalSupport = false; tvdb.worstPdpBpp = 30; tvdb.maxPipWinHeight = 50; tvdb.maxPipWinWidth = 50; break; case 402: ulVer = BVDB_USAGE_MODE_VER_CFG402; tvdb.eMainOsdResolution = BVDB_Osd_e1920_2205p_32bpp; tvdb.eVcrOsdResolution = BVDB_Osd_eNone; tvdb.panelReversalCompensation = 0; tvdb.bPipSupport = true; tvdb.b3dDualPathProcessingSupport = false; tvdb.bMonitorSupport = false; tvdb.bFrcSupport = true; tvdb.bRtcSupport = true; tvdb.bPanelReversalSupport = true; tvdb.worstPdpBpp = 30; tvdb.maxPipWinHeight = 50; tvdb.maxPipWinWidth = 50; break; } tvdb.ulVdbVer = ulVer; 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->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) { BDBG_ERR(("Cannot get memory allocation array for the given RTS configuration")); goto BVDB_GetMemoryAllocationMemFreeExit; } /* 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: 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", tvdb.main.bDotByDot ? "On" : "Off")); return BERR_TRACE(err); }