summaryrefslogtreecommitdiff
path: root/man/XDGA.man
blob: 9c7beefbbaf1626db9fb251011e9e8ec12a3c673 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
.\" $XFree86$
.\" 
.TH XDGA 3 __vendorversion__
.SH NAME
XDGA \- Client library for the XFree86-DGA extension.
.SH SYNOPSIS
.B #include <X11/extensions/xf86dga.h>
.HP
Bool
.BR XDGAQueryExtension (
.br
.RI "Display *" dpy ,
.br
.RI "int *" eventBase ,
.br
.RI "int *" errorBase )
.HP
Bool
.BR XDGAQueryVersion (
.br
.RI "Display *" dpy ,
.br
.RI "int *" majorVersion ,
.br
.RI "int *" minorVersion )
.HP
XDGAMode
.RB * XDGAQueryModes (
.br
.RI "Display *" dpy ,
.br
.RI "int " screen ,
.br
.RI "int *" num )
.HP
XDGADevice
.RB * XDGASetMode (
.br
.RI "Display *" dpy ,
.br
.RI "int " screen ,
.br
.RI "int " mode )
.HP
Bool
.BR XDGAOpenFramebuffer (
.br
.RI "Display *" dpy ,
.br
.RI "int " screen )
.HP
void
.BR XDGACloseFramebuffer (
.br
.RI "Display *" dpy ,
.br
.RI "int " screen )
.HP
void
.BR XDGASetViewport (
.br
.RI "Display *" dpy ,
.br
.RI "int " screen ,
.br
.RI "int " x ,
.br
.RI "int " y ,
.br
.RI "int " flags )
.HP
void
.BR XDGAInstallColormap (
.br
.RI "Display *" dpy ,
.br
.RI "int " screen ,
.br
.RI "Colormap " cmap )
.HP
Colormap
.BR XDGACreateColormap (
.br
.RI "Display *" dpy ,
.br
.RI "int " screen ,
.br
.RI "XDGADevice *" device ,
.br
.RI "int " alloc )
.HP
void
.BR XDGASelectInput (
.br
.RI "Display *" dpy ,
.br
.RI "int " screen ,
.br
.RI "long " event_mask )
.HP
void
.BR XDGAFillRectangle (
.br
.RI "Display *" dpy ,
.br
.RI "int " screen ,
.br
.RI "int " x ,
.br
.RI "int " y ,
.br
.RI "unsigned int " width ,
.br
.RI "unsigned int " height ,
.br
.RI "unsigned long " color )
.HP
void
.BR XDGACopyArea (
.br
.RI "Display *" dpy ,
.br
.RI "int " screen ,
.br
.RI "int " srcx ,
.br
.RI "int " srcy ,
.br
.RI "unsigned int " width ,
.br
.RI "unsigned int " height ,
.br
.RI "int " dstx ,
.br
.RI "int " dsty )
.HP
void
.BR XDGACopyTransparentArea (
.br
.RI "Display *" dpy ,
.br
.RI "int " screen ,
.br
.RI "int " srcx ,
.br
.RI "int " srcy ,
.br
.RI "unsigned int " width ,
.br
.RI "unsigned int " height ,
.br
.RI "int " dstx ,
.br
.RI "int " dsty ,
.br
.RI "unsigned long " key )
.HP
int
.BR XDGAGetViewportStatus (
.br
.RI "Display *" dpy ,
.br
.RI "int " screen )
.HP
void
.BR XDGASync (
.br
.RI "Display *" dpy ,
.br
.RI "int " screen )
.HP
Bool
.BR XDGASetClientVersion (
.br
.RI "Display *" dpy )
.HP
void
.BR XDGAChangePixmapMode (
.br
.RI "Display *" dpy ,
.br
.RI "int " screen ,
.br
.RI "int *" x ,
.br
.RI "int *" y ,
.br
.RI "int " mode )
.HP
void
.BR XDGAKeyEventToXKeyEvent (
.br
.RI "XDGAKeyEvent *" dk ,
.br
.RI "XKeyEvent *" xk )

