diff mbox

[v3,26/40] drm/i915: Implement HDCP2.2 En/Dis-able

Message ID 1522763873-23041-27-git-send-email-ramalingam.c@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ramalingam C April 3, 2018, 1:57 p.m. UTC
Implements a sequence of enabling and disabling the HDCP2.2
(auth and encryption).

v2:
  Rebased.
v3:
  No Changes.

Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
---
 drivers/gpu/drm/i915/intel_hdcp.c | 75 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)

Comments

Shankar, Uma May 14, 2018, 9:30 a.m. UTC | #1
>-----Original Message-----

>From: dri-devel [mailto:dri-devel-bounces@lists.freedesktop.org] On Behalf Of

>Ramalingam C

>Sent: Tuesday, April 3, 2018 7:28 PM

>To: intel-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org;

>seanpaul@chromium.org; daniel@ffwll.ch; chris@chris-wilson.co.uk;

>jani.nikula@linux.intel.com; Winkler, Tomas <tomas.winkler@intel.com>;

>Usyskin, Alexander <alexander.usyskin@intel.com>

>Cc: Vivi, Rodrigo <rodrigo.vivi@intel.com>

>Subject: [PATCH v3 26/40] drm/i915: Implement HDCP2.2 En/Dis-able


May be calling enable/disable sequence separately will be better :)

>

>Implements a sequence of enabling and disabling the HDCP2.2 (auth and

>encryption).

>

>v2:

>  Rebased.

>v3:

>  No Changes.

>

>Signed-off-by: Ramalingam C <ramalingam.c@intel.com>

>---

> drivers/gpu/drm/i915/intel_hdcp.c | 75

>+++++++++++++++++++++++++++++++++++++++

> 1 file changed, 75 insertions(+)

>

>diff --git a/drivers/gpu/drm/i915/intel_hdcp.c

>b/drivers/gpu/drm/i915/intel_hdcp.c

>index 91cac643f083..005627746ca5 100644

>--- a/drivers/gpu/drm/i915/intel_hdcp.c

>+++ b/drivers/gpu/drm/i915/intel_hdcp.c

>@@ -21,6 +21,9 @@

> #define HDCP2_LC_RETRY_CNT		3

> #define TIME_FOR_ENCRYPT_STATUS_CHANGE	32

>

>+static int _intel_hdcp2_enable(struct intel_connector *connector);

>+static int _intel_hdcp2_disable(struct intel_connector *connector);

>+

> static int intel_hdcp_poll_ksv_fifo(struct intel_digital_port *intel_dig_port,

> 				    const struct intel_hdcp_shim *shim)  { @@ -

>1384,3 +1387,75 @@ static int hdcp2_disable_encryption(struct intel_connector

>*connector)

>

> 	return ret;

> }

>+

>+static int hdcp2_authenticate_and_encrypt(struct intel_connector

>+*connector) {

>+	int ret, i, tries = 3;

>+

>+	for (i = 0; i < tries; i++) {

>+		ret = hdcp2_authenticate_sink(connector);

>+		if (!ret)

>+			break;

>+

>+		/* Clearing the mei hdcp session */

>+		hdcp2_deauthenticate_port(&connector->hdcp);

>+		DRM_DEBUG_KMS("HDCP2.2 Auth %d of %d Failed.(%d)\n",

>+			      i + 1, tries, ret);

>+	}

>+

>+	if (i != tries) {

>+

>+		/*

>+		 * Ensuring the required 200mSec min time interval between

>+		 * Session Key Exchange and encryption.

>+		 */

>+		msleep(HDCP_2_2_DELAY_BEFORE_ENCRYPTION_EN);

>+		ret = hdcp2_enable_encryption(connector);

>+		if (ret < 0) {

>+			DRM_DEBUG_KMS("Encryption Enable Failed.(%d)\n",

>ret);

>+			hdcp2_deauthenticate_port(&connector->hdcp);

>+		}

>+	}

>+

>+	return ret;

>+}

>+

>+static int _intel_hdcp2_disable(struct intel_connector *connector) {

>+	int ret;

>+

>+	DRM_DEBUG_KMS("[%s:%d] HDCP2.2 is being Disabled\n",

>+		      connector->base.name, connector->base.base.id);

>+

>+	ret = hdcp2_disable_encryption(connector);


Check for return and print a message.

>+

>+	hdcp2_deauthenticate_port(&connector->hdcp);

>+

>+	return ret;

>+}

>+

