From bf16894809242cd1738fdbcca1810a6315ee42b7 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Fri, 20 Mar 2026 14:08:00 -0500 Subject: [PATCH] drm: Remove cursor and scanout handles from the plane handle list Just put the "normal" planes on that list. This will allow for some simplification later. Signed-off-by: Derek Foreman --- libweston/backend-drm/drm-internal.h | 3 ++- libweston/backend-drm/drm.c | 26 ++++++++++++++++++-------- libweston/backend-drm/state-propose.c | 8 +++++--- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/libweston/backend-drm/drm-internal.h b/libweston/backend-drm/drm-internal.h index 484f96d9e..677a37afb 100644 --- a/libweston/backend-drm/drm-internal.h +++ b/libweston/backend-drm/drm-internal.h @@ -606,7 +606,8 @@ struct drm_output { bool dpms_off_pending; bool mode_switch_pending; - /* List of hardware planes this output can use */ + /* List of hardware planes this output can use, excluding the special + * cursor and scanout planes. */ struct wl_list plane_handle_list; /* True, if underlay planes exist. */ diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c index b9a73a1a2..0d40881d8 100644 --- a/libweston/backend-drm/drm.c +++ b/libweston/backend-drm/drm.c @@ -1588,7 +1588,7 @@ drm_plane_create_handle(struct drm_plane *plane, struct drm_output *output) handle->output = output; handle->plane = plane; - wl_list_insert(&output->plane_handle_list, &handle->link); + wl_list_init(&handle->link); return handle; } @@ -2670,10 +2670,16 @@ drm_output_init_planes(struct drm_output *output) handle = drm_plane_create_handle(plane, output); - if (plane == scanout_plane) + if (plane == scanout_plane) { output->scanout_handle = handle; - if (plane == cursor_plane) + continue; + } + + if (plane == cursor_plane) { output->cursor_handle = handle; + continue; + } + wl_list_insert(&output->plane_handle_list, &handle->link); } assert(output->scanout_handle); @@ -2719,13 +2725,17 @@ drm_output_deinit_planes(struct drm_output *output) * We want the planes to continue to exist and be freed up * for other outputs. */ - if (output->cursor_handle) + if (output->cursor_handle) { drm_plane_reset_state(output->cursor_handle->plane); - if (output->scanout_handle) - drm_plane_reset_state(output->scanout_handle->plane); + drm_plane_destroy_handle(output->cursor_handle); + output->cursor_handle = NULL; + } - output->cursor_handle = NULL; - output->scanout_handle = NULL; + if (output->scanout_handle) { + drm_plane_reset_state(output->scanout_handle->plane); + drm_plane_destroy_handle(output->scanout_handle); + output->scanout_handle = NULL; + } wl_list_for_each_safe(handle, next_handle, &output->plane_handle_list, link) diff --git a/libweston/backend-drm/state-propose.c b/libweston/backend-drm/state-propose.c index 8a9e7d29f..110c5334c 100644 --- a/libweston/backend-drm/state-propose.c +++ b/libweston/backend-drm/state-propose.c @@ -667,6 +667,8 @@ drm_output_find_plane_for_view(struct drm_output_state *state, FAILURE_REASONS_PLANES_REJECTED; return ps; } else { + struct drm_plane *scanout_plane = output->scanout_handle->plane; + if (mode == DRM_OUTPUT_PROPOSE_STATE_RENDERER_AND_CURSOR) { drm_debug(b, "\t\t\t\t[view] not assigning view %s " "to plane: renderer-and-cursor mode\n", @@ -674,12 +676,12 @@ drm_output_find_plane_for_view(struct drm_output_state *state, return NULL; } + if (drm_paint_node_transform_supported(pnode, scanout_plane)) + possible_plane_mask |= 1 << scanout_plane->plane_idx; + wl_list_for_each(handle, &output->plane_handle_list, link) { struct drm_plane *plane = handle->plane; - if (plane->type == WDRM_PLANE_TYPE_CURSOR) - continue; - if (drm_paint_node_transform_supported(pnode, plane)) possible_plane_mask |= 1 << plane->plane_idx; }