1 /* SPDX-License-Identifier: (GPL-2.0+) */
3 * Copyright © 2017-2019 Intel Corporation
6 * Ramalingam C <ramalingam.c@intel.com>
9 #ifndef _I915_HDCP_INTERFACE_H_
10 #define _I915_HDCP_INTERFACE_H_
12 #include <linux/mutex.h>
13 #include <linux/device.h>
14 #include <drm/display/drm_hdcp.h>
17 * enum hdcp_port_type - HDCP port implementation type defined by ME/GSC FW
18 * @HDCP_PORT_TYPE_INVALID: Invalid hdcp port type
19 * @HDCP_PORT_TYPE_INTEGRATED: In-Host HDCP2.x port
20 * @HDCP_PORT_TYPE_LSPCON: HDCP2.2 discrete wired Tx port with LSPCON
22 * @HDCP_PORT_TYPE_CPDP: HDCP2.2 discrete wired Tx port using the CPDP (DP 1.3)
26 HDCP_PORT_TYPE_INVALID
,
27 HDCP_PORT_TYPE_INTEGRATED
,
28 HDCP_PORT_TYPE_LSPCON
,
33 * enum hdcp_wired_protocol - HDCP adaptation used on the port
34 * @HDCP_PROTOCOL_INVALID: Invalid HDCP adaptation protocol
35 * @HDCP_PROTOCOL_HDMI: HDMI adaptation of HDCP used on the port
36 * @HDCP_PROTOCOL_DP: DP adaptation of HDCP used on the port
38 enum hdcp_wired_protocol
{
39 HDCP_PROTOCOL_INVALID
,
45 HDCP_DDI_INVALID_PORT
= 0x0,
53 HDCP_DDI_RANGE_END
= HDCP_DDI_A
,
57 * enum hdcp_transcoder - ME/GSC Firmware defined index for transcoders
58 * @HDCP_INVALID_TRANSCODER: Index for Invalid transcoder
59 * @HDCP_TRANSCODER_EDP: Index for EDP Transcoder
60 * @HDCP_TRANSCODER_DSI0: Index for DSI0 Transcoder
61 * @HDCP_TRANSCODER_DSI1: Index for DSI1 Transcoder
62 * @HDCP_TRANSCODER_A: Index for Transcoder A
63 * @HDCP_TRANSCODER_B: Index for Transcoder B
64 * @HDCP_TRANSCODER_C: Index for Transcoder C
65 * @HDCP_TRANSCODER_D: Index for Transcoder D
67 enum hdcp_transcoder
{
68 HDCP_INVALID_TRANSCODER
= 0x00,
72 HDCP_TRANSCODER_A
= 0x10,
79 * struct hdcp_port_data - intel specific HDCP port data
80 * @hdcp_ddi: ddi index as per ME/GSC FW
81 * @hdcp_transcoder: transcoder index as per ME/GSC FW
82 * @port_type: HDCP port type as per ME/GSC FW classification
83 * @protocol: HDCP adaptation as per ME/GSC FW
84 * @k: No of streams transmitted on a port. Only on DP MST this is != 1
85 * @seq_num_m: Count of RepeaterAuth_Stream_Manage msg propagated.
86 * Initialized to 0 on AKE_INIT. Incremented after every successful
87 * transmission of RepeaterAuth_Stream_Manage message. When it rolls
88 * over re-Auth has to be triggered.
89 * @streams: struct hdcp2_streamid_type[k]. Defines the type and id for the
92 struct hdcp_port_data
{
93 enum hdcp_ddi hdcp_ddi
;
94 enum hdcp_transcoder hdcp_transcoder
;
99 struct hdcp2_streamid_type
*streams
;
103 * struct i915_hdcp_ops- ops for HDCP2.2 services.
104 * @owner: Module providing the ops
105 * @initiate_hdcp2_session: Initiate a Wired HDCP2.2 Tx Session.
106 * And Prepare AKE_Init.
107 * @verify_receiver_cert_prepare_km: Verify the Receiver Certificate
108 * AKE_Send_Cert and prepare
109 * AKE_Stored_Km/AKE_No_Stored_Km
110 * @verify_hprime: Verify AKE_Send_H_prime
111 * @store_pairing_info: Store pairing info received
112 * @initiate_locality_check: Prepare LC_Init
113 * @verify_lprime: Verify lprime
114 * @get_session_key: Prepare SKE_Send_Eks
115 * @repeater_check_flow_prepare_ack: Validate the Downstream topology
116 * and prepare rep_ack
117 * @verify_mprime: Verify mprime
118 * @enable_hdcp_authentication: Mark a port as authenticated.
119 * @close_hdcp_session: Close the Wired HDCP Tx session per port.
120 * This also disables the authenticated state of the port.
122 struct i915_hdcp_ops
{
124 * @owner: hdcp module
126 struct module
*owner
;
128 int (*initiate_hdcp2_session
)(struct device
*dev
,
129 struct hdcp_port_data
*data
,
130 struct hdcp2_ake_init
*ake_data
);
131 int (*verify_receiver_cert_prepare_km
)(struct device
*dev
,
132 struct hdcp_port_data
*data
,
133 struct hdcp2_ake_send_cert
136 struct hdcp2_ake_no_stored_km
139 int (*verify_hprime
)(struct device
*dev
,
140 struct hdcp_port_data
*data
,
141 struct hdcp2_ake_send_hprime
*rx_hprime
);
142 int (*store_pairing_info
)(struct device
*dev
,
143 struct hdcp_port_data
*data
,
144 struct hdcp2_ake_send_pairing_info
146 int (*initiate_locality_check
)(struct device
*dev
,
147 struct hdcp_port_data
*data
,
148 struct hdcp2_lc_init
*lc_init_data
);
149 int (*verify_lprime
)(struct device
*dev
,
150 struct hdcp_port_data
*data
,
151 struct hdcp2_lc_send_lprime
*rx_lprime
);
152 int (*get_session_key
)(struct device
*dev
,
153 struct hdcp_port_data
*data
,
154 struct hdcp2_ske_send_eks
*ske_data
);
155 int (*repeater_check_flow_prepare_ack
)(struct device
*dev
,
156 struct hdcp_port_data
*data
,
157 struct hdcp2_rep_send_receiverid_list
159 struct hdcp2_rep_send_ack
161 int (*verify_mprime
)(struct device
*dev
,
162 struct hdcp_port_data
*data
,
163 struct hdcp2_rep_stream_ready
*stream_ready
);
164 int (*enable_hdcp_authentication
)(struct device
*dev
,
165 struct hdcp_port_data
*data
);
166 int (*close_hdcp_session
)(struct device
*dev
,
167 struct hdcp_port_data
*data
);
171 * struct i915_hdcp_arbiter - Used for communication between i915
172 * and hdcp drivers for the HDCP2.2 services
174 struct i915_hdcp_arbiter
{
176 * @hdcp_dev: device that provides the HDCP2.2 service from MEI Bus.
178 struct device
*hdcp_dev
;
181 * @ops: Ops implemented by hdcp driver or intel_hdcp_gsc, used by i915
184 const struct i915_hdcp_ops
*ops
;
187 * @mutex: To protect the above members.
192 /* fw_hdcp_status: Enumeration of all HDCP Status Codes */
193 enum fw_hdcp_status
{
194 FW_HDCP_STATUS_SUCCESS
= 0x0000,
196 /* WiDi Generic Status Codes */
197 FW_HDCP_STATUS_INTERNAL_ERROR
= 0x1000,
198 FW_HDCP_STATUS_UNKNOWN_ERROR
= 0x1001,
199 FW_HDCP_STATUS_INCORRECT_API_VERSION
= 0x1002,
200 FW_HDCP_STATUS_INVALID_FUNCTION
= 0x1003,
201 FW_HDCP_STATUS_INVALID_BUFFER_LENGTH
= 0x1004,
202 FW_HDCP_STATUS_INVALID_PARAMS
= 0x1005,
203 FW_HDCP_STATUS_AUTHENTICATION_FAILED
= 0x1006,
205 /* WiDi Status Codes */
206 FW_HDCP_INVALID_SESSION_STATE
= 0x6000,
207 FW_HDCP_SRM_FRAGMENT_UNEXPECTED
= 0x6001,
208 FW_HDCP_SRM_INVALID_LENGTH
= 0x6002,
209 FW_HDCP_SRM_FRAGMENT_OFFSET_INVALID
= 0x6003,
210 FW_HDCP_SRM_VERIFICATION_FAILED
= 0x6004,
211 FW_HDCP_SRM_VERSION_TOO_OLD
= 0x6005,
212 FW_HDCP_RX_CERT_VERIFICATION_FAILED
= 0x6006,
213 FW_HDCP_RX_REVOKED
= 0x6007,
214 FW_HDCP_H_VERIFICATION_FAILED
= 0x6008,
215 FW_HDCP_REPEATER_CHECK_UNEXPECTED
= 0x6009,
216 FW_HDCP_TOPOLOGY_MAX_EXCEEDED
= 0x600A,
217 FW_HDCP_V_VERIFICATION_FAILED
= 0x600B,
218 FW_HDCP_L_VERIFICATION_FAILED
= 0x600C,
219 FW_HDCP_STREAM_KEY_ALLOC_FAILED
= 0x600D,
220 FW_HDCP_BASE_KEY_RESET_FAILED
= 0x600E,
221 FW_HDCP_NONCE_GENERATION_FAILED
= 0x600F,
222 FW_HDCP_STATUS_INVALID_E_KEY_STATE
= 0x6010,
223 FW_HDCP_STATUS_INVALID_CS_ICV
= 0x6011,
224 FW_HDCP_STATUS_INVALID_KB_KEY_STATE
= 0x6012,
225 FW_HDCP_STATUS_INVALID_PAVP_MODE_ICV
= 0x6013,
226 FW_HDCP_STATUS_INVALID_PAVP_MODE
= 0x6014,
227 FW_HDCP_STATUS_LC_MAX_ATTEMPTS
= 0x6015,
229 /* New status for HDCP 2.1 */
230 FW_HDCP_STATUS_MISMATCH_IN_M
= 0x6016,
232 /* New status code for HDCP 2.2 Rx */
233 FW_HDCP_STATUS_RX_PROV_NOT_ALLOWED
= 0x6017,
234 FW_HDCP_STATUS_RX_PROV_WRONG_SUBJECT
= 0x6018,
235 FW_HDCP_RX_NEEDS_PROVISIONING
= 0x6019,
236 FW_HDCP_BKSV_ICV_AUTH_FAILED
= 0x6020,
237 FW_HDCP_STATUS_INVALID_STREAM_ID
= 0x6021,
238 FW_HDCP_STATUS_CHAIN_NOT_INITIALIZED
= 0x6022,
239 FW_HDCP_FAIL_NOT_EXPECTED
= 0x6023,
240 FW_HDCP_FAIL_HDCP_OFF
= 0x6024,
241 FW_HDCP_FAIL_INVALID_PAVP_MEMORY_MODE
= 0x6025,
242 FW_HDCP_FAIL_AES_ECB_FAILURE
= 0x6026,
243 FW_HDCP_FEATURE_NOT_SUPPORTED
= 0x6027,
244 FW_HDCP_DMA_READ_ERROR
= 0x6028,
245 FW_HDCP_DMA_WRITE_ERROR
= 0x6029,
246 FW_HDCP_FAIL_INVALID_PACKET_SIZE
= 0x6030,
247 FW_HDCP_H264_PARSING_ERROR
= 0x6031,
248 FW_HDCP_HDCP2_ERRATA_VIDEO_VIOLATION
= 0x6032,
249 FW_HDCP_HDCP2_ERRATA_AUDIO_VIOLATION
= 0x6033,
250 FW_HDCP_TX_ACTIVE_ERROR
= 0x6034,
251 FW_HDCP_MODE_CHANGE_ERROR
= 0x6035,
252 FW_HDCP_STREAM_TYPE_ERROR
= 0x6036,
253 FW_HDCP_STREAM_MANAGE_NOT_POSSIBLE
= 0x6037,
255 FW_HDCP_STATUS_PORT_INVALID_COMMAND
= 0x6038,
256 FW_HDCP_STATUS_UNSUPPORTED_PROTOCOL
= 0x6039,
257 FW_HDCP_STATUS_INVALID_PORT_INDEX
= 0x603a,
258 FW_HDCP_STATUS_TX_AUTH_NEEDED
= 0x603b,
259 FW_HDCP_STATUS_NOT_INTEGRATED_PORT
= 0x603c,
260 FW_HDCP_STATUS_SESSION_MAX_REACHED
= 0x603d,
262 /* hdcp capable bit is not set in rx_caps(error is unique to DP) */
263 FW_HDCP_STATUS_NOT_HDCP_CAPABLE
= 0x6041,
265 FW_HDCP_STATUS_INVALID_STREAM_COUNT
= 0x6042,
268 #define HDCP_API_VERSION 0x00010000
270 #define HDCP_M_LEN 16
271 #define HDCP_KH_LEN 16
273 /* Payload Buffer size(Excluding Header) for CMDs and corresponding response */
275 #define WIRED_CMD_BUF_LEN_INITIATE_HDCP2_SESSION_IN (4 + 1)
276 #define WIRED_CMD_BUF_LEN_INITIATE_HDCP2_SESSION_OUT (4 + 8 + 3)
278 #define WIRED_CMD_BUF_LEN_VERIFY_RECEIVER_CERT_IN (4 + 522 + 8 + 3)
279 #define WIRED_CMD_BUF_LEN_VERIFY_RECEIVER_CERT_MIN_OUT (4 + 1 + 3 + 16 + 16)
280 #define WIRED_CMD_BUF_LEN_VERIFY_RECEIVER_CERT_MAX_OUT (4 + 1 + 3 + 128)
282 #define WIRED_CMD_BUF_LEN_AKE_SEND_HPRIME_IN (4 + 32)
283 #define WIRED_CMD_BUF_LEN_AKE_SEND_HPRIME_OUT (4)
285 #define WIRED_CMD_BUF_LEN_SEND_PAIRING_INFO_IN (4 + 16)
286 #define WIRED_CMD_BUF_LEN_SEND_PAIRING_INFO_OUT (4)
288 #define WIRED_CMD_BUF_LEN_CLOSE_SESSION_IN (4)
289 #define WIRED_CMD_BUF_LEN_CLOSE_SESSION_OUT (4)
292 #define WIRED_CMD_BUF_LEN_INIT_LOCALITY_CHECK_IN (4)
293 #define WIRED_CMD_BUF_LEN_INIT_LOCALITY_CHECK_OUT (4 + 8)
295 #define WIRED_CMD_BUF_LEN_VALIDATE_LOCALITY_IN (4 + 32)
296 #define WIRED_CMD_BUF_LEN_VALIDATE_LOCALITY_OUT (4)
299 #define WIRED_CMD_BUF_LEN_GET_SESSION_KEY_IN (4)
300 #define WIRED_CMD_BUF_LEN_GET_SESSION_KEY_OUT (4 + 16 + 8)
303 #define WIRED_CMD_BUF_LEN_ENABLE_AUTH_IN (4 + 1)
304 #define WIRED_CMD_BUF_LEN_ENABLE_AUTH_OUT (4)
306 /* Wired_Tx_Repeater */
307 #define WIRED_CMD_BUF_LEN_VERIFY_REPEATER_IN (4 + 2 + 3 + 16 + 155)
308 #define WIRED_CMD_BUF_LEN_VERIFY_REPEATER_OUT (4 + 1 + 16)
310 #define WIRED_CMD_BUF_LEN_REPEATER_AUTH_STREAM_REQ_MIN_IN (4 + 3 + \
313 #define WIRED_CMD_BUF_LEN_REPEATER_AUTH_STREAM_REQ_OUT (4)
315 /* hdcp_command_id: Enumeration of all WIRED HDCP Command IDs */
316 enum hdcp_command_id
{
317 _WIDI_COMMAND_BASE
= 0x00030000,
318 WIDI_INITIATE_HDCP2_SESSION
= _WIDI_COMMAND_BASE
,
320 HDCP_SEND_SRM_FRAGMENT
,
322 /* The wired HDCP Tx commands */
323 _WIRED_COMMAND_BASE
= 0x00031000,
324 WIRED_INITIATE_HDCP2_SESSION
= _WIRED_COMMAND_BASE
,
325 WIRED_VERIFY_RECEIVER_CERT
,
326 WIRED_AKE_SEND_HPRIME
,
327 WIRED_AKE_SEND_PAIRING_INFO
,
328 WIRED_INIT_LOCALITY_CHECK
,
329 WIRED_VALIDATE_LOCALITY
,
330 WIRED_GET_SESSION_KEY
,
332 WIRED_VERIFY_REPEATER
,
333 WIRED_REPEATER_AUTH_STREAM_REQ
,
336 _WIRED_COMMANDS_COUNT
,
339 union encrypted_buff
{
340 u8 e_kpub_km
[HDCP_2_2_E_KPUB_KM_LEN
];
341 u8 e_kh_km_m
[HDCP_2_2_E_KH_KM_M_LEN
];
343 u8 e_kh_km
[HDCP_KH_LEN
];
348 /* HDCP HECI message header. All header values are little endian. */
349 struct hdcp_cmd_header
{
352 enum fw_hdcp_status status
;
353 /* Length of the HECI message (excluding the header) */
357 /* Empty command request or response. No data follows the header. */
358 struct hdcp_cmd_no_data
{
359 struct hdcp_cmd_header header
;
362 /* Uniquely identifies the hdcp port being addressed for a given command. */
363 struct hdcp_port_id
{
364 u8 integrated_port_type
;
365 /* physical_port is used until Gen11.5. Must be zero for Gen11.5+ */
367 /* attached_transcoder is for Gen11.5+. Set to zero for <Gen11.5 */
368 u8 attached_transcoder
;
373 * Data structures for integrated wired HDCP2 Tx in
374 * support of the AKE protocol
376 /* HECI struct for integrated wired HDCP Tx session initiation. */
377 struct wired_cmd_initiate_hdcp2_session_in
{
378 struct hdcp_cmd_header header
;
379 struct hdcp_port_id port
;
380 u8 protocol
; /* for HDMI vs DP */
383 struct wired_cmd_initiate_hdcp2_session_out
{
384 struct hdcp_cmd_header header
;
385 struct hdcp_port_id port
;
386 u8 r_tx
[HDCP_2_2_RTX_LEN
];
387 struct hdcp2_tx_caps tx_caps
;
390 /* HECI struct for ending an integrated wired HDCP Tx session. */
391 struct wired_cmd_close_session_in
{
392 struct hdcp_cmd_header header
;
393 struct hdcp_port_id port
;
396 struct wired_cmd_close_session_out
{
397 struct hdcp_cmd_header header
;
398 struct hdcp_port_id port
;
401 /* HECI struct for integrated wired HDCP Tx Rx Cert verification. */
402 struct wired_cmd_verify_receiver_cert_in
{
403 struct hdcp_cmd_header header
;
404 struct hdcp_port_id port
;
405 struct hdcp2_cert_rx cert_rx
;
406 u8 r_rx
[HDCP_2_2_RRX_LEN
];
407 u8 rx_caps
[HDCP_2_2_RXCAPS_LEN
];
410 struct wired_cmd_verify_receiver_cert_out
{
411 struct hdcp_cmd_header header
;
412 struct hdcp_port_id port
;
415 union encrypted_buff ekm_buff
;
418 /* HECI struct for verification of Rx's Hprime in a HDCP Tx session */
419 struct wired_cmd_ake_send_hprime_in
{
420 struct hdcp_cmd_header header
;
421 struct hdcp_port_id port
;
422 u8 h_prime
[HDCP_2_2_H_PRIME_LEN
];
425 struct wired_cmd_ake_send_hprime_out
{
426 struct hdcp_cmd_header header
;
427 struct hdcp_port_id port
;
431 * HECI struct for sending in AKE pairing data generated by the Rx in an
432 * integrated wired HDCP Tx session.
434 struct wired_cmd_ake_send_pairing_info_in
{
435 struct hdcp_cmd_header header
;
436 struct hdcp_port_id port
;
437 u8 e_kh_km
[HDCP_2_2_E_KH_KM_LEN
];
440 struct wired_cmd_ake_send_pairing_info_out
{
441 struct hdcp_cmd_header header
;
442 struct hdcp_port_id port
;
445 /* Data structures for integrated wired HDCP2 Tx in support of the LC protocol*/
447 * HECI struct for initiating locality check with an
448 * integrated wired HDCP Tx session.
450 struct wired_cmd_init_locality_check_in
{
451 struct hdcp_cmd_header header
;
452 struct hdcp_port_id port
;
455 struct wired_cmd_init_locality_check_out
{
456 struct hdcp_cmd_header header
;
457 struct hdcp_port_id port
;
458 u8 r_n
[HDCP_2_2_RN_LEN
];
462 * HECI struct for validating an Rx's LPrime value in an
463 * integrated wired HDCP Tx session.
465 struct wired_cmd_validate_locality_in
{
466 struct hdcp_cmd_header header
;
467 struct hdcp_port_id port
;
468 u8 l_prime
[HDCP_2_2_L_PRIME_LEN
];
471 struct wired_cmd_validate_locality_out
{
472 struct hdcp_cmd_header header
;
473 struct hdcp_port_id port
;
477 * Data structures for integrated wired HDCP2 Tx in support of the
480 /* HECI struct for creating session key */
481 struct wired_cmd_get_session_key_in
{
482 struct hdcp_cmd_header header
;
483 struct hdcp_port_id port
;
486 struct wired_cmd_get_session_key_out
{
487 struct hdcp_cmd_header header
;
488 struct hdcp_port_id port
;
489 u8 e_dkey_ks
[HDCP_2_2_E_DKEY_KS_LEN
];
490 u8 r_iv
[HDCP_2_2_RIV_LEN
];
493 /* HECI struct for the Tx enable authentication command */
494 struct wired_cmd_enable_auth_in
{
495 struct hdcp_cmd_header header
;
496 struct hdcp_port_id port
;
500 struct wired_cmd_enable_auth_out
{
501 struct hdcp_cmd_header header
;
502 struct hdcp_port_id port
;
506 * Data structures for integrated wired HDCP2 Tx in support of
507 * the repeater protocols
510 * HECI struct for verifying the downstream repeater's HDCP topology in an
511 * integrated wired HDCP Tx session.
513 struct wired_cmd_verify_repeater_in
{
514 struct hdcp_cmd_header header
;
515 struct hdcp_port_id port
;
516 u8 rx_info
[HDCP_2_2_RXINFO_LEN
];
517 u8 seq_num_v
[HDCP_2_2_SEQ_NUM_LEN
];
518 u8 v_prime
[HDCP_2_2_V_PRIME_HALF_LEN
];
519 u8 receiver_ids
[HDCP_2_2_RECEIVER_IDS_MAX_LEN
];
522 struct wired_cmd_verify_repeater_out
{
523 struct hdcp_cmd_header header
;
524 struct hdcp_port_id port
;
525 u8 content_type_supported
;
526 u8 v
[HDCP_2_2_V_PRIME_HALF_LEN
];
530 * HECI struct in support of stream management in an
531 * integrated wired HDCP Tx session.
533 struct wired_cmd_repeater_auth_stream_req_in
{
534 struct hdcp_cmd_header header
;
535 struct hdcp_port_id port
;
536 u8 seq_num_m
[HDCP_2_2_SEQ_NUM_LEN
];
537 u8 m_prime
[HDCP_2_2_MPRIME_LEN
];
539 struct hdcp2_streamid_type streams
[];
542 struct wired_cmd_repeater_auth_stream_req_out
{
543 struct hdcp_cmd_header header
;
544 struct hdcp_port_id port
;
547 #endif /* _I915_HDCP_INTERFACE_H_ */