[PATCH 1/1] drm/i915/hdcp: Update CP as per the kernel internal state

Anshuman Gupta anshuman.gupta at intel.com
Mon Jan 27 13:43:37 UTC 2020


Content Protection property should be updated as per the kernel
internal state. Let's say if Content protection is disabled
by userspace, CP property should be set to UNDESIRED so that
reauthentication will not happen until userspace request it again,
but when kernel disables the HDCP due to any DDI disabling sequences
like modeset/DPMS operation, kernel should set the property to
DESIRED, so that when opportunity arises, kernel will start the
HDCP authentication on its own.

Somewhere in the line, state machine to set content protection to
DESIRED from kernel was broken and IGT coverage was missing for it.
This patch fixes it.
IGT patch to catch further regression on this features is being
worked upon.

Signed-off-by: Anshuman Gupta <anshuman.gupta at intel.com>
---
 drivers/gpu/drm/i915/display/intel_display.c |  9 +++++++
 drivers/gpu/drm/i915/display/intel_hdcp.c    | 27 ++++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_hdcp.h    |  2 ++
 3 files changed, 38 insertions(+)

diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index da5266e76738..7b2713f7ea74 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -14595,6 +14595,15 @@ static int intel_atomic_check(struct drm_device *dev,
 		goto fail;
 
 	if (any_ms) {
+		/*
+		 * HDCP uapi was broken, if HDCP is disabled by kernel DDI
+		 * disable sequence which was initiated due to modeset,
+		 * it left hdcp uapi state to be ENABLED while actual hdcp h/w
+		 * state was disabled. HDCP uapi state should change from
+		 * ENABLED to DESIRED in case of hdcp disable initiated by
+		 * modeset.
+		 */
+		intel_hdcp_post_need_modeset_check(state);
 		ret = intel_modeset_checks(state);
 		if (ret)
 			goto fail;
diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c b/drivers/gpu/drm/i915/display/intel_hdcp.c
index 0fdbd39f6641..6de124139540 100644
--- a/drivers/gpu/drm/i915/display/intel_hdcp.c
+++ b/drivers/gpu/drm/i915/display/intel_hdcp.c
@@ -2074,6 +2074,33 @@ void intel_hdcp_atomic_check(struct drm_connector *connector,
 	crtc_state->mode_changed = true;
 }
 
+/**
+ * intel_hdcp_post_need_modeset_check.
+ * @state: intel atomic state.
+ *
+ * This function fix the HDCP uapi state,
+ * If DDI is going to be disable due to modeset, it disbales the hdcp,
+ * therefore hdcp uapi state should be changed to DESIRED so that HDCP uapi
+ * state can be restored as per HDCP Auth state.
+ * This function should be only in case of in case of modeset.
+ * FIXME: As per HDCP content protection property uapi an uevent() need to be
+ * sent if there is transition from ENABLED->DESIRED.
+ */
+void intel_hdcp_post_need_modeset_check(struct intel_atomic_state *state)
+{
+	struct drm_connector *connector;
+	struct drm_connector_state *old_state;
+	struct drm_connector_state *new_state;
+	int i;
+
+	for_each_oldnew_connector_in_state(&state->base, connector, old_state,
+					   new_state, i) {
+		if (old_state->content_protection == DRM_MODE_CONTENT_PROTECTION_ENABLED &&
+		    new_state->content_protection != DRM_MODE_CONTENT_PROTECTION_UNDESIRED)
+			new_state->content_protection = DRM_MODE_CONTENT_PROTECTION_DESIRED;
+	}
+}
+
 /* Handles the CP_IRQ raised from the DP HDCP sink */
 void intel_hdcp_handle_cp_irq(struct intel_connector *connector)
 {
diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.h b/drivers/gpu/drm/i915/display/intel_hdcp.h
index f3c3272e712a..7bf46bc3c348 100644
--- a/drivers/gpu/drm/i915/display/intel_hdcp.h
+++ b/drivers/gpu/drm/i915/display/intel_hdcp.h
@@ -13,6 +13,7 @@
 struct drm_connector;
 struct drm_connector_state;
 struct drm_i915_private;
+struct intel_atomic_state;
 struct intel_connector;
 struct intel_hdcp_shim;
 enum port;
@@ -21,6 +22,7 @@ enum transcoder;
 void intel_hdcp_atomic_check(struct drm_connector *connector,
 			     struct drm_connector_state *old_state,
 			     struct drm_connector_state *new_state);
+void intel_hdcp_post_need_modeset_check(struct intel_atomic_state *state);
 int intel_hdcp_init(struct intel_connector *connector,
 		    const struct intel_hdcp_shim *hdcp_shim);
 int intel_hdcp_enable(struct intel_connector *connector,
-- 
2.24.0



More information about the Intel-gfx-trybot mailing list