source: svn/newcon3bcm2_21bu/magnum/commonutils/vdb/35233/A0/bvdb.c @ 44

Last change on this file since 44 was 44, checked in by megakiss, 11 years ago

광주방송 OTC 주파수 369Mhz로 변경

  • Property svn:executable set to *
File size: 51.6 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2011, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: bvdb.c $
11 * $brcm_Revision: Hydra_Software_Devel/11 $
12 * $brcm_Date: 9/9/11 3:47p $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/commonutils/vdb/35233/A0/bvdb.c $
19 *
20 * Hydra_Software_Devel/11   9/9/11 3:47p jerrylim
21 * SWDTV-8623: Enabled RR
22 *
23 * Hydra_Software_Devel/10   9/7/11 7:57p yingh
24 * SWDTV-8499: Increased the supported height of source resolution from
25 * 1080 to 1088 for MFD
26 *
27 * Hydra_Software_Devel/9   9/7/11 4:58p jerrylim
28 * SWDTV-8574: Display a warning message if an obsolete or a test-purpose
29 * RTS configuration is used
30 *
31 * Hydra_Software_Devel/8   7/20/11 1:44p jerrylim
32 * SWDTV-7684: Selectively choose VDC buffer heap based on 3D display
33 *
34 * Hydra_Software_Devel/7   7/4/11 5:44p jerrylim
35 * SWDTV-7267: Added the secondary display for VDB match
36 *
37 * Hydra_Software_Devel/6   6/23/11 12:06p jerrylim
38 * SWDTV-7568: removed setting grpahics size to 0 for PIP because it'll
39 * share graphics with main
40 *
41 * Hydra_Software_Devel/5   6/22/11 11:07p jerrylim
42 * SWDTV-7593, SWDTV-7587: Force CAP-SCL for RP1080p and Corrected
43 * blockout for FRC clients to support 3D
44 *
45 * Hydra_Software_Devel/4   6/15/11 1:30p jerrylim
46 * SWDTV-7385, SWDTV-6738: Added 3D support to config23301
47 *
48 * Hydra_Software_Devel/3   6/3/11 3:23p jerrylim
49 * SWDTV-7358, SWDTV-7300, SWDTV-7132, SWDTV-5753: Restructured VDB for
50 * 35233
51 *
52 * Hydra_Software_Devel/2   5/10/11 6:59p jerrylim
53 * SWDTV-6973: Updated PDP worst case based on the worst case of the usage
54 * modes
55 *
56 * Hydra_Software_Devel/1   3/17/11 7:22p jerrylim
57 * SWDTV-5980: Added 35233 VDB
58 *
59 ***************************************************************************/
60#include "bstd.h"
61#include "berr.h"
62#include "bkni.h"
63#include "bfmt.h"
64#include "bdbg.h"
65
66#include "bvdb.h"
67#include "bvdb_priv.h"
68
69#include "bchp_memc_arb_0.h"
70
71BDBG_MODULE(BVDB);
72
73#define BVDB_P_ENABLE_MEM_CLIENT_RR 1
74
75
76/* A big number so SCL-CAP orientation can be forced. This will be made obsolete */
77#define BVDB_P_BIG_THRESHOLD    100000
78
79/* Giving 100 max will make first comparison to get passed, so each display mode
80 * will be free to pick up any clipping size in percentage */
81#define BVDB_P_MAX_SRC_CLIP_HEIGHT_AMOUNT   100 /* percent */
82#define BVDB_P_MAX_SRC_CLIP_WIDTH_AMOUNT    100 /* percent */
83
84
85/* This is a list of PC formats that are detected as PC, meaning that a source
86 * with one of the following formats is allowed to have 444 processing. However,
87 * application can force the processing either to 422 or 444 */
88static BVDB_P_SourceResolution astPcFormats[] =
89{
90    {160,  120},
91    {240,  160},
92    {320,  200},
93    {320,  240},
94    {432,  240},
95    {480,  320},
96    {640,  350},
97    {640,  400},
98    {640,  480},
99    {720,  400},
100    {800,  480},
101    {800,  600},
102    {848,  480},
103    {832,  624},
104    {854,  480},
105    {1024, 576},
106    {1024, 600},
107    {1024, 768},
108    {1152, 768},
109    {1152, 864},
110    {1280, 768},
111    {1280, 800},
112    {1280, 854},
113    {1280, 960},
114    {1280, 1024},
115    {1340, 725},
116    {1360, 765},
117    {1360, 768},
118    {1366, 768},
119    {1400, 1050},
120    {1440, 900},
121    {1600, 900},
122    {1600, 1200},
123    {1680, 1050},
124    {1680, 1050},
125
126    /* by default 1920x1080 from HDMI will be handled as non-PC (i.e., 422).
127     * However application is given an option to force it. Refer to
128     * BVDB_PixelMode */
129#if BVDB_P_HANDLE_FHD_AS_PC
130    {1920, 1080},
131#endif
132
133    {1920, 1200},
134    {0, 0}  /* mark end of table */
135};
136
137
138/* Source format to source group conversion table. PC source is coverted in a
139 * different table above - astPcFormats[] */
140static BVDB_P_SourceFormat astSourceFormats[] =
141{
142    /* input type      w     h    scan(p) fr     3d     source group */
143    {BVDB_Input_eMfd,  720,  576, false,  60000, false, BVDB_SourceGroup_Avc_e576i2d},
144    {BVDB_Input_eMfd, 1280,  720,  true,  60000, false, BVDB_SourceGroup_Avc_e720p2d},
145    {BVDB_Input_eMfd, 1920, 1088, false,  60000, false, BVDB_SourceGroup_Avc_e1080i2d},
146    {BVDB_Input_eMfd, 1920, 1088,  true,  30000, false, BVDB_SourceGroup_Avc_e1080psf2d},
147    {BVDB_Input_eMfd, 1920, 1088,  true,  60000, false, BVDB_SourceGroup_Avc_e1080p2d},
148
149    /* if BVDB_P_EXPAND_3D_SOURCES is true, 3D sources will have finer splits */
150#if BVDB_P_EXPAND_3D_SOURCES
151    {BVDB_Input_eMfd,  720,  576, false,  60000,  true, BVDB_SourceGroup_Avc_e576i3d},
152    {BVDB_Input_eMfd, 1280,  720,  true,  60000,  true, BVDB_SourceGroup_Avc_e720p3d},
153    {BVDB_Input_eMfd, 1920, 1088, false,  60000,  true, BVDB_SourceGroup_Avc_e1080i3d},
154    {BVDB_Input_eMfd, 1920, 1088,  true,  30000,  true, BVDB_SourceGroup_Avc_e1080psf3d},
155    {BVDB_Input_eMfd, 1920, 1088,  true,  60000,  true, BVDB_SourceGroup_Avc_e1080p3d},
156#else
157    {BVDB_Input_eMfd,  BIG_NUM, BIG_NUM, false, BIG_NUM,  true, BVDB_SourceGroup_Avc_e3d},
158    {BVDB_Input_eMfd,  BIG_NUM, BIG_NUM,  true, BIG_NUM,  true, BVDB_SourceGroup_Avc_e3d},
159#endif
160
161    {BVDB_Input_Rp,    720,  576, false,  60000, false, BVDB_SourceGroup_Rp_e576i2d},
162    {BVDB_Input_Rp,   1280,  720,  true,  60000, false, BVDB_SourceGroup_Rp_e720p2d},
163    {BVDB_Input_Rp,   1920, 1080, false,  60000, false, BVDB_SourceGroup_Rp_e1080i2d},
164    {BVDB_Input_Rp,   1920, 1080,  true,  30000, false, BVDB_SourceGroup_Rp_e1080psf2d},
165    {BVDB_Input_Rp,   1920, 1080,  true,  60000, false, BVDB_SourceGroup_Rp_e1080p2d},
166
167#if BVDB_P_EXPAND_3D_SOURCES
168    {BVDB_Input_Rp,    720,  576, false,  60000,  true, BVDB_SourceGroup_Rp_e576i3d},
169    {BVDB_Input_Rp,   1280,  720,  true,  60000,  true, BVDB_SourceGroup_Rp_e720p3d},
170    {BVDB_Input_Rp,   1920, 1080, false,  60000,  true, BVDB_SourceGroup_Rp_e1080i3d},
171    {BVDB_Input_Rp,   1920, 1080,  true,  30000,  true, BVDB_SourceGroup_Rp_e1080psf3d},
172    {BVDB_Input_Rp,   1920, 1080,  true,  60000,  true, BVDB_SourceGroup_Rp_e1080p3d},
173#else
174    {BVDB_Input_Rp,  BIG_NUM, BIG_NUM, false, BIG_NUM,  true, BVDB_SourceGroup_Rp_e3d},
175    {BVDB_Input_Rp,  BIG_NUM, BIG_NUM,  true, BIG_NUM,  true, BVDB_SourceGroup_Rp_e3d},
176#endif
177
178    /* Any source which doesn't fall under known groups will use worst */
179    {BVDB_Input_All,  BIG_NUM, BIG_NUM, false, BIG_NUM,  true, BVDB_SourceGroup_eWorst},
180    {BVDB_Input_All,  BIG_NUM, BIG_NUM,  true, BIG_NUM,  true, BVDB_SourceGroup_eWorst},
181    {BVDB_Input_All,  BIG_NUM, BIG_NUM, false, BIG_NUM, false, BVDB_SourceGroup_eWorst},
182    {BVDB_Input_All,  BIG_NUM, BIG_NUM,  true, BIG_NUM, false, BVDB_SourceGroup_eWorst},
183};
184
185
186/*******************************************************************************
187 *
188 * BVDB_CreateVdb - creates VDB context and initialize them. This function must
189 * be called first before using any of VDB public functions
190 *
191 * Input:  phVdb - VDB hanle to return
192 * Output: N/A
193 * Return: BERR_Code
194 */
195BERR_Code BVDB_CreateVdb
196    (BVDB_Handle *phVdb)
197{
198    BERR_Code err = BERR_SUCCESS;
199    BVDB_P_Context *pVdb;
200
201    /* Allocate VDB Context */
202    pVdb = (BVDB_P_Context *) BKNI_Malloc(sizeof(BVDB_P_Context));
203    if (NULL == pVdb)
204    {
205        BDBG_ERR(("Out of memory"));
206        return BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY);
207    }
208
209    *phVdb = (BVDB_Handle) pVdb;
210
211    BKNI_Memset(pVdb, 0, sizeof(BVDB_P_Context));
212
213    /* Initialize VDB context */
214    pVdb->curUsageMode.main.sourceGroup = BVDB_SourceGroup_None;
215    pVdb->curUsageMode.sec.sourceGroup  = BVDB_SourceGroup_None;
216
217    pVdb->main.winHeight = 100;
218    pVdb->main.winWidth  = 100;
219
220    pVdb->sec.winHeight  = 100;
221    pVdb->sec.winWidth   = 100;
222
223    BDBG_MSG(("VDB Created"));
224    return BERR_TRACE(err);
225}
226
227/*******************************************************************************
228 * BVDB_DestroyVdb - free memory previously allocated for VDB context
229 *
230 * Input:  hVdb - VDB handle
231 * Output: N/A
232 * Return: BERR_Code
233 */
234BERR_Code BVDB_DestroyVdb
235    (BVDB_Handle hVdb)
236{
237    BVDB_P_Context *pVdb;
238
239    pVdb = (BVDB_P_Context *) hVdb;
240
241    if (NULL == pVdb)
242    {
243        BDBG_ERR(("NULL pointer"));
244        return BERR_TRACE(BERR_INVALID_PARAMETER);
245    }
246
247    BKNI_Free(pVdb);
248
249    BDBG_MSG(("VDB Destroyed"));
250    return BERR_TRACE(BERR_SUCCESS);
251}
252
253
254#if BDBG_DEBUG_BUILD
255/*******************************************************************************
256 * BVDB_PrintUsageMode - is a debugging function which is built with DEBUG build
257 * option. It prints usage mode information which is currently being used.
258 *
259 * Input:  hVdb - VDB handle
260 *         pstUsageMode - a pointer poiting to the current usage mode
261 * Output: N/A
262 * Return: BERR_Code
263 */
264BERR_Code BVDB_PrintUsageMode
265    (BVDB_Handle          hVdb,
266     const BVDB_UsageMode *pstUsageMode )
267{
268    BERR_Code err = BERR_SUCCESS;
269    BVDB_P_Context *pVdb;
270
271    if (NULL == pstUsageMode)
272    {
273        BDBG_ERR(("NULL usage mode pointer"));
274        return BERR_TRACE(BERR_INVALID_PARAMETER);
275    }
276
277    pVdb = (BVDB_P_Context *) hVdb;
278    if (NULL == pVdb)
279    {
280        BDBG_ERR(("NULL VDB Context pointer"));
281        return BERR_TRACE(BERR_INVALID_PARAMETER);
282    }
283
284    /* ID */
285    BDBG_ASSERT(NULL != pVdb->pRtsConfig);
286    BDBG_P_PrintString("\n* RTS Configuration %d, ver %d.%1d\n",
287            pVdb->pRtsConfig->ulConfigId, pVdb->pRtsConfig->ulVdbVer / 10,
288            pVdb->pRtsConfig->ulVdbVer % 10);
289    BDBG_P_PrintString("\tCurrent VDB ID: %d\n", pstUsageMode->usageId);
290
291    /* Input format */
292    BDBG_P_PrintString("\tInput type: %s, ",
293        pstUsageMode->eInput == BVDB_Input_eCvbsSvidIfd ? "CVBS/SVID/IFD" :
294        pstUsageMode->eInput == BVDB_Input_eComponent ? "Component" :
295        pstUsageMode->eInput == BVDB_Input_eHdmi ? "HDMI" :
296        pstUsageMode->eInput == BVDB_Input_eMfd ? "MFD" :
297        pstUsageMode->eInput == BVDB_Input_eVga ? "VGA" :
298        pstUsageMode->eInput == BVDB_Input_e656 ? "656" : "Invalid");
299
300    BDBG_P_PrintString("Format: %s\n",
301        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e576i2d ?  "Avc_e576i2d" :
302        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e720p2d ? "Avc_e720p2d" :
303        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e1080i2d ? "Avc_e1080i2d" :
304        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e1080psf2d ? "Avc_e1080psf2d" :
305        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e1080p2d ? "Avc_e1080p2d" :
306        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e576i2d ? "Rp_e576i2d" :
307        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e720p2d ? "Rp_e720p2d" :
308        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e1080i2d ? "Rp_e1080i2d" :
309        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e1080psf2d ? "Rp_e1080psf2d" :
310        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e1080p2d ? "Rp_e1080p2d" :
311
312#if BVDB_P_EXPAND_3D_SOURCES
313        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e576i3d ? "Avc_e576i3d" :
314        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e720p3d ? "Avc_e720p3d" :
315        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e1080i3d ? "Avc_e1080i3d" :
316        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e1080psf3d ? "Avc_e1080psf3d" :
317        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e1080p3d ? "Avc_e1080p3d" :
318        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e576i3d ? "Rp_e576i3d" :
319        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e720p3d ? "Rp_e720p3d" :
320        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e1080i3d ? "Rp_e1080i3d" :
321        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e1080psf3d ? "Rp_e1080psf3d" :
322        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e1080p3d ? "Rp_e1080p3d" :
323#else
324        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Avc_e3d ? "Avc_e3d" :
325        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_Rp_e3d ? "Rp_e3d" :
326#endif
327        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_ePc2d ? "ePc2d" :
328        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_eJpeg2d ? "eJpeg2d" :
329        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_eAdcCalibration2d ? "eAdcCalibration2d" :
330        pstUsageMode->eInputFormatGroup == BVDB_SourceGroup_eWorst ? "eWorst" : "Invalid");
331
332    /* Display */
333    BDBG_P_PrintString("\tDisplay: %s, ",
334        pstUsageMode->stDisplay.eType == BVDB_Display_ePrimary24 ? "Primary@24" :
335        pstUsageMode->stDisplay.eType == BVDB_Display_ePrimary48 ? "Primary@48" :
336        pstUsageMode->stDisplay.eType == BVDB_Display_ePrimary50 ? "Primary@50" :
337        pstUsageMode->stDisplay.eType == BVDB_Display_ePrimary60 ? "Primary@60" :
338        pstUsageMode->stDisplay.eType == BVDB_Display_eSecondary50 ? "Secondary@50" :
339        pstUsageMode->stDisplay.eType == BVDB_Display_eSecondary60 ? "Secondary@60" : "Invalid display");
340    BDBG_P_PrintString("resolution: %s, ",
341        pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_e1080p ? "1080p" :
342        pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_eWxga ? "WXGA" :
343        pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_e1080i ? "1080i" :
344        pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_e720p ? "720p" :
345        pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_eXga ? "XGA" :
346        pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_e480p ? "480p" :
347        pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_e576p ? "576p" :
348        pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_e480i ? "480i" :
349        pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_e576i ? "576i" :
350        pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_e1920x2160i ? "1920x2160i" :
351        pstUsageMode->stDisplay.eResolution == BVDB_OutputResolution_e1280x1440p ? "1280x1440p" : "Invalid output resolution");
352
353    BDBG_P_PrintString("Orientation: %s\n",
354        pstUsageMode->stDisplay.eOrientation == BVDB_DisplayOrientation_e3d ?  "3D" : "2D");
355
356    /* Window */
357    BDBG_P_PrintString("\tWindow: %s\n",
358        pstUsageMode->eWindow == BVDB_Window_eMain ? "Main" :
359        pstUsageMode->eWindow == BVDB_Window_ePip ? "PIP" :
360        pstUsageMode->eWindow == BVDB_Window_eMonitor ? "MON_out" : "Invalid window");
361
362    /* OSD size */
363    BDBG_P_PrintString("\tOSD: width = %d, height = %d, bpp = %d\n",
364        pstUsageMode->stOsd.ulWidth,
365        pstUsageMode->stOsd.ulHeight,
366        pstUsageMode->stOsd.ulBpp);
367
368    /* 3D comb */
369    BDBG_P_PrintString("\t3D Comb: %s\n",
370        pstUsageMode->e3dComb == BVDB_State_eNo  ? "no" :
371        pstUsageMode->e3dComb == BVDB_State_eYes ? "yes" : "n/a");
372
373    /* oversampling */
374    BDBG_P_PrintString("\tOversampling: %s\n",
375        pstUsageMode->eOversample == BVDB_State_eNo  ? "no" :
376        pstUsageMode->eOversample == BVDB_State_eYes ? "yes" : "n/a");
377
378    /* DNR */
379    BDBG_P_PrintString("\tDNR: %s\n",
380        pstUsageMode->eDnr == BVDB_State_eNo  ? "no" :
381        pstUsageMode->eDnr == BVDB_State_eYes ? "yes" : "n/a");
382
383    /* CAP/VFD */
384    BDBG_P_PrintString("\tCAP/VFD: %s ",
385        pstUsageMode->stCapVfd.eState == BVDB_State_eYes ? "yes" : "no");
386
387    if (pstUsageMode->stCapVfd.eState == BVDB_State_eYes)
388    {
389        BDBG_P_PrintString("%s ",
390            pstUsageMode->stCapVfd.ePixelFormat == BVDB_PixelFmt_e8Bit422 ? "8-bit 422" :
391            pstUsageMode->stCapVfd.ePixelFormat == BVDB_PixelFmt_e10Bit422 ? "10-bit 422" :
392            pstUsageMode->stCapVfd.ePixelFormat == BVDB_PixelFmt_e10Bit444 ? "10-bit 444" : "n/a");
393        BDBG_P_PrintString("(reserved %d)\n", pstUsageMode->stCapVfd.ulReserved);
394    }
395    else
396    {
397        BDBG_P_PrintString("\n");
398    }
399
400    /* MCVP */
401    BDBG_P_PrintString("\tMCVP: %s ",
402        pstUsageMode->stMad.eState == BVDB_State_eYes ? "yes" : "no");
403    if (pstUsageMode->stMad.eState == BVDB_State_eYes)
404    {
405        BDBG_P_PrintString("%s ",
406            pstUsageMode->stMad.ePixelFormat == BVDB_PixelFmt_e8Bit422 ? "8-bit 422" :
407            pstUsageMode->stMad.ePixelFormat == BVDB_PixelFmt_e10Bit422 ? "10-bit 422" :
408            pstUsageMode->stMad.ePixelFormat == BVDB_PixelFmt_e10Bit444 ? "10-bit 444" : "n/a");
409        BDBG_P_PrintString("\t%s ",
410            pstUsageMode->stMad.eFieldStore == BVDB_FieldStore_e3Fields ? "3-field" :
411            pstUsageMode->stMad.eFieldStore == BVDB_FieldStore_e4Fields ? "4-field" :
412            pstUsageMode->stMad.eFieldStore == BVDB_FieldStore_e5Fields ? "5-field" : "n/a");
413        BDBG_P_PrintString("(reserved %d)\n", pstUsageMode->stMad.ulReserved);
414    }
415    else
416    {
417        BDBG_P_PrintString("\n");
418    }
419
420    /* PDP */
421    BDBG_P_PrintString("\tPDP: %s ",
422        pstUsageMode->stPdp.eState == BVDB_State_eYes ? "yes" : "no");
423    if (pstUsageMode->stPdp.eState == BVDB_State_eYes)
424    {
425        BDBG_P_PrintString("(reserved %d)\n", pstUsageMode->stPdp.ulReserved);
426    }
427    else
428    {
429        BDBG_P_PrintString("\n");
430    }
431
432#if BVDB_P_VDB_VER >= BVDB_P_VDB_VER_3
433    /* RTC */
434    BDBG_P_PrintString("\tRTC: %s ",
435        pstUsageMode->stRtc.eState == BVDB_State_eYes ? "yes" : "no");
436    if (pstUsageMode->stRtc.eState == BVDB_State_eYes)
437    {
438        BDBG_P_PrintString("(reserved %d)\n", pstUsageMode->stRtc.ulReserved);
439    }
440    else
441    {
442        BDBG_P_PrintString("\n");
443    }
444#endif
445
446    /* FRC */
447    BDBG_P_PrintString("\tFRC: %s ",
448        pstUsageMode->stFrc.eState == BVDB_State_eYes ? "yes" : "no");
449    if (pstUsageMode->stFrc.eState == BVDB_State_eYes)
450    {
451        BDBG_P_PrintString("(reserved %d)\n", pstUsageMode->stFrc.ulReserved);
452    }
453    else
454    {
455        BDBG_P_PrintString("\n");
456    }
457
458    /* SCL-CAP tolerance and bias */
459    BDBG_P_PrintString("\tSCL-CAP tolerance: %d, bias: %s\n",
460        pstUsageMode->ulSclCapTolerance,
461        pstUsageMode->eSclCapBias == BVDB_SclCapBias_eAuto ? "auto" :
462        pstUsageMode->eSclCapBias == BVDB_SclCapBias_eSclCap ? "scl-cap" :
463        pstUsageMode->eSclCapBias == BVDB_SclCapBias_eCapScl ? "cap-scl" : "Invalid");
464
465    return BERR_TRACE(err);
466}
467#endif /* BDBG_DEBUG_BUILD */
468
469
470/*******************************************************************************
471 * BVDB_GetInputFormatGroup - Convert the given source inforamtion such as
472 * width, height etc, to a source group that the usage mode table is using.
473 *
474 * Input:  hVdb - VDB handle
475 *         ulHeight - source height
476 *         ulWidth - source width
477 *         ulFrameRate - source frame rate x 1000
478 *         bProgressive - true if source is progressive
479 *         bJpeg - true if source is JPEG image
480 *         bAdcCalibration - true if the mode is in ADC Calibration
481 *         b3dSource - true if source is 3D
482 *         eInput - tells where the source comes through
483 * Output: N/A
484 * Return: BVDB_SourceGroup (Mapped Source Group)
485 *
486 * Note that if a given source doesn't fall under any source group, "Worst" case
487 * source will be used. We want to handle any source.
488 */
489BVDB_SourceGroup BVDB_GetInputFormatGroup
490    (BVDB_Handle hVdb,
491     uint32_t    ulHeight,
492     uint32_t    ulWidth,
493     uint32_t    ulFrameRate,
494     bool        bProgressive,
495     bool        bJpeg,
496     bool        bAdcCalibration,
497     bool        b3dSource,
498     BVDB_Input  eInput)
499{
500    BVDB_P_Context *pVdb;
501    uint32_t numEntry;
502    uint32_t i;
503
504    pVdb = (BVDB_P_Context *) hVdb;
505    if (NULL == pVdb)
506    {
507        BDBG_ERR(("NULL pointer"));
508        return BERR_TRACE(BERR_INVALID_PARAMETER);
509    }
510
511    BDBG_MSG(("Input Source Format"));
512    BDBG_MSG(("Input Port: %s", eInput == BVDB_Input_eMfd ? "MFD" :
513                                eInput == BVDB_Input_eVga ? "VGA" :
514                                eInput == BVDB_Input_eHdmi ? "HDMI" :
515                                eInput == BVDB_Input_eComponent ? "Component" :
516                                eInput == BVDB_Input_eCvbsSvidIfd ? "Composite/S-Vid" :
517                                eInput == BVDB_Input_e656 ? "656" : "Unknown"));
518    BDBG_MSG(("3D:         %s", b3dSource ? "yes" : "no"));
519    BDBG_MSG(("JPEG:       %s", bJpeg ? "yes" : "no"));
520    BDBG_MSG(("ADC:        %s", bAdcCalibration ? "yes" : "no"));
521    BDBG_MSG(("Width:      %d", ulWidth));
522    BDBG_MSG(("Height:     %d", ulHeight));
523    BDBG_MSG(("Frame Rate: %d", ulFrameRate));
524    BDBG_MSG(("Progressive:%s", bProgressive ? "yes" : "no"));
525
526    /* We have cases where 3D mode is not allowed. We are checking the cases
527     * here */
528    if (b3dSource)
529    {
530        if (bJpeg || bAdcCalibration ||
531           ((BVDB_Input_eMfd != eInput) && (BVDB_Input_eComponent != eInput) && (BVDB_Input_eHdmi != eInput)))
532        {
533            BDBG_WRN(("3D source flag set for non-HDMI, non-MFD input, or in modes where 3D is not allowed"));
534            BDBG_WRN(("3D source flag will be forced off in VDB"));
535            b3dSource = false;
536        }
537    }
538
539    /* JPEG Source */
540    if (bJpeg)
541    {
542        return BVDB_SourceGroup_eJpeg2d;
543    }
544
545    /* ADC Calibration */
546    if (bAdcCalibration)
547    {
548        return BVDB_SourceGroup_eAdcCalibration2d;
549    }
550
551    /* Any progressive source from VGA connector is taken as a PC source */
552    if (BVDB_Input_eVga == eInput)
553    {
554        if (bProgressive)
555        {
556            return BVDB_SourceGroup_ePc2d;
557        }
558        else
559        {
560            BDBG_WRN(("A VGA source has interalced flag on. HDMI is forced"));
561            eInput = BVDB_Input_eHdmi;
562        }
563    }
564
565    /* Any PC resolution from HDMI is taken as a PC source */
566    if (BVDB_Input_eHdmi == eInput)
567    {
568        /* PC sources from HDMI */
569        if (BVDB_P_IsPcFormat(ulWidth, ulHeight, bProgressive, astPcFormats))
570        {
571            return BVDB_SourceGroup_ePc2d;
572        }
573    }
574
575    /* Some adjustments for boolean comparison */
576    if (bProgressive) {bProgressive = true;}
577    if (b3dSource)    {b3dSource = true;}
578
579    numEntry = sizeof(astSourceFormats) / sizeof(BVDB_P_SourceFormat);
580    for (i = 0; i < numEntry; i++)
581    {
582        if ((astSourceFormats[i].inputType & eInput) &&
583            (astSourceFormats[i].width >= ulWidth) &&
584            (astSourceFormats[i].height >= ulHeight) &&
585            (astSourceFormats[i].bProgressive == bProgressive) &&
586            (astSourceFormats[i].frameRate >= ulFrameRate) &&
587            (astSourceFormats[i].b3dSource == b3dSource))
588        {
589            if (astSourceFormats[i].eSourceGroup == BVDB_SourceGroup_eWorst)
590            {
591                BDBG_WRN(("No source match found. Worst case source is forced"));
592            }
593            return astSourceFormats[i].eSourceGroup;
594        }
595    }
596
597    /* Shouldn't reach here */
598    BDBG_WRN(("No source match found. Worst case source is forced"));
599    return BVDB_SourceGroup_eWorst;
600}
601
602
603/*******************************************************************************
604 * BVDB_GetVdbEntry - returns a matching usage mode. And Nexus VDB/VDC will
605 * configure BVN based on the retured usage mode.
606 *
607 * Input:  hVdb - VDB handle
608 *         pstUsageMode - usage mode pointer and some of the structure members
609 *                        are used as input
610 *         pstSysConfig - current system configuration
611 * Output: pstUsageMode - usage mode pointer and some of the structure members
612 *                        are used as Output (i.e., to be filled by
613 *                        BVDB_GetVdbEntry())
614 * Return: BERR_Code
615 */
616BERR_Code BVDB_GetVdbEntry
617    (BVDB_Handle                hVdb,
618     BVDB_UsageMode             *pstUsageMode,
619     BVDB_System_Configurations *pstSysConfig)
620{
621    BERR_Code err = BERR_SUCCESS;
622    BVDB_P_Context *pVdb;
623    BVDB_SourceGroup sourceGroup;
624    BVDB_SourceGroup mainSourceToMatch;
625    BVDB_SourceGroup subSourceToMatch;
626    BVDB_P_RtsData tmpUsageMode;
627    bool bMainDispModeMatch;
628    bool bSubDispModeMatch;
629    bool bDontCareMainWinClipSize;
630    bool bDontCareSubWinClipSize;
631    bool bDontCareMain;
632    bool bDontCareSub;
633    bool bUsageModeMatchFound;
634    BVDB_P_BvnTopology * pBvn;
635    uint32_t i;
636
637    pVdb = (BVDB_P_Context *) hVdb;
638
639    /* Sanity checking */
640    BDBG_ASSERT(NULL != pVdb);
641    BDBG_ASSERT(NULL != pstUsageMode);
642    BDBG_ASSERT(NULL != pstSysConfig);
643    BDBG_ASSERT(NULL != pVdb->pRtsConfig);
644    BDBG_ASSERT(NULL != pVdb->pRtsConfig->pUsageMode);
645
646    /* If the current RTS configration doesn't support PIP, PIP window cannot be
647     * used */
648    if (pstUsageMode->eWindow == BVDB_Window_ePip &&
649        !pVdb->pRtsConfig->bPipSupport)
650    {
651        BDBG_ERR(("PIP Window is used for a configuration which doesn't support PIP"));
652        return BERR_TRACE(BERR_INVALID_PARAMETER);
653    }
654
655    /* If the current RTS configration doesn't support Monitor, Monitor window cannot be
656     * used */
657    if (pstUsageMode->eWindow == BVDB_Window_eMonitor &&
658        !pVdb->pRtsConfig->bMonitorSupport)
659    {
660        BDBG_ERR(("Monitor is used for a configuration which doesn't support PIP"));
661        return BERR_TRACE(BERR_INVALID_PARAMETER);
662    }
663
664    bUsageModeMatchFound = false;
665    sourceGroup = pstUsageMode->eInputFormatGroup;
666    BDBG_MSG(("Source = 0x%x for %s window", sourceGroup,
667              pstUsageMode->eWindow == BVDB_Window_eMain ? "Main":
668              pstUsageMode->eWindow == BVDB_Window_ePip ? "Pip" :
669              pstUsageMode->eWindow == BVDB_Window_eMonitor ? "Monitor" : "Invalid"));
670
671
672    /* Just to avoid build warning messages */
673    tmpUsageMode = pVdb->pRtsConfig->pUsageMode[0];
674
675    /* 1. Find main match - group, win, clipping
676     * 2. Find the sec match - group, win, clipping
677     * 3. Use that RTS. The only exception is adcCalibration. If source is
678     *    adc then find rp | pc in pip or vcr */
679    BDBG_MSG(("Window %s: Prev Main Source = 0x%x, Prev Secondary Source = 0x%x, PIP visible = %s\n",
680            pstUsageMode->eWindow == BVDB_Window_eMain ? "main" :
681            pstUsageMode->eWindow == BVDB_Window_ePip ? "pip" : "monitor",
682            pVdb->curUsageMode.main.sourceGroup,
683            pVdb->curUsageMode.sec.sourceGroup,
684            pstSysConfig->bPipVisible ? "Yes" : "No"));
685
686    if (pstUsageMode->eWindow == BVDB_Window_eMain)
687    {
688        /* There are cases where PC sources are forced to be captured as 422 and
689         * vice versa. */
690        if ((pstSysConfig->ePixelMode == BVDB_PixelMode_e444Forced) &&
691            (sourceGroup & BVDB_SourceGroup_RpAll))
692        {
693            if (sourceGroup & BVDB_SourceGroup_Rp2d)
694            {
695                sourceGroup = BVDB_SourceGroup_ePc2d;
696                BDBG_MSG(("444 forced (RP 2D source mapped to PC)"));
697            }
698            else
699            {
700                BDBG_WRN(("RP 3D source cannot be mapped to PC"));
701            }
702        }
703        else if ((pstSysConfig->ePixelMode == BVDB_PixelMode_e422Forced) &&
704                 (sourceGroup & BVDB_SourceGroup_PcAll))
705        {
706            sourceGroup = BVDB_SourceGroup_Rp2d;
707            BDBG_MSG(("422 forced (PC source mapped to 2D RP Progressive)"));
708        }
709
710        /* Now if the given source is PC, but if the display is in 3D, PC
711         * processing cannot be kept because of 444 nature being lost by FRC */
712        if ((pstUsageMode->stDisplay.eOrientation == BVDB_DisplayOrientation_e3d) &&
713            (sourceGroup & BVDB_SourceGroup_PcAll))
714        {
715            sourceGroup = BVDB_SourceGroup_Rp2d;
716            BDBG_MSG(("PC is mapeed to RP because of 3D display mode"));
717        }
718
719        /* If PIP is not supported or no source connected to sec path, do not
720         * check sec source */
721        bDontCareMain = false;
722
723        /* we don't care about the secondary path if PIP is invisible if the
724         * system supports PIP, if the system doesn't support PIP and
725         * Monitor, and if there's no secondary source applied */
726        bDontCareSub  = (!pstSysConfig->bPipVisible && pVdb->pRtsConfig->bPipSupport) ||
727                        (!pVdb->pRtsConfig->bPipSupport && !pVdb->pRtsConfig->bMonitorSupport) ||
728                        (pVdb->curUsageMode.sec.sourceGroup == BVDB_SourceGroup_None);
729
730        /* Do not check clipping and window size for certain cases */
731        bDontCareMainWinClipSize = pVdb->main.bAutomaticAspectRatioBoxMode;
732        bDontCareSubWinClipSize  = bDontCareSub ||
733                                   pVdb->sec.bAutomaticAspectRatioBoxMode;
734
735        mainSourceToMatch = sourceGroup;
736        subSourceToMatch  = pVdb->curUsageMode.sec.sourceGroup;
737    }
738    else
739    {
740        bDontCareMain = (pVdb->curUsageMode.main.sourceGroup == BVDB_SourceGroup_None);
741        bDontCareSub  = false;
742
743        /* Do not check clipping and window size if Automatic Aspect ratio is
744         * used */
745        bDontCareSubWinClipSize  = bDontCareMain ||
746                                   pVdb->sec.bAutomaticAspectRatioBoxMode;
747        bDontCareMainWinClipSize = pVdb->main.bAutomaticAspectRatioBoxMode;
748
749        mainSourceToMatch = pVdb->curUsageMode.main.sourceGroup;
750        subSourceToMatch  = sourceGroup;
751    }
752
753    BDBG_MSG(("Don't care main = %d, Don't care main win/clip size = %d",
754              bDontCareMain, bDontCareMainWinClipSize));
755    BDBG_MSG(("Don't care sec = %d, Don't care sec win/clip size = %d",
756              bDontCareSub, bDontCareSubWinClipSize));
757
758    for (i = 0; i < pVdb->pRtsConfig->usageModeNum; i++)
759    {
760        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)",
761            pVdb->pRtsConfig->pUsageMode[i].id,
762            pVdb->pRtsConfig->ulMainDisplayResolution, pstUsageMode->stDisplay.eResolution,
763            pVdb->pRtsConfig->pUsageMode[i].main.sourceGroup, mainSourceToMatch,
764            pVdb->pRtsConfig->pUsageMode[i].sec.sourceGroup, subSourceToMatch));
765
766        if (pstUsageMode->eWindow == BVDB_Window_eMonitor && pVdb->pRtsConfig->bMonitorSupport)
767        {
768            pVdb->pRtsConfig->ulMainDisplayResolution |=
769                BVDB_OutputResolution_e480i | BVDB_OutputResolution_e576i;
770        }
771
772        if ((pVdb->pRtsConfig->ulMainDisplayResolution & pstUsageMode->stDisplay.eResolution)                  &&
773            (pstUsageMode->stDisplay.eOrientation & pVdb->pRtsConfig->pUsageMode[i].common.displayOrientation) &&
774            (bDontCareMain || (pVdb->pRtsConfig->pUsageMode[i].main.sourceGroup & mainSourceToMatch))          &&
775            (bDontCareSub  || (pVdb->pRtsConfig->pUsageMode[i].sec.sourceGroup & subSourceToMatch)))
776        {
777            /* Now we have main and sec match. Then find the matching display
778             * mode. */
779            bMainDispModeMatch = bDontCareMainWinClipSize                                                   ||
780                ((pVdb->main.winHeight + 1 >= (pVdb->pRtsConfig->pUsageMode[i].main.minWinHeight))          &&
781                 (pVdb->main.winHeight     <= (pVdb->pRtsConfig->pUsageMode[i].main.maxWinHeight + 1))      &&
782                 (pVdb->main.winWidth  + 1 >= (pVdb->pRtsConfig->pUsageMode[i].main.minWinWidth))           &&
783                 (pVdb->main.winWidth      <= (pVdb->pRtsConfig->pUsageMode[i].main.maxWinWidth  + 1))      &&
784                 (pVdb->main.clipHeight    <= (pVdb->pRtsConfig->pUsageMode[i].main.maxClippingHeight + 1)) &&
785                 (pVdb->main.clipWidth     <= (pVdb->pRtsConfig->pUsageMode[i].main.maxClippingWidth  + 1)));
786
787            bSubDispModeMatch = bDontCareSubWinClipSize                                                   ||
788                ((pVdb->sec.winHeight + 1 >= (pVdb->pRtsConfig->pUsageMode[i].sec.minWinHeight))          &&
789                 (pVdb->sec.winHeight     <= (pVdb->pRtsConfig->pUsageMode[i].sec.maxWinHeight + 1))      &&
790                 (pVdb->sec.winWidth  + 1 >= (pVdb->pRtsConfig->pUsageMode[i].sec.minWinWidth))           &&
791                 (pVdb->sec.winWidth      <= (pVdb->pRtsConfig->pUsageMode[i].sec.maxWinWidth  + 1))      &&
792                 (pVdb->sec.clipHeight    <= (pVdb->pRtsConfig->pUsageMode[i].sec.maxClippingHeight + 1)) &&
793                 (pVdb->sec.clipWidth     <= (pVdb->pRtsConfig->pUsageMode[i].sec.maxClippingWidth  + 1)));
794
795            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)\"",
796                pVdb->pRtsConfig->pUsageMode[i].id,
797                bDontCareMainWinClipSize,
798                pVdb->main.winHeight , pVdb->pRtsConfig->pUsageMode[i].main.minWinHeight - 1,
799                pVdb->main.winHeight , pVdb->pRtsConfig->pUsageMode[i].main.maxWinHeight + 1,
800                pVdb->main.winWidth  , pVdb->pRtsConfig->pUsageMode[i].main.minWinWidth  - 1,
801                pVdb->main.winWidth  , pVdb->pRtsConfig->pUsageMode[i].main.maxWinWidth  + 1,
802                pVdb->main.clipHeight, pVdb->pRtsConfig->pUsageMode[i].main.maxClippingHeight + 1,
803                pVdb->main.clipWidth , pVdb->pRtsConfig->pUsageMode[i].main.maxClippingWidth  + 1));
804
805            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)\"",
806                pVdb->pRtsConfig->pUsageMode[i].id,
807                bDontCareSubWinClipSize,
808                pVdb->sec.winHeight , pVdb->pRtsConfig->pUsageMode[i].sec.minWinHeight - 1,
809                pVdb->sec.winHeight , pVdb->pRtsConfig->pUsageMode[i].sec.maxWinHeight + 1,
810                pVdb->sec.winWidth  , pVdb->pRtsConfig->pUsageMode[i].sec.minWinWidth  - 1,
811                pVdb->sec.winWidth  , pVdb->pRtsConfig->pUsageMode[i].sec.maxWinWidth  + 1,
812                pVdb->sec.clipHeight, pVdb->pRtsConfig->pUsageMode[i].sec.maxClippingHeight + 1,
813                pVdb->sec.clipWidth , pVdb->pRtsConfig->pUsageMode[i].sec.maxClippingWidth  + 1));
814
815            BDBG_MSG(("Main disp match = %d, Secondary disp match =%d", bMainDispModeMatch, bSubDispModeMatch));
816            if (bMainDispModeMatch && bSubDispModeMatch)
817            {
818                /* Copy usage mode, but update source group with real ones */
819                tmpUsageMode = pVdb->pRtsConfig->pUsageMode[i];
820
821                BDBG_MSG(("ID \"%d\" is picked", pVdb->pRtsConfig->pUsageMode[i].id));
822
823                if (pstUsageMode->eWindow == BVDB_Window_eMain)
824                {
825                    /* update main source */
826                    tmpUsageMode.main.sourceGroup = sourceGroup;
827
828                    /* and update sec source */
829                    if (bDontCareSub)
830                    {
831                        tmpUsageMode.sec.sourceGroup = BVDB_SourceGroup_None;
832                    }
833                    else
834                    {
835                        tmpUsageMode.sec.sourceGroup = pVdb->curUsageMode.sec.sourceGroup;
836                    }
837                }
838                else
839                {
840                    /* update sec source */
841                    tmpUsageMode.sec.sourceGroup = sourceGroup;
842                    if (bDontCareMain)
843                    {
844                        tmpUsageMode.main.sourceGroup = BVDB_SourceGroup_None;
845                    }
846                    else
847                    {
848                        tmpUsageMode.main.sourceGroup = pVdb->curUsageMode.main.sourceGroup;
849                    }
850                }
851                bUsageModeMatchFound = true;
852                break;
853            }
854        }
855    }
856
857    if (!bUsageModeMatchFound)
858    {
859        BDBG_ERR(("VDB Can't find a match. Video will be muted"));
860        return BERR_TRACE(BERR_INVALID_PARAMETER);
861    }
862
863    /* There's a matching usage mode. Now fill up the Usage Mode */
864    BDBG_MSG(("Matching VDB ID: %d", tmpUsageMode.id));
865
866    pstUsageMode->usageId = tmpUsageMode.id;
867
868    if (pstUsageMode->eWindow == BVDB_Window_eMain)
869    {
870        pBvn = &tmpUsageMode.main;
871    }
872    else
873    {
874        pBvn = &tmpUsageMode.sec;
875    }
876
877    /* Fill in Usage Mode Structure so Nexus can populate relative parameters
878     * to magnum */
879
880    /* Each RTS configuration has a different OSD size to support and it
881     * should be from each configuration context */
882    if (pstUsageMode->eWindow == BVDB_Window_eInvalid)
883    {
884        /* PIP has no OSD, and main OSD will cover it */
885        pstUsageMode->stOsd.ulWidth  = 0;
886        pstUsageMode->stOsd.ulHeight = 0;
887        pstUsageMode->stOsd.ulBpp    = 0;
888    }
889    else if (pstUsageMode->eWindow == BVDB_Window_eMonitor)
890    {
891        pstUsageMode->stOsd = pVdb->pRtsConfig->eVcrOsdResolution;
892    }
893    else
894    {
895        pstUsageMode->stOsd = pVdb->pRtsConfig->eMainOsdResolution;
896    }
897
898    /* e3dComb for composite signal and eOverampling for main path only */
899    if (pstUsageMode->eInput == BVDB_Input_eCvbsSvidIfd)
900    {
901        pstUsageMode->e3dComb = tmpUsageMode.common.b3dcomb;
902        if (pstUsageMode->eWindow == BVDB_Window_eMain)
903        {
904            pstUsageMode->eOversample = true;
905        }
906        else
907        {
908            pstUsageMode->eOversample = false;
909        }
910    }
911    else
912    {
913        pstUsageMode->e3dComb     = false;
914        pstUsageMode->eOversample = false;
915    }
916
917    /* Set DNR based on the usage mode */
918    pstUsageMode->eDnr =  pBvn->bdnr ? BVDB_State_eYes :
919                                       BVDB_State_eNo;
920
921    /* CAP/VFD */
922    pstUsageMode->stCapVfd.eState = pBvn->bcap ? BVDB_State_eYes :
923                                                 BVDB_State_eNo;
924    if (pBvn->bcap)
925    {
926        /* Check if the current RTS configuration support panel reversal */
927        if (pstSysConfig->bPanelReversed && !pVdb->pRtsConfig->bPanelReversalSupport)
928        {
929            BDBG_ERR(("Panel reversal is not supported in this configuration"));
930            return BERR_TRACE(BERR_INVALID_PARAMETER);
931        }
932
933        /* Decide CAP/VFD capture format */
934        if (pstUsageMode->eWindow == BVDB_Window_ePip ||
935            pstUsageMode->eWindow == BVDB_Window_eMonitor)
936        {
937            pstUsageMode->stCapVfd.ePixelFormat = BVDB_PixelFmt_e8Bit422;
938        }
939        else
940        {
941            if (sourceGroup == BVDB_SourceGroup_ePc2d)
942            {
943                pstUsageMode->stCapVfd.ePixelFormat = BVDB_PixelFmt_e10Bit444;
944            }
945            else
946            {
947                pstUsageMode->stCapVfd.ePixelFormat = BVDB_PixelFmt_e10Bit422;
948            }
949        }
950
951        /* Select correct bpp based on the selected capture format */
952        if (pstUsageMode->stCapVfd.ePixelFormat == BVDB_PixelFmt_e10Bit422)
953        {
954            pstUsageMode->stCapVfd.ulReserved = pBvn->c422;
955        }
956        else
957        {
958            pstUsageMode->stCapVfd.ulReserved = pBvn->c444;
959        }
960    }
961    else
962    {
963        pstUsageMode->stCapVfd.ePixelFormat = BVDB_PixelFmt_eInvalid;
964        pstUsageMode->stCapVfd.ulReserved = 0;
965    }
966
967    /* MAD - it actually refers to MCVP in DTV chips, and must be in bypass for
968     * PC processing */
969    pstUsageMode->stMad.eState = (pBvn->bmcvp && (sourceGroup != BVDB_SourceGroup_ePc2d)) ?
970                                 BVDB_State_eYes : BVDB_State_eNo;
971    /* Determine MCVP capture format based on the current RTS configuration */
972    if (pstUsageMode->stMad.eState == BVDB_State_eYes)
973    {
974        pstUsageMode->stMad.eFieldStore  = BVDB_FieldStore_e5Fields;
975        if (pVdb->pRtsConfig->bMcvpCompromise)
976        {
977            pstUsageMode->stMad.ePixelFormat = BVDB_PixelFmt_e8Bit422;
978        }
979        else
980        {
981            pstUsageMode->stMad.ePixelFormat = BVDB_PixelFmt_e10Bit422;
982        }
983        pstUsageMode->stMad.ulReserved   = pBvn->mc;
984    }
985    else
986    {
987        pstUsageMode->stMad.eFieldStore  = BVDB_FieldStore_eNotApplicable;
988        pstUsageMode->stMad.ePixelFormat = BVDB_PixelFmt_eInvalid;
989        pstUsageMode->stMad.ulReserved   = 0;
990    }
991
992    /* PDP - PDP always on */
993    pstUsageMode->stPdp.eState     = BVDB_State_eYes;
994    pstUsageMode->stPdp.ulReserved = tmpUsageMode.common.dc;
995
996    /* FRC - must be in bypass mode for PC processing. Don't need to worry about
997     * 3D display cases because source group is already modified and taken care
998     * of based on 3D display mode above */
999    pstUsageMode->stFrc.eState = (pBvn->bfrc && (sourceGroup != BVDB_SourceGroup_ePc2d)) ?
1000                                 BVDB_State_eYes : BVDB_State_eNo;
1001    /* If a system supports FRC, FRC on/off of each usage mode depends on
1002     * whether it needs PC processing or not */
1003    if (pstUsageMode->stFrc.eState == BVDB_State_eYes)
1004    {
1005        pstUsageMode->stFrc.ulReserved = pBvn->frcc;
1006    }
1007    else
1008    {
1009        pstUsageMode->stFrc.ulReserved = 0;
1010    }
1011
1012    /* CAP-SCL bias and orientation */
1013    pstUsageMode->eSclCapBias = pBvn->eSclCap;
1014
1015#if BVDB_P_VDB_VER <= BVDB_P_VDB_VER_2
1016    /* Need to force CAP-SCL in case of RP 1080p source with full window for VDB
1017     * version <= 2 */
1018    {
1019        bool bMainRpFhdDotByDot;
1020
1021        bMainRpFhdDotByDot = ((pstUsageMode->eWindow == BVDB_Window_eMain)   &&
1022                             ((sourceGroup == BVDB_SourceGroup_Rp_e1080p2d)  ||
1023                              (sourceGroup == BVDB_SourceGroup_Rp_e1080p3d)) &&
1024                              (pVdb->main.winHeight == 100)                  &&
1025                              (pVdb->main.winWidth  == 100));
1026
1027        if (bMainRpFhdDotByDot)
1028        {
1029            pstUsageMode->eSclCapBias = BVDB_SclCapBias_eCapScl;
1030        }
1031    }
1032#endif
1033
1034    /* TODO Make threshold obsolete */
1035    if (pstUsageMode->eSclCapBias == BVDB_SclCapBias_eAuto)
1036    {
1037        pstUsageMode->ulSclCapTolerance = 0;
1038    }
1039    else
1040    {
1041        pstUsageMode->ulSclCapTolerance = BVDB_P_BIG_THRESHOLD;
1042    }
1043
1044    pstUsageMode->pRtsSet = tmpUsageMode.pRtsRegisterTable;
1045    pVdb->curUsageMode    = tmpUsageMode;
1046    /* End of filling in "Usage Mode" */
1047
1048#if BVDB_P_ENABLE_PDP_RR
1049    /* Enable round robin in PDP RD enough bandwidth to cover spike */
1050    if ((err == BERR_SUCCESS) &&
1051        (pstUsageMode->pRtsSet != NULL) &&
1052        (pVdb->pRtsConfig->ulConfigId != 100))
1053    {
1054        uint32_t i;
1055
1056        for (i = 0; i < pstUsageMode->pRtsSet->ulValidTableEntries; i++)
1057        {
1058            /* PDP RD 0 or 1 */
1059            if ((pstUsageMode->pRtsSet->astRts[i].ulId == BVDB_P_CLIENT_ID_BVN_PDP_RD0) ||
1060                (pstUsageMode->pRtsSet->astRts[i].ulId == BVDB_P_CLIENT_ID_BVN_PDP_RD1))
1061            {
1062                pstUsageMode->pRtsSet->astRts[i].ulRegValue |= BVDB_P_CLIENT_INFO_RR_EN;
1063            }
1064        }
1065    }
1066#endif
1067
1068#if BVDB_P_ENABLE_MEM_CLIENT_RR
1069    /* Enable round robin in PDP RD enough bandwidth to cover spike */
1070    if ((err == BERR_SUCCESS) &&
1071        (pstUsageMode->pRtsSet != NULL) &&
1072        (pVdb->pRtsConfig->ulConfigId != 100) &&
1073        (pVdb->pRtsConfig->ulConfigId != 101))
1074    {
1075        uint32_t i;
1076
1077        for (i = 0; i < pstUsageMode->pRtsSet->ulValidTableEntries; i++)
1078        {
1079            if (pstUsageMode->pRtsSet->astRts[i].ulId != BVDB_P_CLIENT_ID_REFRESH)
1080                        {
1081                pstUsageMode->pRtsSet->astRts[i].ulRegValue |= BVDB_P_CLIENT_INFO_RR_EN;
1082                        }
1083        }
1084    }
1085#endif
1086
1087    return BERR_TRACE(err);
1088}
1089
1090
1091/*******************************************************************************
1092 * BVDB_ValidateConfigId - sets RTS configration ID to use. This must be called
1093 * right after VDB Creation.
1094 *
1095 * Input:  hVdb - VDB handle
1096 *         ulConfigId - RTS configuration ID to set
1097 * Output: N/A
1098 * Return: BERR_Code
1099 */
1100BERR_Code BVDB_ValidateConfigId
1101    (BVDB_Handle    hVdb,
1102     const uint32_t ulConfigId)
1103{
1104    BERR_Code err = BERR_SUCCESS;
1105    BVDB_P_Context *pVdb;
1106
1107    pVdb = (BVDB_P_Context *) hVdb;
1108    if (NULL == pVdb)
1109    {
1110        BDBG_ERR(("NULL pointer"));
1111        return BERR_TRACE(BERR_INVALID_PARAMETER);
1112    }
1113
1114    /* Copy RTS configuration context pointer to VDB context */
1115    pVdb->pRtsConfig = BVDB_P_GetRtsConfigInfo(ulConfigId);
1116
1117    if (NULL == pVdb->pRtsConfig)
1118    {
1119        BDBG_ERR(("Can't find RTS configuration %d", ulConfigId));
1120        return BERR_TRACE(err);
1121    }
1122
1123    /* This is to warn a user if an obsolete or a test purpose RTS is used */
1124    if (ulConfigId == 100   ||
1125        ulConfigId == 101   ||
1126        ulConfigId == 23301 ||
1127        ulConfigId == 23302)
1128    {
1129        BDBG_WRN(("RTS Configuration ID %d that you are attempting to use is either obsolete or test-purpose only!", ulConfigId));
1130    }
1131
1132    return BERR_SUCCESS;
1133}
1134
1135
1136/*******************************************************************************
1137 * BVDB_GetFeatures - returns the features of the current RTS configuration.
1138 *                    This function will be extended and exposed as a Nexus API
1139 *                    so application can support new RTS configuration without
1140 *                    modifying application.
1141 *
1142 * Input:  hVdb - VDB hanlde
1143 * Output: pConfigFetures - a pointer poiting to RTS features to return
1144 * Return: BERR_Code
1145 */
1146BERR_Code BVDB_GetFeatures
1147    (BVDB_Handle          hVdb,
1148     BVDB_Config_Features *pConfigFeatures)
1149{
1150    BVDB_P_Context *pVdb;
1151
1152    pVdb = (BVDB_P_Context *) hVdb;
1153    if (NULL == pVdb)
1154    {
1155        BDBG_ERR(("NULL VDB Context pointer"));
1156        return BERR_TRACE(BERR_INVALID_PARAMETER);
1157    }
1158
1159    BDBG_ASSERT(NULL != pVdb->pRtsConfig);
1160    if (pVdb->pRtsConfig->ulConfigId == 0)
1161    {
1162        BDBG_ERR(("RTS configuration is not set\n"));
1163        return BERR_TRACE(BERR_INVALID_PARAMETER);
1164    }
1165
1166    if (NULL == pConfigFeatures)
1167    {
1168        BDBG_ERR(("NULL config feature pointer"));
1169        return BERR_TRACE(BERR_INVALID_PARAMETER);
1170    }
1171
1172    /* Copy the features of the current RTS configuration */
1173    pConfigFeatures->bPipSupport = pVdb->pRtsConfig->bPipSupport;
1174    pConfigFeatures->bMonitorSupport = pVdb->pRtsConfig->bMonitorSupport;
1175    pConfigFeatures->bFrcSupport = pVdb->pRtsConfig->bFrcSupport;
1176    pConfigFeatures->bRtcSupport = pVdb->pRtsConfig->bRtcSupport;
1177    pConfigFeatures->bPanelReversalSupport = pVdb->pRtsConfig->bPanelReversalSupport;
1178    pConfigFeatures->worstPdpBpp = pVdb->pRtsConfig->worstPdpBpp;
1179    pConfigFeatures->maxPipWinHeight = pVdb->pRtsConfig->maxPipWinHeight;
1180    pConfigFeatures->maxPipWinWidth = pVdb->pRtsConfig->maxPipWinWidth;
1181
1182    return BERR_SUCCESS;
1183}
1184
1185
1186/*******************************************************************************
1187 * BVDB_GetMemoryAllocation - get memory allocation of the current RTS
1188 *                            configuration
1189 *
1190 * Input:  configId - RTS configuration ID
1191 *         eWindow - window type such as main, PIP or monitor
1192 *         eInput - input type such as MFD or non-MFD
1193 *         b3dDisplay - true if the system uses 3D panel
1194 * Output: pstHeapSettings - a pointer pointing to Heap configuration
1195 *         pulheapSize - heap size
1196 * Return: BERR_Code
1197 */
1198BERR_Code BVDB_GetMemoryAllocation
1199    (uint32_t           configId,
1200     BVDB_Window        eWindow,
1201     BVDB_Input         eInput,
1202     bool               b3dDisplay,
1203     BVDB_Heap_Settings *pstHeapSettings,
1204     uint32_t           *pulHeapSize)
1205{
1206    BVDB_P_Config_Info *pConfigInfo;
1207    BERR_Code err = BERR_SUCCESS;
1208    uint32_t i, j;
1209    bool bFound = false;
1210    BVDB_P_Config_MemAlloc *pConfigMemAlloc;
1211
1212    BDBG_ASSERT(NULL != pstHeapSettings);
1213    BDBG_ASSERT(NULL != pulHeapSize);
1214
1215    BDBG_MSG(("3D mode = %d VDC Heap to select", b3dDisplay));
1216
1217    /* Use a different VDC heap size depending on display type because 3D TV requires
1218     * almost 2x memory footprint compared to 2D TV and memory footrprint for 2D TV
1219     * can be reduced by half by choosing VDC heap size based on display type */
1220    pConfigInfo = BVDB_P_GetRtsConfigInfo(configId);
1221    pConfigMemAlloc = b3dDisplay ? pConfigInfo->p3dVdcHeap :
1222                                   pConfigInfo->p2dVdcHeap;
1223
1224    if (NULL == pConfigMemAlloc)
1225    {
1226        err = BERR_INVALID_PARAMETER;
1227        BDBG_ERR(("RTS Config %% doesn't support %s", configId, b3dDisplay ? "3D memory" : "2D memory"));
1228        return BERR_TRACE(err);
1229    }
1230
1231    /* Search for window */
1232    for (i = 0; i < BVDB_P_NUM_WINDOW_HEAPS; i++)
1233    {
1234        if (eWindow == pConfigMemAlloc[i].eWindow)
1235        {
1236            bFound = true;
1237            break;
1238        }
1239    }
1240
1241    if (!bFound)
1242    {
1243        err = BERR_INVALID_PARAMETER;
1244        BDBG_ERR(("Invalid window type, or VDC corresponding to the given widnow is not found"));
1245        return BERR_TRACE(err);
1246    }
1247
1248    /* Input type must be valid */
1249    BDBG_ASSERT(eInput != BVDB_Input_eInvalid);
1250
1251    if (eInput != BVDB_Input_eMfd)
1252    {
1253        /* Force all valid non-MPEG inputs to make search simpler */
1254        eInput = BVDB_Input_eComponent;
1255    }
1256
1257    if (eWindow == BVDB_Window_eMain)
1258    {
1259        BDBG_MSG(("Found MAIN window"));
1260        bFound = false;
1261
1262        /* Search for input. Is it MPEG or no? */
1263        for (j = 0; j < 2; j++)
1264        {
1265            if (eInput == pConfigMemAlloc[i + j].eInput)
1266            {
1267                *pstHeapSettings = pConfigMemAlloc[i + j].stHeapSettings;
1268                *pulHeapSize = pConfigMemAlloc[i + j].ulHeapSize;
1269                bFound = true;
1270                break;
1271            }
1272        }
1273    }
1274    else /* PIP or Monitor */
1275    {
1276        *pstHeapSettings = pConfigMemAlloc[i].stHeapSettings;
1277        *pulHeapSize = pConfigMemAlloc[i].ulHeapSize;
1278    }
1279
1280    return BERR_TRACE(err);
1281}
1282
1283
1284
1285/*******************************************************************************
1286 * BVDB_SetVideoDisplayMode - sets window size and clipping
1287 *
1288 * Input:  hVdb - VDB handle
1289 *         pstDisplay - a pointer pointing to current display configuration
1290 *         eWindow - current window type such as main, PIP, monitor
1291 *         ulSrcHeight - source height
1292 *         ulSrcWidth - source width
1293 *         ulSrcHeightClipAmount - source height clip
1294 *         ulSrcWidthClipAmount - source width clip
1295 *         ulDestHeight - window height
1296 *         ulDestWidth - window width
1297 *         bAutomaticAspectRatioBoxMode - true if automatic aspect ratio box
1298 *                                        mode is used
1299 * Output: N/A
1300 * Return: BERR_Code
1301 */
1302BERR_Code BVDB_SetVideoDisplayMode
1303    (BVDB_Handle        hVdb,
1304     const BVDB_Display *pstDisplay,
1305     const BVDB_Window  eWindow,
1306     const uint32_t     ulSrcHeight,
1307     const uint32_t     ulSrcWidth,
1308     const uint32_t     ulSrcHeightClipAmount,
1309     const uint32_t     ulSrcWidthClipAmount,
1310     const uint32_t     ulDestHeight,
1311     const uint32_t     ulDestWidth,
1312     const bool         bAutomaticAspectRatioBoxMode)
1313{
1314    BERR_Code      err = BERR_SUCCESS;
1315    BVDB_P_Context *pVdb;
1316    uint32_t       ulHeightClipAmount, ulWidthClipAmount;
1317    uint32_t       ulDisplayHeight, ulDisplayWidth;
1318
1319    pVdb = (BVDB_P_Context *) hVdb;
1320    if (NULL == pVdb)
1321    {
1322        BDBG_ERR(("NULL pointer"));
1323        return BERR_TRACE(BERR_INVALID_PARAMETER);
1324    }
1325
1326    if (NULL == pstDisplay)
1327    {
1328        BDBG_ERR(("NULL Display pointer"));
1329        return BERR_TRACE(BERR_INVALID_PARAMETER);
1330    }
1331
1332    /* Get display panel info */
1333    err = BVDB_P_GetDisplaySize(pstDisplay->eResolution, &ulDisplayHeight, &ulDisplayWidth);
1334    if (BERR_SUCCESS != err)
1335    {
1336        return BERR_TRACE(err);
1337    }
1338
1339    /* Get clip amount percentage */
1340    ulHeightClipAmount = (ulSrcHeightClipAmount * 100) / ulSrcHeight;
1341    ulWidthClipAmount  = (ulSrcWidthClipAmount * 100) / ulSrcWidth;
1342
1343    if (eWindow == BVDB_Window_eMain)
1344    {
1345        pVdb->main.clipHeight = BVDB_P_MIN(ulHeightClipAmount, 100);
1346        pVdb->main.clipWidth  = BVDB_P_MIN(ulWidthClipAmount, 100);
1347        pVdb->main.winHeight  = BVDB_P_MIN((ulDestHeight * 100) / ulDisplayHeight, 100);
1348        pVdb->main.winWidth   = BVDB_P_MIN((ulDestWidth * 100)  / ulDisplayWidth, 100);
1349        pVdb->main.bAutomaticAspectRatioBoxMode = bAutomaticAspectRatioBoxMode;
1350    }
1351    else
1352    {
1353        pVdb->sec.clipHeight = BVDB_P_MIN(ulHeightClipAmount, 100);
1354        pVdb->sec.clipWidth  = BVDB_P_MIN(ulWidthClipAmount, 100);
1355        pVdb->sec.winHeight  = BVDB_P_MIN((ulDestHeight * 100) / ulDisplayHeight, 100);
1356        pVdb->sec.winWidth   = BVDB_P_MIN((ulDestWidth * 100)  / ulDisplayWidth, 100);
1357        pVdb->sec.bAutomaticAspectRatioBoxMode = bAutomaticAspectRatioBoxMode;
1358    }
1359
1360    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",
1361        eWindow == BVDB_Window_eMain ? "main" :
1362        eWindow == BVDB_Window_ePip  ? "pip"  : "monitor",
1363        ulDisplayWidth,
1364        ulDisplayHeight,
1365        ulSrcWidth,
1366        ulSrcHeight,
1367        ulSrcWidthClipAmount,
1368        ulSrcHeightClipAmount,
1369        ulDestWidth,
1370        ulDestHeight,
1371        bAutomaticAspectRatioBoxMode ? "On" : "Off"));
1372
1373    return BERR_TRACE(err);
1374}
1375
Note: See TracBrowser for help on using the repository browser.