Skip to content

Commit

Permalink
Workaround for bad cursor rects on X11 with cursor planes (LSP)
Browse files Browse the repository at this point in the history
  • Loading branch information
Emilia Majewska committed Jan 28, 2022
2 parents 14f4ce4 + 4e58d3a commit 1568835
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
1 change: 1 addition & 0 deletions module/evdi_drm_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ struct evdi_gem_object {
struct reservation_object *resv;
struct reservation_object _resv;
#endif
bool allow_sw_cursor_rect_updates;
};

#define to_evdi_bo(x) container_of(x, struct evdi_gem_object, base)
Expand Down
29 changes: 19 additions & 10 deletions module/evdi_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ static struct drm_gem_object_funcs gem_obj_funcs = {
};
#endif

bool evdi_was_called_by_mutter(void)
{
char task_comm[TASK_COMM_LEN] = { 0 };

get_task_comm(task_comm, current);

return strcmp(task_comm, "gnome-shell") == 0;
}

uint32_t evdi_gem_object_handle_lookup(struct drm_file *filp,
struct drm_gem_object *obj)
{
Expand Down Expand Up @@ -91,6 +100,8 @@ struct evdi_gem_object *evdi_gem_alloc_object(struct drm_device *dev,
obj->base.funcs = &gem_obj_funcs;
#endif

obj->allow_sw_cursor_rect_updates = false;

mutex_init(&obj->pages_lock);

return obj;
Expand Down Expand Up @@ -121,6 +132,7 @@ evdi_gem_create(struct drm_file *file,
#else
drm_gem_object_put_unlocked(&obj->base);
#endif
obj->allow_sw_cursor_rect_updates = evdi_was_called_by_mutter();
*handle_p = handle;
return 0;
}
Expand Down Expand Up @@ -387,18 +399,14 @@ evdi_prime_import_sg_table(struct drm_device *dev,
{
struct evdi_gem_object *obj;
int npages;
bool called_by_mutter;

if (evdi_disable_texture_import)
return ERR_PTR(-ENOMEM);

else if (strcmp(attach->dmabuf->owner->name, "amdgpu") == 0) {
char task_comm[TASK_COMM_LEN] = { 0 };

get_task_comm(task_comm, current);
called_by_mutter = evdi_was_called_by_mutter();

if (strcmp(task_comm, "gnome-shell") == 0)
return ERR_PTR(-ENOMEM);
}
if (evdi_disable_texture_import ||
(called_by_mutter && strcmp(attach->dmabuf->owner->name, "amdgpu") == 0)) {
return ERR_PTR(-ENOMEM);
}

obj = evdi_gem_alloc_object(dev, attach->dmabuf->size);
if (IS_ERR(obj))
Expand All @@ -418,6 +426,7 @@ evdi_prime_import_sg_table(struct drm_device *dev,
drm_prime_sg_to_page_addr_arrays(sg, obj->pages, NULL, npages);
#endif
obj->sg = sg;
obj->allow_sw_cursor_rect_updates = called_by_mutter;
return &obj->base;
}

Expand Down
17 changes: 12 additions & 5 deletions module/evdi_modeset.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,13 +370,20 @@ static void evdi_cursor_atomic_update(struct drm_plane *plane,

mutex_unlock(&plane->dev->struct_mutex);
if (!evdi->cursor_events_enabled) {
evdi_cursor_atomic_get_rect(&old_rect, old_state);
evdi_cursor_atomic_get_rect(&rect, state);

evdi_painter_mark_dirty(evdi, &old_rect);
evdi_painter_mark_dirty(evdi, &rect);
if (fb != NULL) {
if (efb->obj->allow_sw_cursor_rect_updates) {
evdi_cursor_atomic_get_rect(&old_rect, old_state);
evdi_cursor_atomic_get_rect(&rect, state);

evdi_painter_mark_dirty(evdi, &old_rect);
} else {
rect = evdi_painter_framebuffer_size(evdi->painter);
}
evdi_painter_mark_dirty(evdi, &rect);
}
return;
}

if (cursor_changed)
evdi_painter_send_cursor_set(evdi->painter,
evdi->cursor);
Expand Down

0 comments on commit 1568835

Please sign in to comment.