.SH DESCRIPTION
The
.B XFree86-DGA
extension is an X server extension for allowing client programs direct
access to the video frame buffer.  This is a brief description of the
programming interface for version 2.0 of the
.B XFree86-DGA
extension.
.PP
.B XFree86-DGA
is not intended as a direct rendering API, but rather, as a mechanism
to "get the X Server out of the way" so that some other direct rendering
API can have full access to the hardware.  With this in mind, DGA does
provide clients some direct access to the hardware without requiring a
separate rendering API, but this access is limited to direct linear
framebuffer access.
.PP
Most of the reasons for the
.B XFree86-DGA
extension's existence are now better served in other ways.  Further
development of this extension is not expected, and it may be deprecated
in a future release.  The features that continue to be useful will either
be provided through other existing mechanisms, or through an extension
that address those needs more specifically.
.PP
.B XFree86-DGA
is initialized by passing a number corresponding to a valid
.I XDGAMode
to
.BR XDGASetMode ().
Clients can get a list of valid modes from
.BR XDGAQueryModes ().
Each
.I XDGAMode
corresponds to a different framebuffer layout.
.PP
.BR XDGAQueryModes ()
returns a pointer to an array of 
.IR XDGAMode s
which are valid for the given screen.
.I num
is the number of elements in the array.  The returned array can be freed
with XFree(3).  The
.I XDGAMode
structure is as follows:
.PP
.nf
.ta .5i 2i
typedef struct {
   int num;
   char *name;
   float verticalRefresh;
   int flags;
   int imageWidth;
   int imageHeight;
   int pixmapWidth;
   int pixmapHeight;
   int bytesPerScanline;
   int byteOrder;
   int depth;
   int bitsPerPixel;
   unsigned long redMask;
   unsigned long greenMask;
   unsigned long blueMask;
   short visualClass;
   int viewportWidth;
   int viewportHeight;
   int xViewportStep;
   int yViewportStep;
   int maxViewportX;
   int maxViewportY;
   int viewportFlags;
   int reserved1;
   int reserved2;
.br
} XDGAMode;
.fi
.TP 8
.I num
A unique identifying number
.RI ( num
> 0) for the mode.  This is the number referenced when initializing the mode.
.TP 8
.I name
The name of the corresponding modeline as given in the __xconfigfile__ file.
.TP 8
.I verticalRefresh
The vertical refresh rate for the modeline (in Hz).
.TP 8
.I flags
Any of the following may be OR'd together:
.RS 8
.TP 4
.B XDGAConcurrentAccess
Indicates that concurrent client/server access to the framebuffer is
possible.  If this flag is not set it is very important to call
.BR XDGASync ()
before directly accessing the framebuffer if a call to
.BR XDGAFillRectangle (),
.BR XDGACopyArea ()
or
.BR XDGACopyTransparentArea ()
or any Xlib rendering function has been made prior to such accesses.
.TP 4
.B XDGASolidFillRect
Indicates that
.BR XDGAFillRectangle ()
is supported.
.TP 4
.B XDGABlitRect
Indicates that
.BR XDGACopyArea ()
is supported.
.TP 4
.B XDGABlitTransRect
Indicates that
.BR XDGACopyTransparentArea ()
is supported.
.TP 4
.B XDGAPixmap
Indicates that a Pixmap will be returned when the mode is initialized.
This means that rendering with Xlib is possible for this mode.
.TP 4
.B XDGAInterlaced
.TP 4
.B XDGADoublescan
Indicates that the mode is an interlaced or doublescan mode.
.RE
.TP 8
.I imageWidth
.TP 8
.I imageHeight
The width and height of the framebuffer area accessible by the client.
This rectangle is always justified to the upper left-hand corner.
.TP 8
.I pixmapWidth
.TP 8
.I pixmapHeight
The width and height of the framebuffer area accessible by Xlib.  This
rectangle is always justified to the upper left-hand corner.  These
fields are only valid if the
.B XDGAPixmap
flag is set in the
.I flags
field.
.TP 8
.I bytesPerScanline
The pitch of the framebuffer in bytes.
.TP 8
.I byteOrder
.B MSBFirst
or
.BR LSBFirst .
.TP 8
.I depth
The number of bits in each pixel which contain usable data.
.TP 8
.I bitsPerPixel
The number of bits taken up by each pixel.
.TP 8
.I redMask
.TP 8
.I greenMask
.TP 8
.I blueMask
The RGB masks.  These do not apply to color-indexed modes.
.TP 8
.I visualClass
.BR TrueColor ,
.BR PseudoColor ,
.BR DirectColor ,
etc.
.TP 8
.I viewportWidth
.TP 8
.I viewportHeight
The dimensions of the portion of the framebuffer which will be displayed
on the screen.
.TP 8
.I xViewPortStep
.TP 8
.I yViewPortStep
The granularity of the x,y viewport positioning possible with the
.BR XDGASetViewport ()
function.
.TP 8
.I maxViewportX
.TP 8
.I maxViewportY
The maximum x and y positions possible with the 
.BR XDGASetViewport ()
function.
.TP 8
.I viewportFlags
Any of the following may be OR'd together
.RS 8
.TP 4
.B XDGAFlipRetrace
Indicates that the hardware can switch viewports during the vertical
retrace.
.TP 4
.B XDGAFlipImmediate
Indicates that the hardware can switch viewports immediately without
waiting for the vertical retrace.
.RE
.PP
.BR XDGASetMode ()
initialises the
.I XDGAMode
corresponding to
.IR num .
To exit DGA mode and return to normal server operation, call
.BR XDGASetMode ()
with
.I num
set to zero.
.BR XDGASetMode ()
returns a pointer to an
.I XDGADevice
if successful.  The XDGADevice can be freed with XFree(3).  The
.I XDGADevice
structure is as follows:
.PP
.nf
.ta .5i 2i
typedef struct {
   XDGAMode mode;
   unsigned char *data;
   Pixmap pixmap;
.br
} XDGADevice;
.fi
.TP 8
.I mode
The
.I XDGAMode
structure, identical to the information returned by
.BR XDGAQueryModes ().
.TP 8
.I data
If direct framebuffer access is desired and possible, this field will
contain a pointer to the mapped framebuffer memory.  Generally, this
field will be zero unless a call to
.BR XDGAOpenFramebuffer ()
is made prior to initialization of the mode.
.TP 8
.I pixmap
If the mode supports Xlib rendering as indicated by
.B XDGAPixmap
in the
.I flags
field, this will contain a Pixmap handle suitable for passing as the
drawable argument to Xlib functions.  This field will be zero if Xlib
rendering is not supported.
.PP
.BR XDGAQueryExtension ()
checks for the presence of the extension and returns the event and error bases.
.PP
.BR XDGAQueryVersion ()
returns the
.B XFree86-DGA
major and minor version numbers.
.PP
.BR XDGAOpenFramebuffer ()
maps the framebuffer memory.  The client needs sufficient privileges to be
able to do this.
.BR XDGAOpenFramebuffer ()
should be called prior to initializing a DGA mode if direct framebuffer
access is desired for that mode.
.BR XDGAOpenFramebuffer ()
does not need to be called if direct framebuffer access is not required.
If the framebuffer is opened,
.PP
.BR XDGACloseFramebuffer ()
should be called prior to client exit to unmap the memory.
.PP
.BR XDGAChangePixmapMode ()
can be used to change between two pixmap sizes in cases where a Pixmap is
available for Xlib rendering.  The following values for the
.I mode
parameter are available:
.RS 8
.TP 4
.B XDGAPixmapModeLarge
The pixmap size is defined by the
.I pixmapWidth
and
.I  pixmapHeight
fields in the
.I XDGAMode
structure.  The
.I x
and
.I y
values are ignored in this case.
.TP 4
.B XDGAPixmapModeSmall
The pixmap size is defined by the
.I viewportWidth
and
.I viewportHeight
fields in the
.I XDGAMode
structure.  In this mode, the
.I x
and
.I y
values specify where in the framebuffer this pixmap rectangle is located.
It may be placed anywhere within the Xlib renderable region described
by the
.I pixmapWidth
and
.I pixmapHeight
fields in the
.IR XDGAMode .
The
.I x
and
.I y
values returned are the resultant location of the pixmap and may be
different from the requested x,y location due to platform specific
alignment constraints.  All Xlib rendering is clipped to this pixmap
rectangle.
.RE
.PP
.BR XDGASetViewport ()
sets the upper left-hand corner of the rectangle of framebuffer that is
to be displayed on the screen.  Not all locations may be supported by
the hardware and requested locations will be adjusted according to the
.I xViewPortStep
and
.I yViewPortStep
fields in the
.IR XDGAMode .
.PP
.I flags
can be
.B XDGAFlipRetrace
or
.B XDGAFlipImmediate
to adjust the viewport location at the next vertical retrace or
immediately.  Values other than the supported values advertised in the
mode's
.I viewportFlags
field will result in hardware-specific default behavior.
.B XDGAFlipImmediate
will block until the flip is completed.
.B XDGAFlipRetrace
will generally NOT block so it is necessary to monitor the viewport
status with
.BR XDGAGetViewportStatus ().
.B XDGAFlipImmediate
requests during pending
.B XDGAFlipRetrace
requests will be ignored.
.PP
.BR XDGAGetViewportStatus ()
keeps track of the
.BR XDGASetViewport ()
requests still pending.  The return value of the function will have
consecutive bits set (LSB justified), each bit representing a pending
viewport change.  For example:
.PP
.nf
     while(XDGAGetViewportStatus(dpy, screen));
