Skip to content

Commit

Permalink
Add support for cursor planes
Browse files Browse the repository at this point in the history
This commit enables cursor planes starting with kernel 5.10.
Older kernels use legacy cursor API.
  • Loading branch information
pioto1225 authored and displaylink-emajewsk committed Nov 29, 2021
1 parent 895462f commit b6fc544
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
16 changes: 14 additions & 2 deletions module/evdi_modeset.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ static void evdi_crtc_atomic_flush(
crtc_state->event = NULL;
}

#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE
#else
static void evdi_mark_full_screen_dirty(struct evdi_device *evdi)
{
const struct drm_clip_rect rect =
Expand Down Expand Up @@ -171,6 +173,7 @@ static int evdi_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)

return 0;
}
#endif

static struct drm_crtc_helper_funcs evdi_helper_funcs = {
.mode_set_nofb = evdi_crtc_set_nofb,
Expand Down Expand Up @@ -200,8 +203,11 @@ static const struct drm_crtc_funcs evdi_crtc_funcs = {
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,

#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE
#else
.cursor_set2 = evdi_crtc_cursor_set,
.cursor_move = evdi_crtc_cursor_move,
#endif
#if KERNEL_VERSION(5, 11, 0) <= LINUX_VERSION_CODE
.enable_vblank = evdi_enable_vblank,
.disable_vblank = evdi_disable_vblank,
Expand Down Expand Up @@ -416,10 +422,11 @@ static struct drm_plane *evdi_create_plane(
{
struct drm_plane *plane;
int ret;
char *plane_type = (type == DRM_PLANE_TYPE_CURSOR) ? "cursor" : "primary";

plane = kzalloc(sizeof(*plane), GFP_KERNEL);
if (plane == NULL) {
EVDI_ERROR("Failed to allocate primary plane\n");
EVDI_ERROR("Failed to allocate %s plane\n", plane_type);
return NULL;
}
plane->format_default = true;
Expand All @@ -436,7 +443,7 @@ static struct drm_plane *evdi_create_plane(
);

if (ret) {
EVDI_ERROR("Failed to initialize primary plane\n");
EVDI_ERROR("Failed to initialize %s plane\n", plane_type);
kfree(plane);
return NULL;
}
Expand All @@ -461,6 +468,11 @@ static int evdi_crtc_init(struct drm_device *dev)
primary_plane = evdi_create_plane(dev, DRM_PLANE_TYPE_PRIMARY,
&evdi_plane_helper_funcs);

#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE
cursor_plane = evdi_create_plane(dev, DRM_PLANE_TYPE_CURSOR,
&evdi_cursor_helper_funcs);
#endif

#if KERNEL_VERSION(5, 0, 0) <= LINUX_VERSION_CODE || defined(EL8)
drm_plane_enable_fb_damage_clips(primary_plane);
#endif
Expand Down
5 changes: 4 additions & 1 deletion module/evdi_painter.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,11 @@ void evdi_painter_send_update_ready_if_needed(struct evdi_painter *painter)
EVDI_CHECKPT();
if (painter) {
painter_lock(painter);

#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE
if (painter->was_update_requested && painter->num_dirts) {
#else
if (painter->was_update_requested) {
#endif
evdi_painter_send_update_ready(painter);
painter->was_update_requested = false;
}
Expand Down

0 comments on commit b6fc544

Please sign in to comment.