xref: /utopia/UTPA2-700.0.x/modules/dms/api/dms/apiDMS_private.h (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 #ifndef _DMS_PRIV_H_
95 #define _DMS_PRIV_H_
96 #include "UFO.h"
97 ////////////////////////////////////////////////////////////////////////////////
98 /// @file drvDMS.h
99 /// @author MStar Semiconductor Inc.
100 /// @brief DMS control driver
101 ////////////////////////////////////////////////////////////////////////////////
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 // Header Files
105 ////////////////////////////////////////////////////////////////////////////////
106 #ifdef __cplusplus
107 extern "C"
108 {
109 #endif
110 
111 typedef EN_DMS_RESULT                    (*IOCTL_DMS_INIT)                    (void*, ST_DMS_INITDATA*);
112 typedef EN_DMS_RESULT                    (*IOCTL_DMS_SETMEMTYPE)            (void*, ST_DMS_SET_MEMORY_TYPE*);
113 typedef EN_DMS_RESULT                    (*IOCTL_DMS_CREATEWINDOW)          (void*, ST_DMS_WINDOW*, ST_DMS_CREATE_WIN_INFO*, MS_U32*);
114 typedef EN_DMS_RESULT                    (*IOCTL_DMS_SETDIGIDECINFO)       (void*, MS_U32, ST_DMS_DISPFRAMEFORMAT*);
115 typedef EN_DMS_RESULT                    (*IOCTL_DMS_CLEARDIGIDECINFO)    (void*, MS_U32);
116 typedef EN_DMS_RESULT                    (*IOCTL_DMS_DESTORYWINDOW)        (void*, MS_U32);
117 typedef EN_DMS_RESULT                    (*IOCTL_DMS_SETWINDOW)             (void*, MS_U32, ST_DMS_SETWIN_INFO*);
118 typedef EN_DMS_RESULT                    (*IOCTL_DMS_GETWINDOWINFO)        (void*, MS_U32, ST_DMS_WINDOW_INFO*);
119 typedef EN_DMS_RESULT                    (*IOCTL_DMS_VIDEOFLIP)             (void*, MS_U32, ST_DMS_DISPFRAMEFORMAT*);
120 typedef EN_DMS_RESULT                    (*IOCTL_DMS_SETZORDER)             (void*, MS_U32, ST_DMS_ZORDER_INFO*);
121 typedef EN_DMS_RESULT                    (*IOCTL_DMS_VIDEOMUTE)             (void*, MS_U32, ST_DMS_MUTE_WINDOW_INFO*);
122 typedef EN_DMS_RESULT                    (*IOCTL_DMS_SETMUTECOLOR)         (void*, MS_U32, ST_DMS_MUTE_COLOR_INFO*);
123 typedef EN_DMS_RESULT                    (*IOCTL_DMS_VIDEOFREEZE)          (void*, MS_U32, ST_DMS_FREEZE_WINDOW_INFO*);
124 typedef EN_DMS_RESULT                    (*IOCTL_DMS_GETSTATUS)             (void*, EN_DMS_STATUS*);
125 typedef EN_DMS_RESULT                    (*IOCTL_DMS_GETCAPS)               (void*, EN_DMS_CAPABILITY*);
126 typedef EN_DMS_RESULT                    (*IOCTL_DMS_GETEXISTWIN)          (void*, MS_U32*);
127 typedef EN_DMS_RESULT                    (*IOCTL_DMS_SETOUTPUTLAYER)      (void*, ST_DMS_WINDOW*);
128 typedef EN_DMS_RESULT                    (*IOCTL_DMS_SET3DMODE)             (void*, MS_U32, ST_DMS_3D_INFO*);
129 typedef EN_DMS_RESULT                    (*IOCTL_DMS_SETCAPTUREINFO)      (void*, MS_U32, ST_DMS_SET_CAPTURE_INFO*);
130 typedef EN_DMS_RESULT                    (*IOCTL_DMS_GETCAPTUREBUF)        (void*, MS_U32, ST_DMS_CAPTURE_INFO*);
131 typedef EN_DMS_RESULT                    (*IOCTL_DMS_RELEASECAPTUREBUF)   (void*, MS_U32, ST_DMS_CAPTURE_INFO*);
132 
133 typedef enum
134 {
135     E_DMS_POOL_ID_INTERNAL_VARIABLE = 0,
136     E_DMS_POOL_ID_MAX,
137 } E_DMS_POOL_ID;
138 
139 typedef struct
140 {
141     MS_PHY phyDSAddr;
142     MS_U8 u8DSIndex;
143     DMS_DS_SWDB stDMS_DSSWDB;
144 } ST_HAL_DMS;
145 
146 typedef struct
147 {
148 #ifdef DMS_VERSION_DIPGOP
149     DMS_DIPMEM_INFO _stXC_DIPMemInfo[E_DMS_DIP_CLIENT_MAX];
150     DMS_DIPWIN_INFO _stXC_DIPWinInfo[DMS_MAX_WINDOW_NUM];
151     DMS_DIPWIN_INFO _stXC_DIPWinInfo_MVOPDoubleBuffer;
152     ST_DMS_WINDOW _stXC_PreDispWinInfo[DMS_MAX_WINDOW_NUM];
153     DMS_DISP_BUFFER_FLAG _stXC_DispBuf_Flag[E_DMS_DIP_MULTIVIEW_BUF_ID_MAX][DMS_MAX_WINDOW_NUM];
154 
155     DMS_DIPWriteReadPointer _stXC_DIPWriteReadPointer[DMS_MAX_WINDOW_NUM];
156     MS_U32 u32MaxOutputFrameRate;
157     MS_U32 u32VsyncCount;
158     MS_U32 u32GOPDispCount;
159     MS_U8 u8DIPReadytoCaptureID[DMS_MAX_WINDOW_NUM];
160     MS_U8 u8DIP_Window[E_DMS_DIP_MAX];
161 
162     MS_PHY u32DIPAddress_pa[E_DMS_DIP_CLIENT_MAX];
163     MS_PHY u32GEAddress_pa;
164     MS_U8 u8GOPGWinNum;
165     MS_BOOL bIsGOPInit;
166     MS_BOOL bDIPWriteFirstAddr;
167     MS_BOOL bDIPMVOPWriteFirstAddr;
168     MS_U32 u32WindowFrameRate[DMS_MAX_WINDOW_NUM];
169     MS_U8 u8EnableWindowCount;
170     MS_U8 u8UseDIPWindowCount;
171     MS_BOOL bNeedGEstretch;
172 
173     E_DMS_MVOP_FLOW_CONTROL eDMS_MVOPFlowCtrl;
174     MS_BOOL bDMS_MVOPFlowFromDi;
175     E_DMS_MVOP_FLOW_CONTROL eDMS_PreMVOPFlowCtrl;
176     MS_U8 gDMS_MVOPShowBufferID;
177     MS_U8 gDMS_MVOPRemoveBufferID;
178     MS_BOOL bMVOPMarkRemoveBuffer;
179     MS_BOOL bIsWindowMute[DMS_MAX_WINDOW_NUM];
180 
181     MS_U32 gDMS_ScalingCondition;
182     MS_U32 gu8DMS_SetXC_Status[DMS_MAX_WINDOW_NUM];
183     MS_U8 gu8DMS_Seq_Change_ID;
184     ST_DMS_WINDOW _stXC_XCDispWinInfo;
185     ST_DMS_WINDOW _stXC_XCCropWinInfo;
186     ST_DMS_WINDOW _stXC_XCDispWinInfo_DoubleBuffer;
187     ST_DMS_WINDOW _stXC_XCCropWinInfo_DoubleBuffer;
188 
189     // For DS regen crop
190     ST_DMS_WINDOW _stXC_XCCropWinInfo_raw;
191     MS_U16 u16FirstSrcWidth;
192     MS_U16 u16FirstSrcHeight;
193 
194     MS_PHY u32MVOPFreezeAddress_pa;
195     MS_BOOL bDMS_Freeze_DoubleBuffer;
196     MS_BOOL _bForceSwitchBufferFlag;
197 
198     MS_U32 u32OutputRate;
199     MS_U32 bStartCountFRC[DMS_MAX_WINDOW_NUM];
200     MS_U32 u32AccumuleInputRate[DMS_MAX_WINDOW_NUM];
201 #endif
202 
203     DMS_VDECFRAME_INFO _stXC_DIPPushInfo[DMS_MAX_WINDOW_NUM][DMS_DIP_QUEUEDEPTH];
204     MS_U8 _stXC_LocalFrameRefCount[DMS_MAX_WINDOW_NUM][DMS_DIP_QUEUEDEPTH];
205     MS_U8 WindowZOrder[DMS_MAX_WINDOW_NUM];
206     MS_U8 WindowScore[DMS_MAX_WINDOW_NUM];
207     ST_DMS_WINDOW stOutputLayer;
208 
209 #ifdef DMS_VERSION_VSYNCBRDIGE
210     // vsyncbridge
211     MS_PHY phyVsyncbridgeAddr[DMS_MAX_WINDOW_NUM];
212     MS_PHY phyVsyncbridgeExtAddr[DMS_MAX_WINDOW_NUM];
213     MS_U8 u8MirrorMode;
214     MS_BOOL bWinChanged[DMS_MAX_WINDOW_NUM];
215     MS_BOOL bWinUsed[DMS_MAX_WINDOW_NUM];
216     MS_BOOL bWindowInfoReady[DMS_MAX_WINDOW_NUM];
217     ST_DMS_OUTPUT_WIN_INFO stOutputWinInfo[DMS_MAX_WINDOW_NUM];
218     ST_DMS_WINDOW stDisplayWin[DMS_MAX_WINDOW_NUM];
219 #endif
220 #ifdef DMS_VERSION_DIPGOP
221     // For mvop release
222     MS_U32  u32ReleaseState[DMS_DIP_QUEUEDEPTH];
223     MS_BOOL bFirstPlay;
224     MS_BOOL bDisableBlackScreen;
225     MS_U32 u32MuteCounter;
226     MS_BOOL bXCEnableBob;
227 #endif
228 } ST_DRV_DMS;
229 
230 #ifdef DMS_VERSION_DIPGOP
231 typedef struct
232 {
233     DMS_VDECFRAME_INFO _stXC_DIPDIInfo[DMS_MAX_WINDOW_NUM][DMS_DIP_QUEUEDEPTH];
234     DMS_DIPWriteReadPointer _stXC_DIPWriteReadPointerInterlace[DMS_MAX_WINDOW_NUM];
235     MS_U8 _u8DMS_DiSetEventBufferID;
236     MS_U8 _u8DMS_DiReleaseVDECFrameBufferID;
237     MS_U8 u8DIPReadytoCaptureIDInterlace[DMS_MAX_WINDOW_NUM];
238     MS_U8 _stXC_LocalFrameRefCountInterlace[DMS_MAX_WINDOW_NUM][DMS_DIP_QUEUEDEPTH];
239     MS_U8 u8DIRingBufferID;
240     MS_U8 _bDiNowShowRingBufID;
241     MS_U8 _bDiReleaseShowRingBufID;
242     MS_BOOL _bSetwinToDiTask_DoubleBuffer;
243 
244     MS_PHY u32DIPDIAddress_pa;
245     MS_BOOL bFlipToDiTask;               //For set event can not use, temp solution for push di task
246 } ST_DRV_DMS_DI;
247 
248 typedef struct
249 {
250     DMS_DIPCAPTUREWIN_INFO _stXC_DIPCaptureWinInfo[DMS_MAX_WINDOW_NUM];
251     DMS_DIPWriteReadPointer _stXC_DIPCapWin_WriteReadPointer[DMS_MAX_WINDOW_NUM];
252     DMS_DIPCaptureWin_WritePointer _stXC_DIPCaptureWin_RingBufferPointer[DMS_MAX_WINDOW_NUM];
253     MS_U8 _stXC_CaptureRingBufRefCount[DMS_MAX_WINDOW_NUM][DMS_CAPTUREWIN_RING_BUFFER];
254     MS_U8 _stXC_LocalFrameRefCountCaptureMode[DMS_MAX_WINDOW_NUM][DMS_DIP_QUEUEDEPTH];
255     MS_U8 u8CapturedWinNum;
256     MS_U8 u8frameRepeatCnt[DMS_MAX_WINDOW_NUM][DMS_DIP_QUEUEDEPTH];
257     MS_U32 bIsFrameValid[DMS_MAX_WINDOW_NUM][DMS_DIP_QUEUEDEPTH];
258     MS_U32 bIsRingBufAccessed[DMS_CAPTUREWIN_RING_BUFFER];
259 #if DMS_DIP_Support_IMI
260     DMS_DIPCAPTURE_IMI_INFO _stXC_IMICaptureInfo[DMS_MAX_WINDOW_NUM];
261 #endif
262 } ST_DRV_DMS_CAPTUREMODE;
263 
264 #endif
265 
266 typedef struct __attribute__((__packed__))
267 {
268     // flow control related
269     MS_BOOL bResourceRegistered;
270     MS_BOOL bDrvInit;
271     ST_HAL_DMS stHalDMS;
272     ST_DRV_DMS stDrvDMS;
273     #ifdef DMS_VERSION_DIPGOP
274     ST_DRV_DMS_DI stDrvDMSDi;
275     ST_DRV_DMS_CAPTUREMODE stDrvDMSCapMode;
276     #endif
277 } DMS_RESOURCE_PRIVATE;
278 
279 typedef struct _DAC_INSTANT_PRIVATE
280 {
281     IOCTL_DMS_INIT                  fpDMSInit;
282     IOCTL_DMS_SETMEMTYPE            fpDMSSetMemType;
283     IOCTL_DMS_CREATEWINDOW          fpDMSCreateWin;
284     IOCTL_DMS_SETDIGIDECINFO        fpDMSSetDigiDecInfo;
285     IOCTL_DMS_CLEARDIGIDECINFO      fpDMSClearDigiDecInfo;
286     IOCTL_DMS_DESTORYWINDOW         fpDMSDestoryWin;
287     IOCTL_DMS_SETWINDOW             fpDMSSetWin;
288     IOCTL_DMS_GETWINDOWINFO         fpDMSGetWinInfo;
289     IOCTL_DMS_VIDEOFLIP             fpDMSFlip;
290     IOCTL_DMS_SETZORDER             fpDMSZOrder;
291     IOCTL_DMS_VIDEOMUTE             fpDMSMute;
292     IOCTL_DMS_SETMUTECOLOR          fpDMSSetMuteColor;
293     IOCTL_DMS_VIDEOFREEZE           fpDMSFreeze;
294     IOCTL_DMS_GETSTATUS             fpDMSGetStatus;
295     IOCTL_DMS_GETCAPS               fpDMSGetCaps;
296     IOCTL_DMS_GETEXISTWIN           fpDMSGetExistWin;
297     IOCTL_DMS_SETOUTPUTLAYER        fpDMSSetOutputLayer;
298     IOCTL_DMS_SET3DMODE             fpDMSSet3DMode;
299     IOCTL_DMS_SETCAPTUREINFO        fpDMSSetCaptureInfo;
300     IOCTL_DMS_GETCAPTUREBUF         fpDMSGetCaptureBuf;
301     IOCTL_DMS_RELEASECAPTUREBUF     fpDMSReleaseCaptureBuf;
302 }DMS_INSTANT_PRIVATE;
303 
304 EN_DMS_RESULT MApi_DMS_Init_U2(void* pInstance, ST_DMS_INITDATA *pstDMS_InitData);
305 EN_DMS_RESULT MApi_DMS_SetMemory_U2(void* pInstance, ST_DMS_SET_MEMORY_TYPE *pstDMS_SetMemType);
306 EN_DMS_RESULT MApi_DMS_CreateWindow_U2(void* pInstance, ST_DMS_WINDOW *pstOutputWin, ST_DMS_CREATE_WIN_INFO *pstCreateWin_Info, MS_U32 *pu32WindowID);
307 EN_DMS_RESULT MApi_DMS_SetDigitalDecodeSignalInfo_U2(void* pInstance, MS_U32 u32WindowID, ST_DMS_DISPFRAMEFORMAT *pstDispFrameFormat);
308 EN_DMS_RESULT MApi_DMS_ClearDigitalDecodeSignalInfo_U2(void* pInstance, MS_U32 u32WindowID);
309 EN_DMS_RESULT MApi_DMS_DestroyWindow_U2(void* pInstance, MS_U32 u32WindowID);
310 EN_DMS_RESULT MApi_DMS_SetWindow_U2(void* pInstance, MS_U32 u32WindowID, ST_DMS_SETWIN_INFO *pstDMS_SetWin_Info);
311 EN_DMS_RESULT MApi_DMS_GetWindowInfo_U2(void* pInstance, MS_U32 u32WindowID, ST_DMS_WINDOW_INFO *pstDMS_GetWin_Info);
312 EN_DMS_RESULT MApi_DMS_Video_Flip_U2(void* pInstance, MS_U32 u32WindowID, ST_DMS_DISPFRAMEFORMAT* pstDispFrameFormat);
313 EN_DMS_RESULT MApi_DMS_SetZOrder_U2(void* pInstance, MS_U32 u32WindowID, ST_DMS_ZORDER_INFO *pstZorderInfo);
314 EN_DMS_RESULT MApi_DMS_Video_Freeze_U2(void* pInstance, MS_U32 u32WindowID, ST_DMS_FREEZE_WINDOW_INFO *pstWindowFreeze);
315 EN_DMS_RESULT MApi_DMS_Video_Mute_U2(void* pInstance, MS_U32 u32WindowID, ST_DMS_MUTE_WINDOW_INFO *pstWindowMute);
316 EN_DMS_RESULT MApi_DMS_Set_MuteColor_U2(void* pInstance, MS_U32 u32WindowID, ST_DMS_MUTE_COLOR_INFO *pstMuteColor);
317 EN_DMS_RESULT MApi_DMS_GetStatus_U2(void* pInstance, EN_DMS_STATUS *peStatus);
318 EN_DMS_RESULT MApi_DMS_GetCapability_U2(void* pInstance, EN_DMS_CAPABILITY *peCapability);
319 EN_DMS_RESULT MApi_DMS_GetExistedWindows_U2(void* pInstance, MS_U32 *pu32WindowNums);
320 EN_DMS_RESULT MApi_DMS_SetOutputLayer_U2(void* pInstance, ST_DMS_WINDOW *pstLayer);
321 EN_DMS_RESULT MApi_DMS_Set_3D_Mode_U2(void* pInstance, MS_U32 u32WindowID, ST_DMS_3D_INFO *pst3DInfo);
322 EN_DMS_RESULT MApi_DMS_Set_CaptureInfo_U2(void* pInstance, MS_U32 u32WindowID, ST_DMS_SET_CAPTURE_INFO *pstSetCaptureInfo);
323 EN_DMS_RESULT MApi_DMS_Get_CaptureBuffer_U2(void* pInstance, MS_U32 u32WindowID, ST_DMS_CAPTURE_INFO *pstCaptureInfo);
324 EN_DMS_RESULT MApi_DMS_Release_CaptureBuffer_U2(void* pInstance, MS_U32 u32WindowID, ST_DMS_CAPTURE_INFO *pstCaptureInfo);
325 
326 void DMSRegisterToUtopia(void);
327 MS_U32 DMSOpen(void** ppInstance, const void* const pAttribute);
328 MS_U32 DMSClose(void* pInstance);
329 MS_U32 DMSIoctl(void* pInstance, MS_U32 u32Cmd, void* pArgs);
330 
331 #ifdef __cplusplus
332 }
333 #endif
334 #endif // _DMS_PRIV_H_
335