From 8e6f376ef0beb4b2f619a32120a758f3667391b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 16 Oct 2013 16:31:42 -0700 Subject: [PATCH] compositor-drm: Support configuring the framebuffer format from weston.ini This patch adds a new weston.ini key, gbm-format, to the [core] section. This new key can be rgb565, xrgb8888 or xrgb2101010, and makes the compositor use the corresponding GBM format for the framebuffer. --- man/weston.ini.man | 7 +++++++ src/compositor-drm.c | 20 +++++++++++++++++++- weston.ini | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/man/weston.ini.man b/man/weston.ini.man index c5ec3218..d2524193 100644 --- a/man/weston.ini.man +++ b/man/weston.ini.man @@ -104,6 +104,13 @@ directory are: .BR xwayland.so .fi .RE +.TP 7 +.BI "gbm-format="format +sets the GBM format used for the framebuffer for the GBM backend. Can be +.B xrgb8888, +.B xrgb2101010, +.B rgb565. +By default, xrgb8888 is used. .RS .PP diff --git a/src/compositor-drm.c b/src/compositor-drm.c index 71cbcfa4..44545998 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -2581,9 +2581,11 @@ drm_compositor_create(struct wl_display *display, struct weston_config *config) { struct drm_compositor *ec; + struct weston_config_section *section; struct udev_device *drm_device; struct wl_event_loop *loop; const char *path; + char *s; uint32_t key; weston_log("initializing drm backend\n"); @@ -2595,7 +2597,23 @@ drm_compositor_create(struct wl_display *display, /* KMS support for sprites is not complete yet, so disable the * functionality for now. */ ec->sprites_are_broken = 1; - ec->format = GBM_FORMAT_XRGB8888; + + section = weston_config_get_section(config, "core", NULL, NULL); + weston_config_section_get_string(section, + "gbm-format", &s, "xrgb8888"); + if (strcmp(s, "xrgb8888") == 0) + ec->format = GBM_FORMAT_XRGB8888; + else if (strcmp(s, "rgb565") == 0) + ec->format = GBM_FORMAT_RGB565; + else if (strcmp(s, "xrgb2101010") == 0) + ec->format = GBM_FORMAT_XRGB2101010; + else { + weston_log("fatal: unrecognized pixel format: %s\n", s); + free(s); + goto err_base; + } + free(s); + ec->use_pixman = param->use_pixman; if (weston_compositor_init(&ec->base, display, argc, argv, diff --git a/weston.ini b/weston.ini index 70069316..4761bed1 100644 --- a/weston.ini +++ b/weston.ini @@ -1,6 +1,7 @@ [core] #modules=xwayland.so,cms-colord.so #shell=desktop-shell.so +#gbm-format=xrgb2101010 [shell] background-image=/usr/share/backgrounds/gnome/Aqua.jpg