1 From 91b452fa515b94928d32af6e1b1b0405469747fd Mon Sep 17 00:00:00 2001
2 From: Tomi Valkeinen <tomi.valkeinen@ti.com>
3 Date: Wed, 8 Mar 2017 13:05:38 -0500
4 Subject: [PATCH] compositor-drm: support RGB565 with pixman renderer
6 At the moment only XRGB8888 is supported when using pixman renderer.
7 This patch adds support also for RGB565.
9 Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
10 Reviewed-by: Daniel Stone <daniels@collabora.com>
11 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
12 Signed-off-by: Daniel Stone <daniels@collabora.com>
14 src/compositor-drm.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++------
15 1 file changed, 55 insertions(+), 7 deletions(-)
17 diff --git a/src/compositor-drm.c b/src/compositor-drm.c
18 index fd89627..443b69a 100644
19 --- a/src/compositor-drm.c
20 +++ b/src/compositor-drm.c
21 @@ -262,10 +262,12 @@ drm_fb_destroy_callback(struct gbm_bo *bo, void *data)
24 static struct drm_fb *
25 -drm_fb_create_dumb(struct drm_backend *b, unsigned width, unsigned height)
26 +drm_fb_create_dumb(struct drm_backend *b, unsigned width, unsigned height,
31 + uint32_t bpp, depth;
33 struct drm_mode_create_dumb create_arg;
34 struct drm_mode_destroy_dumb destroy_arg;
35 @@ -275,8 +277,20 @@ drm_fb_create_dumb(struct drm_backend *b, unsigned width, unsigned height)
40 + case GBM_FORMAT_XRGB8888:
44 + case GBM_FORMAT_RGB565:
51 memset(&create_arg, 0, sizeof create_arg);
52 - create_arg.bpp = 32;
53 + create_arg.bpp = bpp;
54 create_arg.width = width;
55 create_arg.height = height;
57 @@ -289,8 +303,29 @@ drm_fb_create_dumb(struct drm_backend *b, unsigned width, unsigned height)
58 fb->size = create_arg.size;
61 - ret = drmModeAddFB(b->drm.fd, width, height, 24, 32,
62 - fb->stride, fb->handle, &fb->fb_id);
65 + if (!b->no_addfb2) {
66 + uint32_t handles[4], pitches[4], offsets[4];
68 + handles[0] = fb->handle;
69 + pitches[0] = fb->stride;
72 + ret = drmModeAddFB2(b->drm.fd, width, height,
73 + format, handles, pitches, offsets,
76 + weston_log("addfb2 failed: %m\n");
82 + ret = drmModeAddFB(b->drm.fd, width, height, depth, bpp,
83 + fb->stride, fb->handle, &fb->fb_id);
89 @@ -1879,17 +1914,30 @@ drm_output_init_pixman(struct drm_output *output, struct drm_backend *b)
91 int w = output->base.current_mode->width;
92 int h = output->base.current_mode->height;
93 + uint32_t format = output->gbm_format;
94 + uint32_t pixman_format;
97 - /* FIXME error checking */
99 + case GBM_FORMAT_XRGB8888:
100 + pixman_format = PIXMAN_x8r8g8b8;
102 + case GBM_FORMAT_RGB565:
103 + pixman_format = PIXMAN_r5g6b5;
106 + weston_log("Unsupported pixman format 0x%x\n", format);
110 + /* FIXME error checking */
111 for (i = 0; i < ARRAY_LENGTH(output->dumb); i++) {
112 - output->dumb[i] = drm_fb_create_dumb(b, w, h);
113 + output->dumb[i] = drm_fb_create_dumb(b, w, h, format);
114 if (!output->dumb[i])
118 - pixman_image_create_bits(PIXMAN_x8r8g8b8, w, h,
119 + pixman_image_create_bits(pixman_format, w, h,
120 output->dumb[i]->map,
121 output->dumb[i]->stride);
122 if (!output->image[i])