[PATCH weston 16/68] compositor-drm: Store format in drm_fb

Pekka Paalanen ppaalanen at gmail.com
Tue Feb 21 13:46:25 UTC 2017


On Fri,  9 Dec 2016 19:57:31 +0000
Daniel Stone <daniels at collabora.com> wrote:

> This uses the new pixel-format helpers, so we can also replace depth/bpp
> with these.
> 
> Signed-off-by: Daniel Stone <daniels at collabora.com>
> 
> Differential Revision: https://phabricator.freedesktop.org/D1513
> ---
>  libweston/compositor-drm.c | 43 +++++++++++++++++++++++++++----------------
>  1 file changed, 27 insertions(+), 16 deletions(-)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index 217db32..af43a15 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -54,6 +54,7 @@
>  #include "gl-renderer.h"
>  #include "weston-egl-ext.h"
>  #include "pixman-renderer.h"
> +#include "pixel-formats.h"
>  #include "libbacklight.h"
>  #include "libinput-seat.h"
>  #include "launcher-util.h"
> @@ -140,6 +141,7 @@ struct drm_fb {
>  	enum drm_fb_type type;
>  
>  	uint32_t fb_id, stride, handle, size;
> +	const struct pixel_format_info *format;
>  	int width, height;
>  	int fd;
>  	struct weston_buffer_reference buffer_ref;
> @@ -267,7 +269,6 @@ drm_fb_create_dumb(struct drm_backend *b, int width, int height,
>  {
>  	struct drm_fb *fb;
>  	int ret;
> -	uint32_t bpp, depth;
>  
>  	struct drm_mode_create_dumb create_arg;
>  	struct drm_mode_destroy_dumb destroy_arg;
> @@ -277,20 +278,20 @@ drm_fb_create_dumb(struct drm_backend *b, int width, int height,
>  	if (!fb)
>  		return NULL;
>  
> -	switch (format) {
> -		case GBM_FORMAT_XRGB8888:
> -			bpp = 32;
> -			depth = 24;
> -			break;
> -		case GBM_FORMAT_RGB565:
> -			bpp = depth = 16;
> -			break;
> -		default:
> -			return NULL;
> +	fb->format = pixel_format_get_info(format);
> +	if (!fb->format) {
> +		weston_log("failed to look up format 0x%lx\n",
> +			   (unsigned long) format);
> +		goto err_fb;
> +	}
> +
> +	if (!fb->format->depth || !fb->format->bpp) {
> +		weston_log("format 0x%lx is not compatible with dumb buffers\n",
> +			   (unsigned long) format);

goto err_fb?

Otherwise:
Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>


Thanks,
pq

>  	}
>  
>  	memset(&create_arg, 0, sizeof create_arg);
> -	create_arg.bpp = bpp;
> +	create_arg.bpp = fb->format->bpp;
>  	create_arg.width = width;
>  	create_arg.height = height;
>  
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20170221/1f1e4e28/attachment-0001.sig>


More information about the wayland-devel mailing list