Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 345322
b: refs/heads/master
c: e62f2f5
h: refs/heads/master
v: v3
  • Loading branch information
Imre Deak authored and Dave Airlie committed Nov 20, 2012
1 parent 06676f7 commit bfb0867
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 11e686855c81c2e5e647b3dcfabd2a4e473c46f0
refs/heads/master: e62f2f5acba1d466da047983ae16f6b96b68b310
18 changes: 12 additions & 6 deletions trunk/drivers/gpu/drm/drm_irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,8 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, int crtc,
unsigned flags,
struct drm_crtc *refcrtc)
{
struct timeval stime, raw_time;
ktime_t stime, etime, mono_time_offset;
struct timeval tv_etime;
struct drm_display_mode *mode;
int vbl_status, vtotal, vdisplay;
int vpos, hpos, i;
Expand Down Expand Up @@ -625,13 +626,14 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, int crtc,
preempt_disable();

/* Get system timestamp before query. */
do_gettimeofday(&stime);
stime = ktime_get();

/* Get vertical and horizontal scanout pos. vpos, hpos. */
vbl_status = dev->driver->get_scanout_position(dev, crtc, &vpos, &hpos);

/* Get system timestamp after query. */
do_gettimeofday(&raw_time);
etime = ktime_get();
mono_time_offset = ktime_get_monotonic_offset();

preempt_enable();

Expand All @@ -642,7 +644,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, int crtc,
return -EIO;
}

duration_ns = timeval_to_ns(&raw_time) - timeval_to_ns(&stime);
duration_ns = ktime_to_ns(etime) - ktime_to_ns(stime);

/* Accept result with < max_error nsecs timing uncertainty. */
if (duration_ns <= (s64) *max_error)
Expand Down Expand Up @@ -689,14 +691,18 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, int crtc,
vbl_status |= 0x8;
}

etime = ktime_sub(etime, mono_time_offset);
/* save this only for debugging purposes */
tv_etime = ktime_to_timeval(etime);
/* Subtract time delta from raw timestamp to get final
* vblank_time timestamp for end of vblank.
*/
*vblank_time = ns_to_timeval(timeval_to_ns(&raw_time) - delta_ns);
etime = ktime_sub_ns(etime, delta_ns);
*vblank_time = ktime_to_timeval(etime);

DRM_DEBUG("crtc %d : v %d p(%d,%d)@ %ld.%ld -> %ld.%ld [e %d us, %d rep]\n",
crtc, (int)vbl_status, hpos, vpos,
(long)raw_time.tv_sec, (long)raw_time.tv_usec,
(long)tv_etime.tv_sec, (long)tv_etime.tv_usec,
(long)vblank_time->tv_sec, (long)vblank_time->tv_usec,
(int)duration_ns/1000, i);

Expand Down

0 comments on commit bfb0867

Please sign in to comment.