1 /* Copyright (c) 1993, 1997, Oracle and/or its affiliates. All rights reserved.
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
25 * dga.h - Sun Direct Graphics Access interface
31 #include <sys/types.h>
34 #endif /* SERVER_DGA */
35 #include "dga_externaldefs.h"
37 #if defined (_POSIX_C_SOURCE)
44 #endif /* SERVER_DGA */
46 #define DGA_X_EOL (-32767)
47 #define DGA_Y_EOL (-32768)
49 #define DGA_DB_DEV_INFO_SZ 132
51 #define DGA_RTN_NOT_CACHED 0
52 #define DGA_RTN_SAME_DEV 1
53 #define DGA_RTN_NEW_DEV 2
55 #define DGA_CLIENT_VERSION 1
57 typedef u_int Dga_token
;
59 typedef struct dga_curs_memimage
{
67 typedef struct dga_dbinfo
{
72 u_int reserved_1
; /* for future use */
73 u_int reserved_2
; /* for future use */
74 u_int reserved_3
; /* for the future */
75 u_int reserved_4
; /* for the future */
76 u_int reserved_5
; /* for the future */
77 u_int wid
; /* db window id. */
79 u_char device_info
[DGA_DB_DEV_INFO_SZ
];
82 #ifndef DGA_NUM_BUFFER_TYPES
83 /* The following buffer types also defined(duplicated) in
84 * dga_winshared.h file. * I can't include dga.h in hw/solaris/dga
85 * due to some declarations inconsistency.
86 * Whenever someone changes/addes/deleted to this enumerated values,
87 * please also update dga_winshared.h which is located
91 /* Known types of ancillary buffers */
104 #define DGA_NUM_BUFFER_TYPES (DGA_AUX_BUFFER3+1)
107 typedef void *Dga_buffer
;
109 typedef struct dga_widinfo
{
110 short number_wids
; /* number of contiguous wids alloc */
111 short start_wid
; /* starting wid */
112 short wid
; /* current wid */
113 short reserved_1
; /* for the future */
116 typedef void* Dga_window
;
117 typedef void* Dga_cmap
;
119 /* May be either a window, the main window of a multibuffer set, or a pixmap */
120 typedef void* Dga_drawable
;
122 typedef struct dga_opaque
{
129 int (*loc_7
)(Dga_window
);
130 int (*loc_8
)(Dga_window
);
131 int (*loc_9
)(Dga_window
);
135 typedef struct dga_opaque_draw
{
142 int (*loc_7
)(Dga_drawable
);
143 int (*loc_8
)(Dga_drawable
);
144 int (*loc_9
)(Dga_drawable
);
146 u_int loc_11
[DGA_MAX_GRABBABLE_BUFS
+ 1];
150 /* Types for drawable notification functions */
151 typedef void (*DgaSiteNotifyFunc
)(Dga_drawable
, short, void *, int);
152 typedef void (*DgaMbNotifyFunc
)(Dga_drawable
, void *, int);
153 typedef void (*DgaRendBufNotifyFunc
)(Dga_drawable
, short, void *);
154 typedef void (*DgaCursTakeDownFunc
)(void *, Dga_drawable
, int, int, Dga_curs_memimage
*);
155 typedef void (*DgaOvlStateNotifyFunc
)(Dga_drawable
, void *, int);
157 #define DGA_LOCK(x) (*(((Dga_opaque)(x))->loc_5)) = 1
158 #define DGA_UNLOCK(x) (*(((Dga_opaque)(x))->loc_6)) = 0
160 #define DGA_WIN_LOCK(win) \
162 if ((((Dga_opaque)(win))->loc_4)++ == 0) { \
164 ((Dga_opaque)win)->loc_10 = (((((Dga_opaque)(win))->loc_2) == \
165 (*(((Dga_opaque)(win))->loc_3))) ? \
166 0 : (*(((Dga_opaque)(win))->loc_9))(win)); \
170 #define DGA_WIN_UNLOCK(win) \
172 if (--(((Dga_opaque)(win))->loc_4) == 0) { \
174 if (((Dga_opaque)(win))->loc_8) \
175 (*(((Dga_opaque)(win))->loc_8))(win); \
179 #define DGA_WIN_MODIF(win) (((Dga_opaque)win)->loc_10)
182 /* this is so we can we can enter the opaque interface */
183 #define DGA_CASTDRAW(dgadraw) ((Dga_opaque_draw)(dgadraw))
185 typedef int (*DgaDrawUpdateFunc
)(Dga_drawable
, short);
186 #define DGA_CASTFUNC(func) ((DgaDrawUpdateFunc)(func))
189 #define DGA_DRAW_LOCK(dgadraw, bufIndex) \
191 if ((DGA_CASTDRAW(dgadraw)->loc_4)++ == 0) { \
193 DGA_CASTDRAW(dgadraw)->loc_10 = \
195 ((DGA_CASTDRAW(dgadraw)->loc_11[bufIndex + 1]) == \
196 (*(DGA_CASTDRAW(dgadraw)->loc_3))) \
198 : (*DGA_CASTFUNC(DGA_CASTDRAW(dgadraw)->loc_9)) \
199 ((dgadraw), (bufIndex)) \
204 #define DGA_DRAW_UNLOCK(dgadraw) \
206 if (--(DGA_CASTDRAW(dgadraw)->loc_4) == 0) { \
207 DGA_UNLOCK(dgadraw); \
208 if (DGA_CASTDRAW(dgadraw)->loc_8) \
209 (*(DGA_CASTDRAW(dgadraw)->loc_8))(dgadraw); \
213 #define DGA_DRAW_LOCK_SRC_AND_DST(dgasrc, bufIndexSrc, dgadst, bufIndexDst) \
215 /* Always lock pixmap first. */ \
216 if ((DGA_CASTDRAW(dgasrc)->loc_1 == DGA_DRAW_WINDOW) && \
217 (DGA_CASTDRAW(dgadst)->loc_1 == DGA_DRAW_PIXMAP)) { \
218 DGA_DRAW_LOCK(dgadst, bufIndexDst); \
219 DGA_DRAW_LOCK(dgasrc, bufIndexSrc); \
220 } else if ((DGA_CASTDRAW(dgasrc)->loc_1 == DGA_DRAW_PIXMAP) && \
221 (DGA_CASTDRAW(dgadst)->loc_1 == DGA_DRAW_WINDOW)) { \
222 DGA_DRAW_LOCK(dgasrc, bufIndexSrc); \
223 DGA_DRAW_LOCK(dgadst, bufIndexDst); \
224 } else if ((DGA_CASTDRAW(dgasrc)->loc_1 == DGA_DRAW_PIXMAP) && \
225 (DGA_CASTDRAW(dgadst)->loc_1 == DGA_DRAW_PIXMAP)) { \
226 /* We lock the src pixmap and since all pixmaps share the same \
227 * lock page, the dst pixmap is locked as well. */ \
229 DGA_DRAW_LOCK(dgasrc, bufIndexSrc); \
231 /* Now update dest pixmap's modif */ \
233 DGA_CASTDRAW(dgadst)->loc_10 = \
234 (((DGA_CASTDRAW(dgadst)->loc_11[0]) == \
235 (*(DGA_CASTDRAW(dgadst)->loc_3))) \
236 ? 0 : (*DGA_CASTFUNC(DGA_CASTDRAW(dgadst)->loc_9)) \
237 ((dgadst), (bufIndexDst))); \
241 #define DGA_DRAW_UNLOCK_SRC_AND_DST(dgasrc, dgadst) \
243 /* Always unlock window first */ \
244 if ((DGA_CASTDRAW(dgasrc)->loc_1 == DGA_DRAW_WINDOW) && \
245 (DGA_CASTDRAW(dgadst)->loc_1 == DGA_DRAW_PIXMAP)) { \
246 DGA_DRAW_UNLOCK(dgasrc); \
247 DGA_DRAW_UNLOCK(dgadst); \
248 } else if ((DGA_CASTDRAW(dgasrc)->loc_1 == DGA_DRAW_PIXMAP) && \
249 (DGA_CASTDRAW(dgadst)->loc_1 == DGA_DRAW_WINDOW)) { \
250 DGA_DRAW_UNLOCK(dgadst); \
251 DGA_DRAW_UNLOCK(dgasrc); \
252 } else if ((DGA_CASTDRAW(dgasrc)->loc_1 == DGA_DRAW_PIXMAP) && \
253 (DGA_CASTDRAW(dgadst)->loc_1 == DGA_DRAW_PIXMAP)) { \
254 /* Unlock the src pixmap */ \
255 DGA_DRAW_UNLOCK(dgasrc); \
259 #define DGA_DRAW_MODIF(dgadraw) (((Dga_opaque_draw)(dgadraw))->loc_10)
261 #define DGA_INIT() dga_init_version(DGA_CLIENT_VERSION)
268 /* General DGA functions */
269 extern void dga_init_version(int);
271 * X protocol extension functions
273 extern Dga_token
XDgaGrabWindow(Display
*, Window
);
274 extern int XDgaUnGrabWindow(Display
*, Window
);
275 extern Dga_token
XDgaGrabColormap(Display
*, Colormap
);
276 extern int XDgaUnGrabColormap(Display
*, Colormap
);
277 extern int XDgaGrabWids(Display
*, Window
, int);
278 extern int XDgaGrabFCS(Display
*, Window
, int);
279 extern int XDgaGrabZbuf(Display
*, Window
, int);
280 extern int XDgaGrabStereo(Display
*, Window
, int);
282 * Window Compatibility Interface - Window grabber functions
285 extern Dga_window
dga_win_grab(int, Dga_token
);
286 extern void dga_win_ungrab(Dga_window
, int);
287 extern char *dga_win_fbname(Dga_window
);
288 extern int dga_win_devfd(Dga_window
);
289 extern int dga_win_clipchg(Dga_window
);
290 extern int dga_win_curschg(Dga_window
);
291 extern int dga_win_rtnchg(Dga_window
);
292 extern short *dga_win_clipinfo(Dga_window
);
293 extern void dga_win_bbox(Dga_window
, int *, int *, int *, int *);
294 extern int dga_win_singlerect(Dga_window
);
295 extern int dga_win_empty(Dga_window
);
296 extern int dga_win_obscured(Dga_window
);
297 extern int dga_win_cursactive(Dga_window
);
298 extern void dga_win_cursupdate(Dga_window
, void(*)(void *,
299 Dga_window
, int, int, Dga_curs_memimage
*), void *);
300 extern Dga_dbinfo
*dga_win_dbinfop(Dga_window
);
301 extern Dga_widinfo
*dga_win_widinfop(Dga_window
);
302 extern void *dga_win_bboxinfop(Dga_window
);
303 extern u_char
dga_win_depth(Dga_window
);
304 extern u_short
dga_win_borderwidth(Dga_window
);
305 extern void dga_win_set_client_infop(Dga_window
, void *);
306 extern void *dga_win_get_client_infop(Dga_window
);
309 * Colormap grabber functions
312 extern Dga_cmap
dga_cm_grab(int, Dga_token
);
313 extern void dga_cm_ungrab(Dga_cmap
, int);
314 extern void dga_cm_read(Dga_cmap
, int, int, u_char
*, u_char
*,
316 extern void dga_cm_write(Dga_cmap
, int, int, u_char
*, u_char
*,
317 u_char
*, void (*)(Dga_window
, int,
318 int, u_char
*, u_char
*, u_char
*));
319 extern int dga_cm_devfd(Dga_cmap
);
320 extern void dga_cm_set_client_infop(Dga_cmap
, void *);
321 extern void *dga_cm_get_client_infop(Dga_cmap
);
322 extern void *dga_cm_devinfop(Dga_cmap
);
325 * Window Compatibility Interface - double buffering functions
328 extern int dga_db_grab(Dga_window
, int, int (*)(Dga_window
),
330 extern int dga_db_ungrab(Dga_window
);
331 extern void dga_db_write(Dga_window
, int,
332 int(*)(void*, Dga_window
, int), void *);
333 extern void dga_db_read(Dga_window
,int,
334 int(*)(void*, Dga_window
, int), void *);
335 extern void dga_db_display(Dga_window
, int,
336 int(*)(void*, Dga_window
, int), void *);
337 extern void dga_db_interval(Dga_window
, int);
338 extern void dga_db_interval_wait(Dga_window
);
339 extern int dga_db_interval_check(Dga_window
);
340 extern int dga_db_write_inquire(Dga_window
);
341 extern int dga_db_read_inquire(Dga_window
);
342 extern int dga_db_display_inquire(Dga_window
);
343 extern int dga_db_display_done(Dga_window
, int,
344 int (*)(Dga_window
));
346 * Window Compatibility Interface - Retained window grabber functions
349 extern int dga_rtn_grab(Dga_window
);
350 extern int dga_rtn_ungrab(Dga_window
);
351 extern int dga_rtn_active(Dga_window
);
352 extern int dga_rtn_cached(Dga_window
);
353 extern void *dga_rtn_devinfo(Dga_window
);
354 extern void dga_rtn_devtype(Dga_window
, u_char
*, char **);
355 extern void dga_rtn_dimensions(Dga_window
, short *, short *,
357 extern void *dga_rtn_pixels(Dga_window
);
360 * Drawable grabber functions
363 extern Dga_drawable
XDgaGrabDrawable(Display
*dpy
, Drawable drawid
);
364 extern int XDgaUnGrabDrawable(Dga_drawable dgadraw
);
365 extern Display
* dga_draw_display (Dga_drawable dgadraw
);
366 extern Drawable
dga_draw_id(Dga_drawable
);
367 extern int dga_draw_type (Dga_drawable dgadraw
);
368 extern char * dga_draw_devname (Dga_drawable dgadraw
);
369 extern int dga_draw_devfd (Dga_drawable dgadraw
);
370 extern int dga_draw_depth (Dga_drawable dgadraw
);
371 extern void dga_draw_set_client_infop (Dga_drawable dgadraw
, void *client_info_ptr
);
372 extern void * dga_draw_get_client_infop (Dga_drawable dgadraw
);
373 extern void * dga_draw_devinfo (Dga_drawable dgadraw
);
374 extern int dga_draw_sitechg (Dga_drawable dgadraw
, int *reason
);
375 extern void dga_draw_sitesetnotify (Dga_drawable dgadraw
,
376 DgaSiteNotifyFunc site_notify_func
,
378 extern void dga_draw_sitegetnotify (Dga_drawable dgadraw
,
379 DgaSiteNotifyFunc
*site_notify_func
,
381 extern int dga_draw_site (Dga_drawable dgadraw
);
382 extern void * dga_draw_address (Dga_drawable dgadraw
);
383 extern int dga_draw_linebytes (Dga_drawable dgadraw
);
384 extern int dga_draw_clipchg (Dga_drawable dgadraw
);
385 extern void dga_draw_bbox(Dga_drawable dgadraw
, int *xp
, int *yp
,
386 int *widthp
, int *heightp
);
387 extern int dga_draw_visibility (Dga_drawable dgadraw
);
388 extern int dga_draw_empty (Dga_drawable dgadraw
);
389 extern short * dga_draw_clipinfo (Dga_drawable dgadraw
);
390 extern int dga_draw_singlerect (Dga_drawable dgadraw
);
391 extern int dga_draw_obscured (Dga_drawable dgadraw
);
392 extern u_short
dga_draw_borderwidth (Dga_drawable dgadraw
);
393 extern void dga_draw_curshandle (Dga_drawable dgadraw
,
394 DgaCursTakeDownFunc take_down_func
,
396 extern int dga_draw_rtngrab (Dga_drawable dgadraw
);
397 extern int dga_draw_rtnungrab (Dga_drawable dgadraw
);
398 extern int dga_draw_rtnchg (Dga_drawable dgadraw
);
399 extern int dga_draw_rtnactive (Dga_drawable dgadraw
);
400 extern int dga_draw_rtncached (Dga_drawable dgadraw
);
401 extern void * dga_draw_rtndevinfop (Dga_drawable dgadraw
);
402 extern void dga_draw_rtndevtype (Dga_drawable dgadraw
, u_char
*type
,
404 extern void dga_draw_rtndimensions (Dga_drawable dgadraw
, short *width
,
405 short *height
, u_int
*linebytes
);
406 extern void * dga_draw_rtnpixels (Dga_drawable dgadraw
);
407 extern int dga_draw_mbchg (Dga_drawable dgadraw
, int *reason
);
408 extern void dga_draw_mbsetnotify (Dga_drawable dgadraw
, DgaMbNotifyFunc mb_notify_func
,
410 extern void dga_draw_mbgetnotify (Dga_drawable dgadraw
, DgaMbNotifyFunc
*mb_notify_func
,
412 extern int dga_draw_mbaccessmode (Dga_drawable dgadraw
);
413 extern int dga_draw_mbsitetypeconst (Dga_drawable dgadraw
);
414 extern void dga_draw_mbsetrendbufnotify (Dga_drawable dgadraw
,
415 DgaRendBufNotifyFunc rb_notify_func
,
417 extern void dga_draw_mbgetrendbufnotify (Dga_drawable dgadraw
,
418 DgaRendBufNotifyFunc
*rb_notify_func
,
420 extern int dga_draw_ovlstatechg (Dga_drawable dgadraw
);
421 extern int dga_draw_ovlstate (Dga_drawable dgadraw
);
422 extern void dga_draw_ovlstatesetnotify (Dga_drawable dgadraw
,
423 DgaOvlStateNotifyFunc ovlstate_notify_func
,
425 extern void dga_draw_ovlstategetnotify (Dga_drawable dgadraw
,
426 DgaOvlStateNotifyFunc
*ovlstate_notify_func
,
431 * Drawable grabber functions - Buffer Control Compatibility
434 extern int dga_draw_db_grab (Dga_drawable dgadraw
, int nbuffers
,
435 int (*vrtfunc
)(Dga_drawable
), u_int
*vrtcounterp
);
436 extern int dga_draw_db_ungrab (Dga_drawable dgadraw
);
437 extern void dga_draw_db_write (Dga_drawable dgadraw
, int buffer
,
438 int (*writefunc
)(void*, Dga_drawable
, int),
440 extern void dga_draw_db_read (Dga_drawable dgadraw
, int buffer
,
441 int (*readfunc
)(void*, Dga_drawable
, int),
443 extern void dga_draw_db_display (Dga_drawable dgadraw
, int buffer
,
444 int (*visfunc
)(void*, Dga_drawable
, int),
446 extern void dga_draw_db_interval (Dga_drawable dgadraw
, int interval
);
447 extern void dga_draw_db_interval_wait (Dga_drawable dgadraw
);
448 extern int dga_draw_db_interval_check (Dga_drawable dgadraw
);
449 extern int dga_draw_db_write_inquire (Dga_drawable dgadraw
);
450 extern int dga_draw_db_read_inquire (Dga_drawable dgadraw
);
451 extern int dga_draw_db_display_inquire (Dga_drawable dgadraw
);
452 extern int dga_draw_db_display_done (Dga_drawable dgadraw
, int flag
,
453 int (*display_done_func
)(Dga_drawable
));
454 extern Dga_dbinfo
*dga_draw_db_dbinfop (Dga_drawable dgadraw
);
455 extern int dga_draw_devinfochg(Dga_drawable dgadraw
);
458 * Misc. grabber functions
461 extern int XDgaDrawGrabWids(Display
*, Drawable
, int);
462 extern Dga_widinfo
*dga_draw_widinfop(Dga_drawable
);
463 extern int XDgaDrawGrabFCS(Display
*, Drawable
, int);
464 extern int XDgaDrawGrabZbuf(Display
*, Drawable
, int);
465 extern int XDgaDrawGrabStereo(Display
*, Drawable
, int);
468 * Window Compatibility Interface - Ancillary buffers functions
469 * New feature for 2.6
472 extern Dga_buffer
dga_draw_grab_buffer(Dga_drawable
,
473 Dga_buffer_type
, int);
474 extern int dga_draw_ungrab_buffer(Dga_drawable
, Dga_buffer_type
);
475 extern int dga_draw_get_buffers(Dga_drawable
, Dga_buffer
**);
476 extern Dga_buffer_type
dga_buffer_type(Dga_buffer
);
477 extern int dga_buffer_site(Dga_buffer
);
478 extern int dga_draw_bufferchg(Dga_drawable
);
479 extern int dga_buffer_sitechg(Dga_buffer
, int *);
480 extern void* dga_buffer_address(Dga_buffer
);
481 extern int dga_buffer_linebytes(Dga_buffer
);
482 extern int dga_buffer_bitsperpixel(Dga_buffer
);