Skip to content

Commit 01b947a

Browse files
Thomas Zimmermannkraxel
authored andcommitted
drm/fb-helper: Instanciate shadow FB if configured in device's mode_config
Generic framebuffer emulation uses a shadow buffer for framebuffers with dirty() function. If drivers want to use the shadow FB without such a function, they can now set prefer_shadow or prefer_shadow_fbdev in their mode_config structures. The former flag is exported to userspace, the latter flag is fbdev-only. v3: * only schedule dirty worker if fbdev uses shadow fb * test shadow fb settings with boolean operators * use bool for struct drm_mode_config.prefer_shadow_fbdev * fix documentation comments Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Noralf Trønnes <[email protected]> Tested-by: Noralf Trønnes <[email protected]> Link: https://patchwork.freedesktop.org/patch/315834/ Signed-off-by: Gerd Hoffmann <[email protected]>
1 parent 87e281f commit 01b947a

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

drivers/gpu/drm/drm_fb_helper.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,9 @@ static void drm_fb_helper_dirty_work(struct work_struct *work)
421421
return;
422422
drm_fb_helper_dirty_blit_real(helper, &clip_copy);
423423
}
424-
helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, &clip_copy, 1);
424+
if (helper->fb->funcs->dirty)
425+
helper->fb->funcs->dirty(helper->fb, NULL, 0, 0,
426+
&clip_copy, 1);
425427

426428
if (helper->buffer)
427429
drm_client_buffer_vunmap(helper->buffer);
@@ -613,14 +615,24 @@ void drm_fb_helper_unlink_fbi(struct drm_fb_helper *fb_helper)
613615
}
614616
EXPORT_SYMBOL(drm_fb_helper_unlink_fbi);
615617

618+
static bool drm_fbdev_use_shadow_fb(struct drm_fb_helper *fb_helper)
619+
{
620+
struct drm_device *dev = fb_helper->dev;
621+
struct drm_framebuffer *fb = fb_helper->fb;
622+
623+
return dev->mode_config.prefer_shadow_fbdev ||
624+
dev->mode_config.prefer_shadow ||
625+
fb->funcs->dirty;
626+
}
627+
616628
static void drm_fb_helper_dirty(struct fb_info *info, u32 x, u32 y,
617629
u32 width, u32 height)
618630
{
619631
struct drm_fb_helper *helper = info->par;
620632
struct drm_clip_rect *clip = &helper->dirty_clip;
621633
unsigned long flags;
622634

623-
if (!helper->fb->funcs->dirty)
635+
if (!drm_fbdev_use_shadow_fb(helper))
624636
return;
625637

626638
spin_lock_irqsave(&helper->dirty_lock, flags);
@@ -2213,7 +2225,7 @@ int drm_fb_helper_generic_probe(struct drm_fb_helper *fb_helper,
22132225

22142226
drm_fb_helper_fill_info(fbi, fb_helper, sizes);
22152227

2216-
if (fb->funcs->dirty) {
2228+
if (drm_fbdev_use_shadow_fb(fb_helper)) {
22172229
struct fb_ops *fbops;
22182230
void *shadow;
22192231

include/drm/drm_mode_config.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,13 @@ struct drm_mode_config {
852852
/* dumb ioctl parameters */
853853
uint32_t preferred_depth, prefer_shadow;
854854

855+
/**
856+
* @prefer_shadow_fbdev:
857+
*
858+
* Hint to framebuffer emulation to prefer shadow-fb rendering.
859+
*/
860+
bool prefer_shadow_fbdev;
861+
855862
/**
856863
* @quirk_addfb_prefer_xbgr_30bpp:
857864
*

0 commit comments

Comments
 (0)