[Intel-gfx] [PATCH 1/3] drm: Make sure at least one plane supports the fb format

Eric Anholt eric at anholt.net
Mon Mar 5 20:59:00 UTC 2018


Ville Syrjala <ville.syrjala at linux.intel.com> writes:

> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
>
> To make life easier for drivers, let's have the core check that the
> requested pixel format is supported by at least one plane when creating
> a new framebuffer.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> ---
>  drivers/gpu/drm/drm_framebuffer.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
> index c0530a1af5e3..155b21e579c4 100644
> --- a/drivers/gpu/drm/drm_framebuffer.c
> +++ b/drivers/gpu/drm/drm_framebuffer.c
> @@ -152,6 +152,23 @@ static int fb_plane_height(int height,
>  	return DIV_ROUND_UP(height, format->vsub);
>  }
>  
> +static bool planes_have_format(struct drm_device *dev, u32 format)
> +{
> +	struct drm_plane *plane;
> +
> +	/* TODO: maybe maintain a device level format list? */
> +	drm_for_each_plane(plane, dev) {
> +		int i;
> +
> +		for (i = 0; i < plane->format_count; i++) {
> +			if (plane->format_types[i] == format)
> +				return true;
> +		}
> +	}
> +
> +	return false;
> +}
> +
>  static int framebuffer_check(struct drm_device *dev,
>  			     const struct drm_mode_fb_cmd2 *r)
>  {
> @@ -168,6 +185,15 @@ static int framebuffer_check(struct drm_device *dev,
>  		return -EINVAL;
>  	}
>  
> +	if (!planes_have_format(dev, r->pixel_format)) {
> +		struct drm_format_name_buf format_name;
> +
> +		DRM_DEBUG_KMS("unsupported framebuffer format %s\n",
> +			      drm_get_format_name(r->pixel_format,
> +						  &format_name));
> +		return -EINVAL;
> +	}
> +

Won't this break KMS on things like the radeon driver, which doesn't do
planes?  Maybe check if any universal planes have been registered and
only do the check in that case?

Also, "any_planes_have_format()" might be slightly more descriptive.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/intel-gfx/attachments/20180305/ea6d774c/attachment-0001.sig>


More information about the Intel-gfx mailing list