[PATCH v4 02/14] drm: Implement the drm_format_*() helpers as drm_format_info() wrappers

Daniel Vetter daniel at ffwll.ch
Wed Sep 21 07:34:13 UTC 2016


On Thu, Sep 08, 2016 at 05:44:16PM +0300, Laurent Pinchart wrote:
> Turn the drm_format_*() helpers into wrappers around the drm_format_info
> lookup function to centralize all format information in a single place.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
>  drivers/gpu/drm/drm_fourcc.c | 186 +++++++++----------------------------------
>  1 file changed, 37 insertions(+), 149 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> index 6b91bd8a510d..bf91c5044d84 100644
> --- a/drivers/gpu/drm/drm_fourcc.c
> +++ b/drivers/gpu/drm/drm_fourcc.c
> @@ -198,69 +198,22 @@ EXPORT_SYMBOL(drm_format_info);
>  void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth,
>  			  int *bpp)
>  {
> -	char *format_name;
> -
> -	switch (format) {
> -	case DRM_FORMAT_C8:
> -	case DRM_FORMAT_RGB332:
> -	case DRM_FORMAT_BGR233:
> -		*depth = 8;
> -		*bpp = 8;
> -		break;
> -	case DRM_FORMAT_XRGB1555:
> -	case DRM_FORMAT_XBGR1555:
> -	case DRM_FORMAT_RGBX5551:
> -	case DRM_FORMAT_BGRX5551:
> -	case DRM_FORMAT_ARGB1555:
> -	case DRM_FORMAT_ABGR1555:
> -	case DRM_FORMAT_RGBA5551:
> -	case DRM_FORMAT_BGRA5551:
> -		*depth = 15;
> -		*bpp = 16;
> -		break;
> -	case DRM_FORMAT_RGB565:
> -	case DRM_FORMAT_BGR565:
> -		*depth = 16;
> -		*bpp = 16;
> -		break;
> -	case DRM_FORMAT_RGB888:
> -	case DRM_FORMAT_BGR888:
> -		*depth = 24;
> -		*bpp = 24;
> -		break;
> -	case DRM_FORMAT_XRGB8888:
> -	case DRM_FORMAT_XBGR8888:
> -	case DRM_FORMAT_RGBX8888:
> -	case DRM_FORMAT_BGRX8888:
> -		*depth = 24;
> -		*bpp = 32;
> -		break;
> -	case DRM_FORMAT_XRGB2101010:
> -	case DRM_FORMAT_XBGR2101010:
> -	case DRM_FORMAT_RGBX1010102:
> -	case DRM_FORMAT_BGRX1010102:
> -	case DRM_FORMAT_ARGB2101010:
> -	case DRM_FORMAT_ABGR2101010:
> -	case DRM_FORMAT_RGBA1010102:
> -	case DRM_FORMAT_BGRA1010102:
> -		*depth = 30;
> -		*bpp = 32;
> -		break;
> -	case DRM_FORMAT_ARGB8888:
> -	case DRM_FORMAT_ABGR8888:
> -	case DRM_FORMAT_RGBA8888:
> -	case DRM_FORMAT_BGRA8888:
> -		*depth = 32;
> -		*bpp = 32;
> -		break;
> -	default:
> -		format_name = drm_get_format_name(format);
> +	const struct drm_format_info *info;
> +
> +	info = drm_format_info(format);
> +	if (!info || !info->depth) {
> +		char *format_name = drm_get_format_name(format);
> +
>  		DRM_DEBUG_KMS("unsupported pixel format %s\n", format_name);
>  		kfree(format_name);
> +
>  		*depth = 0;
>  		*bpp = 0;
> -		break;
> +		return;
>  	}
> +
> +	*depth = info->depth;
> +	*bpp = info->cpp[0] << 3;

Bikeshed: This is a funny way to write * 8 ... Would be nice to fix imo.

Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the dri-devel mailing list