summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:48:55 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:48:55 +0000
commitca3b63783fc4aa1df725dbd0e560a446dcc17913 (patch)
tree6f2c958138a99a021823e85627c014f174cfea2b
Initial revisionXORG-STABLE
-rw-r--r--src/dummy.h76
-rw-r--r--src/dummy_cursor.c101
-rw-r--r--src/dummy_dga.c174
-rw-r--r--src/dummy_driver.c781
4 files changed, 1132 insertions, 0 deletions
diff --git a/src/dummy.h b/src/dummy.h
new file mode 100644
index 0000000..3f9243d
--- /dev/null
+++ b/src/dummy.h
@@ -0,0 +1,76 @@
+
+/* All drivers should typically include these */
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+
+#include "xf86Cursor.h"
+
+#ifdef XvExtension
+# include "xf86xv.h"
+# include "Xv.h"
+#endif /* XvExtension */
+
+
+/* Supported chipsets */
+typedef enum {
+ DUMMY_CHIP
+} DUMMYType;
+
+/* function prototypes */
+
+extern Bool DUMMYSwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
+extern void DUMMYAdjustFrame(int scrnIndex, int x, int y, int flags);
+
+/* in dummy_cursor.c */
+extern Bool DUMMYCursorInit(ScreenPtr pScrn);
+extern void DUMMYShowCursor(ScrnInfoPtr pScrn);
+extern void DUMMYHideCursor(ScrnInfoPtr pScrn);
+
+/* in dummy_dga.c */
+Bool DUMMYDGAInit(ScreenPtr pScreen);
+
+/* in dummy_video.c */
+extern void DUMMYInitVideo(ScreenPtr pScreen);
+
+/* globals */
+typedef struct _color
+{
+ int red;
+ int green;
+ int blue;
+} dummy_colors;
+
+typedef struct dummyRec
+{
+ DGAModePtr DGAModes;
+ int numDGAModes;
+ Bool DGAactive;
+ int DGAViewportStatus;
+ /* options */
+ OptionInfoPtr Options;
+ Bool swCursor;
+ /* proc pointer */
+ CloseScreenProcPtr CloseScreen;
+ xf86CursorInfoPtr CursorInfo;
+
+ Bool DummyHWCursorShown;
+ int cursorX, cursorY;
+ int cursorFG, cursorBG;
+
+ Bool screenSaver;
+#ifdef XvExtension
+ Bool video;
+ XF86VideoAdaptorPtr overlayAdaptor;
+ int overlay;
+ int overlay_offset;
+ int videoKey;
+ int interlace;
+#endif /* XvExtension */
+ dummy_colors colors[256];
+ pointer* FBBase;
+} DUMMYRec, *DUMMYPtr;
+
+/* The privates of the DUMMY driver */
+#define DUMMYPTR(p) ((DUMMYPtr)((p)->driverPrivate))
+
diff --git a/src/dummy_cursor.c b/src/dummy_cursor.c
new file mode 100644
index 0000000..a83b326
--- /dev/null
+++ b/src/dummy_cursor.c
@@ -0,0 +1,101 @@
+/* All drivers should typically include these */
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+
+#include "xf86Cursor.h"
+#include "cursorstr.h"
+/* Driver specific headers */
+#include "dummy.h"
+
+static void
+dummyShowCursor(ScrnInfoPtr pScrn)
+{
+ DUMMYPtr dPtr = DUMMYPTR(pScrn);
+
+ /* turn cursor on */
+ dPtr->DummyHWCursorShown = TRUE;
+}
+
+static void
+dummyHideCursor(ScrnInfoPtr pScrn)
+{
+ DUMMYPtr dPtr = DUMMYPTR(pScrn);
+
+ /*
+ * turn cursor off
+ *
+ */
+ dPtr->DummyHWCursorShown = FALSE;
+}
+
+#define MAX_CURS 64
+
+static void
+dummySetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
+{
+ DUMMYPtr dPtr = DUMMYPTR(pScrn);
+
+/* unsigned char *_dest = ((unsigned char *)dPtr->FBBase + */
+/* pScrn->videoRam * 1024 - 1024); */
+ dPtr->cursorX = x;
+ dPtr->cursorY = y;
+}
+
+static void
+dummySetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
+{
+ DUMMYPtr dPtr = DUMMYPTR(pScrn);
+
+ dPtr->cursorFG = fg;
+ dPtr->cursorBG = bg;
+}
+
+static void
+dummyLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
+{
+}
+
+static Bool
+dummyUseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
+{
+ DUMMYPtr dPtr = DUMMYPTR(xf86Screens[pScr->myNum]);
+ return(!dPtr->swCursor);
+}
+
+#if 0
+static unsigned char*
+dummyRealizeCursor(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
+{
+ return NULL;
+}
+#endif
+
+Bool
+DUMMYCursorInit(ScreenPtr pScreen)
+{
+ DUMMYPtr dPtr = DUMMYPTR(xf86Screens[pScreen->myNum]);
+
+ xf86CursorInfoPtr infoPtr;
+ infoPtr = xf86CreateCursorInfoRec();
+ if(!infoPtr) return FALSE;
+
+ dPtr->CursorInfo = infoPtr;
+
+ infoPtr->MaxHeight = 64;
+ infoPtr->MaxWidth = 64;
+ infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP;
+
+ infoPtr->SetCursorColors = dummySetCursorColors;
+ infoPtr->SetCursorPosition = dummySetCursorPosition;
+ infoPtr->LoadCursorImage = dummyLoadCursorImage;
+ infoPtr->HideCursor = dummyHideCursor;
+ infoPtr->ShowCursor = dummyShowCursor;
+ infoPtr->UseHWCursor = dummyUseHWCursor;
+/* infoPtr->RealizeCursor = dummyRealizeCursor; */
+
+ return(xf86InitCursor(pScreen, infoPtr));
+}
+
+
+
diff --git a/src/dummy_dga.c b/src/dummy_dga.c
new file mode 100644
index 0000000..5e35eda
--- /dev/null
+++ b/src/dummy_dga.c
@@ -0,0 +1,174 @@
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Pci.h"
+#include "xf86PciInfo.h"
+#include "dgaproc.h"
+#include "dummy.h"
+
+static Bool DUMMY_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **,
+ int *, int *, int *);
+static Bool DUMMY_SetMode(ScrnInfoPtr, DGAModePtr);
+static int DUMMY_GetViewport(ScrnInfoPtr);
+static void DUMMY_SetViewport(ScrnInfoPtr, int, int, int);
+
+static
+DGAFunctionRec DUMMYDGAFuncs = {
+ DUMMY_OpenFramebuffer,
+ NULL,
+ DUMMY_SetMode,
+ DUMMY_SetViewport,
+ DUMMY_GetViewport,
+ NULL,
+ NULL,
+ NULL,
+#if 0
+ DUMMY_BlitTransRect
+#else
+ NULL
+#endif
+};
+
+Bool
+DUMMYDGAInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ DUMMYPtr pDUMMY = DUMMYPTR(pScrn);
+ DGAModePtr modes = NULL, newmodes = NULL, currentMode;
+ DisplayModePtr pMode, firstMode;
+ int Bpp = pScrn->bitsPerPixel >> 3;
+ int num = 0, imlines, pixlines;
+
+ imlines = (pScrn->videoRam * 1024) /
+ (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3));
+
+ pixlines = imlines;
+
+ pMode = firstMode = pScrn->modes;
+
+ while(pMode) {
+
+ newmodes = xrealloc(modes, (num + 1) * sizeof(DGAModeRec));
+
+ if(!newmodes) {
+ xfree(modes);
+ return FALSE;
+ }
+ modes = newmodes;
+
+ currentMode = modes + num;
+ num++;
+
+ currentMode->mode = pMode;
+ currentMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE;
+ if(pMode->Flags & V_DBLSCAN)
+ currentMode->flags |= DGA_DOUBLESCAN;
+ if(pMode->Flags & V_INTERLACE)
+ currentMode->flags |= DGA_INTERLACED;
+ currentMode->byteOrder = pScrn->imageByteOrder;
+ currentMode->depth = pScrn->depth;
+ currentMode->bitsPerPixel = pScrn->bitsPerPixel;
+ currentMode->red_mask = pScrn->mask.red;
+ currentMode->green_mask = pScrn->mask.green;
+ currentMode->blue_mask = pScrn->mask.blue;
+ currentMode->visualClass = (Bpp == 1) ? PseudoColor : TrueColor;
+ currentMode->viewportWidth = pMode->HDisplay;
+ currentMode->viewportHeight = pMode->VDisplay;
+ currentMode->xViewportStep = 1;
+ currentMode->yViewportStep = 1;
+ currentMode->viewportFlags = DGA_FLIP_RETRACE;
+ currentMode->offset = 0;
+ currentMode->address = (unsigned char *)pDUMMY->FBBase;
+
+ currentMode->bytesPerScanline =
+ ((pScrn->displayWidth * Bpp) + 3) & ~3L;
+ currentMode->imageWidth = pScrn->displayWidth;
+ currentMode->imageHeight = imlines;
+ currentMode->pixmapWidth = currentMode->imageWidth;
+ currentMode->pixmapHeight = pixlines;
+ currentMode->maxViewportX = currentMode->imageWidth -
+ currentMode->viewportWidth;
+ currentMode->maxViewportY = currentMode->imageHeight -
+ currentMode->viewportHeight;
+
+ pMode = pMode->next;
+ if(pMode == firstMode)
+ break;
+ }
+
+ pDUMMY->numDGAModes = num;
+ pDUMMY->DGAModes = modes;
+
+ return DGAInit(pScreen, &DUMMYDGAFuncs, modes, num);
+}
+
+static DisplayModePtr DUMMYSavedDGAModes[MAXSCREENS];
+
+static Bool
+DUMMY_SetMode(
+ ScrnInfoPtr pScrn,
+ DGAModePtr pMode
+){
+ int index = pScrn->pScreen->myNum;
+ DUMMYPtr pDUMMY = DUMMYPTR(pScrn);
+
+ if(!pMode) { /* restore the original mode */
+ if(pDUMMY->DGAactive) {
+ pScrn->currentMode = DUMMYSavedDGAModes[index];
+ DUMMYSwitchMode(index, pScrn->currentMode, 0);
+ DUMMYAdjustFrame(index, 0, 0, 0);
+ pDUMMY->DGAactive = FALSE;
+ }
+ } else {
+ if(!pDUMMY->DGAactive) { /* save the old parameters */
+ DUMMYSavedDGAModes[index] = pScrn->currentMode;
+ pDUMMY->DGAactive = TRUE;
+ }
+
+ DUMMYSwitchMode(index, pMode->mode, 0);
+ }
+
+ return TRUE;
+}
+
+static int
+DUMMY_GetViewport(
+ ScrnInfoPtr pScrn
+){
+ DUMMYPtr pDUMMY = DUMMYPTR(pScrn);
+
+ return pDUMMY->DGAViewportStatus;
+}
+
+static void
+DUMMY_SetViewport(
+ ScrnInfoPtr pScrn,
+ int x, int y,
+ int flags
+){
+ DUMMYPtr pDUMMY = DUMMYPTR(pScrn);
+
+ DUMMYAdjustFrame(pScrn->pScreen->myNum, x, y, flags);
+ pDUMMY->DGAViewportStatus = 0;
+}
+
+
+static Bool
+DUMMY_OpenFramebuffer(
+ ScrnInfoPtr pScrn,
+ char **name,
+ unsigned char **mem,
+ int *size,
+ int *offset,
+ int *flags
+){
+ DUMMYPtr pDUMMY = DUMMYPTR(pScrn);
+
+ *name = NULL; /* no special device */
+ *mem = (unsigned char*)pDUMMY->FBBase;
+ *size = pScrn->videoRam * 1024;
+ *offset = 0;
+ *flags = DGA_NEED_ROOT;
+
+ return TRUE;
+}
diff --git a/src/dummy_driver.c b/src/dummy_driver.c
new file mode 100644
index 0000000..d95edb0
--- /dev/null
+++ b/src/dummy_driver.c
@@ -0,0 +1,781 @@
+
+/*
+ * Copyright 2002, SuSE Linux AG, Author: Egbert Eich
+ */
+
+/* All drivers should typically include these */
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Bus.h"
+
+/* This is used for module versioning */
+#include "xf86Version.h"
+
+/* All drivers initialising the SW cursor need this */
+#include "mipointer.h"
+
+/* All drivers implementing backing store need this */
+#include "mibstore.h"
+
+/* All drivers using the mi colormap manipulation need this */
+#include "micmap.h"
+
+#include "xf86cmap.h"
+
+#include "xf86fbman.h"
+
+#include "fb.h"
+
+#include "picturestr.h"
+
+#ifdef XvExtension
+#include "xf86xv.h"
+#include "Xv.h"
+#endif
+
+/*
+ * Driver data structures.
+ */
+#include "dummy.h"
+
+/* These need to be checked */
+#include "X.h"
+#include "Xproto.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+#define _XF86DGA_SERVER_
+#include "extensions/xf86dgastr.h"
+
+/* Mandatory functions */
+static const OptionInfoRec * DUMMYAvailableOptions(int chipid, int busid);
+static void DUMMYIdentify(int flags);
+static Bool DUMMYProbe(DriverPtr drv, int flags);
+static Bool DUMMYPreInit(ScrnInfoPtr pScrn, int flags);
+static Bool DUMMYScreenInit(int Index, ScreenPtr pScreen, int argc,
+ char **argv);
+static Bool DUMMYEnterVT(int scrnIndex, int flags);
+static void DUMMYLeaveVT(int scrnIndex, int flags);
+static Bool DUMMYCloseScreen(int scrnIndex, ScreenPtr pScreen);
+static void DUMMYFreeScreen(int scrnIndex, int flags);
+static int DUMMYValidMode(int scrnIndex, DisplayModePtr mode,
+ Bool verbose, int flags);
+static Bool DUMMYSaveScreen(ScreenPtr pScreen, int mode);
+
+/* Internally used functions */
+static Bool dummyModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
+static void dummySave(ScrnInfoPtr pScrn);
+static void dummyRestore(ScrnInfoPtr pScrn, Bool restoreText);
+
+/* static void DUMMYDisplayPowerManagementSet(ScrnInfoPtr pScrn, */
+/* int PowerManagementMode, int flags); */
+
+#define VERSION 4000
+#define DUMMY_NAME "DUMMY"
+#define DUMMY_DRIVER_NAME "dummy"
+
+#define DUMMY_MAJOR_VERSION 0
+#define DUMMY_MINOR_VERSION 1
+#define DUMMY_PATCHLEVEL 0
+
+/*
+ * This is intentionally screen-independent. It indicates the binding
+ * choice made in the first PreInit.
+ */
+static int pix24bpp = 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 DUMMY = {
+ VERSION,
+ DUMMY_DRIVER_NAME,
+ DUMMYIdentify,
+ DUMMYProbe,
+ DUMMYAvailableOptions,
+ NULL,
+ 0
+};
+
+static SymTabRec DUMMYChipsets[] = {
+ { DUMMY_CHIP, "dummy" },
+ { -1, NULL }
+};
+
+typedef enum {
+ OPTION_SW_CURSOR
+} DUMMYOpts;
+
+static const OptionInfoRec DUMMYOptions[] = {
+ { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
+};
+
+
+/*
+ * List of symbols from other modules that this module references. This
+ * list is used to tell the loader that it is OK for symbols here to be
+ * unresolved providing that it hasn't been told that they haven't been
+ * told that they are essential via a call to xf86LoaderReqSymbols() or
+ * xf86LoaderReqSymLists(). The purpose is this is to avoid warnings about
+ * unresolved symbols that are not required.
+ */
+
+static const char *fbSymbols[] = {
+ "fbPictureInit",
+ "fbScreenInit",
+ NULL
+};
+
+static const char *ramdacSymbols[] = {
+ "xf86CreateCursorInfoRec",
+ "xf86DestroyCursorInfoRec",
+ "xf86InitCursor",
+ NULL
+};
+
+
+#ifdef XFree86LOADER
+
+static MODULESETUPPROTO(dummySetup);
+
+static XF86ModuleVersionInfo dummyVersRec =
+{
+ "dummy",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XF86_VERSION_CURRENT,
+ DUMMY_MAJOR_VERSION, DUMMY_MINOR_VERSION, DUMMY_PATCHLEVEL,
+ ABI_CLASS_VIDEODRV,
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_VIDEODRV,
+ {0,0,0,0}
+};
+
+/*
+ * This is the module init data.
+ * Its name has to be the driver name followed by ModuleData
+ */
+XF86ModuleData dummyModuleData = { &dummyVersRec, dummySetup, NULL };
+
+static pointer
+dummySetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = FALSE;
+
+ if (!setupDone) {
+ setupDone = TRUE;
+ xf86AddDriver(&DUMMY, module, 0);
+
+ /*
+ * Modules that this driver always requires can be loaded here
+ * by calling LoadSubModule().
+ */
+
+ /*
+ * Tell the loader about symbols from other modules that this module
+ * might refer to.
+ */
+ LoaderRefSymLists(fbSymbols, ramdacSymbols, NULL);
+ /*
+ * The return value must be non-NULL on success even though there
+ * is no TearDownProc.
+ */
+ return (pointer)1;
+ } else {
+ if (errmaj) *errmaj = LDR_ONCEONLY;
+ return NULL;
+ }
+}
+
+#endif /* XFree86LOADER */
+
+static Bool
+DUMMYGetRec(ScrnInfoPtr pScrn)
+{
+ /*
+ * Allocate a DUMMYRec, 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(DUMMYRec), 1);
+
+ if (pScrn->driverPrivate == NULL)
+ return FALSE;
+ return TRUE;
+}
+
+static void
+DUMMYFreeRec(ScrnInfoPtr pScrn)
+{
+ if (pScrn->driverPrivate == NULL)
+ return;
+ xfree(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
+}
+
+static const OptionInfoRec *
+DUMMYAvailableOptions(int chipid, int busid)
+{
+ return DUMMYOptions;
+}
+
+/* Mandatory */
+static void
+DUMMYIdentify(int flags)
+{
+ xf86PrintChipsets(DUMMY_NAME, "Driver for Dummy chipsets",
+ DUMMYChipsets);
+}
+
+/* Mandatory */
+static Bool
+DUMMYProbe(DriverPtr drv, int flags)
+{
+ Bool foundScreen = FALSE;
+ int numDevSections, numUsed;
+ GDevPtr *devSections;
+ int i;
+
+ if (flags & PROBE_DETECT)
+ return FALSE;
+ /*
+ * Find the config file Device sections that match this
+ * driver, and return if there are none.
+ */
+ if ((numDevSections = xf86MatchDevice(DUMMY_DRIVER_NAME,
+ &devSections)) <= 0) {
+ return FALSE;
+ }
+
+ numUsed = numDevSections;
+
+ if (numUsed > 0) {
+
+ for (i = 0; i < numUsed; i++) {
+ ScrnInfoPtr pScrn = NULL;
+ int entityIndex =
+ xf86ClaimNoSlot(drv,DUMMY_CHIP,devSections[i],TRUE);
+ /* Allocate a ScrnInfoRec and claim the slot */
+ if ((pScrn = xf86AllocateScreen(drv,0 ))) {
+ xf86AddEntityToScreen(pScrn,entityIndex);
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = DUMMY_DRIVER_NAME;
+ pScrn->name = DUMMY_NAME;
+ pScrn->Probe = DUMMYProbe;
+ pScrn->PreInit = DUMMYPreInit;
+ pScrn->ScreenInit = DUMMYScreenInit;
+ pScrn->SwitchMode = DUMMYSwitchMode;
+ pScrn->AdjustFrame = DUMMYAdjustFrame;
+ pScrn->EnterVT = DUMMYEnterVT;
+ pScrn->LeaveVT = DUMMYLeaveVT;
+ pScrn->FreeScreen = DUMMYFreeScreen;
+ pScrn->ValidMode = DUMMYValidMode;
+
+ foundScreen = TRUE;
+ }
+ }
+ }
+ return foundScreen;
+}
+
+# define RETURN \
+ { DUMMYFreeRec(pScrn);\
+ return FALSE;\
+ }
+
+/* Mandatory */
+Bool
+DUMMYPreInit(ScrnInfoPtr pScrn, int flags)
+{
+ ClockRangePtr clockRanges;
+ int i;
+ DUMMYPtr dPtr;
+ int maxClock = 230000;
+ GDevPtr device = xf86GetEntityInfo(pScrn->entityList[0])->device;
+
+ if (flags & PROBE_DETECT)
+ return TRUE;
+
+ /* Allocate the DummyRec driverPrivate */
+ if (!DUMMYGetRec(pScrn)) {
+ return FALSE;
+ }
+# define RETURN \
+ { DUMMYFreeRec(pScrn);\
+ return FALSE;\
+ }
+
+ dPtr = DUMMYPTR(pScrn);
+
+ pScrn->chipset = (char *)xf86TokenToString(DUMMYChipsets,
+ DUMMY_CHIP);
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Chipset is a DUMMY\n");
+
+ pScrn->monitor = pScrn->confScreen->monitor;
+
+ if (!xf86SetDepthBpp(pScrn, 8, 8, 8, Support24bppFb | Support32bppFb))
+ return FALSE;
+ else {
+ /* Check that the returned depth is one we support */
+ switch (pScrn->depth) {
+ case 8:
+ case 15:
+ case 16:
+ case 24:
+ break;
+ default:
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Given depth (%d) is not supported by this driver\n",
+ pScrn->depth);
+ return FALSE;
+ }
+ }
+
+ xf86PrintDepthBpp(pScrn);
+ if (pScrn->depth == 8)
+ pScrn->rgbBits = 8;
+
+ /* Get the depth24 pixmap format */
+ if (pScrn->depth == 24 && pix24bpp == 0)
+ pix24bpp = xf86GetBppFromDepth(pScrn, 24);
+
+ /*
+ * This must happen after pScrn->display has been set because
+ * xf86SetWeight references it.
+ */
+ if (pScrn->depth > 8) {
+ /* The defaults are OK for us */
+ rgb zeros = {0, 0, 0};
+
+ if (!xf86SetWeight(pScrn, zeros, zeros)) {
+ return FALSE;
+ } else {
+ /* XXX check that weight returned is supported */
+ ;
+ }
+ }
+
+ if (!xf86SetDefaultVisual(pScrn, -1))
+ return FALSE;
+
+ if (pScrn->depth > 1) {
+ Gamma zeros = {0.0, 0.0, 0.0};
+
+ if (!xf86SetGamma(pScrn, zeros))
+ return FALSE;
+ }
+
+ xf86CollectOptions(pScrn, device->options);
+ /* Process the options */
+ if (!(dPtr->Options = xalloc(sizeof(DUMMYOptions))))
+ return FALSE;
+ memcpy(dPtr->Options, DUMMYOptions, sizeof(DUMMYOptions));
+
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, dPtr->Options);
+
+ xf86GetOptValBool(dPtr->Options, OPTION_SW_CURSOR,&dPtr->swCursor);
+
+ if (device->videoRam != 0) {
+ pScrn->videoRam = device->videoRam;
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "VideoRAM: %d kByte\n",
+ pScrn->videoRam);
+ } else {
+ pScrn->videoRam = 4096;
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "VideoRAM: %d kByte\n",
+ pScrn->videoRam);
+ }
+
+ if (device->dacSpeeds[0] != 0) {
+ maxClock = device->dacSpeeds[0];
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Max Clock: %d kHz\n",
+ maxClock);
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Max Clock: %d kHz\n",
+ maxClock);
+ }
+
+ pScrn->progClock = TRUE;
+ /*
+ * Setup the ClockRanges, which describe what clock ranges are available,
+ * and what sort of modes they can be used for.
+ */
+ clockRanges = (ClockRangePtr)xnfcalloc(sizeof(ClockRange), 1);
+ clockRanges->next = NULL;
+ clockRanges->ClockMulFactor = 1;
+ clockRanges->minClock = 11000; /* guessed */
+ clockRanges->maxClock = 300000;
+ clockRanges->clockIndex = -1; /* programmable */
+ clockRanges->interlaceAllowed = TRUE;
+ clockRanges->doubleScanAllowed = TRUE;
+
+ /* Subtract memory for HW cursor */
+
+
+ {
+ int apertureSize = (pScrn->videoRam * 1024);
+ i = xf86ValidateModes(pScrn, pScrn->monitor->Modes,
+ pScrn->display->modes, clockRanges,
+ NULL, 256, 2048,(8 * pScrn->bitsPerPixel),
+ 128, 2048, pScrn->display->virtualX,
+ pScrn->display->virtualY, apertureSize,
+ LOOKUP_BEST_REFRESH);
+
+ if (i == -1)
+ RETURN;
+ }
+
+ /* Prune the modes marked as invalid */
+ xf86PruneDriverModes(pScrn);
+
+ if (i == 0 || pScrn->modes == NULL) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n");
+ RETURN;
+ }
+
+ /*
+ * Set the CRTC parameters for all of the modes based on the type
+ * of mode, and the chipset's interlace requirements.
+ *
+ * Calling this is required if the mode->Crtc* values are used by the
+ * driver and if the driver doesn't provide code to set them. They
+ * are not pre-initialised at all.
+ */
+ xf86SetCrtcForModes(pScrn, 0);
+
+ /* Set the current mode to the first in the list */
+ pScrn->currentMode = pScrn->modes;
+
+ /* Print the list of modes being used */
+ xf86PrintModes(pScrn);
+
+ /* If monitor resolution is set on the command line, use it */
+ xf86SetDpi(pScrn, 0, 0);
+
+ if (xf86LoadSubModule(pScrn, "fb") == NULL) {
+ RETURN;
+ }
+ xf86LoaderReqSymLists(fbSymbols, NULL);
+
+ if (!dPtr->swCursor) {
+ if (!xf86LoadSubModule(pScrn, "ramdac"))
+ RETURN;
+ xf86LoaderReqSymLists(ramdacSymbols, NULL);
+ }
+
+ return TRUE;
+}
+#undef RETURN
+
+/* Mandatory */
+static Bool
+DUMMYEnterVT(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+
+ /* Should we re-save the text mode on each VT enter? */
+ if(!dummyModeInit(pScrn, pScrn->currentMode))
+ return FALSE;
+
+ DUMMYAdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+
+ return TRUE;
+}
+
+/* Mandatory */
+static void
+DUMMYLeaveVT(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ dummyRestore(pScrn, TRUE);
+}
+
+static void
+DUMMYLoadPalette(
+ ScrnInfoPtr pScrn,
+ int numColors,
+ int *indices,
+ LOCO *colors,
+ VisualPtr pVisual
+){
+ int i, index, shift, Gshift;
+ DUMMYPtr dPtr = DUMMYPTR(pScrn);
+
+ switch(pScrn->depth) {
+ case 15:
+ shift = Gshift = 1;
+ break;
+ case 16:
+ shift = 0;
+ Gshift = 0;
+ break;
+ default:
+ shift = Gshift = 0;
+ break;
+ }
+
+ for(i = 0; i < numColors; i++) {
+ index = indices[i];
+ dPtr->colors[index].red = colors[index].red << shift;
+ dPtr->colors[index].green = colors[index].green << Gshift;
+ dPtr->colors[index].blue = colors[index].blue << shift;
+ }
+
+}
+
+/* Mandatory */
+static Bool
+DUMMYScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+{
+ ScrnInfoPtr pScrn;
+ DUMMYPtr dPtr;
+ int ret;
+ VisualPtr visual;
+ int height, width;
+
+ /*
+ * we need to get the ScrnInfoRec for this screen, so let's allocate
+ * one first thing
+ */
+ pScrn = xf86Screens[pScreen->myNum];
+ dPtr = DUMMYPTR(pScrn);
+
+
+ if (!(dPtr->FBBase = xalloc(pScrn->videoRam * 1024)))
+ return FALSE;
+
+ /*
+ * next we save the current state and setup the first mode
+ */
+ dummySave(pScrn);
+
+ if (!dummyModeInit(pScrn,pScrn->currentMode))
+ return FALSE;
+ DUMMYAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+
+ /*
+ * Reset visual list.
+ */
+ miClearVisualTypes();
+
+ /* Setup the visuals we support. */
+
+ if (!miSetVisualTypes(pScrn->depth,
+ miGetDefaultVisualMask(pScrn->depth),
+ pScrn->rgbBits, pScrn->defaultVisual))
+ return FALSE;
+
+ if (!miSetPixmapDepths ()) return FALSE;
+
+ /*
+ * Call the framebuffer layer's ScreenInit function, and fill in other
+ * pScreen fields.
+ */
+ width = pScrn->virtualX;
+ height = pScrn->virtualY;
+
+ ret = fbScreenInit(pScreen, dPtr->FBBase,
+ pScrn->virtualX, pScrn->virtualY,
+ pScrn->xDpi, pScrn->yDpi,
+ pScrn->displayWidth, pScrn->bitsPerPixel);
+ if (!ret)
+ return FALSE;
+
+ if (pScrn->depth > 8) {
+ /* Fixup RGB ordering */
+ visual = pScreen->visuals + pScreen->numVisuals;
+ while (--visual >= pScreen->visuals) {
+ if ((visual->class | DynamicClass) == DirectColor) {
+ visual->offsetRed = pScrn->offset.red;
+ visual->offsetGreen = pScrn->offset.green;
+ visual->offsetBlue = pScrn->offset.blue;
+ visual->redMask = pScrn->mask.red;
+ visual->greenMask = pScrn->mask.green;
+ visual->blueMask = pScrn->mask.blue;
+ }
+ }
+ }
+
+ /* must be after RGB ordering fixed */
+ fbPictureInit(pScreen, 0, 0);
+
+ xf86SetBlackWhitePixels(pScreen);
+
+ DUMMYDGAInit(pScreen);
+
+ if (dPtr->swCursor)
+ xf86DrvMsg(scrnIndex, X_CONFIG, "Using Software Cursor.\n");
+
+ {
+
+
+ BoxRec AvailFBArea;
+ int lines = pScrn->videoRam * 1024 /
+ (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3));
+ AvailFBArea.x1 = 0;
+ AvailFBArea.y1 = 0;
+ AvailFBArea.x2 = pScrn->displayWidth;
+ AvailFBArea.y2 = lines;
+ xf86InitFBManager(pScreen, &AvailFBArea);
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Using %i scanlines of offscreen memory \n"
+ , lines - pScrn->virtualY);
+ }
+
+ miInitializeBackingStore(pScreen);
+ xf86SetBackingStore(pScreen);
+ xf86SetSilkenMouse(pScreen);
+
+ /* Initialise cursor functions */
+ miDCInitialize (pScreen, xf86GetPointerScreenFuncs());
+
+
+ if (!dPtr->swCursor) {
+ /* HW cursor functions */
+ if (!DUMMYCursorInit(pScreen)) {
+ xf86DrvMsg(scrnIndex, X_ERROR,
+ "Hardware cursor initialization failed\n");
+ return FALSE;
+ }
+ }
+
+ /* Initialise default colourmap */
+ if(!miCreateDefColormap(pScreen))
+ return FALSE;
+
+ if (!xf86HandleColormaps(pScreen, 256, pScrn->rgbBits,
+ DUMMYLoadPalette, NULL,
+ CMAP_PALETTED_TRUECOLOR
+ | CMAP_RELOAD_ON_MODE_SWITCH))
+ return FALSE;
+
+/* DUMMYInitVideo(pScreen); */
+
+ pScreen->SaveScreen = DUMMYSaveScreen;
+
+
+ /* Wrap the current CloseScreen function */
+ dPtr->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = DUMMYCloseScreen;
+
+ /* Report any unused options (only for the first generation) */
+ if (serverGeneration == 1) {
+ xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+ }
+
+ return TRUE;
+}
+
+/* Mandatory */
+Bool
+DUMMYSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
+{
+ return dummyModeInit(xf86Screens[scrnIndex], mode);
+}
+
+/* Mandatory */
+void
+DUMMYAdjustFrame(int scrnIndex, int x, int y, int flags)
+{
+ ScrnInfoPtr pScrn;
+ int Base;
+
+ pScrn = xf86Screens[scrnIndex];
+
+ Base = (y * pScrn->displayWidth + x) >> 2;
+
+ /* Scale Base by the number of bytes per pixel. */
+ switch (pScrn->depth) {
+ case 8 :
+ break;
+ case 15 :
+ case 16 :
+ Base *= 2;
+ break;
+ case 24 :
+ Base *= 3;
+ break;
+ default :
+ break;
+ }
+}
+
+/* Mandatory */
+static Bool
+DUMMYCloseScreen(int scrnIndex, ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ DUMMYPtr dPtr = DUMMYPTR(pScrn);
+
+ if(pScrn->vtSema){
+ dummyRestore(pScrn, TRUE);
+ xfree(dPtr->FBBase);
+ }
+
+ if (dPtr->CursorInfo)
+ xf86DestroyCursorInfoRec(dPtr->CursorInfo);
+
+ pScrn->vtSema = FALSE;
+ pScreen->CloseScreen = dPtr->CloseScreen;
+ return (*pScreen->CloseScreen)(scrnIndex, pScreen);
+}
+
+/* Optional */
+static void
+DUMMYFreeScreen(int scrnIndex, int flags)
+{
+ DUMMYFreeRec(xf86Screens[scrnIndex]);
+}
+
+static Bool
+DUMMYSaveScreen(ScreenPtr pScreen, int mode)
+{
+ ScrnInfoPtr pScrn = NULL;
+ DUMMYPtr dPtr;
+
+ if (pScreen != NULL) {
+ pScrn = xf86Screens[pScreen->myNum];
+ dPtr = DUMMYPTR(pScrn);
+
+ dPtr->screenSaver = xf86IsUnblank(mode);
+ }
+ return TRUE;
+}
+
+/* Optional */
+static int
+DUMMYValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+{
+ return(MODE_OK);
+}
+
+static void
+dummySave(ScrnInfoPtr pScrn)
+{
+}
+
+static void
+dummyRestore(ScrnInfoPtr pScrn, Bool restoreText)
+{
+}
+
+static Bool
+dummyModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
+{
+ dummyRestore(pScrn, FALSE);
+
+ return(TRUE);
+}
+