1 //<MStar Software>
2 //******************************************************************************
3 // MStar Software
4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved.
5 // All software, firmware and related documentation herein ("MStar Software") are
6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by
7 // law, including, but not limited to, copyright law and international treaties.
8 // Any use, modification, reproduction, retransmission, or republication of all
9 // or part of MStar Software is expressly prohibited, unless prior written
10 // permission has been granted by MStar.
11 //
12 // By accessing, browsing and/or using MStar Software, you acknowledge that you
13 // have read, understood, and agree, to be bound by below terms ("Terms") and to
14 // comply with all applicable laws and regulations:
15 //
16 // 1. MStar shall retain any and all right, ownership and interest to MStar
17 // Software and any modification/derivatives thereof.
18 // No right, ownership, or interest to MStar Software and any
19 // modification/derivatives thereof is transferred to you under Terms.
20 //
21 // 2. You understand that MStar Software might include, incorporate or be
22 // supplied together with third party`s software and the use of MStar
23 // Software may require additional licenses from third parties.
24 // Therefore, you hereby agree it is your sole responsibility to separately
25 // obtain any and all third party right and license necessary for your use of
26 // such third party`s software.
27 //
28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as
29 // MStar`s confidential information and you agree to keep MStar`s
30 // confidential information in strictest confidence and not disclose to any
31 // third party.
32 //
33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any
34 // kind. Any warranties are hereby expressly disclaimed by MStar, including
35 // without limitation, any warranties of merchantability, non-infringement of
36 // intellectual property rights, fitness for a particular purpose, error free
37 // and in conformity with any international standard. You agree to waive any
38 // claim against MStar for any loss, damage, cost or expense that you may
39 // incur related to your use of MStar Software.
40 // In no event shall MStar be liable for any direct, indirect, incidental or
41 // consequential damages, including without limitation, lost of profit or
42 // revenues, lost or damage of data, and unauthorized system use.
43 // You agree that this Section 4 shall still apply without being affected
44 // even if MStar Software has been modified by MStar in accordance with your
45 // request or instruction for your use, except otherwise agreed by both
46 // parties in writing.
47 //
48 // 5. If requested, MStar may from time to time provide technical supports or
49 // services in relation with MStar Software to you for your use of
50 // MStar Software in conjunction with your or your customer`s product
51 // ("Services").
52 // You understand and agree that, except otherwise agreed by both parties in
53 // writing, Services are provided on an "AS IS" basis and the warranty
54 // disclaimer set forth in Section 4 above shall apply.
55 //
56 // 6. Nothing contained herein shall be construed as by implication, estoppels
57 // or otherwise:
58 // (a) conferring any license or right to use MStar name, trademark, service
59 // mark, symbol or any other identification;
60 // (b) obligating MStar or any of its affiliates to furnish any person,
61 // including without limitation, you and your customers, any assistance
62 // of any kind whatsoever, or any information; or
63 // (c) conferring any license or right under any intellectual property right.
64 //
65 // 7. These terms shall be governed by and construed in accordance with the laws
66 // of Taiwan, R.O.C., excluding its conflict of law rules.
67 // Any and all dispute arising out hereof or related hereto shall be finally
68 // settled by arbitration referred to the Chinese Arbitration Association,
69 // Taipei in accordance with the ROC Arbitration Law and the Arbitration
70 // Rules of the Association by three (3) arbitrators appointed in accordance
71 // with the said Rules.
72 // The place of arbitration shall be in Taipei, Taiwan and the language shall
73 // be English.
74 // The arbitration award shall be final and binding to both parties.
75 //
76 //******************************************************************************
77 //<MStar Software>
78 ////////////////////////////////////////////////////////////////////////////////
79 //
80 // Copyright (c) 2008-2009 MStar Semiconductor, Inc.
81 // All rights reserved.
82 //
83 // Unless otherwise stipulated in writing, any and all information contained
84 // herein regardless in any format shall remain the sole proprietary of
85 // MStar Semiconductor Inc. and be kept in strict confidence
86 // ("MStar Confidential Information") by the recipient.
87 // Any unauthorized act including without limitation unauthorized disclosure,
88 // copying, use, reproduction, sale, distribution, modification, disassembling,
89 // reverse engineering and compiling of the contents of MStar Confidential
90 // Information is unlawful and strictly prohibited. MStar hereby reserves the
91 // rights to any and all damages, losses, costs and expenses resulting therefrom.
92 //
93 ////////////////////////////////////////////////////////////////////////////////
94 //==============================================================================
95 // [mhal_sc.c]
96 // Date: 20081203
97 // Descriptions: Add a new layer for HW setting
98 //==============================================================================
99 #define MHAL_PIP_C
100
101 #include "MsCommon.h"
102 #include "mhal_xc_chip_config.h"
103 #include "utopia.h"
104 #include "utopia_dapi.h"
105 #include "drvXC_IOPort.h"
106 #include "apiXC.h"
107 #include "apiXC_PCMonitor.h"
108 #include "xc_hwreg_utility2.h"
109 #include "hwreg_sc.h"
110 #include "drv_sc_menuload.h"
111 #include "mvideo_context.h"
112 #include "drv_sc_ip.h"
113 #include "mhal_sc.h"
114
115 #include "drv_sc_display.h"
116 #include "drv_sc_isr.h"
117 #include "apiXC_Adc.h"
118 #include "apiXC_ModeParse.h"
119 #include "apiXC_Auto.h"
120 #include "drvXC_HDMI_if.h"
121 #include "mvideo_context.h"
122 #if (LD_ENABLE==1)
123 #include "mdrv_ld.h"
124 #include "mdrv_ldalgo.h"
125 #endif
126 #include "mdrv_sc_3d.h"
127 #include "drvXC_ADC_Internal.h"
128 #if FRC_INSIDE
129 #include "mdrv_frc.h"
130 #include "mhal_frc.h"
131 #endif
132 #include "XC_private.h"
133
134
135 //==============================================================================
Hal_SC_Sub_SetDisplayWindow_burst(void * pInstance,MS_WINDOW_TYPE * pstDispWin)136 void Hal_SC_Sub_SetDisplayWindow_burst(void *pInstance, MS_WINDOW_TYPE *pstDispWin)
137 {
138 MS_U16 u16extra_req;
139 XC_INSTANCE_PRIVATE *psXCInstPri = NULL;
140 UtopiaInstanceGetPrivate(pInstance, (void**)&psXCInstPri);
141 _MLOAD_ENTRY(pInstance);
142
143 // When Main is foreground, sub is background, extra must enable.
144
145 u16extra_req = 0x01;
146 MS_U16 DispWinEnd = pstDispWin->x + pstDispWin->width-1 ;
147
148 if(Hal_SC_is_extra_req_en(pInstance, NULL, NULL , &pstDispWin->x , &DispWinEnd))
149 {
150 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK20_11_L, BIT(15), BIT(15));
151
152 u16extra_req = u16extra_req | 0x8000;
153 }
154
155 //this is moved outside this function to mdrv_sc_pip.c
156 //MApi_XC_MLoad_WriteCmd(REG_SC_BK20_10_L, (TRUE<<1), BIT(1));
157
158 // HW PIP architeucture
159 // Becasue BK3_02[8] and BK20_11[15] can not enable toghter, otherwise garbage will be showed,
160 // we need to use BK12_47[0] to instead. And the default value of BK3_02[8] is 1. So, we need
161 // to set it to 0 in this function.
162 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK20_11_L, u16extra_req , 0x800F);
163 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK03_02_L, 0, 0x0080);
164
165 #if PIP_PATCH_USING_SC1_MAIN_AS_SC0_SUB
166 #if (HW_DESIGN_4K2K_VER == 6) // For Manhattan, FSC+FRC
167 MS_U16 u16DsipX = (pstDispWin->x + 1)&~1; // Hstart need to be even
168
169 XC_RESOURCE_PRIVATE* pXCResourcePrivate = NULL;
170 UtopiaResourceGetPrivate(g_pXCResource[_XC_SELECT_INTERNAL_VARIABLE(psXCInstPri->u32DeviceID)],(void**)(&pXCResourcePrivate));
171 #endif
172 if (psXCInstPri->u32DeviceID == 0)
173 {
174 //Display window
175 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK0F_07_L, pstDispWin->x,0xFFFF); // Display H start
176 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK0F_08_L, pstDispWin->width + pstDispWin->x - 1,0xFFFF); // Display H end
177 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK0F_09_L, pstDispWin->y,0xFFFF); // Display V start
178 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK0F_0A_L, pstDispWin->height + pstDispWin->y - 1,0xFFFF); // Display V end
179 //when sc0 sub enable,should set fsc sub de window
180 if(pXCResourcePrivate->stdrvXC_MVideo_Context.g_bFSCEnabled)
181 {
182 if(MHal_FRC_IsFHDToFSC(pInstance,MAIN_WINDOW))
183 {
184 u16DsipX = (pstDispWin->x/2 + 1)&~1;
185 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK68_10_L, u16DsipX, 0x3FFF);
186 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK68_11_L, pstDispWin->width/2 + u16DsipX - 1, 0x3FFF);
187 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK68_12_L, pstDispWin->y/2, 0x1FFF);
188 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK68_13_L, pstDispWin->height/2 + pstDispWin->y/2 - 1, 0x1FFF);
189 }
190 else
191 {
192 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK68_10_L, u16DsipX, 0x3FFF);
193 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK68_11_L, pstDispWin->width + u16DsipX - 1, 0x3FFF);
194 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK68_12_L, pstDispWin->y, 0x1FFF);
195 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK68_13_L, pstDispWin->height + pstDispWin->y - 1, 0x1FFF);
196 }
197 }
198 }
199 else
200 {
201 //FIX ME:review follow HW_DESIGN_4K2K_VER = 6 rule
202 MS_U16 u16HDEStart = SC_R2BYTE(0, REG_SC_BK10_04_L);
203 //Display window
204 MDrv_XC_MLoad_WriteCmd(g_pDevice0Instance, REG_SC_BK0F_07_L, pstDispWin->x,0xFFFF); // Display H start
205 MDrv_XC_MLoad_WriteCmd(g_pDevice0Instance, REG_SC_BK0F_08_L, pstDispWin->width + pstDispWin->x - 1,0xFFFF); // Display H end
206 MDrv_XC_MLoad_WriteCmd(g_pDevice0Instance, REG_SC_BK0F_09_L, pstDispWin->y,0xFFFF); // Display V start
207 MDrv_XC_MLoad_WriteCmd(g_pDevice0Instance, REG_SC_BK0F_0A_L, pstDispWin->height + pstDispWin->y - 1,0xFFFF); // Display V end
208
209 //Display window
210 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK10_08_L, u16HDEStart/2,VOP_DISPLAY_HSTART_MASK);//temp solution(+90)
211 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK10_09_L, (u16HDEStart/2+ pstDispWin->width - 1),VOP_DISPLAY_HEND_MASK);
212
213 // Maxim: Copy MDE to FDE for SC1 case
214 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK10_04_L, u16HDEStart/2,VOP_DISPLAY_HSTART_MASK);//temp solution(+90)
215 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK10_05_L, (u16HDEStart/2+ pstDispWin->width - 1),VOP_DISPLAY_HEND_MASK);
216
217 if (SC_R2BYTEMSK(0, REG_SC_BK68_50_L, BIT(3)) == 0)
218 {
219 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK10_0A_L, pstDispWin->y - 1,VOP_DISPLAY_VSTART_MASK);
220 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK10_0B_L, pstDispWin->height + pstDispWin->y - 1,VOP_DISPLAY_VEND_MASK);
221
222 // Maxim: Copy MDE to FDE for SC1 case
223 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK10_06_L, pstDispWin->y - 1,VOP_DISPLAY_VSTART_MASK);
224 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK10_07_L, pstDispWin->height + pstDispWin->y - 1,VOP_DISPLAY_VEND_MASK);
225 }
226 else
227 {
228 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK10_0A_L, pstDispWin->y,VOP_DISPLAY_VSTART_MASK);
229 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK10_0B_L, pstDispWin->height + pstDispWin->y - 1,VOP_DISPLAY_VEND_MASK);
230
231 // Maxim: Copy MDE to FDE for SC1 case
232 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK10_06_L, pstDispWin->y,VOP_DISPLAY_VSTART_MASK);
233 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK10_07_L, pstDispWin->height + pstDispWin->y - 1,VOP_DISPLAY_VEND_MASK);
234 }
235 }
236 #else
237 //Display window
238 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK0F_07_L, pstDispWin->x, 0xFFFF); // Display H start
239 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK0F_08_L, pstDispWin->width + pstDispWin->x - 1, 0xFFFF); // Display H end
240 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK0F_09_L, pstDispWin->y, 0xFFFF); // Display V start
241 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK0F_0A_L, pstDispWin->height + pstDispWin->y - 1, 0xFFFF); // Display V end
242 #endif
243 MDrv_XC_MLoad_Fire(pInstance, TRUE);
244 _MLOAD_RETURN(pInstance);
245 }
246
Hal_SC_Sub_SetDisplayWindow(void * pInstance,MS_WINDOW_TYPE * pstDispWin)247 void Hal_SC_Sub_SetDisplayWindow(void *pInstance, MS_WINDOW_TYPE *pstDispWin)
248 {
249 //SC_W2BYTEMSK( REG_SC_BK20_10_L, (TRUE<<1), BIT(1));
250 XC_INSTANCE_PRIVATE *psXCInstPri = NULL;
251 UtopiaInstanceGetPrivate(pInstance, (void**)&psXCInstPri);
252 #if PIP_PATCH_USING_SC1_MAIN_AS_SC0_SUB
253 #if (HW_DESIGN_4K2K_VER == 6) // For Manhattan, FSC+FRC
254 MS_U16 u16DsipX = (pstDispWin->x+1)&~1; // Hstart need to be even
255
256 XC_RESOURCE_PRIVATE* pXCResourcePrivate = NULL;
257 UtopiaResourceGetPrivate(g_pXCResource[_XC_SELECT_INTERNAL_VARIABLE(psXCInstPri->u32DeviceID)],(void**)(&pXCResourcePrivate));
258 #endif
259 //FIX ME:review follow HW_DESIGN_4K2K_VER = 6 rule
260 //Display window
261 SC_W2BYTE(0, REG_SC_BK0F_07_L, pstDispWin->x); // Display H start
262 SC_W2BYTE(0, REG_SC_BK0F_08_L, pstDispWin->width + pstDispWin->x - 1); // Display H end
263 SC_W2BYTE(0, REG_SC_BK0F_09_L, pstDispWin->y); // Display V start
264 SC_W2BYTE(0, REG_SC_BK0F_0A_L, pstDispWin->height + pstDispWin->y - 1); // Display V end
265 if (psXCInstPri->u32DeviceID == 1)
266 {
267 MS_U16 u16HDEStart = SC_R2BYTE(0, REG_SC_BK10_04_L);
268 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK10_08_L, u16HDEStart/2);//temp solution(+90)
269 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK10_09_L, (u16HDEStart/2+ pstDispWin->width - 1));
270
271 // Maxim: Copy MDE to FDE for SC1 case
272 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK10_04_L, u16HDEStart/2);//temp solution(+90)
273 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK10_05_L, (u16HDEStart/2+ pstDispWin->width - 1));
274
275 if (SC_R2BYTEMSK(0, REG_SC_BK68_50_L, BIT(3)) == 0)
276 {
277 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK10_0A_L, pstDispWin->y - 1);
278 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK10_0B_L, pstDispWin->height + pstDispWin->y - 1);
279
280 // Maxim: Copy MDE to FDE for SC1 case
281 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK10_06_L, pstDispWin->y - 1);
282 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK10_07_L, pstDispWin->height + pstDispWin->y - 1);
283 }
284 else
285 {
286 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK10_0A_L, pstDispWin->y);
287 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK10_0B_L, pstDispWin->height + pstDispWin->y - 1);
288
289 // Maxim: Copy MDE to FDE for SC1 case
290 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK10_06_L, pstDispWin->y);
291 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK10_07_L, pstDispWin->height + pstDispWin->y - 1);
292 }
293 }
294 else if(psXCInstPri->u32DeviceID == 0)
295 {
296 //when sc0 sub enable,should set fsc sub de window
297 if(pXCResourcePrivate->stdrvXC_MVideo_Context.g_bFSCEnabled)
298 {
299 if(MHal_FRC_IsFHDToFSC(pInstance,MAIN_WINDOW))
300 {
301 u16DsipX = (pstDispWin->x/2+1)&~1;
302 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK68_10_L, u16DsipX);
303 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK68_11_L, pstDispWin->width/2 + u16DsipX - 1);
304 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK68_12_L, pstDispWin->y/2);
305 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK68_13_L, pstDispWin->height/2 + pstDispWin->y/2 - 1);
306 }
307 else
308 {
309 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK68_10_L, u16DsipX);
310 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK68_11_L, pstDispWin->width + u16DsipX - 1);
311 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK68_12_L, pstDispWin->y);
312 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK68_13_L, pstDispWin->height + pstDispWin->y - 1);
313 }
314 }
315 }
316 #else
317 //Display window
318 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK0F_07_L, pstDispWin->x); // Display H start
319 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK0F_08_L, pstDispWin->width + pstDispWin->x - 1); // Display H end
320 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK0F_09_L, pstDispWin->y); // Display V start
321 SC_W2BYTE(psXCInstPri->u32DeviceID, REG_SC_BK0F_0A_L, pstDispWin->height + pstDispWin->y - 1); // Display V end
322 #endif
323 }
324
325
Hal_SC_subwindow_disable_burst(void * pInstance)326 void Hal_SC_subwindow_disable_burst(void *pInstance)
327 {
328 XC_INSTANCE_PRIVATE *psXCInstPri = NULL;
329 UtopiaInstanceGetPrivate(pInstance, (void**)&psXCInstPri);
330 _MLOAD_ENTRY(pInstance);
331 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK20_10_L, (FALSE<<1), BIT(1));
332 #if PIP_PATCH_USING_SC1_MAIN_AS_SC0_SUB
333 //FIX ME:temp tgen setting
334 MDrv_XC_MLoad_WriteCmd(g_pDevice0Instance, REG_SC_BK68_40_L, 0x00, BIT(4));
335 #endif
336 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK58_10_L, 0x0, BIT(0));
337 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK20_11_L, 0x0000 , 0x800F);
338
339 MDrv_XC_MLoad_Fire(pInstance, TRUE);
340 _MLOAD_RETURN(pInstance);
341 }
342
Hal_SC_subwindow_disable(void * pInstance)343 void Hal_SC_subwindow_disable(void *pInstance)
344 {
345 XC_INSTANCE_PRIVATE *psXCInstPri = NULL;
346 UtopiaInstanceGetPrivate(pInstance, (void**)&psXCInstPri);
347 SC_W2BYTEMSK(psXCInstPri->u32DeviceID, REG_SC_BK20_10_L, (FALSE<<1), BIT(1));
348 #if PIP_PATCH_USING_SC1_MAIN_AS_SC0_SUB
349 //FIX ME:temp tgen setting
350 SC_W2BYTEMSK(0, REG_SC_BK68_40_L, 0x00, BIT(4));
351 #endif
352 SC_W2BYTEMSK(psXCInstPri->u32DeviceID, REG_SC_BK58_10_L, 0x0, BIT(0));
353 SC_W2BYTEMSK(psXCInstPri->u32DeviceID, REG_SC_BK20_11_L, 0x0000 , 0x800F);
354 }
355
Hal_SC_Is_subwindow_enable(void * pInstance)356 MS_BOOL Hal_SC_Is_subwindow_enable(void *pInstance)
357 {
358 XC_INSTANCE_PRIVATE *psXCInstPri = NULL;
359 UtopiaInstanceGetPrivate(pInstance, (void**)&psXCInstPri);
360 XC_RESOURCE_PRIVATE* pXCResourcePrivate = NULL;
361 UtopiaResourceGetPrivate(g_pXCResource[_XC_SELECT_INTERNAL_VARIABLE(psXCInstPri->u32DeviceID)],(void**)(&pXCResourcePrivate));
362
363 #if PIP_PATCH_USING_SC1_MAIN_AS_SC0_SUB
364 if(!MDrv_XC_GetMWEStatus(pInstance)
365 && (E_XC_3D_OUTPUT_MODE_NONE == pXCResourcePrivate->stdrvXC_3D._eOutput3DMode))
366 {
367 return (SC_R2BYTEMSK(0, REG_SC_BK68_40_L, BIT(4)) == 0)? FALSE:TRUE;
368 }
369 else
370 {
371 return (SC_R2BYTEMSK( psXCInstPri->u32DeviceID, REG_SC_BK20_10_L, BIT(1)) == 0)? FALSE:TRUE;
372 }
373 #else
374 return (SC_R2BYTEMSK( psXCInstPri->u32DeviceID, REG_SC_BK20_10_L, BIT(1)) == 0)? FALSE:TRUE;
375 #endif
376 }
377
378
Hal_SC_set_border_format(void * pInstance,MS_U8 u8Left,MS_U8 u8Right,MS_U8 u8Up,MS_U8 u8Down,MS_U8 u8color,SCALER_WIN eWindow)379 void Hal_SC_set_border_format(void *pInstance, MS_U8 u8Left, MS_U8 u8Right, MS_U8 u8Up, MS_U8 u8Down, MS_U8 u8color, SCALER_WIN eWindow )
380 {
381 XC_INSTANCE_PRIVATE *psXCInstPri = NULL;
382 UtopiaInstanceGetPrivate(pInstance, (void**)&psXCInstPri);
383 if( eWindow == MAIN_WINDOW && psXCInstPri->u32DeviceID == 0)
384 {
385 SC_W2BYTEMSK( psXCInstPri->u32DeviceID, REG_SC_BK0F_02_L, ((MS_U16)u8Left<<8), 0xFF00);
386 SC_W2BYTEMSK( psXCInstPri->u32DeviceID, REG_SC_BK0F_03_L, ((MS_U16)u8Right<<8), 0xFF00);
387 SC_W2BYTEMSK( psXCInstPri->u32DeviceID, REG_SC_BK0F_04_L, ((MS_U16)u8Up<<8), 0xFF00);
388 SC_W2BYTEMSK( psXCInstPri->u32DeviceID, REG_SC_BK0F_05_L, ((MS_U16)u8Down<<8), 0xFF00);
389
390 SC_W2BYTEMSK( psXCInstPri->u32DeviceID, REG_SC_BK10_24_L, ((MS_U16)u8color<<8), 0xFF00);
391 }
392 else
393 {
394 SC_W2BYTEMSK( 0, REG_SC_BK0F_02_L, (MS_U16)u8Left, 0x00FF);
395 SC_W2BYTEMSK( 0, REG_SC_BK0F_03_L, (MS_U16)u8Right, 0x00FF);
396 SC_W2BYTEMSK( 0, REG_SC_BK0F_04_L, (MS_U16)u8Up, 0x00FF);
397 SC_W2BYTEMSK( 0, REG_SC_BK0F_05_L, (MS_U16)u8Down, 0x00FF);
398
399 SC_W2BYTEMSK( 0, REG_SC_BK0F_17_L, (MS_U16)u8color, 0x00FF);
400 }
401 }
402
Hal_SC_border_enable(void * pInstance,MS_BOOL bEnable,SCALER_WIN eWindow)403 void Hal_SC_border_enable(void *pInstance, MS_BOOL bEnable, SCALER_WIN eWindow )
404 {
405 XC_INSTANCE_PRIVATE *psXCInstPri = NULL;
406 UtopiaInstanceGetPrivate(pInstance, (void**)&psXCInstPri);
407 if( eWindow == MAIN_WINDOW && psXCInstPri->u32DeviceID == 0)
408 {
409 SC_W2BYTEMSK( psXCInstPri->u32DeviceID, REG_SC_BK10_19_L, (bEnable<<2), BIT(2));
410 }
411 else
412 {
413 SC_W2BYTEMSK( 0, REG_SC_BK0F_01_L, (bEnable<<7), BIT(7));
414 }
415 }
416
Hal_SC_set_Zorder_main_first(void * pInstance,MS_BOOL bMainFirst)417 void Hal_SC_set_Zorder_main_first(void *pInstance, MS_BOOL bMainFirst)
418 {
419 XC_INSTANCE_PRIVATE *psXCInstPri = NULL;
420 UtopiaInstanceGetPrivate(pInstance, (void**)&psXCInstPri);
421 SC_W2BYTEMSK( psXCInstPri->u32DeviceID, REG_SC_BK20_10_L, (bMainFirst << 8), BIT(8) );
422
423 if (bMainFirst)
424 SC_W2BYTEMSK( psXCInstPri->u32DeviceID, REG_SC_BK19_14_L, BIT(3) , BIT(3) );
425 else
426 SC_W2BYTEMSK( psXCInstPri->u32DeviceID, REG_SC_BK19_14_L, 0x00 , BIT(3) );
427 }
428
Hal_SC_set_Zorder_main_first_burst(void * pInstance,MS_BOOL bMainFirst)429 void Hal_SC_set_Zorder_main_first_burst(void *pInstance, MS_BOOL bMainFirst)
430 {
431
432 _MLOAD_ENTRY(pInstance);
433
434 MDrv_XC_MLoad_WriteCmd( pInstance, REG_SC_BK20_10_L, (bMainFirst << 8), BIT(8) );
435
436 if (bMainFirst)
437 MDrv_XC_MLoad_WriteCmd( pInstance, REG_SC_BK19_14_L, BIT(3) , BIT(3) );
438 else
439 MDrv_XC_MLoad_WriteCmd( pInstance, REG_SC_BK19_14_L, 0x00 , BIT(3) );
440
441 MDrv_XC_MLoad_Fire(pInstance, TRUE);
442
443 _MLOAD_RETURN(pInstance);
444 }
445
Hal_SC_SetPIP_FRC(void * pInstance,MS_BOOL enable,MS_U8 u8IgonreLinesNum)446 void Hal_SC_SetPIP_FRC(void *pInstance, MS_BOOL enable, MS_U8 u8IgonreLinesNum)
447 {
448 // Enable FRC for Subwindow
449 SC_W2BYTEMSK(0, REG_SC_BK12_45_L, ( enable ? BIT(3):0 ), BIT(3));
450
451 // Set Threadhold
452 SC_W2BYTEMSK(0, REG_SC_BK12_45_L, u8IgonreLinesNum, BIT(2)|BIT(1)|BIT(0));
453 }
454
Hal_SC_set_Zextra_y_half_burst(void * pInstance,MS_BOOL bInterlace)455 void Hal_SC_set_Zextra_y_half_burst(void *pInstance, MS_BOOL bInterlace)
456 {
457 _MLOAD_ENTRY(pInstance);
458
459 if (bInterlace)
460 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK20_11_L, BIT(13), BIT(13));
461 else
462 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK20_11_L, 0, BIT(13));
463
464 MDrv_XC_MLoad_Fire(pInstance, TRUE);
465
466 _MLOAD_RETURN(pInstance);
467 }
468
Hal_SC_set_Zextra_y_half(void * pInstance,MS_BOOL bInterlace)469 void Hal_SC_set_Zextra_y_half(void *pInstance, MS_BOOL bInterlace)
470 {
471 XC_INSTANCE_PRIVATE *psXCInstPri = NULL;
472 UtopiaInstanceGetPrivate(pInstance, (void**)&psXCInstPri);
473 if (bInterlace)
474 SC_W2BYTEMSK(psXCInstPri->u32DeviceID, REG_SC_BK20_11_L, BIT(13), BIT(13));
475 else
476 SC_W2BYTEMSK(psXCInstPri->u32DeviceID, REG_SC_BK20_11_L, 0, BIT(13));
477 }
478
Hal_SC_enable_extra_request(void * pInstance,MS_BOOL bEnable)479 void Hal_SC_enable_extra_request(void *pInstance, MS_BOOL bEnable)
480 {
481 // HW PIP architeucture
482 // Becasue BK3_02[7] and BK20_11[15] can not enable toghter, otherwise garbage will be showed,
483 // With HW auto no signal, BK3_02[7] will be enabled by HW
484 // so, we need to set BK20_11[15] to 0 before no signal, ex. source switch case, need to disable extra request engine
485 // Then we need to restore extra request engine after input source is stable
486
487 XC_INSTANCE_PRIVATE *psXCInstPri = NULL;
488 UtopiaInstanceGetPrivate(pInstance, (void**)&psXCInstPri);
489
490 if(MDrv_XC_MLoad_GetStatus(pInstance) == E_MLOAD_ENABLED)
491 {
492 _MLOAD_ENTRY(pInstance);
493
494 if (TRUE == bEnable)
495 {
496 if(Hal_SC_is_extra_req_en(pInstance, NULL, NULL, NULL, NULL))
497 {
498 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK20_11_L, BIT(15), BIT(15));
499 }
500 else
501 {
502 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK20_11_L, 0, BIT(15));
503 }
504 }
505 else
506 {
507 MDrv_XC_MLoad_WriteCmd(pInstance, REG_SC_BK20_11_L, 0, BIT(15));
508 }
509
510 MDrv_XC_MLoad_Fire(pInstance, TRUE);
511
512 _MLOAD_RETURN(pInstance);
513 }
514 else
515 {
516 if (TRUE == bEnable)
517 {
518 if(Hal_SC_is_extra_req_en(pInstance, NULL, NULL, NULL, NULL))
519 {
520 SC_W2BYTEMSK(psXCInstPri->u32DeviceID, REG_SC_BK20_11_L, BIT(15), BIT(15));
521 }
522 else
523 {
524 SC_W2BYTEMSK(psXCInstPri->u32DeviceID, REG_SC_BK20_11_L, 0, BIT(15));
525 }
526 }
527 else
528 {
529 SC_W2BYTEMSK(psXCInstPri->u32DeviceID, REG_SC_BK20_11_L, 0, BIT(15));
530 }
531 }
532 }
533
Hal_SC_EnableCLK_for_SUB(void * pInstance,MS_BOOL bEnable)534 void Hal_SC_EnableCLK_for_SUB(void * pInstance, MS_BOOL bEnable)
535 {
536 // !!!!Sub FCLK&&ODCLK can not be closed to avoid menuload timeout
537
538 //MDrv_WriteRegBit(REG_CKG_S2_FCLK, bEnable, CKG_S2_FCLK_GATED); // REG_CLKGEN0_57[8], s2_fclk
539 //MDrv_WriteRegBit(REG_CKG_S2_ODCLK, bEnable, CKG_S2_ODCLK_GATED); // REG_CLKGEN2_63[0], s2_odclk
540 MDrv_WriteRegBit(REG_CKG_S2_IDCLK2, !bEnable, CKG_S2_IDCLK2_GATED); // REG_CLKGEN2_65[0], s2_idclk2
541 }
542
543 #undef MHAL_PIP_C
544