[PATCH] rpi-backend: refactor the configuration API
Benoit Gschwind
gschwind at gnu-log.net
Fri Apr 29 13:08:43 UTC 2016
Signed-off-by: Benoit Gschwind <gschwind at gnu-log.net>
---
NOTE: The patch is theorical and wasn't tested on rasbery-pi
src/compositor-rpi.c | 42 ++++++++++++++++--------------------------
src/main.c | 40 ++++++++++++++++++++++++++++++++++++++--
2 files changed, 54 insertions(+), 28 deletions(-)
diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c
index 75b808e..cf24d3f 100644
--- a/src/compositor-rpi.c
+++ b/src/compositor-rpi.c
@@ -47,6 +47,7 @@
#include "shared/helpers.h"
#include "compositor.h"
+#include "compositor-rpi.h"
#include "rpi-renderer.h"
#include "launcher-util.h"
#include "libinput-seat.h"
@@ -455,9 +456,10 @@ struct rpi_parameters {
static struct rpi_backend *
rpi_backend_create(struct weston_compositor *compositor,
- struct rpi_parameters *param)
+ struct weston_rpi_backend_config *param)
{
struct rpi_backend *backend;
+ struct rpi_renderer_parameters renderer_param;
weston_log("initializing Raspberry Pi backend\n");
@@ -490,7 +492,7 @@ rpi_backend_create(struct weston_compositor *compositor,
backend->compositor = compositor;
backend->prev_state = WESTON_COMPOSITOR_ACTIVE;
- backend->single_buffer = param->renderer.single_buffer;
+ backend->single_buffer = param->single_buffer;
weston_log("Dispmanx planes are %s buffered.\n",
backend->single_buffer ? "single" : "double");
@@ -506,7 +508,9 @@ rpi_backend_create(struct weston_compositor *compositor,
*/
bcm_host_init();
- if (rpi_renderer_create(compositor, ¶m->renderer) < 0)
+ renderer_param.single_buffer = param->single_buffer;
+ renderer_param.opaque_regions = param->opaque_regions;
+ if (rpi_renderer_create(compositor, &renderer_param) < 0)
goto out_launcher;
if (rpi_output_create(backend, param->output_transform) < 0)
@@ -541,34 +545,20 @@ out_compositor:
WL_EXPORT int
backend_init(struct weston_compositor *compositor,
int *argc, char *argv[],
- struct weston_config *config,
+ struct weston_config *wc,
struct weston_backend_config *config_base)
{
- const char *transform = "normal";
struct rpi_backend *b;
+ struct weston_rpi_backend_config config = {{ 0, }};
- struct rpi_parameters param = {
- .tty = 0, /* default to current tty */
- .renderer.single_buffer = 0,
- .output_transform = WL_OUTPUT_TRANSFORM_NORMAL,
- .renderer.opaque_regions = 0,
- };
-
- const struct weston_option rpi_options[] = {
- { WESTON_OPTION_INTEGER, "tty", 0, ¶m.tty },
- { WESTON_OPTION_BOOLEAN, "single-buffer", 0,
- ¶m.renderer.single_buffer },
- { WESTON_OPTION_STRING, "transform", 0, &transform },
- { WESTON_OPTION_BOOLEAN, "opaque-regions", 0,
- ¶m.renderer.opaque_regions },
- };
-
- parse_options(rpi_options, ARRAY_LENGTH(rpi_options), argc, argv);
-
- if (weston_parse_transform(transform, ¶m.output_transform) < 0)
- weston_log("invalid transform \"%s\"\n", transform);
+ if (config_base == NULL ||
+ config_base->struct_version != WESTON_RPI_BACKEND_CONFIG_VERSION ||
+ config_base->struct_size > sizeof(struct weston_rpi_backend_config)) {
+ weston_log("rpi backend config structure is invalid\n");
+ return -1;
+ }
- b = rpi_backend_create(compositor, ¶m);
+ b = rpi_backend_create(compositor, &config);
if (b == NULL)
return -1;
return 0;
diff --git a/src/main.c b/src/main.c
index 4c9e035..cb64a6b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -50,6 +50,7 @@
#include "compositor-headless.h"
#include "compositor-rdp.h"
#include "compositor-fbdev.h"
+#include "compositor-rpi.h"
static struct wl_list child_process_list;
static struct weston_compositor *segv_compositor;
@@ -805,6 +806,41 @@ load_fbdev_backend(struct weston_compositor *c, char const * backend,
}
static int
+load_rpi_backend(struct weston_compositor *c, char const * backend,
+ int *argc, char *argv[], struct weston_config *wc)
+{
+ char *transform = NULL;
+ int ret = 0;
+
+ struct weston_rpi_backend_config config = {
+ .tty = 0, /* default to current tty */
+ .single_buffer = 0,
+ .output_transform = WL_OUTPUT_TRANSFORM_NORMAL,
+ .opaque_regions = 0,
+ };
+
+ const struct weston_option rpi_options[] = {
+ { WESTON_OPTION_INTEGER, "tty", 0, &config.tty },
+ { WESTON_OPTION_BOOLEAN, "single-buffer", 0,
+ &config.single_buffer },
+ { WESTON_OPTION_STRING, "transform", 0, &transform },
+ { WESTON_OPTION_BOOLEAN, "opaque-regions", 0,
+ &config.opaque_regions },
+ };
+
+ parse_options(rpi_options, ARRAY_LENGTH(rpi_options), argc, argv);
+
+ if (transform) {
+ if (weston_parse_transform(transform, &config.output_transform) < 0)
+ weston_log("invalid transform \"%s\"\n", transform);
+ free(transform);
+ }
+
+ ret = load_backend_new(c, backend, &config.base);
+ return ret;
+}
+
+static int
load_backend(struct weston_compositor *compositor, const char *backend,
int *argc, char **argv, struct weston_config *config)
{
@@ -814,6 +850,8 @@ load_backend(struct weston_compositor *compositor, const char *backend,
return load_rdp_backend(compositor, backend, argc, argv, config);
else if (strstr(backend, "fbdev-backend.so"))
return load_fbdev_backend(compositor, backend, argc, argv, config);
+ else if (strstr(backend, "rpi-backend.so"))
+ return load_rpi_backend(compositor, backend, argc, argv, config);
#if 0
else if (strstr(backend, "drm-backend.so"))
return load_drm_backend(compositor, backend, argc, argv, config);
@@ -821,8 +859,6 @@ load_backend(struct weston_compositor *compositor, const char *backend,
return load_wayland_backend(compositor, backend, argc, argv, config);
else if (strstr(backend, "x11-backend.so"))
return load_x11_backend(compositor, backend, argc, argv, config);
- else if (strstr(backend, "rpi-backend.so"))
- return load_rpi_backend(compositor, backend, argc, argv, config);
#endif
return load_backend_old(compositor, backend, argc, argv, config);
--
2.7.3
More information about the wayland-devel
mailing list