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 /// 97 /// @file drvLDM.h 98 /// @brief local dimming Driver Interface 99 /// @author MStar Semiconductor Inc. 100 /////////////////////////////////////////////////////////////////////////////////////////////////// 101 102 /*! \defgroup G_LDM Local dimming interface 103 \ingroup G_PERIPHERAL 104 105 \brief 106 107 Local dimming is introduced to achieve power saving and higher image contrast for LED backlight. 108 109 110 <b>Features</b> 111 112 - Less backlight, less energy 113 - Compensation restores image luminance 114 - Average 10~30% saving 115 - Dark region becomes even darker 116 - Light leakage problem 117 118 <b> LDM Block Diagram: </b> \n 119 \image html apiLD_pic.png 120 121 <b> Operation Code Flow: </b> \n 122 -# AP init, local dimming ready 123 -# kernel run algorithm 124 -# pm51 read led data from sharememory 125 -# pm51 send luminance data to led via spi 126 \image html apiLD_pic2.png 127 128 \defgroup LDM_Init LDM Init API 129 \ingroup LDM 130 \defgroup LDM_Debug LDM Debug API 131 \ingroup LDM 132 \defgroup G_LDM_COMMON Common Task relative 133 \ingroup G_LDM 134 \defgroup G_LDM_CONTROL Control relative 135 \ingroup G_LDM 136 137 */ 138 139 140 #ifndef _DRV_LDM_H_ 141 #define _DRV_LDM_H_ 142 143 144 #ifdef __cplusplus 145 extern "C" 146 { 147 #endif 148 149 150 #ifdef MDRV_LDM_C 151 #define MDRV_INTERFACE 152 #else 153 #define MDRV_INTERFACE extern 154 #endif 155 156 // use 'L' as magic number 157 #define MDRV_LDM_IOC_MAGIC ('L') 158 #define MDRV_LDM_IOC_INIT _IO(MDRV_LDM_IOC_MAGIC, 0) 159 #define MDRV_LDM_IOC_DEINIT _IO(MDRV_LDM_IOC_MAGIC, 1) 160 #define MDRV_LDM_IOC_ENABLE _IOW(MDRV_LDM_IOC_MAGIC, 2, MS_U32) 161 #define MDRV_LDM_IOC_DISABLE _IOW(MDRV_LDM_IOC_MAGIC, 3, MS_U32) 162 #define MDRV_LDM_IOC_SUSPEND _IOW(MDRV_LDM_IOC_MAGIC, 4, MS_U32) 163 #define MDRV_LDM_IOC_RESUME _IOW(MDRV_LDM_IOC_MAGIC, 5, MS_U32) 164 #define MDRV_LDM_IOC_SET_STRENGTH _IOW(MDRV_LDM_IOC_MAGIC, 6, MS_U32) 165 #define MDRV_LDM_IOC_GET_DATA _IOR(MDRV_LDM_IOC_MAGIC, 7, MS_U32) 166 #define MDRV_LDM_IOC_DEBUG _IOW(MDRV_LDM_IOC_MAGIC, 8, MS_U32) 167 #define MDRV_LDM_IOC_CUS_PATH _IOW(MDRV_LDM_IOC_MAGIC, 9, MS_U32) 168 #define MDRV_LDM_IOC_DEMO_PATTERN _IOW(MDRV_LDM_IOC_MAGIC, 10, MS_U32) 169 #define MDRV_LDM_IOC_DUMP_DRAM _IOW(MDRV_LDM_IOC_MAGIC, 11, MS_U32) 170 #define MDRV_LDM_IOC_MAX_NR (12) 171 172 173 174 typedef enum 175 { 176 E_LDM_STATUS_INIT = 1, 177 E_LDM_STATUS_ENABLE = 2, 178 E_LDM_STATUS_DISNABLE, 179 E_LDM_STATUS_SUSPEND, 180 E_LDM_STATUS_RESUME, 181 E_LDM_STATUS_DEINIT, 182 } EN_LDM_STATUS; 183 184 typedef enum 185 { 186 E_LDM_RET_SUCCESS = 0, 187 E_LDM_RET_FAIL = 1, 188 E_LDM_RET_NOT_SUPPORTED, 189 E_LDM_RET_PARAMETER_ERROR, 190 E_LDM_RET_OBTAIN_MUTEX_FAIL, ///< obtain mutex timeout when calling this function 191 } EN_LDM_RETURN; 192 193 typedef enum 194 { 195 E_LDM_DEBUG_LEVEL_ERROR=0x01, 196 E_LDM_DEBUG_LEVEL_WARNING=0x02, 197 E_LDM_DEBUG_LEVEL_INFO=0x04, 198 E_LDM_DEBUG_LEVEL_ALL=0x07, 199 E_LDM_DEBUG_LEVEL_MAX 200 }EN_LDM_DEBUG_LEVEL; 201 202 typedef enum 203 { 204 E_LDM_DATA_TYPE_LDF=0x01, 205 E_LDM_DATA_TYPE_LDB=0x02, 206 E_LDM_DATA_TYPE_SPI=0x03, 207 E_LDM_DATA_TYPE_MAX 208 }EN_LDM_GET_DATA_TYPE; 209 210 typedef enum 211 { 212 E_LDM_DEMO_PATTERN_SWITCH_SINGLE_LED=0x00, 213 E_LDM_DEMO_PATTERN_LEFT_RIGHT_HALF=0x01, 214 E_LDM_DEMO_PATTERN_MARQUEE=0x02, 215 E_LDM_DEMO_PATTERN_LEFT_RIGHT_COLOR_SHELTER=0x03, 216 E_LDM_DEMO_PATTERN_MAX 217 }EN_LDM_DEMO_PATTERN; 218 219 220 typedef struct __attribute__((packed)) 221 { 222 MS_U8 aCusPath[64]; 223 MS_U8 aCusPathU[64]; 224 }ST_LDM_CONF_PATH; 225 226 typedef struct __attribute__((packed)) 227 { 228 EN_LDM_GET_DATA_TYPE enDataType; 229 MS_PHY phyAddr; 230 }ST_LDM_GET_DATA; 231 232 typedef struct __attribute__((packed)) 233 { 234 MS_BOOL bOn; 235 EN_LDM_DEMO_PATTERN enDemoPattern; 236 MS_U16 u16LEDNum; 237 }ST_LDM_DEMO_PATTERN; 238 239 typedef struct __attribute__((packed)) 240 { 241 MS_U32 u32CommandIndex; 242 void *pContent; 243 }ST_LDM_CMD_INFO; 244 245 typedef struct 246 { 247 //for LDF addr 248 MS_U32 u32LDFAddr0_l; //double buffer0 249 MS_U32 u32LDFAddr0_r; 250 MS_U32 u32LDFAddr1_l; //double buffer1 251 MS_U32 u32LDFAddr1_r; 252 //for LDB addr 253 MS_U32 u32LDBAddr0_l; //double buffer0 254 MS_U32 u32LDBAddr0_r; 255 MS_U32 u32LDBAddr1_l; //double buffer1 256 MS_U32 u32LDBAddr1_r; 257 //for edge2D addr 258 MS_U32 u32Edge2DAddr; 259 //for spi data mem base 260 MS_U32 u32DataOffset; 261 }__attribute__((packed))ST_LDM_CFG_MMAP_ADDR; 262 263 //---------------------------------------------------------------- 264 // MDrv_LDM_SetDbgLevel - Set debug level 265 /// @ingroup G_LDM_CONTROL 266 // @param: eLevel: debug level 267 // @return: E_LDM_STATUS_SUCCESS is setted 268 //---------------------------------------------------------------- 269 MDRV_INTERFACE MS_U8 MDrv_LDM_SetDbgLevel(EN_LDM_DEBUG_LEVEL eLevel); 270 271 #if defined(MSOS_TYPE_LINUX) 272 //---------------------------------------------------------------- 273 // MDrv_LDM_GetData - get local dimming status 274 /// @ingroup G_LDM_CONTROL 275 // @param: void 276 // @return: EN_LDM_STATUS 277 //---------------------------------------------------------------- 278 MDRV_INTERFACE MS_U8 MDrv_LDM_GetStatus(void); 279 //---------------------------------------------------------------- 280 // MDrv_LDM_SetConfPath - Set config files path 281 /// @ingroup G_LDM_CONTROL 282 // @param: stPath: config files path in board or u-disk 283 // @return: E_LDM_STATUS_SUCCESS is setted 284 //---------------------------------------------------------------- 285 MDRV_INTERFACE MS_U8 MDrv_LDM_SetConfPath(ST_LDM_CONF_PATH stPath); 286 287 //---------------------------------------------------------------- 288 // MDrv_LDM_Init - Set mmap address to register base 289 /// @ingroup G_LDM_CONTROL 290 // @param: phyAddr: local dimming mmap address in mmap.ini 291 // @return: E_LDM_RET_SUCCESS is inital 292 //---------------------------------------------------------------- 293 MDRV_INTERFACE MS_U8 MDrv_LDM_Init(MS_PHY phyAddr); 294 295 //---------------------------------------------------------------- 296 // MDrv_LDM_Enable - start local dimming algorithm 297 /// @ingroup G_LDM_CONTROL 298 // @param: na 299 // @return: E_LDM_RET_SUCCESS is enable 300 //---------------------------------------------------------------- 301 MDRV_INTERFACE MS_U8 MDrv_LDM_Enable(void); 302 303 //---------------------------------------------------------------- 304 // MDrv_LDM_Disable - stop local dimming algorithm, send constant luminance to led 305 /// @ingroup G_LDM_CONTROL 306 // @param: u8Lumma: constant luminance range from 00 to 255 307 // @return: E_LDM_RET_SUCCESS is disable 308 //---------------------------------------------------------------- 309 MDRV_INTERFACE MS_U8 MDrv_LDM_Disable(MS_U8 u8Lumma); 310 311 //---------------------------------------------------------------- 312 // MDrv_LDM_GetData - get LDF/LDB/SPI data pre frame in buffer 313 /// @ingroup G_LDM_CONTROL 314 // @param: stData: data type and mmap address filled with the requied type 315 // @return: E_LDM_RET_SUCCESS is getted 316 //---------------------------------------------------------------- 317 MDRV_INTERFACE MS_U8 MDrv_LDM_GetData(ST_LDM_GET_DATA *stData); 318 319 //---------------------------------------------------------------- 320 // MDrv_LDM_SetStrength - Set back light percent 321 /// @ingroup G_LDM_CONTROL 322 // @param: u8Percent: the percent ranged from 0 to 100 323 // @return: E_LDM_RET_SUCCESS is setted 324 //---------------------------------------------------------------- 325 MDRV_INTERFACE MS_U8 MDrv_LDM_SetStrength(MS_U8 u8Percent); 326 327 //---------------------------------------------------------------- 328 // MDrv_LDM_Suspend -go to sleep 329 /// @ingroup G_LDM_CONTROL 330 // @param: na 331 // @return: E_LDM_RET_SUCCESS is suspend 332 //---------------------------------------------------------------- 333 MDRV_INTERFACE MS_U8 MDrv_LDM_Suspend(void); 334 335 //---------------------------------------------------------------- 336 // MDrv_LDM_Resume - wake up from sleeping 337 /// @ingroup G_LDM_CONTROL 338 // @param: na 339 // @return: E_LDM_RET_SUCCESS is resumed 340 //---------------------------------------------------------------- 341 MDRV_INTERFACE MS_U8 MDrv_LDM_Resume(void); 342 343 //---------------------------------------------------------------- 344 // MDrv_LDM_DemoPattern - demo pattern from customer 345 /// @ingroup G_LDM_CONTROL 346 // @param: stPattern: demo type: turn on led, left-right half show 347 // @return: E_LDM_RET_SUCCESS is demonstrative 348 //---------------------------------------------------------------- 349 MDRV_INTERFACE MS_U8 MDrv_LDM_DemoPattern(ST_LDM_DEMO_PATTERN stPattern); 350 351 //---------------------------------------------------------------- 352 // MDrv_LDM_DumpDRAM - Print LDF/LDB/SPI data 353 /// @ingroup G_LDM_CONTROL 354 // @param: eType: LDF/LDB/SPI 355 // @return: E_LDM_RET_SUCCESS is dumped 356 //---------------------------------------------------------------- 357 MDRV_INTERFACE MS_U8 MDrv_LDM_DumpDRAM(EN_LDM_GET_DATA_TYPE eType); 358 359 //---------------------------------------------------------------- 360 // MDrv_LDM_Deinit - stop local dimmg, free resource owned 361 /// @ingroup G_LDM_CONTROL 362 // @param: na 363 // @return: E_LDM_RET_SUCCESS is deinit 364 //---------------------------------------------------------------- 365 MDRV_INTERFACE MS_U8 MDrv_LDM_Deinit(void); 366 367 //---------------------------------------------------------------- 368 // MDrv_LDM_SendCommads - the api to reserve 369 /// @ingroup G_LDM_CONTROL 370 // @param: pstCMD: pointer to command 371 // @param: u8Number: number of command 372 // @return: E_LDM_RET_SUCCESS is sent 373 //---------------------------------------------------------------- 374 MDRV_INTERFACE MS_U8 MDrv_LDM_SendCommads(ST_LDM_CMD_INFO* pstCMD,MS_U8 u8Number); 375 #endif 376 //------------------------------------------------------------------------------------------------- 377 /// Description : set LDF base address 378 /// @param u8ClkHz \b IN: back light period 60HZ or 120HZ 379 /// @return TRUE : Success 380 /// @return Others : Fail 381 //------------------------------------------------------------------------------------------------- 382 MS_BOOL MDrv_LDM_SetIOMapBase(MS_U8 u8ClkHz); 383 //------------------------------------------------------------------------------------------------- 384 /// Description : set LDF base address 385 /// @param stLdmCfgAddr \b IN: doublebuffer for LDF index 386 /// @return TRUE : Success 387 /// @return Others : Fail 388 //------------------------------------------------------------------------------------------------- 389 MS_BOOL MDrv_LDM_Config_MmapAddr(ST_LDM_CFG_MMAP_ADDR *stLdmCfgAddr); 390 //------------------------------------------------------------------------------------------------- 391 /// Description : Set MIU PackOffset & Pack length [DMA load mem offset data ,ps:always offset=0] 392 /// @param u8HWNum \b IN: LDMA Hw number index 393 /// @param u8PackOffset \b IN: u8PackOffset 394 /// @param u8PackLength \b IN: DMA load mem data pack format size 395 /// @return TRUE : Success 396 /// @return Others : Fail 397 //------------------------------------------------------------------------------------------------- 398 MS_BOOL MDrv_LDM_SetMIUPackFormat(MS_U8 u8HWNum,MS_U8 u8PackOffset,MS_U8 u8PackLength); 399 //------------------------------------------------------------------------------------------------- 400 /// Description : Set YoffEnd 401 /// @param u8HWNum \b IN: LDMA Hw number index 402 /// @param u8YoffEnd \b IN: u8YoffEnd always =led height 403 /// @return DRVAESDMA_OK : Success 404 /// @return Others : Fail 405 //------------------------------------------------------------------------------------------------- 406 MS_BOOL MDrv_LDM_SetYoffEnd(MS_U8 u8HWNum,MS_U8 u8YoffEnd); 407 //------------------------------------------------------------------------------------------------- 408 /// Description : Set Back light height number 409 /// @param u8Height \b IN: LDMA Height = led Height number 410 /// @param u8Height \b IN: LDMA Width = led Width number 411 /// @return DRVAESDMA_OK : Success 412 /// @return Others : Fail 413 //------------------------------------------------------------------------------------------------- 414 MS_BOOL MDrv_LDM_SetBlLdmaSize(MS_U8 u8Height,MS_U8 u8Width); 415 //------------------------------------------------------------------------------------------------- 416 /// Description : Enable ldma for LD 417 /// @param u8HWNum \b IN: LDMA Hw number index 418 /// @param bEnable \b IN: set DMA for local dimming enable or disable 419 /// @return DRVAESDMA_OK : Success 420 /// @return Others : Fail 421 //------------------------------------------------------------------------------------------------- 422 MS_BOOL MDrv_LDM_SetDmaEnable(MS_U8 u8HWNum, MS_BOOL bEnable); 423 #ifdef __cplusplus 424 } 425 #endif 426 427 #endif // _DRV_LDM_H_