]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915: Factor out hdcp->value assignments
authorSean Paul <seanpaul@chromium.org>
Tue, 18 Aug 2020 15:38:54 +0000 (11:38 -0400)
committerRamalingam C <ramalingam.c@intel.com>
Tue, 1 Sep 2020 07:32:33 +0000 (13:02 +0530)
This is a bit of housecleaning for a future patch. Instead of sprinkling
hdcp->value assignments and prop_work scheduling everywhere, introduce a
function to do it for us.

Reviewed-by: Ramalingam C <ramalingam.c@intel.com>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191203173638.94919-7-sean@poorly.run
Link: https://patchwork.freedesktop.org/patch/msgid/20191212190230.188505-7-sean@poorly.run
Link: https://patchwork.freedesktop.org/patch/msgid/20200117193103.156821-7-sean@poorly.run
Link: https://patchwork.freedesktop.org/patch/msgid/20200218220242.107265-7-sean@poorly.run
Link: https://patchwork.freedesktop.org/patch/msgid/20200305201236.152307-7-sean@poorly.run
Link: https://patchwork.freedesktop.org/patch/msgid/20200429195502.39919-7-sean@poorly.run
Link: https://patchwork.freedesktop.org/patch/msgid/20200623155907.22961-7-sean@poorly.run
Changes in v2:
-None
Changes in v3:
-None
Changes in v4:
-Rebased on top of drm_* logging changes
Changes in v5:
-Change WARN_ON to drm_WARN_ON
Changes in v6:
-None
Changes in v7:
-None
Changes in v8:
-None

Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200818153910.27894-7-sean@poorly.run
drivers/gpu/drm/i915/display/intel_hdcp.c

index 321d67f79ebc58a7fc1dced7eb26eb97a5819dd3..b8608602773c9130abc647356d0b8ac3d1021c84 100644 (file)
@@ -867,6 +867,21 @@ static struct intel_connector *intel_hdcp_to_connector(struct intel_hdcp *hdcp)
        return container_of(hdcp, struct intel_connector, hdcp);
 }
 
+static void intel_hdcp_update_value(struct intel_connector *connector,
+                                   u64 value, bool update_property)
+{
+       struct intel_hdcp *hdcp = &connector->hdcp;
+
+       drm_WARN_ON(connector->base.dev, !mutex_is_locked(&hdcp->mutex));
+
+       if (hdcp->value == value)
+               return;
+
+       hdcp->value = value;
+       if (update_property)
+               schedule_work(&hdcp->prop_work);
+}
+
 /* Implements Part 3 of the HDCP authorization procedure */
 static int intel_hdcp_check_link(struct intel_connector *connector)
 {
@@ -894,15 +909,16 @@ static int intel_hdcp_check_link(struct intel_connector *connector)
                        connector->base.name, connector->base.base.id,
                        intel_de_read(dev_priv, HDCP_STATUS(dev_priv, cpu_transcoder, port)));
                ret = -ENXIO;
-               hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED;
-               schedule_work(&hdcp->prop_work);
+               intel_hdcp_update_value(connector,
+                                       DRM_MODE_CONTENT_PROTECTION_DESIRED,
+                                       true);
                goto out;
        }
 
        if (hdcp->shim->check_link(dig_port)) {
                if (hdcp->value != DRM_MODE_CONTENT_PROTECTION_UNDESIRED) {
-                       hdcp->value = DRM_MODE_CONTENT_PROTECTION_ENABLED;
-                       schedule_work(&hdcp->prop_work);
+                       intel_hdcp_update_value(connector,
+                               DRM_MODE_CONTENT_PROTECTION_ENABLED, true);
                }
                goto out;
        }
@@ -914,16 +930,18 @@ static int intel_hdcp_check_link(struct intel_connector *connector)
        ret = _intel_hdcp_disable(connector);
        if (ret) {
                drm_err(&dev_priv->drm, "Failed to disable hdcp (%d)\n", ret);
-               hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED;
-               schedule_work(&hdcp->prop_work);
+               intel_hdcp_update_value(connector,
+                                       DRM_MODE_CONTENT_PROTECTION_DESIRED,
+                                       true);
                goto out;
        }
 
        ret = _intel_hdcp_enable(connector);
        if (ret) {
                drm_err(&dev_priv->drm, "Failed to enable hdcp (%d)\n", ret);
-               hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED;
-               schedule_work(&hdcp->prop_work);
+               intel_hdcp_update_value(connector,
+                                       DRM_MODE_CONTENT_PROTECTION_DESIRED,
+                                       true);
                goto out;
        }
 
