a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/*
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Copyright © 2013 Keith Packard
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync *
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Permission to use, copy, modify, distribute, and sell this software and its
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * documentation for any purpose is hereby granted without fee, provided that
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * the above copyright notice appear in all copies and that both that copyright
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * notice and this permission notice appear in supporting documentation, and
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * that the name of the copyright holders not be used in advertising or
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * publicity pertaining to distribution of the software without specific,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * written prior permission. The copyright holders make no representations
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * about the suitability of this software for any purpose. It is provided "as
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * is" without express or implied warranty.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync *
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * OF THIS SOFTWARE.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#ifndef _PRESENT_H_
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define _PRESENT_H_
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#include <X11/extensions/presentproto.h>
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#include "randrstr.h"
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#include "presentext.h"
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef struct present_vblank present_vblank_rec, *present_vblank_ptr;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* Return the current CRTC for 'window'.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef RRCrtcPtr (*present_get_crtc_ptr) (WindowPtr window);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* Return the current ust/msc for 'crtc'
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef int (*present_get_ust_msc_ptr) (RRCrtcPtr crtc, uint64_t *ust, uint64_t *msc);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* Queue callback on 'crtc' for time 'msc'. Call present_event_notify with 'event_id'
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * at or after 'msc'. Return false if it didn't happen (which might occur if 'crtc'
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * is not currently generating vblanks).
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef Bool (*present_queue_vblank_ptr) (RRCrtcPtr crtc,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync uint64_t event_id,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync uint64_t msc);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* Abort pending vblank. The extension is no longer interested in
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * 'event_id' which was to be notified at 'msc'. If possible, the
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * driver is free to de-queue the notification.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef void (*present_abort_vblank_ptr) (RRCrtcPtr crtc, uint64_t event_id, uint64_t msc);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* Flush pending drawing on 'window' to the hardware.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef void (*present_flush_ptr) (WindowPtr window);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* Check if 'pixmap' is suitable for flipping to 'window'.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef Bool (*present_check_flip_ptr) (RRCrtcPtr crtc, WindowPtr window, PixmapPtr pixmap, Bool sync_flip);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* Flip pixmap, return false if it didn't happen.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync *
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * 'crtc' is to be used for any necessary synchronization.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync *
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * 'sync_flip' requests that the flip be performed at the next
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * vertical blank interval to avoid tearing artifacts. If false, the
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * flip should be performed as soon as possible.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync *
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * present_event_notify should be called with 'event_id' when the flip
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * occurs
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef Bool (*present_flip_ptr) (RRCrtcPtr crtc,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync uint64_t event_id,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync uint64_t target_msc,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync PixmapPtr pixmap,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync Bool sync_flip);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* "unflip" back to the regular screen scanout buffer
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync *
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * present_event_notify should be called with 'event_id' when the unflip occurs.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef void (*present_unflip_ptr) (ScreenPtr screen,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync uint64_t event_id);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define PRESENT_SCREEN_INFO_VERSION 0
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef struct present_screen_info {
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync uint32_t version;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync present_get_crtc_ptr get_crtc;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync present_get_ust_msc_ptr get_ust_msc;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync present_queue_vblank_ptr queue_vblank;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync present_abort_vblank_ptr abort_vblank;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync present_flush_ptr flush;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync uint32_t capabilities;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync present_check_flip_ptr check_flip;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync present_flip_ptr flip;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync present_unflip_ptr unflip;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync} present_screen_info_rec, *present_screen_info_ptr;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/*
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Called when 'event_id' occurs. 'ust' and 'msc' indicate when the
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * event actually happened
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT void
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncpresent_event_notify(uint64_t event_id, uint64_t ust, uint64_t msc);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* 'crtc' has been turned off, so any pending events will never occur.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT void
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncpresent_event_abandon(RRCrtcPtr crtc);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT Bool
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncpresent_screen_init(ScreenPtr screen, present_screen_info_ptr info);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef void (*present_complete_notify_proc)(WindowPtr window,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync CARD8 kind,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync CARD8 mode,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync CARD32 serial,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync uint64_t ust,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync uint64_t msc);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT void
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncpresent_register_complete_notify(present_complete_notify_proc proc);
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#endif /* _PRESENT_H_ */