Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame^] | 1 | From 803ecf2909949e6152f4a81b6cbb92a4430679ac Mon Sep 17 00:00:00 2001 |
| 2 | From: Martin Jansa <Martin.Jansa@gmail.com> |
| 3 | Date: Fri, 23 Nov 2012 00:31:06 +0100 |
| 4 | Subject: [PATCH 6/6] omapfb: port to new xserver video API |
| 5 | |
| 6 | Upstream-Status: Pending |
| 7 | |
| 8 | Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> |
| 9 | --- |
| 10 | src/compat-api.h | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 11 | src/omapfb-driver.c | 41 ++++++++++++----------- |
| 12 | 2 files changed, 118 insertions(+), 19 deletions(-) |
| 13 | create mode 100644 src/compat-api.h |
| 14 | |
| 15 | diff --git a/src/compat-api.h b/src/compat-api.h |
| 16 | new file mode 100644 |
| 17 | index 0000000..b1591b1 |
| 18 | --- /dev/null |
| 19 | +++ b/src/compat-api.h |
| 20 | @@ -0,0 +1,96 @@ |
| 21 | +/* |
| 22 | + * Copyright 2012 Red Hat, Inc. |
| 23 | + * |
| 24 | + * Permission is hereby granted, free of charge, to any person obtaining a |
| 25 | + * copy of this software and associated documentation files (the "Software"), |
| 26 | + * to deal in the Software without restriction, including without limitation |
| 27 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 28 | + * and/or sell copies of the Software, and to permit persons to whom the |
| 29 | + * Software is furnished to do so, subject to the following conditions: |
| 30 | + * |
| 31 | + * The above copyright notice and this permission notice (including the next |
| 32 | + * paragraph) shall be included in all copies or substantial portions of the |
| 33 | + * Software. |
| 34 | + * |
| 35 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 36 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 37 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 38 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 39 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 40 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 41 | + * DEALINGS IN THE SOFTWARE. |
| 42 | + * |
| 43 | + * Author: Dave Airlie <airlied@redhat.com> |
| 44 | + */ |
| 45 | + |
| 46 | +/* this file provides API compat between server post 1.13 and pre it, |
| 47 | + it should be reused inside as many drivers as possible */ |
| 48 | +#ifndef COMPAT_API_H |
| 49 | +#define COMPAT_API_H |
| 50 | + |
| 51 | +#ifndef GLYPH_HAS_GLYPH_PICTURE_ACCESSOR |
| 52 | +#define GetGlyphPicture(g, s) GlyphPicture((g))[(s)->myNum] |
| 53 | +#define SetGlyphPicture(g, s, p) GlyphPicture((g))[(s)->myNum] = p |
| 54 | +#endif |
| 55 | + |
| 56 | +#ifndef XF86_HAS_SCRN_CONV |
| 57 | +#define xf86ScreenToScrn(s) xf86Screens[(s)->myNum] |
| 58 | +#define xf86ScrnToScreen(s) screenInfo.screens[(s)->scrnIndex] |
| 59 | +#endif |
| 60 | + |
| 61 | +#ifndef XF86_SCRN_INTERFACE |
| 62 | + |
| 63 | +#define SCRN_ARG_TYPE int |
| 64 | +#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = xf86Screens[(arg1)] |
| 65 | + |
| 66 | +#define SCREEN_ARG_TYPE int |
| 67 | +#define SCREEN_PTR(arg1) ScreenPtr pScreen = screenInfo.screens[(arg1)] |
| 68 | + |
| 69 | +#define SCREEN_INIT_ARGS_DECL int index, ScreenPtr pScreen, int argc, char **argv |
| 70 | + |
| 71 | +#define BLOCKHANDLER_ARGS_DECL int arg, pointer blockData, pointer pTimeout, pointer pReadmask |
| 72 | +#define BLOCKHANDLER_ARGS arg, blockData, pTimeout, pReadmask |
| 73 | + |
| 74 | +#define CLOSE_SCREEN_ARGS_DECL int scrnIndex, ScreenPtr pScreen |
| 75 | +#define CLOSE_SCREEN_ARGS scrnIndex, pScreen |
| 76 | + |
| 77 | +#define ADJUST_FRAME_ARGS_DECL int arg, int x, int y, int flags |
| 78 | + |
| 79 | +#define SWITCH_MODE_ARGS_DECL int arg, DisplayModePtr mode, int flags |
| 80 | + |
| 81 | +#define FREE_SCREEN_ARGS_DECL int arg, int flags |
| 82 | +#define FREE_SCREEN_ARGS(x) (x)->scrnIndex, 0 |
| 83 | + |
| 84 | +#define VT_FUNC_ARGS_DECL int arg, int flags |
| 85 | +#define VT_FUNC_ARGS(flags) pScrn->scrnIndex, (flags) |
| 86 | + |
| 87 | +#define XF86_ENABLEDISABLEFB_ARG(x) ((x)->scrnIndex) |
| 88 | +#else |
| 89 | +#define SCRN_ARG_TYPE ScrnInfoPtr |
| 90 | +#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = (arg1) |
| 91 | + |
| 92 | +#define SCREEN_ARG_TYPE ScreenPtr |
| 93 | +#define SCREEN_PTR(arg1) ScreenPtr pScreen = (arg1) |
| 94 | + |
| 95 | +#define SCREEN_INIT_ARGS_DECL ScreenPtr pScreen, int argc, char **argv |
| 96 | + |
| 97 | +#define BLOCKHANDLER_ARGS_DECL ScreenPtr arg, pointer pTimeout, pointer pReadmask |
| 98 | +#define BLOCKHANDLER_ARGS arg, pTimeout, pReadmask |
| 99 | + |
| 100 | +#define CLOSE_SCREEN_ARGS_DECL ScreenPtr pScreen |
| 101 | +#define CLOSE_SCREEN_ARGS pScreen |
| 102 | + |
| 103 | +#define ADJUST_FRAME_ARGS_DECL ScrnInfoPtr arg, int x, int y |
| 104 | +#define SWITCH_MODE_ARGS_DECL ScrnInfoPtr arg, DisplayModePtr mode |
| 105 | + |
| 106 | +#define FREE_SCREEN_ARGS_DECL ScrnInfoPtr arg |
| 107 | +#define FREE_SCREEN_ARGS(x) (x) |
| 108 | + |
| 109 | +#define VT_FUNC_ARGS_DECL ScrnInfoPtr arg |
| 110 | +#define VT_FUNC_ARGS(flags) pScrn |
| 111 | + |
| 112 | +#define XF86_ENABLEDISABLEFB_ARG(x) (x) |
| 113 | + |
| 114 | +#endif |
| 115 | + |
| 116 | +#endif |
| 117 | diff --git a/src/omapfb-driver.c b/src/omapfb-driver.c |
| 118 | index 07989f5..486ffa4 100644 |
| 119 | --- a/src/omapfb-driver.c |
| 120 | +++ b/src/omapfb-driver.c |
| 121 | @@ -44,6 +44,8 @@ |
| 122 | |
| 123 | #include "exa.h" |
| 124 | |
| 125 | +#include "compat-api.h" |
| 126 | + |
| 127 | #ifdef HAVE_XEXTPROTO_71 |
| 128 | #include <X11/extensions/dpmsconst.h> |
| 129 | #else |
| 130 | @@ -70,10 +72,10 @@ |
| 131 | |
| 132 | static Bool OMAPFBProbe(DriverPtr drv, int flags); |
| 133 | static Bool OMAPFBPreInit(ScrnInfoPtr pScrn, int flags); |
| 134 | -static Bool OMAPFBScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv); |
| 135 | -static Bool OMAPFBEnterVT(int scrnIndex, int flags); |
| 136 | -static void OMAPFBLeaveVT(int scrnIndex, int flags); |
| 137 | -static Bool OMAPFBSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); |
| 138 | +static Bool OMAPFBScreenInit(SCREEN_INIT_ARGS_DECL); |
| 139 | +static Bool OMAPFBEnterVT(VT_FUNC_ARGS_DECL); |
| 140 | +static void OMAPFBLeaveVT(VT_FUNC_ARGS_DECL); |
| 141 | +static Bool OMAPFBSwitchMode(SWITCH_MODE_ARGS_DECL); |
| 142 | |
| 143 | static Bool |
| 144 | OMAPFBEnsureRec(ScrnInfoPtr pScrn) |
| 145 | @@ -481,7 +483,7 @@ OMAPFBXvScreenInit(ScreenPtr pScreen) |
| 146 | } |
| 147 | |
| 148 | static Bool |
| 149 | -OMAPFBCloseScreen(int scrnIndex, ScreenPtr pScreen) |
| 150 | +OMAPFBCloseScreen(CLOSE_SCREEN_ARGS_DECL) |
| 151 | { |
| 152 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; |
| 153 | OMAPFBPtr ofb = OMAPFB(pScrn); |
| 154 | @@ -490,11 +492,11 @@ OMAPFBCloseScreen(int scrnIndex, ScreenPtr pScreen) |
| 155 | |
| 156 | pScreen->CloseScreen = ofb->CloseScreen; |
| 157 | |
| 158 | - return (*pScreen->CloseScreen)(scrnIndex, pScreen); |
| 159 | + return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS); |
| 160 | } |
| 161 | |
| 162 | static Bool |
| 163 | -OMAPFBScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) |
| 164 | +OMAPFBScreenInit(SCREEN_INIT_ARGS_DECL) |
| 165 | { |
| 166 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; |
| 167 | OMAPFBPtr ofb = OMAPFB(pScrn); |
| 168 | @@ -516,7 +518,7 @@ OMAPFBScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) |
| 169 | PROT_READ | PROT_WRITE, MAP_SHARED, |
| 170 | ofb->fd, 0); |
| 171 | if (ofb->fb == MAP_FAILED) { |
| 172 | - xf86DrvMsg(scrnIndex, X_ERROR, "Mapping framebuffer memory failed, wanted %d bytes.\n", ofb->mem_info.size); |
| 173 | + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Mapping framebuffer memory failed, wanted %d bytes.\n", ofb->mem_info.size); |
| 174 | return FALSE; |
| 175 | } |
| 176 | |
| 177 | @@ -526,7 +528,7 @@ OMAPFBScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) |
| 178 | /* Only support TrueColor for now */ |
| 179 | if (!miSetVisualTypes(pScrn->depth, TrueColorMask, |
| 180 | pScrn->rgbBits, pScrn->defaultVisual)) { |
| 181 | - xf86DrvMsg(scrnIndex, X_ERROR, "visual type setup failed" |
| 182 | + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "visual type setup failed" |
| 183 | " for %d bits per pixel [1]\n", |
| 184 | pScrn->bitsPerPixel); |
| 185 | return FALSE; |
| 186 | @@ -534,7 +536,7 @@ OMAPFBScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) |
| 187 | |
| 188 | /* Set up pixmap depth information */ |
| 189 | if (!miSetPixmapDepths()) { |
| 190 | - xf86DrvMsg(scrnIndex,X_ERROR,"pixmap depth setup failed\n"); |
| 191 | + xf86DrvMsg(pScrn->scrnIndex,X_ERROR,"pixmap depth setup failed\n"); |
| 192 | return FALSE; |
| 193 | } |
| 194 | |
| 195 | @@ -546,7 +548,7 @@ OMAPFBScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) |
| 196 | pScrn->virtualY, pScrn->xDpi, |
| 197 | pScrn->yDpi, pScrn->displayWidth, |
| 198 | pScrn->bitsPerPixel)) { |
| 199 | - xf86DrvMsg(scrnIndex, X_ERROR, "fbScreenInit failed\n"); |
| 200 | + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "fbScreenInit failed\n"); |
| 201 | return FALSE; |
| 202 | } |
| 203 | |
| 204 | @@ -567,7 +569,7 @@ OMAPFBScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) |
| 205 | |
| 206 | /* Initialize XRender fallbacks */ |
| 207 | if (!fbPictureInit(pScreen, NULL, 0)) { |
| 208 | - xf86DrvMsg(scrnIndex, X_ERROR, "fbPictureInit failed\n"); |
| 209 | + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "fbPictureInit failed\n"); |
| 210 | return FALSE; |
| 211 | } |
| 212 | |
| 213 | @@ -579,7 +581,7 @@ OMAPFBScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) |
| 214 | |
| 215 | /* Initialize default colormap */ |
| 216 | if (!miCreateDefColormap(pScreen)) { |
| 217 | - xf86DrvMsg(scrnIndex, X_ERROR, |
| 218 | + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
| 219 | "creating default colormap failed\n"); |
| 220 | return FALSE; |
| 221 | } |
| 222 | @@ -589,7 +591,7 @@ OMAPFBScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) |
| 223 | /* This is non-fatal since we might be running against older |
| 224 | * kernel driver in which case we only do basic 2D stuff... |
| 225 | */ |
| 226 | - xf86DrvMsg(scrnIndex, X_ERROR, "Reading plane info failed\n"); |
| 227 | + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Reading plane info failed\n"); |
| 228 | } else if (!ofb->dss) { |
| 229 | |
| 230 | ofb->plane_info.enabled = 1; |
| 231 | @@ -602,7 +604,7 @@ OMAPFBScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) |
| 232 | } |
| 233 | |
| 234 | if (ioctl (ofb->fd, OMAPFB_SETUP_PLANE, &ofb->plane_info)) { |
| 235 | - xf86DrvMsg(scrnIndex, X_ERROR, |
| 236 | + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
| 237 | "%s: Plane setup failed: %s\n", |
| 238 | __FUNCTION__, strerror(errno)); |
| 239 | return FALSE; |
| 240 | @@ -645,9 +647,10 @@ OMAPFBScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) |
| 241 | return TRUE; |
| 242 | } |
| 243 | |
| 244 | -static Bool OMAPFBSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) |
| 245 | +static Bool OMAPFBSwitchMode(SWITCH_MODE_ARGS_DECL) |
| 246 | { |
| 247 | - return xf86SetSingleMode (xf86Screens[scrnIndex], mode, RR_Rotate_0); |
| 248 | + SCRN_INFO_PTR(arg); |
| 249 | + return xf86SetSingleMode (pScrn, mode, RR_Rotate_0); |
| 250 | } |
| 251 | |
| 252 | void |
| 253 | @@ -699,14 +702,14 @@ OMAPFBPrintCapabilities(ScrnInfoPtr pScrn, |
| 254 | /*** Unimplemented: */ |
| 255 | |
| 256 | static Bool |
| 257 | -OMAPFBEnterVT(int scrnIndex, int flags) |
| 258 | +OMAPFBEnterVT(VT_FUNC_ARGS_DECL) |
| 259 | { |
| 260 | xf86Msg(X_NOT_IMPLEMENTED, "%s\n", __FUNCTION__); |
| 261 | return TRUE; |
| 262 | } |
| 263 | |
| 264 | static void |
| 265 | -OMAPFBLeaveVT(int scrnIndex, int flags) |
| 266 | +OMAPFBLeaveVT(VT_FUNC_ARGS_DECL) |
| 267 | { |
| 268 | xf86Msg(X_NOT_IMPLEMENTED, "%s\n", __FUNCTION__); |
| 269 | } |
| 270 | -- |
| 271 | 1.8.0 |
| 272 | |