diff options
author | Dave Airlie <airlied@redhat.com> | 2012-06-07 18:41:23 +0100 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-06-07 18:41:23 +0100 |
commit | 5954960d4bbaee9ee4d2d3a4d1ca9a93d02f6697 (patch) | |
tree | 67463f90267aa97537d4ca0734deea895e602e0d /src | |
parent | 20e5b57ca3186dd58f88bc663e410aeea638100f (diff) |
sunffb: port to new compat API.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/compat-api.h | 99 | ||||
-rw-r--r-- | src/ffb.h | 1 | ||||
-rw-r--r-- | src/ffb_accel.c | 2 | ||||
-rw-r--r-- | src/ffb_cursor.c | 2 | ||||
-rw-r--r-- | src/ffb_dga.c | 2 | ||||
-rw-r--r-- | src/ffb_driver.c | 48 |
7 files changed, 128 insertions, 27 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 198aac1..0ef8e3e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,6 +33,7 @@ SPARC_ASM_SRC = ffb_asm.s VISmoveImage.s endif sunffb_drv_la_SOURCES = \ + compat-api.h \ ffb_accel.c \ ffb_attr.c \ ffb_cursor.c \ diff --git a/src/compat-api.h b/src/compat-api.h new file mode 100644 index 0000000..6bc946f --- /dev/null +++ b/src/compat-api.h @@ -0,0 +1,99 @@ +/* + * Copyright 2012 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Author: Dave Airlie <airlied@redhat.com> + */ + +/* this file provides API compat between server post 1.13 and pre it, + it should be reused inside as many drivers as possible */ +#ifndef COMPAT_API_H +#define COMPAT_API_H + +#ifndef GLYPH_HAS_GLYPH_PICTURE_ACCESSOR +#define GetGlyphPicture(g, s) GlyphPicture((g))[(s)->myNum] +#define SetGlyphPicture(g, s, p) GlyphPicture((g))[(s)->myNum] = p +#endif + +#ifndef XF86_HAS_SCRN_CONV +#define xf86ScreenToScrn(s) xf86Screens[(s)->myNum] +#define xf86ScrnToScreen(s) screenInfo.screens[(s)->scrnIndex] +#endif + +#ifndef XF86_SCRN_INTERFACE + +#define SCRN_ARG_TYPE int +#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = xf86Screens[(arg1)] + +#define SCREEN_ARG_TYPE int +#define SCREEN_PTR(arg1) ScreenPtr pScreen = screenInfo.screens[(arg1)] + +#define SCREEN_INIT_ARGS_DECL int i, ScreenPtr pScreen, int argc, char **argv + +#define BLOCKHANDLER_ARGS_DECL int arg, pointer blockData, pointer pTimeout, pointer pReadmask +#define BLOCKHANDLER_ARGS arg, blockData, pTimeout, pReadmask + +#define CLOSE_SCREEN_ARGS_DECL int scrnIndex, ScreenPtr pScreen +#define CLOSE_SCREEN_ARGS scrnIndex, pScreen + +#define ADJUST_FRAME_ARGS_DECL int arg, int x, int y, int flags +#define ADJUST_FRAME_ARGS(arg, x, y) (arg)->scrnIndex, x, y, 0 + +#define SWITCH_MODE_ARGS_DECL int arg, DisplayModePtr mode, int flags +#define SWITCH_MODE_ARGS(arg, m) (arg)->scrnIndex, m, 0 + +#define FREE_SCREEN_ARGS_DECL int arg, int flags + +#define VT_FUNC_ARGS_DECL int arg, int flags +#define VT_FUNC_ARGS pScrn->scrnIndex, 0 + +#define XF86_SCRN_ARG(x) ((x)->scrnIndex) +#else +#define SCRN_ARG_TYPE ScrnInfoPtr +#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = (arg1) + +#define SCREEN_ARG_TYPE ScreenPtr +#define SCREEN_PTR(arg1) ScreenPtr pScreen = (arg1) + +#define SCREEN_INIT_ARGS_DECL ScreenPtr pScreen, int argc, char **argv + +#define BLOCKHANDLER_ARGS_DECL ScreenPtr arg, pointer pTimeout, pointer pReadmask +#define BLOCKHANDLER_ARGS arg, pTimeout, pReadmask + +#define CLOSE_SCREEN_ARGS_DECL ScreenPtr pScreen +#define CLOSE_SCREEN_ARGS pScreen + +#define ADJUST_FRAME_ARGS_DECL ScrnInfoPtr arg, int x, int y +#define ADJUST_FRAME_ARGS(arg, x, y) arg, x, y + +#define SWITCH_MODE_ARGS_DECL ScrnInfoPtr arg, DisplayModePtr mode +#define SWITCH_MODE_ARGS(arg, m) arg, m + +#define FREE_SCREEN_ARGS_DECL ScrnInfoPtr arg + +#define VT_FUNC_ARGS_DECL ScrnInfoPtr arg +#define VT_FUNC_ARGS pScrn + +#define XF86_SCRN_ARG(x) (x) + +#endif + +#endif @@ -47,6 +47,7 @@ #include <X11/extensions/dpms.h> #endif +#include "compat-api.h" /* Various offsets in virtual (ie. mmap()) spaces Linux and Solaris support. */ /* Note: do not mmap FFB_DFB8R_VOFF and following mappings using one mmap together with any previous SFB mapping, otherwise the OS won't be able to use 4M pages diff --git a/src/ffb_accel.c b/src/ffb_accel.c index 6ea4dd2..7dc1228 100644 --- a/src/ffb_accel.c +++ b/src/ffb_accel.c @@ -59,7 +59,7 @@ struct fastfill_parms ffb_fastfill_parms[] = { void CreatorVtChange (ScreenPtr pScreen, int enter) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); FFBPtr pFfb = GET_FFB_FROM_SCRN (pScrn); ffb_fbcPtr ffb = pFfb->regs; diff --git a/src/ffb_cursor.c b/src/ffb_cursor.c index d347a46..554866d 100644 --- a/src/ffb_cursor.c +++ b/src/ffb_cursor.c @@ -112,7 +112,7 @@ FFBSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) Bool FFBHWCursorInit(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); FFBPtr pFfb; xf86CursorInfoPtr infoPtr; diff --git a/src/ffb_dga.c b/src/ffb_dga.c index 82ad44f..84598db 100644 --- a/src/ffb_dga.c +++ b/src/ffb_dga.c @@ -61,7 +61,7 @@ static DGAFunctionRec FFB_DGAFuncs = { void FFB_InitDGA(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); FFBPtr pFfb; DGAModePtr mode; Bool result; diff --git a/src/ffb_driver.c b/src/ffb_driver.c index b89771a..d02835e 100644 --- a/src/ffb_driver.c +++ b/src/ffb_driver.c @@ -42,22 +42,21 @@ static const OptionInfoRec * FFBAvailableOptions(int chipid, int busid); static void FFBIdentify(int flags); static Bool FFBProbe(DriverPtr drv, int flags); static Bool FFBPreInit(ScrnInfoPtr pScrn, int flags); -static Bool FFBScreenInit(int Index, ScreenPtr pScreen, int argc, - char **argv); -static Bool FFBEnterVT(int scrnIndex, int flags); -static void FFBLeaveVT(int scrnIndex, int flags); -static Bool FFBCloseScreen(int scrnIndex, ScreenPtr pScreen); +static Bool FFBScreenInit(SCREEN_INIT_ARGS_DECL); +static Bool FFBEnterVT(VT_FUNC_ARGS_DECL); +static void FFBLeaveVT(VT_FUNC_ARGS_DECL); +static Bool FFBCloseScreen(CLOSE_SCREEN_ARGS_DECL); static Bool FFBSaveScreen(ScreenPtr pScreen, int mode); static void FFBDPMSSet(ScrnInfoPtr pScrn, int mode, int flags); /* Required if the driver supports mode switching */ -static Bool FFBSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); +static Bool FFBSwitchMode(SWITCH_MODE_ARGS_DECL); /* Required if the driver supports moving the viewport */ -static void FFBAdjustFrame(int scrnIndex, int x, int y, int flags); +static void FFBAdjustFrame(ADJUST_FRAME_ARGS_DECL); /* Optional functions */ -static void FFBFreeScreen(int scrnIndex, int flags); -static ModeStatus FFBValidMode(int scrnIndex, DisplayModePtr mode, +static void FFBFreeScreen(FREE_SCREEN_ARGS_DECL); +static ModeStatus FFBValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags); static void FFBDPMSMode(ScrnInfoPtr pScrn, int DPMSMode, int flags); /* ffb_dga.c */ @@ -573,7 +572,7 @@ FFBProbeBoardType(FFBPtr pFfb) /* This gets called at the start of each server generation */ static Bool -FFBScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +FFBScreenInit(SCREEN_INIT_ARGS_DECL) { ScrnInfoPtr pScrn; FFBPtr pFfb; @@ -584,7 +583,7 @@ FFBScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* * First get the ScrnInfoRec */ - pScrn = xf86Screens[pScreen->myNum]; + pScrn = xf86ScreenToScrn(pScreen); pFfb = GET_FFB_FROM_SCRN(pScrn); @@ -822,7 +821,7 @@ FFBScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* Usually mandatory */ static Bool -FFBSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +FFBSwitchMode(SWITCH_MODE_ARGS_DECL) { return TRUE; } @@ -834,7 +833,7 @@ FFBSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) */ /* Usually mandatory */ static void -FFBAdjustFrame(int scrnIndex, int x, int y, int flags) +FFBAdjustFrame(ADJUST_FRAME_ARGS_DECL) { /* we don't support virtual desktops */ return; @@ -847,9 +846,9 @@ FFBAdjustFrame(int scrnIndex, int x, int y, int flags) /* Mandatory */ static Bool -FFBEnterVT(int scrnIndex, int flags) +FFBEnterVT(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); pFfb->vtSema = FALSE; @@ -870,9 +869,9 @@ FFBEnterVT(int scrnIndex, int flags) /* Mandatory */ static void -FFBLeaveVT(int scrnIndex, int flags) +FFBLeaveVT(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); FFBDacLeaveVT(pFfb); @@ -895,9 +894,9 @@ FFBLeaveVT(int scrnIndex, int flags) /* Mandatory */ static Bool -FFBCloseScreen(int scrnIndex, ScreenPtr pScreen) +FFBCloseScreen(CLOSE_SCREEN_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); /* Restore kernel ramdac state before we unmap registers. */ @@ -919,7 +918,7 @@ FFBCloseScreen(int scrnIndex, ScreenPtr pScreen) xf86SbusHideOsHwCursor (pFfb->psdp); pScreen->CloseScreen = pFfb->CloseScreen; - return (*pScreen->CloseScreen)(scrnIndex, pScreen); + return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS); } @@ -927,9 +926,10 @@ FFBCloseScreen(int scrnIndex, ScreenPtr pScreen) /* Optional */ static void -FFBFreeScreen(int scrnIndex, int flags) +FFBFreeScreen(FREE_SCREEN_ARGS_DECL) { - FFBFreeRec(xf86Screens[scrnIndex]); + SCRN_INFO_PTR(arg); + FFBFreeRec(pScrn); } @@ -937,7 +937,7 @@ FFBFreeScreen(int scrnIndex, int flags) /* Optional */ static ModeStatus -FFBValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) +FFBValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags) { if (mode->Flags & V_INTERLACE) return MODE_BAD; @@ -957,7 +957,7 @@ FFBSaveScreen(ScreenPtr pScreen, int mode) done in "ffb_dac.c" `for aesthetic reasons.' */ { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); return FFBDacSaveScreen(GET_FFB_FROM_SCRN(pScrn), mode); } |