From 101c0f6b8ba9bd79517629ee3313f907750cf273 Mon Sep 17 00:00:00 2001 From: Michael Tretter Date: Wed, 3 Nov 2021 10:16:10 +0100 Subject: [PATCH] backend-drm: get the fb using the device instead of the backend The fbs are specific to the device on which they will be displayed. Therefore, we have to tell which device shall be used when we are creating the fb. Signed-off-by: Michael Tretter --- libweston/backend-drm/drm-gbm.c | 5 +++-- libweston/backend-drm/drm-internal.h | 4 ++-- libweston/backend-drm/drm.c | 3 ++- libweston/backend-drm/fb.c | 26 ++++++++++++-------------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/libweston/backend-drm/drm-gbm.c b/libweston/backend-drm/drm-gbm.c index 1799e8da..afefffbf 100644 --- a/libweston/backend-drm/drm-gbm.c +++ b/libweston/backend-drm/drm-gbm.c @@ -163,7 +163,7 @@ drm_output_init_cursor_egl(struct drm_output *output, struct drm_backend *b) goto err; output->gbm_cursor_fb[i] = - drm_fb_get_from_bo(bo, b, false, BUFFER_CURSOR); + drm_fb_get_from_bo(bo, device, false, BUFFER_CURSOR); if (!output->gbm_cursor_fb[i]) { gbm_bo_destroy(bo); goto err; @@ -291,6 +291,7 @@ drm_output_render_gl(struct drm_output_state *state, pixman_region32_t *damage) { struct drm_output *output = state->output; struct drm_backend *b = to_drm_backend(output->base.compositor); + struct drm_device *device = b->drm; struct gbm_bo *bo; struct drm_fb *ret; @@ -305,7 +306,7 @@ drm_output_render_gl(struct drm_output_state *state, pixman_region32_t *damage) } /* The renderer always produces an opaque image. */ - ret = drm_fb_get_from_bo(bo, b, true, BUFFER_GBM_SURFACE); + ret = drm_fb_get_from_bo(bo, device, true, BUFFER_GBM_SURFACE); if (!ret) { weston_log("failed to get drm_fb for bo\n"); gbm_surface_release_buffer(output->gbm_surface, bo); diff --git a/libweston/backend-drm/drm-internal.h b/libweston/backend-drm/drm-internal.h index 062b8612..a551bbf0 100644 --- a/libweston/backend-drm/drm-internal.h +++ b/libweston/backend-drm/drm-internal.h @@ -725,10 +725,10 @@ void drm_fb_unref(struct drm_fb *fb); struct drm_fb * -drm_fb_create_dumb(struct drm_backend *b, int width, int height, +drm_fb_create_dumb(struct drm_device *device, int width, int height, uint32_t format); struct drm_fb * -drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_backend *backend, +drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_device *device, bool is_opaque, enum drm_fb_type type); void diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c index 89838afd..ff29f5a9 100644 --- a/libweston/backend-drm/drm.c +++ b/libweston/backend-drm/drm.c @@ -1160,6 +1160,7 @@ make_connector_name(const drmModeConnector *con) static int drm_output_init_pixman(struct drm_output *output, struct drm_backend *b) { + struct drm_device *device = b->drm; int w = output->base.current_mode->width; int h = output->base.current_mode->height; uint32_t format = output->gbm_format; @@ -1183,7 +1184,7 @@ drm_output_init_pixman(struct drm_output *output, struct drm_backend *b) /* FIXME error checking */ for (i = 0; i < ARRAY_LENGTH(output->dumb); i++) { - output->dumb[i] = drm_fb_create_dumb(b, w, h, format); + output->dumb[i] = drm_fb_create_dumb(device, w, h, format); if (!output->dumb[i]) goto err; diff --git a/libweston/backend-drm/fb.c b/libweston/backend-drm/fb.c index 4fa06ce8..d7df874a 100644 --- a/libweston/backend-drm/fb.c +++ b/libweston/backend-drm/fb.c @@ -69,9 +69,8 @@ drm_fb_destroy_dumb(struct drm_fb *fb) } static int -drm_fb_addfb(struct drm_backend *b, struct drm_fb *fb) +drm_fb_addfb(struct drm_device *device, struct drm_fb *fb) { - struct drm_device *device = b->drm; int ret = -EINVAL; uint64_t mods[4] = { }; size_t i; @@ -113,10 +112,9 @@ drm_fb_addfb(struct drm_backend *b, struct drm_fb *fb) } struct drm_fb * -drm_fb_create_dumb(struct drm_backend *b, int width, int height, +drm_fb_create_dumb(struct drm_device *device, int width, int height, uint32_t format) { - struct drm_device *device = b->drm; struct drm_fb *fb; int ret; @@ -161,7 +159,7 @@ drm_fb_create_dumb(struct drm_backend *b, int width, int height, fb->height = height; fb->fd = device->drm.fd; - if (drm_fb_addfb(b, fb) != 0) { + if (drm_fb_addfb(device, fb) != 0) { weston_log("failed to create kms fb: %s\n", strerror(errno)); goto err_bo; } @@ -220,7 +218,7 @@ drm_fb_destroy_dmabuf(struct drm_fb *fb) static struct drm_fb * drm_fb_get_from_dmabuf(struct linux_dmabuf_buffer *dmabuf, - struct drm_backend *backend, bool is_opaque, + struct drm_device *device, bool is_opaque, uint32_t *try_view_on_plane_failure_reasons) { #ifndef HAVE_GBM_FD_IMPORT @@ -229,7 +227,7 @@ drm_fb_get_from_dmabuf(struct linux_dmabuf_buffer *dmabuf, * of GBM_BO_IMPORT_FD_MODIFIER. */ return NULL; #else - struct drm_device *device = backend->drm; + struct drm_backend *backend = device->backend; struct drm_fb *fb; int i; struct gbm_import_fd_modifier_data import_mod = { @@ -326,7 +324,7 @@ drm_fb_get_from_dmabuf(struct linux_dmabuf_buffer *dmabuf, fb->handles[i] = handle.u32; } - if (drm_fb_addfb(backend, fb) != 0) { + if (drm_fb_addfb(device, fb) != 0) { if (try_view_on_plane_failure_reasons) *try_view_on_plane_failure_reasons |= FAILURE_REASONS_ADD_FB_FAILED; @@ -342,10 +340,9 @@ err_free: } struct drm_fb * -drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_backend *backend, +drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_device *device, bool is_opaque, enum drm_fb_type type) { - struct drm_device *device = backend->drm; struct drm_fb *fb = gbm_bo_get_user_data(bo); #ifdef HAVE_GBM_MODIFIERS int i; @@ -404,7 +401,7 @@ drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_backend *backend, goto err_free; } - if (drm_fb_addfb(backend, fb) != 0) { + if (drm_fb_addfb(device, fb) != 0) { if (type == BUFFER_GBM_SURFACE) weston_log("failed to create kms fb: %s\n", strerror(errno)); @@ -460,10 +457,11 @@ drm_can_scanout_dmabuf(struct weston_compositor *ec, { struct drm_fb *fb; struct drm_backend *b = to_drm_backend(ec); + struct drm_device *device = b->drm; bool ret = false; uint32_t try_reason = 0x0; - fb = drm_fb_get_from_dmabuf(dmabuf, b, true, &try_reason); + fb = drm_fb_get_from_dmabuf(dmabuf, device, true, &try_reason); if (fb) ret = true; @@ -582,7 +580,7 @@ drm_fb_get_from_view(struct drm_output_state *state, struct weston_view *ev, } if (buffer->type == WESTON_BUFFER_DMABUF) { - fb = drm_fb_get_from_dmabuf(buffer->dmabuf, b, is_opaque, + fb = drm_fb_get_from_dmabuf(buffer->dmabuf, device, is_opaque, &buf_fb->failure_reasons); if (!fb) goto unsuitable; @@ -594,7 +592,7 @@ drm_fb_get_from_view(struct drm_output_state *state, struct weston_view *ev, if (!bo) goto unsuitable; - fb = drm_fb_get_from_bo(bo, b, is_opaque, BUFFER_CLIENT); + fb = drm_fb_get_from_bo(bo, device, is_opaque, BUFFER_CLIENT); if (!fb) { *try_view_on_plane_failure_reasons |= (1 << FAILURE_REASONS_ADD_FB_FAILED);