diff mbox

[1/4] drm: Centralize format information

Message ID 1465255994-317-2-git-send-email-laurent.pinchart@ideasonboard.com (mailing list archive)
State New, archived
Headers show

Commit Message

Laurent Pinchart June 6, 2016, 11:33 p.m. UTC
Various pieces of information about DRM formats (number of planes, color
depth, chroma subsampling, ...) are scattered across different helper
functions in the DRM core. Callers of those functions often need to
access more than a single parameter of the format, leading to
inefficiencies due to multiple lookups.

Centralize all format information in a data structure and create a
function to look up information based on the format 4CC.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/drm_crtc.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_crtc.h     | 21 ++++++++++++
 2 files changed, 104 insertions(+)

Comments

Tomi Valkeinen June 7, 2016, 9:18 a.m. UTC | #1
On 07/06/16 02:33, Laurent Pinchart wrote:

> +/**
> + * struct drm_format_info - information about a DRM format
> + * @format: 4CC format identifier (DRM_FORMAT_*)
> + * @depth: color depth (number of bits per pixel excluding padding bits)
> + * @bpp: number of bits per pixel including padding
> + * @num_planes: number of color planes (1 to 3)
> + * @cpp: number of bytes per pixel (per plane)
> + * @hsub: horizontal chroma subsampling factor
> + * @vsub: vertical chroma subsampling factor
> + */
> +struct drm_format_info {
> +	u32 format;
> +	unsigned int depth;
> +	unsigned int bpp;
> +	unsigned int num_planes;
> +	unsigned int cpp[3];
> +	unsigned int hsub;
> +	unsigned int vsub;
> +};

Any reason not to pack this a bit? All those unsigned ints would fit
easily into u8.

 Tomi
Tomi Valkeinen June 7, 2016, 9:25 a.m. UTC | #2
On 07/06/16 02:33, Laurent Pinchart wrote:
> Various pieces of information about DRM formats (number of planes, color
> depth, chroma subsampling, ...) are scattered across different helper
> functions in the DRM core. Callers of those functions often need to
> access more than a single parameter of the format, leading to
> inefficiencies due to multiple lookups.
> 
> Centralize all format information in a data structure and create a
> function to look up information based on the format 4CC.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/gpu/drm/drm_crtc.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++
>  include/drm/drm_crtc.h     | 21 ++++++++++++
>  2 files changed, 104 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 0e3cc66aa8b7..74b0c6dd80cd 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -5544,6 +5544,89 @@ int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
>  }
>  
>  /**
> + * drm_format_info - information for a given format
> + * @format: pixel format (DRM_FORMAT_*)
> + *
> + * Returns:
> + * The instance of struct drm_format_info that describes the pixel format, or
> + * NULL if the format is unsupported.
> + */
> +const struct drm_format_info *drm_format_info(u32 format)
> +{
> +	static const struct drm_format_info formats[] = {
> +		{ DRM_FORMAT_C8, 8, 8, 1, { 1 }, 1, 1 },
> +		{ DRM_FORMAT_RGB332, 8, 8, 1, { 1 }, 1, 1 },
> +		{ DRM_FORMAT_BGR233, 8, 8, 1, { 1 }, 1, 1 },
> +		{ DRM_FORMAT_XRGB4444, 12, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_XBGR4444, 12, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_RGBX4444, 12, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_BGRX4444, 12, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_ARGB4444, 12, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_ABGR4444, 12, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_RGBA4444, 12, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_BGRA4444, 12, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_XRGB1555, 15, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_XBGR1555, 15, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_RGBX5551, 15, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_BGRX5551, 15, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_ARGB1555, 15, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_ABGR1555, 15, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_RGBA5551, 15, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_BGRA5551, 15, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_RGB565, 16, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_BGR565, 16, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_RGB888, 24, 24, 1, { 3 }, 1, 1 },
> +		{ DRM_FORMAT_BGR888, 24, 24, 1, { 3 }, 1, 1 },
> +		{ DRM_FORMAT_XRGB8888, 24, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_XBGR8888, 24, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_RGBX8888, 24, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_BGRX8888, 24, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_XRGB2101010, 30, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_XBGR2101010, 30, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_RGBX1010102, 30, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_BGRX1010102, 30, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_ARGB2101010, 30, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_ABGR2101010, 30, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_RGBA1010102, 30, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_BGRA1010102, 30, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_ARGB8888, 32, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_ABGR8888, 32, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_RGBA8888, 32, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_BGRA8888, 32, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_YUV410, 0, 0, 3, { 1, 1, 1 }, 4, 4 },
> +		{ DRM_FORMAT_YVU410, 0, 0, 3, { 1, 1, 1 }, 4, 4 },
> +		{ DRM_FORMAT_YUV411, 0, 0, 3, { 1, 1, 1 }, 4, 1 },
> +		{ DRM_FORMAT_YVU411, 0, 0, 3, { 1, 1, 1 }, 4, 1 },
> +		{ DRM_FORMAT_YUV420, 0, 0, 3, { 1, 1, 1 }, 2, 2 },
> +		{ DRM_FORMAT_YVU420, 0, 0, 3, { 1, 1, 1 }, 2, 2 },
> +		{ DRM_FORMAT_YUV422, 0, 0, 3, { 1, 1, 1 }, 2, 1 },
> +		{ DRM_FORMAT_YVU422, 0, 0, 3, { 1, 1, 1 }, 2, 1 },
> +		{ DRM_FORMAT_YUV444, 0, 0, 3, { 1, 1, 1 }, 1, 1 },
> +		{ DRM_FORMAT_YVU444, 0, 0, 3, { 1, 1, 1 }, 1, 1 },
> +		{ DRM_FORMAT_NV12, 0, 0, 2, { 1, 2 }, 2, 2 },
> +		{ DRM_FORMAT_NV21, 0, 0, 2, { 1, 2 }, 2, 2 },
> +		{ DRM_FORMAT_NV16, 0, 0, 2, { 1, 2 }, 2, 1 },
> +		{ DRM_FORMAT_NV61, 0, 0, 2, { 1, 2 }, 2, 1 },
> +		{ DRM_FORMAT_NV24, 0, 0, 2, { 1, 2 }, 1, 1 },
> +		{ DRM_FORMAT_NV42, 0, 0, 2, { 1, 2 }, 1, 1 },
> +		{ DRM_FORMAT_YUYV, 0, 0, 1, { 2 }, 2, 1 },
> +		{ DRM_FORMAT_YVYU, 0, 0, 1, { 2 }, 2, 1 },
> +		{ DRM_FORMAT_UYVY, 0, 0, 1, { 2 }, 2, 1 },
> +		{ DRM_FORMAT_VYUY, 0, 0, 1, { 2 }, 2, 1 },
> +		{ DRM_FORMAT_AYUV, 0, 0, 1, { 4 }, 1, 1 },
> +	};
> +
> +	unsigned int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(formats); ++i) {
> +		if (formats[i].format == format)
> +			return &formats[i];
> +	}
> +
> +	return NULL;

