Skip to contentSkip to conversation

drm: make frame duration time calculation more precise

PATCH In review Daniel Kurtz 1 participant 3 messages Dec 27, 2012 – Feb 15, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: make frame duration time calculation more precise

It is a bit more precise to compute the total number of pixels first and then divide, rather than multiplying the line pixel count by the already-rounded line duration.

---
 drivers/gpu/drm/drm_irq.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/gpu/drm/drm_irq.c +5 -1
index 19c01ca..05c91e0 100644
@@ -505,6 +505,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc)
 
 	/* Valid dotclock? */
 	if (dotclock > 0) {
+		int frame_size;
 		/* Convert scanline length in pixels and video dot clock to
 		 * line duration, frame duration and pixel duration in
 		 * nanoseconds:
@@ -512,7 +513,10 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc)
 		pixeldur_ns = (s64) div64_u64(1000000000, dotclock);
 		linedur_ns  = (s64) div64_u64(((u64) crtc->hwmode.crtc_htotal *
 					      1000000000), dotclock);
-		framedur_ns = (s64) crtc->hwmode.crtc_vtotal * linedur_ns;
+		frame_size = crtc->hwmode.crtc_htotal *
+				crtc->hwmode.crtc_vtotal;
+		framedur_ns = (s64) div64_u64((u64) frame_size * 1000000000,
+					      dotclock);
 	} else
 		DRM_ERROR("crtc %d: Can't calculate constants, dotclock = 0!\n",
 			  crtc->base.id);
Signature · 1 line
1.7.7.3
#1 lore raw
Quoted 6 lines · Daniel Kurtz

It is a bit more precise to compute the total number of pixels first and then divide, rather than multiplying the line pixel count by the already-rounded line duration.

Ping?

Quoted 32 lines
---
 drivers/gpu/drm/drm_irq.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/gpu/drm/drm_irq.c +1 -0
index 19c01ca..05c91e0 100644
@@ -505,6 +505,7 @@ void drm_calc_timestamping_constants(struct drm_crtc
 *crtc)
 
        /* Valid dotclock? */
        if (dotclock > 0) {
+               int frame_size;
                /* Convert scanline length in pixels and video dot clock to
                 * line duration, frame duration and pixel duration in

* nanoseconds:

drivers/gpu/drm/drm_irq.c +0 -0
@@ -512,7 +513,10 @@ void drm_calc_timestamping_constants(struct drm_crtc
 *crtc)
                pixeldur_ns = (s64) div64_u64(1000000000, dotclock);
                linedur_ns  = (s64) div64_u64(((u64)

crtc->hwmode.crtc_htotal *

                                              1000000000), dotclock);
drivers/gpu/drm/drm_irq.c +3 -1
-               framedur_ns = (s64) crtc->hwmode.crtc_vtotal * linedur_ns;
+               frame_size = crtc->hwmode.crtc_htotal *
+                               crtc->hwmode.crtc_vtotal;
+               framedur_ns = (s64) div64_u64((u64) frame_size *

1000000000,
+ dotclock);
} else
DRM_ERROR("crtc %d: Can't calculate constants, dotclock =
0!\n",

Quoted 5 lines
                          crtc->base.id);

--
1.7.7.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
In reply to Daniel Kurtz
Quoted 6 lines · Daniel Kurtz

It is a bit more precise to compute the total number of pixels first and then divide, rather than multiplying the line pixel count by the already-rounded line duration.

Ping?

Quoted 37 lines
---
 drivers/gpu/drm/drm_irq.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/gpu/drm/drm_irq.c +1 -0
index 19c01ca..05c91e0 100644
@@ -505,6 +505,7 @@ void drm_calc_timestamping_constants(struct drm_crtc
 *crtc)
 
        /* Valid dotclock? */
        if (dotclock > 0) {
+               int frame_size;
                /* Convert scanline length in pixels and video dot clock

to
* line duration, frame duration and pixel duration in
* nanoseconds:

drivers/gpu/drm/drm_irq.c +0 -0
@@ -512,7 +513,10 @@ void drm_calc_timestamping_constants(struct drm_crtc
 *crtc)
                pixeldur_ns = (s64) div64_u64(1000000000, dotclock);
                linedur_ns  = (s64) div64_u64(((u64)

crtc->hwmode.crtc_htotal *

                                              1000000000), dotclock);
drivers/gpu/drm/drm_irq.c +3 -1
-               framedur_ns = (s64) crtc->hwmode.crtc_vtotal * linedur_ns;
+               frame_size = crtc->hwmode.crtc_htotal *
+                               crtc->hwmode.crtc_vtotal;
+               framedur_ns = (s64) div64_u64((u64) frame_size *

1000000000,
+ dotclock);
} else
DRM_ERROR("crtc %d: Can't calculate constants, dotclock =
0!\n",

                          crtc->base.id);

--
1.7.7.3