>+static int _intel_hdcp2_enable(struct intel_connector *connector) {

>+	struct intel_hdcp *hdcp = &connector->hdcp;

>+	int ret;

>+

>+	DRM_DEBUG_KMS("[%s:%d] HDCP2.2 is being enabled. Type: %d\n",

>+		      connector->base.name, connector->base.base.id,

>+		      hdcp->content_type);

>+

>+	ret = hdcp2_authenticate_and_encrypt(connector);

>+	if (ret) {

>+		DRM_ERROR("HDCP2 Type%d  Enabling Failed. (%d)\n",

>+			   hdcp->content_type, ret);

>+		return ret;

>+	}

>+

>+	DRM_DEBUG_KMS("[%s:%d] HDCP2.2 is enabled. Type %d\n",

>+		      connector->base.name, connector->base.base.id,

>+		      hdcp->content_type);

>+

>+	hdcp->hdcp_value = DRM_MODE_CONTENT_PROTECTION_ENABLED;

>+	schedule_work(&hdcp->hdcp_prop_work);

>+

>+	return 0;

>+}

>--

>2.7.4

>

>_______________________________________________

>dri-devel mailing list

>dri-devel@lists.freedesktop.org

;>https://lists.freedesktop.org/mailman/listinfo/dri-devel
Ramalingam C May 17, 2018, 1:16 p.m. UTC | #2
On Monday 14 May 2018 03:00 PM, Shankar, Uma wrote:
>
>> -----Original Message-----
>> From: dri-devel [mailto:dri-devel-bounces@lists.freedesktop.org] On Behalf Of
>> Ramalingam C
>> Sent: Tuesday, April 3, 2018 7:28 PM
>> To: intel-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org;
>> seanpaul@chromium.org; daniel@ffwll.ch; chris@chris-wilson.co.uk;
>> jani.nikula@linux.intel.com; Winkler, Tomas <tomas.winkler@intel.com>;
>> Usyskin, Alexander <alexander.usyskin@intel.com>
>> Cc: Vivi, Rodrigo <rodrigo.vivi@intel.com>
>> Subject: [PATCH v3 26/40] drm/i915: Implement HDCP2.2 En/Dis-able
> May be calling enable/disable sequence separately will be better :)
>
>> Implements a sequence of enabling and disabling the HDCP2.2 (auth and
>> encryption).
>>
>> v2:
>>   Rebased.
>> v3:
>>   No Changes.
>>
>> Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
>> ---
>> drivers/gpu/drm/i915/intel_hdcp.c | 75
>> +++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 75 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/i915/intel_hdcp.c
>> b/drivers/gpu/drm/i915/intel_hdcp.c
>> index 91cac643f083..005627746ca5 100644
>> --- a/drivers/gpu/drm/i915/intel_hdcp.c
>> +++ b/drivers/gpu/drm/i915/intel_hdcp.c
>> @@ -21,6 +21,9 @@
>> #define HDCP2_LC_RETRY_CNT		3
>> #define TIME_FOR_ENCRYPT_STATUS_CHANGE	32
>>
>> +static int _intel_hdcp2_enable(struct intel_connector *connector);
>> +static int _intel_hdcp2_disable(struct intel_connector *connector);
>> +
>> static int intel_hdcp_poll_ksv_fifo(struct intel_digital_port *intel_dig_port,
>> 				    const struct intel_hdcp_shim *shim)  { @@ -
>> 1384,3 +1387,75 @@ static int hdcp2_disable_encryption(struct intel_connector
>> *connector)
>>
>> 	return ret;
>> }
>> +
>> +static int hdcp2_authenticate_and_encrypt(struct intel_connector
>> +*connector) {
>> +	int ret, i, tries = 3;
>> +
>> +	for (i = 0; i < tries; i++) {
>> +		ret = hdcp2_authenticate_sink(connector);
>> +		if (!ret)
>> +			break;
>> +
>> +		/* Clearing the mei hdcp session */
>> +		hdcp2_deauthenticate_port(&connector->hdcp);
>> +		DRM_DEBUG_KMS("HDCP2.2 Auth %d of %d Failed.(%d)\n",
>> +			      i + 1, tries, ret);
>> +	}
>> +
>> +	if (i != tries) {
>> +
>> +		/*
>> +		 * Ensuring the required 200mSec min time interval between
>> +		 * Session Key Exchange and encryption.
>> +		 */
>> +		msleep(HDCP_2_2_DELAY_BEFORE_ENCRYPTION_EN);
>> +		ret = hdcp2_enable_encryption(connector);
>> +		if (ret < 0) {
>> +			DRM_DEBUG_KMS("Encryption Enable Failed.(%d)\n",
>> ret);
>> +			hdcp2_deauthenticate_port(&connector->hdcp);
>> +		}
>> +	}
>> +
>> +	return ret;
>> +}
>> +
>> +static int _intel_hdcp2_disable(struct intel_connector *connector) {
>> +	int ret;
>> +
>> +	DRM_DEBUG_KMS("[%s:%d] HDCP2.2 is being Disabled\n",
>> +		      connector->base.name, connector->base.base.id);
>> +
>> +	ret = hdcp2_disable_encryption(connector);
> Check for return and print a message.
Caller will handle the error cases I guess. So we will just pass the 
error here.
>
>> +
>> +	hdcp2_deauthenticate_port(&connector->hdcp);
>> +
>> +	return ret;
>> +}
>> +
>> +static int _intel_hdcp2_enable(struct intel_connector *connector) {
>> +	struct intel_hdcp *hdcp = &connector->hdcp;
>> +	int ret;
>> +
>> +	DRM_DEBUG_KMS("[%s:%d] HDCP2.2 is being enabled. Type: %d\n",
>> +		      connector->base.name, connector->base.base.id,
>> +		      hdcp->content_type);
>> +
>> +	ret = hdcp2_authenticate_and_encrypt(connector);
>> +	if (ret) {
>> +		DRM_ERROR("HDCP2 Type%d  Enabling Failed. (%d)\n",
>> +			   hdcp->content_type, ret);
>> +		return ret;
>> +	}
>> +
>> +	DRM_DEBUG_KMS("[%s:%d] HDCP2.2 is enabled. Type %d\n",
>> +		      connector->base.name, connector->base.base.id,
>> +		      hdcp->content_type);
>> +
>> +	hdcp->hdcp_value = DRM_MODE_CONTENT_PROTECTION_ENABLED;
>> +	schedule_work(&hdcp->hdcp_prop_work);
>> +
>> +	return 0;
>> +}
>> --
>> 2.7.4
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
> ;>https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_hdcp.c b/drivers/gpu/drm/i915/intel_hdcp.c
index 91cac643f083..005627746ca5 100644
--- a/drivers/gpu/drm/i915/intel_hdcp.c
+++ b/drivers/gpu/drm/i915/intel_hdcp.c
@@ -21,6 +21,9 @@ 
 #define HDCP2_LC_RETRY_CNT		3
 #define TIME_FOR_ENCRYPT_STATUS_CHANGE	32
 
