backend-drm: import cursors on non gbm outputs
Additional devices don't have a gbm device. Therefore, we cannot create gbm bos for the cursor. If the output device differs from the gbm device, fall back to the allocation of a dumb buffer for the cursor on the output device. Update the cursor sprite with a memcpy to the already mapped dumb buffer that belongs to the current cursor. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
This commit is contained in:
parent
7887d3fb48
commit
3f9f4277c3
|
@ -123,6 +123,9 @@ static void drm_output_fini_cursor_egl(struct drm_output *output)
|
|||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_LENGTH(output->gbm_cursor_fb); i++) {
|
||||
/* This cursor does not have a GBM device */
|
||||
if (output->gbm_cursor_fb[i] && !output->gbm_cursor_fb[i]->bo)
|
||||
output->gbm_cursor_fb[i]->type = BUFFER_PIXMAN_DUMB;
|
||||
drm_fb_unref(output->gbm_cursor_fb[i]);
|
||||
output->gbm_cursor_fb[i] = NULL;
|
||||
}
|
||||
|
@ -141,19 +144,31 @@ drm_output_init_cursor_egl(struct drm_output *output, struct drm_backend *b)
|
|||
for (i = 0; i < ARRAY_LENGTH(output->gbm_cursor_fb); i++) {
|
||||
struct gbm_bo *bo;
|
||||
|
||||
bo = gbm_bo_create(b->gbm, device->cursor_width, device->cursor_height,
|
||||
GBM_FORMAT_ARGB8888,
|
||||
GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
|
||||
if (!bo)
|
||||
goto err;
|
||||
if (gbm_device_get_fd(b->gbm) != output->device->drm.fd) {
|
||||
output->gbm_cursor_fb[i] =
|
||||
drm_fb_create_dumb(output->device,
|
||||
device->cursor_width,
|
||||
device->cursor_height,
|
||||
DRM_FORMAT_ARGB8888);
|
||||
/* Override buffer type, since we know it is a cursor */
|
||||
output->gbm_cursor_fb[i]->type = BUFFER_CURSOR;
|
||||
output->gbm_cursor_handle[i] =
|
||||
output->gbm_cursor_fb[i]->handles[0];
|
||||
} else {
|
||||
bo = gbm_bo_create(b->gbm, device->cursor_width, device->cursor_height,
|
||||
GBM_FORMAT_ARGB8888,
|
||||
GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
|
||||
if (!bo)
|
||||
goto err;
|
||||
|
||||
output->gbm_cursor_fb[i] =
|
||||
drm_fb_get_from_bo(bo, device, false, BUFFER_CURSOR);
|
||||
if (!output->gbm_cursor_fb[i]) {
|
||||
gbm_bo_destroy(bo);
|
||||
goto err;
|
||||
output->gbm_cursor_fb[i] =
|
||||
drm_fb_get_from_bo(bo, device, false, BUFFER_CURSOR);
|
||||
if (!output->gbm_cursor_fb[i]) {
|
||||
gbm_bo_destroy(bo);
|
||||
goto err;
|
||||
}
|
||||
output->gbm_cursor_handle[i] = gbm_bo_get_handle(bo).s32;
|
||||
}
|
||||
output->gbm_cursor_handle[i] = gbm_bo_get_handle(bo).s32;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -188,8 +188,13 @@ cursor_bo_update(struct drm_plane_state *plane_state, struct weston_view *ev)
|
|||
buffer->width * 4);
|
||||
wl_shm_buffer_end_access(buffer->shm_buffer);
|
||||
|
||||
if (gbm_bo_write(bo, buf, sizeof buf) < 0)
|
||||
weston_log("failed update cursor: %s\n", strerror(errno));
|
||||
if (bo) {
|
||||
if (gbm_bo_write(bo, buf, sizeof buf) < 0)
|
||||
weston_log("failed update cursor: %s\n", strerror(errno));
|
||||
} else {
|
||||
memcpy(output->gbm_cursor_fb[output->current_cursor]->map,
|
||||
buf, sizeof buf);
|
||||
}
|
||||
}
|
||||
|
||||
static struct drm_plane_state *
|
||||
|
|
Loading…
Reference in New Issue