xref: /utopia/UTPA2-700.0.x/projects/tmplib/include/apiLD.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 /*! \defgroup G_LD Local dimming interface
96     \ingroup  G_PERIPHERAL
97 
98     \brief
99 
100     Local dimming is introduced to achieve power saving and higher image contrast for LED backlight.
101 
102 
103     <b>Features</b>
104 
105     - Less backlight, less energy
106     - Compensation restores image luminance
107     - Average 10~30% saving
108     - Dark region becomes even darker
109     - Light leakage problem
110 
111     <b> LD Block Diagram: </b> \n
112     \image html apiLD_pic.png
113 
114     <b> Operation Code Flow: </b> \n
115     -# mboot init, local dimming ready
116     -# kernel run algorithm
117     -# pm51 read led data from sharememory
118     -# pm51 send luminance data to led via spi
119     \image html apiLD_pic2.png
120 
121     \defgroup LD_Init LD Init API
122     \ingroup LD
123     \defgroup LD_Debug LD Debug API
124     \ingroup LD
125     \defgroup LD_to_be_removed LD_to_be_removed (to be removed)
126     \ingroup LD
127 */
128 
129 #ifndef _API_XC_LD_H_
130 #define _API_XC_LD_H_
131 
132 //#include "MsCommon.h"
133 //#include "MsDevice.h"
134 #include "MsTypes.h"
135 
136 #ifdef __cplusplus
137 extern "C" {
138 #endif
139 
140 
141 //-------------------------------------------------------------------------------------------------
142 //  Macro and Define
143 //-------------------------------------------------------------------------------------------------
144 #define LD_LOG_DBG     1
145 
146 // Debug related
147 #if LD_LOG_DBG
148 #define LD_DBG(_fmt, _args...)      {printf("LD:"_fmt, ##_args); }
149 #define LD_ASSERT(_fmt, _args...)  {printf("LD ASSERT: %s %d:"_fmt, __FILE__, __LINE__, ##_args); }
150 #else
151 #define LD_DBG(_fmt, _args...)      { }
152 #define LD_ASSERT(_fmt, _args...)  {printf("LD ASSERT: %s %d:"_fmt, __FILE__, __LINE__, ##_args); }
153 #endif
154 
155 
156 //-------------------------------------------------------------------------------------------------
157 //  Type and Structure
158 //-------------------------------------------------------------------------------------------------
159 
160 /// Define PNL local dimming return type
161 typedef enum
162 {
163     E_APILD_STATUS_SUCCESS = 0,
164     E_APILD_STATUS_FAIL = 1,
165     E_APILD_STATUS_NOT_SUPPORTED,
166     E_APILD_STATUS_PARAMETER_ERROR,
167     E_APILD_OBTAIN_MUTEX_FAIL,            ///< obtain mutex timeout when calling this function
168     E_APILD_OBTAIN_MMIO_FAIL,            ///< obtain mutex timeout when calling this function
169 } E_LD_RETURN;
170 
171 typedef enum
172 {
173     E_LD_LED_EDGE_TB_TYPE = 0, // deprecated
174     E_LD_LED_EDGE_LR_TYPE = 1, // deprecated
175     E_LD_LED_DIRECT_TYPE  = 2,
176     E_LD_LED_LOCAL_TYPE   = 3,  // new mode supporting 32x32 LED
177     E_LD_LED_TYPE_NUM,
178     E_LD_LED_TYPE_MAX = E_LD_LED_TYPE_NUM,
179 } E_LD_TYPE;
180 
181 typedef struct _stLD_Init_Parameters
182 {
183     E_LD_TYPE ePnlLDType;
184     MS_U8* pu8RawData;
185     MS_U16 u16DataSize;
186     MS_U16 u16PnlWidth;
187     MS_U16 u16PnlHeight;
188     MS_U16 u16MemSize;
189     MS_PHYADDR u32MemAdrress;
190     MS_U32 u32Reserved;
191 } stLD_Init_Parameters, *pstLD_Init_Parameters;
192 
193 //-------------------------------------------------------------------------------------------------
194 //  Function and Variable
195 //--------------
196 
197 
198 //-------------------------------------------------------------------------------------------------
199 /// init local dimming, set base registers, load table etc
200 /// @return MS_U16
201 //-------------------------------------------------------------------------------------------------
202 MS_U16 MApi_LD_Init(pstLD_Init_Parameters pstLDArgs, MS_U16 u16DataLen);
203 
204 
205 
206 //-------------------------------------------------------------------------------------------------
207 /// set debug level
208 /// @return MS_U16
209 //-------------------------------------------------------------------------------------------------
210 MS_BOOL MApi_LD_SetDbgLevel(MS_U16 u16DbgSwitch);
211 
212 
213 #ifdef __cplusplus
214 }
215 #endif
216 
217 #endif
218