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 /*! \defgroup G_PWS PWS interface 95 \ingroup G_PERIPHERAL 96 97 \brief 98 Load power settings of demo atop and video atop at a specified source. 99 100 <b>Features</b> 101 102 - Load power settings. 103 104 <b> PWS Block Diagram: </b> \n 105 106 NA 107 108 \defgroup G_PWS_INIT Initialization Task relative 109 \ingroup G_PWS 110 \defgroup G_PWS_COMMON Common Task relative 111 \ingroup G_PWS 112 \defgroup G_PWS_CONTROL Control relative 113 \ingroup G_PWS 114 \defgroup G_PWS_OTHER other relative 115 \ingroup G_PWS 116 \defgroup G_PWS_ToBeModified PWS api to be modified 117 \ingroup G_PWS 118 \defgroup G_PWS_ToBeRemove PWS api to be removed 119 \ingroup G_PWS 120 */ 121 122 #ifndef _DRVPWS_H_ 123 #define _DRVPWS_H_ 124 125 //////////////////////////////////////////////////////////////////////////////// 126 /// @file drvPWS.h 127 /// @author MStar Semiconductor Inc. 128 /// @brief power saving driver 129 //////////////////////////////////////////////////////////////////////////////// 130 131 //------------------------------------------------------------------------------ 132 // Header Files 133 //------------------------------------------------------------------------------ 134 #ifdef __cplusplus 135 extern "C" 136 { 137 #endif 138 139 #include "MsCommon.h" 140 #include "MsTypes.h" 141 142 //------------------------------------------------------------------------------------------------- 143 // Macro and Define 144 //------------------------------------------------------------------------------------------------- 145 #define MSIF_PWS_LIB_CODE {'P','W','S','_'} //Lib code 146 #define MSIF_PWS_LIBVER {'0','2'} //LIB version 147 #define MSIF_PWS_BUILDNUM {'0','9'} //Build Number 148 #define MSIF_PWS_CHANGELIST {'0','0','4','4','8','1','7','6'} //P4 ChangeList Number 149 150 #define PWS_API_VERSION /* Character String for DRV/API version */ \ 151 MSIF_TAG, /* 'MSIF' */ \ 152 MSIF_CLASS, /* '00' */ \ 153 MSIF_CUS, /* 0x0000 */ \ 154 MSIF_MOD, /* 0x0000 */ \ 155 MSIF_CHIP, \ 156 MSIF_CPU, \ 157 MSIF_PWS_LIB_CODE, /* IP__ */ \ 158 MSIF_PWS_LIBVER, /* 0.0 ~ Z.Z */ \ 159 MSIF_PWS_BUILDNUM, /* 00 ~ 99 */ \ 160 MSIF_PWS_CHANGELIST, /* CL# */ \ 161 MSIF_OS 162 163 #define SIOCDEVON 0x89F1 164 #define SIOCDEVOFF 0x89F2 165 166 #define PWS_VERSION 0x00000001 167 168 169 //------------------------------------------------------------------------------------------------- 170 // Type and Structure 171 //------------------------------------------------------------------------------------------------- 172 173 typedef enum 174 { 175 PWS_FAIL = 0, 176 PWS_SUCCESS = 1 177 } E_PWS_Result; 178 179 #if defined (MSOS_TYPE_LINUX) 180 typedef enum 181 { 182 PHY_OFF = 0, 183 PHY_ON = 1 184 } E_PWS_PHY; 185 #endif 186 187 typedef enum 188 { 189 PWS_ADD_SOURCE = 0, 190 PWS_DEL_SOURCE = 1, 191 PWS_INVAILD_OP = 2 192 } E_PWS_Operation; 193 194 typedef enum 195 { 196 PWS_FULL = 0, 197 PWS_OFF_LINE_DETECT = 1 198 } E_PWS_Sync; 199 200 typedef enum 201 { 202 _NO_SOURCE_ = 0, 203 _USB_ = BIT_(0), 204 _SV_ = BIT_(1), 205 _HDMI4_ = BIT_(2), 206 _HDMI3_ = BIT_(3), 207 _HDMI2_ = BIT_(4), 208 _HDMI1_ = BIT_(5), 209 _YPbPr_ = BIT_(6), 210 _SCART_ = BIT_(7), 211 _RGB_ = BIT_(8), 212 _CVBS_ = BIT_(9), 213 _ATV_SSIF_ = BIT_(10), 214 _ATV_VIF_ = BIT_(11), 215 _DTV_ATSC_ = BIT_(12), 216 _DTV_DVB_ = BIT_(13), 217 _CVBSOe_ = BIT_(14), 218 _CVBSOi_ = BIT_(15), 219 _UNKNOWN_ = BIT_(16) 220 } E_PWS_SouceInfo; 221 222 typedef enum 223 { 224 E_PWS_DBGLV_NONE, //no debug message 225 E_PWS_DBGLV_ERR_ONLY, //show error only 226 E_PWS_DBGLV_REG_DUMP, //show error & reg dump 227 E_PWS_DBGLV_INFO, //show error & informaiton 228 E_PWS_DBGLV_ALL //show error, information & funciton name 229 } E_PWS_DBG_LEVEL; 230 231 typedef struct 232 { 233 E_PWS_DBG_LEVEL u8DbgLevel; 234 MS_BOOL bInit; 235 } PWS_Status; 236 237 typedef struct 238 { 239 E_PWS_SouceInfo SourceList; 240 MS_U32 u32IOMap; 241 } PWS_Info; 242 243 typedef enum 244 { 245 E_PWS_API_UNUSED = 0, 246 E_PWS_USE_HANDLE_SOURCE = 1, 247 E_PWS_USE_HANDLE_IP = 2 248 } E_PWS_Use; 249 250 typedef enum 251 { 252 E_PWS_IP_ON = 0, 253 E_PWS_IP_OFF = 1 254 } E_PWS_IpPowerCtrl; 255 256 typedef enum 257 { 258 E_PWS_IP_CALLBACK_BEFORE_ON = 0, 259 E_PWS_IP_CALLBACK_BEFORE_OFF = 1, 260 E_PWS_IP_CALLBACK_AFTER_ON = 2, 261 E_PWS_IP_CALLBACK_AFTER_OFF = 3, 262 E_PWS_IP_CALLBACK_UNKNOWN = 4 263 } E_PWS_CallbackCtrl; 264 265 #define STR_LEN 32 266 typedef void (*P_PWS_Callback)(void); 267 typedef struct 268 { 269 E_PWS_CallbackCtrl ctrl; 270 unsigned char regName[STR_LEN]; 271 P_PWS_Callback _PWSCallback; 272 } PWS_RegisterCallback; 273 274 typedef enum 275 { 276 E_PWS_VIF_NO_SAW = 0, 277 E_PWS_VIF_SINGLE_SAW = 1, 278 E_PWS_VIF_DUAL_SAW = 2, 279 E_PWS_VIF_SINGLE_SAW_DIF = 3, 280 E_PWS_VIF_UNKNOWN = 3 281 } E_PWS_VIF_type; 282 283 #define PWS_Register_CB_size 2 284 285 286 typedef enum 287 { 288 E_PWS_IP_AUDIO = 0, 289 E_PWS_IP_DEMOD, 290 E_PWS_IP_AUPLL, 291 E_PWS_IP_USB_PORT0, 292 E_PWS_IP_USB_PORT1, 293 E_PWS_IP_USB_PORT2, 294 E_PWS_IP_USB_PORT3, 295 E_PWS_IP_USB_3, 296 E_PWS_IP_MHL, 297 E_PWS_IP_VEDIO, 298 E_PWS_IP_ATSC_DVBTC, 299 E_PWS_IP_GME, 300 E_PWS_IP_GMAC, 301 E_PWS_IP_IDAC, 302 E_PWS_IP_ETH, 303 E_PWS_IP_TSP, 304 E_PWS_IP_CLK_R2_SECURE, 305 E_PWS_IP_VE, 306 E_PWS_IP_AUDIO_R2, 307 E_PWS_IP_MAX 308 } E_PWS_IP_name; 309 310 //------------------------------------------------------------------------------ 311 // Extern Function 312 //------------------------------------------------------------------------------ 313 //------------------------------------------------------------------------------------------------- 314 /// MOBF Encrypt 315 /// @ingroup G_PWS_COMMON 316 /// @param u32Key \b IN: Key 317 /// @param bEnable \b IN: TRUE/FLASE 318 /// @return DRVAESDMA_OK : Success 319 /// @return Others : Fail 320 //------------------------------------------------------------------------------------------------- 321 // E_PWS_Result MDrv_PWS_GetLibVer(const MSIF_Version **ppVersion); 322 //------------------------------------------------------------------------------------------------- 323 /// MOBF Encrypt 324 /// @ingroup G_PWS_COMMON 325 /// @param u32Key \b IN: Key 326 /// @param bEnable \b IN: TRUE/FLASE 327 /// @return DRVAESDMA_OK : Success 328 /// @return Others : Fail 329 //------------------------------------------------------------------------------------------------- 330 E_PWS_Result MDrv_PWS_SetDbgLevel(E_PWS_DBG_LEVEL eLEVEL); 331 //------------------------------------------------------------------------------------------------- 332 /// MOBF Encrypt 333 /// @ingroup G_PWS_COMMON 334 /// @param u32Key \b IN: Key 335 /// @param bEnable \b IN: TRUE/FLASE 336 /// @return DRVAESDMA_OK : Success 337 /// @return Others : Fail 338 //------------------------------------------------------------------------------------------------- 339 void MDrv_PWS_GetInfo(PWS_Info *pInfo); // ToBeRemove 340 //------------------------------------------------------------------------------------------------- 341 /// MOBF Encrypt 342 /// @ingroup G_PWS_COMMON 343 /// @param u32Key \b IN: Key 344 /// @param bEnable \b IN: TRUE/FLASE 345 /// @return DRVAESDMA_OK : Success 346 /// @return Others : Fail 347 //------------------------------------------------------------------------------------------------- 348 void MDrv_PWS_GetStatus(PWS_Status *pStatus); 349 //------------------------------------------------------------------------------------------------- 350 /// MOBF Encrypt 351 /// @ingroup G_PWS_COMMON 352 /// @param u32Key \b IN: Key 353 /// @param bEnable \b IN: TRUE/FLASE 354 /// @return DRVAESDMA_OK : Success 355 /// @return Others : Fail 356 //------------------------------------------------------------------------------------------------- 357 E_PWS_SouceInfo MDrv_PWS_GetSourceInfo(void); 358 //------------------------------------------------------------------------------------------------- 359 /// MOBF Encrypt 360 /// @ingroup G_PWS_COMMON 361 /// @param u32Key \b IN: Key 362 /// @param bEnable \b IN: TRUE/FLASE 363 /// @return DRVAESDMA_OK : Success 364 /// @return Others : Fail 365 //------------------------------------------------------------------------------------------------- 366 // MS_U16 MDrv_PWS_Read2Byte(MS_U32 u32RegAddr ); 367 //------------------------------------------------------------------------------------------------- 368 /// MOBF Encrypt 369 /// @ingroup G_PWS_COMMON 370 /// @param u32Key \b IN: Key 371 /// @param bEnable \b IN: TRUE/FLASE 372 /// @return DRVAESDMA_OK : Success 373 /// @return Others : Fail 374 //------------------------------------------------------------------------------------------------- 375 // E_PWS_Result MDrv_PWS_IpPowerControl(E_PWS_IP_name eIpName, E_PWS_IpPowerCtrl pwr_type); 376 //------------------------------------------------------------------------------------------------- 377 /// MOBF Encrypt 378 /// @ingroup G_PWS_INIT 379 /// @param u32Key \b IN: Key 380 /// @param bEnable \b IN: TRUE/FLASE 381 /// @return DRVAESDMA_OK : Success 382 /// @return Others : Fail 383 //------------------------------------------------------------------------------------------------- 384 E_PWS_Result MDrv_PWS_Init(E_PWS_VIF_type eVifType); 385 //------------------------------------------------------------------------------------------------- 386 /// MOBF Encrypt 387 /// @ingroup G_PWS_CONTROL 388 /// @param u32Key \b IN: Key 389 /// @param bEnable \b IN: TRUE/FLASE 390 /// @return DRVAESDMA_OK : Success 391 /// @return Others : Fail 392 //------------------------------------------------------------------------------------------------- 393 E_PWS_Result MDrv_PWS_HandleSource(E_PWS_Operation operation,E_PWS_SouceInfo source,E_PWS_Sync sync_type); 394 //------------------------------------------------------------------------------------------------- 395 /// MOBF Encrypt 396 /// @ingroup G_PWS_ToBeRemove 397 /// @param u32Key \b IN: Key 398 /// @param bEnable \b IN: TRUE/FLASE 399 /// @return DRVAESDMA_OK : Success 400 /// @return Others : Fail 401 //------------------------------------------------------------------------------------------------- 402 // E_PWS_Result MDrv_PWS_HandleIP(E_PWS_IpPowerCtrl IpPowerCtrl,const unsigned char *RegName); // ToBeRemove 403 //------------------------------------------------------------------------------------------------- 404 /// MOBF Encrypt 405 /// @ingroup G_PWS_COMMON 406 /// @param u32Key \b IN: Key 407 /// @param bEnable \b IN: TRUE/FLASE 408 /// @return DRVAESDMA_OK : Success 409 /// @return Others : Fail 410 //------------------------------------------------------------------------------------------------- 411 // E_PWS_Result MDrv_PWS_RegisterCallback(MS_U8 index,E_PWS_CallbackCtrl cb_ctrl,unsigned char *RegName,P_PWS_Callback pfCallback); 412 //------------------------------------------------------------------------------------------------- 413 /// MOBF Encrypt 414 /// @ingroup G_PWS_COMMON 415 /// @param u32Key \b IN: Key 416 /// @param bEnable \b IN: TRUE/FLASE 417 /// @return DRVAESDMA_OK : Success 418 /// @return Others : Fail 419 //------------------------------------------------------------------------------------------------- 420 // E_PWS_Result MDrv_PWS_CancelCallback(MS_U8 index); 421 //------------------------------------------------------------------------------------------------- 422 /// MOBF Encrypt 423 /// @ingroup G_PWS_COMMON 424 /// @param u32Key \b IN: Key 425 /// @param bEnable \b IN: TRUE/FLASE 426 /// @return DRVAESDMA_OK : Success 427 /// @return Others : Fail 428 //------------------------------------------------------------------------------------------------- 429 MS_U32 MDrv_PWS_SetPowerState(EN_POWER_MODE u16PowerState); 430 #if defined (MSOS_TYPE_LINUX) 431 //------------------------------------------------------------------------------------------------- 432 /// MOBF Encrypt 433 /// @ingroup G_PWS_ToBeRemove 434 /// @param u32Key \b IN: Key 435 /// @param bEnable \b IN: TRUE/FLASE 436 /// @return DRVAESDMA_OK : Success 437 /// @return Others : Fail 438 //------------------------------------------------------------------------------------------------- 439 E_PWS_Result MDrv_PWS_PHYPower(E_PWS_PHY bSetFlag); // ToBeRemove 440 #endif 441 442 //------------------------------------------------------------------------------------ 443 // Utopia 2.0 444 //------------------------------------------------------------------------------------ 445 typedef enum { 446 MDrv_CMD_PWS_GetLibVer, 447 MDrv_CMD_PWS_SetDbgLevel, 448 MDrv_CMD_PWS_HandleSource, 449 MDrv_CMD_PWS_PHYPower, 450 } ePwsIoctlOpt; 451 452 typedef E_PWS_Result (*IOCTL_PWS_GETLIBVER)(const MSIF_Version **); 453 typedef E_PWS_Result (*IOCTL_PWS_SETDBGLEVEL)(E_PWS_DBG_LEVEL); 454 typedef E_PWS_Result (*IOCTL_PWS_HANDLESOURCE)(E_PWS_Operation, E_PWS_SouceInfo, E_PWS_Sync); 455 #if defined (MSOS_TYPE_LINUX) 456 typedef E_PWS_Result (*IOCTL_PWS_PHYPOWER)(E_PWS_PHY); 457 #endif 458 459 typedef struct _PWS_INSTANT_PRIVATE 460 { 461 IOCTL_PWS_GETLIBVER fpPWSGetLibVer; 462 IOCTL_PWS_SETDBGLEVEL fpPWSSetDbgLevel; 463 IOCTL_PWS_HANDLESOURCE fpPWSHandleSource; 464 #if defined (MSOS_TYPE_LINUX) 465 IOCTL_PWS_PHYPOWER fpPWSPHYPower; 466 #endif 467 }PWS_INSTANT_PRIVATE; 468 469 // for pws MDrv_PWS_GetLibVer 470 typedef struct _PWS_GETLIBVER_PARAM 471 { 472 const MSIF_Version **ppVersion; 473 }PWS_GETLIBVER_PARAM, *PPWS_GETLIBVER_PARAM; 474 475 // for pws MDrv_PWS_SetDbgLevel 476 typedef struct _PWS_SETDBGLEVEL_PARAM 477 { 478 E_PWS_DBG_LEVEL DbgLevel; 479 }PWS_SETDBGLEVEL_PARAM, *PPWS_SETDBGLEVEL_PARAM; 480 481 // for pws MDrv_PWS_HandleSource 482 typedef struct _PWS_HANDLESOURCE_PARAM 483 { 484 E_PWS_Operation operation; 485 E_PWS_SouceInfo source; 486 E_PWS_Sync sync_type; 487 }PWS_HANDLESOURCE_PARAM, *PPWS_HANDLESOURCE_PARAM; 488 489 #if defined (MSOS_TYPE_LINUX) 490 // for pws MDrv_PWS_PHYPower 491 typedef struct _PWS_PHYPOWER_PARAM 492 { 493 E_PWS_PHY bSetFlag; 494 }PWS_PHYPOWER_PARAM, *PPWS_PHYPOWER_PARAM; 495 #endif 496 497 // void PWSRegisterToUtopia(FUtopiaOpen ModuleType); 498 //------------------------------------------------------------------------------------------------- 499 /// MOBF Encrypt 500 /// @ingroup G_PWS_ToBeRemove 501 /// @param u32Key \b IN: Key 502 /// @param bEnable \b IN: TRUE/FLASE 503 /// @return DRVAESDMA_OK : Success 504 /// @return Others : Fail 505 //------------------------------------------------------------------------------------------------- 506 MS_U32 PWSOpen(void** pInstance, MS_U32 u32ModuleVersion, void* pAttribute); 507 //------------------------------------------------------------------------------------------------- 508 /// MOBF Encrypt 509 /// @ingroup G_PWS_ToBeRemove 510 /// @param u32Key \b IN: Key 511 /// @param bEnable \b IN: TRUE/FLASE 512 /// @return DRVAESDMA_OK : Success 513 /// @return Others : Fail 514 //------------------------------------------------------------------------------------------------- 515 // MS_U32 PWSClose(void* pInstance); 516 //------------------------------------------------------------------------------------------------- 517 /// MOBF Encrypt 518 /// @ingroup G_PWS_ToBeRemove 519 /// @param u32Key \b IN: Key 520 /// @param bEnable \b IN: TRUE/FLASE 521 /// @return DRVAESDMA_OK : Success 522 /// @return Others : Fail 523 //------------------------------------------------------------------------------------------------- 524 // MS_U32 PWSIoctl(void* pInstance, MS_U32 u32Cmd, void *pArgs); 525 526 //PWS_Private 527 typedef struct _PWS_RESOURCE_PRIVATE 528 { 529 MS_U32 Dummy; 530 }PWS_RESOURCE_PRIVATE; 531 532 #ifdef __cplusplus 533 } 534 #endif 535 536 #endif 537