[PATCH xserver] xf86-video-modesetting: Add ms_queue_vblank helper [v2]
Michel Dänzer
michel at daenzer.net
Fri Sep 29 08:29:32 UTC 2017
On 29/09/17 08:30 AM, Keith Packard wrote:
> This provides an API wrapper around the kernel interface for queueing
> a vblank event, simplifying all of the callers.
>
> v2: Fix missing '|' in computing vbl.request.type
>
> Signed-off-by: Keith Packard <keithp at keithp.com>
[...]
> @@ -198,13 +198,53 @@ ms_get_kernel_ust_msc(xf86CrtcPtr crtc,
> }
> }
>
> +Bool
> +ms_queue_vblank(xf86CrtcPtr crtc, ms_queue_flag flags,
> + uint64_t msc, uint64_t *msc_queued, uint32_t seq)
> +{
> + ScreenPtr screen = crtc->randr_crtc->pScreen;
> + ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
> + modesettingPtr ms = modesettingPTR(scrn);
> + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
> + drmVBlank vbl;
> + int ret;
> +
> + for (;;) {
> + /* Queue an event at the specified sequence */
> + vbl.request.type = DRM_VBLANK_EVENT | drmmode_crtc->vblank_pipe;
> + if (flags & MS_QUEUE_RELATIVE)
> + vbl.request.type |= DRM_VBLANK_RELATIVE;
> + else
> + vbl.request.type |= DRM_VBLANK_ABSOLUTE;
> + if (flags & MS_QUEUE_NEXT_ON_MISS)
> + vbl.request.type |= DRM_VBLANK_NEXTONMISS;
> +
> + vbl.request.sequence = ms_crtc_msc_to_kernel_msc(crtc, msc);
> + vbl.request.signal = seq;
> + ret = drmWaitVBlank(ms->fd, &vbl);
> + if (ret == 0) {
> + if (msc_queued)
> + *msc_queued = ms_kernel_msc_to_crtc_msc(crtc, vbl.reply.sequence);
> + return TRUE;
> + }
> +#ifdef DRM_IOCTL_CRTC_QUEUE_SEQUENCE
> + check:
> +#endif
The DRM_IOCTL_CRTC_QUEUE_SEQUENCE part belongs in patch 2.
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
More information about the xorg-devel
mailing list