Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/ast: Move cursor format conversion into helper function

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

+37 -21
+37 -21
drivers/gpu/drm/ast/ast_cursor.c
··· 181 181 return 0; 182 182 } 183 183 184 + static const u8 *ast_cursor_plane_get_argb4444(struct ast_cursor_plane *ast_cursor_plane, 185 + struct drm_shadow_plane_state *shadow_plane_state, 186 + const struct drm_rect *clip) 187 + { 188 + struct drm_plane_state *plane_state = &shadow_plane_state->base; 189 + struct drm_framebuffer *fb = plane_state->fb; 190 + u8 *argb4444 = NULL; 191 + 192 + switch (fb->format->format) { 193 + case DRM_FORMAT_ARGB4444: 194 + argb4444 = shadow_plane_state->data[0].vaddr; 195 + break; 196 + case DRM_FORMAT_ARGB8888: 197 + { 198 + struct iosys_map argb4444_dst[DRM_FORMAT_MAX_PLANES] = { 199 + IOSYS_MAP_INIT_VADDR(ast_cursor_plane->argb4444), 200 + }; 201 + unsigned int argb4444_dst_pitch[DRM_FORMAT_MAX_PLANES] = { 202 + AST_HWC_PITCH, 203 + }; 204 + 205 + drm_fb_argb8888_to_argb4444(argb4444_dst, argb4444_dst_pitch, 206 + shadow_plane_state->data, fb, clip, 207 + &shadow_plane_state->fmtcnv_state); 208 + argb4444 = argb4444_dst[0].vaddr; 209 + } 210 + break; 211 + } 212 + 213 + return argb4444; 214 + } 215 + 184 216 static void ast_cursor_plane_helper_atomic_update(struct drm_plane *plane, 185 217 struct drm_atomic_state *state) 186 218 { ··· 237 205 */ 238 206 239 207 if (drm_atomic_helper_damage_merged(old_plane_state, plane_state, &damage)) { 240 - u8 *argb4444; 208 + const u8 *argb4444 = ast_cursor_plane_get_argb4444(ast_cursor_plane, 209 + shadow_plane_state, 210 + &damage); 241 211 242 - switch (fb->format->format) { 243 - case DRM_FORMAT_ARGB4444: 244 - argb4444 = shadow_plane_state->data[0].vaddr; 245 - break; 246 - default: 247 - argb4444 = ast_cursor_plane->argb4444; 248 - { 249 - struct iosys_map argb4444_dst[DRM_FORMAT_MAX_PLANES] = { 250 - IOSYS_MAP_INIT_VADDR(argb4444), 251 - }; 252 - unsigned int argb4444_dst_pitch[DRM_FORMAT_MAX_PLANES] = { 253 - AST_HWC_PITCH, 254 - }; 212 + if (argb4444) 213 + ast_set_cursor_image(ast, argb4444, fb->width, fb->height); 255 214 256 - drm_fb_argb8888_to_argb4444(argb4444_dst, argb4444_dst_pitch, 257 - shadow_plane_state->data, fb, &damage, 258 - &shadow_plane_state->fmtcnv_state); 259 - } 260 - break; 261 - } 262 - ast_set_cursor_image(ast, argb4444, fb->width, fb->height); 263 215 ast_set_cursor_base(ast, dst_off); 264 216 } 265 217