[PATCH 4/4] DRI2: defer swap if relevant CRTC is in DMPS off state

Michel Dänzer michel at daenzer.net
Mon Dec 17 08:07:03 PST 2012


On Fre, 2012-12-14 at 21:09 -0500, Ilija Hadzic wrote: 
> 
> diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
> index a025e16..98ce8eb 100644
> --- a/src/radeon_dri2.c
> +++ b/src/radeon_dri2.c
> @@ -1281,6 +1282,45 @@ void radeon_dri2_flip_event_handler(unsigned int frame, unsigned int tv_sec,
>  }
>  
>  /*
> + * Subtract current time from the time of last recorded frame event.
> + * In (highly unlikely) case of an overflow, clip the result to max integer
> + */
> +static int time_since_last_event(unsigned int tv_sec, unsigned int tv_usec)
> +{
> +    struct timeval now;
> +    int64_t delta_t_usec, delta_t_msec;
> +    int delta_t_sec;
> +
> +    gettimeofday(&now, NULL);
> +    delta_t_sec = (int)now.tv_sec - (int)tv_sec;
> +    delta_t_usec = (int64_t)now.tv_usec - (int64_t)tv_usec;
> +    delta_t_usec += (int64_t)delta_t_sec * 1000000;
> +    delta_t_msec = delta_t_usec / 1000;
> +    if (delta_t_msec > INT_MAX)
> +	delta_t_msec = INT_MAX;
> +    if (delta_t_msec < -INT_MAX)
> +	delta_t_msec = -INT_MAX;
> +    return delta_t_msec;

This looks unnecessarily complicated. Just calculate the delta as a
subtraction of two uint64_t values (so wraparounds are handled
naturally) and cast it to int64_t for testing < 0.


-- 
Earthling Michel Dänzer           |                   http://www.amd.com
Libre software enthusiast         |          Debian, X and DRI developer


More information about the xorg-driver-ati mailing list