Commit 5a01d143 authored by Kaleb Keithley Keithley's avatar Kaleb Keithley Keithley
Browse files

Initial revision

parents
.\" $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>
/*
* 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 */
/*
* 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);
}
/*
* 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)) {