[PATCH 31/43] drm/i915: Implement HDCP2.2 En/Dis-able

Ramalingam C
2018-02-14T14:20:59Z

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

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

diff --git a/drivers/gpu/drm/i915/intel_hdcp.c b/drivers/gpu/drm/i915/intel_hdcp.c
index 6a0506cdefd5..8bf30513713a 100644
--- a/drivers/gpu/drm/i915/intel_hdcp.c
+++ b/drivers/gpu/drm/i915/intel_hdcp.c
@@ -22,6 +22,9 @@
#define HDCP2_LC_RETRY_CNT 3
#define TIME_FOR_ENCRYPT_STATUS_CHANGE 32

+static int _intel_hdcp2_enable(struct intel_hdcp *hdcp);
+static int _intel_hdcp2_disable(struct intel_hdcp *hdcp);
+
static int intel_hdcp_poll_ksv_fifo(struct intel_digital_port *intel_dig_port,
const struct intel_hdcp_shim *shim)
{
@@ -1386,3 +1389,70 @@ static int hdcp2_disable_encryption(struct intel_hdcp *hdcp)

return ret;
}
+
+static int hdcp2_authenticate_and_encrypt(struct intel_hdcp *hdcp)
+{
+ int ret, i, tries = 3;
+
+ for (i = 0; i < tries; i++) {
+ ret = hdcp2_authenticate_sink(hdcp);
+ if (!ret)
+ break;
+
+ /* Clearing the mei hdcp session */
+ hdcp2_deauthenticate_port(hdcp);
+ DRM_DEBUG_KMS("HDCP2.2 Reauth %d of %d\n", i + 1, tries);
+ }
+
+ if (!ret) {
+
+ /*
+ * 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(hdcp);
+ if (ret < 0)
+ DRM_DEBUG_KMS("Encryption Enable Failed. %d\n", ret);
+ }
+
+ return ret;
+}
+
+static int _intel_hdcp2_disable(struct intel_hdcp *hdcp)
+{
+ int ret;
+
+ DRM_ERROR("[%s:%d] HDCP2.2 is being Disabled\n",
+ hdcp->connector->base.name, hdcp->connector->base.base.id);
+
+ ret = hdcp2_disable_encryption(hdcp);
+
+ hdcp2_deauthenticate_port(hdcp);
+
+ return ret;
+}
+
+static int _intel_hdcp2_enable(struct intel_hdcp *hdcp)
+{
+ struct intel_connector *connector = hdcp->connector;
+ int ret;
+
+ DRM_INFO("[%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(hdcp);
+ if (ret) {
+ DRM_ERROR("HDCP2 Enabling Failed. (%d)\n", ret);
+ return ret;
+ }
+
+ DRM_INFO("[%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;
+}