3
* Copyright 2002, SuSE Linux AG, Author: Egbert Eich
10
/* All drivers should typically include these */
12
#include "xf86_OSproc.h"
14
/* All drivers initialising the SW cursor need this */
15
#include "mipointer.h"
17
/* All drivers using the mi colormap manipulation need this */
20
/* identifying atom needed by magnifiers */
21
#include <X11/Xatom.h>
26
#include "xf86fbman.h"
30
#include "picturestr.h"
34
#include <X11/extensions/Xv.h>
38
* Driver data structures.
42
/* These need to be checked */
44
#include <X11/Xproto.h>
45
#include "scrnintstr.h"
48
#define _XF86DGA_SERVER_
49
#include <X11/extensions/xf86dgaproto.h>
52
/* Mandatory functions */
53
static const OptionInfoRec * DUMMYAvailableOptions(int chipid, int busid);
54
static void DUMMYIdentify(int flags);
55
static Bool DUMMYProbe(DriverPtr drv, int flags);
56
static Bool DUMMYPreInit(ScrnInfoPtr pScrn, int flags);
57
static Bool DUMMYScreenInit(SCREEN_INIT_ARGS_DECL);
58
static Bool DUMMYEnterVT(VT_FUNC_ARGS_DECL);
59
static void DUMMYLeaveVT(VT_FUNC_ARGS_DECL);
60
static Bool DUMMYCloseScreen(CLOSE_SCREEN_ARGS_DECL);
61
static Bool DUMMYCreateWindow(WindowPtr pWin);
62
static void DUMMYFreeScreen(FREE_SCREEN_ARGS_DECL);
63
static ModeStatus DUMMYValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode,
64
Bool verbose, int flags);
65
static Bool DUMMYSaveScreen(ScreenPtr pScreen, int mode);
67
/* Internally used functions */
68
static Bool dummyModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
69
static void dummySave(ScrnInfoPtr pScrn);
70
static void dummyRestore(ScrnInfoPtr pScrn, Bool restoreText);
71
static Bool dummyDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op,
75
/* static void DUMMYDisplayPowerManagementSet(ScrnInfoPtr pScrn, */
76
/* int PowerManagementMode, int flags); */
78
#define DUMMY_VERSION 4000
79
#define DUMMY_NAME "DUMMY"
80
#define DUMMY_DRIVER_NAME "dummy"
82
#define DUMMY_MAJOR_VERSION PACKAGE_VERSION_MAJOR
83
#define DUMMY_MINOR_VERSION PACKAGE_VERSION_MINOR
84
#define DUMMY_PATCHLEVEL PACKAGE_VERSION_PATCHLEVEL
86
#define DUMMY_MAX_WIDTH 32767
87
#define DUMMY_MAX_HEIGHT 32767
90
* This is intentionally screen-independent. It indicates the binding
91
* choice made in the first PreInit.
93
static int pix24bpp = 0;
97
* This contains the functions needed by the server after loading the driver
98
* module. It must be supplied, and gets passed back by the SetupProc
99
* function in the dynamic case. In the static case, a reference to this
100
* is compiled in, and this requires that the name of this DriverRec be
101
* an upper-case version of the driver name.
104
_X_EXPORT DriverRec DUMMY = {
109
DUMMYAvailableOptions,
115
static SymTabRec DUMMYChipsets[] = {
116
{ DUMMY_CHIP, "dummy" },
124
static const OptionInfoRec DUMMYOptions[] = {
125
{ OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE },
126
{ -1, NULL, OPTV_NONE, {0}, FALSE }
131
static MODULESETUPPROTO(dummySetup);
133
static XF86ModuleVersionInfo dummyVersRec =
139
XORG_VERSION_CURRENT,
140
DUMMY_MAJOR_VERSION, DUMMY_MINOR_VERSION, DUMMY_PATCHLEVEL,
142
ABI_VIDEODRV_VERSION,
148
* This is the module init data.
149
* Its name has to be the driver name followed by ModuleData
151
_X_EXPORT XF86ModuleData dummyModuleData = { &dummyVersRec, dummySetup, NULL };
154
dummySetup(pointer module, pointer opts, int *errmaj, int *errmin)
156
static Bool setupDone = FALSE;
160
xf86AddDriver(&DUMMY, module, HaveDriverFuncs);
163
* Modules that this driver always requires can be loaded here
164
* by calling LoadSubModule().
168
* The return value must be non-NULL on success even though there
169
* is no TearDownProc.
173
if (errmaj) *errmaj = LDR_ONCEONLY;
178
#endif /* XFree86LOADER */
181
DUMMYGetRec(ScrnInfoPtr pScrn)
184
* Allocate a DUMMYRec, and hook it into pScrn->driverPrivate.
185
* pScrn->driverPrivate is initialised to NULL, so we can check if
186
* the allocation has already been done.
188
if (pScrn->driverPrivate != NULL)
191
pScrn->driverPrivate = xnfcalloc(sizeof(DUMMYRec), 1);
193
if (pScrn->driverPrivate == NULL)
199
DUMMYFreeRec(ScrnInfoPtr pScrn)
201
if (pScrn->driverPrivate == NULL)
203
free(pScrn->driverPrivate);
204
pScrn->driverPrivate = NULL;
207
static const OptionInfoRec *
208
DUMMYAvailableOptions(int chipid, int busid)
215
DUMMYIdentify(int flags)
217
xf86PrintChipsets(DUMMY_NAME, "Driver for Dummy chipsets",
223
DUMMYProbe(DriverPtr drv, int flags)
225
Bool foundScreen = FALSE;
226
int numDevSections, numUsed;
227
GDevPtr *devSections;
230
if (flags & PROBE_DETECT)
233
* Find the config file Device sections that match this
234
* driver, and return if there are none.
236
if ((numDevSections = xf86MatchDevice(DUMMY_DRIVER_NAME,
237
&devSections)) <= 0) {
241
numUsed = numDevSections;
245
for (i = 0; i < numUsed; i++) {
246
ScrnInfoPtr pScrn = NULL;
248
xf86ClaimNoSlot(drv,DUMMY_CHIP,devSections[i],TRUE);
249
/* Allocate a ScrnInfoRec and claim the slot */
250
if ((pScrn = xf86AllocateScreen(drv,0 ))) {
251
xf86AddEntityToScreen(pScrn,entityIndex);
252
pScrn->driverVersion = DUMMY_VERSION;
253
pScrn->driverName = DUMMY_DRIVER_NAME;
254
pScrn->name = DUMMY_NAME;
255
pScrn->Probe = DUMMYProbe;
256
pScrn->PreInit = DUMMYPreInit;
257
pScrn->ScreenInit = DUMMYScreenInit;
258
pScrn->SwitchMode = DUMMYSwitchMode;
259
pScrn->AdjustFrame = DUMMYAdjustFrame;
260
pScrn->EnterVT = DUMMYEnterVT;
261
pScrn->LeaveVT = DUMMYLeaveVT;
262
pScrn->FreeScreen = DUMMYFreeScreen;
263
pScrn->ValidMode = DUMMYValidMode;
273
{ DUMMYFreeRec(pScrn);\
279
DUMMYPreInit(ScrnInfoPtr pScrn, int flags)
281
ClockRangePtr clockRanges;
284
int maxClock = 230000;
285
GDevPtr device = xf86GetEntityInfo(pScrn->entityList[0])->device;
287
if (flags & PROBE_DETECT)
290
/* Allocate the DummyRec driverPrivate */
291
if (!DUMMYGetRec(pScrn)) {
295
dPtr = DUMMYPTR(pScrn);
297
pScrn->chipset = (char *)xf86TokenToString(DUMMYChipsets,
300
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Chipset is a DUMMY\n");
302
pScrn->monitor = pScrn->confScreen->monitor;
304
if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support24bppFb | Support32bppFb))
307
/* Check that the returned depth is one we support */
308
switch (pScrn->depth) {
315
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
316
"Given depth (%d) is not supported by this driver\n",
322
xf86PrintDepthBpp(pScrn);
323
if (pScrn->depth == 8)
326
/* Get the depth24 pixmap format */
327
if (pScrn->depth == 24 && pix24bpp == 0)
328
pix24bpp = xf86GetBppFromDepth(pScrn, 24);
331
* This must happen after pScrn->display has been set because
332
* xf86SetWeight references it.
334
if (pScrn->depth > 8) {
335
/* The defaults are OK for us */
336
rgb zeros = {0, 0, 0};
338
if (!xf86SetWeight(pScrn, zeros, zeros)) {
341
/* XXX check that weight returned is supported */
346
if (!xf86SetDefaultVisual(pScrn, -1))
349
if (pScrn->depth > 1) {
350
Gamma zeros = {0.0, 0.0, 0.0};
352
if (!xf86SetGamma(pScrn, zeros))
356
xf86CollectOptions(pScrn, device->options);
357
/* Process the options */
358
if (!(dPtr->Options = malloc(sizeof(DUMMYOptions))))
360
memcpy(dPtr->Options, DUMMYOptions, sizeof(DUMMYOptions));
362
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, dPtr->Options);
364
xf86GetOptValBool(dPtr->Options, OPTION_SW_CURSOR,&dPtr->swCursor);
366
if (device->videoRam != 0) {
367
pScrn->videoRam = device->videoRam;
368
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "VideoRAM: %d kByte\n",
371
pScrn->videoRam = 4096;
372
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "VideoRAM: %d kByte\n",
376
if (device->dacSpeeds[0] != 0) {
377
maxClock = device->dacSpeeds[0];
378
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Max Clock: %d kHz\n",
381
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Max Clock: %d kHz\n",
385
pScrn->progClock = TRUE;
387
* Setup the ClockRanges, which describe what clock ranges are available,
388
* and what sort of modes they can be used for.
390
clockRanges = (ClockRangePtr)xnfcalloc(sizeof(ClockRange), 1);
391
clockRanges->next = NULL;
392
clockRanges->ClockMulFactor = 1;
393
clockRanges->minClock = 11000; /* guessed Ā§Ā§Ā§ */
394
clockRanges->maxClock = 300000;
395
clockRanges->clockIndex = -1; /* programmable */
396
clockRanges->interlaceAllowed = TRUE;
397
clockRanges->doubleScanAllowed = TRUE;
399
/* Subtract memory for HW cursor */
403
int apertureSize = (pScrn->videoRam * 1024);
404
i = xf86ValidateModes(pScrn, pScrn->monitor->Modes,
405
pScrn->display->modes, clockRanges,
406
NULL, 256, DUMMY_MAX_WIDTH,
407
(8 * pScrn->bitsPerPixel),
408
128, DUMMY_MAX_HEIGHT, pScrn->display->virtualX,
409
pScrn->display->virtualY, apertureSize,
410
LOOKUP_BEST_REFRESH);
416
/* Prune the modes marked as invalid */
417
xf86PruneDriverModes(pScrn);
419
if (i == 0 || pScrn->modes == NULL) {
420
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n");
425
* Set the CRTC parameters for all of the modes based on the type
426
* of mode, and the chipset's interlace requirements.
428
* Calling this is required if the mode->Crtc* values are used by the
429
* driver and if the driver doesn't provide code to set them. They
430
* are not pre-initialised at all.
432
xf86SetCrtcForModes(pScrn, 0);
434
/* Set the current mode to the first in the list */
435
pScrn->currentMode = pScrn->modes;
437
/* Print the list of modes being used */
438
xf86PrintModes(pScrn);
440
/* If monitor resolution is set on the command line, use it */
441
xf86SetDpi(pScrn, 0, 0);
443
if (xf86LoadSubModule(pScrn, "fb") == NULL) {
447
if (!dPtr->swCursor) {
448
if (!xf86LoadSubModule(pScrn, "ramdac"))
452
/* We have no contiguous physical fb in physical memory */
453
pScrn->memPhysBase = 0;
462
DUMMYEnterVT(VT_FUNC_ARGS_DECL)
466
/* Should we re-save the text mode on each VT enter? */
467
if(!dummyModeInit(pScrn, pScrn->currentMode))
470
DUMMYAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0));
477
DUMMYLeaveVT(VT_FUNC_ARGS_DECL)
480
dummyRestore(pScrn, TRUE);
491
int i, index, shift, Gshift;
492
DUMMYPtr dPtr = DUMMYPTR(pScrn);
494
switch(pScrn->depth) {
507
for(i = 0; i < numColors; i++) {
509
dPtr->colors[index].red = colors[index].red << shift;
510
dPtr->colors[index].green = colors[index].green << Gshift;
511
dPtr->colors[index].blue = colors[index].blue << shift;
516
static ScrnInfoPtr DUMMYScrn; /* static-globalize it */
520
DUMMYScreenInit(SCREEN_INIT_ARGS_DECL)
528
* we need to get the ScrnInfoRec for this screen, so let's allocate
531
pScrn = xf86ScreenToScrn(pScreen);
532
dPtr = DUMMYPTR(pScrn);
536
if (!(dPtr->FBBase = malloc(pScrn->videoRam * 1024)))
540
* next we save the current state and setup the first mode
544
if (!dummyModeInit(pScrn,pScrn->currentMode))
546
DUMMYAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0));
551
miClearVisualTypes();
553
/* Setup the visuals we support. */
555
if (!miSetVisualTypes(pScrn->depth,
556
miGetDefaultVisualMask(pScrn->depth),
557
pScrn->rgbBits, pScrn->defaultVisual))
560
if (!miSetPixmapDepths ()) return FALSE;
563
* Call the framebuffer layer's ScreenInit function, and fill in other
566
ret = fbScreenInit(pScreen, dPtr->FBBase,
567
pScrn->virtualX, pScrn->virtualY,
568
pScrn->xDpi, pScrn->yDpi,
569
pScrn->displayWidth, pScrn->bitsPerPixel);
573
if (pScrn->depth > 8) {
574
/* Fixup RGB ordering */
575
visual = pScreen->visuals + pScreen->numVisuals;
576
while (--visual >= pScreen->visuals) {
577
if ((visual->class | DynamicClass) == DirectColor) {
578
visual->offsetRed = pScrn->offset.red;
579
visual->offsetGreen = pScrn->offset.green;
580
visual->offsetBlue = pScrn->offset.blue;
581
visual->redMask = pScrn->mask.red;
582
visual->greenMask = pScrn->mask.green;
583
visual->blueMask = pScrn->mask.blue;
588
/* must be after RGB ordering fixed */
589
fbPictureInit(pScreen, 0, 0);
591
xf86SetBlackWhitePixels(pScreen);
594
DUMMYDGAInit(pScreen);
598
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using Software Cursor.\n");
604
int lines = pScrn->videoRam * 1024 /
605
(pScrn->displayWidth * (pScrn->bitsPerPixel >> 3));
608
AvailFBArea.x2 = pScrn->displayWidth;
609
AvailFBArea.y2 = lines;
610
xf86InitFBManager(pScreen, &AvailFBArea);
612
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
613
"Using %i scanlines of offscreen memory \n"
614
, lines - pScrn->virtualY);
617
xf86SetBackingStore(pScreen);
618
xf86SetSilkenMouse(pScreen);
620
/* Initialise cursor functions */
621
miDCInitialize (pScreen, xf86GetPointerScreenFuncs());
624
if (!dPtr->swCursor) {
625
/* HW cursor functions */
626
if (!DUMMYCursorInit(pScreen)) {
627
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
628
"Hardware cursor initialization failed\n");
633
/* Initialise default colourmap */
634
if(!miCreateDefColormap(pScreen))
637
if (!xf86HandleColormaps(pScreen, 256, pScrn->rgbBits,
638
DUMMYLoadPalette, NULL,
639
CMAP_PALETTED_TRUECOLOR
640
| CMAP_RELOAD_ON_MODE_SWITCH))
643
/* DUMMYInitVideo(pScreen); */
645
pScreen->SaveScreen = DUMMYSaveScreen;
648
/* Wrap the current CloseScreen function */
649
dPtr->CloseScreen = pScreen->CloseScreen;
650
pScreen->CloseScreen = DUMMYCloseScreen;
652
/* Wrap the current CreateWindow function */
653
dPtr->CreateWindow = pScreen->CreateWindow;
654
pScreen->CreateWindow = DUMMYCreateWindow;
656
/* Report any unused options (only for the first generation) */
657
if (serverGeneration == 1) {
658
xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
666
DUMMYSwitchMode(SWITCH_MODE_ARGS_DECL)
669
return dummyModeInit(pScrn, mode);
674
DUMMYAdjustFrame(ADJUST_FRAME_ARGS_DECL)
679
Base = (y * pScrn->displayWidth + x) >> 2;
681
/* Scale Base by the number of bytes per pixel. */
682
switch (pScrn->depth) {
699
DUMMYCloseScreen(CLOSE_SCREEN_ARGS_DECL)
701
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
702
DUMMYPtr dPtr = DUMMYPTR(pScrn);
705
dummyRestore(pScrn, TRUE);
709
if (dPtr->CursorInfo)
710
xf86DestroyCursorInfoRec(dPtr->CursorInfo);
712
pScrn->vtSema = FALSE;
713
pScreen->CloseScreen = dPtr->CloseScreen;
714
return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS);
719
DUMMYFreeScreen(FREE_SCREEN_ARGS_DECL)
726
DUMMYSaveScreen(ScreenPtr pScreen, int mode)
728
ScrnInfoPtr pScrn = NULL;
731
if (pScreen != NULL) {
732
pScrn = xf86ScreenToScrn(pScreen);
733
dPtr = DUMMYPTR(pScrn);
735
dPtr->screenSaver = xf86IsUnblank(mode);
742
DUMMYValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags)
748
dummySave(ScrnInfoPtr pScrn)
753
dummyRestore(ScrnInfoPtr pScrn, Bool restoreText)
758
dummyModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
760
dummyRestore(pScrn, FALSE);
766
#define VFB_PROP_NAME "VFB_IDENT"
769
DUMMYCreateWindow(WindowPtr pWin)
771
ScreenPtr pScreen = pWin->drawable.pScreen;
772
DUMMYPtr dPtr = DUMMYPTR(DUMMYScrn);
776
pScreen->CreateWindow = dPtr->CreateWindow;
777
ret = pScreen->CreateWindow(pWin);
778
dPtr->CreateWindow = pScreen->CreateWindow;
779
pScreen->CreateWindow = DUMMYCreateWindow;
784
if(dPtr->prop == FALSE) {
785
#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 8
786
pWinRoot = WindowTable[DUMMYScrn->pScreen->myNum];
788
pWinRoot = DUMMYScrn->pScreen->root;
790
if (! ValidAtom(VFB_PROP))
791
VFB_PROP = MakeAtom(VFB_PROP_NAME, strlen(VFB_PROP_NAME), 1);
793
ret = ChangeWindowProperty(pWinRoot, VFB_PROP, XA_STRING,
794
8, PropModeReplace, (int)4, (pointer)"TRUE", FALSE);
796
ErrorF("Could not set VFB root window property");
804
#ifndef HW_SKIP_CONSOLE
805
#define HW_SKIP_CONSOLE 4
809
dummyDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, pointer ptr)
814
case GET_REQUIRED_HW_INTERFACES:
816
(*flag) = HW_SKIP_CONSOLE;