Skip to content

Commit 061963c

Browse files
committed
drm/sysfb: Blit to CRTC destination format
Use the color format stored in struct drm_sysfb_crtc_state for color-format conversion instead of the scanout-buffer format announced by firmware. Currently, both values are identical. This will allow drivers to modify the CRTC's input format to a certain extend. Specifically, vesadrm will be able to display RGB framebuffers when the scanout buffer is of C8 format. With color- format conversion to RGB332 and correct setup of the C8 palette, displaying XRGB8888-based buffers under C8 can be achieved. v2: - refer to RGB332 as CRTC input format Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250714151513.309475-5-tzimmermann@suse.de
1 parent 31eea29 commit 061963c

2 files changed

Lines changed: 20 additions & 11 deletions

File tree

drivers/gpu/drm/sysfb/drm_sysfb_helper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ int drm_sysfb_plane_helper_get_scanout_buffer(struct drm_plane *plane,
132132
struct drm_sysfb_crtc_state {
133133
struct drm_crtc_state base;
134134

135-
/* Primary-plane format; required for color mgmt. */
135+
/* CRTC input color format; required for color mgmt. */
136136
const struct drm_format_info *format;
137137
};
138138

drivers/gpu/drm/sysfb/drm_sysfb_modeset.c

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,12 @@ int drm_sysfb_plane_helper_atomic_check(struct drm_plane *plane,
210210
else if (!new_plane_state->visible)
211211
return 0;
212212

213-
if (new_fb->format != sysfb->fb_format) {
213+
new_crtc_state = drm_atomic_get_new_crtc_state(new_state, new_plane_state->crtc);
214+
215+
new_sysfb_crtc_state = to_drm_sysfb_crtc_state(new_crtc_state);
216+
new_sysfb_crtc_state->format = sysfb->fb_format;
217+
218+
if (new_fb->format != new_sysfb_crtc_state->format) {
214219
void *buf;
215220

216221
/* format conversion necessary; reserve buffer */
@@ -220,11 +225,6 @@ int drm_sysfb_plane_helper_atomic_check(struct drm_plane *plane,
220225
return -ENOMEM;
221226
}
222227

223-
new_crtc_state = drm_atomic_get_new_crtc_state(new_state, new_plane_state->crtc);
224-
225-
new_sysfb_crtc_state = to_drm_sysfb_crtc_state(new_crtc_state);
226-
new_sysfb_crtc_state->format = new_fb->format;
227-
228228
return 0;
229229
}
230230
EXPORT_SYMBOL(drm_sysfb_plane_helper_atomic_check);
@@ -238,7 +238,10 @@ void drm_sysfb_plane_helper_atomic_update(struct drm_plane *plane, struct drm_at
238238
struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
239239
struct drm_framebuffer *fb = plane_state->fb;
240240
unsigned int dst_pitch = sysfb->fb_pitch;
241-
const struct drm_format_info *dst_format = sysfb->fb_format;
241+
struct drm_crtc_state *crtc_state = crtc_state =
242+
drm_atomic_get_new_crtc_state(state, plane_state->crtc);
243+
struct drm_sysfb_crtc_state *sysfb_crtc_state = to_drm_sysfb_crtc_state(crtc_state);
244+
const struct drm_format_info *dst_format = sysfb_crtc_state->format;
242245
struct drm_atomic_helper_damage_iter iter;
243246
struct drm_rect damage;
244247
int ret, idx;
@@ -278,7 +281,10 @@ void drm_sysfb_plane_helper_atomic_disable(struct drm_plane *plane,
278281
struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
279282
void __iomem *dst_vmap = dst.vaddr_iomem; /* TODO: Use mapping abstraction */
280283
unsigned int dst_pitch = sysfb->fb_pitch;
281-
const struct drm_format_info *dst_format = sysfb->fb_format;
284+
struct drm_crtc_state *crtc_state = crtc_state =
285+
drm_atomic_get_new_crtc_state(state, plane_state->crtc);
286+
struct drm_sysfb_crtc_state *sysfb_crtc_state = to_drm_sysfb_crtc_state(crtc_state);
287+
const struct drm_format_info *dst_format = sysfb_crtc_state->format;
282288
struct drm_rect dst_clip;
283289
unsigned long lines, linepixels, i;
284290
int idx;
@@ -370,16 +376,19 @@ EXPORT_SYMBOL(drm_sysfb_crtc_helper_atomic_check);
370376

371377
void drm_sysfb_crtc_reset(struct drm_crtc *crtc)
372378
{
379+
struct drm_sysfb_device *sysfb = to_drm_sysfb_device(crtc->dev);
373380
struct drm_sysfb_crtc_state *sysfb_crtc_state;
374381

375382
if (crtc->state)
376383
drm_sysfb_crtc_state_destroy(to_drm_sysfb_crtc_state(crtc->state));
377384

378385
sysfb_crtc_state = kzalloc(sizeof(*sysfb_crtc_state), GFP_KERNEL);
379-
if (sysfb_crtc_state)
386+
if (sysfb_crtc_state) {
387+
sysfb_crtc_state->format = sysfb->fb_format;
380388
__drm_atomic_helper_crtc_reset(crtc, &sysfb_crtc_state->base);
381-
else
389+
} else {
382390
__drm_atomic_helper_crtc_reset(crtc, NULL);
391+
}
383392
}
384393
EXPORT_SYMBOL(drm_sysfb_crtc_reset);
385394

0 commit comments

Comments
 (0)