.fi
.PP
waits for all pending viewport changes to finish.
.PP
.nf
     while(0x2 & XDGAGetViewportStatus(dpy, screen));
.fi
.PP
waits until all but the last viewport changes have completed.
.PP
.BR XDGACreateColormap ()
is similar to the Xlib function XCreateColormap(3) except that it takes
an
.I XDGADevice
as an argument instead of a Window and Visual.  Though XCreateColormap(3)
may create usable colormaps in some cases,
.BR XDGACreateColormap ()
is the preferred method for creating colormaps in DGA since there may
not be an advertised visual compatible with the DGA device.
.PP
.BR XDGAInstallColormap ()
must be used to install colormaps in DGA mode.  XInstallColormap(3) will
not work.
.PP
.BR XDGASelectInput ()
enables DGA's own event mechanism.  This function is similar to
XSelectInput(3), and all Xlib Key, Button and Motion masks are supported.
The following DGA events are defined:
.PP
.nf
.ta .5i 2i
typedef struct {
   int type;             /\(** ButtonPress or ButtonRelease + the DGA event base*/
   unsigned long serial; /\(** # or last request processed by the server */
   Display *display;     /\(** Display the event was read from */
   int screen;           /\(** The screen number the event came from */
   Time time;            /\(** milliseconds */
   unsigned int state;   /\(** key or button mask */
   unsigned int button;  /\(** detail */
.br
} XDGAButtonEvent;
.fi
.PP
.nf
.ta .5i 2i
typedef struct {
   int type;             /\(** KeyPress or KeyRelease + the DGA event base*/
   unsigned long serial; /\(** # or last request processed by the server */
   Display *display;     /\(** Display the event was read from */
   int screen;           /\(** The screen number the event came from */
   Time time;            /\(** milliseconds */
   unsigned int state;   /\(** key or button mask */
   unsigned int keycode; /\(** detail */
.br
} XDGAKeyEvent;
.fi
.PP
.nf
.ta .5i 2i
typedef struct {
   int type;             /\(** MotionNotify + the DGA event base*/
   unsigned long serial; /\(** # or last request processed by the server */
   Display *display;     /\(** Display the event was read from */
   int screen;           /\(** The screen number the event came from */
   Time time;            /\(** milliseconds */
   unsigned int state;   /\(** key or button mask */
   int dx;               /\(** relative pointer motion */
   int dy;               /\(** relative pointer motion */
.br
} XDGAMotionEvent;
.fi
.PP
.BR XDGAKeyEventToXKeyEvent ()
is a helper function to translate
.IR XDGAKeyEvent s
into
.IR XKeyEvent s
suitable for use with XLookupKeysym(3).
.PP
.BR XDGAFillRectangle (),
.BR XDGACopyArea (),
and
.BR XDGACopyTransparentArea ()
are included with some reservation since DGA is not intended as a
rendering API.  These are merely convenience routines and are optionally
supported.  The associated flags will be set in the
.IR XDGAMode 's
.I flags
field if these functions are supported.  These functions will be no-ops
otherwise. they do not provide direct access to the hardware, but are
simply context-less operations performed by the server.
.PP
.BR XDGASync ()
blocks until all server rendering to the framebuffer completes.  If Xlib
or the 3 rendering functions above are used,
.BR XDGASync ()
must be called before the client directly accesses the framebuffer as
the server rendering is asynchronous with the client and may have not
completed.  This is especially important if the
.B XDGAConcurrentAccess
flag is not set in the
.IR XDGAMode 's
.I flags
field since concurrent access by the server and client may result in a
system lockup.
.SH SEE ALSO
__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__)
.SH AUTHORS
.B XFree86-DGA
version 2 was written by Mark Vojkovich.  Version 1 was written by Jon
Tombs, Harm Hanemaayer, Mark Vojkovich.