summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Vlad <marius.vlad@collabora.com>2024-02-16 11:13:58 +0200
committerMarius Vlad <marius.vlad@collabora.com>2024-02-23 18:08:16 +0200
commite7ccf51adc37748d3ca000109d16d0495dc0a7e8 (patch)
tree076cad9b2f82546adff38b3dc093716f64b0bd29
parent754636273ffc6b872d6fb194009c857e76e7cec1 (diff)
compositor: Add the ability to load rdp-backend.so
Similar to Weston this loads the backend-rdp shared library. Bug-AGL: SPEC-5077 Signed-off-by: Marius Vlad <marius.vlad@collabora.com> Change-Id: Ib4e1d408fbb7e1eb0a09135c85a3275d424f7015
-rw-r--r--meson.build10
-rw-r--r--src/compositor.c175
-rw-r--r--src/ivi-compositor.h9
3 files changed, 183 insertions, 11 deletions
diff --git a/meson.build b/meson.build
index fc87e20..0357b29 100644
--- a/meson.build
+++ b/meson.build
@@ -169,14 +169,17 @@ if libweston_dep.found()
if not prefix_path.contains('/usr')
dir_path_x11_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-x11.h')
dir_path_headless_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-headless.h')
+ dir_path_rdp_backend = join_paths(prefix_path, 'include', libweston_version, 'libweston', 'backend-rdp.h')
else
dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
- dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-headless.h')
+ dir_path_headless_backend = join_paths(libweston_version, 'libweston', 'backend-headless.h')
+ dir_path_rdp = join_paths(libweston_version, 'libweston', 'backend-rdp.h')
endif
else
message('Building with cross environment')
dir_path_x11_backend = join_paths(libweston_version, 'libweston', 'backend-x11.h')
dir_path_headless_backend = join_paths(libweston_version, 'libweston', 'backend-headless.h')
+ dir_path_rdp_backend = join_paths(libweston_version, 'libweston', 'backend-rdp.h')
endif
# do the test
@@ -189,6 +192,11 @@ if libweston_dep.found()
config_h.set('HAVE_BACKEND_HEADLESS', 1)
message('Building with headless backend')
endif
+
+ if cc.has_header(dir_path_rdp_backend)
+ config_h.set('HAVE_BACKEND_RDP', 1)
+ message('Building with RDP backend')
+ endif
endif
if dep_libsystemd.found()
diff --git a/src/compositor.c b/src/compositor.c
index 827ef7a..3509cc0 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -39,6 +39,9 @@
#include <libweston/backend-drm.h>
#include <libweston/backend-wayland.h>
+#ifdef HAVE_BACKEND_RDP
+#include <libweston/backend-rdp.h>
+#endif
#ifdef HAVE_BACKEND_HEADLESS
#include <libweston/backend-headless.h>
#endif
@@ -69,6 +72,28 @@ to_ivi_compositor(struct weston_compositor *ec)
return weston_compositor_get_user_data(ec);
}
+static struct ivi_output_config *
+ivi_init_parsed_options(struct weston_compositor *compositor)
+{
+ struct ivi_compositor *ivi = to_ivi_compositor(compositor);
+ struct ivi_output_config *config;
+
+ config = zalloc(sizeof *config);
+ if (!config)
+ return NULL;
+
+ config->width = 0;
+ config->height = 0;
+ config->scale = 0;
+ config->transform = UINT32_MAX;
+
+ ivi->parsed_options = config;
+
+ return config;
+}
+
+
+
static void
sigint_helper(int sig)
{
@@ -218,7 +243,8 @@ ivi_output_configure_app_id(struct ivi_output *ivi_output)
static struct ivi_output *
ivi_ensure_output(struct ivi_compositor *ivi, char *name,
- struct weston_config_section *config)
+ struct weston_config_section *config,
+ struct weston_head *head)
{
struct ivi_output *output = NULL;
wl_list_for_each(output, &ivi->outputs, link) {
@@ -238,11 +264,41 @@ ivi_ensure_output(struct ivi_compositor *ivi, char *name,
output->name = name;
output->config = config;
- output->output = weston_compositor_create_output(ivi->compositor, name);
- if (!output->output) {
- free(output->name);
- free(output);
- return NULL;
+ if (ivi->simple_output_configure) {
+ output->output =
+ weston_compositor_create_output_with_head(ivi->compositor,
+ head);
+ if (!output->output) {
+ free(output->name);
+ free(output);
+ return NULL;
+ }
+
+ int ret = ivi->simple_output_configure(output->output);
+ if (ret < 0) {
+ weston_log("Configuring output \"%s\" failed.\n",
+ weston_head_get_name(head));
+ weston_output_destroy(output->output);
+ ivi->init_failed = true;
+ return NULL;
+ }
+
+ if (weston_output_enable(output->output) < 0) {
+ weston_log("Enabling output \"%s\" failed.\n",
+ weston_head_get_name(head));
+ weston_output_destroy(output->output);
+ ivi->init_failed = true;
+ return NULL;
+ }
+
+ } else {
+ output->output =
+ weston_compositor_create_output(ivi->compositor, name);
+ if (!output->output) {
+ free(output->name);
+ free(output);
+ return NULL;
+ }
}
output->output_destroy.notify = handle_output_destroy;
@@ -491,7 +547,6 @@ try_attach_heads(struct ivi_output *output)
output->add[fail_len++] = tmp;
}
}
-
return fail_len;
}
@@ -636,6 +691,7 @@ head_prepare_enable(struct ivi_compositor *ivi, struct weston_head *head)
struct ivi_output *output;
char *output_name = NULL;
+
section = find_controlling_output_config(ivi->config, name);
if (section) {
char *mode;
@@ -656,7 +712,7 @@ head_prepare_enable(struct ivi_compositor *ivi, struct weston_head *head)
if (!output_name)
return;
- output = ivi_ensure_output(ivi, output_name, section);
+ output = ivi_ensure_output(ivi, output_name, section, head);
if (!output)
return;
@@ -1199,6 +1255,104 @@ load_headless_backend(struct ivi_compositor *ivi, int *argc, char **argv)
}
#endif
+#ifdef HAVE_BACKEND_RDP
+static void
+weston_rdp_backend_config_init(struct weston_rdp_backend_config *config)
+{
+ config->base.struct_version = WESTON_RDP_BACKEND_CONFIG_VERSION;
+ config->base.struct_size = sizeof(struct weston_rdp_backend_config);
+
+ config->bind_address = NULL;
+ config->port = 3389;
+ config->rdp_key = NULL;
+ config->server_cert = NULL;
+ config->server_key = NULL;
+ config->env_socket = 0;
+ config->no_clients_resize = 1;
+ config->force_no_compression = 0;
+}
+
+static int
+rdp_backend_output_configure(struct weston_output *output)
+{
+ struct ivi_compositor *ivi = to_ivi_compositor(output->compositor);
+ struct ivi_output_config *parsed_options = ivi->parsed_options;
+ const struct weston_rdp_output_api *api =
+ weston_rdp_output_get_api(output->compositor);
+ int width = 640;
+ int height = 480;
+
+ assert(parsed_options);
+
+ if (!api) {
+ weston_log("Cannot use weston_rdp_output_api.\n");
+ return -1;
+ }
+
+ if (parsed_options->width)
+ width = parsed_options->width;
+
+ if (parsed_options->height)
+ height = parsed_options->height;
+
+ weston_output_set_scale(output, 1);
+ weston_output_set_transform(output, WL_OUTPUT_TRANSFORM_NORMAL);
+
+ if (api->output_set_size(output, width, height) < 0) {
+ weston_log("Cannot configure output \"%s\" using weston_rdp_output_api.\n",
+ output->name);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int
+load_rdp_backend(struct ivi_compositor *ivi, int *argc, char **argv)
+{
+ struct weston_rdp_backend_config config = {};
+ int ret = 0;
+
+ struct ivi_output_config *parsed_options = ivi_init_parsed_options(ivi->compositor);
+ if (!parsed_options)
+ return -1;
+
+ weston_rdp_backend_config_init(&config);
+
+ const struct weston_option rdp_options[] = {
+ { WESTON_OPTION_BOOLEAN, "env-socket", 0, &config.env_socket },
+ { WESTON_OPTION_INTEGER, "width", 0, &parsed_options->width },
+ { WESTON_OPTION_INTEGER, "height", 0, &parsed_options->height },
+ { WESTON_OPTION_STRING, "address", 0, &config.bind_address },
+ { WESTON_OPTION_INTEGER, "port", 0, &config.port },
+ { WESTON_OPTION_BOOLEAN, "no-clients-resize", 0, &config.no_clients_resize },
+ { WESTON_OPTION_STRING, "rdp4-key", 0, &config.rdp_key },
+ { WESTON_OPTION_STRING, "rdp-tls-cert", 0, &config.server_cert },
+ { WESTON_OPTION_STRING, "rdp-tls-key", 0, &config.server_key },
+ { WESTON_OPTION_BOOLEAN, "force-no-compression", 0, &config.force_no_compression },
+ };
+
+ parse_options(rdp_options, ARRAY_LENGTH(rdp_options), argc, argv);
+
+ ivi->simple_output_configure = rdp_backend_output_configure;
+ ret = weston_compositor_load_backend(ivi->compositor, WESTON_BACKEND_RDP, &config.base);
+
+ free(config.bind_address);
+ free(config.rdp_key);
+ free(config.server_cert);
+ free(config.server_key);
+
+ return ret;
+}
+#else
+static int
+load_rdp_backend(struct ivi_compositor *ivi, int *argc, char **argv)
+{
+ return -1;
+}
+#endif
+
+
static int
load_backend(struct ivi_compositor *ivi, const char *backend,
int *argc, char *argv[])
@@ -1211,6 +1365,8 @@ load_backend(struct ivi_compositor *ivi, const char *backend,
return load_x11_backend(ivi, argc, argv);
} else if (strcmp(backend, "headless-backend.so") == 0) {
return load_headless_backend(ivi, argc, argv);
+ } else if (strcmp(backend, "rdp-backend.so") == 0) {
+ return load_rdp_backend(ivi, argc, argv);
}
weston_log("fatal: unknown backend '%s'.\n", backend);
@@ -1828,6 +1984,7 @@ int wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_da
weston_compositor_add_heads_changed_listener(ivi.compositor,
&ivi.heads_changed);
+ weston_compositor_flush_heads_changed(ivi.compositor);
if (ivi_desktop_init(&ivi) < 0)
goto error_compositor;
@@ -1876,8 +2033,6 @@ int wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_da
add_bindings(ivi.compositor);
- weston_compositor_flush_heads_changed(ivi.compositor);
-
if (ivi.remoting_api)
ivi_enable_remote_outputs(&ivi);
diff --git a/src/ivi-compositor.h b/src/ivi-compositor.h
index ca40fff..cb76d8c 100644
--- a/src/ivi-compositor.h
+++ b/src/ivi-compositor.h
@@ -51,11 +51,20 @@ enum agl_shell_bound_status {
BOUND_FAILED,
};
+struct ivi_output_config {
+ int width;
+ int height;
+ int32_t scale;
+ uint32_t transform;
+};
+
struct ivi_compositor {
struct weston_compositor *compositor;
struct weston_config *config;
+ struct ivi_output_config *parsed_options;
struct wl_listener heads_changed;
+ int (*simple_output_configure)(struct weston_output *output);
bool init_failed;
bool disable_cursor;