xref: /utopia/UTPA2-700.0.x/modules/graphic/api/gopscd/apiGOPSCD.c (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
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 ////////////////////////////////////////////////////////////////////////////////
96 //  [Doxygen]
97 /// file apiGOP_SC.c
98 /// This file includes MStar application interface for Graphic output path
99 /// @brief API for Graphics output path (GOP)
100 /// @author MStar Semiconductor, Inc.
101 //
102 ////////////////////////////////////////////////////////////////////////////////
103 
104 //-------------------------------------------------------------------------------------------------
105 //  Include Files
106 //-------------------------------------------------------------------------------------------------
107 #ifndef MSOS_TYPE_LINUX_KERNEL
108 #include <stdio.h>
109 #include <string.h>
110 #endif
111 
112 #include "utopia.h"
113 #include "utopia_dapi.h"
114 
115 #include "MsTypes.h"
116 #include "MsCommon.h"
117 #include "MsVersion.h"
118 #include "apiGOPSC_Ex.h"
119 #include "apiGOPSCD_v2.h"
120 #include "apiGOPSCD_private.h"
121 #include "drvGOPSCD.h"
122 #include "drvMMIO.h"
123 
124 //GOPSC_Info gGOPSCInfoData =
125 //{EN_Cubic,EN_Source_GOP,0x40,FALSE,FALSE,FALSE,TRUE};
126 
127 #define HW_LIMIT_WIDTH 720
128 
129 #define _GOPSCD_ENTRY_CHECKER(ARGS)															  \
130 		ARGS.bReturnValue = En_GOPSC_NOT_INITIALIZE; \
131 		if (pu32GOPSCDInst == NULL) 							  \
132 		{																						  \
133 			printf("[%s,%5d] No instance existed, please get an instance by calling MApi_GOPSC_Init() first\n",__FUNCTION__,__LINE__); 				  \
134 			return ARGS.bReturnValue; \
135 		}																						   \
136 
137 #define _GOPSCD_SET_INSTPRI_ID_FROM_INFO(pINSTPRI, pDEV)                                    \
138 		if(UtopiaInstanceGetPrivate(pu32GOPSCDInst, (void*)&pINSTPRI)!=UTOPIA_STATUS_SUCCESS) \
139 		{ \
140 			printf("[%s,%5d] Instance Get Private failed\n",__FUNCTION__,__LINE__); \
141 			return En_GOPSC_FAIL;                                                  \
142 		} \
143 		pINSTPRI->u32DeviceID = _GetDeviceIdFromInfo(pDEV);
144 
145 
_GetDeviceIdFromInfo(GOPSC_DeviceInfo * pDevInfo)146 static MS_U32 _GetDeviceIdFromInfo(GOPSC_DeviceInfo* pDevInfo)
147 {
148     if(NULL == pDevInfo)
149     {
150         return 0;
151     }
152     else
153     {
154         return pDevInfo->u32Id;
155     }
156 }
157 
_GetDeviceIDFromInstance(void * pInstance)158 static MS_U32 _GetDeviceIDFromInstance(void* pInstance)
159 {
160 	if(NULL == pInstance)
161 	{
162 		printf("[%s] NULL instance\n",__FUNCTION__);
163 		return 0;
164 	}
165 	GOPSCD_INSTANT_PRIVATE* psGOPSCDInstPri = NULL;
166 	if(UtopiaInstanceGetPrivate(pInstance, (void*)&psGOPSCDInstPri)!=UTOPIA_STATUS_SUCCESS)
167 	{
168 		printf("[%s,%5d] Instance Get Private failed\n",__FUNCTION__,__LINE__);
169 		return 0;
170 	}
171 	return psGOPSCDInstPri->u32DeviceID;
172 }
173 
MApi_GOPSCD_Init_U2(void * pInstance)174 GOPSC_Result MApi_GOPSCD_Init_U2(void* pInstance)
175 {
176     MS_VIRT virtGOPSCRiuBaseAddr;
177     MS_U32 u32NonPMBankSize;
178 
179 	GOPSCD_RESOURCE_PRIVATE* psGOPSCDResPri = NULL;
180 	if(UtopiaResourceGetPrivate(g_pGOPSCDResource, (void*)&psGOPSCDResPri)!=UTOPIA_STATUS_SUCCESS)
181 	{
182 		printf("[%s,%5d] Resource Get Private failed\n",__FUNCTION__,__LINE__);
183 		return En_GOPSC_FAIL;
184 	}
185 
186 	//Initialize globle
187 	psGOPSCDResPri->GOPSCDInfoData.en_Source = EN_Source_GOP;
188 	psGOPSCDResPri->GOPSCDInfoData.en_VScalingMode = EN_Cubic;
189 	psGOPSCDResPri->GOPSCDInfoData.dlyLineNumber = 0x40;
190 	psGOPSCDResPri->GOPSCDInfoData.P2IEnable = FALSE;
191 	psGOPSCDResPri->GOPSCDInfoData.HalfModeEnable = FALSE;
192 	psGOPSCDResPri->GOPSCDInfoData.OutputRateControlEnable = FALSE;
193 	psGOPSCDResPri->GOPSCDInfoData.UseP2IFormula = TRUE;
194 
195     // get MMIO base
196     if(MDrv_MMIO_GetBASE( &virtGOPSCRiuBaseAddr, &u32NonPMBankSize, MS_MODULE_GE ) != TRUE)
197     {
198         printf("GOP_SC GetBase failed\n");
199         return En_GOPSC_FAIL;
200     }
201     MDrv_GOPSC_Init_riu_base(_GetDeviceIDFromInstance(pInstance),virtGOPSCRiuBaseAddr);
202     MDrv_GOPSC_Init(_GetDeviceIDFromInstance(pInstance));
203     MDrv_GOPSC_SetSkipPixel(_GetDeviceIDFromInstance(pInstance),TRUE,FALSE,0,HW_LIMIT_WIDTH,0,0); //for HW limit, XSkip must 720.
204     MApi_GOPSC_SetGOPSCInfo_U2(pInstance,NULL);
205 
206     return En_GOPSC_OK;
207 }
208 
MApi_GOPSC_Init(GOPSC_DeviceInfo * DevInfo)209 GOPSC_Result MApi_GOPSC_Init(GOPSC_DeviceInfo* DevInfo)
210 {
211     if (pu32GOPSCDInst == NULL)
212     {
213         if(UtopiaOpen(MODULE_GOPSCD, &pu32GOPSCDInst, 0, NULL) != UTOPIA_STATUS_SUCCESS)
214         {
215             printf("UtopiaOpen pu32GOPSCDInst failed\n");
216     		return En_GOPSC_FAIL;
217         }
218     }
219 
220 	GOPSCD_INSTANT_PRIVATE* psGOPSCDInstPri = NULL;
221 	if(UtopiaInstanceGetPrivate(pu32GOPSCDInst, (void*)&psGOPSCDInstPri)!=UTOPIA_STATUS_SUCCESS)
222 	{
223 		printf("[%s,%5d] Instance Get Private failed\n",__FUNCTION__,__LINE__);
224 	}
225 	psGOPSCDInstPri->u32DeviceID = _GetDeviceIdFromInfo(DevInfo);
226 
227 	GOPSCD_INIT_INFO GOPSCDArgs;
228 	if(UtopiaIoctl(pu32GOPSCDInst, MAPI_CMD_GOPSCD_INIT, (void*)&GOPSCDArgs) != UTOPIA_STATUS_SUCCESS)
229 	{
230 		printf("Obtain GOPSCD engine fail\n");
231 		return En_GOPSC_FAIL;
232 	}
233 	else
234 	{
235 		return GOPSCDArgs.bReturnValue;
236 	}
237 }
238 
MApi_GOPSCD_Scaling_U2(void * pInstance,E_GOPSCD_SCALING_CMD cmd,MS_U8 FrameNum)239 GOPSC_Result MApi_GOPSCD_Scaling_U2(void* pInstance, E_GOPSCD_SCALING_CMD cmd, MS_U8 FrameNum)
240 {
241 	if(E_GOPSCD_CMD_ENABLE == cmd)
242 	{
243 		MDrv_GOPSC_Enable(_GetDeviceIDFromInstance(pInstance),TRUE);
244 	}
245 	else if(E_GOPSCD_CMD_DISABLE == cmd)
246 	{
247 		MDrv_GOPSC_Enable(_GetDeviceIDFromInstance(pInstance),FALSE);
248 	}
249 	else if(E_GOPSCD_CMD_SCALING_ONCE == cmd)
250 	{
251 	    if(0 == FrameNum)
252 	    {
253 	        printf("[%s] FrameNum is 0.\n",__FUNCTION__);
254 	        return En_GOPSC_INVALID_PARAM;
255 	    }
256 	    MDrv_GOPSC_Enable(_GetDeviceIDFromInstance(pInstance),FALSE);
257 	    MDrv_GOPSC_TriggerOnce(_GetDeviceIDFromInstance(pInstance),FrameNum);
258 	}
259 	else
260 	{
261 		printf("[%s,%5d] Unkown command\n",__FUNCTION__,__LINE__);
262 		return En_GOPSC_FAIL;
263 	}
264     return En_GOPSC_OK;
265 }
266 
MApi_GOPSC_Enable(GOPSC_DeviceInfo * DevInfo,MS_BOOL enable)267 GOPSC_Result MApi_GOPSC_Enable(GOPSC_DeviceInfo* DevInfo, MS_BOOL enable)
268 {
269 	GOPSCD_SCALING GOPSCDArgs;
270 	_GOPSCD_ENTRY_CHECKER(GOPSCDArgs);
271 
272 	GOPSCD_INSTANT_PRIVATE* psGOPSCDInstPri = NULL;
273 	_GOPSCD_SET_INSTPRI_ID_FROM_INFO(psGOPSCDInstPri,DevInfo);
274 
275 	GOPSCDArgs.gopscCmd = E_GOPSCD_CMD_ENABLE;
276 	GOPSCDArgs.u8FrameCount = 0;
277 	if(UtopiaIoctl(pu32GOPSCDInst, MAPI_CMD_GOPSCD_SCALING, (void*)&GOPSCDArgs) != UTOPIA_STATUS_SUCCESS)
278 	{
279 		printf("Obtain GOPSCD engine fail\n");
280 		return En_GOPSC_FAIL; // return meaningless value because get instance failed.
281 	}
282 	else
283 	{
284 		return GOPSCDArgs.bReturnValue;
285 	}
286 }
287 
MApi_GOPSC_GetGOPSCInfo_U2(void * pInstance,GOPSC_Info * gopscInfo)288 GOPSC_Result MApi_GOPSC_GetGOPSCInfo_U2(void* pInstance, GOPSC_Info* gopscInfo)
289 {
290     if(gopscInfo == NULL)
291     {
292         printf("[%s] gopscInfo is NULL\n",__FUNCTION__);
293         return En_GOPSC_INVALID_PARAM;
294     }
295 
296 	GOPSCD_RESOURCE_PRIVATE* psGOPSCDResPri = NULL;
297 	if(UtopiaResourceGetPrivate(g_pGOPSCDResource, (void*)&psGOPSCDResPri)!=UTOPIA_STATUS_SUCCESS)
298 	{
299 		printf("[%s,%5d] Resource Get Private failed\n",__FUNCTION__,__LINE__);
300 		return En_GOPSC_FAIL;
301 	}
302 
303     gopscInfo->en_Source = psGOPSCDResPri->GOPSCDInfoData.en_Source;
304     gopscInfo->en_VScalingMode = psGOPSCDResPri->GOPSCDInfoData.en_VScalingMode;
305     gopscInfo->dlyLineNumber = psGOPSCDResPri->GOPSCDInfoData.dlyLineNumber;
306     gopscInfo->P2IEnable = psGOPSCDResPri->GOPSCDInfoData.P2IEnable;
307     gopscInfo->HalfModeEnable = psGOPSCDResPri->GOPSCDInfoData.HalfModeEnable;
308     gopscInfo->OutputRateControlEnable = psGOPSCDResPri->GOPSCDInfoData.OutputRateControlEnable;
309 	gopscInfo->UseP2IFormula = psGOPSCDResPri->GOPSCDInfoData.UseP2IFormula;
310 
311     return En_GOPSC_OK;
312 }
313 
MApi_GOPSC_GetGOPSCInfo(GOPSC_DeviceInfo * DevInfo,GOPSC_Info * gopscInfo)314 GOPSC_Result MApi_GOPSC_GetGOPSCInfo(GOPSC_DeviceInfo* DevInfo, GOPSC_Info* gopscInfo)
315 {
316 	GOPSCD_GET_INFO GOPSCDArgs;
317 	_GOPSCD_ENTRY_CHECKER(GOPSCDArgs);
318 	//If gopscInfo == NULL, it will set value for globle variable directly
319 
320 	GOPSCD_INSTANT_PRIVATE* psGOPSCDInstPri = NULL;
321 	_GOPSCD_SET_INSTPRI_ID_FROM_INFO(psGOPSCDInstPri,DevInfo);
322 
323     GOPSCDArgs.gopscInfo = gopscInfo;
324 	if(UtopiaIoctl(pu32GOPSCDInst, MAPI_CMD_GOPSCD_GET_INFO, (void*)&GOPSCDArgs) != UTOPIA_STATUS_SUCCESS)
325 	{
326 		printf("Obtain GOPSCD engine fail\n");
327 		return En_GOPSC_FAIL; // return meaningless value because get instance failed.
328 	}
329 	else
330 	{
331 		return GOPSCDArgs.bReturnValue;
332 	}
333 }
334 
MApi_GOPSC_SetGOPSCInfo_U2(void * pInstance,GOPSC_Info * gopscInfo)335 GOPSC_Result MApi_GOPSC_SetGOPSCInfo_U2(void* pInstance, GOPSC_Info* gopscInfo)
336 {
337 	GOPSCD_RESOURCE_PRIVATE* psGOPSCDResPri = NULL;
338 	if(UtopiaResourceGetPrivate(g_pGOPSCDResource, (void*)&psGOPSCDResPri)!=UTOPIA_STATUS_SUCCESS)
339 	{
340 		printf("[%s,%5d] Resource Get Private failed\n",__FUNCTION__,__LINE__);
341 		return En_GOPSC_FAIL;
342 	}
343 
344     if(gopscInfo != NULL)
345     {
346 		psGOPSCDResPri->GOPSCDInfoData.en_Source = gopscInfo->en_Source;
347 		psGOPSCDResPri->GOPSCDInfoData.en_VScalingMode = gopscInfo->en_VScalingMode;
348 		psGOPSCDResPri->GOPSCDInfoData.dlyLineNumber = gopscInfo->dlyLineNumber;
349 		psGOPSCDResPri->GOPSCDInfoData.P2IEnable = gopscInfo->P2IEnable;
350 		psGOPSCDResPri->GOPSCDInfoData.HalfModeEnable = gopscInfo->HalfModeEnable;
351 		psGOPSCDResPri->GOPSCDInfoData.OutputRateControlEnable = gopscInfo->OutputRateControlEnable;
352 		psGOPSCDResPri->GOPSCDInfoData.UseP2IFormula = gopscInfo->UseP2IFormula;
353     }
354 
355     MDrv_GOPSC_SetVScalingMode(_GetDeviceIDFromInstance(pInstance),psGOPSCDResPri->GOPSCDInfoData.en_VScalingMode);
356     MDrv_GOPSC_SetSource(_GetDeviceIDFromInstance(pInstance),psGOPSCDResPri->GOPSCDInfoData.en_Source);
357     MDrv_GOPSC_SetDelayLineNumber(_GetDeviceIDFromInstance(pInstance),psGOPSCDResPri->GOPSCDInfoData.dlyLineNumber);
358     MDrv_GOPSC_P2IEnable(_GetDeviceIDFromInstance(pInstance),psGOPSCDResPri->GOPSCDInfoData.P2IEnable);
359     MDrv_GOPSC_HalfMode(_GetDeviceIDFromInstance(pInstance),psGOPSCDResPri->GOPSCDInfoData.HalfModeEnable);
360 
361     return En_GOPSC_OK;
362 }
363 
MApi_GOPSC_SetGOPSCInfo(GOPSC_DeviceInfo * DevInfo,GOPSC_Info * gopscInfo)364 GOPSC_Result MApi_GOPSC_SetGOPSCInfo(GOPSC_DeviceInfo* DevInfo, GOPSC_Info* gopscInfo)
365 {
366 	GOPSCD_SET_INFO GOPSCDArgs;
367 	_GOPSCD_ENTRY_CHECKER(GOPSCDArgs);
368 	//If gopscInfo == NULL, it will set value for globle variable directly
369 
370 	GOPSCD_INSTANT_PRIVATE* psGOPSCDInstPri = NULL;
371 	_GOPSCD_SET_INSTPRI_ID_FROM_INFO(psGOPSCDInstPri,DevInfo);
372 
373     GOPSCDArgs.gopscInfo = gopscInfo;
374 	if(UtopiaIoctl(pu32GOPSCDInst, MAPI_CMD_GOPSCD_SET_INFO, (void*)&GOPSCDArgs) != UTOPIA_STATUS_SUCCESS)
375 	{
376 		printf("Obtain GOPSCD engine fail\n");
377 		return En_GOPSC_FAIL; // return meaningless value because get instance failed.
378 	}
379 	else
380 	{
381 		return GOPSCDArgs.bReturnValue;
382 	}
383 }
384 
MApi_GOPSC_SetHVSPSize_U2(void * pInstance,const GOPSC_SizeInfo * sizeInfo,MS_U32 flag)385 GOPSC_Result MApi_GOPSC_SetHVSPSize_U2(void* pInstance, const GOPSC_SizeInfo* sizeInfo, MS_U32 flag)
386 {
387     if(NULL == sizeInfo)
388     {
389         printf("[%s] sizeInfo is NULL\n",__FUNCTION__);
390         return En_GOPSC_INVALID_PARAM;
391     }
392     //No support destination > source (this case is not function of GOPSC)
393     if((sizeInfo->destHeight > sizeInfo->srcHeight) || (sizeInfo->destWidth > sizeInfo->srcWidth))
394     {
395         printf("[%s] sizeInfo data is error\n",__FUNCTION__);
396         return En_GOPSC_FAIL;
397     }
398 
399 	GOPSCD_RESOURCE_PRIVATE* psGOPSCDResPri = NULL;
400 	if(UtopiaResourceGetPrivate(g_pGOPSCDResource, (void*)&psGOPSCDResPri)!=UTOPIA_STATUS_SUCCESS)
401 	{
402 		printf("[%s,%5d] Resource Get Private failed\n",__FUNCTION__,__LINE__);
403 		return En_GOPSC_FAIL;
404 	}
405 
406     if(psGOPSCDResPri->GOPSCDInfoData.OutputRateControlEnable)
407     {
408         MDrv_GOPSC_SetOutputControlRate(_GetDeviceIDFromInstance(pInstance),TRUE,
409             sizeInfo->srcWidth,sizeInfo->srcHeight,sizeInfo->destWidth,sizeInfo->destHeight,
410             psGOPSCDResPri->GOPSCDInfoData.P2IEnable);
411     }
412     else
413     {
414         MDrv_GOPSC_SetOutputControlRate(_GetDeviceIDFromInstance(pInstance),
415             FALSE,0,0,0,0,FALSE);
416     }
417 	MDrv_GOPSC_SetScalingFormula(_GetDeviceIDFromInstance(pInstance),psGOPSCDResPri->GOPSCDInfoData.UseP2IFormula);
418 
419     return MDrv_GOPSC_SetHVSP(_GetDeviceIDFromInstance(pInstance),sizeInfo->bEnableScaleX,sizeInfo->bEnableScaleY,
420         sizeInfo->srcWidth,sizeInfo->srcHeight,sizeInfo->destWidth,sizeInfo->destHeight);
421 }
422 
423 // flag is reserve for enable dither, V-y Scaling, V-c Scaling...options
MApi_GOPSC_SetHVSPSize(GOPSC_DeviceInfo * DevInfo,GOPSC_SizeInfo * sizeInfo,MS_U32 flag)424 GOPSC_Result MApi_GOPSC_SetHVSPSize(GOPSC_DeviceInfo* DevInfo, GOPSC_SizeInfo* sizeInfo, MS_U32 flag)
425 {
426 	GOPSCD_SET_HVSPSZIE GOPSCDArgs;
427 	_GOPSCD_ENTRY_CHECKER(GOPSCDArgs);
428 
429 	GOPSCD_INSTANT_PRIVATE* psGOPSCDInstPri = NULL;
430 	_GOPSCD_SET_INSTPRI_ID_FROM_INFO(psGOPSCDInstPri,DevInfo);
431 
432 	GOPSCDArgs.sizeInfo = sizeInfo;
433 	GOPSCDArgs.flag = flag;
434 	if(UtopiaIoctl(pu32GOPSCDInst, MAPI_CMD_GOPSCD_SET_HVSPSIZE, (void*)&GOPSCDArgs) != UTOPIA_STATUS_SUCCESS)
435 	{
436 		printf("Obtain GOPSCD engine fail\n");
437 		return En_GOPSC_FAIL; // return meaningless value because get instance failed.
438 	}
439 	else
440 	{
441 		return GOPSCDArgs.bReturnValue;
442 	}
443 }
444 
MApi_GOPSC_SetSkipPixel_U2(void * pInstance,const GOPSC_SkipPixelInfo * skippixelInfo,MS_U32 flag)445 GOPSC_Result MApi_GOPSC_SetSkipPixel_U2(void* pInstance, const GOPSC_SkipPixelInfo* skippixelInfo, MS_U32 flag)
446 {
447     if(NULL == skippixelInfo)
448     {
449         printf("[%s] skippixelInfo is NULL\n",__FUNCTION__);
450         return En_GOPSC_INVALID_PARAM;
451     }
452     if(skippixelInfo->xEnd <= skippixelInfo->xStart || skippixelInfo->yEnd <= skippixelInfo->yStart)
453     {
454         printf("[%s] skippixelInfo data is error\n",__FUNCTION__);
455         return En_GOPSC_FAIL;
456     }
457     if(skippixelInfo->xEnd > HW_LIMIT_WIDTH)
458     {
459         printf("[%s] skippixelInfo xEnd must be smaller than HW_LIMIT_WIDTH\n",__FUNCTION__);
460         return En_GOPSC_FAIL;
461     }
462     return MDrv_GOPSC_SetSkipPixel(_GetDeviceIDFromInstance(pInstance),skippixelInfo->bEnableSkipX,skippixelInfo->bEnableSkipY,
463         skippixelInfo->xStart,skippixelInfo->xEnd,skippixelInfo->yStart,skippixelInfo->yEnd);
464 }
465 
MApi_GOPSC_SetSkipPixel(GOPSC_DeviceInfo * DevInfo,GOPSC_SkipPixelInfo * skippixelInfo,MS_U32 flag)466 GOPSC_Result MApi_GOPSC_SetSkipPixel(GOPSC_DeviceInfo* DevInfo, GOPSC_SkipPixelInfo* skippixelInfo, MS_U32 flag)
467 {
468 	GOPSCD_SET_SKIPPIXEL GOPSCDArgs;
469 	_GOPSCD_ENTRY_CHECKER(GOPSCDArgs);
470 
471 	GOPSCD_INSTANT_PRIVATE* psGOPSCDInstPri = NULL;
472 	_GOPSCD_SET_INSTPRI_ID_FROM_INFO(psGOPSCDInstPri,DevInfo);
473 
474 	GOPSCDArgs.skippixelInfo = skippixelInfo;
475 	GOPSCDArgs.flag = flag;
476 	if(UtopiaIoctl(pu32GOPSCDInst, MAPI_CMD_GOPSCD_SET_SKIPPIXEL, (void*)&GOPSCDArgs) != UTOPIA_STATUS_SUCCESS)
477 	{
478 		printf("Obtain GOPSCD engine fail\n");
479 		return En_GOPSC_FAIL; // return meaningless value because get instance failed.
480 	}
481 	else
482 	{
483 		return GOPSCDArgs.bReturnValue;
484 	}
485 
486 }
487 
488 #if 0 //take out this because of no use now.
489 GOPSC_Result MApi_GOPSC_SetFieldStartPosition(GOPSC_DeviceInfo* DevInfo, MS_BOOL enable, MS_U16 topFieldOffset, MS_U16 bottomFieldOffset)
490 {
491     return MDrv_GOPSC_SetFieldStartPosition(_GetDeviceIdFromInfo(DevInfo),
492         enable,topFieldOffset,bottomFieldOffset);
493 }
494 #endif
495 
MApi_GOPSC_ScalingDownOnce(GOPSC_DeviceInfo * DevInfo,MS_U8 FrameNum)496 GOPSC_Result MApi_GOPSC_ScalingDownOnce(GOPSC_DeviceInfo* DevInfo, MS_U8 FrameNum)
497 {
498 	GOPSCD_SCALING GOPSCDArgs;
499 	_GOPSCD_ENTRY_CHECKER(GOPSCDArgs);
500 
501 	GOPSCD_INSTANT_PRIVATE* psGOPSCDInstPri = NULL;
502 	_GOPSCD_SET_INSTPRI_ID_FROM_INFO(psGOPSCDInstPri,DevInfo);
503 
504 	GOPSCDArgs.gopscCmd = E_GOPSCD_CMD_SCALING_ONCE;
505 	GOPSCDArgs.u8FrameCount = FrameNum;
506 	if(UtopiaIoctl(pu32GOPSCDInst, MAPI_CMD_GOPSCD_SCALING, (void*)&GOPSCDArgs) != UTOPIA_STATUS_SUCCESS)
507 	{
508 		printf("Obtain GOPSCD engine fail\n");
509 		return En_GOPSC_FAIL; // return meaningless value because get instance failed.
510 	}
511 	else
512 	{
513 		return GOPSCDArgs.bReturnValue;
514 	}
515 }
516 
517