xref: /openbmc/linux/drivers/misc/mei/hdcp/mei_hdcp.c (revision 5e23491175eed8f9546491b5512ff62c1ea62dd3)
164e9bbddSRamalingam C // SPDX-License-Identifier: (GPL-2.0)
264e9bbddSRamalingam C /*
364e9bbddSRamalingam C  * Copyright © 2019 Intel Corporation
464e9bbddSRamalingam C  *
564e9bbddSRamalingam C  * Mei_hdcp.c: HDCP client driver for mei bus
664e9bbddSRamalingam C  *
764e9bbddSRamalingam C  * Author:
864e9bbddSRamalingam C  * Ramalingam C <ramalingam.c@intel.com>
964e9bbddSRamalingam C  */
1064e9bbddSRamalingam C 
1164e9bbddSRamalingam C /**
1264e9bbddSRamalingam C  * DOC: MEI_HDCP Client Driver
1364e9bbddSRamalingam C  *
1464e9bbddSRamalingam C  * This is a client driver to the mei_bus to make the HDCP2.2 services of
1564e9bbddSRamalingam C  * ME FW available for the interested consumers like I915.
1664e9bbddSRamalingam C  *
1764e9bbddSRamalingam C  * This module will act as a translation layer between HDCP protocol
1864e9bbddSRamalingam C  * implementor(I915) and ME FW by translating HDCP2.2 authentication
1964e9bbddSRamalingam C  * messages to ME FW command payloads and vice versa.
2064e9bbddSRamalingam C  */
2164e9bbddSRamalingam C 
2264e9bbddSRamalingam C #include <linux/module.h>
2364e9bbddSRamalingam C #include <linux/slab.h>
2464e9bbddSRamalingam C #include <linux/uuid.h>
2564e9bbddSRamalingam C #include <linux/mei_cl_bus.h>
26a37fb1e4SRamalingam C #include <drm/drm_connector.h>
27a37fb1e4SRamalingam C #include <drm/i915_component.h>
28a37fb1e4SRamalingam C #include <drm/i915_mei_hdcp_interface.h>
29a37fb1e4SRamalingam C 
30a37fb1e4SRamalingam C #include "mei_hdcp.h"
31a37fb1e4SRamalingam C 
32a37fb1e4SRamalingam C static inline u8 mei_get_ddi_index(enum port port)
33a37fb1e4SRamalingam C {
34a37fb1e4SRamalingam C 	switch (port) {
35a37fb1e4SRamalingam C 	case PORT_A:
36a37fb1e4SRamalingam C 		return MEI_DDI_A;
37a37fb1e4SRamalingam C 	case PORT_B ... PORT_F:
38a37fb1e4SRamalingam C 		return (u8)port;
39a37fb1e4SRamalingam C 	default:
40a37fb1e4SRamalingam C 		return MEI_DDI_INVALID_PORT;
41a37fb1e4SRamalingam C 	}
42a37fb1e4SRamalingam C }
43a37fb1e4SRamalingam C 
44a37fb1e4SRamalingam C /**
45a37fb1e4SRamalingam C  * mei_hdcp_initiate_session() - Initiate a Wired HDCP2.2 Tx Session in ME FW
46a37fb1e4SRamalingam C  * @dev: device corresponding to the mei_cl_device
47a37fb1e4SRamalingam C  * @data: Intel HW specific hdcp data
48a37fb1e4SRamalingam C  * @ake_data: AKE_Init msg output.
49a37fb1e4SRamalingam C  *
50a37fb1e4SRamalingam C  * Return:  0 on Success, <0 on Failure.
51a37fb1e4SRamalingam C  */
52a37fb1e4SRamalingam C static int
53a37fb1e4SRamalingam C mei_hdcp_initiate_session(struct device *dev, struct hdcp_port_data *data,
54a37fb1e4SRamalingam C 			  struct hdcp2_ake_init *ake_data)
55a37fb1e4SRamalingam C {
56a37fb1e4SRamalingam C 	struct wired_cmd_initiate_hdcp2_session_in session_init_in = { { 0 } };
57a37fb1e4SRamalingam C 	struct wired_cmd_initiate_hdcp2_session_out
58a37fb1e4SRamalingam C 						session_init_out = { { 0 } };
59a37fb1e4SRamalingam C 	struct mei_cl_device *cldev;
60a37fb1e4SRamalingam C 	ssize_t byte;
61a37fb1e4SRamalingam C 
62a37fb1e4SRamalingam C 	if (!dev || !data || !ake_data)
63a37fb1e4SRamalingam C 		return -EINVAL;
64a37fb1e4SRamalingam C 
65a37fb1e4SRamalingam C 	cldev = to_mei_cl_device(dev);
66a37fb1e4SRamalingam C 
67a37fb1e4SRamalingam C 	session_init_in.header.api_version = HDCP_API_VERSION;
68a37fb1e4SRamalingam C 	session_init_in.header.command_id = WIRED_INITIATE_HDCP2_SESSION;
69a37fb1e4SRamalingam C 	session_init_in.header.status = ME_HDCP_STATUS_SUCCESS;
70a37fb1e4SRamalingam C 	session_init_in.header.buffer_len =
71a37fb1e4SRamalingam C 				WIRED_CMD_BUF_LEN_INITIATE_HDCP2_SESSION_IN;
72a37fb1e4SRamalingam C 
73a37fb1e4SRamalingam C 	session_init_in.port.integrated_port_type = data->port_type;
74a37fb1e4SRamalingam C 	session_init_in.port.physical_port = mei_get_ddi_index(data->port);
75a37fb1e4SRamalingam C 	session_init_in.protocol = data->protocol;
76a37fb1e4SRamalingam C 
77a37fb1e4SRamalingam C 	byte = mei_cldev_send(cldev, (u8 *)&session_init_in,
78a37fb1e4SRamalingam C 			      sizeof(session_init_in));
79a37fb1e4SRamalingam C 	if (byte < 0) {
80a37fb1e4SRamalingam C 		dev_dbg(dev, "mei_cldev_send failed. %zd\n", byte);
81a37fb1e4SRamalingam C 		return byte;
82a37fb1e4SRamalingam C 	}
83a37fb1e4SRamalingam C 
84a37fb1e4SRamalingam C 	byte = mei_cldev_recv(cldev, (u8 *)&session_init_out,
85a37fb1e4SRamalingam C 			      sizeof(session_init_out));
86a37fb1e4SRamalingam C 	if (byte < 0) {
87a37fb1e4SRamalingam C 		dev_dbg(dev, "mei_cldev_recv failed. %zd\n", byte);
88a37fb1e4SRamalingam C 		return byte;
89a37fb1e4SRamalingam C 	}
90a37fb1e4SRamalingam C 
91a37fb1e4SRamalingam C 	if (session_init_out.header.status != ME_HDCP_STATUS_SUCCESS) {
92a37fb1e4SRamalingam C 		dev_dbg(dev, "ME cmd 0x%08X Failed. Status: 0x%X\n",
93a37fb1e4SRamalingam C 			WIRED_INITIATE_HDCP2_SESSION,
94a37fb1e4SRamalingam C 			session_init_out.header.status);
95a37fb1e4SRamalingam C 		return -EIO;
96a37fb1e4SRamalingam C 	}
97a37fb1e4SRamalingam C 
98a37fb1e4SRamalingam C 	ake_data->msg_id = HDCP_2_2_AKE_INIT;
99a37fb1e4SRamalingam C 	ake_data->tx_caps = session_init_out.tx_caps;
100a37fb1e4SRamalingam C 	memcpy(ake_data->r_tx, session_init_out.r_tx, HDCP_2_2_RTX_LEN);
101a37fb1e4SRamalingam C 
102a37fb1e4SRamalingam C 	return 0;
103a37fb1e4SRamalingam C }
104a37fb1e4SRamalingam C 
10539b71c2bSRamalingam C /**
10639b71c2bSRamalingam C  * mei_hdcp_verify_receiver_cert_prepare_km() - Verify the Receiver Certificate
10739b71c2bSRamalingam C  * AKE_Send_Cert and prepare AKE_Stored_Km/AKE_No_Stored_Km
10839b71c2bSRamalingam C  * @dev: device corresponding to the mei_cl_device
10939b71c2bSRamalingam C  * @data: Intel HW specific hdcp data
11039b71c2bSRamalingam C  * @rx_cert: AKE_Send_Cert for verification
11139b71c2bSRamalingam C  * @km_stored: Pairing status flag output
11239b71c2bSRamalingam C  * @ek_pub_km: AKE_Stored_Km/AKE_No_Stored_Km output msg
11339b71c2bSRamalingam C  * @msg_sz : size of AKE_XXXXX_Km output msg
11439b71c2bSRamalingam C  *
11539b71c2bSRamalingam C  * Return: 0 on Success, <0 on Failure
11639b71c2bSRamalingam C  */
11739b71c2bSRamalingam C static int
11839b71c2bSRamalingam C mei_hdcp_verify_receiver_cert_prepare_km(struct device *dev,
11939b71c2bSRamalingam C 					 struct hdcp_port_data *data,
12039b71c2bSRamalingam C 					 struct hdcp2_ake_send_cert *rx_cert,
12139b71c2bSRamalingam C 					 bool *km_stored,
12239b71c2bSRamalingam C 					 struct hdcp2_ake_no_stored_km
12339b71c2bSRamalingam C 								*ek_pub_km,
12439b71c2bSRamalingam C 					 size_t *msg_sz)
12539b71c2bSRamalingam C {
12639b71c2bSRamalingam C 	struct wired_cmd_verify_receiver_cert_in verify_rxcert_in = { { 0 } };
12739b71c2bSRamalingam C 	struct wired_cmd_verify_receiver_cert_out verify_rxcert_out = { { 0 } };
12839b71c2bSRamalingam C 	struct mei_cl_device *cldev;
12939b71c2bSRamalingam C 	ssize_t byte;
13039b71c2bSRamalingam C 
13139b71c2bSRamalingam C 	if (!dev || !data || !rx_cert || !km_stored || !ek_pub_km || !msg_sz)
13239b71c2bSRamalingam C 		return -EINVAL;
13339b71c2bSRamalingam C 
13439b71c2bSRamalingam C 	cldev = to_mei_cl_device(dev);
13539b71c2bSRamalingam C 
13639b71c2bSRamalingam C 	verify_rxcert_in.header.api_version = HDCP_API_VERSION;
13739b71c2bSRamalingam C 	verify_rxcert_in.header.command_id = WIRED_VERIFY_RECEIVER_CERT;
13839b71c2bSRamalingam C 	verify_rxcert_in.header.status = ME_HDCP_STATUS_SUCCESS;
13939b71c2bSRamalingam C 	verify_rxcert_in.header.buffer_len =
14039b71c2bSRamalingam C 				WIRED_CMD_BUF_LEN_VERIFY_RECEIVER_CERT_IN;
14139b71c2bSRamalingam C 
14239b71c2bSRamalingam C 	verify_rxcert_in.port.integrated_port_type = data->port_type;
14339b71c2bSRamalingam C 	verify_rxcert_in.port.physical_port = mei_get_ddi_index(data->port);
14439b71c2bSRamalingam C 
14539b71c2bSRamalingam C 	verify_rxcert_in.cert_rx = rx_cert->cert_rx;
14639b71c2bSRamalingam C 	memcpy(verify_rxcert_in.r_rx, &rx_cert->r_rx, HDCP_2_2_RRX_LEN);
14739b71c2bSRamalingam C 	memcpy(verify_rxcert_in.rx_caps, rx_cert->rx_caps, HDCP_2_2_RXCAPS_LEN);
14839b71c2bSRamalingam C 
14939b71c2bSRamalingam C 	byte = mei_cldev_send(cldev, (u8 *)&verify_rxcert_in,
15039b71c2bSRamalingam C 			      sizeof(verify_rxcert_in));
15139b71c2bSRamalingam C 	if (byte < 0) {
15239b71c2bSRamalingam C 		dev_dbg(dev, "mei_cldev_send failed: %zd\n", byte);
15339b71c2bSRamalingam C 		return byte;
15439b71c2bSRamalingam C 	}
15539b71c2bSRamalingam C 
15639b71c2bSRamalingam C 	byte = mei_cldev_recv(cldev, (u8 *)&verify_rxcert_out,
15739b71c2bSRamalingam C 			      sizeof(verify_rxcert_out));
15839b71c2bSRamalingam C 	if (byte < 0) {
15939b71c2bSRamalingam C 		dev_dbg(dev, "mei_cldev_recv failed: %zd\n", byte);
16039b71c2bSRamalingam C 		return byte;
16139b71c2bSRamalingam C 	}
16239b71c2bSRamalingam C 
16339b71c2bSRamalingam C 	if (verify_rxcert_out.header.status != ME_HDCP_STATUS_SUCCESS) {
16439b71c2bSRamalingam C 		dev_dbg(dev, "ME cmd 0x%08X Failed. Status: 0x%X\n",
16539b71c2bSRamalingam C 			WIRED_VERIFY_RECEIVER_CERT,
16639b71c2bSRamalingam C 			verify_rxcert_out.header.status);
16739b71c2bSRamalingam C 		return -EIO;
16839b71c2bSRamalingam C 	}
16939b71c2bSRamalingam C 
17039b71c2bSRamalingam C 	*km_stored = !!verify_rxcert_out.km_stored;
17139b71c2bSRamalingam C 	if (verify_rxcert_out.km_stored) {
17239b71c2bSRamalingam C 		ek_pub_km->msg_id = HDCP_2_2_AKE_STORED_KM;
17339b71c2bSRamalingam C 		*msg_sz = sizeof(struct hdcp2_ake_stored_km);
17439b71c2bSRamalingam C 	} else {
17539b71c2bSRamalingam C 		ek_pub_km->msg_id = HDCP_2_2_AKE_NO_STORED_KM;
17639b71c2bSRamalingam C 		*msg_sz = sizeof(struct hdcp2_ake_no_stored_km);
17739b71c2bSRamalingam C 	}
17839b71c2bSRamalingam C 
17939b71c2bSRamalingam C 	memcpy(ek_pub_km->e_kpub_km, &verify_rxcert_out.ekm_buff,
18039b71c2bSRamalingam C 	       sizeof(verify_rxcert_out.ekm_buff));
18139b71c2bSRamalingam C 
18239b71c2bSRamalingam C 	return 0;
18339b71c2bSRamalingam C }
18439b71c2bSRamalingam C 
185a7dcbed2SRamalingam C /**
186a7dcbed2SRamalingam C  * mei_hdcp_verify_hprime() - Verify AKE_Send_H_prime at ME FW.
187a7dcbed2SRamalingam C  * @dev: device corresponding to the mei_cl_device
188a7dcbed2SRamalingam C  * @data: Intel HW specific hdcp data
189a7dcbed2SRamalingam C  * @rx_hprime: AKE_Send_H_prime msg for ME FW verification
190a7dcbed2SRamalingam C  *
191a7dcbed2SRamalingam C  * Return: 0 on Success, <0 on Failure
192a7dcbed2SRamalingam C  */
193a7dcbed2SRamalingam C static int
194a7dcbed2SRamalingam C mei_hdcp_verify_hprime(struct device *dev, struct hdcp_port_data *data,
195a7dcbed2SRamalingam C 		       struct hdcp2_ake_send_hprime *rx_hprime)
196a7dcbed2SRamalingam C {
197a7dcbed2SRamalingam C 	struct wired_cmd_ake_send_hprime_in send_hprime_in = { { 0 } };
198a7dcbed2SRamalingam C 	struct wired_cmd_ake_send_hprime_out send_hprime_out = { { 0 } };
199a7dcbed2SRamalingam C 	struct mei_cl_device *cldev;
200a7dcbed2SRamalingam C 	ssize_t byte;
201a7dcbed2SRamalingam C 
202a7dcbed2SRamalingam C 	if (!dev || !data || !rx_hprime)
203a7dcbed2SRamalingam C 		return -EINVAL;
204a7dcbed2SRamalingam C 
205a7dcbed2SRamalingam C 	cldev = to_mei_cl_device(dev);
206a7dcbed2SRamalingam C 
207a7dcbed2SRamalingam C 	send_hprime_in.header.api_version = HDCP_API_VERSION;
208a7dcbed2SRamalingam C 	send_hprime_in.header.command_id = WIRED_AKE_SEND_HPRIME;
209a7dcbed2SRamalingam C 	send_hprime_in.header.status = ME_HDCP_STATUS_SUCCESS;
210a7dcbed2SRamalingam C 	send_hprime_in.header.buffer_len = WIRED_CMD_BUF_LEN_AKE_SEND_HPRIME_IN;
211a7dcbed2SRamalingam C 
212a7dcbed2SRamalingam C 	send_hprime_in.port.integrated_port_type = data->port_type;
213a7dcbed2SRamalingam C 	send_hprime_in.port.physical_port = mei_get_ddi_index(data->port);
214a7dcbed2SRamalingam C 
215a7dcbed2SRamalingam C 	memcpy(send_hprime_in.h_prime, rx_hprime->h_prime,
216a7dcbed2SRamalingam C 	       HDCP_2_2_H_PRIME_LEN);
217a7dcbed2SRamalingam C 
218a7dcbed2SRamalingam C 	byte = mei_cldev_send(cldev, (u8 *)&send_hprime_in,
219a7dcbed2SRamalingam C 			      sizeof(send_hprime_in));
220a7dcbed2SRamalingam C 	if (byte < 0) {
221a7dcbed2SRamalingam C 		dev_dbg(dev, "mei_cldev_send failed. %zd\n", byte);
222a7dcbed2SRamalingam C 		return byte;
223a7dcbed2SRamalingam C 	}
224a7dcbed2SRamalingam C 
225a7dcbed2SRamalingam C 	byte = mei_cldev_recv(cldev, (u8 *)&send_hprime_out,
226a7dcbed2SRamalingam C 			      sizeof(send_hprime_out));
227a7dcbed2SRamalingam C 	if (byte < 0) {
228a7dcbed2SRamalingam C 		dev_dbg(dev, "mei_cldev_recv failed. %zd\n", byte);
229a7dcbed2SRamalingam C 		return byte;
230a7dcbed2SRamalingam C 	}
231a7dcbed2SRamalingam C 
232a7dcbed2SRamalingam C 	if (send_hprime_out.header.status != ME_HDCP_STATUS_SUCCESS) {
233a7dcbed2SRamalingam C 		dev_dbg(dev, "ME cmd 0x%08X Failed. Status: 0x%X\n",
234a7dcbed2SRamalingam C 			WIRED_AKE_SEND_HPRIME, send_hprime_out.header.status);
235a7dcbed2SRamalingam C 		return -EIO;
236a7dcbed2SRamalingam C 	}
237a7dcbed2SRamalingam C 
238a7dcbed2SRamalingam C 	return 0;
239a7dcbed2SRamalingam C }
240a7dcbed2SRamalingam C 
2416a1a00a3SRamalingam C /**
2426a1a00a3SRamalingam C  * mei_hdcp_store_pairing_info() - Store pairing info received at ME FW
2436a1a00a3SRamalingam C  * @dev: device corresponding to the mei_cl_device
2446a1a00a3SRamalingam C  * @data: Intel HW specific hdcp data
2456a1a00a3SRamalingam C  * @pairing_info: AKE_Send_Pairing_Info msg input to ME FW
2466a1a00a3SRamalingam C  *
2476a1a00a3SRamalingam C  * Return: 0 on Success, <0 on Failure
2486a1a00a3SRamalingam C  */
2496a1a00a3SRamalingam C static int
2506a1a00a3SRamalingam C mei_hdcp_store_pairing_info(struct device *dev, struct hdcp_port_data *data,
2516a1a00a3SRamalingam C 			    struct hdcp2_ake_send_pairing_info *pairing_info)
2526a1a00a3SRamalingam C {
2536a1a00a3SRamalingam C 	struct wired_cmd_ake_send_pairing_info_in pairing_info_in = { { 0 } };
2546a1a00a3SRamalingam C 	struct wired_cmd_ake_send_pairing_info_out pairing_info_out = { { 0 } };
2556a1a00a3SRamalingam C 	struct mei_cl_device *cldev;
2566a1a00a3SRamalingam C 	ssize_t byte;
2576a1a00a3SRamalingam C 
2586a1a00a3SRamalingam C 	if (!dev || !data || !pairing_info)
2596a1a00a3SRamalingam C 		return -EINVAL;
2606a1a00a3SRamalingam C 
2616a1a00a3SRamalingam C 	cldev = to_mei_cl_device(dev);
2626a1a00a3SRamalingam C 
2636a1a00a3SRamalingam C 	pairing_info_in.header.api_version = HDCP_API_VERSION;
2646a1a00a3SRamalingam C 	pairing_info_in.header.command_id = WIRED_AKE_SEND_PAIRING_INFO;
2656a1a00a3SRamalingam C 	pairing_info_in.header.status = ME_HDCP_STATUS_SUCCESS;
2666a1a00a3SRamalingam C 	pairing_info_in.header.buffer_len =
2676a1a00a3SRamalingam C 					WIRED_CMD_BUF_LEN_SEND_PAIRING_INFO_IN;
2686a1a00a3SRamalingam C 
2696a1a00a3SRamalingam C 	pairing_info_in.port.integrated_port_type = data->port_type;
2706a1a00a3SRamalingam C 	pairing_info_in.port.physical_port = mei_get_ddi_index(data->port);
2716a1a00a3SRamalingam C 
2726a1a00a3SRamalingam C 	memcpy(pairing_info_in.e_kh_km, pairing_info->e_kh_km,
2736a1a00a3SRamalingam C 	       HDCP_2_2_E_KH_KM_LEN);
2746a1a00a3SRamalingam C 
2756a1a00a3SRamalingam C 	byte = mei_cldev_send(cldev, (u8 *)&pairing_info_in,
2766a1a00a3SRamalingam C 			      sizeof(pairing_info_in));
2776a1a00a3SRamalingam C 	if (byte < 0) {
2786a1a00a3SRamalingam C 		dev_dbg(dev, "mei_cldev_send failed. %zd\n", byte);
2796a1a00a3SRamalingam C 		return byte;
2806a1a00a3SRamalingam C 	}
2816a1a00a3SRamalingam C 
2826a1a00a3SRamalingam C 	byte = mei_cldev_recv(cldev, (u8 *)&pairing_info_out,
2836a1a00a3SRamalingam C 			      sizeof(pairing_info_out));
2846a1a00a3SRamalingam C 	if (byte < 0) {
2856a1a00a3SRamalingam C 		dev_dbg(dev, "mei_cldev_recv failed. %zd\n", byte);
2866a1a00a3SRamalingam C 		return byte;
2876a1a00a3SRamalingam C 	}
2886a1a00a3SRamalingam C 
2896a1a00a3SRamalingam C 	if (pairing_info_out.header.status != ME_HDCP_STATUS_SUCCESS) {
2906a1a00a3SRamalingam C 		dev_dbg(dev, "ME cmd 0x%08X failed. Status: 0x%X\n",
2916a1a00a3SRamalingam C 			WIRED_AKE_SEND_PAIRING_INFO,
2926a1a00a3SRamalingam C 			pairing_info_out.header.status);
2936a1a00a3SRamalingam C 		return -EIO;
2946a1a00a3SRamalingam C 	}
2956a1a00a3SRamalingam C 
2966a1a00a3SRamalingam C 	return 0;
2976a1a00a3SRamalingam C }
2986a1a00a3SRamalingam C 
299682932f3SRamalingam C /**
300682932f3SRamalingam C  * mei_hdcp_initiate_locality_check() - Prepare LC_Init
301682932f3SRamalingam C  * @dev: device corresponding to the mei_cl_device
302682932f3SRamalingam C  * @data: Intel HW specific hdcp data
303682932f3SRamalingam C  * @lc_init_data: LC_Init msg output
304682932f3SRamalingam C  *
305682932f3SRamalingam C  * Return: 0 on Success, <0 on Failure
306682932f3SRamalingam C  */
307682932f3SRamalingam C static int
308682932f3SRamalingam C mei_hdcp_initiate_locality_check(struct device *dev,
309682932f3SRamalingam C 				 struct hdcp_port_data *data,
310682932f3SRamalingam C 				 struct hdcp2_lc_init *lc_init_data)
311682932f3SRamalingam C {
312682932f3SRamalingam C 	struct wired_cmd_init_locality_check_in lc_init_in = { { 0 } };
313682932f3SRamalingam C 	struct wired_cmd_init_locality_check_out lc_init_out = { { 0 } };
314682932f3SRamalingam C 	struct mei_cl_device *cldev;
315682932f3SRamalingam C 	ssize_t byte;
316682932f3SRamalingam C 
317682932f3SRamalingam C 	if (!dev || !data || !lc_init_data)
318682932f3SRamalingam C 		return -EINVAL;
319682932f3SRamalingam C 
320682932f3SRamalingam C 	cldev = to_mei_cl_device(dev);
321682932f3SRamalingam C 
322682932f3SRamalingam C 	lc_init_in.header.api_version = HDCP_API_VERSION;
323682932f3SRamalingam C 	lc_init_in.header.command_id = WIRED_INIT_LOCALITY_CHECK;
324682932f3SRamalingam C 	lc_init_in.header.status = ME_HDCP_STATUS_SUCCESS;
325682932f3SRamalingam C 	lc_init_in.header.buffer_len = WIRED_CMD_BUF_LEN_INIT_LOCALITY_CHECK_IN;
326682932f3SRamalingam C 
327682932f3SRamalingam C 	lc_init_in.port.integrated_port_type = data->port_type;
328682932f3SRamalingam C 	lc_init_in.port.physical_port = mei_get_ddi_index(data->port);
329682932f3SRamalingam C 
330682932f3SRamalingam C 	byte = mei_cldev_send(cldev, (u8 *)&lc_init_in, sizeof(lc_init_in));
331682932f3SRamalingam C 	if (byte < 0) {
332682932f3SRamalingam C 		dev_dbg(dev, "mei_cldev_send failed. %zd\n", byte);
333682932f3SRamalingam C 		return byte;
334682932f3SRamalingam C 	}
335682932f3SRamalingam C 
336682932f3SRamalingam C 	byte = mei_cldev_recv(cldev, (u8 *)&lc_init_out, sizeof(lc_init_out));
337682932f3SRamalingam C 	if (byte < 0) {
338682932f3SRamalingam C 		dev_dbg(dev, "mei_cldev_recv failed. %zd\n", byte);
339682932f3SRamalingam C 		return byte;
340682932f3SRamalingam C 	}
341682932f3SRamalingam C 
342682932f3SRamalingam C 	if (lc_init_out.header.status != ME_HDCP_STATUS_SUCCESS) {
343682932f3SRamalingam C 		dev_dbg(dev, "ME cmd 0x%08X Failed. status: 0x%X\n",
344682932f3SRamalingam C 			WIRED_INIT_LOCALITY_CHECK, lc_init_out.header.status);
345682932f3SRamalingam C 		return -EIO;
346682932f3SRamalingam C 	}
347682932f3SRamalingam C 
348682932f3SRamalingam C 	lc_init_data->msg_id = HDCP_2_2_LC_INIT;
349682932f3SRamalingam C 	memcpy(lc_init_data->r_n, lc_init_out.r_n, HDCP_2_2_RN_LEN);
350682932f3SRamalingam C 
351682932f3SRamalingam C 	return 0;
352682932f3SRamalingam C }
353682932f3SRamalingam C 
35445479b67SRamalingam C /**
35545479b67SRamalingam C  * mei_hdcp_verify_lprime() - Verify lprime.
35645479b67SRamalingam C  * @dev: device corresponding to the mei_cl_device
35745479b67SRamalingam C  * @data: Intel HW specific hdcp data
35845479b67SRamalingam C  * @rx_lprime: LC_Send_L_prime msg for ME FW verification
35945479b67SRamalingam C  *
36045479b67SRamalingam C  * Return: 0 on Success, <0 on Failure
36145479b67SRamalingam C  */
36245479b67SRamalingam C static int
36345479b67SRamalingam C mei_hdcp_verify_lprime(struct device *dev, struct hdcp_port_data *data,
36445479b67SRamalingam C 		       struct hdcp2_lc_send_lprime *rx_lprime)
36545479b67SRamalingam C {
36645479b67SRamalingam C 	struct wired_cmd_validate_locality_in verify_lprime_in = { { 0 } };
36745479b67SRamalingam C 	struct wired_cmd_validate_locality_out verify_lprime_out = { { 0 } };
36845479b67SRamalingam C 	struct mei_cl_device *cldev;
36945479b67SRamalingam C 	ssize_t byte;
37045479b67SRamalingam C 
37145479b67SRamalingam C 	if (!dev || !data || !rx_lprime)
37245479b67SRamalingam C 		return -EINVAL;
37345479b67SRamalingam C 
37445479b67SRamalingam C 	cldev = to_mei_cl_device(dev);
37545479b67SRamalingam C 
37645479b67SRamalingam C 	verify_lprime_in.header.api_version = HDCP_API_VERSION;
37745479b67SRamalingam C 	verify_lprime_in.header.command_id = WIRED_VALIDATE_LOCALITY;
37845479b67SRamalingam C 	verify_lprime_in.header.status = ME_HDCP_STATUS_SUCCESS;
37945479b67SRamalingam C 	verify_lprime_in.header.buffer_len =
38045479b67SRamalingam C 					WIRED_CMD_BUF_LEN_VALIDATE_LOCALITY_IN;
38145479b67SRamalingam C 
38245479b67SRamalingam C 	verify_lprime_in.port.integrated_port_type = data->port_type;
38345479b67SRamalingam C 	verify_lprime_in.port.physical_port = mei_get_ddi_index(data->port);
38445479b67SRamalingam C 
38545479b67SRamalingam C 	memcpy(verify_lprime_in.l_prime, rx_lprime->l_prime,
38645479b67SRamalingam C 	       HDCP_2_2_L_PRIME_LEN);
38745479b67SRamalingam C 
38845479b67SRamalingam C 	byte = mei_cldev_send(cldev, (u8 *)&verify_lprime_in,
38945479b67SRamalingam C 			      sizeof(verify_lprime_in));
39045479b67SRamalingam C 	if (byte < 0) {
39145479b67SRamalingam C 		dev_dbg(dev, "mei_cldev_send failed. %zd\n", byte);
39245479b67SRamalingam C 		return byte;
39345479b67SRamalingam C 	}
39445479b67SRamalingam C 
39545479b67SRamalingam C 	byte = mei_cldev_recv(cldev, (u8 *)&verify_lprime_out,
39645479b67SRamalingam C 			      sizeof(verify_lprime_out));
39745479b67SRamalingam C 	if (byte < 0) {
39845479b67SRamalingam C 		dev_dbg(dev, "mei_cldev_recv failed. %zd\n", byte);
39945479b67SRamalingam C 		return byte;
40045479b67SRamalingam C 	}
40145479b67SRamalingam C 
40245479b67SRamalingam C 	if (verify_lprime_out.header.status != ME_HDCP_STATUS_SUCCESS) {
40345479b67SRamalingam C 		dev_dbg(dev, "ME cmd 0x%08X failed. status: 0x%X\n",
40445479b67SRamalingam C 			WIRED_VALIDATE_LOCALITY,
40545479b67SRamalingam C 			verify_lprime_out.header.status);
40645479b67SRamalingam C 		return -EIO;
40745479b67SRamalingam C 	}
40845479b67SRamalingam C 
40945479b67SRamalingam C 	return 0;
41045479b67SRamalingam C }
41145479b67SRamalingam C 
412b491264fSRamalingam C /**
413b491264fSRamalingam C  * mei_hdcp_get_session_key() - Prepare SKE_Send_Eks.
414b491264fSRamalingam C  * @dev: device corresponding to the mei_cl_device
415b491264fSRamalingam C  * @data: Intel HW specific hdcp data
416b491264fSRamalingam C  * @ske_data: SKE_Send_Eks msg output from ME FW.
417b491264fSRamalingam C  *
418b491264fSRamalingam C  * Return: 0 on Success, <0 on Failure
419b491264fSRamalingam C  */
420b491264fSRamalingam C static int mei_hdcp_get_session_key(struct device *dev,
421b491264fSRamalingam C 				    struct hdcp_port_data *data,
422b491264fSRamalingam C 				    struct hdcp2_ske_send_eks *ske_data)
423b491264fSRamalingam C {
424b491264fSRamalingam C 	struct wired_cmd_get_session_key_in get_skey_in = { { 0 } };
425b491264fSRamalingam C 	struct wired_cmd_get_session_key_out get_skey_out = { { 0 } };
426b491264fSRamalingam C 	struct mei_cl_device *cldev;
427b491264fSRamalingam C 	ssize_t byte;
428b491264fSRamalingam C 
429b491264fSRamalingam C 	if (!dev || !data || !ske_data)
430b491264fSRamalingam C 		return -EINVAL;
431b491264fSRamalingam C 
432b491264fSRamalingam C 	cldev = to_mei_cl_device(dev);
433b491264fSRamalingam C 
434b491264fSRamalingam C 	get_skey_in.header.api_version = HDCP_API_VERSION;
435b491264fSRamalingam C 	get_skey_in.header.command_id = WIRED_GET_SESSION_KEY;
436b491264fSRamalingam C 	get_skey_in.header.status = ME_HDCP_STATUS_SUCCESS;
437b491264fSRamalingam C 	get_skey_in.header.buffer_len = WIRED_CMD_BUF_LEN_GET_SESSION_KEY_IN;
438b491264fSRamalingam C 
439b491264fSRamalingam C 	get_skey_in.port.integrated_port_type = data->port_type;
440b491264fSRamalingam C 	get_skey_in.port.physical_port = mei_get_ddi_index(data->port);
441b491264fSRamalingam C 
442b491264fSRamalingam C 	byte = mei_cldev_send(cldev, (u8 *)&get_skey_in, sizeof(get_skey_in));
443b491264fSRamalingam C 	if (byte < 0) {
444b491264fSRamalingam C 		dev_dbg(dev, "mei_cldev_send failed. %zd\n", byte);
445b491264fSRamalingam C 		return byte;
446b491264fSRamalingam C 	}
447b491264fSRamalingam C 
448b491264fSRamalingam C 	byte = mei_cldev_recv(cldev, (u8 *)&get_skey_out, sizeof(get_skey_out));
449b491264fSRamalingam C 
450b491264fSRamalingam C 	if (byte < 0) {
451b491264fSRamalingam C 		dev_dbg(dev, "mei_cldev_recv failed. %zd\n", byte);
452b491264fSRamalingam C 		return byte;
453b491264fSRamalingam C 	}
454b491264fSRamalingam C 
455b491264fSRamalingam C 	if (get_skey_out.header.status != ME_HDCP_STATUS_SUCCESS) {
456b491264fSRamalingam C 		dev_dbg(dev, "ME cmd 0x%08X failed. status: 0x%X\n",
457b491264fSRamalingam C 			WIRED_GET_SESSION_KEY, get_skey_out.header.status);
458b491264fSRamalingam C 		return -EIO;
459b491264fSRamalingam C 	}
460b491264fSRamalingam C 
461b491264fSRamalingam C 	ske_data->msg_id = HDCP_2_2_SKE_SEND_EKS;
462b491264fSRamalingam C 	memcpy(ske_data->e_dkey_ks, get_skey_out.e_dkey_ks,
463b491264fSRamalingam C 	       HDCP_2_2_E_DKEY_KS_LEN);
464b491264fSRamalingam C 	memcpy(ske_data->riv, get_skey_out.r_iv, HDCP_2_2_RIV_LEN);
465b491264fSRamalingam C 
466b491264fSRamalingam C 	return 0;
467b491264fSRamalingam C }
468b491264fSRamalingam C 
469f46ea842SRamalingam C /**
470f46ea842SRamalingam C  * mei_hdcp_repeater_check_flow_prepare_ack() - Validate the Downstream topology
471f46ea842SRamalingam C  * and prepare rep_ack.
472f46ea842SRamalingam C  * @dev: device corresponding to the mei_cl_device
473f46ea842SRamalingam C  * @data: Intel HW specific hdcp data
474f46ea842SRamalingam C  * @rep_topology: Receiver ID List to be validated
475f46ea842SRamalingam C  * @rep_send_ack : repeater ack from ME FW.
476f46ea842SRamalingam C  *
477f46ea842SRamalingam C  * Return: 0 on Success, <0 on Failure
478f46ea842SRamalingam C  */
479f46ea842SRamalingam C static int
480f46ea842SRamalingam C mei_hdcp_repeater_check_flow_prepare_ack(struct device *dev,
481f46ea842SRamalingam C 					 struct hdcp_port_data *data,
482f46ea842SRamalingam C 					 struct hdcp2_rep_send_receiverid_list
483f46ea842SRamalingam C 							*rep_topology,
484f46ea842SRamalingam C 					 struct hdcp2_rep_send_ack
485f46ea842SRamalingam C 							*rep_send_ack)
486f46ea842SRamalingam C {
487f46ea842SRamalingam C 	struct wired_cmd_verify_repeater_in verify_repeater_in = { { 0 } };
488f46ea842SRamalingam C 	struct wired_cmd_verify_repeater_out verify_repeater_out = { { 0 } };
489f46ea842SRamalingam C 	struct mei_cl_device *cldev;
490f46ea842SRamalingam C 	ssize_t byte;
491f46ea842SRamalingam C 
492f46ea842SRamalingam C 	if (!dev || !rep_topology || !rep_send_ack || !data)
493f46ea842SRamalingam C 		return -EINVAL;
494f46ea842SRamalingam C 
495f46ea842SRamalingam C 	cldev = to_mei_cl_device(dev);
496f46ea842SRamalingam C 
497f46ea842SRamalingam C 	verify_repeater_in.header.api_version = HDCP_API_VERSION;
498f46ea842SRamalingam C 	verify_repeater_in.header.command_id = WIRED_VERIFY_REPEATER;
499f46ea842SRamalingam C 	verify_repeater_in.header.status = ME_HDCP_STATUS_SUCCESS;
500f46ea842SRamalingam C 	verify_repeater_in.header.buffer_len =
501f46ea842SRamalingam C 					WIRED_CMD_BUF_LEN_VERIFY_REPEATER_IN;
502f46ea842SRamalingam C 
503f46ea842SRamalingam C 	verify_repeater_in.port.integrated_port_type = data->port_type;
504f46ea842SRamalingam C 	verify_repeater_in.port.physical_port = mei_get_ddi_index(data->port);
505f46ea842SRamalingam C 
506f46ea842SRamalingam C 	memcpy(verify_repeater_in.rx_info, rep_topology->rx_info,
507f46ea842SRamalingam C 	       HDCP_2_2_RXINFO_LEN);
508f46ea842SRamalingam C 	memcpy(verify_repeater_in.seq_num_v, rep_topology->seq_num_v,
509f46ea842SRamalingam C 	       HDCP_2_2_SEQ_NUM_LEN);
510f46ea842SRamalingam C 	memcpy(verify_repeater_in.v_prime, rep_topology->v_prime,
511f46ea842SRamalingam C 	       HDCP_2_2_V_PRIME_HALF_LEN);
512f46ea842SRamalingam C 	memcpy(verify_repeater_in.receiver_ids, rep_topology->receiver_ids,
513f46ea842SRamalingam C 	       HDCP_2_2_RECEIVER_IDS_MAX_LEN);
514f46ea842SRamalingam C 
515f46ea842SRamalingam C 	byte = mei_cldev_send(cldev, (u8 *)&verify_repeater_in,
516f46ea842SRamalingam C 			      sizeof(verify_repeater_in));
517f46ea842SRamalingam C 	if (byte < 0) {
518f46ea842SRamalingam C 		dev_dbg(dev, "mei_cldev_send failed. %zd\n", byte);
519f46ea842SRamalingam C 		return byte;
520f46ea842SRamalingam C 	}
521f46ea842SRamalingam C 
522f46ea842SRamalingam C 	byte = mei_cldev_recv(cldev, (u8 *)&verify_repeater_out,
523f46ea842SRamalingam C 			      sizeof(verify_repeater_out));
524f46ea842SRamalingam C 	if (byte < 0) {
525f46ea842SRamalingam C 		dev_dbg(dev, "mei_cldev_recv failed. %zd\n", byte);
526f46ea842SRamalingam C 		return byte;
527f46ea842SRamalingam C 	}
528f46ea842SRamalingam C 
529f46ea842SRamalingam C 	if (verify_repeater_out.header.status != ME_HDCP_STATUS_SUCCESS) {
530f46ea842SRamalingam C 		dev_dbg(dev, "ME cmd 0x%08X failed. status: 0x%X\n",
531f46ea842SRamalingam C 			WIRED_VERIFY_REPEATER,
532f46ea842SRamalingam C 			verify_repeater_out.header.status);
533f46ea842SRamalingam C 		return -EIO;
534f46ea842SRamalingam C 	}
535f46ea842SRamalingam C 
536f46ea842SRamalingam C 	memcpy(rep_send_ack->v, verify_repeater_out.v,
537f46ea842SRamalingam C 	       HDCP_2_2_V_PRIME_HALF_LEN);
538f46ea842SRamalingam C 	rep_send_ack->msg_id = HDCP_2_2_REP_SEND_ACK;
539f46ea842SRamalingam C 
540f46ea842SRamalingam C 	return 0;
541f46ea842SRamalingam C }
542f46ea842SRamalingam C 
5430a1af1b5SRamalingam C /**
5440a1af1b5SRamalingam C  * mei_hdcp_verify_mprime() - Verify mprime.
5450a1af1b5SRamalingam C  * @dev: device corresponding to the mei_cl_device
5460a1af1b5SRamalingam C  * @data: Intel HW specific hdcp data
5470a1af1b5SRamalingam C  * @stream_ready: RepeaterAuth_Stream_Ready msg for ME FW verification.
5480a1af1b5SRamalingam C  *
5490a1af1b5SRamalingam C  * Return: 0 on Success, <0 on Failure
5500a1af1b5SRamalingam C  */
5510a1af1b5SRamalingam C static int mei_hdcp_verify_mprime(struct device *dev,
5520a1af1b5SRamalingam C 				  struct hdcp_port_data *data,
5530a1af1b5SRamalingam C 				  struct hdcp2_rep_stream_ready *stream_ready)
5540a1af1b5SRamalingam C {
5550a1af1b5SRamalingam C 	struct wired_cmd_repeater_auth_stream_req_in
5560a1af1b5SRamalingam C 					verify_mprime_in = { { 0 } };
5570a1af1b5SRamalingam C 	struct wired_cmd_repeater_auth_stream_req_out
5580a1af1b5SRamalingam C 					verify_mprime_out = { { 0 } };
5590a1af1b5SRamalingam C 	struct mei_cl_device *cldev;
5600a1af1b5SRamalingam C 	ssize_t byte;
5610a1af1b5SRamalingam C 
5620a1af1b5SRamalingam C 	if (!dev || !stream_ready || !data)
5630a1af1b5SRamalingam C 		return -EINVAL;
5640a1af1b5SRamalingam C 
5650a1af1b5SRamalingam C 	cldev = to_mei_cl_device(dev);
5660a1af1b5SRamalingam C 
5670a1af1b5SRamalingam C 	verify_mprime_in.header.api_version = HDCP_API_VERSION;
5680a1af1b5SRamalingam C 	verify_mprime_in.header.command_id = WIRED_REPEATER_AUTH_STREAM_REQ;
5690a1af1b5SRamalingam C 	verify_mprime_in.header.status = ME_HDCP_STATUS_SUCCESS;
5700a1af1b5SRamalingam C 	verify_mprime_in.header.buffer_len =
5710a1af1b5SRamalingam C 			WIRED_CMD_BUF_LEN_REPEATER_AUTH_STREAM_REQ_MIN_IN;
5720a1af1b5SRamalingam C 
5730a1af1b5SRamalingam C 	verify_mprime_in.port.integrated_port_type = data->port_type;
5740a1af1b5SRamalingam C 	verify_mprime_in.port.physical_port = mei_get_ddi_index(data->port);
5750a1af1b5SRamalingam C 
5760a1af1b5SRamalingam C 	memcpy(verify_mprime_in.m_prime, stream_ready->m_prime,
5770a1af1b5SRamalingam C 	       HDCP_2_2_MPRIME_LEN);
5780a1af1b5SRamalingam C 	drm_hdcp2_u32_to_seq_num(verify_mprime_in.seq_num_m, data->seq_num_m);
5790a1af1b5SRamalingam C 	memcpy(verify_mprime_in.streams, data->streams,
5800a1af1b5SRamalingam C 	       (data->k * sizeof(struct hdcp2_streamid_type)));
5810a1af1b5SRamalingam C 
5820a1af1b5SRamalingam C 	verify_mprime_in.k = cpu_to_be16(data->k);
5830a1af1b5SRamalingam C 
5840a1af1b5SRamalingam C 	byte = mei_cldev_send(cldev, (u8 *)&verify_mprime_in,
5850a1af1b5SRamalingam C 			      sizeof(verify_mprime_in));
5860a1af1b5SRamalingam C 	if (byte < 0) {
5870a1af1b5SRamalingam C 		dev_dbg(dev, "mei_cldev_send failed. %zd\n", byte);
5880a1af1b5SRamalingam C 		return byte;
5890a1af1b5SRamalingam C 	}
5900a1af1b5SRamalingam C 
5910a1af1b5SRamalingam C 	byte = mei_cldev_recv(cldev, (u8 *)&verify_mprime_out,
5920a1af1b5SRamalingam C 			      sizeof(verify_mprime_out));
5930a1af1b5SRamalingam C 	if (byte < 0) {
5940a1af1b5SRamalingam C 		dev_dbg(dev, "mei_cldev_recv failed. %zd\n", byte);
5950a1af1b5SRamalingam C 		return byte;
5960a1af1b5SRamalingam C 	}
5970a1af1b5SRamalingam C 
5980a1af1b5SRamalingam C 	if (verify_mprime_out.header.status != ME_HDCP_STATUS_SUCCESS) {
5990a1af1b5SRamalingam C 		dev_dbg(dev, "ME cmd 0x%08X failed. status: 0x%X\n",
6000a1af1b5SRamalingam C 			WIRED_REPEATER_AUTH_STREAM_REQ,
6010a1af1b5SRamalingam C 			verify_mprime_out.header.status);
6020a1af1b5SRamalingam C 		return -EIO;
6030a1af1b5SRamalingam C 	}
6040a1af1b5SRamalingam C 
6050a1af1b5SRamalingam C 	return 0;
6060a1af1b5SRamalingam C }
6070a1af1b5SRamalingam C 
608*5e234911SRamalingam C /**
609*5e234911SRamalingam C  * mei_hdcp_enable_authentication() - Mark a port as authenticated
610*5e234911SRamalingam C  * through ME FW
611*5e234911SRamalingam C  * @dev: device corresponding to the mei_cl_device
612*5e234911SRamalingam C  * @data: Intel HW specific hdcp data
613*5e234911SRamalingam C  *
614*5e234911SRamalingam C  * Return: 0 on Success, <0 on Failure
615*5e234911SRamalingam C  */
616*5e234911SRamalingam C static int mei_hdcp_enable_authentication(struct device *dev,
617*5e234911SRamalingam C 					  struct hdcp_port_data *data)
618*5e234911SRamalingam C {
619*5e234911SRamalingam C 	struct wired_cmd_enable_auth_in enable_auth_in = { { 0 } };
620*5e234911SRamalingam C 	struct wired_cmd_enable_auth_out enable_auth_out = { { 0 } };
621*5e234911SRamalingam C 	struct mei_cl_device *cldev;
622*5e234911SRamalingam C 	ssize_t byte;
623*5e234911SRamalingam C 
624*5e234911SRamalingam C 	if (!dev || !data)
625*5e234911SRamalingam C 		return -EINVAL;
626*5e234911SRamalingam C 
627*5e234911SRamalingam C 	cldev = to_mei_cl_device(dev);
628*5e234911SRamalingam C 
629*5e234911SRamalingam C 	enable_auth_in.header.api_version = HDCP_API_VERSION;
630*5e234911SRamalingam C 	enable_auth_in.header.command_id = WIRED_ENABLE_AUTH;
631*5e234911SRamalingam C 	enable_auth_in.header.status = ME_HDCP_STATUS_SUCCESS;
632*5e234911SRamalingam C 	enable_auth_in.header.buffer_len = WIRED_CMD_BUF_LEN_ENABLE_AUTH_IN;
633*5e234911SRamalingam C 
634*5e234911SRamalingam C 	enable_auth_in.port.integrated_port_type = data->port_type;
635*5e234911SRamalingam C 	enable_auth_in.port.physical_port = mei_get_ddi_index(data->port);
636*5e234911SRamalingam C 	enable_auth_in.stream_type = data->streams[0].stream_type;
637*5e234911SRamalingam C 
638*5e234911SRamalingam C 	byte = mei_cldev_send(cldev, (u8 *)&enable_auth_in,
639*5e234911SRamalingam C 			      sizeof(enable_auth_in));
640*5e234911SRamalingam C 	if (byte < 0) {
641*5e234911SRamalingam C 		dev_dbg(dev, "mei_cldev_send failed. %zd\n", byte);
642*5e234911SRamalingam C 		return byte;
643*5e234911SRamalingam C 	}
644*5e234911SRamalingam C 
645*5e234911SRamalingam C 	byte = mei_cldev_recv(cldev, (u8 *)&enable_auth_out,
646*5e234911SRamalingam C 			      sizeof(enable_auth_out));
647*5e234911SRamalingam C 	if (byte < 0) {
648*5e234911SRamalingam C 		dev_dbg(dev, "mei_cldev_recv failed. %zd\n", byte);
649*5e234911SRamalingam C 		return byte;
650*5e234911SRamalingam C 	}
651*5e234911SRamalingam C 
652*5e234911SRamalingam C 	if (enable_auth_out.header.status != ME_HDCP_STATUS_SUCCESS) {
653*5e234911SRamalingam C 		dev_dbg(dev, "ME cmd 0x%08X failed. status: 0x%X\n",
654*5e234911SRamalingam C 			WIRED_ENABLE_AUTH, enable_auth_out.header.status);
655*5e234911SRamalingam C 		return -EIO;
656*5e234911SRamalingam C 	}
657*5e234911SRamalingam C 
658*5e234911SRamalingam C 	return 0;
659*5e234911SRamalingam C }
660*5e234911SRamalingam C 
661a37fb1e4SRamalingam C static const __attribute__((unused))
662a37fb1e4SRamalingam C struct i915_hdcp_component_ops mei_hdcp_ops = {
663a37fb1e4SRamalingam C 	.owner = THIS_MODULE,
664a37fb1e4SRamalingam C 	.initiate_hdcp2_session = mei_hdcp_initiate_session,
66539b71c2bSRamalingam C 	.verify_receiver_cert_prepare_km =
66639b71c2bSRamalingam C 				mei_hdcp_verify_receiver_cert_prepare_km,
667a7dcbed2SRamalingam C 	.verify_hprime = mei_hdcp_verify_hprime,
6686a1a00a3SRamalingam C 	.store_pairing_info = mei_hdcp_store_pairing_info,
669682932f3SRamalingam C 	.initiate_locality_check = mei_hdcp_initiate_locality_check,
67045479b67SRamalingam C 	.verify_lprime = mei_hdcp_verify_lprime,
671b491264fSRamalingam C 	.get_session_key = mei_hdcp_get_session_key,
672f46ea842SRamalingam C 	.repeater_check_flow_prepare_ack =
673f46ea842SRamalingam C 				mei_hdcp_repeater_check_flow_prepare_ack,
6740a1af1b5SRamalingam C 	.verify_mprime = mei_hdcp_verify_mprime,
675*5e234911SRamalingam C 	.enable_hdcp_authentication = mei_hdcp_enable_authentication,
676a37fb1e4SRamalingam C 	.close_hdcp_session = NULL,
677a37fb1e4SRamalingam C };
67864e9bbddSRamalingam C 
67964e9bbddSRamalingam C static int mei_hdcp_probe(struct mei_cl_device *cldev,
68064e9bbddSRamalingam C 			  const struct mei_cl_device_id *id)
68164e9bbddSRamalingam C {
68264e9bbddSRamalingam C 	int ret;
68364e9bbddSRamalingam C 
68464e9bbddSRamalingam C 	ret = mei_cldev_enable(cldev);
68564e9bbddSRamalingam C 	if (ret < 0)
68664e9bbddSRamalingam C 		dev_err(&cldev->dev, "mei_cldev_enable Failed. %d\n", ret);
68764e9bbddSRamalingam C 
68864e9bbddSRamalingam C 	return ret;
68964e9bbddSRamalingam C }
69064e9bbddSRamalingam C 
69164e9bbddSRamalingam C static int mei_hdcp_remove(struct mei_cl_device *cldev)
69264e9bbddSRamalingam C {
69364e9bbddSRamalingam C 	return mei_cldev_disable(cldev);
69464e9bbddSRamalingam C }
69564e9bbddSRamalingam C 
69664e9bbddSRamalingam C #define MEI_UUID_HDCP GUID_INIT(0xB638AB7E, 0x94E2, 0x4EA2, 0xA5, \
69764e9bbddSRamalingam C 				0x52, 0xD1, 0xC5, 0x4B, 0x62, 0x7F, 0x04)
69864e9bbddSRamalingam C 
69964e9bbddSRamalingam C static struct mei_cl_device_id mei_hdcp_tbl[] = {
70064e9bbddSRamalingam C 	{ .uuid = MEI_UUID_HDCP, .version = MEI_CL_VERSION_ANY },
70164e9bbddSRamalingam C 	{ }
70264e9bbddSRamalingam C };
70364e9bbddSRamalingam C MODULE_DEVICE_TABLE(mei, mei_hdcp_tbl);
70464e9bbddSRamalingam C 
70564e9bbddSRamalingam C static struct mei_cl_driver mei_hdcp_driver = {
70664e9bbddSRamalingam C 	.id_table = mei_hdcp_tbl,
70764e9bbddSRamalingam C 	.name = KBUILD_MODNAME,
70864e9bbddSRamalingam C 	.probe = mei_hdcp_probe,
70964e9bbddSRamalingam C 	.remove	= mei_hdcp_remove,
71064e9bbddSRamalingam C };
71164e9bbddSRamalingam C 
71264e9bbddSRamalingam C module_mei_cl_driver(mei_hdcp_driver);
71364e9bbddSRamalingam C 
71464e9bbddSRamalingam C MODULE_AUTHOR("Intel Corporation");
71564e9bbddSRamalingam C MODULE_LICENSE("GPL");
71664e9bbddSRamalingam C MODULE_DESCRIPTION("MEI HDCP");
717