14f73dc7aSAnshuman Gupta /* SPDX-License-Identifier: (GPL-2.0+) */
24f73dc7aSAnshuman Gupta /*
34f73dc7aSAnshuman Gupta  * Copyright © 2017-2019 Intel Corporation
44f73dc7aSAnshuman Gupta  *
54f73dc7aSAnshuman Gupta  * Authors:
64f73dc7aSAnshuman Gupta  * Ramalingam C <ramalingam.c@intel.com>
74f73dc7aSAnshuman Gupta  */
84f73dc7aSAnshuman Gupta 
94f73dc7aSAnshuman Gupta #ifndef _I915_HDCP_INTERFACE_H_
104f73dc7aSAnshuman Gupta #define _I915_HDCP_INTERFACE_H_
114f73dc7aSAnshuman Gupta 
124f73dc7aSAnshuman Gupta #include <linux/mutex.h>
134f73dc7aSAnshuman Gupta #include <linux/device.h>
144f73dc7aSAnshuman Gupta #include <drm/display/drm_hdcp.h>
154f73dc7aSAnshuman Gupta 
164f73dc7aSAnshuman Gupta /**
174f73dc7aSAnshuman Gupta  * enum hdcp_port_type - HDCP port implementation type defined by ME/GSC FW
184f73dc7aSAnshuman Gupta  * @HDCP_PORT_TYPE_INVALID: Invalid hdcp port type
194f73dc7aSAnshuman Gupta  * @HDCP_PORT_TYPE_INTEGRATED: In-Host HDCP2.x port
204f73dc7aSAnshuman Gupta  * @HDCP_PORT_TYPE_LSPCON: HDCP2.2 discrete wired Tx port with LSPCON
214f73dc7aSAnshuman Gupta  *			   (HDMI 2.0) solution
224f73dc7aSAnshuman Gupta  * @HDCP_PORT_TYPE_CPDP: HDCP2.2 discrete wired Tx port using the CPDP (DP 1.3)
234f73dc7aSAnshuman Gupta  *			 solution
244f73dc7aSAnshuman Gupta  */
254f73dc7aSAnshuman Gupta enum hdcp_port_type {
264f73dc7aSAnshuman Gupta 	HDCP_PORT_TYPE_INVALID,
274f73dc7aSAnshuman Gupta 	HDCP_PORT_TYPE_INTEGRATED,
284f73dc7aSAnshuman Gupta 	HDCP_PORT_TYPE_LSPCON,
294f73dc7aSAnshuman Gupta 	HDCP_PORT_TYPE_CPDP
304f73dc7aSAnshuman Gupta };
314f73dc7aSAnshuman Gupta 
324f73dc7aSAnshuman Gupta /**
334f73dc7aSAnshuman Gupta  * enum hdcp_wired_protocol - HDCP adaptation used on the port
344f73dc7aSAnshuman Gupta  * @HDCP_PROTOCOL_INVALID: Invalid HDCP adaptation protocol
354f73dc7aSAnshuman Gupta  * @HDCP_PROTOCOL_HDMI: HDMI adaptation of HDCP used on the port
364f73dc7aSAnshuman Gupta  * @HDCP_PROTOCOL_DP: DP adaptation of HDCP used on the port
374f73dc7aSAnshuman Gupta  */
384f73dc7aSAnshuman Gupta enum hdcp_wired_protocol {
394f73dc7aSAnshuman Gupta 	HDCP_PROTOCOL_INVALID,
404f73dc7aSAnshuman Gupta 	HDCP_PROTOCOL_HDMI,
414f73dc7aSAnshuman Gupta 	HDCP_PROTOCOL_DP
424f73dc7aSAnshuman Gupta };
434f73dc7aSAnshuman Gupta 
444f73dc7aSAnshuman Gupta enum hdcp_ddi {
454f73dc7aSAnshuman Gupta 	HDCP_DDI_INVALID_PORT = 0x0,
464f73dc7aSAnshuman Gupta 
474f73dc7aSAnshuman Gupta 	HDCP_DDI_B = 1,
484f73dc7aSAnshuman Gupta 	HDCP_DDI_C,
494f73dc7aSAnshuman Gupta 	HDCP_DDI_D,
504f73dc7aSAnshuman Gupta 	HDCP_DDI_E,
514f73dc7aSAnshuman Gupta 	HDCP_DDI_F,
524f73dc7aSAnshuman Gupta 	HDCP_DDI_A = 7,
534f73dc7aSAnshuman Gupta 	HDCP_DDI_RANGE_END = HDCP_DDI_A,
544f73dc7aSAnshuman Gupta };
554f73dc7aSAnshuman Gupta 
564f73dc7aSAnshuman Gupta /**
574f73dc7aSAnshuman Gupta  * enum hdcp_tc - ME/GSC Firmware defined index for transcoders
584f73dc7aSAnshuman Gupta  * @HDCP_INVALID_TRANSCODER: Index for Invalid transcoder
594f73dc7aSAnshuman Gupta  * @HDCP_TRANSCODER_EDP: Index for EDP Transcoder
604f73dc7aSAnshuman Gupta  * @HDCP_TRANSCODER_DSI0: Index for DSI0 Transcoder
614f73dc7aSAnshuman Gupta  * @HDCP_TRANSCODER_DSI1: Index for DSI1 Transcoder
624f73dc7aSAnshuman Gupta  * @HDCP_TRANSCODER_A: Index for Transcoder A
634f73dc7aSAnshuman Gupta  * @HDCP_TRANSCODER_B: Index for Transcoder B
644f73dc7aSAnshuman Gupta  * @HDCP_TRANSCODER_C: Index for Transcoder C
654f73dc7aSAnshuman Gupta  * @HDCP_TRANSCODER_D: Index for Transcoder D
664f73dc7aSAnshuman Gupta  */
674f73dc7aSAnshuman Gupta enum hdcp_transcoder {
684f73dc7aSAnshuman Gupta 	HDCP_INVALID_TRANSCODER = 0x00,
694f73dc7aSAnshuman Gupta 	HDCP_TRANSCODER_EDP,
704f73dc7aSAnshuman Gupta 	HDCP_TRANSCODER_DSI0,
714f73dc7aSAnshuman Gupta 	HDCP_TRANSCODER_DSI1,
724f73dc7aSAnshuman Gupta 	HDCP_TRANSCODER_A = 0x10,
734f73dc7aSAnshuman Gupta 	HDCP_TRANSCODER_B,
744f73dc7aSAnshuman Gupta 	HDCP_TRANSCODER_C,
754f73dc7aSAnshuman Gupta 	HDCP_TRANSCODER_D
764f73dc7aSAnshuman Gupta };
774f73dc7aSAnshuman Gupta 
784f73dc7aSAnshuman Gupta /**
794f73dc7aSAnshuman Gupta  * struct hdcp_port_data - intel specific HDCP port data
804f73dc7aSAnshuman Gupta  * @hdcp_ddi: ddi index as per ME/GSC FW
814f73dc7aSAnshuman Gupta  * @hdcp_transcoder: transcoder index as per ME/GSC FW
824f73dc7aSAnshuman Gupta  * @port_type: HDCP port type as per ME/GSC FW classification
834f73dc7aSAnshuman Gupta  * @protocol: HDCP adaptation as per ME/GSC FW
844f73dc7aSAnshuman Gupta  * @k: No of streams transmitted on a port. Only on DP MST this is != 1
854f73dc7aSAnshuman Gupta  * @seq_num_m: Count of RepeaterAuth_Stream_Manage msg propagated.
864f73dc7aSAnshuman Gupta  *	       Initialized to 0 on AKE_INIT. Incremented after every successful
874f73dc7aSAnshuman Gupta  *	       transmission of RepeaterAuth_Stream_Manage message. When it rolls
884f73dc7aSAnshuman Gupta  *	       over re-Auth has to be triggered.
894f73dc7aSAnshuman Gupta  * @streams: struct hdcp2_streamid_type[k]. Defines the type and id for the
904f73dc7aSAnshuman Gupta  *	     streams
914f73dc7aSAnshuman Gupta  */
924f73dc7aSAnshuman Gupta struct hdcp_port_data {
934f73dc7aSAnshuman Gupta 	enum hdcp_ddi hdcp_ddi;
944f73dc7aSAnshuman Gupta 	enum hdcp_transcoder hdcp_transcoder;
954f73dc7aSAnshuman Gupta 	u8 port_type;
964f73dc7aSAnshuman Gupta 	u8 protocol;
974f73dc7aSAnshuman Gupta 	u16 k;
984f73dc7aSAnshuman Gupta 	u32 seq_num_m;
994f73dc7aSAnshuman Gupta 	struct hdcp2_streamid_type *streams;
1004f73dc7aSAnshuman Gupta };
1014f73dc7aSAnshuman Gupta 
1024f73dc7aSAnshuman Gupta /**
1034f73dc7aSAnshuman Gupta  * struct i915_hdcp_ops- ops for HDCP2.2 services.
1044f73dc7aSAnshuman Gupta  * @owner: Module providing the ops
1054f73dc7aSAnshuman Gupta  * @initiate_hdcp2_session: Initiate a Wired HDCP2.2 Tx Session.
1064f73dc7aSAnshuman Gupta  *			    And Prepare AKE_Init.
1074f73dc7aSAnshuman Gupta  * @verify_receiver_cert_prepare_km: Verify the Receiver Certificate
1084f73dc7aSAnshuman Gupta  *				     AKE_Send_Cert and prepare
1094f73dc7aSAnshuman Gupta 				     AKE_Stored_Km/AKE_No_Stored_Km
1104f73dc7aSAnshuman Gupta  * @verify_hprime: Verify AKE_Send_H_prime
1114f73dc7aSAnshuman Gupta  * @store_pairing_info: Store pairing info received
1124f73dc7aSAnshuman Gupta  * @initiate_locality_check: Prepare LC_Init
1134f73dc7aSAnshuman Gupta  * @verify_lprime: Verify lprime
1144f73dc7aSAnshuman Gupta  * @get_session_key: Prepare SKE_Send_Eks
1154f73dc7aSAnshuman Gupta  * @repeater_check_flow_prepare_ack: Validate the Downstream topology
1164f73dc7aSAnshuman Gupta  *				     and prepare rep_ack
1174f73dc7aSAnshuman Gupta  * @verify_mprime: Verify mprime
1184f73dc7aSAnshuman Gupta  * @enable_hdcp_authentication:  Mark a port as authenticated.
1194f73dc7aSAnshuman Gupta  * @close_hdcp_session: Close the Wired HDCP Tx session per port.
1204f73dc7aSAnshuman Gupta  *			This also disables the authenticated state of the port.
1214f73dc7aSAnshuman Gupta  */
1224f73dc7aSAnshuman Gupta struct i915_hdcp_ops {
1234f73dc7aSAnshuman Gupta 	/**
1244f73dc7aSAnshuman Gupta 	 * @owner: hdcp module
1254f73dc7aSAnshuman Gupta 	 */
1264f73dc7aSAnshuman Gupta 	struct module *owner;
1274f73dc7aSAnshuman Gupta 
1284f73dc7aSAnshuman Gupta 	int (*initiate_hdcp2_session)(struct device *dev,
1294f73dc7aSAnshuman Gupta 				      struct hdcp_port_data *data,
1304f73dc7aSAnshuman Gupta 				      struct hdcp2_ake_init *ake_data);
1314f73dc7aSAnshuman Gupta 	int (*verify_receiver_cert_prepare_km)(struct device *dev,
1324f73dc7aSAnshuman Gupta 					       struct hdcp_port_data *data,
1334f73dc7aSAnshuman Gupta 					       struct hdcp2_ake_send_cert
1344f73dc7aSAnshuman Gupta 								*rx_cert,
1354f73dc7aSAnshuman Gupta 					       bool *km_stored,
1364f73dc7aSAnshuman Gupta 					       struct hdcp2_ake_no_stored_km
1374f73dc7aSAnshuman Gupta 								*ek_pub_km,
1384f73dc7aSAnshuman Gupta 					       size_t *msg_sz);
1394f73dc7aSAnshuman Gupta 	int (*verify_hprime)(struct device *dev,
1404f73dc7aSAnshuman Gupta 			     struct hdcp_port_data *data,
1414f73dc7aSAnshuman Gupta 			     struct hdcp2_ake_send_hprime *rx_hprime);
1424f73dc7aSAnshuman Gupta 	int (*store_pairing_info)(struct device *dev,
1434f73dc7aSAnshuman Gupta 				  struct hdcp_port_data *data,
1444f73dc7aSAnshuman Gupta 				  struct hdcp2_ake_send_pairing_info
1454f73dc7aSAnshuman Gupta 								*pairing_info);
1464f73dc7aSAnshuman Gupta 	int (*initiate_locality_check)(struct device *dev,
1474f73dc7aSAnshuman Gupta 				       struct hdcp_port_data *data,
1484f73dc7aSAnshuman Gupta 				       struct hdcp2_lc_init *lc_init_data);
1494f73dc7aSAnshuman Gupta 	int (*verify_lprime)(struct device *dev,
1504f73dc7aSAnshuman Gupta 			     struct hdcp_port_data *data,
1514f73dc7aSAnshuman Gupta 			     struct hdcp2_lc_send_lprime *rx_lprime);
1524f73dc7aSAnshuman Gupta 	int (*get_session_key)(struct device *dev,
1534f73dc7aSAnshuman Gupta 			       struct hdcp_port_data *data,
1544f73dc7aSAnshuman Gupta 			       struct hdcp2_ske_send_eks *ske_data);
1554f73dc7aSAnshuman Gupta 	int (*repeater_check_flow_prepare_ack)(struct device *dev,
1564f73dc7aSAnshuman Gupta 					       struct hdcp_port_data *data,
1574f73dc7aSAnshuman Gupta 					       struct hdcp2_rep_send_receiverid_list
1584f73dc7aSAnshuman Gupta 								*rep_topology,
1594f73dc7aSAnshuman Gupta 					       struct hdcp2_rep_send_ack
1604f73dc7aSAnshuman Gupta 								*rep_send_ack);
1614f73dc7aSAnshuman Gupta 	int (*verify_mprime)(struct device *dev,
1624f73dc7aSAnshuman Gupta 			     struct hdcp_port_data *data,
1634f73dc7aSAnshuman Gupta 			     struct hdcp2_rep_stream_ready *stream_ready);
1644f73dc7aSAnshuman Gupta 	int (*enable_hdcp_authentication)(struct device *dev,
1654f73dc7aSAnshuman Gupta 					  struct hdcp_port_data *data);
1664f73dc7aSAnshuman Gupta 	int (*close_hdcp_session)(struct device *dev,
1674f73dc7aSAnshuman Gupta 				  struct hdcp_port_data *data);
1684f73dc7aSAnshuman Gupta };
1694f73dc7aSAnshuman Gupta 
1704f73dc7aSAnshuman Gupta /**
1714f73dc7aSAnshuman Gupta  * struct i915_hdcp_master - Used for communication between i915
1724f73dc7aSAnshuman Gupta  * and hdcp drivers for the HDCP2.2 services
1734f73dc7aSAnshuman Gupta  * @hdcp_dev: device that provide the HDCP2.2 service from MEI Bus.
1744f73dc7aSAnshuman Gupta  * @hdcp_ops: Ops implemented by hdcp driver or intel_hdcp_gsc , used by i915 driver.
1754f73dc7aSAnshuman Gupta  */
1764f73dc7aSAnshuman Gupta struct i915_hdcp_master {
1774f73dc7aSAnshuman Gupta 	struct device *hdcp_dev;
1784f73dc7aSAnshuman Gupta 	const struct i915_hdcp_ops *ops;
1794f73dc7aSAnshuman Gupta 
1804f73dc7aSAnshuman Gupta 	/* To protect the above members. */
1814f73dc7aSAnshuman Gupta 	struct mutex mutex;
1824f73dc7aSAnshuman Gupta };
1834f73dc7aSAnshuman Gupta 
184*33898377SSuraj Kandpal /* fw_hdcp_status: Enumeration of all HDCP Status Codes */
185*33898377SSuraj Kandpal enum fw_hdcp_status {
186*33898377SSuraj Kandpal 	FW_HDCP_STATUS_SUCCESS			= 0x0000,
187*33898377SSuraj Kandpal 
188*33898377SSuraj Kandpal 	/* WiDi Generic Status Codes */
189*33898377SSuraj Kandpal 	FW_HDCP_STATUS_INTERNAL_ERROR		= 0x1000,
190*33898377SSuraj Kandpal 	FW_HDCP_STATUS_UNKNOWN_ERROR		= 0x1001,
191*33898377SSuraj Kandpal 	FW_HDCP_STATUS_INCORRECT_API_VERSION	= 0x1002,
192*33898377SSuraj Kandpal 	FW_HDCP_STATUS_INVALID_FUNCTION		= 0x1003,
193*33898377SSuraj Kandpal 	FW_HDCP_STATUS_INVALID_BUFFER_LENGTH	= 0x1004,
194*33898377SSuraj Kandpal 	FW_HDCP_STATUS_INVALID_PARAMS		= 0x1005,
195*33898377SSuraj Kandpal 	FW_HDCP_STATUS_AUTHENTICATION_FAILED	= 0x1006,
196*33898377SSuraj Kandpal 
197*33898377SSuraj Kandpal 	/* WiDi Status Codes */
198*33898377SSuraj Kandpal 	FW_HDCP_INVALID_SESSION_STATE		= 0x6000,
199*33898377SSuraj Kandpal 	FW_HDCP_SRM_FRAGMENT_UNEXPECTED		= 0x6001,
200*33898377SSuraj Kandpal 	FW_HDCP_SRM_INVALID_LENGTH		= 0x6002,
201*33898377SSuraj Kandpal 	FW_HDCP_SRM_FRAGMENT_OFFSET_INVALID	= 0x6003,
202*33898377SSuraj Kandpal 	FW_HDCP_SRM_VERIFICATION_FAILED		= 0x6004,
203*33898377SSuraj Kandpal 	FW_HDCP_SRM_VERSION_TOO_OLD		= 0x6005,
204*33898377SSuraj Kandpal 	FW_HDCP_RX_CERT_VERIFICATION_FAILED	= 0x6006,
205*33898377SSuraj Kandpal 	FW_HDCP_RX_REVOKED			= 0x6007,
206*33898377SSuraj Kandpal 	FW_HDCP_H_VERIFICATION_FAILED		= 0x6008,
207*33898377SSuraj Kandpal 	FW_HDCP_REPEATER_CHECK_UNEXPECTED	= 0x6009,
208*33898377SSuraj Kandpal 	FW_HDCP_TOPOLOGY_MAX_EXCEEDED		= 0x600A,
209*33898377SSuraj Kandpal 	FW_HDCP_V_VERIFICATION_FAILED		= 0x600B,
210*33898377SSuraj Kandpal 	FW_HDCP_L_VERIFICATION_FAILED		= 0x600C,
211*33898377SSuraj Kandpal 	FW_HDCP_STREAM_KEY_ALLOC_FAILED		= 0x600D,
212*33898377SSuraj Kandpal 	FW_HDCP_BASE_KEY_RESET_FAILED		= 0x600E,
213*33898377SSuraj Kandpal 	FW_HDCP_NONCE_GENERATION_FAILED		= 0x600F,
214*33898377SSuraj Kandpal 	FW_HDCP_STATUS_INVALID_E_KEY_STATE	= 0x6010,
215*33898377SSuraj Kandpal 	FW_HDCP_STATUS_INVALID_CS_ICV		= 0x6011,
216*33898377SSuraj Kandpal 	FW_HDCP_STATUS_INVALID_KB_KEY_STATE	= 0x6012,
217*33898377SSuraj Kandpal 	FW_HDCP_STATUS_INVALID_PAVP_MODE_ICV	= 0x6013,
218*33898377SSuraj Kandpal 	FW_HDCP_STATUS_INVALID_PAVP_MODE	= 0x6014,
219*33898377SSuraj Kandpal 	FW_HDCP_STATUS_LC_MAX_ATTEMPTS		= 0x6015,
220*33898377SSuraj Kandpal 
221*33898377SSuraj Kandpal 	/* New status for HDCP 2.1 */
222*33898377SSuraj Kandpal 	FW_HDCP_STATUS_MISMATCH_IN_M		= 0x6016,
223*33898377SSuraj Kandpal 
224*33898377SSuraj Kandpal 	/* New status code for HDCP 2.2 Rx */
225*33898377SSuraj Kandpal 	FW_HDCP_STATUS_RX_PROV_NOT_ALLOWED	= 0x6017,
226*33898377SSuraj Kandpal 	FW_HDCP_STATUS_RX_PROV_WRONG_SUBJECT	= 0x6018,
227*33898377SSuraj Kandpal 	FW_HDCP_RX_NEEDS_PROVISIONING		= 0x6019,
228*33898377SSuraj Kandpal 	FW_HDCP_BKSV_ICV_AUTH_FAILED		= 0x6020,
229*33898377SSuraj Kandpal 	FW_HDCP_STATUS_INVALID_STREAM_ID	= 0x6021,
230*33898377SSuraj Kandpal 	FW_HDCP_STATUS_CHAIN_NOT_INITIALIZED	= 0x6022,
231*33898377SSuraj Kandpal 	FW_HDCP_FAIL_NOT_EXPECTED		= 0x6023,
232*33898377SSuraj Kandpal 	FW_HDCP_FAIL_HDCP_OFF			= 0x6024,
233*33898377SSuraj Kandpal 	FW_HDCP_FAIL_INVALID_PAVP_MEMORY_MODE	= 0x6025,
234*33898377SSuraj Kandpal 	FW_HDCP_FAIL_AES_ECB_FAILURE		= 0x6026,
235*33898377SSuraj Kandpal 	FW_HDCP_FEATURE_NOT_SUPPORTED		= 0x6027,
236*33898377SSuraj Kandpal 	FW_HDCP_DMA_READ_ERROR			= 0x6028,
237*33898377SSuraj Kandpal 	FW_HDCP_DMA_WRITE_ERROR			= 0x6029,
238*33898377SSuraj Kandpal 	FW_HDCP_FAIL_INVALID_PACKET_SIZE	= 0x6030,
239*33898377SSuraj Kandpal 	FW_HDCP_H264_PARSING_ERROR		= 0x6031,
240*33898377SSuraj Kandpal 	FW_HDCP_HDCP2_ERRATA_VIDEO_VIOLATION	= 0x6032,
241*33898377SSuraj Kandpal 	FW_HDCP_HDCP2_ERRATA_AUDIO_VIOLATION	= 0x6033,
242*33898377SSuraj Kandpal 	FW_HDCP_TX_ACTIVE_ERROR			= 0x6034,
243*33898377SSuraj Kandpal 	FW_HDCP_MODE_CHANGE_ERROR		= 0x6035,
244*33898377SSuraj Kandpal 	FW_HDCP_STREAM_TYPE_ERROR		= 0x6036,
245*33898377SSuraj Kandpal 	FW_HDCP_STREAM_MANAGE_NOT_POSSIBLE	= 0x6037,
246*33898377SSuraj Kandpal 
247*33898377SSuraj Kandpal 	FW_HDCP_STATUS_PORT_INVALID_COMMAND	= 0x6038,
248*33898377SSuraj Kandpal 	FW_HDCP_STATUS_UNSUPPORTED_PROTOCOL	= 0x6039,
249*33898377SSuraj Kandpal 	FW_HDCP_STATUS_INVALID_PORT_INDEX	= 0x603a,
250*33898377SSuraj Kandpal 	FW_HDCP_STATUS_TX_AUTH_NEEDED		= 0x603b,
251*33898377SSuraj Kandpal 	FW_HDCP_STATUS_NOT_INTEGRATED_PORT	= 0x603c,
252*33898377SSuraj Kandpal 	FW_HDCP_STATUS_SESSION_MAX_REACHED	= 0x603d,
253*33898377SSuraj Kandpal 
254*33898377SSuraj Kandpal 	/* hdcp capable bit is not set in rx_caps(error is unique to DP) */
255*33898377SSuraj Kandpal 	FW_HDCP_STATUS_NOT_HDCP_CAPABLE		= 0x6041,
256*33898377SSuraj Kandpal 
257*33898377SSuraj Kandpal 	FW_HDCP_STATUS_INVALID_STREAM_COUNT	= 0x6042,
258*33898377SSuraj Kandpal };
259*33898377SSuraj Kandpal 
260*33898377SSuraj Kandpal #define HDCP_API_VERSION				0x00010000
261*33898377SSuraj Kandpal 
262*33898377SSuraj Kandpal #define HDCP_M_LEN					16
263*33898377SSuraj Kandpal #define HDCP_KH_LEN					16
264*33898377SSuraj Kandpal 
265*33898377SSuraj Kandpal /* Payload Buffer size(Excluding Header) for CMDs and corresponding response */
266*33898377SSuraj Kandpal /* Wired_Tx_AKE  */
267*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_INITIATE_HDCP2_SESSION_IN	(4 + 1)
268*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_INITIATE_HDCP2_SESSION_OUT	(4 + 8 + 3)
269*33898377SSuraj Kandpal 
270*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_VERIFY_RECEIVER_CERT_IN	(4 + 522 + 8 + 3)
271*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_VERIFY_RECEIVER_CERT_MIN_OUT	(4 + 1 + 3 + 16 + 16)
272*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_VERIFY_RECEIVER_CERT_MAX_OUT	(4 + 1 + 3 + 128)
273*33898377SSuraj Kandpal 
274*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_AKE_SEND_HPRIME_IN		(4 + 32)
275*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_AKE_SEND_HPRIME_OUT		(4)
276*33898377SSuraj Kandpal 
277*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_SEND_PAIRING_INFO_IN		(4 + 16)
278*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_SEND_PAIRING_INFO_OUT		(4)
279*33898377SSuraj Kandpal 
280*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_CLOSE_SESSION_IN		(4)
281*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_CLOSE_SESSION_OUT		(4)
282*33898377SSuraj Kandpal 
283*33898377SSuraj Kandpal /* Wired_Tx_LC */
284*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_INIT_LOCALITY_CHECK_IN	(4)
285*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_INIT_LOCALITY_CHECK_OUT	(4 + 8)
286*33898377SSuraj Kandpal 
287*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_VALIDATE_LOCALITY_IN		(4 + 32)
288*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_VALIDATE_LOCALITY_OUT		(4)
289*33898377SSuraj Kandpal 
290*33898377SSuraj Kandpal /* Wired_Tx_SKE */
291*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_GET_SESSION_KEY_IN		(4)
292*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_GET_SESSION_KEY_OUT		(4 + 16 + 8)
293*33898377SSuraj Kandpal 
294*33898377SSuraj Kandpal /* Wired_Tx_SKE */
295*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_ENABLE_AUTH_IN		(4 + 1)
296*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_ENABLE_AUTH_OUT		(4)
297*33898377SSuraj Kandpal 
298*33898377SSuraj Kandpal /* Wired_Tx_Repeater */
299*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_VERIFY_REPEATER_IN		(4 + 2 + 3 + 16 + 155)
300*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_VERIFY_REPEATER_OUT		(4 + 1 + 16)
301*33898377SSuraj Kandpal 
302*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_REPEATER_AUTH_STREAM_REQ_MIN_IN	(4 + 3 + \
303*33898377SSuraj Kandpal 								32 + 2 + 2)
304*33898377SSuraj Kandpal 
305*33898377SSuraj Kandpal #define	WIRED_CMD_BUF_LEN_REPEATER_AUTH_STREAM_REQ_OUT		(4)
306*33898377SSuraj Kandpal 
307*33898377SSuraj Kandpal /* hdcp_command_id: Enumeration of all WIRED HDCP Command IDs */
308*33898377SSuraj Kandpal enum hdcp_command_id {
309*33898377SSuraj Kandpal 	_WIDI_COMMAND_BASE		= 0x00030000,
310*33898377SSuraj Kandpal 	WIDI_INITIATE_HDCP2_SESSION	= _WIDI_COMMAND_BASE,
311*33898377SSuraj Kandpal 	HDCP_GET_SRM_STATUS,
312*33898377SSuraj Kandpal 	HDCP_SEND_SRM_FRAGMENT,
313*33898377SSuraj Kandpal 
314*33898377SSuraj Kandpal 	/* The wired HDCP Tx commands */
315*33898377SSuraj Kandpal 	_WIRED_COMMAND_BASE		= 0x00031000,
316*33898377SSuraj Kandpal 	WIRED_INITIATE_HDCP2_SESSION	= _WIRED_COMMAND_BASE,
317*33898377SSuraj Kandpal 	WIRED_VERIFY_RECEIVER_CERT,
318*33898377SSuraj Kandpal 	WIRED_AKE_SEND_HPRIME,
319*33898377SSuraj Kandpal 	WIRED_AKE_SEND_PAIRING_INFO,
320*33898377SSuraj Kandpal 	WIRED_INIT_LOCALITY_CHECK,
321*33898377SSuraj Kandpal 	WIRED_VALIDATE_LOCALITY,
322*33898377SSuraj Kandpal 	WIRED_GET_SESSION_KEY,
323*33898377SSuraj Kandpal 	WIRED_ENABLE_AUTH,
324*33898377SSuraj Kandpal 	WIRED_VERIFY_REPEATER,
325*33898377SSuraj Kandpal 	WIRED_REPEATER_AUTH_STREAM_REQ,
326*33898377SSuraj Kandpal 	WIRED_CLOSE_SESSION,
327*33898377SSuraj Kandpal 
328*33898377SSuraj Kandpal 	_WIRED_COMMANDS_COUNT,
329*33898377SSuraj Kandpal };
330*33898377SSuraj Kandpal 
331*33898377SSuraj Kandpal union encrypted_buff {
332*33898377SSuraj Kandpal 	u8		e_kpub_km[HDCP_2_2_E_KPUB_KM_LEN];
333*33898377SSuraj Kandpal 	u8		e_kh_km_m[HDCP_2_2_E_KH_KM_M_LEN];
334*33898377SSuraj Kandpal 	struct {
335*33898377SSuraj Kandpal 		u8	e_kh_km[HDCP_KH_LEN];
336*33898377SSuraj Kandpal 		u8	m[HDCP_M_LEN];
337*33898377SSuraj Kandpal 	} __packed;
338*33898377SSuraj Kandpal };
339*33898377SSuraj Kandpal 
340*33898377SSuraj Kandpal /* HDCP HECI message header. All header values are little endian. */
341*33898377SSuraj Kandpal struct hdcp_cmd_header {
342*33898377SSuraj Kandpal 	u32			api_version;
343*33898377SSuraj Kandpal 	u32			command_id;
344*33898377SSuraj Kandpal 	enum fw_hdcp_status	status;
345*33898377SSuraj Kandpal 	/* Length of the HECI message (excluding the header) */
346*33898377SSuraj Kandpal 	u32			buffer_len;
347*33898377SSuraj Kandpal } __packed;
348*33898377SSuraj Kandpal 
349*33898377SSuraj Kandpal /* Empty command request or response. No data follows the header. */
350*33898377SSuraj Kandpal struct hdcp_cmd_no_data {
351*33898377SSuraj Kandpal 	struct hdcp_cmd_header header;
352*33898377SSuraj Kandpal } __packed;
353*33898377SSuraj Kandpal 
354*33898377SSuraj Kandpal /* Uniquely identifies the hdcp port being addressed for a given command. */
355*33898377SSuraj Kandpal struct hdcp_port_id {
356*33898377SSuraj Kandpal 	u8	integrated_port_type;
357*33898377SSuraj Kandpal 	/* physical_port is used until Gen11.5. Must be zero for Gen11.5+ */
358*33898377SSuraj Kandpal 	u8	physical_port;
359*33898377SSuraj Kandpal 	/* attached_transcoder is for Gen11.5+. Set to zero for <Gen11.5 */
360*33898377SSuraj Kandpal 	u8	attached_transcoder;
361*33898377SSuraj Kandpal 	u8	reserved;
362*33898377SSuraj Kandpal } __packed;
363*33898377SSuraj Kandpal 
364*33898377SSuraj Kandpal /*
365*33898377SSuraj Kandpal  * Data structures for integrated wired HDCP2 Tx in
366*33898377SSuraj Kandpal  * support of the AKE protocol
367*33898377SSuraj Kandpal  */
368*33898377SSuraj Kandpal /* HECI struct for integrated wired HDCP Tx session initiation. */
369*33898377SSuraj Kandpal struct wired_cmd_initiate_hdcp2_session_in {
370*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
371*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
372*33898377SSuraj Kandpal 	u8			protocol; /* for HDMI vs DP */
373*33898377SSuraj Kandpal } __packed;
374*33898377SSuraj Kandpal 
375*33898377SSuraj Kandpal struct wired_cmd_initiate_hdcp2_session_out {
376*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
377*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
378*33898377SSuraj Kandpal 	u8			r_tx[HDCP_2_2_RTX_LEN];
379*33898377SSuraj Kandpal 	struct hdcp2_tx_caps	tx_caps;
380*33898377SSuraj Kandpal } __packed;
381*33898377SSuraj Kandpal 
382*33898377SSuraj Kandpal /* HECI struct for ending an integrated wired HDCP Tx session. */
383*33898377SSuraj Kandpal struct wired_cmd_close_session_in {
384*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
385*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
386*33898377SSuraj Kandpal } __packed;
387*33898377SSuraj Kandpal 
388*33898377SSuraj Kandpal struct wired_cmd_close_session_out {
389*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
390*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
391*33898377SSuraj Kandpal } __packed;
392*33898377SSuraj Kandpal 
393*33898377SSuraj Kandpal /* HECI struct for integrated wired HDCP Tx Rx Cert verification. */
394*33898377SSuraj Kandpal struct wired_cmd_verify_receiver_cert_in {
395*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
396*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
397*33898377SSuraj Kandpal 	struct hdcp2_cert_rx	cert_rx;
398*33898377SSuraj Kandpal 	u8			r_rx[HDCP_2_2_RRX_LEN];
399*33898377SSuraj Kandpal 	u8			rx_caps[HDCP_2_2_RXCAPS_LEN];
400*33898377SSuraj Kandpal } __packed;
401*33898377SSuraj Kandpal 
402*33898377SSuraj Kandpal struct wired_cmd_verify_receiver_cert_out {
403*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
404*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
405*33898377SSuraj Kandpal 	u8			km_stored;
406*33898377SSuraj Kandpal 	u8			reserved[3];
407*33898377SSuraj Kandpal 	union encrypted_buff	ekm_buff;
408*33898377SSuraj Kandpal } __packed;
409*33898377SSuraj Kandpal 
410*33898377SSuraj Kandpal /* HECI struct for verification of Rx's Hprime in a HDCP Tx session */
411*33898377SSuraj Kandpal struct wired_cmd_ake_send_hprime_in {
412*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
413*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
414*33898377SSuraj Kandpal 	u8			h_prime[HDCP_2_2_H_PRIME_LEN];
415*33898377SSuraj Kandpal } __packed;
416*33898377SSuraj Kandpal 
417*33898377SSuraj Kandpal struct wired_cmd_ake_send_hprime_out {
418*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
419*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
420*33898377SSuraj Kandpal } __packed;
421*33898377SSuraj Kandpal 
422*33898377SSuraj Kandpal /*
423*33898377SSuraj Kandpal  * HECI struct for sending in AKE pairing data generated by the Rx in an
424*33898377SSuraj Kandpal  * integrated wired HDCP Tx session.
425*33898377SSuraj Kandpal  */
426*33898377SSuraj Kandpal struct wired_cmd_ake_send_pairing_info_in {
427*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
428*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
429*33898377SSuraj Kandpal 	u8			e_kh_km[HDCP_2_2_E_KH_KM_LEN];
430*33898377SSuraj Kandpal } __packed;
431*33898377SSuraj Kandpal 
432*33898377SSuraj Kandpal struct wired_cmd_ake_send_pairing_info_out {
433*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
434*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
435*33898377SSuraj Kandpal } __packed;
436*33898377SSuraj Kandpal 
437*33898377SSuraj Kandpal /* Data structures for integrated wired HDCP2 Tx in support of the LC protocol*/
438*33898377SSuraj Kandpal /*
439*33898377SSuraj Kandpal  * HECI struct for initiating locality check with an
440*33898377SSuraj Kandpal  * integrated wired HDCP Tx session.
441*33898377SSuraj Kandpal  */
442*33898377SSuraj Kandpal struct wired_cmd_init_locality_check_in {
443*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
444*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
445*33898377SSuraj Kandpal } __packed;
446*33898377SSuraj Kandpal 
447*33898377SSuraj Kandpal struct wired_cmd_init_locality_check_out {
448*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
449*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
450*33898377SSuraj Kandpal 	u8			r_n[HDCP_2_2_RN_LEN];
451*33898377SSuraj Kandpal } __packed;
452*33898377SSuraj Kandpal 
453*33898377SSuraj Kandpal /*
454*33898377SSuraj Kandpal  * HECI struct for validating an Rx's LPrime value in an
455*33898377SSuraj Kandpal  * integrated wired HDCP Tx session.
456*33898377SSuraj Kandpal  */
457*33898377SSuraj Kandpal struct wired_cmd_validate_locality_in {
458*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
459*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
460*33898377SSuraj Kandpal 	u8			l_prime[HDCP_2_2_L_PRIME_LEN];
461*33898377SSuraj Kandpal } __packed;
462*33898377SSuraj Kandpal 
463*33898377SSuraj Kandpal struct wired_cmd_validate_locality_out {
464*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
465*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
466*33898377SSuraj Kandpal } __packed;
467*33898377SSuraj Kandpal 
468*33898377SSuraj Kandpal /*
469*33898377SSuraj Kandpal  * Data structures for integrated wired HDCP2 Tx in support of the
470*33898377SSuraj Kandpal  * SKE protocol
471*33898377SSuraj Kandpal  */
472*33898377SSuraj Kandpal /* HECI struct for creating session key */
473*33898377SSuraj Kandpal struct wired_cmd_get_session_key_in {
474*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
475*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
476*33898377SSuraj Kandpal } __packed;
477*33898377SSuraj Kandpal 
478*33898377SSuraj Kandpal struct wired_cmd_get_session_key_out {
479*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
480*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
481*33898377SSuraj Kandpal 	u8			e_dkey_ks[HDCP_2_2_E_DKEY_KS_LEN];
482*33898377SSuraj Kandpal 	u8			r_iv[HDCP_2_2_RIV_LEN];
483*33898377SSuraj Kandpal } __packed;
484*33898377SSuraj Kandpal 
485*33898377SSuraj Kandpal /* HECI struct for the Tx enable authentication command */
486*33898377SSuraj Kandpal struct wired_cmd_enable_auth_in {
487*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
488*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
489*33898377SSuraj Kandpal 	u8			stream_type;
490*33898377SSuraj Kandpal } __packed;
491*33898377SSuraj Kandpal 
492*33898377SSuraj Kandpal struct wired_cmd_enable_auth_out {
493*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
494*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
495*33898377SSuraj Kandpal } __packed;
496*33898377SSuraj Kandpal 
497*33898377SSuraj Kandpal /*
498*33898377SSuraj Kandpal  * Data structures for integrated wired HDCP2 Tx in support of
499*33898377SSuraj Kandpal  * the repeater protocols
500*33898377SSuraj Kandpal  */
501*33898377SSuraj Kandpal /*
502*33898377SSuraj Kandpal  * HECI struct for verifying the downstream repeater's HDCP topology in an
503*33898377SSuraj Kandpal  * integrated wired HDCP Tx session.
504*33898377SSuraj Kandpal  */
505*33898377SSuraj Kandpal struct wired_cmd_verify_repeater_in {
506*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
507*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
508*33898377SSuraj Kandpal 	u8			rx_info[HDCP_2_2_RXINFO_LEN];
509*33898377SSuraj Kandpal 	u8			seq_num_v[HDCP_2_2_SEQ_NUM_LEN];
510*33898377SSuraj Kandpal 	u8			v_prime[HDCP_2_2_V_PRIME_HALF_LEN];
511*33898377SSuraj Kandpal 	u8			receiver_ids[HDCP_2_2_RECEIVER_IDS_MAX_LEN];
512*33898377SSuraj Kandpal } __packed;
513*33898377SSuraj Kandpal 
514*33898377SSuraj Kandpal struct wired_cmd_verify_repeater_out {
515*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
516*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
517*33898377SSuraj Kandpal 	u8			content_type_supported;
518*33898377SSuraj Kandpal 	u8			v[HDCP_2_2_V_PRIME_HALF_LEN];
519*33898377SSuraj Kandpal } __packed;
520*33898377SSuraj Kandpal 
521*33898377SSuraj Kandpal /*
522*33898377SSuraj Kandpal  * HECI struct in support of stream management in an
523*33898377SSuraj Kandpal  * integrated wired HDCP Tx session.
524*33898377SSuraj Kandpal  */
525*33898377SSuraj Kandpal struct wired_cmd_repeater_auth_stream_req_in {
526*33898377SSuraj Kandpal 	struct hdcp_cmd_header		header;
527*33898377SSuraj Kandpal 	struct hdcp_port_id		port;
528*33898377SSuraj Kandpal 	u8				seq_num_m[HDCP_2_2_SEQ_NUM_LEN];
529*33898377SSuraj Kandpal 	u8				m_prime[HDCP_2_2_MPRIME_LEN];
530*33898377SSuraj Kandpal 	__be16				k;
531*33898377SSuraj Kandpal 	struct hdcp2_streamid_type	streams[];
532*33898377SSuraj Kandpal } __packed;
533*33898377SSuraj Kandpal 
534*33898377SSuraj Kandpal struct wired_cmd_repeater_auth_stream_req_out {
535*33898377SSuraj Kandpal 	struct hdcp_cmd_header	header;
536*33898377SSuraj Kandpal 	struct hdcp_port_id	port;
537*33898377SSuraj Kandpal } __packed;
538*33898377SSuraj Kandpal 
5394f73dc7aSAnshuman Gupta #endif /* _I915_HDCP_INTERFACE_H_ */
540