xref: /utopia/UTPA2-700.0.x/modules/graphic/api/gop/apiGOP.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.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 #if !defined(MSOS_TYPE_LINUX_KERNEL)
108 #include <stdio.h>
109 #include <string.h>
110 #include <pthread.h>
111 #else
112 #include <linux/string.h>
113 #include <linux/slab.h>
114 #endif
115 
116 #include "utopia.h"
117 #include "MsTypes.h"
118 #include "MsCommon.h"
119 #include "MsVersion.h"
120 #include "apiGOP.h"
121 #include "apiGOP_priv.h"
122 #include "util_symbol.h"
123 #include "drvGOP.h"
124 #include "MsOS.h"
125 
126 
127 #include "drvXC_IOPort.h"
128 #include "apiXC.h"
129 #include "apiXC_v2.h"
130 #include "mvideo_context.h"
131 
132 //-------------------------------------------------------------------------------------------------
133 //  Local Compiler Options
134 //-------------------------------------------------------------------------------------------------
135 #if defined(MSOS_TYPE_LINUX) || defined(MSOS_TYPE_LINUX_KERNEL)
136 #ifndef GOP_UTOPIA2K
137 #define GOP_UTOPIA2K
138 #endif
139 #endif
140 
141 #define DUMP_INFO   0UL
142 
143 #define FPGA_TEST   0UL
144 
145 //-------------------------------------------------------------------------------------------------
146 //  Local Defines
147 //-------------------------------------------------------------------------------------------------
148 #ifdef MSOS_TYPE_LINUX_KERNEL
149 #define atoi(str) simple_strtoul(((str != NULL) ? str : ""), NULL, 0)
150 #endif
151 
152 #if defined(MSOS_TYPE_LINUX)
153     #include <sys/types.h>
154     #include <unistd.h>
155 #elif defined(MSOS_TYPE_LINUX_KERNEL)
156     #define getpid()    pInstantGOP
157 #else
158 #define getpid() 0UL
159 #endif
160 
161 #define GetMaxActiveGwinFalse 4UL
162 #define GetMaxActiveGwinFalse_op 5UL
163 #define GetMaxActiveGwinFalse_opened 6UL
164 #define PALETTE_ENTRY_NUM   32UL
165 #define GWIN_SDRAM_NULL 0x30UL
166 #define msWarning(c)    do {} while (0)
167 #define XC_MAIN_WINDOW  0UL
168 
169 #define SCALING_MULITPLIER 0x1000UL
170 #define UNUSED( var )                   (void)((var) = (var))
171 
172 //=============================================================
173 #include "ULog.h"
174 MS_U32 u32GOPDbgLevel_api;
175 
176 // Debug Logs, level form low(INFO) to high(FATAL, always show)
177 // Function information, ex function entry
178 #define GOP_INFO(x, args...) if(u32GOPDbgLevel_api >= E_GOP_Debug_Level_HIGH) { ULOGI("GOP API", x, ##args); }
179 // Warning, illegal paramter but can be self fixed in functions
180 #define GOP_WARN(x, args...) if(u32GOPDbgLevel_api >= E_GOP_Debug_Level_HIGH) { ULOGW("GOP API", x, ##args); }
181 //  Need debug, illegal paramter.
182 #define GOP_DBUG(x, args...) if(u32GOPDbgLevel_api >= E_GOP_Debug_Level_MED) { ULOGD("GOP API", x, ##args); }
183 // Error, function will be terminated but system not crash
184 #define GOP_ERR(x, args...) if(u32GOPDbgLevel_api >= E_GOP_Debug_Level_LOW) { ULOGE("GOP API", x, ##args); }
185 // Critical, system crash. (ex. assert)
186 #define GOP_FATAL(x, args...) if(u32GOPDbgLevel_api >= E_GOP_Debug_Level_LOW) { ULOGF("GOP API", x, ##args); }
187 
188 //=============================================================
189 
190 #ifdef  MSOS_TYPE_LINUX
191 #include <assert.h>
192 #include <unistd.h>
193 #define GOP_ASSERT(_bool, pri)  if (!(_bool)) {GOP_FATAL("\nAssert in %s,%d\n", __FUNCTION__, __LINE__); (pri); MsOS_DelayTask(100); assert(0);}
194 #else
195 #define GOP_ASSERT(_bool, pri)  if (!(_bool)) {GOP_FATAL("\nAssert in %s,%d\n", __FUNCTION__, __LINE__); (pri);};
196 #endif
197 
198 #ifdef MSOS_TYPE_LINUX
199 static pthread_mutex_t          GOP_XC_Instance_Mutex = PTHREAD_MUTEX_INITIALIZER;
200 #endif
201 
_GOP_XC_Instance_Lock(void)202 static void _GOP_XC_Instance_Lock(void)
203 {
204 
205 #ifdef MSOS_TYPE_LINUX
206     pthread_mutex_lock(&GOP_XC_Instance_Mutex);
207 #endif
208 
209 }
210 
_GOP_XC_Instance_UnLock(void)211 static void _GOP_XC_Instance_UnLock(void)
212 {
213 
214 #ifdef MSOS_TYPE_LINUX
215     pthread_mutex_unlock(&GOP_XC_Instance_Mutex);
216 #endif
217 
218 }
219 
220 
221 #define CheckGOPInstanceOpen() do{\
222     if(pInstantGOP == NULL)\
223     {\
224         if(UtopiaOpen(MODULE_GOP | GOPDRIVER_BASE, &pInstantGOP, 0, pAttributeGOP) !=  UTOPIA_STATUS_SUCCESS)\
225         {\
226             GOP_ERR("Open GOP fail\n");\
227             return GOP_API_FAIL;\
228         }\
229     }\
230 }while(0)
231 
232 
233 void* pInstantGOP_XC = NULL;
234 
235 #define CheckXCOpen()   do{\
236      _GOP_XC_Instance_Lock();\
237      if(pInstantGOP_XC==NULL)\
238      {\
239          XC_INSTANT_ATTRIBUTE stXCInstantAttribute;\
240          memset(&stXCInstantAttribute, 0, sizeof(stXCInstantAttribute));\
241          stXCInstantAttribute.u32DeviceID = 0;\
242          stXCInstantAttribute.eXCType     = E_XC_INSTANT_TYPE_GOP;\
243         if(UtopiaOpen(MODULE_XC, &pInstantGOP_XC, 0, &stXCInstantAttribute) != UTOPIA_STATUS_SUCCESS)\
244         {\
245             GOP_ERR("UtopiaOpen XC failed\n");\
246             return GOP_API_FAIL;\
247         }\
248      }\
249      _GOP_XC_Instance_UnLock();\
250 }while(0)
251 
252 
253 #define GOP_ENTRY()                 do{ \
254                                         APIGOP_ASSERT(bInit, GOP_FATAL("\n [Function   %s] [%d] Need GOP Driver Init First !!!!!!!\n",__FUNCTION__,__LINE__));\
255                                         _GOP_Entry();\
256                                     }while(0);
257 //{if(TRUE != MDrv_GOP_GWIN_BeginDraw()){GOP_ASSERT(FALSE, printf("\nError: Obtain GOP mutex fail\n"));}}
258 #define GOP_RETURN(_ret)             do{\
259                                         return _ret;\
260                                      }while(0);//{if(TRUE == MDrv_GOP_GWIN_EndDraw()){return _ret;}else{GOP_ASSERT(FALSE, printf("\nError: Release GOP mutex fail\n"));return _ret;}}
261 
262 //-------------------------------------------------------------------------------------------------
263 //  Local Structures
264 //-------------------------------------------------------------------------------------------------
265 
266 
267 //-------------------------------------------------------------------------------------------------
268 //  Global Variables
269 //-------------------------------------------------------------------------------------------------
270 
271 
272 //-------------------------------------------------------------------------------------------------
273 //  Local Variables
274 //-------------------------------------------------------------------------------------------------
275 //GOP Lib Version Control
276 static MSIF_Version _api_gop_version =
277 {
278     .DDI = { GOP_API_VERSION },
279 };
280 
281 
282 static MS_U32 (*fpSetFBFmt)(MS_U16 ,MS_PHY , MS_U16 ) = NULL;
283 static MS_BOOL (*fpXCIsInterlace)(void) = NULL;
284 static MS_U16 (*fpXCGetCapHStart)(void) = NULL;
285 static void (*fpXCReduceBWForOSD)(MS_U8 , MS_BOOL) = NULL;
286 static void (*fpEventNotify)(MS_U32 , void* ) = NULL;
287 static MS_BOOL (*fpXCSetDwinInfo)(MS_U16 cmd,MS_U32 *arg,MS_U16 size) = NULL;
288 static MS_BOOL bInit = FALSE;
289 MS_U32 u32TransColor = 0x00000000;
290 
291 //-------------------------------------------------------------------------------------------------
292 //  Utopia 2.0
293 //-------------------------------------------------------------------------------------------------
294 
295 void* pInstantGOP = NULL;
296 void* pAttributeGOP = NULL;
297 
298 GOP_Palette PaletteEntry[PALETTE_ENTRY_NUM] =
299 {
300     //   A,    R,    G,    B
301     { 0x00, 0x00, 0x00, 0x00 },   // black           0
302     { 0x00, 0xff, 0x00, 0x00 },   // red             1
303     { 0x00, 0x00, 0xff, 0x00 },   // green           2
304     { 0x00, 0xff, 0xff, 0x00 },   // yellow          3
305     { 0x00, 0x00, 0x00, 0xff },   // blue            4
306     { 0x00, 0xff, 0x00, 0xff },   // magenta         5
307     { 0x00, 0x00, 0xff, 0xff },   // cyan            6
308     { 0x00, 0xff, 0xff, 0xff },   // white           7
309     { 0x00, 0xff, 0x08, 0xff },   // transparent     8
310     { 0x00, 0x7f, 0x00, 0x00 },   // half red        9
311     { 0x00, 0xCC, 0xCC, 0xCC },   // half green      10
312     { 0x00, 0x54, 0x54, 0x54 },   // half yellow     11
313     { 0x00, 0x00, 0x00, 0x7f },   // half blue       12
314     { 0x00, 0x7f, 0x00, 0x7f },   // half magenta    13
315     { 0x00, 0x00, 0x7f, 0x7f },   // half cyan       14
316     { 0x00, 0x7f, 0x7f, 0x7f },   // gray            15
317     { 0x00, 0x0f, 0x0f, 0x0f },
318     { 0x00, 0xff, 0x00, 0x00 },
319     { 0x00, 0x00, 0xff, 0x00 },
320     { 0x00, 0xff, 0xff, 0x00 },
321     { 0x00, 0x00, 0x00, 0xff },
322     { 0x00, 0xff, 0x00, 0xff },
323     { 0x00, 0x00, 0xff, 0xff },
324     { 0x00, 0xff, 0xff, 0xff },
325     { 0x00, 0x00, 0x00, 0x00 },   // Transparent      24
326     { 0x00, 0x7f, 0x00, 0x00 },
327     { 0x00, 0x00, 0x7f, 0x00 },
328     { 0x00, 0x7f, 0x7f, 0x00 },
329     { 0x00, 0x00, 0x00, 0x7f },
330     { 0x00, 0x7f, 0x00, 0x7f },
331     { 0x00, 0x00, 0x7f, 0x7f },
332     { 0x00, 0x7f, 0x7f, 0x7f },
333 };
334 
335 //-------------------------------------------------------------------------------------------------
336 //  Debug Functions
337 //-------------------------------------------------------------------------------------------------
338 
339 //------------------------------------------------------------------------------
340 //  Local Functions
341 //------------------------------------------------------------------------------
GOP_CalcPitch(MS_U8 fbFmt,MS_U16 width)342 static MS_U32 GOP_CalcPitch(MS_U8 fbFmt, MS_U16 width)
343 {
344     MS_U16 pitch=0;
345 
346     switch ( fbFmt )
347     {
348     case E_MS_FMT_I1 :
349         pitch = (width) >> 3;
350         break;
351     case E_MS_FMT_I2 :
352         pitch = (width<<1) >> 3;
353         break;
354     case E_MS_FMT_I4 :
355         pitch = (width<<2) >> 3;
356         break;
357     case E_MS_FMT_I8 :
358         pitch = width;
359         break;
360     case E_MS_FMT_RGB565 :
361     case E_MS_FMT_BGR565 :
362     case E_MS_FMT_ARGB1555 :
363     case E_MS_FMT_ABGR1555 :
364     case E_MS_FMT_BGRA5551 :
365     case E_MS_FMT_RGBA5551 :
366     case E_MS_FMT_ARGB4444 :
367     case E_MS_FMT_RGBA4444 :
368     case E_MS_FMT_ABGR4444 :
369     case E_MS_FMT_BGRA4444 :
370     case E_MS_FMT_1ABFgBg12355:
371     case E_MS_FMT_FaBaFgBg2266:
372     case E_MS_FMT_YUV422:
373     case E_MS_FMT_ARGB1555_DST :
374         pitch = width << 1;
375         break;
376     case E_MS_FMT_AYUV8888 :
377     case E_MS_FMT_ARGB8888 :
378     case E_MS_FMT_RGBA8888 :
379     case E_MS_FMT_BGRA8888:
380     case E_MS_FMT_ABGR8888 :
381         pitch = width << 2;
382         break;
383     default :
384         //print err
385         pitch = 0;
386         break;
387     }
388     return pitch;
389 }
390 
GOP_GetBPP(EN_GOP_COLOR_TYPE fbFmt)391 static MS_U16 GOP_GetBPP(EN_GOP_COLOR_TYPE fbFmt)
392 {
393     MS_U16 bpp=0;
394 
395     switch ( fbFmt )
396     {
397     case E_GOP_COLOR_RGB555_BLINK :
398     case E_GOP_COLOR_RGB565 :
399     case E_GOP_COLOR_BGR565 :
400     case E_GOP_COLOR_ARGB1555:
401     case E_GOP_COLOR_ABGR1555:
402     case E_GOP_COLOR_ARGB4444 :
403     case E_GOP_COLOR_RGBA4444 :
404     case E_GOP_COLOR_ABGR4444 :
405     case E_GOP_COLOR_BGRA4444 :
406     case E_GOP_COLOR_RGB555YUV422:
407     case E_GOP_COLOR_YUV422:
408     case E_GOP_COLOR_2266:
409     case E_GOP_COLOR_RGBA5551:
410     case E_GOP_COLOR_BGRA5551:
411         bpp = 16;
412         break;
413     case E_GOP_COLOR_AYUV8888 :
414     case E_GOP_COLOR_ARGB8888 :
415     case E_GOP_COLOR_ABGR8888 :
416     case E_GOP_COLOR_RGBA8888 :
417     case E_GOP_COLOR_BGRA8888 :
418         bpp = 32;
419         break;
420 
421     case E_GOP_COLOR_I8 :
422         bpp = 8;
423         break;
424     default :
425         //print err
426         //__ASSERT(0);
427         bpp = FB_FMT_AS_DEFAULT;
428         break;
429     }
430     return bpp;
431 
432 }
433 
434 #ifdef UTOPIA_V2
_XCGetCapHStartCB(void)435 static E_GOP_API_Result _XCGetCapHStartCB(void)
436 {
437     MS_XC_DST_DispInfo dstDispInfo;
438     MS_U32 u32XCHStart=0;
439     GOP_REGISTER_CB_PARAM ioctl_info;
440     memset(&ioctl_info, 0x0, sizeof(GOP_REGISTER_CB_PARAM));
441 
442     CheckXCOpen();
443 
444     MApi_XC_GetDstInfo(&dstDispInfo,sizeof(MS_XC_DST_DispInfo),E_GOP_XCDST_IP1_MAIN);
445     u32XCHStart = dstDispInfo.DEHST;
446 
447     if(pInstantGOP != NULL)
448     {
449         ioctl_info.cb_type = GOP_CB_XC_PANEL_HSTART;
450         ioctl_info.pCB = (void*)&u32XCHStart;
451         if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_REGISTER_CB,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
452         {
453             GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
454             return GOP_API_FAIL;
455         }
456     }
457     return GOP_API_SUCCESS;
458 }
459 
_XCGetXCInterlaceCB(void)460 static E_GOP_API_Result _XCGetXCInterlaceCB(void)
461 {
462     XC_ApiStatus xcStatus;
463     MS_BOOL bInterlace=0;
464     GOP_REGISTER_CB_PARAM ioctl_info;
465     memset(&ioctl_info, 0x0, sizeof(GOP_REGISTER_CB_PARAM));
466 
467     CheckXCOpen();
468 
469     MApi_XC_GetStatus(&xcStatus,MAIN_WINDOW);
470     bInterlace = xcStatus.bInterlace;
471 
472     if(pInstantGOP != NULL)
473     {
474         ioctl_info.cb_type = GOP_CB_XC_INTERLACE;
475         ioctl_info.pCB = &bInterlace;
476         if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_REGISTER_CB,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
477         {
478             GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
479             return GOP_API_FAIL;
480         }
481     }
482     return GOP_API_SUCCESS;
483 }
484 #endif
485 
_GOP_Entry(void)486 static void _GOP_Entry(void)
487 {
488 #ifdef UTOPIA_V2
489     //_XCGetCapHStartCB();
490     //_XCGetXCInterlaceCB();
491 #endif
492 }
MApi_GOP_GWIN_ResetPool(void)493 E_GOP_API_Result MApi_GOP_GWIN_ResetPool(void)
494 {
495     MS_U32 i;
496     static MS_BOOL bPoolReseted = FALSE;
497 
498     if (bPoolReseted)
499     {
500         return GOP_API_SUCCESS;
501     }
502     else
503     {
504         bPoolReseted = TRUE;
505     }
506     CheckGOPInstanceOpen();
507     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_RESETPOOL,&i) != UTOPIA_STATUS_SUCCESS)
508     {
509         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
510         return GOP_API_FAIL;
511     }
512     return GOP_API_SUCCESS;
513 
514 }
515 
Mapi_GOP_GWIN_ResetGOP(MS_U32 u32Gop)516 E_GOP_API_Result Mapi_GOP_GWIN_ResetGOP(MS_U32 u32Gop)
517 {
518     GOP_SET_PROPERTY_PARAM ioctl_info;
519     MS_U32 i;
520 
521     CheckGOPInstanceOpen();
522     ioctl_info.en_pro   = E_GOP_RESOURCE;
523     ioctl_info.gop_idx  = u32Gop;
524     ioctl_info.pSetting = (void*)&i;
525     ioctl_info.u32Size  = sizeof(MS_U32);
526 
527     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
528     {
529         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
530         return GOP_API_FAIL;
531     }
532 
533     return GOP_API_SUCCESS;
534 }
535 
536 /********************************************************************************/
537 /// Open API function:
538 ///     Read GWIN information from GOP registers
539 /// @param u8win \b IN  GWINID
540 /// @param pinfo \b OUT buffer to store GWIN information
541 /// @return GOP_API_SUCCESS - Success
542 /// @return GOP_API_FAIL - Failure
543 /********************************************************************************/
MApi_GOP_GWIN_GetWinInfo(MS_U8 u8win,GOP_GwinInfo * pinfo)544 E_GOP_API_Result MApi_GOP_GWIN_GetWinInfo(MS_U8 u8win, GOP_GwinInfo* pinfo)
545 {
546     GOP_ENTRY();
547 
548     GOP_GWIN_SETWININFO_PARAM ioctl_info;
549     GOP_BUFFER_INFO win_info;
550 
551     memset(&ioctl_info, 0x0, sizeof(GOP_GWIN_SETWININFO_PARAM));
552     memset(&win_info, 0x0, sizeof(GOP_BUFFER_INFO));
553 
554     ioctl_info.GwinId = u8win;
555     ioctl_info.pinfo = (MS_U32*)&win_info;
556     ioctl_info.u32Size = sizeof(GOP_BUFFER_INFO);
557 
558     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_GET_WININFO,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
559     {
560         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
561         GOP_RETURN( GOP_API_FAIL);
562     }
563 
564     pinfo->u32DRAMRBlkStart   =  win_info.addr;
565     pinfo->u16DispHPixelStart =  win_info.disp_rect.x ;
566     pinfo->u16DispVPixelStart =  win_info.disp_rect.y;
567     pinfo->u16DispHPixelEnd   =  win_info.disp_rect.x + win_info.disp_rect.w;
568     pinfo->u16DispVPixelEnd   =  win_info.disp_rect.y + win_info.disp_rect.h;
569     pinfo->u16RBlkHPixSize    =  win_info.width;
570     pinfo->u16RBlkVPixSize    =  win_info.height;
571     pinfo->clrType            =  (EN_GOP_COLOR_TYPE)win_info.fbFmt;
572     pinfo->u16RBlkHRblkSize   =  win_info.pitch;
573 
574 
575     GOP_RETURN(GOP_API_SUCCESS);
576 
577 }
578 MS_U32 _GOP_RegisterAllCBFunc(void);
579 
580 /********************************************************************************/
581 /// Set transparent color (ARGB domain). Note that this funcion just set transparent color to gop hareware but
582 /// does not enable gop transparent function yet.
583 /// @param clr \b IN: transparent color
584 /// @param mask \b IN: alpha value
585 /// @return GOP_API_SUCCESS - Success
586 /********************************************************************************/
MApi_GOP_GWIN_SetTransClr_8888_EX(MS_U8 u8GOP,MS_U32 clr,MS_U32 mask)587 E_GOP_API_Result MApi_GOP_GWIN_SetTransClr_8888_EX(MS_U8 u8GOP,MS_U32 clr, MS_U32 mask)
588 {
589 
590     GOP_SET_PROPERTY_PARAM ioctl_info;
591     GOP_TRANSCOLOR trans_set;
592 
593     GOP_ENTRY();
594 
595     trans_set.bEn = TRUE;
596     trans_set.color = clr;
597     trans_set.fmt = GOPTRANSCLR_FMT2;
598     trans_set.transclr_property = EN_TRANSCLR_SET_COLOR;
599 
600     ioctl_info.en_pro = E_GOP_TRANSCOLOR;
601     ioctl_info.gop_idx = u8GOP;
602     ioctl_info.pSetting = (void*)&trans_set;
603     ioctl_info.u32Size = sizeof(GOP_TRANSCOLOR);
604 
605     u32TransColor = clr;
606 
607     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
608     {
609         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
610         GOP_RETURN(GOP_API_FAIL);
611     }
612 
613     GOP_RETURN(GOP_API_SUCCESS);
614 }
MApi_GOP_GWIN_SetTransClr_8888(MS_U32 clr,MS_U32 mask)615 E_GOP_API_Result MApi_GOP_GWIN_SetTransClr_8888(MS_U32 clr, MS_U32 mask)
616 {
617     MS_U8 u8GOP;
618     E_GOP_API_Result ret;
619 
620     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
621     ret = MApi_GOP_GWIN_SetTransClr_8888_EX(u8GOP,clr,mask);
622     return ret;
623 }
624 
625 
MApi_GOP_GWIN_EnableT3DMode(MS_BOOL bEnable)626 E_GOP_API_Result MApi_GOP_GWIN_EnableT3DMode(MS_BOOL bEnable)
627 {
628     GOP_MISC_PARAM ioctl_info;
629     MS_BOOL  bEna;
630 
631     GOP_ENTRY();
632 
633     bEna = bEnable;
634     ioctl_info.misc_type = E_GOP_MISC_ENABLE_T3D;
635     ioctl_info.pMISC = (void*)&bEna;
636     ioctl_info.u32Size  = sizeof(MS_BOOL);
637 
638     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_MISC,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
639     {
640         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
641         GOP_RETURN( GOP_API_FAIL);
642     }
643 
644     GOP_RETURN(GOP_API_SUCCESS);
645 }
646 
647 /********************************************************************************/
648 /// Set clock for gop dwin (for dwin source is OP)
649 /// @return GOP_API_SUCCESS - Success
650 /********************************************************************************/
MApi_GOP_SetClkForCapture(void)651 E_GOP_API_Result MApi_GOP_SetClkForCapture(void)
652 {
653     GOP_MISC_PARAM ioctl_info;
654     MS_U32  value = 0;
655 
656     GOP_ENTRY();
657 
658     ioctl_info.misc_type = E_GOP_MISC_SET_CAPTURE_CLK;
659     ioctl_info.pMISC = (MS_U32*)&value;
660     ioctl_info.u32Size  = sizeof(MS_U32);
661 
662     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_MISC,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
663     {
664         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
665         GOP_RETURN( GOP_API_FAIL);
666     }
667 
668     GOP_RETURN(GOP_API_SUCCESS);
669 }
670 
671 GOP_CAPTURE_INFO g_CaptureInfo;
672 
673 /********************************************************************************/
674 /// Set gop dwin capture one frame
675 /// @return GOP_API_SUCCESS - Success
676 /********************************************************************************/
MApi_GOP_DWIN_CaptureOneFrame(void)677 E_GOP_API_Result MApi_GOP_DWIN_CaptureOneFrame(void)
678 {
679     GOP_ENTRY();
680 
681     GOP_DWIN_CAPTURE_PARAM ioctl_info;
682     GOP_CAPTURE_INFO dwin_info;
683 
684     ioctl_info.pDwin = (MS_U32*)&dwin_info;
685     ioctl_info.u32Size = sizeof(GOP_CAPTURE_INFO);
686 
687     g_CaptureInfo.framecount = 1;
688     g_CaptureInfo.bEn = FALSE;
689     g_CaptureInfo.bWait = TRUE;
690     memcpy(&dwin_info, &g_CaptureInfo, sizeof(GOP_CAPTURE_INFO));
691 
692     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_DWIN_CAPTURE,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
693     {
694         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
695         GOP_RETURN( GOP_API_FAIL);
696     }
697 
698     MsOS_ReadMemory();  //make mips can read the dram without cache coherence issue.
699     GOP_RETURN(GOP_API_SUCCESS);
700 
701 }
702 
703 
704 /********************************************************************************/
705 /// Set gop dwin capture one frame
706 /// @return GOP_API_SUCCESS - Success
707 /********************************************************************************/
MApi_GOP_DWIN_CaptureOneFrame2(void)708 E_GOP_API_Result MApi_GOP_DWIN_CaptureOneFrame2(void)
709 {
710     GOP_ENTRY();
711 
712     GOP_DWIN_CAPTURE_PARAM ioctl_info;
713     GOP_CAPTURE_INFO dwin_info;
714 
715     ioctl_info.pDwin = (MS_U32*)&dwin_info;
716     ioctl_info.u32Size = sizeof(GOP_CAPTURE_INFO);
717 
718     g_CaptureInfo.framecount = 1;
719     g_CaptureInfo.bEn = FALSE;
720     g_CaptureInfo.bWait = FALSE;
721     memcpy(&dwin_info, &g_CaptureInfo, sizeof(GOP_CAPTURE_INFO));
722 
723     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_DWIN_CAPTURE,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
724     {
725         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
726         GOP_RETURN( GOP_API_FAIL);
727     }
728 
729     MsOS_ReadMemory();  //make mips can read the dram without cache coherence issue.
730     GOP_RETURN(GOP_API_SUCCESS);
731 
732 }
733 
734 /********************************************************************************/
735 /// Config Dwin source (OP or MVOP).
736 /// @param enScanMode \b IN: EN_GOP_DWIN_SCAN_MODE
737 /// @return GOP_API_SUCCESS - Success
738 ///            GOP_API_INVALID_PARAMETERS - don't support this dwin source
739 /********************************************************************************/
MApi_GOP_DWIN_SetSourceSel(EN_GOP_DWIN_SRC_SEL enSrcSel)740 E_GOP_API_Result MApi_GOP_DWIN_SetSourceSel(EN_GOP_DWIN_SRC_SEL enSrcSel)
741 {
742     GOP_ENTRY();
743 
744     g_CaptureInfo.src = (EN_GOP_DWIN_SRC)enSrcSel;
745 
746     GOP_RETURN(GOP_API_SUCCESS);
747 }
748 
749 /******************************************************************************/
750 /// Set interrupt mask of GOP DWIN.
751 /// @param u8mask \b IN bitmask of interrupt type
752 ///   - bit7 DWIN VSYNC interrupt mask
753 ///   - bit6 Dump Window interlace Bottom Field ACK Interrupt Mask
754 ///   - bit5 Dump Window interlace Top Field ACK Interrupt Mask
755 ///   - bit4 Dump Window Progressive ACK Interrupt Mask
756 ///   - bit3:1 Reserved
757 ///   - bit0 GWIN VSYNC Interrupt Mask
758 /// @param bEnable \b IN
759 ///   - # TRUE enable interrupts specified by u8mask
760 ///   - # FALSE disable interrupts specified by u8mask
761 /// @return GOP_API_SUCCESS - Success
762 /******************************************************************************/
MApi_GOP_DWIN_EnableIntr(MS_U16 u8mask,MS_BOOL bEnable)763 E_GOP_API_Result MApi_GOP_DWIN_EnableIntr(MS_U16 u8mask, MS_BOOL bEnable)
764 {
765     GOP_ENTRY();
766 
767     GOP_DWIN_INTR_STATUS_PARAM ioctl_info;
768     GOP_DWIN_INTR_CTRL intrInfo;
769 
770     ioctl_info.intr_type = E_GOP_DWIN_INTR_CONTROL;
771     ioctl_info.pIntrInfo = (MS_U32*)&intrInfo;
772     ioctl_info.u32Size = sizeof(GOP_DWIN_INTR_CTRL);
773 
774     intrInfo.mask = u8mask;
775     intrInfo.intrEn = (MS_U32)bEnable;
776 
777     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_DWIN_INTR,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
778     {
779         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
780         GOP_RETURN(GOP_API_FAIL);
781     }
782 
783     GOP_RETURN(GOP_API_SUCCESS);
784 
785 }
786 
787 
788 /********************************************************************************/
789 /// Set gop output color type
790 /// @param type \b IN: gop output color type
791 ///   - # GOPOUT_RGB => RGB mode
792 ///   - # GOPOUT_YUV => YUV mode
793 /// @return GOP_API_SUCCESS - Success
794 /********************************************************************************/
MApi_GOP_GWIN_OutputColor_EX(MS_U8 u8GOP,EN_GOP_OUTPUT_COLOR type)795 E_GOP_API_Result MApi_GOP_GWIN_OutputColor_EX(MS_U8 u8GOP,EN_GOP_OUTPUT_COLOR type)
796 {
797     GOP_SET_PROPERTY_PARAM ioctl_info;
798     EN_GOP_OUTPUT_COLOR  output;
799 
800     GOP_ENTRY();
801 
802     output = type;
803     ioctl_info.en_pro   = E_GOP_OUTPUT_COLOR;
804     ioctl_info.gop_idx  = u8GOP;
805     ioctl_info.pSetting = (void*)&output;
806     ioctl_info.u32Size  = sizeof(EN_GOP_OUTPUT_COLOR);
807 
808     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
809     {
810         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
811         GOP_RETURN( GOP_API_FAIL);
812     }
813 
814     GOP_RETURN(GOP_API_SUCCESS);
815 }
MApi_GOP_GWIN_OutputColor(EN_GOP_OUTPUT_COLOR type)816 E_GOP_API_Result MApi_GOP_GWIN_OutputColor(EN_GOP_OUTPUT_COLOR type)
817 {
818     MS_U8 u8GOP;
819     E_GOP_API_Result ret;
820 
821     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
822     ret = MApi_GOP_GWIN_OutputColor_EX(u8GOP,type);
823     return ret;
824 }
825 
826 
827 /********************************************************************************/
828 /// Get GOP Dwin interrupt status
829 /// @return GOP Dwin interrupt status
830 /********************************************************************************/
MApi_GOP_DWIN_GetIntrStatus(void)831 MS_U16 MApi_GOP_DWIN_GetIntrStatus(void)
832 {
833     MS_U16 ret = 0;
834     GOP_ENTRY();
835 
836     GOP_DWIN_INTR_STATUS_PARAM ioctl_info;
837     MS_U16 intrStatus;
838 
839     ioctl_info.intr_type = E_GOP_DWIN_INTR_GETINFO;
840     ioctl_info.pIntrInfo = (void*)&intrStatus;
841     ioctl_info.u32Size = sizeof(MS_U16);
842 
843     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_DWIN_INTR,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
844     {
845         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
846         GOP_RETURN(GOP_API_FAIL);
847     }
848 
849 
850     GOP_RETURN(ret);
851 
852 }
853 
854 
855 //******************************************************************************
856 /// clear DWIN interrupt
857 /// @param u8mask \b IN: interrup mask
858 /// @return GOP_API_SUCCESS - Success
859 //******************************************************************************
MApi_GOP_DWIN_ClearIntr(MS_U16 u8mask)860 E_GOP_API_Result MApi_GOP_DWIN_ClearIntr(MS_U16 u8mask)
861 {
862     GOP_ENTRY();
863 
864     GOP_DWIN_INTR_STATUS_PARAM ioctl_info;
865     GOP_DWIN_INTR_CTRL intrInfo;
866 
867     ioctl_info.intr_type = E_GOP_DWIN_INTR_CONTROL;
868     ioctl_info.pIntrInfo = (MS_U32*)&intrInfo;
869     ioctl_info.u32Size = sizeof(GOP_DWIN_INTR_CTRL);
870 
871     intrInfo.mask = u8mask;
872     intrInfo.intrEn  = 0x0;
873 
874     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_DWIN_INTR,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
875     {
876         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
877         GOP_RETURN(GOP_API_FAIL);
878     }
879 
880     GOP_RETURN(GOP_API_SUCCESS);
881 
882 }
883 
884 //******************************************************************************
885 /// Get DWIN interrupt Information.
886 /// @param pDWinIntInfo \b OUT: dwin interrup flag
887 /// @return GOP_API_SUCCESS - Success
888 //******************************************************************************
889 #define DWIN_TIMEOUT_CNT     60UL
MApi_GOP_DWIN_GetDWinIntInfoTimeout(GOP_DWinIntInfo * pDWinIntInfo,MS_U32 u32Timeout)890 E_GOP_API_Result MApi_GOP_DWIN_GetDWinIntInfoTimeout(GOP_DWinIntInfo *pDWinIntInfo,MS_U32 u32Timeout)
891 {
892     MS_U16 ret = 0;
893     GOP_ENTRY();
894 
895     GOP_DWIN_INTR_STATUS_PARAM ioctl_info;
896     GOP_DWIN_INTR_TIME_OUT DWinIntinfoTimeout;
897 
898     memset(&DWinIntinfoTimeout, 0x0, sizeof(GOP_DWIN_INTR_TIME_OUT));
899     memcpy(&DWinIntinfoTimeout.DWinIntInfo, pDWinIntInfo, sizeof(GOP_DWinIntInfo));
900     DWinIntinfoTimeout.u32Timeout = u32Timeout;
901 
902     ioctl_info.intr_type = E_GOP_DWIN_INTR_GETINFO_TIMEOUT;
903     ioctl_info.pIntrInfo = (MS_U32*)&DWinIntinfoTimeout;
904     ioctl_info.u32Size = sizeof(GOP_DWIN_INTR_TIME_OUT);
905 
906     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_DWIN_INTR,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
907     {
908         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
909         GOP_RETURN(GOP_API_FAIL);
910     }
911 
912     memcpy(pDWinIntInfo, &DWinIntinfoTimeout.DWinIntInfo, sizeof(GOP_DWinIntInfo));
913 
914     GOP_RETURN(ret);
915 
916 }
917 
918 
919 //******************************************************************************
920 /// Get DWIN interrupt Information.
921 /// @param pDWinIntInfo \b OUT: dwin interrup flag
922 /// @return GOP_API_SUCCESS - Success
923 //******************************************************************************
MApi_GOP_DWIN_GetDWinIntInfo(GOP_DWinIntInfo * pDWinIntInfo)924 E_GOP_API_Result MApi_GOP_DWIN_GetDWinIntInfo(GOP_DWinIntInfo *pDWinIntInfo)
925 {
926     GOP_ENTRY();
927 
928     GOP_DWIN_INTR_STATUS_PARAM ioctl_info;
929     GOP_DWIN_INTR_TIME_OUT DWinIntinfoTimeout;
930 
931     memset(&DWinIntinfoTimeout, 0x0, sizeof(GOP_DWIN_INTR_TIME_OUT));
932     memcpy(&DWinIntinfoTimeout.DWinIntInfo, pDWinIntInfo, sizeof(GOP_DWinIntInfo));
933     DWinIntinfoTimeout.u32Timeout = 0;
934 
935     ioctl_info.intr_type = E_GOP_DWIN_INTR_GETINFO_TIMEOUT;
936     ioctl_info.pIntrInfo = (MS_U32*)&DWinIntinfoTimeout;
937     ioctl_info.u32Size = sizeof(GOP_DWIN_INTR_TIME_OUT);
938 
939     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_DWIN_INTR,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
940     {
941         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
942         GOP_RETURN(GOP_API_FAIL);
943     }
944 
945     memcpy(pDWinIntInfo, &DWinIntinfoTimeout.DWinIntInfo, sizeof(GOP_DWinIntInfo));
946 
947     GOP_RETURN(GOP_API_SUCCESS);
948 
949 }
950 /******************************************************************************/
951 /// Enable/Disable gop alpha inverse
952 /// @param bEnable \b IN: TRUE or FALSE
953 /// @return GOP_API_SUCCESS - Success
954 /******************************************************************************/
MApi_GOP_GWIN_SetAlphaInverse_EX(MS_U8 u8GOP,MS_BOOL bEnable)955 E_GOP_API_Result MApi_GOP_GWIN_SetAlphaInverse_EX(MS_U8 u8GOP,MS_BOOL bEnable)
956 {
957     MS_BOOL bAlphaInv;
958     GOP_SET_PROPERTY_PARAM ioctl_info;
959 
960     GOP_ENTRY();
961 
962     memset(&ioctl_info, 0x0, sizeof(GOP_SET_PROPERTY_PARAM));
963     bAlphaInv = bEnable;
964 
965 
966     ioctl_info.en_pro   = E_GOP_ALPHAINVERSE;
967     ioctl_info.gop_idx  = u8GOP;
968     ioctl_info.pSetting = (void*)&bAlphaInv;
969     ioctl_info.u32Size  = sizeof(MS_BOOL);
970 
971     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
972     {
973         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
974         GOP_RETURN( GOP_API_FAIL);
975     }
976 
977     GOP_RETURN(GOP_API_SUCCESS);
978 
979 
980 }
981 
MApi_GOP_GWIN_SetAlphaInverse(MS_BOOL bEnable)982 E_GOP_API_Result MApi_GOP_GWIN_SetAlphaInverse(MS_BOOL bEnable)
983 {
984     MS_U8 u8GOP;
985     E_GOP_API_Result ret;
986 
987     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
988     ret = MApi_GOP_GWIN_SetAlphaInverse_EX(u8GOP,bEnable);
989     return ret;
990 }
991 
992 /******************************************************************************/
993 /// Get gop alpha inverse setting
994 /// @param bEnable \b OUT: TRUE or FALSE
995 /// @return GOP_API_SUCCESS - Success
996 /******************************************************************************/
MApi_GOP_GWIN_GetAlphaInverse_EX(MS_U8 u8GOP,MS_BOOL * bEnable)997 E_GOP_API_Result MApi_GOP_GWIN_GetAlphaInverse_EX(MS_U8 u8GOP,MS_BOOL *bEnable)
998 {
999     MS_BOOL bAlphaInv;
1000     GOP_SET_PROPERTY_PARAM ioctl_info;
1001 
1002     GOP_ENTRY();
1003 
1004     memset(&ioctl_info, 0x0, sizeof(GOP_SET_PROPERTY_PARAM));
1005 
1006     ioctl_info.en_pro   = E_GOP_ALPHAINVERSE;
1007     ioctl_info.gop_idx  = u8GOP;
1008     ioctl_info.pSetting = (void*)&bAlphaInv;
1009     ioctl_info.u32Size  = sizeof(MS_BOOL);
1010 
1011     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
1012     {
1013         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1014         GOP_RETURN( GOP_API_FAIL);
1015     }
1016     *bEnable      = bAlphaInv;
1017 
1018     GOP_RETURN(GOP_API_SUCCESS);
1019 
1020 }
1021 
MApi_GOP_GWIN_GetAlphaInverse(MS_BOOL * bEnable)1022 E_GOP_API_Result MApi_GOP_GWIN_GetAlphaInverse(MS_BOOL *bEnable)
1023 {
1024     MS_U8 u8GOP;
1025     E_GOP_API_Result ret;
1026 
1027     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
1028     ret = MApi_GOP_GWIN_GetAlphaInverse_EX(u8GOP,bEnable);
1029     return ret;
1030 }
1031 
1032 /********************************************************************************/
1033 /// Set GOP bank force write mode for update register. When enable bank force write mode, update gop num registers action will directly
1034 /// take effect (do not wait next v-sync to update gop register!).
1035 /// @param bEnable \b IN: TRUE/FALSE
1036 /// @return GOP_API_SUCCESS - Success
1037 /********************************************************************************/
MApi_GOP_GWIN_SetBnkForceWrite(MS_U8 u8GOP,MS_BOOL bEnable)1038 E_GOP_API_Result MApi_GOP_GWIN_SetBnkForceWrite(MS_U8 u8GOP, MS_BOOL bEnable)
1039 {
1040     MS_BOOL bEna;
1041     GOP_SET_PROPERTY_PARAM ioctl_info;
1042 
1043     CheckGOPInstanceOpen();
1044     memset(&ioctl_info, 0x0, sizeof(GOP_SET_PROPERTY_PARAM));
1045     bEna = bEnable;
1046 
1047     ioctl_info.en_pro   = E_GOP_BANK_FORCE_WRITE;
1048     ioctl_info.gop_idx  = u8GOP;
1049     ioctl_info.pSetting = (void*)&bEna;
1050     ioctl_info.u32Size  = sizeof(MS_BOOL);
1051 
1052     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
1053     {
1054         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1055         return GOP_API_FAIL;
1056     }
1057 
1058     return GOP_API_SUCCESS;
1059 }
1060 
1061 
1062 /********************************************************************************/
1063 /// Set GOP force write mode for update register. When enable force write mode, all update gop registers action will directly
1064 /// take effect (do not wait next v-sync to update gop register!).
1065 /// @param bEnable \b IN: TRUE/FALSE
1066 /// @return GOP_API_SUCCESS - Success
1067 /********************************************************************************/
MApi_GOP_GWIN_SetForceWrite(MS_BOOL bEnable)1068 E_GOP_API_Result MApi_GOP_GWIN_SetForceWrite(MS_BOOL bEnable)
1069 {
1070     MS_BOOL bEna;
1071     GOP_SET_PROPERTY_PARAM ioctl_info;
1072 
1073     CheckGOPInstanceOpen();
1074     memset(&ioctl_info, 0x0, sizeof(GOP_SET_PROPERTY_PARAM));
1075     bEna = bEnable;
1076 
1077     ioctl_info.en_pro   = E_GOP_FORCE_WRITE;
1078     ioctl_info.gop_idx  = 0x0;
1079     ioctl_info.pSetting = (void*)&bEna;
1080     ioctl_info.u32Size  = sizeof(MS_BOOL);
1081 
1082     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
1083     {
1084         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1085         return GOP_API_FAIL;
1086     }
1087 
1088     return GOP_API_SUCCESS;
1089 }
1090 
1091 
1092 /********************************************************************************/
1093 /// Write optional palette values to GOP0 registers
1094 /// Note that this GOP0 palette table only support 256 group palette data
1095 /// @param *pPalArray \b IN Pointer to pallete list gonna set into pallete table
1096 /// @param u32PalStart \b IN start of pallete table gonna be overwrite
1097 /// @param u32PalEnd \b IN end of pallete table gonna be overwrite
1098 /// @param ePalType \b IN Pallete format, true/false ARGB8888
1099 /// @return GOP_API_SUCCESS - Success
1100 /********************************************************************************/
MApi_GOP_GWIN_SetPaletteOpt_EX(MS_U8 u8GOP,GOP_PaletteEntry * pPalArray,MS_U16 u32PalStart,MS_U16 u32PalEnd,EN_GOP_PALETTE_TYPE ePalType)1101 E_GOP_API_Result MApi_GOP_GWIN_SetPaletteOpt_EX(MS_U8 u8GOP,GOP_PaletteEntry *pPalArray, MS_U16 u32PalStart, MS_U16 u32PalEnd, EN_GOP_PALETTE_TYPE ePalType)
1102 {
1103     GOP_PALETTE_SET_PARAM  ioctl_info;
1104     GOP_PALETTE_ENTRY  palEntry;
1105 
1106     GOP_ENTRY();
1107 
1108     memset(&ioctl_info, 0x0, sizeof(GOP_PALETTE_SET_PARAM));
1109     memset(&palEntry, 0x0, sizeof(GOP_PALETTE_ENTRY));
1110 
1111     palEntry.gop_idx = u8GOP;
1112     palEntry.pClut = (void*)pPalArray;
1113     palEntry.start = u32PalStart;
1114     palEntry.end   = u32PalEnd;
1115     palEntry.palType = ePalType;
1116     palEntry.palSrc = E_GOP_4G_PALETTE;
1117 
1118     ioctl_info.pClut = (void*)&palEntry;
1119     ioctl_info.u32Size = sizeof(GOP_PALETTE_ENTRY);
1120 
1121     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_PALETTE_SET_ENTRY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
1122     {
1123         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1124         GOP_RETURN( GOP_API_FAIL);
1125     }
1126 
1127     GOP_RETURN(GOP_API_SUCCESS);
1128 
1129 }
1130 
MApi_GOP_GWIN_SetPaletteOpt(GOP_PaletteEntry * pPalArray,MS_U16 u32PalStart,MS_U16 u32PalEnd,EN_GOP_PALETTE_TYPE ePalType)1131 E_GOP_API_Result MApi_GOP_GWIN_SetPaletteOpt( GOP_PaletteEntry *pPalArray, MS_U16 u32PalStart, MS_U16 u32PalEnd, EN_GOP_PALETTE_TYPE ePalType)
1132 {
1133     MS_U8 u8GOP;
1134     E_GOP_API_Result ret;
1135 
1136     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();//GOP0 support only(X) , STB is GOP2 support palette
1137     ret = MApi_GOP_GWIN_SetPaletteOpt_EX(u8GOP,pPalArray,u32PalStart,u32PalEnd,ePalType);
1138     return ret;
1139 
1140 }
1141 /********************************************************************************/
1142 /// Set GOP0 palette table read out control
1143 /// @param type \b IN \copydoc EN_GOP_PALETTE_READTYPE
1144 /// @return GOP_API_SUCCESS - Success
1145 /********************************************************************************/
MApi_GOP_GWIN_SetPaletteRead_EX(MS_U8 u8GOP,EN_GOP_PALETTE_READTYPE type)1146 E_GOP_API_Result MApi_GOP_GWIN_SetPaletteRead_EX(MS_U8 u8GOP,EN_GOP_PALETTE_READTYPE type)
1147 {
1148 
1149     GOP_PALETTE_CONFIG_PARAM  ioctl_info;
1150     GOP_PAL_OPT  palOpt;
1151 
1152     GOP_ENTRY();
1153 
1154     memset(&ioctl_info, 0x0, sizeof(GOP_PALETTE_CONFIG_PARAM));
1155     memset(&palOpt, 0x0, sizeof(GOP_PAL_OPT));
1156 
1157     palOpt.gop_idx = u8GOP;
1158     palOpt.paltype = type;
1159     palOpt.palSrc = E_GOP_4G_PALETTE;
1160 
1161     ioctl_info.gop_idx = palOpt.gop_idx;
1162     ioctl_info.pPaletteInfo = (MS_U32*)&palOpt;
1163     ioctl_info.u32Size = sizeof(GOP_PAL_OPT);
1164 
1165     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_PALETTE_SET_CONFIG,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
1166     {
1167         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1168         GOP_RETURN( GOP_API_FAIL);
1169     }
1170 
1171     GOP_RETURN(GOP_API_SUCCESS);
1172 
1173 }
MApi_GOP_GWIN_SetPaletteRead(EN_GOP_PALETTE_READTYPE type)1174 E_GOP_API_Result MApi_GOP_GWIN_SetPaletteRead(EN_GOP_PALETTE_READTYPE type)
1175 {
1176     MS_U8 u8GOP;
1177     E_GOP_API_Result ret;
1178 
1179     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
1180     ret = MApi_GOP_GWIN_SetPaletteRead_EX(u8GOP,type);
1181     return ret;
1182 }
1183 /********************************************************************************/
1184 /// Read GOP0 palette values From Pallete
1185 /// @param idx \b IN Index for pallete wanna retrieve
1186 /// @param clr \b OUT color of specific pallete index
1187 /// @return GOP_API_SUCCESS - Success
1188 /********************************************************************************/
MApi_GOP_GWIN_ReadPalette_EX(MS_U8 u8GOP,MS_U8 idx,MS_U32 * clr)1189 E_GOP_API_Result MApi_GOP_GWIN_ReadPalette_EX(MS_U8 u8GOP,MS_U8 idx, MS_U32* clr)
1190 {
1191     GOP_PALETTE_SET_PARAM  ioctl_info;
1192     GOP_PALETTE_ENTRY  palEntry;
1193     MS_U32 u32Color;
1194     GOP_ENTRY();
1195 
1196     memset(&ioctl_info, 0x0, sizeof(GOP_PALETTE_SET_PARAM));
1197     memset(&palEntry, 0x0, sizeof(GOP_PALETTE_ENTRY));
1198 
1199     palEntry.gop_idx = u8GOP;
1200     palEntry.pClut = (MS_U32*)&u32Color;
1201     palEntry.start = idx;
1202     palEntry.end   = idx+1;
1203     palEntry.palType = E_GOP_PAL_ARGB8888;
1204     palEntry.palSrc = E_GOP_4G_PALETTE;
1205 
1206     ioctl_info.pClut = (void*)&palEntry;
1207     ioctl_info.u32Size = sizeof(GOP_PALETTE_ENTRY);
1208 
1209     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_PALETTE_GET_ENTRY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
1210     {
1211         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1212         GOP_RETURN( GOP_API_FAIL);
1213     }
1214     *clr = u32Color;
1215     GOP_RETURN(GOP_API_SUCCESS);
1216 }
1217 
MApi_GOP_GWIN_ReadPalette(MS_U8 idx,MS_U32 * clr)1218 E_GOP_API_Result MApi_GOP_GWIN_ReadPalette(MS_U8 idx, MS_U32* clr)
1219 {
1220     MS_U8 u8GOP;
1221     E_GOP_API_Result ret;
1222 
1223     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
1224     ret = MApi_GOP_GWIN_ReadPalette_EX(u8GOP,idx,clr);
1225     return ret;
1226 }
1227 
1228 /********************************************************************************/
1229 /// Write optional palette values to GOP1 registers
1230 /// Note that this GOP1 palette table only support 64 group palette data
1231 /// @param *pPalArray \b IN Pointer to pallete list gonna set into pallete table
1232 /// @param u32PalStart \b IN start of pallete table gonna be overwrite
1233 /// @param u32PalEnd \b IN end of pallete table gonna be overwrite
1234 /// @return GOP_API_SUCCESS - Success
1235 /********************************************************************************/
MApi_GOP_GWIN_2GSetPaletteOpt_EX(MS_U8 u8GOP,GOP_PaletteEntry * pPalArray,MS_U16 u32PalStart,MS_U16 u32PalEnd)1236 E_GOP_API_Result MApi_GOP_GWIN_2GSetPaletteOpt_EX(MS_U8 u8GOP,GOP_PaletteEntry *pPalArray, MS_U16 u32PalStart, MS_U16 u32PalEnd)
1237 {
1238 #ifndef CONFIG_GOP_2ND_PAL
1239     GOP_ERR("\33[0;36m   %s: #define CONFIG_GOP_2ND_PAL not opened\33[m \n",__FUNCTION__);
1240     return GOP_API_FUN_NOT_SUPPORTED;
1241 #else
1242     GOP_PALETTE_SET_PARAM  ioctl_info;
1243     GOP_PALETTE_ENTRY  palEntry;
1244 
1245     GOP_ENTRY();
1246 
1247     memset(&ioctl_info, 0x0, sizeof(GOP_PALETTE_SET_PARAM));
1248     memset(&palEntry, 0x0, sizeof(GOP_PALETTE_ENTRY));
1249 
1250     palEntry.gop_idx = u8GOP;
1251     palEntry.pClut = (MS_U32*)(void*)pPalArray;
1252     palEntry.start = u32PalStart;
1253     palEntry.end   = u32PalEnd;
1254     palEntry.palType = E_GOP_PAL_ARGB8888;
1255     palEntry.palSrc = E_GOP_2G_PALETTE;
1256 
1257     ioctl_info.pClut = (void*)&palEntry;
1258     ioctl_info.u32Size = sizeof(GOP_PALETTE_ENTRY);
1259 
1260     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_PALETTE_SET_ENTRY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
1261     {
1262         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1263         GOP_RETURN( GOP_API_FAIL);
1264     }
1265 
1266     GOP_RETURN(GOP_API_SUCCESS);
1267 #endif
1268 }
MApi_GOP_GWIN_2GSetPaletteOpt(GOP_PaletteEntry * pPalArray,MS_U16 u32PalStart,MS_U16 u32PalEnd)1269 E_GOP_API_Result MApi_GOP_GWIN_2GSetPaletteOpt(GOP_PaletteEntry *pPalArray, MS_U16 u32PalStart, MS_U16 u32PalEnd)
1270 {
1271     MS_U8 u8GOP;
1272     E_GOP_API_Result ret;
1273 
1274     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
1275     ret = MApi_GOP_GWIN_2GSetPaletteOpt_EX(u8GOP,pPalArray,u32PalStart,u32PalEnd);
1276     return ret;
1277 
1278 }
1279 /********************************************************************************/
1280 /// Set GOP1 palette table read out control
1281 /// @param type \b IN \copydoc EN_GOP_PALETTE_READTYPE
1282 /// @return GOP_API_SUCCESS - Success
1283 /********************************************************************************/
MApi_GOP_GWIN_2GSetPaletteRead_EX(MS_U8 u8GOP,EN_GOP_PALETTE_READTYPE type)1284 E_GOP_API_Result MApi_GOP_GWIN_2GSetPaletteRead_EX(MS_U8 u8GOP,EN_GOP_PALETTE_READTYPE type)
1285 {
1286 #ifndef CONFIG_GOP_2ND_PAL
1287     GOP_ERR("\33[0;36m   %s: #define CONFIG_GOP_2ND_PAL not opened\33[m \n",__FUNCTION__);
1288     return GOP_API_FUN_NOT_SUPPORTED;
1289 #else
1290     GOP_PALETTE_CONFIG_PARAM  ioctl_info;
1291     GOP_PAL_OPT  palOpt;
1292 
1293     GOP_ENTRY();
1294 
1295     memset(&ioctl_info, 0x0, sizeof(GOP_PALETTE_CONFIG_PARAM));
1296     memset(&palOpt, 0x0, sizeof(GOP_PAL_OPT));
1297 
1298     palOpt.gop_idx = u8GOP;
1299     palOpt.paltype = type;
1300     palOpt.palSrc = E_GOP_2G_PALETTE;
1301 
1302     ioctl_info.gop_idx = palOpt.gop_idx;
1303     ioctl_info.pPaletteInfo = (MS_U32*)&palOpt;
1304     ioctl_info.u32Size = sizeof(GOP_PAL_OPT);
1305 
1306     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_PALETTE_SET_CONFIG,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
1307     {
1308         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1309         GOP_RETURN( GOP_API_FAIL);
1310     }
1311 
1312     GOP_RETURN(GOP_API_SUCCESS);
1313 
1314 #endif
1315 }
MApi_GOP_GWIN_2GSetPaletteRead(EN_GOP_PALETTE_READTYPE type)1316 E_GOP_API_Result MApi_GOP_GWIN_2GSetPaletteRead(EN_GOP_PALETTE_READTYPE type)
1317 {
1318     MS_U8 u8GOP;
1319     E_GOP_API_Result ret;
1320 
1321     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
1322     ret = MApi_GOP_GWIN_2GSetPaletteRead_EX(u8GOP,type);
1323     return ret;
1324 }
1325 /********************************************************************************/
1326 /// Read GOP2G(GOP1) palette values From Pallete
1327 /// @param idx \b IN Index for pallete wanna retrieve
1328 /// @param clr \b OUT color of specific pallete index
1329 /// @return GOP_API_SUCCESS - Success
1330 /********************************************************************************/
MApi_GOP_GWIN_2GReadPalette_EX(MS_U8 u8GOP,MS_U8 idx,MS_U32 * clr)1331 E_GOP_API_Result MApi_GOP_GWIN_2GReadPalette_EX(MS_U8 u8GOP,MS_U8 idx, MS_U32* clr)
1332 {
1333 #ifndef CONFIG_GOP_2ND_PAL
1334     GOP_ERR("\33[0;36m   %s: #define CONFIG_GOP_2ND_PAL not opened\33[m \n",__FUNCTION__);
1335     return GOP_API_FUN_NOT_SUPPORTED;
1336 #else
1337     GOP_PALETTE_SET_PARAM  ioctl_info;
1338     GOP_PALETTE_ENTRY  palEntry;
1339     MS_U32 u32Color;
1340     GOP_ENTRY();
1341 
1342     memset(&ioctl_info, 0x0, sizeof(GOP_PALETTE_SET_PARAM));
1343     memset(&palEntry, 0x0, sizeof(GOP_PALETTE_ENTRY));
1344 
1345     palEntry.gop_idx = u8GOP;
1346     palEntry.pClut = (MS_U32*)&u32Color;
1347     palEntry.start = idx;
1348     palEntry.end   = idx+1;
1349     palEntry.palType = E_GOP_PAL_ARGB8888;
1350     palEntry.palSrc = E_GOP_2G_PALETTE;
1351 
1352     ioctl_info.pClut = (void*)&palEntry;
1353     ioctl_info.u32Size = sizeof(GOP_PALETTE_ENTRY);
1354 
1355     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_PALETTE_GET_ENTRY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
1356     {
1357         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1358         GOP_RETURN( GOP_API_FAIL);
1359     }
1360     *clr = u32Color;
1361     GOP_RETURN(GOP_API_SUCCESS);
1362 #endif
1363 }
MApi_GOP_GWIN_2GReadPalette(MS_U8 idx,MS_U32 * clr)1364 E_GOP_API_Result MApi_GOP_GWIN_2GReadPalette(MS_U8 idx, MS_U32* clr)
1365 {
1366     MS_U8 u8GOP;
1367     E_GOP_API_Result ret;
1368 
1369     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
1370     ret = MApi_GOP_GWIN_2GReadPalette_EX(u8GOP,idx,clr);
1371     return ret;
1372 }
1373 /********************************************************************************/
1374 /// Set stretch window H-Stretch ratio.
1375 /// Example: gwin size:960*540  target gwin size: 1920*1080
1376 ///     step1: MApi_GOP_GWIN_Set_HSCALE(TRUE, 960, 1920);
1377 ///     step2: MApi_GOP_GWIN_Set_VSCALE(TRUE, 540, 1080);
1378 ///     step3: MApi_GOP_GWIN_Set_STRETCHWIN(u8GOPNum, E_GOP_DST_OP0, 0, 0, 960, 540);
1379 /// @param bEnable \b IN:
1380 ///   - # TRUE enable
1381 ///   - # FALSE disable
1382 /// @param src \b IN: original size
1383 /// @param dst \b IN: target size
1384 /// @return GOP_API_SUCCESS - Success
1385 /********************************************************************************/
MApi_GOP_GWIN_Set_HSCALE_EX(MS_U8 u8GOP,MS_BOOL bEnable,MS_U16 src,MS_U16 dst)1386 E_GOP_API_Result MApi_GOP_GWIN_Set_HSCALE_EX(MS_U8 u8GOP,MS_BOOL bEnable, MS_U16 src, MS_U16 dst)
1387 {
1388     GOP_STRETCH_SET_PARAM ioctl_info;
1389     GOP_STRETCH_INFO stretch_info;
1390     GOP_ENTRY();
1391 
1392     memset(&ioctl_info, 0x0, sizeof(GOP_STRETCH_SET_PARAM));
1393     memset(&stretch_info, 0x0, sizeof(GOP_STRETCH_INFO));
1394 
1395     stretch_info.SrcRect.w = src;
1396     if (bEnable)
1397     {
1398         stretch_info.DstRect.w = dst;
1399     }
1400     else
1401     {
1402         stretch_info.DstRect.w = src;
1403     }
1404     ioctl_info.gop_idx = u8GOP;
1405     ioctl_info.enStrtchType = E_GOP_STRETCH_HSCALE;
1406     ioctl_info.pStretch = (MS_U32*)&stretch_info;
1407     ioctl_info.u32Size = sizeof(GOP_STRETCH_INFO);
1408 
1409     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_STRETCH,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
1410     {
1411         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1412         GOP_RETURN(GOP_API_FAIL);
1413     }
1414 
1415     GOP_RETURN(GOP_API_SUCCESS);
1416 }
1417 
MApi_GOP_GWIN_Set_HSCALE(MS_BOOL bEnable,MS_U16 src,MS_U16 dst)1418 E_GOP_API_Result MApi_GOP_GWIN_Set_HSCALE(MS_BOOL bEnable, MS_U16 src, MS_U16 dst)
1419 {
1420     MS_U8 u8GOP;
1421     E_GOP_API_Result ret;
1422 
1423     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
1424     ret = MApi_GOP_GWIN_Set_HSCALE_EX(u8GOP,bEnable,src,dst);
1425     return ret;
1426 }
1427 /********************************************************************************/
1428 /// Set stretch window V-Stretch ratio.
1429 /// Example: gwin size:960*540  target gwin size: 1920*1080
1430 ///     step1: MApi_GOP_GWIN_Set_HSCALE(TRUE, 960, 1920);
1431 ///     step2: MApi_GOP_GWIN_Set_VSCALE(TRUE, 540, 1080);
1432 ///     step3: MApi_GOP_GWIN_Set_STRETCHWIN(u8GOPNum, E_GOP_DST_OP0, 0, 0, 960, 540);
1433 /// @param bEnable \b IN:
1434 ///   - # TRUE enable
1435 ///   - # FALSE disable
1436 /// @param src \b IN: original size
1437 /// @param dst \b IN: target size
1438 /// @return GOP_API_SUCCESS - Success
1439 /********************************************************************************/
MApi_GOP_GWIN_Set_VSCALE_EX(MS_U8 u8GOP,MS_BOOL bEnable,MS_U16 src,MS_U16 dst)1440 E_GOP_API_Result MApi_GOP_GWIN_Set_VSCALE_EX(MS_U8 u8GOP,MS_BOOL bEnable, MS_U16 src, MS_U16 dst)
1441 {
1442     GOP_STRETCH_SET_PARAM ioctl_info;
1443     GOP_STRETCH_INFO stretch_info;
1444     GOP_ENTRY();
1445 
1446     memset(&ioctl_info, 0x0, sizeof(GOP_STRETCH_SET_PARAM));
1447     memset(&stretch_info, 0x0, sizeof(GOP_STRETCH_INFO));
1448 
1449     stretch_info.SrcRect.h = src;
1450     if (bEnable)
1451     {
1452         stretch_info.DstRect.h = dst;
1453     }
1454     else
1455     {
1456         stretch_info.DstRect.h = src;
1457     }
1458     ioctl_info.gop_idx = u8GOP;
1459     ioctl_info.enStrtchType = E_GOP_STRETCH_VSCALE;
1460     ioctl_info.pStretch = (MS_U32*)&stretch_info;
1461     ioctl_info.u32Size = sizeof(GOP_STRETCH_INFO);
1462 
1463     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_STRETCH,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
1464     {
1465         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1466         GOP_RETURN(GOP_API_FAIL);
1467     }
1468 
1469     GOP_RETURN(GOP_API_SUCCESS);
1470 }
MApi_GOP_GWIN_Set_VSCALE(MS_BOOL bEnable,MS_U16 src,MS_U16 dst)1471 E_GOP_API_Result MApi_GOP_GWIN_Set_VSCALE(MS_BOOL bEnable, MS_U16 src, MS_U16 dst)
1472 {
1473     MS_U8 u8GOP;
1474     E_GOP_API_Result ret;
1475 
1476     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
1477     ret = MApi_GOP_GWIN_Set_VSCALE_EX(u8GOP,bEnable,src,dst);
1478     return ret;
1479 }
1480 /********************************************************************************/
1481 /// Set GOP H stretch mode
1482 /// @param HStrchMode \b IN:
1483 ///   - # E_GOP_HSTRCH_6TAPE
1484 ///   - # E_GOP_HSTRCH_DUPLICATE
1485 /// @return GOP_API_SUCCESS - Success
1486 /********************************************************************************/
MApi_GOP_GWIN_Set_HStretchMode_EX(MS_U8 u8GOP,EN_GOP_STRETCH_HMODE HStrchMode)1487 E_GOP_API_Result MApi_GOP_GWIN_Set_HStretchMode_EX(MS_U8 u8GOP,EN_GOP_STRETCH_HMODE HStrchMode)
1488 {
1489     GOP_STRETCH_SET_PARAM ioctl_info;
1490     GOP_STRETCH_INFO stretch_info;
1491     GOP_ENTRY();
1492 
1493     memset(&ioctl_info, 0x0, sizeof(GOP_STRETCH_SET_PARAM));
1494     memset(&stretch_info, 0x0, sizeof(GOP_STRETCH_INFO));
1495 
1496     stretch_info.enHMode = HStrchMode;
1497 
1498     ioctl_info.gop_idx = u8GOP;
1499     ioctl_info.enStrtchType = E_GOP_STRETCH_HSTRETCH_MODE;
1500     ioctl_info.pStretch = (MS_U32*)&stretch_info;
1501     ioctl_info.u32Size = sizeof(GOP_STRETCH_INFO);
1502 
1503     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_STRETCH,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
1504     {
1505         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1506         GOP_RETURN(GOP_API_FAIL);
1507     }
1508 
1509     GOP_RETURN(GOP_API_SUCCESS);
1510 }
MApi_GOP_GWIN_Set_HStretchMode(EN_GOP_STRETCH_HMODE HStrchMode)1511 E_GOP_API_Result MApi_GOP_GWIN_Set_HStretchMode(EN_GOP_STRETCH_HMODE HStrchMode)
1512 {
1513     MS_U8 u8GOP;
1514     E_GOP_API_Result ret;
1515 
1516     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
1517     ret = MApi_GOP_GWIN_Set_HStretchMode_EX(u8GOP,HStrchMode);
1518     return ret;
1519 }
1520 
1521 /********************************************************************************/
1522 /// Set GOP Transparent color Stretch Mode
1523 /// @param VStrchMode \b IN:
1524 ///   - # E_GOP_TRANSPCOLOR_STRCH_DUPLICATE
1525 ///   - # E_GOP_TRANSPCOLOR_STRCH_ASNORMAL
1526 /// @return GOP_API_SUCCESS - Success
1527 /********************************************************************************/
MApi_GOP_GWIN_Set_TranspColorStretchMode_EX(MS_U8 u8GOP,EN_GOP_STRCH_TRANSPCOLORMODE TColorStrchMode)1528 E_GOP_API_Result MApi_GOP_GWIN_Set_TranspColorStretchMode_EX(MS_U8 u8GOP,EN_GOP_STRCH_TRANSPCOLORMODE  TColorStrchMode)
1529 {
1530     GOP_STRETCH_SET_PARAM ioctl_info;
1531     GOP_STRETCH_INFO stretch_info;
1532     GOP_ENTRY();
1533 
1534     memset(&ioctl_info, 0x0, sizeof(GOP_STRETCH_SET_PARAM));
1535     memset(&stretch_info, 0x0, sizeof(GOP_STRETCH_INFO));
1536 
1537     stretch_info.enTColorMode = TColorStrchMode;
1538 
1539     ioctl_info.gop_idx = u8GOP;
1540     ioctl_info.enStrtchType = E_GOP_STRETCH_TRANSPCOLOR_MODE;
1541     ioctl_info.pStretch = (MS_U32*)&stretch_info;
1542     ioctl_info.u32Size = sizeof(GOP_STRETCH_INFO);
1543 
1544     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_STRETCH,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
1545     {
1546         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1547         GOP_RETURN(GOP_API_FAIL);
1548     }
1549 
1550     GOP_RETURN(GOP_API_SUCCESS);
1551 }
1552 
MApi_GOP_GWIN_Set_TranspColorStretchMode(EN_GOP_STRCH_TRANSPCOLORMODE TColorStrchMode)1553 E_GOP_API_Result MApi_GOP_GWIN_Set_TranspColorStretchMode(EN_GOP_STRCH_TRANSPCOLORMODE  TColorStrchMode)
1554 {
1555     MS_U8 u8GOP;
1556     E_GOP_API_Result ret;
1557 
1558     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
1559     ret = MApi_GOP_GWIN_Set_TranspColorStretchMode_EX(u8GOP,TColorStrchMode);
1560     return ret;
1561 }
1562 
1563 /********************************************************************************/
1564 /// Set GOP V stretch mode
1565 /// @param VStrchMode \b IN:
1566 ///   - # E_GOP_VSTRCH_LINEAR
1567 ///   - # E_GOP_VSTRCH_DUPLICATE
1568 ///   - # E_GOP_VSTRCH_NEAREST
1569 /// @return GOP_API_SUCCESS - Success
1570 /********************************************************************************/
MApi_GOP_GWIN_Set_VStretchMode_EX(MS_U8 u8GOP,EN_GOP_STRETCH_VMODE VStrchMode)1571 E_GOP_API_Result MApi_GOP_GWIN_Set_VStretchMode_EX(MS_U8 u8GOP,EN_GOP_STRETCH_VMODE VStrchMode)
1572 {
1573     GOP_STRETCH_SET_PARAM ioctl_info;
1574     GOP_STRETCH_INFO stretch_info;
1575     GOP_ENTRY();
1576 
1577     memset(&ioctl_info, 0x0, sizeof(GOP_STRETCH_SET_PARAM));
1578     memset(&stretch_info, 0x0, sizeof(GOP_STRETCH_INFO));
1579 
1580     stretch_info.enVMode = VStrchMode;
1581     ioctl_info.gop_idx = u8GOP;
1582     ioctl_info.enStrtchType = E_GOP_STRETCH_VSTRETCH_MODE;
1583     ioctl_info.pStretch = (MS_U32*)&stretch_info;
1584     ioctl_info.u32Size = sizeof(GOP_STRETCH_INFO);
1585 
1586     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_STRETCH,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
1587     {
1588         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1589         GOP_RETURN(GOP_API_FAIL);
1590     }
1591 
1592     GOP_RETURN(GOP_API_SUCCESS);
1593 }
MApi_GOP_GWIN_Set_VStretchMode(EN_GOP_STRETCH_VMODE VStrchMode)1594 E_GOP_API_Result MApi_GOP_GWIN_Set_VStretchMode(EN_GOP_STRETCH_VMODE VStrchMode)
1595 {
1596     MS_U8 u8GOP;
1597     E_GOP_API_Result ret;
1598 
1599     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
1600     ret = MApi_GOP_GWIN_Set_VStretchMode_EX(u8GOP,VStrchMode);
1601     return ret;
1602 }
1603 
1604 //-------------------------------------------------------------------------------------------------
1605 /// set gop destination path clock
1606 /// @param gopNum \b IN: Number of GOP
1607 /// @param eDstType \b IN: gop destination type
1608 /// @return GOP_API_SUCCESS - Success
1609 //-------------------------------------------------------------------------------------------------
MApi_GOP_SetGOPClk(MS_U8 gopNum,EN_GOP_DST_TYPE eDstType)1610 E_GOP_API_Result MApi_GOP_SetGOPClk(MS_U8 gopNum, EN_GOP_DST_TYPE eDstType)
1611 {
1612     GOP_SET_PROPERTY_PARAM ioctl_info;
1613     EN_GOP_DST_TYPE eType;
1614 
1615     GOP_ENTRY();
1616 
1617     memset(&ioctl_info, 0x0, sizeof(GOP_SET_PROPERTY_PARAM));
1618     eType = eDstType;
1619 
1620 
1621     ioctl_info.en_pro   = E_GOP_CLK;
1622     ioctl_info.gop_idx  = gopNum;
1623     ioctl_info.pSetting = (void*)&eType;
1624     ioctl_info.u32Size  = sizeof(EN_GOP_DST_TYPE);
1625 
1626     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
1627     {
1628         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1629         GOP_RETURN( GOP_API_FAIL);
1630     }
1631 
1632     GOP_RETURN(GOP_API_SUCCESS);
1633 }
1634 
1635 
1636 //******************************************************************************
1637 /// Enable gop progressive mode
1638 /// @param bEnable \b IN:
1639 ///   - # TRUE Enable gop progressive mode
1640 ///   - # FALSE Disable gop progressive mode
1641 /// @return GOP_API_SUCCESS - Success
1642 //******************************************************************************
MApi_GOP_GWIN_EnableProgressive_EX(MS_U8 u8GOP,MS_BOOL bEnable)1643 E_GOP_API_Result MApi_GOP_GWIN_EnableProgressive_EX(MS_U8 u8GOP,MS_BOOL bEnable)
1644 {
1645 
1646     GOP_SET_PROPERTY_PARAM ioctl_info;
1647     MS_U32  Progressive;
1648 
1649     GOP_ENTRY();
1650 
1651     Progressive = bEnable;
1652 
1653     ioctl_info.en_pro   = E_GOP_PROGRESSIVE;
1654     ioctl_info.gop_idx  = u8GOP;
1655     ioctl_info.pSetting = (void*)&Progressive;
1656     ioctl_info.u32Size  = sizeof(MS_BOOL);
1657 
1658     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
1659     {
1660         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1661         GOP_RETURN( GOP_API_FAIL);
1662     }
1663 
1664     GOP_RETURN(GOP_API_SUCCESS);
1665 }
1666 
MApi_GOP_GWIN_EnableProgressive(MS_BOOL bEnable)1667 E_GOP_API_Result MApi_GOP_GWIN_EnableProgressive(MS_BOOL bEnable)
1668 {
1669     MS_U8 u8GOP;
1670     E_GOP_API_Result ret;
1671 
1672     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
1673     ret = MApi_GOP_GWIN_EnableProgressive_EX(u8GOP,bEnable);
1674     return ret;
1675 
1676 }
1677 
1678 //******************************************************************************
1679 /// Set gop update register method by only once.
1680 /// Example: if you want to update GOP function A, B, C in the same V sync, please write down your code like below
1681 /// MApi_GOP_GWIN_UpdateRegOnce(TRUE);
1682 /// GOP_FUN_A;
1683 /// GOP_FUN_B;
1684 /// GOP_FUN_C;
1685 /// MApi_GOP_GWIN_UpdateRegOnce(FALSE);
1686 /// @param bWriteRegOnce \b IN: TRUE/FALSE
1687 /// @return GOP_API_SUCCESS - Success
1688 //******************************************************************************
MApi_GOP_GWIN_UpdateRegOnce(MS_BOOL bWriteRegOnce)1689 E_GOP_API_Result MApi_GOP_GWIN_UpdateRegOnce(MS_BOOL bWriteRegOnce)
1690 {
1691     return MApi_GOP_GWIN_UpdateRegOnceEx(bWriteRegOnce, TRUE);
1692 }
1693 
1694 //******************************************************************************
1695 /// Extend MApi_GOP_GWIN_UpdateRegOnceEx, update special gop.
1696 /// Set gop update register method by only once.
1697 /// Example: if you want to update GOP function A, B, C in the same V sync, please write down your code like below
1698 /// MApi_GOP_GWIN_UpdateRegOnceByMask(u16GopMask,TRUE, TRUE);
1699 /// GOP_FUN_A;
1700 /// GOP_FUN_B;
1701 /// GOP_FUN_C;
1702 /// MApi_GOP_GWIN_UpdateRegOnceByMask(u16GopMask,FALSE, TRUE);
1703 /// @param u16GopMask    \b IN:bit0-gop0, bit1-gop1...
1704 /// @param bWriteRegOnce    \b IN: TRUE/FALSE
1705 /// @param bSync            \b IN: TRUE/FALSE
1706 /// @return GOP_API_SUCCESS - Success
1707 //******************************************************************************
MApi_GOP_GWIN_UpdateRegOnceByMask(MS_U16 u16GopMask,MS_BOOL bWriteRegOnce,MS_BOOL bSync)1708 E_GOP_API_Result MApi_GOP_GWIN_UpdateRegOnceByMask(MS_U16 u16GopMask,MS_BOOL bWriteRegOnce, MS_BOOL bSync)
1709 {
1710     GOP_UPDATE_PARAM ioctl_info;
1711     GOP_UPDATE_INFO update;
1712 
1713     GOP_ENTRY();
1714     memset(&ioctl_info, 0x0, sizeof(GOP_UPDATE_PARAM));
1715     memset(&update, 0x0, sizeof(GOP_UPDATE_INFO));
1716 
1717     update.gop_idx = u16GopMask;
1718     update.update_type = E_GOP_UPDATE_CURRENT_ONCE;
1719     update.bEn = bWriteRegOnce;
1720     update.bSync = bSync;
1721 
1722     ioctl_info.pUpdateInfo = (MS_U32*)&update;
1723     ioctl_info.u32Size = sizeof(GOP_UPDATE_INFO);
1724 
1725     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_UPDATE,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
1726     {
1727         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1728         GOP_RETURN( GOP_API_FAIL);
1729     }
1730 
1731     GOP_RETURN(GOP_API_SUCCESS);
1732 
1733 }
1734 
1735 //******************************************************************************
1736 /// Extend MApi_GOP_GWIN_UpdateRegOnce, add parameter bSync.
1737 /// Set gop update register method by only once.
1738 /// Example: if you want to update GOP function A, B, C in the same V sync, please write down your code like below
1739 /// MApi_GOP_GWIN_UpdateRegOnceEx(TRUE, TRUE);
1740 /// GOP_FUN_A;
1741 /// GOP_FUN_B;
1742 /// GOP_FUN_C;
1743 /// MApi_GOP_GWIN_UpdateRegOnceEx(FALSE, TRUE);
1744 /// @param bWriteRegOnce    \b IN: TRUE/FALSE
1745 /// @param bSync            \b IN: TRUE/FALSE
1746 /// @return GOP_API_SUCCESS - Success
1747 //******************************************************************************
MApi_GOP_GWIN_UpdateRegOnceEx2(MS_U8 u8GOP,MS_BOOL bWriteRegOnce,MS_BOOL bSync)1748 E_GOP_API_Result MApi_GOP_GWIN_UpdateRegOnceEx2(MS_U8 u8GOP,MS_BOOL bWriteRegOnce, MS_BOOL bSync)
1749 {
1750     GOP_UPDATE_PARAM ioctl_info;
1751     GOP_UPDATE_INFO update;
1752 
1753     GOP_ENTRY();
1754     memset(&ioctl_info, 0x0, sizeof(GOP_UPDATE_PARAM));
1755     memset(&update, 0x0, sizeof(GOP_UPDATE_INFO));
1756 
1757     update.gop_idx = u8GOP;
1758     update.update_type = E_GOP_UPDATE_ONCE;
1759     update.bEn = bWriteRegOnce;
1760     update.bSync = bSync;
1761 
1762     ioctl_info.pUpdateInfo = (MS_U32*)&update;
1763     ioctl_info.u32Size = sizeof(GOP_UPDATE_INFO);
1764 
1765     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_UPDATE,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
1766     {
1767         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1768         GOP_RETURN( GOP_API_FAIL);
1769     }
1770 
1771     GOP_RETURN(GOP_API_SUCCESS);
1772 
1773 }
1774 
MApi_GOP_GWIN_UpdateRegOnceEx(MS_BOOL bWriteRegOnce,MS_BOOL bSync)1775 E_GOP_API_Result MApi_GOP_GWIN_UpdateRegOnceEx(MS_BOOL bWriteRegOnce, MS_BOOL bSync)
1776 {
1777     MS_U8 u8GOP;
1778     E_GOP_API_Result ret;
1779 
1780     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
1781     ret = MApi_GOP_GWIN_UpdateRegOnceEx2(u8GOP,bWriteRegOnce,bSync);
1782     return ret;
1783 
1784 }
1785 
1786 //******************************************************************************
1787 /// API for initialize the GOP DWIN
1788 /// @return GOP_API_SUCCESS - Success
1789 //******************************************************************************
MApi_GOP_DWIN_Init(void)1790 E_GOP_API_Result MApi_GOP_DWIN_Init(void)
1791 {
1792     MS_U32 ioctl_info = 0;
1793 
1794     CheckGOPInstanceOpen();
1795     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_DWIN_INIT,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
1796     {
1797         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1798         return GOP_API_FAIL;
1799     }
1800     bInit =TRUE;
1801     return GOP_API_SUCCESS;
1802 }
1803 
1804 //******************************************************************************
1805 /// API for enable or disable DWIN
1806 /// @param bEnable \b IN DWIN enable or not
1807 /// @return GOP_API_SUCCESS - Success
1808 //******************************************************************************
MApi_GOP_DWIN_Enable(MS_BOOL bEnable)1809 E_GOP_API_Result MApi_GOP_DWIN_Enable(MS_BOOL bEnable)
1810 {
1811     GOP_ENTRY();
1812 
1813 
1814     GOP_DWIN_CAPTURE_PARAM ioctl_info;
1815     GOP_CAPTURE_INFO dwin_info;
1816     MS_U32 bpp;
1817     MS_U16 fCnt;
1818 
1819 
1820     ioctl_info.pDwin = (MS_U32*)&dwin_info;
1821     ioctl_info.u32Size = sizeof(GOP_CAPTURE_INFO);
1822 
1823     g_CaptureInfo.bEn = bEnable;
1824 
1825     if(g_CaptureInfo.fmt == GOP_DWIN_FMT_ARGB8888)
1826         bpp = 4;
1827     else
1828         bpp = 2;
1829 
1830     if(g_CaptureInfo.rect.w*g_CaptureInfo.rect.h *bpp ==0)
1831     {
1832         fCnt=0;
1833     }
1834     else
1835     {
1836         fCnt = (g_CaptureInfo.addr1[0]-g_CaptureInfo.addr[0])/(g_CaptureInfo.rect.w*g_CaptureInfo.rect.h *bpp);
1837     }
1838     g_CaptureInfo.framecount = fCnt;
1839 
1840 
1841     memcpy(&dwin_info, &g_CaptureInfo, sizeof(GOP_CAPTURE_INFO));
1842 
1843     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_DWIN_CAPTURE,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
1844     {
1845         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1846         GOP_RETURN( GOP_API_FAIL);
1847     }
1848 
1849     GOP_RETURN(GOP_API_SUCCESS);
1850 
1851 }
1852 
1853 //******************************************************************************
1854 /// API for enable or disable DWIN
1855 /// @param bEnable \b IN DWIN enable or not
1856 /// @return GOP_API_SUCCESS - Success
1857 //******************************************************************************
MApi_GOP_DWIN_EnableR2YCSC(MS_BOOL bEnable)1858 E_GOP_API_Result MApi_GOP_DWIN_EnableR2YCSC(MS_BOOL bEnable)
1859 {
1860     GOP_ENTRY();
1861 
1862     GOP_DWIN_PROPERTY_PARAM ioctl_info;
1863     MS_BOOL bEna;
1864 
1865     bEna = bEnable;
1866     ioctl_info.en_dwin_property = E_GOP_DWIN_R2Y;
1867     ioctl_info.pDwinProp = (void*)&bEna;
1868     ioctl_info.u32Size = sizeof(MS_BOOL);
1869 
1870     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_DWIN_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
1871     {
1872         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1873         GOP_RETURN( GOP_API_FAIL);
1874     }
1875 
1876     GOP_RETURN(GOP_API_SUCCESS);
1877 }
1878 
1879 
1880 //******************************************************************************
1881 /// API for enable or disable DWIN UV SWAP
1882 /// @param bEnable \b IN DWIN enable or not
1883 /// @return GOP_API_SUCCESS - Success
1884 //******************************************************************************
MApi_GOP_DWIN_SetUVSwap(MS_BOOL bEnable)1885 E_GOP_API_Result MApi_GOP_DWIN_SetUVSwap(MS_BOOL bEnable)
1886 {
1887     GOP_ENTRY();
1888 
1889     GOP_DWIN_PROPERTY_PARAM ioctl_info;
1890     MS_BOOL bEna;
1891 
1892     bEna = bEnable;
1893     ioctl_info.en_dwin_property = E_GOP_DWIN_UV_SWAP;
1894     ioctl_info.pDwinProp = (void*)&bEna;
1895     ioctl_info.u32Size = sizeof(MS_BOOL);
1896 
1897     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_DWIN_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
1898     {
1899         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1900         GOP_RETURN( GOP_API_FAIL);
1901     }
1902 
1903     GOP_RETURN(GOP_API_SUCCESS);
1904 }
1905 
1906 
1907 //******************************************************************************
1908 /// Get DWIN property
1909 /// @param pproperty \b OUT buffer to store DWIN property
1910 /// @return GOP_API_SUCCESS - Success
1911 //******************************************************************************
MApi_GOP_DWIN_GetWinProperty(GOP_DwinProperty * pproperty)1912 E_GOP_API_Result MApi_GOP_DWIN_GetWinProperty(GOP_DwinProperty *pproperty)
1913 {
1914     CheckGOPInstanceOpen();
1915     pproperty->u16x = g_CaptureInfo.rect.x;
1916     pproperty->u16y = g_CaptureInfo.rect.y;
1917     pproperty->u16w = g_CaptureInfo.rect.w;
1918     pproperty->u16h = g_CaptureInfo.rect.h;
1919     pproperty->u16fbw = g_CaptureInfo.pitch;
1920 
1921     pproperty->u32fbaddr0 = g_CaptureInfo.addr[0];
1922     pproperty->u32fbaddr1 = g_CaptureInfo.addr1[0];
1923 
1924     return GOP_API_SUCCESS;
1925 }
1926 
1927 //******************************************************************************
1928 /// Set DWIN property
1929 /// @param pproperty \b IN buffer to store DWIN property
1930 /// @return GOP_API_SUCCESS - Success
1931 //******************************************************************************
MApi_GOP_DWIN_SetWinProperty(GOP_DwinProperty * pproperty)1932 E_GOP_API_Result MApi_GOP_DWIN_SetWinProperty(GOP_DwinProperty *pproperty)
1933 {
1934     GOP_ENTRY();
1935 
1936     if((pproperty->u16h <=0) || (pproperty->u16w<=0))
1937     {
1938         GOP_ERR("\n %s DWIN Width(%d) or Height(%d) <= 0\n", __FUNCTION__,pproperty->u16w,pproperty->u16h);
1939         GOP_RETURN(GOP_API_FAIL);
1940     }
1941 
1942     g_CaptureInfo.rect.x = pproperty->u16x;
1943     g_CaptureInfo.rect.y = pproperty->u16y;
1944     g_CaptureInfo.rect.w = pproperty->u16w;
1945     g_CaptureInfo.rect.h = pproperty->u16h;
1946     g_CaptureInfo.pitch  = pproperty->u16fbw;
1947 
1948     g_CaptureInfo.addr[0] = pproperty->u32fbaddr0;
1949     g_CaptureInfo.addr1[0] = pproperty->u32fbaddr1;
1950 
1951     GOP_RETURN(GOP_API_SUCCESS);
1952 
1953 }
1954 
1955 //******************************************************************************
1956 /// Set DWIN data source scan type
1957 /// @param enScanMode \b IN: EN_GOP_DWIN_SCAN_MODE
1958 /// @return GOP_API_SUCCESS - Success
1959 //******************************************************************************
MApi_GOP_DWIN_SelectSourceScanType(EN_GOP_DWIN_SCAN_MODE enScanMode)1960 E_GOP_API_Result MApi_GOP_DWIN_SelectSourceScanType(EN_GOP_DWIN_SCAN_MODE enScanMode)
1961 {
1962     GOP_ENTRY();
1963 
1964     GOP_DWIN_PROPERTY_PARAM ioctl_info;
1965     EN_GOP_DWIN_SCAN_MODE enMode;
1966 
1967     enMode = enScanMode;
1968     ioctl_info.en_dwin_property = E_GOP_DWIN_SOURCE_SCAN_TYPE;
1969     ioctl_info.pDwinProp = (MS_U32*)&enMode;
1970     ioctl_info.u32Size = sizeof(EN_GOP_DWIN_SCAN_MODE);
1971 
1972     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_DWIN_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
1973     {
1974         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
1975         GOP_RETURN( GOP_API_FAIL);
1976     }
1977 
1978     GOP_RETURN(GOP_API_SUCCESS);
1979 }
1980 
1981 //******************************************************************************
1982 /// Set DWIN Capture format
1983 /// @param fmt \b IN: buffer format to store DWIN content
1984 /// @return GOP_API_SUCCESS - Success
1985 //******************************************************************************
MApi_GOP_DWIN_SetDataFmt(EN_GOP_DWIN_DATA_FMT fmt)1986 E_GOP_API_Result MApi_GOP_DWIN_SetDataFmt(EN_GOP_DWIN_DATA_FMT fmt)
1987 {
1988     GOP_ENTRY();
1989 
1990     g_CaptureInfo.fmt = (EN_GOP_DWIN_FMT)fmt;
1991 
1992     GOP_RETURN(GOP_API_SUCCESS);
1993 
1994 }
1995 
1996 /*****************************************************************************/
1997 /// Set DWIN Capture constant alpha value for format ARGB8888
1998 /// @param u8AlphaVal \b IN: constant alpha value
1999 /// @return GOP_API_SUCCESS - Success
2000 /*****************************************************************************/
MApi_GOP_DWIN_SetAlphaValue(MS_U8 u8AlphaVal)2001 E_GOP_API_Result MApi_GOP_DWIN_SetAlphaValue(MS_U8 u8AlphaVal)
2002 {
2003     GOP_ENTRY();
2004 
2005     GOP_DWIN_PROPERTY_PARAM ioctl_info;
2006     MS_U8 u8Value;
2007 
2008     u8Value = u8AlphaVal;
2009     ioctl_info.en_dwin_property = E_GOP_DWIN_ALPHA_VALUE;
2010     ioctl_info.pDwinProp = (void*)&u8Value;
2011     ioctl_info.u32Size = sizeof(MS_U8);
2012 
2013     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_DWIN_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
2014     {
2015         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2016         GOP_RETURN( GOP_API_FAIL);
2017     }
2018 
2019     GOP_RETURN(GOP_API_SUCCESS);
2020 }
2021 
2022 /*****************************************************************************/
2023 /// Set DWIN Capture alpha source
2024 /// @param source \b IN: alpha source
2025 /// @return GOP_API_SUCCESS - Success
2026 /*****************************************************************************/
MApi_GOP_DWIN_SetAlphaSrc(EN_GOP_DWIN_ALPHA_SRC source)2027 E_GOP_API_Result MApi_GOP_DWIN_SetAlphaSrc(EN_GOP_DWIN_ALPHA_SRC source)
2028 {
2029     GOP_ENTRY();
2030 
2031     GOP_DWIN_PROPERTY_PARAM ioctl_info;
2032     EN_GOP_DWIN_ALPHA_SRC enSource;
2033 
2034     enSource = source;
2035     ioctl_info.en_dwin_property = E_GOP_DWIN_ALPHA_SOURCE;
2036     ioctl_info.pDwinProp = (MS_U32*)&enSource;
2037     ioctl_info.u32Size = sizeof(EN_GOP_DWIN_ALPHA_SRC);
2038 
2039     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_DWIN_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
2040     {
2041         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2042         GOP_RETURN( GOP_API_FAIL);
2043     }
2044 
2045     GOP_RETURN(GOP_API_SUCCESS);
2046 }
2047 
2048 /*****************************************************************************/
2049 /// Set DWIN Capture alpha inverse
2050 /// @param source \b IN: enable alpha inverse
2051 /// @return GOP_API_SUCCESS - Success
2052 /*****************************************************************************/
MApi_GOP_DWIN_SetAlphaInverse(MS_BOOL bEnable)2053 E_GOP_API_Result MApi_GOP_DWIN_SetAlphaInverse(MS_BOOL bEnable)
2054 {
2055     GOP_ENTRY();
2056 
2057     GOP_DWIN_PROPERTY_PARAM ioctl_info;
2058     MS_BOOL bEna;
2059 
2060     bEna = bEnable;
2061     ioctl_info.en_dwin_property = E_GOP_DWIN_ALPHA_INVERSE;
2062     ioctl_info.pDwinProp = (void*)&bEna;
2063     ioctl_info.u32Size = sizeof(MS_BOOL);
2064 
2065     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_DWIN_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
2066     {
2067         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2068         GOP_RETURN( GOP_API_FAIL);
2069     }
2070 
2071     GOP_RETURN(GOP_API_SUCCESS);
2072 }
2073 
2074 /*****************************************************************************/
2075 /// Set DWIN UVSample mode
2076 /// @param mode \b IN: UVSample mode
2077 /// @return GOP_API_SUCCESS - Success
2078 /*****************************************************************************/
MApi_GOP_DWIN_SetUVSample(EN_GOP_DWIN_UVSAMPLE_Mode mode)2079 E_GOP_API_Result MApi_GOP_DWIN_SetUVSample(EN_GOP_DWIN_UVSAMPLE_Mode mode)
2080 {
2081     GOP_ENTRY();
2082 
2083     GOP_DWIN_PROPERTY_PARAM ioctl_info;
2084     EN_GOP_DWIN_UVSAMPLE_Mode enMode;
2085 
2086     enMode = mode;
2087     ioctl_info.en_dwin_property = E_GOP_DWIN_UV_SAMPLE;
2088     ioctl_info.pDwinProp = (MS_U32*)&enMode;
2089     ioctl_info.u32Size = sizeof(EN_GOP_DWIN_UVSAMPLE_Mode);
2090 
2091     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_DWIN_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
2092     {
2093         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2094         GOP_RETURN( GOP_API_FAIL);
2095     }
2096 
2097     GOP_RETURN(GOP_API_SUCCESS);
2098 }
2099 
2100 /*****************************************************************************/
2101 /// Set DWIN skipframe count
2102 /// @param mode \b IN: skipframe count
2103 /// @return GOP_API_SUCCESS - Success
2104 /*****************************************************************************/
MApi_GOP_DWIN_SetSkipFrame(MS_U32 framecount)2105 E_GOP_API_Result MApi_GOP_DWIN_SetSkipFrame(MS_U32 framecount)
2106 {
2107     GOP_ENTRY();
2108 
2109     GOP_DWIN_PROPERTY_PARAM ioctl_info;
2110     MS_U32 u32Count;
2111 
2112     u32Count = framecount;
2113     ioctl_info.en_dwin_property = E_GOP_DWIN_SKIP_FRAME;
2114     ioctl_info.pDwinProp = (MS_U32*)&u32Count;
2115     ioctl_info.u32Size = sizeof(MS_U32);
2116 
2117     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_DWIN_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
2118     {
2119         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2120         GOP_RETURN( GOP_API_FAIL);
2121     }
2122 
2123     GOP_RETURN(GOP_API_SUCCESS);
2124 
2125 }
2126 
2127 
2128 //-------------------------------------------------------------------------------------------------
2129 /// Get current active gop
2130 /// @return current gop number
2131 //-------------------------------------------------------------------------------------------------
MApi_GOP_GWIN_GetCurrentGOP(void)2132 MS_U8 MApi_GOP_GWIN_GetCurrentGOP(void)
2133 {
2134     GOP_GET_STATUS_PARAM ioctl_info;
2135     MS_U32 u32Gop = INVALID_GOP_NUM;
2136     GOP_ENTRY();
2137     ioctl_info.type = 0;
2138     ioctl_info.en_status = E_GOP_STATUS_CURRENT_GOP;
2139     ioctl_info.pStatus = (MS_U32*) &u32Gop;
2140     ioctl_info.u32Size = sizeof(MS_U32);
2141 
2142     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GET_STATUS,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
2143     {
2144         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2145         GOP_RETURN(GOP_API_FAIL);
2146     }
2147     GOP_RETURN((MS_U8)(u32Gop&0xFF));
2148 }
2149 
2150 /********************************************************************************/
2151 /// Set GWIN information to GOP registers
2152 /// @param u8win \b IN: GWINID
2153 /// @param pinfo \b IN: GWIN Information
2154 /// @return GOP_API_SUCCESS - Success
2155 /// @return GOP_API_FAIL - Failure
2156 /********************************************************************************/
MApi_GOP_GWIN_SetWinInfo(MS_U8 u8win,GOP_GwinInfo * pinfo)2157 E_GOP_API_Result MApi_GOP_GWIN_SetWinInfo(MS_U8 u8win, GOP_GwinInfo* pinfo)
2158 {
2159     GOP_GWIN_SETWININFO_PARAM ioctl_info;
2160     GOP_BUFFER_INFO win_info;
2161 
2162     GOP_ENTRY();
2163 
2164     memset(&ioctl_info, 0x0, sizeof(GOP_GWIN_SETWININFO_PARAM));
2165     memset(&win_info, 0x0, sizeof(GOP_BUFFER_INFO));
2166 
2167     ioctl_info.GwinId = u8win;
2168     ioctl_info.pinfo = (MS_U32*)&win_info;
2169     ioctl_info.u32Size = sizeof(GOP_BUFFER_INFO);
2170 
2171 
2172     win_info.addr = pinfo->u32DRAMRBlkStart;
2173     win_info.disp_rect.x = pinfo->u16DispHPixelStart;
2174     win_info.disp_rect.y = pinfo->u16DispVPixelStart;
2175     win_info.disp_rect.w = pinfo->u16DispHPixelEnd - pinfo->u16DispHPixelStart;
2176     win_info.disp_rect.h = pinfo->u16DispVPixelEnd - pinfo->u16DispVPixelStart;
2177     win_info.width  = pinfo->u16RBlkHPixSize;
2178     win_info.height = pinfo->u16RBlkVPixSize;
2179     win_info.fbFmt  = pinfo->clrType;
2180     win_info.pitch  = pinfo->u16RBlkHRblkSize;
2181 
2182     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_WININFO,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
2183     {
2184         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2185         GOP_RETURN( GOP_API_FAIL);
2186     }
2187 
2188     GOP_RETURN(GOP_API_SUCCESS);
2189 }
2190 
2191 /******************************************************************************/
2192 /// Get current frame buffer pool id
2193 /// @return current frame buffer pool id. 0: first frame buffer pool, 1: second frame buffer pool
2194 /******************************************************************************/
MApi_GOP_FB_Get(void)2195 MS_U8 MApi_GOP_FB_Get(void)
2196 {
2197     GOP_FB_PROPERTY_PARAM ioctl_info;
2198     MS_U8 u8PoolId = 0x0;
2199     GOP_ENTRY();
2200     ioctl_info.en_property = E_GOP_FB_POOLID;
2201     ioctl_info.FBId = 0x0;
2202     ioctl_info.pSet = (void*)&u8PoolId;
2203     ioctl_info.u32Size = sizeof(MS_U8);
2204 
2205     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_FB_GET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
2206     {
2207         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2208         GOP_RETURN(u8PoolId);
2209     }
2210 
2211     GOP_RETURN(u8PoolId);
2212 }
2213 
2214 //******************************************************************************
2215 /// Set GWin Attribute to Shared. If shared GWin, More than one process could
2216 /// access this GWin.
2217 /// @param winId \b IN: GWIN ID for shared
2218 /// @param bIsShared \b IN: shared or not
2219 /// @return GOP_API_SUCCESS - Success
2220 //******************************************************************************
MApi_GOP_GWIN_SetGWinShared(MS_U8 winId,MS_BOOL bIsShared)2221 E_GOP_API_Result MApi_GOP_GWIN_SetGWinShared(MS_U8 winId, MS_BOOL bIsShared)
2222 {
2223     GOP_GWIN_PROPERTY_PARAM ioctl_info;
2224     MS_BOOL bShared;
2225 
2226     GOP_ENTRY();
2227 
2228     bShared = bIsShared;
2229     ioctl_info.en_property = E_GOP_GWIN_SHARE;
2230     ioctl_info.GwinId = winId;
2231     ioctl_info.pSet = (void*)&bShared;
2232     ioctl_info.u32Size = sizeof(MS_BOOL);
2233 
2234     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
2235     {
2236         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2237         GOP_RETURN(GOP_API_FAIL);
2238     }
2239 
2240     GOP_RETURN(GOP_API_SUCCESS);
2241 }
2242 
2243 //******************************************************************************
2244 /// Set Reference cnt of shared GWin.
2245 /// @param winId \b IN: GWIN ID for shared
2246 /// @param u16SharedCnt \b IN: shared reference cnt.
2247 /// @return GOP_API_SUCCESS - Success
2248 //******************************************************************************
MApi_GOP_GWIN_SetGWinSharedCnt(MS_U8 winId,MS_U16 u16SharedCnt)2249 E_GOP_API_Result MApi_GOP_GWIN_SetGWinSharedCnt(MS_U8 winId, MS_U16 u16SharedCnt)
2250 {
2251     GOP_GWIN_PROPERTY_PARAM ioctl_info;
2252     MS_U16 u16Cnt;
2253 
2254     GOP_ENTRY();
2255 
2256     u16Cnt = u16SharedCnt;
2257     ioctl_info.en_property = E_GOP_GWIN_SHARE_CNT;
2258     ioctl_info.GwinId = winId;
2259     ioctl_info.pSet = (void*)&u16Cnt;
2260     ioctl_info.u32Size = sizeof(MS_U16);
2261 
2262     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
2263     {
2264         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2265         GOP_RETURN(GOP_API_FAIL);
2266     }
2267 
2268     GOP_RETURN(GOP_API_SUCCESS);
2269 }
2270 
2271 //******************************************************************************
2272 /// Create GWIN
2273 /// @param width \b IN: GWIN width
2274 /// @param height \b IN: GWIN height
2275 /// @param fbFmt \b IN: frame buffer pixel format
2276 ///   - #0xFFFF default FB format
2277 /// @return The id for the created GWIN, if return 0xff, it represents create gwin fail
2278 //******************************************************************************
MApi_GOP_GWIN_CreateWin(MS_U16 width,MS_U16 height,MS_U16 fbFmt)2279 MS_U8 MApi_GOP_GWIN_CreateWin(MS_U16 width, MS_U16 height, MS_U16 fbFmt)
2280 {
2281     MS_U32 u32FBId = INVALID_POOL_NEXT_FBID;
2282     MS_U8 winId =INVALID_GWIN_ID;
2283     GOP_ENTRY();
2284 
2285     u32FBId = MApi_GOP_GWIN_GetFree32FBID();
2286 
2287     MApi_GOP_GWIN_Create32FB(u32FBId,0,0,width,height,fbFmt);
2288 
2289     winId = MApi_GOP_GWIN_GetFreeWinID();
2290 
2291     MApi_GOP_GWIN_Map32FB2Win(u32FBId,winId);
2292 
2293     GOP_RETURN(winId);
2294 }
2295 
2296 
2297 //******************************************************************************
2298 /// Create GWIN
2299 /// @param width \b IN: GWIN width
2300 /// @param height \b IN: GWIN height
2301 /// @param fbFmt \b IN: frame buffer pixel format
2302 ///   - #0xFFFF default FB format
2303 /// @param FBString \b IN: open by which one application
2304 /// @return The id for the created GWIN, if return 0xff, it represents create gwin fail
2305 //******************************************************************************
MApi_GOP_GWIN_CreateWin2(MS_U16 width,MS_U16 height,MS_U16 fbFmt,EN_GOP_FRAMEBUFFER_STRING FBString)2306 MS_U8 MApi_GOP_GWIN_CreateWin2(MS_U16 width, MS_U16 height, MS_U16 fbFmt, EN_GOP_FRAMEBUFFER_STRING FBString)
2307 {
2308     MS_U32 u32FBId = INVALID_POOL_NEXT_FBID;
2309     MS_U8 winId =INVALID_GWIN_ID;
2310     GOP_ENTRY();
2311 
2312     u32FBId = MApi_GOP_GWIN_GetFree32FBID();
2313 
2314     MApi_GOP_GWIN_Create32FB2_EXT(u32FBId, 0, 0, width, height, fbFmt ,FBString);
2315 
2316     winId = MApi_GOP_GWIN_GetFreeWinID();
2317 
2318     MApi_GOP_GWIN_Map32FB2Win(u32FBId,winId);
2319 
2320     GOP_RETURN(winId);
2321 
2322 
2323 }
2324 
2325 
2326 //******************************************************************************
2327 /// Create GWIN and assign frame buffer to this GWIN
2328 /// @param u8GOP \b IN: GOP number
2329 /// @param FBId \b IN: frame buffer ID
2330 /// @param dispX \b IN: frame buffer starting x position
2331 /// @param dispY \b IN: frame buffer starting y position
2332 /// @return The id for the created GWIN, if return 0xff, it represents create gwin fail
2333 //******************************************************************************
MApi_GOP_GWIN_CreateWin_Assign_FB(MS_U8 u8GOP,MS_U8 FBId,MS_U16 dispX,MS_U16 dispY)2334 MS_U8 MApi_GOP_GWIN_CreateWin_Assign_FB(MS_U8 u8GOP, MS_U8 FBId, MS_U16 dispX, MS_U16 dispY)
2335 {
2336     return MApi_GOP_GWIN_CreateWin_Assign_32FB(u8GOP, (MS_U32)FBId, dispX, dispY);
2337 }
2338 
MApi_GOP_GWIN_CreateWin_Assign_32FB(MS_U8 u8GOP,MS_U32 u32FBId,MS_U16 dispX,MS_U16 dispY)2339 MS_U8 MApi_GOP_GWIN_CreateWin_Assign_32FB(MS_U8 u8GOP, MS_U32 u32FBId, MS_U16 dispX, MS_U16 dispY)
2340 {
2341     MS_U8 winId =INVALID_GWIN_ID;
2342     GOP_ENTRY();
2343 
2344     MApi_GOP_GWIN_SwitchGOP(u8GOP);
2345 
2346     winId = MApi_GOP_GWIN_GetFreeWinID();
2347 
2348     MApi_GOP_GWIN_Map32FB2Win(u32FBId,winId);
2349 
2350     GOP_RETURN(winId);
2351 
2352 }
2353 
2354 //******************************************************************************
2355 /// Create given GWIN id
2356 /// @param u8WinId \b IN: GWIN id
2357 /// @param width \b IN: GWIN width
2358 /// @param height \b IN: GWIN height
2359 /// @param fbFmt \b IN: GWIN color format
2360 /// @return The id for the created GWIN, if return 0xff, it represents create gwin fail
2361 //******************************************************************************
MApi_GOP_GWIN_CreateStaticWin(MS_U8 u8WinId,MS_U16 width,MS_U16 height,MS_U16 fbFmt)2362 MS_U8 MApi_GOP_GWIN_CreateStaticWin(MS_U8 u8WinId, MS_U16 width, MS_U16 height, MS_U16 fbFmt)
2363 {
2364     E_GOP_API_Result eRet=GOP_API_FAIL;
2365     MS_U32 u32FBId = INVALID_POOL_NEXT_FBID;
2366 
2367     GOP_ENTRY();
2368     u32FBId = MApi_GOP_GWIN_GetFree32FBID();
2369     MApi_GOP_GWIN_Create32FB(u32FBId,0,0,width,height,fbFmt);
2370     eRet = MApi_GOP_GWIN_Map32FB2Win(u32FBId,u8WinId);
2371     GOP_RETURN(eRet);
2372 }
2373 
2374 
2375 //******************************************************************************
2376 /// Create GWIN by given GWIN id
2377 /// @param u8WinId \b IN: GWIN id
2378 /// @param width \b IN: GWIN width
2379 /// @param height \b IN: GWIN height
2380 /// @param fbFmt \b IN: GWIN color format
2381 /// @param FBString \b IN: open by which one application
2382 /// @return The id for the created GWIN, if return 0xff, it represents create gwin fail
2383 //******************************************************************************
MApi_GOP_GWIN_CreateStaticWin2(MS_U8 u8WinId,MS_U16 width,MS_U16 height,MS_U16 fbFmt,EN_GOP_FRAMEBUFFER_STRING FBString)2384 MS_U8 MApi_GOP_GWIN_CreateStaticWin2(MS_U8 u8WinId, MS_U16 width, MS_U16 height, MS_U16 fbFmt, EN_GOP_FRAMEBUFFER_STRING FBString)
2385 {
2386     E_GOP_API_Result eRet=GOP_API_FAIL;
2387     MS_U32 u32FBId = INVALID_POOL_NEXT_FBID;
2388 
2389     GOP_ENTRY();
2390     u32FBId = MApi_GOP_GWIN_GetFree32FBID();
2391     MApi_GOP_GWIN_Create32FB2_EXT(u32FBId, 0, 0, width, height, fbFmt ,FBString);
2392     eRet = MApi_GOP_GWIN_Map32FB2Win(u32FBId,u8WinId);
2393     GOP_RETURN(eRet);
2394 
2395 }
2396 
2397 
2398 //******************************************************************************
2399 /// Create GWIN by given GWIN id and frame buffer id
2400 /// @param u8WinId \b IN: GWIN id
2401 /// @param u8GOP \b IN: GOP number
2402 /// @param FBId \b IN: frame buffer id
2403 /// @param dispX \b IN: gwin's frame buffer starting x
2404 /// @param dispY \b IN: gwin's frame buffer starting y
2405 /// @return The id for the created GWIN, if return 0xff, it represents create gwin fail
2406 //******************************************************************************
MApi_GOP_GWIN_CreateStaticWin_Assign_FB(MS_U8 u8WinId,MS_U8 u8GOP,MS_U8 FBId,MS_U16 dispX,MS_U16 dispY)2407 MS_U8 MApi_GOP_GWIN_CreateStaticWin_Assign_FB(MS_U8 u8WinId, MS_U8 u8GOP, MS_U8 FBId, MS_U16 dispX, MS_U16 dispY)
2408 {
2409     return MApi_GOP_GWIN_CreateStaticWin_Assign_32FB(u8WinId, u8GOP, (MS_U32)FBId, dispX, dispY);
2410 }
2411 
MApi_GOP_GWIN_CreateStaticWin_Assign_32FB(MS_U8 u8WinId,MS_U8 u8GOP,MS_U32 u32FBId,MS_U16 dispX,MS_U16 dispY)2412 MS_U8 MApi_GOP_GWIN_CreateStaticWin_Assign_32FB(MS_U8 u8WinId, MS_U8 u8GOP, MS_U32 u32FBId, MS_U16 dispX, MS_U16 dispY)
2413 {
2414     GOP_ENTRY();
2415 
2416     MApi_GOP_GWIN_Map32FB2Win(u32FBId,u8WinId);
2417 
2418     GOP_RETURN(u8WinId);
2419 }
2420 
2421 
2422 /******************************************************************************/
2423 /// Check if GWIN is created
2424 /// @param gId \b IN: GWINID
2425 /// @return TRUE or FALSE
2426 /******************************************************************************/
MApi_GOP_GWIN_IsGwinExist(MS_U8 gId)2427 MS_U8 MApi_GOP_GWIN_IsGwinExist(MS_U8 gId)
2428 {
2429     GOP_GWIN_PROPERTY_PARAM ioctl_info;
2430     MS_U8 u8Exist = FALSE;
2431 
2432     GOP_ENTRY();
2433     ioctl_info.en_property = E_GOP_GWIN_EXIST;
2434     ioctl_info.GwinId = gId;
2435     ioctl_info.pSet = (void*)&u8Exist;
2436     ioctl_info.u32Size = sizeof(MS_U8);
2437 
2438     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_GET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
2439     {
2440         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2441         GOP_RETURN(u8Exist);
2442     }
2443 
2444     GOP_RETURN(u8Exist);
2445 }
2446 
2447 /******************************************************************************/
2448 /// Get total active gwin number
2449 /// @return total active gwin number
2450 /******************************************************************************/
MApi_GOP_GWIN_GetActiveGWIN(void)2451 MS_U16   MApi_GOP_GWIN_GetActiveGWIN(void)
2452 {
2453     MS_U8 gwinNum = 0;
2454     MS_U8 i;
2455     GOP_ENTRY();
2456 
2457     for(i = 0; i < MAX_GWIN_SUPPORT ; i++)
2458     {
2459         if(MApi_GOP_GWIN_IsGWINEnabled(i) == TRUE)
2460         {
2461             gwinNum |= 1<<i;
2462         }
2463     }
2464     GOP_RETURN(gwinNum);
2465 
2466 }
2467 
2468 //******************************************************************************
2469 /// Enable GWIN for display
2470 /// @param winId \b IN: GWIN id
2471 /// @param bEnable \b IN:
2472 ///   - # TRUE Show GWIN
2473 ///   - # FALSE Hide GWIN
2474 /// @return GOP_API_SUCCESS - Success
2475 /// @return GOP_API_FAIL - Failure
2476 //******************************************************************************
MApi_GOP_GWIN_Enable(MS_U8 winId,MS_BOOL bEnable)2477 E_GOP_API_Result MApi_GOP_GWIN_Enable(MS_U8 winId, MS_BOOL bEnable)
2478 {
2479     GOP_GWIN_PROPERTY_PARAM ioctl_info;
2480 
2481     GOP_ENTRY();
2482     ioctl_info.en_property = E_GOP_GWIN_ENABLE;
2483     ioctl_info.GwinId = winId;
2484     ioctl_info.pSet = (void*) &bEnable;
2485     ioctl_info.u32Size = sizeof(MS_BOOL);
2486 
2487     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
2488     {
2489         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2490         GOP_RETURN(GOP_API_FAIL);
2491     }
2492 
2493     GOP_RETURN(GOP_API_SUCCESS);
2494 
2495 }
2496 
2497 /********************************************************************************/
2498 /// Check if GWIN is enabled
2499 /********************************************************************************/
MApi_GOP_GWIN_IsEnabled(void)2500 MS_BOOL MApi_GOP_GWIN_IsEnabled(void)
2501 {
2502     MS_U8 i = 0;
2503     MS_BOOL bEnable =FALSE;
2504     GOP_ENTRY();
2505 
2506     while(i<MAX_GWIN_SUPPORT)
2507     {
2508         bEnable = MApi_GOP_GWIN_IsGWINEnabled(i);
2509         if (bEnable==TRUE)
2510         {
2511             GOP_RETURN(TRUE);
2512         }
2513         i++;
2514     }
2515     GOP_RETURN(FALSE);
2516 }
2517 
2518 //******************************************************************************
2519 /// Check if all GWIN is currently enabled
2520 /// @return  - # TRUE GWins are enabled
2521 /// @return  - # FALSE not all GWins are enabled
2522 //******************************************************************************
MApi_GOP_GWIN_IsAllGWINDisabled(void)2523 MS_BOOL MApi_GOP_GWIN_IsAllGWINDisabled(void)
2524 {
2525     MS_BOOL ret;
2526     GOP_ENTRY();
2527 
2528     ret =  MApi_GOP_GWIN_IsEnabled();
2529     GOP_RETURN(ret);
2530 
2531 }
2532 
2533 //******************************************************************************
2534 /// Check if all some GWIN is currently enabled
2535 /// @param  winId \b IN: gwin id
2536 /// @return  - the according GWin is enabled or not
2537 //******************************************************************************
MApi_GOP_GWIN_IsGWINEnabled(MS_U8 winId)2538 MS_BOOL MApi_GOP_GWIN_IsGWINEnabled(MS_U8 winId)
2539 {
2540     MS_BOOL bEn;
2541     GOP_GWIN_PROPERTY_PARAM ioctl_info;
2542 
2543     GOP_ENTRY();
2544 
2545     ioctl_info.en_property = E_GOP_GWIN_ENABLE;
2546     ioctl_info.GwinId = winId;
2547     ioctl_info.pSet = (void*) &bEn;
2548     ioctl_info.u32Size = sizeof(MS_BOOL);
2549 
2550     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_GET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
2551     {
2552         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2553         GOP_RETURN( GOP_API_FAIL);
2554     }
2555 
2556     GOP_RETURN(bEn);
2557 
2558 
2559 }
2560 
2561 //******************************************************************************
2562 /// [Obsolete Function]
2563 /// @param hext \b IN
2564 ///   - 0 disable horizontal pixel duplication
2565 ///   - 1 enable  horizontal pixel duplication
2566 /// @param vext \b IN
2567 ///   - 0 disable vertical line duplication
2568 ///   - 1 enable  vertical line duplication
2569 /// @return GOP_API_SUCCESS - Success
2570 //******************************************************************************
MApi_GOP_GWIN_SetDuplication(MS_U8 hext,MS_U8 vext)2571 E_GOP_API_Result MApi_GOP_GWIN_SetDuplication(MS_U8 hext, MS_U8 vext)
2572 {
2573 //NOT USE FOR COVERITY HAPPY -_-~
2574 // THE CODE BELOW is useless
2575     GOP_ENTRY();
2576     UNUSED(hext);
2577     UNUSED(vext);
2578     GOP_RETURN(GOP_API_SUCCESS);
2579 
2580 }
2581 
2582 
2583 /******************************************************************************/
2584 /// Delete the GWIN, free corresponding frame buffer
2585 /// @param winId \b IN GWIN id
2586 /// @return GOP_API_SUCCESS - Success
2587 /// @return GOP_API_FAIL - Failure
2588 /******************************************************************************/
MApi_GOP_GWIN_DeleteWin(MS_U8 winId)2589 E_GOP_API_Result MApi_GOP_GWIN_DeleteWin(MS_U8 winId)
2590 {
2591     GOP_GWIN_DESTROY_PARAM ioctl_info;
2592     MS_U32 u32FBID=DRV_MAX_GWIN_FB_SUPPORT;
2593 
2594     GOP_ENTRY();
2595     memset(&ioctl_info, 0x0, sizeof(GOP_GWIN_DESTROY_PARAM));
2596     ioctl_info.GwinId = winId;
2597 
2598     u32FBID = MApi_GOP_GWIN_Get32FBfromGWIN(winId);
2599     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_DESTROY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
2600     {
2601         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2602         GOP_RETURN(GOP_API_FAIL);
2603     }
2604 
2605     if(MApi_GOP_GWIN_Is32FBExist(u32FBID)==TRUE)
2606     {
2607         MApi_GOP_GWIN_Destroy32FB(u32FBID);
2608     }
2609     GOP_RETURN(GOP_API_SUCCESS);
2610 
2611 }
2612 
2613 /******************************************************************************/
2614 /// Set the GWIN's position
2615 /// @param winId  \b IN: GWIN id
2616 /// @param dispX \b IN: x coordinate
2617 /// @param dispY \b IN: y coordinate
2618 /// @return GOP_API_SUCCESS - Success
2619 /// @return GOP_API_FAIL - Failure
2620 /******************************************************************************/
MApi_GOP_GWIN_SetWinPosition(MS_U8 winId,MS_U16 dispX,MS_U16 dispY)2621 E_GOP_API_Result MApi_GOP_GWIN_SetWinPosition(MS_U8 winId, MS_U16 dispX, MS_U16 dispY)
2622 {
2623 
2624     GOP_GWIN_SETWININFO_PARAM ioctl_info;
2625     GOP_BUFFER_INFO win_info;
2626     GOP_ENTRY();
2627     memset(&ioctl_info, 0x0, sizeof(GOP_GWIN_SETWININFO_PARAM));
2628     memset(&win_info, 0x0, sizeof(GOP_BUFFER_INFO));
2629 
2630     ioctl_info.GwinId = winId;
2631     ioctl_info.pinfo = (MS_U32*)&win_info;
2632     ioctl_info.u32Size = sizeof(GOP_BUFFER_INFO);
2633 
2634     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_GET_WININFO,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
2635     {
2636         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2637         GOP_RETURN( GOP_API_FAIL);
2638     }
2639 
2640 
2641     win_info.disp_rect.x = dispX;
2642     win_info.disp_rect.y = dispY;
2643 
2644     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_WININFO,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
2645     {
2646         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2647         GOP_RETURN( GOP_API_FAIL);
2648     }
2649 
2650     GOP_RETURN(GOP_API_SUCCESS);
2651 
2652 }
2653 
2654 /******************************************************************************/
2655 /// [Obstacle Function]
2656 /// @return 0
2657 /******************************************************************************/
MApi_GOP_GWIN_Get_HSTART(void)2658 MS_U16 MApi_GOP_GWIN_Get_HSTART(void)
2659 {
2660     return 0;
2661 }
2662 
2663 
2664 /******************************************************************************/
2665 /// Set the GWIN's frame buffer offset
2666 /// @param winId  \b IN: GWIN id
2667 /// @param x \b IN: x coordinate
2668 /// @param y \b IN: y coordinate
2669 /// @return GOP_API_SUCCESS - Success
2670 /// @return GOP_API_FAIL - Failure
2671 /******************************************************************************/
MApi_GOP_GWIN_SetWinPositionOffset(MS_U8 winId,MS_U16 x,MS_U16 y)2672 E_GOP_API_Result MApi_GOP_GWIN_SetWinPositionOffset(MS_U8 winId, MS_U16 x, MS_U16 y)
2673 {
2674     GOP_GwinInfo gwin;
2675     GOP_ENTRY();
2676     memset(&gwin, 0, sizeof(GOP_GwinInfo));
2677     MApi_GOP_GWIN_GetWinInfo(winId, &gwin);
2678     gwin.u16WinX = x;
2679     gwin.u16WinY = y;
2680     MApi_GOP_GWIN_SetWinInfo(winId, &gwin);
2681     GOP_RETURN(GOP_API_SUCCESS);
2682 
2683 }
2684 
2685 
2686 /******************************************************************************/
2687 /// Set gwin property
2688 /// @param WinProperty  \b IN: gwin property info
2689 /// @return GOP_API_SUCCESS - Success
2690 /// @return GOP_API_FAIL - Failure
2691 /******************************************************************************/
MApi_GOP_GWIN_SetWinProperty(GOP_GwinDispProperty WinProperty)2692 E_GOP_API_Result MApi_GOP_GWIN_SetWinProperty(GOP_GwinDispProperty WinProperty)
2693 {
2694     GOP_GwinInfo gWin;
2695     MS_U32 u32fbId;
2696     GOP_GwinFBAttr  fbInfo;
2697 
2698     GOP_ENTRY();
2699 
2700     u32fbId = MApi_GOP_GWIN_GetFBfromGWIN(WinProperty.gId);
2701 
2702     memset(&gWin, 0, sizeof(GOP_GwinInfo));
2703     memset(&fbInfo, 0x0, sizeof(GOP_GwinFBAttr));
2704 
2705     if(MApi_GOP_GWIN_GetWinInfo(WinProperty.gId,&gWin)!=GOP_API_SUCCESS)
2706     {
2707         GOP_WARN("[%s][%d] Fail!!!!\n",__FUNCTION__,__LINE__);
2708     }
2709     if(MApi_GOP_GWIN_Get32FBInfo(u32fbId,  &fbInfo)!=GOP_API_SUCCESS)
2710     {
2711         GOP_WARN("[%s][%d] Fail!!!!\n",__FUNCTION__,__LINE__);
2712     }
2713 
2714     gWin.u16DispHPixelStart = WinProperty.StartX;
2715     gWin.u16DispVPixelStart = WinProperty.StartY;
2716     gWin.u16DispHPixelEnd = WinProperty.StartX + WinProperty.Win_Width;
2717     gWin.u16DispVPixelEnd = WinProperty.StartY + WinProperty.Win_Height;
2718     gWin.u16WinX = WinProperty.FBOffset_X;
2719     gWin.u16WinY = WinProperty.FBOffset_Y;
2720     gWin.u16RBlkVPixSize = fbInfo.height;
2721     gWin.u16RBlkHPixSize = fbInfo.width;
2722     gWin.u16RBlkHRblkSize = GOP_CalcPitch(fbInfo.fbFmt, fbInfo.width);
2723     gWin.u32DRAMRBlkStart = fbInfo.addr;
2724     gWin.clrType = (EN_GOP_COLOR_TYPE)fbInfo.fbFmt;
2725 
2726     MApi_GOP_GWIN_SetWinInfo(WinProperty.gId, &gWin);
2727     GOP_RETURN(GOP_API_SUCCESS);
2728 
2729 }
2730 
2731 /******************************************************************************/
2732 /// Switch GE to render on a GWIN's frame buffer
2733 /// @param winId \b IN: GWIN id
2734 /// @return GOP_API_SUCCESS - Success
2735 /// @return GOP_API_FAIL - Failure
2736 /******************************************************************************/
MApi_GOP_GWIN_Switch2Gwin(MS_U8 winId)2737 E_GOP_API_Result MApi_GOP_GWIN_Switch2Gwin(MS_U8 winId)
2738 {
2739     GOP_GWIN_PROPERTY_PARAM ioctl_info;
2740     GOP_CBFmtInfo* pCBFmtInfo=NULL;
2741 
2742     GOP_ENTRY();
2743     pCBFmtInfo = (PGOP_CBFmtInfo)malloc(sizeof(GOP_CBFmtInfo));
2744     ioctl_info.en_property = E_GOP_GWIN_SWITCH_2_GWIN;
2745     ioctl_info.GwinId = winId;
2746     ioctl_info.pSet = (MS_U32*)pCBFmtInfo;
2747     ioctl_info.u32Size = sizeof(MS_U32);
2748 
2749     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
2750     {
2751         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2752         free(pCBFmtInfo);
2753         GOP_RETURN(GOP_API_FAIL);
2754     }
2755 
2756     free(pCBFmtInfo);
2757 
2758     GOP_RETURN(GOP_API_SUCCESS);
2759 }
2760 
2761 
2762 /*****************************************************************************/
2763 /// Get current active GWIN id
2764 /// @return current active GWIN id
2765 /*****************************************************************************/
MApi_GOP_GWIN_GetCurrentWinId()2766 MS_U8 MApi_GOP_GWIN_GetCurrentWinId()
2767 {
2768     GOP_GET_STATUS_PARAM ioctl_info;
2769     MS_U32 u32GWin = INVALID_WIN_ID;
2770     GOP_ENTRY();
2771     ioctl_info.type = 0;
2772     ioctl_info.en_status = E_GOP_STATUS_CURRENT_GWIN;
2773     ioctl_info.pStatus = (MS_U32*) &u32GWin;
2774     ioctl_info.u32Size = sizeof(MS_U32);
2775 
2776     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GET_STATUS,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
2777     {
2778         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2779         GOP_RETURN(GOP_API_FAIL);
2780     }
2781     GOP_RETURN((MS_U8)(u32GWin&0xFF));
2782 }
2783 
2784 /********************************************************************************/
2785 /// Set which one gop show in the top when different gop do alpha blending.
2786 /// @param u8GOP \b IN: GOP number
2787 ///   - # u8GOP is 0 => gop0's gwins will be shown in the top
2788 ///   - # u8GOP is 1 => gop1's gwins will be shown in the top
2789 /// @return GOP_API_SUCCESS - Success
2790 /********************************************************************************/
MApi_GOP_GWIN_OutputLayerSwitch(MS_U8 u8GOP)2791 E_GOP_API_Result MApi_GOP_GWIN_OutputLayerSwitch(MS_U8 u8GOP)
2792 {
2793     GOP_SET_PROPERTY_PARAM ioctl_info;
2794     MS_U32 value = 0;
2795 
2796     GOP_ENTRY();
2797     memset(&ioctl_info, 0x0, sizeof(GOP_SET_PROPERTY_PARAM));
2798 
2799     ioctl_info.en_pro   = E_GOP_OUTPUT_LAYER_SWITCH;
2800     ioctl_info.gop_idx  = u8GOP;
2801     ioctl_info.pSetting = (void*)&value;
2802     ioctl_info.u32Size  = sizeof(MS_U32);
2803 
2804     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
2805     {
2806         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2807         GOP_RETURN( GOP_API_FAIL);
2808     }
2809 
2810     GOP_RETURN(GOP_API_SUCCESS);
2811 }
2812 
2813 
2814 /*******************************************************************************/
2815 //Set which MUX select which GOP ,when different gop do the alpha blending
2816 //@param pGopMuxConfig \b IN:information about GOP and corresponding level
2817 //   #u8GopNum: the total GOP counts who need to select change Mux
2818 //   #GopMux[i].u8GopIndex :the GOP which need to change Mux
2819 //   #GopMux[i].u8MuxIndex :the GOP corresponding Mux
2820 //@return GOP_API_SUCCESS - Success
2821 /*******************************************************************************/
2822 
MApi_GOP_GWIN_SetMux(GOP_MuxConfig * pGopMuxConfig,MS_U32 u32SizeOfMuxInfo)2823 E_GOP_API_Result MApi_GOP_GWIN_SetMux(GOP_MuxConfig * pGopMuxConfig, MS_U32 u32SizeOfMuxInfo)
2824 {
2825     GOP_SETMUX_PARAM  ioctl_info;
2826     GOP_SETMUX  MuxSet;
2827     MS_U32 i;
2828 
2829     GOP_ENTRY();
2830 
2831     memset(&ioctl_info, 0x0, sizeof(GOP_SETMUX_PARAM));
2832     memset(&MuxSet, 0x0, sizeof(GOP_MuxConfig));
2833 
2834     MuxSet.MuxCount = pGopMuxConfig->u8MuxCounts;
2835 
2836     for(i=0; i< pGopMuxConfig->u8MuxCounts; i++)
2837     {
2838         MuxSet.gop[i] = pGopMuxConfig->GopMux[i].u8GopIndex;
2839         MuxSet.mux[i] = pGopMuxConfig->GopMux[i].u8MuxIndex;
2840     }
2841 
2842     ioctl_info.pMuxInfo = (MS_U32*)&MuxSet;
2843     ioctl_info.u32Size  = sizeof(GOP_SETMUX);
2844 
2845     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_MUX,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
2846     {
2847         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2848         GOP_RETURN( GOP_API_FAIL);
2849     }
2850 
2851     GOP_RETURN(GOP_API_SUCCESS);
2852 }
2853 
2854 /*******************************************************************************/
2855 //Set which OSD Layer select which GOP
2856 //@param pGopLayer \b IN:information about GOP and corresponding Layer
2857 //   #u32LayerCounts: the total GOP/Layer counts to set
2858 //   #stGopLayer[i].u32GopIndex :the GOP which need to change Layer
2859 //   #stGopLayer[i].u32LayerIndex :the GOP corresponding Layer
2860 //@return GOP_API_SUCCESS - Success
2861 /*******************************************************************************/
MApi_GOP_GWIN_SetLayer(GOP_LayerConfig * pGopLayer,MS_U32 u32SizeOfLayerInfo)2862 E_GOP_API_Result MApi_GOP_GWIN_SetLayer(GOP_LayerConfig *pGopLayer, MS_U32 u32SizeOfLayerInfo)
2863 {
2864     GOP_SETLAYER_PARAM  ioctl_info;
2865     GOP_SETLayer  stLayerSetting;
2866     MS_U32 i;
2867 
2868     GOP_ENTRY();
2869 
2870     memset(&ioctl_info, 0x0, sizeof(GOP_SETLAYER_PARAM));
2871     memset(&stLayerSetting, 0x0, sizeof(GOP_SETLayer));
2872 
2873     stLayerSetting.u32LayerCount = pGopLayer->u32LayerCounts;
2874 
2875     for(i=0; i< stLayerSetting.u32LayerCount; i++)
2876     {
2877         stLayerSetting.u32Gop[i] = pGopLayer->stGopLayer[i].u32GopIndex;
2878         stLayerSetting.u32Layer[i] = pGopLayer->stGopLayer[i].u32LayerIndex;
2879     }
2880 
2881     ioctl_info.pLayerInfo= (MS_U32*)&stLayerSetting;
2882     ioctl_info.u32Size  = sizeof(GOP_SETLayer);
2883 
2884     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_LAYER,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
2885     {
2886         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2887         GOP_RETURN( GOP_API_FAIL);
2888     }
2889 
2890     GOP_RETURN(GOP_API_SUCCESS);
2891 }
2892 
2893 /*******************************************************************************/
2894 //Get which OSD Layer select which GOP
2895 //@param pGopLayer \b OUT:information about GOP and corresponding Layer
2896 //   #u32LayerCounts: the total GOP/Layer inited
2897 //   #stGopLayer[i].u32GopIndex :the GOP which need to change Layer
2898 //   #stGopLayer[i].u32LayerIndex :the GOP corresponding Layer
2899 //@return GOP_API_SUCCESS - Success
2900 /*******************************************************************************/
MApi_GOP_GWIN_GetLayer(GOP_LayerConfig * pGopLayer,MS_U32 u32SizeOfLayerInfo)2901 E_GOP_API_Result MApi_GOP_GWIN_GetLayer(GOP_LayerConfig *pGopLayer, MS_U32 u32SizeOfLayerInfo)
2902 {
2903     GOP_SETLAYER_PARAM  ioctl_info;
2904     GOP_SETLayer  stLayerSetting;
2905 
2906     GOP_ENTRY();
2907 
2908     memset(&ioctl_info, 0x0, sizeof(GOP_SETLAYER_PARAM));
2909     memset(&stLayerSetting, 0x0, sizeof(GOP_SETLayer));
2910 
2911     ioctl_info.pLayerInfo= (MS_U32*)&stLayerSetting;
2912     ioctl_info.u32Size  = sizeof(GOP_SETLayer);
2913 
2914     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GET_LAYER,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
2915     {
2916         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
2917         GOP_RETURN( GOP_API_FAIL);
2918     }
2919     if (pGopLayer != NULL)
2920     {
2921         MS_U32 u32GOP;
2922         pGopLayer->u32LayerCounts = stLayerSetting.u32LayerCount;
2923         for (u32GOP = 0; u32GOP < pGopLayer->u32LayerCounts; u32GOP++)
2924         {
2925             pGopLayer->stGopLayer[u32GOP].u32GopIndex = stLayerSetting.u32Gop[u32GOP];
2926             pGopLayer->stGopLayer[u32GOP].u32LayerIndex = stLayerSetting.u32Layer[u32GOP];
2927         }
2928     }
2929 
2930     GOP_RETURN(GOP_API_SUCCESS);
2931 }
2932 
2933 /*******************************************************************************/
2934 //Get Layer From GOP
2935 //@param u32GOP \b IN: gop id
2936 //@return MS_U32 - the layer id which the gop is on, LAYER_ID_INVALID for invalid
2937 /*******************************************************************************/
MApi_GOP_GWIN_GetLayerFromGOP(MS_U32 u32GOP)2938 MS_U32 MApi_GOP_GWIN_GetLayerFromGOP(MS_U32 u32GOP)
2939 {
2940     GOP_LayerConfig stGOPLayerConfig;
2941     MS_U32 u32Layer = LAYER_ID_INVALID;
2942     memset(&stGOPLayerConfig, 0, sizeof(GOP_LayerConfig));
2943     if (GOP_API_SUCCESS == MApi_GOP_GWIN_GetLayer(&stGOPLayerConfig, sizeof(GOP_LayerConfig)))
2944     {
2945         MS_U32 u32Index;
2946         for (u32Index = 0; u32Index < stGOPLayerConfig.u32LayerCounts; u32Index++)
2947         {
2948             if (stGOPLayerConfig.stGopLayer[u32Index].u32GopIndex == u32GOP)
2949             {
2950                 u32Layer = stGOPLayerConfig.stGopLayer[u32Index].u32LayerIndex;
2951                 break;
2952             }
2953         }
2954     }
2955     return u32Layer;
2956 }
2957 
2958 /*******************************************************************************/
2959 //Get GOP From layer
2960 //@param u32Layer \b IN: layer id
2961 //@return MS_U32 - the gop id which the layer have,  INVALID_GOP_NUM for invalid
2962 /*******************************************************************************/
MApi_GOP_GWIN_GetGOPFromLayer(MS_U32 u32Layer)2963 MS_U32 MApi_GOP_GWIN_GetGOPFromLayer(MS_U32 u32Layer)
2964 {
2965     MS_U32 u32GOP = INVALID_GOP_NUM;
2966     GOP_LayerConfig stGOPLayerConfig;
2967     memset(&stGOPLayerConfig, 0, sizeof(GOP_LayerConfig));
2968     if (GOP_API_SUCCESS == MApi_GOP_GWIN_GetLayer(&stGOPLayerConfig, sizeof(GOP_LayerConfig)))
2969     {
2970         MS_U32 u32Index;
2971         for (u32Index = 0; u32Index < stGOPLayerConfig.u32LayerCounts; u32Index++)
2972         {
2973             if (stGOPLayerConfig.stGopLayer[u32Index].u32LayerIndex == u32Layer)
2974             {
2975                 u32GOP = stGOPLayerConfig.stGopLayer[u32Index].u32GopIndex;
2976                 break;
2977             }
2978         }
2979     }
2980 
2981     return u32GOP;
2982 }
2983 
2984 /******************************************************************************/
2985 /// Switch current active GOP
2986 /// @param u8GOP \b IN : Number of GOP
2987 /// @return GOP_API_SUCCESS - Success
2988 /******************************************************************************/
MApi_GOP_GWIN_SwitchGOP(MS_U8 u8GOP)2989 E_GOP_API_Result MApi_GOP_GWIN_SwitchGOP(MS_U8 u8GOP)
2990 {
2991     GOP_SELECTION_PROPERTY_PARAM ioctl_info;
2992     GOP_CBFmtInfo* pCBFmtInfo=NULL;
2993 
2994     GOP_ENTRY();
2995     pCBFmtInfo = (PGOP_CBFmtInfo)malloc(sizeof(GOP_CBFmtInfo));
2996     ioctl_info.sel_type = EN_GOP_SEL_GOP;
2997     ioctl_info.id = u8GOP;
2998     ioctl_info.pinfo = (MS_U32*)pCBFmtInfo;
2999 
3000     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SELECTION,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
3001     {
3002         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3003         free(pCBFmtInfo);
3004         GOP_RETURN(GOP_API_FAIL);
3005     }
3006 
3007     free(pCBFmtInfo);
3008 
3009     GOP_RETURN(GOP_API_SUCCESS);
3010 }
3011 
3012 /******************************************************************************/
3013 /// Configure the destination of a specific GOP
3014 /// @param u8GOP \b IN : Number of GOP
3015 /// @param dsttype \b IN : GOP destination
3016 /// @return GOP_API_SUCCESS - Success
3017 /// @return GOP_API_ENUM_NOT_SUPPORTED - GOP destination not support
3018 /******************************************************************************/
MApi_GOP_GWIN_SetGOPDst(MS_U8 u8GOP,EN_GOP_DST_TYPE dsttype)3019 E_GOP_API_Result MApi_GOP_GWIN_SetGOPDst(MS_U8 u8GOP, EN_GOP_DST_TYPE dsttype)
3020 {
3021 
3022     GOP_SETDST_PARAM ioctl_info;
3023 
3024     GOP_ENTRY();
3025     memset(&ioctl_info, 0x0, sizeof(GOP_SETDST_PARAM));
3026 
3027     ioctl_info.en_dst  = dsttype;
3028     ioctl_info.gop_idx = u8GOP;
3029 
3030     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_DST,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
3031     {
3032         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3033         GOP_RETURN (GOP_API_FAIL);
3034     }
3035 
3036     GOP_RETURN( GOP_API_SUCCESS);
3037 }
3038 
3039 
3040 /*****************************************************************************/
3041 /// Get the free GWIN id
3042 /// @return the GWIN id
3043 /*****************************************************************************/
MApi_GOP_GWIN_GetFreeWinID(void)3044 MS_U8 MApi_GOP_GWIN_GetFreeWinID(void)
3045 {
3046     GOP_GWIN_PROPERTY_PARAM ioctl_info;
3047     MS_U8 u8FreeId = (MS_U8)INVALID_POOL_NEXT_FBID;
3048 
3049     GOP_ENTRY();
3050     ioctl_info.en_property = E_GOP_GWIN_FREE_ID;
3051     ioctl_info.GwinId = 0x0;
3052     ioctl_info.pSet = (void*)&u8FreeId;
3053     ioctl_info.u32Size = sizeof(MS_U8);
3054 
3055     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_GET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
3056     {
3057         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3058         GOP_RETURN(u8FreeId);
3059     }
3060 
3061     GOP_RETURN(u8FreeId);
3062 
3063 }
3064 
3065 /******************************************************************************/
3066 /// Check if a frame buffer is allocated
3067 /// @param fbId \b IN frame buffer id
3068 /// @return
3069 ///   - # TRUE fbId is allocated
3070 ///   - # FALSE fbId is invalid or not allocated
3071 /******************************************************************************/
MApi_GOP_GWIN_IsFBExist(MS_U8 fbId)3072 MS_U8 MApi_GOP_GWIN_IsFBExist(MS_U8 fbId)
3073 {
3074     return MApi_GOP_GWIN_Is32FBExist((MS_U32)fbId);
3075 }
3076 
MApi_GOP_GWIN_Is32FBExist(MS_U32 u32fbId)3077 MS_U8 MApi_GOP_GWIN_Is32FBExist(MS_U32 u32fbId)
3078 {
3079     GOP_FB_PROPERTY_PARAM ioctl_info;
3080     MS_U8 u8Exist = FALSE;
3081     GOP_ENTRY();
3082     ioctl_info.en_property = E_GOP_FB_EXIST;
3083     ioctl_info.FBId = u32fbId;
3084     ioctl_info.pSet = (void*)&u8Exist;
3085     ioctl_info.u32Size = sizeof(MS_U8);
3086 
3087     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_FB_GET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
3088     {
3089         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3090         GOP_RETURN(u8Exist);
3091     }
3092 
3093     GOP_RETURN(u8Exist);
3094 }
3095 
3096 
3097 /******************************************************************************/
3098 /// Get free frame buffer id
3099 /// @return frame buffer id. If return oxFF, it represents no free frame buffer id for use.
3100 /******************************************************************************/
MApi_GOP_GWIN_GetFreeFBID(void)3101 MS_U8 MApi_GOP_GWIN_GetFreeFBID(void)
3102 {
3103     MS_U32 u32FreeFBId;
3104 
3105     u32FreeFBId = MApi_GOP_GWIN_GetFree32FBID();
3106     if( u32FreeFBId > 256) //Out of MS_U8
3107     {
3108         GOP_WARN( "[Warning] %s %d( u32FreeFBId:%td....)out of MS_U8 bound, please to use MApi_GOP_GWIN_GetFree32FBID()\n",__FUNCTION__,__LINE__,(ptrdiff_t)u32FreeFBId );
3109     }
3110 
3111     return u32FreeFBId;
3112 }
3113 
MApi_GOP_GWIN_GetFree32FBID(void)3114 MS_U32 MApi_GOP_GWIN_GetFree32FBID(void)
3115 {
3116     GOP_FB_PROPERTY_PARAM ioctl_info;
3117     MS_U32 u32FBId = 0xFFFFFFFF;
3118     GOP_ENTRY();
3119     ioctl_info.en_property = E_GOP_FB_OBTAIN;
3120     ioctl_info.FBId = 0x0;
3121     ioctl_info.pSet = (MS_U32*)&u32FBId;
3122     ioctl_info.u32Size = sizeof(MS_U32);
3123 
3124     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_FB_GET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
3125     {
3126         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3127         GOP_RETURN(u32FBId);
3128     }
3129     GOP_RETURN(u32FBId);
3130 }
3131 
3132 
3133 /******************************************************************************/
3134 /// Create frame buffer - take alignment factor into consideration
3135 /// @param FBId  \b IN frame buffer id
3136 /// @param x  \b IN frame buffer starting x
3137 /// @param y  \b IN frame buffer starting y
3138 /// @param width \b IN width
3139 /// @param height \b IN height
3140 /// @param fbFmt \b IN frame buffer format
3141 /// @return TRUE: create OK,  FALSE: create fail
3142 /******************************************************************************/
MApi_GOP_GWIN_CreateFB2(MS_U8 FBId,MS_U16 x,MS_U16 y,MS_U16 width,MS_U16 height,MS_U16 fbFmt)3143 MS_U8 MApi_GOP_GWIN_CreateFB2(MS_U8 FBId, MS_U16 x, MS_U16 y, MS_U16 width, MS_U16 height, MS_U16 fbFmt)
3144 {
3145     return MApi_GOP_GWIN_Create32FB2((MS_U32)FBId, x, y, width, height, fbFmt);
3146 }
3147 
MApi_GOP_GWIN_Create32FB2(MS_U32 u32FBId,MS_U16 x,MS_U16 y,MS_U16 width,MS_U16 height,MS_U16 fbFmt)3148 MS_U8 MApi_GOP_GWIN_Create32FB2(MS_U32 u32FBId, MS_U16 x, MS_U16 y, MS_U16 width, MS_U16 height, MS_U16 fbFmt)
3149 {
3150     GOP_CREATE_BUFFER_PARAM ioctl_info;
3151     GOP_BUFFER_INFO BuffInfo;
3152 
3153     GOP_ENTRY();
3154 
3155     memset(&ioctl_info, 0x0, sizeof(GOP_CREATE_BUFFER_PARAM));
3156     memset(&BuffInfo, 0x0, sizeof(GOP_BUFFER_INFO));
3157 
3158     ioctl_info.fb_type  = GOP_CREATE_BUFFER;
3159     ioctl_info.pBufInfo = (MS_U32*)&BuffInfo;
3160     ioctl_info.u32Size = sizeof(GOP_BUFFER_INFO);
3161     ioctl_info.fbid = u32FBId;
3162 
3163     BuffInfo.addr = 0x0;
3164     BuffInfo.fbFmt = fbFmt;
3165     BuffInfo.disp_rect.x = x;
3166     BuffInfo.disp_rect.y = y;
3167     BuffInfo.disp_rect.w = width;
3168     BuffInfo.disp_rect.h = height;
3169 
3170     BuffInfo.width = width;
3171     BuffInfo.height = height;
3172 
3173     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_FB_CREATE,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
3174     {
3175         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3176         GOP_RETURN( GOP_API_FAIL);
3177     }
3178     GOP_RETURN(GOP_API_SUCCESS);
3179 }
3180 
3181 /******************************************************************************/
3182 /// Destroy the frame buffer and return the memory to mmgr
3183 /// @param fbId  \b IN frame buffer id
3184 /// @return GOP_API_SUCCESS - Success
3185 /// @return GOP_API_CRT_GWIN_NOAVAIL - destory frame buffer fail
3186 /******************************************************************************/
MApi_GOP_GWIN_DestroyFB(MS_U8 fbId)3187 MS_U8 MApi_GOP_GWIN_DestroyFB(MS_U8 fbId)
3188 {
3189     return MApi_GOP_GWIN_Destroy32FB((MS_U32)fbId);
3190 }
3191 
MApi_GOP_GWIN_Destroy32FB(MS_U32 u32fbId)3192 MS_U8 MApi_GOP_GWIN_Destroy32FB(MS_U32 u32fbId)
3193 {
3194     GOP_DELETE_BUFFER_PARAM ioctl_info;
3195     GOP_ENTRY();
3196     memset(&ioctl_info, 0x0, sizeof(GOP_DELETE_BUFFER_PARAM));
3197 
3198     ioctl_info.pBufId = (MS_U32*)&u32fbId;
3199     ioctl_info.u32Size = sizeof(MS_U32);
3200 
3201     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_FB_DESTROY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
3202     {
3203         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3204         GOP_RETURN( GOP_API_FAIL);
3205     }
3206 
3207     GOP_RETURN(GWIN_OK);
3208 }
3209 
3210 
3211 /******************************************************************************/
3212 /// Destroy a frame buffer
3213 /// @param fbId \b IN frame buffer id
3214 /// @return GOP_API_SUCCESS - Success
3215 /******************************************************************************/
MApi_GOP_GWIN_DeleteFB(MS_U8 fbId)3216 E_GOP_API_Result MApi_GOP_GWIN_DeleteFB(MS_U8 fbId)
3217 {
3218     return MApi_GOP_GWIN_Delete32FB((MS_U32)fbId);
3219 }
3220 
MApi_GOP_GWIN_Delete32FB(MS_U32 u32fbId)3221 E_GOP_API_Result MApi_GOP_GWIN_Delete32FB(MS_U32 u32fbId)
3222 {
3223     GOP_ENTRY();
3224     GOP_INFO("\33[0;36m   %s:%d   FBId = %td \33[m \n",__FUNCTION__,__LINE__, (ptrdiff_t)u32fbId);
3225     if ((MApi_GOP_GWIN_Destroy32FB(u32fbId)) != GWIN_OK)
3226     {
3227         GOP_RETURN(GOP_API_FAIL);
3228     }
3229     GOP_RETURN(GOP_API_SUCCESS);
3230 
3231 }
3232 
3233 /********************************************************************************/
3234 /// Set GWIN alpha blending
3235 /// @param u8win \b IN GWIN id
3236 /// @param bEnable \b IN
3237 ///   - # TRUE enable pixel alpha
3238 ///   - # FALSE disable pixel alpha
3239 /// @param u8coef \b IN alpha blending coefficient (0-7)
3240 /// @return GOP_API_SUCCESS - Success
3241 /********************************************************************************/
MApi_GOP_GWIN_SetBlending(MS_U8 u8win,MS_BOOL bEnable,MS_U8 u8coef)3242 E_GOP_API_Result MApi_GOP_GWIN_SetBlending(MS_U8 u8win, MS_BOOL bEnable, MS_U8 u8coef)
3243 {
3244     GOP_GWIN_PROPERTY_PARAM ioctl_info;
3245     GOP_GWIN_BLENDING blendInfo;
3246     GOP_ENTRY();
3247     ioctl_info.en_property = E_GOP_GWIN_BLENDING;
3248     ioctl_info.GwinId = u8win;
3249     ioctl_info.pSet = (MS_U32*)&blendInfo;
3250     ioctl_info.u32Size = sizeof(GOP_GWIN_BLENDING);
3251 
3252     blendInfo.Coef = u8coef;
3253     blendInfo.bEn = bEnable;
3254 
3255     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
3256     {
3257         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3258         GOP_RETURN(GOP_API_FAIL);
3259     }
3260 
3261     GOP_RETURN(GOP_API_SUCCESS);
3262 
3263 }
3264 
3265 
3266 /********************************************************************************/
3267 /// Set transparent color for the GWIN
3268 /// @param fmt \b IN:
3269 ///  # GOPTRANSCLR_FMT0: RGB mode
3270 ///  # GOPTRANSCLR_FMT1: index mode
3271 /// @param clr \b IN Transparent color for in specific color format. Note that this is only for
3272 /// GOPTRANSCLR_FMT0(RGB mode) use. If you use GOPTRANSCLR_FMT1 (index mode), do not care this
3273 /// @return GOP_API_SUCCESS - Success
3274 /********************************************************************************/
MApi_GOP_GWIN_SetTransClr_EX(MS_U8 u8GOP,EN_GOP_TRANSCLR_FMT fmt,MS_U16 clr)3275 E_GOP_API_Result MApi_GOP_GWIN_SetTransClr_EX(MS_U8 u8GOP,EN_GOP_TRANSCLR_FMT fmt, MS_U16 clr)
3276 {
3277     GOP_SET_PROPERTY_PARAM ioctl_info;
3278     GOP_TRANSCOLOR trans_set;
3279 
3280     GOP_ENTRY();
3281 
3282     trans_set.bEn = TRUE;
3283     trans_set.color = clr;
3284     trans_set.fmt = fmt;
3285     trans_set.transclr_property = EN_TRANSCLR_SET_COLOR;
3286 
3287     ioctl_info.en_pro = E_GOP_TRANSCOLOR;
3288     ioctl_info.gop_idx = u8GOP;
3289     ioctl_info.pSetting = (void*)&trans_set;
3290     ioctl_info.u32Size = sizeof(GOP_TRANSCOLOR);
3291 
3292     u32TransColor = clr;
3293 
3294     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
3295     {
3296         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3297         GOP_RETURN(GOP_API_FAIL);
3298     }
3299 
3300     GOP_RETURN(GOP_API_SUCCESS);
3301 
3302 }
3303 
MApi_GOP_GWIN_SetTransClr(EN_GOP_TRANSCLR_FMT fmt,MS_U16 clr)3304 E_GOP_API_Result MApi_GOP_GWIN_SetTransClr(EN_GOP_TRANSCLR_FMT fmt, MS_U16 clr)
3305 {
3306     MS_U8 u8GOP;
3307     E_GOP_API_Result ret;
3308 
3309     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
3310     ret = MApi_GOP_GWIN_SetTransClr_EX(u8GOP,fmt,clr);
3311     return ret;
3312 
3313 }
3314 /********************************************************************************/
3315 /// Set transparent color for the GWIN
3316 /// @param fmt \b IN GOP number
3317 /// @param fmt \b IN:
3318 ///  # GOPTRANSCLR_FMT0: RGB mode
3319 ///  # GOPTRANSCLR_FMT1: index mode
3320 ///  # GOPTRANSCLR_FMT2: ARGB8888 mode
3321 ///  # GOPTRANSCLR_FMT3: YUV mode
3322 /// @param ST_Transparent_Color \b IN This structure has an element color which is used for trans color.
3323 /// @return GOP_API_SUCCESS - Success
3324 /********************************************************************************/
MApi_GOP_GWIN_SetTransparentClr(MS_U8 u8GOP,EN_GOP_TRANSCLR_FMT fmt,ST_Transparent_Color * st_Transcolor)3325 E_GOP_API_Result MApi_GOP_GWIN_SetTransparentClr(MS_U8 u8GOP, EN_GOP_TRANSCLR_FMT fmt, ST_Transparent_Color *st_Transcolor)
3326 {
3327     GOP_SET_PROPERTY_PARAM ioctl_info;
3328     GOP_TRANSCOLOR trans_set;
3329 
3330     GOP_ENTRY();
3331 
3332     trans_set.bEn = TRUE;
3333     trans_set.color = st_Transcolor->color;
3334     trans_set.fmt = fmt;
3335     trans_set.transclr_property = EN_TRANSCLR_SET_COLOR;
3336 
3337     u32TransColor = st_Transcolor->color;
3338 
3339     ioctl_info.en_pro = E_GOP_TRANSCOLOR;
3340     ioctl_info.gop_idx = u8GOP;
3341     ioctl_info.pSetting = (void*)&trans_set;
3342     ioctl_info.u32Size = sizeof(GOP_TRANSCOLOR);
3343 
3344     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
3345     {
3346         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3347         GOP_RETURN(GOP_API_FAIL);
3348     }
3349 
3350     GOP_RETURN(GOP_API_SUCCESS);
3351 }
3352 /********************************************************************************/
3353 /// Set transparent color (ARGB domain) and enable it for the GWIN
3354 /// @param clr \b IN: transparent color
3355 /// @return GOP_API_SUCCESS - Success
3356 /********************************************************************************/
MApi_GOP_GWIN_SetFMT0TransClr_EX(MS_U8 u8GOP,MS_U16 clr)3357 E_GOP_API_Result MApi_GOP_GWIN_SetFMT0TransClr_EX(MS_U8 u8GOP,MS_U16 clr)
3358 {
3359     GOP_SET_PROPERTY_PARAM ioctl_info;
3360     GOP_TRANSCOLOR trans_set;
3361 
3362     GOP_ENTRY();
3363 
3364     trans_set.bEn = TRUE;
3365     trans_set.color = clr;
3366     trans_set.fmt = GOPTRANSCLR_FMT0;
3367     trans_set.transclr_property = EN_TRANSCLR_SET_COLOR;
3368 
3369     u32TransColor = clr;
3370 
3371     ioctl_info.en_pro = E_GOP_TRANSCOLOR;
3372     ioctl_info.gop_idx = u8GOP;
3373     ioctl_info.pSetting = (void*)&trans_set;
3374     ioctl_info.u32Size = sizeof(GOP_TRANSCOLOR);
3375 
3376     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
3377     {
3378         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3379         GOP_RETURN(GOP_API_FAIL);
3380     }
3381 
3382     GOP_RETURN(GOP_API_SUCCESS);
3383 }
MApi_GOP_GWIN_SetFMT0TransClr(MS_U16 clr)3384 E_GOP_API_Result MApi_GOP_GWIN_SetFMT0TransClr(MS_U16 clr)
3385 {
3386     MS_U8 u8GOP;
3387     E_GOP_API_Result ret;
3388 
3389     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
3390     ret = MApi_GOP_GWIN_SetFMT0TransClr_EX(u8GOP,clr);
3391     return ret;
3392 }
3393 //-------------------------------------------------------------------------------------------------
3394 /// Get maximum support frame buffer number
3395 /// @return maximum support frame buffer number
3396 //-------------------------------------------------------------------------------------------------
MApi_GOP_GWIN_GetMAXFBID(void)3397 MS_U8 MApi_GOP_GWIN_GetMAXFBID(void)
3398 {
3399     MS_U32 u32MaxFBID;
3400     u32MaxFBID = MApi_GOP_GWIN_GetMAX32FBID();
3401     if( u32MaxFBID> 256) //Out of MS_U8
3402     {
3403         GOP_WARN( "[Warning] %s %d( u32MaxFBID:%td....)out of MS_U8 bound, please to use MApi_GOP_GWIN_GetMAX32FBID()\n",__FUNCTION__,__LINE__,(ptrdiff_t)u32MaxFBID );
3404     }
3405     return u32MaxFBID;
3406 }
3407 
MApi_GOP_GWIN_GetMAX32FBID(void)3408 MS_U32 MApi_GOP_GWIN_GetMAX32FBID(void)
3409 {
3410     return MApi_GOP_GWIN_GetMax32FBNum();
3411 }
3412 
3413 //-------------------------------------------------------------------------------------------------
3414 /// Get maximum support gop number
3415 /// @return maximum support gop number
3416 //-------------------------------------------------------------------------------------------------
MApi_GOP_GWIN_GetMaxGOPNum(void)3417 MS_U8 MApi_GOP_GWIN_GetMaxGOPNum(void)
3418 {
3419     MS_U8 u8MaxGop;
3420     GOP_GET_STATUS_PARAM ioctl_info;
3421 
3422     CheckGOPInstanceOpen();
3423     ioctl_info.type = 0;
3424     ioctl_info.en_status = E_GOP_STATUS_GOP_MAXNUM;
3425     ioctl_info.pStatus = (void*) &u8MaxGop;
3426     ioctl_info.u32Size = sizeof(MS_U8);
3427 
3428     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GET_STATUS,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
3429     {
3430         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3431         return GOP_API_FAIL;
3432     }
3433 
3434     return u8MaxGop;
3435 
3436 }
3437 
3438 
3439 //-------------------------------------------------------------------------------------------------
3440 /// Get maximum gwin number by individual gop
3441 /// @param u8GopNum \b IN: Number of GOP
3442 /// @return maximum gwin number by individual gop
3443 //-------------------------------------------------------------------------------------------------
MApi_GOP_GWIN_GetGwinNum(MS_U8 u8GopNum)3444 MS_U8 MApi_GOP_GWIN_GetGwinNum(MS_U8 u8GopNum)
3445 {
3446     GOP_GET_STATUS_PARAM ioctl_info;
3447     GOP_GWIN_NUM  gwin_num;
3448     CheckGOPInstanceOpen();
3449     ioctl_info.type = 0;
3450     ioctl_info.en_status = E_GOP_STATUS_GWIN_MAXNUM;
3451     ioctl_info.pStatus = (MS_U32*)&gwin_num;
3452     ioctl_info.u32Size = sizeof(GOP_GWIN_NUM);
3453 
3454     gwin_num.gop_idx = u8GopNum;
3455 
3456     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GET_STATUS,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
3457     {
3458         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3459         return GOP_API_FAIL;
3460     }
3461 
3462     return gwin_num.gwin_num;
3463 }
3464 
3465 
3466 //-------------------------------------------------------------------------------------------------
3467 /// Get maximum support gwin number by all gop
3468 /// @return maximum support gwin number by all gop
3469 //-------------------------------------------------------------------------------------------------
MApi_GOP_GWIN_GetTotalGwinNum(void)3470 MS_U8 MApi_GOP_GWIN_GetTotalGwinNum(void)
3471 {
3472     MS_U8 u8TotalWin;
3473     GOP_GET_STATUS_PARAM ioctl_info;
3474     CheckGOPInstanceOpen();
3475     ioctl_info.type = 0;
3476     ioctl_info.en_status = E_GOP_STATUS_GWIN_TOTALNUM;
3477     ioctl_info.pStatus = (void*)&u8TotalWin;
3478     ioctl_info.u32Size = sizeof(MS_U8);
3479     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GET_STATUS,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
3480     {
3481         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3482         return GOP_API_FAIL;
3483     }
3484 
3485     return u8TotalWin;
3486 }
3487 
3488 
3489 /*****************************************************************************/
3490 /// Get max GWIN id
3491 /// @return the maximum number of GWIN id
3492 /*****************************************************************************/
MApi_GOP_GWIN_GetMAXWinID(void)3493 MS_U8 MApi_GOP_GWIN_GetMAXWinID(void)
3494 {
3495     return MApi_GOP_GWIN_GetTotalGwinNum();
3496 }
3497 
3498 /******************************************************************************/
3499 /// Enable/Disable multi alpha for one gop
3500 /// @param u32GopIdx \b IN: gop ID
3501 /// @param bEnable \b IN: TRUE/FALSE
3502 /// @return GOP_API_SUCCESS - Success
3503 /******************************************************************************/
MApi_GOP_GWIN_EnableMultiAlpha(MS_U32 u32GopIdx,MS_BOOL bEnable)3504 E_GOP_API_Result MApi_GOP_GWIN_EnableMultiAlpha(MS_U32 u32GopIdx, MS_BOOL bEnable)
3505 {
3506     GOP_SET_PROPERTY_PARAM ioctl_info;
3507     GOP_ENTRY();
3508     ioctl_info.en_pro = E_GOP_MULTI_ALPHA_ENABLE;
3509     ioctl_info.gop_idx = u32GopIdx;
3510     ioctl_info.pSetting = (void*)&bEnable;
3511     ioctl_info.u32Size = sizeof(MS_BOOL);
3512     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
3513     {
3514         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3515         GOP_RETURN(GOP_API_FAIL);
3516     }
3517 
3518     GOP_RETURN(GOP_API_SUCCESS);
3519 
3520 }
3521 
3522 /******************************************************************************/
3523 /// get multi alpha status for one gop
3524 /// @param u32GopIdx \b IN: gop ID
3525 /// @return multi alpha status
3526 /******************************************************************************/
MApi_GOP_GWIN_IsMultiAlphaEnable(MS_U32 u32GopIdx)3527 MS_BOOL MApi_GOP_GWIN_IsMultiAlphaEnable(MS_U32 u32GopIdx)
3528 {
3529     MS_BOOL bEnable = FALSE;
3530     GOP_SET_PROPERTY_PARAM ioctl_info;
3531     GOP_ENTRY();
3532     ioctl_info.en_pro = E_GOP_MULTI_ALPHA_ENABLE;
3533     ioctl_info.gop_idx = u32GopIdx;
3534     ioctl_info.pSetting = (void*)&bEnable;
3535     ioctl_info.u32Size = sizeof(MS_BOOL);
3536     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
3537     {
3538         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3539         GOP_RETURN(GOP_API_FAIL);
3540     }
3541 
3542     GOP_RETURN(bEnable);
3543 }
3544 
3545 /******************************************************************************/
3546 /// Set alpha value of GOP0 4 Gwins
3547 /// @param Gwin01AlphaValue \b IN: Alpha coefficient and Enable status of Gwin 0/1
3548 /// @param Gwin23AlphaValue \b IN: Alpha coefficient and Enable status of Gwin 2/3
3549 /// @return GOP_API_SUCCESS - Success
3550 /******************************************************************************/
MApi_GOP_GWIN_SetAlphaValue(MS_U16 * Gwin01AlphaValue,MS_U16 * Gwin23AlphaValue)3551 E_GOP_API_Result MApi_GOP_GWIN_SetAlphaValue(MS_U16 * Gwin01AlphaValue, MS_U16 * Gwin23AlphaValue)
3552 {
3553     GOP_ENTRY();
3554 
3555     GOP_ERR("[%s] Not Support \n",__FUNCTION__);
3556 
3557     GOP_RETURN(GOP_API_SUCCESS);
3558 
3559 }
3560 
3561 
3562 /********************************************************************************/
3563 /// Get GOP0 4 gwin alpha blending setting
3564 /// @param Gwin01AlphaValue \b OUT: gwin0 and gwin1 alpha setting
3565 /// @param Gwin23AlphaValue \b OUT: gwin2 and gwin3 alpha setting
3566 /// @return GOP_API_SUCCESS - Success
3567 /********************************************************************************/
MApi_GOP_GWIN_GetAlphaValue(MS_U16 * Gwin01AlphaValue,MS_U16 * Gwin23AlphaValue)3568 E_GOP_API_Result MApi_GOP_GWIN_GetAlphaValue(MS_U16 * Gwin01AlphaValue, MS_U16 * Gwin23AlphaValue)
3569 {
3570     GOP_ENTRY();
3571 
3572     GOP_ERR("[%s] Not Support \n",__FUNCTION__);
3573 
3574     GOP_RETURN(GOP_API_SUCCESS);
3575 
3576 }
3577 
MApi_GOP_GWIN_SetPreAlphaMode(MS_U8 u8GOP,MS_BOOL bEnble)3578 E_GOP_API_Result MApi_GOP_GWIN_SetPreAlphaMode(MS_U8 u8GOP, MS_BOOL bEnble)
3579 {
3580     MS_BOOL bPreAlpha;
3581     GOP_SET_PROPERTY_PARAM ioctl_info;
3582 
3583     GOP_ENTRY();
3584 
3585     memset(&ioctl_info, 0x0, sizeof(GOP_SET_PROPERTY_PARAM));
3586     bPreAlpha = bEnble;
3587 
3588 
3589     ioctl_info.en_pro   = E_GOP_PREALPHAMODE;
3590     ioctl_info.gop_idx  = u8GOP;
3591     ioctl_info.pSetting = (void*)&bPreAlpha;
3592     ioctl_info.u32Size  = sizeof(MS_BOOL);
3593 
3594     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
3595     {
3596         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3597         GOP_RETURN( GOP_API_FAIL);
3598     }
3599 
3600     GOP_RETURN(GOP_API_SUCCESS);
3601 
3602 }
3603 
3604 
3605 /******************************************************************************/
3606 /// Set gop driver internal palette table to GOP0
3607 /// @return GOP_API_SUCCESS - Success
3608 /******************************************************************************/
MApi_GOP_GWIN_SetPalette(void)3609 E_GOP_API_Result MApi_GOP_GWIN_SetPalette(void)
3610 {
3611     MS_U32 i;
3612     GOP_PALETTE_SET_PARAM  ioctl_info;
3613     GOP_PALETTE_ENTRY  palEntry;
3614 
3615     GOP_ENTRY();
3616     for (i=0;i<(256/PALETTE_ENTRY_NUM);i++)
3617     {
3618         memset(&ioctl_info, 0x0, sizeof(GOP_PALETTE_SET_PARAM));
3619         memset(&palEntry, 0x0, sizeof(GOP_PALETTE_ENTRY));
3620 
3621         palEntry.gop_idx = 0x0;
3622         palEntry.pClut = (void*)&PaletteEntry;
3623         palEntry.start = i;
3624         palEntry.end   = ((i+1)*PALETTE_ENTRY_NUM - 1);
3625         palEntry.palType = E_GOP_PAL_ARGB8888;
3626         palEntry.palSrc = E_GOP_4G_PALETTE;
3627 
3628         ioctl_info.pClut = (void*)&palEntry;
3629         ioctl_info.u32Size = sizeof(GOP_PALETTE_ENTRY);
3630 
3631         if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_PALETTE_SET_ENTRY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
3632         {
3633             GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3634             GOP_RETURN( GOP_API_FAIL);
3635         }
3636     }
3637     GOP_RETURN(GOP_API_SUCCESS);
3638 }
3639 
3640 
3641 /******************************************************************************/
3642 /// Get GWin position info
3643 /// @param winId  \b IN: gwin id
3644 /// @param dispX \b OUT: position-X
3645 /// @param dispY \b OUT: position-Y
3646 /// @return GOP_API_SUCCESS - Success
3647 /// @return GOP_API_FAIL - Failure
3648 /******************************************************************************/
MApi_GOP_GWIN_GetWinPosition(MS_U8 winId,MS_U16 * dispX,MS_U16 * dispY)3649 E_GOP_API_Result MApi_GOP_GWIN_GetWinPosition(MS_U8 winId, MS_U16 * dispX, MS_U16 *dispY)
3650 {
3651     GOP_ENTRY();
3652     GOP_GwinInfo info;
3653     MApi_GOP_GWIN_GetWinInfo(winId,&info);
3654     *dispX = info.u16DispHPixelStart;
3655     *dispY = info.u16DispVPixelStart;
3656     GOP_RETURN(GOP_API_SUCCESS);
3657 }
3658 
3659 
3660 /******************************************************************************/
3661 /// Get frame buffer address
3662 /// @param fbID \b IN: frame buffer id
3663 /// @param pAddr \b OUT: frame buffer address
3664 /// @return GOP_API_SUCCESS - Success
3665 /******************************************************************************/
MApi_GOP_GWIN_GetFBAddr(MS_U8 fbID,MS_PHY * pAddr)3666 E_GOP_API_Result MApi_GOP_GWIN_GetFBAddr(MS_U8 fbID, MS_PHY *pAddr)
3667 {
3668     return MApi_GOP_GWIN_Get32FBAddr((MS_U32)fbID, pAddr);
3669 }
3670 
MApi_GOP_GWIN_Get32FBAddr(MS_U32 u32fbID,MS_PHY * pAddr)3671 E_GOP_API_Result MApi_GOP_GWIN_Get32FBAddr(MS_U32 u32fbID, MS_PHY *pAddr)
3672 {
3673     GOP_GwinFBAttr fbAttr;
3674     GOP_ENTRY();
3675 
3676     if(MApi_GOP_GWIN_Get32FBInfo(u32fbID, &fbAttr) == GOP_API_SUCCESS)
3677     {
3678         *pAddr = fbAttr.addr;
3679         GOP_RETURN(GOP_API_SUCCESS);
3680     }
3681     else
3682     {
3683         GOP_RETURN(GOP_API_FAIL);
3684     }
3685 
3686 }
3687 
3688 /******************************************************************************/
3689 /// Reset the gwin info. Note that no free any frame buffer in this interface!!
3690 /// @param gId  \b IN: gwin id
3691 /// @return GOP_API_SUCCESS - Success
3692 /// @return GOP_API_FAIL - Failure
3693 /******************************************************************************/
MApi_GOP_GWIN_ReleaseWin(MS_U8 gId)3694 E_GOP_API_Result MApi_GOP_GWIN_ReleaseWin(MS_U8 gId)
3695 {
3696     GOP_ENTRY();
3697 
3698     MApi_GOP_GWIN_Enable(gId, FALSE);
3699     MApi_GOP_GWIN_DestroyWin(gId);
3700 
3701     GOP_RETURN(GOP_API_SUCCESS);
3702 
3703 }
3704 
3705 
3706 /******************************************************************************/
3707 /// Get frame bufferid from the gwin id
3708 /// @param gwinId  \b IN gwin id
3709 /// @return return frame buffer id. If return 0xFF, it represents this function fail
3710 /******************************************************************************/
MApi_GOP_GWIN_GetFBfromGWIN(MS_U8 gwinId)3711 MS_U8 MApi_GOP_GWIN_GetFBfromGWIN(MS_U8 gwinId)
3712 {
3713     MS_U32 u32CurFBId;
3714 
3715     u32CurFBId = MApi_GOP_GWIN_Get32FBfromGWIN(gwinId);
3716     if( u32CurFBId > 256) //Out of MS_U8
3717     {
3718         GOP_WARN( "[Warning] %s %d( u32CurFBId:%td....)out of MS_U8 bound, please to use MApi_GOP_GWIN_Get32FBfromGWIN()\n",__FUNCTION__,__LINE__,(ptrdiff_t)u32CurFBId );
3719     }
3720     return u32CurFBId;
3721 }
3722 
MApi_GOP_GWIN_Get32FBfromGWIN(MS_U8 gwinId)3723 MS_U32 MApi_GOP_GWIN_Get32FBfromGWIN(MS_U8 gwinId)
3724 {
3725     GOP_GWIN_PROPERTY_PARAM ioctl_info;
3726     MS_U32 u32FB = INVALID_POOL_NEXT_FBID;
3727     GOP_ENTRY();
3728 
3729     ioctl_info.en_property = E_GOP_GWIN_GET_FB;
3730     ioctl_info.GwinId = gwinId;
3731     ioctl_info.pSet = (MS_U32*)&u32FB;
3732     ioctl_info.u32Size = sizeof(MS_U32);
3733 
3734     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_GET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
3735     {
3736         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3737         GOP_RETURN(u32FB);
3738     }
3739 
3740     GOP_RETURN(u32FB);
3741 
3742 }
3743 
3744 
3745 /******************************************************************************/
3746 /// Get region info for a frame buffer
3747 /// @param fbID  \b IN frame buffer id 0 ~ (MAX_GWIN_FB_SUPPORT - 1)
3748 /// @param pX \b OUT position-X
3749 /// @param pY \b OUT position-Y
3750 /// @param pW \b OUT width
3751 /// @param pH \b OUT height
3752 /// @return GOP_API_SUCCESS - Success
3753 /******************************************************************************/
MApi_GOP_GWIN_GetFBRegion(MS_U8 fbID,MS_U16 * pX,MS_U16 * pY,MS_U16 * pW,MS_U16 * pH)3754 E_GOP_API_Result MApi_GOP_GWIN_GetFBRegion(MS_U8 fbID, MS_U16 *pX, MS_U16 *pY, MS_U16 *pW, MS_U16 *pH)
3755 {
3756     return MApi_GOP_GWIN_Get32FBRegion((MS_U32)fbID, pX, pY, pW, pH);
3757 }
3758 
MApi_GOP_GWIN_Get32FBRegion(MS_U32 u32fbID,MS_U16 * pX,MS_U16 * pY,MS_U16 * pW,MS_U16 * pH)3759 E_GOP_API_Result MApi_GOP_GWIN_Get32FBRegion(MS_U32 u32fbID, MS_U16 *pX, MS_U16 *pY, MS_U16 *pW, MS_U16 *pH)
3760 {
3761     GOP_GwinFBAttr fbAttr;
3762     GOP_ENTRY();
3763 
3764     if(MApi_GOP_GWIN_Get32FBInfo(u32fbID, &fbAttr) == GOP_API_SUCCESS)
3765     {
3766         *pX = fbAttr.x0;
3767         *pY = fbAttr.y0;
3768         *pW = fbAttr.width;
3769         *pH = fbAttr.height;
3770         GOP_RETURN(GOP_API_SUCCESS);
3771     }
3772     else
3773     {
3774         GOP_RETURN(GOP_API_FAIL);
3775     }
3776 
3777 }
3778 
3779 /******************************************************************************/
3780 /// Get position info for a frame buffer
3781 /// @param fbID  \b IN frame buffer id 0 ~ (MAX_GWIN_FB_SUPPORT - 1)
3782 /// @param pX \b OUT position-X
3783 /// @param pY \b OUT position-Y
3784 /// @return GOP_API_SUCCESS - Success
3785 /******************************************************************************/
MApi_GOP_GWIN_GetFBPosition(MS_U8 fbID,MS_U16 * pX,MS_U16 * pY)3786 E_GOP_API_Result MApi_GOP_GWIN_GetFBPosition(MS_U8 fbID, MS_U16 *pX, MS_U16 *pY)
3787 {
3788     return MApi_GOP_GWIN_Get32FBPosition((MS_U32)fbID, pX, pY);
3789 }
3790 
MApi_GOP_GWIN_Get32FBPosition(MS_U32 u32fbID,MS_U16 * pX,MS_U16 * pY)3791 E_GOP_API_Result MApi_GOP_GWIN_Get32FBPosition(MS_U32 u32fbID, MS_U16 *pX, MS_U16 *pY)
3792 {
3793     GOP_GwinFBAttr fbAttr;
3794     GOP_ENTRY();
3795     if(MApi_GOP_GWIN_Get32FBInfo(u32fbID, &fbAttr) == GOP_API_SUCCESS)
3796     {
3797         *pX = fbAttr.x0;
3798         *pY = fbAttr.y0;
3799         GOP_RETURN(GOP_API_SUCCESS);
3800     }
3801     else
3802     {
3803         GOP_RETURN(GOP_API_FAIL);
3804     }
3805 
3806 }
3807 
3808 
3809 /******************************************************************************/
3810 /// Create frame buffer - take alignment factor into consideration
3811 /// @param FBId  \b IN frame buffer id
3812 /// @param x  \b IN frame buffer starting x
3813 /// @param y  \b IN frame buffer starting y
3814 /// @param width \b IN width
3815 /// @param height \b IN height
3816 /// @param fbFmt \b IN frame buffer format
3817 /// @param FBString \n IN create frame buffer by which one application
3818 /// @return TRUE: create OK,  FALSE: create fail
3819 /******************************************************************************/
MApi_GOP_GWIN_CreateFB2_EXT(MS_U8 FBId,MS_U16 x,MS_U16 y,MS_U16 width,MS_U16 height,MS_U16 fbFmt,EN_GOP_FRAMEBUFFER_STRING FBString)3820 MS_U8 MApi_GOP_GWIN_CreateFB2_EXT(MS_U8 FBId, MS_U16 x, MS_U16 y, MS_U16 width, MS_U16 height, MS_U16 fbFmt, EN_GOP_FRAMEBUFFER_STRING FBString)
3821 {
3822     return MApi_GOP_GWIN_Create32FB2_EXT((MS_U32)FBId, x, y, width, height, fbFmt ,FBString);
3823 }
3824 
MApi_GOP_GWIN_Create32FB2_EXT(MS_U32 u32FBId,MS_U16 x,MS_U16 y,MS_U16 width,MS_U16 height,MS_U16 fbFmt,EN_GOP_FRAMEBUFFER_STRING FBString)3825 MS_U8 MApi_GOP_GWIN_Create32FB2_EXT(MS_U32 u32FBId, MS_U16 x, MS_U16 y, MS_U16 width, MS_U16 height, MS_U16 fbFmt, EN_GOP_FRAMEBUFFER_STRING FBString)
3826 {
3827     GOP_CREATE_BUFFER_PARAM ioctl_info;
3828     GOP_BUFFER_INFO BuffInfo;
3829 
3830     GOP_ENTRY();
3831 
3832     memset(&ioctl_info, 0x0, sizeof(GOP_CREATE_BUFFER_PARAM));
3833     memset(&BuffInfo, 0x0, sizeof(GOP_BUFFER_INFO));
3834 
3835     ioctl_info.fb_type  = GOP_CREATE_BUFFER;
3836     ioctl_info.pBufInfo = (MS_U32*)&BuffInfo;
3837     ioctl_info.u32Size = sizeof(GOP_BUFFER_INFO);
3838     ioctl_info.fbid = u32FBId;
3839 
3840     BuffInfo.addr = 0x0;
3841     BuffInfo.fbFmt = fbFmt;
3842     BuffInfo.disp_rect.x = x;
3843     BuffInfo.disp_rect.y = y;
3844     BuffInfo.disp_rect.w = width;
3845     BuffInfo.disp_rect.h = height;
3846 
3847     BuffInfo.width = width;
3848     BuffInfo.height = height;
3849     BuffInfo.FBString = FBString;
3850 
3851     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_FB_CREATE,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
3852     {
3853         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3854         GOP_RETURN( GOP_API_FAIL);
3855     }
3856     GOP_RETURN(GOP_API_SUCCESS);
3857 
3858 }
3859 
3860 /********************************************************************************/
3861 /// Check if GOP destination is op mode
3862 /// @return TRUE:op mode  FALSE: not in op mode
3863 /********************************************************************************/
MApi_GOP_GWIN_CheckOpmodeIsOn_EX(MS_U8 u8GOP)3864 MS_BOOL MApi_GOP_GWIN_CheckOpmodeIsOn_EX(MS_U8 u8GOP)
3865 {
3866     EN_GOP_DST_TYPE enGopDst;
3867     GOP_GETDST_PARAM ioctl_info;
3868     memset(&ioctl_info,0x0, sizeof(GOP_GETDST_PARAM));
3869 
3870     GOP_ENTRY();
3871 
3872     ioctl_info.gop_idx = u8GOP;
3873     ioctl_info.pDst = (MS_U32*) &enGopDst;
3874     ioctl_info.u32Size = sizeof(EN_GOP_DST_TYPE);
3875 
3876     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GET_DST,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
3877     {
3878         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
3879         GOP_RETURN(GOP_API_FAIL);
3880     }
3881 
3882     if (enGopDst == E_GOP_DST_OP0)
3883     {
3884         GOP_RETURN(TRUE);
3885     }
3886     else
3887     {
3888         GOP_RETURN(FALSE);
3889     }
3890 }
3891 
MApi_GOP_GWIN_CheckOpmodeIsOn(void)3892 MS_BOOL MApi_GOP_GWIN_CheckOpmodeIsOn(void)
3893 {
3894     MS_U8 u8GOP;
3895     MS_BOOL ret;
3896 
3897     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
3898     ret = MApi_GOP_GWIN_CheckOpmodeIsOn_EX(u8GOP);
3899     return ret;
3900 }
3901 /*****************************************************************************/
3902 /// Get Active GWIN id with max vertical pixel length
3903 /// Active means that displaying OSD currently on screen
3904 /// @return the active GWIN's length  with the maximum vertical pixel length
3905 /*****************************************************************************/
MApi_GOP_GWIN_GetMaxActiveGwin_v(void)3906 MS_U16 MApi_GOP_GWIN_GetMaxActiveGwin_v(void)
3907 {
3908     MS_U16 v_length=0;
3909     MS_U8 i=0;
3910     GOP_GwinInfo gwin;
3911     MS_U16 maxvlength=0;
3912     MS_U16 h_length=0;
3913     GOP_ENTRY();
3914 
3915     if (MApi_GOP_GWIN_CheckOpmodeIsOn()==false)
3916     {
3917         GOP_RETURN(GetMaxActiveGwinFalse_op);
3918     }
3919     else
3920     {
3921         // Check which GWINS are active
3922         if (MApi_GOP_GWIN_IsEnabled()==false)
3923         {
3924             GOP_RETURN(GetMaxActiveGwinFalse_opened);
3925         }
3926         else
3927         //if gwin are active then compare their vertical size
3928         // Initialize
3929         {
3930             for (i=0;i<MAX_GWIN_SUPPORT;i++)
3931             {
3932                 //printf("\n(1) i:0x%bx",i);
3933                 if (MApi_GOP_GWIN_IsGWINEnabled(i)==true)
3934                 {
3935                     memset(&gwin, 0, sizeof(GOP_GwinInfo));
3936                     MApi_GOP_GWIN_GetWinInfo(i,&gwin);
3937                     h_length=gwin.u16DispHPixelEnd-gwin.u16DispHPixelStart;
3938                     if (gwin.u16DispVPixelEnd>gwin.u16DispVPixelStart)
3939                     {
3940 
3941                         if (h_length>4)
3942                         {
3943                             v_length=gwin.u16DispVPixelEnd-gwin.u16DispVPixelStart;
3944                             if (v_length>maxvlength)
3945                             {
3946                                 maxvlength=v_length;
3947                             }
3948                         }
3949                     }
3950                     else
3951                     {
3952                         GOP_RETURN(GetMaxActiveGwinFalse);
3953                     }
3954                 }
3955 
3956             }
3957 
3958             GOP_RETURN(maxvlength);
3959 
3960         }
3961 
3962     }
3963 }
3964 
3965 
3966 /*****************************************************************************/
3967 /// API for acquiring displaying GWIN's properties
3968 /// @param WinProperty  \b OUT: pointer of GOP_GwinDispProperty
3969 /// @return GOP_API_SUCCESS - Success
3970 /*****************************************************************************/
MApi_GOP_GWIN_GetWinProperty(GOP_GwinDispProperty * WinProperty)3971 E_GOP_API_Result MApi_GOP_GWIN_GetWinProperty(GOP_GwinDispProperty *WinProperty)
3972 {
3973     GOP_GwinInfo gWin;
3974     GOP_ENTRY();
3975 
3976     memset(&gWin, 0, sizeof(GOP_GwinInfo));
3977 
3978     if(GOP_API_SUCCESS == MApi_GOP_GWIN_GetWinInfo(WinProperty->gId,&gWin))
3979     {
3980         WinProperty->StartX=gWin.u16DispHPixelStart;
3981         WinProperty->StartY=gWin.u16DispVPixelStart;
3982         //WinProperty->GOPWinWidth=gWin.u16DispVPixelEnd-gWin.u16DispHPixelStart;
3983         WinProperty->Win_Width=gWin.u16DispHPixelEnd-gWin.u16DispHPixelStart+1;
3984         WinProperty->Win_Height=gWin.u16DispVPixelEnd-gWin.u16DispVPixelStart+1;
3985         GOP_RETURN(GOP_API_SUCCESS);
3986     }
3987     else
3988     {
3989         GOP_RETURN(GOP_API_FAIL);
3990     }
3991 
3992 }
3993 
3994 /*****************************************************************************/
3995 /// API for acquiring color format of some Framebuffer
3996 /// @param fbId  \b IN frame buffer id
3997 /// @return the format of Frame buffer. If return 0xF, it represents get frame buffer format fail.
3998 /*****************************************************************************/
MApi_GOP_GWIN_GetFBFmt(MS_U8 fbId)3999 MS_U16 MApi_GOP_GWIN_GetFBFmt(MS_U8 fbId)
4000 {
4001     return MApi_GOP_GWIN_Get32FBFmt((MS_U32)fbId);
4002 }
4003 
MApi_GOP_GWIN_Get32FBFmt(MS_U32 u32fbId)4004 MS_U16 MApi_GOP_GWIN_Get32FBFmt(MS_U32 u32fbId)
4005 {
4006    GOP_GwinFBAttr fbAttr;
4007    GOP_ENTRY();
4008 
4009     if (!MApi_GOP_GWIN_Is32FBExist(u32fbId))
4010     {
4011         MS_DEBUG_MSG( GOP_ERR("MApi_GOP_GWIN_Get32FBFmt: u32fbId=%d is not in existence\n",u32fbId));
4012         GOP_RETURN(GWIN_NO_AVAILABLE);
4013     }
4014     else
4015     {
4016         if(MApi_GOP_GWIN_Get32FBInfo(u32fbId, &fbAttr) == GOP_API_SUCCESS)
4017         {
4018             GOP_RETURN(fbAttr.fbFmt);
4019         }
4020         else
4021         {
4022             GOP_RETURN(GOP_API_FAIL);
4023         }
4024     }
4025 }
4026 
4027 
4028 /*****************************************************************************/
4029 /// API for acquiring current FB's ID
4030 /// @ return current FB'id. if return is 0xFF, it represents get current frame buffer fail
4031 /*****************************************************************************/
MApi_GOP_GWIN_GetCurrentFBID(void)4032 MS_U8 MApi_GOP_GWIN_GetCurrentFBID(void)
4033 {
4034     MS_U32 u32CurFBID;
4035 
4036     u32CurFBID = MApi_GOP_GWIN_GetCurrent32FBID();
4037     if( u32CurFBID > 256) //Out of MS_U8
4038     {
4039         GOP_WARN( "[Warning] %s %d( u32CurFBID:%td....)out of MS_U8 bound, please to use MApi_GOP_GWIN_GetCurrent32FBID()\n",__FUNCTION__,__LINE__,(ptrdiff_t)u32CurFBID );
4040     }
4041     return u32CurFBID;
4042 }
4043 
MApi_GOP_GWIN_GetCurrent32FBID(void)4044 MS_U32 MApi_GOP_GWIN_GetCurrent32FBID(void)
4045 {
4046     GOP_GET_STATUS_PARAM ioctl_info;
4047     MS_U32 u32FbId = INVALID_POOL_NEXT_FBID;
4048     GOP_ENTRY();
4049     ioctl_info.type = 0;
4050     ioctl_info.en_status = E_GOP_STATUS_CURRENT_FBID;
4051     ioctl_info.pStatus = (MS_U32*) &u32FbId;
4052     ioctl_info.u32Size = sizeof(MS_U32);
4053 
4054     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GET_STATUS,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
4055     {
4056         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4057         GOP_RETURN(GOP_API_FAIL);
4058     }
4059     GOP_RETURN(u32FbId);
4060 
4061 }
4062 
4063 
4064 /********************************************************************************/
4065 /// Enable/disable GOP field inverse
4066 /// @param enable  \b IN TRUE/FALSE
4067 /// @return GOP_API_SUCCESS - Success
4068 /********************************************************************************/
MApi_GOP_GWIN_SetFieldInver_EX(MS_U8 u8GOP,MS_BOOL enable)4069 E_GOP_API_Result MApi_GOP_GWIN_SetFieldInver_EX(MS_U8 u8GOP,MS_BOOL enable)
4070 {
4071     MS_BOOL bFieldInv;
4072     GOP_SET_PROPERTY_PARAM ioctl_info;
4073 
4074     GOP_ENTRY();
4075 
4076     memset(&ioctl_info, 0x0, sizeof(GOP_SET_PROPERTY_PARAM));
4077     bFieldInv = enable;
4078 
4079     ioctl_info.en_pro   = E_GOP_FIELD_INVERSE;
4080     ioctl_info.gop_idx  = u8GOP;
4081     ioctl_info.pSetting = (void*)&bFieldInv;
4082     ioctl_info.u32Size  = sizeof(MS_BOOL);
4083 
4084     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
4085     {
4086         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4087         GOP_RETURN( GOP_API_FAIL);
4088     }
4089 
4090     GOP_RETURN(GOP_API_SUCCESS);
4091 
4092 }
MApi_GOP_GWIN_SetFieldInver(MS_BOOL enable)4093 E_GOP_API_Result MApi_GOP_GWIN_SetFieldInver(MS_BOOL enable)
4094 {
4095     MS_U8 u8GOP;
4096     E_GOP_API_Result ret;
4097 
4098     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
4099     ret = MApi_GOP_GWIN_SetFieldInver_EX(u8GOP,enable);
4100     return ret;
4101 }
4102 
4103 //******************************************************************************
4104 /// Enable gop transparent color
4105 /// @param fmt \b IN: RGB mode or u8Index mode color format
4106 /// @param bEnable \b IN:
4107 ///   - # TRUE Enable gop transparent color
4108 ///   - # FALSE Disable gop transparent color
4109 /// @return GOP_API_SUCCESS - Success
4110 //******************************************************************************
MApi_GOP_GWIN_EnableTransClr_EX(MS_U8 u8GOP,EN_GOP_TRANSCLR_FMT fmt,MS_BOOL bEnable)4111 E_GOP_API_Result MApi_GOP_GWIN_EnableTransClr_EX(MS_U8 u8GOP,EN_GOP_TRANSCLR_FMT fmt, MS_BOOL bEnable)
4112 {
4113     GOP_SET_PROPERTY_PARAM ioctl_info;
4114     GOP_TRANSCOLOR trans_set;
4115 
4116     GOP_ENTRY();
4117     trans_set.bEn = bEnable;
4118     trans_set.color = u32TransColor;
4119     trans_set.fmt = fmt;
4120     trans_set.transclr_property =  EN_TRANSCLR_ENABLE;
4121 
4122     ioctl_info.en_pro = E_GOP_TRANSCOLOR;
4123     ioctl_info.gop_idx = u8GOP;
4124     ioctl_info.pSetting = (void*)&trans_set;
4125     ioctl_info.u32Size = sizeof(GOP_TRANSCOLOR);
4126 
4127 
4128     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
4129     {
4130         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4131         GOP_RETURN(GOP_API_FAIL);
4132     }
4133 
4134     GOP_RETURN(GOP_API_SUCCESS);
4135 
4136 }
MApi_GOP_GWIN_EnableTransClr(EN_GOP_TRANSCLR_FMT fmt,MS_BOOL bEnable)4137 E_GOP_API_Result MApi_GOP_GWIN_EnableTransClr(EN_GOP_TRANSCLR_FMT fmt, MS_BOOL bEnable)
4138 {
4139     MS_U8 u8GOP;
4140     E_GOP_API_Result ret;
4141 
4142     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
4143     ret = MApi_GOP_GWIN_EnableTransClr_EX(u8GOP,fmt,bEnable);
4144     return ret;
4145 }
4146 /********************************************************************************/
4147 /// Set GWIN Blink
4148 /// @param bEnable \b IN
4149 ///   - # TRUE enable
4150 ///   - # FALSE disable
4151 /// @param u8rate \b IN Blink frame rate
4152 /// @return GOP_API_SUCCESS - Success
4153 /********************************************************************************/
MApi_GOP_GWIN_SetBlink(MS_BOOL bEnable,MS_U8 u8rate)4154 E_GOP_API_Result MApi_GOP_GWIN_SetBlink(MS_BOOL bEnable, MS_U8 u8rate)
4155 {
4156     GOP_GWIN_PROPERTY_PARAM ioctl_info;
4157     GOP_GWIN_BLINK blinkInfo;
4158     GOP_ENTRY();
4159     ioctl_info.en_property = E_GOP_GWIN_BLINK;
4160     ioctl_info.GwinId = 0x0;
4161     ioctl_info.pSet = (MS_U32*)&blinkInfo;
4162     ioctl_info.u32Size = sizeof(GOP_GWIN_BLINK);
4163 
4164     blinkInfo.rate = u8rate;
4165     blinkInfo.bEn = bEnable;
4166 
4167     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
4168     {
4169         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4170         GOP_RETURN(GOP_API_FAIL);
4171     }
4172 
4173     GOP_RETURN(GOP_API_SUCCESS);
4174 
4175 }
4176 
MApi_GOP_GWIN_Enable_BGWIN(MS_U8 bgwID,MS_BOOL bEnable)4177 E_GOP_API_Result MApi_GOP_GWIN_Enable_BGWIN(MS_U8 bgwID, MS_BOOL bEnable)
4178 {
4179     GOP_ENTRY();
4180     GOP_ERR("[%s] Not Support \n",__FUNCTION__);
4181     GOP_RETURN(GOP_API_SUCCESS);
4182 }
4183 
4184 
MApi_GOP_GWIN_Set_BGWIN(MS_U8 bgwID,MS_U16 x0,MS_U16 y0,MS_U16 w,MS_U16 h,MS_U16 color)4185 E_GOP_API_Result MApi_GOP_GWIN_Set_BGWIN(MS_U8 bgwID, MS_U16 x0, MS_U16 y0, MS_U16 w, MS_U16 h, MS_U16 color)
4186 {
4187     GOP_ENTRY();
4188     GOP_ERR("[%s] Not Support \n",__FUNCTION__);
4189     GOP_RETURN(GOP_API_SUCCESS);
4190 }
4191 
MApi_GOP_GWIN_Set_BGWIN_Alpha(MS_U8 bgwID,MS_BOOL bEnable,MS_U8 alpha)4192 E_GOP_API_Result MApi_GOP_GWIN_Set_BGWIN_Alpha(MS_U8 bgwID, MS_BOOL bEnable, MS_U8 alpha)
4193 {
4194     GOP_ENTRY();
4195     GOP_ERR("[%s] Not Support \n",__FUNCTION__);
4196     GOP_RETURN(GOP_API_SUCCESS);
4197 }
4198 
4199 // Alignment stretch window value
4200 
4201 /********************************************************************************/
4202 /// Set stretch window property
4203 /// @param u8GOP_num \b IN 0: GOP0  1:GOP1
4204 /// @param eDstType \b IN \copydoc EN_GOP_DST_TYPE
4205 /// @param x \b IN stretch window horizontal start position
4206 /// @param y \b IN stretch window vertical start position
4207 /// @param width \b IN stretch window width
4208 /// @param height \b IN stretch window height
4209 /// @return GOP_API_SUCCESS - Success
4210 /// @return GOP_API_FAIL - Failure
4211 /********************************************************************************/
MApi_GOP_GWIN_Set_STRETCHWIN(MS_U8 u8GOP_num,EN_GOP_DST_TYPE eDstType,MS_U16 x,MS_U16 y,MS_U16 width,MS_U16 height)4212 E_GOP_API_Result MApi_GOP_GWIN_Set_STRETCHWIN(MS_U8 u8GOP_num, EN_GOP_DST_TYPE eDstType,MS_U16 x, MS_U16 y, MS_U16 width, MS_U16 height)
4213 {
4214     GOP_STRETCH_SET_PARAM ioctl_info;
4215     GOP_STRETCH_INFO stretch_info;
4216     GOP_ENTRY();
4217 
4218     memset(&ioctl_info,0x0, sizeof(GOP_STRETCH_SET_PARAM));
4219     memset(&stretch_info, 0x0, sizeof(GOP_STRETCH_INFO));
4220 
4221     stretch_info.DstRect.x = x;
4222     stretch_info.DstRect.y = y;
4223     stretch_info.DstRect.w = width;
4224     stretch_info.DstRect.h = height;
4225 
4226     stretch_info.SrcRect.x = x;
4227     stretch_info.SrcRect.y = y;
4228     stretch_info.SrcRect.w = width;
4229     stretch_info.SrcRect.h = height;
4230 
4231     ioctl_info.gop_idx = u8GOP_num;
4232     ioctl_info.enStrtchType = E_GOP_STRETCH_WIN;
4233     ioctl_info.pStretch = (MS_U32*)&stretch_info;
4234     ioctl_info.u32Size = sizeof(GOP_STRETCH_INFO);
4235 
4236     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_STRETCH,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
4237     {
4238         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4239         GOP_RETURN(GOP_API_FAIL);
4240     }
4241 
4242     GOP_RETURN(GOP_API_SUCCESS);
4243 
4244 }
4245 
4246 /********************************************************************************/
4247 /// Set stretch window position
4248 /// @param u8GOPNum \b IN 0: GOP0  1:GOP1
4249 /// @param u16DispX \b IN stretch window horizontal start position
4250 /// @param u16DispY \b IN stretch window vertical start position
4251 /// @return GOP_API_SUCCESS - Success
4252 /// @return GOP_API_INVALID_PARAMETERS - Failure
4253 /********************************************************************************/
MApi_GOP_GWIN_SetStretchWinPosition(MS_U8 u8GOPNum,MS_U16 u16DispX,MS_U16 u16DispY)4254 E_GOP_API_Result MApi_GOP_GWIN_SetStretchWinPosition(MS_U8 u8GOPNum, MS_U16 u16DispX, MS_U16 u16DispY)
4255 {
4256     GOP_STRETCH_SET_PARAM ioctl_StrrtchInfo;
4257     GOP_STRETCH_INFO stretch_info;
4258     GOP_ENTRY();
4259 
4260     memset(&ioctl_StrrtchInfo, 0x0, sizeof(GOP_STRETCH_SET_PARAM));
4261     memset(&stretch_info, 0x0, sizeof(GOP_STRETCH_INFO));
4262 
4263     stretch_info.SrcRect.x = u16DispX;
4264     stretch_info.SrcRect.y = u16DispY;
4265 
4266     ioctl_StrrtchInfo.gop_idx = u8GOPNum;
4267     ioctl_StrrtchInfo.enStrtchType = E_GOP_STRETCH_WIN_POSITION;
4268     ioctl_StrrtchInfo.pStretch = (MS_U32*)&stretch_info;
4269     ioctl_StrrtchInfo.u32Size = sizeof(GOP_STRETCH_INFO);
4270 
4271     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_STRETCH,(void*)&ioctl_StrrtchInfo) != UTOPIA_STATUS_SUCCESS)
4272     {
4273         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4274         GOP_RETURN( GOP_API_FAIL);
4275     }
4276 
4277     GOP_RETURN(GOP_API_SUCCESS);
4278 
4279 }
4280 
4281 
4282 /********************************************************************************/
4283 /// Restore initial stretch window setting of GOP. It will set gop to OP path and stretch window width/height
4284 /// to panel width/height
4285 /// @param u8GOPNum \b IN : Number of GOP
4286 /// @return GOP_API_SUCCESS - Success
4287 /********************************************************************************/
MApi_GOP_Initialize_StretchWindow(MS_U8 u8GOPNum)4288 E_GOP_API_Result MApi_GOP_Initialize_StretchWindow(MS_U8 u8GOPNum)
4289 {
4290 #ifndef CONFIG_GOP_GWIN_MISC
4291     GOP_ERR("\33[0;36m   %s: #define CONFIG_GOP_GWIN_MISC not opened\33[m \n",__FUNCTION__);
4292     return GOP_API_FUN_NOT_SUPPORTED;
4293 #else
4294     ST_GOP_TIMING_INFO stTimingInfo;
4295     MS_PHY *plist;
4296 
4297     GOP_ENTRY();
4298     plist = (MS_PHY *)(void*)&stTimingInfo;
4299 
4300     MApi_GOP_GetConfigEx(u8GOPNum,E_GOP_TIMING_INFO,plist);
4301 
4302 #if (FPGA_TEST)
4303     MApi_GOP_GWIN_Set_STRETCHWIN(u8GOPNum, E_GOP_DST_VOP,0, 0
4304         , stTimingInfo.u16DEHSize, stTimingInfo.u16DEVSize);
4305 #else
4306     MApi_GOP_GWIN_Set_STRETCHWIN(u8GOPNum, E_GOP_DST_OP0,0, 0
4307         , stTimingInfo.u16DEHSize, stTimingInfo.u16DEVSize);
4308 #endif
4309     GOP_RETURN(GOP_API_SUCCESS);
4310 #endif
4311 }
4312 
4313 
4314 
4315 /********************************************************************************/
4316 /// Set GOP H-Mirror
4317 /// @param bEnable \b IN
4318 ///   - # TRUE enable
4319 ///   - # FALSE disable
4320 /// @return GOP_API_SUCCESS - Success
4321 /********************************************************************************/
MApi_GOP_GWIN_SetHMirror_EX(MS_U8 u8GOP,MS_BOOL bEnable)4322 E_GOP_API_Result MApi_GOP_GWIN_SetHMirror_EX(MS_U8 u8GOP,MS_BOOL bEnable)
4323 {
4324     GOP_SETMIRROR_PARAM ioctl_info;
4325     GOP_ENTRY();
4326     memset(&ioctl_info, 0x0, sizeof(GOP_SETMIRROR_PARAM));
4327 
4328 
4329     if(bEnable == TRUE)
4330         ioctl_info.dir = E_GOP_MIRROR_H_ONLY;
4331     else
4332         ioctl_info.dir = E_GOP_MIRROR_H_NONE;
4333 
4334     ioctl_info.gop_idx = (MS_U32)u8GOP;  //get current gop for driver capability
4335     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_MIRROR,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
4336     {
4337         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4338         GOP_RETURN(GOP_API_FAIL);
4339     }
4340 
4341 
4342     GOP_RETURN(GOP_API_SUCCESS);
4343 }
MApi_GOP_GWIN_SetHMirror(MS_BOOL bEnable)4344 E_GOP_API_Result MApi_GOP_GWIN_SetHMirror(MS_BOOL bEnable)
4345 {
4346     MS_U8 u8GOP;
4347     E_GOP_API_Result ret;
4348 
4349     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
4350     ret = MApi_GOP_GWIN_SetHMirror_EX(u8GOP,bEnable);
4351     return ret;
4352 }
4353 //******************************************************************************
4354 /// Get gop h-mirror and v-mirror status
4355 /// @param *bHMirror \b OUT TRUE:h-Mirror on, FALSE: h-Mirror off
4356 /// @param *bVMirror \b OUT TRUE:v-Mirror on, FALSE: v-Mirror off
4357 /// @return GOP_API_SUCCESS - Success
4358 //******************************************************************************
MApi_GOP_GWIN_IsMirrorOn_EX(MS_U8 u8GOP,MS_BOOL * bHMirror,MS_BOOL * bVMirror)4359 E_GOP_API_Result MApi_GOP_GWIN_IsMirrorOn_EX(MS_U8 u8GOP,MS_BOOL *bHMirror, MS_BOOL *bVMirror)
4360 {
4361     GOP_GETMIRROR_PARAM ioctl_info;
4362     EN_GOP_MIRROR_TYPE mirror_type;
4363     GOP_ENTRY();
4364     memset(&ioctl_info, 0x0, sizeof(GOP_GETMIRROR_PARAM));
4365 
4366     ioctl_info.gop_idx = (MS_U32)u8GOP;  //get current gop for driver capability
4367     ioctl_info.pdir    = &mirror_type;
4368 
4369     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GET_MIRROR,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
4370     {
4371         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4372         GOP_RETURN(GOP_API_FAIL);
4373     }
4374 
4375     if(mirror_type == E_GOP_MIRROR_HV)
4376     {
4377         *bHMirror = TRUE;
4378         *bVMirror = TRUE;
4379     }
4380     else if(mirror_type == E_GOP_MIRROR_H_ONLY)
4381     {
4382         *bHMirror = TRUE;
4383         *bVMirror = FALSE;
4384     }
4385     else if(mirror_type == E_GOP_MIRROR_V_ONLY)
4386     {
4387         *bHMirror = FALSE;
4388         *bVMirror = TRUE;
4389     }
4390     else
4391     {
4392         *bHMirror = FALSE;
4393         *bVMirror = FALSE;
4394     }
4395 
4396     GOP_RETURN(GOP_API_SUCCESS);
4397 
4398 }
MApi_GOP_GWIN_IsMirrorOn(MS_BOOL * bHMirror,MS_BOOL * bVMirror)4399 E_GOP_API_Result MApi_GOP_GWIN_IsMirrorOn(MS_BOOL *bHMirror, MS_BOOL *bVMirror)
4400 {
4401     MS_U8 u8GOP;
4402     E_GOP_API_Result ret;
4403 
4404     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
4405     ret = MApi_GOP_GWIN_IsMirrorOn_EX(u8GOP,bHMirror,bVMirror);
4406     return ret;
4407 }
4408 /********************************************************************************/
4409 /// Set GOP V-Mirror
4410 /// @param bEnable \b IN
4411 ///   - # TRUE enable
4412 ///   - # FALSE disable
4413 /// @return GOP_API_SUCCESS - Success
4414 /********************************************************************************/
MApi_GOP_GWIN_SetVMirror_EX(MS_U8 u8GOP,MS_BOOL bEnable)4415 E_GOP_API_Result MApi_GOP_GWIN_SetVMirror_EX(MS_U8 u8GOP,MS_BOOL bEnable)
4416 {
4417     GOP_SETMIRROR_PARAM ioctl_info;
4418     GOP_ENTRY();
4419     memset(&ioctl_info, 0x0, sizeof(GOP_SETMIRROR_PARAM));
4420 
4421     if( bEnable == TRUE )
4422         ioctl_info.dir = E_GOP_MIRROR_V_ONLY;
4423     else
4424         ioctl_info.dir = E_GOP_MIRROR_V_NONE;
4425 
4426     ioctl_info.gop_idx = (MS_U32)u8GOP;  //get current gop for driver capability
4427     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_MIRROR,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
4428     {
4429         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4430         GOP_RETURN(GOP_API_FAIL);
4431     }
4432 
4433     GOP_RETURN(GOP_API_SUCCESS);
4434 
4435 }
4436 
MApi_GOP_GWIN_SetVMirror(MS_BOOL bEnable)4437 E_GOP_API_Result MApi_GOP_GWIN_SetVMirror(MS_BOOL bEnable)
4438 {
4439     MS_U8 u8GOP;
4440     E_GOP_API_Result ret;
4441     u8GOP = MApi_GOP_GWIN_GetCurrentGOP();
4442     ret = MApi_GOP_GWIN_SetVMirror_EX(u8GOP,bEnable);
4443     return ret;
4444 }
4445 
4446 /********************************************************************************/
4447 /// Set GWIN Tile Mode
4448 /// @param u8win \b IN GWIN id
4449 /// @param bEnable \b IN
4450 ///   - # TRUE Gwin Tile Mode
4451 ///   - # FALSE Gwin Tile Mode
4452 /// @param u8coef \b IN alpha blending coefficient (0-7)
4453 /// @return GOP_API_SUCCESS - Success
4454 /********************************************************************************/
MApi_GOP_GWIN_SetGPUTile(MS_U8 u8win,EN_GOP_GPU_TILE_MODE TileMode)4455 E_GOP_API_Result MApi_GOP_GWIN_SetGPUTile(MS_U8 u8win, EN_GOP_GPU_TILE_MODE TileMode)
4456 {
4457     GOP_GWIN_PROPERTY_PARAM ioctl_info;
4458     EN_GOP_GPU_TILE_MODE mode;
4459     mode = TileMode;
4460     GOP_ENTRY();
4461     ioctl_info.en_property = E_GOP_GWIN_GPUTILE;
4462     ioctl_info.GwinId = u8win;
4463     ioctl_info.pSet = (MS_U32*)&mode;
4464     ioctl_info.u32Size = sizeof(EN_GOP_GPU_TILE_MODE);
4465 
4466 
4467     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
4468     {
4469         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4470         GOP_RETURN(GOP_API_FAIL);
4471     }
4472 
4473     GOP_RETURN(GOP_API_SUCCESS);
4474 
4475 }
4476 
4477 /********************************************************************************/
4478 /// Set GOP TLB Mode
4479 /// @param u8GOP \b IN: only init by which gop
4480 /// @param bEnable \b IN
4481 ///   - # TRUE enable
4482 ///   - # FALSE disable
4483 /// @param tlbaddr \b TLB entry base address
4484 /// @return GOP_API_SUCCESS - Success
4485 /********************************************************************************/
MApi_GOP_TLB_Enable(MS_U8 u8GOP,MS_BOOL bEnable,MS_PHY phytlbaddr)4486 E_GOP_API_Result MApi_GOP_TLB_Enable(MS_U8 u8GOP,MS_BOOL bEnable, MS_PHY phytlbaddr)
4487 {
4488     GOP_SET_PROPERTY_PARAM ioctl_info;
4489     GOP_TLB_Enable tlb_enable;
4490 
4491     GOP_ENTRY();
4492     tlb_enable.gop_idx = (MS_U32)u8GOP;
4493     tlb_enable.bEn = bEnable;
4494     tlb_enable.u64TLBAddr = phytlbaddr;
4495 
4496     ioctl_info.en_pro = E_GOP_GWIN_TLB_ENABLE;
4497     ioctl_info.gop_idx = u8GOP;
4498     ioctl_info.pSetting = (MS_U32*)&tlb_enable;
4499     ioctl_info.u32Size = sizeof(GOP_TLB_Enable);
4500 
4501     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
4502     {
4503         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4504         GOP_RETURN(GOP_API_FAIL);
4505     }
4506 
4507     GOP_RETURN(GOP_API_SUCCESS);
4508 
4509 }
4510 
4511 //-------------------------------------------------------------------------------------------------
4512 /// GOP Exit
4513 /// @param  void                \b IN: none
4514 //-------------------------------------------------------------------------------------------------
MApi_GOP_Exit()4515 void MApi_GOP_Exit()
4516 {
4517     //App call exit, should wait mutex return to avoid mutex conflict use with other thread.
4518     //But do not need GOP_RETURN, because all mutex and resouce has been released in atexit.
4519     GOP_INFO("---%s %d: PID[%td], TID[%td] tries to exit\n", __FUNCTION__, __LINE__, (ptrdiff_t)getpid(), (ptrdiff_t)MsOS_GetOSThreadID());
4520     GOP_ENTRY();
4521 #ifdef  MSOS_TYPE_LINUX
4522     GOP_MISC_PARAM ioctl_info;
4523     MS_U32  value = 0;
4524 
4525     ioctl_info.misc_type = E_GOP_MISC_AT_EXIT;
4526     ioctl_info.pMISC = (MS_U32*)&value;
4527     ioctl_info.u32Size  = sizeof(MS_U32);
4528 
4529     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_MISC,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
4530     {
4531         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4532         return;
4533     }
4534 #else
4535     GOP_INFO("not enable MSOS_TYPE_LINUX\n");
4536 #endif
4537 }
4538 
4539 //-------------------------------------------------------------------------------------------------
4540 /// Initial individual GOP driver
4541 /// @param pGopInit \b IN:gop driver init info
4542 /// @param u8GOP \b IN: only init by which gop
4543 /// @return GOP_API_SUCCESS - Success
4544 /// @return GOP_API_FAIL - Failure
4545 //-------------------------------------------------------------------------------------------------
MApi_GOP_InitByGOP(GOP_InitInfo * pGopInit,MS_U8 u8GOP)4546 E_GOP_API_Result MApi_GOP_InitByGOP(GOP_InitInfo *pGopInit, MS_U8 u8GOP)
4547 {
4548 
4549     GOP_INIT_PARAM  ioctl_info;
4550 
4551     CheckXCOpen();
4552     CheckGOPInstanceOpen();
4553     _GOP_RegisterAllCBFunc();
4554 
4555     ioctl_info.gop_idx = u8GOP;
4556     ioctl_info.pInfo = (MS_U32*) pGopInit;
4557     ioctl_info.u32Size = sizeof(GOP_InitInfo);
4558 
4559     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_INIT,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
4560     {
4561         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4562         return GOP_API_FAIL;
4563     }
4564 #ifdef  MSOS_TYPE_LINUX
4565     atexit(MApi_GOP_Exit);
4566 #endif
4567     bInit =TRUE;
4568     return GOP_API_SUCCESS;
4569 }
4570 
4571 
4572 //-------------------------------------------------------------------------------------------------
4573 /// Initial all GOP driver (include gop0, gop1 ext..)
4574 /// @param pGopInit \b IN:gop driver init info
4575 /// @return GOP_API_SUCCESS - Success
4576 /// @return GOP_API_FAIL - Failure
4577 //-------------------------------------------------------------------------------------------------
MApi_GOP_Init(GOP_InitInfo * pGopInit)4578 E_GOP_API_Result MApi_GOP_Init(GOP_InitInfo *pGopInit)
4579 {
4580     GOP_INIT_PARAM  ioctl_info;
4581     MS_U32 i =0;
4582 
4583     CheckXCOpen();
4584     CheckGOPInstanceOpen();
4585     //init GOP0
4586     _GOP_RegisterAllCBFunc();
4587     ioctl_info.gop_idx = 0;
4588     ioctl_info.pInfo = (MS_U32*) pGopInit;
4589     ioctl_info.u32Size = sizeof(GOP_InitInfo);
4590 
4591     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_INIT,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
4592     {
4593         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4594         return GOP_API_FAIL;
4595     }
4596     //init others
4597     for(i = 1;i<MApi_GOP_GWIN_GetMaxGOPNum();i++)
4598     {
4599         ioctl_info.gop_idx = i;
4600         if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_INIT,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
4601         {
4602             GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4603             return GOP_API_FAIL;
4604         }
4605     }
4606     bInit =TRUE;
4607     return GOP_API_SUCCESS;
4608 }
4609 
4610 /******************************************************************************/
4611 /// Set gwin fade in/out
4612 /// @param gId  \b IN: gwin id
4613 /// @param Width \b IN: gwin display width
4614 /// @param X_Start \b IN: gwin display H display starting position
4615 /// @return GOP_API_SUCCESS - Success
4616 /// @return GOP_API_FAIL - Failure
4617 /******************************************************************************/
MApi_GOP_GWIN_SetFadeInOut(MS_U8 gId,EN_GOP_FADE_TYPE eGwinFadeType,MS_BOOL bEnable,MS_U8 u8FadeRate)4618 E_GOP_API_Result MApi_GOP_GWIN_SetFadeInOut(MS_U8 gId, EN_GOP_FADE_TYPE eGwinFadeType, MS_BOOL bEnable, MS_U8 u8FadeRate)
4619 {
4620     E_GOP_API_Result ret = GOP_API_SUCCESS;
4621     GOP_SET_FADE_PARAM ioctl_info;
4622     GOP_FADE_INFO fade_info;
4623 
4624     GOP_ENTRY();
4625 
4626     memset(&ioctl_info, 0x0, sizeof(GOP_SET_FADE_PARAM));
4627     memset(&fade_info, 0x0, sizeof(GOP_FADE_INFO));
4628 
4629     fade_info.gwin_idx = gId;
4630     fade_info.bEnable = bEnable;
4631     fade_info.eGwinFadeType = (EN_GOP_SET_FADE_TYPE)eGwinFadeType;
4632     fade_info.u8FadeRate = u8FadeRate;
4633 
4634     ioctl_info.pSetting = (MS_U32*)&fade_info;
4635     ioctl_info.u32Size  = sizeof(GOP_FADE_INFO);
4636 
4637     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_FADE,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
4638     {
4639         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4640         GOP_RETURN( GOP_API_FAIL);
4641     }
4642 
4643     GOP_RETURN(ret);
4644 }
4645 
4646 /******************************************************************************/
4647 /// Set a GWIN's H display size
4648 /// @param gId  \b IN: gwin id
4649 /// @param Width \b IN: gwin display width
4650 /// @param X_Start \b IN: gwin display H display starting position
4651 /// @return GOP_API_SUCCESS - Success
4652 /// @return GOP_API_FAIL - Failure
4653 /******************************************************************************/
MApi_GOP_GWIN_SetHDisplaySize(MS_U8 gId,MS_U16 Width,MS_U16 X_Start)4654 E_GOP_API_Result MApi_GOP_GWIN_SetHDisplaySize(MS_U8 gId, MS_U16 Width,MS_U16 X_Start)
4655 {
4656     GOP_GWIN_SETWININFO_PARAM WinInfo;
4657     GOP_BUFFER_INFO  BuffInfo;
4658 
4659 
4660     GOP_ENTRY();
4661 
4662     memset(&WinInfo, 0, sizeof(GOP_GWIN_SETWININFO_PARAM));
4663     memset(&BuffInfo, 0, sizeof(GOP_BUFFER_INFO));
4664 
4665 
4666     WinInfo.GwinId = gId;
4667     WinInfo.pinfo = (MS_U32*)&BuffInfo;
4668     WinInfo.u32Size = sizeof(GOP_BUFFER_INFO);
4669 
4670     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_GET_WININFO,(void*)&WinInfo) != UTOPIA_STATUS_SUCCESS)
4671     {
4672         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4673         GOP_RETURN(GOP_API_FAIL);
4674     }
4675 
4676 
4677     if (X_Start % 4 != 0 )
4678     {
4679        X_Start = (X_Start +2) / 4; // rounding
4680        X_Start = X_Start * 4;
4681     }
4682 
4683     BuffInfo.disp_rect.x = X_Start;
4684     BuffInfo.disp_rect.w = Width;
4685     BuffInfo.width = Width;
4686 
4687 
4688     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_WININFO,(void*)&WinInfo) != UTOPIA_STATUS_SUCCESS)
4689     {
4690         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4691         GOP_RETURN(GOP_API_FAIL);
4692     }
4693 
4694     GOP_RETURN(GOP_API_SUCCESS);
4695 
4696 }
4697 
4698 /******************************************************************************/
4699 /// Move a GWIN's display left top position
4700 /// @param gId  \b IN : GWINID
4701 /// @param dispX \b IN: left top x
4702 /// @param dispY \b IN: left top y
4703 /// @return GOP_API_SUCCESS - Success
4704 /// @return GOP_API_FAIL - Failure
4705 /******************************************************************************/
MApi_GOP_GWIN_SetWinDispPosition(MS_U8 gId,MS_U16 dispX,MS_U16 dispY)4706 E_GOP_API_Result MApi_GOP_GWIN_SetWinDispPosition(MS_U8 gId, MS_U16 dispX, MS_U16 dispY)
4707 {
4708 
4709     GOP_GWIN_SETWININFO_PARAM WinInfo;
4710     GOP_BUFFER_INFO  BuffInfo;
4711 
4712 
4713     GOP_ENTRY();
4714 
4715     memset(&WinInfo, 0, sizeof(GOP_GWIN_SETWININFO_PARAM));
4716     memset(&BuffInfo, 0, sizeof(GOP_BUFFER_INFO));
4717 
4718 
4719     WinInfo.GwinId = gId;
4720     WinInfo.pinfo = (MS_U32*)&BuffInfo;
4721     WinInfo.u32Size = sizeof(GOP_BUFFER_INFO);
4722 
4723     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_GET_WININFO,(void*)&WinInfo) != UTOPIA_STATUS_SUCCESS)
4724     {
4725         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4726         GOP_RETURN(GOP_API_FAIL);
4727     }
4728 
4729     BuffInfo.disp_rect.x = dispX;
4730     BuffInfo.disp_rect.y = dispY;
4731 
4732     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_WININFO,(void*)&WinInfo) != UTOPIA_STATUS_SUCCESS)
4733     {
4734         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4735         GOP_RETURN(GOP_API_FAIL);
4736     }
4737 
4738     GOP_RETURN(GOP_API_SUCCESS);
4739 
4740 }
4741 
4742 
4743 /******************************************************************************/
4744 /// Delete the GWIN, free corresponding frame buffer
4745 /// @param gId \b IN \copydoc GWINID
4746 /// @return GOP_API_SUCCESS - Success
4747 /// @return GOP_API_FAIL - Failure
4748 /******************************************************************************/
MApi_GOP_GWIN_DestroyWin(MS_U8 gId)4749 E_GOP_API_Result MApi_GOP_GWIN_DestroyWin(MS_U8 gId)
4750 {
4751     GOP_GWIN_DESTROY_PARAM ioctl_info;
4752     GOP_ENTRY();
4753     memset(&ioctl_info, 0x0, sizeof(GOP_GWIN_DESTROY_PARAM));
4754     ioctl_info.GwinId = gId;
4755 
4756     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_DESTROY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
4757     {
4758         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4759         GOP_RETURN(GOP_API_FAIL);
4760     }
4761     GOP_RETURN(GOP_API_SUCCESS);
4762 
4763 }
4764 
4765 
4766 /******************************************************************************/
4767 /// Get corresponding frame buffer attribute from a GWIN id
4768 /// @param gId \b IN GWINID
4769 /// @param x0 \b OUT buffer to store left top x
4770 /// @param y0 \b OUT buffer to store left top y
4771 /// @param width \b OUT buffer to store width
4772 /// @param height \b OUT buffer to store height
4773 /// @param fbPitch \b OUT buffer to store pitch
4774 /// @param fbFmt \b OUT buffer to store FB format
4775 /// @param addr \b OUT buffer to store addr
4776 /// @param size \b OUT buffer to store size
4777 /// @return GOP_API_SUCCESS - Success
4778 /// @return GOP_API_FAIL - Failure
4779 /******************************************************************************/
MApi_GOP_GWIN_GetWinAttr(MS_U8 gId,MS_U16 * x0,MS_U16 * y0,MS_U16 * width,MS_U16 * height,MS_U16 * fbPitch,MS_U16 * fbFmt,MS_PHY * addr,MS_U32 * size)4780 E_GOP_API_Result MApi_GOP_GWIN_GetWinAttr(MS_U8 gId, MS_U16 *x0, MS_U16 *y0, MS_U16 *width, MS_U16 *height,  MS_U16 *fbPitch, MS_U16 *fbFmt, MS_PHY *addr, MS_U32 *size)
4781 {
4782 
4783     GOP_GWIN_SETWININFO_PARAM WinInfo;
4784     GOP_BUFFER_INFO  BuffInfo;
4785 
4786 
4787     GOP_ENTRY();
4788 
4789     memset(&WinInfo, 0, sizeof(GOP_GWIN_SETWININFO_PARAM));
4790     memset(&BuffInfo, 0, sizeof(GOP_BUFFER_INFO));
4791 
4792 
4793     WinInfo.GwinId = gId;
4794     WinInfo.pinfo = (MS_U32*)&BuffInfo;
4795     WinInfo.u32Size = sizeof(GOP_BUFFER_INFO);
4796 
4797     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_GET_WININFO,(void*)&WinInfo) != UTOPIA_STATUS_SUCCESS)
4798     {
4799         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4800         GOP_RETURN(GOP_API_FAIL);
4801     }
4802 
4803     *x0 = BuffInfo.disp_rect.x;
4804     *y0 = BuffInfo.disp_rect.y;
4805     *width = BuffInfo.width;
4806     *height = BuffInfo.height;
4807     *fbPitch = BuffInfo.pitch;
4808     *fbFmt = BuffInfo.fbFmt;
4809     *addr = BuffInfo.addr;
4810     *size = BuffInfo.width * BuffInfo.height * GOP_GetBPP((EN_GOP_COLOR_TYPE)BuffInfo.fbFmt)/8;
4811 
4812     GOP_RETURN(GOP_API_SUCCESS);
4813 }
4814 
4815 /********************************************************************************/
4816 /// Get max V-End from all GWIN
4817 /// @param bActive \b IN
4818 ///   - # TRUE enable
4819 ///   - # FALSE disable
4820 /// @return max V-End value from all GWIN
4821 /********************************************************************************/
MApi_GOP_GWIN_GetMaxVEnd(MS_BOOL bActive)4822 MS_U16 MApi_GOP_GWIN_GetMaxVEnd(MS_BOOL bActive)
4823 {
4824 
4825     GOP_ENTRY();
4826     GOP_ERR("[%s] Not SUPPORT\n",__FUNCTION__);
4827     GOP_RETURN(0);
4828 }
4829 
4830 
4831 /******************************************************************************/
4832 /// Get maximum frame buffer number
4833 /// @return maximum frame buffer number
4834 /******************************************************************************/
MApi_GOP_GWIN_GetMaxFBNum(void)4835 MS_U8 MApi_GOP_GWIN_GetMaxFBNum(void)
4836 {
4837     MS_U32 u32MaxFBNum;
4838     u32MaxFBNum = MApi_GOP_GWIN_GetMax32FBNum ();
4839     if( u32MaxFBNum > 256) //Out of MS_U8
4840     {
4841         GOP_WARN( "[Warning] %s %d( u32MaxFBNum:%td....)out of MS_U8 bound, please to use MApi_GOP_GWIN_GetMax32FBNum()\n",__FUNCTION__,__LINE__,(ptrdiff_t)u32MaxFBNum );
4842     }
4843     return u32MaxFBNum;
4844 }
4845 
MApi_GOP_GWIN_GetMax32FBNum(void)4846 MS_U32 MApi_GOP_GWIN_GetMax32FBNum(void)
4847 {
4848     MS_PHY u32FBIDNum=INVALID_POOL_NEXT_FBID;
4849     MApi_GOP_GetConfigEx(0, E_GOP_GET_MAXFBNUM, &u32FBIDNum);
4850     return u32FBIDNum;
4851 }
4852 
4853 
4854 /********************************************************************************/
4855 /// Set second frame buffer pool
4856 /// @param u32DblHeapAdr \b IN: second frame buffer pool starting address
4857 /// @param u32DblHeapLen \b IN: second frame buffer pool length
4858 /// @return GOP_API_SUCCESS - Success
4859 /// @return GOP_API_FAIL - Failure
4860 /********************************************************************************/
MApi_GOP_GWIN_SetDoubleHeap(MS_U32 u32DblHeapAdr,MS_U32 u32DblHeapLen)4861 E_GOP_API_Result MApi_GOP_GWIN_SetDoubleHeap(MS_U32 u32DblHeapAdr, MS_U32 u32DblHeapLen)
4862 {
4863     GOP_ERR("[%s] Not SUPPORT\n",__FUNCTION__);
4864     return GOP_API_SUCCESS;
4865 }
4866 
4867 
4868 /******************************************************************************/
4869 /// Create frame buffer from given frame buffer id . User should call MApi_GOP_GWIN_GetFree32FBID()
4870 /// first and then use this frame buffer id as this function input parameter
4871 /// @param fbId  \b IN frame buffer id
4872 /// @param dispX \b IN display x
4873 /// @param dispY \b IN display y
4874 /// @param width \b IN width
4875 /// @param height \b IN height
4876 /// @param fbFmt \b IN frame buffer format
4877 /// @return GOP_API_SUCCESS - Success
4878 /// @return GOP_API_CRT_GWIN_NOAVAIL - Failure
4879 /******************************************************************************/
MApi_GOP_GWIN_CreateFB(MS_U8 fbId,MS_U16 dispX,MS_U16 dispY,MS_U16 width,MS_U16 height,MS_U16 fbFmt)4880 MS_U8 MApi_GOP_GWIN_CreateFB(MS_U8 fbId, MS_U16 dispX, MS_U16 dispY, MS_U16 width, MS_U16 height,  MS_U16 fbFmt)
4881 {
4882     return MApi_GOP_GWIN_Create32FB((MS_U32)fbId, dispX, dispY, width, height, fbFmt);
4883 }
4884 
MApi_GOP_GWIN_Create32FB(MS_U32 u32fbId,MS_U16 dispX,MS_U16 dispY,MS_U16 width,MS_U16 height,MS_U16 fbFmt)4885 MS_U8 MApi_GOP_GWIN_Create32FB(MS_U32 u32fbId, MS_U16 dispX, MS_U16 dispY, MS_U16 width, MS_U16 height,  MS_U16 fbFmt)
4886 {
4887     GOP_CREATE_BUFFER_PARAM ioctl_info;
4888     GOP_BUFFER_INFO BuffInfo;
4889 
4890     GOP_ENTRY();
4891 
4892     memset(&ioctl_info, 0x0, sizeof(GOP_CREATE_BUFFER_PARAM));
4893     memset(&BuffInfo, 0x0, sizeof(GOP_BUFFER_INFO));
4894 
4895     ioctl_info.fb_type  = GOP_CREATE_BUFFER;
4896     ioctl_info.pBufInfo = (MS_U32*)&BuffInfo;
4897     ioctl_info.u32Size = sizeof(GOP_BUFFER_INFO);
4898     ioctl_info.fbid = u32fbId;
4899 
4900     BuffInfo.addr = 0x0;
4901     BuffInfo.fbFmt = fbFmt;
4902     BuffInfo.disp_rect.x = dispX;
4903     BuffInfo.disp_rect.y = dispY;
4904     BuffInfo.disp_rect.w = width;
4905     BuffInfo.disp_rect.h = height;
4906 
4907     BuffInfo.width = width;
4908     BuffInfo.height = height;
4909 
4910     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_FB_CREATE,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
4911     {
4912         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4913         GOP_RETURN( GOP_API_FAIL);
4914     }
4915     GOP_RETURN(GOP_API_SUCCESS);
4916 
4917 }
4918 
4919 
4920 /******************************************************************************/
4921 /// Create frame buffer from given frame buffer id and dram address. User should call MApi_GOP_GWIN_GetFree32FBID()
4922 /// first and then use this frame buffer id as this function input parameter
4923 /// @param fbId  \b IN: frame buffer id
4924 /// @param dispX \b IN: frame buffer starting x
4925 /// @param dispY \b IN: frame buffer starting y
4926 /// @param width \b IN: frame buffer width
4927 /// @param height \b IN: frame buffer height
4928 /// @param fbFmt \b IN: frame buffer color format
4929 /// @param u32FbAddr \b IN: frame buffer starting address
4930 /// @param FBString \b IN: create frame buffer by which one application
4931 /// @return GOP_API_SUCCESS - Success
4932 /// @return GOP_API_CRT_GWIN_NOAVAIL - Failure
4933 /******************************************************************************/
MApi_GOP_GWIN_CreateFBbyStaticAddr2(MS_U8 fbId,MS_U16 dispX,MS_U16 dispY,MS_U16 width,MS_U16 height,MS_U16 fbFmt,MS_PHY phyFbAddr,EN_GOP_FRAMEBUFFER_STRING FBString)4934 MS_U8 MApi_GOP_GWIN_CreateFBbyStaticAddr2(MS_U8 fbId, MS_U16 dispX, MS_U16 dispY, MS_U16 width, MS_U16 height,  MS_U16 fbFmt, MS_PHY phyFbAddr ,EN_GOP_FRAMEBUFFER_STRING FBString)
4935 {
4936     return MApi_GOP_GWIN_Create32FBbyStaticAddr2((MS_U32)fbId, dispX, dispY, width, height, fbFmt, phyFbAddr, FBString);
4937 }
4938 
MApi_GOP_GWIN_Create32FBbyStaticAddr2(MS_U32 u32fbId,MS_U16 dispX,MS_U16 dispY,MS_U16 width,MS_U16 height,MS_U16 fbFmt,MS_PHY phyFbAddr,EN_GOP_FRAMEBUFFER_STRING FBString)4939 MS_U8 MApi_GOP_GWIN_Create32FBbyStaticAddr2(MS_U32 u32fbId, MS_U16 dispX, MS_U16 dispY, MS_U16 width, MS_U16 height,  MS_U16 fbFmt, MS_PHY phyFbAddr ,EN_GOP_FRAMEBUFFER_STRING FBString)
4940 {
4941     GOP_CREATE_BUFFER_PARAM ioctl_info;
4942     GOP_BUFFER_INFO BuffInfo;
4943     GOP_ENTRY();
4944     memset(&ioctl_info, 0x0, sizeof(GOP_CREATE_BUFFER_PARAM));
4945     memset(&BuffInfo, 0x0, sizeof(GOP_BUFFER_INFO));
4946 
4947     ioctl_info.fb_type  = GOP_CREATE_BUFFER_BYADDR;
4948     ioctl_info.pBufInfo = (MS_U32*)&BuffInfo;
4949     ioctl_info.u32Size = sizeof(GOP_BUFFER_INFO);
4950     ioctl_info.fbid = u32fbId;
4951 
4952     BuffInfo.addr = phyFbAddr;
4953     BuffInfo.fbFmt = fbFmt;
4954     BuffInfo.disp_rect.x = dispX;
4955     BuffInfo.disp_rect.y = dispY;
4956     BuffInfo.disp_rect.w = width;
4957     BuffInfo.disp_rect.h = height;
4958 
4959     BuffInfo.width = width;
4960     BuffInfo.height = height;
4961     BuffInfo.FBString = FBString;
4962 
4963     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_FB_CREATE,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
4964     {
4965         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
4966         GOP_RETURN(GOP_API_FAIL);
4967     }
4968 
4969 
4970     GOP_RETURN(GOP_API_SUCCESS);
4971 
4972 }
4973 
4974 
4975 /******************************************************************************/
4976 /// Create frame buffer from given dram address
4977 /// @param width  \b IN: frame buffer width
4978 /// @param height \b IN: frame buffer height
4979 /// @param fbFmt \b IN: frame buffer color format
4980 /// @param u32FbAddr \b IN: frame buffer starting address
4981 /// @param pitch \b IN: frame buffer pitch
4982 /// @param ret_FBId \b OUT: frame buffer id
4983 /// @return GOP_API_SUCCESS - Success
4984 /// @return GOP_API_FAIL - Failure
4985 /******************************************************************************/
MApi_GOP_GWIN_CreateFBFrom3rdSurf(MS_U16 width,MS_U16 height,MS_U16 fbFmt,MS_PHY phyFbAddr,MS_U16 pitch,MS_U8 * ret_FBId)4986 MS_U8 MApi_GOP_GWIN_CreateFBFrom3rdSurf(MS_U16 width, MS_U16 height,  MS_U16 fbFmt, MS_PHY phyFbAddr, MS_U16 pitch, MS_U8* ret_FBId)
4987 {
4988     MS_U32 u32ret_FBID = 0;
4989     MS_U8 u8result = 0;
4990     u8result = MApi_GOP_GWIN_Create32FBFrom3rdSurf(width, height, fbFmt, phyFbAddr, pitch, &u32ret_FBID);
4991     if(u32ret_FBID > 256)//Out of MS_U8
4992     {
4993         GOP_WARN( "[Warning] %s %d( ret_FBID:%td....)out of MS_U8 bound, please to use MApi_GOP_GWIN_Create32FBFrom3rdSurf()\n",__FUNCTION__,__LINE__,(ptrdiff_t)u32ret_FBID );
4994     }
4995     *ret_FBId = (MS_U8)u32ret_FBID;
4996     return u8result;
4997 }
4998 
MApi_GOP_GWIN_Create32FBFrom3rdSurf(MS_U16 width,MS_U16 height,MS_U16 fbFmt,MS_PHY phyFbAddr,MS_U16 pitch,MS_U32 * u32ret_FBId)4999 MS_U8 MApi_GOP_GWIN_Create32FBFrom3rdSurf(MS_U16 width, MS_U16 height,  MS_U16 fbFmt, MS_PHY phyFbAddr, MS_U16 pitch, MS_U32* u32ret_FBId)
5000 {
5001 
5002     GOP_CREATE_BUFFER_PARAM ioctl_info;
5003     GOP_BUFFER_INFO BuffInfo;
5004     GOP_ENTRY();
5005 
5006     memset(&ioctl_info, 0x0, sizeof(GOP_CREATE_BUFFER_PARAM));
5007     memset(&BuffInfo, 0x0, sizeof(GOP_BUFFER_INFO));
5008 
5009     ioctl_info.fb_type  = GOP_CREATE_BUFFER_BYADDR;
5010     ioctl_info.pBufInfo = (MS_U32*)&BuffInfo;
5011     ioctl_info.u32Size = sizeof(GOP_BUFFER_INFO);
5012     *u32ret_FBId = MApi_GOP_GWIN_GetFree32FBID();
5013     ioctl_info.fbid = *u32ret_FBId;
5014 
5015     BuffInfo.addr = phyFbAddr;
5016     BuffInfo.fbFmt = fbFmt;
5017     BuffInfo.disp_rect.x = 0;
5018     BuffInfo.disp_rect.y = 0;
5019     BuffInfo.disp_rect.w = width;
5020     BuffInfo.disp_rect.h = height;
5021 
5022     BuffInfo.width = width;
5023     BuffInfo.height = height;
5024     BuffInfo.pitch = pitch;
5025 
5026     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_FB_CREATE,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5027     {
5028         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5029         GOP_RETURN(GOP_API_FAIL);
5030     }
5031 
5032 
5033     GOP_RETURN(GOP_API_SUCCESS);
5034 
5035 }
5036 
5037 
5038 /******************************************************************************/
5039 /// Create frame buffer from given frame buffer id and dram address. User should call MApi_GOP_GWIN_GetFree32FBID()
5040 /// first and then use this frame buffer id as this function input parameter
5041 /// @param fbId  \b IN: frame buffer id
5042 /// @param dispX \b IN: frame buffer starting x
5043 /// @param dispY \b IN: frame buffer starting y
5044 /// @param width \b IN: frame buffer width
5045 /// @param height \b IN: frame buffer height
5046 /// @param fbFmt \b IN: frame buffer color format
5047 /// @param u32FbAddr \b IN: frame buffer starting address
5048 /// @return GOP_API_SUCCESS - Success
5049 /// @return GOP_API_FAIL - Failure
5050 /******************************************************************************/
MApi_GOP_GWIN_CreateFBbyStaticAddr(MS_U8 fbId,MS_U16 dispX,MS_U16 dispY,MS_U16 width,MS_U16 height,MS_U16 fbFmt,MS_PHY phyFbAddr)5051 MS_U8 MApi_GOP_GWIN_CreateFBbyStaticAddr(MS_U8 fbId, MS_U16 dispX, MS_U16 dispY, MS_U16 width, MS_U16 height,  MS_U16 fbFmt, MS_PHY phyFbAddr)
5052 {
5053      return MApi_GOP_GWIN_Create32FBbyStaticAddr((MS_U32)fbId, dispX, dispY, width, height,  fbFmt, phyFbAddr);
5054 }
5055 
MApi_GOP_GWIN_Create32FBbyStaticAddr(MS_U32 u32fbId,MS_U16 dispX,MS_U16 dispY,MS_U16 width,MS_U16 height,MS_U16 fbFmt,MS_PHY phyFbAddr)5056 MS_U8 MApi_GOP_GWIN_Create32FBbyStaticAddr(MS_U32 u32fbId, MS_U16 dispX, MS_U16 dispY, MS_U16 width, MS_U16 height,  MS_U16 fbFmt, MS_PHY phyFbAddr)
5057 {
5058      return MApi_GOP_GWIN_Create32FBbyStaticAddr2(u32fbId, dispX, dispY, width, height,  fbFmt, phyFbAddr, E_GOP_FB_NULL);
5059 }
5060 
5061 /******************************************************************************/
5062 /// Set GE to render on the frame buffer
5063 /// @param fbId \b IN: frame buffer id
5064 /// @return GOP_API_SUCCESS - Success
5065 /// @return GOP_API_FAIL - Failure
5066 /******************************************************************************/
MApi_GOP_GWIN_Switch2FB(MS_U8 fbId)5067 E_GOP_API_Result MApi_GOP_GWIN_Switch2FB(MS_U8 fbId)
5068 {
5069     return MApi_GOP_GWIN_Switch2_32FB((MS_U32)fbId);
5070 }
5071 
MApi_GOP_GWIN_Switch2_32FB(MS_U32 u32fbId)5072 E_GOP_API_Result MApi_GOP_GWIN_Switch2_32FB(MS_U32 u32fbId)
5073 {
5074     GOP_SELECTION_PROPERTY_PARAM ioctl_info;
5075     GOP_CBFmtInfo* pCBFmtInfo=NULL;
5076 
5077     GOP_ENTRY();
5078     pCBFmtInfo = (PGOP_CBFmtInfo)malloc(sizeof(GOP_CBFmtInfo));
5079 	memset(pCBFmtInfo, 0x0, sizeof(GOP_CBFmtInfo));
5080     memset(&ioctl_info, 0x0, sizeof(GOP_SELECTION_PROPERTY_PARAM));
5081     ioctl_info.sel_type = EN_GOP_SEL_FB;
5082     ioctl_info.id = u32fbId;
5083     ioctl_info.pinfo = (MS_U32*)pCBFmtInfo;
5084     ioctl_info.u32Size = sizeof(GOP_CBFmtInfo);
5085 
5086     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SELECTION,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5087     {
5088         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5089         free(pCBFmtInfo);
5090         GOP_RETURN( GOP_API_FAIL);
5091     }
5092     fpSetFBFmt(pCBFmtInfo->u16Pitch,pCBFmtInfo->u64Addr,pCBFmtInfo->u16Fmt);
5093 
5094     free(pCBFmtInfo);
5095     GOP_RETURN(GOP_API_SUCCESS);
5096 
5097 }
5098 
5099 
5100 /******************************************************************************/
5101 /// Set Flip GWIN frame buffer
5102 /// @param gWinId \b IN: gwin id
5103 /// @param fbId \b IN: frame buffer id
5104 /// @param u16WaitTagID \b IN: WaitTagID
5105 /// @param pU16QueueCnt \b IN: Queue count
5106 /// @return TRUE or FALSE
5107 /******************************************************************************/
MApi_GOP_Switch_GWIN_2_FB(MS_U8 gWinId,MS_U8 fbId,MS_U16 u16WaitTagID,MS_U16 * pU16QueueCnt)5108 MS_BOOL MApi_GOP_Switch_GWIN_2_FB(MS_U8 gWinId, MS_U8 fbId, MS_U16 u16WaitTagID, MS_U16 *pU16QueueCnt)
5109 {
5110     MS_U32 u32QueueCnt = 0;
5111     MS_BOOL bResult = FALSE;
5112 
5113     u32QueueCnt = (MS_U32)*pU16QueueCnt;
5114     bResult = MApi_GOP_Switch_GWIN_2_32FB(gWinId, (MS_U32)fbId, (MS_U32)u16WaitTagID, &u32QueueCnt);
5115     *pU16QueueCnt = (MS_U16)u32QueueCnt;
5116     if( u32QueueCnt > 65536) //Out of MS_U16
5117     {
5118         printf( "[Warning] %s %d( QueueCnt:%td....)out of MS_U16 bound, please to use MApi_GOP_Switch_GWIN_2_32FB()\n",__FUNCTION__,__LINE__,(ptrdiff_t)u32QueueCnt);
5119     }
5120 
5121     return bResult;
5122 
5123 }
5124 
MApi_GOP_Switch_GWIN_2_32FB(MS_U8 gWinId,MS_U32 u32fbId,MS_U32 u32WaitTagID,MS_U32 * pU32QueueCnt)5125 MS_BOOL MApi_GOP_Switch_GWIN_2_32FB(MS_U8 gWinId, MS_U32 u32fbId, MS_U32 u32WaitTagID, MS_U32* pU32QueueCnt)
5126 {
5127 
5128     GOP_GWIN_GFLIP_SWITCH_GWIN_PARAM ioctl_info;
5129     GOP_GWIN_FLIP_WIN_INFO flipInfo;
5130 
5131     GOP_ENTRY();
5132 
5133     memset(&ioctl_info, 0x0, sizeof(GOP_GWIN_GFLIP_SWITCH_GWIN_PARAM));
5134     memset(&flipInfo, 0x0, sizeof(GOP_GWIN_FLIP_WIN_INFO));
5135 
5136     flipInfo.enFlip    = GOP_FLIP_BY_FBID;
5137     flipInfo.b3DEnable = FALSE;
5138     flipInfo.GwinId    = gWinId;
5139     flipInfo.FbId      = u32fbId;
5140     flipInfo.SubFbId   = u32fbId;
5141     flipInfo.WaitTagID = u32WaitTagID;
5142     flipInfo.pQueueCnt = (MS_U32*)pU32QueueCnt;
5143 
5144     ioctl_info.pFlipInfo = (void*)&flipInfo;
5145     ioctl_info.u32Size   = sizeof(GOP_GWIN_FLIP_WIN_INFO);
5146 
5147     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GFLIP_SWITCHGWIN,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5148     {
5149         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5150         GOP_RETURN(FALSE);
5151     }
5152 
5153     GOP_RETURN(TRUE);
5154 }
MApi_GOP_Switch_Multi_GWIN_2_FB_BY_ADDR(GOP_MultiFlipInfo GopMultiFlipInfo)5155 MS_BOOL MApi_GOP_Switch_Multi_GWIN_2_FB_BY_ADDR(GOP_MultiFlipInfo GopMultiFlipInfo)
5156 {
5157     GOP_GWIN_GFLIP_SWITCH_MULTI_GWIN_PARAM ioctl_info;
5158     GOP_GWIN_FLIP_MULTI_WIN_INFO multiflipInfo;
5159     MS_U32 u32QueueCnt[GOP_MULTIINFO_NUM] = {0};
5160     MS_U8 i = 0;
5161 
5162     memset(&ioctl_info, 0x0, sizeof(GOP_GWIN_GFLIP_SWITCH_MULTI_GWIN_PARAM));
5163     memset(&multiflipInfo, 0x0, sizeof(GOP_GWIN_FLIP_MULTI_WIN_INFO));
5164     for(i =0;i < GOP_MULTIINFO_NUM;i++ )
5165         multiflipInfo.FlipInfo[i].pQueueCnt = &u32QueueCnt[i];
5166 
5167     multiflipInfo.u8InfoCnt = GopMultiFlipInfo.u8InfoCnt;
5168     for(i =0;i < (multiflipInfo.u8InfoCnt);i++ )
5169     {
5170         multiflipInfo.FlipInfo[i].enFlip = GOP_FLIP_BY_ADDR;
5171         multiflipInfo.FlipInfo[i].b3DEnable = FALSE;
5172         multiflipInfo.FlipInfo[i].GwinId = GopMultiFlipInfo.astGopInfo[i].gWinId;;
5173         multiflipInfo.FlipInfo[i].FlipAddr = GopMultiFlipInfo.astGopInfo[i].u32FlipAddr;;
5174         multiflipInfo.FlipInfo[i].SubFlipAddr = GopMultiFlipInfo.astGopInfo[i].u32SubAddr;
5175         multiflipInfo.FlipInfo[i].WaitTagID = GopMultiFlipInfo.astGopInfo[i].u16WaitTagID;
5176 
5177         /*One platform would coredump, check*/
5178         if(GopMultiFlipInfo.astGopInfo[i].pU16QueueCnt==NULL)
5179         {
5180             u32QueueCnt[i]=0;
5181         }
5182         else
5183         {
5184             memcpy(&u32QueueCnt[i], GopMultiFlipInfo.astGopInfo[i].pU16QueueCnt, sizeof(MS_U16));
5185         }
5186         //u32QueueCnt[i] =(MS_U32) *GopMultiFlipInfo.astGopInfo[i].pU16QueueCnt;
5187     }
5188     ioctl_info.pMultiFlipInfo = (void*)&multiflipInfo;
5189     ioctl_info.u32Size   = sizeof(GOP_GWIN_FLIP_MULTI_WIN_INFO);
5190 
5191     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GFLIP_SWITCHMULTIGWIN,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5192     {
5193         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5194         return FALSE;
5195     }
5196     for(i =0;i < (multiflipInfo.u8InfoCnt);i++ )
5197     {
5198         *(GopMultiFlipInfo.astGopInfo[i].pU16QueueCnt) = (MS_U16)u32QueueCnt[i];
5199     }
5200     return TRUE;
5201 }
5202 
MApi_GOP_Switch_GWIN_2_FB_BY_ADDR(MS_U8 gWinId,MS_PHY phyFlipAddr,MS_U16 u16WaitTagID,MS_U16 * pU16QueueCnt)5203 MS_BOOL MApi_GOP_Switch_GWIN_2_FB_BY_ADDR(MS_U8 gWinId, MS_PHY phyFlipAddr, MS_U16 u16WaitTagID, MS_U16 *pU16QueueCnt)
5204 {
5205     GOP_GWIN_GFLIP_SWITCH_GWIN_PARAM ioctl_info;
5206     GOP_GWIN_FLIP_WIN_INFO flipInfo;
5207     MS_U32 QueueCnt;
5208 
5209 
5210     memset(&ioctl_info, 0x0, sizeof(GOP_GWIN_GFLIP_SWITCH_GWIN_PARAM));
5211     memset(&flipInfo, 0x0, sizeof(GOP_GWIN_FLIP_WIN_INFO));
5212     GOP_ENTRY();
5213     QueueCnt = *pU16QueueCnt;
5214 
5215     flipInfo.enFlip    = GOP_FLIP_BY_ADDR;
5216     flipInfo.b3DEnable = FALSE;
5217     flipInfo.GwinId    = gWinId;
5218     flipInfo.FlipAddr  = phyFlipAddr;
5219     flipInfo.SubFlipAddr = phyFlipAddr;
5220     flipInfo.WaitTagID = u16WaitTagID;
5221     flipInfo.pQueueCnt = &QueueCnt;
5222 
5223     ioctl_info.pFlipInfo = (void*)&flipInfo;
5224     ioctl_info.u32Size   = sizeof(GOP_GWIN_FLIP_WIN_INFO);
5225 
5226     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GFLIP_SWITCHGWIN,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5227     {
5228         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5229         GOP_RETURN(FALSE);
5230     }
5231     *pU16QueueCnt = QueueCnt;
5232     GOP_RETURN(TRUE);
5233 }
5234 
5235 //Flip out GOP 3D output
MApi_GOP_Switch_3DGWIN_2_FB_BY_ADDR(MS_U8 gWinId,MS_PHY phyMainFlipAddr,MS_PHY phySubFlipAddr,MS_U16 u16WaitTagID,MS_U16 * pu16QueueCnt)5236 MS_BOOL MApi_GOP_Switch_3DGWIN_2_FB_BY_ADDR(MS_U8 gWinId, MS_PHY phyMainFlipAddr, MS_PHY phySubFlipAddr, MS_U16 u16WaitTagID, MS_U16 *pu16QueueCnt)
5237 {
5238 
5239     GOP_GWIN_GFLIP_SWITCH_GWIN_PARAM ioctl_info;
5240     GOP_GWIN_FLIP_WIN_INFO flipInfo;
5241     MS_U32 QueueCnt;
5242 
5243     GOP_ENTRY();
5244     memset(&ioctl_info, 0x0, sizeof(GOP_GWIN_GFLIP_SWITCH_GWIN_PARAM));
5245     memset(&flipInfo, 0x0, sizeof(GOP_GWIN_FLIP_WIN_INFO));
5246 
5247     QueueCnt = *pu16QueueCnt;
5248 
5249     flipInfo.enFlip    = GOP_FLIP_BY_ADDR;
5250     flipInfo.b3DEnable = TRUE;
5251     flipInfo.GwinId    = gWinId;
5252     flipInfo.FlipAddr  = phyMainFlipAddr;
5253     flipInfo.SubFlipAddr = phySubFlipAddr;
5254     flipInfo.WaitTagID = u16WaitTagID;
5255     flipInfo.pQueueCnt = &QueueCnt;
5256 
5257     ioctl_info.pFlipInfo = (void*)&flipInfo;
5258     ioctl_info.u32Size   = sizeof(GOP_GWIN_FLIP_WIN_INFO);
5259 
5260     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GFLIP_SWITCHGWIN,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5261     {
5262         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5263         GOP_RETURN(FALSE);
5264     }
5265     *pu16QueueCnt = QueueCnt;
5266     GOP_RETURN(TRUE);
5267 }
5268 
5269 /******************************************************************************/
5270 /// Change a GWIN's frame buffer, this enables an off screen buffer to be shown
5271 /// @param fbId \b IN frame buffer id
5272 /// @param gwinId \b IN \copydoc GWINID
5273 /// @return GOP_API_SUCCESS - Success
5274 /// @return GOP_API_FAIL - Failure
5275 /******************************************************************************/
MApi_GOP_GWIN_MapFB2Win(MS_U8 fbId,MS_U8 gwinId)5276 E_GOP_API_Result MApi_GOP_GWIN_MapFB2Win(MS_U8 fbId, MS_U8 gwinId)
5277 {
5278     return MApi_GOP_GWIN_Map32FB2Win((MS_U32)fbId, gwinId);
5279 }
5280 
MApi_GOP_GWIN_Map32FB2Win(MS_U32 u32fbId,MS_U8 u8gwinId)5281 E_GOP_API_Result MApi_GOP_GWIN_Map32FB2Win(MS_U32 u32fbId, MS_U8 u8gwinId)
5282 {
5283 
5284     GOP_GWIN_MAPFBINFO_PARAM ioctl_info;
5285     memset(&ioctl_info, 0x0, sizeof(GOP_GWIN_MAPFBINFO_PARAM));
5286 
5287     GOP_ENTRY();
5288     ioctl_info.fbid = u32fbId;
5289     ioctl_info.GwinId = u8gwinId;
5290 
5291     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_MAPFB2WIN,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5292     {
5293         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5294         GOP_RETURN(GOP_API_FAIL);
5295     }
5296 
5297     GOP_RETURN(GOP_API_SUCCESS);
5298 
5299 }
5300 
5301 
5302 /******************************************************************************/
5303 /// Get frame buffer information
5304 /// @param fbId \b IN frame buffer id
5305 /// @param fbAttr \b OUT buffer to store \copydoc GOP_GwinFBAttr
5306 /// @return GOP_API_SUCCESS - Success
5307 /// @return GOP_API_FAIL - Failure
5308 /******************************************************************************/
MApi_GOP_GWIN_GetFBInfo(MS_U8 fbId,GOP_GwinFBAttr * fbAttr)5309 E_GOP_API_Result MApi_GOP_GWIN_GetFBInfo(MS_U8 fbId, GOP_GwinFBAttr *fbAttr)
5310 {
5311     return MApi_GOP_GWIN_Get32FBInfo((MS_U32)fbId, fbAttr);
5312 }
5313 
MApi_GOP_GWIN_Get32FBInfo(MS_U32 u32fbId,GOP_GwinFBAttr * fbAttr)5314 E_GOP_API_Result MApi_GOP_GWIN_Get32FBInfo(MS_U32 u32fbId, GOP_GwinFBAttr *fbAttr)
5315 {
5316     GOP_FB_INFO_PARAM ioctl_info;
5317     GOP_BUFFER_INFO BuffInfo;
5318 
5319     GOP_ENTRY();
5320 
5321     memset(&ioctl_info, 0x0, sizeof(GOP_FB_INFO_PARAM));
5322     memset(&BuffInfo, 0x0, sizeof(GOP_BUFFER_INFO));
5323 
5324     ioctl_info.pBufInfo = (MS_U32*)&BuffInfo;
5325     ioctl_info.u32Size = sizeof(GOP_BUFFER_INFO);
5326     ioctl_info.fbid = u32fbId;
5327 
5328     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_FB_GETINFO,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5329     {
5330         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5331         GOP_RETURN( GOP_API_FAIL);
5332     }
5333 
5334     memset(fbAttr, 0x0, sizeof(GOP_GwinFBAttr));
5335 
5336     fbAttr->width   = BuffInfo.width;
5337     fbAttr->height  = BuffInfo.height;
5338     fbAttr->fbFmt   = BuffInfo.fbFmt;
5339     fbAttr->pitch   = BuffInfo.pitch;
5340     fbAttr->x0      = BuffInfo.disp_rect.x;
5341     fbAttr->y0      = BuffInfo.disp_rect.y;
5342     fbAttr->x1      = BuffInfo.disp_rect.x + BuffInfo.disp_rect.w;
5343     fbAttr->y1      = BuffInfo.disp_rect.y + BuffInfo.disp_rect.h;
5344     fbAttr->s_x     = BuffInfo.disp_rect.x;
5345     fbAttr->s_y     = BuffInfo.disp_rect.y;
5346     fbAttr->addr    = BuffInfo.addr;
5347 
5348     fbAttr->size    = GOP_CalcPitch(BuffInfo.fbFmt, BuffInfo.width) * BuffInfo.height;
5349 
5350     //printf("[%s] buff size:%lx addr:%lx (%d,%d)\n",__FUNCTION__,fbAttr->size,fbAttr->addr, fbAttr->width, fbAttr->height);
5351 
5352     fbAttr->dispWidth  = BuffInfo.disp_rect.w;
5353     fbAttr->dispHeight = BuffInfo.disp_rect.h;
5354 
5355     //fbAttr->allocated = pwinFB->in_use;
5356     //fbAttr->enable = pwinFB->enable;
5357     //fbAttr->gWinId = pwinFB->gWinId;
5358     //fbAttr->string = pwinFB->string;
5359 
5360     GOP_RETURN(GOP_API_SUCCESS);
5361 
5362 }
5363 
5364 
5365 /******************************************************************************/
5366 /// Set frame buffer info
5367 /// @param fbId  \b IN: frame buffer id
5368 /// @param fbAttr \b IN: frame buffer attribute
5369 /// @return GOP_API_SUCCESS - Success
5370 /// @return GOP_API_FAIL - Failure
5371 /******************************************************************************/
MApi_GOP_GWIN_SetFBInfo(MS_U8 fbId,GOP_GwinFBAttr * fbAttr)5372 E_GOP_API_Result MApi_GOP_GWIN_SetFBInfo(MS_U8 fbId, GOP_GwinFBAttr *fbAttr)
5373 {
5374     return MApi_GOP_GWIN_Set32FBInfo((MS_U32)fbId, fbAttr);
5375 }
5376 
MApi_GOP_GWIN_Set32FBInfo(MS_U32 u32fbId,GOP_GwinFBAttr * fbAttr)5377 E_GOP_API_Result MApi_GOP_GWIN_Set32FBInfo(MS_U32 u32fbId, GOP_GwinFBAttr *fbAttr)
5378 {
5379     GOP_FB_INFO_PARAM ioctl_info;
5380     GOP_BUFFER_INFO BuffInfo;
5381 
5382     GOP_ENTRY();
5383 
5384     memset(&ioctl_info, 0x0, sizeof(GOP_FB_INFO_PARAM));
5385     memset(&BuffInfo, 0x0, sizeof(GOP_BUFFER_INFO));
5386 
5387     BuffInfo.addr = fbAttr->addr;
5388     BuffInfo.disp_rect.x = fbAttr->x0;
5389     BuffInfo.disp_rect.y = fbAttr->y0;
5390     BuffInfo.disp_rect.w = fbAttr->x1 - fbAttr->x0;
5391     BuffInfo.disp_rect.h = fbAttr->y1 - fbAttr->y0;
5392     BuffInfo.fbFmt       = fbAttr->fbFmt;
5393     BuffInfo.pitch       = fbAttr->pitch;
5394 
5395     BuffInfo.width  = fbAttr->width;
5396     BuffInfo.height = fbAttr->height;
5397 
5398 
5399     ioctl_info.pBufInfo = (MS_U32*)&BuffInfo;
5400     ioctl_info.u32Size = sizeof(GOP_BUFFER_INFO);
5401     ioctl_info.fbid = u32fbId;
5402 
5403     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_FB_SETINFO,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5404     {
5405         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5406         GOP_RETURN( GOP_API_FAIL);
5407     }
5408 
5409     GOP_RETURN(GOP_API_SUCCESS);
5410 }
5411 
5412 
5413 /********************************************************************************/
5414 /// Set GWIN high priority when GWIN overlap in the same gop. If different gwins overlap in the same gop, only
5415 /// high priority gwin can be shown
5416 /// @param u8GOP \b IN:  GOP number
5417 /// @param u8win \b IN: Gwin ID
5418 /// @return GOP_API_SUCCESS - Success
5419 /// @return GOP_API_FAIL - Failure
5420 /********************************************************************************/
MApi_GOP_GWIN_SwapOverlapWin(MS_U8 u8GOP,MS_U8 u8win)5421 E_GOP_API_Result MApi_GOP_GWIN_SwapOverlapWin(MS_U8 u8GOP, MS_U8 u8win)
5422 {
5423     MS_U8 u8WinId;
5424     GOP_SET_PROPERTY_PARAM ioctl_info;
5425 
5426     GOP_ENTRY();
5427     memset(&ioctl_info, 0x0, sizeof(GOP_SET_PROPERTY_PARAM));
5428     u8WinId = u8win;
5429 
5430     ioctl_info.en_pro   = E_GOP_SWAP_OVERLAP_WIN;
5431     ioctl_info.gop_idx  = u8GOP;
5432     ioctl_info.pSetting = (void*)&u8WinId;
5433     ioctl_info.u32Size  = sizeof(MS_U8);
5434 
5435     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5436     {
5437         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5438         GOP_RETURN( GOP_API_FAIL);
5439     }
5440 
5441     GOP_RETURN(GOP_API_SUCCESS);
5442 }
5443 
5444 /********************************************************************************/
5445 /// Set GWIN relative Priority
5446 /// Will Ensure Gwin Priority in the same sequence in hw as pGwinPri defined
5447 /// @param u8GOP \b IN:  GOP number
5448 /// @param pGwinPri \b IN: Relative Gwin ID Priority Defines
5449 /// @return GOP_API_SUCCESS - Success
5450 /// @return GOP_API_FAIL - Failure
5451 /********************************************************************************/
MApi_GOP_GWIN_SetRelativeWinPrio(MS_U8 u8GOP,GOP_GwinPri * pGwinPri)5452 E_GOP_API_Result MApi_GOP_GWIN_SetRelativeWinPrio(MS_U8 u8GOP, GOP_GwinPri *pGwinPri)
5453 {
5454     GOP_SET_PROPERTY_PARAM ioctl_info;
5455     GOP_GwinPri GwinPri;
5456 
5457     GOP_ENTRY();
5458     memset(&ioctl_info, 0x0, sizeof(GOP_SET_PROPERTY_PARAM));
5459     memcpy(&GwinPri, pGwinPri, sizeof(GOP_GwinPri));
5460 
5461     ioctl_info.en_pro   = E_GOP_RELATIVE_WIN_PRIO;
5462     ioctl_info.gop_idx  = u8GOP;
5463     ioctl_info.pSetting = (void*)&GwinPri;
5464     ioctl_info.u32Size  = sizeof(GOP_GwinPri);
5465 
5466     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5467     {
5468         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5469         GOP_RETURN( GOP_API_FAIL);
5470     }
5471 
5472     GOP_RETURN(GOP_API_SUCCESS);
5473 
5474 }
5475 
5476 /********************************************************************************/
5477 /// Switch frame buffer pool. This function is used for when user use MApi_GOP_GWIN_SetDoubleHeap to set second
5478 /// frame buffer pool. User can control frame buffer opened in first or second buffer pool pool
5479 /// @param u8FB \b IN 0: first frame buffer pool , 1: second frame buffer pool
5480 /// @return GOP_API_SUCCESS - Success
5481 /********************************************************************************/
MApi_GOP_FB_SEL(MS_U8 u8FB)5482 E_GOP_API_Result MApi_GOP_FB_SEL(MS_U8 u8FB)
5483 {
5484     GOP_FB_PROPERTY_PARAM ioctl_info;
5485     MS_U8 u8PoolId = u8FB;
5486     GOP_ENTRY();
5487     ioctl_info.en_property = E_GOP_FB_POOLID;
5488     ioctl_info.FBId = 0x0;
5489     ioctl_info.pSet = (void*)&u8PoolId;
5490     ioctl_info.u32Size = sizeof(MS_U8);
5491 
5492     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_FB_SET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
5493     {
5494         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5495         GOP_RETURN(GOP_API_FAIL);
5496     }
5497 
5498     GOP_RETURN(GOP_API_SUCCESS);
5499 }
5500 
5501 /********************************************************************************/
5502 /// Get GOP version number
5503 ///@param ppVersion \b OUT: GOP Version
5504 /// @return GOP_API_SUCCESS - Success
5505 /// @return GOP_API_FAIL - Failure
5506 /********************************************************************************/
MApi_GOP_GetLibVer(const MSIF_Version ** ppVersion)5507 E_GOP_API_Result MApi_GOP_GetLibVer(const MSIF_Version **ppVersion)
5508 {
5509     if (!ppVersion)
5510     {
5511         return GOP_API_INVALID_PARAMETERS;
5512     }
5513     *ppVersion = &_api_gop_version;
5514     return GOP_API_SUCCESS;
5515 }
5516 
5517 /********************************************************************************/
5518 /// Set Debug level of GOP
5519 /// @param level \b IN debug level
5520 /// @return GOP_API_SUCCESS - Success
5521 /// @return GOP_API_FAIL - Failure
5522 /********************************************************************************/
MApi_GOP_SetDbgLevel(EN_GOP_DEBUG_LEVEL level)5523 E_GOP_API_Result MApi_GOP_SetDbgLevel(EN_GOP_DEBUG_LEVEL level)
5524 {
5525 	GOP_MISC_PARAM ioctl_info;
5526 
5527     u32GOPDbgLevel_api= level;
5528 
5529     GOP_ENTRY();
5530 
5531     ioctl_info.misc_type = E_GOP_MISC_SET_DBG_LEVEL;
5532     ioctl_info.pMISC = (MS_U32*)&level;
5533     ioctl_info.u32Size  = sizeof(MS_U32);
5534 
5535     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_MISC,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5536     {
5537         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5538         GOP_RETURN( GOP_API_FAIL);
5539     }
5540     GOP_RETURN(GOP_API_SUCCESS);
5541 }
5542 
5543 
5544 /********************************************************************************/
5545 /// GOP call back function: Set destination buffer pitch,addr,fmt to GE.
5546 /// This function should be registered before MApi_GOP_Init!!
5547 /// @return GOP_API_SUCCESS - Success
5548 /// @return GOP_API_FAIL - Failure
5549 /********************************************************************************/
MApi_GOP_RegisterFBFmtCB(MS_U32 (* fpGOP_CB)(MS_U16 pitch,MS_PHY addr,MS_U16 fmt))5550 E_GOP_API_Result MApi_GOP_RegisterFBFmtCB(MS_U32 (*fpGOP_CB)(MS_U16 pitch,MS_PHY addr , MS_U16 fmt )  )
5551 {
5552     GOP_REGISTER_CB_PARAM ioctl_info;
5553     memset(&ioctl_info, 0x0, sizeof(GOP_REGISTER_CB_PARAM));
5554 
5555     fpSetFBFmt = fpGOP_CB;
5556 
5557 #ifdef GOP_UTOPIA2K
5558 #else
5559     if(pInstantGOP != NULL)
5560     {
5561         ioctl_info.cb_type = GOP_CB_GFX_FBFMT;
5562         ioctl_info.pCB = fpSetFBFmt;
5563         if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_REGISTER_CB,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5564         {
5565             GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5566             return GOP_API_FAIL;
5567         }
5568     }
5569 #endif
5570     return GOP_API_SUCCESS;
5571 }
5572 
5573 
5574 
5575 /********************************************************************************/
5576 /// GOP call back function: Get vedio status (is interlace mode?) from scaler.
5577 /// This function should be registered before MApi_GOP_Init!!
5578 /// @return GOP_API_SUCCESS - Success
5579 /// @return GOP_API_FAIL - Failure
5580 /********************************************************************************/
MApi_GOP_RegisterXCIsInterlaceCB(MS_BOOL (* fpGOP_CB)(void))5581 E_GOP_API_Result MApi_GOP_RegisterXCIsInterlaceCB(MS_BOOL (*fpGOP_CB)(void))
5582 {
5583     GOP_REGISTER_CB_PARAM ioctl_info;
5584     memset(&ioctl_info, 0x0, sizeof(GOP_REGISTER_CB_PARAM));
5585 
5586     fpXCIsInterlace = fpGOP_CB;
5587 
5588 #ifdef GOP_UTOPIA2K
5589 #else
5590     if(pInstantGOP != NULL)
5591     {
5592         ioctl_info.cb_type = GOP_CB_XC_INTERLACE;
5593         ioctl_info.pCB = fpXCIsInterlace;
5594         if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_REGISTER_CB,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5595         {
5596             GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5597             return GOP_API_FAIL;
5598         }
5599     }
5600 #endif
5601     return GOP_API_SUCCESS;
5602 }
5603 
5604 /********************************************************************************/
5605 /// GOP call back function: Get capture window h-start from scaler.
5606 /// This function should be registered before MApi_GOP_Init!!
5607 /// @return GOP_API_SUCCESS - Success
5608 /// @return GOP_API_FAIL - Failure
5609 /********************************************************************************/
MApi_GOP_RegisterXCGetCapHStartCB(MS_U16 (* fpGOP_CB)(void))5610 E_GOP_API_Result MApi_GOP_RegisterXCGetCapHStartCB(MS_U16 (*fpGOP_CB)(void))
5611 {
5612     GOP_REGISTER_CB_PARAM ioctl_info;
5613     memset(&ioctl_info, 0x0, sizeof(GOP_REGISTER_CB_PARAM));
5614 
5615     fpXCGetCapHStart = fpGOP_CB;
5616 
5617 #ifdef GOP_UTOPIA2K
5618 #else
5619     if(pInstantGOP != NULL)
5620     {
5621         ioctl_info.cb_type = GOP_CB_XC_PANEL_HSTART;
5622         ioctl_info.pCB = fpXCGetCapHStart;
5623         if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_REGISTER_CB,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5624         {
5625             GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5626             return GOP_API_FAIL;
5627         }
5628     }
5629 #endif
5630     return GOP_API_SUCCESS;
5631 }
5632 
5633 
5634 /********************************************************************************/
5635 /// GOP call back function: Notify callback for the end of GOP events such as buffer rearrange.
5636 /// This function should be registered before MApi_GOP_Init!!
5637 /// @return GOP_API_SUCCESS - Success
5638 /// @return GOP_API_FAIL - Failure
5639 /********************************************************************************/
MApi_GOP_RegisterEventNotify(void (* fpGOP_CB)(MS_U32 u32EventID,void * reserved0))5640 E_GOP_API_Result MApi_GOP_RegisterEventNotify(void (*fpGOP_CB)(MS_U32 u32EventID, void* reserved0))
5641 {
5642     GOP_REGISTER_CB_PARAM ioctl_info;
5643     memset(&ioctl_info, 0x0, sizeof(GOP_REGISTER_CB_PARAM));
5644 
5645     fpEventNotify = fpGOP_CB;
5646 
5647 #ifdef GOP_UTOPIA2K
5648 #else
5649     if(pInstantGOP != NULL)
5650     {
5651         ioctl_info.cb_type = GOP_CB_EVENT_NOTIFY;
5652         ioctl_info.pCB = fpEventNotify;
5653         if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_REGISTER_CB,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5654         {
5655             GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5656             return GOP_API_FAIL;
5657         }
5658     }
5659 #endif
5660     return GOP_API_SUCCESS;
5661 }
5662 
5663 
5664 /********************************************************************************/
5665 /// GOP call back function: Reduce scaler bandwidth when OSD on.
5666 /// This function should be registered before MApi_GOP_Init!!
5667 /// @return GOP_API_SUCCESS - Success
5668 /// @return GOP_API_FAIL - Failure
5669 /********************************************************************************/
MApi_GOP_RegisterXCReduceBWForOSDCB(void (* fpGOP_CB)(MS_U8 PqWin,MS_BOOL enable))5670 E_GOP_API_Result MApi_GOP_RegisterXCReduceBWForOSDCB(void (*fpGOP_CB)(MS_U8 PqWin, MS_BOOL enable))
5671 {
5672     GOP_REGISTER_CB_PARAM ioctl_info;
5673     memset(&ioctl_info, 0x0, sizeof(GOP_REGISTER_CB_PARAM));
5674 
5675     fpXCReduceBWForOSD = fpGOP_CB;
5676 
5677 #ifdef GOP_UTOPIA2K
5678 #else
5679     if(pInstantGOP != NULL)
5680     {
5681         ioctl_info.cb_type = GOP_CB_XC_REDUCE_BW;
5682         ioctl_info.pCB = fpXCReduceBWForOSD;
5683         if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_REGISTER_CB,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5684         {
5685             GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5686             return GOP_API_FAIL;
5687         }
5688     }
5689 #endif
5690     return GOP_API_SUCCESS;
5691 }
5692 /********************************************************************************/
5693 /// GOP call back function: Register XC DIP call back
5694 /// This function should be registered before MApi_GOP_Init!!
5695 /// @return GOP_API_SUCCESS - Success
5696 /// @return GOP_API_FAIL - Failure
5697 /********************************************************************************/
MApi_GOP_RegisterXCSetDwinInfo(MS_BOOL (* fpGOP_CB)(MS_U16 cmd,MS_U32 * arg,MS_U16 size))5698 E_GOP_API_Result MApi_GOP_RegisterXCSetDwinInfo(MS_BOOL (*fpGOP_CB)(MS_U16 cmd,MS_U32 *arg,MS_U16 size))
5699 {
5700     GOP_REGISTER_CB_PARAM ioctl_info;
5701     memset(&ioctl_info, 0x0, sizeof(GOP_REGISTER_CB_PARAM));
5702 
5703     fpXCSetDwinInfo = fpGOP_CB;
5704 
5705 #ifdef GOP_UTOPIA2K
5706 #else
5707     if(pInstantGOP != NULL)
5708     {
5709         ioctl_info.cb_type = GOP_CB_DWIN_INFO;
5710         ioctl_info.pCB = fpXCSetDwinInfo;
5711         if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_REGISTER_CB,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5712         {
5713             GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5714             return GOP_API_FAIL;
5715         }
5716     }
5717 #endif
5718     return GOP_API_SUCCESS;
5719 }
5720 
5721 
_GOP_RegisterAllCBFunc()5722 MS_U32 _GOP_RegisterAllCBFunc()
5723 {
5724 #ifdef GOP_UTOPIA2K
5725 #else
5726     GOP_REGISTER_CB_PARAM ioctl_info;
5727     memset(&ioctl_info, 0x0, sizeof(GOP_REGISTER_CB_PARAM));
5728 
5729     if(fpSetFBFmt == NULL)
5730     {
5731 #ifdef MSOS_TYPE_NOS
5732         GOP_INFO("[%s][%d] fpSetFBFmt is NULL.(If on STR state, this is a normal message) \n",__FUNCTION__,__LINE__);
5733 #endif
5734     }
5735     ioctl_info.cb_type = GOP_CB_GFX_FBFMT;
5736     ioctl_info.pCB = fpSetFBFmt;
5737     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_REGISTER_CB,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5738     {
5739         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5740         return GOP_API_FAIL;
5741     }
5742 
5743     if(fpXCIsInterlace == NULL)
5744     {
5745         GOP_INFO("[%s][%d] fpXCIsInterlace is NULL.(If on STR state, this is a normal message) \n",__FUNCTION__,__LINE__);
5746     }
5747     ioctl_info.cb_type = GOP_CB_XC_INTERLACE;
5748     ioctl_info.pCB = fpXCIsInterlace;
5749     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_REGISTER_CB,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5750     {
5751         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5752         return GOP_API_FAIL;
5753     }
5754 
5755     if(fpXCGetCapHStart == NULL)
5756     {
5757         GOP_INFO("[%s][%d] fpXCGetCapHStart is NULL.(If on STR state, this is a normal message) \n",__FUNCTION__,__LINE__);
5758     }
5759     ioctl_info.cb_type = GOP_CB_XC_PANEL_HSTART;
5760     ioctl_info.pCB = fpXCGetCapHStart;
5761     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_REGISTER_CB,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5762     {
5763         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5764         return GOP_API_FAIL;
5765     }
5766 
5767     if(fpXCReduceBWForOSD == NULL)
5768     {
5769 #ifdef MSOS_TYPE_NOS
5770         GOP_INFO("[%s][%d] fpXCReduceBWForOSD is NULL.(If on STR state, this is a normal message) \n",__FUNCTION__,__LINE__);
5771 #endif
5772     }
5773     ioctl_info.cb_type = GOP_CB_XC_REDUCE_BW;
5774     ioctl_info.pCB = fpXCReduceBWForOSD;
5775     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_REGISTER_CB,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5776     {
5777         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5778         return GOP_API_FAIL;
5779     }
5780 
5781     if(fpEventNotify == NULL)
5782     {
5783 #ifdef MSOS_TYPE_NOS
5784         GOP_INFO("[%s][%d] fpEventNotify is NULL.(If on STR state, this is a normal message) \n",__FUNCTION__,__LINE__);
5785 #endif
5786     }
5787     ioctl_info.cb_type = GOP_CB_EVENT_NOTIFY;
5788     ioctl_info.pCB = fpEventNotify;
5789     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_REGISTER_CB,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5790     {
5791         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5792         return GOP_API_FAIL;
5793     }
5794 
5795     if(fpXCSetDwinInfo == NULL)
5796     {
5797 #ifdef MSOS_TYPE_NOS
5798         GOP_INFO("[%s][%d] fpXCSetDwinInfo is NULL.(If on STR state, this is a normal message) \n",__FUNCTION__,__LINE__);
5799 #endif
5800     }
5801     ioctl_info.cb_type = GOP_CB_DWIN_INFO;
5802     ioctl_info.pCB = fpXCSetDwinInfo;
5803     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_REGISTER_CB,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5804     {
5805         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5806         return GOP_API_FAIL;
5807     }
5808 #endif
5809     return GOP_API_SUCCESS;
5810 }
5811 
5812 
5813 /********************************************************************************/
5814 /// Get gop static api info.
5815 /// @param *pGopApiInfo \b OUT pointer to api info structure
5816 /// @return GOP_API_SUCCESS - Success
5817 /// @return GOP_API_FAIL - Failure
5818 /********************************************************************************/
MApi_GOP_GetInfo(GOP_ApiInfo * pGopApiInfo)5819 E_GOP_API_Result MApi_GOP_GetInfo(GOP_ApiInfo* pGopApiInfo)
5820 {
5821     GOP_MISC_PARAM ioctl_info;
5822     GOP_ApiInfo  GopApiInfo;
5823 
5824     GOP_ENTRY();
5825 
5826     memcpy(&GopApiInfo, pGopApiInfo, sizeof(GOP_ApiInfo));
5827     ioctl_info.misc_type = E_GOP_MISC_GET_INFO;
5828     ioctl_info.pMISC = (MS_U32*)&GopApiInfo;
5829     ioctl_info.u32Size  = sizeof(GOP_ApiInfo);
5830 
5831     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_MISC,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5832     {
5833         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5834         GOP_RETURN( GOP_API_FAIL);
5835     }
5836     memcpy(pGopApiInfo, &GopApiInfo, sizeof(GOP_ApiInfo));
5837     GOP_RETURN(GOP_API_SUCCESS);
5838 }
5839 
5840 
5841 /********************************************************************************/
5842 /// Get gop run time api status.
5843 /// @param *GOP_ApiStatus \b OUT pointer to api status structure
5844 /// @return GOP_API_SUCCESS - Success
5845 /// @return GOP_API_FAIL - Failure
5846 /********************************************************************************/
MApi_GOP_GetStatus(GOP_ApiStatus * pGopApiSts)5847 E_GOP_API_Result MApi_GOP_GetStatus(GOP_ApiStatus *pGopApiSts)
5848 {
5849     GOP_MISC_PARAM ioctl_info;
5850     GOP_ApiStatus  GopApiSts;
5851 
5852     GOP_ENTRY();
5853 
5854     memcpy(&GopApiSts, pGopApiSts, sizeof(GOP_ApiStatus));
5855     ioctl_info.misc_type = E_GOP_MISC_GET_RT_STATUS;
5856     ioctl_info.pMISC = (MS_U32*)&GopApiSts;
5857     ioctl_info.u32Size  = sizeof(GOP_ApiStatus);
5858 
5859     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_MISC,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5860     {
5861         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5862         GOP_RETURN( GOP_API_FAIL);
5863     }
5864     memcpy(pGopApiSts, &GopApiSts, sizeof(GOP_ApiStatus));
5865     GOP_RETURN(GOP_API_SUCCESS);
5866 }
5867 
5868 
5869 /********************************************************************************/
5870 /// Set GOP Power ON.
5871 /// @return GOP_API_SUCCESS - Success
5872 /// @return GOP_API_FAIL - Failure
5873 /********************************************************************************/
MApi_GOP_PowerOn(void)5874 E_GOP_API_Result MApi_GOP_PowerOn(void)
5875 {
5876     GOP_MISC_PARAM ioctl_info;
5877     MS_U32  value = 0;
5878 
5879     GOP_ENTRY();
5880 
5881     ioctl_info.misc_type = E_GOP_MISC_POWER_ON;
5882     ioctl_info.pMISC = (MS_U32*)&value;
5883     ioctl_info.u32Size  = sizeof(MS_U32);
5884 
5885     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_MISC,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5886     {
5887         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5888         GOP_RETURN( GOP_API_FAIL);
5889     }
5890 
5891     GOP_RETURN(GOP_API_SUCCESS);
5892 
5893 }
5894 /********************************************************************************/
5895 /// Set GOP Power OFF for saving power.
5896 /// @return GOP_API_SUCCESS - Success
5897 /// @return GOP_API_FAIL - Failure
5898 /********************************************************************************/
MApi_GOP_PowerOff(void)5899 E_GOP_API_Result MApi_GOP_PowerOff(void)
5900 {
5901     GOP_MISC_PARAM ioctl_info;
5902     MS_U32  value = 0;
5903 
5904     GOP_ENTRY();
5905 
5906     ioctl_info.misc_type = E_GOP_MISC_POWER_OFF;
5907     ioctl_info.pMISC = (MS_U32*)&value;
5908     ioctl_info.u32Size  = sizeof(MS_U32);
5909 
5910     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_MISC,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5911     {
5912         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5913         GOP_RETURN( GOP_API_FAIL);
5914     }
5915 
5916     GOP_RETURN(GOP_API_SUCCESS);
5917 
5918 }
5919 
5920 
5921 /********************************************************************************/
5922 /// Set GOP bandwidth saving mode.
5923 /// @return GOP_API_SUCCESS - Success
5924 /// @return GOP_API_FAIL - Failure
5925 /********************************************************************************/
MApi_GOP_SetGOPBWStrength(EN_GOP_BW_STRENGTH eGOPBWStr,MS_U8 u8GOP)5926 E_GOP_API_Result MApi_GOP_SetGOPBWStrength(EN_GOP_BW_STRENGTH eGOPBWStr, MS_U8 u8GOP)
5927 {
5928     EN_GOP_BW_STRENGTH eBWStr;
5929     GOP_SET_PROPERTY_PARAM ioctl_info;
5930 
5931     GOP_ENTRY();
5932     memset(&ioctl_info, 0x0, sizeof(GOP_SET_PROPERTY_PARAM));
5933     eBWStr = eGOPBWStr;
5934 
5935     ioctl_info.en_pro   = E_GOP_BW_STRENGTH;
5936     ioctl_info.gop_idx  = u8GOP;
5937     ioctl_info.pSetting = (MS_U32*)&eBWStr;
5938     ioctl_info.u32Size  = sizeof(EN_GOP_BW_STRENGTH);
5939 
5940     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5941     {
5942         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5943         GOP_RETURN( GOP_API_FAIL);
5944     }
5945 
5946     GOP_RETURN(GOP_API_SUCCESS);
5947 }
5948 
5949 
5950 /********************************************************************************/
5951 /// Get GOP Power OFF for saving power.
5952 /// @return EN_GOP_BW_STRENGTH - mode of GOP bw saving .
5953 /********************************************************************************/
MApi_GOP_GetGOPBWStrength(MS_U8 u8GOP,EN_GOP_BW_STRENGTH * curBW)5954 E_GOP_API_Result MApi_GOP_GetGOPBWStrength(MS_U8 u8GOP, EN_GOP_BW_STRENGTH* curBW)
5955 {
5956 
5957     EN_GOP_BW_STRENGTH eBWStr;
5958     GOP_SET_PROPERTY_PARAM ioctl_info;
5959 
5960     GOP_ENTRY();
5961     memset(&ioctl_info, 0x0, sizeof(GOP_SET_PROPERTY_PARAM));
5962 
5963     ioctl_info.en_pro   = E_GOP_BW_STRENGTH;
5964     ioctl_info.gop_idx  = u8GOP;
5965     ioctl_info.pSetting = (MS_U32*)&eBWStr;
5966     ioctl_info.u32Size  = sizeof(EN_GOP_BW_STRENGTH);
5967 
5968     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5969     {
5970         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5971         GOP_RETURN( GOP_API_FAIL);
5972     }
5973     * curBW = eBWStr;
5974     GOP_RETURN(GOP_API_SUCCESS);
5975 
5976 }
5977 
5978 /********************************************************************************/
5979 /// Set GOP bandwidth saving mode.
5980 /// @return GOP_API_SUCCESS - Success
5981 /// @return GOP_API_FAIL - Failure
5982 /********************************************************************************/
MApi_GOP_SetGOPYUV(MS_U8 u8GOP)5983 E_GOP_API_Result MApi_GOP_SetGOPYUV(MS_U8 u8GOP)
5984 {
5985     MS_U32  value = 0;
5986     GOP_SET_PROPERTY_PARAM ioctl_info;
5987 
5988     GOP_ENTRY();
5989     memset(&ioctl_info, 0x0, sizeof(GOP_SET_PROPERTY_PARAM));
5990 
5991     ioctl_info.en_pro   = E_GOP_YUV;
5992     ioctl_info.gop_idx  = u8GOP;
5993     ioctl_info.pSetting = (MS_U32*)&value;
5994     ioctl_info.u32Size  = sizeof(MS_U32);
5995 
5996     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
5997     {
5998         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
5999         GOP_RETURN( GOP_API_FAIL);
6000     }
6001 
6002     GOP_RETURN(GOP_API_SUCCESS);
6003 
6004 }
6005 
6006 /********************************************************************************/
6007 /// Configure panel hstart timing for GOP; For configuring correct OSD position.
6008 /// @param u8GOP \b IN:  GOP number
6009 /// @param u16PanelHStr \b IN horizontal start
6010 /// @return GOP_API_SUCCESS - Success
6011 /// @return GOP_API_FAIL - Failure
6012 /********************************************************************************/
MApi_GOP_SetGOPHStart(MS_U8 u8GOP,MS_U16 u16PanelHStr)6013 E_GOP_API_Result MApi_GOP_SetGOPHStart(MS_U8 u8GOP,MS_U16 u16PanelHStr)
6014 {
6015     GOP_SET_PROPERTY_PARAM ioctl_info;
6016     MS_U32 u32PHstart;
6017 
6018     GOP_ENTRY();
6019 
6020     u32PHstart = u16PanelHStr;
6021 
6022     ioctl_info.en_pro   = E_GOP_HSTART;
6023     ioctl_info.gop_idx  = u8GOP;
6024     ioctl_info.pSetting = &u32PHstart;
6025     ioctl_info.u32Size  = sizeof(MS_U16);
6026 
6027     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
6028     {
6029         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6030         GOP_RETURN( GOP_API_FAIL);
6031     }
6032 
6033     GOP_RETURN(GOP_API_SUCCESS);
6034 
6035 }
6036 
6037 /********************************************************************************/
6038 /// Configure panel hstart timing for GOP; For configuring correct OSD position.
6039 /// @param u16PanelHStr \b IN horizontal start
6040 /// @return GOP_API_SUCCESS - Success
6041 /// @return GOP_API_FAIL - Failure
6042 /********************************************************************************/
MApi_GOP_VE_SetOutputTiming(GOP_VE_TIMINGTYPE mode)6043 E_GOP_API_Result MApi_GOP_VE_SetOutputTiming(GOP_VE_TIMINGTYPE mode)
6044 {
6045     GOP_ENTRY();
6046 
6047     GOP_VE_PROPERTY_PARAM ioctl_info;
6048     GOP_VE_TIMING_INFO VETimingInfo;
6049 
6050     VETimingInfo.mode = mode;
6051 
6052     ioctl_info.en_ve_property = E_GOP_VE_OUTPUT_TIMING;
6053     ioctl_info.pVEProp = (MS_U32*)&VETimingInfo;
6054     ioctl_info.u32Size = sizeof(GOP_VE_TIMING_INFO);
6055 
6056     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_VE_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
6057     {
6058         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6059         GOP_RETURN( GOP_API_FAIL);
6060     }
6061 
6062     GOP_RETURN(GOP_API_SUCCESS);
6063 
6064 }
6065 
6066 /********************************************************************************/
6067 /// Configure panel hstart timing for GOP; For configuring correct OSD position.
6068 /// @param u16PanelHStr \b IN horizontal start
6069 /// @return GOP_API_SUCCESS - Success
6070 /// @return GOP_API_FAIL - Failure
6071 /********************************************************************************/
MApi_GOP_MIXER_SetOutputTiming(GOP_MIXER_TIMINGTYPE mode,GOP_MixerTiming * pMT)6072 E_GOP_API_Result MApi_GOP_MIXER_SetOutputTiming(GOP_MIXER_TIMINGTYPE mode,  GOP_MixerTiming *pMT)
6073 {
6074     GOP_ENTRY();
6075 
6076     GOP_MIXER_PROPERTY_PARAM ioctl_info;
6077     GOP_MIXER_TIMING_INFO MixerTimingInfo;
6078 
6079     memcpy(&MixerTimingInfo.pMT, pMT, sizeof(GOP_MixerTiming));
6080     MixerTimingInfo.mode = mode;
6081 
6082     ioctl_info.en_mixer_property = E_GOP_MIXER_OUTPUT_TIMING;
6083     ioctl_info.pMixerProp = (MS_U32*)&MixerTimingInfo;
6084     ioctl_info.u32Size = sizeof(GOP_MIXER_TIMING_INFO);
6085 
6086     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_MIXER_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
6087     {
6088         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6089         GOP_RETURN( GOP_API_FAIL);
6090     }
6091 
6092     GOP_RETURN(GOP_API_SUCCESS);
6093 }
6094 
6095 /********************************************************************************/
6096 /// Configure mixer timing for GOP destination MIXER2OP; For configuring correct OSD position.
6097 /// @param pMT \b IN:  mixer timing
6098 /// @return GOP_API_SUCCESS - Success
6099 /// @return GOP_API_FAIL - Failure
6100 /********************************************************************************/
MApi_GOP_MIXER_SetMIXER2OPOutputTiming(GOP_Mixer2OPTiming * pMT)6101 E_GOP_API_Result MApi_GOP_MIXER_SetMIXER2OPOutputTiming(GOP_Mixer2OPTiming *pMT)
6102 {
6103     GOP_ENTRY();
6104 
6105     GOP_MIXER_PROPERTY_PARAM ioctl_info;
6106     GOP_Mixer2OPTiming Mixer2OPTiming;
6107 
6108     memcpy(&Mixer2OPTiming, pMT, sizeof(GOP_Mixer2OPTiming));
6109 
6110     ioctl_info.en_mixer_property = E_GOP_MIXER_TO_OP_OUTPUT_TIMING;
6111     ioctl_info.pMixerProp = (MS_U32*)&Mixer2OPTiming;
6112     ioctl_info.u32Size = sizeof(GOP_Mixer2OPTiming);
6113 
6114     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_MIXER_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
6115     {
6116         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6117         GOP_RETURN( GOP_API_FAIL);
6118     }
6119 
6120     GOP_RETURN(GOP_API_SUCCESS);
6121 }
6122 
6123 /********************************************************************************/
6124 /// Enable Mixer for Vfilter
6125 /// @param bEnable \b IN:
6126 ///   - # TRUE Enable Vfilter
6127 ///   - # FALSE Disable Vfilter
6128 /// @return GOP_API_SUCCESS - Success
6129 /// @return GOP_API_FAIL - Failure
6130 /********************************************************************************/
MApi_GOP_MIXER_EnableVfilter(MS_BOOL bEnable)6131 E_GOP_API_Result MApi_GOP_MIXER_EnableVfilter(MS_BOOL bEnable)
6132 {
6133     GOP_ENTRY();
6134 
6135     GOP_MIXER_PROPERTY_PARAM ioctl_info;
6136     MS_BOOL bEna;
6137 
6138     bEna = bEnable;
6139 
6140     ioctl_info.en_mixer_property = E_GOP_MIXER_V_FILTER;
6141     ioctl_info.pMixerProp = (void*)&bEna;
6142     ioctl_info.u32Size = sizeof(MS_BOOL);
6143 
6144     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_MIXER_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
6145     {
6146         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6147         GOP_RETURN( GOP_API_FAIL);
6148     }
6149 
6150     GOP_RETURN(GOP_API_SUCCESS);
6151 }
6152 
6153 /*******************************************************************************/
6154 //Set which MUX select which GOP of mixer, when different gop do the alpha blending
6155 /// @param u8GOP \b IN:  GOP number
6156 /// @param u8Mux \b IN:  Mux number
6157 /// @param bEn \b IN:
6158 ///   - # TRUE Enable u8GOP to mixer u8Mux
6159 ///   - # FALSE Disable u8GOP to mixer u8Mux
6160 //@return GOP_API_SUCCESS - Success
6161 /*******************************************************************************/
MApi_GOP_MIXER_SetMux(MS_U8 u8GOP,MS_U8 u8Mux,MS_BOOL bEn)6162 E_GOP_API_Result MApi_GOP_MIXER_SetMux(MS_U8 u8GOP,MS_U8 u8Mux, MS_BOOL bEn) //jasmine2
6163 {
6164     GOP_ENTRY();
6165 
6166     //Need to implement
6167 
6168 
6169     GOP_RETURN(GOP_API_SUCCESS);
6170 }
6171 
6172 /********************************************************************************/
6173 /// Enable Mixer for old mode blending
6174 /// @param bEnable \b IN:
6175 ///   - # TRUE Enable old mode
6176 ///   - # FALSE Disable old mode
6177 /// @return GOP_API_SUCCESS - Success
6178 /// @return GOP_API_FAIL - Failure
6179 /********************************************************************************/
MApi_GOP_MIXER_EnableOldBlendMode(MS_U8 u8GOP,MS_BOOL bEnable)6180 E_GOP_API_Result MApi_GOP_MIXER_EnableOldBlendMode(MS_U8 u8GOP, MS_BOOL bEnable)
6181 {
6182     GOP_ENTRY();
6183 
6184     GOP_MIXER_PROPERTY_PARAM ioctl_info;
6185     GOP_MixerOldBlendingMode MixerOldBlendingMode;
6186     MixerOldBlendingMode.bEnable = bEnable;
6187     MixerOldBlendingMode.u8GOP = u8GOP;
6188 
6189     ioctl_info.en_mixer_property = E_GOP_MIXER_OLD_BLENDING_MODE;
6190     ioctl_info.pMixerProp = (void*)&MixerOldBlendingMode;
6191     ioctl_info.u32Size = sizeof(GOP_MixerOldBlendingMode);
6192 
6193     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_MIXER_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
6194     {
6195         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6196         GOP_RETURN( GOP_API_FAIL);
6197     }
6198 
6199     GOP_RETURN(GOP_API_SUCCESS);
6200 
6201 }
6202 
6203 
6204 //******************************************************************************
6205 /// Call this API to Nofify GOP could restore from vsync. limitation. That
6206 /// means App. could switch back to its dst.
6207 /// @return GOP_API_SUCCESS - Success
6208 //******************************************************************************
MApi_GOP_RestoreFromVsyncLimitation(void)6209 E_GOP_API_Result MApi_GOP_RestoreFromVsyncLimitation(void)
6210 {
6211     GOP_ENTRY();
6212     GOP_ERR("[%s] Not SUPPORT\n",__FUNCTION__);
6213     GOP_RETURN(GOP_API_SUCCESS);
6214 }
6215 
6216 /********************************************************************************/
6217 /// Configure GOP brightness
6218 /// @param u8GOP \b IN:  GOP number
6219 /// @param u16BriVal \b IN brightness value
6220 /// @param bMSB \b IN MSB
6221 /// @return GOP_API_SUCCESS - Success
6222 /// @return GOP_API_FAIL - Failure
6223 /********************************************************************************/
6224 
MApi_GOP_SetGOPBrightness(MS_U8 u8GOP,MS_U16 u16BriVal,MS_BOOL bMSB)6225 E_GOP_API_Result MApi_GOP_SetGOPBrightness(MS_U8 u8GOP,MS_U16 u16BriVal,MS_BOOL bMSB)
6226 {
6227     GOP_SET_PROPERTY_PARAM ioctl_info;
6228     GOP_BRIGHTNESS  bri;
6229 
6230     GOP_ENTRY();
6231 
6232     bri.bMSB = bMSB;
6233     bri.Brightness = u16BriVal;
6234 
6235     ioctl_info.en_pro   = E_GOP_BRIGHTNESS;
6236     ioctl_info.gop_idx  = u8GOP;
6237     ioctl_info.pSetting = (MS_U32*)&bri;
6238     ioctl_info.u32Size  = sizeof(GOP_BRIGHTNESS);
6239 
6240     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
6241     {
6242         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6243         GOP_RETURN( GOP_API_FAIL);
6244     }
6245 
6246     GOP_RETURN(GOP_API_SUCCESS);
6247 
6248 }
6249 
6250 /********************************************************************************/
6251 /// Enable LB Couple Feature to enlarge GOP FIFO for BW issue
6252 /// @param u8GOP \b IN:  GOP number
6253 /// @param bEnable \b IN Enable or Disable
6254 /// @return GOP_API_SUCCESS - Success
6255 /// @return GOP_API_FAIL - Failure
6256 /********************************************************************************/
6257 
MApi_GOP_EnableLBCouple(MS_U8 u8GOP,MS_BOOL bEnable)6258 E_GOP_API_Result MApi_GOP_EnableLBCouple(MS_U8 u8GOP, MS_BOOL bEnable)
6259 {
6260     MS_BOOL bEna;
6261     GOP_SET_PROPERTY_PARAM ioctl_info;
6262 
6263     GOP_ENTRY();
6264     memset(&ioctl_info, 0x0, sizeof(GOP_SET_PROPERTY_PARAM));
6265     bEna = bEnable;
6266 
6267     ioctl_info.en_pro   = E_GOP_LB_COUPLE;
6268     ioctl_info.gop_idx  = u8GOP;
6269     ioctl_info.pSetting = (void*)&bEna;
6270     ioctl_info.u32Size  = sizeof(MS_BOOL);
6271 
6272     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
6273     {
6274         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6275         GOP_RETURN( GOP_API_FAIL);
6276     }
6277 
6278     GOP_RETURN(GOP_API_SUCCESS);
6279 }
6280 
6281 /********************************************************************************/
6282 /// Get GOP brightness value
6283 /// @param u8GOP \b IN:  GOP number
6284 /// @param u16BriVal \b OUT brightness value
6285 /// @param bMSB \b OUT MSB
6286 /// @return GOP_API_SUCCESS - Success
6287 /// @return GOP_API_FAIL - Failure
6288 /********************************************************************************/
MApi_GOP_GetGOPBrightness(MS_U8 u8GOP,MS_U16 * u16BriVal,MS_BOOL * bMSB)6289 E_GOP_API_Result MApi_GOP_GetGOPBrightness(MS_U8 u8GOP,MS_U16* u16BriVal,MS_BOOL* bMSB)
6290 {
6291     GOP_SET_PROPERTY_PARAM ioctl_info;
6292     GOP_BRIGHTNESS  bri;
6293 
6294     GOP_ENTRY();
6295 
6296     memset(&ioctl_info, 0x0, sizeof(GOP_SET_PROPERTY_PARAM));
6297     memset(&bri, 0x0, sizeof(GOP_BRIGHTNESS));
6298 
6299     ioctl_info.en_pro   = E_GOP_BRIGHTNESS;
6300     ioctl_info.gop_idx  = u8GOP;
6301     ioctl_info.pSetting = (void*)&bri;
6302     ioctl_info.u32Size  = sizeof(GOP_BRIGHTNESS);
6303 
6304     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
6305     {
6306         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6307         GOP_RETURN( GOP_API_FAIL);
6308     }
6309 
6310     *bMSB      = bri.bMSB;
6311     *u16BriVal = bri.Brightness;
6312 
6313     GOP_RETURN(GOP_API_SUCCESS);
6314 
6315 }
6316 
6317 //******************************************************************************
6318 /// API for enable or disable Tile mode for GWIN
6319 /// @param winId \b IN: GWIN id
6320 /// @param bEnable \b IN:
6321 ///   - # TRUE Enable Tile Mode for GWIN
6322 ///   - # FALSE Disable Tile Mode for GWIN
6323 /// @return GOP_API_SUCCESS - Success
6324 /// @return GOP_API_FAIL - Failure
6325 
6326 //******************************************************************************
MApi_GOP_GWIN_EnableTileMode(MS_U8 winId,MS_BOOL bEnable,EN_GOP_TILE_DATA_TYPE tiletype)6327 E_GOP_API_Result MApi_GOP_GWIN_EnableTileMode(MS_U8 winId, MS_BOOL bEnable, EN_GOP_TILE_DATA_TYPE tiletype )
6328 {
6329     GOP_ENTRY();
6330     GOP_ERR("[%s] Not SUPPORT bEn:%d type:%d\n",__FUNCTION__,bEnable, tiletype);
6331     GOP_RETURN(GOP_API_SUCCESS);
6332 }
6333 
6334 
6335 //******************************************************************************
6336 /// API for set gop miu selection
6337 /// @param bEnable \b IN:
6338 ///   - # TRUE Enable Tile Mode for GWIN
6339 ///   - # FALSE Disable Tile Mode for GWIN
6340 /// @return GOP_API_SUCCESS - Success
6341 /// @return GOP_API_FAIL - Failure
6342 
6343 //******************************************************************************
MApi_GOP_MIUSel(MS_U8 u8GOP,EN_GOP_SEL_TYPE MiuSel)6344 E_GOP_API_Result MApi_GOP_MIUSel(MS_U8 u8GOP, EN_GOP_SEL_TYPE MiuSel )
6345 {
6346     GOP_SET_PROPERTY_PARAM ioctl_info;
6347     EN_GOP_SEL_TYPE  miu;
6348 
6349     GOP_ENTRY();
6350 
6351     memset(&ioctl_info, 0x0, sizeof(GOP_SET_PROPERTY_PARAM));
6352     memset(&miu, 0x0, sizeof(EN_GOP_SEL_TYPE));
6353 
6354 
6355     miu = MiuSel;
6356 
6357     ioctl_info.en_pro   = E_GOP_MIUSEL;
6358     ioctl_info.pSetting = (MS_U32*)&miu;
6359     ioctl_info.gop_idx = u8GOP;
6360     ioctl_info.u32Size  = sizeof(EN_GOP_SEL_TYPE);
6361 
6362 
6363     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
6364     {
6365         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6366         GOP_RETURN( GOP_API_FAIL);
6367     }
6368 
6369     GOP_RETURN(GOP_API_SUCCESS);
6370 
6371 }
6372 
6373 //******************************************************************************
6374 /// API for query gop miu selection
6375 /// @param bEnable \b IN:
6376 ///   - # TRUE Enable Tile Mode for GWIN
6377 ///   - # FALSE Disable Tile Mode for GWIN
6378 /// @return GOP_API_SUCCESS - Success
6379 /// @return GOP_API_FAIL - Failure
6380 
6381 //******************************************************************************
MApi_GOP_GetMIUSel(MS_U8 u8GOP)6382 MS_U8 MApi_GOP_GetMIUSel(MS_U8 u8GOP)
6383 {
6384     GOP_SET_PROPERTY_PARAM ioctl_info;
6385     EN_GOP_SEL_TYPE  miu;
6386     GOP_ENTRY();
6387     ioctl_info.en_pro   = E_GOP_MIUSEL;
6388     ioctl_info.gop_idx  = u8GOP;
6389     ioctl_info.pSetting = (void*)&miu;
6390     ioctl_info.u32Size  = sizeof(EN_GOP_SEL_TYPE);
6391 
6392     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
6393     {
6394         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6395         GOP_RETURN( GOP_API_FAIL);
6396     }
6397 
6398     GOP_RETURN( (MS_U8)miu);
6399 }
6400 
6401 
6402 //******************************************************************************
6403 /// API for set gop pinpong
6404 /// @param winId \b IN: GWIN id
6405 /// @param bEnable \b IN:
6406 ///   - # TRUE Enable Tile Mode for GWIN
6407 ///   - # FALSE Disable Tile Mode for GWIN
6408 /// @return GOP_API_SUCCESS - Success
6409 /// @return GOP_API_FAIL - Failure
6410 
6411 //******************************************************************************
MApi_GOP_SetPINPON(MS_U8 winId,MS_BOOL bEn,GOP_PINPON_MODE PINPON_Mode)6412 E_GOP_API_Result MApi_GOP_SetPINPON(MS_U8 winId, MS_BOOL bEn,GOP_PINPON_MODE PINPON_Mode)
6413 {
6414     GOP_SET_PINPON_INFO pinpon_info;
6415     switch(PINPON_Mode)
6416     {
6417         case GOP_PINPON_G3D:
6418             pinpon_info.mode = E_GOP_PINPON_G3D;
6419             break;
6420         case GOP_PINPON_VE:
6421             pinpon_info.mode = E_GOP_PINPON_VE;
6422             break;
6423         case GOP_PINPON_DWIN:
6424             pinpon_info.mode = E_GOP_PINPON_DWIN;
6425             break;
6426         case GOP_PINPON_DIP:
6427             pinpon_info.mode = E_GOP_PINPON_DIP;
6428             break;
6429         case GOP_PINPON_DWIN0:
6430             pinpon_info.mode = E_GOP_PINPON_DWIN0;
6431             break;
6432         case GOP_PINPON_DWIN1:
6433             pinpon_info.mode = E_GOP_PINPON_DWIN1;
6434             break;
6435         default:
6436             GOP_ERR("MApi_GOP_SetPINPON Enum not mapping!\n");
6437             return GOP_API_INVALID_PARAMETERS;
6438     }
6439     pinpon_info.GwinId  = winId;
6440     pinpon_info.bEnable = bEn;
6441 
6442     GOP_SET_PINPON_PARAM ioctl_info;
6443     GOP_ENTRY();
6444     ioctl_info.en_pro   = E_GOP_SET_PINPON;
6445     ioctl_info.pSetting = (MS_U32*)&pinpon_info;
6446     ioctl_info.u32Size  = sizeof(GOP_SET_PINPON_INFO);
6447 
6448     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PINPON,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
6449     {
6450         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6451         GOP_RETURN(GOP_API_FAIL);
6452     }
6453 
6454     GOP_RETURN(GOP_API_SUCCESS);
6455 }
6456 
MApi_GOP_DWIN_SetBufferPINPON(MS_PHY phyfbaddr0,MS_PHY phyfbaddr1)6457 E_GOP_API_Result MApi_GOP_DWIN_SetBufferPINPON(MS_PHY phyfbaddr0,MS_PHY phyfbaddr1)
6458 {
6459     GOP_ENTRY();
6460 
6461     GOP_DWIN_PROPERTY_PARAM ioctl_info;
6462     GOP_PINPON_INFO stPinpon;
6463 
6464     stPinpon.u64Addr0 = phyfbaddr0;
6465     stPinpon.u64Addr1 = phyfbaddr1;
6466     ioctl_info.en_dwin_property = E_GOP_DWIN_PINPON;
6467     ioctl_info.pDwinProp = (MS_U32*)&stPinpon;
6468     ioctl_info.u32Size = sizeof(GOP_PINPON_INFO);
6469 
6470     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_DWIN_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
6471     {
6472         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6473         GOP_RETURN( GOP_API_FAIL);
6474     }
6475 
6476     GOP_RETURN(GOP_API_SUCCESS);
6477 }
6478 //******************************************************************************
6479 /// API for set U/V SWAP
6480 /// @param u8GOP \b IN: GOP number
6481 /// @param bEnable \b IN:
6482 ///   - # TRUE Enable U/V SWAP for GOP
6483 ///   - # FALSE Disable U/V SWAP for GOP
6484 /// @return GOP_API_SUCCESS - Success
6485 /// @return GOP_API_FAIL - Failure
6486 //******************************************************************************
MApi_GOP_SetUVSwap(MS_U8 u8GOP,MS_BOOL bEn)6487 E_GOP_API_Result MApi_GOP_SetUVSwap(MS_U8 u8GOP, MS_BOOL bEn)
6488 {
6489 
6490     GOP_SET_PROPERTY_PARAM ioctl_info;
6491     MS_U32  UVSwapEn;
6492 
6493     GOP_ENTRY();
6494 
6495     UVSwapEn = bEn;
6496 
6497     ioctl_info.en_pro   = E_GOP_UV_SWAP;
6498     ioctl_info.gop_idx  = u8GOP;
6499     ioctl_info.pSetting = (MS_U32*)&UVSwapEn;
6500     ioctl_info.u32Size  = sizeof(MS_BOOL);
6501 
6502     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
6503     {
6504         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6505         GOP_RETURN( GOP_API_FAIL);
6506     }
6507 
6508     GOP_RETURN(GOP_API_SUCCESS);
6509 }
6510 
6511 //******************************************************************************
6512 /// API for set Y/C SWAP
6513 /// @param u8GOP \b IN: GOP number
6514 /// @param bEnable \b IN:
6515 ///   - # TRUE Enable Y/C SWAP for GOP
6516 ///   - # FALSE Disable Y/C SWAP for GOP
6517 /// @return GOP_API_SUCCESS - Success
6518 /// @return GOP_API_FAIL - Failure
6519 //******************************************************************************
MApi_GOP_SetYCSwap(MS_U8 u8GOP,MS_BOOL bEn)6520 E_GOP_API_Result MApi_GOP_SetYCSwap(MS_U8 u8GOP, MS_BOOL bEn)
6521 {
6522 
6523     GOP_SET_PROPERTY_PARAM ioctl_info;
6524     MS_U32  YCSwapEn;
6525 
6526     GOP_ENTRY();
6527 
6528     YCSwapEn = bEn;
6529 
6530     ioctl_info.en_pro   = E_GOP_YC_SWAP;
6531     ioctl_info.gop_idx  = u8GOP;
6532     ioctl_info.pSetting = (MS_U32*)&YCSwapEn;
6533     ioctl_info.u32Size  = sizeof(MS_BOOL);
6534 
6535     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
6536     {
6537         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6538         GOP_RETURN( GOP_API_FAIL);
6539     }
6540 
6541     GOP_RETURN(GOP_API_SUCCESS);
6542 }
6543 
6544 //******************************************************************************
6545 /// API for set GWIN New Alpha Mode
6546 /// @param gWinId \b IN: GWin ID
6547 /// @param bEnable \b IN:
6548 ///   - # TRUE enable new alpha mode
6549 ///   - # FALSE disable new alpha mode
6550 /// @return GOP_API_SUCCESS - Success
6551 /// @return GOP_API_FAIL - Failure
6552 //******************************************************************************
MApi_GOP_GWIN_SetNewAlphaMode(MS_U8 gWinId,MS_BOOL bEnable)6553 E_GOP_API_Result MApi_GOP_GWIN_SetNewAlphaMode(MS_U8 gWinId, MS_BOOL bEnable)
6554 {
6555     GOP_GWIN_PROPERTY_PARAM ioctl_info;
6556 
6557     GOP_ENTRY();
6558 
6559     ioctl_info.en_property = E_GOP_GWIN_NEWAPLHA;
6560     ioctl_info.GwinId = gWinId;
6561     ioctl_info.pSet = (void*) &bEnable;
6562     ioctl_info.u32Size = sizeof(MS_BOOL);
6563 
6564     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
6565     {
6566         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6567         GOP_RETURN( GOP_API_FAIL);
6568     }
6569 
6570     GOP_RETURN(GOP_API_SUCCESS);
6571 }
6572 
6573 //******************************************************************************
6574 /// API for Trigger reg writes in
6575 /// @param u8win \b IN: GWin ID
6576 /// @param bForceWriteIn \b IN:
6577 ///   - # TRUE , Register will take effect immediately
6578 ///   - # FALSE, Register will take effect after the next vsync
6579 /// @return GOP_API_SUCCESS - Success
6580 /// @return GOP_API_FAIL - Failure
6581 //******************************************************************************
MApi_GOP_TriggerRegWriteIn(MS_U8 u8win,MS_BOOL bForceWriteIn)6582 E_GOP_API_Result MApi_GOP_TriggerRegWriteIn(MS_U8 u8win, MS_BOOL bForceWriteIn)
6583 {
6584     E_GOP_API_Result ret;
6585     ret = MApi_GOP_TriggerRegWriteIn_Ex(u8win, bForceWriteIn, TRUE);
6586     return ret;
6587 }
6588 
6589 //******************************************************************************
6590 /// API for Trigger reg writes in
6591 /// @param u8win \b IN: GWin ID
6592 /// @param bForceWriteIn \b IN:
6593 ///   - # TRUE , Register will take effect immediately
6594 ///   - # FALSE, Register will take effect after the next vsync
6595 /// @param bSync \b IN:
6596 ///   - # FALSE , Register will fire without waiting vsync (driver will not polling the vsync)
6597 ///   - # TRUE, Register will fire and waiting vsync
6598 /// @return GOP_API_SUCCESS - Success
6599 /// @return GOP_API_FAIL - Failure
6600 //******************************************************************************
MApi_GOP_TriggerRegWriteIn_Ex(MS_U8 u8win,MS_BOOL bForceWriteIn,MS_BOOL bSync)6601 E_GOP_API_Result MApi_GOP_TriggerRegWriteIn_Ex(MS_U8 u8win, MS_BOOL bForceWriteIn, MS_BOOL bSync)
6602 {
6603     GOP_UPDATE_PARAM ioctl_info;
6604     GOP_UPDATE_INFO update;
6605     GOP_GWIN_PROPERTY_PARAM ioctl_gwin_info;
6606     MS_U32 gop = INVAILD_GOP_NUM;
6607     GOP_ENTRY();
6608 
6609     ioctl_gwin_info.en_property = E_GOP_GWIN_GET_GOP;
6610     ioctl_gwin_info.GwinId = u8win;
6611     ioctl_gwin_info.pSet = (MS_U32*)&gop;
6612     ioctl_gwin_info.u32Size = sizeof(MS_U32);
6613     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_GET_PROPERTY,(void*)&ioctl_gwin_info) != UTOPIA_STATUS_SUCCESS)
6614     {
6615         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6616         GOP_RETURN(GOP_API_FAIL);
6617     }
6618 
6619     memset(&ioctl_info, 0x0, sizeof(GOP_UPDATE_PARAM));
6620     memset(&update, 0x0, sizeof(GOP_UPDATE_INFO));
6621 
6622     update.gop_idx = gop;
6623     update.update_type = E_GOP_UPDATE_FORCEWRITE;
6624     update.bEn = bForceWriteIn;
6625     update.bSync = bSync;
6626 
6627     ioctl_info.pUpdateInfo = (MS_U32*)&update;
6628     ioctl_info.u32Size = sizeof(GOP_UPDATE_INFO);
6629 
6630     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_UPDATE,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
6631     {
6632         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6633         GOP_RETURN( GOP_API_FAIL);
6634     }
6635 
6636     GOP_RETURN(GOP_API_SUCCESS);
6637 
6638 
6639 }
6640 
6641 
6642 
MApi_GOP_SetGOPContrast(MS_U8 u8GOP,MS_U16 u16YContrast,MS_U16 u16UContrast,MS_U16 u16VContrast)6643 E_GOP_API_Result MApi_GOP_SetGOPContrast( MS_U8 u8GOP, MS_U16 u16YContrast
6644     , MS_U16 u16UContrast, MS_U16 u16VContrast )
6645 {
6646     GOP_SET_PROPERTY_PARAM ioctl_info;
6647     GOP_CONTRAST  contrast;
6648 
6649     GOP_ENTRY();
6650 
6651     contrast.y = u16YContrast;
6652     contrast.u = u16UContrast;
6653     contrast.v = u16VContrast;
6654 
6655     ioctl_info.en_pro   = E_GOP_CONTRAST;
6656     ioctl_info.gop_idx  = u8GOP;
6657     ioctl_info.pSetting = (MS_U32*)&contrast;
6658     ioctl_info.u32Size  = sizeof(GOP_CONTRAST);
6659 
6660     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
6661     {
6662         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6663         GOP_RETURN( GOP_API_FAIL);
6664     }
6665 
6666     GOP_RETURN(GOP_API_SUCCESS);
6667 }
6668 
MApi_GOP_GetGOPContrast(MS_U8 u8GOP,MS_U16 * u16YContrast,MS_U16 * u16UContrast,MS_U16 * u16VContrast)6669 E_GOP_API_Result MApi_GOP_GetGOPContrast( MS_U8 u8GOP, MS_U16* u16YContrast
6670     , MS_U16* u16UContrast, MS_U16* u16VContrast )
6671 {
6672 
6673     GOP_SET_PROPERTY_PARAM ioctl_info;
6674     GOP_CONTRAST  contrast;
6675 
6676     GOP_ENTRY();
6677 
6678     ioctl_info.en_pro   = E_GOP_CONTRAST;
6679     ioctl_info.gop_idx  = u8GOP;
6680     ioctl_info.pSetting = (MS_U32*)&contrast;
6681     ioctl_info.u32Size  = sizeof(GOP_CONTRAST);
6682 
6683     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
6684     {
6685         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6686         GOP_RETURN( GOP_API_FAIL);
6687     }
6688 
6689     *u16YContrast = contrast.y;
6690     *u16UContrast = contrast.u;
6691     *u16VContrast = contrast.v;
6692 
6693     GOP_RETURN(GOP_API_SUCCESS);
6694 
6695 }
6696 
MApi_GOP_GetVECaptureState(PMS_GOP_VECAPTURESTATE pstVECapState)6697 E_GOP_API_Result MApi_GOP_GetVECaptureState(PMS_GOP_VECAPTURESTATE pstVECapState)
6698 {
6699     GOP_ERR("[%s] Not SUPPORT in utopia2\n",__FUNCTION__);
6700     return GOP_API_FUN_NOT_SUPPORTED;
6701 }
6702 
MApi_GOP_VECaptureWaitOnFrame(PMS_GOP_VECAPTURESTATE pstVECapState)6703 E_GOP_API_Result MApi_GOP_VECaptureWaitOnFrame(PMS_GOP_VECAPTURESTATE pstVECapState)
6704 {
6705     GOP_ERR("[%s] Not SUPPORT in utopia2\n",__FUNCTION__);
6706     return GOP_API_FUN_NOT_SUPPORTED;
6707 }
6708 
MApi_GOP_EnaVECapture(PMS_GOP_VECAPTURESTATE pstVECapState)6709 E_GOP_API_Result MApi_GOP_EnaVECapture(PMS_GOP_VECAPTURESTATE pstVECapState)
6710 {
6711     GOP_ERR("[%s] Not SUPPORT in utopia2\n",__FUNCTION__);
6712     return GOP_API_FUN_NOT_SUPPORTED;
6713 }
6714 
6715 //******************************************************************************
6716 /// API for Enable VEOSD
6717 /// @param u8win \b IN: GOP ID
6718 /// @return GOP_API_SUCCESS - Success
6719 /// @return GOP_API_FAIL - Failure
6720 //******************************************************************************
MApi_GOP_Enable_VEOSD(MS_U8 u8GOP,MS_BOOL bEn)6721 E_GOP_API_Result MApi_GOP_Enable_VEOSD(MS_U8 u8GOP, MS_BOOL bEn)
6722 {
6723     MS_BOOL bEna;
6724     GOP_SET_PROPERTY_PARAM ioctl_info;
6725 
6726     GOP_ENTRY();
6727     memset(&ioctl_info, 0x0, sizeof(GOP_SET_PROPERTY_PARAM));
6728     bEna = bEn;
6729 
6730     ioctl_info.en_pro   = E_GOP_VE_OSD;
6731     ioctl_info.gop_idx  = u8GOP;
6732     ioctl_info.pSetting = (void*)&bEna;
6733     ioctl_info.u32Size  = sizeof(MS_BOOL);
6734 
6735     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
6736     {
6737         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6738         GOP_RETURN( GOP_API_FAIL);
6739     }
6740 
6741     GOP_RETURN(GOP_API_SUCCESS);
6742 }
6743 
6744 
6745 /*******************************************************************************/
6746 //Set configuration for special cases
6747 ///        - This is for special case usage. Do NOT overuse this function
6748 /// @param type \b IN:  Config type
6749 ///        - Think twice if you are going to add one type
6750 ///        - Be careful to create config type. Do NOT affect the normal code flow
6751 /// @param plist \b IN:  Config list for the specific type
6752 //         - This list could be an enum or a structure
6753 //@return GOP_API_SUCCESS - Success
6754 /*******************************************************************************/
MApi_GOP_SetConfig(EN_GOP_CONFIG_TYPE type,void * plist)6755 E_GOP_API_Result MApi_GOP_SetConfig(EN_GOP_CONFIG_TYPE type, void *plist)
6756 {
6757     GOP_SETCONFIG_PARAM ioctl_info;
6758     MS_U32 u32Size =0;
6759 
6760     CheckGOPInstanceOpen();
6761 
6762     switch(type)
6763     {
6764         case E_GOP_IGNOREINIT:
6765         {
6766             u32Size = sizeof(EN_GOP_IGNOREINIT);
6767             break;
6768         }
6769         case E_GOP_CONSALPHA_BITS:
6770         {
6771             u32Size = sizeof(EN_GOP_CONSALPHA_BITS);
6772             break;
6773         }
6774         default:
6775             u32Size = 0;
6776             break;
6777     }
6778 
6779 
6780     ioctl_info.cfg_type = type;
6781     ioctl_info.pCfg = plist;
6782     ioctl_info.u32Size = u32Size;
6783 
6784     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_CONFIG,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
6785     {
6786         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6787         return GOP_API_FAIL;
6788     }
6789 
6790 
6791     return GOP_API_SUCCESS;
6792 
6793 
6794 }
6795 
6796 /********************************************************************************/
6797 /// Set config by GOP; For dynamic usage.
6798 /// @param u8GOP \b IN:  GOP number
6799 /// @param pstInfo \b IN misc info
6800 /// @return GOP_API_SUCCESS - Success
6801 /// @return GOP_API_FAIL - Failure
6802 /********************************************************************************/
MApi_GOP_SetConfigEx(MS_U8 u8Gop,EN_GOP_CONFIG_TYPE enType,void * plist)6803 E_GOP_API_Result MApi_GOP_SetConfigEx(MS_U8 u8Gop, EN_GOP_CONFIG_TYPE enType, void *plist)
6804 {
6805     E_GOP_API_CMD_TYPE enApiCmdType;
6806     GOP_SETCONFIG_PARAM ioctl_ConfigInfo;
6807     GOP_SET_PROPERTY_PARAM ioctl_PropInfo;
6808     void *pInfo = NULL;
6809 
6810     CheckGOPInstanceOpen();
6811 
6812     switch(enType)
6813     {
6814         case E_GOP_IGNOREINIT:
6815         {
6816             ioctl_ConfigInfo.cfg_type = enType;
6817             ioctl_ConfigInfo.pCfg = plist;
6818             ioctl_ConfigInfo.u32Size = sizeof(EN_GOP_IGNOREINIT);
6819             pInfo = (void*)&ioctl_ConfigInfo;
6820             enApiCmdType = MAPI_CMD_GOP_SET_CONFIG;
6821             break;
6822         }
6823         case E_GOP_CONSALPHA_BITS:
6824         {
6825             ioctl_ConfigInfo.cfg_type = enType;
6826             ioctl_ConfigInfo.pCfg = plist;
6827             ioctl_ConfigInfo.u32Size = sizeof(EN_GOP_CONSALPHA_BITS);
6828             pInfo = (void*)&ioctl_ConfigInfo;
6829             enApiCmdType = MAPI_CMD_GOP_SET_CONFIG;
6830             break;
6831         }
6832         case E_GOP_TIMING_INFO:
6833         {
6834             ioctl_PropInfo.en_pro = E_GOP_OUTPUT_TIMING;
6835             ioctl_PropInfo.gop_idx = u8Gop;
6836             ioctl_PropInfo.pSetting = plist;
6837             ioctl_PropInfo.u32Size = sizeof(ST_GOP_TIMING_INFO);
6838             pInfo = (void*)&ioctl_PropInfo;
6839             enApiCmdType = MAPI_CMD_GOP_SET_PROPERTY;
6840             break;
6841         }
6842         case E_GOP_IS_PIXELBASE_ENABLE:
6843         {
6844             ioctl_PropInfo.en_pro = E_GOP_PIXELBASE_ENABLE;
6845             ioctl_PropInfo.gop_idx = u8Gop;
6846             ioctl_PropInfo.pSetting = plist;
6847             ioctl_PropInfo.u32Size = sizeof(MS_BOOL);
6848             pInfo = (void*)&ioctl_PropInfo;
6849             enApiCmdType = MAPI_CMD_GOP_SET_PROPERTY;
6850             break;
6851         }
6852         case E_GOP_AFBC_RESET:
6853         {
6854             ioctl_PropInfo.en_pro = E_GOP_AFBC_CORE_RESET;
6855             ioctl_PropInfo.gop_idx = u8Gop;
6856             ioctl_PropInfo.pSetting = plist;
6857             ioctl_PropInfo.u32Size = sizeof(MS_BOOL);
6858             pInfo = (void*)&ioctl_PropInfo;
6859             enApiCmdType = MAPI_CMD_GOP_SET_PROPERTY;
6860             break;
6861         }
6862         case E_GOP_AFBC_ENABLE:
6863         {
6864             ioctl_PropInfo.en_pro = E_GOP_AFBC_CORE_ENABLE;
6865             ioctl_PropInfo.gop_idx = u8Gop;
6866             ioctl_PropInfo.pSetting = plist;
6867             ioctl_PropInfo.u32Size = sizeof(MS_BOOL);
6868             pInfo = (void*)&ioctl_PropInfo;
6869             enApiCmdType = MAPI_CMD_GOP_SET_PROPERTY;
6870             break;
6871         }
6872         default:
6873             return GOP_API_INVALID_PARAMETERS;
6874             break;
6875     }
6876 
6877     if (UtopiaIoctl(pInstantGOP, enApiCmdType, pInfo) != UTOPIA_STATUS_SUCCESS)
6878     {
6879         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6880         return GOP_API_FAIL;
6881     }
6882     return GOP_API_SUCCESS;
6883 }
6884 
6885 /********************************************************************************/
6886 /// Get config by GOP.
6887 /// @param u8GOP \b IN:  GOP number
6888 /// @param pstInfo \b IN misc info
6889 /// @return GOP_API_SUCCESS - Success
6890 /// @return GOP_API_FAIL - Failure
6891 /********************************************************************************/
MApi_GOP_GetConfigEx(MS_U8 u8Gop,EN_GOP_CONFIG_TYPE enType,void * plist)6892 E_GOP_API_Result MApi_GOP_GetConfigEx(MS_U8 u8Gop, EN_GOP_CONFIG_TYPE enType, void *plist)
6893 {
6894     E_GOP_API_CMD_TYPE enApiCmdType;
6895     GOP_SETCONFIG_PARAM ioctl_ConfigInfo;
6896     GOP_SET_PROPERTY_PARAM ioctl_PropInfo;
6897     void *pInfo = NULL;
6898 
6899     CheckGOPInstanceOpen();
6900 
6901     switch(enType)
6902     {
6903         case E_GOP_IGNOREINIT:
6904         {
6905             ioctl_ConfigInfo.cfg_type = enType;
6906             ioctl_ConfigInfo.pCfg = plist;
6907             ioctl_ConfigInfo.u32Size = sizeof(EN_GOP_IGNOREINIT);
6908             pInfo = (void*)&ioctl_ConfigInfo;
6909             enApiCmdType = MAPI_CMD_GOP_GET_CONFIG;
6910             break;
6911         }
6912         case E_GOP_CONSALPHA_BITS:
6913         {
6914             ioctl_ConfigInfo.cfg_type = enType;
6915             ioctl_ConfigInfo.pCfg = plist;
6916             ioctl_ConfigInfo.u32Size = sizeof(EN_GOP_CONSALPHA_BITS);
6917             pInfo = (void*)&ioctl_ConfigInfo;
6918             enApiCmdType = MAPI_CMD_GOP_GET_CONFIG;
6919             break;
6920         }
6921         case E_GOP_TIMING_INFO:
6922         {
6923             ioctl_PropInfo.en_pro = E_GOP_OUTPUT_TIMING;
6924             ioctl_PropInfo.gop_idx = u8Gop;
6925             ioctl_PropInfo.pSetting = plist;
6926             ioctl_PropInfo.u32Size = sizeof(ST_GOP_TIMING_INFO);
6927             pInfo = (void*)&ioctl_PropInfo;
6928             enApiCmdType = MAPI_CMD_GOP_GET_PROPERTY;
6929             break;
6930         }
6931         case E_GOP_IS_PIXELBASE_ENABLE:
6932         {
6933             ioctl_PropInfo.en_pro = E_GOP_PIXELBASE_ENABLE;
6934             ioctl_PropInfo.gop_idx = u8Gop;
6935             ioctl_PropInfo.pSetting = plist;
6936             ioctl_PropInfo.u32Size = sizeof(MS_BOOL);
6937             pInfo = (void*)&ioctl_PropInfo;
6938             enApiCmdType = MAPI_CMD_GOP_GET_PROPERTY;
6939             break;
6940         }
6941         case E_GOP_GET_MAXFBNUM:
6942         {
6943             ioctl_PropInfo.en_pro = E_GOP_MAXFBNUM;
6944             ioctl_PropInfo.gop_idx = u8Gop;
6945             ioctl_PropInfo.pSetting = plist;
6946             ioctl_PropInfo.u32Size = sizeof(MS_U32);
6947             pInfo = (void*)&ioctl_PropInfo;
6948             enApiCmdType = MAPI_CMD_GOP_GET_PROPERTY;
6949             break;
6950         }
6951         case E_GOP_IS_INIT:
6952         {
6953             ioctl_PropInfo.en_pro = E_GOP_NUM_IS_INIT;
6954             ioctl_PropInfo.gop_idx = u8Gop;
6955             ioctl_PropInfo.pSetting = plist;
6956             ioctl_PropInfo.u32Size = sizeof(GOP_InitInfo);
6957             pInfo = (void*)&ioctl_PropInfo;
6958             enApiCmdType = MAPI_CMD_GOP_GET_PROPERTY;
6959             break;
6960         }
6961         default:
6962             return GOP_API_INVALID_PARAMETERS;
6963             break;
6964     }
6965 
6966     if (UtopiaIoctl(pInstantGOP, enApiCmdType, pInfo) != UTOPIA_STATUS_SUCCESS)
6967     {
6968         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
6969         return GOP_API_FAIL;
6970     }
6971     return GOP_API_SUCCESS;
6972 }
6973 
6974 //******************************************************************************
6975 /// API for set GWIN resolution in one function
6976 /// @param u8GwinId \b IN: GWin ID
6977 /// @param u8FbId \b IN: Frame Buffer ID
6978 /// @param pGwinInfo \b IN: pointer to GOP_GwinInfo structure
6979 /// @param pStretchInfo \b IN: pointer to GOP_StretchInfo
6980 /// @param direction \b IN: to decide which direction to stretch
6981 /// @param u16DstWidth \b IN: set scaled width if H direction is specified
6982 /// @param u16DstHeight \b IN: set scaled height if V direction is specified
6983 /// @return GOP_API_SUCCESS - Success
6984 //******************************************************************************
MApi_GOP_GWIN_SetResolution(MS_U8 u8GwinId,MS_U8 u8FbId,GOP_GwinInfo * pGwinInfo,GOP_StretchInfo * pStretchInfo,EN_GOP_STRETCH_DIRECTION direction,MS_U16 u16DstWidth,MS_U16 u16DstHeight)6985 E_GOP_API_Result MApi_GOP_GWIN_SetResolution(MS_U8 u8GwinId, MS_U8 u8FbId
6986     , GOP_GwinInfo* pGwinInfo, GOP_StretchInfo* pStretchInfo, EN_GOP_STRETCH_DIRECTION direction
6987     , MS_U16 u16DstWidth, MS_U16 u16DstHeight)
6988 {
6989     return MApi_GOP_GWIN_SetResolution_32FB(u8GwinId, (MS_U32)u8FbId, pGwinInfo, pStretchInfo, direction, u16DstWidth, u16DstHeight);
6990 }
6991 
MApi_GOP_GWIN_SetResolution_32FB(MS_U8 u8GwinId,MS_U32 u32FbId,GOP_GwinInfo * pGwinInfo,GOP_StretchInfo * pStretchInfo,EN_GOP_STRETCH_DIRECTION direction,MS_U16 u16DstWidth,MS_U16 u16DstHeight)6992 E_GOP_API_Result MApi_GOP_GWIN_SetResolution_32FB(MS_U8 u8GwinId, MS_U32 u32FbId
6993     , GOP_GwinInfo* pGwinInfo, GOP_StretchInfo* pStretchInfo, EN_GOP_STRETCH_DIRECTION direction
6994     , MS_U16 u16DstWidth, MS_U16 u16DstHeight)
6995 {
6996 
6997     GOP_GWIN_DISPLAY_PARAM ioctl_info;
6998     GOP_GWINDISPLAY_INFO DispInfo;
6999     GOP_ENTRY();
7000     memset(&ioctl_info, 0x0, sizeof(GOP_GWIN_DISPLAY_PARAM));
7001     memset(&DispInfo, 0x0, sizeof(GOP_GWINDISPLAY_INFO));
7002 
7003     DispInfo.dir = direction;
7004     DispInfo.gwin = u8GwinId;
7005     DispInfo.fbid = u32FbId;
7006     DispInfo.dst_size.w = u16DstWidth;
7007     DispInfo.dst_size.h = u16DstHeight;
7008 
7009     memcpy(&DispInfo.gwin_info, pGwinInfo, sizeof(GOP_GwinInfo));
7010     memcpy(&DispInfo.stretch_info, pStretchInfo, sizeof(GOP_StretchInfo));
7011 
7012     ioctl_info.GwinId = u8GwinId;
7013     ioctl_info.u32Size = sizeof(GOP_GWINDISPLAY_INFO);
7014     ioctl_info.pDisplayInfo = (MS_U32*)&DispInfo;
7015 
7016 
7017     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SETDISPLAY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
7018     {
7019         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
7020         GOP_RETURN( GOP_API_FAIL);
7021     }
7022 
7023     GOP_RETURN(GOP_API_SUCCESS);
7024 }
7025 
7026 //******************************************************************************
7027 /// API for change L/R frame for GOP 3D function
7028 /// @param u8GOP \b IN: GOP ID
7029 /// @return GOP_API_SUCCESS - Success
7030 //******************************************************************************
MApi_GOP_Set3D_LR_FrameExchange(MS_U8 u8GOP)7031 E_GOP_API_Result MApi_GOP_Set3D_LR_FrameExchange(MS_U8 u8GOP)
7032 {
7033     GOP_SET_PROPERTY_PARAM ioctl_info;
7034     MS_U32 value = 0;
7035 
7036     GOP_ENTRY();
7037     memset(&ioctl_info, 0x0, sizeof(GOP_SET_PROPERTY_PARAM));
7038 
7039     ioctl_info.en_pro   = E_GOP_3D_LR_EXCHANGE;
7040     ioctl_info.gop_idx  = u8GOP;
7041     ioctl_info.pSetting = (MS_U32*)&value;
7042     ioctl_info.u32Size  = sizeof(MS_U32);
7043 
7044     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
7045     {
7046         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
7047         GOP_RETURN( GOP_API_FAIL);
7048     }
7049 
7050     GOP_RETURN(GOP_API_SUCCESS);
7051 }
7052 
7053 //******************************************************************************
7054 /// API for set GWIN 3D Mode
7055 /// @param u8GwinId \b IN: GWin ID
7056 /// @param u16MainFBId \b IN: Main-Frame Buffer ID
7057 /// @param u16SubFBId \b IN: Sub-Frame Buffer ID
7058 /// @param EN_3DOSD_Mode \b IN: 3D Osd mode select.
7059 /// @return GOP_API_SUCCESS - Success
7060 //******************************************************************************
7061 
MApi_GOP_Set3DOSDMode(MS_U8 u8Gwin,MS_U16 u16MainFBId,MS_U16 u16SubFBId,EN_GOP_3D_MODETYPE en3DMode)7062 E_GOP_API_Result MApi_GOP_Set3DOSDMode(MS_U8 u8Gwin, MS_U16 u16MainFBId, MS_U16 u16SubFBId,EN_GOP_3D_MODETYPE en3DMode)
7063 {
7064     GOP_GWIN_PROPERTY_PARAM ioctl_info;
7065     GOP_GWIN_3D_MODE st3DMode;
7066 
7067     GOP_ENTRY();
7068 
7069     st3DMode.u32MainFBId = u16MainFBId;
7070     st3DMode.u32SubFBId = u16SubFBId;
7071     st3DMode.en3DMode = en3DMode;
7072 
7073     ioctl_info.en_property = E_GOP_GWIN_3D_MODE;
7074     ioctl_info.GwinId = u8Gwin;
7075     ioctl_info.pSet = (MS_U32*)&st3DMode;
7076     ioctl_info.u32Size = sizeof(GOP_GWIN_3D_MODE);
7077 
7078     if (UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GWIN_SET_PROPERTY,(void*)&ioctl_info) != UTOPIA_STATUS_SUCCESS)
7079     {
7080         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
7081         GOP_RETURN(GOP_API_FAIL);
7082     }
7083 
7084     GOP_RETURN(GOP_API_SUCCESS);
7085 }
7086 
7087 //******************************************************************************
7088 /// API for notify kernel about 3D gpio pin
7089 /// @param u32GPIO3DPin \b IN: GPIO 3D pin
7090 /// @return GOP_API_SUCCESS - Success
7091 //******************************************************************************
MApi_GOP_Set_GPIO3DPin(MS_U32 u32GPIO3DPin)7092 E_GOP_API_Result MApi_GOP_Set_GPIO3DPin(MS_U32 u32GPIO3DPin)
7093 {
7094     GOP_ERR("[%s] Not SUPPORT in utopia2\n",__FUNCTION__);
7095 
7096     return GOP_API_FAIL;
7097 }
7098 
7099 //******************************************************************************
7100 /// API for Clear GOP GWIN FlipQueue
7101 /// @param u8GwinId \b IN: GWin ID
7102 /// @return GOP_API_SUCCESS - Success
7103 //******************************************************************************
MApi_GOP_GWIN_ClearFlipQueue(MS_U8 gWinId)7104 E_GOP_API_Result MApi_GOP_GWIN_ClearFlipQueue(MS_U8 gWinId)
7105 {
7106     GOP_ENTRY();
7107 
7108     GOP_GWIN_CLEARQUEUE_PARAM ioctl_info;
7109     GOP_GWIN_CLEARQUEUE_INFO flipQinfo;
7110 
7111     memset(&ioctl_info, 0x0, sizeof(GOP_GWIN_CLEARQUEUE_PARAM));
7112     memset(&flipQinfo, 0x0, sizeof(GOP_GWIN_CLEARQUEUE_INFO));
7113 
7114     flipQinfo.GwinId = gWinId;
7115 
7116     ioctl_info.pClearInfo = (MS_U32*)&flipQinfo;
7117     ioctl_info.u32Size = sizeof(GOP_GWIN_CLEARQUEUE_INFO);
7118 
7119 
7120     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GFLIP_CLEARQUEUE,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
7121     {
7122         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
7123         GOP_RETURN( GOP_API_FAIL);
7124     }
7125 
7126     GOP_RETURN( GOP_API_SUCCESS);
7127 
7128 }
7129 
7130 
7131 //******************************************************************************
7132 /// API for Query GOP Capability
7133 /// @param eCapType \b IN: Capability type
7134 /// @param pRet     \b OUT: return value
7135 /// @param ret_size \b IN: input structure size
7136 /// @return GOP_API_SUCCESS - Success
7137 //******************************************************************************
MApi_GOP_GetChipCaps(EN_GOP_CAPS eCapType,void * pRet,MS_U32 ret_size)7138 E_GOP_API_Result MApi_GOP_GetChipCaps(EN_GOP_CAPS eCapType, void* pRet, MS_U32 ret_size)
7139 {
7140     CheckGOPInstanceOpen();
7141     if(eCapType == E_GOP_CAP_VERSION)
7142     {
7143         char ver[] = MSIF_GOP_LIBVER;
7144         char blnum[] = MSIF_GOP_BUILDNUM;
7145         char cl[] = MSIF_GOP_CHANGELIST;
7146         GOP_LIB_VER * pLibVer;
7147 
7148         if(ret_size != sizeof(GOP_LIB_VER))
7149         {
7150             GOP_ERR("[%s] [%d]ERROR, invalid input structure size :0x%tx on E_GOP_CAP_VERSION\n",__FUNCTION__,__LINE__,(ptrdiff_t)ret_size);
7151             return GOP_API_FAIL;
7152         }
7153 
7154         pLibVer = (GOP_LIB_VER *)pRet;
7155 
7156         pLibVer->GOP_LibVer = atoi(ver);
7157         pLibVer->GOP_BuildNum = atoi(blnum);
7158         pLibVer->GOP_ChangeList = atoi(cl);
7159 
7160     }
7161     else if (eCapType == E_GOP_CAP_WORD_UNIT)
7162     {
7163         GOP_GETCAPS_PARAM gopcaps;
7164         MS_U16 u16Align = 0x0;
7165 
7166         memset(&gopcaps, 0x0, sizeof(GOP_GETCAPS_PARAM));
7167 
7168         gopcaps.caps = eCapType;
7169         gopcaps.pInfo = &u16Align;
7170         gopcaps.u32Size = sizeof(u16Align);
7171 
7172         if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GET_CHIPCAPS,&gopcaps)!= UTOPIA_STATUS_SUCCESS)
7173         {
7174             GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
7175             return GOP_API_FAIL;
7176         }
7177 
7178         if (ret_size == sizeof(MS_U8))
7179         {
7180             *((MS_U8 *)pRet) = (MS_U8)u16Align;
7181         }
7182         if (ret_size == sizeof(MS_U16))
7183         {
7184             *((MS_U16 *)pRet) = u16Align;
7185         }
7186         else if (ret_size == sizeof(MS_U32))
7187         {
7188             *((MS_U32 *)pRet) = (MS_U32)u16Align;
7189         }
7190     }
7191     else if (eCapType == E_GOP_CAP_GOP_MUX)
7192     {
7193         GOP_GETCAPS_PARAM gopcaps;
7194         PST_GOP_MUX_CAP pstDrvMuxCap = (PST_GOP_MUX_CAP)pRet;
7195         ST_DRV_GOP_MUX_CAP_EX stDrvMuxCapEx;
7196         MS_U8 u8num = 0;
7197         memset(&gopcaps, 0x0, sizeof(GOP_GETCAPS_PARAM));
7198         memset(&stDrvMuxCapEx, 0x0, sizeof(ST_DRV_GOP_MUX_CAP_EX));
7199 
7200         stDrvMuxCapEx.u8MuxNumber=pstDrvMuxCap->u8MuxNumber;
7201         for(u8num=0;u8num<pstDrvMuxCap->u8MuxNumber;u8num++)
7202         {
7203             stDrvMuxCapEx.pu8MuxProrityArray[u8num]=pstDrvMuxCap->pu8MuxProrityArray[u8num];
7204         }
7205         stDrvMuxCapEx.bNewMux = pstDrvMuxCap->bNewMux;
7206         stDrvMuxCapEx.bNeedSetMUX1ToIP0 = pstDrvMuxCap->bNeedSetMUX1ToIP0;
7207         stDrvMuxCapEx.bNeedSetMUX3ToIP0 = pstDrvMuxCap->bNeedSetMUX3ToIP0;
7208 
7209         gopcaps.caps = eCapType;
7210         gopcaps.pInfo = (MS_U32*)&stDrvMuxCapEx;
7211         gopcaps.u32Size = sizeof(ST_DRV_GOP_MUX_CAP_EX);;
7212 
7213         if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GET_CHIPCAPS,&gopcaps)!= UTOPIA_STATUS_SUCCESS)
7214         {
7215             printf("Ioctl %s fail\n",__FUNCTION__);
7216             GOP_RETURN(GOP_API_FAIL);
7217         }
7218         pstDrvMuxCap->u8MuxNumber=stDrvMuxCapEx.u8MuxNumber;
7219         for(u8num=0;u8num<stDrvMuxCapEx.u8MuxNumber;u8num++)
7220         {
7221             pstDrvMuxCap->pu8MuxProrityArray[u8num]=stDrvMuxCapEx.pu8MuxProrityArray[u8num];
7222         }
7223         pstDrvMuxCap->bNewMux = stDrvMuxCapEx.bNewMux;
7224         pstDrvMuxCap->bNeedSetMUX1ToIP0 = stDrvMuxCapEx.bNeedSetMUX1ToIP0;
7225         pstDrvMuxCap->bNeedSetMUX3ToIP0 = stDrvMuxCapEx.bNeedSetMUX3ToIP0;
7226     }
7227     else
7228     {
7229         GOP_GETCAPS_PARAM gopcaps;
7230 
7231         memset(&gopcaps, 0x0, sizeof(GOP_GETCAPS_PARAM));
7232 
7233         gopcaps.caps = eCapType;
7234         gopcaps.pInfo = pRet;
7235         gopcaps.u32Size = ret_size;
7236 
7237         if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GET_CHIPCAPS,&gopcaps)!= UTOPIA_STATUS_SUCCESS)
7238         {
7239             GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
7240             return GOP_API_FAIL;
7241         }
7242     }
7243     return GOP_API_SUCCESS;
7244 }
7245 
7246 //******************************************************************************
7247 /// API for Set Scroll rate for Gwin
7248 /// @param winId \b IN: GWIN id
7249 /// @param bEnable \b IN:
7250 ///   - # TRUE Enable Tile Mode for GWIN
7251 ///   - # FALSE Disable Tile Mode for GWIN
7252 /// @return GOP_API_SUCCESS - Success
7253 /// @return GOP_API_FAIL - Failure
7254 
7255 //******************************************************************************
MApi_GOP_GWIN_SetScrollRate(MS_U8 u8rate)7256 E_GOP_API_Result MApi_GOP_GWIN_SetScrollRate(MS_U8 u8rate)
7257 {
7258     GOP_ENTRY();
7259     GOP_SCROLL_PARAM ioctl_info;
7260     MS_U8 u8ScrollRate;
7261 
7262     u8ScrollRate = u8rate;
7263     ioctl_info.scroll_type = E_GOP_SCROLL_RATE;
7264     ioctl_info.pCfg = (void*)&u8ScrollRate;
7265     ioctl_info.u32Size  = sizeof(MS_U8);
7266 
7267     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_SCROLL,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
7268     {
7269         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
7270         GOP_RETURN( GOP_API_FAIL);
7271     }
7272 
7273     GOP_RETURN(GOP_API_SUCCESS);
7274 
7275 }
7276 
MApi_GOP_GWIN_SetScrollType(MS_U8 u8WinId,GOP_SCROLL_TYPE type,MS_U16 u16Offset,MS_BOOL bEnable)7277 E_GOP_API_Result MApi_GOP_GWIN_SetScrollType(MS_U8 u8WinId, GOP_SCROLL_TYPE type,  MS_U16 u16Offset, MS_BOOL bEnable )
7278 {
7279     GOP_ENTRY();
7280     GOP_SCROLL_PARAM ioctl_info;
7281     GOP_SCROLL_INFO scroll_info;
7282 
7283     scroll_info.u8WinId = u8WinId;
7284     scroll_info.type = type;
7285     scroll_info.u16Offset = u16Offset;
7286     scroll_info.bEnable = bEnable;
7287 
7288     ioctl_info.scroll_type = E_GOP_SCROLL_CONFIG;
7289     ioctl_info.pCfg = (MS_U32*)&scroll_info;
7290     ioctl_info.u32Size  = sizeof(GOP_SCROLL_INFO);
7291 
7292     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_SET_SCROLL,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
7293     {
7294         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
7295         GOP_RETURN( GOP_API_FAIL);
7296     }
7297 
7298     GOP_RETURN(GOP_API_SUCCESS);
7299 }
7300 
7301 
MApi_GOP_GWIN_SetSWScrollBuffer(MS_U16 bufNum,MS_U32 * pBuffer)7302 E_GOP_API_Result MApi_GOP_GWIN_SetSWScrollBuffer(MS_U16 bufNum, MS_U32* pBuffer)
7303 {
7304     GOP_ENTRY();
7305     GOP_ERR("[%s] Not SUPPORT in utopia2\n",__FUNCTION__);
7306     GOP_RETURN(GOP_API_SUCCESS);
7307 
7308 
7309 }
7310 
7311 /******************************************************************************/
7312 /// Map FBinfo to OCinfo
7313 /// @param u32Addr\b IN Bank Start Addr
7314 /// @param BankMode\b IN Bank Mode
7315 /// @param enBufSize\b IN Bank Sizee
7316 /******************************************************************************/
MApi_GOP_OC_SetOCFBinfo(MS_PHY phyAddr,EN_GOP_OC_SEL_TYPE BankMode,MS_U32 enBufSize)7317 E_GOP_API_Result MApi_GOP_OC_SetOCFBinfo(MS_PHY phyAddr, EN_GOP_OC_SEL_TYPE BankMode, MS_U32 enBufSize)
7318 {
7319     GOP_MISC_PARAM ioctl_info;
7320     GOP_OC_FB_INFO stOCFbInfo;
7321 
7322     GOP_ENTRY();
7323 
7324     stOCFbInfo.u64Addr = phyAddr;
7325     stOCFbInfo.BankMode = BankMode;
7326     stOCFbInfo.enBufSize = enBufSize;
7327 
7328     ioctl_info.misc_type = E_GOP_MISC_OC_FB_INFO;
7329     ioctl_info.pMISC = (MS_U32*)&stOCFbInfo;
7330     ioctl_info.u32Size  = sizeof(GOP_OC_FB_INFO);
7331 
7332     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_MISC,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
7333     {
7334         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
7335         GOP_RETURN( GOP_API_FAIL);
7336     }
7337 
7338     GOP_RETURN(GOP_API_SUCCESS);
7339 }
7340 
7341 
7342 //******************************************************************************
7343 /// API for Test Pattern Type Select
7344 /// @param eTstPatternType \b IN: Test Pattern Type
7345 /// @param MS_U32 u32ARGB  \b IN: ARGB Color
7346 /// @return GOP_API_SUCCESS - Success
7347 /// @return GOP_API_FAIL - Failure
7348 //******************************************************************************
MApi_GOP_TestPatternAlpha_Enable(MS_BOOL bTSTAlpha)7349 E_GOP_API_Result MApi_GOP_TestPatternAlpha_Enable(MS_BOOL bTSTAlpha)
7350 {
7351     GOP_MISC_PARAM ioctl_info;
7352     MS_BOOL  bEna;
7353 
7354     GOP_ENTRY();
7355 
7356     bEna = bTSTAlpha;
7357     ioctl_info.misc_type = E_GOP_MISC_TESTPATTERN_ALPHA;
7358     ioctl_info.pMISC = (void*)&bEna;
7359     ioctl_info.u32Size  = sizeof(MS_BOOL);
7360 
7361     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_MISC,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
7362     {
7363         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
7364         GOP_RETURN( GOP_API_FAIL);
7365     }
7366 
7367     GOP_RETURN(GOP_API_SUCCESS);
7368 
7369 }
7370 
MApi_GOP_IsRegUpdated(MS_U8 u8GopType)7371 E_GOP_API_Result MApi_GOP_IsRegUpdated(MS_U8 u8GopType)
7372 {
7373     MS_BOOL bUpdate = FALSE;
7374     GOP_SET_PROPERTY_PARAM ioctl_info;
7375 
7376     GOP_ENTRY();
7377     memset(&ioctl_info, 0x0, sizeof(GOP_SET_PROPERTY_PARAM));
7378 
7379     ioctl_info.en_pro   = E_GOP_REG_UPDATED;
7380     ioctl_info.gop_idx  = u8GopType;
7381     ioctl_info.pSetting = (void*)&bUpdate;
7382     ioctl_info.u32Size  = sizeof(MS_BOOL);
7383 
7384     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_GET_PROPERTY,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
7385     {
7386         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
7387         GOP_RETURN((E_GOP_API_Result)bUpdate);
7388     }
7389     GOP_RETURN((E_GOP_API_Result)bUpdate);
7390 
7391 }
7392 
MApi_GOP_TestPattern(EN_GOP_TST_PATTERN eTstPatternType,MS_U32 u32ARGB)7393 E_GOP_API_Result MApi_GOP_TestPattern(EN_GOP_TST_PATTERN eTstPatternType, MS_U32 u32ARGB)
7394 {
7395     GOP_TEST_PATTERN_PARAM TestPatternPar;
7396 
7397     GOP_ENTRY();
7398 
7399     memset(&TestPatternPar,0x0,sizeof(GOP_TEST_PATTERN_PARAM));
7400 
7401     TestPatternPar.gop_idx = 0x0;
7402     TestPatternPar.TestPatternType = eTstPatternType;
7403     TestPatternPar.u32ARGB = u32ARGB;
7404     TestPatternPar.u32Size = sizeof(GOP_TEST_PATTERN_PARAM);
7405 
7406     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_TESTPATTERN,&TestPatternPar)!= UTOPIA_STATUS_SUCCESS)
7407     {
7408         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
7409         GOP_RETURN(GOP_API_FAIL);
7410     }
7411 
7412     GOP_RETURN(GOP_API_SUCCESS);
7413 
7414 }
7415 
7416 /******************************************************************************/
7417 /// set GOP power state
7418 /// @param enPowerState\b IN power status
7419 /******************************************************************************/
MApi_GOP_SetPowerState(EN_POWER_MODE enPowerState)7420 E_GOP_API_Result MApi_GOP_SetPowerState(EN_POWER_MODE enPowerState)
7421 {
7422 
7423     CheckGOPInstanceOpen();
7424     GOP_ENTRY();
7425     _GOP_RegisterAllCBFunc();
7426     GOP_POWERSTATE_PARAM PowerState;
7427 
7428     memset(&PowerState,0x0,sizeof(GOP_POWERSTATE_PARAM));
7429     PowerState.pInfo = &enPowerState;
7430     PowerState.u32Size = sizeof(GOP_POWERSTATE_PARAM);
7431 
7432     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_POWERSTATE,&PowerState)!= UTOPIA_STATUS_SUCCESS)
7433             {
7434         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
7435         GOP_RETURN(GOP_API_FAIL);
7436     }
7437     GOP_RETURN(GOP_API_SUCCESS);
7438 }
7439 
MApi_GOP_GWIN_BeginDraw(void)7440 E_GOP_API_Result MApi_GOP_GWIN_BeginDraw(void)
7441 {
7442     GOP_MUTEX_PARAM stMutexPara;
7443 
7444     GOP_ENTRY();
7445 
7446     memset(&stMutexPara,0x0,sizeof(GOP_MUTEX_PARAM));
7447     stMutexPara.en_mutex = E_GOP_LOCK;
7448     stMutexPara.u32Size = sizeof(GOP_MUTEX_PARAM);
7449 
7450     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_MUTEX,&stMutexPara)!= UTOPIA_STATUS_SUCCESS)
7451     {
7452         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
7453         GOP_RETURN(GOP_API_FAIL);
7454     }
7455 
7456     GOP_RETURN(GOP_API_SUCCESS);
7457 
7458 }
7459 
MApi_GOP_GWIN_EndDraw(void)7460 E_GOP_API_Result MApi_GOP_GWIN_EndDraw(void)
7461 {
7462     GOP_MUTEX_PARAM stMutexPara;
7463 
7464     GOP_ENTRY();
7465 
7466     memset(&stMutexPara,0x0,sizeof(GOP_MUTEX_PARAM));
7467     stMutexPara.en_mutex = E_GOP_UNLOCK;
7468     stMutexPara.u32Size = sizeof(GOP_MUTEX_PARAM);
7469 
7470     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_MUTEX,&stMutexPara)!= UTOPIA_STATUS_SUCCESS)
7471     {
7472         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
7473         GOP_RETURN(GOP_API_FAIL);
7474     }
7475 
7476     GOP_RETURN(GOP_API_SUCCESS);
7477 }
7478 
7479 /******************************************************************************/
7480 /// API for GOP delete upexpect H/V win size for output
7481 /// @param MS_U8 u8GOP\b IN: GOP ID
7482 /// @param MS_U32 u32ARGB  \b IN: ARGB Color
7483 /// @return GOP_API_SUCCESS - Success
7484 /// @return GOP_API_FAIL - Failure
7485 /******************************************************************************/
MApi_GOP_GWIN_DeleteWinHVSize(MS_U8 u8GOP,MS_U16 u16HSize,MS_U16 u16VSize)7486 E_GOP_API_Result MApi_GOP_GWIN_DeleteWinHVSize(MS_U8 u8GOP, MS_U16 u16HSize, MS_U16 u16VSize)
7487 {
7488     GOP_MISC_PARAM ioctl_info;
7489     GOP_DeleteWinSize_PARAM GOP_VaildSize;
7490 
7491     GOP_ENTRY();
7492     memset(&ioctl_info,0x0,sizeof(GOP_MISC_PARAM));
7493     memset(&GOP_VaildSize,0x0,sizeof(GOP_DeleteWinSize_PARAM));
7494 
7495     GOP_VaildSize.u32GOP_idx = u8GOP;
7496     GOP_VaildSize.u32HSize = (MS_U32)u16HSize;
7497     GOP_VaildSize.u32VSize = (MS_U32)u16VSize;
7498 
7499     ioctl_info.misc_type = E_GOP_MISC_DELETE_GWINSIZE;
7500     ioctl_info.pMISC = (MS_U32*)&GOP_VaildSize;
7501     ioctl_info.u32Size  = sizeof(GOP_DeleteWinSize_PARAM);
7502 
7503     if(UtopiaIoctl(pInstantGOP,MAPI_CMD_GOP_MISC,&ioctl_info)!= UTOPIA_STATUS_SUCCESS)
7504     {
7505         GOP_ERR("Ioctl %s fail\n",__FUNCTION__);
7506         GOP_RETURN( GOP_API_FAIL);
7507     }
7508 
7509     GOP_RETURN(GOP_API_SUCCESS);
7510 }
7511 
7512 #undef MApi_GOP_C
7513