from UniTAP.libs.lib_tsi.tsi_types import *


TSI_CAP_OWNER_UNKNOWN = 0x0                        
TSI_CAP_OWNER_NONE = 0x1                           
TSI_CAP_OWNER_TEST_SYSTEM = 0x2                    
TSI_CAP_OWNER_PREVIEW = 0x3                        
TSI_CAP_OWNER = TSI_BASE_LEGACY_CAP(0x1f)          

TSI_SEARCHOPTIONS_FIX_500_IN_UCDCONFIG = 0x80000000 

TSI_VIDCAP_AVAILABLE_FRAME_COUNT_R = TSI_BASE_LEGACY_VIDCAP(0x1d) 
TSI_VIDCAP_CAPTURE_STATUS_R = TSI_BASE_LEGACY_VIDCAP(0x1e) 
TSI_VIDCAP_AVAILABLE_FRAME_COUNT = TSI_VIDCAP_AVAILABLE_FRAME_COUNT_R 
TSI_CRC_MEASUREMENT_DATA_R = TSI_BASE_R_CRC_VIDEO(0x3) 

TSI_AUDCAP_PACKET_HEADER_R = TSI_BASE_LEGACY_AUDCAP(0xe) 

TSI_PG_ADAPTIVE_SYNC_CTRL = 0x733                  
TSI_PG_ADAPTIVE_SYNC_CAPS = 0x734                  
TSI_PG_ADAPTIVE_SYNC_STS = 0x735                   
TSI_PG_CAPS_R = 0x736
TSI_PG_PR_CAPS_R = 0x737
TSI_PG_PR_CTRL_W = 0x738
TSI_PG_PR_STATUS_R = 0x738
TSI_PG_PR_CFG = 0x739
TSI_DPTX_EVENTS = TSI_BASE_DPTX(0x0e)              
TSI_DPTX_POST_LT_FEATURES = TSI_BASE_DPTX(0x68)
TSI_DPTX_SDP_CTRL = TSI_BASE_DPTX(0x74)
TSI_TEST_STATUS = 0x80000019  # Used for reading test status.
TSI_DEVICE_INFO_R = 0x80000020  # Used for reading FW version
TSI_TEST_ERROR_CODE_R = 0x80000021 # Used for reading test error code
TSI_PDC_DPAM_CONFIG_R = TSI_BASE_PDC(0x33)
TSI_PDC_HW_CAPS_R = TSI_BASE_PDC(0x00)
TSI_PDC_CONTRACT_DATA = TSI_BASE_PDC(0x09)
TSI_PDC_TX_ID_VDO_CNT = TSI_BASE_PDC(0x14)
TSI_PDC_TX_ID_VDO = TSI_BASE_PDC(0x15)

TSI_DPTX_OUT_LC = TSI_BASE_DPTX(0x52)              
TSI_DPTX_OUT_BR = TSI_BASE_DPTX(0x53)
TSI_DPTX_OUT_LINK_MODE = TSI_BASE_DPTX(0x54)
TSI_DP2TX_OUT_BR = TSI_BASE_DPTX(0x55)             
TSI_DP2TX_OUT_LC = TSI_BASE_DPTX(0x5A)
TSI_DP2TX_OUT_TEST_PATTERN = TSI_BASE_DPTX(0x5B)

TSI_MLEG_CONTROL = TSI_BASE_MLEG(0x00)
TSI_MLEG_SYMBOL_REPLACE_A = TSI_BASE_MLEG(0x01)
TSI_MLEG_SYMBOL_REPLACE_MASK_A = TSI_BASE_MLEG(0x02)
TSI_MLEG_SYMBOL_REPLACE_B = TSI_BASE_MLEG(0x03)
TSI_MLEG_SYMBOL_REPLACE_MASK_B = TSI_BASE_MLEG(0x04)
TSI_MLEG_DELAY_COUNTER = TSI_BASE_MLEG(0x0A)
TSI_MLEG_LANE0_REPLACE_COUNTERS = TSI_BASE_MLEG(0x05)
TSI_MLEG_LANE1_REPLACE_COUNTERS = TSI_BASE_MLEG(0x06)
TSI_MLEG_LANE2_REPLACE_COUNTERS = TSI_BASE_MLEG(0x07)
TSI_MLEG_LANE3_REPLACE_COUNTERS = TSI_BASE_MLEG(0x08)

TSI_HDCP_2X_CFG = TSI_BASE_LEGACY_HDCP2(0x2)

TSI_W_PDC_EPR_MODE_CONTROL = TSI_BASE_PDC(0x04)    

TSI_EVCAP_TIMESTAMP = TSI_BASE_LEGACY_EVCAP(0x8)   

TSI_DPRX_INF_VALID_EX = TSI_BASE_DPRX(0x29)
TSI_DPRX_SDP_CRC16_CTRL = TSI_BASE_DPRX(0x98)
TSI_DPRX_SDP_CRC16_COUNTERS = TSI_BASE_DPRX(0x99)

TSI_HDRX_INF_STATUS = TSI_BASE_HDRX(0x0C)          
TSI_HDRX_INF_VALID = TSI_BASE_HDRX(0x0D)           
TSI_HDRX_INF_SELECT = TSI_BASE_HDRX(0x0E)          
TSI_HDRX_INF_DATA = TSI_BASE_HDRX(0x0F)            

MAX_EDID_SIZE = 4096                               

TSI_DPRX_DSC_TEST_CRC = TSI_BASE_DPRX(0x43)        
TSI_DPRX_CRD_FEATURES = TSI_BASE_DPRX(0x63)        
TSI_DPRX_ALPM_LT_INFO_R = TSI_BASE_DPRX(0x38)      

