diff mbox

[v5,10/40] drm/i915: Pullout the bksv read and validation

Message ID 1530088829-11730-11-git-send-email-ramalingam.c@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ramalingam C June 27, 2018, 8:39 a.m. UTC
For reusability purpose, this patch implements the hdcp1.4 bksv's
read and validation as a functions.

For detecting the HDMI panel's HDCP capability this fucntions will be
used.

v2:
  Rebased.
v3:
  No Changes.
v4:
  inline tag is removed with modified error msg.
v5:
  No Changes.

Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
---
 drivers/gpu/drm/i915/intel_hdcp.c | 37 +++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)

Comments

Sean Paul July 9, 2018, 8:35 p.m. UTC | #1
On Wed, Jun 27, 2018 at 02:09:59PM +0530, Ramalingam C wrote:
> For reusability purpose, this patch implements the hdcp1.4 bksv's
> read and validation as a functions.
> 
> For detecting the HDMI panel's HDCP capability this fucntions will be
> used.
> 
> v2:
>   Rebased.
> v3:
>   No Changes.
> v4:
>   inline tag is removed with modified error msg.
> v5:
>   No Changes.
> 
> Signed-off-by: Ramalingam C <ramalingam.c@intel.com>


Reviewed-by: Sean Paul <seanpaul@chromium.org>


> ---
>  drivers/gpu/drm/i915/intel_hdcp.c | 37 +++++++++++++++++++++++++------------
>  1 file changed, 25 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_hdcp.c b/drivers/gpu/drm/i915/intel_hdcp.c
> index 4bff74b3bed0..32a1a3f39b65 100644
> --- a/drivers/gpu/drm/i915/intel_hdcp.c
> +++ b/drivers/gpu/drm/i915/intel_hdcp.c
> @@ -400,6 +400,28 @@ int intel_hdcp_validate_v_prime(struct intel_digital_port *intel_dig_port,
>  	return 0;
>  }
>  
> +static
> +int intel_hdcp_read_valid_bksv(struct intel_digital_port *intel_dig_port,
> +			       const struct intel_hdcp_shim *shim, u8 *bksv)
> +{
> +	int ret, i, tries = 2;
> +
> +	/* HDCP spec states that we must retry the bksv if it is invalid */
> +	for (i = 0; i < tries; i++) {
> +		ret = shim->read_bksv(intel_dig_port, bksv);
> +		if (ret)
> +			return ret;
> +		if (intel_hdcp_is_ksv_valid(bksv))
> +			break;
> +	}
> +	if (i == tries) {
> +		DRM_ERROR("Bksv is invalid\n");
> +		return -ENODEV;
> +	}
> +
> +	return 0;
> +}
> +
>  /* Implements Part 2 of the HDCP authorization procedure */
>  static
>  int intel_hdcp_auth_downstream(struct intel_digital_port *intel_dig_port,
> @@ -533,18 +555,9 @@ static int intel_hdcp_auth(struct intel_digital_port *intel_dig_port,
>  
>  	memset(&bksv, 0, sizeof(bksv));
>  
> -	/* HDCP spec states that we must retry the bksv if it is invalid */
> -	for (i = 0; i < tries; i++) {
> -		ret = shim->read_bksv(intel_dig_port, bksv.shim);
> -		if (ret)
> -			return ret;
> -		if (intel_hdcp_is_ksv_valid(bksv.shim))
> -			break;
> -	}
> -	if (i == tries) {
> -		DRM_ERROR("HDCP failed, Bksv is invalid\n");
> -		return -ENODEV;
> -	}
> +	ret = intel_hdcp_read_valid_bksv(intel_dig_port, shim, bksv.shim);
> +	if (ret < 0)
> +		return ret;
>  
>  	I915_WRITE(PORT_HDCP_BKSVLO(port), bksv.reg[0]);
>  	I915_WRITE(PORT_HDCP_BKSVHI(port), bksv.reg[1]);
> -- 
> 2.7.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_hdcp.c b/drivers/gpu/drm/i915/intel_hdcp.c
index 4bff74b3bed0..32a1a3f39b65 100644
--- a/drivers/gpu/drm/i915/intel_hdcp.c
+++ b/drivers/gpu/drm/i915/intel_hdcp.c
@@ -400,6 +400,28 @@  int intel_hdcp_validate_v_prime(struct intel_digital_port *intel_dig_port,
 	return 0;
 }
 
+static
+int intel_hdcp_read_valid_bksv(struct intel_digital_port *intel_dig_port,
+			       const struct intel_hdcp_shim *shim, u8 *bksv)
+{
+	int ret, i, tries = 2;
+
+	/* HDCP spec states that we must retry the bksv if it is invalid */
+	for (i = 0; i < tries; i++) {
+		ret = shim->read_bksv(intel_dig_port, bksv);
+		if (ret)
+			return ret;
+		if (intel_hdcp_is_ksv_valid(bksv))
+			break;
+	}
+	if (i == tries) {
+		DRM_ERROR("Bksv is invalid\n");
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
 /* Implements Part 2 of the HDCP authorization procedure */
 static
 int intel_hdcp_auth_downstream(struct intel_digital_port *intel_dig_port,
@@ -533,18 +555,9 @@  static int intel_hdcp_auth(struct intel_digital_port *intel_dig_port,
 
 	memset(&bksv, 0, sizeof(bksv));
 
-	/* HDCP spec states that we must retry the bksv if it is invalid */
-	for (i = 0; i < tries; i++) {
-		ret = shim->read_bksv(intel_dig_port, bksv.shim);
-		if (ret)
-			return ret;
-		if (intel_hdcp_is_ksv_valid(bksv.shim))
-			break;
-	}
-	if (i == tries) {
-		DRM_ERROR("HDCP failed, Bksv is invalid\n");
-		return -ENODEV;
-	}
+	ret = intel_hdcp_read_valid_bksv(intel_dig_port, shim, bksv.shim);
+	if (ret < 0)
+		return ret;
 
 	I915_WRITE(PORT_HDCP_BKSVLO(port), bksv.reg[0]);
 	I915_WRITE(PORT_HDCP_BKSVHI(port), bksv.reg[1]);