1 From 5216cb0f14414b5451f58df48a36c1c62c035276 Mon Sep 17 00:00:00 2001
2 From: Otavio Salvador <otavio@ossystems.com.br>
3 Date: Sat, 29 Dec 2012 18:02:11 -0200
4 Subject: [PATCH] Make video API forward and backward compatible
6 This updates the video API in a forward and backward compatible way
7 using the "compat-api.h" as used in Xorg maintained drivers.
9 Upstream-Status: Pending
11 Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
13 src/compat-api.h | 106 +++++++++++++++++++++++++++++++++++++++++++++++
14 src/imx_display.c | 22 +++++-----
15 src/imx_display.h | 8 ++--
16 src/imx_driver.c | 60 ++++++++++++++-------------
17 src/imx_exa_offscreen.c | 12 +++---
18 src/imx_exa_z160.c | 53 ++++++++++++------------
19 src/imx_xv_ipu.c | 4 +-
20 7 files changed, 188 insertions(+), 77 deletions(-)
21 create mode 100644 src/compat-api.h
23 diff --git a/src/compat-api.h b/src/compat-api.h
25 index 0000000..73ac8a2
27 +++ b/src/compat-api.h
30 + * Copyright 2012 Red Hat, Inc.
32 + * Permission is hereby granted, free of charge, to any person obtaining a
33 + * copy of this software and associated documentation files (the "Software"),
34 + * to deal in the Software without restriction, including without limitation
35 + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
36 + * and/or sell copies of the Software, and to permit persons to whom the
37 + * Software is furnished to do so, subject to the following conditions:
39 + * The above copyright notice and this permission notice (including the next
40 + * paragraph) shall be included in all copies or substantial portions of the
43 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
46 + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
47 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
48 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
49 + * DEALINGS IN THE SOFTWARE.
51 + * Author: Dave Airlie <airlied@redhat.com>
54 +/* this file provides API compat between server post 1.13 and pre it,
55 + it should be reused inside as many drivers as possible */
59 +#ifndef GLYPH_HAS_GLYPH_PICTURE_ACCESSOR
60 +#define GetGlyphPicture(g, s) GlyphPicture((g))[(s)->myNum]
61 +#define SetGlyphPicture(g, s, p) GlyphPicture((g))[(s)->myNum] = p
64 +#ifndef XF86_HAS_SCRN_CONV
65 +#define xf86ScreenToScrn(s) xf86Screens[(s)->myNum]
66 +#define xf86ScrnToScreen(s) screenInfo.screens[(s)->scrnIndex]
69 +#ifndef XF86_SCRN_INTERFACE
71 +#define SCRN_ARG_TYPE int
72 +#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = xf86Screens[(arg1)]
74 +#define SCREEN_ARG_TYPE int
75 +#define SCREEN_PTR(arg1) ScreenPtr pScreen = screenInfo.screens[(arg1)]
77 +#define SCREEN_INIT_ARGS_DECL int index, ScreenPtr pScreen, int argc, char **argv
79 +#define BLOCKHANDLER_ARGS_DECL int arg, pointer blockData, pointer pTimeout, pointer pReadmask
80 +#define BLOCKHANDLER_ARGS arg, blockData, pTimeout, pReadmask
82 +#define CLOSE_SCREEN_ARGS_DECL int scrnIndex, ScreenPtr pScreen
83 +#define CLOSE_SCREEN_ARGS scrnIndex, pScreen
84 +#define CLOSE_SCREEN_DECL_ScrnInfoPtr ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
86 +#define FBDEVHWADJUSTFRAME_ARGS(x, y) scrnIndex, (x), (y), 0
88 +#define ADJUST_FRAME_ARGS_DECL int arg, int x, int y, int flags
90 +#define SWITCH_MODE_ARGS_DECL int arg, DisplayModePtr mode, int flags
92 +#define FREE_SCREEN_ARGS_DECL int arg, int flags
93 +#define FREE_SCREEN_ARGS(x) (x)->scrnIndex, 0
95 +#define VT_FUNC_ARGS_DECL int arg, int flags
96 +#define VT_FUNC_ARGS(flags) pScrn->scrnIndex, (flags)
98 +#define ENABLE_DISABLE_FB_ACCESS_ARGS(pScrn, b) pScrn->scrnIndex, b
100 +#define XF86_ENABLEDISABLEFB_ARG(x) ((x)->scrnIndex)
102 +#define SCRN_ARG_TYPE ScrnInfoPtr
103 +#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = (arg1)
105 +#define SCREEN_ARG_TYPE ScreenPtr
106 +#define SCREEN_PTR(arg1) ScreenPtr pScreen = (arg1)
108 +#define SCREEN_INIT_ARGS_DECL ScreenPtr pScreen, int argc, char **argv
110 +#define BLOCKHANDLER_ARGS_DECL ScreenPtr arg, pointer pTimeout, pointer pReadmask
111 +#define BLOCKHANDLER_ARGS arg, pTimeout, pReadmask
113 +#define CLOSE_SCREEN_ARGS_DECL ScreenPtr pScreen
114 +#define CLOSE_SCREEN_ARGS pScreen
115 +#define CLOSE_SCREEN_DECL_ScrnInfoPtr ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
117 +#define FBDEVHWADJUSTFRAME_ARGS(x, y) pScrn, (x), (y)
119 +#define ADJUST_FRAME_ARGS_DECL ScrnInfoPtr arg, int x, int y
120 +#define SWITCH_MODE_ARGS_DECL ScrnInfoPtr arg, DisplayModePtr mode
122 +#define FREE_SCREEN_ARGS_DECL ScrnInfoPtr arg
123 +#define FREE_SCREEN_ARGS(x) (x)
125 +#define VT_FUNC_ARGS_DECL ScrnInfoPtr arg
126 +#define VT_FUNC_ARGS(flags) pScrn
128 +#define ENABLE_DISABLE_FB_ACCESS_ARGS(pScrn, b) pScrn, b
130 +#define XF86_ENABLEDISABLEFB_ARG(x) (x)
135 diff --git a/src/imx_display.c b/src/imx_display.c
136 index fcb8195..e2dc36a 100644
137 --- a/src/imx_display.c
138 +++ b/src/imx_display.c
141 #include "imx_display.h"
143 +#include "compat-api.h"
145 #include <X11/Xatom.h>
147 #if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,7,6,0,0)
148 @@ -1373,19 +1375,19 @@ imxDisplayPreInit(ScrnInfoPtr pScrn)
150 imxDisplayStartScreenInit(int scrnIndex, ScreenPtr pScreen)
152 - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
153 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
154 ImxPtr fPtr = IMXPTR(pScrn);
156 if (!xf86SetDesiredModes(pScrn)) {
158 - xf86DrvMsg(scrnIndex, X_ERROR, "mode initialization failed\n");
159 + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "mode initialization failed\n");
164 if (!fbdevHWModeInit(pScrn, pScrn->currentMode)) {
166 - xf86DrvMsg(scrnIndex, X_ERROR, "mode initialization failed\n");
167 + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "mode initialization failed\n");
170 pScrn->displayWidth =
171 @@ -1463,29 +1465,29 @@ imxDisplayFinishScreenInit(int scrnIndex, ScreenPtr pScreen)
172 /* -------------------------------------------------------------------- */
175 -imxDisplaySwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
176 +imxDisplaySwitchMode(SWITCH_MODE_ARGS_DECL)
178 - ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
179 + SCRN_INFO_PTR(arg);
181 return xf86SetSingleMode(pScrn, mode, RR_Rotate_0);
185 -imxDisplayAdjustFrame(int scrnIndex, int x, int y, int flags)
186 +imxDisplayAdjustFrame(ADJUST_FRAME_ARGS_DECL)
188 -// fbdevHWAdjustFrame(scrnIndex, x, y, flags);
189 +// fbdevHWAdjustFrame(pScrn->scrnIndex, x, y, flags);
193 -imxDisplayEnterVT(int scrnIndex, int flags)
194 +imxDisplayEnterVT(VT_FUNC_ARGS_DECL)
196 - ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
197 + SCRN_INFO_PTR(arg);
199 return xf86SetDesiredModes(pScrn);
203 -imxDisplayLeaveVT(int scrnIndex, int flags)
204 +imxDisplayLeaveVT(VT_FUNC_ARGS_DECL)
208 diff --git a/src/imx_display.h b/src/imx_display.h
209 index 4a5d5aa..3a3d43a 100644
210 --- a/src/imx_display.h
211 +++ b/src/imx_display.h
212 @@ -59,16 +59,16 @@ imxDisplayValidMode(int scrnIndex, DisplayModePtr mode,
213 Bool verbose, int flags);
216 -imxDisplaySwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
217 +imxDisplaySwitchMode(SWITCH_MODE_ARGS_DECL);
220 -imxDisplayAdjustFrame(int scrnIndex, int x, int y, int flags);
221 +imxDisplayAdjustFrame(ADJUST_FRAME_ARGS_DECL);
224 -imxDisplayEnterVT(int scrnIndex, int flags);
225 +imxDisplayEnterVT(VT_FUNC_ARGS_DECL);
228 -imxDisplayLeaveVT(int scrnIndex, int flags);
229 +imxDisplayLeaveVT(VT_FUNC_ARGS_DECL);
232 imxDisplayChangeFrameBufferRotateEPDC(int scrnIndex, int fbRotate);
233 diff --git a/src/imx_driver.c b/src/imx_driver.c
234 index 178e36e..f4b3e38 100644
235 --- a/src/imx_driver.c
236 +++ b/src/imx_driver.c
241 +#include "compat-api.h"
243 #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 6
244 #include "xf86Resources.h"
246 @@ -435,17 +437,17 @@ errorPreInit:
250 -imxFreeScreen(int scrnIndex, int flags)
251 +imxFreeScreen(FREE_SCREEN_ARGS_DECL)
253 - ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
254 + SCRN_INFO_PTR(arg);
260 -imxCloseScreen(int scrnIndex, ScreenPtr pScreen)
261 +imxCloseScreen(CLOSE_SCREEN_ARGS_DECL)
263 - ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
264 + CLOSE_SCREEN_DECL_ScrnInfoPtr;
265 ImxPtr fPtr = IMXPTR(pScrn);
267 fbdevHWRestore(pScrn);
268 @@ -453,7 +455,7 @@ imxCloseScreen(int scrnIndex, ScreenPtr pScreen)
269 pScrn->vtSema = FALSE;
271 pScreen->CloseScreen = fPtr->saveCloseScreen;
272 - return (*pScreen->CloseScreen)(scrnIndex, pScreen);
273 + return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS);
277 @@ -488,9 +490,9 @@ LCM(a, b)
281 -imxScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
282 +imxScreenInit(SCREEN_INIT_ARGS_DECL)
284 - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
285 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
286 ImxPtr fPtr = IMXPTR(pScrn);
288 int init_picture = 0;
289 @@ -514,7 +516,7 @@ imxScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
290 /* Map frame buffer memory */
291 fPtr->fbMemoryBase = fbdevHWMapVidmem(pScrn);
292 if (NULL == fPtr->fbMemoryBase) {
293 - xf86DrvMsg(scrnIndex,X_ERROR,"mapping of video memory"
294 + xf86DrvMsg(pScrn->scrnIndex,X_ERROR,"mapping of video memory"
298 @@ -558,7 +560,7 @@ imxScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
299 const int fbOffsetScreen2 =
300 IMX_ALIGN(fbMaxScreenSize, fbMaxAlignOffset);
301 fPtr->fbMemoryScreenReserve = fbMaxScreenSize;
302 - xf86DrvMsg(scrnIndex, X_INFO,
303 + xf86DrvMsg(pScrn->scrnIndex, X_INFO,
304 "reserve %d bytes of frame buffer for screen\n",
305 fPtr->fbMemoryScreenReserve);
306 fPtr->fbMemoryStart2 = NULL;
307 @@ -568,12 +570,12 @@ imxScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
309 fPtr->fbMemoryScreenReserve += fbOffsetScreen2;
311 - xf86DrvMsg(scrnIndex, X_INFO,
312 + xf86DrvMsg(pScrn->scrnIndex, X_INFO,
313 "reserve same number of bytes for XRandR rotated screen at offset %d\n",
317 - if (!imxDisplayStartScreenInit(scrnIndex, pScreen)) {
318 + if (!imxDisplayStartScreenInit(pScrn->scrnIndex, pScreen)) {
322 @@ -582,7 +584,7 @@ imxScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
323 miClearVisualTypes();
324 if (pScrn->bitsPerPixel > 8) {
325 if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, TrueColor)) {
326 - xf86DrvMsg(scrnIndex,X_ERROR,"visual type setup failed"
327 + xf86DrvMsg(pScrn->scrnIndex,X_ERROR,"visual type setup failed"
328 " for %d bits per pixel [1]\n",
329 pScrn->bitsPerPixel);
331 @@ -591,14 +593,14 @@ imxScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
332 if (!miSetVisualTypes(pScrn->depth,
333 miGetDefaultVisualMask(pScrn->depth),
334 pScrn->rgbBits, pScrn->defaultVisual)) {
335 - xf86DrvMsg(scrnIndex,X_ERROR,"visual type setup failed"
336 + xf86DrvMsg(pScrn->scrnIndex,X_ERROR,"visual type setup failed"
337 " for %d bits per pixel [2]\n",
338 pScrn->bitsPerPixel);
342 if (!miSetPixmapDepths()) {
343 - xf86DrvMsg(scrnIndex,X_ERROR,"pixmap depth setup failed\n");
344 + xf86DrvMsg(pScrn->scrnIndex,X_ERROR,"pixmap depth setup failed\n");
348 @@ -607,10 +609,10 @@ imxScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
349 has a padding which is independent from the depth (controlfb) */
350 pScrn->displayWidth = fbdevHWGetLineLength(pScrn) /
351 (pScrn->bitsPerPixel / 8);
352 - xf86DrvMsg(scrnIndex, X_INFO, "displayWidth = %d\n", pScrn->displayWidth);
353 + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "displayWidth = %d\n", pScrn->displayWidth);
355 if (pScrn->displayWidth != pScrn->virtualX) {
356 - xf86DrvMsg(scrnIndex, X_INFO,
357 + xf86DrvMsg(pScrn->scrnIndex, X_INFO,
358 "Pitch updated to %d after ModeInit\n",
359 pScrn->displayWidth);
361 @@ -633,7 +635,7 @@ imxScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
365 - xf86DrvMsg(scrnIndex, X_ERROR,
366 + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
367 "internal error: invalid number of bits per"
368 " pixel (%d) encountered in"
369 " imxScreenInit()\n", pScrn->bitsPerPixel);
370 @@ -644,7 +646,7 @@ imxScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
371 case FBDEVHW_INTERLEAVED_PLANES:
372 /* This should never happen ...
373 * we should check for this much much earlier ... */
374 - xf86DrvMsg(scrnIndex, X_ERROR,
375 + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
376 "internal error: interleaved planes are not yet "
377 "supported by the imx driver\n");
379 @@ -652,20 +654,20 @@ imxScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
381 /* This should never happen ...
382 * we should check for this much much earlier ... */
383 - xf86DrvMsg(scrnIndex, X_ERROR,
384 + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
385 "internal error: text mode is not supported by the "
389 case FBDEVHW_VGA_PLANES:
390 /* Not supported yet */
391 - xf86DrvMsg(scrnIndex, X_ERROR,
392 + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
393 "internal error: EGA/VGA Planes are not yet "
394 "supported by the imx driver\n");
398 - xf86DrvMsg(scrnIndex, X_ERROR,
399 + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
400 "internal error: unrecognised hardware type (%d) "
401 "encountered in imxScreenInit()\n", type);
403 @@ -699,7 +701,7 @@ imxScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
404 /* INIT ACCELERATION BEFORE INIT FOR BACKING STORE & SOFTWARE CURSOR */
405 if (fPtr->useAccel) {
407 - if (!imxExaZ160Setup(scrnIndex, pScreen)) {
408 + if (!imxExaZ160Setup(pScrn->scrnIndex, pScreen)) {
410 fPtr->useAccel = FALSE;
412 @@ -731,29 +733,29 @@ imxScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
413 /* XXX It would be simpler to use miCreateDefColormap() in all cases. */
414 case FBDEVHW_PACKED_PIXELS:
415 if (!miCreateDefColormap(pScreen)) {
416 - xf86DrvMsg(scrnIndex, X_ERROR,
417 + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
418 "internal error: miCreateDefColormap failed "
419 "in imxScreenInit()\n");
423 case FBDEVHW_INTERLEAVED_PLANES:
424 - xf86DrvMsg(scrnIndex, X_ERROR,
425 + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
426 "internal error: interleaved planes are not yet "
427 "supported by the imx driver\n");
430 - xf86DrvMsg(scrnIndex, X_ERROR,
431 + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
432 "internal error: text mode is not supported by "
435 case FBDEVHW_VGA_PLANES:
436 - xf86DrvMsg(scrnIndex, X_ERROR,
437 + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
438 "internal error: EGA/VGA planes are not yet "
439 "supported by the imx driver\n");
442 - xf86DrvMsg(scrnIndex, X_ERROR,
443 + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
444 "internal error: unrecognised imx hardware type "
445 "(%d) encountered in imxScreenInit()\n", type);
447 @@ -782,7 +784,7 @@ imxScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
451 - if (!imxDisplayFinishScreenInit(scrnIndex, pScreen)) {
452 + if (!imxDisplayFinishScreenInit(pScrn->scrnIndex, pScreen)) {
456 @@ -810,7 +812,7 @@ IMXGetPixmapProperties(
459 /* Access screen associated with this pixmap. */
460 - ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
461 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmap->drawable.pScreen);
463 /* Check if the screen associated with this pixmap has IMX driver. */
464 if (0 != strcmp(IMX_DRIVER_NAME, pScrn->driverName)) {
465 diff --git a/src/imx_exa_offscreen.c b/src/imx_exa_offscreen.c
466 index 3a5c24d..0fbe2fc 100644
467 --- a/src/imx_exa_offscreen.c
468 +++ b/src/imx_exa_offscreen.c
469 @@ -79,7 +79,7 @@ static void
470 imxExaOffscreenValidate (ScreenPtr pScreen)
472 /* Access the driver specific data. */
473 - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
474 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
475 ImxPtr imxPtr = IMXPTR(pScrn);
476 ImxExaPtr imxExaPtr = IMXEXAPTR(imxPtr);
477 ExaOffscreenArea *prev = 0, *area;
478 @@ -135,7 +135,7 @@ imxExaOffscreenMerge (ImxExaPtr imxExaPtr, ExaOffscreenArea *area)
480 imxExaOffscreenFree (ScreenPtr pScreen, ExaOffscreenArea *area)
482 - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
483 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
484 ImxPtr imxPtr = IMXPTR(pScrn);
485 ImxExaPtr imxExaPtr = IMXEXAPTR(imxPtr);
486 ExaOffscreenArea *next = area->next;
487 @@ -281,7 +281,7 @@ imxExaOffscreenAlloc (ScreenPtr pScreen, int size, int align,
490 ExaOffscreenArea *area;
491 - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
492 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
493 ImxPtr imxPtr = IMXPTR(pScrn);
494 ImxExaPtr imxExaPtr = IMXEXAPTR(imxPtr);
495 int real_size = 0, largest_avail = 0;
496 @@ -418,7 +418,7 @@ imxExaOffscreenSwapIn (ScreenPtr pScreen)
498 imxExaOffscreenInit (ScreenPtr pScreen)
500 - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
501 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
502 ImxPtr imxPtr = IMXPTR(pScrn);
503 ImxExaPtr imxExaPtr = IMXEXAPTR(imxPtr);
504 ExaOffscreenArea *area;
505 @@ -453,7 +453,7 @@ imxExaOffscreenInit (ScreenPtr pScreen)
507 imxExaOffscreenFini (ScreenPtr pScreen)
509 - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
510 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
511 ImxPtr imxPtr = IMXPTR(pScrn);
512 ImxExaPtr imxExaPtr = IMXEXAPTR(imxPtr);
513 ExaOffscreenArea *area;
514 @@ -472,7 +472,7 @@ imxExaOffscreenFini (ScreenPtr pScreen)
516 imxExaOffscreenSwapOut (ScreenPtr pScreen)
518 - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
519 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
520 ImxPtr imxPtr = IMXPTR(pScrn);
521 ImxExaPtr imxExaPtr = IMXEXAPTR(imxPtr);
523 diff --git a/src/imx_exa_z160.c b/src/imx_exa_z160.c
524 index fb718e0..3d0bc96 100644
525 --- a/src/imx_exa_z160.c
526 +++ b/src/imx_exa_z160.c
531 +#include "compat-api.h"
533 /* Set if handles pixmap allocation and migration, i.e, EXA_HANDLES_PIXMAPS */
534 #define IMX_EXA_ENABLE_HANDLES_PIXMAPS \
535 @@ -299,7 +300,7 @@ imxExaZ160GetPixmapAddress(PixmapPtr pPixmap)
536 return fPixmapPtr->ptr;
538 /* Access screen associated with this pixmap. */
539 - ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
540 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmap->drawable.pScreen);
542 /* Access driver specific data */
543 ImxPtr imxPtr = IMXPTR(pScrn);
544 @@ -344,7 +345,7 @@ imxExaZ160GetPixmapProperties(
547 /* Access screen associated with this pixmap. */
548 - ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
549 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmap->drawable.pScreen);
551 /* Make sure pixmap is in framebuffer */
552 if (!exaDrawableIsOffscreen(&(pPixmap->drawable))) {
553 @@ -856,7 +857,7 @@ imxExaZ160SyncIfBusyPixmap(PixmapPtr pPixmap)
555 /* Access screen associated with this pixmap. */
556 ScreenPtr pScreen = pPixmap->drawable.pScreen;
557 - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
558 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
560 /* Access driver specific data for screen. */
561 ImxPtr imxPtr = IMXPTR(pScrn);
562 @@ -924,7 +925,7 @@ imxExaZ160CreatePixmap2(ScreenPtr pScreen, int width, int height,
565 /* Access the driver specific data. */
566 - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
567 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
568 ImxPtr imxPtr = IMXPTR(pScrn);
569 ImxExaZ160Ptr fPtr = IMXEXAZ160PTR(imxPtr);
571 @@ -1028,7 +1029,7 @@ imxExaZ160DestroyPixmap(ScreenPtr pScreen, void *driverPriv)
572 ImxExaPixmapPtr fPixmapPtr = (ImxExaPixmapPtr)driverPriv;
574 /* Access the driver specific data. */
575 - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
576 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
577 ImxPtr imxPtr = IMXPTR(pScrn);
578 ImxExaZ160Ptr fPtr = IMXEXAZ160PTR(imxPtr);
580 @@ -1068,7 +1069,7 @@ imxExaZ160ModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
583 /* Access screen associated with this pixmap */
584 - ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
585 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmap->drawable.pScreen);
587 /* Access driver specific data */
588 ImxPtr imxPtr = IMXPTR(pScrn);
589 @@ -1194,7 +1195,7 @@ imxExaZ160TrackBusyPixmap(ImxExaZ160Ptr fPtr, PixmapPtr pPixmap)
591 imxExaZ160WaitMarker(ScreenPtr pScreen, int marker)
593 - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
594 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
596 /* Access driver specific data associated with the screen. */
597 ImxPtr imxPtr = IMXPTR(pScrn);
598 @@ -1249,7 +1250,7 @@ imxExaZ160PrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg)
601 /* Access screen associated with this pixmap */
602 - ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
603 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmap->drawable.pScreen);
605 /* Access driver specific data */
606 ImxPtr imxPtr = IMXPTR(pScrn);
607 @@ -1352,7 +1353,7 @@ static void
608 imxExaZ160Solid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2)
610 /* Access screen associated with this pixmap */
611 - ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
612 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmap->drawable.pScreen);
614 /* Access driver specific data */
615 ImxPtr imxPtr = IMXPTR(pScrn);
616 @@ -1423,7 +1424,7 @@ static void
617 imxExaZ160DoneSolid(PixmapPtr pPixmap)
619 /* Access screen associated with this pixmap */
620 - ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
621 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmap->drawable.pScreen);
623 /* Access driver specific data */
624 ImxPtr imxPtr = IMXPTR(pScrn);
625 @@ -1485,7 +1486,7 @@ imxExaZ160PrepareCopy(
628 /* Access the screen associated with this pixmap. */
629 - ScrnInfoPtr pScrn = xf86Screens[pPixmapDst->drawable.pScreen->myNum];
630 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmapDst->drawable.pScreen);
632 /* Access driver specific data */
633 ImxPtr imxPtr = IMXPTR(pScrn);
634 @@ -1599,7 +1600,7 @@ static void
635 imxExaZ160Copy(PixmapPtr pPixmapDst, int srcX, int srcY, int dstX, int dstY, int width, int height)
637 /* Access screen associated with dst pixmap */
638 - ScrnInfoPtr pScrn = xf86Screens[pPixmapDst->drawable.pScreen->myNum];
639 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmapDst->drawable.pScreen);
641 /* Access driver specific data */
642 ImxPtr imxPtr = IMXPTR(pScrn);
643 @@ -1661,7 +1662,7 @@ static void
644 imxExaZ160DoneCopy(PixmapPtr pPixmapDst)
646 /* Access screen associated with this pixmap */
647 - ScrnInfoPtr pScrn = xf86Screens[pPixmapDst->drawable.pScreen->myNum];
648 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmapDst->drawable.pScreen);
650 /* Access driver specific data */
651 ImxPtr imxPtr = IMXPTR(pScrn);
652 @@ -1770,7 +1771,7 @@ imxExaZ160CheckComposite(int op, PicturePtr pPictureSrc, PicturePtr pPictureMask
655 /* Access screen associated with dst pixmap (same screen as for src pixmap). */
656 - ScrnInfoPtr pScrn = xf86Screens[pPixmapDst->drawable.pScreen->myNum];
657 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmapDst->drawable.pScreen);
659 /* Check the number of entities, and fail if it isn't one. */
660 if (pScrn->numEntities != 1) {
661 @@ -1987,7 +1988,7 @@ imxExaZ160PrepareComposite(
663 /* Access screen associated with dst pixmap. */
664 /* Should be same screen as for src pixmap. */
665 - ScrnInfoPtr pScrn = xf86Screens[pPixmapDst->drawable.pScreen->myNum];
666 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmapDst->drawable.pScreen);
668 /* NOTE - many preconditions already verified in CheckComposite. */
670 @@ -2196,7 +2197,7 @@ imxExaZ160Composite(
673 /* Access screen associated with dst pixmap */
674 - ScrnInfoPtr pScrn = xf86Screens[pPixmapDst->drawable.pScreen->myNum];
675 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmapDst->drawable.pScreen);
677 /* Access driver specific data */
678 ImxPtr imxPtr = IMXPTR(pScrn);
679 @@ -2275,7 +2276,7 @@ static void
680 imxExaZ160DoneComposite(PixmapPtr pPixmapDst)
682 /* Access screen associated with this pixmap */
683 - ScrnInfoPtr pScrn = xf86Screens[pPixmapDst->drawable.pScreen->myNum];
684 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmapDst->drawable.pScreen);
686 /* Access driver specific data */
687 ImxPtr imxPtr = IMXPTR(pScrn);
688 @@ -2323,7 +2324,7 @@ imxExaZ160UploadToScreen(
690 /* Access screen associated with this pixmap */
691 ScreenPtr pScreen = pPixmapDst->drawable.pScreen;
692 - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
693 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
695 /* Access driver specific data */
696 ImxPtr imxPtr = IMXPTR(pScrn);
697 @@ -2381,7 +2382,7 @@ imxExaZ160DownloadFromScreen(
699 /* Access screen associated with this pixmap */
700 ScreenPtr pScreen = pPixmapSrc->drawable.pScreen;
701 - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
702 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
704 /* Access driver specific data */
705 ImxPtr imxPtr = IMXPTR(pScrn);
706 @@ -2412,9 +2413,9 @@ imxExaZ160DownloadFromScreen(
710 -imxExaZ160CloseScreen(int scrnIndex, ScreenPtr pScreen)
711 +imxExaZ160CloseScreen(CLOSE_SCREEN_ARGS_DECL)
713 - ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
714 + CLOSE_SCREEN_DECL_ScrnInfoPtr;
715 ImxPtr imxPtr = IMXPTR(pScrn);
717 ImxExaZ160Ptr fPtr = IMXEXAZ160PTR(imxPtr);
718 @@ -2504,7 +2505,7 @@ imxExaZ160CloseScreen(int scrnIndex, ScreenPtr pScreen)
719 /* Install our CloseScreen function so that it gets called. */
720 if (NULL != pScreen->CloseScreen) {
722 - return (*pScreen->CloseScreen)(scrnIndex, pScreen);
723 + return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS);
727 @@ -2514,7 +2515,7 @@ Bool
728 imxExaZ160Setup(int scrnIndex, ScreenPtr pScreen)
730 /* Access the screen info and then private data structures. */
731 - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
732 + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
733 ImxPtr imxPtr = IMXPTR(pScrn);
735 /* Private data structure must not already be in use. */
736 @@ -2582,7 +2583,7 @@ imxExaZ160Setup(int scrnIndex, ScreenPtr pScreen)
738 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
739 "Initialize Z160 interfaces failed.\n");
740 - imxExaZ160CloseScreen(scrnIndex, pScreen);
741 + imxExaZ160CloseScreen(CLOSE_SCREEN_ARGS);
745 @@ -2592,7 +2593,7 @@ imxExaZ160Setup(int scrnIndex, ScreenPtr pScreen)
747 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
748 "Allocate EXA driver structure.\n");
749 - imxExaZ160CloseScreen(scrnIndex, pScreen);
750 + imxExaZ160CloseScreen(CLOSE_SCREEN_ARGS);
754 @@ -2657,7 +2658,7 @@ imxExaZ160Setup(int scrnIndex, ScreenPtr pScreen)
755 if (!exaDriverInit(pScreen, exaDriverPtr)) {
757 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "EXA initialization failed.\n");
758 - imxExaZ160CloseScreen(scrnIndex, pScreen);
759 + imxExaZ160CloseScreen(CLOSE_SCREEN_ARGS);
762 fPtr->imxExaRec.exaDriverPtr = exaDriverPtr;
763 diff --git a/src/imx_xv_ipu.c b/src/imx_xv_ipu.c
764 index a517742..fc8a827 100644
765 --- a/src/imx_xv_ipu.c
766 +++ b/src/imx_xv_ipu.c
767 @@ -398,7 +398,7 @@ xf86XVFillKeyHelper1 (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes)
771 - if(!xf86Screens[pScreen->myNum]->vtSema) return;
772 + if(!xf86ScreenToScrn(pScreen)->vtSema) return;
774 gc = GetScratchGC(root->depth, pScreen);
776 @@ -771,7 +771,7 @@ MXXVInitializeAdaptor
777 XF86VideoAdaptorPtr **pppAdaptor
780 - ScreenPtr pScreen = screenInfo.screens[pScreenInfo->scrnIndex];
781 + ScreenPtr pScreen = xf86ScrnToScreen(pScreenInfo);
782 XF86VideoAdaptorPtr *ppAdaptor = NULL;
783 IMXPtr fPtr = IMXPTR(pScreenInfo);