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 299*682932f3SRamalingam C /** 300*682932f3SRamalingam C * mei_hdcp_initiate_locality_check() - Prepare LC_Init 301*682932f3SRamalingam C * @dev: device corresponding to the mei_cl_device 302*682932f3SRamalingam C * @data: Intel HW specific hdcp data 303*682932f3SRamalingam C * @lc_init_data: LC_Init msg output 304*682932f3SRamalingam C * 305*682932f3SRamalingam C * Return: 0 on Success, <0 on Failure 306*682932f3SRamalingam C */ 307*682932f3SRamalingam C static int 308*682932f3SRamalingam C mei_hdcp_initiate_locality_check(struct device *dev, 309*682932f3SRamalingam C struct hdcp_port_data *data, 310*682932f3SRamalingam C struct hdcp2_lc_init *lc_init_data) 311*682932f3SRamalingam C { 312*682932f3SRamalingam C struct wired_cmd_init_locality_check_in lc_init_in = { { 0 } }; 313*682932f3SRamalingam C struct wired_cmd_init_locality_check_out lc_init_out = { { 0 } }; 314*682932f3SRamalingam C struct mei_cl_device *cldev; 315*682932f3SRamalingam C ssize_t byte; 316*682932f3SRamalingam C 317*682932f3SRamalingam C if (!dev || !data || !lc_init_data) 318*682932f3SRamalingam C return -EINVAL; 319*682932f3SRamalingam C 320*682932f3SRamalingam C cldev = to_mei_cl_device(dev); 321*682932f3SRamalingam C 322*682932f3SRamalingam C lc_init_in.header.api_version = HDCP_API_VERSION; 323*682932f3SRamalingam C lc_init_in.header.command_id = WIRED_INIT_LOCALITY_CHECK; 324*682932f3SRamalingam C lc_init_in.header.status = ME_HDCP_STATUS_SUCCESS; 325*682932f3SRamalingam C lc_init_in.header.buffer_len = WIRED_CMD_BUF_LEN_INIT_LOCALITY_CHECK_IN; 326*682932f3SRamalingam C 327*682932f3SRamalingam C lc_init_in.port.integrated_port_type = data->port_type; 328*682932f3SRamalingam C lc_init_in.port.physical_port = mei_get_ddi_index(data->port); 329*682932f3SRamalingam C 330*682932f3SRamalingam C byte = mei_cldev_send(cldev, (u8 *)&lc_init_in, sizeof(lc_init_in)); 331*682932f3SRamalingam C if (byte < 0) { 332*682932f3SRamalingam C dev_dbg(dev, "mei_cldev_send failed. %zd\n", byte); 333*682932f3SRamalingam C return byte; 334*682932f3SRamalingam C } 335*682932f3SRamalingam C 336*682932f3SRamalingam C byte = mei_cldev_recv(cldev, (u8 *)&lc_init_out, sizeof(lc_init_out)); 337*682932f3SRamalingam C if (byte < 0) { 338*682932f3SRamalingam C dev_dbg(dev, "mei_cldev_recv failed. %zd\n", byte); 339*682932f3SRamalingam C return byte; 340*682932f3SRamalingam C } 341*682932f3SRamalingam C 342*682932f3SRamalingam C if (lc_init_out.header.status != ME_HDCP_STATUS_SUCCESS) { 343*682932f3SRamalingam C dev_dbg(dev, "ME cmd 0x%08X Failed. status: 0x%X\n", 344*682932f3SRamalingam C WIRED_INIT_LOCALITY_CHECK, lc_init_out.header.status); 345*682932f3SRamalingam C return -EIO; 346*682932f3SRamalingam C } 347*682932f3SRamalingam C 348*682932f3SRamalingam C lc_init_data->msg_id = HDCP_2_2_LC_INIT; 349*682932f3SRamalingam C memcpy(lc_init_data->r_n, lc_init_out.r_n, HDCP_2_2_RN_LEN); 350*682932f3SRamalingam C 351*682932f3SRamalingam C return 0; 352*682932f3SRamalingam C } 353*682932f3SRamalingam C 354a37fb1e4SRamalingam C static const __attribute__((unused)) 355a37fb1e4SRamalingam C struct i915_hdcp_component_ops mei_hdcp_ops = { 356a37fb1e4SRamalingam C .owner = THIS_MODULE, 357a37fb1e4SRamalingam C .initiate_hdcp2_session = mei_hdcp_initiate_session, 35839b71c2bSRamalingam C .verify_receiver_cert_prepare_km = 35939b71c2bSRamalingam C mei_hdcp_verify_receiver_cert_prepare_km, 360a7dcbed2SRamalingam C .verify_hprime = mei_hdcp_verify_hprime, 3616a1a00a3SRamalingam C .store_pairing_info = mei_hdcp_store_pairing_info, 362*682932f3SRamalingam C .initiate_locality_check = mei_hdcp_initiate_locality_check, 363a37fb1e4SRamalingam C .verify_lprime = NULL, 364a37fb1e4SRamalingam C .get_session_key = NULL, 365a37fb1e4SRamalingam C .repeater_check_flow_prepare_ack = NULL, 366a37fb1e4SRamalingam C .verify_mprime = NULL, 367a37fb1e4SRamalingam C .enable_hdcp_authentication = NULL, 368a37fb1e4SRamalingam C .close_hdcp_session = NULL, 369a37fb1e4SRamalingam C }; 37064e9bbddSRamalingam C 37164e9bbddSRamalingam C static int mei_hdcp_probe(struct mei_cl_device *cldev, 37264e9bbddSRamalingam C const struct mei_cl_device_id *id) 37364e9bbddSRamalingam C { 37464e9bbddSRamalingam C int ret; 37564e9bbddSRamalingam C 37664e9bbddSRamalingam C ret = mei_cldev_enable(cldev); 37764e9bbddSRamalingam C if (ret < 0) 37864e9bbddSRamalingam C dev_err(&cldev->dev, "mei_cldev_enable Failed. %d\n", ret); 37964e9bbddSRamalingam C 38064e9bbddSRamalingam C return ret; 38164e9bbddSRamalingam C } 38264e9bbddSRamalingam C 38364e9bbddSRamalingam C static int mei_hdcp_remove(struct mei_cl_device *cldev) 38464e9bbddSRamalingam C { 38564e9bbddSRamalingam C return mei_cldev_disable(cldev); 38664e9bbddSRamalingam C } 38764e9bbddSRamalingam C 38864e9bbddSRamalingam C #define MEI_UUID_HDCP GUID_INIT(0xB638AB7E, 0x94E2, 0x4EA2, 0xA5, \ 38964e9bbddSRamalingam C 0x52, 0xD1, 0xC5, 0x4B, 0x62, 0x7F, 0x04) 39064e9bbddSRamalingam C 39164e9bbddSRamalingam C static struct mei_cl_device_id mei_hdcp_tbl[] = { 39264e9bbddSRamalingam C { .uuid = MEI_UUID_HDCP, .version = MEI_CL_VERSION_ANY }, 39364e9bbddSRamalingam C { } 39464e9bbddSRamalingam C }; 39564e9bbddSRamalingam C MODULE_DEVICE_TABLE(mei, mei_hdcp_tbl); 39664e9bbddSRamalingam C 39764e9bbddSRamalingam C static struct mei_cl_driver mei_hdcp_driver = { 39864e9bbddSRamalingam C .id_table = mei_hdcp_tbl, 39964e9bbddSRamalingam C .name = KBUILD_MODNAME, 40064e9bbddSRamalingam C .probe = mei_hdcp_probe, 40164e9bbddSRamalingam C .remove = mei_hdcp_remove, 40264e9bbddSRamalingam C }; 40364e9bbddSRamalingam C 40464e9bbddSRamalingam C module_mei_cl_driver(mei_hdcp_driver); 40564e9bbddSRamalingam C 40664e9bbddSRamalingam C MODULE_AUTHOR("Intel Corporation"); 40764e9bbddSRamalingam C MODULE_LICENSE("GPL"); 40864e9bbddSRamalingam C MODULE_DESCRIPTION("MEI HDCP"); 409