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