xref: /OK3568_Linux_fs/kernel/include/drm/i915_mei_hdcp_interface.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: (GPL-2.0+) */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright © 2017-2019 Intel Corporation
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Authors:
6*4882a593Smuzhiyun  * Ramalingam C <ramalingam.c@intel.com>
7*4882a593Smuzhiyun  */
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #ifndef _I915_MEI_HDCP_INTERFACE_H_
10*4882a593Smuzhiyun #define _I915_MEI_HDCP_INTERFACE_H_
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun #include <linux/mutex.h>
13*4882a593Smuzhiyun #include <linux/device.h>
14*4882a593Smuzhiyun #include <drm/drm_hdcp.h>
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun /**
17*4882a593Smuzhiyun  * enum hdcp_port_type - HDCP port implementation type defined by ME FW
18*4882a593Smuzhiyun  * @HDCP_PORT_TYPE_INVALID: Invalid hdcp port type
19*4882a593Smuzhiyun  * @HDCP_PORT_TYPE_INTEGRATED: In-Host HDCP2.x port
20*4882a593Smuzhiyun  * @HDCP_PORT_TYPE_LSPCON: HDCP2.2 discrete wired Tx port with LSPCON
21*4882a593Smuzhiyun  *			   (HDMI 2.0) solution
22*4882a593Smuzhiyun  * @HDCP_PORT_TYPE_CPDP: HDCP2.2 discrete wired Tx port using the CPDP (DP 1.3)
23*4882a593Smuzhiyun  *			 solution
24*4882a593Smuzhiyun  */
25*4882a593Smuzhiyun enum hdcp_port_type {
26*4882a593Smuzhiyun 	HDCP_PORT_TYPE_INVALID,
27*4882a593Smuzhiyun 	HDCP_PORT_TYPE_INTEGRATED,
28*4882a593Smuzhiyun 	HDCP_PORT_TYPE_LSPCON,
29*4882a593Smuzhiyun 	HDCP_PORT_TYPE_CPDP
30*4882a593Smuzhiyun };
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun /**
33*4882a593Smuzhiyun  * enum hdcp_wired_protocol - HDCP adaptation used on the port
34*4882a593Smuzhiyun  * @HDCP_PROTOCOL_INVALID: Invalid HDCP adaptation protocol
35*4882a593Smuzhiyun  * @HDCP_PROTOCOL_HDMI: HDMI adaptation of HDCP used on the port
36*4882a593Smuzhiyun  * @HDCP_PROTOCOL_DP: DP adaptation of HDCP used on the port
37*4882a593Smuzhiyun  */
38*4882a593Smuzhiyun enum hdcp_wired_protocol {
39*4882a593Smuzhiyun 	HDCP_PROTOCOL_INVALID,
40*4882a593Smuzhiyun 	HDCP_PROTOCOL_HDMI,
41*4882a593Smuzhiyun 	HDCP_PROTOCOL_DP
42*4882a593Smuzhiyun };
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun enum mei_fw_ddi {
45*4882a593Smuzhiyun 	MEI_DDI_INVALID_PORT = 0x0,
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun 	MEI_DDI_B = 1,
48*4882a593Smuzhiyun 	MEI_DDI_C,
49*4882a593Smuzhiyun 	MEI_DDI_D,
50*4882a593Smuzhiyun 	MEI_DDI_E,
51*4882a593Smuzhiyun 	MEI_DDI_F,
52*4882a593Smuzhiyun 	MEI_DDI_A = 7,
53*4882a593Smuzhiyun 	MEI_DDI_RANGE_END = MEI_DDI_A,
54*4882a593Smuzhiyun };
55*4882a593Smuzhiyun 
56*4882a593Smuzhiyun /**
57*4882a593Smuzhiyun  * enum mei_fw_tc - ME Firmware defined index for transcoders
58*4882a593Smuzhiyun  * @MEI_INVALID_TRANSCODER: Index for Invalid transcoder
59*4882a593Smuzhiyun  * @MEI_TRANSCODER_EDP: Index for EDP Transcoder
60*4882a593Smuzhiyun  * @MEI_TRANSCODER_DSI0: Index for DSI0 Transcoder
61*4882a593Smuzhiyun  * @MEI_TRANSCODER_DSI1: Index for DSI1 Transcoder
62*4882a593Smuzhiyun  * @MEI_TRANSCODER_A: Index for Transcoder A
63*4882a593Smuzhiyun  * @MEI_TRANSCODER_B: Index for Transcoder B
64*4882a593Smuzhiyun  * @MEI_TRANSCODER_C: Index for Transcoder C
65*4882a593Smuzhiyun  * @MEI_TRANSCODER_D: Index for Transcoder D
66*4882a593Smuzhiyun  */
67*4882a593Smuzhiyun enum mei_fw_tc {
68*4882a593Smuzhiyun 	MEI_INVALID_TRANSCODER = 0x00,
69*4882a593Smuzhiyun 	MEI_TRANSCODER_EDP,
70*4882a593Smuzhiyun 	MEI_TRANSCODER_DSI0,
71*4882a593Smuzhiyun 	MEI_TRANSCODER_DSI1,
72*4882a593Smuzhiyun 	MEI_TRANSCODER_A = 0x10,
73*4882a593Smuzhiyun 	MEI_TRANSCODER_B,
74*4882a593Smuzhiyun 	MEI_TRANSCODER_C,
75*4882a593Smuzhiyun 	MEI_TRANSCODER_D
76*4882a593Smuzhiyun };
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun /**
79*4882a593Smuzhiyun  * struct hdcp_port_data - intel specific HDCP port data
80*4882a593Smuzhiyun  * @fw_ddi: ddi index as per ME FW
81*4882a593Smuzhiyun  * @fw_tc: transcoder index as per ME FW
82*4882a593Smuzhiyun  * @port_type: HDCP port type as per ME FW classification
83*4882a593Smuzhiyun  * @protocol: HDCP adaptation as per ME FW
84*4882a593Smuzhiyun  * @k: No of streams transmitted on a port. Only on DP MST this is != 1
85*4882a593Smuzhiyun  * @seq_num_m: Count of RepeaterAuth_Stream_Manage msg propagated.
86*4882a593Smuzhiyun  *	       Initialized to 0 on AKE_INIT. Incremented after every successful
87*4882a593Smuzhiyun  *	       transmission of RepeaterAuth_Stream_Manage message. When it rolls
88*4882a593Smuzhiyun  *	       over re-Auth has to be triggered.
89*4882a593Smuzhiyun  * @streams: struct hdcp2_streamid_type[k]. Defines the type and id for the
90*4882a593Smuzhiyun  *	     streams
91*4882a593Smuzhiyun  */
92*4882a593Smuzhiyun struct hdcp_port_data {
93*4882a593Smuzhiyun 	enum mei_fw_ddi fw_ddi;
94*4882a593Smuzhiyun 	enum mei_fw_tc fw_tc;
95*4882a593Smuzhiyun 	u8 port_type;
96*4882a593Smuzhiyun 	u8 protocol;
97*4882a593Smuzhiyun 	u16 k;
98*4882a593Smuzhiyun 	u32 seq_num_m;
99*4882a593Smuzhiyun 	struct hdcp2_streamid_type *streams;
100*4882a593Smuzhiyun };
101*4882a593Smuzhiyun 
102*4882a593Smuzhiyun /**
103*4882a593Smuzhiyun  * struct i915_hdcp_component_ops- ops for HDCP2.2 services.
104*4882a593Smuzhiyun  * @owner: Module providing the ops
105*4882a593Smuzhiyun  * @initiate_hdcp2_session: Initiate a Wired HDCP2.2 Tx Session.
106*4882a593Smuzhiyun  *			    And Prepare AKE_Init.
107*4882a593Smuzhiyun  * @verify_receiver_cert_prepare_km: Verify the Receiver Certificate
108*4882a593Smuzhiyun  *				     AKE_Send_Cert and prepare
109*4882a593Smuzhiyun 				     AKE_Stored_Km/AKE_No_Stored_Km
110*4882a593Smuzhiyun  * @verify_hprime: Verify AKE_Send_H_prime
111*4882a593Smuzhiyun  * @store_pairing_info: Store pairing info received
112*4882a593Smuzhiyun  * @initiate_locality_check: Prepare LC_Init
113*4882a593Smuzhiyun  * @verify_lprime: Verify lprime
114*4882a593Smuzhiyun  * @get_session_key: Prepare SKE_Send_Eks
115*4882a593Smuzhiyun  * @repeater_check_flow_prepare_ack: Validate the Downstream topology
116*4882a593Smuzhiyun  *				     and prepare rep_ack
117*4882a593Smuzhiyun  * @verify_mprime: Verify mprime
118*4882a593Smuzhiyun  * @enable_hdcp_authentication:  Mark a port as authenticated.
119*4882a593Smuzhiyun  * @close_hdcp_session: Close the Wired HDCP Tx session per port.
120*4882a593Smuzhiyun  *			This also disables the authenticated state of the port.
121*4882a593Smuzhiyun  */
122*4882a593Smuzhiyun struct i915_hdcp_component_ops {
123*4882a593Smuzhiyun 	/**
124*4882a593Smuzhiyun 	 * @owner: mei_hdcp module
125*4882a593Smuzhiyun 	 */
126*4882a593Smuzhiyun 	struct module *owner;
127*4882a593Smuzhiyun 
128*4882a593Smuzhiyun 	int (*initiate_hdcp2_session)(struct device *dev,
129*4882a593Smuzhiyun 				      struct hdcp_port_data *data,
130*4882a593Smuzhiyun 				      struct hdcp2_ake_init *ake_data);
131*4882a593Smuzhiyun 	int (*verify_receiver_cert_prepare_km)(struct device *dev,
132*4882a593Smuzhiyun 					       struct hdcp_port_data *data,
133*4882a593Smuzhiyun 					       struct hdcp2_ake_send_cert
134*4882a593Smuzhiyun 								*rx_cert,
135*4882a593Smuzhiyun 					       bool *km_stored,
136*4882a593Smuzhiyun 					       struct hdcp2_ake_no_stored_km
137*4882a593Smuzhiyun 								*ek_pub_km,
138*4882a593Smuzhiyun 					       size_t *msg_sz);
139*4882a593Smuzhiyun 	int (*verify_hprime)(struct device *dev,
140*4882a593Smuzhiyun 			     struct hdcp_port_data *data,
141*4882a593Smuzhiyun 			     struct hdcp2_ake_send_hprime *rx_hprime);
142*4882a593Smuzhiyun 	int (*store_pairing_info)(struct device *dev,
143*4882a593Smuzhiyun 				  struct hdcp_port_data *data,
144*4882a593Smuzhiyun 				  struct hdcp2_ake_send_pairing_info
145*4882a593Smuzhiyun 								*pairing_info);
146*4882a593Smuzhiyun 	int (*initiate_locality_check)(struct device *dev,
147*4882a593Smuzhiyun 				       struct hdcp_port_data *data,
148*4882a593Smuzhiyun 				       struct hdcp2_lc_init *lc_init_data);
149*4882a593Smuzhiyun 	int (*verify_lprime)(struct device *dev,
150*4882a593Smuzhiyun 			     struct hdcp_port_data *data,
151*4882a593Smuzhiyun 			     struct hdcp2_lc_send_lprime *rx_lprime);
152*4882a593Smuzhiyun 	int (*get_session_key)(struct device *dev,
153*4882a593Smuzhiyun 			       struct hdcp_port_data *data,
154*4882a593Smuzhiyun 			       struct hdcp2_ske_send_eks *ske_data);
155*4882a593Smuzhiyun 	int (*repeater_check_flow_prepare_ack)(struct device *dev,
156*4882a593Smuzhiyun 					       struct hdcp_port_data *data,
157*4882a593Smuzhiyun 					       struct hdcp2_rep_send_receiverid_list
158*4882a593Smuzhiyun 								*rep_topology,
159*4882a593Smuzhiyun 					       struct hdcp2_rep_send_ack
160*4882a593Smuzhiyun 								*rep_send_ack);
161*4882a593Smuzhiyun 	int (*verify_mprime)(struct device *dev,
162*4882a593Smuzhiyun 			     struct hdcp_port_data *data,
163*4882a593Smuzhiyun 			     struct hdcp2_rep_stream_ready *stream_ready);
164*4882a593Smuzhiyun 	int (*enable_hdcp_authentication)(struct device *dev,
165*4882a593Smuzhiyun 					  struct hdcp_port_data *data);
166*4882a593Smuzhiyun 	int (*close_hdcp_session)(struct device *dev,
167*4882a593Smuzhiyun 				  struct hdcp_port_data *data);
168*4882a593Smuzhiyun };
169*4882a593Smuzhiyun 
170*4882a593Smuzhiyun /**
171*4882a593Smuzhiyun  * struct i915_hdcp_component_master - Used for communication between i915
172*4882a593Smuzhiyun  * and mei_hdcp drivers for the HDCP2.2 services
173*4882a593Smuzhiyun  * @mei_dev: device that provide the HDCP2.2 service from MEI Bus.
174*4882a593Smuzhiyun  * @hdcp_ops: Ops implemented by mei_hdcp driver, used by i915 driver.
175*4882a593Smuzhiyun  */
176*4882a593Smuzhiyun struct i915_hdcp_comp_master {
177*4882a593Smuzhiyun 	struct device *mei_dev;
178*4882a593Smuzhiyun 	const struct i915_hdcp_component_ops *ops;
179*4882a593Smuzhiyun 
180*4882a593Smuzhiyun 	/* To protect the above members. */
181*4882a593Smuzhiyun 	struct mutex mutex;
182*4882a593Smuzhiyun };
183*4882a593Smuzhiyun 
184*4882a593Smuzhiyun #endif /* _I915_MEI_HDCP_INTERFACE_H_ */
185