[Intel-gfx] [PATCH 10/11] drm/edid: Make version checks less convoluted

Jani Nikula jani.nikula at linux.intel.com
Fri Sep 2 12:31:39 UTC 2022


On Sat, 27 Aug 2022, Ville Syrjala <ville.syrjala at linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
>
> Get rid of the confusing version_greater() stuff and
> simply compare edid->revision directly everwhere. Half
> the places already did it this way, and since we actually
> reject any EDID with edid->version!=1 it's a perfectly
> sane thing to do.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>

Reviewed-by: Jani Nikula <jani.nikula at intel.com>

> ---
>  drivers/gpu/drm/drm_edid.c | 25 ++++++++-----------------
>  1 file changed, 8 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 0fe06e5fd6e0..e7f46260dfe7 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -1572,15 +1572,6 @@ struct drm_edid {
>  	const struct edid *edid;
>  };
>  
> -static bool version_greater(const struct drm_edid *drm_edid,
> -			    u8 version, u8 revision)
> -{
> -	const struct edid *edid = drm_edid->edid;
> -
> -	return edid->version > version ||
> -		(edid->version == version && edid->revision > revision);
> -}
> -
>  static int edid_hfeeodb_extension_block_count(const struct edid *edid);
>  
>  static int edid_hfeeodb_block_count(const struct edid *edid)
> @@ -3652,7 +3643,7 @@ do_inferred_modes(const struct detailed_timing *timing, void *c)
>  						  closure->drm_edid,
>  						  timing);
>  
> -	if (!version_greater(closure->drm_edid, 1, 1))
> +	if (closure->drm_edid->edid->revision < 2)
>  		return; /* GTF not defined yet */
>  
>  	switch (range->flags) {
> @@ -3667,7 +3658,7 @@ do_inferred_modes(const struct detailed_timing *timing, void *c)
>  							  timing);
>  		break;
>  	case DRM_EDID_CVT_SUPPORT_FLAG:
> -		if (!version_greater(closure->drm_edid, 1, 3))
> +		if (closure->drm_edid->edid->revision < 4)
>  			break;
>  
>  		closure->modes += drm_cvt_modes_for_range(closure->connector,
> @@ -3688,7 +3679,7 @@ static int add_inferred_modes(struct drm_connector *connector,
>  		.drm_edid = drm_edid,
>  	};
>  
> -	if (version_greater(drm_edid, 1, 0))
> +	if (drm_edid->edid->revision >= 1)
>  		drm_for_each_detailed_block(drm_edid, do_inferred_modes, &closure);
>  
>  	return closure.modes;
> @@ -3765,7 +3756,7 @@ static int add_established_modes(struct drm_connector *connector,
>  		}
>  	}
>  
> -	if (version_greater(drm_edid, 1, 0))
> +	if (edid->revision >= 1)
>  		drm_for_each_detailed_block(drm_edid, do_established_modes,
>  					    &closure);
>  
> @@ -3820,7 +3811,7 @@ static int add_standard_modes(struct drm_connector *connector,
>  		}
>  	}
>  
> -	if (version_greater(drm_edid, 1, 0))
> +	if (drm_edid->edid->revision >= 1)
>  		drm_for_each_detailed_block(drm_edid, do_standard_modes,
>  					    &closure);
>  
> @@ -3900,7 +3891,7 @@ add_cvt_modes(struct drm_connector *connector, const struct drm_edid *drm_edid)
>  		.drm_edid = drm_edid,
>  	};
>  
> -	if (version_greater(drm_edid, 1, 2))
> +	if (drm_edid->edid->revision >= 3)
>  		drm_for_each_detailed_block(drm_edid, do_cvt_mode, &closure);
>  
>  	/* XXX should also look for CVT codes in VTB blocks */
> @@ -3955,7 +3946,7 @@ static int add_detailed_modes(struct drm_connector *connector,
>  		.quirks = quirks,
>  	};
>  
> -	if (version_greater(drm_edid, 1, 3))
> +	if (drm_edid->edid->revision >= 4)
>  		closure.preferred = true; /* first detailed timing is always preferred */
>  	else
>  		closure.preferred =
> @@ -6144,7 +6135,7 @@ static void drm_get_vrr_range(struct drm_connector *connector,
>  		.drm_edid = drm_edid,
>  	};
>  
> -	if (!version_greater(drm_edid, 1, 3))
> +	if (drm_edid->edid->revision < 4)
>  		return;
>  
>  	if (!(drm_edid->edid->features & DRM_EDID_FEATURE_CONTINUOUS_FREQ))

-- 
Jani Nikula, Intel Open Source Graphics Center


More information about the Intel-gfx mailing list