18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0+) */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright © 2017-2019 Intel Corporation
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Authors:
68c2ecf20Sopenharmony_ci * Ramalingam C <ramalingam.c@intel.com>
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef _I915_MEI_HDCP_INTERFACE_H_
108c2ecf20Sopenharmony_ci#define _I915_MEI_HDCP_INTERFACE_H_
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/mutex.h>
138c2ecf20Sopenharmony_ci#include <linux/device.h>
148c2ecf20Sopenharmony_ci#include <drm/drm_hdcp.h>
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci/**
178c2ecf20Sopenharmony_ci * enum hdcp_port_type - HDCP port implementation type defined by ME FW
188c2ecf20Sopenharmony_ci * @HDCP_PORT_TYPE_INVALID: Invalid hdcp port type
198c2ecf20Sopenharmony_ci * @HDCP_PORT_TYPE_INTEGRATED: In-Host HDCP2.x port
208c2ecf20Sopenharmony_ci * @HDCP_PORT_TYPE_LSPCON: HDCP2.2 discrete wired Tx port with LSPCON
218c2ecf20Sopenharmony_ci *			   (HDMI 2.0) solution
228c2ecf20Sopenharmony_ci * @HDCP_PORT_TYPE_CPDP: HDCP2.2 discrete wired Tx port using the CPDP (DP 1.3)
238c2ecf20Sopenharmony_ci *			 solution
248c2ecf20Sopenharmony_ci */
258c2ecf20Sopenharmony_cienum hdcp_port_type {
268c2ecf20Sopenharmony_ci	HDCP_PORT_TYPE_INVALID,
278c2ecf20Sopenharmony_ci	HDCP_PORT_TYPE_INTEGRATED,
288c2ecf20Sopenharmony_ci	HDCP_PORT_TYPE_LSPCON,
298c2ecf20Sopenharmony_ci	HDCP_PORT_TYPE_CPDP
308c2ecf20Sopenharmony_ci};
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci/**
338c2ecf20Sopenharmony_ci * enum hdcp_wired_protocol - HDCP adaptation used on the port
348c2ecf20Sopenharmony_ci * @HDCP_PROTOCOL_INVALID: Invalid HDCP adaptation protocol
358c2ecf20Sopenharmony_ci * @HDCP_PROTOCOL_HDMI: HDMI adaptation of HDCP used on the port
368c2ecf20Sopenharmony_ci * @HDCP_PROTOCOL_DP: DP adaptation of HDCP used on the port
378c2ecf20Sopenharmony_ci */
388c2ecf20Sopenharmony_cienum hdcp_wired_protocol {
398c2ecf20Sopenharmony_ci	HDCP_PROTOCOL_INVALID,
408c2ecf20Sopenharmony_ci	HDCP_PROTOCOL_HDMI,
418c2ecf20Sopenharmony_ci	HDCP_PROTOCOL_DP
428c2ecf20Sopenharmony_ci};
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_cienum mei_fw_ddi {
458c2ecf20Sopenharmony_ci	MEI_DDI_INVALID_PORT = 0x0,
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci	MEI_DDI_B = 1,
488c2ecf20Sopenharmony_ci	MEI_DDI_C,
498c2ecf20Sopenharmony_ci	MEI_DDI_D,
508c2ecf20Sopenharmony_ci	MEI_DDI_E,
518c2ecf20Sopenharmony_ci	MEI_DDI_F,
528c2ecf20Sopenharmony_ci	MEI_DDI_A = 7,
538c2ecf20Sopenharmony_ci	MEI_DDI_RANGE_END = MEI_DDI_A,
548c2ecf20Sopenharmony_ci};
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/**
578c2ecf20Sopenharmony_ci * enum mei_fw_tc - ME Firmware defined index for transcoders
588c2ecf20Sopenharmony_ci * @MEI_INVALID_TRANSCODER: Index for Invalid transcoder
598c2ecf20Sopenharmony_ci * @MEI_TRANSCODER_EDP: Index for EDP Transcoder
608c2ecf20Sopenharmony_ci * @MEI_TRANSCODER_DSI0: Index for DSI0 Transcoder
618c2ecf20Sopenharmony_ci * @MEI_TRANSCODER_DSI1: Index for DSI1 Transcoder
628c2ecf20Sopenharmony_ci * @MEI_TRANSCODER_A: Index for Transcoder A
638c2ecf20Sopenharmony_ci * @MEI_TRANSCODER_B: Index for Transcoder B
648c2ecf20Sopenharmony_ci * @MEI_TRANSCODER_C: Index for Transcoder C
658c2ecf20Sopenharmony_ci * @MEI_TRANSCODER_D: Index for Transcoder D
668c2ecf20Sopenharmony_ci */
678c2ecf20Sopenharmony_cienum mei_fw_tc {
688c2ecf20Sopenharmony_ci	MEI_INVALID_TRANSCODER = 0x00,
698c2ecf20Sopenharmony_ci	MEI_TRANSCODER_EDP,
708c2ecf20Sopenharmony_ci	MEI_TRANSCODER_DSI0,
718c2ecf20Sopenharmony_ci	MEI_TRANSCODER_DSI1,
728c2ecf20Sopenharmony_ci	MEI_TRANSCODER_A = 0x10,
738c2ecf20Sopenharmony_ci	MEI_TRANSCODER_B,
748c2ecf20Sopenharmony_ci	MEI_TRANSCODER_C,
758c2ecf20Sopenharmony_ci	MEI_TRANSCODER_D
768c2ecf20Sopenharmony_ci};
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci/**
798c2ecf20Sopenharmony_ci * struct hdcp_port_data - intel specific HDCP port data
808c2ecf20Sopenharmony_ci * @fw_ddi: ddi index as per ME FW
818c2ecf20Sopenharmony_ci * @fw_tc: transcoder index as per ME FW
828c2ecf20Sopenharmony_ci * @port_type: HDCP port type as per ME FW classification
838c2ecf20Sopenharmony_ci * @protocol: HDCP adaptation as per ME FW
848c2ecf20Sopenharmony_ci * @k: No of streams transmitted on a port. Only on DP MST this is != 1
858c2ecf20Sopenharmony_ci * @seq_num_m: Count of RepeaterAuth_Stream_Manage msg propagated.
868c2ecf20Sopenharmony_ci *	       Initialized to 0 on AKE_INIT. Incremented after every successful
878c2ecf20Sopenharmony_ci *	       transmission of RepeaterAuth_Stream_Manage message. When it rolls
888c2ecf20Sopenharmony_ci *	       over re-Auth has to be triggered.
898c2ecf20Sopenharmony_ci * @streams: struct hdcp2_streamid_type[k]. Defines the type and id for the
908c2ecf20Sopenharmony_ci *	     streams
918c2ecf20Sopenharmony_ci */
928c2ecf20Sopenharmony_cistruct hdcp_port_data {
938c2ecf20Sopenharmony_ci	enum mei_fw_ddi fw_ddi;
948c2ecf20Sopenharmony_ci	enum mei_fw_tc fw_tc;
958c2ecf20Sopenharmony_ci	u8 port_type;
968c2ecf20Sopenharmony_ci	u8 protocol;
978c2ecf20Sopenharmony_ci	u16 k;
988c2ecf20Sopenharmony_ci	u32 seq_num_m;
998c2ecf20Sopenharmony_ci	struct hdcp2_streamid_type *streams;
1008c2ecf20Sopenharmony_ci};
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci/**
1038c2ecf20Sopenharmony_ci * struct i915_hdcp_component_ops- ops for HDCP2.2 services.
1048c2ecf20Sopenharmony_ci * @owner: Module providing the ops
1058c2ecf20Sopenharmony_ci * @initiate_hdcp2_session: Initiate a Wired HDCP2.2 Tx Session.
1068c2ecf20Sopenharmony_ci *			    And Prepare AKE_Init.
1078c2ecf20Sopenharmony_ci * @verify_receiver_cert_prepare_km: Verify the Receiver Certificate
1088c2ecf20Sopenharmony_ci *				     AKE_Send_Cert and prepare
1098c2ecf20Sopenharmony_ci				     AKE_Stored_Km/AKE_No_Stored_Km
1108c2ecf20Sopenharmony_ci * @verify_hprime: Verify AKE_Send_H_prime
1118c2ecf20Sopenharmony_ci * @store_pairing_info: Store pairing info received
1128c2ecf20Sopenharmony_ci * @initiate_locality_check: Prepare LC_Init
1138c2ecf20Sopenharmony_ci * @verify_lprime: Verify lprime
1148c2ecf20Sopenharmony_ci * @get_session_key: Prepare SKE_Send_Eks
1158c2ecf20Sopenharmony_ci * @repeater_check_flow_prepare_ack: Validate the Downstream topology
1168c2ecf20Sopenharmony_ci *				     and prepare rep_ack
1178c2ecf20Sopenharmony_ci * @verify_mprime: Verify mprime
1188c2ecf20Sopenharmony_ci * @enable_hdcp_authentication:  Mark a port as authenticated.
1198c2ecf20Sopenharmony_ci * @close_hdcp_session: Close the Wired HDCP Tx session per port.
1208c2ecf20Sopenharmony_ci *			This also disables the authenticated state of the port.
1218c2ecf20Sopenharmony_ci */
1228c2ecf20Sopenharmony_cistruct i915_hdcp_component_ops {
1238c2ecf20Sopenharmony_ci	/**
1248c2ecf20Sopenharmony_ci	 * @owner: mei_hdcp module
1258c2ecf20Sopenharmony_ci	 */
1268c2ecf20Sopenharmony_ci	struct module *owner;
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci	int (*initiate_hdcp2_session)(struct device *dev,
1298c2ecf20Sopenharmony_ci				      struct hdcp_port_data *data,
1308c2ecf20Sopenharmony_ci				      struct hdcp2_ake_init *ake_data);
1318c2ecf20Sopenharmony_ci	int (*verify_receiver_cert_prepare_km)(struct device *dev,
1328c2ecf20Sopenharmony_ci					       struct hdcp_port_data *data,
1338c2ecf20Sopenharmony_ci					       struct hdcp2_ake_send_cert
1348c2ecf20Sopenharmony_ci								*rx_cert,
1358c2ecf20Sopenharmony_ci					       bool *km_stored,
1368c2ecf20Sopenharmony_ci					       struct hdcp2_ake_no_stored_km
1378c2ecf20Sopenharmony_ci								*ek_pub_km,
1388c2ecf20Sopenharmony_ci					       size_t *msg_sz);
1398c2ecf20Sopenharmony_ci	int (*verify_hprime)(struct device *dev,
1408c2ecf20Sopenharmony_ci			     struct hdcp_port_data *data,
1418c2ecf20Sopenharmony_ci			     struct hdcp2_ake_send_hprime *rx_hprime);
1428c2ecf20Sopenharmony_ci	int (*store_pairing_info)(struct device *dev,
1438c2ecf20Sopenharmony_ci				  struct hdcp_port_data *data,
1448c2ecf20Sopenharmony_ci				  struct hdcp2_ake_send_pairing_info
1458c2ecf20Sopenharmony_ci								*pairing_info);
1468c2ecf20Sopenharmony_ci	int (*initiate_locality_check)(struct device *dev,
1478c2ecf20Sopenharmony_ci				       struct hdcp_port_data *data,
1488c2ecf20Sopenharmony_ci				       struct hdcp2_lc_init *lc_init_data);
1498c2ecf20Sopenharmony_ci	int (*verify_lprime)(struct device *dev,
1508c2ecf20Sopenharmony_ci			     struct hdcp_port_data *data,
1518c2ecf20Sopenharmony_ci			     struct hdcp2_lc_send_lprime *rx_lprime);
1528c2ecf20Sopenharmony_ci	int (*get_session_key)(struct device *dev,
1538c2ecf20Sopenharmony_ci			       struct hdcp_port_data *data,
1548c2ecf20Sopenharmony_ci			       struct hdcp2_ske_send_eks *ske_data);
1558c2ecf20Sopenharmony_ci	int (*repeater_check_flow_prepare_ack)(struct device *dev,
1568c2ecf20Sopenharmony_ci					       struct hdcp_port_data *data,
1578c2ecf20Sopenharmony_ci					       struct hdcp2_rep_send_receiverid_list
1588c2ecf20Sopenharmony_ci								*rep_topology,
1598c2ecf20Sopenharmony_ci					       struct hdcp2_rep_send_ack
1608c2ecf20Sopenharmony_ci								*rep_send_ack);
1618c2ecf20Sopenharmony_ci	int (*verify_mprime)(struct device *dev,
1628c2ecf20Sopenharmony_ci			     struct hdcp_port_data *data,
1638c2ecf20Sopenharmony_ci			     struct hdcp2_rep_stream_ready *stream_ready);
1648c2ecf20Sopenharmony_ci	int (*enable_hdcp_authentication)(struct device *dev,
1658c2ecf20Sopenharmony_ci					  struct hdcp_port_data *data);
1668c2ecf20Sopenharmony_ci	int (*close_hdcp_session)(struct device *dev,
1678c2ecf20Sopenharmony_ci				  struct hdcp_port_data *data);
1688c2ecf20Sopenharmony_ci};
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci/**
1718c2ecf20Sopenharmony_ci * struct i915_hdcp_component_master - Used for communication between i915
1728c2ecf20Sopenharmony_ci * and mei_hdcp drivers for the HDCP2.2 services
1738c2ecf20Sopenharmony_ci * @mei_dev: device that provide the HDCP2.2 service from MEI Bus.
1748c2ecf20Sopenharmony_ci * @hdcp_ops: Ops implemented by mei_hdcp driver, used by i915 driver.
1758c2ecf20Sopenharmony_ci */
1768c2ecf20Sopenharmony_cistruct i915_hdcp_comp_master {
1778c2ecf20Sopenharmony_ci	struct device *mei_dev;
1788c2ecf20Sopenharmony_ci	const struct i915_hdcp_component_ops *ops;
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci	/* To protect the above members. */
1818c2ecf20Sopenharmony_ci	struct mutex mutex;
1828c2ecf20Sopenharmony_ci};
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci#endif /* _I915_MEI_HDCP_INTERFACE_H_ */
185