/**
 * Copyright (C) 2011 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Mobile Communication Division,
 * Digital Media & Communications Business, Samsung Electronics Co., Ltd.
 *
 * This software and its documentation are confidential and proprietary
 * information of Samsung Electronics Co., Ltd.  No part of the software and
 * documents may be copied, reproduced, transmitted, translated, or reduced to
 * any electronic medium or machine-readable form without the prior written
 * consent of Samsung Electronics.
 *
 * Samsung Electronics makes no representations with respect to the contents,
 * and assumes no responsibility for any errors that might appear in the
 * software and documents. This publication and the contents hereof are subject
 * to change without notice.
 *
 */

/*
 * hdcp_common.h
 *
 * Common Constants for normal & secure world
 *
 */

 /**
 * @file hdcp2_common.h
 * @author
 * @date
 * @brief This file has all the common definitions and structure definitions used everywhere in the whole system.
 */
#ifndef _HDCP2_COMMON_H_
#define _HDCP2_COMMON_H_

#ifdef __cplusplus
extern "C"
{
#endif
#include <time.h>

#ifdef USE_QUALCOMM
#include "app_main.h"
#endif /* USE_QUALCOMM */

typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;

/**
 * @def INSTHK_SYS_PROP
 *
 * This macro is assigned a system property of "wlan.hdcp2.insthk" to select the process of installing HDCP key
 *
 */
#define INSTHK_SYS_PROP	"wlan.hdcp2.insthk"

/**
 * @def PROP_DEFAULT
 *
 * This macro is assigned a value of "none" to indicate system property default value
 *
 */
#define PROP_DEFAULT	"none"

/**
 * @def PROP_LSI_WRAP
 *
 * This macro is assigned a value of "none" to indicate system property for LSI wrapping key
 *
 */
#define PROP_LSI_WRAP	"lsi.wrap"

/**
 * @def PROP_QC_SFS
 *
 * This macro is assigned a value of "none" to indicate system property for QC using sfs
 *
 */
#define PROP_QC_SFS	"qc.sfs"

/**
 * @def PROP_QC_WRAP
 *
 * This macro is assigned a value of "none" to indicate system property for QC wrapping key
 *
 */
#define PROP_QC_WRAP	"qc.wrap"

/**
 * @def INSTHK_SYS_PROP
 *
 * This macro is assigned a value of 0 to maintained when INSTHK_SYS_PROP is set PROP_DEFAULT
 *
 */
#define PROP_NUM_DEFAULT	0

/**
 * @def INSTHK_SYS_PROP
 *
 * This macro is assigned a value of 0 to maintained when INSTHK_SYS_PROP is set PROP_LSI_WRAP
 *
 */
#define PROP_NUM_LSI_WRAP	1

/**
 * @def INSTHK_SYS_PROP
 *
 * This macro is assigned a value of 0 to maintained when INSTHK_SYS_PROP is set PROP_QC_SFS
 *
 */
#define PROP_NUM_QC_SFS	2

/**
 * @def INSTHK_SYS_PROP
 *
 * This macro is assigned a value of 0 to maintained when INSTHK_SYS_PROP is set PROP_QC_WRAP
 *
 */
#define PROP_NUM_QC_WRAP	3
// system property

/**
 * @def MAX_SPS_BUFFER
 *
 * This macro is assigned a value of 0xFFFF to be maintained (because tlapi(tlApiVirt2PhysMemcpy) supports max 64KB)
 *
 */
#define MAX_SPS_BUFFER	0xFFFF  // 64KB

/**
 * @def MAX_VIDEO_ENCRYPT_BUFFER
 *
 * This macro is assigned a value about contiguous buffer allocating
 *
 */

#if defined(USE_MOBICORE) && defined(USE_MTK)
#define MAX_VIDEO_ENCRYPT_BUFFER	0x00080000  // 512k
#else
#ifdef USE_4KMIRRORING
#define MAX_VIDEO_ENCRYPT_BUFFER	0x00280000  // 2.5MB
#else
#define MAX_VIDEO_ENCRYPT_BUFFER	0x00100000  // 1MB
#endif /* USE_4KMIRRORING */
#endif /* USE_MTK */
/**
 * @def MAX_ENCRYPT_BUFFER
 *
 * This macro is assigned a value about contiguous buffer size for encryption/decryption
 *
 */
#define MAX_ENCRYPT_BUFFER	MAX_VIDEO_ENCRYPT_BUFFER

/**
 * @def MAX_ENCRYPT_BUFFER_BL
 *
 * This macro is assigned a value of (MAX_ENCRYPT_BUFFER/16) to be maintained everywhere
 *
 */
#define MAX_ENCRYPT_BUFFER_BL	(MAX_ENCRYPT_BUFFER/16)

/**
 * @def MAX_INPUT_LENTH
 *
 * This macro is assigned a value about contiguous buffer size for old chipset
 *
 */
#define MAX_INPUT_LENTH	MAX_VIDEO_ENCRYPT_BUFFER

/**
 * @def MAX_INCREASE_BUFFER
 *
 * This macro is assigned a value of 255 to be maintained everywhere
 *
 */
#define MAX_INCREASE_COUNTER	255

/**
 * @def MAX_HASH_BUFFER
 *
 * This macro is assigned a value of 256 to be maintained everywhere
 *
 */
#define MAX_HASH_BUFFER	256

/**
 * @def HDCP2_BUFFER_LEN
 *
 * This macro is assigned a value of 2048 to maintain buffer length everywhere
 *
 */
#define HDCP2_BUFFER_LEN	2048

/**
 * @def HDCP2_AKE_TIMEOUT
 *
 * This macro is assigned a value of 15000 to maintain the AKE timeout value everywhere
 *
 */
#define HDCP2_AKE_TIMEOUT	15000  // 15 sec

/**
 * @def HDCP2_AKE_RETRY_COUNT
 *
 * This macro is assigned a value of 10 to maintain the AKE retry count everywhere
 *
 */
#define HDCP2_AKE_RETRY_COUNT	10

/**
 * @def HDCP2_LC_RETRY_COUNT
 *
 * This macro is assigned a value of 10 to maintain Locality check retry count everywhere
 *
 */
#define HDCP2_LC_RETRY_COUNT	10

#if defined(USE_MOBICORE)
#include "hdcp2_exynos.h"

/**
 * @def PROVISIONING_KEY_SIZE
 *
 * This macro is assigned a value of 880 to maintain provisioning key size when USE_MOBICORE is defined
 *
 */
#define PROVISIONING_KEY_SIZE	880

/**
 * @def PROVISIONING_KEY_SIZE
 *
 * This macro is assigned a value of 1100 to maintain wrapped key size when USE_MOBICORE is defined
 *
 */
#define WRAPPED_KEY_SIZE	1100
#elif defined(USE_TEEGRIS)
/**
 * @def PROVISIONING_KEY_SIZE
 *
 * This macro is assigned a value of 880 to maintain provisioning key size for blowfish
 *
 */
#define PROVISIONING_KEY_SIZE	880

/**
 * @def PROVISIONING_KEY_SIZE
 *
 * This macro is assigned a value of 920 to maintain wrapped key size for blowfish
 *
 */
#define WRAPPED_KEY_SIZE	920
#else
/**
 * @def PROVISIONING_KEY_SIZE
 *
 * This macro is assigned a value of 880 to maintain provisioning key size when USE_MOBICORE is not defined
 *
 */
#define PROVISIONING_KEY_SIZE	880

/**
 * @def PROVISIONING_KEY_SIZE
 *
 * This macro is assigned a value of 1008 to maintain wrapped key size when USE_MOBICORE is not defined
 *
 */
#ifdef USE_QSEE_WRAP_WITH_SFS
#define WRAPPED_KEY_SIZE	1008
#else
#define WRAPPED_KEY_SIZE	913
#endif /* USE_QSEE_WRAP_WITH_SFS */
#endif /* USE_MOBICORE */

/**
 * @def HDCP2_BUFFER_TYPE_NORMAL
 *
 * This macro is assigned a value of 0 to be maintained everywhere.
 *
 */
#define HDCP2_BUFFER_TYPE_NORMAL	0

/**
 * @def HDCP2_BUFFER_TYPE_TZ
 *
 * This macro is assigned a value of 1 to be maintain everywhere.
 *
 */
#define HDCP2_BUFFER_TYPE_TZ	1

/**
 * @def HDCP2_BUFFER_TYPE_NORMAL
 *
 * This macro is assigned a value of 2 to be maintained everywhere.
 *
 */
#define HDCP2_BUFFER_TYPE_TZ_ALL	2

/**
 * @def HDCP2_TZ_OK
 *
 * This macro is assigned a value of 0 to indicate no error.
 *
 */
#define HDCP2_TZ_OK	0

/**
 * @def HDCP2_TZ_NULL_RESPONSE
 *
 * This macro is assigned a value of -1 to indicate upstream shutdown.
 *
 */
#define HDCP2_TZ_NULL_RESPONSE	-1

/**
 * @def HDCP2_TZ_NULL_REQUEST
 *
 * This macro is assigned a value of -2 to indicate upstream shutdown.
 *
 */
#define HDCP2_TZ_NULL_REQUEST	-2

/**
 * @def HDCP2_TZ_CRYPTO_ERROR
 *
 * This macro is assigned value of -3 to indicate TrustZone crypt error.
 *
 */
#define HDCP2_TZ_CRYPTO_ERROR	-3

/**
 * @def HDCP2_SIZE_AKE_SEND_CERT
 *
 * This macro is assigned value of 524 to indicate size of AKE_Send_Cert message.
 *
 */
#define HDCP2_SIZE_AKE_SEND_CERT	524

/**
 * @def HDCP2_SIZE_AKE_RECEIVER_INFO
 *
 * This macro is assigned value of 6 to indicate size of AKE_Receiver_Info message.
 *
 */
#define HDCP2_SIZE_AKE_RECEIVER_INFO	6

/**
 * @def HDCP2_SIZE_AKE_SEND_RRX
 *
 * This macro is assigned value of 9 to indicate size of AKE_Send_rrx message received from receiver.
 *
 */
#define HDCP2_SIZE_AKE_SEND_RRX	9

/**
 * @def HDCP2_SIZE_AKE_SEND_H_PRIME
 *
 * This macro is assigned value of 33 to indicate size of AKE_Send_H_Prime message.
 *
 */
#define HDCP2_SIZE_AKE_SEND_H_PRIME	33

/**
 * @def HDCP2_SIZE_AKE_SEND_PAIRING_INFO
 *
 * This macro is assigned value of 17 to indicate size of AKE_Send_Pairing_Info message.
 *
 */
#define HDCP2_SIZE_AKE_SEND_PAIRING_INFO	17

/**
 * @def HDCP2_SIZE_EXTRA_BUFFER_SIZE
 *
 * This macro is assigned value of 175 to indicate size of HDCP2_SIZE_EXTRA_BUFFER_SIZE.
 *
 */
#ifdef USE_QUALCOMM
#define HDCP2_SIZE_EXTRA_BUFFER_SIZE	176
#else
#define HDCP2_SIZE_EXTRA_BUFFER_SIZE	0
#endif /* USE_QUALCOMM */

/**
 * @def HDCP2_SIZE_LC_SEND_L_PRIME
 *
 * This macro is assigned value of 33 to indicate size of LC_Send_L_prime message.
 *
 */
#define HDCP2_SIZE_LC_SEND_L_PRIME	33

/**
 * @def HDCP2_SIZE_RECEIVER_PUBKEY
 *
 * This macro is assigned value of 128 to indicate size of Receiver's public key.
 *
 */
#define HDCP2_SIZE_RECEIVER_PUBKEY	128

/**
 * @def HDCP2_SIZE_RTT_READY
 *
 * This macro is assigned value of 1 to indicate size of RTT_Ready message.
 *
 */
#define HDCP2_SIZE_RTT_READY	1

/**
 * @def HDCP2_SIZE_LC_SEND_L_PRIME_PC
 *
 * This macro is assigned value of 17 to indicate size of LC_Send_L_Prime message.
 *
 */
#define HDCP2_SIZE_LC_SEND_L_PRIME_PC	17

/**
 * @def RECEIVER_ID_SIZE
 *
 * This macro is assigned value of 5 to indicate size of Reciever_id in case of multiple Rx Support.
 *
 */
#define RECEIVER_ID_SIZE	5

/**
 * @def HDCP_FIXED_SIZE_REPEATERAUTH_SEND_RECEIVERID_LIST21
 *
 * This macro is assigned value of 26 to indicate size of RepeaterAuth_Send_ReceiverID_List_21 in case of multiple Rx Support.
 *
 */
#define HDCP_FIXED_SIZE_REPEATERAUTH_SEND_RECEIVERID_LIST21	26

/**
 * @def HDCP_FIXED_SIZE_REPEATERAUTH_SEND_RECEIVERID_LIST20
 *
 * This macro is assigned value of 37 to indicate fixed size of RepeaterAuth_Send_ReceiverID_List_20 in case of multiple Rx Support.
 *
 */
#define HDCP_FIXED_SIZE_REPEATERAUTH_SEND_RECEIVERID_LIST20	37

/**
 * @def HDCP_SIZE_REPEATERAUTH_SEND_RECEIVERID_LIST21
 *
 * This macro is assigned value of 176 to indicate size of RepeaterAuth_Send_ReceiverID_List message in case of multiple Rx Support.
 *
 */
#define HDCP_SIZE_REPEATERAUTH_SEND_RECEIVERID_LIST21	181

/**
 * @def HDCP_SIZE_REPEATERAUTH_SEND_RECEIVERID_LIST20
 *
 * This macro is assigned value of 187 to indicate size of RepeaterAuth_Send_ReceiverID_List message in case of multiple Rx Support.
 *
 */
#define HDCP_SIZE_REPEATERAUTH_SEND_RECEIVERID_LIST20	192

/**
 * @def HDCP_SIZE_RECEIVERAUTH_STATUS
 *
 * This macro is assigned value 4 to indicate the size of Receiver_AuthStatus message.
 *
 */
#define HDCP_SIZE_RECEIVERAUTH_STATUS	4

/**
 * @def HDCP_SIZE_RECEIVERAUTH_READY
 *
 * This macro is assigned value of 33 to indicate size of RepeaterAuth_Stream_Ready message.
 *
 */
#define HDCP_SIZE_RECEIVERAUTH_READY	33

/**
 * @def LOG_TAG
 *
 * This macro is assigned value of "HDCP2" to be maintained everywhere
 *
 */
#define LOG_TAG	"HDCP2"

/**
 * @def HDCP2_OK
 *
 * This macro is assigned value of 0 to indicate no error.
 */
#define HDCP2_OK	0

/**
 * @def HDCP2_ERR
 *
 * This macro is assigned value of -1 to indicate error.
 */
#define HDCP2_ERR	-1

/**
 * @def HDCP2_ERR_CLOSED
 *
 * This macro is assigned value of -2 to indicate error for closed connection.
 */
#define HDCP2_ERR_CLOSED	-2

/**
 * @def HDCP2_NOT_SUPPORTED
 *
 * This macro is assigned value of -3 to indicate error for no support.
 */
#define HDCP2_NOT_SUPPORTED	-3

/**
 * @def HDCP2_ERR_THREAD
 *
 * This macro is assigned value of -4 to indicate error in hdcp thread.
 */
#define HDCP2_ERR_THREAD	-4

/**
 * @def HDCP2_ERR_CONCURRENT_TX
 *
 * This macro is assigned value of -11 to indicate error of concurrent Tx.
 */
#define HDCP2_ERR_CONCURRENT_TX	-11

/**
 * @def HDCP2_ERR_CONCURRENT_RX
 *
 * This macro is assigned value of -12 to indicate error of concurrent Rx.
 */
#define HDCP2_ERR_CONCURRENT_RX	-12

/**
 * @def HDCP2_ERR_INVALID_INPUT
 *
 * This macro is assigned value of -51 to indicate invalid input error.
 */
#define HDCP2_ERR_INVALID_INPUT	-51

/**
 * @def HDCP2_ERR_NOT_SUPPORTED_COMMAND
 *
 * This macro is assigned value of -52 to indicate error for command not supported.
 */
#define HDCP2_ERR_NOT_SUPPORTED_COMMAND	-52

/**
 * @def HDCP2_ERR_UNSUPPRTED_PARTY
 *
 * This macro is assigned value of -53 to indicate unsupported party error.
 */
#define HDCP2_ERR_UNSUPPRTED_PARTY	-53

/**
 * @def HDCP2_ERR_UNSUPPRTED_TZ
 *
 * This macro is assigned value of -54 to indicate unsupported TZ error.
 */
#define HDCP2_ERR_UNSUPPRTED_TZ	-54

/**
 * @def HDCP2_ERR_MAKE_PAIRING_DIR
 *
 * This macro is assigned value of -55 to indicate error in making pair.
 */
#define HDCP2_ERR_MAKE_PAIRING_DIR	-55

/**
 * @def HDCP2_ERR_DCP_VERIFICATION
 *
 * This macro is assigned value of -56 to indicate error in HDCP Receiver Cert fail
 */
#define HDCP2_ERR_DCP_VERIFICATION	-56

/**
 * @def HDCP2_ERR_SEND_PAIRING_INFO
 *
 * This macro is assigned value of -100 to indicate error in AKE_Send_Pairing_Info.
 */
#define HDCP2_ERR_SEND_PAIRING_INFO	-100

/**
 * @def HDCP2_ERR_WRITE_PAIRING_INFO1
 *
 * This macro is assigned value of -101 to indicate error in opening pair_info_path in HDCP2_Store_Pairing_Info while writing.
 */
#define HDCP2_ERR_WRITE_PAIRING_INFO1	-101

/**
 * @def HDCP2_ERR_WRITE_PAIRING_INFO2
 *
 * This macro is assigned value of -102 to indicate error in writing encrypted paiting info.
 */
#define HDCP2_ERR_WRITE_PAIRING_INFO2	-102

/**
 * @def HDCP2_ERR_WRITE_PAIRING_INFO3
 *
 * This macro is assigned value of -103 to be maintained everywhere.
 */
#define HDCP2_ERR_WRITE_PAIRING_INFO3	-103

/**
 * @def HDCP2_ERR_SET_PAIRING_INFO
 *
 * This macro is assigned value of -110 to indicate error in setting pairing info.
 */
#define HDCP2_ERR_SET_PAIRING_INFO	-110

/**
 * @def HDCP2_ERR_LOAD_PAIRING_INFO1
 *
 * This macro is assigned value of -120 to indicate error in opening pair_info_path in HDCP2_Store_Pairing_Info while reading.
 */
#define HDCP2_ERR_LOAD_PAIRING_INFO1	-120

/**
 * @def HDCP2_ERR_LOAD_PAIRING_INFO2
 *
 * This macro is assigned value of -121 to indicate error in reading encrypted paiting info.
 */
#define HDCP2_ERR_LOAD_PAIRING_INFO2	-121

/**
 * @def HDCP2_ERR_LOAD_PAIRING_INFO3
 *
 * This macro is assigned value of -122 to indicate error in loading encrypted pair info in TZ.
 */
#define HDCP2_ERR_LOAD_PAIRING_INFO3	-122

/**
 * @def HDCP2_ERR_INVALID_KEYBOX
 *
 * This macro is assigned value of -131 to indicate error in loading key.
 */
#define HDCP2_ERR_INVALID_KEYBOX	-131

/**
 * @def HDCP2_ERR_WRITE_WRAPPED_KEYBOX1
 *
 * This macro is assigned value of -132 to indicate error in opening path for wrap key for reading.
 */
#define HDCP2_ERR_WRITE_WRAPPED_KEYBOX1	-132

/**
 * @def HDCP2_ERR_WRITE_WRAPPED_KEYBOX2
 *
 * This macro is assigned value of -133 to indicate error in reading the wrap key.
 */
#define HDCP2_ERR_WRITE_WRAPPED_KEYBOX2	-133

/**
 * @def HDCP2_ERR_WRITE_WRAPPED_KEYBOX3
 *
 * This macro is assigned value of -134 to indicate error in opening path for wrap key for writing.
 */
#define HDCP2_ERR_WRITE_WRAPPED_KEYBOX3	-134

/**
 * @def HDCP2_ERR_WRITE_WRAPPED_KEYBOX4
 *
 * This macro is assigned value of -135 to indicate error in writing the wrap key.
 */
#define HDCP2_ERR_WRITE_WRAPPED_KEYBOX4	-135

/**
 * @def HDCP2_ERR_WRITE_WRAPPED_KEYBOX5
 *
 * This macro is assigned value of -136 to indicate error in opening path for wrap key for wiping redata.bin
 */
#define HDCP2_ERR_WRITE_WRAPPED_KEYBOX5	-136

/**
 * @def HDCP2_ERR_WRITE_WRAPPED_KEYBOX6
 *
 * This macro is assigned value of -137 to be maintained everywhere.
 */
#define HDCP2_ERR_WRITE_WRAPPED_KEYBOX6	-137

/**
 * @def HDCP2_ERR_WRITE_WRAPPED_KEYBOX7
 *
 * This macro is assigned value of -138 to indicate error in checking the wrap key.
 */
#define HDCP2_ERR_WRITE_WRAPPED_KEYBOX7	-138

/**
 * @def HDCP2_ERR_WRITE_WRAPPED_KEYBOX8
 *
 * This macro is assigned value of -139 to indicate error in checking the wrap key.
 */
#define HDCP2_ERR_WRITE_WRAPPED_KEYBOX8	-139

/**
 * @def HDCP2_ERR_WRAP_KEYBOX1
 *
 * This macro is assigned value of -140 to be maintained everywhere.
 */
#define HDCP2_ERR_WRAP_KEYBOX1	-140

/**
 * @def HDCP2_ERR_WRAP_KEYBOX2
 *
 * This macro is assigned value of -141 to be maintained everywhere.
 */
#define HDCP2_ERR_WRAP_KEYBOX2	-141

/**
 * @def HDCP2_ERR_WRAP_KEYBOX3
 *
 * This macro is assigned value of -142 to be maintained everywhere.
 */
#define HDCP2_ERR_WRAP_KEYBOX3	-142

/**
 * @def HDCP2_ERR_READ_WRAPPED_KEYBOX1
 *
 * This macro is assigned value of -145 to indicate error in opening wrappedkey path.
 */
#define HDCP2_ERR_READ_WRAPPED_KEYBOX1	-145

/**
 * @def HDCP2_ERR_READ_WRAPPED_KEYBOX2
 *
 * This macro is assigned value of -146 to indicate error in reading wrappedkey.
 */
#define HDCP2_ERR_READ_WRAPPED_KEYBOX2	-146

/**
 * @def HDCP2_ERR_INVALID_H
 *
 * This macro is assigned value of -201 to indicate error in case of invalid H value in AKE_Send_H_prime message.
 */
#define HDCP2_ERR_INVALID_H	-201

/**
 * @def HDCP2_ERR_INVALID_L
 *
 * This macro is assigned value of -202 to indicate error in case of invalid L value in LC_Send_L_prime message.
 */
#define HDCP2_ERR_INVALID_L	-202

/**
 * @def HDCP2_ERR_STORED_KM_NOT_PAIRED
 *
 * This macro is assigned value of -203 to indicate error if Stored KM is not paired.
 */
#define HDCP2_ERR_STORED_KM_NOT_PAIRED	-203

/**
 * @def HDCP2_ERR_REAUTH_REQ
 *
 * This macro is assigned value of -204 to indicate signal if Repeater Asks for Reauthentication.
 */
#define HDCP2_ERR_REAUTH_REQ	-204

/**
 * @def HDCP2_ERR_INVALID_V
 *
 * This macro is assigned value of -205 to indicate error if v is not equal to V'.
 */
#define HDCP2_ERR_INVALID_V	-205

/**
 * @def HDCP2_ERR_TIME_REPEATER_RECEIVER_ID
 *
 * This macro is assigned value of -206 to be maintained everywhere.
 */
#define HDCP2_ERR_TIME_REPEATER_RECEIVER_ID	-206

/**
 * @def HDCP2_ERR_SRM_CHECK_FAIL
 *
 * This macro is assigned value of -207 to indicate error in SRM_Check.
 */
#define HDCP2_ERR_SRM_CHECK_FAIL	-207

/**
 * @def HDCP2_ERR_NO_SRM_FILE
 *
 * This macro is assigned value of -208 to indicate error in opening SRM file.
 */
#define HDCP2_ERR_NO_SRM_FILE	-208

/**
 * @def HDCP2_ERR_SRM_BUFFER_MEMORY_FAIL
 *
 * This macro is assigned value of -209 to indicate error in memory allocation.
 */
#define HDCP2_ERR_SRM_BUFFER_MEMORY_FAIL	-209

/**
 * @def HDCP2_ERR_INVALID_M
 *
 * This macro is assigned value of -210 to indicate error in case of invalid M value.
 */
#define HDCP2_ERR_INVALID_M	-210

/**
 * @def HDCP2_ERR_MAX_STREAM_EXCEEDED
 *
 * This macro is assigned value of -211 to indicate Max stream exceeded in HDCP2_DownstreamPropagation.
 */
#define HDCP2_ERR_MAX_STREAM_EXCEEDED	-211

/**
 * @def HDCP2_ERR_REAUTH_REQ_TRUE
 *
 * This macro is assigned value of -212 to be maintained everywhere.
 */
#define HDCP2_ERR_REAUTH_REQ_TRUE	-212

/**
 * @def HDCP2_MAX_DEVS_OR_CASCADE_EXCEEDED
 *
 * This macro is assigned value of -213 to indicate error in case of exceed in device count or cascade level.
 */
#define HDCP2_MAX_DEVS_OR_CASCADE_EXCEEDED	-213

/**
 * @def HDCP2_ERR_BKSV_READ_FAIL
 *
 * This macro is assigned value of -214 to indicate HDCP2_DOWNSTREAM_HDMI_ERROR.
 */
#define HDCP2_ERR_BKSV_READ_FAIL	-214

/**
 * @def HDCP2_ERR_REPEATER_AUTH_SEND_ACK_FAILED
 *
 * This macro is assigned value of -215 to indicate Timeout of REPEATERAUTH_SEND_ACK.
 */
#define HDCP2_ERR_REPEATER_AUTH_SEND_ACK_FAILED	-215

/**
 * @def HDCP2_ERR_TOO_MANY_DEVICES
 *
 * This macro is assigned value of -216 to indicate of HDCP2_ERR_TOO_MANY_DEVICES.
 */
#define HDCP2_ERR_TOO_MANY_DEVICES	-216

/**
 * @def HDCP2_ERR_TIME_AKE
 *
 * This macro is assigned value of -301 to indicate AKE timeout.
 */
#define HDCP2_ERR_TIME_AKE	-301

/**
 * @def HDCP2_ERR_TIME_AKE_RECEIVER_INFO
 *
 * This macro is assigned value of -302 to indicate AKE_RECEIVER_INFO timeout.
 */
#define HDCP2_ERR_TIME_AKE_RECEIVER_INFO	-302

/**
 * @def HDCP2_ERR_TIME_AKE_SEND_H_PRIME
 *
 * This macro is assigned value of -303 to indicate AKE_SEND_H_PRIME timeout.
 */
#define HDCP2_ERR_TIME_AKE_SEND_H_PRIME	-303

/**
 * @def HDCP2_ERR_TIME_AKE_SEND_PAIRING_INFO
 *
 * This macro is assigned value of -304 to indicate AKE_SEND_PAIRING_INFO timeout.
 */
#define HDCP2_ERR_TIME_AKE_SEND_PAIRING_INFO	-304

/**
 * @def HDCP2_ERR_TIME_LC
 *
 * This macro is assigned value of -305 to indicate timeout in Locality check.
 */
#define HDCP2_ERR_TIME_LC	-305

/**
 * @def HDCP2_ERR_TIME_SKE
 *
 * This macro is assigned value of -306 to indicate RepeaterAuth_Stream_Ready timeout.
 */
#define HDCP2_ERR_TIME_SKE	-306

/**
 * @def HDCP2_ERR_SKE
 *
 * This macro is assigned value of -307 to indicate error in SKE.
 */
#define HDCP2_ERR_SKE	-307

/**
 * @def HDCP2_ERR_VERI_SKE
 *
 * This macro is assigned value of -308 to indicate Compare HMAC fail in SKE_Send_Eks.
 */
#define HDCP2_ERR_VERI_SKE	-308

/**
 * @def HDCP2_ERR_AKE
 *
 * This macro is assigned value of -310 to indicate error in AKE.
 */
#define HDCP2_ERR_AKE	-310

/**
 * @def HDCP2_ERR_LC
 *
 * This macro is assigned value of -311 to indicate error in Locality Check.
 */
#define HDCP2_ERR_LC	-311

/**
 * @def HDCP2_ERR_CRYPTO
 *
 * This macro is assigned value of -401 to indicate error in encryption-decryption.
 */
#define HDCP2_ERR_CRYPTO	-401

/**
 * @def HDCP2_ERR_OAEP_ENCRYPTION
 *
 * This macro is assigned value of -402 to indicate error in OAEP encryption.
 */
#define HDCP2_ERR_OAEP_ENCRYPTION	-402

/**
 * @def HDCP2_ERR_OAEP_DECRYPTION
 *
 * This macro is assigned value of -403 to indicate error in OAEP decryption.
 */
#define HDCP2_ERR_OAEP_DECRYPTION	-403

/**
 * @def HDCP2_ERR_NULL_POINTER
 *
 * This macro is assigned value of -500 to indicate error in case of null pointer.
 */
#define HDCP2_ERR_NULL_POINTER	-500

/**
 * @def HDCP2_ERR_NULL_REQUEST
 *
 * This macro is assigned value of -501 to indicate error in case of null request.
 */
#define HDCP2_ERR_NULL_REQUEST	-501

/**
 * @def HDCP2_ERR_NULL_RESPONSE
 *
 * This macro is assigned value of -502 to indicate error in case of null response.
 */
#define HDCP2_ERR_NULL_RESPONSE	-502

/**
 * @def HDCP2_NETWORK_ERROR
 *
 * This macro is assigned value of -600 to indicate network error.
 */
#define HDCP2_NETWORK_ERROR	-600

/**
 * @def HDCP2_NETWORK_UNREACHABLE
 *
 * This macro is assigned value of -601 to indicate network error.
 */
#define HDCP2_NETWORK_UNREACHABLE	-601

/**
 * @def HDCP2_ERR_TRUSTZONE_OPEN
 *
 * This macro is assigned value of -650 to indicate error in opening trustzone.
 */
#define HDCP2_ERR_TRUSTZONE_OPEN	-650

/**
 * @def HDCP2_ERR_TRUSTZONE_BASE
 *
 * This macro is assigned value of -1000 to indicate error in tlApiCipher
 */
#define HDCP2_ERR_TRUSTZONE_BASE	-1000

/**
 * @def HDCP2_ERR_TRUSTZONE_ENCODE_KEY
 *
 * This macro is assigned value of -1098 to indicate error in TZ key encode.
 */
#define HDCP2_ERR_TRUSTZONE_ENCODE_KEY	-1098

/**
 * @def HDCP2_ERR_TRUSTZONE_DECODE_KEY
 *
 * This macro is assigned value of -1099 to indicate error in TZ key decode.
 */
#define HDCP2_ERR_TRUSTZONE_DECODE_KEY	-1099

/**
 * @def HDCP2_ERR_HW_INIT
 *
 * This macro is assigned value of -1100 to indicate error in HW init.
 */
#define HDCP2_ERR_HW_INIT	-1100

/**
 * @def HDCP2_ERR_HW_TERMINATE
 *
 * This macro is assigned value of -1101 to indicate [HDCP2]Sec Finalization error.
 */
#define HDCP2_ERR_HW_TERMINATE	-1101

/**
 * @def HDCP2_ERR_HW_ATTACH_CRYPTO
 *
 * This macro is assigned value of -1102 to indicate [HDCP2]Sec H/W attach error.
 */
#define HDCP2_ERR_HW_ATTACH_CRYPTO	-1102

/**
 * @def HDCP2_ERR_HW_DETTACH_CRYPTO
 *
 * This macro is assigned value of -1103 to indicate [HDCP2]Sec H/W detach error.
 */
#define HDCP2_ERR_HW_DETTACH_CRYPTO	-1103

/**
 * @def HDCP2_ERR_HW_CRYPTO
 *
 * This macro is assigned value of -1104 to indicate HW encryption-decryption failure.
 */
#define HDCP2_ERR_HW_CRYPTO	-1104

/**
 * @def HDCP2_ERR_HW_RESET
 *
 * This macro is assigned value of -1105 to indicate HDCP2_TZ_Reset Failure.
 */
#define HDCP2_ERR_HW_RESET	-1105

/**
 * @def HDCP2_ERR_HW_FIRMWARE_LOAD
 *
 * This macro is assigned value of -1106 to indicate error in loading HW Firmware.
 */
#define HDCP2_ERR_HW_FIRMWARE_LOAD	-1106

/**
 * @def HDCP2_ERR_DRM_SET_HDCP2_MAGICKEY
 *
 * This macro is assigned value of -1200 to indicate error in setting HDCP2 MagicKey.
 */
#define HDCP2_ERR_DRM_SET_HDCP2_MAGICKEY	-1200

/**
 * @def HDCP2_ERR_GET_OEM_FLAG
 *
 * This macro is assigned value of -1301 to indicate HDCP2_GetOemFlag Failure.
 */
#define HDCP2_ERR_GET_OEM_FLAG	-1301

/**
 * @def HDCP2_ERR_SET_OEM_FLAG
 *
 * This macro is assigned value of -1302 to indicate HDCP2_SetOemFlag Failure.
 */
#define HDCP2_ERR_SET_OEM_FLAG	-1302

/**
 * @def HDCP2_ERR_SET_HDCP2_FLAG
 *
 * This macro is assigned value of -1303 to indicate [HDCP2]Sec tlApiSecSetHdcp2Flag error.
 */
#define HDCP2_ERR_SET_HDCP2_FLAG	-1303

/**
 * @def HDCP2_ERR_BUFFER_PROTECTION
 *
 * This macro is assigned value of -1304 to indicate tlApi_tzbsp_core_is_stag_area non secure memory.
 */
#define HDCP2_ERR_BUFFER_PROTECTION	-1304

/**
 * @def HDCP2_ERR_HDMI
 *
 * This macro is assigned value of -1305 to indicate error in HDMI stat.
 */
#define HDCP2_ERR_HDMI	-1305

/**
 * @def HDCP2_ERR_INTEGRITY
 *
 * This macro is assigned value of -1310 to indicate error in integrity.
 */
#define HDCP2_ERR_INTEGRITY	-1310

/**
 * @def HDCP2_ERR_OS_INTEGRITY
 *
 * This macro is assigned value of -1311 to indicate error in OS integrity.
 */
#define HDCP2_ERR_OS_INTEGRITY	-1311

/**
 * @def HDCP2_ERR_AUDIO
 *
 * This macro is assigned value of -1320 to indicate error in case input is not audio.
 */
#define HDCP2_ERR_AUDIO	-1320

/**
 * @def HDCP2_ERR_NOT_SUPPORTED_STREAM
 *
 * This macro is assigned value of -1330 to indicate Not Supported Stream error.
 */
#define HDCP2_ERR_NOT_SUPPORTED_STREAM	-1330

/**
 * @def HDCP2_ERR_GET_STREAM_TYPE
 *
 * This macro is assigned value of -1331 to indicate error in getting Stream type.
 */
#define HDCP2_ERR_GET_STREAM_TYPE	-1331

/**
 * @def HDCP2_TYPE1_CONTENT
 *
 * This macro is assigned value of -1332 to indicate HDCP2_DOWNSTREAM_TYPE_CHANGE error.
 */
#define HDCP2_TYPE1_CONTENT	-1332

/**
 * @def HDCP2_TYPE0_CONTENT
 *
 * This macro is assigned value of -1333 to indicate HDCP2_DOWNSTREAM_TYPE_CHANGE error.
 */
#define HDCP2_TYPE0_CONTENT	-1333

/**
 * @def HDCP2_ERR_INVALID_STATE
 *
 * This macro is assigned value of -1334 to indicate Invalid argument in server_repeater.
 */
#define HDCP2_ERR_INVALID_STATE	-1334

/**
 * @def HDCP2_ERR_STORE_CONTENT_KEY
 *
 * This macro is assigned value of -1335 to indicate error in storing Content Key.
 */
#define HDCP2_ERR_STORE_CONTENT_KEY	-1335

/**
 * @def HDCP2_ERR_DELETE_CONTENT_KEY
 *
 * This macro is assigned value of -1336 to indicate error in HDCP DCP verification
 */
#define HDCP2_ERR_DELETE_CONTENT_KEY	-1336

/**
 * @def HDCP2_ERR_SPSPPS_COPY_FAIL
 *
 * This macro is assigned value of -1337 to indicate error in copying to secure memory
 */
#define HDCP2_ERR_SPSPPS_COPY_FAIL	-1337

/**
 * @def HDCP2_ERR_UNKNOWN_PIPE
 *
 * This macro is assigned value of -1338 to indicate error in ake init process with EINPROGRESS
 */
#define HDCP2_ERR_UNKNOWN_PIPE	-1338

/**
 * @def HDCP2_VALID_TIME_100MS
 *
 * This macro is assigned value of 100 to indicate 100ms time constraint
 */
#define HDCP2_VALID_TIME_100MS	100 // 100ms

/**
 * @def HDCP2_VALID_TIME_200MS
 *
 * This macro is assigned value of 200 to check AKE_Send_H_prime timeout in case of stored Km.
 */
#define HDCP2_VALID_TIME_200MS	200 // 200ms

/**
 * @def HDCP2_VALID_TIME_1SEC
 *
 * This macro is assigned value of 1000 to check AKE_Send_H_prime timeout in case of No stored Km.
 */
#define HDCP2_VALID_TIME_1SEC	1000 // 1sec

/**
 * @def HDCP2_VALID_TIME_7MS
 *
 * This macro is assigned value of 7 to check LC_Send_L_prime timeout.
 */
#define HDCP2_VALID_TIME_7MS	7 //7ms

/**
 * @def HDCP2_VALID_TRAILS_LC_INIT
 *
 * This macro is assigned value of 16 to indicate number of valid Locality Check trials.
 */
#define HDCP2_VALID_TRAILS_LC_INIT	16

/**
 * @def HDCP_REPEATER_RECEIVER_ID_DURATION
 *
 * This macro is assigned value of 3000 to indicate duration for Repeater ReceiverID.
 */
#define HDCP_REPEATER_RECEIVER_ID_DURATION	3000 // 3 sec

/**
 * @def HDCP2_AES_KEY_SIZE
 *
 * This macro is assigned value of 16 to indicate hdcp2 key size
 */
#define HDCP2_AES_KEY_SIZE	16

/**
 * @def CMD_TRANSMITTER
 *
 * This macro is assigned value of 100 to be maintained everywhere as Transmitter command.
 */
#define CMD_TRANSMITTER	100

/**
 * @def CMD_RECEIVER
 *
 * This macro is assigned value of 200 to be maintained everywhere as Receiver command.
 */
#define CMD_RECEIVER	200

/**
 * @def CMD_REPEATER
 *
 * This macro is assigned value of 0 to be maintained everywhere as Repeater command.
 */
#define CMD_REPEATER	0

/**
 * @def CMD_NULL_MESSAGE
 *
 * This macro is assigned value of 1 to indicate null message command.
 */
#define CMD_NULL_MESSAGE	1

/**
 * @def CMD_AKE_INIT
 *
 * This macro is assigned value of 2 to indicate AKE_Init command.
 */
#define CMD_AKE_INIT	2

/**
 * @def CMD_AKE_SEND_CERT
 *
 * This macro is assigned value of 3 to indicate AKE_Send_Cert command.
 */
#define CMD_AKE_SEND_CERT	3

/**
 * @def CMD_AKE_NO_STORED_KM
 *
 * This macro is assigned value of 4 to indicate AKE_No_Stored_Km command.
 */
#define CMD_AKE_NO_STORED_KM	4

/**
 * @def CMD_AKE_STORED_KM
 *
 * This macro is assigned value of 5 to indicate AKE_Stored_Km command.
 */
#define CMD_AKE_STORED_KM	5

/**
 * @def CMD_AKE_SEND_RRX
 *
 * This macro is assigned value of 6 to indicate AKE_Send_rrx command.
 */
#define CMD_AKE_SEND_RRX	6

/**
 * @def CMD_AKE_SEND_H_PRIME
 *
 * This macro is assigned value of 7 to indicate AKE_Send_H_prime command.
 */
#define CMD_AKE_SEND_H_PRIME	7

/**
 * @def CMD_AKE_SEND_PAIRING_INFO
 *
 * This macro is assigned value of 8 to indicate AKE_Send_Pairing_Info command.
 */
#define CMD_AKE_SEND_PAIRING_INFO	8

/**
 * @def CMD_LC_INIT
 *
 * This macro is assigned value of 9 to indicate LC_Init command.
 */
#define CMD_LC_INIT	9

/**
 * @def CMD_LC_SEND_L_PRIME
 *
 * This macro is assigned value of 10 to indicate LC_Send_L_Prime command.
 */
#define CMD_LC_SEND_L_PRIME	10

/**
 * @def CMD_SKE_SEND_EKS
 *
 * This macro is assigned value of 11 to indicate SKE_Send_Eks command.
 */
#define CMD_SKE_SEND_EKS	11

/**
 * @def CMD_REPEATERAUTH_SEND_RECEIVER_ID_LIST
 *
 * This macro is assigned value of 12 to indicate RepeaterAuth_Send_ReceiverID_list command.
 */
#define CMD_REPEATERAUTH_SEND_RECEIVER_ID_LIST	12

/**
 * @def CMD_RTT_READY
 *
 * This macro is assigned value of 13 to indicate RTT_Ready command.
 */
#define CMD_RTT_READY	13

/**
 * @def CMD_RTT_CHALLENGE
 *
 * This macro is assigned value of 14 to indicate RTT_Challenge command.
 */
#define CMD_RTT_CHALLENGE	14

/**
 * @def CMD_REPEATERAUTH_SEND_ACK
 *
 * This macro is assigned value of 15 to indicate RepeaterAuth_Send_Ack command.
 */
#define CMD_REPEATERAUTH_SEND_ACK	15

/**
 * @def CMD_REPEATERAUTH_STREAM_MANAGE
 *
 * This macro is assigned value of 16 to indicate RepeaterAuth_Stream_Manage command.
 */
#define CMD_REPEATERAUTH_STREAM_MANAGE	16

/**
 * @def CMD_REPEATERAUTH_STREAM_READY
 *
 * This macro is assigned value of 17 to indicate RepeaterAuth_Stream_Ready command.
 */
#define CMD_REPEATERAUTH_STREAM_READY	17

/**
 * @def CMD_RECEIVER_AUTHSTATUS
 *
 * This macro is assigned value of 18 to indicate Repeater_AuthStatus command.
 */
#define CMD_RECEIVER_AUTHSTATUS	18

/**
 * @def CMD_AKE_TRANSMITTER_INFO
 *
 * This macro is assigned value of 19 to indicate AKE_Transmitter_Info command.
 */
#define CMD_AKE_TRANSMITTER_INFO	19

/**
 * @def CMD_AKE_RECEIVER_INFO
 *
 * This macro is assigned value of 20 to indicate AKE_Receiver_Info command.
 */
#define CMD_AKE_RECEIVER_INFO	20

/**
 * @def CMD_CIP_ENC_DATA
 *
 * This macro is assigned value of 21 to indicate CIP_ENC_Data command.
 */
#define CMD_CIP_ENC_DATA	21

/**
 * @def CMD_CIP_DEC_DATA
 *
 * This macro is assigned value of 22 to indicate CIP_DEC_Data command.
 */
#define CMD_CIP_DEC_DATA	22

/**
 * @def CMD_CIP_DEC_VIR
 *
 * This macro is assigned value of 23 to indicate CIP_DEC_VIR command.
 */
#define CMD_CIP_DEC_VIR	23

/**
 * @def CMD_CIP_DEC_AUDIO
 *
 * This macro is assigned value of 24 to indicate CIP_DEC_AUDIO command.
 */
#define CMD_CIP_DEC_AUDIO	24

/**
 * @def CMD_CIP_ENC_VIR
 *
 * This macro is assigned value of 25 to indicate CIP_ENC_VIR command.
 */
#define CMD_CIP_ENC_VIR	25

/**
 * @def CMD_CIP_SPS_PPS_DATA
 *
 * This macro is assigned value of 26 to indicate CIP_SPS_PPS_Data command.
 */
#define CMD_CIP_SPS_PPS_DATA	26

/**
 * @def CMD_SET_HDCP_VERSION
 *
 * This macro is assigned value of 27 to indicate SET_HDCP_VERSION command.
 */
#define CMD_SET_HDCP_VERSION	27

/**
 * @def CMD_TRUSTZONE_INIT
 *
 * This macro is assigned value of 30 to indicate TRUSTZONE_Init command.
 */
#define CMD_TRUSTZONE_INIT	30

/**
 * @def CMD_TRUSTZONE_CLOSE
 *
 * This macro is assigned value of 31 to indicate TRUSTZONE_Close command.
 */
#define CMD_TRUSTZONE_CLOSE	31

/**
 * @def CMD_TRUSTZONE_RESET
 *
 * This macro is assigned value of 32 to indicate TRUSTZONE_Reset command.
 */
#define CMD_TRUSTZONE_RESET	32

/**
 * @def CMD_HDCP2_LOADKEY_ODM
 *
 * This macro is assigned value of 49 to indicate HDCP2_LoadKey command for ODM.
 */
#define CMD_HDCP2_LOADKEY_ODM	49

/**
 * @def CMD_AKE_SET_PAIRING_INFO
 *
 * This macro is assigned value of 50 to indicate AKE_Set_Pairing_Info command.
 */
#define CMD_AKE_SET_PAIRING_INFO	50

/**
 * @def CMD_HDCP2_WRAPKEY
 *
 * This macro is assigned value of 51 to indicate HDCP2_WrapKey command.
 */
#define CMD_HDCP2_WRAPKEY	51

/**
 * @def CMD_HDCP2_LOADKEY
 *
 * This macro is assigned value of 52 to indicate HDCP2_LoadKey command.
 */
#define CMD_HDCP2_LOADKEY	52

/**
 * @def CMD_CIP_DEC_DATA_ION
 *
 * This macro is assigned value of 53 to indicate CIP_DEC_Data_Ion command.
 */
#define CMD_CIP_DEC_DATA_ION	53

/**
 * @def CMD_HDCP2_STOREKEY
 *
 * This macro is assigned value of 54 to indicate HDCP2_StoreKey command.
 */
#define CMD_HDCP2_STOREKEY	54

/**
 * @def CMD_HDCP2_STORE_CONTENT_KEY
 *
 * This macro is assigned value of 55 to indicate HDCP2_storeContentKey command.
 */
#define CMD_HDCP2_STORE_CONTENT_KEY	55

/**
 * @def CMD_HDCP2_DELETE_CONTENT_KEY
 *
 * This macro is assigned value of 56 to indicate HDCP2_deleteContentKey command.
 */
#define CMD_HDCP2_DELETE_CONTENT_KEY	56

/**
 * @def CMD_OEM_GET_FLAG
 *
 * This macro is assigned value of 80 to indicate OEM_GetFlag command.
 */
#define CMD_OEM_GET_FLAG	80

/**
 * @def CMD_OEM_SET_FLAG
 *
 * This macro is assigned value of 81 to indicate OEM_SetFlag command.
 */
#define CMD_OEM_SET_FLAG	81

/**
 * @def CMD_SET_HDCP2_MAGICKEY
 *
 * This macro is assigned value of 91 to indicate Set_HDCP2_MagicKey command.
 */
#define CMD_SET_HDCP2_MAGICKEY	91

/**
 * @def CMD_GET_CONTENT_STREAM_TYPE
 *
 * This macro is assigned value of 100 to indicate Get_Content_Stream_Type command.
 */
#define CMD_GET_CONTENT_STREAM_TYPE	100

/**
 * @def DEC_TYPE_NORMAL
 *
 * This macro is assigned value of 0x00 to indicate decimal type normal value.
 */
#define DEC_TYPE_NORMAL	0x00

/**
 * @def DEC_TYPE_CHECK_KEY_FRAME
 *
 * This macro is assigned value of 0x01 to check Key frame type.
 */
#define DEC_TYPE_CHECK_KEY_FRAME	0x01

/**
 * @def DEC_TYPE_AUDIO
 *
 * This macro is assigned value of 0x02 to check input type as audio.
 */
#define DEC_TYPE_AUDIO	0x02

/**
 * @def DEC_TYPE_VIDEO
 *
 * This macro is assigned value of 0x03 to check input type as video.
 */
#define DEC_TYPE_VIDEO	0x03

/**
 * @def DEC_MAX_HEADER_SIZE
 *
 * This macro is assigned value of 960 to indicate maximum header size.
 */
#define DEC_MAX_HEADER_SIZE	960

/**
 * @def ENC_OPTION_NORMAL
 *
 * This macro is assigned value of 0 to be maintained everywhere.
 */
#define ENC_OPTION_NORMAL	0

/**
 * @def ENC_OPTION_FIRST_BUFFER
 *
 * This macro is assigned value of 1 to be maintained everywhere.
 */
#define ENC_OPTION_FIRST_BUFFER	1

/**
 * @def TRANSMITTER_LOCALITY_PRECOMPUTE_SUPPORT
 *
 * This macro is assigned value of 0x01 to be maintained everywhere.
 */
#define LOCALITY_PRECOMPUTE_SUPPORT	0x01

/**
 * @def TRANSMITTER_CONTENT_CATEGORY_SUPPORT
 *
 * This macro is assigned value of 0x02 to be maintained everywhere.
 */
#define CONTENT_CATEGORY_SUPPORT	0x02

/**
 * @def MAX_RECEIVER_DEVICE 
 *
 * This macro is assigned value of 31 to be maintained everywhere.
 */
#define MAX_RECEIVER_DEVICE	31

#if defined(USE_64BIT_ADDR)
typedef uint64_t addr_s;
#elif defined(USE_TEEGRIS)
typedef uint8_t addr_s;
#else
typedef unsigned long addr_s;
#endif /* USE_64BIT_ADDR */

/**
 * @struct Pairing_Info_
 * This structure contains information regarding Pairing info.
 */
typedef struct Pairing_Info_
{
	unsigned char m[16];
	unsigned char km[16];
	unsigned char Ekm[16];
	unsigned char receiver_id[5];
#if defined(USE_TEEGRIS)
	unsigned char padding[40]; // for encryption
#else
	unsigned char padding[107]; // for encryption
#endif /* defined(USE_TEEGRIS) */
} HDCP2_PAIRING_INFO;

/**
 * @struct HDCP2_Receiver_Certificate_
 *
 * This structure contains information regarding receiver certificate.
 *
 */
typedef struct HDCP2_Receiver_Certificate_ {
	u8 receiver_id[5];
	u8 publickey_n[HDCP2_SIZE_RECEIVER_PUBKEY];
	u8 publickey_e[3];
	u8 reserved_1:4;
	u8 Protocol_Descriptor:4;
	u8 reserved_2;
	u8 dcp_llc_sign[384];
} HDCP2_RECEIVER_CERTIFICATE;

/**
 * @struct RSA_PRIVATE_KEY_
 *
 * This structure contains information regarding rsa private key.
 */
typedef struct RSA_PRIVATE_KEY_ {
	u8 p[64];
	u8 q[64];
	u8 dmp1[64];
	u8 dmq1[64];
	u8 iqmp[64];
} RSA_PRIVATE_KEY;

/**
 * @struct HDCP2_KEY_
 *
 * This structure contains information regarding Device Key Set of Receiver.
 */
typedef struct HDCP2_KEY_ {
	u8 lc128[16];
	HDCP2_RECEIVER_CERTIFICATE cert;
	RSA_PRIVATE_KEY private_key;
	u8 ckey[16];
	u8 reserved[134];
} HDCP2_KEY;

/**
 * @struct AKE_Init_
 *
 * This structure contains information regarding AKE_Init message.
 */
typedef struct AKE_Init_ {
	u8 msg_id;
	u8 rtx[8];
} AKE_INIT;

/**
 * @struct AKE_Send_cert_
 *
 * This structure contains information regarding AKE_Send_Cert message.
 */
typedef struct AKE_Send_cert_ {
	u8 msg_id;
	u8 REPEATER;
	u8 certrx[522];
} AKE_SEND_CERT;

//4.3.3 AKE_No_Stored_km(Transmitter to Receiver)
/**
 * @struct AKE_No_Stored_km_
 *
 * This structure contains information regarding AKE_No_Stored_km message.
 */
typedef struct AKE_No_Stored_km_ {
	u8 msg_id;
	u8 Ekpub_km[HDCP2_SIZE_RECEIVER_PUBKEY];
} AKE_NO_STORED_KM;

/**
 * @struct AKE_STORED_KM
 *
 * This structure contains information regarding AKE_Stored_km message.
 */
typedef struct AKE_Stored_km_ {
	u8 msg_id;
	u8 Ekh_km[16];
	u8 m[16];
} AKE_STORED_KM;

/**
 * @struct AKE_Send_rrx_
 *
 * This structure contains information regarding AKE_Send_rrx message.
 */
typedef struct AKE_Send_rrx_ {
	u8 msg_id;
	u8 rrx[8];
} AKE_SEND_RRX;

/**
 * @struct AKE_Send_H_prime_
 *
 * This structure contains information regarding AKE_Send_H_prime message.
 */
typedef struct AKE_Send_H_prime_ {
	u8 msg_id;
	u8 H[32];
} AKE_SEND_H_PRIME;

/**
 * @struct AKE_Send_Pairing_Info_
 *
 * This structure contains information regarding AKE_Send_Pairing_Info message.
 */
typedef struct AKE_Send_Pairing_Info_ {
	u8 msg_id;
	u8 Ekh_Km[16];
} AKE_SEND_PAIRING_INFO;

/**
 * @struct AKE_Transmitter_Info_
 *
 * This structure contains information regarding AKE_Transmitter_Info message.
 */
typedef struct AKE_Transmitter_Info_ {
	u8 msg_id;
	u8 LENGTH[2];
	u8 VERSION;
	u8 TRANSMITTER_CAPABILITY_MASK[2];
} AKE_TRANSMITTER_INFO;

/**
 * @struct AKE_Receiver_Info_
 *
 * This structure contains information regarding AKE_Receiver_Info message.
 */
typedef struct AKE_Receiver_Info_ {
	u8 msg_id;
	u8 LENGTH[2];
	u8 VERSION;
	u8 RECEIVER_CAPABILITY_MASK[2];
} AKE_RECEIVER_INFO;

/**
 * @struct LC_Init_
 *
 * This structure contains information regarding LC_Init message.
 */
typedef struct LC_Init_ {
	u8 msg_id;
	u8 rn[8];
} LC_INIT;

/**
 * @struct RTT_Ready_
 *
 * This structure contains information regarding RTT_Ready message.
 */
typedef struct RTT_Ready_ {
	u8 msg_id;
} RTT_READY;

/**
 * @struct RTT_Challenge_
 *
 * This structure contains information regarding RTT_Challenge message.
 */
typedef struct RTT_Challenge_ {
	u8 msg_id;
	u8 L_lsb[16];
} RTT_CHALLENGE;

/**
 * @struct LC_Send_L_prime_pc
 *
 * This structure contains information regarding LC_Send_L_prime_pc message
 */
typedef struct LC_Send_L_prime_pc {
	u8 msg_id;
	u8 L_msb[16];
} LC_SEND_L_PRIME_PC;

/**
 * @struct LC_Send_L_prime_
 *
 * This structure contains information regarding LC_Send_L_prime message.
 */
typedef struct LC_Send_L_prime_ {
	u8 msg_id;
	u8 L[32];
} LC_SEND_L_PRIME;

/**
 * @struct SKE_Send_Eks_
 *
 * This structure contains information regarding SKE_Send_Eks message.
 */
typedef struct SKE_Send_Eks_ {
	u8 msg_id;
	u8 Eks[16];
	u8 riv[8];
} SKE_SEND_EKS;

/**
 * @struct SKE_Send_Eks_Ver23_
 *
 * This structure contains information regarding EKS.
 */
typedef struct SKE_Send_Eks_Ver23_ {
	u8 msg_id;
	u8 Eks[16];
	u8 riv[8];
	u8 H[32];
} SKE_SEND_EKS_VER23;

/**
 * @struct Device_Receiver_ID_
 *
 * This structure contains information regarding Device Receiver Id.
 */
typedef struct Device_Receiver_ID_ {
	u8 RECEIVER_IDj[5];
} DEVICE_RECEIVER_ID;

/**
 * @struct RepeaterAuth_Send_ReceiverId_List21_
 *
 * This structure contains information regarding RepeaterAuth_Send_ReceiverId_List message.
 */
typedef struct RepeaterAuth_Send_ReceiverId_List21_ {
	u8 msg_id;
	u8 MAX_DEVS_EXCEEDED;
	u8 MAX_CASCADE_EXCEEDED;
	u8 DEVICE_COUNT;
	u8 DEPTH;
	u8 HDCP2_LEGACY_DEVICE_DOWNSTREAM;
	u8 HDCP1_DEVICE_DOWNSTREAM;
	u8 seq_num_V[3];
	u8 V_PRIME[16];
	DEVICE_RECEIVER_ID RECEIVER_IDs[31];
} REPEATERAUTH_SEND_RECEIVER_ID_LIST21;

/**
 * @struct RepeaterAuth_Send_ReceiverId_List20_
 *
 * This structure contains information regarding RepeaterAuth_Send_ReceiverId_List message.
 */
typedef struct RepeaterAuth_Send_ReceiverId_List20_ {
	u8 msg_id;
	u8 MAX_DEVS_EXCEEDED;
	u8 MAX_CASCADE_EXCEEDED;
	u8 DEVICE_COUNT;
	u8 DEPTH;
	u8 V_PRIME[32];
	DEVICE_RECEIVER_ID RECEIVER_IDs[31];
} REPEATERAUTH_SEND_RECEIVER_ID_LIST20;

/**
 * @struct RepeaterAuth_Send_Ack_
 *
 * This structure contains information regarding RepeaterAuth_Send_Ack message.
 */
typedef struct RepeaterAuth_Send_Ack_ {
	u8 msg_id;
	u8 V[16];
} REPEATERAUTH_SEND_ACK;

/**
 * @struct Receiver_AuthStatus_
 *
 * This structure contains information regarding Receiver_AuthStatus message.
 */
typedef struct Receiver_AuthStatus_ {
	u8 msg_id;
	u8 LENGTH[2];
	u8 REAUTH_Req;
} RECEIVER_AUTHSTATUS;

/**
 * @struct Downstream_Params_
 *
 * This structure contains information regarding Downstream_Params message.
 */
typedef struct Downstream_Params_ {
	u8 streamCtrj[4];
	/*
	 * [15:13] =0
	 * [12:0] = PID
	 */
	u8 ContentStreamIDj[2];
	u8 Type;
} Downstream_Params;

/**
 * @struct RepeaterAuth_Stream_Manage_
 *
 * This structure contains information regarding RepeaterAuth_Stream_Manage message.
 */
typedef struct RepeaterAuth_Stream_Manage_ {
	u8 msg_id;
	u8 seq_num_M[3];
	u8 k[2];
	Downstream_Params max_k_info[16];
} REPEATERAUTH_STREAM_MANAGE;

/**
 * @struct RepeaterAuth_Stream_Info_
 *
 * This structure contains information regarding RepeaterAuth_Stream_Info message.
 */
typedef struct RepeaterAuth_Stream_Info_ {
#ifdef USE_QUALCOMM
	u8 msg_id;
#endif /* USE_QUALCOMM */
	u8 no_of_streams[2];
	Downstream_Params multi_streaminfo[16];
} REPEATERAUTH_STREAM_INFO;

/**
 * @struct RepeaterAuth_Stream_Ready_
 *
 * This structure contains information regarding RepeaterAuth_Stream_Ready message.
 */
typedef struct RepeaterAuth_Stream_Ready_ {
	u8 msg_id;
	u8 M_PRIME[32];
}REPEATERAUTH_STREAM_READY;


// QUALCOMM ------------------------------------------
#if defined(USE_QUALCOMM)
/**
 * @struct Deliver_Key_Data
 *
 * This structure contains information regarding Deliver_Key_Data message if chipset is QUALCOMM.
 */
typedef struct Deliver_Key_Data {
	u8 msg_id;
	u8 key[PROVISIONING_KEY_SIZE];
}DELIVER_KEY_DATA;

#pragma pack(1)
/**
 * @struct Cipher_Data_Info_
 *
 * This structure contains information regarding Cipher_Data_Info.
 */
typedef struct Cipher_Data_Info_ {
	u32 str_ctr; //4
	u64 inp_ctr; //8
	u32 length;
	u8 *input;
	u8 *output;
} CIP_DATA_INFO;

#pragma pack(1)
/**
 * @struct Cipher_Data_Info_RX
 *
 * This structure contains information regarding Cipher_Data_Info_RX.
 */
typedef struct Cipher_Data_Info_RX {
	u8 msg_id;
	u32 str_ctr;
	u64 inp_ctr;
	u32 length;
	u32 dec_type;
	u32 codec_type;
	u8 *output;
	u8 *input;
} CIP_DATA_INFO_RX;

#pragma pack(1)
typedef struct Cipher_Data_Info_ION_RX {
	u8 msg_id;
	u32 str_ctr;
	u64 inp_ctr;
	u32 length;
	u32 dec_type;
	u32 codec_type;
	u8 *output;
	u8 *input;
	tz_buf_array_s_t input_data;
	tz_buf_array_s_t output_data;
} CIP_DATA_INFO_ION_RX;

/**
 * @struct Cipher_Data_Info_QC_TX
 *
 * This structure contains information regarding Cipher_Data_Info_QC_TX.
 */
#pragma pack(1)
typedef struct Cipher_Data_Info_QC_TX {
	u32 dummy;

#ifndef CONFIG_HDCP_64BIT
	tz_buf_array_s_t input_data;
	tz_buf_array_s_t output_data;
#endif /* !CONFIG_HDCP_64BIT */

	u32 str_ctr;
	u64 inp_ctr;
	u32 length;
	u8 *input;
	u8 *output;
	size_t offset;
	u8 dummy_arr[60 - sizeof(size_t)];

#ifdef CONFIG_HDCP_64BIT
	tz_buf_array_s_t output_data;
	tz_buf_array_s_t input_data;
#endif /* CONFIG_HDCP_64BIT */
} CIP_DATA_INFO_QC_TX;

// TEEGRIS ------------------------------------------
#elif defined (USE_TEEGRIS)
typedef struct Cipher_Data_Info_BF_TX {
	u32 dummy;
	u32 input_data;
	u32 output_data;
	u32 str_ctr;
	u64 inp_ctr;
	u32 length;
	u8 *input;
	u8 *output;
	size_t offset;
	u32 split_ctr;
#ifdef USE_MTK
	u32 is_sec_buf;
	u8 dummy_arr[60 - sizeof(size_t) - sizeof(u32)];
#else
	u8 dummy_arr[60 - sizeof(size_t)];
#endif /* USE_MTK */
} CIP_DATA_INFO;

/**
 * @struct Cipher_Data_Info_RX
 *
 * This structure contains information regarding Cipher_Data_Info_RX.
 */
typedef struct Cipher_Data_Info_RX {
	u32 str_ctr;
	u64 inp_ctr;
	u8 *input;
	u8 *output;
	u32 length;
	u32 dec_type;
	u32 codec_type;
} CIP_DATA_INFO_RX;

/**
 * @struct CIP_DATA_SPSPPS_RX
 *
 * This structure contains information regarding CIP_DATA_SPSPPS_RX.
 */
typedef struct CIP_DATA_SPSPPS_RX {
	u8 spspps[MAX_SPS_BUFFER];
	u8 *phy_in;
	u8 *phy_out;
	int size;
	int split_ctr;
} CIP_DATA_SPSPPS;

/**
 * @struct Cipher_Data_Info_VIR
 *
 * This structure contains information regarding Cipher_Data_Info_VIR.
 */
typedef struct Cipher_Data_Info_VIR {
	u32 str_ctr;
	u64 inp_ctr;
	u8 input[1024];
	u8 output[1024];
	u32 length;
	u32 dec_type;
	u32 codec_type;
} CIP_DATA_INFO_VIR;

// MOBICORE ------------------------------------------
#else /* USE_MOBICORE */
/**
 * @struct Cipher_Data_Info_
 *
 * This structure contains information regarding Cipher_Data_Info.
 */
typedef struct Cipher_Data_Info_ {
	u32 str_ctr; //4
	u64 inp_ctr; //8
	addr_s input;
	addr_s output;
	u32 length;
#ifdef USE_MTK
	size_t type;
#endif /* USE_MTK */
} CIP_DATA_INFO;
/**
 * @struct Cipher_Data_Info_RX
 *
 * This structure contains information regarding Cipher_Data_Info_RX.
 */
typedef struct Cipher_Data_Info_RX {
	u32 str_ctr;
	u64 inp_ctr;
	addr_s input;
	addr_s output;
	u32 length;
	u32 dec_type;
	u32 codec_type;
} CIP_DATA_INFO_RX;

/**
 * @struct CIP_DATA_SPSPPS_RX
 *
 * This structure contains information regarding CIP_DATA_SPSPPS_RX.
 */
typedef struct CIP_DATA_SPSPPS_RX {
	u8 spspps[MAX_SPS_BUFFER];
	u8 *phy_in;
	addr_s *phy_out;
	int size;
} CIP_DATA_SPSPPS;

/**
 * @struct Cipher_Data_Info_VIR
 *
 * This structure contains information regarding Cipher_Data_Info_VIR.
 */
typedef struct Cipher_Data_Info_VIR {
	u32 str_ctr;
	u64 inp_ctr;
	u8 input[1024];
	u8 output[1024];
	u32 length;
	u32 dec_type;
	u32 codec_type;
} CIP_DATA_INFO_VIR;
#endif /* USE_QUALCOMM */

/**
 * @def MAX_NAME_LENGTH
 *
 * This macro is assigned value 20 to indicate maximum length of name.
 *
 */
#define MAX_NAME_LENGTH	20

/**
 * @def MAX_CHUNK_INFO_COUNT
 *
 * This macro is assigned value 12 to indicate the maximum count of chunk info
 *
 */
#define MAX_CHUNK_INFO_COUNT	12

/**
 * @struct secmem_buffer
 *
 * This structure contains information regarding secmem_buffer.
 */
#ifdef CONFIG_KERNEL_ARCH32
struct secmem_buffer {
	int buf_fd;
	void *virt_addr;
	unsigned long phys_addr;
	unsigned long len;
};
#else
struct secmem_buffer {
	int buf_fd;
	void *virt_addr;
	uint64_t phys_addr;
	uint64_t len;
};
#endif /* CONFIG_KERNEL_ARCH32 */

/**
 * @struct secmem_
 *
 * This structure contains information regarding secmem.
 */
#ifdef CONFIG_KERNEL_ARCH32
typedef struct secmem_ {
	int index;
	uint8_t name[MAX_NAME_LENGTH];
	uint32_t base;
	uint32_t size;
} SECMEM;
#else
typedef struct secmem_ {
	int index;
	uint8_t name[MAX_NAME_LENGTH];
	uint64_t base;
	uint64_t size;
} SECMEM;
#endif /* CONFIG_KERNEL_ARCH32 */

/**
 * @struct secmem_init_cmd_
 *
 * This structure contains information regarding secmem_init_cmd.
 */
typedef struct secmem_init_cmd_ {
	int32_t chunk_num;
	SECMEM secmem[MAX_CHUNK_INFO_COUNT];
} SECMEM_INIT_CMD;

#ifdef __cplusplus
}
#endif

#endif /* HDCP2_COMMON_H_ */
