Message ID | 20180222200653.19453-9-noralf@tronnes.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Feb 22, 2018 at 09:06:49PM +0100, Noralf Trønnes wrote: > Add a function so the generic fbdev client can check if the framebuffer > does flushing. This is needed to set up deferred I/O. > > Signed-off-by: Noralf Trønnes <noralf@tronnes.org> Again I guess not needed if we use drm_framebuffer * internally for in-kernel clients. For a high-level design I think the only place where we have to use the abstract (drm_file, id) pair is for backing storage buffers, because not every driver is using drm_gem_object for that. But otherwise I don't think there's a need, and not using the abstract IDs makes for more cumbersome code I think. Real userspace compositors also recreate their own mirroring objects as the first thing, since the IDs are all a bit unwiedling to manage. -Daniel > --- > drivers/gpu/drm/drm_framebuffer.c | 31 +++++++++++++++++++++++++++++++ > include/drm/drm_framebuffer.h | 2 ++ > 2 files changed, 33 insertions(+) > > diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c > index ad8f7d308656..a659cff45844 100644 > --- a/drivers/gpu/drm/drm_framebuffer.c > +++ b/drivers/gpu/drm/drm_framebuffer.c > @@ -600,6 +600,37 @@ int drm_mode_dirtyfb_ioctl(struct drm_device *dev, > return drm_mode_dirtyfb(dev, data, file_priv, true); > } > > +/** > + * drm_mode_can_dirtyfb - check if the FB does flushing > + * @dev: drm device > + * @fb_id: Framebuffer id > + * @file_priv: drm file > + * > + * Returns: > + * True if the framebuffer does flushing, false otherwise. > + */ > +bool drm_mode_can_dirtyfb(struct drm_device *dev, u32 fb_id, > + struct drm_file *file_priv) > +{ > + struct drm_framebuffer *fb; > + bool ret = false; > + > + if (!drm_core_check_feature(dev, DRIVER_MODESET)) > + return false; > + > + fb = drm_framebuffer_lookup(dev, file_priv, fb_id); > + if (!fb) > + return false; > + > + if (fb->funcs->dirty) > + ret = true; > + > + drm_framebuffer_put(fb); > + > + return ret; > +} > +EXPORT_SYMBOL(drm_mode_can_dirtyfb); > + > /** > * drm_fb_release - remove and free the FBs on this file > * @priv: drm file for the ioctl > diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h > index c50502c656e5..05d170f4e215 100644 > --- a/include/drm/drm_framebuffer.h > +++ b/include/drm/drm_framebuffer.h > @@ -216,6 +216,8 @@ struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev, > void drm_framebuffer_remove(struct drm_framebuffer *fb); > void drm_framebuffer_cleanup(struct drm_framebuffer *fb); > void drm_framebuffer_unregister_private(struct drm_framebuffer *fb); > +bool drm_mode_can_dirtyfb(struct drm_device *dev, u32 fb_id, > + struct drm_file *file_priv); > > /** > * drm_framebuffer_get - acquire a framebuffer reference > -- > 2.15.1 >
diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c index ad8f7d308656..a659cff45844 100644 --- a/drivers/gpu/drm/drm_framebuffer.c +++ b/drivers/gpu/drm/drm_framebuffer.c @@ -600,6 +600,37 @@ int drm_mode_dirtyfb_ioctl(struct drm_device *dev, return drm_mode_dirtyfb(dev, data, file_priv, true); } +/** + * drm_mode_can_dirtyfb - check if the FB does flushing + * @dev: drm device + * @fb_id: Framebuffer id + * @file_priv: drm file + * + * Returns: + * True if the framebuffer does flushing, false otherwise. + */ +bool drm_mode_can_dirtyfb(struct drm_device *dev, u32 fb_id, + struct drm_file *file_priv) +{ + struct drm_framebuffer *fb; + bool ret = false; + + if (!drm_core_check_feature(dev, DRIVER_MODESET)) + return false; + + fb = drm_framebuffer_lookup(dev, file_priv, fb_id); + if (!fb) + return false; + + if (fb->funcs->dirty) + ret = true; + + drm_framebuffer_put(fb); + + return ret; +} +EXPORT_SYMBOL(drm_mode_can_dirtyfb); + /** * drm_fb_release - remove and free the FBs on this file * @priv: drm file for the ioctl diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h index c50502c656e5..05d170f4e215 100644 --- a/include/drm/drm_framebuffer.h +++ b/include/drm/drm_framebuffer.h @@ -216,6 +216,8 @@ struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev, void drm_framebuffer_remove(struct drm_framebuffer *fb); void drm_framebuffer_cleanup(struct drm_framebuffer *fb); void drm_framebuffer_unregister_private(struct drm_framebuffer *fb); +bool drm_mode_can_dirtyfb(struct drm_device *dev, u32 fb_id, + struct drm_file *file_priv); /** * drm_framebuffer_get - acquire a framebuffer reference
Add a function so the generic fbdev client can check if the framebuffer does flushing. This is needed to set up deferred I/O. Signed-off-by: Noralf Trønnes <noralf@tronnes.org> --- drivers/gpu/drm/drm_framebuffer.c | 31 +++++++++++++++++++++++++++++++ include/drm/drm_framebuffer.h | 2 ++ 2 files changed, 33 insertions(+)