libweston: use enum to choose the backend
Change weston_compositor_load_backend() to use an enum to choose the backend. The caller no longer needs to know what the backend DSO is called in the file system. Custom backends cannot be laoded anymore, as the loading path is now always either LIBWESTON_MODULEDIR, or formed from $WESTON_BUILD_DIR. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
This commit is contained in:
parent
a256c5ed8d
commit
50dbf38514
@ -4867,6 +4867,15 @@ weston_compositor_get_user_data(struct weston_compositor *compositor)
|
||||
return compositor->user_data;
|
||||
}
|
||||
|
||||
static const char * const backend_map[] = {
|
||||
[WESTON_BACKEND_DRM] = "drm-backend.so",
|
||||
[WESTON_BACKEND_FBDEV] = "fbdev-backend.so",
|
||||
[WESTON_BACKEND_HEADLESS] = "headless-backend.so",
|
||||
[WESTON_BACKEND_RDP] = "rdp-backend.so",
|
||||
[WESTON_BACKEND_WAYLAND] = "wayland-backend.so",
|
||||
[WESTON_BACKEND_X11] = "x11-backend.so",
|
||||
};
|
||||
|
||||
/** Load a backend into a weston_compositor
|
||||
*
|
||||
* A backend must be loaded to make a weston_compositor work. A backend
|
||||
@ -4881,13 +4890,16 @@ weston_compositor_get_user_data(struct weston_compositor *compositor)
|
||||
*/
|
||||
WL_EXPORT int
|
||||
weston_compositor_load_backend(struct weston_compositor *compositor,
|
||||
const char *backend,
|
||||
enum weston_compositor_backend backend,
|
||||
struct weston_backend_config *config_base)
|
||||
{
|
||||
int (*backend_init)(struct weston_compositor *c,
|
||||
struct weston_backend_config *config_base);
|
||||
|
||||
backend_init = weston_load_module(backend, "backend_init");
|
||||
if (backend < 0 || backend >= ARRAY_LENGTH(backend_map))
|
||||
return -1;
|
||||
|
||||
backend_init = weston_load_module(backend_map[backend], "backend_init");
|
||||
if (!backend_init)
|
||||
return -1;
|
||||
|
||||
|
@ -1466,9 +1466,19 @@ void
|
||||
weston_compositor_destroy(struct weston_compositor *ec);
|
||||
struct weston_compositor *
|
||||
weston_compositor_create(struct wl_display *display, void *user_data);
|
||||
|
||||
enum weston_compositor_backend {
|
||||
WESTON_BACKEND_DRM,
|
||||
WESTON_BACKEND_FBDEV,
|
||||
WESTON_BACKEND_HEADLESS,
|
||||
WESTON_BACKEND_RDP,
|
||||
WESTON_BACKEND_WAYLAND,
|
||||
WESTON_BACKEND_X11,
|
||||
};
|
||||
|
||||
int
|
||||
weston_compositor_load_backend(struct weston_compositor *compositor,
|
||||
const char *backend,
|
||||
enum weston_compositor_backend backend,
|
||||
struct weston_backend_config *config_base);
|
||||
void
|
||||
weston_compositor_exit(struct weston_compositor *ec);
|
||||
|
18
src/main.c
18
src/main.c
@ -1003,7 +1003,8 @@ load_drm_backend(struct weston_compositor *c, const char *backend,
|
||||
config.configure_output = drm_configure_output;
|
||||
config.configure_device = configure_input_device;
|
||||
|
||||
ret = weston_compositor_load_backend(c, backend, &config.base);
|
||||
ret = weston_compositor_load_backend(c, WESTON_BACKEND_DRM,
|
||||
&config.base);
|
||||
|
||||
free(config.gbm_format);
|
||||
free(config.seat_id);
|
||||
@ -1042,7 +1043,8 @@ load_headless_backend(struct weston_compositor *c, char const * backend,
|
||||
config.base.struct_size = sizeof(struct weston_headless_backend_config);
|
||||
|
||||
/* load the actual wayland backend and configure it */
|
||||
ret = weston_compositor_load_backend(c, backend, &config.base);
|
||||
ret = weston_compositor_load_backend(c, WESTON_BACKEND_HEADLESS,
|
||||
&config.base);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -1087,7 +1089,8 @@ load_rdp_backend(struct weston_compositor *c, char const * backend,
|
||||
|
||||
parse_options(rdp_options, ARRAY_LENGTH(rdp_options), argc, argv);
|
||||
|
||||
ret = weston_compositor_load_backend(c, backend, &config.base);
|
||||
ret = weston_compositor_load_backend(c, WESTON_BACKEND_RDP,
|
||||
&config.base);
|
||||
|
||||
free(config.bind_address);
|
||||
free(config.rdp_key);
|
||||
@ -1127,7 +1130,8 @@ load_fbdev_backend(struct weston_compositor *c, char const * backend,
|
||||
config.configure_device = configure_input_device;
|
||||
|
||||
/* load the actual wayland backend and configure it */
|
||||
ret = weston_compositor_load_backend(c, backend, &config.base);
|
||||
ret = weston_compositor_load_backend(c, WESTON_BACKEND_FBDEV,
|
||||
&config.base);
|
||||
|
||||
free(config.device);
|
||||
|
||||
@ -1263,7 +1267,8 @@ load_x11_backend(struct weston_compositor *c, char const * backend,
|
||||
config.base.struct_size = sizeof(struct weston_x11_backend_config);
|
||||
|
||||
/* load the actual backend and configure it */
|
||||
ret = weston_compositor_load_backend(c, backend, &config.base);
|
||||
ret = weston_compositor_load_backend(c, WESTON_BACKEND_X11,
|
||||
&config.base);
|
||||
|
||||
out:
|
||||
for (j = 0; j < config.num_outputs; ++j)
|
||||
@ -1483,7 +1488,8 @@ load_wayland_backend(struct weston_compositor *c, char const * backend,
|
||||
}
|
||||
|
||||
/* load the actual wayland backend and configure it */
|
||||
ret = weston_compositor_load_backend(c, backend, &config.base);
|
||||
ret = weston_compositor_load_backend(c, WESTON_BACKEND_WAYLAND,
|
||||
&config.base);
|
||||
weston_wayland_backend_config_release(&config);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user