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!L) 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 drvXC_HDMI_if.h 98 /// @brief HDMI Interface 99 /// @author MStar Semiconductor Inc. 100 /////////////////////////////////////////////////////////////////////////////////////////////////// 101 102 /*! \defgroup MISC HDMI modules 103 104 * \defgroup HDMI_IF HDMI interface (drvXC_HDMI_if.h) 105 * \ingroup MISC 106 107 <b> Features </b> 108 - HDMI Ethernet Channel 109 Support Ethernet communication through HDMI 110 - Audio Return Channel 111 - 3D support 112 - Frame packing, Side-by-Side half, Top-Buttom and etc. 113 - 4Kx2K support 114 3840x2160@24/25/30Hz, 4096x2160@24Hz 115 - Additional Color Spaces 116 sYCC601, AdobeRGB, AdobeYCC601 117 - HDMI Micro Connector 118 19-pin/1080p 119 120 \image html api_HDMI_if_pic1.png 121 122 <b> Operation Flow </b> 123 - Initialized and enable HDMI 124 - MApi_HDMITx_SetHPDGpioPin(_st_msAPI_XC_InitData.u16HdmitxHpdPin); 125 - MApi_HDMITx_Init(); 126 - MApi_HDMITx_TurnOnOff(TRUE); 127 - MApi_HDMITx_SetVideoOnOff(TRUE) 128 - MApi_HDMITx_SetAudioConfiguration(HDMITX_AUDIO_48K, HDMITX_AUDIO_CH_2, HDMITX_AUDIO_PCM); 129 */ 130 #ifndef DRVXC_HDMI_IF_H 131 #define DRVXC_HDMI_IF_H 132 133 #include "MsDevice.h" 134 #include "MsCommon.h" 135 #ifdef __cplusplus 136 extern "C" 137 { 138 #endif 139 140 //------------------------------------------------------------------------------------------------- 141 // Driver Capability 142 //------------------------------------------------------------------------------------------------- 143 144 #ifdef MDRV_HDMI_C 145 #define INTERFACE 146 #else 147 #define INTERFACE extern 148 #endif 149 150 //------------------------------------------------------------------------------------------------- 151 // Macro and Define 152 //------------------------------------------------------------------------------------------------- 153 #define _BYTE_0 0x00 154 #define _BYTE_1 0x01 155 #define _BYTE_2 0x02 156 #define _BYTE_3 0x03 157 #define _BYTE_4 0x04 158 #define _BYTE_5 0x05 159 #define _BYTE_6 0x06 160 #define _BYTE_7 0x07 161 #define _BYTE_8 0x08 162 #define _BYTE_9 0x09 163 #define _BYTE_10 0x0A 164 #define _BYTE_11 0x0B 165 #define _BYTE_12 0x0C 166 #define _BYTE_13 0x0D 167 // library information 168 #define MSIF_HDMI_LIB_CODE {'H','D','M','I'} 169 #define MSIF_HDMI_LIBVER {'0','1'} 170 #define MSIF_HDMI_BUILDNUM {'0','7'} 171 #define MSIF_HDMI_CHANGELIST {'0','0','3','5','1','6','6','3'} 172 #define HDMI_DRV_VERSION /* Character String for DRV/API version */ \ 173 MSIF_TAG, /* 'MSIF' */ \ 174 MSIF_CLASS, /* '00' */ \ 175 MSIF_CUS, /* 0x0000 */ \ 176 MSIF_MOD, /* 0x0000 */ \ 177 MSIF_CHIP, \ 178 MSIF_CPU, \ 179 MSIF_HDMI_LIB_CODE , /* IP__ */ \ 180 MSIF_HDMI_LIBVER , /* 0.0 ~ Z.Z */ \ 181 MSIF_HDMI_BUILDNUM , /* 00 ~ 99 */ \ 182 MSIF_HDMI_CHANGELIST, /* CL# */ \ 183 MSIF_OS 184 185 #define HDMI_VSDB_PACKET_SIZE 14 186 #define HDMI_HDR_PACKET_SIZE HDMI_VSDB_PACKET_SIZE 187 188 /// Extend packet receive structure version 189 #define HDMI_EXTEND_PACKET_RECEIVE_VERSION 1 190 #define HDMI_EXTEND_PACKET_RECEIVE_VERSION_1_SIZE 22 191 192 /// HDR metadata structure version 193 #define HDMI_HDR_METADATA_VERSION 1 194 #define HDMI_HDR_METADATA_VERSION_1_SIZE 30 195 196 //------------------------------------------------------------------------------------------------- 197 // Type and Structure 198 //------------------------------------------------------------------------------------------------- 199 // for HDCP 22 callback function 200 typedef void (*HDCP22_Recv_CBF)(MS_U8, MS_U8, MS_U8*, MS_U32, void*); //type, portIdx, msg, msg length, context 201 202 203 typedef enum 204 { 205 E_HDMI_SWITCH_VSDB_TO_HDR_PACKET, 206 E_HDMI_HDR_INFOFRAME_GET, 207 E_HDMI_EXTEND_PACKET_RECEIVE_GET 208 } E_HDMI_CTRL_ID; 209 210 /// HDMI reset type 211 typedef enum 212 { 213 REST_AVMUTE = _BIT(8), ///<HDMI Reset bit[8] 214 REST_Y_COLOR = _BIT(9), ///<HDMI Reset bit[9] 215 REST_PIXEL_REPETITION = _BIT(10), ///<HDMI Reset bit[10] 216 REST_FRAME_REPETITION = _BIT(11), ///<HDMI Reset bit[11] 217 REST_GCP_PKT = _BIT(12), ///<HDMI Reset bit[12] 218 REST_DEEP_COLOR_FIFO = _BIT(13), ///<HDMI Reset bit[13] 219 REST_RESERVE = _BIT(14), ///<HDMI Reset bit[14] 220 REST_HDMI_STATUS = _BIT(15), ///<HDMI Reset bit[15] 221 }HDMI_REST_t; 222 223 /*! 224 HDMI Aspect Ratio TYPE 225 */ 226 typedef enum 227 { 228 // Active Format Aspect Ratio - AFAR 229 // HDMI_AF_AR_Not_Present = -1, ///< IF0[11..8] AFD not present, or AFD not yet found 230 HDMI_AF_AR_Reserve_0 = 0x00, ///< IF0[11..8] 0000, Reserved 231 HDMI_AF_AR_Reserve_1 = 0x01, ///< IF0[11..8] 0001, Reserved 232 HDMI_AF_AR_16x9_Top = 0x02, ///< IF0[11..8] 0010, box 16:9 (top). 233 HDMI_AF_AR_14x9_Top = 0x03, ///< IF0[11..8] 0011, box 14:9 (top). 234 HDMI_AF_AR_GT_16x9 = 0x04, ///< IF0[11..8] 0100, box >16:9 (centre) 235 HDMI_AF_AR_Reserve_5 = 0x05, ///< IF0[11..8] 0101, Reserved 236 HDMI_AF_AR_Reserve_6 = 0x06, ///< IF0[11..8] 0110, Reserved 237 HDMI_AF_AR_Reserve_7 = 0x07, ///< IF0[11..8] 0111, Reserved 238 HDMI_AF_AR_SAME = 0x08, ///< IF0[11..8] 1000, same as picture 239 HDMI_AF_AR_4x3_C = 0x09, ///< IF0[11..8] 1001, 4:3 Center 240 HDMI_AF_AR_16x9_C = 0x0A, ///< IF0[11..8] 1010, 16:9 Center 241 HDMI_AF_AR_14x9_C = 0x0B, ///< IF0[11..8] 1011, 14:9 Center 242 HDMI_AF_AR_Reserve_12 = 0x0C, ///< IF0[11..8] 1100, Reserved. 243 HDMI_AF_AR_4x3_with_14x9_C = 0x0D, ///< IF0[11..8] 1101, 4:3 with shoot and protect 14:9 centre. 244 HDMI_AF_AR_16x9_with_14x9_C = 0x0E, ///< IF0[11..8] 1110, 16:9 with shoot and protect 14:9 centre. 245 HDMI_AF_AR_16x9_with_4x3_C = 0x0F, ///< IF0[11..8] 1111, 16:9 with shoot and protect 4:3 centre. 246 247 // Picture Aspect Ratio - PAR 248 HDMI_Pic_AR_NODATA = 0x00, ///< IF0[13..12] 00 249 HDMI_Pic_AR_4x3 = 0x10, ///< IF0[13..12] 01, 4:3 250 HDMI_Pic_AR_16x9 = 0x20, ///< IF0[13..12] 10, 16:9 251 HDMI_Pic_AR_RSV = 0x30, ///< IF0[13..12] 11, reserved 252 } MS_HDMI_AR_TYPE; 253 254 //------------------------------------------------------------------------------------------------- 255 /// AVI infomation frame version 256 //------------------------------------------------------------------------------------------------- 257 typedef enum 258 { 259 E_AVI_INFOFRAME_VERSION_NON, //invalid version 260 E_AVI_INFOFRAME_VERSION1, //AVI infomation frame version 1 261 E_AVI_INFOFRAME_VERSION2, //AVI infomation frame version 2 262 E_AVI_INFOFRAME_VERSION3 //AVI infomation frame version 3 263 }EN_AVI_INFOFRAME_VERSION; 264 265 #define HDMI_AR_INIT_VALUE (HDMI_Pic_AR_RSV) 266 #define HDMI_AR_REG_MASK (0x3F) 267 #define HDMI_AFAR_MASK (0x0F) // mask to get the AFAR 268 #define HDMI_AR_MASK (0x30) // mask to get the PAR 269 270 /// HDMI GControl package type. 271 typedef enum 272 { 273 G_CTRL_AVMUTE = 0, ///< bit[0]: AVMUTE 274 G_Ctrl_DEFAULT_PHASE, ///< bit[1]: Default_Phase 275 G_Ctrl_LAST_PP, ///< bit[4:2]: LAST_PP[2:0] 276 G_Ctrl_PRE_LPP, ///< bit[7:5]: PRE_LPP[2:0] 277 G_Ctrl_CD_VAL, ///< bit[11:8]: CD_VAL[3:0] 278 G_Ctrl_PP_VAL, ///< bit[15:12]: PP_VAL[3:0] 279 G_Ctrl_ALL 280 }HDMI_GControl_INFO_t; 281 282 /// HDMI PLL control type 283 typedef enum 284 { 285 PLL_CTRL_L=0, ///< HDMI_PLL_CTRL1_L 7:0 286 PLL_CTRL_MANUAL_DIV, ///< MANUAL_PLL_DIV 7 287 PLL_CTRL_PORST, ///< PLL_PORST 6 288 PLL_CTRL_RESET_TP, ///< RESET_TP 5 289 PLL_CTRL_RESET_TF, ///< RESET_TF 4 290 PLL_CTRL_RESET_TI, ///< RESET_TI 3 291 PLL_CTRL_VCO_OFFSET, ///< VCO_OFFSET 2 292 PLL_CTRL_RESET, ///< PLL_RESET 1 293 PLL_CTRL_PWRDOWN, ///< PWRDOWN 0 294 295 PLL_CTRL_H, ///< HDMI_PLL_CTRL1_H 7:0 296 PLL_CTRL_KN, ///< KN[1:0] 7:6 297 PLL_CTRL_RCTRL, ///< RCTRL 5:3 298 PLL_CTRL_ICTRL, ///< ICTRL 2:0 299 }HDMI_PLL_CTRL_t; 300 301 /// HDMI PLL control type 302 typedef enum 303 { 304 PLL_CTRL2_L, ///< HDMI_PLL_CTRL2_L 7:0 305 PLL_CTRL2_KP, ///< KP[3:0] 7:4 306 PLL_CTRL2_KM, ///< KM[3:0] 3:0 307 308 PLL_CTRL2_H, ///< HDMI_PLL_CTRL2_H 7:0 309 PLL_CTRL2_DDIV, ///< DDIV[3:0] 7:4 310 PLL_CTRL2_FBDIV, ///< FBDIV[3:0] 3:0 311 }HDMI_PLL_CTRL2_t; 312 313 ////===========================>>HDMI 314 typedef struct 315 { 316 MS_BOOL bIsHDMIMode; 317 MS_BOOL bMuteHDMIVideo; 318 319 MS_BOOL bMuteHDMIAudio; 320 MS_BOOL bEnableNonPCM; 321 MS_U8 u8AudioStbCnt; // If stable more than HDMI_AUDIO_STABLE_CNT, enable audio 322 // In 199M case, audio on->off->on->off->on, so, we wait 4 * HDMI_AUDIO_STABLE_CNT, if unstable, 323 // enable audio still to prevent mute audio always because of un-stable 324 MS_U8 u8AudioForceEnableCnt; 325 326 MS_U8 u8ColorFormat; 327 MS_U8 u8LostHDMICounter; 328 MS_BOOL bColorFMTChange; 329 MS_U8 u8PreClolrFormat; 330 MS_U8 u8AspectRatio; 331 } HDMI_POLLING_STATUS_t; 332 333 typedef enum 334 { 335 MS_DVI_CHANNEL_R, 336 MS_DVI_CHANNEL_G, 337 MS_DVI_CHANNEL_B, 338 } MS_DVI_CHANNEL_TYPE; 339 340 /// HDMI COLOR FORMAT 341 typedef enum 342 { 343 MS_HDMI_COLOR_RGB, ///< HDMI RGB 444 Color Format 344 MS_HDMI_COLOR_YUV_422, ///< HDMI YUV 422 Color Format 345 MS_HDMI_COLOR_YUV_444, ///< HDMI YUV 444 Color Format 346 MS_HDMI_COLOR_YUV_420, ///< HDMI YUV 420 Color Format 347 MS_HDMI_COLOR_RESERVED, ///< Reserve 348 MS_HDMI_COLOR_DEFAULT = MS_HDMI_COLOR_RGB, ///< Default setting 349 MS_HDMI_COLOR_UNKNOWN = 7, ///< Unknow Color Format 350 } MS_HDMI_COLOR_FORMAT; 351 352 /// HDMI Extended COLORIMETRY 353 typedef enum 354 { 355 MS_HDMI_EXT_COLOR_XVYCC601, ///< xvycc 601 356 MS_HDMI_EXT_COLOR_XVYCC709, ///< xvycc 709 357 MS_HDMI_EXT_COLOR_SYCC601, ///< sYCC 601 358 MS_HDMI_EXT_COLOR_ADOBEYCC601, ///< Adobe YCC 601 359 MS_HDMI_EXT_COLOR_ADOBERGB, ///< Adobe RGB 360 MS_HDMI_EXT_COLOR_DEFAULT = MS_HDMI_EXT_COLOR_XVYCC601, ///< Default setting 361 MS_HDMI_EXT_COLOR_UNKNOWN = 7, ///< Unknow 362 } MS_HDMI_EXT_COLORIMETRY_FORMAT; 363 364 /// HDMI Content Type 365 typedef enum 366 { 367 MS_HDMI_CONTENT_NoData = 0, // No Data. 368 MS_HDMI_CONTENT_Graphics, // Graphics(text). 369 MS_HDMI_CONTENT_Photo, // Photo type. 370 MS_HDMI_CONTENT_Cinema, // Cinema type. 371 MS_HDMI_CONTENT_Game, // Game type. 372 } MS_HDMI_CONTENT_TYPE; 373 374 ///HDMI COLOR RANGE 375 typedef enum 376 { 377 E_HDMI_COLOR_RANGE_DEFAULT, // 378 E_HDMI_COLOR_RANGE_LIMIT, //HDMI RGB Limited Range (16-235) 379 E_HDMI_COLOR_RANGE_FULL, //HDMI Full Range (0-255) 380 E_HDMI_COLOR_RANGE_RESERVED 381 } EN_HDMI_COLOR_RANGE; 382 383 /// HDMI Equalize Level 384 typedef enum 385 { 386 MS_HDMI_EQ_2M, ///< HDMI EQ 2M 387 MS_HDMI_EQ_10M, ///< HDMI EQ 10M 388 MS_HDMI_EQ_15M, ///< HDMI EQ 15M 389 MS_HDMI_EQ_MAX, ///< HDMI EQ MAX 390 MS_HDMI_EQ_USER_DEFINE, ///< HDMI EQ User define 391 } MS_HDMI_EQ; 392 393 /// HDMI Packet nauber 394 typedef enum 395 { 396 PKT_MPEG = _BIT(0), ///< Pactet[0] 397 PKT_AUI = _BIT(1), ///< Pactet[1] 398 PKT_SPD = _BIT(2), ///< Pactet[2] 399 PKT_AVI = _BIT(3), ///< Pactet[3] 400 PKT_GC = _BIT(4), ///< Pactet[4] 401 PKT_ASAMPLE = _BIT(5), ///< Pactet[5] 402 PKT_ACR = _BIT(6), ///< Pactet[6] 403 PKT_VS = _BIT(7), ///< Pactet[7] 404 PKT_NULL = _BIT(8), ///< Pactet[8] 405 PKT_ISRC2 = _BIT(9), ///< Pactet[9] 406 PKT_ISRC1 = _BIT(10), ///< Pactet[10] 407 PKT_ACP = _BIT(11), ///< Pactet[11] 408 PKT_ONEBIT_AUD = _BIT(12), ///< Pactet[12] 409 PKT_GM = _BIT(13), ///< Pactet[13] 410 PKT_HBR = _BIT(14), ///< Pactet[14] 411 PKT_VBI = _BIT(15), ///< Pactet[15] 412 PKT_HDR = _BIT(16), ///< Pactet[16] 413 PKT_RSV = _BIT(17), ///< Pactet[17] 414 }MS_HDMI_PACKET_STATE_t; 415 416 typedef enum 417 { 418 CAPS_DVI_ADJ_70M = _BIT(0), 419 CAPS_VSYNC_END_EN = _BIT(1), 420 }MS_HDMI_FUNC_CAPS; 421 422 /// HDMI PACKET VALUE structure 423 typedef struct __attribute__((packed)) 424 { 425 MS_U16 PKT_MPEG_VALUE; ///< MPEG packet content 426 MS_U16 PKT_AUI_VALUE; ///< AUI packet content 427 MS_U16 PKT_SPD_VALUE; ///< SPD packet content 428 MS_U16 PKT_AVI_VALUE; ///< AVI packet content 429 MS_U16 PKT_GC_VALUE; ///< GC packet content 430 MS_U16 PKT_ASAMPLE_VALUE; ///< ASAMPLE packet content 431 MS_U16 PKT_ACR_VALUE; ///< ACR packet content 432 MS_U16 PKT_VS_VALUE; ///< VS packet content 433 MS_U16 PKT_NULL_VALUE; ///< NULL packet content 434 MS_U16 PKT_ISRC2_VALUE; ///< ISRC2 packet content 435 MS_U16 PKT_ISRC1_VALUE; ///< ISRC1 packet content 436 MS_U16 PKT_ACP_VALUE; ///< ACP packet content 437 MS_U16 PKT_ONEBIT_AUD_VALUE; ///< ONE bit AUD packet content 438 }MS_HDMI_PACKET_VALUE_t; 439 440 /// Received HDMI packet flag. 441 typedef struct __attribute__((packed)) 442 { 443 MS_U16 u16Version; /// Version. 444 MS_U16 u16Size; /// Structure size. 445 MS_BOOL bPKT_MPEG_RECEIVE; ///< MPEG packet enable 446 MS_BOOL bPKT_AUI_RECEIVE; ///< AUI packet enable 447 MS_BOOL bPKT_SPD_RECEIVE; ///< SPD packet enable 448 MS_BOOL bPKT_AVI_RECEIVE; ///< AVI packet enable 449 MS_BOOL bPKT_GC_RECEIVE; ///< GC packet enable 450 MS_BOOL bPKT_ASAMPLE_RECEIVE; ///< ASAMPLE packet enable 451 MS_BOOL bPKT_ACR_RECEIVE; ///< ACR packet enable 452 MS_BOOL bPKT_VS_RECEIVE; ///< VS packet enable 453 MS_BOOL bPKT_NULL_RECEIVE; ///< NULL packet enable 454 MS_BOOL bPKT_ISRC2_RECEIVE; ///< ISRC2 packet enable 455 MS_BOOL bPKT_ISRC1_RECEIVE; ///< ISRC1 packet enable 456 MS_BOOL bPKT_ACP_RECEIVE; ///< ACP packet enable 457 MS_BOOL bPKT_ONEBIT_AUD_RECEIVE; ///< ONE bit AUD packet enable 458 MS_BOOL bPKT_GM_RECEIVE; /// <GM packet enable 459 MS_BOOL bPKT_HBR_RECEIVE; /// <HBR packet enable 460 MS_BOOL bPKT_VBI_RECEIVE; /// <VBIpacket enable 461 MS_BOOL bPKT_HDR_RECEIVE; ///< HDR packet enable 462 MS_BOOL bPKT_RSV_RECEIVE; ///< RSV packet enable 463 }MS_HDMI_EXTEND_PACKET_RECEIVE_t; 464 465 466 467 typedef struct 468 { 469 MS_U8 AVMuteStatus; 470 MS_U8 AudioNotPCM; 471 MS_U8 PreAudiostatus; 472 MS_U8 ChecksumErrOrBCHParityErr; 473 MS_U8 PacketColorFormat; 474 MS_U8 AspectRatio; 475 MS_U8 AudioPacketErr; 476 MS_U8 ACPType; 477 } MS_HDMI_PACKET_STATUS_t; 478 479 480 typedef struct 481 { 482 MS_HDMI_PACKET_VALUE_t enPKT_Value; 483 MS_HDMI_PACKET_STATUS_t enPKT_Status; 484 } HDMI_PACKET_INFO_t, *P_HDMI_PACKET_INFO_t; 485 486 /// HDCP STATUS INFO structure 487 typedef struct __attribute__((packed)) 488 { 489 MS_BOOL b_St_HDMI_Mode; ///> HDCP_STATUS[0] & BIT0 490 MS_BOOL b_St_Reserve_1; ///> (HDCP_STATUS[0] & BIT1)>>1 491 MS_BOOL b_St_HDCP_Ver; ///> (HDCP_STATUS[0] & BIT2)>>2 492 MS_BOOL b_St_AVMute; ///> (HDCP_STATUS[0] & BIT3)>>3 493 MS_BOOL b_St_ENC_En; ///> (HDCP_STATUS[0] & BIT4)>>4 494 MS_BOOL b_St_AKsv_Rcv; ///> (HDCP_STATUS[0] & BIT5)>>5 495 MS_BOOL b_St_ENC_Dis; ///> (HDCP_STATUS[0] & BIT6)>>6 496 MS_BOOL b_St_Reserve_7; ///> (HDCP_STATUS[0] & BIT7)>>7 497 }MS_HDCP_STATUS_INFO_t; 498 499 /// HDMI Black Level 500 typedef enum 501 { 502 E_BLACK_LEVEL_LOW = 0, ///> HDMI black level low 503 E_BLACK_LEVEL_HIGH, ///> HDMI black level high 504 } BLACK_LEVEL; 505 506 /// VGA/DVI/HDMI EDID 507 typedef enum 508 { 509 E_XC_PROG_DVI0_EDID = 0x00, 510 E_XC_PROG_DVI1_EDID = 0x01, 511 E_XC_PROG_DVI2_EDID = 0x02, 512 E_XC_PROG_DVI3_EDID = 0x03, 513 E_XC_PROG_VGA_EDID = 0x10, 514 } E_XC_DDCRAM_PROG_TYPE; 515 516 typedef struct 517 { 518 MS_U8 *EDID; ///< customer EDID 519 MS_U16 u16EDIDSize; ///< 128 for VGA/DVI , 256 for HDMI 520 E_XC_DDCRAM_PROG_TYPE eDDCProgType; ///< what kind of DDCRam to program 521 522 MS_U16 u16CECPhyAddr; ///< if only 1 Digital DDCRam (get this information from MApi_XC_GetInfo()), you need to specify CEC physical address here 523 MS_U8 u8CECPhyAddrIdxL; ///< start point of CEC physical address (low byte) in EDID 524 MS_U8 u8CECPhyAddrIdxH; ///< start point of CEC physical address (high byte) in EDID 525 } XC_DDCRAM_PROG_INFO; 526 527 ////===========================>>HDCP 528 529 ///HDCP polling status 530 typedef struct 531 { 532 MS_BOOL bHPD_OK; ///< HPD OK 533 MS_U16 u16HPD_Counter; ///< HPD times counter 534 MS_U16 u16HDCP_KeyCounter; /// > HDCP key number 535 MS_U16 u16HDCP_KeyChkSum; ///> HDCP key check sum 536 MS_BOOL bIsPullHighHPD; ///> HPD is high or not 537 MS_U8 u8BKSV[5]; ///> BKSV 538 539 } HDCP_POLLING_STATUS_t; 540 541 /** 542 * The return value for HDMI fuction. 543 */ 544 typedef enum 545 { 546 /// fail 547 E_HDMI_RET_FAIL = 0, 548 /// success 549 E_HDMI_RET_OK, 550 } HDMI_Ret_Value; 551 552 553 // HDMI v1.4 new feature - T8 and T9 554 typedef enum 555 { 556 E_HDMI_NO_ADDITIONAL_FORMAT, // 000 557 E_HDMI_4Kx2K_FORMAT, // 001 558 E_HDMI_3D_FORMAT, // 010 559 E_HDMI_RESERVED, // 011 ~ 111 560 E_HDMI_NA // Not available 561 } E_HDMI_ADDITIONAL_VIDEO_FORMAT; 562 563 typedef enum 564 { 565 E_VIC_4Kx2K_30Hz = 0x01, // 1920(x2)x1080(x2) @ 29.97/30Hz 566 E_VIC_4Kx2K_25Hz = 0x02, // 1920(x2)x1080(x2) @ 25Hz 567 E_VIC_4Kx2K_24Hz = 0x03, // 1920(x2)x1080(x2) @ 23.976/24Hz 568 E_VIC_4Kx2K_24Hz_SMPTE = 0x04, // 2048(x2)x1080(x2) @ 24Hz 569 E_VIC_RESERVED, // 0x00, 0x05 ~ 0xFF 570 E_VIC_NA // Not available 571 } E_HDMI_VIC_4Kx2K_CODE; 572 573 typedef enum 574 { 575 E_3D_EXT_DATA_HOR_SUB_SAMPL_0, //0000 576 E_3D_EXT_DATA_HOR_SUB_SAMPL_1, //0001 577 E_3D_EXT_DATA_HOR_SUB_SAMPL_2, //0010 578 E_3D_EXT_DATA_HOR_SUB_SAMPL_3, //0011 579 E_3D_EXT_DATA_QUINCUNX_MATRIX_0, //0100 580 E_3D_EXT_DATA_QUINCUNX_MATRIX_1, //0101 581 E_3D_EXT_DATA_QUINCUNX_MATRIX_2, //0110 582 E_3D_EXT_DATA_QUINCUNX_MATRIX_3, //0111 583 E_3D_EXT_DATA_RESERVE, //1000 ~ 1111 584 E_3D_EXT_DATA_MODE_MAX, 585 } E_HDMI_3D_EXT_DATA_T; 586 587 typedef enum 588 { 589 E_3D_META_DATA_PARALLAX_ISO23002_3, //0000 590 E_3D_META_DATA_RESERVE, //001 ~ 1111 591 E_3D_META_DATA_MAX, 592 } E_HDMI_3D_META_DATA_TYPE; 593 594 typedef struct 595 { 596 MS_BOOL b3D_Meta_Present; 597 E_HDMI_3D_META_DATA_TYPE t3D_Metadata_Type; 598 MS_U8 u83D_Metadata_Length; 599 MS_U8 u83D_Metadata[23]; // Maximum length of VS is 31 - 8 = 23 600 } sHDMI_3D_META_FIELD; 601 602 /////////// HDCP22 ///////////////// 603 typedef enum 604 { 605 E_HDCP22_IF_HDMI, //0x00 606 E_HDCP22_IF_MIRACAST, //0x01 607 //TBD 608 } E_HDCP22_PORT_TYPE; 609 610 /////////// HDR metadata ///////////////// 611 typedef struct __attribute__((packed)) 612 { 613 MS_U16 u16Version; /// Version. 614 MS_U16 u16Size; /// Structure size. 615 MS_U8 u8EOTF; // 0:SDR gamma, 1:HDR gamma, 2:SMPTE ST2084, 3:Future EOTF, 4-7:Reserved 616 MS_U8 u8Static_Metadata_ID; // 0:Static Metadata Type 1, 1-7:Reserved for future use 617 MS_U16 u16Display_Primaries_X[3]; // display_primaries_x 618 MS_U16 u16Display_Primaries_Y[3]; // display_primaries_x 619 MS_U16 u16White_Point_X; // display primaries Wx 620 MS_U16 u16White_Point_Y; // display primaries Wy 621 MS_U16 u16Max_Display_Mastering_Luminance; // max display mastering luminance 622 MS_U16 u16Min_Display_Mastering_Luminance; // min display mastering luminance 623 MS_U16 u16Maximum_Content_Light_Level; // maximum content light level 624 MS_U16 u16Maximum_Frame_Average_Light_Level; // maximum frame-average light level 625 } sHDR_METADATA; 626 627 628 // HDMI Control structure 629 /** 630 * Switch VSDB to HDR packet control parameters. 631 */ 632 typedef struct __attribute__((packed)) 633 { 634 MS_BOOL bEnableHDR; 635 } MS_HDMI_Switch_VSDB_to_HDR_Parameters; 636 637 /** 638 * HDR info-frame get control parameters. 639 */ 640 typedef struct __attribute__((packed)) 641 { 642 sHDR_METADATA *pstHDRMetadata; 643 } MS_HDMI_HDR_InfoFrame_Get_Parameters; 644 645 /** 646 * Extend packet receive get control parameters. 647 */ 648 typedef struct __attribute__((packed)) 649 { 650 MS_BOOL bEnable; 651 MS_HDMI_EXTEND_PACKET_RECEIVE_t *pstPacketReceive; 652 } MS_HDMI_Extend_Packet_Receive_Get_Parameters; 653 654 //------------------------------------------------------------------------------------------------- 655 // Function and Variable 656 //------------------------------------------------------------------------------------------------- 657 658 //HDMI/DVI 659 INTERFACE HDMI_POLLING_STATUS_t g_HdmiPollingStatus; 660 661 //HDCP 662 INTERFACE HDCP_POLLING_STATUS_t g_HdcpPollingStatus; 663 664 INTERFACE MS_U16 g_AVMUTEMissingCounter; 665 INTERFACE MS_U16 g_AVIMissingCounter; 666 INTERFACE MS_U16 g_ACPMissingCounter; 667 668 #ifdef DVI_NEW_Patch 669 // 20081226 - DVI+HDCP snow noise patch - start ... 670 INTERFACE MS_U16 g_DVI70MhzPollingCounter; 671 INTERFACE MS_U8 g_DVI70MhzUnstableCounter; 672 INTERFACE MS_BOOL g_bDVILess70MHz; 673 // 20081226 - DVI+HDCP snow noise patch - end ... 674 #endif 675 676 677 //HDMI 678 INTERFACE MS_U16 MDrv_HDMI_Func_Caps(void); 679 INTERFACE void MDrv_HDMI_init( void ); 680 // INTERFACE void MDrv_HDMI_Exit( void ); 681 INTERFACE void MDrv_HDMI_pkt_reset( HDMI_REST_t breset ); 682 INTERFACE void MDrv_HDMI_pullhpd( MS_BOOL bHighLow, E_MUX_INPUTPORT enInputPortType, MS_BOOL bInverse); 683 INTERFACE MS_U16 MDrv_HDMI_GC_Info(HDMI_GControl_INFO_t gcontrol); 684 INTERFACE MS_HDMI_PACKET_VALUE_t MDrv_HDMI_Packet_Received(MS_BOOL bEnable); 685 INTERFACE MS_HDMI_COLOR_FORMAT MDrv_HDMI_Get_ColorFormat(void); 686 INTERFACE EN_HDMI_COLOR_RANGE MDrv_HDMI_Get_ColorRange(void); 687 INTERFACE MS_HDMI_CONTENT_TYPE MDrv_HDMI_Get_Content_Type(void); 688 INTERFACE MS_HDMI_EXT_COLORIMETRY_FORMAT MDrv_HDMI_Get_ExtColorimetry(void); 689 690 INTERFACE void MDrv_HDMI_Set_EQ(MS_HDMI_EQ enEq, MS_U8 u8EQValue); 691 INTERFACE MS_BOOL MDrv_HDMI_Set_EQ_To_Port(MS_HDMI_EQ enEq, MS_U8 u8EQValue, E_MUX_INPUTPORT enInputPortType); 692 // INTERFACE void MDrv_HDMI_Audio_MUTE_Enable(MS_U16 u16MuteEvent, MS_U16 u16MuteMask); 693 // INTERFACE void MDrv_HDMI_Audio_Status_Clear(void); 694 695 INTERFACE MS_HDMI_AR_TYPE MDrv_HDMI_Get_AspectRatio(MS_BOOL bEn_PAR, MS_BOOL bEn_AFAR); 696 INTERFACE MS_HDMI_AR_TYPE MDrv_HDMI_Get_ActiveFormat_AspectRatio(MS_BOOL bEn_AFAR); 697 INTERFACE EN_AVI_INFOFRAME_VERSION MDrv_HDMI_Get_AVIInfoFrameVer(void); 698 699 INTERFACE MS_U8 MDrv_HDMI_err_status_update(MS_U8 u8value, MS_BOOL bread); 700 // INTERFACE void MDrv_HDMI_Get_PollingStatus(HDMI_POLLING_STATUS_t **pStatus); 701 INTERFACE MS_BOOL MDrv_HDMI_IsHDMI_Mode(void); 702 703 // INTERFACE void MDrv_HDMI_Get_MID_info(MS_U8 * pu8ManufactorData); 704 INTERFACE MS_BOOL MDrv_HDMI_get_packet_value(MS_HDMI_PACKET_STATE_t u8state, MS_U8 u8byte_idx, MS_U8 *pValue); 705 706 //DVI 707 INTERFACE MS_U16 MDrv_DVI_ChannelPhaseStatus( MS_DVI_CHANNEL_TYPE u8Channel); 708 // INTERFACE void MDrv_DVI_HF_adjust( void ); 709 INTERFACE void MDrv_DVI_SoftwareReset( MS_U16 u16Reset ); 710 INTERFACE void mdrv_dvi_reset(void); 711 INTERFACE void MDrv_DVI_ClkPullLow(MS_BOOL bPullLow, E_MUX_INPUTPORT enInputPortType); 712 INTERFACE void MDrv_DVI_SwitchSrc(E_MUX_INPUTPORT enInputPortType); 713 INTERFACE MS_BOOL MDrv_HDMI_SetForClockLessThan70Mhz( E_MUX_INPUTPORT InputSourceType ); 714 INTERFACE void MDrv_HDMI_dvi_adjust( MS_BOOL bClockLessThan70MHz); 715 INTERFACE void MDrv_HDMI_SetUpdatePhaseLineCount(INPUT_SOURCE_TYPE_t enInputSourceType); 716 // INTERFACE MS_U16 MDrv_HDMI_GetTMDSFreq(void); 717 718 719 //HDCP 720 INTERFACE void MDrv_HDCP_Enable(MS_BOOL bEnable); 721 INTERFACE MS_BOOL MDrv_HDMI_SetHdcpEnable(E_MUX_INPUTPORT enInputPortType,MS_BOOL bEnable); 722 INTERFACE void MDrv_HDCP_ClearStatus( void ); 723 INTERFACE void MDrv_HDCP_initproductionkey( MS_U8 * pu8HdcpKeyData ); 724 INTERFACE MS_HDCP_STATUS_INFO_t* MDrv_HDCP_GetStatus(void ); 725 INTERFACE void MDrv_HDCP_Vsync_end_en(MS_BOOL bStable); 726 727 //Audio 728 // INTERFACE void MDrv_HDMI_audio_output( MS_BOOL bEnable ); 729 INTERFACE MS_U8 MDrv_HDMI_audio_cp_hdr_info(void); 730 INTERFACE MS_U8 MDrv_HDMI_audio_channel_status(MS_U8 u8byte); 731 732 733 // Debug 734 /** 735 * HDMI Info 736 */ 737 typedef struct __attribute__((packed)) 738 { 739 MS_U8 u8SupportPorts; 740 }MS_HDMI_INFO; 741 742 /** 743 * HDMI Status 744 */ 745 typedef struct __attribute__((packed)) 746 { 747 MS_BOOL bIsInitialized; 748 MS_BOOL bIsRunning; 749 }MS_HDMI_Status; 750 751 // INTERFACE HDMI_Ret_Value MDrv_HDMI_GetLibVer(const MSIF_Version **ppVersion); ///< Get version (without Mutex protect) 752 // INTERFACE HDMI_Ret_Value MDrv_HDMI_GetInfo(MS_HDMI_INFO *pInfo); 753 // INTERFACE HDMI_Ret_Value MDrv_HDMI_GetStatus(MS_HDMI_Status *pStatus); 754 // INTERFACE MS_BOOL MDrv_HDMI_Get_AVIInfoActiveInfoPresent(void); 755 756 // DDC Ram 757 INTERFACE void MDrv_HDMI_READ_DDCRAM(XC_DDCRAM_PROG_INFO *pstDDCRam_Info, MS_U32 u32SizeOfInfo); 758 INTERFACE void MDrv_HDMI_PROG_DDCRAM(XC_DDCRAM_PROG_INFO *pstDDCRam_Info, MS_U32 u32SizeOfInfo); 759 INTERFACE MS_U8 MDrv_HDMI_Get_Pixel_Repetition(void); 760 761 //#if defined(CHIP_T8) || defined(CHIP_J2) // HDMI 1.4 new feature 762 INTERFACE void MDrv_HDMI_3D_4Kx2K_Process(void); 763 // INTERFACE void MDrv_HDMI_AVG_ScaleringDown(MS_BOOL bTrue); 764 // INTERFACE MS_BOOL MDrv_HDMI_Check4K2K(void); 765 INTERFACE E_HDMI_ADDITIONAL_VIDEO_FORMAT MDrv_HDMI_Check_Additional_Format(void); 766 INTERFACE E_XC_3D_INPUT_MODE MDrv_HDMI_Get_3D_Structure(void); 767 INTERFACE E_HDMI_3D_EXT_DATA_T MDrv_HDMI_Get_3D_Ext_Data(void); 768 // INTERFACE void MDrv_HDMI_Get_3D_Meta_Field(sHDMI_3D_META_FIELD *pdata); 769 // INTERFACE MS_U8 MDrv_HDMI_Get_VIC_Code(void); 770 INTERFACE E_HDMI_VIC_4Kx2K_CODE MDrv_HDMI_Get_4Kx2K_VIC_Code(void); 771 // HDMI ARC pin control 772 INTERFACE void MDrv_HDMI_ARC_PINControl(E_MUX_INPUTPORT enInputPortType, MS_BOOL bEnable, MS_BOOL bDrivingHigh); 773 INTERFACE void MDrv_DVI_Software_Reset(E_MUX_INPUTPORT enInputPortType, MS_U16 u16Reset); 774 INTERFACE MS_BOOL MDrv_HDMI_CheckHDMI20_Setting(E_MUX_INPUTPORT enInputPortType); 775 // INTERFACE void MDrv_HDMI_StablePolling(void); 776 // INTERFACE MS_U8 MDrv_HDMI_GetSourceVersion(E_MUX_INPUTPORT enInputPortType); 777 INTERFACE void SYMBOL_WEAK MDrv_HDMI_Set5VDetectGPIOSelect(MS_U32 ul5VDetectGPIOIndex); 778 // INTERFACE MS_BOOL SYMBOL_WEAK MDrv_HDMI_GetDEStableStatus(E_MUX_INPUTPORT enInputPortType); 779 // INTERFACE MS_BOOL SYMBOL_WEAK MDrv_HDMI_CheckHDCP14(void); 780 781 // HDMI common function. If you want to add new function, you shold modify MDrv_HDMI_Ctrl to support new feature. 782 INTERFACE MS_BOOL SYMBOL_WEAK MDrv_HDMI_Ctrl(MS_U32 u32Cmd, void *pBuf, MS_U32 u32BufSize); 783 784 //#endif 785 786 // fast boot 787 INTERFACE MS_U32 MDrv_HDMI_SetPowerState(EN_POWER_MODE enPowerState); 788 789 /*************************** HDCP22 ***************************/ 790 INTERFACE void MDrv_HDCP22_FillCipherKey(MS_U8 pucPortIdx, MS_U8 * pucRiv,MS_U8 * pucSessionKey); 791 INTERFACE void MDrv_HDCP22_InitCBFunc(HDCP22_Recv_CBF pCBFunc, void* pContext); 792 INTERFACE void MDrv_HDCP22_PortInit(MS_U8 ucPortIdx); 793 INTERFACE MS_BOOL MDrv_HDCP22_PollingReadDone(MS_U8 ucPortIdx); 794 INTERFACE void MDrv_HDCP22_EnableCipher(MS_U8 ucPortType, MS_U8 ucPortIdx, MS_BOOL bIsEnable); 795 INTERFACE void MDrv_HDCP22_SendMsg(MS_U8 ucPortType, MS_U8 ucPortIdx, MS_U8* pucData, MS_U32 dwDataLen, void* pDummy); 796 INTERFACE void MDrv_HDCP22_Handler(MS_U8 ucPortIdx); 797 /*************************** HDCP22 ***************************/ 798 799 #if 0 800 INTERFACE MS_U8 u8PSDVIStableCount[4]; 801 void MDrv_HDMI_ImmeswitchPS_Handler(void); 802 void MDrv_DVI_ForceAllPortsEnterPS(void); 803 #endif 804 #undef INTERFACE 805 806 807 #ifdef __cplusplus 808 } 809 #endif 810 811 #endif /* MDRV_HDMI_H */ 812 813