present_priv.h revision 35c4bbdf
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 38extern int present_request; 39 40extern DevPrivateKeyRec present_screen_private_key; 41 42typedef struct present_fence *present_fence_ptr; 43 44typedef struct present_notify present_notify_rec, *present_notify_ptr; 45 46struct present_notify { 47 struct xorg_list window_list; 48 WindowPtr window; 49 CARD32 serial; 50}; 51 52struct 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 requeue; /* on queue, but target_msc has changed */ 74 Bool flip; /* planning on using flip */ 75 Bool flip_ready; /* wants to flip, but waiting for previous flip or unflip */ 76 Bool sync_flip; /* do flip synchronous to vblank */ 77 Bool abort_flip; /* aborting this flip */ 78}; 79 80typedef struct present_screen_priv { 81 CloseScreenProcPtr CloseScreen; 82 ConfigNotifyProcPtr ConfigNotify; 83 DestroyWindowProcPtr DestroyWindow; 84 ClipNotifyProcPtr ClipNotify; 85 86 present_vblank_ptr flip_pending; 87 uint64_t unflip_event_id; 88 89 uint32_t fake_interval; 90 91 /* Currently active flipped pixmap and fence */ 92 RRCrtcPtr flip_crtc; 93 WindowPtr flip_window; 94 uint32_t flip_serial; 95 PixmapPtr flip_pixmap; 96 present_fence_ptr flip_idle_fence; 97 Bool flip_sync; 98 99 present_screen_info_ptr info; 100} present_screen_priv_rec, *present_screen_priv_ptr; 101 102#define wrap(priv,real,mem,func) {\ 103 priv->mem = real->mem; \ 104 real->mem = func; \ 105} 106 107#define unwrap(priv,real,mem) {\ 108 real->mem = priv->mem; \ 109} 110 111static inline present_screen_priv_ptr 112present_screen_priv(ScreenPtr screen) 113{ 114 return (present_screen_priv_ptr)dixLookupPrivate(&(screen)->devPrivates, &present_screen_private_key); 115} 116 117/* 118 * Each window has a list of clients and event masks 119 */ 120typedef struct present_event *present_event_ptr; 121 122typedef struct present_event { 123 present_event_ptr next; 124 ClientPtr client; 125 WindowPtr window; 126 XID id; 127 int mask; 128} present_event_rec; 129 130typedef struct present_window_priv { 131 present_event_ptr events; 132 RRCrtcPtr crtc; /* Last reported CRTC from get_ust_msc */ 133 uint64_t msc_offset; 134 uint64_t msc; /* Last reported MSC from the current crtc */ 135 struct xorg_list vblank; 136 struct xorg_list notifies; 137} present_window_priv_rec, *present_window_priv_ptr; 138 139#define PresentCrtcNeverSet ((RRCrtcPtr) 1) 140 141extern DevPrivateKeyRec present_window_private_key; 142 143static inline present_window_priv_ptr 144present_window_priv(WindowPtr window) 145{ 146 return (present_window_priv_ptr)dixGetPrivate(&(window)->devPrivates, &present_window_private_key); 147} 148 149present_window_priv_ptr 150present_get_window_priv(WindowPtr window, Bool create); 151 152/* 153 * present.c 154 */ 155int 156present_pixmap(WindowPtr window, 157 PixmapPtr pixmap, 158 CARD32 serial, 159 RegionPtr valid, 160 RegionPtr update, 161 int16_t x_off, 162 int16_t y_off, 163 RRCrtcPtr target_crtc, 164 SyncFence *wait_fence, 165 SyncFence *idle_fence, 166 uint32_t options, 167 uint64_t target_msc, 168 uint64_t divisor, 169 uint64_t remainder, 170 present_notify_ptr notifies, 171 int num_notifies); 172 173int 174present_notify_msc(WindowPtr window, 175 CARD32 serial, 176 uint64_t target_msc, 177 uint64_t divisor, 178 uint64_t remainder); 179 180void 181present_abort_vblank(ScreenPtr screen, RRCrtcPtr crtc, uint64_t event_id, uint64_t msc); 182 183void 184present_vblank_destroy(present_vblank_ptr vblank); 185 186void 187present_flip_destroy(ScreenPtr screen); 188 189void 190present_check_flip_window(WindowPtr window); 191 192RRCrtcPtr 193present_get_crtc(WindowPtr window); 194 195uint32_t 196present_query_capabilities(RRCrtcPtr crtc); 197 198Bool 199present_init(void); 200 201/* 202 * present_event.c 203 */ 204 205void 206present_free_events(WindowPtr window); 207 208void 209present_send_config_notify(WindowPtr window, int x, int y, int w, int h, int bw, WindowPtr sibling); 210 211void 212present_send_complete_notify(WindowPtr window, CARD8 kind, CARD8 mode, CARD32 serial, uint64_t ust, uint64_t msc); 213 214void 215present_send_idle_notify(WindowPtr window, CARD32 serial, PixmapPtr pixmap, present_fence_ptr idle_fence); 216 217int 218present_select_input(ClientPtr client, 219 CARD32 eid, 220 WindowPtr window, 221 CARD32 event_mask); 222 223Bool 224present_event_init(void); 225 226/* 227 * present_fake.c 228 */ 229int 230present_fake_get_ust_msc(ScreenPtr screen, uint64_t *ust, uint64_t *msc); 231 232int 233present_fake_queue_vblank(ScreenPtr screen, uint64_t event_id, uint64_t msc); 234 235void 236present_fake_abort_vblank(ScreenPtr screen, uint64_t event_id, uint64_t msc); 237 238void 239present_fake_screen_init(ScreenPtr screen); 240 241void 242present_fake_queue_init(void); 243 244/* 245 * present_fence.c 246 */ 247struct present_fence * 248present_fence_create(SyncFence *sync_fence); 249 250void 251present_fence_destroy(struct present_fence *present_fence); 252 253void 254present_fence_set_triggered(struct present_fence *present_fence); 255 256Bool 257present_fence_check_triggered(struct present_fence *present_fence); 258 259void 260present_fence_set_callback(struct present_fence *present_fence, 261 void (*callback)(void *param), 262 void *param); 263 264XID 265present_fence_id(struct present_fence *present_fence); 266 267/* 268 * present_notify.c 269 */ 270void 271present_clear_window_notifies(WindowPtr window); 272 273void 274present_free_window_notify(present_notify_ptr notify); 275 276int 277present_add_window_notify(present_notify_ptr notify); 278 279int 280present_create_notifies(ClientPtr client, int num_notifies, xPresentNotify *x_notifies, present_notify_ptr *p_notifies); 281 282void 283present_destroy_notifies(present_notify_ptr notifies, int num_notifies); 284 285/* 286 * present_redirect.c 287 */ 288 289WindowPtr 290present_redirect(ClientPtr client, WindowPtr target); 291 292/* 293 * present_request.c 294 */ 295int 296proc_present_dispatch(ClientPtr client); 297 298int 299sproc_present_dispatch(ClientPtr client); 300 301/* 302 * present_screen.c 303 */ 304 305#endif /* _PRESENT_PRIV_H_ */ 306