1 | /*
|
---|
2 | * Copyright © 2013 Keith Packard
|
---|
3 | *
|
---|
4 | * Permission to use, copy, modify, distribute, and sell this software and its
|
---|
5 | * documentation for any purpose is hereby granted without fee, provided that
|
---|
6 | * the above copyright notice appear in all copies and that both that copyright
|
---|
7 | * notice and this permission notice appear in supporting documentation, and
|
---|
8 | * that the name of the copyright holders not be used in advertising or
|
---|
9 | * publicity pertaining to distribution of the software without specific,
|
---|
10 | * written prior permission. The copyright holders make no representations
|
---|
11 | * about the suitability of this software for any purpose. It is provided "as
|
---|
12 | * is" without express or implied warranty.
|
---|
13 | *
|
---|
14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
---|
15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
---|
16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
---|
17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
---|
18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
---|
19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
---|
20 | * OF THIS SOFTWARE.
|
---|
21 | */
|
---|
22 |
|
---|
23 | #ifndef _PRESENT_PRIV_H_
|
---|
24 | #define _PRESENT_PRIV_H_
|
---|
25 |
|
---|
26 | #include <X11/X.h>
|
---|
27 | #include "scrnintstr.h"
|
---|
28 | #include "misc.h"
|
---|
29 | #include "list.h"
|
---|
30 | #include "windowstr.h"
|
---|
31 | #include "dixstruct.h"
|
---|
32 | #include "present.h"
|
---|
33 | #include <syncsdk.h>
|
---|
34 | #include <syncsrv.h>
|
---|
35 | #include <xfixes.h>
|
---|
36 | #include <randrstr.h>
|
---|
37 |
|
---|
38 | extern int present_request;
|
---|
39 |
|
---|
40 | extern DevPrivateKeyRec present_screen_private_key;
|
---|
41 |
|
---|
42 | typedef struct present_fence *present_fence_ptr;
|
---|
43 |
|
---|
44 | typedef struct present_notify present_notify_rec, *present_notify_ptr;
|
---|
45 |
|
---|
46 | struct present_notify {
|
---|
47 | struct xorg_list window_list;
|
---|
48 | WindowPtr window;
|
---|
49 | CARD32 serial;
|
---|
50 | };
|
---|
51 |
|
---|
52 | struct present_vblank {
|
---|
53 | struct xorg_list window_list;
|
---|
54 | struct xorg_list event_queue;
|
---|
55 | ScreenPtr screen;
|
---|
56 | WindowPtr window;
|
---|
57 | PixmapPtr pixmap;
|
---|
58 | RegionPtr valid;
|
---|
59 | RegionPtr update;
|
---|
60 | RRCrtcPtr crtc;
|
---|
61 | uint32_t serial;
|
---|
62 | int16_t x_off;
|
---|
63 | int16_t y_off;
|
---|
64 | CARD16 kind;
|
---|
65 | uint64_t event_id;
|
---|
66 | uint64_t target_msc;
|
---|
67 | uint64_t msc_offset;
|
---|
68 | present_fence_ptr idle_fence;
|
---|
69 | present_fence_ptr wait_fence;
|
---|
70 | present_notify_ptr notifies;
|
---|
71 | int num_notifies;
|
---|
72 | Bool queued; /* on present_exec_queue */
|
---|
73 | Bool flip; /* planning on using flip */
|
---|
74 | Bool flip_ready; /* wants to flip, but waiting for previous flip or unflip */
|
---|
75 | Bool sync_flip; /* do flip synchronous to vblank */
|
---|
76 | Bool abort_flip; /* aborting this flip */
|
---|
77 | };
|
---|
78 |
|
---|
79 | typedef struct present_screen_priv {
|
---|
80 | CloseScreenProcPtr CloseScreen;
|
---|
81 | ConfigNotifyProcPtr ConfigNotify;
|
---|
82 | DestroyWindowProcPtr DestroyWindow;
|
---|
83 | ClipNotifyProcPtr ClipNotify;
|
---|
84 |
|
---|
85 | present_vblank_ptr flip_pending;
|
---|
86 | uint64_t unflip_event_id;
|
---|
87 |
|
---|
88 | uint32_t fake_interval;
|
---|
89 |
|
---|
90 | /* Currently active flipped pixmap and fence */
|
---|
91 | RRCrtcPtr flip_crtc;
|
---|
92 | WindowPtr flip_window;
|
---|
93 | uint32_t flip_serial;
|
---|
94 | PixmapPtr flip_pixmap;
|
---|
95 | present_fence_ptr flip_idle_fence;
|
---|
96 |
|
---|
97 | present_screen_info_ptr info;
|
---|
98 | } present_screen_priv_rec, *present_screen_priv_ptr;
|
---|
99 |
|
---|
100 | #define wrap(priv,real,mem,func) {\
|
---|
101 | priv->mem = real->mem; \
|
---|
102 | real->mem = func; \
|
---|
103 | }
|
---|
104 |
|
---|
105 | #define unwrap(priv,real,mem) {\
|
---|
106 | real->mem = priv->mem; \
|
---|
107 | }
|
---|
108 |
|
---|
109 | static inline present_screen_priv_ptr
|
---|
110 | present_screen_priv(ScreenPtr screen)
|
---|
111 | {
|
---|
112 | return (present_screen_priv_ptr)dixLookupPrivate(&(screen)->devPrivates, &present_screen_private_key);
|
---|
113 | }
|
---|
114 |
|
---|
115 | /*
|
---|
116 | * Each window has a list of clients and event masks
|
---|
117 | */
|
---|
118 | typedef struct present_event *present_event_ptr;
|
---|
119 |
|
---|
120 | typedef struct present_event {
|
---|
121 | present_event_ptr next;
|
---|
122 | ClientPtr client;
|
---|
123 | WindowPtr window;
|
---|
124 | XID id;
|
---|
125 | int mask;
|
---|
126 | } present_event_rec;
|
---|
127 |
|
---|
128 | typedef struct present_window_priv {
|
---|
129 | present_event_ptr events;
|
---|
130 | RRCrtcPtr crtc; /* Last reported CRTC from get_ust_msc */
|
---|
131 | uint64_t msc_offset;
|
---|
132 | uint64_t msc; /* Last reported MSC from the current crtc */
|
---|
133 | struct xorg_list vblank;
|
---|
134 | struct xorg_list notifies;
|
---|
135 | } present_window_priv_rec, *present_window_priv_ptr;
|
---|
136 |
|
---|
137 | extern DevPrivateKeyRec present_window_private_key;
|
---|
138 |
|
---|
139 | static inline present_window_priv_ptr
|
---|
140 | present_window_priv(WindowPtr window)
|
---|
141 | {
|
---|
142 | return (present_window_priv_ptr)dixGetPrivate(&(window)->devPrivates, &present_window_private_key);
|
---|
143 | }
|
---|
144 |
|
---|
145 | present_window_priv_ptr
|
---|
146 | present_get_window_priv(WindowPtr window, Bool create);
|
---|
147 |
|
---|
148 | extern RESTYPE present_event_type;
|
---|
149 |
|
---|
150 | /*
|
---|
151 | * present.c
|
---|
152 | */
|
---|
153 | int
|
---|
154 | present_pixmap(WindowPtr window,
|
---|
155 | PixmapPtr pixmap,
|
---|
156 | CARD32 serial,
|
---|
157 | RegionPtr valid,
|
---|
158 | RegionPtr update,
|
---|
159 | int16_t x_off,
|
---|
160 | int16_t y_off,
|
---|
161 | RRCrtcPtr target_crtc,
|
---|
162 | SyncFence *wait_fence,
|
---|
163 | SyncFence *idle_fence,
|
---|
164 | uint32_t options,
|
---|
165 | uint64_t target_msc,
|
---|
166 | uint64_t divisor,
|
---|
167 | uint64_t remainder,
|
---|
168 | present_notify_ptr notifies,
|
---|
169 | int num_notifies);
|
---|
170 |
|
---|
171 | int
|
---|
172 | present_notify_msc(WindowPtr window,
|
---|
173 | CARD32 serial,
|
---|
174 | uint64_t target_msc,
|
---|
175 | uint64_t divisor,
|
---|
176 | uint64_t remainder);
|
---|
177 |
|
---|
178 | void
|
---|
179 | present_abort_vblank(ScreenPtr screen, RRCrtcPtr crtc, uint64_t event_id, uint64_t msc);
|
---|
180 |
|
---|
181 | void
|
---|
182 | present_vblank_destroy(present_vblank_ptr vblank);
|
---|
183 |
|
---|
184 | void
|
---|
185 | present_flip_destroy(ScreenPtr screen);
|
---|
186 |
|
---|
187 | void
|
---|
188 | present_check_flip_window(WindowPtr window);
|
---|
189 |
|
---|
190 | RRCrtcPtr
|
---|
191 | present_get_crtc(WindowPtr window);
|
---|
192 |
|
---|
193 | uint32_t
|
---|
194 | present_query_capabilities(RRCrtcPtr crtc);
|
---|
195 |
|
---|
196 | Bool
|
---|
197 | present_init(void);
|
---|
198 |
|
---|
199 | /*
|
---|
200 | * present_event.c
|
---|
201 | */
|
---|
202 |
|
---|
203 | void
|
---|
204 | present_free_events(WindowPtr window);
|
---|
205 |
|
---|
206 | void
|
---|
207 | present_send_config_notify(WindowPtr window, int x, int y, int w, int h, int bw, WindowPtr sibling);
|
---|
208 |
|
---|
209 | void
|
---|
210 | present_send_complete_notify(WindowPtr window, CARD8 kind, CARD8 mode, CARD32 serial, uint64_t ust, uint64_t msc);
|
---|
211 |
|
---|
212 | void
|
---|
213 | present_send_idle_notify(WindowPtr window, CARD32 serial, PixmapPtr pixmap, present_fence_ptr idle_fence);
|
---|
214 |
|
---|
215 | int
|
---|
216 | present_select_input(ClientPtr client,
|
---|
217 | CARD32 eid,
|
---|
218 | WindowPtr window,
|
---|
219 | CARD32 event_mask);
|
---|
220 |
|
---|
221 | Bool
|
---|
222 | present_event_init(void);
|
---|
223 |
|
---|
224 | /*
|
---|
225 | * present_fake.c
|
---|
226 | */
|
---|
227 | int
|
---|
228 | present_fake_get_ust_msc(ScreenPtr screen, uint64_t *ust, uint64_t *msc);
|
---|
229 |
|
---|
230 | int
|
---|
231 | present_fake_queue_vblank(ScreenPtr screen, uint64_t event_id, uint64_t msc);
|
---|
232 |
|
---|
233 | void
|
---|
234 | present_fake_abort_vblank(ScreenPtr screen, uint64_t event_id, uint64_t msc);
|
---|
235 |
|
---|
236 | void
|
---|
237 | present_fake_screen_init(ScreenPtr screen);
|
---|
238 |
|
---|
239 | void
|
---|
240 | present_fake_queue_init(void);
|
---|
241 |
|
---|
242 | /*
|
---|
243 | * present_fence.c
|
---|
244 | */
|
---|
245 | struct present_fence *
|
---|
246 | present_fence_create(SyncFence *sync_fence);
|
---|
247 |
|
---|
248 | void
|
---|
249 | present_fence_destroy(struct present_fence *present_fence);
|
---|
250 |
|
---|
251 | void
|
---|
252 | present_fence_set_triggered(struct present_fence *present_fence);
|
---|
253 |
|
---|
254 | Bool
|
---|
255 | present_fence_check_triggered(struct present_fence *present_fence);
|
---|
256 |
|
---|
257 | void
|
---|
258 | present_fence_set_callback(struct present_fence *present_fence,
|
---|
259 | void (*callback)(void *param),
|
---|
260 | void *param);
|
---|
261 |
|
---|
262 | XID
|
---|
263 | present_fence_id(struct present_fence *present_fence);
|
---|
264 |
|
---|
265 | /*
|
---|
266 | * present_notify.c
|
---|
267 | */
|
---|
268 | void
|
---|
269 | present_clear_window_notifies(WindowPtr window);
|
---|
270 |
|
---|
271 | void
|
---|
272 | present_free_window_notify(present_notify_ptr notify);
|
---|
273 |
|
---|
274 | int
|
---|
275 | present_add_window_notify(present_notify_ptr notify);
|
---|
276 |
|
---|
277 | int
|
---|
278 | present_create_notifies(ClientPtr client, int num_notifies, xPresentNotify *x_notifies, present_notify_ptr *p_notifies);
|
---|
279 |
|
---|
280 | void
|
---|
281 | present_destroy_notifies(present_notify_ptr notifies, int num_notifies);
|
---|
282 |
|
---|
283 | /*
|
---|
284 | * present_redirect.c
|
---|
285 | */
|
---|
286 |
|
---|
287 | WindowPtr
|
---|
288 | present_redirect(ClientPtr client, WindowPtr target);
|
---|
289 |
|
---|
290 | /*
|
---|
291 | * present_request.c
|
---|
292 | */
|
---|
293 | int
|
---|
294 | proc_present_dispatch(ClientPtr client);
|
---|
295 |
|
---|
296 | int
|
---|
297 | sproc_present_dispatch(ClientPtr client);
|
---|
298 |
|
---|
299 | /*
|
---|
300 | * present_screen.c
|
---|
301 | */
|
---|
302 |
|
---|
303 | #endif /* _PRESENT_PRIV_H_ */
|
---|