intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Mark Yacoub <markyacoub@chromium.org>
To: David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>
Cc: Jani Nikula <jani.nikula@intel.com>,
	Mark Yacoub <markyacoub@chromium.org>,
	intel-gfx@lists.freedesktop.org, dianders@chromium.org,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	seanpaul@chromium.org, Rodrigo Vivi <rodrigo.vivi@intel.com>,
	freedreno@lists.freedesktop.org
Subject: [Intel-gfx] [PATCH v8 03/10] drm/hdcp: Update property value on content type and user changes
Date: Fri, 31 Mar 2023 18:12:05 -0400	[thread overview]
Message-ID: <20230331221213.1691997-4-markyacoub@google.com> (raw)
In-Reply-To: <20230331221213.1691997-1-markyacoub@google.com>

From: Sean Paul <seanpaul@chromium.org>

Update the connector's property value in 2 cases which were
previously missed:

1- Content type changes. The value should revert back to DESIRED from
   ENABLED in case the driver must re-authenticate the link due to the
   new content type.

2- Userspace sets value to DESIRED while ENABLED. In this case, the
   value should be reset immediately to ENABLED since the link is
   actively being encrypted.

To accommodate these changes, I've split up the conditionals to make
things a bit more clear (as much as one can with this mess of state).

Acked-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Mark Yacoub <markyacoub@chromium.org>

---
Changes in v2:
-None
Changes in v3:
-Fixed indentation issue identified by 0-day
Changes in v4:
-None
Changes in v5:
-None
Changes in v6:
-Rebased: modifications in drm_hdcp_helper.c instead of drm_hdcp.c
Changes in v7:
-Rebased as function name has changed.
Changes in v8:
-None

 drivers/gpu/drm/display/drm_hdcp_helper.c | 29 +++++++++++++++--------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/display/drm_hdcp_helper.c b/drivers/gpu/drm/display/drm_hdcp_helper.c
index 34baf2b97cd87..3ee1a6ae26c53 100644
--- a/drivers/gpu/drm/display/drm_hdcp_helper.c
+++ b/drivers/gpu/drm/display/drm_hdcp_helper.c
@@ -480,21 +480,30 @@ bool drm_hdcp_has_changed(struct drm_connector *connector,
 		return true;
 
 	/*
-	 * Nothing to do if content type is unchanged and one of:
-	 *  - state didn't change
-	 *  - HDCP was activated since the last commit
-	 *  - attempting to set to desired while already enabled
+	 * Content type changes require an HDCP disable/enable cycle.
 	 */
-	if (old_hdcp == new_hdcp ||
-	    (old_hdcp == DRM_MODE_CONTENT_PROTECTION_DESIRED &&
+	if (new_conn_state->hdcp_content_type !=
+	    old_conn_state->hdcp_content_type) {
+		new_conn_state->content_protection =
+			DRM_MODE_CONTENT_PROTECTION_DESIRED;
+		return true;
+	}
+
+	/*
+	 * Ignore meaningless state changes:
+ 	 *  - HDCP was activated since the last commit
+	 *  - Attempting to set to desired while already enabled
+ 	 */
+	if ((old_hdcp == DRM_MODE_CONTENT_PROTECTION_DESIRED &&
 	     new_hdcp == DRM_MODE_CONTENT_PROTECTION_ENABLED) ||
 	    (old_hdcp == DRM_MODE_CONTENT_PROTECTION_ENABLED &&
 	     new_hdcp == DRM_MODE_CONTENT_PROTECTION_DESIRED)) {
-		if (old_conn_state->hdcp_content_type ==
-		    new_conn_state->hdcp_content_type)
-			return false;
+		new_conn_state->content_protection =
+			DRM_MODE_CONTENT_PROTECTION_ENABLED;
+		return false;
 	}
 
-	return true;
+	/* Finally, if state changes, we need action */
+	return old_hdcp != new_hdcp;
 }
 EXPORT_SYMBOL(drm_hdcp_has_changed);
-- 
2.40.0.348.gf938b09366-goog


  parent reply	other threads:[~2023-03-31 22:12 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-31 22:12 [Intel-gfx] [PATCH v8 00/10] drm/hdcp: Pull HDCP auth/exchange/check into helpers Mark Yacoub
2023-03-31 22:12 ` [Intel-gfx] [PATCH v8 01/10] drm/hdcp: Add drm_hdcp_atomic_check() Mark Yacoub
2023-03-31 22:12 ` [Intel-gfx] [PATCH v8 02/10] drm/hdcp: Avoid changing crtc state in hdcp atomic check Mark Yacoub
2023-03-31 22:12 ` Mark Yacoub [this message]
2023-03-31 22:12 ` [Intel-gfx] [PATCH v8 04/10] drm/hdcp: Expand HDCP helper library for enable/disable/check Mark Yacoub
2023-04-01  0:19   ` kernel test robot
2023-04-03  6:38   ` Kandpal, Suraj
2023-04-07 16:32   ` Dmitry Baryshkov
2023-03-31 22:12 ` [Intel-gfx] [PATCH v8 05/10] drm/i915/hdcp: Consolidate HDCP setup/state cache Mark Yacoub
2023-03-31 22:12 ` [Intel-gfx] [PATCH v8 06/10] drm/i915/hdcp: Retain hdcp_capable return codes Mark Yacoub
2023-04-03  6:41   ` Kandpal, Suraj
2023-04-03  6:45     ` Kandpal, Suraj
2023-03-31 22:12 ` [Intel-gfx] [PATCH v8 07/10] drm/i915/hdcp: Use HDCP helpers for i915 Mark Yacoub
2023-04-03  6:59   ` Kandpal, Suraj
2023-03-31 22:12 ` [Intel-gfx] [PATCH v8 08/10] dt-bindings: msm/dp: Add bindings for HDCP registers Mark Yacoub
2023-03-31 22:12 ` [Intel-gfx] [PATCH v8 09/10] arm64: dts: qcom: sc7180: Add support for HDCP in dp-controller Mark Yacoub
2023-04-07 16:34   ` Dmitry Baryshkov
2023-04-07 16:34   ` Dmitry Baryshkov
2023-03-31 22:12 ` [Intel-gfx] [PATCH v8 10/10] drm/msm: Implement HDCP 1.x using the new drm HDCP helpers Mark Yacoub
2023-04-01  3:44   ` kernel test robot
2023-03-31 22:17 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for drm/hdcp: Pull HDCP auth/exchange/check into helpers (rev8) Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230331221213.1691997-4-markyacoub@google.com \
    --to=markyacoub@chromium.org \
    --cc=airlied@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=dianders@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rodrigo.vivi@intel.com \
    --cc=seanpaul@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).