Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame^] | 1 | From 57e8944e3cced03b9526bd075649d74d97c24899 Mon Sep 17 00:00:00 2001 |
| 2 | From: Martin Jansa <Martin.Jansa@gmail.com> |
| 3 | Date: Tue, 20 Nov 2012 22:18:23 +0100 |
| 4 | Subject: [PATCH 3/3] glamo-driver: adapt to xserver-0.13 video API |
| 5 | |
| 6 | Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> |
| 7 | --- |
| 8 | src/compat-api.h | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 9 | src/glamo-driver.c | 43 ++++++++++++------------ |
| 10 | 2 files changed, 118 insertions(+), 21 deletions(-) |
| 11 | create mode 100644 src/compat-api.h |
| 12 | |
| 13 | diff --git a/src/compat-api.h b/src/compat-api.h |
| 14 | new file mode 100644 |
| 15 | index 0000000..b1591b1 |
| 16 | --- /dev/null |
| 17 | +++ b/src/compat-api.h |
| 18 | @@ -0,0 +1,96 @@ |
| 19 | +/* |
| 20 | + * Copyright 2012 Red Hat, Inc. |
| 21 | + * |
| 22 | + * Permission is hereby granted, free of charge, to any person obtaining a |
| 23 | + * copy of this software and associated documentation files (the "Software"), |
| 24 | + * to deal in the Software without restriction, including without limitation |
| 25 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 26 | + * and/or sell copies of the Software, and to permit persons to whom the |
| 27 | + * Software is furnished to do so, subject to the following conditions: |
| 28 | + * |
| 29 | + * The above copyright notice and this permission notice (including the next |
| 30 | + * paragraph) shall be included in all copies or substantial portions of the |
| 31 | + * Software. |
| 32 | + * |
| 33 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 34 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 35 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 36 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 37 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 38 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 39 | + * DEALINGS IN THE SOFTWARE. |
| 40 | + * |
| 41 | + * Author: Dave Airlie <airlied@redhat.com> |
| 42 | + */ |
| 43 | + |
| 44 | +/* this file provides API compat between server post 1.13 and pre it, |
| 45 | + it should be reused inside as many drivers as possible */ |
| 46 | +#ifndef COMPAT_API_H |
| 47 | +#define COMPAT_API_H |
| 48 | + |
| 49 | +#ifndef GLYPH_HAS_GLYPH_PICTURE_ACCESSOR |
| 50 | +#define GetGlyphPicture(g, s) GlyphPicture((g))[(s)->myNum] |
| 51 | +#define SetGlyphPicture(g, s, p) GlyphPicture((g))[(s)->myNum] = p |
| 52 | +#endif |
| 53 | + |
| 54 | +#ifndef XF86_HAS_SCRN_CONV |
| 55 | +#define xf86ScreenToScrn(s) xf86Screens[(s)->myNum] |
| 56 | +#define xf86ScrnToScreen(s) screenInfo.screens[(s)->scrnIndex] |
| 57 | +#endif |
| 58 | + |
| 59 | +#ifndef XF86_SCRN_INTERFACE |
| 60 | + |
| 61 | +#define SCRN_ARG_TYPE int |
| 62 | +#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = xf86Screens[(arg1)] |
| 63 | + |
| 64 | +#define SCREEN_ARG_TYPE int |
| 65 | +#define SCREEN_PTR(arg1) ScreenPtr pScreen = screenInfo.screens[(arg1)] |
| 66 | + |
| 67 | +#define SCREEN_INIT_ARGS_DECL int index, ScreenPtr pScreen, int argc, char **argv |
| 68 | + |
| 69 | +#define BLOCKHANDLER_ARGS_DECL int arg, pointer blockData, pointer pTimeout, pointer pReadmask |
| 70 | +#define BLOCKHANDLER_ARGS arg, blockData, pTimeout, pReadmask |
| 71 | + |
| 72 | +#define CLOSE_SCREEN_ARGS_DECL int scrnIndex, ScreenPtr pScreen |
| 73 | +#define CLOSE_SCREEN_ARGS scrnIndex, pScreen |
| 74 | + |
| 75 | +#define ADJUST_FRAME_ARGS_DECL int arg, int x, int y, int flags |
| 76 | + |
| 77 | +#define SWITCH_MODE_ARGS_DECL int arg, DisplayModePtr mode, int flags |
| 78 | + |
| 79 | +#define FREE_SCREEN_ARGS_DECL int arg, int flags |
| 80 | +#define FREE_SCREEN_ARGS(x) (x)->scrnIndex, 0 |
| 81 | + |
| 82 | +#define VT_FUNC_ARGS_DECL int arg, int flags |
| 83 | +#define VT_FUNC_ARGS(flags) pScrn->scrnIndex, (flags) |
| 84 | + |
| 85 | +#define XF86_ENABLEDISABLEFB_ARG(x) ((x)->scrnIndex) |
| 86 | +#else |
| 87 | +#define SCRN_ARG_TYPE ScrnInfoPtr |
| 88 | +#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = (arg1) |
| 89 | + |
| 90 | +#define SCREEN_ARG_TYPE ScreenPtr |
| 91 | +#define SCREEN_PTR(arg1) ScreenPtr pScreen = (arg1) |
| 92 | + |
| 93 | +#define SCREEN_INIT_ARGS_DECL ScreenPtr pScreen, int argc, char **argv |
| 94 | + |
| 95 | +#define BLOCKHANDLER_ARGS_DECL ScreenPtr arg, pointer pTimeout, pointer pReadmask |
| 96 | +#define BLOCKHANDLER_ARGS arg, pTimeout, pReadmask |
| 97 | + |
| 98 | +#define CLOSE_SCREEN_ARGS_DECL ScreenPtr pScreen |
| 99 | +#define CLOSE_SCREEN_ARGS pScreen |
| 100 | + |
| 101 | +#define ADJUST_FRAME_ARGS_DECL ScrnInfoPtr arg, int x, int y |
| 102 | +#define SWITCH_MODE_ARGS_DECL ScrnInfoPtr arg, DisplayModePtr mode |
| 103 | + |
| 104 | +#define FREE_SCREEN_ARGS_DECL ScrnInfoPtr arg |
| 105 | +#define FREE_SCREEN_ARGS(x) (x) |
| 106 | + |
| 107 | +#define VT_FUNC_ARGS_DECL ScrnInfoPtr arg |
| 108 | +#define VT_FUNC_ARGS(flags) pScrn |
| 109 | + |
| 110 | +#define XF86_ENABLEDISABLEFB_ARG(x) (x) |
| 111 | + |
| 112 | +#endif |
| 113 | + |
| 114 | +#endif |
| 115 | diff --git a/src/glamo-driver.c b/src/glamo-driver.c |
| 116 | index b13caae..10b7762 100644 |
| 117 | --- a/src/glamo-driver.c |
| 118 | +++ b/src/glamo-driver.c |
| 119 | @@ -43,6 +43,7 @@ |
| 120 | |
| 121 | #include <sys/mman.h> |
| 122 | |
| 123 | +#include "compat-api.h" |
| 124 | |
| 125 | static Bool debug = 0; |
| 126 | |
| 127 | @@ -68,10 +69,10 @@ static Bool |
| 128 | GlamoPreInit(ScrnInfoPtr pScrn, int flags); |
| 129 | |
| 130 | static Bool |
| 131 | -GlamoScreenInit(int Index, ScreenPtr pScreen, int argc, char **argv); |
| 132 | +GlamoScreenInit(SCREEN_INIT_ARGS_DECL); |
| 133 | |
| 134 | static Bool |
| 135 | -GlamoCloseScreen(int scrnIndex, ScreenPtr pScreen); |
| 136 | +GlamoCloseScreen(CLOSE_SCREEN_ARGS_DECL); |
| 137 | |
| 138 | static Bool |
| 139 | GlamoCrtcResize(ScrnInfoPtr scrn, int width, int height); |
| 140 | @@ -86,10 +87,10 @@ static void |
| 141 | GlamoRestoreHW(ScrnInfoPtr pScren); |
| 142 | |
| 143 | static Bool |
| 144 | -GlamoEnterVT(int scrnIndex, int flags); |
| 145 | +GlamoEnterVT(VT_FUNC_ARGS_DECL); |
| 146 | |
| 147 | static void |
| 148 | -GlamoLeaveVT(int scrnIndex, int flags); |
| 149 | +GlamoLeaveVT(VT_FUNC_ARGS_DECL); |
| 150 | |
| 151 | static void |
| 152 | GlamoLoadColormap(ScrnInfoPtr pScrn, int numColors, int *indices, |
| 153 | @@ -248,8 +249,8 @@ GlamoUnmapMMIO(ScrnInfoPtr pScrn) { |
| 154 | } |
| 155 | |
| 156 | static Bool |
| 157 | -GlamoSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) { |
| 158 | - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; |
| 159 | +GlamoSwitchMode(SWITCH_MODE_ARGS_DECL) { |
| 160 | + SCRN_INFO_PTR(arg); |
| 161 | xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR (pScrn); |
| 162 | xf86OutputPtr output = config->output[config->compat_output]; |
| 163 | Rotation rotation; |
| 164 | @@ -286,7 +287,7 @@ GlamoFbdevProbe(DriverPtr drv, GDevPtr *devSections, int numDevSections) |
| 165 | |
| 166 | for (i = 0; i < numDevSections; i++) { |
| 167 | |
| 168 | - dev = xf86FindOptionValue(devSections[i]->options, "Device"); |
| 169 | + dev = (char *) xf86FindOptionValue(devSections[i]->options, "Device"); |
| 170 | if (fbdevHWProbe(NULL, dev, NULL)) { |
| 171 | int entity; |
| 172 | pScrn = NULL; |
| 173 | @@ -430,7 +431,7 @@ GlamoPreInit(ScrnInfoPtr pScrn, int flags) |
| 174 | |
| 175 | pGlamo->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); |
| 176 | |
| 177 | - fb_device = xf86FindOptionValue(pGlamo->pEnt->device->options, "Device"); |
| 178 | + fb_device = (char *) xf86FindOptionValue(pGlamo->pEnt->device->options, "Device"); |
| 179 | |
| 180 | /* open device */ |
| 181 | if (!fbdevHWInit(pScrn, NULL, fb_device)) |
| 182 | @@ -523,7 +524,7 @@ GlamoPreInit(ScrnInfoPtr pScrn, int flags) |
| 183 | |
| 184 | |
| 185 | static Bool |
| 186 | -GlamoScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) |
| 187 | +GlamoScreenInit(SCREEN_INIT_ARGS_DECL) |
| 188 | { |
| 189 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; |
| 190 | GlamoPtr pGlamo = GlamoPTR(pScrn); |
| 191 | @@ -545,7 +546,7 @@ GlamoScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) |
| 192 | #endif |
| 193 | |
| 194 | if (NULL == (pGlamo->fbmem = fbdevHWMapVidmem(pScrn))) { |
| 195 | - xf86DrvMsg(scrnIndex, X_ERROR, "mapping of video memory failed\n"); |
| 196 | + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "mapping of video memory failed\n"); |
| 197 | return FALSE; |
| 198 | } |
| 199 | |
| 200 | @@ -556,13 +557,13 @@ GlamoScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) |
| 201 | /* mi layer */ |
| 202 | miClearVisualTypes(); |
| 203 | if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, TrueColor)) { |
| 204 | - xf86DrvMsg(scrnIndex, X_ERROR, |
| 205 | + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
| 206 | "visual type setup failed for %d bits per pixel [1]\n", |
| 207 | pScrn->bitsPerPixel); |
| 208 | return FALSE; |
| 209 | } |
| 210 | if (!miSetPixmapDepths()) { |
| 211 | - xf86DrvMsg(scrnIndex, X_ERROR, "pixmap depth setup failed\n"); |
| 212 | + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "pixmap depth setup failed\n"); |
| 213 | return FALSE; |
| 214 | } |
| 215 | |
| 216 | @@ -617,7 +618,7 @@ GlamoScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) |
| 217 | /* software cursor */ |
| 218 | miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); |
| 219 | |
| 220 | - GlamoEnterVT(scrnIndex, 0); |
| 221 | + GlamoEnterVT(VT_FUNC_ARGS(0)); |
| 222 | |
| 223 | xf86CrtcScreenInit(pScreen); |
| 224 | #if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,5,0,0,0) |
| 225 | @@ -627,7 +628,7 @@ GlamoScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) |
| 226 | /* colormap */ |
| 227 | pGlamo->colormap = NULL; |
| 228 | if (!miCreateDefColormap(pScreen)) { |
| 229 | - xf86DrvMsg(scrnIndex, X_ERROR, |
| 230 | + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
| 231 | "internal error: miCreateDefColormap failed " |
| 232 | "in GlamoScreenInit()\n"); |
| 233 | return FALSE; |
| 234 | @@ -652,9 +653,9 @@ GlamoScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) |
| 235 | } |
| 236 | |
| 237 | static Bool |
| 238 | -GlamoCloseScreen(int scrnIndex, ScreenPtr pScreen) |
| 239 | +GlamoCloseScreen(CLOSE_SCREEN_ARGS_DECL) |
| 240 | { |
| 241 | - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; |
| 242 | + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
| 243 | GlamoPtr pGlamo = GlamoPTR(pScrn); |
| 244 | |
| 245 | if (pGlamo->accel) |
| 246 | @@ -675,7 +676,7 @@ GlamoCloseScreen(int scrnIndex, ScreenPtr pScreen) |
| 247 | |
| 248 | pScreen->CreateScreenResources = pGlamo->CreateScreenResources; |
| 249 | pScreen->CloseScreen = pGlamo->CloseScreen; |
| 250 | - return (*pScreen->CloseScreen)(scrnIndex, pScreen); |
| 251 | + return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS); |
| 252 | } |
| 253 | |
| 254 | static Bool |
| 255 | @@ -826,8 +827,8 @@ GlamoRestoreHW(ScrnInfoPtr pScrn) { |
| 256 | } |
| 257 | |
| 258 | static Bool |
| 259 | -GlamoEnterVT(int scrnIndex, int flags) { |
| 260 | - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; |
| 261 | +GlamoEnterVT(VT_FUNC_ARGS_DECL) { |
| 262 | + SCRN_INFO_PTR(arg); |
| 263 | GlamoPtr pGlamo = GlamoPTR(pScrn); |
| 264 | |
| 265 | GlamoSaveHW(pScrn); |
| 266 | @@ -842,8 +843,8 @@ GlamoEnterVT(int scrnIndex, int flags) { |
| 267 | } |
| 268 | |
| 269 | static void |
| 270 | -GlamoLeaveVT(int scrnIndex, int flags) { |
| 271 | - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; |
| 272 | +GlamoLeaveVT(VT_FUNC_ARGS_DECL) { |
| 273 | + SCRN_INFO_PTR(arg); |
| 274 | GlamoPtr pGlamo = GlamoPTR(pScrn); |
| 275 | |
| 276 | if (pGlamo->accel) |
| 277 | -- |
| 278 | 1.8.0 |
| 279 | |