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
|
XFree86-DGA Extension version 2.0
The 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 the
XFree86-DGA extension. This describes version 2.0, which is the second
official version. The functions described here are found in the library
libXxf86dga.a, and their prototypes are in <X11/extensions/xf86dga.h>.
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 a direct
rendering API, such as OpenGL, 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.
DGA is initialized by passing a number corresponding to a valid
XDGAMode to XDGASetMode(). Clients can get a list of valid modes
from XDGAQueryModes(). Each XDGAMode corresponds to a different
framebuffer layout.
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;
} XDGAMode;
num
A unique identifying number (num > 0) for the mode. This is the
number referenced when initializing the mode.
name
The name of the corresponding modeline as given in the XF86Config file.
verticalRefresh
The vertical refresh rate for the modeline (in Hz).
flags
Any of the following may be OR'd together:
XDGAConcurrentAccess
Indicates that concurrent client/server access to the
framebuffer is possible. If this flag is not set it is
very important to call XDGASync() before directly accessing
the framebuffer if a call to XDGAFillRectangle(),
XDGACopyArea() or XDGACopyTransparentArea() or any Xlib
rendering function has been made prior to such accesses.
XDGASolidFillRect
Indicates that XDGAFillRectangle() is supported.
XDGABlitRect
Indicates that XDGACopyArea() is supported.
XDGABlitTransRect
Indicates that XDGACopyTransparentArea() is supported.
XDGAPixmap
Indicates that a Pixmap will be returned when the mode is
initialized. This means that rendering with Xlib is possible
for this mode.
XDGAInterlaced
XDGADoublescan
Indicates that the mode is an interlaced or doublescan mode.
imageWidth
imageHeight
The width and height of the framebuffer area accessible by the client.
This rectangle is always justified to the upper left-hand corner.
pixmapWidth
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 XDGAPixmap flag is set in the
"flags" field.
bytesPerScanline
The pitch of the framebuffer in bytes.
byteOrder
MSBFirst or LSBFirst.
depth
The number of bits in each pixel which contain usable data.
bitsPerPixel
The number of bits taken up by each pixel.
redMask
greenMask
blueMask
The RGB masks. These do not apply to color-indexed modes.
visualClass
TrueColor, PseudoColor, DirectColor, etc...
viewportWidth
viewportHeight
The dimensions of the portion of the framebuffer which will be
displayed on the screen.
xViewPortStep
yViewPortStep
The granularity of the x,y viewport positioning possible with
the XDGASetViewport function.
maxViewportX
maxViewportY
The maximimum x and y positions possible with the XDGASetViewport
function.
viewportFlags
Any of the following may be OR'd together:
XDGAFlipRetrace
Indicates that the hardware can switch viewports during
the vertical retrace.
XDGAFlipImmediate
Indicates that the hardware can switch viewports immediately
without waiting for the vertical retrace.
XDGAMode* XDGAQueryModes(
Display *dpy,
int screen,
int *num
);
XDGAQueryModes() returns a pointer to an array of XDGAModes which
are valid for the given screen. "num" is the number of elements in the
array. The returned array can be freed with XFree();
XDGADevice* XDGASetMode(
Display *dpy,
int screen,
int num
);
A XDGAMode will be initialized when its "num" is passed to
XDGASetMode(). To exit DGA mode and return to normal server operation,
pass number zero to XDGASetMode(). XDGASetMode() returns a pointer
to an XDGADevice if successful. The XDGADevice can be freed with
XFree().
struct {
XDGAMode mode;
unsigned char *data;
Pixmap pixmap;
} XDGADevice;
mode
The XDGAMode structure, identical to the information returned
by XDGAQueryModes.
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 XDGAOpenFramebuffer()
is made prior to initialization of the mode.
pixmap
If the mode supports Xlib rendering as indicated by XDGAPixmap
in the 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.
Bool XDGAQueryExtension(
Display *dpy,
int *eventBase,
int *errorBase
);
XDGAQueryExtension() checks for the prescence of the extension
and returns the event and error bases.
Bool XDGAQueryVersion(
Display *dpy,
int *majorVersion,
int *minorVersion
);
XDGAQueryVersion() returns the major and minor version numbers (duh).
Bool XDGAOpenFramebuffer(
Display *dpy,
int screen
);
void XDGACloseFramebuffer(
Display *dpy,
int screen
);
XDGAOpenFramebuffer() maps the framebuffer memory. The client
needs sufficient privledges to be able to do this.
XDGAOpenFramebuffer() should be called prior to initializing
a dga mode if direct framebuffer access is desired for that mode.
XDGAOpenFramebuffer() does not need to be called if direct framebuffer
access is not required. If the framebuffer is opened,
XDGACloseFramebuffer() should be called prior to client exit to
unmap the memory.
void XDGAChangePixmapMode(
Display *dpy,
int screen,
int *x,
int *y,
int mode
);
In the case where a Pixmap is available for Xlib rendering, this
function allows changing between two pixmap sizes. The following
values for "mode" are possible.
XDGAPixmapModeLarge
The pixmap size is defined by the pixmapWidth and pixmapHeight
fields in the XDGAMode structure. The "x" and "y" values are
ignored in this case.
XDGAPixmapModeSmall
The pixmap size is defined by the viewportWidth and viewportHeight
fields in the XDGAMode structure. In this mode, the "x" and "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 pixmapWidth and pixmapHeight fields in
the XDGAMode. The "x" and "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.
void XDGASetViewport(
Display *dpy,
int screen,
int x,
int y,
int flags
);
Set 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 xViewPortStep and yViewPortStep fields in the XDGAMode.
"flags" can be XDGAFlipRetrace or XDGAFlipImmediate to adjust
the viewport location at the next vertical retrace or immediately.
Values other than the supported values advertised in the mode's
viewportFlags field will result in hardware-specific default behavior.
XDGAFlipImmediate will block until the flip is completed.
XDGAFlipRetrace will generally NOT block so it is necessary to
monitor the viewport status with XDGAGetViewportStatus().
FlipImmediate requests during pending FlipRetrace requests
will be ignored.
int XDGAGetViewportStatus(
Display *dpy,
int screen
);
XDGAGetViewportStatus() keeps track of the 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:
while(XDGAGetViewportStatus(dpy, screen));
waits for all pending viewport changes to finish.
while(0x2 & XDGAGetViewportStatus(dpy, screen));
waits until all but the last viewport changes have completed.
Colormap XDGACreateColormap(
Display *dpy,
int screen,
XDGADevice *device,
int alloc
);
void XDGAInstallColormap(
Display *dpy,
int screen,
Colormap cmap
);
XDGACreateColormap() is similar to the Xlib function XCreateColormap()
except that it takes an XDGADevice as an argument instead of a Window
and Visual. Though XCreateColormap() may create useable colormaps in
some cases, XDGACreateColormap() is the prefered method for creating
colormaps in DGA since there may not be an advertised visual compatible
with the DGA device.
XDGAInstallColormap() must be used to install colormaps in DGA
mode. XInstallColormap() will not work.
void XDGASelectInput(
Display *dpy,
int screen,
long event_mask
);
DGA provides its own events. These can be enabled by calling
XDGASelectInput(). This function is similar to XSelectInput()
and all Xlib Key, Button and Motion masks are supported.
The following DGA events are defined.
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 */
} XDGAButtonEvent;
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 */
} XDGAKeyEvent;
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 */
} XDGAMotionEvent;
void
XDGAKeyEventToXKeyEvent(XDGAKeyEvent* dk, XKeyEvent* xk);
XDGAKeyEventToXKeyEvent() is a helper function to translate
XDGAKeyEvents into XKeyEvents suitable for use with XLookupKeysym().
void XDGAFillRectangle(
Display *dpy,
int screen,
int x,
int y,
unsigned int width,
unsigned int height,
unsigned long color
);
void XDGACopyArea(
Display *dpy,
int screen,
int srcx,
int srcy,
unsigned int width,
unsigned int height,
int dstx,
int dsty
);
void XDGACopyTransparentArea(
Display *dpy,
int screen,
int srcx,
int srcy,
unsigned int width,
unsigned int height,
int dstx,
int dsty,
unsigned long key /* source pixels of this value will not be copied */
);
These three functions are included with some reserveration since
DGA is not intended as a rendering API. These are merely convience
routines and are optionally supported. The associated flags will
be set in the XDGAMode's "flags" field if these functions are supported.
These functions will be no-ops otherwise.
These functions do not provide direct access to the hardware,
but are merely context-less operations performed by the server.
void XDGASync(
Display *dpy,
int screen
);
This function blocks until all server rendering to the framebuffer
completes. If Xlib or the 3 rendering functions above are used, 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 XDGAConcurrentAccess
flag is not set in the XDGAMode's "flags" field since concurrent access
by the server and client may result in a system lockup.
$XFree86: xc/programs/Xserver/hw/xfree86/DGA,v 1.1 1999/11/19 13:54:09 hohndel Exp $
|