backend-drm: 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 that the backend is capable of being loaded simultaneously
with other backends.

The DRM backend can only be loaded as primary backend.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
This commit is contained in:
Philipp Zabel 2021-03-24 13:38:27 +01:00 committed by Derek Foreman
parent efe9707ef2
commit 281aa0a4d7
2 changed files with 17 additions and 2 deletions

View File

@ -739,7 +739,14 @@ to_drm_output(struct weston_output *base)
static inline struct drm_backend *
to_drm_backend(struct weston_compositor *base)
{
return container_of(base->backend, struct drm_backend, base);
struct weston_backend *backend;
wl_list_for_each(backend, &base->backend_list, link) {
if (backend->destroy == drm_destroy)
return container_of(backend, struct drm_backend, base);
}
return NULL;
}
static inline struct drm_mode *

View File

@ -3263,6 +3263,8 @@ drm_destroy(struct weston_backend *backend)
struct drm_crtc *crtc, *crtc_tmp;
struct drm_writeback *writeback, *writeback_tmp;
wl_list_remove(&b->base.link);
wl_list_for_each_safe(crtc, crtc_tmp, &b->drm->crtc_list, link)
drm_crtc_destroy(crtc);
@ -3802,7 +3804,7 @@ drm_backend_create(struct weston_compositor *compositor,
"Debug messages from DRM/KMS backend\n",
NULL, NULL, NULL);
compositor->backend = &b->base;
wl_list_insert(&compositor->backend_list, &b->base.link);
if (parse_gbm_format(config->gbm_format,
pixel_format_get_info(DRM_FORMAT_XRGB8888),
@ -4021,6 +4023,7 @@ err_udev:
err_launcher:
weston_launcher_destroy(compositor->launcher);
err_compositor:
wl_list_remove(&b->base.link);
#ifdef BUILD_DRM_GBM
if (b->gbm)
gbm_device_destroy(b->gbm);
@ -4050,6 +4053,11 @@ weston_backend_init(struct weston_compositor *compositor,
return -1;
}
if (compositor->renderer) {
weston_log("drm backend must be the primary backend\n");
return -1;
}
config_init_to_defaults(&config);
memcpy(&config, config_base, config_base->struct_size);