1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Cadence MHDP8546 DP bridge driver.
4  *
5  * Copyright (C) 2020 Cadence Design Systems, Inc.
6  *
7  */
8 
9 #ifndef CDNS_MHDP8546_HDCP_H
10 #define CDNS_MHDP8546_HDCP_H
11 
12 #include "cdns-mhdp8546-core.h"
13 
14 #define HDCP_MAX_RECEIVERS 32
15 #define HDCP_RECEIVER_ID_SIZE_BYTES 5
16 #define HDCP_STATUS_SIZE         0x5
17 #define HDCP_PORT_STS_AUTH       0x1
18 #define HDCP_PORT_STS_LAST_ERR_SHIFT 0x5
19 #define HDCP_PORT_STS_LAST_ERR_MASK  (0x0F << 5)
20 #define GET_HDCP_PORT_STS_LAST_ERR(__sts__) \
21 	(((__sts__) & HDCP_PORT_STS_LAST_ERR_MASK) >> \
22 	HDCP_PORT_STS_LAST_ERR_SHIFT)
23 
24 #define HDCP_CONFIG_1_4     BIT(0) /* use HDCP 1.4 only */
25 #define HDCP_CONFIG_2_2     BIT(1) /* use HDCP 2.2 only */
26 /* use All HDCP versions */
27 #define HDCP_CONFIG_ALL     (BIT(0) | BIT(1))
28 #define HDCP_CONFIG_NONE    0
29 
30 enum {
31 	HDCP_GENERAL_SET_LC_128,
32 	HDCP_SET_SEED,
33 };
34 
35 enum {
36 	HDCP_TRAN_CONFIGURATION,
37 	HDCP2X_TX_SET_PUBLIC_KEY_PARAMS,
38 	HDCP2X_TX_SET_DEBUG_RANDOM_NUMBERS,
39 	HDCP2X_TX_RESPOND_KM,
40 	HDCP1_TX_SEND_KEYS,
41 	HDCP1_TX_SEND_RANDOM_AN,
42 	HDCP_TRAN_STATUS_CHANGE,
43 	HDCP2X_TX_IS_KM_STORED,
44 	HDCP2X_TX_STORE_KM,
45 	HDCP_TRAN_IS_REC_ID_VALID,
46 	HDCP_TRAN_RESPOND_RECEIVER_ID_VALID,
47 	HDCP_TRAN_TEST_KEYS,
48 	HDCP2X_TX_SET_KM_KEY_PARAMS,
49 	HDCP_NUM_OF_SUPPORTED_MESSAGES
50 };
51 
52 enum {
53 	HDCP_CONTENT_TYPE_0,
54 	HDCP_CONTENT_TYPE_1,
55 };
56 
57 #define DRM_HDCP_CHECK_PERIOD_MS (128 * 16)
58 
59 #define HDCP_PAIRING_R_ID 5
60 #define HDCP_PAIRING_M_LEN 16
61 #define HDCP_KM_LEN 16
62 #define HDCP_PAIRING_M_EKH 16
63 
64 struct cdns_hdcp_pairing_data {
65 	u8 receiver_id[HDCP_PAIRING_R_ID];
66 	u8 m[HDCP_PAIRING_M_LEN];
67 	u8 km[HDCP_KM_LEN];
68 	u8 ekh[HDCP_PAIRING_M_EKH];
69 };
70 
71 enum {
72 	HDCP_TX_2,
73 	HDCP_TX_1,
74 	HDCP_TX_BOTH,
75 };
76 
77 #define DLP_MODULUS_N 384
78 #define DLP_E 3
79 
80 struct cdns_hdcp_tx_public_key_param {
81 	u8 N[DLP_MODULUS_N];
82 	u8 E[DLP_E];
83 };
84 
85 int cdns_mhdp_hdcp_set_public_key_param(struct cdns_mhdp_device *mhdp,
86 					struct cdns_hdcp_tx_public_key_param *val);
87 int cdns_mhdp_hdcp_set_lc(struct cdns_mhdp_device *mhdp, u8 *val);
88 int cdns_mhdp_hdcp_enable(struct cdns_mhdp_device *mhdp, u8 content_type);
89 int cdns_mhdp_hdcp_disable(struct cdns_mhdp_device *mhdp);
90 void cdns_mhdp_hdcp_init(struct cdns_mhdp_device *mhdp);
91 
92 #endif
93