After looking at the third patch, I wonder if it would make sense to
give a warning here if the format was not found. In the third patch many
of the helpers will quietly return a valid value for unknown modes.
Which is what they do at the moment too, but is there ever a valid
reason to do that without something being wrong?

 Tomi
Laurent Pinchart June 7, 2016, 11:48 a.m. UTC | #3
Hi Tomi,

On Tuesday 07 Jun 2016 12:18:34 Tomi Valkeinen wrote:
> On 07/06/16 02:33, Laurent Pinchart wrote:
> > +/**
> > + * struct drm_format_info - information about a DRM format
> > + * @format: 4CC format identifier (DRM_FORMAT_*)
> > + * @depth: color depth (number of bits per pixel excluding padding bits)
> > + * @bpp: number of bits per pixel including padding
> > + * @num_planes: number of color planes (1 to 3)
> > + * @cpp: number of bytes per pixel (per plane)
> > + * @hsub: horizontal chroma subsampling factor
> > + * @vsub: vertical chroma subsampling factor
> > + */
> > +struct drm_format_info {
> > +	u32 format;
> > +	unsigned int depth;
> > +	unsigned int bpp;
> > +	unsigned int num_planes;
> > +	unsigned int cpp[3];
> > +	unsigned int hsub;
> > +	unsigned int vsub;
> > +};
> 
> Any reason not to pack this a bit? All those unsigned ints would fit
> easily into u8.

Good point, I'll do that.
Laurent Pinchart June 7, 2016, 12:05 p.m. UTC | #4
Hi Tomi,

