diff options
author | Dave Airlie <airlied@redhat.com> | 2012-07-17 02:01:07 +0100 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-07-17 02:01:07 +0100 |
commit | 1aad7b44e3e141bd8d3e589b7cd410e791050bd0 (patch) | |
tree | 564720025e84292184927dbf82e79a58d86970bb | |
parent | 891ea02395079b1480faf701156185ad01405e6d (diff) |
smi: port to compat-api for new server.
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/compat-api.h | 99 | ||||
-rw-r--r-- | src/smi.h | 1 | ||||
-rw-r--r-- | src/smi_driver.c | 36 | ||||
-rw-r--r-- | src/smi_video.c | 16 | ||||
-rw-r--r-- | src/smilynx_hw.c | 2 |
6 files changed, 125 insertions, 30 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index f3ee526..77b3b85 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -31,6 +31,7 @@ siliconmotion_drv_la_LDFLAGS = -module -avoid-version siliconmotion_drv_ladir = @moduledir@/drivers siliconmotion_drv_la_SOURCES = \ + compat-api.h \ regsmi.h \ smi_501.c \ smi_501.h \ 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 @@ -63,6 +63,7 @@ authorization from the XFree86 Project and Silicon Motion. #include "xf86xv.h" #include <X11/extensions/Xv.h> +#include "compat-api.h" /******************************************************************************/ /* D E F I N I T I O N S */ /******************************************************************************/ diff --git a/src/smi_driver.c b/src/smi_driver.c index 05d7202..604b675 100644 --- a/src/smi_driver.c +++ b/src/smi_driver.c @@ -72,15 +72,14 @@ static const OptionInfoRec * SMI_AvailableOptions(int chipid, int busid); static void SMI_Identify(int flags); static Bool SMI_Probe(DriverPtr drv, int flags); static Bool SMI_PreInit(ScrnInfoPtr pScrn, int flags); -static Bool SMI_EnterVT(int scrnIndex, int flags); -static void SMI_LeaveVT(int scrnIndex, int flags); -static Bool SMI_ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, - char **argv); +static Bool SMI_EnterVT(VT_FUNC_ARGS_DECL); +static void SMI_LeaveVT(VT_FUNC_ARGS_DECL); +static Bool SMI_ScreenInit(SCREEN_INIT_ARGS_DECL); static void SMI_DisableVideo(ScrnInfoPtr pScrn); static void SMI_EnableVideo(ScrnInfoPtr pScrn); -static Bool SMI_CloseScreen(int scrnIndex, ScreenPtr pScreen); +static Bool SMI_CloseScreen(CLOSE_SCREEN_ARGS_DECL); static Bool SMI_SaveScreen(ScreenPtr pScreen, int mode); -static void SMI_FreeScreen(int ScrnIndex, int flags); +static void SMI_FreeScreen(FREE_SCREEN_ARGS_DECL); static void SMI_ProbeDDC(ScrnInfoPtr pScrn, int index); static void SMI_DetectPanelSize(ScrnInfoPtr pScrn); static void SMI_DetectMCLK(ScrnInfoPtr pScrn); @@ -917,9 +916,9 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags) */ static Bool -SMI_EnterVT(int scrnIndex, int flags) +SMI_EnterVT(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); SMIPtr pSmi = SMIPTR(pScrn); ENTER(); @@ -965,9 +964,9 @@ SMI_EnterVT(int scrnIndex, int flags) */ static void -SMI_LeaveVT(int scrnIndex, int flags) +SMI_LeaveVT(VT_FUNC_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + SCRN_INFO_PTR(arg); SMIPtr pSmi = SMIPTR(pScrn); ENTER(); @@ -1620,9 +1619,9 @@ SMI_UnmapMem(ScrnInfoPtr pScrn) /* This gets called at the start of each server generation. */ static Bool -SMI_ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +SMI_ScreenInit(SCREEN_INIT_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SMIPtr pSmi = SMIPTR(pScrn); EntityInfoPtr pEnt; @@ -1832,9 +1831,9 @@ SMI_ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) */ static Bool -SMI_CloseScreen(int scrnIndex, ScreenPtr pScreen) +SMI_CloseScreen(CLOSE_SCREEN_ARGS_DECL) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SMIPtr pSmi = SMIPTR(pScrn); Bool ret; @@ -1845,7 +1844,7 @@ SMI_CloseScreen(int scrnIndex, ScreenPtr pScreen) if (pScrn->vtSema) /* Restore console mode and unmap framebuffer */ - SMI_LeaveVT(scrnIndex, 0); + SMI_LeaveVT(VT_FUNC_ARGS); #ifdef HAVE_XAA_H if (pSmi->XAAInfoRec != NULL) { @@ -1873,15 +1872,16 @@ SMI_CloseScreen(int scrnIndex, ScreenPtr pScreen) pScrn->vtSema = FALSE; pScreen->CloseScreen = pSmi->CloseScreen; - ret = (*pScreen->CloseScreen)(scrnIndex, pScreen); + ret = (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS); LEAVE(ret); } static void -SMI_FreeScreen(int scrnIndex, int flags) +SMI_FreeScreen(FREE_SCREEN_ARGS_DECL) { - SMI_FreeRec(xf86Screens[scrnIndex]); + SCRN_INFO_PTR(arg); + SMI_FreeRec(pScrn); } static Bool diff --git a/src/smi_video.c b/src/smi_video.c index b4511b8..9d8b35f 100644 --- a/src/smi_video.c +++ b/src/smi_video.c @@ -123,8 +123,7 @@ static void SMI_DisplayVideo0501(ScrnInfoPtr pScrn, int id, int offset, static void SMI_DisplayVideo0730(ScrnInfoPtr pScrn, int id, int offset, short width, short height, int pitch, int x1, int y1, int x2, int y2, BoxPtr dstBox, short vid_w, short vid_h, short drw_w, short drw_h); -static void SMI_BlockHandler(int i, pointer blockData, pointer pTimeout, - pointer pReadMask); +static void SMI_BlockHandler(BLOCKHANDLER_ARGS_DECL); /*static int SMI_SendI2C(ScrnInfoPtr pScrn, CARD8 device, char *devName, SMI_I2CDataPtr i2cData);*/ @@ -2060,20 +2059,15 @@ SMI_DisplayVideo0730( } static void -SMI_BlockHandler( - int i, - pointer blockData, - pointer pTimeout, - pointer pReadMask -) +SMI_BlockHandler(BLOCKHANDLER_ARGS_DECL) { - ScreenPtr pScreen = screenInfo.screens[i]; - ScrnInfoPtr pScrn = xf86Screens[i]; + SCREEN_PTR(arg); + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); SMIPtr pSmi = SMIPTR(pScrn); SMI_PortPtr pPort = (SMI_PortPtr) pSmi->ptrAdaptor->pPortPrivates[0].ptr; pScreen->BlockHandler = pSmi->BlockHandler; - (*pScreen->BlockHandler)(i, blockData, pTimeout, pReadMask); + (*pScreen->BlockHandler)(BLOCKHANDLER_ARGS); pScreen->BlockHandler = SMI_BlockHandler; if (pPort->videoStatus & TIMER_MASK) { diff --git a/src/smilynx_hw.c b/src/smilynx_hw.c index 019261d..9a10a31 100644 --- a/src/smilynx_hw.c +++ b/src/smilynx_hw.c @@ -584,7 +584,7 @@ SMILynx_ddc1(ScrnInfoPtr pScrn) tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x72); VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x72, tmp | 0x20); - pMon = xf86PrintEDID(xf86DoEDID_DDC1(pScrn->scrnIndex, + pMon = xf86PrintEDID(xf86DoEDID_DDC1(XF86_SCRN_ARG(pScrn), vgaHWddc1SetSpeedWeak(), SMILynx_ddc1Read)); VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x72, tmp); |