diff options
author | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:48:55 +0000 |
---|---|---|
committer | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:48:55 +0000 |
commit | 5a01d1437514492397158ee26c597589e8a6935f (patch) | |
tree | d46ed2d07a9d76f48081dcfe38159b474b3243d2 |
Initial revisionXORG-STABLE
-rw-r--r-- | man/suncg6.man | 30 | ||||
-rw-r--r-- | src/cg6.h | 98 | ||||
-rw-r--r-- | src/cg6_cursor.c | 121 | ||||
-rw-r--r-- | src/cg6_driver.c | 691 | ||||
-rw-r--r-- | src/cg6_regs.h | 194 |
5 files changed, 1134 insertions, 0 deletions
diff --git a/man/suncg6.man b/man/suncg6.man new file mode 100644 index 0000000..b0dc5e8 --- /dev/null +++ b/man/suncg6.man @@ -0,0 +1,30 @@ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg6/suncg6.man,v 1.2 2001/01/27 18:20:54 dawes Exp $ +.\" shorthand for double quote that works everywhere. +.ds q \N'34' +.TH SUNCG6 __drivermansuffix__ __vendorversion__ +.SH NAME +suncg6 \- GX/Turbo GX video driver +.SH SYNOPSIS +.nf +.B "Section \*qDevice\*q" +.BI " Identifier \*q" devname \*q +.B " Driver \*qsuncg6\*q" +\ \ ... +.B EndSection +.fi +.SH DESCRIPTION +.B suncg6 +is an XFree86 driver for Sun GX and Turbo GX (also known as cgsix) video cards. +THIS MAN PAGE NEEDS TO BE FILLED IN. +.SH SUPPORTED HARDWARE +The +.B suncg6 +driver supports... +.SH CONFIGURATION DETAILS +Please refer to XF86Config(__filemansuffix__) for general configuration +details. This section only covers configuration details specific to this +driver. +.SH "SEE ALSO" +XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__) +.SH AUTHORS +Authors include: Jakub Jelinek <jakub@redhat.com> diff --git a/src/cg6.h b/src/cg6.h new file mode 100644 index 0000000..00ed5b7 --- /dev/null +++ b/src/cg6.h @@ -0,0 +1,98 @@ +/* + * GX and Turbo GX framebuffer - defines. + * + * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com) + * + * 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 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 + * JAKUB JELINEK 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. + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6.h,v 1.3 2001/05/04 19:05:45 dawes Exp $ */ + +#ifndef CG6_H +#define CG6_H + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86_ansic.h" +#include "xf86RamDac.h" +#include "Xmd.h" +#include "gcstruct.h" +#include "cg6_regs.h" +#include "xf86sbusBus.h" + +/* Various offsets in virtual (ie. mmap()) spaces Linux and Solaris support. */ +#define CG6_FBC_VOFF 0x70000000 +#define CG6_TEC_VOFF 0x70001000 +#define CG6_BTREGS_VOFF 0x70002000 +#define CG6_FHC_VOFF 0x70004000 +#define CG6_THC_VOFF 0x70005000 +#define CG6_ROM_VOFF 0x70006000 +#define CG6_RAM_VOFF 0x70016000 +#define CG6_DHC_VOFF 0x80000000 + +typedef struct { + unsigned int fg, bg; /* FG/BG colors for stipple */ + unsigned int patalign; /* X/Y alignment of bits */ + unsigned int alu; /* Transparent/Opaque + rop */ + unsigned int bits[32]; /* The stipple bits themselves */ +} Cg6StippleRec, *Cg6StipplePtr; + +typedef struct { + int type; + Cg6StipplePtr stipple; +} Cg6PrivGCRec, *Cg6PrivGCPtr; + +typedef struct { + unsigned char *fb; + Cg6FbcPtr fbc; + Cg6ThcPtr thc; + int vclipmax; + int width; + int height; + + sbusDevicePtr psdp; + Bool HWCursor; + Bool NoAccel; + CloseScreenProcPtr CloseScreen; + xf86CursorInfoPtr CursorInfoRec; + unsigned int CursorXY; + int CursorBg, CursorFg; + Bool CursorEnabled; + OptionInfoPtr Options; +} Cg6Rec, *Cg6Ptr; + +extern int Cg6ScreenPrivateIndex; +extern int Cg6GCPrivateIndex; +extern int Cg6WindowPrivateIndex; + +#define GET_CG6_FROM_SCRN(p) ((Cg6Ptr)((p)->driverPrivate)) + +#define Cg6GetScreenPrivate(s) \ +((Cg6Ptr) (s)->devPrivates[Cg6ScreenPrivateIndex].ptr) + +#define Cg6GetGCPrivate(g) \ +((Cg6PrivGCPtr) (g)->devPrivates [Cg6GCPrivateIndex].ptr) + +#define Cg6GetWindowPrivate(w) \ +((Cg6StipplePtr) (w)->devPrivates[Cg6WindowPrivateIndex].ptr) + +#define Cg6SetWindowPrivate(w,p) \ +((w)->devPrivates[Cg6WindowPrivateIndex].ptr = (pointer) p) + +extern int cg6RopTable[]; + +#endif /* CG6_H */ diff --git a/src/cg6_cursor.c b/src/cg6_cursor.c new file mode 100644 index 0000000..72a396f --- /dev/null +++ b/src/cg6_cursor.c @@ -0,0 +1,121 @@ +/* + * Hardware cursor support for GX or Turbo GX + * + * Copyright 2000 by Jakub Jelinek <jakub@redhat.com>. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of Jakub + * Jelinek not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Jakub Jelinek makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * JAKUB JELINEK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL JAKUB JELINEK BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_cursor.c,v 1.1 2000/06/30 19:30:46 dawes Exp $ */ + +#include "cg6.h" + +static void CG6LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src); +static void CG6ShowCursor(ScrnInfoPtr pScrn); +static void CG6HideCursor(ScrnInfoPtr pScrn); +static void CG6SetCursorPosition(ScrnInfoPtr pScrn, int x, int y); +static void CG6SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg); + +static void +CG6LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) +{ + Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); + int i; + unsigned int *data = (unsigned int *)src; + + for (i = 0; i < 32; i++) + pCg6->thc->thc_cursmask[i] = *data++; + for (i = 0; i < 32; i++) + pCg6->thc->thc_cursbits[i] = *data++; +} + +static void +CG6ShowCursor(ScrnInfoPtr pScrn) +{ + Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); + + pCg6->thc->thc_cursxy = pCg6->CursorXY; + pCg6->CursorEnabled = TRUE; +} + +static void +CG6HideCursor(ScrnInfoPtr pScrn) +{ + Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); + + pCg6->thc->thc_cursxy = ((65536 - 32) << 16) | (65536 - 32); + pCg6->CursorEnabled = FALSE; +} + +static void +CG6SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) +{ + Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); + + pCg6->CursorXY = ((x & 0xffff) << 16) | (y & 0xffff); + if (pCg6->CursorEnabled) + pCg6->thc->thc_cursxy = pCg6->CursorXY; +} + +static void +CG6SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) +{ + Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); + + if (bg != pCg6->CursorBg || fg != pCg6->CursorFg) { + xf86SbusSetOsHwCursorCmap(pCg6->psdp, bg, fg); + pCg6->CursorBg = bg; + pCg6->CursorFg = fg; + } +} + +Bool +CG6HWCursorInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + Cg6Ptr pCg6; + xf86CursorInfoPtr infoPtr; + + pCg6 = GET_CG6_FROM_SCRN(pScrn); + pCg6->CursorXY = 0; + pCg6->CursorBg = pCg6->CursorFg = 0; + pCg6->CursorEnabled = FALSE; + + infoPtr = xf86CreateCursorInfoRec(); + if(!infoPtr) return FALSE; + + pCg6->CursorInfoRec = infoPtr; + + infoPtr->MaxWidth = 32; + infoPtr->MaxHeight = 32; + infoPtr->Flags = HARDWARE_CURSOR_AND_SOURCE_WITH_MASK | + HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK | + HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED | + HARDWARE_CURSOR_TRUECOLOR_AT_8BPP; + + infoPtr->SetCursorColors = CG6SetCursorColors; + infoPtr->SetCursorPosition = CG6SetCursorPosition; + infoPtr->LoadCursorImage = CG6LoadCursorImage; + infoPtr->HideCursor = CG6HideCursor; + infoPtr->ShowCursor = CG6ShowCursor; + infoPtr->UseHWCursor = NULL; + + return xf86InitCursor(pScreen, infoPtr); +} diff --git a/src/cg6_driver.c b/src/cg6_driver.c new file mode 100644 index 0000000..bf9a333 --- /dev/null +++ b/src/cg6_driver.c @@ -0,0 +1,691 @@ +/* + * GX and Turbo GX framebuffer driver. + * + * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com) + * + * 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 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 + * JAKUB JELINEK 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. + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_driver.c,v 1.7 2002/12/06 16:44:38 tsi Exp $ */ + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86_ansic.h" +#include "xf86Version.h" +#include "mipointer.h" +#include "mibstore.h" +#include "micmap.h" + +#include "fb.h" +#include "xf86cmap.h" +#include "cg6.h" + +static const OptionInfoRec * CG6AvailableOptions(int chipid, int busid); +static void CG6Identify(int flags); +static Bool CG6Probe(DriverPtr drv, int flags); +static Bool CG6PreInit(ScrnInfoPtr pScrn, int flags); +static Bool CG6ScreenInit(int Index, ScreenPtr pScreen, int argc, + char **argv); +static Bool CG6EnterVT(int scrnIndex, int flags); +static void CG6LeaveVT(int scrnIndex, int flags); +static Bool CG6CloseScreen(int scrnIndex, ScreenPtr pScreen); +static Bool CG6SaveScreen(ScreenPtr pScreen, int mode); + +/* Required if the driver supports mode switching */ +static Bool CG6SwitchMode(int scrnIndex, DisplayModePtr mode, int flags); +/* Required if the driver supports moving the viewport */ +static void CG6AdjustFrame(int scrnIndex, int x, int y, int flags); + +/* Optional functions */ +static void CG6FreeScreen(int scrnIndex, int flags); +static int CG6ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, + int flags); + +void CG6Sync(ScrnInfoPtr pScrn); + +#define VERSION 4000 +#define CG6_NAME "SUNCG6" +#define CG6_DRIVER_NAME "suncg6" +#define CG6_MAJOR_VERSION 1 +#define CG6_MINOR_VERSION 0 +#define CG6_PATCHLEVEL 0 + +/* + * This contains the functions needed by the server after loading the driver + * module. It must be supplied, and gets passed back by the SetupProc + * function in the dynamic case. In the static case, a reference to this + * is compiled in, and this requires that the name of this DriverRec be + * an upper-case version of the driver name. + */ + +DriverRec SUNCG6 = { + VERSION, + CG6_DRIVER_NAME, + CG6Identify, + CG6Probe, + CG6AvailableOptions, + NULL, + 0 +}; + +typedef enum { + OPTION_SW_CURSOR, + OPTION_HW_CURSOR, + OPTION_NOACCEL +} CG6Opts; + +static const OptionInfoRec CG6Options[] = { + { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE } +}; + +#ifdef XFree86LOADER + +static MODULESETUPPROTO(cg6Setup); + +static XF86ModuleVersionInfo suncg6VersRec = +{ + "suncg6", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + CG6_MAJOR_VERSION, CG6_MINOR_VERSION, CG6_PATCHLEVEL, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + MOD_CLASS_VIDEODRV, + {0,0,0,0} +}; + +XF86ModuleData suncg6ModuleData = { &suncg6VersRec, cg6Setup, NULL }; + +pointer +cg6Setup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + static Bool setupDone = FALSE; + + if (!setupDone) { + setupDone = TRUE; + xf86AddDriver(&SUNCG6, module, 0); + + /* + * Modules that this driver always requires can be loaded here + * by calling LoadSubModule(). + */ + + /* + * The return value must be non-NULL on success even though there + * is no TearDownProc. + */ + return (pointer)TRUE; + } else { + if (errmaj) *errmaj = LDR_ONCEONLY; + return NULL; + } +} + +#endif /* XFree86LOADER */ + +static Bool +CG6GetRec(ScrnInfoPtr pScrn) +{ + /* + * Allocate an Cg6Rec, and hook it into pScrn->driverPrivate. + * pScrn->driverPrivate is initialised to NULL, so we can check if + * the allocation has already been done. + */ + if (pScrn->driverPrivate != NULL) + return TRUE; + + pScrn->driverPrivate = xnfcalloc(sizeof(Cg6Rec), 1); + return TRUE; +} + +static void +CG6FreeRec(ScrnInfoPtr pScrn) +{ + Cg6Ptr pCg6; + + if (pScrn->driverPrivate == NULL) + return; + + pCg6 = GET_CG6_FROM_SCRN(pScrn); + + xfree(pScrn->driverPrivate); + pScrn->driverPrivate = NULL; + + return; +} + +static const OptionInfoRec * +CG6AvailableOptions(int chipid, int busid) +{ + return CG6Options; +} + +/* Mandatory */ +static void +CG6Identify(int flags) +{ + xf86Msg(X_INFO, "%s: driver for CGsix (GX and Turbo GX)\n", CG6_NAME); +} + + +/* Mandatory */ +static Bool +CG6Probe(DriverPtr drv, int flags) +{ + int i; + GDevPtr *devSections; + int *usedChips; + int numDevSections; + int numUsed; + Bool foundScreen = FALSE; + EntityInfoPtr pEnt; + + /* + * The aim here is to find all cards that this driver can handle, + * and for the ones not already claimed by another driver, claim the + * slot, and allocate a ScrnInfoRec. + * + * This should be a minimal probe, and it should under no circumstances + * change the state of the hardware. Because a device is found, don't + * assume that it will be used. Don't do any initialisations other than + * the required ScrnInfoRec initialisations. Don't allocate any new + * data structures. + */ + + /* + * Next we check, if there has been a chipset override in the config file. + * For this we must find out if there is an active device section which + * is relevant, i.e., which has no driver specified or has THIS driver + * specified. + */ + + if ((numDevSections = xf86MatchDevice(CG6_DRIVER_NAME, + &devSections)) <= 0) { + /* + * There's no matching device section in the config file, so quit + * now. + */ + return FALSE; + } + + /* + * We need to probe the hardware first. We then need to see how this + * fits in with what is given in the config file, and allow the config + * file info to override any contradictions. + */ + + numUsed = xf86MatchSbusInstances(CG6_NAME, SBUS_DEVICE_CG6, + devSections, numDevSections, + drv, &usedChips); + + xfree(devSections); + if (numUsed <= 0) + return FALSE; + + if (flags & PROBE_DETECT) + foundScreen = TRUE; + else for (i = 0; i < numUsed; i++) { + pEnt = xf86GetEntityInfo(usedChips[i]); + + /* + * Check that nothing else has claimed the slots. + */ + if(pEnt->active) { + ScrnInfoPtr pScrn; + + /* Allocate a ScrnInfoRec and claim the slot */ + pScrn = xf86AllocateScreen(drv, 0); + + /* Fill in what we can of the ScrnInfoRec */ + pScrn->driverVersion = VERSION; + pScrn->driverName = CG6_DRIVER_NAME; + pScrn->name = CG6_NAME; + pScrn->Probe = CG6Probe; + pScrn->PreInit = CG6PreInit; + pScrn->ScreenInit = CG6ScreenInit; + pScrn->SwitchMode = CG6SwitchMode; + pScrn->AdjustFrame = CG6AdjustFrame; + pScrn->EnterVT = CG6EnterVT; + pScrn->LeaveVT = CG6LeaveVT; + pScrn->FreeScreen = CG6FreeScreen; + pScrn->ValidMode = CG6ValidMode; + xf86AddEntityToScreen(pScrn, pEnt->index); + foundScreen = TRUE; + } + xfree(pEnt); + } + xfree(usedChips); + return foundScreen; +} + +/* Mandatory */ +static Bool +CG6PreInit(ScrnInfoPtr pScrn, int flags) +{ + Cg6Ptr pCg6; + sbusDevicePtr psdp; + MessageType from; + int i; + + if (flags & PROBE_DETECT) return FALSE; + + /* + * Note: This function is only called once at server startup, and + * not at the start of each server generation. This means that + * only things that are persistent across server generations can + * be initialised here. xf86Screens[] is (pScrn is a pointer to one + * of these). Privates allocated using xf86AllocateScrnInfoPrivateIndex() + * are too, and should be used for data that must persist across + * server generations. + * + * Per-generation data should be allocated with + * AllocateScreenPrivateIndex() from the ScreenInit() function. + */ + + /* Allocate the Cg6Rec driverPrivate */ + if (!CG6GetRec(pScrn)) { + return FALSE; + } + pCg6 = GET_CG6_FROM_SCRN(pScrn); + + /* Set pScrn->monitor */ + pScrn->monitor = pScrn->confScreen->monitor; + + /* This driver doesn't expect more than one entity per screen */ + if (pScrn->numEntities > 1) + return FALSE; + /* This is the general case */ + for (i = 0; i < pScrn->numEntities; i++) { + EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[i]); + + /* CG6 is purely SBUS */ + if (pEnt->location.type == BUS_SBUS) { + psdp = xf86GetSbusInfoForEntity(pEnt->index); + pCg6->psdp = psdp; + } else + return FALSE; + } + + /********************* + deal with depth + *********************/ + + if (!xf86SetDepthBpp(pScrn, 0, 0, 0, NoDepth24Support)) { + return FALSE; + } else { + /* Check that the returned depth is one we support */ + switch (pScrn->depth) { + case 8: + /* OK */ + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Given depth (%d) is not supported by this driver\n", + pScrn->depth); + return FALSE; + } + } + + /* Collect all of the relevant option flags (fill in pScrn->options) */ + xf86CollectOptions(pScrn, NULL); + /* Process the options */ + if (!(pCg6->Options = xalloc(sizeof(CG6Options)))) + return FALSE; + memcpy(pCg6->Options, CG6Options, sizeof(CG6Options)); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pCg6->Options); + + if (!xf86SetDefaultVisual(pScrn, -1)) + return FALSE; + + /* + * The new cmap code requires this to be initialised. + */ + + { + Gamma zeros = {0.0, 0.0, 0.0}; + + if (!xf86SetGamma(pScrn, zeros)) { + return FALSE; + } + } + + /* Set the bits per RGB for 8bpp mode */ + from = X_DEFAULT; + + /* determine whether we use hardware or software cursor */ + + pCg6->HWCursor = TRUE; + if (xf86GetOptValBool(pCg6->Options, OPTION_HW_CURSOR, &pCg6->HWCursor)) + from = X_CONFIG; + if (xf86ReturnOptValBool(pCg6->Options, OPTION_SW_CURSOR, FALSE)) { + from = X_CONFIG; + pCg6->HWCursor = FALSE; + } + + xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n", + pCg6->HWCursor ? "HW" : "SW"); + + if (xf86ReturnOptValBool(pCg6->Options, OPTION_NOACCEL, FALSE)) { + pCg6->NoAccel = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Acceleration disabled\n"); + } + + if (xf86LoadSubModule(pScrn, "fb") == NULL) { + CG6FreeRec(pScrn); + return FALSE; + } + + if (pCg6->HWCursor && xf86LoadSubModule(pScrn, "ramdac") == NULL) { + CG6FreeRec(pScrn); + return FALSE; + } + + /********************* + set up clock and mode stuff + *********************/ + + pScrn->progClock = TRUE; + + if(pScrn->display->virtualX || pScrn->display->virtualY) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "CG6 does not support a virtual desktop\n"); + pScrn->display->virtualX = 0; + pScrn->display->virtualY = 0; + } + + xf86SbusUseBuiltinMode(pScrn, pCg6->psdp); + pScrn->currentMode = pScrn->modes; + pScrn->displayWidth = pScrn->virtualX; + + /* Set display resolution */ + xf86SetDpi(pScrn, 0, 0); + + return TRUE; +} + +/* Mandatory */ + +/* This gets called at the start of each server generation */ + +static Bool +CG6ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +{ + ScrnInfoPtr pScrn; + Cg6Ptr pCg6; + int ret; + + /* + * First get the ScrnInfoRec + */ + pScrn = xf86Screens[pScreen->myNum]; + + pCg6 = GET_CG6_FROM_SCRN(pScrn); + + /* Map the CG6 memory */ + pCg6->fbc = + xf86MapSbusMem (pCg6->psdp, CG6_FBC_VOFF, + CG6_RAM_VOFF - CG6_FBC_VOFF + + (pCg6->psdp->width * pCg6->psdp->height)); + + if (! pCg6->fbc) + return FALSE; + + pCg6->fb = (unsigned char *)pCg6->fbc + CG6_RAM_VOFF - CG6_FBC_VOFF; + pCg6->thc = (Cg6ThcPtr)((char *)pCg6->fbc + CG6_THC_VOFF - CG6_FBC_VOFF); + + /* Darken the screen for aesthetic reasons and set the viewport */ + CG6SaveScreen(pScreen, SCREEN_SAVER_ON); + + /* + * The next step is to setup the screen's visuals, and initialise the + * framebuffer code. In cases where the framebuffer's default + * choices for things like visual layouts and bits per RGB are OK, + * this may be as simple as calling the framebuffer's ScreenInit() + * function. If not, the visuals will need to be setup before calling + * a fb ScreenInit() function and fixed up after. + */ + + /* + * Reset visual list. + */ + miClearVisualTypes(); + + /* Set the bits per RGB for 8bpp mode */ + pScrn->rgbBits = 8; + + /* Setup the visuals we support. */ + + if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; + + miSetPixmapDepths (); + + /* + * Call the framebuffer layer's ScreenInit function, and fill in other + * pScreen fields. + */ + + ret = fbScreenInit(pScreen, pCg6->fb, pScrn->virtualX, + pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, + pScrn->virtualX, 8); + if (!ret) + return FALSE; + +#ifdef RENDER + fbPictureInit (pScreen, 0, 0); +#endif + + miInitializeBackingStore(pScreen); + xf86SetBackingStore(pScreen); + xf86SetSilkenMouse(pScreen); + + xf86SetBlackWhitePixels(pScreen); + +#if 0 + if (!pCg6->NoAccel) { + extern Bool CG6AccelInit(ScreenPtr pScreen, Cg6Ptr pCg6); + + if (!CG6AccelInit(pScreen, pCg6)) + return FALSE; + xf86Msg(X_INFO, "%s: Using acceleration\n", pCg6->psdp->device); + } +#endif + + /* Initialise cursor functions */ + miDCInitialize (pScreen, xf86GetPointerScreenFuncs()); + + /* Initialize HW cursor layer. + Must follow software cursor initialization*/ + if (pCg6->HWCursor) { + extern Bool CG6HWCursorInit(ScreenPtr pScreen); + + if(!CG6HWCursorInit(pScreen)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Hardware cursor initialization failed\n"); + return(FALSE); + } + xf86SbusHideOsHwCursor(pCg6->psdp); + } + + /* Initialise default colourmap */ + if (!miCreateDefColormap(pScreen)) + return FALSE; + + if(!xf86SbusHandleColormaps(pScreen, pCg6->psdp)) + return FALSE; + + pCg6->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = CG6CloseScreen; + pScreen->SaveScreen = CG6SaveScreen; + + /* Report any unused options (only for the first generation) */ + if (serverGeneration == 1) { + xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); + } + + /* unblank the screen */ + CG6SaveScreen(pScreen, SCREEN_SAVER_OFF); + + /* Done */ + return TRUE; +} + + +/* Usually mandatory */ +static Bool +CG6SwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +{ + return TRUE; +} + + +/* + * This function is used to initialize the Start Address - the first + * displayed location in the video memory. + */ +/* Usually mandatory */ +static void +CG6AdjustFrame(int scrnIndex, int x, int y, int flags) +{ + /* we don't support virtual desktops */ + return; +} + +/* + * This is called when VT switching back to the X server. Its job is + * to reinitialise the video mode. + */ + +/* Mandatory */ +static Bool +CG6EnterVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); + + if (pCg6->HWCursor) { + xf86SbusHideOsHwCursor (pCg6->psdp); + pCg6->CursorFg = 0; + pCg6->CursorBg = 0; + } + return TRUE; +} + + +/* + * This is called when VT switching away from the X server. + */ + +/* Mandatory */ +static void +CG6LeaveVT(int scrnIndex, int flags) +{ + return; +} + + +/* + * This is called at the end of each server generation. It restores the + * original (text) mode. It should really also unmap the video memory too. + */ + +/* Mandatory */ +static Bool +CG6CloseScreen(int scrnIndex, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); + + pScrn->vtSema = FALSE; + + xf86UnmapSbusMem(pCg6->psdp, pCg6->fbc, + CG6_RAM_VOFF - CG6_FBC_VOFF + + (pCg6->psdp->width * pCg6->psdp->height)); + + if (pCg6->HWCursor) + xf86SbusHideOsHwCursor(pCg6->psdp); + + pScreen->CloseScreen = pCg6->CloseScreen; + return (*pScreen->CloseScreen)(scrnIndex, pScreen); + return FALSE; +} + + +/* Free up any per-generation data structures */ + +/* Optional */ +static void +CG6FreeScreen(int scrnIndex, int flags) +{ + CG6FreeRec(xf86Screens[scrnIndex]); +} + + +/* Checks if a mode is suitable for the selected chipset. */ + +/* Optional */ +static int +CG6ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) +{ + if (mode->Flags & V_INTERLACE) + return(MODE_BAD); + + return(MODE_OK); +} + +/* Do screen blanking */ + +/* Mandatory */ +static Bool +CG6SaveScreen(ScreenPtr pScreen, int mode) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn); + unsigned int tmp = pCg6->thc->thc_misc; + + switch(mode) + { + case SCREEN_SAVER_ON: + case SCREEN_SAVER_CYCLE: + tmp &= ~CG6_THC_MISC_SYNC_ENAB; + break; + case SCREEN_SAVER_OFF: + case SCREEN_SAVER_FORCER: + tmp |= CG6_THC_MISC_SYNC_ENAB; + break; + default: + return FALSE; + } + + pCg6->thc->thc_misc = tmp; + return TRUE; +} + +/* + * This is the implementation of the Sync() function. + */ +void +CG6Sync(ScrnInfoPtr pScrn) +{ + return; +} diff --git a/src/cg6_regs.h b/src/cg6_regs.h new file mode 100644 index 0000000..f6f3f05 --- /dev/null +++ b/src/cg6_regs.h @@ -0,0 +1,194 @@ +/* + * GX and Turbo GX framebuffer - hardware registers. + * + * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com) + * + * 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 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 + * JAKUB JELINEK 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. + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_regs.h,v 1.1 2000/05/23 04:47:43 dawes Exp $ */ + +#ifndef CG6_REGS_H +#define CG6_REGS_H + +/* FHC definitions */ +#define CG6_FHC_FBID_SHIFT 24 +#define CG6_FHC_FBID_MASK 255 +#define CG6_FHC_REV_SHIFT 20 +#define CG6_FHC_REV_MASK 15 +#define CG6_FHC_FROP_DISABLE (1 << 19) +#define CG6_FHC_ROW_DISABLE (1 << 18) +#define CG6_FHC_SRC_DISABLE (1 << 17) +#define CG6_FHC_DST_DISABLE (1 << 16) +#define CG6_FHC_RESET (1 << 15) +#define CG6_FHC_LITTLE_ENDIAN (1 << 13) +#define CG6_FHC_RES_MASK (3 << 11) +#define CG6_FHC_1024 (0 << 11) +#define CG6_FHC_1152 (1 << 11) +#define CG6_FHC_1280 (2 << 11) +#define CG6_FHC_1600 (3 << 11) +#define CG6_FHC_CPU_MASK (3 << 9) +#define CG6_FHC_CPU_SPARC (0 << 9) +#define CG6_FHC_CPU_68020 (1 << 9) +#define CG6_FHC_CPU_386 (2 << 9) +#define CG6_FHC_TEST (1 << 8) +#define CG6_FHC_TEST_X_SHIFT 4 +#define CG6_FHC_TEST_X_MASK 15 +#define CG6_FHC_TEST_Y_SHIFT 0 +#define CG6_FHC_TEST_Y_MASK 15 + +/* FBC mode definitions */ +#define CG6_FBC_BLIT_IGNORE 0x00000000 +#define CG6_FBC_BLIT_NOSRC 0x00100000 +#define CG6_FBC_BLIT_SRC 0x00200000 +#define CG6_FBC_BLIT_ILLEGAL 0x00300000 +#define CG6_FBC_BLIT_MASK 0x00300000 + +#define CG6_FBC_VBLANK 0x00080000 + +#define CG6_FBC_MODE_IGNORE 0x00000000 +#define CG6_FBC_MODE_COLOR8 0x00020000 +#define CG6_FBC_MODE_COLOR1 0x00040000 +#define CG6_FBC_MODE_HRMONO 0x00060000 +#define CG6_FBC_MODE_MASK 0x00060000 + +#define CG6_FBC_DRAW_IGNORE 0x00000000 +#define CG6_FBC_DRAW_RENDER 0x00008000 +#define CG6_FBC_DRAW_PICK 0x00010000 +#define CG6_FBC_DRAW_ILLEGAL 0x00018000 +#define CG6_FBC_DRAW_MASK 0x00018000 + +#define CG6_FBC_BWRITE0_IGNORE 0x00000000 +#define CG6_FBC_BWRITE0_ENABLE 0x00002000 +#define CG6_FBC_BWRITE0_DISABLE 0x00004000 +#define CG6_FBC_BWRITE0_ILLEGAL 0x00006000 +#define CG6_FBC_BWRITE0_MASK 0x00006000 + +#define CG6_FBC_BWRITE1_IGNORE 0x00000000 +#define CG6_FBC_BWRITE1_ENABLE 0x00000800 +#define CG6_FBC_BWRITE1_DISABLE 0x00001000 +#define CG6_FBC_BWRITE1_ILLEGAL 0x00001800 +#define CG6_FBC_BWRITE1_MASK 0x00001800 + +#define CG6_FBC_BREAD_IGNORE 0x00000000 +#define CG6_FBC_BREAD_0 0x00000200 +#define CG6_FBC_BREAD_1 0x00000400 +#define CG6_FBC_BREAD_ILLEGAL 0x00000600 +#define CG6_FBC_BREAD_MASK 0x00000600 + +#define CG6_FBC_BDISP_IGNORE 0x00000000 +#define CG6_FBC_BDISP_0 0x00000080 +#define CG6_FBC_BDISP_1 0x00000100 +#define CG6_FBC_BDISP_ILLEGAL 0x00000180 +#define CG6_FBC_BDISP_MASK 0x00000180 + +#define CG6_FBC_INDEX_MOD 0x00000040 +#define CG6_FBC_INDEX_MASK 0x00000030 + +/* THC definitions */ +#define CG6_THC_MISC_REV_SHIFT 16 +#define CG6_THC_MISC_REV_MASK 15 +#define CG6_THC_MISC_RESET (1 << 12) +#define CG6_THC_MISC_VIDEO (1 << 10) +#define CG6_THC_MISC_SYNC (1 << 9) +#define CG6_THC_MISC_VSYNC (1 << 8) +#define CG6_THC_MISC_SYNC_ENAB (1 << 7) +#define CG6_THC_MISC_CURS_RES (1 << 6) +#define CG6_THC_MISC_INT_ENAB (1 << 5) +#define CG6_THC_MISC_INT (1 << 4) +#define CG6_THC_MISC_INIT 0x9f + +typedef struct cg6_tec { + volatile unsigned int tec_matrix; + volatile unsigned int tec_clip; + volatile unsigned int tec_vdc; +} Cg6Tec, *Cg6TecPtr; + +typedef struct cg6_thc { + unsigned int thc_pad0[512]; + volatile unsigned int thc_hs; /* hsync timing */ + volatile unsigned int thc_hsdvs; + volatile unsigned int thc_hd; + volatile unsigned int thc_vs; /* vsync timing */ + volatile unsigned int thc_vd; + volatile unsigned int thc_refresh; + volatile unsigned int thc_misc; + unsigned int thc_pad1[56]; + volatile unsigned int thc_cursxy; /* cursor x,y position (16 bits each) */ + volatile unsigned int thc_cursmask[32];/* cursor mask bits */ + volatile unsigned int thc_cursbits[32];/* what to show where mask enabled */ +} Cg6Thc, *Cg6ThcPtr; + +typedef struct cg6_fbc { + unsigned int xxx0[1]; + volatile unsigned int mode; + volatile unsigned int clip; + unsigned int xxx1[1]; + volatile unsigned int s; + volatile unsigned int draw; + volatile unsigned int blit; + volatile unsigned int font; + unsigned int xxx2[24]; + volatile unsigned int x0, y0, z0, color0; + volatile unsigned int x1, y1, z1, color1; + volatile unsigned int x2, y2, z2, color2; + volatile unsigned int x3, y3, z3, color3; + volatile unsigned int offx, offy; + unsigned int xxx3[2]; + volatile unsigned int incx, incy; + unsigned int xxx4[2]; + volatile unsigned int clipminx, clipminy; + unsigned int xxx5[2]; + volatile unsigned int clipmaxx, clipmaxy; + unsigned int xxx6[2]; + volatile unsigned int fg; + volatile unsigned int bg; + volatile unsigned int alu; + volatile unsigned int pm; + volatile unsigned int pixelm; + unsigned int xxx7[2]; + volatile unsigned int patalign; + volatile unsigned int pattern[8]; + unsigned int xxx8[432]; + volatile unsigned int apointx, apointy, apointz; + unsigned int xxx9[1]; + volatile unsigned int rpointx, rpointy, rpointz; + unsigned int xxx10[5]; + volatile unsigned int pointr, pointg, pointb, pointa; + volatile unsigned int alinex, aliney, alinez; + unsigned int xxx11[1]; + volatile unsigned int rlinex, rliney, rlinez; + unsigned int xxx12[5]; + volatile unsigned int liner, lineg, lineb, linea; + volatile unsigned int atrix, atriy, atriz; + unsigned int xxx13[1]; + volatile unsigned int rtrix, rtriy, rtriz; + unsigned int xxx14[5]; + volatile unsigned int trir, trig, trib, tria; + volatile unsigned int aquadx, aquady, aquadz; + unsigned int xxx15[1]; + volatile unsigned int rquadx, rquady, rquadz; + unsigned int xxx16[5]; + volatile unsigned int quadr, quadg, quadb, quada; + volatile unsigned int arectx, arecty, arectz; + unsigned int xxx17[1]; + volatile unsigned int rrectx, rrecty, rrectz; + unsigned int xxx18[5]; + volatile unsigned int rectr, rectg, rectb, recta; +} Cg6Fbc, *Cg6FbcPtr; + +#endif /* CG6_REGS_H */ |