+static int _intel_hdcp2_enable(struct intel_connector *connector);
+static int _intel_hdcp2_disable(struct intel_connector *connector);
+
 static int intel_hdcp_poll_ksv_fifo(struct intel_digital_port *intel_dig_port,
 				    const struct intel_hdcp_shim *shim)
 {
@@ -1384,3 +1387,75 @@  static int hdcp2_disable_encryption(struct intel_connector *connector)
 
 	return ret;
 }
+
+static int hdcp2_authenticate_and_encrypt(struct intel_connector *connector)
+{
+	int ret, i, tries = 3;
+
+	for (i = 0; i < tries; i++) {
+		ret = hdcp2_authenticate_sink(connector);
+		if (!ret)
+			break;
+
+		/* Clearing the mei hdcp session */
+		hdcp2_deauthenticate_port(&connector->hdcp);
+		DRM_DEBUG_KMS("HDCP2.2 Auth %d of %d Failed.(%d)\n",
+			      i + 1, tries, ret);
+	}
+
+	if (i != tries) {
+
+		/*
+		 * Ensuring the required 200mSec min time interval between
+		 * Session Key Exchange and encryption.
+		 */
+		msleep(HDCP_2_2_DELAY_BEFORE_ENCRYPTION_EN);
+		ret = hdcp2_enable_encryption(connector);
+		if (ret < 0) {
+			DRM_DEBUG_KMS("Encryption Enable Failed.(%d)\n", ret);
+			hdcp2_deauthenticate_port(&connector->hdcp);
+		}
+	}
+
+	return ret;
+}
+
+static int _intel_hdcp2_disable(struct intel_connector *connector)
+{
+	int ret;
+
+	DRM_DEBUG_KMS("[%s:%d] HDCP2.2 is being Disabled\n",
+		      connector->base.name, connector->base.base.id);
+
+	ret = hdcp2_disable_encryption(connector);
+
+	hdcp2_deauthenticate_port(&connector->hdcp);
+
+	return ret;
+}
+
+static int _intel_hdcp2_enable(struct intel_connector *connector)
+{
+	struct intel_hdcp *hdcp = &connector->hdcp;
+	int ret;
+
+	DRM_DEBUG_KMS("[%s:%d] HDCP2.2 is being enabled. Type: %d\n",
+		      connector->base.name, connector->base.base.id,
+		      hdcp->content_type);
+
+	ret = hdcp2_authenticate_and_encrypt(connector);
+	if (ret) {
+		DRM_ERROR("HDCP2 Type%d  Enabling Failed. (%d)\n",
+			   hdcp->content_type, ret);
+		return ret;
+	}
+
+	DRM_DEBUG_KMS("[%s:%d] HDCP2.2 is enabled. Type %d\n",
+		      connector->base.name, connector->base.base.id,
+		      hdcp->content_type);
+
+	hdcp->hdcp_value = DRM_MODE_CONTENT_PROTECTION_ENABLED;
+	schedule_work(&hdcp->hdcp_prop_work);
+
+	return 0;
+}