xref: /OK3568_Linux_fs/external/xserver/present/present.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright © 2013 Keith Packard
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Permission to use, copy, modify, distribute, and sell this software and its
5*4882a593Smuzhiyun  * documentation for any purpose is hereby granted without fee, provided that
6*4882a593Smuzhiyun  * the above copyright notice appear in all copies and that both that copyright
7*4882a593Smuzhiyun  * notice and this permission notice appear in supporting documentation, and
8*4882a593Smuzhiyun  * that the name of the copyright holders not be used in advertising or
9*4882a593Smuzhiyun  * publicity pertaining to distribution of the software without specific,
10*4882a593Smuzhiyun  * written prior permission.  The copyright holders make no representations
11*4882a593Smuzhiyun  * about the suitability of this software for any purpose.  It is provided "as
12*4882a593Smuzhiyun  * is" without express or implied warranty.
13*4882a593Smuzhiyun  *
14*4882a593Smuzhiyun  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15*4882a593Smuzhiyun  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16*4882a593Smuzhiyun  * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17*4882a593Smuzhiyun  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18*4882a593Smuzhiyun  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19*4882a593Smuzhiyun  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20*4882a593Smuzhiyun  * OF THIS SOFTWARE.
21*4882a593Smuzhiyun  */
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun #ifndef _PRESENT_H_
24*4882a593Smuzhiyun #define _PRESENT_H_
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun #include <X11/extensions/presentproto.h>
27*4882a593Smuzhiyun #include "randrstr.h"
28*4882a593Smuzhiyun #include "presentext.h"
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun typedef enum {
31*4882a593Smuzhiyun     PRESENT_FLIP_REASON_UNKNOWN,
32*4882a593Smuzhiyun     PRESENT_FLIP_REASON_BUFFER_FORMAT
33*4882a593Smuzhiyun } PresentFlipReason;
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun typedef struct present_vblank present_vblank_rec, *present_vblank_ptr;
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun /* Return the current CRTC for 'window'.
38*4882a593Smuzhiyun  */
39*4882a593Smuzhiyun typedef RRCrtcPtr (*present_get_crtc_ptr) (WindowPtr window);
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun /* Return the current ust/msc for 'crtc'
42*4882a593Smuzhiyun  */
43*4882a593Smuzhiyun typedef int (*present_get_ust_msc_ptr) (RRCrtcPtr crtc, uint64_t *ust, uint64_t *msc);
44*4882a593Smuzhiyun typedef int (*present_wnmd_get_ust_msc_ptr) (WindowPtr window, uint64_t *ust, uint64_t *msc);
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun /* Queue callback on 'crtc' for time 'msc'. Call present_event_notify with 'event_id'
47*4882a593Smuzhiyun  * at or after 'msc'. Return false if it didn't happen (which might occur if 'crtc'
48*4882a593Smuzhiyun  * is not currently generating vblanks).
49*4882a593Smuzhiyun  */
50*4882a593Smuzhiyun typedef Bool (*present_queue_vblank_ptr) (RRCrtcPtr crtc,
51*4882a593Smuzhiyun                                           uint64_t event_id,
52*4882a593Smuzhiyun                                           uint64_t msc);
53*4882a593Smuzhiyun typedef Bool (*present_wnmd_queue_vblank_ptr) (WindowPtr window,
54*4882a593Smuzhiyun                                                RRCrtcPtr crtc,
55*4882a593Smuzhiyun                                                uint64_t event_id,
56*4882a593Smuzhiyun                                                uint64_t msc);
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun /* Abort pending vblank. The extension is no longer interested in
59*4882a593Smuzhiyun  * 'event_id' which was to be notified at 'msc'. If possible, the
60*4882a593Smuzhiyun  * driver is free to de-queue the notification.
61*4882a593Smuzhiyun  */
62*4882a593Smuzhiyun typedef void (*present_abort_vblank_ptr) (RRCrtcPtr crtc, uint64_t event_id, uint64_t msc);
63*4882a593Smuzhiyun typedef void (*present_wnmd_abort_vblank_ptr) (WindowPtr window,
64*4882a593Smuzhiyun                                                RRCrtcPtr crtc,
65*4882a593Smuzhiyun                                                uint64_t event_id,
66*4882a593Smuzhiyun                                                uint64_t msc);
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun /* Flush pending drawing on 'window' to the hardware.
69*4882a593Smuzhiyun  */
70*4882a593Smuzhiyun typedef void (*present_flush_ptr) (WindowPtr window);
71*4882a593Smuzhiyun 
72*4882a593Smuzhiyun /* Check if 'pixmap' is suitable for flipping to 'window'.
73*4882a593Smuzhiyun  */
74*4882a593Smuzhiyun typedef Bool (*present_check_flip_ptr) (RRCrtcPtr crtc, WindowPtr window, PixmapPtr pixmap, Bool sync_flip);
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun /* Same as 'check_flip' but it can return a 'reason' why the flip would fail.
77*4882a593Smuzhiyun  */
78*4882a593Smuzhiyun typedef Bool (*present_check_flip2_ptr) (RRCrtcPtr crtc, WindowPtr window, PixmapPtr pixmap, Bool sync_flip, PresentFlipReason *reason);
79*4882a593Smuzhiyun 
80*4882a593Smuzhiyun /* Flip pixmap, return false if it didn't happen.
81*4882a593Smuzhiyun  *
82*4882a593Smuzhiyun  * 'crtc' is to be used for any necessary synchronization.
83*4882a593Smuzhiyun  *
84*4882a593Smuzhiyun  * 'sync_flip' requests that the flip be performed at the next
85*4882a593Smuzhiyun  * vertical blank interval to avoid tearing artifacts. If false, the
86*4882a593Smuzhiyun  * flip should be performed as soon as possible.
87*4882a593Smuzhiyun  *
88*4882a593Smuzhiyun  * present_event_notify should be called with 'event_id' when the flip
89*4882a593Smuzhiyun  * occurs
90*4882a593Smuzhiyun  */
91*4882a593Smuzhiyun typedef Bool (*present_flip_ptr) (RRCrtcPtr crtc,
92*4882a593Smuzhiyun                                   uint64_t event_id,
93*4882a593Smuzhiyun                                   uint64_t target_msc,
94*4882a593Smuzhiyun                                   PixmapPtr pixmap,
95*4882a593Smuzhiyun                                   Bool sync_flip);
96*4882a593Smuzhiyun /* Flip pixmap for window, return false if it didn't happen.
97*4882a593Smuzhiyun  *
98*4882a593Smuzhiyun  * Like present_flip_ptr, additionaly with:
99*4882a593Smuzhiyun  *
100*4882a593Smuzhiyun  * 'window' used for synchronization.
101*4882a593Smuzhiyun  *
102*4882a593Smuzhiyun  */
103*4882a593Smuzhiyun typedef Bool (*present_wnmd_flip_ptr) (WindowPtr window,
104*4882a593Smuzhiyun                                        RRCrtcPtr crtc,
105*4882a593Smuzhiyun                                        uint64_t event_id,
106*4882a593Smuzhiyun                                        uint64_t target_msc,
107*4882a593Smuzhiyun                                        PixmapPtr pixmap,
108*4882a593Smuzhiyun                                        Bool sync_flip,
109*4882a593Smuzhiyun                                        RegionPtr damage);
110*4882a593Smuzhiyun 
111*4882a593Smuzhiyun /* "unflip" back to the regular screen scanout buffer
112*4882a593Smuzhiyun  *
113*4882a593Smuzhiyun  * present_event_notify should be called with 'event_id' when the unflip occurs.
114*4882a593Smuzhiyun  */
115*4882a593Smuzhiyun typedef void (*present_unflip_ptr) (ScreenPtr screen,
116*4882a593Smuzhiyun                                     uint64_t event_id);
117*4882a593Smuzhiyun 
118*4882a593Smuzhiyun /* Doing flips has been discontinued.
119*4882a593Smuzhiyun  *
120*4882a593Smuzhiyun  * Inform driver for potential cleanup on its side.
121*4882a593Smuzhiyun  */
122*4882a593Smuzhiyun typedef void (*present_wnmd_flips_stop_ptr) (WindowPtr window);
123*4882a593Smuzhiyun 
124*4882a593Smuzhiyun #define PRESENT_SCREEN_INFO_VERSION        1
125*4882a593Smuzhiyun 
126*4882a593Smuzhiyun typedef struct present_screen_info {
127*4882a593Smuzhiyun     uint32_t                            version;
128*4882a593Smuzhiyun 
129*4882a593Smuzhiyun     present_get_crtc_ptr                get_crtc;
130*4882a593Smuzhiyun     present_get_ust_msc_ptr             get_ust_msc;
131*4882a593Smuzhiyun     present_queue_vblank_ptr            queue_vblank;
132*4882a593Smuzhiyun     present_abort_vblank_ptr            abort_vblank;
133*4882a593Smuzhiyun     present_flush_ptr                   flush;
134*4882a593Smuzhiyun     uint32_t                            capabilities;
135*4882a593Smuzhiyun     present_check_flip_ptr              check_flip;
136*4882a593Smuzhiyun     present_flip_ptr                    flip;
137*4882a593Smuzhiyun     present_unflip_ptr                  unflip;
138*4882a593Smuzhiyun     present_check_flip2_ptr             check_flip2;
139*4882a593Smuzhiyun 
140*4882a593Smuzhiyun } present_screen_info_rec, *present_screen_info_ptr;
141*4882a593Smuzhiyun 
142*4882a593Smuzhiyun typedef struct present_wnmd_info {
143*4882a593Smuzhiyun     uint32_t                            version;
144*4882a593Smuzhiyun 
145*4882a593Smuzhiyun     present_get_crtc_ptr                get_crtc;
146*4882a593Smuzhiyun     present_wnmd_get_ust_msc_ptr        get_ust_msc;
147*4882a593Smuzhiyun     present_wnmd_queue_vblank_ptr       queue_vblank;
148*4882a593Smuzhiyun     present_wnmd_abort_vblank_ptr       abort_vblank;
149*4882a593Smuzhiyun     present_flush_ptr                   flush;
150*4882a593Smuzhiyun     uint32_t                            capabilities;
151*4882a593Smuzhiyun     present_check_flip2_ptr             check_flip2;
152*4882a593Smuzhiyun     present_wnmd_flip_ptr               flip;
153*4882a593Smuzhiyun     present_wnmd_flips_stop_ptr         flips_stop;
154*4882a593Smuzhiyun 
155*4882a593Smuzhiyun } present_wnmd_info_rec, *present_wnmd_info_ptr;
156*4882a593Smuzhiyun 
157*4882a593Smuzhiyun /*
158*4882a593Smuzhiyun  * Called when 'event_id' occurs. 'ust' and 'msc' indicate when the
159*4882a593Smuzhiyun  * event actually happened
160*4882a593Smuzhiyun  */
161*4882a593Smuzhiyun extern _X_EXPORT void
162*4882a593Smuzhiyun present_event_notify(uint64_t event_id, uint64_t ust, uint64_t msc);
163*4882a593Smuzhiyun /*
164*4882a593Smuzhiyun  * Called when 'event_id' occurs for 'window'.
165*4882a593Smuzhiyun  * 'ust' and 'msc' indicate when the event actually happened
166*4882a593Smuzhiyun  */
167*4882a593Smuzhiyun extern _X_EXPORT void
168*4882a593Smuzhiyun present_wnmd_event_notify(WindowPtr window, uint64_t event_id, uint64_t ust, uint64_t msc);
169*4882a593Smuzhiyun 
170*4882a593Smuzhiyun /* 'crtc' has been turned off, so any pending events will never occur.
171*4882a593Smuzhiyun  */
172*4882a593Smuzhiyun extern _X_EXPORT void
173*4882a593Smuzhiyun present_event_abandon(RRCrtcPtr crtc);
174*4882a593Smuzhiyun 
175*4882a593Smuzhiyun extern _X_EXPORT Bool
176*4882a593Smuzhiyun present_screen_init(ScreenPtr screen, present_screen_info_ptr info);
177*4882a593Smuzhiyun extern _X_EXPORT Bool
178*4882a593Smuzhiyun present_wnmd_screen_init(ScreenPtr screen, present_wnmd_info_ptr info);
179*4882a593Smuzhiyun 
180*4882a593Smuzhiyun typedef void (*present_complete_notify_proc)(WindowPtr window,
181*4882a593Smuzhiyun                                              CARD8 kind,
182*4882a593Smuzhiyun                                              CARD8 mode,
183*4882a593Smuzhiyun                                              CARD32 serial,
184*4882a593Smuzhiyun                                              uint64_t ust,
185*4882a593Smuzhiyun                                              uint64_t msc);
186*4882a593Smuzhiyun 
187*4882a593Smuzhiyun extern _X_EXPORT void
188*4882a593Smuzhiyun present_register_complete_notify(present_complete_notify_proc proc);
189*4882a593Smuzhiyun 
190*4882a593Smuzhiyun extern _X_EXPORT Bool
191*4882a593Smuzhiyun present_can_window_flip(WindowPtr window);
192*4882a593Smuzhiyun 
193*4882a593Smuzhiyun #endif /* _PRESENT_H_ */
194