Skip to content

Commit

Permalink
drm/fb-helper: Instanciate shadow FB if configured in device's mode_c…
Browse files Browse the repository at this point in the history
…onfig

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]>
  • Loading branch information
Thomas Zimmermann authored and kraxel committed Aug 1, 2019
1 parent 87e281f commit 01b947a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
18 changes: 15 additions & 3 deletions drivers/gpu/drm/drm_fb_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,9 @@ static void drm_fb_helper_dirty_work(struct work_struct *work)
return;
drm_fb_helper_dirty_blit_real(helper, &clip_copy);
}
helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, &clip_copy, 1);
if (helper->fb->funcs->dirty)
helper->fb->funcs->dirty(helper->fb, NULL, 0, 0,
&clip_copy, 1);

if (helper->buffer)
drm_client_buffer_vunmap(helper->buffer);
Expand Down Expand Up @@ -613,14 +615,24 @@ void drm_fb_helper_unlink_fbi(struct drm_fb_helper *fb_helper)
}
EXPORT_SYMBOL(drm_fb_helper_unlink_fbi);

static bool drm_fbdev_use_shadow_fb(struct drm_fb_helper *fb_helper)
{
struct drm_device *dev = fb_helper->dev;
struct drm_framebuffer *fb = fb_helper->fb;

return dev->mode_config.prefer_shadow_fbdev ||
dev->mode_config.prefer_shadow ||
fb->funcs->dirty;
}

static void drm_fb_helper_dirty(struct fb_info *info, u32 x, u32 y,
u32 width, u32 height)
{
struct drm_fb_helper *helper = info->par;
struct drm_clip_rect *clip = &helper->dirty_clip;
unsigned long flags;

if (!helper->fb->funcs->dirty)
if (!drm_fbdev_use_shadow_fb(helper))
return;

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

drm_fb_helper_fill_info(fbi, fb_helper, sizes);

if (fb->funcs->dirty) {
if (drm_fbdev_use_shadow_fb(fb_helper)) {
struct fb_ops *fbops;
void *shadow;

Expand Down
7 changes: 7 additions & 0 deletions include/drm/drm_mode_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,13 @@ struct drm_mode_config {
/* dumb ioctl parameters */
uint32_t preferred_depth, prefer_shadow;

/**
* @prefer_shadow_fbdev:
*
* Hint to framebuffer emulation to prefer shadow-fb rendering.
*/
bool prefer_shadow_fbdev;

/**
* @quirk_addfb_prefer_xbgr_30bpp:
*
Expand Down

0 comments on commit 01b947a

Please sign in to comment.