Commit c229bfbb authored by Michel Dänzer's avatar Michel Dänzer Committed by Alex Deucher

drm: Add page_flip_target CRTC hook v2

Mostly the same as the existing page_flip hook, but takes an additional
parameter specifying the target vertical blank period when the flip
should take effect.

v2:
* Add curly braces around else statement corresponding to an if block
  with curly braces (Alex Deucher)
* Call drm_crtc_vblank_put in the error case (Daniel Vetter)
* Clarify entry point documentation comment (Daniel Vetter)
Acked-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarMichel Dänzer <michel.daenzer@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 88afb9e6
...@@ -5402,6 +5402,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, ...@@ -5402,6 +5402,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
struct drm_crtc *crtc; struct drm_crtc *crtc;
struct drm_framebuffer *fb = NULL; struct drm_framebuffer *fb = NULL;
struct drm_pending_vblank_event *e = NULL; struct drm_pending_vblank_event *e = NULL;
u32 target_vblank = 0;
int ret = -EINVAL; int ret = -EINVAL;
if (page_flip->flags & ~DRM_MODE_PAGE_FLIP_FLAGS || if (page_flip->flags & ~DRM_MODE_PAGE_FLIP_FLAGS ||
...@@ -5415,6 +5416,19 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, ...@@ -5415,6 +5416,19 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
if (!crtc) if (!crtc)
return -ENOENT; return -ENOENT;
if (crtc->funcs->page_flip_target) {
int r;
r = drm_crtc_vblank_get(crtc);
if (r)
return r;
target_vblank = drm_crtc_vblank_count(crtc) +
!(page_flip->flags & DRM_MODE_PAGE_FLIP_ASYNC);
} else if (crtc->funcs->page_flip == NULL) {
return -EINVAL;
}
drm_modeset_lock_crtc(crtc, crtc->primary); drm_modeset_lock_crtc(crtc, crtc->primary);
if (crtc->primary->fb == NULL) { if (crtc->primary->fb == NULL) {
/* The framebuffer is currently unbound, presumably /* The framebuffer is currently unbound, presumably
...@@ -5425,9 +5439,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, ...@@ -5425,9 +5439,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
goto out; goto out;
} }
if (crtc->funcs->page_flip == NULL)
goto out;
fb = drm_framebuffer_lookup(dev, page_flip->fb_id); fb = drm_framebuffer_lookup(dev, page_flip->fb_id);
if (!fb) { if (!fb) {
ret = -ENOENT; ret = -ENOENT;
...@@ -5468,7 +5479,12 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, ...@@ -5468,7 +5479,12 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
} }
crtc->primary->old_fb = crtc->primary->fb; crtc->primary->old_fb = crtc->primary->fb;
ret = crtc->funcs->page_flip(crtc, fb, e, page_flip->flags); if (crtc->funcs->page_flip_target)
ret = crtc->funcs->page_flip_target(crtc, fb, e,
page_flip->flags,
target_vblank);
else
ret = crtc->funcs->page_flip(crtc, fb, e, page_flip->flags);
if (ret) { if (ret) {
if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT)
drm_event_cancel_free(dev, &e->base); drm_event_cancel_free(dev, &e->base);
...@@ -5481,6 +5497,8 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, ...@@ -5481,6 +5497,8 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
} }
out: out:
if (ret)
drm_crtc_vblank_put(crtc);
if (fb) if (fb)
drm_framebuffer_unreference(fb); drm_framebuffer_unreference(fb);
if (crtc->primary->old_fb) if (crtc->primary->old_fb)
......
...@@ -580,6 +580,24 @@ struct drm_crtc_funcs { ...@@ -580,6 +580,24 @@ struct drm_crtc_funcs {
struct drm_pending_vblank_event *event, struct drm_pending_vblank_event *event,
uint32_t flags); uint32_t flags);
/**
* @page_flip_target:
*
* Same as @page_flip but with an additional parameter specifying the
* absolute target vertical blank period (as reported by
* drm_crtc_vblank_count()) when the flip should take effect.
*
* Note that the core code calls drm_crtc_vblank_get before this entry
* point, and will call drm_crtc_vblank_put if this entry point returns
* any non-0 error code. It's the driver's responsibility to call
* drm_crtc_vblank_put after this entry point returns 0, typically when
* the flip completes.
*/
int (*page_flip_target)(struct drm_crtc *crtc,
struct drm_framebuffer *fb,
struct drm_pending_vblank_event *event,
uint32_t flags, uint32_t target);
/** /**
* @set_property: * @set_property:
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment