3
* Copyright 2002, SuSE Linux AG, Author: Egbert Eich
6
/* All drivers should typically include these */
8
#include "xf86_OSproc.h"
9
#include "xf86_ansic.h"
12
/* This is used for module versioning */
13
#include "xf86Version.h"
15
/* All drivers initialising the SW cursor need this */
16
#include "mipointer.h"
18
/* All drivers implementing backing store need this */
21
/* All drivers using the mi colormap manipulation need this */
26
#include "xf86fbman.h"
30
#include "picturestr.h"
38
* Driver data structures.
42
/* These need to be checked */
45
#include "scrnintstr.h"
47
#define _XF86DGA_SERVER_
48
#include "extensions/xf86dgastr.h"
50
/* Mandatory functions */
51
static const OptionInfoRec * DUMMYAvailableOptions(int chipid, int busid);
52
static void DUMMYIdentify(int flags);
53
static Bool DUMMYProbe(DriverPtr drv, int flags);
54
static Bool DUMMYPreInit(ScrnInfoPtr pScrn, int flags);
55
static Bool DUMMYScreenInit(int Index, ScreenPtr pScreen, int argc,
57
static Bool DUMMYEnterVT(int scrnIndex, int flags);
58
static void DUMMYLeaveVT(int scrnIndex, int flags);
59
static Bool DUMMYCloseScreen(int scrnIndex, ScreenPtr pScreen);
60
static void DUMMYFreeScreen(int scrnIndex, int flags);
61
static int DUMMYValidMode(int scrnIndex, DisplayModePtr mode,
62
Bool verbose, int flags);
63
static Bool DUMMYSaveScreen(ScreenPtr pScreen, int mode);
65
/* Internally used functions */
66
static Bool dummyModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
67
static void dummySave(ScrnInfoPtr pScrn);
68
static void dummyRestore(ScrnInfoPtr pScrn, Bool restoreText);
70
/* static void DUMMYDisplayPowerManagementSet(ScrnInfoPtr pScrn, */
71
/* int PowerManagementMode, int flags); */
74
#define DUMMY_NAME "DUMMY"
75
#define DUMMY_DRIVER_NAME "dummy"
77
#define DUMMY_MAJOR_VERSION 0
78
#define DUMMY_MINOR_VERSION 1
79
#define DUMMY_PATCHLEVEL 0
82
* This is intentionally screen-independent. It indicates the binding
83
* choice made in the first PreInit.
85
static int pix24bpp = 0;
89
* This contains the functions needed by the server after loading the driver
90
* module. It must be supplied, and gets passed back by the SetupProc
91
* function in the dynamic case. In the static case, a reference to this
92
* is compiled in, and this requires that the name of this DriverRec be
93
* an upper-case version of the driver name.
101
DUMMYAvailableOptions,
106
static SymTabRec DUMMYChipsets[] = {
107
{ DUMMY_CHIP, "dummy" },
115
static const OptionInfoRec DUMMYOptions[] = {
116
{ OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE },
117
{ -1, NULL, OPTV_NONE, {0}, FALSE }
122
* List of symbols from other modules that this module references. This
123
* list is used to tell the loader that it is OK for symbols here to be
124
* unresolved providing that it hasn't been told that they haven't been
125
* told that they are essential via a call to xf86LoaderReqSymbols() or
126
* xf86LoaderReqSymLists(). The purpose is this is to avoid warnings about
127
* unresolved symbols that are not required.
130
static const char *fbSymbols[] = {
136
static const char *ramdacSymbols[] = {
137
"xf86CreateCursorInfoRec",
138
"xf86DestroyCursorInfoRec",
146
static MODULESETUPPROTO(dummySetup);
148
static XF86ModuleVersionInfo dummyVersRec =
154
XF86_VERSION_CURRENT,
155
DUMMY_MAJOR_VERSION, DUMMY_MINOR_VERSION, DUMMY_PATCHLEVEL,
157
ABI_VIDEODRV_VERSION,
163
* This is the module init data.
164
* Its name has to be the driver name followed by ModuleData
166
XF86ModuleData dummyModuleData = { &dummyVersRec, dummySetup, NULL };
169
dummySetup(pointer module, pointer opts, int *errmaj, int *errmin)
171
static Bool setupDone = FALSE;
175
xf86AddDriver(&DUMMY, module, 0);
178
* Modules that this driver always requires can be loaded here
179
* by calling LoadSubModule().
183
* Tell the loader about symbols from other modules that this module
186
LoaderRefSymLists(fbSymbols, ramdacSymbols, NULL);
188
* The return value must be non-NULL on success even though there
189
* is no TearDownProc.
193
if (errmaj) *errmaj = LDR_ONCEONLY;
198
#endif /* XFree86LOADER */
201
DUMMYGetRec(ScrnInfoPtr pScrn)
204
* Allocate a DUMMYRec, and hook it into pScrn->driverPrivate.
205
* pScrn->driverPrivate is initialised to NULL, so we can check if
206
* the allocation has already been done.
208
if (pScrn->driverPrivate != NULL)
211
pScrn->driverPrivate = xnfcalloc(sizeof(DUMMYRec), 1);
213
if (pScrn->driverPrivate == NULL)
219
DUMMYFreeRec(ScrnInfoPtr pScrn)
221
if (pScrn->driverPrivate == NULL)
223
xfree(pScrn->driverPrivate);
224
pScrn->driverPrivate = NULL;
227
static const OptionInfoRec *
228
DUMMYAvailableOptions(int chipid, int busid)
235
DUMMYIdentify(int flags)
237
xf86PrintChipsets(DUMMY_NAME, "Driver for Dummy chipsets",
243
DUMMYProbe(DriverPtr drv, int flags)
245
Bool foundScreen = FALSE;
246
int numDevSections, numUsed;
247
GDevPtr *devSections;
250
if (flags & PROBE_DETECT)
253
* Find the config file Device sections that match this
254
* driver, and return if there are none.
256
if ((numDevSections = xf86MatchDevice(DUMMY_DRIVER_NAME,
257
&devSections)) <= 0) {
261
numUsed = numDevSections;
265
for (i = 0; i < numUsed; i++) {
266
ScrnInfoPtr pScrn = NULL;
268
xf86ClaimNoSlot(drv,DUMMY_CHIP,devSections[i],TRUE);
269
/* Allocate a ScrnInfoRec and claim the slot */
270
if ((pScrn = xf86AllocateScreen(drv,0 ))) {
271
xf86AddEntityToScreen(pScrn,entityIndex);
272
pScrn->driverVersion = VERSION;
273
pScrn->driverName = DUMMY_DRIVER_NAME;
274
pScrn->name = DUMMY_NAME;
275
pScrn->Probe = DUMMYProbe;
276
pScrn->PreInit = DUMMYPreInit;
277
pScrn->ScreenInit = DUMMYScreenInit;
278
pScrn->SwitchMode = DUMMYSwitchMode;
279
pScrn->AdjustFrame = DUMMYAdjustFrame;
280
pScrn->EnterVT = DUMMYEnterVT;
281
pScrn->LeaveVT = DUMMYLeaveVT;
282
pScrn->FreeScreen = DUMMYFreeScreen;
283
pScrn->ValidMode = DUMMYValidMode;
293
{ DUMMYFreeRec(pScrn);\
299
DUMMYPreInit(ScrnInfoPtr pScrn, int flags)
301
ClockRangePtr clockRanges;
304
int maxClock = 230000;
305
GDevPtr device = xf86GetEntityInfo(pScrn->entityList[0])->device;
307
if (flags & PROBE_DETECT)
310
/* Allocate the DummyRec driverPrivate */
311
if (!DUMMYGetRec(pScrn)) {
315
{ DUMMYFreeRec(pScrn);\
319
dPtr = DUMMYPTR(pScrn);
321
pScrn->chipset = (char *)xf86TokenToString(DUMMYChipsets,
324
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Chipset is a DUMMY\n");
326
pScrn->monitor = pScrn->confScreen->monitor;
328
if (!xf86SetDepthBpp(pScrn, 8, 8, 8, Support24bppFb | Support32bppFb))
331
/* Check that the returned depth is one we support */
332
switch (pScrn->depth) {
339
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
340
"Given depth (%d) is not supported by this driver\n",
346
xf86PrintDepthBpp(pScrn);
347
if (pScrn->depth == 8)
350
/* Get the depth24 pixmap format */
351
if (pScrn->depth == 24 && pix24bpp == 0)
352
pix24bpp = xf86GetBppFromDepth(pScrn, 24);
355
* This must happen after pScrn->display has been set because
356
* xf86SetWeight references it.
358
if (pScrn->depth > 8) {
359
/* The defaults are OK for us */
360
rgb zeros = {0, 0, 0};
362
if (!xf86SetWeight(pScrn, zeros, zeros)) {
365
/* XXX check that weight returned is supported */
370
if (!xf86SetDefaultVisual(pScrn, -1))
373
if (pScrn->depth > 1) {
374
Gamma zeros = {0.0, 0.0, 0.0};
376
if (!xf86SetGamma(pScrn, zeros))
380
xf86CollectOptions(pScrn, device->options);
381
/* Process the options */
382
if (!(dPtr->Options = xalloc(sizeof(DUMMYOptions))))
384
memcpy(dPtr->Options, DUMMYOptions, sizeof(DUMMYOptions));
386
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, dPtr->Options);
388
xf86GetOptValBool(dPtr->Options, OPTION_SW_CURSOR,&dPtr->swCursor);
390
if (device->videoRam != 0) {
391
pScrn->videoRam = device->videoRam;
392
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "VideoRAM: %d kByte\n",
395
pScrn->videoRam = 4096;
396
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "VideoRAM: %d kByte\n",
400
if (device->dacSpeeds[0] != 0) {
401
maxClock = device->dacSpeeds[0];
402
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Max Clock: %d kHz\n",
405
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Max Clock: %d kHz\n",
409
pScrn->progClock = TRUE;
411
* Setup the ClockRanges, which describe what clock ranges are available,
412
* and what sort of modes they can be used for.
414
clockRanges = (ClockRangePtr)xnfcalloc(sizeof(ClockRange), 1);
415
clockRanges->next = NULL;
416
clockRanges->ClockMulFactor = 1;
417
clockRanges->minClock = 11000; /* guessed ��� */
418
clockRanges->maxClock = 300000;
419
clockRanges->clockIndex = -1; /* programmable */
420
clockRanges->interlaceAllowed = TRUE;
421
clockRanges->doubleScanAllowed = TRUE;
423
/* Subtract memory for HW cursor */
427
int apertureSize = (pScrn->videoRam * 1024);
428
i = xf86ValidateModes(pScrn, pScrn->monitor->Modes,
429
pScrn->display->modes, clockRanges,
430
NULL, 256, 2048,(8 * pScrn->bitsPerPixel),
431
128, 2048, pScrn->display->virtualX,
432
pScrn->display->virtualY, apertureSize,
433
LOOKUP_BEST_REFRESH);
439
/* Prune the modes marked as invalid */
440
xf86PruneDriverModes(pScrn);
442
if (i == 0 || pScrn->modes == NULL) {
443
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n");
448
* Set the CRTC parameters for all of the modes based on the type
449
* of mode, and the chipset's interlace requirements.
451
* Calling this is required if the mode->Crtc* values are used by the
452
* driver and if the driver doesn't provide code to set them. They
453
* are not pre-initialised at all.
455
xf86SetCrtcForModes(pScrn, 0);
457
/* Set the current mode to the first in the list */
458
pScrn->currentMode = pScrn->modes;
460
/* Print the list of modes being used */
461
xf86PrintModes(pScrn);
463
/* If monitor resolution is set on the command line, use it */
464
xf86SetDpi(pScrn, 0, 0);
466
if (xf86LoadSubModule(pScrn, "fb") == NULL) {
469
xf86LoaderReqSymLists(fbSymbols, NULL);
471
if (!dPtr->swCursor) {
472
if (!xf86LoadSubModule(pScrn, "ramdac"))
474
xf86LoaderReqSymLists(ramdacSymbols, NULL);
483
DUMMYEnterVT(int scrnIndex, int flags)
485
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
487
/* Should we re-save the text mode on each VT enter? */
488
if(!dummyModeInit(pScrn, pScrn->currentMode))
491
DUMMYAdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
498
DUMMYLeaveVT(int scrnIndex, int flags)
500
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
501
dummyRestore(pScrn, TRUE);
512
int i, index, shift, Gshift;
513
DUMMYPtr dPtr = DUMMYPTR(pScrn);
515
switch(pScrn->depth) {
528
for(i = 0; i < numColors; i++) {
530
dPtr->colors[index].red = colors[index].red << shift;
531
dPtr->colors[index].green = colors[index].green << Gshift;
532
dPtr->colors[index].blue = colors[index].blue << shift;
539
DUMMYScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
548
* we need to get the ScrnInfoRec for this screen, so let's allocate
551
pScrn = xf86Screens[pScreen->myNum];
552
dPtr = DUMMYPTR(pScrn);
555
if (!(dPtr->FBBase = xalloc(pScrn->videoRam * 1024)))
559
* next we save the current state and setup the first mode
563
if (!dummyModeInit(pScrn,pScrn->currentMode))
565
DUMMYAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
570
miClearVisualTypes();
572
/* Setup the visuals we support. */
574
if (!miSetVisualTypes(pScrn->depth,
575
miGetDefaultVisualMask(pScrn->depth),
576
pScrn->rgbBits, pScrn->defaultVisual))
579
if (!miSetPixmapDepths ()) return FALSE;
582
* Call the framebuffer layer's ScreenInit function, and fill in other
585
width = pScrn->virtualX;
586
height = pScrn->virtualY;
588
ret = fbScreenInit(pScreen, dPtr->FBBase,
589
pScrn->virtualX, pScrn->virtualY,
590
pScrn->xDpi, pScrn->yDpi,
591
pScrn->displayWidth, pScrn->bitsPerPixel);
595
if (pScrn->depth > 8) {
596
/* Fixup RGB ordering */
597
visual = pScreen->visuals + pScreen->numVisuals;
598
while (--visual >= pScreen->visuals) {
599
if ((visual->class | DynamicClass) == DirectColor) {
600
visual->offsetRed = pScrn->offset.red;
601
visual->offsetGreen = pScrn->offset.green;
602
visual->offsetBlue = pScrn->offset.blue;
603
visual->redMask = pScrn->mask.red;
604
visual->greenMask = pScrn->mask.green;
605
visual->blueMask = pScrn->mask.blue;
610
/* must be after RGB ordering fixed */
611
fbPictureInit(pScreen, 0, 0);
613
xf86SetBlackWhitePixels(pScreen);
615
DUMMYDGAInit(pScreen);
618
xf86DrvMsg(scrnIndex, X_CONFIG, "Using Software Cursor.\n");
624
int lines = pScrn->videoRam * 1024 /
625
(pScrn->displayWidth * (pScrn->bitsPerPixel >> 3));
628
AvailFBArea.x2 = pScrn->displayWidth;
629
AvailFBArea.y2 = lines;
630
xf86InitFBManager(pScreen, &AvailFBArea);
632
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
633
"Using %i scanlines of offscreen memory \n"
634
, lines - pScrn->virtualY);
637
miInitializeBackingStore(pScreen);
638
xf86SetBackingStore(pScreen);
639
xf86SetSilkenMouse(pScreen);
641
/* Initialise cursor functions */
642
miDCInitialize (pScreen, xf86GetPointerScreenFuncs());
645
if (!dPtr->swCursor) {
646
/* HW cursor functions */
647
if (!DUMMYCursorInit(pScreen)) {
648
xf86DrvMsg(scrnIndex, X_ERROR,
649
"Hardware cursor initialization failed\n");
654
/* Initialise default colourmap */
655
if(!miCreateDefColormap(pScreen))
658
if (!xf86HandleColormaps(pScreen, 256, pScrn->rgbBits,
659
DUMMYLoadPalette, NULL,
660
CMAP_PALETTED_TRUECOLOR
661
| CMAP_RELOAD_ON_MODE_SWITCH))
664
/* DUMMYInitVideo(pScreen); */
666
pScreen->SaveScreen = DUMMYSaveScreen;
669
/* Wrap the current CloseScreen function */
670
dPtr->CloseScreen = pScreen->CloseScreen;
671
pScreen->CloseScreen = DUMMYCloseScreen;
673
/* Report any unused options (only for the first generation) */
674
if (serverGeneration == 1) {
675
xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
683
DUMMYSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
685
return dummyModeInit(xf86Screens[scrnIndex], mode);
690
DUMMYAdjustFrame(int scrnIndex, int x, int y, int flags)
695
pScrn = xf86Screens[scrnIndex];
697
Base = (y * pScrn->displayWidth + x) >> 2;
699
/* Scale Base by the number of bytes per pixel. */
700
switch (pScrn->depth) {
717
DUMMYCloseScreen(int scrnIndex, ScreenPtr pScreen)
719
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
720
DUMMYPtr dPtr = DUMMYPTR(pScrn);
723
dummyRestore(pScrn, TRUE);
727
if (dPtr->CursorInfo)
728
xf86DestroyCursorInfoRec(dPtr->CursorInfo);
730
pScrn->vtSema = FALSE;
731
pScreen->CloseScreen = dPtr->CloseScreen;
732
return (*pScreen->CloseScreen)(scrnIndex, pScreen);
737
DUMMYFreeScreen(int scrnIndex, int flags)
739
DUMMYFreeRec(xf86Screens[scrnIndex]);
743
DUMMYSaveScreen(ScreenPtr pScreen, int mode)
745
ScrnInfoPtr pScrn = NULL;
748
if (pScreen != NULL) {
749
pScrn = xf86Screens[pScreen->myNum];
750
dPtr = DUMMYPTR(pScrn);
752
dPtr->screenSaver = xf86IsUnblank(mode);
759
DUMMYValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
765
dummySave(ScrnInfoPtr pScrn)
770
dummyRestore(ScrnInfoPtr pScrn, Bool restoreText)
775
dummyModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
777
dummyRestore(pScrn, FALSE);