EXT: [PATCH weston 6/9] compositor-drm: move refresh rate computation

Pekka Paalanen ppaalanen at gmail.com
Fri Feb 9 13:56:28 UTC 2018


On Fri, 9 Feb 2018 13:19:48 +0000
"Ray, Ian (GE Healthcare)" <ian.ray at ge.com> wrote:

> > On 9 Feb 2018, at 15.07, Pekka Paalanen <ppaalanen at gmail.com> wrote:
> > 
> > From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> > 
> > Move it into to a new function. Following patches want to compute it
> > elsewhere as well.
> > 
> > No functional changes.
> > 
> > Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> > ---
> > libweston/compositor-drm.c | 33 ++++++++++++++++++++-------------
> > 1 file changed, 20 insertions(+), 13 deletions(-)
> > 
> > diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> > index 23ffb005..1897f455 100644
> > --- a/libweston/compositor-drm.c
> > +++ b/libweston/compositor-drm.c
> > @@ -3699,6 +3699,25 @@ destroy_sprites(struct drm_backend *b)
> > 		drm_plane_destroy(plane);
> > }
> > 
> > +static uint32_t
> > +drm_refresh_rate_mHz(const drmModeModeInfo *info)
> > +{
> > +	uint64_t refresh;
> > +
> > +	/* Calculate higher precision (mHz) refresh rate */  
> 
> Nit: Is it really milli-hertz?

Yes, it is. Weston and even Wayland wl_output use integer milli-Hertz
to store the monitor refresh rate. Rounding to Hz would be too coarse.


Thanks,
pq

> > +	refresh = (info->clock * 1000000LL / info->htotal +
> > +		   info->vtotal / 2) / info->vtotal;
> > +
> > +	if (info->flags & DRM_MODE_FLAG_INTERLACE)
> > +		refresh *= 2;
> > +	if (info->flags & DRM_MODE_FLAG_DBLSCAN)
> > +		refresh /= 2;
> > +	if (info->vscan > 1)
> > +	    refresh /= info->vscan;
> > +
> > +	return refresh;
> > +}
> > +
> > /**
> >  * Add a mode to output's mode list
> >  *
> > @@ -3713,7 +3732,6 @@ static struct drm_mode *
> > drm_output_add_mode(struct drm_output *output, const drmModeModeInfo *info)
> > {
> > 	struct drm_mode *mode;
> > -	uint64_t refresh;
> > 
> > 	mode = malloc(sizeof *mode);
> > 	if (mode == NULL)
> > @@ -3723,18 +3741,7 @@ drm_output_add_mode(struct drm_output *output, const drmModeModeInfo *info)
> > 	mode->base.width = info->hdisplay;
> > 	mode->base.height = info->vdisplay;
> > 
> > -	/* Calculate higher precision (mHz) refresh rate */
> > -	refresh = (info->clock * 1000000LL / info->htotal +
> > -		   info->vtotal / 2) / info->vtotal;
> > -
> > -	if (info->flags & DRM_MODE_FLAG_INTERLACE)
> > -		refresh *= 2;
> > -	if (info->flags & DRM_MODE_FLAG_DBLSCAN)
> > -		refresh /= 2;
> > -	if (info->vscan > 1)
> > -	    refresh /= info->vscan;
> > -
> > -	mode->base.refresh = refresh;
> > +	mode->base.refresh = drm_refresh_rate_mHz(info);
> > 	mode->mode_info = *info;
> > 	mode->blob_id = 0;
> > 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20180209/b8d17234/attachment-0001.sig>


More information about the wayland-devel mailing list