Commit | Line | Data |
---|---|---|
a09e091a JB |
1 | /* |
2 | * This code was stolen from RAC and adapted to control the legacy vga | |
3 | * interface. | |
4 | * | |
5 | * | |
6 | * Copyright (c) 2007 Paulo R. Zanoni, Tiago Vignatti | |
7 | * | |
8 | * Permission is hereby granted, free of charge, to any person | |
9 | * obtaining a copy of this software and associated documentation | |
10 | * files (the "Software"), to deal in the Software without | |
11 | * restriction, including without limitation the rights to use, | |
12 | * copy, modify, merge, publish, distribute, sublicense, and/or sell | |
13 | * copies of the Software, and to permit persons to whom the | |
14 | * Software is furnished to do so, subject to the following | |
15 | * conditions: | |
16 | * | |
17 | * The above copyright notice and this permission notice shall be | |
18 | * included in all copies or substantial portions of the Software. | |
19 | * | |
20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
21 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | |
22 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
23 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |
24 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
25 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
26 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
27 | * OTHER DEALINGS IN THE SOFTWARE. | |
28 | * | |
29 | */ | |
30 | ||
31 | #include "xorg-config.h" | |
32 | ||
33 | #include "xf86VGAarbiter.h" | |
34 | #include "xf86VGAarbiterPriv.h" | |
35 | #include "xf86Bus.h" | |
36 | #include "xf86Priv.h" | |
37 | #include "pciaccess.h" | |
38 | ||
39 | static GCFuncs VGAarbiterGCFuncs = { | |
40 | VGAarbiterValidateGC, VGAarbiterChangeGC, VGAarbiterCopyGC, | |
41 | VGAarbiterDestroyGC, VGAarbiterChangeClip, VGAarbiterDestroyClip, | |
42 | VGAarbiterCopyClip | |
43 | }; | |
44 | ||
45 | static GCOps VGAarbiterGCOps = { | |
46 | VGAarbiterFillSpans, VGAarbiterSetSpans, VGAarbiterPutImage, | |
47 | VGAarbiterCopyArea, VGAarbiterCopyPlane, VGAarbiterPolyPoint, | |
48 | VGAarbiterPolylines, VGAarbiterPolySegment, VGAarbiterPolyRectangle, | |
49 | VGAarbiterPolyArc, VGAarbiterFillPolygon, VGAarbiterPolyFillRect, | |
50 | VGAarbiterPolyFillArc, VGAarbiterPolyText8, VGAarbiterPolyText16, | |
51 | VGAarbiterImageText8, VGAarbiterImageText16, VGAarbiterImageGlyphBlt, | |
52 | VGAarbiterPolyGlyphBlt, VGAarbiterPushPixels, | |
53 | }; | |
54 | ||
55 | static miPointerSpriteFuncRec VGAarbiterSpriteFuncs = { | |
56 | VGAarbiterSpriteRealizeCursor, VGAarbiterSpriteUnrealizeCursor, | |
57 | VGAarbiterSpriteSetCursor, VGAarbiterSpriteMoveCursor, | |
58 | VGAarbiterDeviceCursorInitialize, VGAarbiterDeviceCursorCleanup | |
59 | }; | |
60 | ||
61 | static DevPrivateKeyRec VGAarbiterScreenKeyRec; | |
62 | ||
63 | #define VGAarbiterScreenKey (&VGAarbiterScreenKeyRec) | |
64 | static DevPrivateKeyRec VGAarbiterGCKeyRec; | |
65 | ||
66 | #define VGAarbiterGCKey (&VGAarbiterGCKeyRec) | |
67 | ||
68 | static int vga_no_arb = 0; | |
69 | void | |
70 | xf86VGAarbiterInit(void) | |
71 | { | |
72 | if (pci_device_vgaarb_init() != 0) { | |
73 | vga_no_arb = 1; | |
74 | xf86Msg(X_WARNING, | |
75 | "VGA arbiter: cannot open kernel arbiter, no multi-card support\n"); | |
76 | } | |
77 | } | |
78 | ||
79 | void | |
80 | xf86VGAarbiterFini(void) | |
81 | { | |
82 | if (vga_no_arb) | |
83 | return; | |
84 | pci_device_vgaarb_fini(); | |
85 | } | |
86 | ||
87 | void | |
88 | xf86VGAarbiterLock(ScrnInfoPtr pScrn) | |
89 | { | |
90 | if (vga_no_arb) | |
91 | return; | |
92 | pci_device_vgaarb_set_target(pScrn->vgaDev); | |
93 | pci_device_vgaarb_lock(); | |
94 | } | |
95 | ||
96 | void | |
97 | xf86VGAarbiterUnlock(ScrnInfoPtr pScrn) | |
98 | { | |
99 | if (vga_no_arb) | |
100 | return; | |
101 | pci_device_vgaarb_unlock(); | |
102 | } | |
103 | ||
104 | Bool | |
105 | xf86VGAarbiterAllowDRI(ScreenPtr pScreen) | |
106 | { | |
107 | int vga_count; | |
108 | int rsrc_decodes; | |
109 | ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); | |
110 | ||
111 | if (vga_no_arb) | |
112 | return TRUE; | |
113 | ||
114 | pci_device_vgaarb_get_info(pScrn->vgaDev, &vga_count, &rsrc_decodes); | |
115 | if (vga_count > 1) { | |
116 | if (rsrc_decodes) { | |
117 | return FALSE; | |
118 | } | |
119 | } | |
120 | return TRUE; | |
121 | } | |
122 | ||
123 | void | |
124 | xf86VGAarbiterScrnInit(ScrnInfoPtr pScrn) | |
125 | { | |
126 | struct pci_device *dev; | |
127 | EntityPtr pEnt; | |
128 | ||
129 | if (vga_no_arb) | |
130 | return; | |
131 | ||
132 | pEnt = xf86Entities[pScrn->entityList[0]]; | |
133 | if (pEnt->bus.type != BUS_PCI) | |
134 | return; | |
135 | ||
136 | dev = pEnt->bus.id.pci; | |
137 | pScrn->vgaDev = dev; | |
138 | } | |
139 | ||
140 | void | |
141 | xf86VGAarbiterDeviceDecodes(ScrnInfoPtr pScrn, int rsrc) | |
142 | { | |
143 | if (vga_no_arb) | |
144 | return; | |
145 | pci_device_vgaarb_set_target(pScrn->vgaDev); | |
146 | pci_device_vgaarb_decodes(rsrc); | |
147 | } | |
148 | ||
149 | Bool | |
150 | xf86VGAarbiterWrapFunctions(void) | |
151 | { | |
152 | ScrnInfoPtr pScrn; | |
153 | VGAarbiterScreenPtr pScreenPriv; | |
154 | miPointerScreenPtr PointPriv; | |
155 | PictureScreenPtr ps; | |
156 | ScreenPtr pScreen; | |
157 | int vga_count, i; | |
158 | ||
159 | if (vga_no_arb) | |
160 | return FALSE; | |
161 | ||
162 | /* | |
163 | * we need to wrap the arbiter if we have more than | |
164 | * one VGA card - hotplug cries. | |
165 | */ | |
166 | pci_device_vgaarb_get_info(NULL, &vga_count, NULL); | |
167 | if (vga_count < 2 || !xf86Screens) | |
168 | return FALSE; | |
169 | ||
170 | xf86Msg(X_INFO, "Found %d VGA devices: arbiter wrapping enabled\n", | |
171 | vga_count); | |
172 | ||
173 | for (i = 0; i < xf86NumScreens; i++) { | |
174 | pScreen = xf86Screens[i]->pScreen; | |
175 | ps = GetPictureScreenIfSet(pScreen); | |
176 | pScrn = xf86ScreenToScrn(pScreen); | |
177 | PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey); | |
178 | ||
179 | if (!dixRegisterPrivateKey | |
180 | (&VGAarbiterGCKeyRec, PRIVATE_GC, sizeof(VGAarbiterGCRec))) | |
181 | return FALSE; | |
182 | ||
183 | if (!dixRegisterPrivateKey(&VGAarbiterScreenKeyRec, PRIVATE_SCREEN, 0)) | |
184 | return FALSE; | |
185 | ||
186 | if (!(pScreenPriv = malloc(sizeof(VGAarbiterScreenRec)))) | |
187 | return FALSE; | |
188 | ||
189 | dixSetPrivate(&pScreen->devPrivates, VGAarbiterScreenKey, pScreenPriv); | |
190 | ||
191 | WRAP_SCREEN(CloseScreen, VGAarbiterCloseScreen); | |
192 | WRAP_SCREEN(SaveScreen, VGAarbiterSaveScreen); | |
193 | WRAP_SCREEN(WakeupHandler, VGAarbiterWakeupHandler); | |
194 | WRAP_SCREEN(BlockHandler, VGAarbiterBlockHandler); | |
195 | WRAP_SCREEN(CreateGC, VGAarbiterCreateGC); | |
196 | WRAP_SCREEN(GetImage, VGAarbiterGetImage); | |
197 | WRAP_SCREEN(GetSpans, VGAarbiterGetSpans); | |
198 | WRAP_SCREEN(SourceValidate, VGAarbiterSourceValidate); | |
199 | WRAP_SCREEN(CopyWindow, VGAarbiterCopyWindow); | |
200 | WRAP_SCREEN(ClearToBackground, VGAarbiterClearToBackground); | |
201 | WRAP_SCREEN(CreatePixmap, VGAarbiterCreatePixmap); | |
202 | WRAP_SCREEN(StoreColors, VGAarbiterStoreColors); | |
203 | WRAP_SCREEN(DisplayCursor, VGAarbiterDisplayCursor); | |
204 | WRAP_SCREEN(RealizeCursor, VGAarbiterRealizeCursor); | |
205 | WRAP_SCREEN(UnrealizeCursor, VGAarbiterUnrealizeCursor); | |
206 | WRAP_SCREEN(RecolorCursor, VGAarbiterRecolorCursor); | |
207 | WRAP_SCREEN(SetCursorPosition, VGAarbiterSetCursorPosition); | |
208 | WRAP_PICT(Composite, VGAarbiterComposite); | |
209 | WRAP_PICT(Glyphs, VGAarbiterGlyphs); | |
210 | WRAP_PICT(CompositeRects, VGAarbiterCompositeRects); | |
211 | WRAP_SCREEN_INFO(AdjustFrame, VGAarbiterAdjustFrame); | |
212 | WRAP_SCREEN_INFO(SwitchMode, VGAarbiterSwitchMode); | |
213 | WRAP_SCREEN_INFO(EnterVT, VGAarbiterEnterVT); | |
214 | WRAP_SCREEN_INFO(LeaveVT, VGAarbiterLeaveVT); | |
215 | WRAP_SCREEN_INFO(FreeScreen, VGAarbiterFreeScreen); | |
216 | WRAP_SPRITE; | |
217 | } | |
218 | ||
219 | return TRUE; | |
220 | } | |
221 | ||
222 | /* Screen funcs */ | |
223 | static Bool | |
224 | VGAarbiterCloseScreen(ScreenPtr pScreen) | |
225 | { | |
226 | Bool val; | |
227 | ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); | |
228 | VGAarbiterScreenPtr pScreenPriv = | |
229 | (VGAarbiterScreenPtr) dixLookupPrivate(&pScreen->devPrivates, | |
230 | VGAarbiterScreenKey); | |
231 | miPointerScreenPtr PointPriv = | |
232 | (miPointerScreenPtr) dixLookupPrivate(&pScreen->devPrivates, | |
233 | miPointerScreenKey); | |
234 | PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); | |
235 | ||
236 | UNWRAP_SCREEN(CreateGC); | |
237 | UNWRAP_SCREEN(CloseScreen); | |
238 | UNWRAP_SCREEN(GetImage); | |
239 | UNWRAP_SCREEN(GetSpans); | |
240 | UNWRAP_SCREEN(SourceValidate); | |
241 | UNWRAP_SCREEN(CopyWindow); | |
242 | UNWRAP_SCREEN(ClearToBackground); | |
243 | UNWRAP_SCREEN(SaveScreen); | |
244 | UNWRAP_SCREEN(StoreColors); | |
245 | UNWRAP_SCREEN(DisplayCursor); | |
246 | UNWRAP_SCREEN(RealizeCursor); | |
247 | UNWRAP_SCREEN(UnrealizeCursor); | |
248 | UNWRAP_SCREEN(RecolorCursor); | |
249 | UNWRAP_SCREEN(SetCursorPosition); | |
250 | UNWRAP_PICT(Composite); | |
251 | UNWRAP_PICT(Glyphs); | |
252 | UNWRAP_PICT(CompositeRects); | |
253 | UNWRAP_SCREEN_INFO(AdjustFrame); | |
254 | UNWRAP_SCREEN_INFO(SwitchMode); | |
255 | UNWRAP_SCREEN_INFO(EnterVT); | |
256 | UNWRAP_SCREEN_INFO(LeaveVT); | |
257 | UNWRAP_SCREEN_INFO(FreeScreen); | |
258 | UNWRAP_SPRITE; | |
259 | ||
260 | free((pointer) pScreenPriv); | |
261 | xf86VGAarbiterLock(xf86ScreenToScrn(pScreen)); | |
262 | val = (*pScreen->CloseScreen) (pScreen); | |
263 | xf86VGAarbiterUnlock(xf86ScreenToScrn(pScreen)); | |
264 | return val; | |
265 | } | |
266 | ||
267 | static void | |
268 | VGAarbiterBlockHandler(ScreenPtr pScreen, | |
269 | pointer pTimeout, pointer pReadmask) | |
270 | { | |
271 | SCREEN_PROLOG(BlockHandler); | |
272 | VGAGet(pScreen); | |
273 | pScreen->BlockHandler(pScreen, pTimeout, pReadmask); | |
274 | VGAPut(); | |
275 | SCREEN_EPILOG(BlockHandler, VGAarbiterBlockHandler); | |
276 | } | |
277 | ||
278 | static void | |
279 | VGAarbiterWakeupHandler(ScreenPtr pScreen, unsigned long result, | |
280 | pointer pReadmask) | |
281 | { | |
282 | SCREEN_PROLOG(WakeupHandler); | |
283 | VGAGet(pScreen); | |
284 | pScreen->WakeupHandler(pScreen, result, pReadmask); | |
285 | VGAPut(); | |
286 | SCREEN_EPILOG(WakeupHandler, VGAarbiterWakeupHandler); | |
287 | } | |
288 | ||
289 | static void | |
290 | VGAarbiterGetImage(DrawablePtr pDrawable, | |
291 | int sx, int sy, int w, int h, | |
292 | unsigned int format, unsigned long planemask, char *pdstLine) | |
293 | { | |
294 | ScreenPtr pScreen = pDrawable->pScreen; | |
295 | ||
296 | SCREEN_PROLOG(GetImage); | |
297 | VGAGet(pScreen); | |
298 | (*pScreen->GetImage) (pDrawable, sx, sy, w, h, format, planemask, pdstLine); | |
299 | VGAPut(); | |
300 | SCREEN_EPILOG(GetImage, VGAarbiterGetImage); | |
301 | } | |
302 | ||
303 | static void | |
304 | VGAarbiterGetSpans(DrawablePtr pDrawable, | |
305 | int wMax, | |
306 | DDXPointPtr ppt, int *pwidth, int nspans, char *pdstStart) | |
307 | { | |
308 | ScreenPtr pScreen = pDrawable->pScreen; | |
309 | ||
310 | SCREEN_PROLOG(GetSpans); | |
311 | VGAGet(pScreen); | |
312 | (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart); | |
313 | VGAPut(); | |
314 | SCREEN_EPILOG(GetSpans, VGAarbiterGetSpans); | |
315 | } | |
316 | ||
317 | static void | |
318 | VGAarbiterSourceValidate(DrawablePtr pDrawable, | |
319 | int x, int y, int width, int height, | |
320 | unsigned int subWindowMode) | |
321 | { | |
322 | ScreenPtr pScreen = pDrawable->pScreen; | |
323 | ||
324 | SCREEN_PROLOG(SourceValidate); | |
325 | VGAGet(pScreen); | |
326 | if (pScreen->SourceValidate) | |
327 | (*pScreen->SourceValidate) (pDrawable, x, y, width, height, | |
328 | subWindowMode); | |
329 | VGAPut(); | |
330 | SCREEN_EPILOG(SourceValidate, VGAarbiterSourceValidate); | |
331 | } | |
332 | ||
333 | static void | |
334 | VGAarbiterCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) | |
335 | { | |
336 | ScreenPtr pScreen = pWin->drawable.pScreen; | |
337 | ||
338 | SCREEN_PROLOG(CopyWindow); | |
339 | VGAGet(pScreen); | |
340 | (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc); | |
341 | VGAPut(); | |
342 | SCREEN_EPILOG(CopyWindow, VGAarbiterCopyWindow); | |
343 | } | |
344 | ||
345 | static void | |
346 | VGAarbiterClearToBackground(WindowPtr pWin, | |
347 | int x, int y, int w, int h, Bool generateExposures) | |
348 | { | |
349 | ScreenPtr pScreen = pWin->drawable.pScreen; | |
350 | ||
351 | SCREEN_PROLOG(ClearToBackground); | |
352 | VGAGet(pScreen); | |
353 | (*pScreen->ClearToBackground) (pWin, x, y, w, h, generateExposures); | |
354 | VGAPut(); | |
355 | SCREEN_EPILOG(ClearToBackground, VGAarbiterClearToBackground); | |
356 | } | |
357 | ||
358 | static PixmapPtr | |
359 | VGAarbiterCreatePixmap(ScreenPtr pScreen, int w, int h, int depth, | |
360 | unsigned usage_hint) | |
361 | { | |
362 | PixmapPtr pPix; | |
363 | ||
364 | SCREEN_PROLOG(CreatePixmap); | |
365 | VGAGet(pScreen); | |
366 | pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth, usage_hint); | |
367 | VGAPut(); | |
368 | SCREEN_EPILOG(CreatePixmap, VGAarbiterCreatePixmap); | |
369 | ||
370 | return pPix; | |
371 | } | |
372 | ||
373 | static Bool | |
374 | VGAarbiterSaveScreen(ScreenPtr pScreen, Bool unblank) | |
375 | { | |
376 | Bool val; | |
377 | ||
378 | SCREEN_PROLOG(SaveScreen); | |
379 | VGAGet(pScreen); | |
380 | val = (*pScreen->SaveScreen) (pScreen, unblank); | |
381 | VGAPut(); | |
382 | SCREEN_EPILOG(SaveScreen, VGAarbiterSaveScreen); | |
383 | ||
384 | return val; | |
385 | } | |
386 | ||
387 | static void | |
388 | VGAarbiterStoreColors(ColormapPtr pmap, int ndef, xColorItem * pdefs) | |
389 | { | |
390 | ScreenPtr pScreen = pmap->pScreen; | |
391 | ||
392 | SCREEN_PROLOG(StoreColors); | |
393 | VGAGet(pScreen); | |
394 | (*pScreen->StoreColors) (pmap, ndef, pdefs); | |
395 | VGAPut(); | |
396 | SCREEN_EPILOG(StoreColors, VGAarbiterStoreColors); | |
397 | } | |
398 | ||
399 | static void | |
400 | VGAarbiterRecolorCursor(DeviceIntPtr pDev, | |
401 | ScreenPtr pScreen, CursorPtr pCurs, Bool displayed) | |
402 | { | |
403 | SCREEN_PROLOG(RecolorCursor); | |
404 | VGAGet(pScreen); | |
405 | (*pScreen->RecolorCursor) (pDev, pScreen, pCurs, displayed); | |
406 | VGAPut(); | |
407 | SCREEN_EPILOG(RecolorCursor, VGAarbiterRecolorCursor); | |
408 | } | |
409 | ||
410 | static Bool | |
411 | VGAarbiterRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) | |
412 | { | |
413 | Bool val; | |
414 | ||
415 | SCREEN_PROLOG(RealizeCursor); | |
416 | VGAGet(pScreen); | |
417 | val = (*pScreen->RealizeCursor) (pDev, pScreen, pCursor); | |
418 | VGAPut(); | |
419 | SCREEN_EPILOG(RealizeCursor, VGAarbiterRealizeCursor); | |
420 | return val; | |
421 | } | |
422 | ||
423 | static Bool | |
424 | VGAarbiterUnrealizeCursor(DeviceIntPtr pDev, | |
425 | ScreenPtr pScreen, CursorPtr pCursor) | |
426 | { | |
427 | Bool val; | |
428 | ||
429 | SCREEN_PROLOG(UnrealizeCursor); | |
430 | VGAGet(pScreen); | |
431 | val = (*pScreen->UnrealizeCursor) (pDev, pScreen, pCursor); | |
432 | VGAPut(); | |
433 | SCREEN_EPILOG(UnrealizeCursor, VGAarbiterUnrealizeCursor); | |
434 | return val; | |
435 | } | |
436 | ||
437 | static Bool | |
438 | VGAarbiterDisplayCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor) | |
439 | { | |
440 | Bool val; | |
441 | ||
442 | SCREEN_PROLOG(DisplayCursor); | |
443 | VGAGet(pScreen); | |
444 | val = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor); | |
445 | VGAPut(); | |
446 | SCREEN_EPILOG(DisplayCursor, VGAarbiterDisplayCursor); | |
447 | return val; | |
448 | } | |
449 | ||
450 | static Bool | |
451 | VGAarbiterSetCursorPosition(DeviceIntPtr pDev, | |
452 | ScreenPtr pScreen, int x, int y, Bool generateEvent) | |
453 | { | |
454 | Bool val; | |
455 | ||
456 | SCREEN_PROLOG(SetCursorPosition); | |
457 | VGAGet(pScreen); | |
458 | val = (*pScreen->SetCursorPosition) (pDev, pScreen, x, y, generateEvent); | |
459 | VGAPut(); | |
460 | SCREEN_EPILOG(SetCursorPosition, VGAarbiterSetCursorPosition); | |
461 | return val; | |
462 | } | |
463 | ||
464 | static void | |
465 | VGAarbiterAdjustFrame(ScrnInfoPtr pScrn, int x, int y) | |
466 | { | |
467 | ScreenPtr pScreen = xf86ScrnToScreen(pScrn); | |
468 | VGAarbiterScreenPtr pScreenPriv = | |
469 | (VGAarbiterScreenPtr) dixLookupPrivate(&pScreen->devPrivates, | |
470 | VGAarbiterScreenKey); | |
471 | ||
472 | VGAGet(pScreen); | |
473 | (*pScreenPriv->AdjustFrame) (pScrn, x, y); | |
474 | VGAPut(); | |
475 | } | |
476 | ||
477 | static Bool | |
478 | VGAarbiterSwitchMode(ScrnInfoPtr pScrn, DisplayModePtr mode) | |
479 | { | |
480 | Bool val; | |
481 | ScreenPtr pScreen = xf86ScrnToScreen(pScrn); | |
482 | VGAarbiterScreenPtr pScreenPriv = | |
483 | (VGAarbiterScreenPtr) dixLookupPrivate(&pScreen->devPrivates, | |
484 | VGAarbiterScreenKey); | |
485 | ||
486 | VGAGet(pScreen); | |
487 | val = (*pScreenPriv->SwitchMode) (pScrn, mode); | |
488 | VGAPut(); | |
489 | return val; | |
490 | } | |
491 | ||
492 | static Bool | |
493 | VGAarbiterEnterVT(ScrnInfoPtr pScrn) | |
494 | { | |
495 | Bool val; | |
496 | ScreenPtr pScreen = xf86ScrnToScreen(pScrn); | |
497 | VGAarbiterScreenPtr pScreenPriv = | |
498 | (VGAarbiterScreenPtr) dixLookupPrivate(&pScreen->devPrivates, | |
499 | VGAarbiterScreenKey); | |
500 | ||
501 | VGAGet(pScreen); | |
502 | pScrn->EnterVT = pScreenPriv->EnterVT; | |
503 | val = (*pScrn->EnterVT) (pScrn); | |
504 | pScreenPriv->EnterVT = pScrn->EnterVT; | |
505 | pScrn->EnterVT = VGAarbiterEnterVT; | |
506 | VGAPut(); | |
507 | return val; | |
508 | } | |
509 | ||
510 | static void | |
511 | VGAarbiterLeaveVT(ScrnInfoPtr pScrn) | |
512 | { | |
513 | ScreenPtr pScreen = xf86ScrnToScreen(pScrn); | |
514 | VGAarbiterScreenPtr pScreenPriv = | |
515 | (VGAarbiterScreenPtr) dixLookupPrivate(&pScreen->devPrivates, | |
516 | VGAarbiterScreenKey); | |
517 | ||
518 | VGAGet(pScreen); | |
519 | pScrn->LeaveVT = pScreenPriv->LeaveVT; | |
520 | (*pScreenPriv->LeaveVT) (pScrn); | |
521 | pScreenPriv->LeaveVT = pScrn->LeaveVT; | |
522 | pScrn->LeaveVT = VGAarbiterLeaveVT; | |
523 | VGAPut(); | |
524 | } | |
525 | ||
526 | static void | |
527 | VGAarbiterFreeScreen(ScrnInfoPtr pScrn) | |
528 | { | |
529 | ScreenPtr pScreen = xf86ScrnToScreen(pScrn); | |
530 | VGAarbiterScreenPtr pScreenPriv = | |
531 | (VGAarbiterScreenPtr) dixLookupPrivate(&pScreen->devPrivates, | |
532 | VGAarbiterScreenKey); | |
533 | ||
534 | VGAGet(pScreen); | |
535 | (*pScreenPriv->FreeScreen) (pScrn); | |
536 | VGAPut(); | |
537 | } | |
538 | ||
539 | static Bool | |
540 | VGAarbiterCreateGC(GCPtr pGC) | |
541 | { | |
542 | ScreenPtr pScreen = pGC->pScreen; | |
543 | VGAarbiterGCPtr pGCPriv = | |
544 | (VGAarbiterGCPtr) dixLookupPrivate(&pGC->devPrivates, VGAarbiterGCKey); | |
545 | Bool ret; | |
546 | ||
547 | SCREEN_PROLOG(CreateGC); | |
548 | ret = (*pScreen->CreateGC) (pGC); | |
549 | GC_WRAP(pGC); | |
550 | SCREEN_EPILOG(CreateGC, VGAarbiterCreateGC); | |
551 | ||
552 | return ret; | |
553 | } | |
554 | ||
555 | /* GC funcs */ | |
556 | static void | |
557 | VGAarbiterValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDraw) | |
558 | { | |
559 | GC_UNWRAP(pGC); | |
560 | (*pGC->funcs->ValidateGC) (pGC, changes, pDraw); | |
561 | GC_WRAP(pGC); | |
562 | } | |
563 | ||
564 | static void | |
565 | VGAarbiterDestroyGC(GCPtr pGC) | |
566 | { | |
567 | GC_UNWRAP(pGC); | |
568 | (*pGC->funcs->DestroyGC) (pGC); | |
569 | GC_WRAP(pGC); | |
570 | } | |
571 | ||
572 | static void | |
573 | VGAarbiterChangeGC(GCPtr pGC, unsigned long mask) | |
574 | { | |
575 | GC_UNWRAP(pGC); | |
576 | (*pGC->funcs->ChangeGC) (pGC, mask); | |
577 | GC_WRAP(pGC); | |
578 | } | |
579 | ||
580 | static void | |
581 | VGAarbiterCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst) | |
582 | { | |
583 | GC_UNWRAP(pGCDst); | |
584 | (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst); | |
585 | GC_WRAP(pGCDst); | |
586 | } | |
587 | ||
588 | static void | |
589 | VGAarbiterChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects) | |
590 | { | |
591 | GC_UNWRAP(pGC); | |
592 | (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects); | |
593 | GC_WRAP(pGC); | |
594 | } | |
595 | ||
596 | static void | |
597 | VGAarbiterCopyClip(GCPtr pgcDst, GCPtr pgcSrc) | |
598 | { | |
599 | GC_UNWRAP(pgcDst); | |
600 | (*pgcDst->funcs->CopyClip) (pgcDst, pgcSrc); | |
601 | GC_WRAP(pgcDst); | |
602 | } | |
603 | ||
604 | static void | |
605 | VGAarbiterDestroyClip(GCPtr pGC) | |
606 | { | |
607 | GC_UNWRAP(pGC); | |
608 | (*pGC->funcs->DestroyClip) (pGC); | |
609 | GC_WRAP(pGC); | |
610 | } | |
611 | ||
612 | /* GC Ops */ | |
613 | static void | |
614 | VGAarbiterFillSpans(DrawablePtr pDraw, | |
615 | GC * pGC, | |
616 | int nInit, | |
617 | DDXPointPtr pptInit, int *pwidthInit, int fSorted) | |
618 | { | |
619 | ScreenPtr pScreen = pGC->pScreen; | |
620 | ||
621 | GC_UNWRAP(pGC); | |
622 | VGAGet(pScreen); | |
623 | (*pGC->ops->FillSpans) (pDraw, pGC, nInit, pptInit, pwidthInit, fSorted); | |
624 | VGAPut(); | |
625 | GC_WRAP(pGC); | |
626 | } | |
627 | ||
628 | static void | |
629 | VGAarbiterSetSpans(DrawablePtr pDraw, | |
630 | GCPtr pGC, | |
631 | char *pcharsrc, | |
632 | register DDXPointPtr ppt, | |
633 | int *pwidth, int nspans, int fSorted) | |
634 | { | |
635 | ScreenPtr pScreen = pGC->pScreen; | |
636 | ||
637 | GC_UNWRAP(pGC); | |
638 | VGAGet(pScreen); | |
639 | (*pGC->ops->SetSpans) (pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted); | |
640 | VGAPut(); | |
641 | GC_WRAP(pGC); | |
642 | } | |
643 | ||
644 | static void | |
645 | VGAarbiterPutImage(DrawablePtr pDraw, | |
646 | GCPtr pGC, | |
647 | int depth, | |
648 | int x, int y, int w, int h, | |
649 | int leftPad, int format, char *pImage) | |
650 | { | |
651 | ScreenPtr pScreen = pGC->pScreen; | |
652 | ||
653 | GC_UNWRAP(pGC); | |
654 | VGAGet(pScreen); | |
655 | (*pGC->ops->PutImage) (pDraw, pGC, depth, x, y, w, h, | |
656 | leftPad, format, pImage); | |
657 | VGAPut(); | |
658 | GC_WRAP(pGC); | |
659 | } | |
660 | ||
661 | static RegionPtr | |
662 | VGAarbiterCopyArea(DrawablePtr pSrc, | |
663 | DrawablePtr pDst, | |
664 | GC * pGC, | |
665 | int srcx, int srcy, | |
666 | int width, int height, int dstx, int dsty) | |
667 | { | |
668 | RegionPtr ret; | |
669 | ScreenPtr pScreen = pGC->pScreen; | |
670 | ||
671 | GC_UNWRAP(pGC); | |
672 | VGAGet(pScreen); | |
673 | ret = (*pGC->ops->CopyArea) (pSrc, pDst, | |
674 | pGC, srcx, srcy, width, height, dstx, dsty); | |
675 | VGAPut(); | |
676 | GC_WRAP(pGC); | |
677 | return ret; | |
678 | } | |
679 | ||
680 | static RegionPtr | |
681 | VGAarbiterCopyPlane(DrawablePtr pSrc, | |
682 | DrawablePtr pDst, | |
683 | GCPtr pGC, | |
684 | int srcx, int srcy, | |
685 | int width, int height, | |
686 | int dstx, int dsty, unsigned long bitPlane) | |
687 | { | |
688 | RegionPtr ret; | |
689 | ScreenPtr pScreen = pGC->pScreen; | |
690 | ||
691 | GC_UNWRAP(pGC); | |
692 | VGAGet(pScreen); | |
693 | ret = (*pGC->ops->CopyPlane) (pSrc, pDst, pGC, srcx, srcy, | |
694 | width, height, dstx, dsty, bitPlane); | |
695 | VGAPut(); | |
696 | GC_WRAP(pGC); | |
697 | return ret; | |
698 | } | |
699 | ||
700 | static void | |
701 | VGAarbiterPolyPoint(DrawablePtr pDraw, | |
702 | GCPtr pGC, int mode, int npt, xPoint * pptInit) | |
703 | { | |
704 | ScreenPtr pScreen = pGC->pScreen; | |
705 | ||
706 | GC_UNWRAP(pGC); | |
707 | VGAGet(pScreen); | |
708 | (*pGC->ops->PolyPoint) (pDraw, pGC, mode, npt, pptInit); | |
709 | VGAPut(); | |
710 | GC_WRAP(pGC); | |
711 | } | |
712 | ||
713 | static void | |
714 | VGAarbiterPolylines(DrawablePtr pDraw, | |
715 | GCPtr pGC, int mode, int npt, DDXPointPtr pptInit) | |
716 | { | |
717 | ScreenPtr pScreen = pGC->pScreen; | |
718 | ||
719 | GC_UNWRAP(pGC); | |
720 | VGAGet(pScreen); | |
721 | (*pGC->ops->Polylines) (pDraw, pGC, mode, npt, pptInit); | |
722 | VGAPut(); | |
723 | GC_WRAP(pGC); | |
724 | } | |
725 | ||
726 | static void | |
727 | VGAarbiterPolySegment(DrawablePtr pDraw, GCPtr pGC, int nseg, xSegment * pSeg) | |
728 | { | |
729 | ScreenPtr pScreen = pGC->pScreen; | |
730 | ||
731 | GC_UNWRAP(pGC); | |
732 | VGAGet(pScreen); | |
733 | (*pGC->ops->PolySegment) (pDraw, pGC, nseg, pSeg); | |
734 | VGAPut(); | |
735 | GC_WRAP(pGC); | |
736 | } | |
737 | ||
738 | static void | |
739 | VGAarbiterPolyRectangle(DrawablePtr pDraw, | |
740 | GCPtr pGC, int nRectsInit, xRectangle *pRectsInit) | |
741 | { | |
742 | ScreenPtr pScreen = pGC->pScreen; | |
743 | ||
744 | GC_UNWRAP(pGC); | |
745 | VGAGet(pScreen); | |
746 | (*pGC->ops->PolyRectangle) (pDraw, pGC, nRectsInit, pRectsInit); | |
747 | VGAPut(); | |
748 | GC_WRAP(pGC); | |
749 | } | |
750 | ||
751 | static void | |
752 | VGAarbiterPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs) | |
753 | { | |
754 | ScreenPtr pScreen = pGC->pScreen; | |
755 | ||
756 | GC_UNWRAP(pGC); | |
757 | VGAGet(pScreen); | |
758 | (*pGC->ops->PolyArc) (pDraw, pGC, narcs, parcs); | |
759 | VGAPut(); | |
760 | GC_WRAP(pGC); | |
761 | } | |
762 | ||
763 | static void | |
764 | VGAarbiterFillPolygon(DrawablePtr pDraw, | |
765 | GCPtr pGC, | |
766 | int shape, int mode, int count, DDXPointPtr ptsIn) | |
767 | { | |
768 | ScreenPtr pScreen = pGC->pScreen; | |
769 | ||
770 | GC_UNWRAP(pGC); | |
771 | VGAGet(pScreen); | |
772 | (*pGC->ops->FillPolygon) (pDraw, pGC, shape, mode, count, ptsIn); | |
773 | VGAPut(); | |
774 | GC_WRAP(pGC); | |
775 | } | |
776 | ||
777 | static void | |
778 | VGAarbiterPolyFillRect(DrawablePtr pDraw, | |
779 | GCPtr pGC, int nrectFill, xRectangle *prectInit) | |
780 | { | |
781 | ScreenPtr pScreen = pGC->pScreen; | |
782 | ||
783 | GC_UNWRAP(pGC); | |
784 | VGAGet(pScreen); | |
785 | (*pGC->ops->PolyFillRect) (pDraw, pGC, nrectFill, prectInit); | |
786 | VGAPut(); | |
787 | GC_WRAP(pGC); | |
788 | } | |
789 | ||
790 | static void | |
791 | VGAarbiterPolyFillArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs) | |
792 | { | |
793 | ScreenPtr pScreen = pGC->pScreen; | |
794 | ||
795 | GC_UNWRAP(pGC); | |
796 | VGAGet(pScreen); | |
797 | (*pGC->ops->PolyFillArc) (pDraw, pGC, narcs, parcs); | |
798 | VGAPut(); | |
799 | GC_WRAP(pGC); | |
800 | } | |
801 | ||
802 | static int | |
803 | VGAarbiterPolyText8(DrawablePtr pDraw, | |
804 | GCPtr pGC, int x, int y, int count, char *chars) | |
805 | { | |
806 | int ret; | |
807 | ScreenPtr pScreen = pGC->pScreen; | |
808 | ||
809 | GC_UNWRAP(pGC); | |
810 | VGAGet(pScreen); | |
811 | ret = (*pGC->ops->PolyText8) (pDraw, pGC, x, y, count, chars); | |
812 | VGAPut(); | |
813 | GC_WRAP(pGC); | |
814 | return ret; | |
815 | } | |
816 | ||
817 | static int | |
818 | VGAarbiterPolyText16(DrawablePtr pDraw, | |
819 | GCPtr pGC, int x, int y, int count, unsigned short *chars) | |
820 | { | |
821 | int ret; | |
822 | ScreenPtr pScreen = pGC->pScreen; | |
823 | ||
824 | GC_UNWRAP(pGC); | |
825 | VGAGet(pScreen); | |
826 | ret = (*pGC->ops->PolyText16) (pDraw, pGC, x, y, count, chars); | |
827 | VGAPut(); | |
828 | GC_WRAP(pGC); | |
829 | return ret; | |
830 | } | |
831 | ||
832 | static void | |
833 | VGAarbiterImageText8(DrawablePtr pDraw, | |
834 | GCPtr pGC, int x, int y, int count, char *chars) | |
835 | { | |
836 | ScreenPtr pScreen = pGC->pScreen; | |
837 | ||
838 | GC_UNWRAP(pGC); | |
839 | VGAGet(pScreen); | |
840 | (*pGC->ops->ImageText8) (pDraw, pGC, x, y, count, chars); | |
841 | VGAPut(); | |
842 | GC_WRAP(pGC); | |
843 | } | |
844 | ||
845 | static void | |
846 | VGAarbiterImageText16(DrawablePtr pDraw, | |
847 | GCPtr pGC, int x, int y, int count, unsigned short *chars) | |
848 | { | |
849 | ScreenPtr pScreen = pGC->pScreen; | |
850 | ||
851 | GC_UNWRAP(pGC); | |
852 | VGAGet(pScreen); | |
853 | (*pGC->ops->ImageText16) (pDraw, pGC, x, y, count, chars); | |
854 | VGAPut(); | |
855 | GC_WRAP(pGC); | |
856 | } | |
857 | ||
858 | static void | |
859 | VGAarbiterImageGlyphBlt(DrawablePtr pDraw, | |
860 | GCPtr pGC, | |
861 | int xInit, int yInit, | |
862 | unsigned int nglyph, | |
863 | CharInfoPtr * ppci, pointer pglyphBase) | |
864 | { | |
865 | ScreenPtr pScreen = pGC->pScreen; | |
866 | ||
867 | GC_UNWRAP(pGC); | |
868 | VGAGet(pScreen); | |
869 | (*pGC->ops->ImageGlyphBlt) (pDraw, pGC, xInit, yInit, | |
870 | nglyph, ppci, pglyphBase); | |
871 | VGAPut(); | |
872 | GC_WRAP(pGC); | |
873 | } | |
874 | ||
875 | static void | |
876 | VGAarbiterPolyGlyphBlt(DrawablePtr pDraw, | |
877 | GCPtr pGC, | |
878 | int xInit, int yInit, | |
879 | unsigned int nglyph, | |
880 | CharInfoPtr * ppci, pointer pglyphBase) | |
881 | { | |
882 | ScreenPtr pScreen = pGC->pScreen; | |
883 | ||
884 | GC_UNWRAP(pGC); | |
885 | VGAGet(pScreen); | |
886 | (*pGC->ops->PolyGlyphBlt) (pDraw, pGC, xInit, yInit, | |
887 | nglyph, ppci, pglyphBase); | |
888 | VGAPut(); | |
889 | GC_WRAP(pGC); | |
890 | } | |
891 | ||
892 | static void | |
893 | VGAarbiterPushPixels(GCPtr pGC, | |
894 | PixmapPtr pBitMap, | |
895 | DrawablePtr pDraw, int dx, int dy, int xOrg, int yOrg) | |
896 | { | |
897 | ScreenPtr pScreen = pGC->pScreen; | |
898 | ||
899 | GC_UNWRAP(pGC); | |
900 | VGAGet(pScreen); | |
901 | (*pGC->ops->PushPixels) (pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg); | |
902 | VGAPut(); | |
903 | GC_WRAP(pGC); | |
904 | } | |
905 | ||
906 | /* miSpriteFuncs */ | |
907 | static Bool | |
908 | VGAarbiterSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, | |
909 | CursorPtr pCur) | |
910 | { | |
911 | Bool val; | |
912 | ||
913 | SPRITE_PROLOG; | |
914 | VGAGet(pScreen); | |
915 | val = PointPriv->spriteFuncs->RealizeCursor(pDev, pScreen, pCur); | |
916 | VGAPut(); | |
917 | SPRITE_EPILOG; | |
918 | return val; | |
919 | } | |
920 | ||
921 | static Bool | |
922 | VGAarbiterSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, | |
923 | CursorPtr pCur) | |
924 | { | |
925 | Bool val; | |
926 | ||
927 | SPRITE_PROLOG; | |
928 | VGAGet(pScreen); | |
929 | val = PointPriv->spriteFuncs->UnrealizeCursor(pDev, pScreen, pCur); | |
930 | VGAPut(); | |
931 | SPRITE_EPILOG; | |
932 | return val; | |
933 | } | |
934 | ||
935 | static void | |
936 | VGAarbiterSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCur, | |
937 | int x, int y) | |
938 | { | |
939 | SPRITE_PROLOG; | |
940 | VGAGet(pScreen); | |
941 | PointPriv->spriteFuncs->SetCursor(pDev, pScreen, pCur, x, y); | |
942 | VGAPut(); | |
943 | SPRITE_EPILOG; | |
944 | } | |
945 | ||
946 | static void | |
947 | VGAarbiterSpriteMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) | |
948 | { | |
949 | SPRITE_PROLOG; | |
950 | VGAGet(pScreen); | |
951 | PointPriv->spriteFuncs->MoveCursor(pDev, pScreen, x, y); | |
952 | VGAPut(); | |
953 | SPRITE_EPILOG; | |
954 | } | |
955 | ||
956 | static Bool | |
957 | VGAarbiterDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen) | |
958 | { | |
959 | Bool val; | |
960 | ||
961 | SPRITE_PROLOG; | |
962 | VGAGet(pScreen); | |
963 | val = PointPriv->spriteFuncs->DeviceCursorInitialize(pDev, pScreen); | |
964 | VGAPut(); | |
965 | SPRITE_EPILOG; | |
966 | return val; | |
967 | } | |
968 | ||
969 | static void | |
970 | VGAarbiterDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen) | |
971 | { | |
972 | SPRITE_PROLOG; | |
973 | VGAGet(pScreen); | |
974 | PointPriv->spriteFuncs->DeviceCursorCleanup(pDev, pScreen); | |
975 | VGAPut(); | |
976 | SPRITE_EPILOG; | |
977 | } | |
978 | ||
979 | static void | |
980 | VGAarbiterComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, | |
981 | PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask, | |
982 | INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, | |
983 | CARD16 height) | |
984 | { | |
985 | ScreenPtr pScreen = pDst->pDrawable->pScreen; | |
986 | PictureScreenPtr ps = GetPictureScreen(pScreen); | |
987 | ||
988 | PICTURE_PROLOGUE(Composite); | |
989 | ||
990 | VGAGet(pScreen); | |
991 | (*ps->Composite) (op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst, | |
992 | yDst, width, height); | |
993 | VGAPut(); | |
994 | PICTURE_EPILOGUE(Composite, VGAarbiterComposite); | |
995 | } | |
996 | ||
997 | static void | |
998 | VGAarbiterGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, | |
999 | PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc, int nlist, | |
1000 | GlyphListPtr list, GlyphPtr * glyphs) | |
1001 | { | |
1002 | ScreenPtr pScreen = pDst->pDrawable->pScreen; | |
1003 | PictureScreenPtr ps = GetPictureScreen(pScreen); | |
1004 | ||
1005 | PICTURE_PROLOGUE(Glyphs); | |
1006 | ||
1007 | VGAGet(pScreen); | |
1008 | (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs); | |
1009 | VGAPut(); | |
1010 | PICTURE_EPILOGUE(Glyphs, VGAarbiterGlyphs); | |
1011 | } | |
1012 | ||
1013 | static void | |
1014 | VGAarbiterCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor * color, | |
1015 | int nRect, xRectangle *rects) | |
1016 | { | |
1017 | ScreenPtr pScreen = pDst->pDrawable->pScreen; | |
1018 | PictureScreenPtr ps = GetPictureScreen(pScreen); | |
1019 | ||
1020 | PICTURE_PROLOGUE(CompositeRects); | |
1021 | ||
1022 | VGAGet(pScreen); | |
1023 | (*ps->CompositeRects) (op, pDst, color, nRect, rects); | |
1024 | VGAPut(); | |
1025 | PICTURE_EPILOGUE(CompositeRects, VGAarbiterCompositeRects); | |
1026 | } |