Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c184f69 authored by Ville Syrjälä's avatar Ville Syrjälä
Browse files

drm: Change {pixel,line,frame}dur_ns from s64 to int



Using s64 for the timestamping constants is wasteful. Signed 32bit
integers get us a range of over +-2 seconds. Presuming that no-one
wants to a vrefresh rate less than 0.5, we can switch to using int
for the timestamping constants. We save a few bytes in drm_crtc and
avoid a bunch of 64bit math.

Reviewed-by: default avatar <mario.kleiner.de@gmail.com>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
parent 77666b72
Loading
Loading
Loading
Loading
+9 −9
Original line number Original line Diff line number Diff line
@@ -450,7 +450,7 @@ int drm_control(struct drm_device *dev, void *data,
void drm_calc_timestamping_constants(struct drm_crtc *crtc,
void drm_calc_timestamping_constants(struct drm_crtc *crtc,
				     const struct drm_display_mode *mode)
				     const struct drm_display_mode *mode)
{
{
	s64 linedur_ns = 0, pixeldur_ns = 0, framedur_ns = 0;
	int linedur_ns = 0, pixeldur_ns = 0, framedur_ns = 0;
	int dotclock = mode->crtc_clock;
	int dotclock = mode->crtc_clock;


	/* Fields of interlaced scanout modes are only half a frame duration.
	/* Fields of interlaced scanout modes are only half a frame duration.
@@ -483,8 +483,8 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,
		  crtc->base.id, mode->crtc_htotal,
		  crtc->base.id, mode->crtc_htotal,
		  mode->crtc_vtotal, mode->crtc_vdisplay);
		  mode->crtc_vtotal, mode->crtc_vdisplay);
	DRM_DEBUG("crtc %d: clock %d kHz framedur %d linedur %d, pixeldur %d\n",
	DRM_DEBUG("crtc %d: clock %d kHz framedur %d linedur %d, pixeldur %d\n",
		  crtc->base.id, dotclock, (int) framedur_ns,
		  crtc->base.id, dotclock, framedur_ns,
		  (int) linedur_ns, (int) pixeldur_ns);
		  linedur_ns, pixeldur_ns);
}
}
EXPORT_SYMBOL(drm_calc_timestamping_constants);
EXPORT_SYMBOL(drm_calc_timestamping_constants);


@@ -544,7 +544,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, int crtc,
	struct timeval tv_etime;
	struct timeval tv_etime;
	int vbl_status, vtotal, vdisplay;
	int vbl_status, vtotal, vdisplay;
	int vpos, hpos, i;
	int vpos, hpos, i;
	s64 framedur_ns, linedur_ns, pixeldur_ns, delta_ns, duration_ns;
	int framedur_ns, linedur_ns, pixeldur_ns, delta_ns, duration_ns;
	bool invbl;
	bool invbl;


	if (crtc < 0 || crtc >= dev->num_crtcs) {
	if (crtc < 0 || crtc >= dev->num_crtcs) {
@@ -607,18 +607,18 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, int crtc,
		duration_ns = ktime_to_ns(etime) - ktime_to_ns(stime);
		duration_ns = ktime_to_ns(etime) - ktime_to_ns(stime);


		/* Accept result with <  max_error nsecs timing uncertainty. */
		/* Accept result with <  max_error nsecs timing uncertainty. */
		if (duration_ns <= (s64) *max_error)
		if (duration_ns <= *max_error)
			break;
			break;
	}
	}


	/* Noisy system timing? */
	/* Noisy system timing? */
	if (i == DRM_TIMESTAMP_MAXRETRIES) {
	if (i == DRM_TIMESTAMP_MAXRETRIES) {
		DRM_DEBUG("crtc %d: Noisy timestamp %d us > %d us [%d reps].\n",
		DRM_DEBUG("crtc %d: Noisy timestamp %d us > %d us [%d reps].\n",
			  crtc, (int) duration_ns/1000, *max_error/1000, i);
			  crtc, duration_ns/1000, *max_error/1000, i);
	}
	}


	/* Return upper bound of timestamp precision error. */
	/* Return upper bound of timestamp precision error. */
	*max_error = (int) duration_ns;
	*max_error = duration_ns;


	/* Check if in vblank area:
	/* Check if in vblank area:
	 * vpos is >=0 in video scanout area, but negative
	 * vpos is >=0 in video scanout area, but negative
@@ -631,7 +631,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, int crtc,
	 * since start of scanout at first display scanline. delta_ns
	 * since start of scanout at first display scanline. delta_ns
	 * can be negative if start of scanout hasn't happened yet.
	 * can be negative if start of scanout hasn't happened yet.
	 */
	 */
	delta_ns = (s64) vpos * linedur_ns + (s64) hpos * pixeldur_ns;
	delta_ns = vpos * linedur_ns + hpos * pixeldur_ns;


	/* Is vpos outside nominal vblank area, but less than
	/* Is vpos outside nominal vblank area, but less than
	 * 1/100 of a frame height away from start of vblank?
	 * 1/100 of a frame height away from start of vblank?
@@ -669,7 +669,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, int crtc,
		  crtc, (int)vbl_status, hpos, vpos,
		  crtc, (int)vbl_status, hpos, vpos,
		  (long)tv_etime.tv_sec, (long)tv_etime.tv_usec,
		  (long)tv_etime.tv_sec, (long)tv_etime.tv_usec,
		  (long)vblank_time->tv_sec, (long)vblank_time->tv_usec,
		  (long)vblank_time->tv_sec, (long)vblank_time->tv_usec,
		  (int)duration_ns/1000, i);
		  duration_ns/1000, i);


	vbl_status = DRM_VBLANKTIME_SCANOUTPOS_METHOD;
	vbl_status = DRM_VBLANKTIME_SCANOUTPOS_METHOD;
	if (invbl)
	if (invbl)
+1 −1
Original line number Original line Diff line number Diff line
@@ -447,7 +447,7 @@ struct drm_crtc {
	uint16_t *gamma_store;
	uint16_t *gamma_store;


	/* Constants needed for precise vblank and swap timestamping. */
	/* Constants needed for precise vblank and swap timestamping. */
	s64 framedur_ns, linedur_ns, pixeldur_ns;
	int framedur_ns, linedur_ns, pixeldur_ns;


	/* if you are using the helper */
	/* if you are using the helper */
	void *helper_private;
	void *helper_private;