backend-pipewire: enable multi-backend support

Insert the backend into the weston_compositor::backend_list instead
of setting weston_compositor::backend. The compositor uses this to
determine whether the backend is capable of being loaded simultaneously
with other backends.

To stay backwards compatible, the PipeWire backend can be loaded as
primary backend. It also supports being loaded as secondary backend.

Co-authored-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
This commit is contained in:
Philipp Zabel 2023-04-18 13:57:33 +02:00 committed by Derek Foreman
parent baaef12432
commit 308d5cf367
1 changed files with 41 additions and 25 deletions

View File

@ -628,6 +628,8 @@ pipewire_destroy(struct weston_backend *base)
weston_log_scope_destroy(b->debug);
b->debug = NULL;
wl_list_remove(&b->base.link);
pw_loop_leave(b->loop);
pw_loop_destroy(b->loop);
wl_event_source_remove(b->loop_source);
@ -996,7 +998,7 @@ pipewire_backend_create(struct weston_compositor *compositor,
backend->base.destroy = pipewire_destroy;
backend->base.create_output = pipewire_create_output;
compositor->backend = &backend->base;
wl_list_insert(&compositor->backend_list, &backend->base.link);
backend->formats_count = ARRAY_LENGTH(pipewire_formats);
backend->formats = pixel_format_get_array(pipewire_formats,
@ -1005,31 +1007,33 @@ pipewire_backend_create(struct weston_compositor *compositor,
backend->base.supported_presentation_clocks =
WESTON_PRESENTATION_CLOCKS_SOFTWARE;
switch (config->renderer) {
case WESTON_RENDERER_AUTO:
case WESTON_RENDERER_PIXMAN:
ret = weston_compositor_init_renderer(compositor,
WESTON_RENDERER_PIXMAN,
NULL);
break;
case WESTON_RENDERER_GL: {
const struct gl_renderer_display_options options = {
.egl_platform = EGL_PLATFORM_SURFACELESS_MESA,
.formats = backend->formats,
.formats_count = backend->formats_count,
};
ret = weston_compositor_init_renderer(compositor,
WESTON_RENDERER_GL,
&options.base);
break;
}
default:
weston_log("Unsupported renderer requested\n");
goto err_compositor;
}
if (!compositor->renderer) {
switch (config->renderer) {
case WESTON_RENDERER_AUTO:
case WESTON_RENDERER_PIXMAN:
ret = weston_compositor_init_renderer(compositor,
WESTON_RENDERER_PIXMAN,
NULL);
break;
case WESTON_RENDERER_GL: {
const struct gl_renderer_display_options options = {
.egl_platform = EGL_PLATFORM_SURFACELESS_MESA,
.formats = backend->formats,
.formats_count = backend->formats_count,
};
ret = weston_compositor_init_renderer(compositor,
WESTON_RENDERER_GL,
&options.base);
break;
}
default:
weston_log("Unsupported renderer requested\n");
goto err_compositor;
}
if (ret < 0)
goto err_compositor;
if (ret < 0)
goto err_compositor;
}
compositor->capabilities |= WESTON_CAP_ARBITRARY_MODES;
@ -1055,6 +1059,7 @@ pipewire_backend_create(struct weston_compositor *compositor,
return backend;
err_compositor:
wl_list_remove(&backend->base.link);
free(backend);
return NULL;
}
@ -1082,6 +1087,17 @@ weston_backend_init(struct weston_compositor *compositor,
return -1;
}
if (compositor->renderer) {
switch (compositor->renderer->type) {
case WESTON_RENDERER_PIXMAN:
case WESTON_RENDERER_GL:
break;
default:
weston_log("Renderer not supported by PipeWire backend\n");
return -1;
}
}
config_init_to_defaults(&config);
memcpy(&config, config_base, config_base->struct_size);