Signed-off-by: Benoit Gschwind <[email protected]>
---
v1:
 - fix missing file
 - update Makefile.am

 Makefile.am          |  3 +++
 src/compositor-rpi.c | 42 ++++++++++++++++--------------------------
 src/compositor-rpi.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/main.c           | 40 ++++++++++++++++++++++++++++++++++++++--
 4 files changed, 106 insertions(+), 28 deletions(-)
 create mode 100644 src/compositor-rpi.h

diff --git a/Makefile.am b/Makefile.am
index f94eae2..9b240ca 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -75,6 +75,7 @@ weston_SOURCES =                                      \
        src/compositor-headless.h                       \
        src/compositor-fbdev.h                          \
        src/compositor-rdp.h                            \
+       src/compositor-rpi.h                            \
        src/input.c                                     \
        src/data-device.c                               \
        src/screenshooter.c                             \
@@ -214,6 +215,7 @@ westoninclude_HEADERS =                             \
        src/compositor-headless.h               \
        src/compositor-fbdev.h                  \
        src/compositor-rdp.h                    \
+       src/compositor-rpi.h                    \
        src/timeline-object.h                   \
        shared/matrix.h                         \
        shared/config-parser.h                  \
@@ -340,6 +342,7 @@ rpi_backend_la_CFLAGS =                             \
        $(RPI_BCM_HOST_CFLAGS)
 rpi_backend_la_SOURCES =                       \
        src/compositor-rpi.c                    \
+       src/compositor-rpi.h                    \
        src/rpi-renderer.c                      \
        src/rpi-renderer.h                      \
        src/rpi-bcm-stubs.h                     \
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, &param->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, &param.tty },
-               { WESTON_OPTION_BOOLEAN, "single-buffer", 0,
-                 &param.renderer.single_buffer },
-               { WESTON_OPTION_STRING, "transform", 0, &transform },
-               { WESTON_OPTION_BOOLEAN, "opaque-regions", 0,
-                 &param.renderer.opaque_regions },
-       };
-
-       parse_options(rpi_options, ARRAY_LENGTH(rpi_options), argc, argv);
-
-       if (weston_parse_transform(transform, &param.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, &param);
+       b = rpi_backend_create(compositor, &config);
        if (b == NULL)
                return -1;
        return 0;
diff --git a/src/compositor-rpi.h b/src/compositor-rpi.h
new file mode 100644
index 0000000..d897109
--- /dev/null
+++ b/src/compositor-rpi.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright © 2016 Benoit Gschwind
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef WESTON_COMPOSITOR_RPI_H
+#define WESTON_COMPOSITOR_RPI_H
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+#include "compositor.h"
+
+#define WESTON_RPI_BACKEND_CONFIG_VERSION 1
+
+struct weston_rpi_backend_config {
+       struct weston_backend_config base;
+       int tty;
+       int single_buffer;
+       int opaque_regions;
+       uint32_t output_transform;
+};
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif /* WESTON_COMPOSITOR_RPI_H */
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

_______________________________________________
wayland-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to