xref: /utopia/UTPA2-700.0.x/modules/graphic/drv/gop/mdrv_gflip_st.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 //////////////////////////////////////////////////////////////////////////////////////////////////
95 //
96 // @file   mdrv_gflip_st.h
97 // @brief  GFlip KMD Driver Interface
98 // @author MStar Semiconductor Inc.
99 //////////////////////////////////////////////////////////////////////////////////////////////////
100 
101 
102 #ifndef _MDRV_GFLIP_ST_H
103 #define _MDRV_GFLIP_ST_H
104 
105 //=============================================================================
106 // Includs
107 //=============================================================================
108 
109 //=============================================================================
110 // Type and Structure Declaration
111 //=============================================================================
112 #define MULTIINFO_NUM               8UL
113 
114 #define MS_HDR_VERSION  4
115 
116 //IO Ctrl struct defines:
117 typedef enum
118 {
119     /// Color format RGB555 and Blink.
120     E_GFLIP_COLOR_RGB555_BLINK    =0,
121     /// Color format RGB565.
122     E_GFLIP_COLOR_RGB565          =1,
123     /// Color format ARGB4444.
124     E_GFLIP_COLOR_ARGB4444        =2,
125     /// Color format alpha blink.
126     E_GFLIP_COLOR_2266      =3,
127     /// Color format I8 (256-entry palette).
128     E_GFLIP_COLOR_I8              =4,
129     /// Color format ARGB8888.
130     E_GFLIP_COLOR_ARGB8888        =5,
131     /// Color format ARGB1555.
132     E_GFLIP_COLOR_ARGB1555        =6,
133     /// Color format ARGB8888.  - Andriod format
134     E_GFLIP_COLOR_ABGR8888        =7,
135     /// Color format RGB555/YUV422.
136     E_GFLIP_COLOR_RGB555YUV422    =8,
137     /// Color format YUV422.
138     E_GFLIP_COLOR_YUV422          =9,
139     /// Color format ARGB8888.  - Andriod format
140     E_GFLIP_COLOR_RGBA5551        =10,
141     /// Color format ARGB8888.  - Andriod format
142     E_GFLIP_COLOR_RGBA4444        =11,
143 
144     /// Invalid color format.
145     E_GFLIP_COLOR_INVALID
146 } GFLIP_COLOR_TYPE;
147 
148 typedef union
149 {
150     MS_U8 u8DWinIntInfo;
151     struct
152     {
153         MS_U8 bDWinIntWADR:1;
154         MS_U8 bDWinIntPROG:1;
155         MS_U8 bDWinIntTF:1;
156         MS_U8 bDWinIntBF:1;
157         MS_U8 bDWinIntVS:1;
158         MS_U8 reserved:3;
159     }sDwinIntInfo;
160 }GFLIP_DWININT_INFO, *PGFLIP_DWININT_INFO;
161 
162 typedef struct
163 {
164     MS_U32 u32GopIdx; //in
165     MS_U32 u32GwinIdx; //in
166     MS_PHY u64Addr; //in
167     MS_U32 u32TagId; //in
168     MS_U32 u32QEntry; //InOut
169     MS_U32 u32Result; //Out
170 }MS_GFLIP_INFO, *PMS_GFLIP_INFO;
171 
172 typedef struct
173 {
174     MS_U32 u32GopIdx; //in
175     MS_U32 u32GwinIdx; //in
176     MS_PHY u64Addr; //in
177     MS_U32 u32TagId; //in
178     MS_U32 u32QEntry; //InOut
179     MS_U32 u32Result; //Out
180     MS_BOOL bTLBEnable;
181     MS_PHY u64TLBAddr;
182 }MS_TLB_GFLIP_INFO, *PMS_TLB_GFLIP_INFO;
183 
184 typedef struct
185 {
186     MS_U32 u32GopIdx; //in
187     MS_U32 u32GwinIdx; //in
188     MS_PHY u64MainAddr; //in
189     MS_U32 u32TagId; //in
190     MS_U32 u32QEntry; //InOut
191     MS_U32 u32Result; //Out
192     MS_PHY u64SubAddr; //in
193 }MS_GFLIP_3DINFO, *PMS_GFLIP_3DINFO;
194 
195 typedef struct
196 {
197     MS_U32 u32GopIdx; //in
198     MS_U32 u32GwinIdx; //in
199     MS_PHY u64MainAddr; //in
200     MS_U32 u32TagId; //in
201     MS_U32 u32QEntry; //InOut
202     MS_U32 u32Result; //Out
203     MS_PHY u64SubAddr; //in
204     MS_BOOL bTLBEnable;
205     MS_PHY u64TLBAddr;
206 }MS_TLB_GFLIP_3DINFO, *PMS_TLB_GFLIP_3DINFO;
207 
208 typedef struct
209 {
210     MS_U8 u8GopInfoCnt;
211     MS_GFLIP_3DINFO astGopInfo[MULTIINFO_NUM];
212 }MS_GFLIP_MULTIINFO, *PMS_GFLIP_MULTIINFO;
213 
214 typedef struct
215 {
216     MS_U8 u8GopInfoCnt;
217     MS_TLB_GFLIP_3DINFO astTLBGopInfo[MULTIINFO_NUM];
218 }MS_TLB_GFLIP_MULTIINFO, *PMS_TLB_GFLIP_MULTIINFO;
219 
220 typedef struct
221 {
222     GFLIP_DWININT_INFO gflipDWinIntInfo;
223     MS_BOOL bResetDWinIntInfo;
224 
225 }MS_GFLIP_DWININT_INFO, *PMS_GFLIP_DWININT_INFO;
226 
227 typedef struct
228 {
229     GFLIP_DWININT_INFO gflipDWinIntInfo;
230     MS_U32  u32Timeout;
231     MS_BOOL bResetDWinIntInfo;
232 }MS_GFLIP_DWININT_INFO2, *PMS_GFLIP_DWININT_INFO2;
233 
234 typedef struct
235 {
236     MS_BOOL bEnable; //InOut
237     MS_U8   u8FrameCount; //Out, value range: 0~3
238     MS_U8   u8Result; //Out
239 }MS_GFLIP_VECAPTURESTATE, *PMS_GFLIP_VECAPTURESTATE;
240 
241 typedef struct
242 {
243     MS_U32 u32GopIdx; //in
244     MS_U32 u32GwinIdx; //in
245     MS_U32 u32Result; //Out
246 }MS_GFLIP_GOPGWINIDX,*PMS_GFLIP_GOPGWINIDX;
247 
248 typedef struct
249 {
250     MS_PHY u64Addr;
251     MS_U16 u16X;
252     MS_U16 u16Y;
253     MS_U16 u16W;
254     MS_U16 u16H;
255     MS_U8  u8GopIdx;
256     MS_U8  u8GwinIdx;
257     GFLIP_COLOR_TYPE clrType;
258 }MS_GWIN_INFO;
259 
260 typedef struct
261 {
262     MS_BOOL bCurveChange;  // Curve Change
263     MS_U8  u8LumaCurve[16];  // Default luma curve from Supernova DLC.ini
264     MS_U8  u8LumaCurve2_a[16];  // Default luma curve 2a  from Supernova DLC.ini
265     MS_U8  u8LumaCurve2_b[16];  // Default luma curve 2b  from Supernova DLC.ini
266     MS_U8  u8Result; //Out
267 }MS_DLC_INFO;
268 
269 typedef struct
270 {
271     MS_BOOL bBLEPointChange;  // BLE Point Change
272     MS_U16  u16BLESlopPoint[6];  // Default BLE Slop Point from Supernova DLC.ini
273     MS_U8  u8Result; //Out
274 }MS_BLE_INFO;
275 
276 
277 typedef struct
278 {
279     MS_BOOL bInitInfoChange;  // Init Info Change
280 
281     // Default luma curve
282     MS_U8 ucLumaCurve[16];
283     MS_U8 ucLumaCurve2_a[16];
284     MS_U8 ucLumaCurve2_b[16];
285     MS_U8 ucDlcHistogramLimitCurve[17];
286 
287     MS_U8 ucDlcPureImageMode; // Compare difference of max and min bright
288     MS_U8 ucDlcLevelLimit; // n = 0 ~ 4 => Limit n levels => ex. n=2, limit 2 level 0xF7, 0xE7
289     MS_U8 ucDlcAvgDelta; // n = 0 ~ 50, default value: 12
290     MS_U8 ucDlcAvgDeltaStill; // n = 0 ~ 15 => 0: disable still curve, 1 ~ 15 => 0.1 ~ 1.5 enable still curve
291     MS_U8 ucDlcFastAlphaBlending; // min 17 ~ max 32
292     MS_U8 ucDlcYAvgThresholdL; // default value: 0
293     MS_U8 ucDlcYAvgThresholdH; // default value: 128
294 
295     MS_U8 ucDlcBLEPoint; // n = 24 ~ 64, default value: 48
296     MS_U8 ucDlcWLEPoint; // n = 24 ~ 64, default value: 48
297     MS_U8 bEnableBLE : 1; // 1: enable; 0: disable
298     MS_U8 bEnableWLE : 1; // 1: enable; 0: disable
299     MS_U8 ucDlcYAvgThresholdM;
300     MS_U8 ucDlcCurveMode;
301     MS_U8 ucDlcCurveModeMixAlpha;
302     MS_U8 ucDlcAlgorithmMode;
303     MS_U8 ucDlcSepPointH;
304     MS_U8 ucDlcSepPointL;
305     MS_U16 uwDlcBleStartPointTH;
306     MS_U16 uwDlcBleEndPointTH;
307     MS_U8 ucDlcCurveDiff_L_TH;
308     MS_U8 ucDlcCurveDiff_H_TH;
309     MS_U16 uwDlcBLESlopPoint_1;
310     MS_U16 uwDlcBLESlopPoint_2;
311     MS_U16 uwDlcBLESlopPoint_3;
312     MS_U16 uwDlcBLESlopPoint_4;
313     MS_U16 uwDlcBLESlopPoint_5;
314     MS_U16 uwDlcDark_BLE_Slop_Min;
315     MS_U8 ucDlcCurveDiffCoringTH;
316     MS_U8 ucDlcAlphaBlendingMin;
317     MS_U8 ucDlcAlphaBlendingMax;
318     MS_U8 ucDlcFlicker_alpha;
319     MS_U8 ucDlcYAVG_L_TH;
320     MS_U8 ucDlcYAVG_H_TH;
321     MS_U8 ucDlcDiffBase_L;
322     MS_U8 ucDlcDiffBase_M;
323     MS_U8 ucDlcDiffBase_H;
324     // NEW DLC
325     MS_U8 ucLMaxThreshold;
326     MS_U8 ucLMinThreshold;
327     MS_U8 ucLMaxCorrection;
328     MS_U8 ucLMinCorrection;
329     MS_U8 ucRMaxThreshold;
330     MS_U8 ucRMinThreshold;
331     MS_U8 ucRMaxCorrection;
332     MS_U8 ucRMinCorrection;
333     MS_U8 ucAllowLoseContrast;
334     MS_U8 ucKernelDlcAlgorithm;
335     MS_U8 ucDlcHistogramSource;
336 }MS_DLC_INIT_INFO;
337 
338 typedef struct __attribute__((packed))
339 {
340     MS_U8      u8ColorPrimaries;
341     MS_U8      u8TransferCharacteristics;
342     MS_U8      u8MatrixCoefficients;
343 } MS_DLC_HDR_METADATA_MPEG_VUI;
344 
345 // Data format follows HDR_Metadata_MpegSEI_MasteringColorVolume
346 typedef struct __attribute__((packed))
347 {
348     MS_U16     display_primaries_x[3]; // x = data*0.00002    [709] {15000, 7500, 32000}
349     MS_U16     display_primaries_y[3]; // y = data*0.00002    [709] {30000, 3000, 16500}
350     MS_U16     white_point_x; // x = data*0.00002    [709] 15635
351     MS_U16     white_point_y; // y = data*0.00002    [709] 16450
352     MS_U32     max_display_mastering_luminance; // data*0.0001 nits    [600nits] 6000000
353     MS_U32     min_display_mastering_luminance; // data*0.0001 nits    [0.3nits] 3000
354 } MS_DLC_HDR_METADATA_MPEG_SEI_MASTERING_COLOR_VOLUME;
355 
356 typedef struct __attribute__((packed))
357 {
358     MS_U16 u16Smin; // 0.10
359     MS_U16 u16Smed; // 0.10
360     MS_U16 u16Smax; // 0.10
361     MS_U16 u16Tmin; // 0.10
362     MS_U16 u16Tmed; // 0.10
363     MS_U16 u16Tmax; // 0.10
364     MS_U16 u16MidSourceOffset;
365     MS_U16 u16MidTargetOffset;
366     MS_U16 u16MidSourceRatio;
367     MS_U16 u16MidTargetRatio;
368 } MS_DLC_HDRToneMappingData;
369 
370 typedef struct __attribute__((packed))
371 {
372     MS_U16 u16tRx; // target Rx
373     MS_U16 u16tRy; // target Ry
374     MS_U16 u16tGx; // target Gx
375     MS_U16 u16tGy; // target Gy
376     MS_U16 u16tBx; // target Bx
377     MS_U16 u16tBy; // target By
378     MS_U16 u16tWx; // target Wx
379     MS_U16 u16tWy; // target Wy
380 } MS_DLC_HDRGamutMappingData;
381 
382 typedef struct __attribute__((packed))
383 {
384     MS_U8      u8EOTF; // 0:SDR gamma, 1:HDR gamma, 2:SMPTE ST2084, 3:Future EOTF, 4-7:Reserved
385     MS_U16     u16Rx; // display primaries Rx
386     MS_U16     u16Ry; // display primaries Ry
387     MS_U16     u16Gx; // display primaries Gx
388     MS_U16     u16Gy; // display primaries Gy
389     MS_U16     u16Bx; // display primaries Bx
390     MS_U16     u16By; // display primaries By
391     MS_U16     u16Wx; // display primaries Wx
392     MS_U16     u16Wy; // display primaries Wy
393     MS_U16     u16Lmax; // max display mastering luminance
394     MS_U16     u16Lmin; // min display mastering luminance
395     MS_U16     u16MaxCLL; // maximum content light level
396     MS_U16     u16MaxFALL; // maximum frame-average light level
397 } MS_DLC_HDRMetadataHdmiTxInfoFrame;
398 
399 typedef struct __attribute__((packed))
400 {
401     MS_U8 PixelFormat;              // Pixel Format
402     MS_U8 Colorimetry;              // Color imetry
403     MS_U8 ExtendedColorimetry;      // Extended Color imetry
404     MS_U8 RgbQuantizationRange;     // Rgb Quantization Range
405     MS_U8 YccQuantizationRange;     // Ycc Quantization Range
406     MS_U8 StaticMetadataDescriptorID; //Static Metadata Descriptor ID
407 } MS_DLC_HDRHdmiTxAviInfoFrame;
408 
409 typedef struct __attribute__((packed))
410 {
411     /// HDR Version Info
412     MS_U16 u16HDRVerInfo;
413     /// HDR init Length
414     MS_U16 u16HDRInitLength;
415     /// HDR Enable
416     MS_BOOL bHDREnable;
417     /// HDR Function Select
418     MS_U16 u16HDRFunctionSelect;
419     /// HDR Metadata Mpeg VUI
420     MS_DLC_HDR_METADATA_MPEG_VUI DLC_HDRMetadataMpegVUI;
421     /// HDR Tone Mapping Data
422     MS_DLC_HDRToneMappingData DLC_HDRToneMappingData;
423     /// HDR Gamut Mapping Data
424     MS_DLC_HDRGamutMappingData DLC_HDRGamutMappingData;
425     //HDR Metadata Hdmi Tx Info Frame
426     MS_DLC_HDRMetadataHdmiTxInfoFrame DLC_HDRMetadataHdmiTxInfoFrame;
427     //HDR Hdmi Tx Avi Info Frame
428     MS_DLC_HDRHdmiTxAviInfoFrame DLC_HDRHdmiTxInfoAviFrame;
429 } MS_HDR_INFO;
430 
431 // HDR use customer DLC curve.
432 typedef struct __attribute__((packed))
433 {
434     MS_BOOL bFixHdrCurve;
435     MS_U16 u16DlcCurveSize;
436     MS_U8 *pucDlcCurve;
437 #if !defined (__aarch64__)
438     void    *pDummy;
439 #endif
440 } MS_DLC_HDRCustomerDlcCurve;
441 
442 // HDR use customer color primaries.
443 typedef struct __attribute__((packed))
444 {
445     MS_BOOL bCustomerEnable;
446     MS_U16 u16sWx;
447     MS_U16 u16sWy;
448 } MS_DLC_HDRCustomerColorPrimaries;
449 
450 // HDR new tone mapping parameters.
451 typedef struct __attribute__((packed))
452 {
453     // TMO
454     MS_U16 u16SrcMinRatio;			//default 10
455     MS_U16 u16SrcMedRatio;                   //default 512
456     MS_U16 u16SrcMaxRatio;			//default 990
457 
458     MS_U8 u8TgtMinFlag;                         //default 1
459     MS_U16 u16TgtMin;					//default 500
460     MS_U8 u8TgtMaxFlag;                        //default 0
461     MS_U16 u16TgtMax;				//default 300
462 
463     MS_U16 u16FrontSlopeMin;			//default 256
464     MS_U16 u16FrontSlopeMax;			//default 512
465     MS_U16 u16BackSlopeMin;			//default 128
466     MS_U16 u16BackSlopeMax;			//default 256
467 
468     MS_U16 u16SceneChangeThrd;		//default 1024
469     MS_U16 u16SceneChangeRatioMax;	//default 1024
470 
471     MS_U8 u8IIRRatio;					//default 31
472     MS_U8 u8TMO_TargetMode;      // default 0. 0 : keeps the value in initial function  1 : from output source
473     MS_U8 u8TMO_Algorithm;                // default 0.  0: 18 level TMO algorithm, 1: 512 level TMO algorithm.
474 
475 } MS_DLC_HDRNewToneMapping;
476 
477 typedef struct __attribute__((packed))
478 {
479     /// HDR Version Info
480     MS_U16 u16HDRVerInfo;
481     /// HDR init Length
482     MS_U16 u16HDRInitLength;
483     /// HDR Enable
484     MS_BOOL bHDREnable;
485     /// HDR Function Select
486     MS_U16 u16HDRFunctionSelect;
487     /// HDR Metadata Mpeg VUI
488     MS_DLC_HDR_METADATA_MPEG_VUI DLC_HDRMetadataMpegVUI;
489     /// HDR Tone Mapping Data
490     MS_DLC_HDRToneMappingData DLC_HDRToneMappingData;
491     /// HDR Gamut Mapping Data
492     MS_DLC_HDRGamutMappingData DLC_HDRGamutMappingData;
493     //HDR Metadata Hdmi Tx Info Frame
494     MS_DLC_HDRMetadataHdmiTxInfoFrame DLC_HDRMetadataHdmiTxInfoFrame;
495     // Customer DLC Curve
496     MS_DLC_HDRCustomerDlcCurve DLC_HDRCustomerDlcCurve;
497     // Customer color primarie.
498     MS_DLC_HDRCustomerColorPrimaries DLC_HDRCustomerColorPrimaries;
499     //HDR Hdmi Tx Avi Info Frame
500     MS_DLC_HDRHdmiTxAviInfoFrame DLC_HDRHdmiTxInfoAviFrame;
501     /// HDR metadata MPEG SEI mastering color volume/
502     MS_DLC_HDR_METADATA_MPEG_SEI_MASTERING_COLOR_VOLUME DLC_HDRMetadataMpegSEIMasteringColorVolume;
503     /// New tone mapping parameters.
504     MS_DLC_HDRNewToneMapping DLC_HDRNewToneMapping;
505 } MS_HDR_INFO_EXTEND;
506 
507 #endif //_MDRV_GFLIP_ST_H
508