/******************************************************************************
 *
 * Copyright 2013, Silicon Image, Inc.  All rights reserved.
 * No part of this work may be reproduced, modified, distributed, transmitted,
 * transcribed, or translated into any language or computer format, in any form
 * or by any means without written permission of
 * Silicon Image, Inc., 1140 East Arques Avenue, Sunnyvale, California 94085
 *
 *****************************************************************************/
/**
 * @file sii9777_common_data.h
 *
 * @brief Host Driver for SiI9777 device.
 *
 *****************************************************************************/

#ifndef SII9777_COMMON_DATA_H
#define SII9777_COMMON_DATA_H

#ifdef __cplusplus
extern "C"{
#endif

/***** #include statements ***************************************************/

/***** public macro definitions **********************************************/

/***** public macro definitions **********************************************/

/*****************************************************************************/
/**
* @brief Events generated by the driver
*
* These notifications are passed through a parameter of the @ref SiiDrvAdaptCallBackFunc_t
* callback function when corresponding status is changed.
* The callback is registered through @ref SiiDrvAdaptCreate() function.
* Each notification can be enabled or disabled by @ref SiiDrvAdaptNotifMaskSet() function.
*
******************************************************************************/
/* @{ */
#define SII9777_EVENT_FLAGS__ALL                    ((Sii9777EventFlags_t)0xFFFFFFFF)  //!< All event flags

#define SII9777_EVENT_FLAGS__BOOT_DONE              ((Sii9777EventFlags_t)0x00000001)  //!< Booting is done.
#define SII9777_EVENT_FLAGS__FLASH_DONE             ((Sii9777EventFlags_t)0x00000002)  //!< Flash operation is finished.
#define SII9777_EVENT_FLAGS__GPIO_CHNG              ((Sii9777EventFlags_t)0x00000004)  //!< GPIO changed
/* @} */


/*****************************************************************************/
/**
* @brief Host driver error codes.
*
******************************************************************************/
/* @{ */
#define SII9777_RETVAL__SUCCESS                       ((SiiRetVal_t)0)       // Successful executed

#define SII9777_RETVAL__SEMAPHORE_IPC_EXPIRE          ((SiiRetVal_t) 70000)  // IPC semaphore error
#define SII9777_RETVAL__SEMAPHORE_HANDLE_EXPIRE       ((SiiRetVal_t) 80000)  // IPC semaphore error
#define SII9777_RETVAL__SEMAPHORE_API_EXPIRE          ((SiiRetVal_t) 90000)  // IPC semaphore error

#define SII9777_RETVAL__IPC_WRONG_TAG_CODE            ((SiiRetVal_t)100000)  // Wrong Tag code received
#define SII9777_RETVAL__IPC_WRONG_OP_CODE             ((SiiRetVal_t)110000)  // Wrong Tag code received
#define SII9777_RETVAL__IPC_NO_RESPONSE               ((SiiRetVal_t)120000)  // Wrong Tag code received
/* @} */


/***** public type definitions ***********************************************/

typedef uint32_t  Sii9777EventFlags_t;
typedef uint8_t   Sii9777IfActiveAR_t;
typedef uint8_t   Sii9777IfPicScaling_t;
typedef uint8_t   Sii9777IfScanInfo_t;
typedef uint8_t   Sii9777IfContentType_t;

/**
* @brief !!!Need to be defined
*/
typedef uint32_t SiiRetVal_t;

/**
* @brief Result of data exchange
*/
typedef enum
{
    SII9777_DATA__SUCCESS,                   //!< Retrieved information is valid
    SII9777_DATA__UNAVAILABLE,               //!< Information is not available
} Sii9777Data_t;

    /**
* @brief A/V output ports
*/
typedef enum
{
    SII9777_TX_PORT__0,                      //!< TMDS Transmitter Port 0
    SII9777_TX_PORT__1,                      //!< TMDS Transmitter Port 1
    SII9777_TX_PORT__2                       //!< TMDS Transmitter Port 2
} Sii9777TxPort_t;
    
/**
* @brief A/V input ports
*/
typedef enum
{
    SII9777_RX_PORT__0,                      //!< TMDS Receiver Port 0
    SII9777_RX_PORT__1,                      //!< TMDS Receiver Port 1
    SII9777_RX_PORT__2,                      //!< TMDS Receiver Port 2
    SII9777_RX_PORT__3                       //!< TMDS Receiver Port 3
} Sii9777RxPort_t;

/**
* @brief Boot-loader status
*/
typedef enum
{
    SII9777_BOOT_STAT__SUCCESS,              //!< Booting is done successfully
    SII9777_BOOT_STAT__IN_PROGRESS,          //!< Booting is in progress
    SII9777_BOOT_STAT__FAILURE,              //!< Booting failed
} Sii9777BootStat_t;

/**
* @brief Flash operation code
*/
typedef enum
{
    SII9777_FLASH_OPERATION__READ,
    SII9777_FLASH_OPERATION__WRITE,
    SII9777_FLASH_OPERATION__WRITE_VERIFY
} Sii9777FlashOperation_t;

/**
* @brief Flash target
*/
typedef enum
{
    SII9777_FLASH_TARGET__FULL_DEVICE,
    SII9777_FLASH_TARGET__EDID_TABLES,
    SII9777_FLASH_TARGET__FIRMWARE
} Sii9777FlashTarget_t;

/* Obsoleted enums */
#define SII9777_FIRMWARE_STAT__READY             SII9777_FLASH_STAT__READY         //!< Flash Reading/writing is done successfully
#define SII9777_FIRMWARE_STAT__IN_PROGRESS       SII9777_FLASH_STAT__IN_PROGRESS   //!< Flash Reading/writing is in progress
#define SII9777_FIRMWARE_STAT__FAILURE           SII9777_FLASH_STAT__FAILURE       //!< Flash Reading/writing failed

/**
* @brief Flash programming status
*/
typedef enum
{
   SII9777_FLASH_STAT__READY,                    //!< Flash Reading/writing is done successfully
   SII9777_FLASH_STAT__IN_PROGRESS,              //!< Flash Reading/writing is in progress
   SII9777_FLASH_STAT__FAILURE                   //!< Flash Reading/writing failed
} Sii9777FlashStat_t;

/**
* @brief Video Split Mode
*/
typedef enum
{
   SII9777_DUAL_LINK_MODE__LEFT_RIGHT,           //!< Video is splitted/merged by left/right half line
   SII9777_DUAL_LINK_MODE__EVEN_ODD,             //!< Video is splitted/merged by even/odd pixel
   SII9777_DUAL_LINK_MODE__PIXEL_REORDER         //!< Video is splitted/merged by pixel-reordering
} Sii9777DualLinkMode_t;

/**
* @brief Video test pattern selection
*/
typedef enum
{
    SII9777_TPG_PATTERN__RED,                //!< Solid Red (255,0,0)
    SII9777_TPG_PATTERN__GREEN,              //!< Solid Green (0,255,0)
    SII9777_TPG_PATTERN__BLUE,               //!< Solid Blue (0,0,255)
    SII9777_TPG_PATTERN__CYAN,               //!< Solid Cyan (0,255,255)
    SII9777_TPG_PATTERN__MAGENTA,            //!< Solid Magenta (255,0,0)
    SII9777_TPG_PATTERN__YELLOW,             //!< Solid Yellow (255,255,0)
    SII9777_TPG_PATTERN__BLACK,              //!< Solid Black (0,0,0)
    SII9777_TPG_PATTERN__WHITE,              //!< Solid White (255,255,255)
    SII9777_TPG_PATTERN__GRYSCL,             //!< 256 Gray Pattern
    SII9777_TPG_PATTERN__CHKBRD,             //!< Checkerboard Pattern
    SII9777_TPG_PATTERN__CLRBAR,             //!< RGB Color bars
    SII9777_TPG_PATTERN__SPECIAL,            //!< Customized image
    SII9777_TPG_PATTERN__BLUESCREEN,         //!< 720P Blue screen
} Sii9777TpgPattern_t;

/**
* @brief Audio/Video Link Mode
*/
typedef enum
{
    SII9777_AV_LINK__NONE,                   //!< No video
    SII9777_AV_LINK__DVI,                    //!< DVI
    SII9777_AV_LINK__HDMI1,                  //!< HDMI1.x
    SII9777_AV_LINK__HDMI2,                  //!< HDMI2.x
    SII9777_AV_LINK__MHL,                    //!< MHL
} Sii9777AvLink_t;
    
/**
* @brief HDCP Status
*/
typedef enum
{
     SII9777_HDCP_STATUS__OFF,               //!< Authentication is not enabled
     SII9777_HDCP_STATUS__SUCCESS_1X,        //!< Authentication succeeded for HDCP 1.X
     SII9777_HDCP_STATUS__SUCCESS_22,        //!< Authentication succeeded for HDCP 2.2
     SII9777_HDCP_STATUS__AUTHENTICATING,    //!< Authentication is in progress
     SII9777_HDCP_STATUS__FAILED,            //!< Authentication failed and does not re-try
} Sii9777HdcpStatus_t;

/**
* @brief Video resolution
*
* VIC refers o CEA-861 specification's VIC code.
* HDMI VIC refers to HDMI specification's HDMI VIC code.
*/
typedef enum
{
    SII9777_VID_RES__NONE,                   //!< No video
    SII9777_VID_RES__UNKNOWN,                //!< Video format does not match any of the formats in this enumeration
    SII9777_VID_RES__VGA60,                  //!< \f$ 640 \times 480\f$ 60Hz progressive (VGA) (CEA VIC 2/3)
    SII9777_VID_RES__480P,                   //!< \f$ 720 \times 480\f$ 60Hz progressive (480P60) (CEA VIC 2/3)
    SII9777_VID_RES__720P60,                 //!< \f$ 1280 \times 720\f$ 60Hz progressive (720P60) (CEA VIC 4/69)
    SII9777_VID_RES__1080I60,                //!< \f$ 1920 \times 1080\f$ 60Hz interlaced (1080I60) (CEA VIC 5)
    SII9777_VID_RES__480I2,                  //!< \f$ 720(1440) \times 480\f$ 60Hz interlaced (480I60) (CEA VIC 6/7)
    SII9777_VID_RES__240P2A,                 //!< \f$ 720(1440) \times 240\f$ 60Hz progressive, 262 total lines (CEA VIC 8/9)
    SII9777_VID_RES__240P2B,                 //!< \f$ 720(1440) \times 240\f$ 60Hz progressive, 263 total lines (CEA VIC 8/9)
    SII9777_VID_RES__480I4,                  //!< \f$ 2880 \times 480\f$ 60Hz interlaced (CEA VIC 10/11)
    SII9777_VID_RES__240P4A,                 //!< \f$ 2880 \times 240\f$ 60Hz progressive, 262 total lines (CEA VIC 12/13)
    SII9777_VID_RES__240P4B,                 //!< \f$ 2880 \times 240\f$ 60Hz progressive, 263 total lines (CEA VIC 12/13)
    SII9777_VID_RES__480P2,                  //!< \f$ 1440 \times 480\f$ 60Hz progressive (CEA VIC 14/15)
    SII9777_VID_RES__1080P60,                //!< \f$ 1920 \times 1080\f$ 60Hz progressive (1080P60) (CEA VIC 16/76)
    SII9777_VID_RES__576P,                   //!< \f$ 720 \times 576\f$ 50Hz progressive (576P60) (CEA VIC 17/18)
    SII9777_VID_RES__720P50,                 //!< \f$ 1280 \times 720\f$ 50Hz progressive (720P50) (CEA VIC 19/68)
    SII9777_VID_RES__1080I50,                //!< \f$ 1920 \times 1080\f$ 50Hz interlaced (1080I50) (CEA VIC 20)
    SII9777_VID_RES__576I2,                  //!< \f$ 720(1440) \times 576\f$ 50Hz interlaced (CEA VIC 21)
    SII9777_VID_RES__288P2A,                 //!< \f$ 720(1440) \times 288\f$ 50Hz progressive, 312 total lines (CEA VIC 23/24)
    SII9777_VID_RES__288P2B,                 //!< \f$ 720(1440) \times 288\f$ 50Hz progressive, 313 total lines (CEA VIC 23/24)
    SII9777_VID_RES__288P2C,                 //!< \f$ 720(1440) \times 288\f$ 50Hz progressive, 314 total lines (CEA VIC 23/24)
    SII9777_VID_RES__576I4,                  //!< \f$ 2880 \times 576\f$ 50Hz interlaced (CEA VIC 12/26)
    SII9777_VID_RES__288P4A,                 //!< \f$ 2880 \times 288\f$ 50Hz progressive, 312 total lines (CEA VIC 27/28)
    SII9777_VID_RES__288P4B,                 //!< \f$ 2880 \times 288\f$ 50Hz progressive, 313 total lines (CEA VIC 27/28)
    SII9777_VID_RES__288P4C,                 //!< \f$ 2880 \times 288\f$ 50Hz progressive, 314 total lines (CEA VIC 27/28)
    SII9777_VID_RES__576P2,                  //!< \f$ 1440 \times 576\f$ 50Hz progressive (CEA VIC 29/30)
    SII9777_VID_RES__1080P50,                //!< \f$ 1920 \times 1080\f$ 50Hz progressive (1080P50) (CEA VIC 31/75)
    SII9777_VID_RES__1080P24,                //!< \f$ 1920 \times 1080\f$ 24Hz progressive (1080P24) (CEA VIC 32/72)
    SII9777_VID_RES__1080P25,                //!< \f$ 1920 \times 1080\f$ 25Hz progressive (1080P25) (CEA VIC 33/73)
    SII9777_VID_RES__1080P30,                //!< \f$ 1920 \times 1080\f$ 30Hz progressive (1080P30) (CEA VIC 34/74)
    SII9777_VID_RES__480P4,                  //!< \f$ 2880 \times 480\f$ 60Hz progressive (CEA VIC 35/36)
    SII9777_VID_RES__576P4,                  //!< \f$ 2880 \times 576\f$ 50Hz progressive (CEA VIC 37/38)
    SII9777_VID_RES__1080I50A,               //!< \f$ 1920 \times 1080\f$ 50Hz interlaced, 1250 total lines in each video field (CEA VIC 39)
    SII9777_VID_RES__1080I100,               //!< \f$ 1920 \times 1080\f$ 100Hz interlaced (CEA VIC 40)
    SII9777_VID_RES__720P100,                //!< \f$ 1280 \times 720\f$ 100Hz progressive (CEA VIC 41/70)
    SII9777_VID_RES__576P100,                //!< \f$ 720 \times 576\f$ 100Hz progressive (CEA VIC 42)
    SII9777_VID_RES__576I100,                //!< \f$ 720(1440) \times 576\f$ 100Hz interlaced (CEA VIC 44/45)
    SII9777_VID_RES__1080I120,               //!< \f$ 1920 \times 1080\f$ 120Hz interlaced (CEA VIC 46)
    SII9777_VID_RES__720P120,                //!< \f$ 1280 \times 720\f$ 120Hz progressive (CEA VIC 47/71)
    SII9777_VID_RES__480P120,                //!< \f$ 720 \times 480\f$ 120Hz progressive (CEA VIC 48/49)
    SII9777_VID_RES__480I120,                //!< \f$ 720(1440) \times 480\f$ 120Hz interlaced (CEA VIC 50/51)
    SII9777_VID_RES__576P200,                //!< \f$ 720 \times 576\f$ 200Hz progressive (CEA VIC 52/53)
    SII9777_VID_RES__576I200,                //!< \f$ 720(1440) \times 576\f$ 200Hz interlaced (CEA VIC 54/55)
    SII9777_VID_RES__480P240,                //!< \f$ 720 \times 480\f$ 240Hz progressive (CEA VIC 56/57)
    SII9777_VID_RES__480I240,                //!< \f$ 1440 \times 480\f$ 240Hz interlaced (CEA VIC 58/59)
    SII9777_VID_RES__720P24,                 //!< \f$ 12800 \times 720\f$ 24Hz progressive (720P24) (CEA VIC 60/65)
    SII9777_VID_RES__720P25,                 //!< \f$ 12800 \times 720\f$ 25Hz progressive (720P25) (CEA VIC 61/66)
    SII9777_VID_RES__720P30,                 //!< \f$ 12800 \times 720\f$ 30Hz progressive (720P30) (CEA VIC 62/67)
    SII9777_VID_RES__1080P120,               //!< \f$ 19200 \times 1080\f$ 120Hz progressive (CEA VIC 63/78)
    SII9777_VID_RES__1080P100,               //!< \f$ 19200 \times 1080\f$ 100Hz progressive (CEA VIC 64/77)
    SII9777_VID_RES__4K2K30,                 //!< \f$ 3840 \times 2160\f$ 30Hz progressive (HDMI VIC 1)
    SII9777_VID_RES__4K2K25,                 //!< \f$ 3840 \times 2160\f$ 25Hz progressive (HDMI VIC 2)
    SII9777_VID_RES__4K2K24A,                //!< \f$ 3840 \times 2160\f$ 24Hz progressive (HDMI VIC 3)
    SII9777_VID_RES__4K2K24B,                //!< \f$ 4096 \times 2160\f$ 24Hz progressive (HDMI VIC 4)
    SII9777_VID_RES__1680X720P24,            //!< \f$ 1680 \times 720 \f$ 24Hz progressive (CEA VIC 79)
    SII9777_VID_RES__1680X720P25,            //!< \f$ 1680 \times 720 \f$ 25Hz progressive (CEA VIC 80)
    SII9777_VID_RES__1680X720P30,            //!< \f$ 1680 \times 720 \f$ 30Hz progressive (CEA VIC 81)
    SII9777_VID_RES__1680X720P50,            //!< \f$ 1680 \times 720 \f$ 50Hz progressive (CEA VIC 82)
    SII9777_VID_RES__1680X720P60,            //!< \f$ 1680 \times 720 \f$ 60Hz progressive (CEA VIC 83)
    SII9777_VID_RES__1680X720P100,           //!< \f$ 1680 \times 720 \f$ 100Hz progressive (CEA VIC 84)
    SII9777_VID_RES__1680X720P120,           //!< \f$ 1680 \times 720 \f$ 120Hz progressive (CEA VIC 85)
    SII9777_VID_RES__2560X1080P24,           //!< \f$ 2560 \times 1080 \f$ 24Hz progressive (CEA VIC 86)
    SII9777_VID_RES__2560X1080P25,           //!< \f$ 2560 \times 1080 \f$ 25Hz progressive (CEA VIC 87)
    SII9777_VID_RES__2560X1080P30,           //!< \f$ 2560 \times 1080 \f$ 30Hz progressive (CEA VIC 88)
    SII9777_VID_RES__2560X1080P50,           //!< \f$ 2560 \times 1080 \f$ 50Hz progressive (CEA VIC 89)
    SII9777_VID_RES__2560X1080P60,           //!< \f$ 2560 \times 1080 \f$ 60Hz progressive (CEA VIC 90)
    SII9777_VID_RES__2560X1080P100,          //!< \f$ 2560 \times 1080 \f$ 100Hz progressive (CEA VIC 91)
    SII9777_VID_RES__2560X1080P120,          //!< \f$ 2560 \times 1080 \f$ 120Hz progressive (CEA VIC 92)
    SII9777_VID_RES__2160P50,                //!< \f$ 3840 \times 2160\f$ 50Hz progressive (CEA VIC 96/106)
    SII9777_VID_RES__2160P60,                //!< \f$ 3840 \times 2160\f$ 60Hz progressive (CEA VIC 97/107)    
    SII9777_VID_RES__4096X2160P24,           //!< \f$ 4096 \times 2160\f$ 24Hz progressive (CEA VIC 98)
    SII9777_VID_RES__4096X2160P25,           //!< \f$ 4096 \times 2160\f$ 25Hz progressive (CEA VIC 99)
    SII9777_VID_RES__4096X2160P30,           //!< \f$ 4096 \times 2160\f$ 30Hz progressive (CEA VIC 100)
    SII9777_VID_RES__4096X2160P50,           //!< \f$ 4096 \times 2160\f$ 50Hz progressive (CEA VIC 101)
    SII9777_VID_RES__4096X2160P60,           //!< \f$ 4096 \times 2160\f$ 60Hz progressive (CEA VIC 102)
    SII9777_VID_RES__2048X1536P60,           /* pc format A */
    SII9777_VID_RES__2560X1440P60,           /* pc format B */
    SII9777_VID_RES__2560X1600P60            /* pc format C */
} Sii9777VidRes_t;

/**
* @brief 3D Video Modes
*
*/
typedef enum
{
    SII9777_3D_MODE__NONE,                   //!< 2D mode
    SII9777_3D_MODE__FP,                     //!< Frame Packing.
                                                   //!< Progressive/Interlaced Vertical ribbon:
                                                   //!< Progressive: L, R (one frame);
                                                   //!< Interl: L_odd, R_odd, L_even, R_even (one frame)
    SII9777_3D_MODE__FA,                     //!< Field Alternative.
                                                   //!< Interlaced Vertical ribbon: L_odd, R_odd, L_even, R_even (two frames)
    SII9777_3D_MODE__TB,                     //!< Top and Bottom.
                                                   //!< Progressive/Interlaced Vertical ribbon: L_odd, R_odd, L_even, R_even (two frames)
    SII9777_3D_MODE__SBSF,                   //!< Side By Side Full.
                                                   //!< Progressive/Interlaced Horizontal ribbon: L, R (one frame)
    SII9777_3D_MODE__LA,                     //!< Line Alternative.
                                                   //!< Progressive Line intermittent: 1L, 1R, 2L, 2R, ... (one frame)
    SII9777_3D_MODE__LD,                     //!< Left Plus Depth.
                                                   //!< Progressive Vertical ribbon: L, depth (one frame)
    SII9777_3D_MODE__LDG,                    //!< Left Plus Graphics.
                                                   //!< Progressive Vertical ribbon: L, depth, Graphics, Graphics Minus Depth (one frame)
    SII9777_3D_MODE__SBSH_HORIZ_OL_OR,       //!< Side By Side Half.
                                                   //!< Progressive/Interlaced Horizontal sub-sampling: Odd L, Odd R
    SII9777_3D_MODE__SBSH_HORIZ_OL_ER,       //!< Side By Side Half.
                                                   //!< Progressive/Interlaced Horizontal sub-sampling: Odd L, Even R
    SII9777_3D_MODE__SBSH_HORIZ_EL_OR,       //!< Side By Side Half.
                                                   //!< Progressive/Interlaced Horizontal sub-sampling: Even L, Odd R
    SII9777_3D_MODE__SBSH_HORIZ_EL_ER,       //!< Side By Side Half.
                                                   //!< Progressive/Interlaced Horizontal sub-sampling: Even L, Even R
    SII9777_3D_MODE__SBSH_QUINX_OL_OR,       //!< Side By Side Half.
                                                   //!< Progressive/Interlaced Quincunx matrix: Odd L, Odd R
    SII9777_3D_MODE__SBSH_QUINX_OL_ER,       //!< Side By Side Half.
                                                   //!< Progressive/Interlaced Quincunx matrix: Odd L, Even R
    SII9777_3D_MODE__SBSH_QUINX_EL_OR,       //!< Side By Side Half.
                                                   //!< Progressive/Interlaced Quincunx matrix: Even L, Odd R
    SII9777_3D_MODE__SBSH_QUINX_EL_ER,       //!< Side By Side Half.
                                                   //!< Progressive/Interlaced Quincunx matrix: Even L, Even R
} Sii97773dMode_t;

/**
* @brief Picture Aspect ratio
*/
typedef enum
{
    SII9777_PICT_AR__UNKNOWN,                //!< Unknown or default
    SII9777_PICT_AR__4X3,                    //!< \f$ 4 \times 3 \f$
    SII9777_PICT_AR__16X9,                   //!< \f$ 16 \times 9 \f$
    SII9777_PICT_AR__64X27,                  //!< \f$ 64 \times 27 \f$ (\f$ (4 \times 3)^3 \f$)
    SII9777_PICT_AR__SQP                     //!< Square Pixel (Aspect ratio is defined as *number of pixels per line* \f$ \times \f$ *number of lines*)
} Sii9777PictAR_t;

/**
* @brief Types of protected audio
*/
typedef enum
{
    SII9777_ACP_TYPE__GENERIC_AUDIO,         //!< Generic audio without protection
    SII9777_ACP_TYPE__IEC60958_AUDIO,        //!< Payload for IEC-60958 standard
    SII9777_ACP_TYPE__DVD_AUDIO,             //!< Payload for DVD Audio (DVD-A) standard
    SII9777_ACP_TYPE__SUPER_AUDIO_CD         //!< Payload for Super-Audio CD (DSD) standard
} Sii9777AcpType_t;

/**
* @brief Color Format
*
* Color Format includes color space, colorimetry, and range (Full vs. Limited).
*/
typedef enum
{
    SII9777_CLR_FMT__NO_DATA,                //!< No information or default selection
    SII9777_CLR_FMT__RGB_F,                  //!< RGB Full Range
    SII9777_CLR_FMT__RGB_L,                  //!< RGB Limited Range
    SII9777_CLR_FMT__YC601_F,                //!< YCbCr ITU-601 Full Range
    SII9777_CLR_FMT__YC601_L,                //!< YCbCr ITU-601 Limited Range
    SII9777_CLR_FMT__YC709_F,                //!< YCbCr ITU-709 Full Range
    SII9777_CLR_FMT__YC709_L,                //!< YCbCr ITU-709 Limited Range
    SII9777_CLR_FMT__XV601,                  //!< xvYCC ITU-601
    SII9777_CLR_FMT__XV709,                  //!< xvYCC ITU-709
    SII9777_CLR_FMT__YC2020_CL,              //!< YCbCr BT-2020 Constant Luminance
    SII9777_CLR_FMT__YC2020_NCL,             //!< YCbCr BT-2020 Non-Constant Luminance
} Sii9777ClrFmt_t;

/**
* @brief Chroma sampling
*/
typedef enum
{
    SII9777_CR_SMPL__NO_DATA,                //!< No information or default selection
    SII9777_CR_SMPL__444,                    //!< 4:4:4
    SII9777_CR_SMPL__422,                    //!< 4:2:2
    SII9777_CR_SMPL__420,                    //!< 4:2:0
} Sii9777CrSmpl_t;

/**
* @brief Bit Depth
*/
typedef enum
{
    SII9777_BIT_DEPTH__NO_DATA,              //!< No information or default selection
    SII9777_BIT_DEPTH__8,                    //!< 8 bit
    SII9777_BIT_DEPTH__10,                   //!< 10 bit
    SII9777_BIT_DEPTH__12,                   //!< 12 bit
} Sii9777BitDepth_t;

/**
* @brief Source Device Information
*
* Specifies type of the source device.
* Refer to CEA-861D or later specification for details.
*/
typedef enum
{
    SII9777_SRC_DEV_INFO__UNKNOWN     = 0,   //!< Unknown type
    SII9777_SRC_DEV_INFO__DIGITAL_STB = 1,   //!< Digital Set Top Box
    SII9777_SRC_DEV_INFO__DVD_PLAYER  = 2,   //!< DVD Player
    SII9777_SRC_DEV_INFO__D_VHS       = 3,   //!< Digital VHS
    SII9777_SRC_DEV_INFO__HDD_VIDREC  = 4,   //!< HDD Recorder
    SII9777_SRC_DEV_INFO__DVC         = 5,   //!< Digital Video Camera
    SII9777_SRC_DEV_INFO__DSC         = 6,   //!< Digital Still Camera
    SII9777_SRC_DEV_INFO__VIDEO_CD    = 7,   //!< Video CD
    SII9777_SRC_DEV_INFO__GAME        = 8,   //!< Game concole
    SII9777_SRC_DEV_INFO__PC_GENERAL  = 9,   //!< Personal Computer
    SII9777_SRC_DEV_INFO__BD          =10,   //!< Blu-Ray Disc
    SII9777_SRC_DEV_INFO__SACD        =11,   //!< Super Audio CD
} Sii9777SrcDevInfo_t;

/**
* @brief HDCP Content Stream type
*/
typedef enum
{
    SII9777_HDCP_CONTENT_TYPE__NONE,         //!< for all unprotected content
    SII9777_HDCP_CONTENT_TYPE__0,            //!< Type 0 content stream protection
    SII9777_HDCP_CONTENT_TYPE__1             //!< Type 1 content stream protection
} Sii9777HdcpContentType_t;

/**
* @brief TMDS Pin Swap
*/
typedef enum
{
    SII9777_TMDS_PIN_SWAP__NONE,             // Connector alignment
    SII9777_TMDS_PIN_SWAP__DATA,             // SWAP between all Data TMDS lanes, Clk lane remains the same
    SII9777_TMDS_PIN_SWAP__FULL              // SWAP between all TMDS lanes

} Sii9777TmdsPinSwap_t;

/**
* @brief HDCP Content Stream type
*/
typedef enum
{
    SII9777_PIX_FMT_CONV__SUPPORTED,         //!< Current Pixel format conversion configuration is supported
    SII9777_PIX_FMT_CONV__UNSUPPORTED        //!< Current Pixel format conversion configuration is not supported
} Sii9777PixFmtConv_t;

/**
* @brief 4K horizontal timing conversion setting
*/
typedef enum
{
    SII9777_SMPTE4K__PASSTHRU,      //!< No conversion
    SII9777_SMPTE4K__4096_TO_3840,  //!< SMPTE to CEA timing conversion
    SII9777_SMPTE4K__3840_TO_4096   //!< CEA to SMPTE timing conversion

} Sii9777Smpte4k_t;

/**
* @brief Color index of primary or secondary color
*/
typedef enum
{
    SII9777_CMS_COLOR__RED,         //!< Red Primary
    SII9777_CMS_COLOR__GREEN,       //!< Green Primary
    SII9777_CMS_COLOR__BLUE,        //!< Blue Primary
    SII9777_CMS_COLOR__CYAN,        //!< Cyan Secondary
    SII9777_CMS_COLOR__MAGENTA,     //!< Magenta Secondary
    SII9777_CMS_COLOR__YELLOW,      //!< Yellow Secondary
    SII9777_CMS_COLOR__WHITE        //!< White
} Sii9777CmsColor_t;

/**
*/
typedef enum
{
    SII9777_AUDIO_SOURCE__NONE,     //! No Audio transmitted
    SII9777_AUDIO_SOURCE__RX,       //! Audio from Rx0…Rx3
    SII9777_AUDIO_SOURCE__I2S,      //! from I2S input
    SII9777_AUDIO_SOURCE__SPDIF     //! from S/PDIF input
} Sii9777AudioSource_t;

/**
* @brief HDCP Downstream Repeater RxInfo
*/
typedef struct
{
    bool_t                      bHdcp1DeviceDs;          //!< HDCP 1.X compliant device in the topology if set to true, HDCP 2.X use only
    bool_t                      bHdcp20RepeaterDs;       //!< HDCP 2.0 compliant repeater in the topology if set to true, HDCP 2.X use only
    bool_t                      bMaxCascadeExceeded;     //!< More than seven level for HDCP 1.X or four levels for HDCP 2.X of repeaters cascaded together if set to true
    bool_t                      bMaxDevsExceeded;        //!< More than 127 devices (for HDCP1.X) or 31 devices (for HDCP 2.X) as attached if set to true
    uint8_t                     deviceCount;             //!< Total number of attached downstream devices
    uint8_t                     depth;                   //!< Repeater cascade depth
    uint32_t                    seqNumV;                 //!< seq_num_V value, HDCP 2.X use only
} Sii9777HdcpTopology_t;

/**
* @brief HDCP 2.X Stream Manage Info
*/
typedef struct
{
    uint32_t                    seqNumM;                 //!< The seq_num_M for the RepeaterAuth_Stream_Manage message
    uint16_t                    k;                       //!< The K value for the RepeaterAuth_Stream_Manage message, always be 0x001 in HDMI
    uint16_t                    streamIdType[4];         //!< The streamID_Type for the RepeaterAuth_Stream_Manage message, the buffer length shoule be K
} Sii9777HdcpStreamManageInfo_t;

/**
* @brief KSV
*/
typedef struct
{
    uint8_t                     b[5];                    //!< 5 bytes KSV
} Sii9777HdcpKsv_t;

/**
* @brief Video test pattern generator timing configuration
*
* @see SiiDrvAdaptTpgTimingSet()
* @see SiiDrvAdaptTpgTimingGet()
*/
typedef struct
{
    bit_fld_t                   interlaced   : 1;        //!< 0: Progressive, 1: Interlaced
    bit_fld_t                   posHsync     : 1;        //!< 0: negative hor. sync, 1: postoive hor. sync
    bit_fld_t                   posVsync     : 1;        //!< 0: negative ver. sync, 1: postoive ver. sync

    uint32_t                    pixelFreq;               //!< Pixel frequency in Hz

    uint16_t                    vTotal;                  //!< Total number of lines per field (note: not frame)
    uint16_t                    vActive;                 //!< Active number of lines per field (note: not frame)
    uint16_t                    vSync;                   //!< V Sync width in number of field lines
    uint16_t                    vFrontPorch;             //!< V Front Porch width in number of field lines

    uint16_t                    hTotal;                  //!< Total number of un-replicated clocks per line
    uint16_t                    hActive;                 //!< Active number of un-replicated clocks per line
    uint16_t                    hSync;                   //!< H Sync width in number of un-replicated clocks
    uint16_t                    hFrontPorch;             //!< H Front Porch width in number of un-replicated clocks
} Sii9777VideoTiming_t;

/**
* @brief ISRC structure
*
* International Standard Recording Code (ISRC) information.
* Refer to HDMI specification for details.
*/
typedef struct
{
    bit_fld_t                   isrcCont   : 1;          //!< ISRC_Cont field of ISRC packet
    bit_fld_t                   isrcStatus : 1;          //!< ISRC_Status field of ISRC packet
    bit_fld_t                   isrcValid  : 1;          //!< ISRC_Valid field of ISRC packet
    uint8_t                     isrcData[32];            //!< ISRC/UCP/EAN information
} Sii9777Isrc_t;

/**
* @brief Source Product Description (ACP) structure
*
* Contains Source Product Description (ACP) information.
* Refer to CEA-861D or later specification for details.
*/
typedef struct
{
    uint8_t                     acpData[32];            //!< ACP information
} Sii9777Acp_t;

/**
* @brief Source Product Description (SPD) structure
*
* Contains Source Product Description (SPD) information.
* Refer to CEA-861D or later specification for details.
*/
typedef struct
{
    uint8_t                     vendorName[8];           //!< Vendor name in ASCII
    uint8_t                     productDescription[16];  //!< Product description in ASCII
    Sii9777SrcDevInfo_t         sourceDevInfo;           //!< Source device information
} Sii9777Spd_t;

/**
* @brief High Dynamic Range (HDR) structure
*
* Contains High Dynamic Range (HDR) information.
* Refer to CEA-861.3 or later specification for details.
*/
typedef struct
{
    uint8_t                     hdrData[32];            //!< ACP information
} Sii9777Hdr_t;

/**
* @brief Pixel format description structure
*/
typedef struct
{
    Sii9777ClrFmt_t             clrFmt;                  //!< color space, colorimetry, and range
    Sii9777CrSmpl_t             crSmpl;                  //!< Chroma sampling
    Sii9777BitDepth_t           bitDepth;                //!< Bit Depth
} Sii9777PixFmt_t;

/**
* @brief Video format structure
*
* This structure contains video format information carried
* by AVI InfoFrame, HDMI Vendor Specific InfoFrame,
* HDMI Forum Vendor Specific InfoFrame,
* MHL Vendor Specific InfoFrame,
* Gamut Boundaries Packet,
* and video format timing.
*/
typedef struct
{
    Sii9777VidRes_t             vidRes;                  //!< Video resolution ID
    Sii97773dMode_t             mode3D;                  //!< 3D mode
    Sii9777PictAR_t             pictureAR;               //!< Picture Aspect Ratio
    uint8_t                     pixelRepetition;         //!< @brief Pixel repetition
                                                             //!< Indicates how many times a pixel is repeated.
                                                             //!< 0- no repetition, 1- 1 time (doubled), etc.

    Sii9777PixFmt_t             pixFmt;                  //!< Format of video pixel. Such chroma sampling, colorimetry, range, bit depth
                                                           
    Sii9777IfActiveAR_t         activeAR;                //!< @brief Active format aspect ratio specification
    Sii9777IfPicScaling_t       picScaling;              //!< Non-uniform picture scaling
    Sii9777IfScanInfo_t         scanInfo;                //!< Scan information
    Sii9777IfContentType_t      contentType;             //!< Content type
    bit_fld_t                   isITContent    : 1;      //!< IT Content flag
    bit_fld_t                   isActiveFormat : 1;      //!< @brief Indicates if active format information is present
                                                        
    //! BarInfo data                                    
    bit_fld_t                   isVertBarInfoValid  :1;  //!< @brief Indicates if Vertical BarInfo data is valid
    bit_fld_t                   isHorizBarInfoValid :1;  //!< @brief Indicates if Horizontal BarInfo data is valid
    struct              
    {                   
        uint16_t                lineNumEndOfTopBar;      //!< End of top bar
        uint16_t                lineNumStartOfBottomBar; //!< Start of bottom bar
    } vertBarInfo;                                       //!< Vertical bar info
    struct              
    {                   
        uint16_t                pixNumEndOfLeftBar;      //!< End of left bar
        uint16_t                pixNumStartOfRightBar;   //!< Start of right bar
    } horizBarInfo;                                      //!< Horizontal bar info
} Sii9777VideoFmt_t;

/**
* @brief Audio format structure
*
* This structure contains audio format information carried
* by Audio InfoFrame, Audio Status Channel, and audio sample packet type.
*/
typedef struct
{
    uint8_t                     aifData[10];             //!< Audio Info-Frame data. Refer to CEA861 specification for details.
    uint8_t                     csData[7];              //!< Channel Status data. Refer to IEC 60958-3 specification for details.
} Sii9777AudioFmt_t;

/*****************************************************************************/
/**
* @brief Notification callback prototype
*
* This callback is generated from @ref Sii9777Handle() when there is
* any notifications about driver status change.
* Call-back is only generated for the events that have been masked by
* Sii9777EventFlagsMaskSet().
*
* @param[in] inst  Driver instance caused the callback notification
* @param[in] flags Bit mask of the events
*
*****************************************************************************/
typedef void (* Sii9777EventCallbackFunc_t)( SiiInst_t inst, Sii9777EventFlags_t eventFlags );

#ifdef __cplusplus
}
#endif

#endif // SII9777_COMMON_DATA_H

