diff mbox series

[v2] drm/i915/hdcp: restore hdcp state same as previous

Message ID 20200109125508.19601-1-anshuman.gupta@intel.com (mailing list archive)
State New, archived
Headers show
Series [v2] drm/i915/hdcp: restore hdcp state same as previous | expand

Commit Message

Gupta, Anshuman Jan. 9, 2020, 12:55 p.m. UTC
When port is disabled due to modeset or DPMS off actually
it disables the HDCP encryption keeping its state to
CP_ENABLED this doesn't enable HDCP again while port
gets enable again. HDCP state should set accordingly
when port is disabled.

v2: Incorporated the necessary locking and making sure
    when user explicitly set HDCP to UNDESRIED it should
    make HDCP to desired while disabling DDI. (Ram)

CC: Ramalingam C <ramalingam.c@intel.com>
Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
---
 drivers/gpu/drm/i915/display/intel_display_types.h |  1 +
 drivers/gpu/drm/i915/display/intel_hdcp.c          | 12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

Comments

Ramalingam C Jan. 9, 2020, 1:27 p.m. UTC | #1
On 2020-01-09 at 18:25:08 +0530, Anshuman Gupta wrote:
> When port is disabled due to modeset or DPMS off actually
> it disables the HDCP encryption keeping its state to
s/state/"content protection property as"
> CP_ENABLED.
> this doesn't enable HDCP again while port
> gets enable again.
Since the content protection is left at ENABLED state by mistake at next
DDI enable flow HDCP auth is not attempted.

> HDCP state should set accordingly
content protection property state should be updated as per port
authentication state.
> when port is disabled.
> 
> v2: Incorporated the necessary locking and making sure
>     when user explicitly set HDCP to UNDESRIED it should
>     make HDCP to desired while disabling DDI. (Ram)
Need to rephrase this too.
> 
> CC: Ramalingam C <ramalingam.c@intel.com>
> Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_display_types.h |  1 +
>  drivers/gpu/drm/i915/display/intel_hdcp.c          | 12 +++++++++++-
>  2 files changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
> index 630a94892b7b..f2552a52f26a 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_types.h
> +++ b/drivers/gpu/drm/i915/display/intel_display_types.h
> @@ -344,6 +344,7 @@ struct intel_hdcp {
>  	u64 value;
>  	struct delayed_work check_work;
>  	struct work_struct prop_work;
> +	bool is_hdcp_undesired;
small comment on why this is needed now would be good.

/* Indicates whether HDCP is UNDESIERD by userspace */
>  
>  	/* HDCP1.4 Encryption status */
>  	bool hdcp_encrypted;
> diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c b/drivers/gpu/drm/i915/display/intel_hdcp.c
> index 0fdbd39f6641..507056aab33b 100644
> --- a/drivers/gpu/drm/i915/display/intel_hdcp.c
> +++ b/drivers/gpu/drm/i915/display/intel_hdcp.c
> @@ -2002,11 +2002,17 @@ 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;
>  		if (hdcp->hdcp2_encrypted)
>  			ret = _intel_hdcp2_disable(connector);
>  		else if (hdcp->hdcp_encrypted)
>  			ret = _intel_hdcp_disable(connector);
> +
> +		if (hdcp->is_hdcp_undesired) {
> +			hdcp->value = DRM_MODE_CONTENT_PROTECTION_UNDESIRED;
> +		} else {
> +			hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED;
> +			schedule_work(&hdcp->prop_work);
> +		}
>  	}
>  
>  	mutex_unlock(&hdcp->mutex);
> @@ -2044,6 +2050,7 @@ void intel_hdcp_atomic_check(struct drm_connector *connector,
>  {
>  	u64 old_cp = old_state->content_protection;
>  	u64 new_cp = new_state->content_protection;
> +	struct intel_connector *intel_conn = to_intel_connector(connector);
>  	struct drm_crtc_state *crtc_state;
>  
>  	if (!new_state->crtc) {
> @@ -2069,6 +2076,9 @@ void intel_hdcp_atomic_check(struct drm_connector *connector,
>  			return;
>  	}
>  
> +	if (new_cp == DRM_MODE_CONTENT_PROTECTION_UNDESIRED)
> +		intel_conn->hdcp.is_hdcp_undesired  =  true;
This flag will be always left at true. reset it to false as soon as used
at intel_hdcp_disable()

-Ram
> +
>  	crtc_state = drm_atomic_get_new_crtc_state(new_state->state,
>  						   new_state->crtc);
>  	crtc_state->mode_changed = true;
> -- 
> 2.24.0
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index 630a94892b7b..f2552a52f26a 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -344,6 +344,7 @@  struct intel_hdcp {
 	u64 value;
 	struct delayed_work check_work;
 	struct work_struct prop_work;
+	bool is_hdcp_undesired;
 
 	/* HDCP1.4 Encryption status */
 	bool hdcp_encrypted;
diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c b/drivers/gpu/drm/i915/display/intel_hdcp.c
index 0fdbd39f6641..507056aab33b 100644
--- a/drivers/gpu/drm/i915/display/intel_hdcp.c
+++ b/drivers/gpu/drm/i915/display/intel_hdcp.c
@@ -2002,11 +2002,17 @@  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;
 		if (hdcp->hdcp2_encrypted)
 			ret = _intel_hdcp2_disable(connector);
 		else if (hdcp->hdcp_encrypted)
 			ret = _intel_hdcp_disable(connector);
+
+		if (hdcp->is_hdcp_undesired) {
+			hdcp->value = DRM_MODE_CONTENT_PROTECTION_UNDESIRED;
+		} else {
+			hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED;
+			schedule_work(&hdcp->prop_work);
+		}
 	}
 
 	mutex_unlock(&hdcp->mutex);
@@ -2044,6 +2050,7 @@  void intel_hdcp_atomic_check(struct drm_connector *connector,
 {
 	u64 old_cp = old_state->content_protection;
 	u64 new_cp = new_state->content_protection;
+	struct intel_connector *intel_conn = to_intel_connector(connector);
 	struct drm_crtc_state *crtc_state;
 
 	if (!new_state->crtc) {
@@ -2069,6 +2076,9 @@  void intel_hdcp_atomic_check(struct drm_connector *connector,
 			return;
 	}
 
+	if (new_cp == DRM_MODE_CONTENT_PROTECTION_UNDESIRED)
+		intel_conn->hdcp.is_hdcp_undesired  =  true;
+
 	crtc_state = drm_atomic_get_new_crtc_state(new_state->state,
 						   new_state->crtc);
 	crtc_state->mode_changed = true;