@@ -1759,16 +1777,18 @@ static int intel_hdcp2_check_link(struct intel_connector *connector)
                        "HDCP2.2 link stopped the encryption, %x\n",
                        intel_de_read(dev_priv, HDCP2_STATUS(dev_priv, cpu_transcoder, port)));
                ret = -ENXIO;
-               hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED;
-               schedule_work(&hdcp->prop_work);
+               intel_hdcp_update_value(connector,
+                                       DRM_MODE_CONTENT_PROTECTION_DESIRED,
+                                       true);
                goto out;
        }
 
        ret = hdcp->shim->check_2_2_link(dig_port);
        if (ret == HDCP_LINK_PROTECTED) {
                if (hdcp->value != DRM_MODE_CONTENT_PROTECTION_UNDESIRED) {
-                       hdcp->value = DRM_MODE_CONTENT_PROTECTION_ENABLED;
-                       schedule_work(&hdcp->prop_work);
+                       intel_hdcp_update_value(connector,
+                                       DRM_MODE_CONTENT_PROTECTION_ENABLED,
+                                       true);
                }
                goto out;
        }
@@ -1781,8 +1801,9 @@ static int intel_hdcp2_check_link(struct intel_connector *connector)
                            "HDCP2.2 Downstream topology change\n");
                ret = hdcp2_authenticate_repeater_topology(connector);
                if (!ret) {
-                       hdcp->value = DRM_MODE_CONTENT_PROTECTION_ENABLED;
-                       schedule_work(&hdcp->prop_work);
+                       intel_hdcp_update_value(connector,
+                                       DRM_MODE_CONTENT_PROTECTION_ENABLED,
+                                       true);
                        goto out;
                }
                drm_dbg_kms(&dev_priv->drm,
@@ -1800,8 +1821,8 @@ static int intel_hdcp2_check_link(struct intel_connector *connector)
                drm_err(&dev_priv->drm,
                        "[%s:%d] Failed to disable hdcp2.2 (%d)\n",
                        connector->base.name, connector->base.base.id, ret);
-               hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED;
-               schedule_work(&hdcp->prop_work);
+               intel_hdcp_update_value(connector,
+                               DRM_MODE_CONTENT_PROTECTION_DESIRED, true);
                goto out;
        }
 
@@ -1811,8 +1832,9 @@ static int intel_hdcp2_check_link(struct intel_connector *connector)
                            "[%s:%d] Failed to enable hdcp2.2 (%d)\n",
                            connector->base.name, connector->base.base.id,
                            ret);
-               hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED;
-               schedule_work(&hdcp->prop_work);
+               intel_hdcp_update_value(connector,
+                                       DRM_MODE_CONTENT_PROTECTION_DESIRED,
+                                       true);
                goto out;
        }
 
@@ -2055,8 +2077,9 @@ int intel_hdcp_enable(struct intel_connector *connector,
 
        if (!ret) {
                schedule_delayed_work(&hdcp->check_work, check_link_interval);
-               hdcp->value = DRM_MODE_CONTENT_PROTECTION_ENABLED;
-               schedule_work(&hdcp->prop_work);
+               intel_hdcp_update_value(connector,
+                                       DRM_MODE_CONTENT_PROTECTION_ENABLED,
+                                       true);
        }
 
        mutex_unlock(&hdcp->mutex);
@@ -2074,7 +2097,9 @@ int intel_hdcp_disable(struct intel_connector *connector)
        mutex_lock(&hdcp->mutex);
 
        if (hdcp->value != DRM_MODE_CONTENT_PROTECTION_UNDESIRED) {
-               hdcp->value = DRM_MODE_CONTENT_PROTECTION_UNDESIRED;
+               intel_hdcp_update_value(connector,
+                                       DRM_MODE_CONTENT_PROTECTION_UNDESIRED,
+                                       false);
                if (hdcp->hdcp2_encrypted)
                        ret = _intel_hdcp2_disable(connector);
                else if (hdcp->hdcp_encrypted)