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 <m.tretter@pengutronix.de>
dev
Michael Tretter 3 years ago committed by Daniel Stone
parent d89fcf10cb
commit 101c0f6b8b
  1. 5
      libweston/backend-drm/drm-gbm.c
  2. 4
      libweston/backend-drm/drm-internal.h
  3. 3
      libweston/backend-drm/drm.c
  4. 26
      libweston/backend-drm/fb.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);

@ -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

@ -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;

@ -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);

Loading…
Cancel
Save