On Tuesday 07 Jun 2016 12:25:08 Tomi Valkeinen wrote:
> On 07/06/16 02:33, Laurent Pinchart wrote:
> > Various pieces of information about DRM formats (number of planes, color
> > depth, chroma subsampling, ...) are scattered across different helper
> > functions in the DRM core. Callers of those functions often need to
> > access more than a single parameter of the format, leading to
> > inefficiencies due to multiple lookups.
> > 
> > Centralize all format information in a data structure and create a
> > function to look up information based on the format 4CC.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> > 
> >  drivers/gpu/drm/drm_crtc.c | 83 +++++++++++++++++++++++++++++++++++++++++
> >  include/drm/drm_crtc.h     | 21 ++++++++++++
> >  2 files changed, 104 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> > index 0e3cc66aa8b7..74b0c6dd80cd 100644
> > --- a/drivers/gpu/drm/drm_crtc.c
> > +++ b/drivers/gpu/drm/drm_crtc.c
> > @@ -5544,6 +5544,89 @@ int drm_mode_destroy_dumb_ioctl(struct drm_device
> > *dev,> 
> >  }
> >  
> >  /**
> > 
> > + * drm_format_info - information for a given format
> > + * @format: pixel format (DRM_FORMAT_*)
> > + *
> > + * Returns:
> > + * The instance of struct drm_format_info that describes the pixel
> > format, or + * NULL if the format is unsupported.
> > + */
> > +const struct drm_format_info *drm_format_info(u32 format)
> > +{
> > +	static const struct drm_format_info formats[] = {
> > +		{ DRM_FORMAT_C8, 8, 8, 1, { 1 }, 1, 1 },
> > +		{ DRM_FORMAT_RGB332, 8, 8, 1, { 1 }, 1, 1 },
> > +		{ DRM_FORMAT_BGR233, 8, 8, 1, { 1 }, 1, 1 },
> > +		{ DRM_FORMAT_XRGB4444, 12, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_XBGR4444, 12, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_RGBX4444, 12, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_BGRX4444, 12, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_ARGB4444, 12, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_ABGR4444, 12, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_RGBA4444, 12, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_BGRA4444, 12, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_XRGB1555, 15, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_XBGR1555, 15, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_RGBX5551, 15, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_BGRX5551, 15, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_ARGB1555, 15, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_ABGR1555, 15, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_RGBA5551, 15, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_BGRA5551, 15, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_RGB565, 16, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_BGR565, 16, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_RGB888, 24, 24, 1, { 3 }, 1, 1 },
> > +		{ DRM_FORMAT_BGR888, 24, 24, 1, { 3 }, 1, 1 },
> > +		{ DRM_FORMAT_XRGB8888, 24, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_XBGR8888, 24, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_RGBX8888, 24, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_BGRX8888, 24, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_XRGB2101010, 30, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_XBGR2101010, 30, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_RGBX1010102, 30, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_BGRX1010102, 30, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_ARGB2101010, 30, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_ABGR2101010, 30, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_RGBA1010102, 30, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_BGRA1010102, 30, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_ARGB8888, 32, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_ABGR8888, 32, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_RGBA8888, 32, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_BGRA8888, 32, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_YUV410, 0, 0, 3, { 1, 1, 1 }, 4, 4 },
> > +		{ DRM_FORMAT_YVU410, 0, 0, 3, { 1, 1, 1 }, 4, 4 },
> > +		{ DRM_FORMAT_YUV411, 0, 0, 3, { 1, 1, 1 }, 4, 1 },
> > +		{ DRM_FORMAT_YVU411, 0, 0, 3, { 1, 1, 1 }, 4, 1 },
> > +		{ DRM_FORMAT_YUV420, 0, 0, 3, { 1, 1, 1 }, 2, 2 },
> > +		{ DRM_FORMAT_YVU420, 0, 0, 3, { 1, 1, 1 }, 2, 2 },
> > +		{ DRM_FORMAT_YUV422, 0, 0, 3, { 1, 1, 1 }, 2, 1 },
> > +		{ DRM_FORMAT_YVU422, 0, 0, 3, { 1, 1, 1 }, 2, 1 },
> > +		{ DRM_FORMAT_YUV444, 0, 0, 3, { 1, 1, 1 }, 1, 1 },
> > +		{ DRM_FORMAT_YVU444, 0, 0, 3, { 1, 1, 1 }, 1, 1 },
> > +		{ DRM_FORMAT_NV12, 0, 0, 2, { 1, 2 }, 2, 2 },
> > +		{ DRM_FORMAT_NV21, 0, 0, 2, { 1, 2 }, 2, 2 },
> > +		{ DRM_FORMAT_NV16, 0, 0, 2, { 1, 2 }, 2, 1 },
> > +		{ DRM_FORMAT_NV61, 0, 0, 2, { 1, 2 }, 2, 1 },
> > +		{ DRM_FORMAT_NV24, 0, 0, 2, { 1, 2 }, 1, 1 },
> > +		{ DRM_FORMAT_NV42, 0, 0, 2, { 1, 2 }, 1, 1 },
> > +		{ DRM_FORMAT_YUYV, 0, 0, 1, { 2 }, 2, 1 },
> > +		{ DRM_FORMAT_YVYU, 0, 0, 1, { 2 }, 2, 1 },
> > +		{ DRM_FORMAT_UYVY, 0, 0, 1, { 2 }, 2, 1 },
> > +		{ DRM_FORMAT_VYUY, 0, 0, 1, { 2 }, 2, 1 },
> > +		{ DRM_FORMAT_AYUV, 0, 0, 1, { 4 }, 1, 1 },
> > +	};
> > +
> > +	unsigned int i;
> > +
> > +	for (i = 0; i < ARRAY_SIZE(formats); ++i) {
> > +		if (formats[i].format == format)
> > +			return &formats[i];
> > +	}
> > +
> > +	return NULL;
> 
> After looking at the third patch, I wonder if it would make sense to
> give a warning here if the format was not found. In the third patch many
> of the helpers will quietly return a valid value for unknown modes.
> Which is what they do at the moment too, but is there ever a valid
> reason to do that without something being wrong?

We can't warn in this function due to its usage in framebuffer_check() that 
uses drm_format_info() to validate the format provided by userspace. However, 
I agree that all other call sites should not pass an unsupported format, that 
would be a bug in the caller.

I can rename the function to __drm_format_info(), call that in 
framebuffer_check(), and create a drm_format_info() wrapper with a WARN_ON if 
the format isn't found. Would you prefer that ?
Ville Syrjälä June 7, 2016, 1:20 p.m. UTC | #5
On Tue, Jun 07, 2016 at 02:33:11AM +0300, Laurent Pinchart wrote:
> Various pieces of information about DRM formats (number of planes, color
> depth, chroma subsampling, ...) are scattered across different helper
> functions in the DRM core. Callers of those functions often need to
> access more than a single parameter of the format, leading to
> inefficiencies due to multiple lookups.
> 
> Centralize all format information in a data structure and create a
> function to look up information based on the format 4CC.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/gpu/drm/drm_crtc.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++
>  include/drm/drm_crtc.h     | 21 ++++++++++++
>  2 files changed, 104 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 0e3cc66aa8b7..74b0c6dd80cd 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -5544,6 +5544,89 @@ int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
>  }
>  
>  /**
> + * drm_format_info - information for a given format
> + * @format: pixel format (DRM_FORMAT_*)
> + *
> + * Returns:
> + * The instance of struct drm_format_info that describes the pixel format, or
> + * NULL if the format is unsupported.
> + */
> +const struct drm_format_info *drm_format_info(u32 format)
> +{
> +	static const struct drm_format_info formats[] = {
> +		{ DRM_FORMAT_C8, 8, 8, 1, { 1 }, 1, 1 },

Named initializers please.

> +		{ DRM_FORMAT_RGB332, 8, 8, 1, { 1 }, 1, 1 },
> +		{ DRM_FORMAT_BGR233, 8, 8, 1, { 1 }, 1, 1 },
> +		{ DRM_FORMAT_XRGB4444, 12, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_XBGR4444, 12, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_RGBX4444, 12, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_BGRX4444, 12, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_ARGB4444, 12, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_ABGR4444, 12, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_RGBA4444, 12, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_BGRA4444, 12, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_XRGB1555, 15, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_XBGR1555, 15, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_RGBX5551, 15, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_BGRX5551, 15, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_ARGB1555, 15, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_ABGR1555, 15, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_RGBA5551, 15, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_BGRA5551, 15, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_RGB565, 16, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_BGR565, 16, 16, 1, { 2 }, 1, 1 },
> +		{ DRM_FORMAT_RGB888, 24, 24, 1, { 3 }, 1, 1 },
> +		{ DRM_FORMAT_BGR888, 24, 24, 1, { 3 }, 1, 1 },
> +		{ DRM_FORMAT_XRGB8888, 24, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_XBGR8888, 24, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_RGBX8888, 24, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_BGRX8888, 24, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_XRGB2101010, 30, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_XBGR2101010, 30, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_RGBX1010102, 30, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_BGRX1010102, 30, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_ARGB2101010, 30, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_ABGR2101010, 30, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_RGBA1010102, 30, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_BGRA1010102, 30, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_ARGB8888, 32, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_ABGR8888, 32, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_RGBA8888, 32, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_BGRA8888, 32, 32, 1, { 4 }, 1, 1 },
> +		{ DRM_FORMAT_YUV410, 0, 0, 3, { 1, 1, 1 }, 4, 4 },
> +		{ DRM_FORMAT_YVU410, 0, 0, 3, { 1, 1, 1 }, 4, 4 },
> +		{ DRM_FORMAT_YUV411, 0, 0, 3, { 1, 1, 1 }, 4, 1 },
> +		{ DRM_FORMAT_YVU411, 0, 0, 3, { 1, 1, 1 }, 4, 1 },
> +		{ DRM_FORMAT_YUV420, 0, 0, 3, { 1, 1, 1 }, 2, 2 },
> +		{ DRM_FORMAT_YVU420, 0, 0, 3, { 1, 1, 1 }, 2, 2 },
> +		{ DRM_FORMAT_YUV422, 0, 0, 3, { 1, 1, 1 }, 2, 1 },
> +		{ DRM_FORMAT_YVU422, 0, 0, 3, { 1, 1, 1 }, 2, 1 },
> +		{ DRM_FORMAT_YUV444, 0, 0, 3, { 1, 1, 1 }, 1, 1 },
> +		{ DRM_FORMAT_YVU444, 0, 0, 3, { 1, 1, 1 }, 1, 1 },
> +		{ DRM_FORMAT_NV12, 0, 0, 2, { 1, 2 }, 2, 2 },
> +		{ DRM_FORMAT_NV21, 0, 0, 2, { 1, 2 }, 2, 2 },
> +		{ DRM_FORMAT_NV16, 0, 0, 2, { 1, 2 }, 2, 1 },
> +		{ DRM_FORMAT_NV61, 0, 0, 2, { 1, 2 }, 2, 1 },
> +		{ DRM_FORMAT_NV24, 0, 0, 2, { 1, 2 }, 1, 1 },
> +		{ DRM_FORMAT_NV42, 0, 0, 2, { 1, 2 }, 1, 1 },
> +		{ DRM_FORMAT_YUYV, 0, 0, 1, { 2 }, 2, 1 },
> +		{ DRM_FORMAT_YVYU, 0, 0, 1, { 2 }, 2, 1 },
> +		{ DRM_FORMAT_UYVY, 0, 0, 1, { 2 }, 2, 1 },
> +		{ DRM_FORMAT_VYUY, 0, 0, 1, { 2 }, 2, 1 },
> +		{ DRM_FORMAT_AYUV, 0, 0, 1, { 4 }, 1, 1 },
> +	};
> +
> +	unsigned int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(formats); ++i) {
> +		if (formats[i].format == format)
> +			return &formats[i];
> +	}
> +
> +	return NULL;
> +}
> +
> +/**
>   * drm_fb_get_bpp_depth - get the bpp/depth values for format
>   * @format: pixel format (DRM_FORMAT_*)
>   * @depth: storage for the depth value
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index d1559cd04e3d..4199794cc317 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -155,6 +155,26 @@ struct drm_display_info {
>  	u8 cea_rev;
>  };
>  
> +/**
> + * struct drm_format_info - information about a DRM format
> + * @format: 4CC format identifier (DRM_FORMAT_*)
> + * @depth: color depth (number of bits per pixel excluding padding bits)
> + * @bpp: number of bits per pixel including padding
> + * @num_planes: number of color planes (1 to 3)
> + * @cpp: number of bytes per pixel (per plane)
> + * @hsub: horizontal chroma subsampling factor
> + * @vsub: vertical chroma subsampling factor
> + */
> +struct drm_format_info {
> +	u32 format;
> +	unsigned int depth;
> +	unsigned int bpp;
> +	unsigned int num_planes;
> +	unsigned int cpp[3];
> +	unsigned int hsub;
> +	unsigned int vsub;
> +};
> +
>  /* data corresponds to displayid vend/prod/serial */
>  struct drm_tile_group {
>  	struct kref refcount;
> @@ -2540,6 +2560,7 @@ extern int drm_mode_plane_set_obj_prop(struct drm_plane *plane,
>  extern int drm_mode_atomic_ioctl(struct drm_device *dev,
>  				 void *data, struct drm_file *file_priv);
>  
> +extern const struct drm_format_info *drm_format_info(u32 format);
>  extern void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth,
>  				 int *bpp);
>  extern int drm_format_num_planes(uint32_t format);
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Laurent Pinchart June 7, 2016, 1:24 p.m. UTC | #6
Hi Ville,

On Tuesday 07 Jun 2016 16:20:17 Ville Syrjälä wrote:
> On Tue, Jun 07, 2016 at 02:33:11AM +0300, Laurent Pinchart wrote:
> > Various pieces of information about DRM formats (number of planes, color
> > depth, chroma subsampling, ...) are scattered across different helper
> > functions in the DRM core. Callers of those functions often need to
> > access more than a single parameter of the format, leading to
> > inefficiencies due to multiple lookups.
> > 
> > Centralize all format information in a data structure and create a
> > function to look up information based on the format 4CC.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> > 
> >  drivers/gpu/drm/drm_crtc.c | 83 +++++++++++++++++++++++++++++++++++++++++
> >  include/drm/drm_crtc.h     | 21 ++++++++++++
> >  2 files changed, 104 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> > index 0e3cc66aa8b7..74b0c6dd80cd 100644
> > --- a/drivers/gpu/drm/drm_crtc.c
> > +++ b/drivers/gpu/drm/drm_crtc.c
> > @@ -5544,6 +5544,89 @@ int drm_mode_destroy_dumb_ioctl(struct drm_device
> > *dev,> 
> >  }
> >  
> >  /**
> > 
> > + * drm_format_info - information for a given format
> > + * @format: pixel format (DRM_FORMAT_*)
> > + *
> > + * Returns:
> > + * The instance of struct drm_format_info that describes the pixel
> > format, or + * NULL if the format is unsupported.
> > + */
> > +const struct drm_format_info *drm_format_info(u32 format)
> > +{
> > +	static const struct drm_format_info formats[] = {
> > +		{ DRM_FORMAT_C8, 8, 8, 1, { 1 }, 1, 1 },
> 
> Named initializers please.

Do we really want to expand every entry to 7 lines ? I can do so, but it won't 
look pretty.

> > +		{ DRM_FORMAT_RGB332, 8, 8, 1, { 1 }, 1, 1 },
> > +		{ DRM_FORMAT_BGR233, 8, 8, 1, { 1 }, 1, 1 },
> > +		{ DRM_FORMAT_XRGB4444, 12, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_XBGR4444, 12, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_RGBX4444, 12, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_BGRX4444, 12, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_ARGB4444, 12, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_ABGR4444, 12, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_RGBA4444, 12, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_BGRA4444, 12, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_XRGB1555, 15, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_XBGR1555, 15, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_RGBX5551, 15, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_BGRX5551, 15, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_ARGB1555, 15, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_ABGR1555, 15, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_RGBA5551, 15, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_BGRA5551, 15, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_RGB565, 16, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_BGR565, 16, 16, 1, { 2 }, 1, 1 },
> > +		{ DRM_FORMAT_RGB888, 24, 24, 1, { 3 }, 1, 1 },
> > +		{ DRM_FORMAT_BGR888, 24, 24, 1, { 3 }, 1, 1 },
> > +		{ DRM_FORMAT_XRGB8888, 24, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_XBGR8888, 24, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_RGBX8888, 24, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_BGRX8888, 24, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_XRGB2101010, 30, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_XBGR2101010, 30, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_RGBX1010102, 30, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_BGRX1010102, 30, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_ARGB2101010, 30, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_ABGR2101010, 30, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_RGBA1010102, 30, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_BGRA1010102, 30, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_ARGB8888, 32, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_ABGR8888, 32, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_RGBA8888, 32, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_BGRA8888, 32, 32, 1, { 4 }, 1, 1 },
> > +		{ DRM_FORMAT_YUV410, 0, 0, 3, { 1, 1, 1 }, 4, 4 },
> > +		{ DRM_FORMAT_YVU410, 0, 0, 3, { 1, 1, 1 }, 4, 4 },
> > +		{ DRM_FORMAT_YUV411, 0, 0, 3, { 1, 1, 1 }, 4, 1 },
> > +		{ DRM_FORMAT_YVU411, 0, 0, 3, { 1, 1, 1 }, 4, 1 },
> > +		{ DRM_FORMAT_YUV420, 0, 0, 3, { 1, 1, 1 }, 2, 2 },
> > +		{ DRM_FORMAT_YVU420, 0, 0, 3, { 1, 1, 1 }, 2, 2 },
> > +		{ DRM_FORMAT_YUV422, 0, 0, 3, { 1, 1, 1 }, 2, 1 },
> > +		{ DRM_FORMAT_YVU422, 0, 0, 3, { 1, 1, 1 }, 2, 1 },
> > +		{ DRM_FORMAT_YUV444, 0, 0, 3, { 1, 1, 1 }, 1, 1 },
> > +		{ DRM_FORMAT_YVU444, 0, 0, 3, { 1, 1, 1 }, 1, 1 },
> > +		{ DRM_FORMAT_NV12, 0, 0, 2, { 1, 2 }, 2, 2 },
> > +		{ DRM_FORMAT_NV21, 0, 0, 2, { 1, 2 }, 2, 2 },
> > +		{ DRM_FORMAT_NV16, 0, 0, 2, { 1, 2 }, 2, 1 },
> > +		{ DRM_FORMAT_NV61, 0, 0, 2, { 1, 2 }, 2, 1 },
> > +		{ DRM_FORMAT_NV24, 0, 0, 2, { 1, 2 }, 1, 1 },
> > +		{ DRM_FORMAT_NV42, 0, 0, 2, { 1, 2 }, 1, 1 },
> > +		{ DRM_FORMAT_YUYV, 0, 0, 1, { 2 }, 2, 1 },
> > +		{ DRM_FORMAT_YVYU, 0, 0, 1, { 2 }, 2, 1 },
> > +		{ DRM_FORMAT_UYVY, 0, 0, 1, { 2 }, 2, 1 },
> > +		{ DRM_FORMAT_VYUY, 0, 0, 1, { 2 }, 2, 1 },
> > +		{ DRM_FORMAT_AYUV, 0, 0, 1, { 4 }, 1, 1 },
> > +	};
> > +
> > +	unsigned int i;
> > +
> > +	for (i = 0; i < ARRAY_SIZE(formats); ++i) {
> > +		if (formats[i].format == format)
> > +			return &formats[i];
> > +	}
> > +
> > +	return NULL;
> > +}
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 0e3cc66aa8b7..74b0c6dd80cd 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -5544,6 +5544,89 @@  int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
 }
 
 /**
+ * drm_format_info - information for a given format
+ * @format: pixel format (DRM_FORMAT_*)
+ *
+ * Returns:
+ * The instance of struct drm_format_info that describes the pixel format, or
+ * NULL if the format is unsupported.
+ */
+const struct drm_format_info *drm_format_info(u32 format)
+{
+	static const struct drm_format_info formats[] = {
+		{ DRM_FORMAT_C8, 8, 8, 1, { 1 }, 1, 1 },
+		{ DRM_FORMAT_RGB332, 8, 8, 1, { 1 }, 1, 1 },
+		{ DRM_FORMAT_BGR233, 8, 8, 1, { 1 }, 1, 1 },
+		{ DRM_FORMAT_XRGB4444, 12, 16, 1, { 2 }, 1, 1 },
+		{ DRM_FORMAT_XBGR4444, 12, 16, 1, { 2 }, 1, 1 },
+		{ DRM_FORMAT_RGBX4444, 12, 16, 1, { 2 }, 1, 1 },
+		{ DRM_FORMAT_BGRX4444, 12, 16, 1, { 2 }, 1, 1 },
+		{ DRM_FORMAT_ARGB4444, 12, 16, 1, { 2 }, 1, 1 },
+		{ DRM_FORMAT_ABGR4444, 12, 16, 1, { 2 }, 1, 1 },
+		{ DRM_FORMAT_RGBA4444, 12, 16, 1, { 2 }, 1, 1 },
+		{ DRM_FORMAT_BGRA4444, 12, 16, 1, { 2 }, 1, 1 },
+		{ DRM_FORMAT_XRGB1555, 15, 16, 1, { 2 }, 1, 1 },
+		{ DRM_FORMAT_XBGR1555, 15, 16, 1, { 2 }, 1, 1 },
+		{ DRM_FORMAT_RGBX5551, 15, 16, 1, { 2 }, 1, 1 },
+		{ DRM_FORMAT_BGRX5551, 15, 16, 1, { 2 }, 1, 1 },
+		{ DRM_FORMAT_ARGB1555, 15, 16, 1, { 2 }, 1, 1 },
+		{ DRM_FORMAT_ABGR1555, 15, 16, 1, { 2 }, 1, 1 },
+		{ DRM_FORMAT_RGBA5551, 15, 16, 1, { 2 }, 1, 1 },
+		{ DRM_FORMAT_BGRA5551, 15, 16, 1, { 2 }, 1, 1 },
+		{ DRM_FORMAT_RGB565, 16, 16, 1, { 2 }, 1, 1 },
+		{ DRM_FORMAT_BGR565, 16, 16, 1, { 2 }, 1, 1 },
+		{ DRM_FORMAT_RGB888, 24, 24, 1, { 3 }, 1, 1 },
+		{ DRM_FORMAT_BGR888, 24, 24, 1, { 3 }, 1, 1 },
+		{ DRM_FORMAT_XRGB8888, 24, 32, 1, { 4 }, 1, 1 },
+		{ DRM_FORMAT_XBGR8888, 24, 32, 1, { 4 }, 1, 1 },
+		{ DRM_FORMAT_RGBX8888, 24, 32, 1, { 4 }, 1, 1 },
+		{ DRM_FORMAT_BGRX8888, 24, 32, 1, { 4 }, 1, 1 },
+		{ DRM_FORMAT_XRGB2101010, 30, 32, 1, { 4 }, 1, 1 },
+		{ DRM_FORMAT_XBGR2101010, 30, 32, 1, { 4 }, 1, 1 },
+		{ DRM_FORMAT_RGBX1010102, 30, 32, 1, { 4 }, 1, 1 },
+		{ DRM_FORMAT_BGRX1010102, 30, 32, 1, { 4 }, 1, 1 },
+		{ DRM_FORMAT_ARGB2101010, 30, 32, 1, { 4 }, 1, 1 },
+		{ DRM_FORMAT_ABGR2101010, 30, 32, 1, { 4 }, 1, 1 },
+		{ DRM_FORMAT_RGBA1010102, 30, 32, 1, { 4 }, 1, 1 },
+		{ DRM_FORMAT_BGRA1010102, 30, 32, 1, { 4 }, 1, 1 },
+		{ DRM_FORMAT_ARGB8888, 32, 32, 1, { 4 }, 1, 1 },
+		{ DRM_FORMAT_ABGR8888, 32, 32, 1, { 4 }, 1, 1 },
+		{ DRM_FORMAT_RGBA8888, 32, 32, 1, { 4 }, 1, 1 },
+		{ DRM_FORMAT_BGRA8888, 32, 32, 1, { 4 }, 1, 1 },
+		{ DRM_FORMAT_YUV410, 0, 0, 3, { 1, 1, 1 }, 4, 4 },
+		{ DRM_FORMAT_YVU410, 0, 0, 3, { 1, 1, 1 }, 4, 4 },
+		{ DRM_FORMAT_YUV411, 0, 0, 3, { 1, 1, 1 }, 4, 1 },
+		{ DRM_FORMAT_YVU411, 0, 0, 3, { 1, 1, 1 }, 4, 1 },
+		{ DRM_FORMAT_YUV420, 0, 0, 3, { 1, 1, 1 }, 2, 2 },
+		{ DRM_FORMAT_YVU420, 0, 0, 3, { 1, 1, 1 }, 2, 2 },
+		{ DRM_FORMAT_YUV422, 0, 0, 3, { 1, 1, 1 }, 2, 1 },
+		{ DRM_FORMAT_YVU422, 0, 0, 3, { 1, 1, 1 }, 2, 1 },
+		{ DRM_FORMAT_YUV444, 0, 0, 3, { 1, 1, 1 }, 1, 1 },
+		{ DRM_FORMAT_YVU444, 0, 0, 3, { 1, 1, 1 }, 1, 1 },
+		{ DRM_FORMAT_NV12, 0, 0, 2, { 1, 2 }, 2, 2 },
+		{ DRM_FORMAT_NV21, 0, 0, 2, { 1, 2 }, 2, 2 },
+		{ DRM_FORMAT_NV16, 0, 0, 2, { 1, 2 }, 2, 1 },
+		{ DRM_FORMAT_NV61, 0, 0, 2, { 1, 2 }, 2, 1 },
+		{ DRM_FORMAT_NV24, 0, 0, 2, { 1, 2 }, 1, 1 },
+		{ DRM_FORMAT_NV42, 0, 0, 2, { 1, 2 }, 1, 1 },
+		{ DRM_FORMAT_YUYV, 0, 0, 1, { 2 }, 2, 1 },
+		{ DRM_FORMAT_YVYU, 0, 0, 1, { 2 }, 2, 1 },
+		{ DRM_FORMAT_UYVY, 0, 0, 1, { 2 }, 2, 1 },
+		{ DRM_FORMAT_VYUY, 0, 0, 1, { 2 }, 2, 1 },
+		{ DRM_FORMAT_AYUV, 0, 0, 1, { 4 }, 1, 1 },
+	};
+
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(formats); ++i) {
+		if (formats[i].format == format)
+			return &formats[i];
+	}
+
+	return NULL;
+}
+
+/**
  * drm_fb_get_bpp_depth - get the bpp/depth values for format
  * @format: pixel format (DRM_FORMAT_*)
  * @depth: storage for the depth value
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index d1559cd04e3d..4199794cc317 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -155,6 +155,26 @@  struct drm_display_info {
 	u8 cea_rev;
 };
 
+/**
+ * struct drm_format_info - information about a DRM format
+ * @format: 4CC format identifier (DRM_FORMAT_*)
+ * @depth: color depth (number of bits per pixel excluding padding bits)
+ * @bpp: number of bits per pixel including padding
+ * @num_planes: number of color planes (1 to 3)
+ * @cpp: number of bytes per pixel (per plane)
+ * @hsub: horizontal chroma subsampling factor
+ * @vsub: vertical chroma subsampling factor
+ */
+struct drm_format_info {
+	u32 format;
+	unsigned int depth;
+	unsigned int bpp;
+	unsigned int num_planes;
+	unsigned int cpp[3];
+	unsigned int hsub;
+	unsigned int vsub;
+};
+
 /* data corresponds to displayid vend/prod/serial */
 struct drm_tile_group {
 	struct kref refcount;
@@ -2540,6 +2560,7 @@  extern int drm_mode_plane_set_obj_prop(struct drm_plane *plane,
 extern int drm_mode_atomic_ioctl(struct drm_device *dev,
 				 void *data, struct drm_file *file_priv);
 
+extern const struct drm_format_info *drm_format_info(u32 format);
 extern void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth,
 				 int *bpp);
 extern int drm_format_num_planes(uint32_t format);