]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/ast: Move cursor format conversion into helper function
authorThomas Zimmermann <tzimmermann@suse.de>
Wed, 26 Nov 2025 09:40:08 +0000 (10:40 +0100)
committerThomas Zimmermann <tzimmermann@suse.de>
Mon, 1 Dec 2025 07:40:18 +0000 (08:40 +0100)
Move the format conversion of the cursor framebuffer into the new
helper ast_cursor_plane_get_argb4444(). It returns a buffer in system
memory, which the atomic_update handler copies to video memory.

The returned buffer is either the GEM buffer itself, or a temporary
copy within the plane in ARGB4444 format.

As a small change, list supported formats explicitly in the switch
statement. Do not assume ARGB8888 input by default. The cursor
framebuffer knows its format, so should we.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://patch.msgid.link/20251126094626.41985-2-tzimmermann@suse.de
drivers/gpu/drm/ast/ast_cursor.c

index 2d3ad7610c2e9cf0cf7f2304aadd1f382f8dba07..24d696df8fcda657f1dc08b3e44152d7945d203f 100644 (file)
@@ -181,6 +181,38 @@ static int ast_cursor_plane_helper_atomic_check(struct drm_plane *plane,
        return 0;
 }
 
+static const u8 *ast_cursor_plane_get_argb4444(struct ast_cursor_plane *ast_cursor_plane,
+                                              struct drm_shadow_plane_state *shadow_plane_state,
+                                              const struct drm_rect *clip)
+{
+       struct drm_plane_state *plane_state = &shadow_plane_state->base;
+       struct drm_framebuffer *fb = plane_state->fb;
+       u8 *argb4444 = NULL;
+
+       switch (fb->format->format) {
+       case DRM_FORMAT_ARGB4444:
+               argb4444 = shadow_plane_state->data[0].vaddr;
+               break;
+       case DRM_FORMAT_ARGB8888:
+               {
+                       struct iosys_map argb4444_dst[DRM_FORMAT_MAX_PLANES] = {
+                               IOSYS_MAP_INIT_VADDR(ast_cursor_plane->argb4444),
+                       };
+                       unsigned int argb4444_dst_pitch[DRM_FORMAT_MAX_PLANES] = {
+                               AST_HWC_PITCH,
+                       };
+
+                       drm_fb_argb8888_to_argb4444(argb4444_dst, argb4444_dst_pitch,
+                                                   shadow_plane_state->data, fb, clip,
+                                                   &shadow_plane_state->fmtcnv_state);
+                       argb4444 = argb4444_dst[0].vaddr;
+               }
+               break;
+       }
+
+       return argb4444;
+}
+
 static void ast_cursor_plane_helper_atomic_update(struct drm_plane *plane,
                                                  struct drm_atomic_state *state)
 {
@@ -205,29 +237,13 @@ static void ast_cursor_plane_helper_atomic_update(struct drm_plane *plane,
         */
 
        if (drm_atomic_helper_damage_merged(old_plane_state, plane_state, &damage)) {
-               u8 *argb4444;
-
-               switch (fb->format->format) {
-               case DRM_FORMAT_ARGB4444:
-                       argb4444 = shadow_plane_state->data[0].vaddr;
-                       break;
-               default:
-                       argb4444 = ast_cursor_plane->argb4444;
-                       {
-                               struct iosys_map argb4444_dst[DRM_FORMAT_MAX_PLANES] = {
-                                       IOSYS_MAP_INIT_VADDR(argb4444),
-                               };
-                               unsigned int argb4444_dst_pitch[DRM_FORMAT_MAX_PLANES] = {
-                                       AST_HWC_PITCH,
-                               };
-
-                               drm_fb_argb8888_to_argb4444(argb4444_dst, argb4444_dst_pitch,
-                                                           shadow_plane_state->data, fb, &damage,
-                                                           &shadow_plane_state->fmtcnv_state);
-                       }
-                       break;
-               }
-               ast_set_cursor_image(ast, argb4444, fb->width, fb->height);
+               const u8 *argb4444 = ast_cursor_plane_get_argb4444(ast_cursor_plane,
+                                                                  shadow_plane_state,
+                                                                  &damage);
+
+               if (argb4444)
+                       ast_set_cursor_image(ast, argb4444, fb->width, fb->height);
+
                ast_set_cursor_base(ast, dst_off);
        }