diff mbox

[v6,28/35] misc/mei/hdcp: Store the HDCP Pairing info

Message ID 1531538117-1606-29-git-send-email-ramalingam.c@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ramalingam C July 14, 2018, 3:15 a.m. UTC
Provides Pairing info to ME to store.

Pairing is a process to fast track the subsequent authentication
with the same HDCP sink.

On Success, received HDCP pairing info is stored in non-volatile
memory of ME.

v2:
  Rebased.
v3:
  cldev is passed as first parameter [Tomas]
  Redundant comments and cast are removed [Tomas]
v4:
  %zd for ssize_t [Alexander]
  %s/return -1/return -EIO [Alexander]
  Style fixed [Uma]
v5:
  Rebased.
v6:
  No change.

Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
---
 drivers/misc/mei/hdcp/mei_hdcp.c | 63 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 62 insertions(+), 1 deletion(-)

Comments

Shankar, Uma Aug. 1, 2018, 1:23 p.m. UTC | #1
>-----Original Message-----
>From: C, Ramalingam
>Sent: Saturday, July 14, 2018 8:45 AM
>To: intel-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org;
>daniel@ffwll.ch; seanpaul@chromium.org; Winkler, Tomas
><tomas.winkler@intel.com>; Usyskin, Alexander <alexander.usyskin@intel.com>;
>Shankar, Uma <uma.shankar@intel.com>
>Cc: Sharma, Shashank <shashank.sharma@intel.com>; C, Ramalingam
><ramalingam.c@intel.com>
>Subject: [PATCH v6 28/35] misc/mei/hdcp: Store the HDCP Pairing info
>
>Provides Pairing info to ME to store.
>
>Pairing is a process to fast track the subsequent authentication with the same
>HDCP sink.
>
>On Success, received HDCP pairing info is stored in non-volatile memory of ME.
>
>v2:
>  Rebased.
>v3:
>  cldev is passed as first parameter [Tomas]
>  Redundant comments and cast are removed [Tomas]
>v4:
>  %zd for ssize_t [Alexander]
>  %s/return -1/return -EIO [Alexander]
>  Style fixed [Uma]
>v5:
>  Rebased.
>v6:
>  No change.
>

Looks ok to me.
Reviewed-by: Uma Shankar <uma.shankar@intel.com>

>Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
>---
> drivers/misc/mei/hdcp/mei_hdcp.c | 63
>+++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 62 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/misc/mei/hdcp/mei_hdcp.c
>b/drivers/misc/mei/hdcp/mei_hdcp.c
>index d455d4e54f46..4349eff4d0fb 100644
>--- a/drivers/misc/mei/hdcp/mei_hdcp.c
>+++ b/drivers/misc/mei/hdcp/mei_hdcp.c
>@@ -246,13 +246,74 @@ static int mei_verify_hprime(struct mei_cl_device
>*cldev,
> 	return 0;
> }
>
>+/*
>+ * mei_store_pairing_info:
>+ *	Function to store pairing info received from panel
>+ *
>+ * cldev		: Pointer for mei client device
>+ * data			: Intel HW specific Data
>+ * pairing_info		: Pointer for AKE_Send_Pairing_Info
>+ *
>+ * Returns 0 on Success, <0 on Failure
>+ */
>+static int
>+mei_store_pairing_info(struct mei_cl_device *cldev,
>+		       struct mei_hdcp_data *data,
>+		       struct hdcp2_ake_send_pairing_info *pairing_info) {
>+	struct wired_cmd_ake_send_pairing_info_in pairing_info_in = { { 0 } };
>+	struct wired_cmd_ake_send_pairing_info_out pairing_info_out = { { 0 } };
>+	struct device *dev;
>+	ssize_t byte;
>+
>+	if (!data || !pairing_info)
>+		return -EINVAL;
>+
>+	dev = &cldev->dev;
>+
>+	pairing_info_in.header.api_version = HDCP_API_VERSION;
>+	pairing_info_in.header.command_id =
>WIRED_AKE_SEND_PAIRING_INFO;
>+	pairing_info_in.header.status = ME_HDCP_STATUS_SUCCESS;
>+	pairing_info_in.header.buffer_len =
>+
>	WIRED_CMD_BUF_LEN_SEND_PAIRING_INFO_IN;
>+
>+	pairing_info_in.port.integrated_port_type = data->port_type;
>+	pairing_info_in.port.physical_port = data->port;
>+
>+	memcpy(pairing_info_in.e_kh_km, pairing_info->e_kh_km,
>+	       sizeof(pairing_info_in.e_kh_km));
>+
>+	byte = mei_cldev_send(cldev, (u8 *)&pairing_info_in,
>+			      sizeof(pairing_info_in));
>+	if (byte < 0) {
>+		dev_dbg(dev, "mei_cldev_send failed. %zd\n", byte);
>+		return byte;
>+	}
>+
>+	byte = mei_cldev_recv(cldev, (u8 *)&pairing_info_out,
>+			      sizeof(pairing_info_out));
>+	if (byte < 0) {
>+		dev_dbg(dev, "mei_cldev_recv failed. %zd\n", byte);
>+		return byte;
>+	}
>+
>+	if (pairing_info_out.header.status != ME_HDCP_STATUS_SUCCESS) {
>+		dev_dbg(dev, "ME cmd 0x%08X failed. Status: 0x%X\n",
>+			WIRED_AKE_SEND_PAIRING_INFO,
>+			pairing_info_out.header.status);
>+		return -EIO;
>+	}
>+
>+	return 0;
>+}
>+
> struct i915_hdcp_component_ops mei_hdcp_component_ops = {
> 	.owner					= THIS_MODULE,
> 	.initiate_hdcp2_session			= mei_initiate_hdcp2_session,
> 	.verify_receiver_cert_prepare_km	=
> 					mei_verify_receiver_cert_prepare_km,
> 	.verify_hprime				= mei_verify_hprime,
>-	.store_pairing_info			= NULL,
>+	.store_pairing_info			= mei_store_pairing_info,
> 	.initiate_locality_check		= NULL,
> 	.verify_lprime				= NULL,
> 	.get_session_key			= NULL,
>--
>2.7.4
diff mbox

Patch

diff --git a/drivers/misc/mei/hdcp/mei_hdcp.c b/drivers/misc/mei/hdcp/mei_hdcp.c
index d455d4e54f46..4349eff4d0fb 100644
--- a/drivers/misc/mei/hdcp/mei_hdcp.c
+++ b/drivers/misc/mei/hdcp/mei_hdcp.c
@@ -246,13 +246,74 @@  static int mei_verify_hprime(struct mei_cl_device *cldev,
 	return 0;
 }
 
+/*
+ * mei_store_pairing_info:
+ *	Function to store pairing info received from panel
+ *
+ * cldev		: Pointer for mei client device
+ * data			: Intel HW specific Data
+ * pairing_info		: Pointer for AKE_Send_Pairing_Info
+ *
+ * Returns 0 on Success, <0 on Failure
+ */
+static int
+mei_store_pairing_info(struct mei_cl_device *cldev,
+		       struct mei_hdcp_data *data,
+		       struct hdcp2_ake_send_pairing_info *pairing_info)
+{
+	struct wired_cmd_ake_send_pairing_info_in pairing_info_in = { { 0 } };
+	struct wired_cmd_ake_send_pairing_info_out pairing_info_out = { { 0 } };
+	struct device *dev;
+	ssize_t byte;
+
+	if (!data || !pairing_info)
+		return -EINVAL;
+
+	dev = &cldev->dev;
+
+	pairing_info_in.header.api_version = HDCP_API_VERSION;
+	pairing_info_in.header.command_id = WIRED_AKE_SEND_PAIRING_INFO;
+	pairing_info_in.header.status = ME_HDCP_STATUS_SUCCESS;
+	pairing_info_in.header.buffer_len =
+					WIRED_CMD_BUF_LEN_SEND_PAIRING_INFO_IN;
+
+	pairing_info_in.port.integrated_port_type = data->port_type;
+	pairing_info_in.port.physical_port = data->port;
+
+	memcpy(pairing_info_in.e_kh_km, pairing_info->e_kh_km,
+	       sizeof(pairing_info_in.e_kh_km));
+
+	byte = mei_cldev_send(cldev, (u8 *)&pairing_info_in,
+			      sizeof(pairing_info_in));
+	if (byte < 0) {
+		dev_dbg(dev, "mei_cldev_send failed. %zd\n", byte);
+		return byte;
+	}
+
+	byte = mei_cldev_recv(cldev, (u8 *)&pairing_info_out,
+			      sizeof(pairing_info_out));
+	if (byte < 0) {
+		dev_dbg(dev, "mei_cldev_recv failed. %zd\n", byte);
+		return byte;
+	}
+
+	if (pairing_info_out.header.status != ME_HDCP_STATUS_SUCCESS) {
+		dev_dbg(dev, "ME cmd 0x%08X failed. Status: 0x%X\n",
+			WIRED_AKE_SEND_PAIRING_INFO,
+			pairing_info_out.header.status);
+		return -EIO;
+	}
+
+	return 0;
+}
+
 struct i915_hdcp_component_ops mei_hdcp_component_ops = {
 	.owner					= THIS_MODULE,
 	.initiate_hdcp2_session			= mei_initiate_hdcp2_session,
 	.verify_receiver_cert_prepare_km	=
 					mei_verify_receiver_cert_prepare_km,
 	.verify_hprime				= mei_verify_hprime,
-	.store_pairing_info			= NULL,
+	.store_pairing_info			= mei_store_pairing_info,
 	.initiate_locality_check		= NULL,
 	.verify_lprime				= NULL,
 	.get_session_key			= NULL,