135c4bbdfSmrg/* 235c4bbdfSmrg * Copyright © 2013 Keith Packard 335c4bbdfSmrg * 435c4bbdfSmrg * Permission to use, copy, modify, distribute, and sell this software and its 535c4bbdfSmrg * documentation for any purpose is hereby granted without fee, provided that 635c4bbdfSmrg * the above copyright notice appear in all copies and that both that copyright 735c4bbdfSmrg * notice and this permission notice appear in supporting documentation, and 835c4bbdfSmrg * that the name of the copyright holders not be used in advertising or 935c4bbdfSmrg * publicity pertaining to distribution of the software without specific, 1035c4bbdfSmrg * written prior permission. The copyright holders make no representations 1135c4bbdfSmrg * about the suitability of this software for any purpose. It is provided "as 1235c4bbdfSmrg * is" without express or implied warranty. 1335c4bbdfSmrg * 1435c4bbdfSmrg * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 1535c4bbdfSmrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 1635c4bbdfSmrg * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 1735c4bbdfSmrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 1835c4bbdfSmrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 1935c4bbdfSmrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 2035c4bbdfSmrg * OF THIS SOFTWARE. 2135c4bbdfSmrg */ 2235c4bbdfSmrg 2335c4bbdfSmrg#ifndef _PRESENT_H_ 2435c4bbdfSmrg#define _PRESENT_H_ 2535c4bbdfSmrg 2635c4bbdfSmrg#include <X11/extensions/presentproto.h> 2735c4bbdfSmrg#include "randrstr.h" 2835c4bbdfSmrg#include "presentext.h" 2935c4bbdfSmrg 301b5d61b8Smrgtypedef enum { 311b5d61b8Smrg PRESENT_FLIP_REASON_UNKNOWN, 321b5d61b8Smrg PRESENT_FLIP_REASON_BUFFER_FORMAT 331b5d61b8Smrg} PresentFlipReason; 341b5d61b8Smrg 3535c4bbdfSmrgtypedef struct present_vblank present_vblank_rec, *present_vblank_ptr; 3635c4bbdfSmrg 3735c4bbdfSmrg/* Return the current CRTC for 'window'. 3835c4bbdfSmrg */ 3935c4bbdfSmrgtypedef RRCrtcPtr (*present_get_crtc_ptr) (WindowPtr window); 4035c4bbdfSmrg 4135c4bbdfSmrg/* Return the current ust/msc for 'crtc' 4235c4bbdfSmrg */ 4335c4bbdfSmrgtypedef int (*present_get_ust_msc_ptr) (RRCrtcPtr crtc, uint64_t *ust, uint64_t *msc); 441b5d61b8Smrgtypedef int (*present_wnmd_get_ust_msc_ptr) (WindowPtr window, uint64_t *ust, uint64_t *msc); 4535c4bbdfSmrg 4635c4bbdfSmrg/* Queue callback on 'crtc' for time 'msc'. Call present_event_notify with 'event_id' 4735c4bbdfSmrg * at or after 'msc'. Return false if it didn't happen (which might occur if 'crtc' 4835c4bbdfSmrg * is not currently generating vblanks). 4935c4bbdfSmrg */ 5035c4bbdfSmrgtypedef Bool (*present_queue_vblank_ptr) (RRCrtcPtr crtc, 5135c4bbdfSmrg uint64_t event_id, 5235c4bbdfSmrg uint64_t msc); 531b5d61b8Smrgtypedef Bool (*present_wnmd_queue_vblank_ptr) (WindowPtr window, 541b5d61b8Smrg RRCrtcPtr crtc, 551b5d61b8Smrg uint64_t event_id, 561b5d61b8Smrg uint64_t msc); 5735c4bbdfSmrg 5835c4bbdfSmrg/* Abort pending vblank. The extension is no longer interested in 5935c4bbdfSmrg * 'event_id' which was to be notified at 'msc'. If possible, the 6035c4bbdfSmrg * driver is free to de-queue the notification. 6135c4bbdfSmrg */ 6235c4bbdfSmrgtypedef void (*present_abort_vblank_ptr) (RRCrtcPtr crtc, uint64_t event_id, uint64_t msc); 631b5d61b8Smrgtypedef void (*present_wnmd_abort_vblank_ptr) (WindowPtr window, 641b5d61b8Smrg RRCrtcPtr crtc, 651b5d61b8Smrg uint64_t event_id, 661b5d61b8Smrg uint64_t msc); 6735c4bbdfSmrg 6835c4bbdfSmrg/* Flush pending drawing on 'window' to the hardware. 6935c4bbdfSmrg */ 7035c4bbdfSmrgtypedef void (*present_flush_ptr) (WindowPtr window); 7135c4bbdfSmrg 7235c4bbdfSmrg/* Check if 'pixmap' is suitable for flipping to 'window'. 7335c4bbdfSmrg */ 7435c4bbdfSmrgtypedef Bool (*present_check_flip_ptr) (RRCrtcPtr crtc, WindowPtr window, PixmapPtr pixmap, Bool sync_flip); 7535c4bbdfSmrg 761b5d61b8Smrg/* Same as 'check_flip' but it can return a 'reason' why the flip would fail. 771b5d61b8Smrg */ 781b5d61b8Smrgtypedef Bool (*present_check_flip2_ptr) (RRCrtcPtr crtc, WindowPtr window, PixmapPtr pixmap, Bool sync_flip, PresentFlipReason *reason); 791b5d61b8Smrg 8035c4bbdfSmrg/* Flip pixmap, return false if it didn't happen. 8135c4bbdfSmrg * 8235c4bbdfSmrg * 'crtc' is to be used for any necessary synchronization. 8335c4bbdfSmrg * 8435c4bbdfSmrg * 'sync_flip' requests that the flip be performed at the next 8535c4bbdfSmrg * vertical blank interval to avoid tearing artifacts. If false, the 8635c4bbdfSmrg * flip should be performed as soon as possible. 8735c4bbdfSmrg * 8835c4bbdfSmrg * present_event_notify should be called with 'event_id' when the flip 8935c4bbdfSmrg * occurs 9035c4bbdfSmrg */ 9135c4bbdfSmrgtypedef Bool (*present_flip_ptr) (RRCrtcPtr crtc, 9235c4bbdfSmrg uint64_t event_id, 9335c4bbdfSmrg uint64_t target_msc, 9435c4bbdfSmrg PixmapPtr pixmap, 9535c4bbdfSmrg Bool sync_flip); 961b5d61b8Smrg/* Flip pixmap for window, return false if it didn't happen. 971b5d61b8Smrg * 98ed6184dfSmrg * Like present_flip_ptr, additionally with: 991b5d61b8Smrg * 1001b5d61b8Smrg * 'window' used for synchronization. 1011b5d61b8Smrg * 1021b5d61b8Smrg */ 1031b5d61b8Smrgtypedef Bool (*present_wnmd_flip_ptr) (WindowPtr window, 1041b5d61b8Smrg RRCrtcPtr crtc, 1051b5d61b8Smrg uint64_t event_id, 1061b5d61b8Smrg uint64_t target_msc, 1071b5d61b8Smrg PixmapPtr pixmap, 1081b5d61b8Smrg Bool sync_flip, 1091b5d61b8Smrg RegionPtr damage); 11035c4bbdfSmrg 11135c4bbdfSmrg/* "unflip" back to the regular screen scanout buffer 11235c4bbdfSmrg * 11335c4bbdfSmrg * present_event_notify should be called with 'event_id' when the unflip occurs. 11435c4bbdfSmrg */ 11535c4bbdfSmrgtypedef void (*present_unflip_ptr) (ScreenPtr screen, 11635c4bbdfSmrg uint64_t event_id); 11735c4bbdfSmrg 1181b5d61b8Smrg/* Doing flips has been discontinued. 1191b5d61b8Smrg * 1201b5d61b8Smrg * Inform driver for potential cleanup on its side. 1211b5d61b8Smrg */ 1221b5d61b8Smrgtypedef void (*present_wnmd_flips_stop_ptr) (WindowPtr window); 1231b5d61b8Smrg 1241b5d61b8Smrg#define PRESENT_SCREEN_INFO_VERSION 1 12535c4bbdfSmrg 12635c4bbdfSmrgtypedef struct present_screen_info { 12735c4bbdfSmrg uint32_t version; 12835c4bbdfSmrg 12935c4bbdfSmrg present_get_crtc_ptr get_crtc; 13035c4bbdfSmrg present_get_ust_msc_ptr get_ust_msc; 13135c4bbdfSmrg present_queue_vblank_ptr queue_vblank; 13235c4bbdfSmrg present_abort_vblank_ptr abort_vblank; 13335c4bbdfSmrg present_flush_ptr flush; 13435c4bbdfSmrg uint32_t capabilities; 13535c4bbdfSmrg present_check_flip_ptr check_flip; 13635c4bbdfSmrg present_flip_ptr flip; 13735c4bbdfSmrg present_unflip_ptr unflip; 1381b5d61b8Smrg present_check_flip2_ptr check_flip2; 13935c4bbdfSmrg 14035c4bbdfSmrg} present_screen_info_rec, *present_screen_info_ptr; 14135c4bbdfSmrg 14235c4bbdfSmrg/* 14335c4bbdfSmrg * Called when 'event_id' occurs. 'ust' and 'msc' indicate when the 14435c4bbdfSmrg * event actually happened 14535c4bbdfSmrg */ 14635c4bbdfSmrgextern _X_EXPORT void 14735c4bbdfSmrgpresent_event_notify(uint64_t event_id, uint64_t ust, uint64_t msc); 14835c4bbdfSmrg 14935c4bbdfSmrgextern _X_EXPORT Bool 15035c4bbdfSmrgpresent_screen_init(ScreenPtr screen, present_screen_info_ptr info); 15135c4bbdfSmrg 15235c4bbdfSmrgtypedef void (*present_complete_notify_proc)(WindowPtr window, 15335c4bbdfSmrg CARD8 kind, 15435c4bbdfSmrg CARD8 mode, 15535c4bbdfSmrg CARD32 serial, 15635c4bbdfSmrg uint64_t ust, 15735c4bbdfSmrg uint64_t msc); 15835c4bbdfSmrg 15935c4bbdfSmrgextern _X_EXPORT void 16035c4bbdfSmrgpresent_register_complete_notify(present_complete_notify_proc proc); 16135c4bbdfSmrg 1621b5d61b8Smrgextern _X_EXPORT Bool 1631b5d61b8Smrgpresent_can_window_flip(WindowPtr window); 1641b5d61b8Smrg 165ed6184dfSmrgextern _X_EXPORT uint32_t FakeScreenFps; 166ed6184dfSmrg 16735c4bbdfSmrg#endif /* _PRESENT_H_ */ 168