TSI_DPRX_MSA_INFO_R = TSI_BASE_DPRX(0x48)          
TSI_DPRX_MST_STATUS_R = TSI_BASE_DPRX(0x49)        

TSI_GENERIC_STATUS = 0x210                         # TSI State flags. NOTE: Access mode changes to R+W

TSI_VIDCAP_HDCP_PROTECTED_R = 0x8000f000           
TSI_VIDCAP_HDCP_DECRYPTED_R = 0x8000f001           
TSI_HDCP_COMPLIANT_R = 0x8000f002                  

TSI_DSC_BLOCK_NO = 0x80000009                      # Used for stating start & end address to DSC PG. Changed  20191202 because not properly reserved.

TSI_CRC_DEFINITIONS = TSI_BASE_CRC_VIDEO(14)       # CRC definitions. Default setting is 0
TSI_CRC_WINDOW_0_0 = TSI_BASE_CRC_VIDEO(15)        # Left border/window pixel for first window 15..0. Top border/window line for first window 31..16. Default setting is 0
TSI_CRC_WINDOW_0_1 = TSI_BASE_CRC_VIDEO(16)        # Right border pixel/ window width for first window. 15..0. Bottom border line / window height for first window 31..16. Default setting is 0
TSI_CRC_WINDOW_1_0 = TSI_BASE_CRC_VIDEO(17)        # Left border/window pixel for second window 15..0. Top border/window line for second window 31..16. Default setting is 0
TSI_CRC_WINDOW_1_1 = TSI_BASE_CRC_VIDEO(18)        # Right border pixel/ window width for second window. 15..0. Bottom border line / window height for second window 31..16. Default setting is 0
TSI_CRC_WINDOW_2_0 = TSI_BASE_CRC_VIDEO(19)        # Left border/window pixel for third window 15..0. Top border/window line for third window 31..16. Default setting is 0
TSI_CRC_WINDOW_2_1 = TSI_BASE_CRC_VIDEO(20)        # Right border pixel/ window width for third window. 15..0. Bottom border line / window height for third window 31..16. Default setting is 0
TSI_CRC_WINDOW_3_0 = TSI_BASE_CRC_VIDEO(21)        # Left border/window pixel for fourth window 15..0. Top border/window line for fourth window 31..16. Default setting is 0
TSI_CRC_WINDOW_3_1 = TSI_BASE_CRC_VIDEO(22)        # Right border pixel/ window width for fourth window. 15..0. Bottom border line / window height for fourth window 31..16. Default setting is 0

TSI_R_LC_COUNT = 0x80000010                        # Number of licenses available.
TSI_W_LC_SELECT = 0x80000011                       # Index from 0 to LC_Count-1: Select which license to access through the CI's below
TSI_R_LC_CODE = 0x80000012                         # License ID (To identify type of license: "Basic" / "Advanced" / etc...)
TSI_R_LC_NAME = 0x80000013                         # Human readable name for license.
TSI_R_LC_GET_KEY = 0x80000014                      # Key string (40 characters, including the terminating NULL)
TSI_W_LC_ADD_KEY = 0x80000015                      # -> Write license key string. Matching key is validated and added.
TSI_W_LC_REMOVE_KEY = 0x80000016                   # -> Write license key string. Matching key is deleted.
TSI_W_LC_HAS_CODE = 0x80000017                     # Check if specified code is available on device.
TSI_R_LC_SHA_TYPE = 0x80000018                     # Check SHA type used in device.

TSI_DEVICE_DESCRIPTOR = 0x81000000                 
TSI_DEBUG_INFORMATION = 0x82000000                 

TSI_SELECT_SUITE = TSI_BASE_TEST(0x04)
TSI_TEST_DLG_CONFIG = TSI_BASE_TEST(0x22)

TSI_LOGICAL_PORT = c_uint
TSI_PORT_FLAGS = c_uint

TSI_DPRX_ALPM_STATS_CONTROL_W = TSI_BASE_DPRX(0x60) 
TSI_DPRX_ALPM_STATS_STATUS_R = TSI_BASE_DPRX(0x60) 
TSI_DPRX_ALPM_STATS_VB_R = TSI_BASE_DPRX(0x61)     
TSI_DPRX_ALPM_STATS_IFP_R = TSI_BASE_DPRX(0x62)    
TSI_DPRX_ALPM_STATS_CTRL_W = TSI_DPRX_ALPM_STATS_CONTROL_W 
TSI_DSC_TX_CRC = TSI_BASE_DSC(0x01)
TSI_DSC_MEMORY_BLOCK = TSI_BASE_DSC(0x05)
TSI_DSC_DATA_SIZE = TSI_BASE_DSC(0x06)

TSI_TERMINAL_RW = 0xFFFFFFFE

TSI_DPTX_CABLE_ATTRIBUTES_R = TSI_BASE_DPTX(0x6E)
TSI_DPRX_CABLE_ATTRIBUTES_R = TSI_BASE_DPRX(0x6E)

TSI_DPRX_LT_INTERNAL_USE = 0x50000000 + 0xFFFFF
TSI_DPRX_LT_ROUTE_CREATE = TSI_BASE_LEGACY_DPRX(0x1A + TSI_DPRX_LT_INTERNAL_USE)


class DeviceMaskInternal(IntEnum):
    Sink = TSI_DEVCAP_SINK
    Source = TSI_DEVCAP_SOURCE
    All = TSI_DEVCAP_ALL_CAPS
    Nothing = 0
