aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_vblank.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2019-01-17 18:20:10 -0500
committerDave Airlie <airlied@redhat.com>2019-01-17 18:31:28 -0500
commitf164a94c2c87752caeb1a3cbe068c440e7f7921f (patch)
treee914296ef0ce1df83e506a12bf4306d5aa468b24 /drivers/gpu/drm/drm_vblank.c
parentb122153c7198e35fcb981ca9efd63b0df8ef3eab (diff)
parent94520db52fc0e931327bb77fe79a952a0e9dd2b0 (diff)
Merge tag 'drm-misc-next-2019-01-16' of git://anongit.freedesktop.org/drm/drm-misc into drm-next
drm-misc-next for 5.1: UAPI Changes: - New fourcc identifier for ARM Framebuffer Compression v1.3 Cross-subsystem Changes: Core Changes: - Reorganisation of drm_device and drm_framebuffer headers - Cleanup of the drmP inclusion - Fix leaks in the fb-helpers - Allow for depth different from bpp in fb-helper fbdev emulation - Remove drm_mode_object from drm_display_mode Driver Changes: - Add reflection properties to rockchip - a bunch of fixes for virtio - a bunch of fixes for dp_mst and drivers using it, and introduction of a new refcounting scheme - Convertion of bochs to atomic and generic fbdev emulation - Allow meson to remove the firmware framebuffers [airlied: patch rcar-du to add drm_modes.h] Signed-off-by: Dave Airlie <airlied@redhat.com> From: Maxime Ripard <maxime.ripard@bootlin.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190116200428.u2n4jbk4mzza7n6e@flea
Diffstat (limited to 'drivers/gpu/drm/drm_vblank.c')
-rw-r--r--drivers/gpu/drm/drm_vblank.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index 98e091175921..cde71ee95a8f 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -105,13 +105,20 @@ static void store_vblank(struct drm_device *dev, unsigned int pipe,
105 write_sequnlock(&vblank->seqlock); 105 write_sequnlock(&vblank->seqlock);
106} 106}
107 107
108static u32 drm_max_vblank_count(struct drm_device *dev, unsigned int pipe)
109{
110 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
111
112 return vblank->max_vblank_count ?: dev->max_vblank_count;
113}
114
108/* 115/*
109 * "No hw counter" fallback implementation of .get_vblank_counter() hook, 116 * "No hw counter" fallback implementation of .get_vblank_counter() hook,
110 * if there is no useable hardware frame counter available. 117 * if there is no useable hardware frame counter available.
111 */ 118 */
112static u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe) 119static u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe)
113{ 120{
114 WARN_ON_ONCE(dev->max_vblank_count != 0); 121 WARN_ON_ONCE(drm_max_vblank_count(dev, pipe) != 0);
115 return 0; 122 return 0;
116} 123}
117 124
@@ -198,6 +205,7 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,
198 ktime_t t_vblank; 205 ktime_t t_vblank;
199 int count = DRM_TIMESTAMP_MAXRETRIES; 206 int count = DRM_TIMESTAMP_MAXRETRIES;
200 int framedur_ns = vblank->framedur_ns; 207 int framedur_ns = vblank->framedur_ns;
208 u32 max_vblank_count = drm_max_vblank_count(dev, pipe);
201 209
202 /* 210 /*
203 * Interrupts were disabled prior to this call, so deal with counter 211 * Interrupts were disabled prior to this call, so deal with counter
@@ -216,9 +224,9 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,
216 rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, in_vblank_irq); 224 rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, in_vblank_irq);
217 } while (cur_vblank != __get_vblank_counter(dev, pipe) && --count > 0); 225 } while (cur_vblank != __get_vblank_counter(dev, pipe) && --count > 0);
218 226
219 if (dev->max_vblank_count != 0) { 227 if (max_vblank_count) {
220 /* trust the hw counter when it's around */ 228 /* trust the hw counter when it's around */
221 diff = (cur_vblank - vblank->last) & dev->max_vblank_count; 229 diff = (cur_vblank - vblank->last) & max_vblank_count;
222 } else if (rc && framedur_ns) { 230 } else if (rc && framedur_ns) {
223 u64 diff_ns = ktime_to_ns(ktime_sub(t_vblank, vblank->time)); 231 u64 diff_ns = ktime_to_ns(ktime_sub(t_vblank, vblank->time));
224 232
@@ -1205,6 +1213,37 @@ void drm_crtc_vblank_reset(struct drm_crtc *crtc)
1205EXPORT_SYMBOL(drm_crtc_vblank_reset); 1213EXPORT_SYMBOL(drm_crtc_vblank_reset);
1206 1214
1207/** 1215/**
1216 * drm_crtc_set_max_vblank_count - configure the hw max vblank counter value
1217 * @crtc: CRTC in question
1218 * @max_vblank_count: max hardware vblank counter value
1219 *
1220 * Update the maximum hardware vblank counter value for @crtc
1221 * at runtime. Useful for hardware where the operation of the
1222 * hardware vblank counter depends on the currently active
1223 * display configuration.
1224 *
1225 * For example, if the hardware vblank counter does not work
1226 * when a specific connector is active the maximum can be set
1227 * to zero. And when that specific connector isn't active the
1228 * maximum can again be set to the appropriate non-zero value.
1229 *
1230 * If used, must be called before drm_vblank_on().
1231 */
1232void drm_crtc_set_max_vblank_count(struct drm_crtc *crtc,
1233 u32 max_vblank_count)
1234{
1235 struct drm_device *dev = crtc->dev;
1236 unsigned int pipe = drm_crtc_index(crtc);
1237 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
1238
1239 WARN_ON(dev->max_vblank_count);
1240 WARN_ON(!READ_ONCE(vblank->inmodeset));
1241
1242 vblank->max_vblank_count = max_vblank_count;
1243}
1244EXPORT_SYMBOL(drm_crtc_set_max_vblank_count);
1245
1246/**
1208 * drm_crtc_vblank_on - enable vblank events on a CRTC 1247 * drm_crtc_vblank_on - enable vblank events on a CRTC
1209 * @crtc: CRTC in question 1248 * @crtc: CRTC in question
1210 * 1249 *