drm/i915: Gathering the HDCP1.4 routines together
authorRamalingam C <ramalingam.c@intel.com>
Sat, 16 Feb 2019 17:36:48 +0000 (23:06 +0530)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 20 Feb 2019 19:37:58 +0000 (20:37 +0100)
All HDCP1.4 routines are gathered together, followed by the generic
functions those can be extended for HDCP2.2 too.

Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Uma Shankar <uma.shankar@intel.com>
Reviewed-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/1550338640-17470-2-git-send-email-ramalingam.c@intel.com
drivers/gpu/drm/i915/intel_hdcp.c

index ce7ba3a..8cb85b0 100644 (file)
@@ -730,6 +730,65 @@ struct intel_connector *intel_hdcp_to_connector(struct intel_hdcp *hdcp)
        return container_of(hdcp, struct intel_connector, hdcp);
 }
 
+/* Implements Part 3 of the HDCP authorization procedure */
+int intel_hdcp_check_link(struct intel_connector *connector)
+{
+       struct intel_hdcp *hdcp = &connector->hdcp;
+       struct drm_i915_private *dev_priv = connector->base.dev->dev_private;
+       struct intel_digital_port *intel_dig_port = conn_to_dig_port(connector);
+       enum port port = intel_dig_port->base.port;
+       int ret = 0;
+
+       if (!hdcp->shim)
+               return -ENOENT;
+
+       mutex_lock(&hdcp->mutex);
+
+       if (hdcp->value == DRM_MODE_CONTENT_PROTECTION_UNDESIRED)
+               goto out;
+
+       if (!(I915_READ(PORT_HDCP_STATUS(port)) & HDCP_STATUS_ENC)) {
+               DRM_ERROR("%s:%d HDCP check failed: link is not encrypted,%x\n",
+                         connector->base.name, connector->base.base.id,
+                         I915_READ(PORT_HDCP_STATUS(port)));
+               ret = -ENXIO;
+               hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED;
+               schedule_work(&hdcp->prop_work);
+               goto out;
+       }
+
+       if (hdcp->shim->check_link(intel_dig_port)) {
+               if (hdcp->value != DRM_MODE_CONTENT_PROTECTION_UNDESIRED) {
+                       hdcp->value = DRM_MODE_CONTENT_PROTECTION_ENABLED;
+                       schedule_work(&hdcp->prop_work);
+               }
+               goto out;
+       }
+
+       DRM_DEBUG_KMS("[%s:%d] HDCP link failed, retrying authentication\n",
+                     connector->base.name, connector->base.base.id);
+
+       ret = _intel_hdcp_disable(connector);
+       if (ret) {
+               DRM_ERROR("Failed to disable hdcp (%d)\n", ret);
+               hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED;
+               schedule_work(&hdcp->prop_work);
+               goto out;
+       }
+
+       ret = _intel_hdcp_enable(connector);
+       if (ret) {
+               DRM_ERROR("Failed to enable hdcp (%d)\n", ret);
+               hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED;
+               schedule_work(&hdcp->prop_work);
+               goto out;
+       }
+
+out:
+       mutex_unlock(&hdcp->mutex);
+       return ret;
+}
+
 static void intel_hdcp_check_work(struct work_struct *work)
 {
        struct intel_hdcp *hdcp = container_of(to_delayed_work(work),
@@ -866,62 +925,3 @@ void intel_hdcp_atomic_check(struct drm_connector *connector,
                                                   new_state->crtc);
        crtc_state->mode_changed = true;
 }
-
-/* Implements Part 3 of the HDCP authorization procedure */
-int intel_hdcp_check_link(struct intel_connector *connector)
-{
-       struct intel_hdcp *hdcp = &connector->hdcp;
-       struct drm_i915_private *dev_priv = connector->base.dev->dev_private;
-       struct intel_digital_port *intel_dig_port = conn_to_dig_port(connector);
-       enum port port = intel_dig_port->base.port;
-       int ret = 0;
-
-       if (!hdcp->shim)
-               return -ENOENT;
-
-       mutex_lock(&hdcp->mutex);
-
-       if (hdcp->value == DRM_MODE_CONTENT_PROTECTION_UNDESIRED)
-               goto out;
-
-       if (!(I915_READ(PORT_HDCP_STATUS(port)) & HDCP_STATUS_ENC)) {
-               DRM_ERROR("%s:%d HDCP check failed: link is not encrypted,%x\n",
-                         connector->base.name, connector->base.base.id,
-                         I915_READ(PORT_HDCP_STATUS(port)));
-               ret = -ENXIO;
-               hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED;
-               schedule_work(&hdcp->prop_work);
-               goto out;
-       }
-
-       if (hdcp->shim->check_link(intel_dig_port)) {
-               if (hdcp->value != DRM_MODE_CONTENT_PROTECTION_UNDESIRED) {
-                       hdcp->value = DRM_MODE_CONTENT_PROTECTION_ENABLED;
-                       schedule_work(&hdcp->prop_work);
-               }
-               goto out;
-       }
-
-       DRM_DEBUG_KMS("[%s:%d] HDCP link failed, retrying authentication\n",
-                     connector->base.name, connector->base.base.id);
-
-       ret = _intel_hdcp_disable(connector);
-       if (ret) {
-               DRM_ERROR("Failed to disable hdcp (%d)\n", ret);
-               hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED;
-               schedule_work(&hdcp->prop_work);
-               goto out;
-       }
-
-       ret = _intel_hdcp_enable(connector);
-       if (ret) {
-               DRM_DEBUG_KMS("Failed to enable hdcp (%d)\n", ret);
-               hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED;
-               schedule_work(&hdcp->prop_work);
-               goto out;
-       }
-
-out:
-       mutex_unlock(&hdcp->mutex);
-       return ret;
-}