1 | |
---|
2 | /* |
---|
3 | * Copyright 2002, SuSE Linux AG, Author: Egbert Eich |
---|
4 | */ |
---|
5 | |
---|
6 | #ifdef HAVE_CONFIG_H |
---|
7 | #include "config.h" |
---|
8 | #endif |
---|
9 | |
---|
10 | /* All drivers should typically include these */ |
---|
11 | #include "xf86.h" |
---|
12 | #include "xf86_OSproc.h" |
---|
13 | |
---|
14 | /* All drivers initialising the SW cursor need this */ |
---|
15 | #include "mipointer.h" |
---|
16 | |
---|
17 | /* All drivers using the mi colormap manipulation need this */ |
---|
18 | #include "micmap.h" |
---|
19 | |
---|
20 | #ifdef RANDR |
---|
21 | #include "randrstr.h" |
---|
22 | #endif |
---|
23 | |
---|
24 | #include "windowstr.h" |
---|
25 | |
---|
26 | /* identifying atom needed by magnifiers */ |
---|
27 | #include <X11/Xatom.h> |
---|
28 | #include "property.h" |
---|
29 | |
---|
30 | #include "xf86cmap.h" |
---|
31 | |
---|
32 | #include "xf86fbman.h" |
---|
33 | |
---|
34 | #include "fb.h" |
---|
35 | |
---|
36 | #include "picturestr.h" |
---|
37 | |
---|
38 | #ifdef XvExtension |
---|
39 | #include "xf86xv.h" |
---|
40 | #include <X11/extensions/Xv.h> |
---|
41 | #endif |
---|
42 | |
---|
43 | |
---|
44 | /* |
---|
45 | * Driver data structures. |
---|
46 | */ |
---|
47 | #include "dummy.h" |
---|
48 | |
---|
49 | /* These need to be checked */ |
---|
50 | #include <X11/X.h> |
---|
51 | #include <X11/Xproto.h> |
---|
52 | #include "scrnintstr.h" |
---|
53 | #include "servermd.h" |
---|
54 | #ifdef USE_DGA |
---|
55 | #define _XF86DGA_SERVER_ |
---|
56 | #include <X11/extensions/xf86dgaproto.h> |
---|
57 | #endif |
---|
58 | |
---|
59 | #include <xf86Crtc.h> |
---|
60 | #include "inputstr.h" |
---|
61 | |
---|
62 | /* Mandatory functions */ |
---|
63 | static const OptionInfoRec * DUMMYAvailableOptions(int chipid, int busid); |
---|
64 | static void DUMMYIdentify(int flags); |
---|
65 | static Bool DUMMYProbe(DriverPtr drv, int flags); |
---|
66 | static Bool DUMMYPreInit(ScrnInfoPtr pScrn, int flags); |
---|
67 | static Bool DUMMYScreenInit(SCREEN_INIT_ARGS_DECL); |
---|
68 | static Bool DUMMYEnterVT(VT_FUNC_ARGS_DECL); |
---|
69 | static void DUMMYLeaveVT(VT_FUNC_ARGS_DECL); |
---|
70 | static Bool DUMMYCloseScreen(CLOSE_SCREEN_ARGS_DECL); |
---|
71 | static Bool DUMMYCreateWindow(WindowPtr pWin); |
---|
72 | static void DUMMYFreeScreen(FREE_SCREEN_ARGS_DECL); |
---|
73 | static ModeStatus DUMMYValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, |
---|
74 | Bool verbose, int flags); |
---|
75 | static Bool DUMMYSaveScreen(ScreenPtr pScreen, int mode); |
---|
76 | |
---|
77 | /* Internally used functions */ |
---|
78 | static Bool dummyModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); |
---|
79 | static void dummySave(ScrnInfoPtr pScrn); |
---|
80 | static void dummyRestore(ScrnInfoPtr pScrn, Bool restoreText); |
---|
81 | static Bool dummyDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, |
---|
82 | pointer ptr); |
---|
83 | |
---|
84 | |
---|
85 | /* static void DUMMYDisplayPowerManagementSet(ScrnInfoPtr pScrn, */ |
---|
86 | /* int PowerManagementMode, int flags); */ |
---|
87 | |
---|
88 | #define DUMMY_VERSION 4000 |
---|
89 | #define DUMMY_NAME "DUMMY" |
---|
90 | #define DUMMY_DRIVER_NAME "dummy" |
---|
91 | |
---|
92 | #define DUMMY_MAJOR_VERSION PACKAGE_VERSION_MAJOR |
---|
93 | #define DUMMY_MINOR_VERSION PACKAGE_VERSION_MINOR |
---|
94 | #define DUMMY_PATCHLEVEL PACKAGE_VERSION_PATCHLEVEL |
---|
95 | |
---|
96 | #define DUMMY_MAX_WIDTH 32767 |
---|
97 | #define DUMMY_MAX_HEIGHT 32767 |
---|
98 | |
---|
99 | /* |
---|
100 | * This is intentionally screen-independent. It indicates the binding |
---|
101 | * choice made in the first PreInit. |
---|
102 | */ |
---|
103 | static int pix24bpp = 0; |
---|
104 | |
---|
105 | |
---|
106 | /* |
---|
107 | * This contains the functions needed by the server after loading the driver |
---|
108 | * module. It must be supplied, and gets passed back by the SetupProc |
---|
109 | * function in the dynamic case. In the static case, a reference to this |
---|
110 | * is compiled in, and this requires that the name of this DriverRec be |
---|
111 | * an upper-case version of the driver name. |
---|
112 | */ |
---|
113 | |
---|
114 | _X_EXPORT DriverRec DUMMY = { |
---|
115 | DUMMY_VERSION, |
---|
116 | DUMMY_DRIVER_NAME, |
---|
117 | DUMMYIdentify, |
---|
118 | DUMMYProbe, |
---|
119 | DUMMYAvailableOptions, |
---|
120 | NULL, |
---|
121 | 0, |
---|
122 | dummyDriverFunc |
---|
123 | }; |
---|
124 | |
---|
125 | static SymTabRec DUMMYChipsets[] = { |
---|
126 | { DUMMY_CHIP, "dummy" }, |
---|
127 | { -1, NULL } |
---|
128 | }; |
---|
129 | |
---|
130 | typedef enum { |
---|
131 | OPTION_SW_CURSOR, |
---|
132 | OPTION_CONSTANT_DPI |
---|
133 | } DUMMYOpts; |
---|
134 | |
---|
135 | static const OptionInfoRec DUMMYOptions[] = { |
---|
136 | { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, |
---|
137 | #ifdef RANDR |
---|
138 | { OPTION_CONSTANT_DPI, "ConstantDPI", OPTV_BOOLEAN, {0}, FALSE }, |
---|
139 | #endif |
---|
140 | { -1, NULL, OPTV_NONE, {0}, FALSE } |
---|
141 | }; |
---|
142 | |
---|
143 | #ifdef XFree86LOADER |
---|
144 | |
---|
145 | static MODULESETUPPROTO(dummySetup); |
---|
146 | |
---|
147 | static XF86ModuleVersionInfo dummyVersRec = |
---|
148 | { |
---|
149 | "dummy", |
---|
150 | MODULEVENDORSTRING, |
---|
151 | MODINFOSTRING1, |
---|
152 | MODINFOSTRING2, |
---|
153 | XORG_VERSION_CURRENT, |
---|
154 | DUMMY_MAJOR_VERSION, DUMMY_MINOR_VERSION, DUMMY_PATCHLEVEL, |
---|
155 | ABI_CLASS_VIDEODRV, |
---|
156 | ABI_VIDEODRV_VERSION, |
---|
157 | MOD_CLASS_VIDEODRV, |
---|
158 | {0,0,0,0} |
---|
159 | }; |
---|
160 | |
---|
161 | /* |
---|
162 | * This is the module init data. |
---|
163 | * Its name has to be the driver name followed by ModuleData |
---|
164 | */ |
---|
165 | _X_EXPORT XF86ModuleData dummyModuleData = { &dummyVersRec, dummySetup, NULL }; |
---|
166 | |
---|
167 | static pointer |
---|
168 | dummySetup(pointer module, pointer opts, int *errmaj, int *errmin) |
---|
169 | { |
---|
170 | static Bool setupDone = FALSE; |
---|
171 | |
---|
172 | if (!setupDone) { |
---|
173 | setupDone = TRUE; |
---|
174 | xf86AddDriver(&DUMMY, module, HaveDriverFuncs); |
---|
175 | |
---|
176 | /* |
---|
177 | * Modules that this driver always requires can be loaded here |
---|
178 | * by calling LoadSubModule(). |
---|
179 | */ |
---|
180 | |
---|
181 | /* |
---|
182 | * The return value must be non-NULL on success even though there |
---|
183 | * is no TearDownProc. |
---|
184 | */ |
---|
185 | return (pointer)1; |
---|
186 | } else { |
---|
187 | if (errmaj) *errmaj = LDR_ONCEONLY; |
---|
188 | return NULL; |
---|
189 | } |
---|
190 | } |
---|
191 | |
---|
192 | #endif /* XFree86LOADER */ |
---|
193 | |
---|
194 | static Bool |
---|
195 | DUMMYGetRec(ScrnInfoPtr pScrn) |
---|
196 | { |
---|
197 | /* |
---|
198 | * Allocate a DUMMYRec, and hook it into pScrn->driverPrivate. |
---|
199 | * pScrn->driverPrivate is initialised to NULL, so we can check if |
---|
200 | * the allocation has already been done. |
---|
201 | */ |
---|
202 | if (pScrn->driverPrivate != NULL) |
---|
203 | return TRUE; |
---|
204 | |
---|
205 | pScrn->driverPrivate = xnfcalloc(sizeof(DUMMYRec), 1); |
---|
206 | |
---|
207 | if (pScrn->driverPrivate == NULL) |
---|
208 | return FALSE; |
---|
209 | return TRUE; |
---|
210 | } |
---|
211 | |
---|
212 | static void |
---|
213 | DUMMYFreeRec(ScrnInfoPtr pScrn) |
---|
214 | { |
---|
215 | if (pScrn->driverPrivate == NULL) |
---|
216 | return; |
---|
217 | free(pScrn->driverPrivate); |
---|
218 | pScrn->driverPrivate = NULL; |
---|
219 | } |
---|
220 | |
---|
221 | static const OptionInfoRec * |
---|
222 | DUMMYAvailableOptions(int chipid, int busid) |
---|
223 | { |
---|
224 | return DUMMYOptions; |
---|
225 | } |
---|
226 | |
---|
227 | /* Mandatory */ |
---|
228 | static void |
---|
229 | DUMMYIdentify(int flags) |
---|
230 | { |
---|
231 | xf86PrintChipsets(DUMMY_NAME, "Driver for Dummy chipsets", |
---|
232 | DUMMYChipsets); |
---|
233 | } |
---|
234 | |
---|
235 | /* Mandatory */ |
---|
236 | static Bool |
---|
237 | DUMMYProbe(DriverPtr drv, int flags) |
---|
238 | { |
---|
239 | Bool foundScreen = FALSE; |
---|
240 | int numDevSections, numUsed; |
---|
241 | GDevPtr *devSections; |
---|
242 | int i; |
---|
243 | |
---|
244 | if (flags & PROBE_DETECT) |
---|
245 | return FALSE; |
---|
246 | /* |
---|
247 | * Find the config file Device sections that match this |
---|
248 | * driver, and return if there are none. |
---|
249 | */ |
---|
250 | if ((numDevSections = xf86MatchDevice(DUMMY_DRIVER_NAME, |
---|
251 | &devSections)) <= 0) { |
---|
252 | return FALSE; |
---|
253 | } |
---|
254 | |
---|
255 | numUsed = numDevSections; |
---|
256 | |
---|
257 | if (numUsed > 0) { |
---|
258 | |
---|
259 | for (i = 0; i < numUsed; i++) { |
---|
260 | ScrnInfoPtr pScrn = NULL; |
---|
261 | int entityIndex = |
---|
262 | xf86ClaimNoSlot(drv,DUMMY_CHIP,devSections[i],TRUE); |
---|
263 | /* Allocate a ScrnInfoRec and claim the slot */ |
---|
264 | if ((pScrn = xf86AllocateScreen(drv,0 ))) { |
---|
265 | xf86AddEntityToScreen(pScrn,entityIndex); |
---|
266 | pScrn->driverVersion = DUMMY_VERSION; |
---|
267 | pScrn->driverName = DUMMY_DRIVER_NAME; |
---|
268 | pScrn->name = DUMMY_NAME; |
---|
269 | pScrn->Probe = DUMMYProbe; |
---|
270 | pScrn->PreInit = DUMMYPreInit; |
---|
271 | pScrn->ScreenInit = DUMMYScreenInit; |
---|
272 | pScrn->SwitchMode = DUMMYSwitchMode; |
---|
273 | pScrn->AdjustFrame = DUMMYAdjustFrame; |
---|
274 | pScrn->EnterVT = DUMMYEnterVT; |
---|
275 | pScrn->LeaveVT = DUMMYLeaveVT; |
---|
276 | pScrn->FreeScreen = DUMMYFreeScreen; |
---|
277 | pScrn->ValidMode = DUMMYValidMode; |
---|
278 | |
---|
279 | foundScreen = TRUE; |
---|
280 | } |
---|
281 | } |
---|
282 | } |
---|
283 | return foundScreen; |
---|
284 | } |
---|
285 | |
---|
286 | # define RETURN \ |
---|
287 | { DUMMYFreeRec(pScrn);\ |
---|
288 | return FALSE;\ |
---|
289 | } |
---|
290 | |
---|
291 | /* Mandatory */ |
---|
292 | Bool |
---|
293 | DUMMYPreInit(ScrnInfoPtr pScrn, int flags) |
---|
294 | { |
---|
295 | ClockRangePtr clockRanges; |
---|
296 | int i; |
---|
297 | DUMMYPtr dPtr; |
---|
298 | int maxClock = 230000; |
---|
299 | GDevPtr device = xf86GetEntityInfo(pScrn->entityList[0])->device; |
---|
300 | |
---|
301 | if (flags & PROBE_DETECT) |
---|
302 | return TRUE; |
---|
303 | |
---|
304 | /* Allocate the DummyRec driverPrivate */ |
---|
305 | if (!DUMMYGetRec(pScrn)) { |
---|
306 | return FALSE; |
---|
307 | } |
---|
308 | |
---|
309 | dPtr = DUMMYPTR(pScrn); |
---|
310 | |
---|
311 | pScrn->chipset = (char *)xf86TokenToString(DUMMYChipsets, |
---|
312 | DUMMY_CHIP); |
---|
313 | |
---|
314 | xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Chipset is a DUMMY\n"); |
---|
315 | |
---|
316 | pScrn->monitor = pScrn->confScreen->monitor; |
---|
317 | |
---|
318 | if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support24bppFb | Support32bppFb)) |
---|
319 | return FALSE; |
---|
320 | else { |
---|
321 | /* Check that the returned depth is one we support */ |
---|
322 | switch (pScrn->depth) { |
---|
323 | case 8: |
---|
324 | case 15: |
---|
325 | case 16: |
---|
326 | case 24: |
---|
327 | break; |
---|
328 | default: |
---|
329 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
---|
330 | "Given depth (%d) is not supported by this driver\n", |
---|
331 | pScrn->depth); |
---|
332 | return FALSE; |
---|
333 | } |
---|
334 | } |
---|
335 | |
---|
336 | xf86PrintDepthBpp(pScrn); |
---|
337 | if (pScrn->depth == 8) |
---|
338 | pScrn->rgbBits = 8; |
---|
339 | |
---|
340 | /* Get the depth24 pixmap format */ |
---|
341 | if (pScrn->depth == 24 && pix24bpp == 0) |
---|
342 | pix24bpp = xf86GetBppFromDepth(pScrn, 24); |
---|
343 | |
---|
344 | /* |
---|
345 | * This must happen after pScrn->display has been set because |
---|
346 | * xf86SetWeight references it. |
---|
347 | */ |
---|
348 | if (pScrn->depth > 8) { |
---|
349 | /* The defaults are OK for us */ |
---|
350 | rgb zeros = {0, 0, 0}; |
---|
351 | |
---|
352 | if (!xf86SetWeight(pScrn, zeros, zeros)) { |
---|
353 | return FALSE; |
---|
354 | } else { |
---|
355 | /* XXX check that weight returned is supported */ |
---|
356 | ; |
---|
357 | } |
---|
358 | } |
---|
359 | |
---|
360 | if (!xf86SetDefaultVisual(pScrn, -1)) |
---|
361 | return FALSE; |
---|
362 | |
---|
363 | if (pScrn->depth > 1) { |
---|
364 | Gamma zeros = {0.0, 0.0, 0.0}; |
---|
365 | |
---|
366 | if (!xf86SetGamma(pScrn, zeros)) |
---|
367 | return FALSE; |
---|
368 | } |
---|
369 | |
---|
370 | xf86CollectOptions(pScrn, device->options); |
---|
371 | /* Process the options */ |
---|
372 | if (!(dPtr->Options = malloc(sizeof(DUMMYOptions)))) |
---|
373 | return FALSE; |
---|
374 | memcpy(dPtr->Options, DUMMYOptions, sizeof(DUMMYOptions)); |
---|
375 | |
---|
376 | xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, dPtr->Options); |
---|
377 | |
---|
378 | xf86GetOptValBool(dPtr->Options, OPTION_SW_CURSOR,&dPtr->swCursor); |
---|
379 | xf86GetOptValBool(dPtr->Options, OPTION_CONSTANT_DPI, &dPtr->constantDPI); |
---|
380 | |
---|
381 | if (device->videoRam != 0) { |
---|
382 | pScrn->videoRam = device->videoRam; |
---|
383 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "VideoRAM: %d kByte\n", |
---|
384 | pScrn->videoRam); |
---|
385 | } else { |
---|
386 | pScrn->videoRam = 4096; |
---|
387 | xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "VideoRAM: %d kByte\n", |
---|
388 | pScrn->videoRam); |
---|
389 | } |
---|
390 | |
---|
391 | if (device->dacSpeeds[0] != 0) { |
---|
392 | maxClock = device->dacSpeeds[0]; |
---|
393 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Max Clock: %d kHz\n", |
---|
394 | maxClock); |
---|
395 | } else { |
---|
396 | xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Max Clock: %d kHz\n", |
---|
397 | maxClock); |
---|
398 | } |
---|
399 | |
---|
400 | pScrn->progClock = TRUE; |
---|
401 | /* |
---|
402 | * Setup the ClockRanges, which describe what clock ranges are available, |
---|
403 | * and what sort of modes they can be used for. |
---|
404 | */ |
---|
405 | clockRanges = (ClockRangePtr)xnfcalloc(sizeof(ClockRange), 1); |
---|
406 | clockRanges->next = NULL; |
---|
407 | clockRanges->ClockMulFactor = 1; |
---|
408 | clockRanges->minClock = 11000; /* guessed §§§ */ |
---|
409 | clockRanges->maxClock = 300000; |
---|
410 | clockRanges->clockIndex = -1; /* programmable */ |
---|
411 | clockRanges->interlaceAllowed = TRUE; |
---|
412 | clockRanges->doubleScanAllowed = TRUE; |
---|
413 | |
---|
414 | /* Subtract memory for HW cursor */ |
---|
415 | |
---|
416 | |
---|
417 | { |
---|
418 | int apertureSize = (pScrn->videoRam * 1024); |
---|
419 | i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, |
---|
420 | pScrn->display->modes, clockRanges, |
---|
421 | NULL, 256, DUMMY_MAX_WIDTH, |
---|
422 | (8 * pScrn->bitsPerPixel), |
---|
423 | 128, DUMMY_MAX_HEIGHT, pScrn->display->virtualX, |
---|
424 | pScrn->display->virtualY, apertureSize, |
---|
425 | LOOKUP_BEST_REFRESH); |
---|
426 | |
---|
427 | if (i == -1) |
---|
428 | RETURN; |
---|
429 | } |
---|
430 | |
---|
431 | /* Prune the modes marked as invalid */ |
---|
432 | xf86PruneDriverModes(pScrn); |
---|
433 | |
---|
434 | if (i == 0 || pScrn->modes == NULL) { |
---|
435 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); |
---|
436 | RETURN; |
---|
437 | } |
---|
438 | |
---|
439 | /* |
---|
440 | * Set the CRTC parameters for all of the modes based on the type |
---|
441 | * of mode, and the chipset's interlace requirements. |
---|
442 | * |
---|
443 | * Calling this is required if the mode->Crtc* values are used by the |
---|
444 | * driver and if the driver doesn't provide code to set them. They |
---|
445 | * are not pre-initialised at all. |
---|
446 | */ |
---|
447 | xf86SetCrtcForModes(pScrn, 0); |
---|
448 | |
---|
449 | /* Set the current mode to the first in the list */ |
---|
450 | pScrn->currentMode = pScrn->modes; |
---|
451 | |
---|
452 | /* Print the list of modes being used */ |
---|
453 | xf86PrintModes(pScrn); |
---|
454 | |
---|
455 | /* If monitor resolution is set on the command line, use it */ |
---|
456 | xf86SetDpi(pScrn, 0, 0); |
---|
457 | |
---|
458 | if (xf86LoadSubModule(pScrn, "fb") == NULL) { |
---|
459 | RETURN; |
---|
460 | } |
---|
461 | |
---|
462 | if (!dPtr->swCursor) { |
---|
463 | if (!xf86LoadSubModule(pScrn, "ramdac")) |
---|
464 | RETURN; |
---|
465 | } |
---|
466 | |
---|
467 | /* We have no contiguous physical fb in physical memory */ |
---|
468 | pScrn->memPhysBase = 0; |
---|
469 | pScrn->fbOffset = 0; |
---|
470 | |
---|
471 | return TRUE; |
---|
472 | } |
---|
473 | #undef RETURN |
---|
474 | |
---|
475 | /* Mandatory */ |
---|
476 | static Bool |
---|
477 | DUMMYEnterVT(VT_FUNC_ARGS_DECL) |
---|
478 | { |
---|
479 | SCRN_INFO_PTR(arg); |
---|
480 | |
---|
481 | /* Should we re-save the text mode on each VT enter? */ |
---|
482 | if(!dummyModeInit(pScrn, pScrn->currentMode)) |
---|
483 | return FALSE; |
---|
484 | |
---|
485 | DUMMYAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); |
---|
486 | |
---|
487 | return TRUE; |
---|
488 | } |
---|
489 | |
---|
490 | /* Mandatory */ |
---|
491 | static void |
---|
492 | DUMMYLeaveVT(VT_FUNC_ARGS_DECL) |
---|
493 | { |
---|
494 | SCRN_INFO_PTR(arg); |
---|
495 | dummyRestore(pScrn, TRUE); |
---|
496 | } |
---|
497 | |
---|
498 | static void |
---|
499 | DUMMYLoadPalette( |
---|
500 | ScrnInfoPtr pScrn, |
---|
501 | int numColors, |
---|
502 | int *indices, |
---|
503 | LOCO *colors, |
---|
504 | VisualPtr pVisual |
---|
505 | ){ |
---|
506 | int i, index, shift, Gshift; |
---|
507 | DUMMYPtr dPtr = DUMMYPTR(pScrn); |
---|
508 | |
---|
509 | switch(pScrn->depth) { |
---|
510 | case 15: |
---|
511 | shift = Gshift = 1; |
---|
512 | break; |
---|
513 | case 16: |
---|
514 | shift = 0; |
---|
515 | Gshift = 0; |
---|
516 | break; |
---|
517 | default: |
---|
518 | shift = Gshift = 0; |
---|
519 | break; |
---|
520 | } |
---|
521 | |
---|
522 | for(i = 0; i < numColors; i++) { |
---|
523 | index = indices[i]; |
---|
524 | dPtr->colors[index].red = colors[index].red << shift; |
---|
525 | dPtr->colors[index].green = colors[index].green << Gshift; |
---|
526 | dPtr->colors[index].blue = colors[index].blue << shift; |
---|
527 | } |
---|
528 | |
---|
529 | } |
---|
530 | |
---|
531 | static ScrnInfoPtr DUMMYScrn; /* static-globalize it */ |
---|
532 | |
---|
533 | /* Mandatory */ |
---|
534 | static Bool |
---|
535 | DUMMYScreenInit(SCREEN_INIT_ARGS_DECL) |
---|
536 | { |
---|
537 | ScrnInfoPtr pScrn; |
---|
538 | DUMMYPtr dPtr; |
---|
539 | int ret; |
---|
540 | VisualPtr visual; |
---|
541 | |
---|
542 | /* |
---|
543 | * we need to get the ScrnInfoRec for this screen, so let's allocate |
---|
544 | * one first thing |
---|
545 | */ |
---|
546 | pScrn = xf86ScreenToScrn(pScreen); |
---|
547 | dPtr = DUMMYPTR(pScrn); |
---|
548 | DUMMYScrn = pScrn; |
---|
549 | |
---|
550 | |
---|
551 | if (!(dPtr->FBBase = malloc(pScrn->videoRam * 1024))) |
---|
552 | return FALSE; |
---|
553 | |
---|
554 | /* |
---|
555 | * next we save the current state and setup the first mode |
---|
556 | */ |
---|
557 | dummySave(pScrn); |
---|
558 | |
---|
559 | if (!dummyModeInit(pScrn,pScrn->currentMode)) |
---|
560 | return FALSE; |
---|
561 | DUMMYAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); |
---|
562 | |
---|
563 | /* |
---|
564 | * Reset visual list. |
---|
565 | */ |
---|
566 | miClearVisualTypes(); |
---|
567 | |
---|
568 | /* Setup the visuals we support. */ |
---|
569 | |
---|
570 | if (!miSetVisualTypes(pScrn->depth, |
---|
571 | miGetDefaultVisualMask(pScrn->depth), |
---|
572 | pScrn->rgbBits, pScrn->defaultVisual)) |
---|
573 | return FALSE; |
---|
574 | |
---|
575 | if (!miSetPixmapDepths ()) return FALSE; |
---|
576 | |
---|
577 | /* |
---|
578 | * Call the framebuffer layer's ScreenInit function, and fill in other |
---|
579 | * pScreen fields. |
---|
580 | */ |
---|
581 | ret = fbScreenInit(pScreen, dPtr->FBBase, |
---|
582 | pScrn->virtualX, pScrn->virtualY, |
---|
583 | pScrn->xDpi, pScrn->yDpi, |
---|
584 | pScrn->displayWidth, pScrn->bitsPerPixel); |
---|
585 | if (!ret) |
---|
586 | return FALSE; |
---|
587 | |
---|
588 | if (pScrn->depth > 8) { |
---|
589 | /* Fixup RGB ordering */ |
---|
590 | visual = pScreen->visuals + pScreen->numVisuals; |
---|
591 | while (--visual >= pScreen->visuals) { |
---|
592 | if ((visual->class | DynamicClass) == DirectColor) { |
---|
593 | visual->offsetRed = pScrn->offset.red; |
---|
594 | visual->offsetGreen = pScrn->offset.green; |
---|
595 | visual->offsetBlue = pScrn->offset.blue; |
---|
596 | visual->redMask = pScrn->mask.red; |
---|
597 | visual->greenMask = pScrn->mask.green; |
---|
598 | visual->blueMask = pScrn->mask.blue; |
---|
599 | } |
---|
600 | } |
---|
601 | } |
---|
602 | |
---|
603 | /* must be after RGB ordering fixed */ |
---|
604 | fbPictureInit(pScreen, 0, 0); |
---|
605 | |
---|
606 | xf86SetBlackWhitePixels(pScreen); |
---|
607 | |
---|
608 | #ifdef USE_DGA |
---|
609 | DUMMYDGAInit(pScreen); |
---|
610 | #endif |
---|
611 | |
---|
612 | if (dPtr->swCursor) |
---|
613 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using Software Cursor.\n"); |
---|
614 | |
---|
615 | { |
---|
616 | |
---|
617 | |
---|
618 | BoxRec AvailFBArea; |
---|
619 | int lines = pScrn->videoRam * 1024 / |
---|
620 | (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)); |
---|
621 | AvailFBArea.x1 = 0; |
---|
622 | AvailFBArea.y1 = 0; |
---|
623 | AvailFBArea.x2 = pScrn->displayWidth; |
---|
624 | AvailFBArea.y2 = lines; |
---|
625 | xf86InitFBManager(pScreen, &AvailFBArea); |
---|
626 | |
---|
627 | xf86DrvMsg(pScrn->scrnIndex, X_INFO, |
---|
628 | "Using %i scanlines of offscreen memory \n" |
---|
629 | , lines - pScrn->virtualY); |
---|
630 | } |
---|
631 | |
---|
632 | xf86SetBackingStore(pScreen); |
---|
633 | xf86SetSilkenMouse(pScreen); |
---|
634 | |
---|
635 | //pScreen->isGPU = 0; |
---|
636 | |
---|
637 | /* Initialise cursor functions */ |
---|
638 | miDCInitialize (pScreen, xf86GetPointerScreenFuncs()); |
---|
639 | |
---|
640 | |
---|
641 | if (!dPtr->swCursor) { |
---|
642 | /* HW cursor functions */ |
---|
643 | if (!DUMMYCursorInit(pScreen)) { |
---|
644 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
---|
645 | "Hardware cursor initialization failed\n"); |
---|
646 | return FALSE; |
---|
647 | } |
---|
648 | } |
---|
649 | |
---|
650 | /* Initialise default colourmap */ |
---|
651 | if(!miCreateDefColormap(pScreen)) |
---|
652 | return FALSE; |
---|
653 | |
---|
654 | if (!xf86HandleColormaps(pScreen, 256, pScrn->rgbBits, |
---|
655 | DUMMYLoadPalette, NULL, |
---|
656 | CMAP_PALETTED_TRUECOLOR |
---|
657 | | CMAP_RELOAD_ON_MODE_SWITCH)) |
---|
658 | return FALSE; |
---|
659 | |
---|
660 | /* DUMMYInitVideo(pScreen); */ |
---|
661 | |
---|
662 | pScreen->SaveScreen = DUMMYSaveScreen; |
---|
663 | |
---|
664 | |
---|
665 | /* Wrap the current CloseScreen function */ |
---|
666 | dPtr->CloseScreen = pScreen->CloseScreen; |
---|
667 | pScreen->CloseScreen = DUMMYCloseScreen; |
---|
668 | |
---|
669 | /* Wrap the current CreateWindow function */ |
---|
670 | dPtr->CreateWindow = pScreen->CreateWindow; |
---|
671 | pScreen->CreateWindow = DUMMYCreateWindow; |
---|
672 | |
---|
673 | pScreen->ConstrainCursorHarder = NULL; |
---|
674 | |
---|
675 | /* Report any unused options (only for the first generation) */ |
---|
676 | if (serverGeneration == 1) { |
---|
677 | xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); |
---|
678 | } |
---|
679 | |
---|
680 | return TRUE; |
---|
681 | } |
---|
682 | |
---|
683 | const char *XDPY_PROPERTY = "dummy-constant-xdpi"; |
---|
684 | const char *YDPY_PROPERTY = "dummy-constant-ydpi"; |
---|
685 | static int get_dpi_value(WindowPtr root, const char *property_name, int default_dpi) |
---|
686 | { |
---|
687 | PropertyPtr prop; |
---|
688 | Atom type_atom = MakeAtom("CARDINAL", 8, TRUE); |
---|
689 | Atom prop_atom = MakeAtom(property_name, strlen(property_name), FALSE); |
---|
690 | |
---|
691 | for (prop = wUserProps(root); prop; prop = prop->next) { |
---|
692 | if (prop->propertyName == prop_atom && prop->type == type_atom && prop->data) { |
---|
693 | int v = (int) (*((CARD32 *) prop->data)); |
---|
694 | if ((v>0) && (v<4096)) { |
---|
695 | xf86DrvMsg(0, X_INFO, "get_constant_dpi_value() found property \"%s\" with value=%i\n", property_name, (int) v); |
---|
696 | return (int) v; |
---|
697 | } |
---|
698 | break; |
---|
699 | } |
---|
700 | } |
---|
701 | return default_dpi; |
---|
702 | } |
---|
703 | |
---|
704 | /* Mandatory */ |
---|
705 | Bool |
---|
706 | DUMMYSwitchMode(SWITCH_MODE_ARGS_DECL) |
---|
707 | { |
---|
708 | SCRN_INFO_PTR(arg); |
---|
709 | if (!dummyModeInit(pScrn, mode)) |
---|
710 | return FALSE; |
---|
711 | pScrn->pScreen->ConstrainCursorHarder = NULL; |
---|
712 | #ifdef RANDR |
---|
713 | DUMMYPtr dPtr = DUMMYPTR(pScrn); |
---|
714 | if (dPtr->constantDPI) { |
---|
715 | int xDpi = get_dpi_value(pScrn->pScreen->root, XDPY_PROPERTY, pScrn->xDpi); |
---|
716 | int yDpi = get_dpi_value(pScrn->pScreen->root, YDPY_PROPERTY, pScrn->yDpi); |
---|
717 | //25.4 mm per inch: (254/10) |
---|
718 | pScrn->pScreen->mmWidth = mode->HDisplay * 254 / xDpi / 10; |
---|
719 | pScrn->pScreen->mmHeight = mode->VDisplay * 254 / yDpi / 10; |
---|
720 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "mm(dpi %ix%i)=%ix%i\n", xDpi, yDpi, pScrn->pScreen->mmWidth, pScrn->pScreen->mmHeight); |
---|
721 | RRScreenSizeNotify(pScrn->pScreen); |
---|
722 | RRTellChanged(pScrn->pScreen); |
---|
723 | } |
---|
724 | #endif |
---|
725 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Screen: %ix%i\n", pScrn->pScreen->width, pScrn->pScreen->height); |
---|
726 | //xf86SetCrtcForModes(pScrn, 0); |
---|
727 | //xf86SetModeCrtc(pScrn->modes, 0); |
---|
728 | //xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Modes: %s : %ix%i\n", pScrn->modes->name, pScrn->modes->HTotal, pScrn->modes->VTotal); |
---|
729 | int c,d; |
---|
730 | |
---|
731 | rrScrPrivPtr rrScrPriv = rrGetScrPriv(pScrn->pScreen); |
---|
732 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "rrScrPriv: %p\n", rrScrPriv); |
---|
733 | for (c = 0; c < rrScrPriv->numCrtcs; c++) { |
---|
734 | RRCrtcPtr crtc = rrScrPriv->crtcs[c]; |
---|
735 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "crtc[%i]: %p %i outputs\n", c, &crtc, crtc->numOutputs); |
---|
736 | //xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "crtc[%i]: %p\n", c, &crtc); |
---|
737 | for (d = 0; d < crtc->numOutputs; d++) { |
---|
738 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, " output[%i] = %s", d, crtc->outputs[d]->name); |
---|
739 | } |
---|
740 | xf86CrtcPtr xfcrtc = crtc->devPrivate; |
---|
741 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "CRTC: %i: %p\n", c, xfcrtc); |
---|
742 | } |
---|
743 | |
---|
744 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "InputInfo: %p\n", &inputInfo); |
---|
745 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "InputInfo.devices: %p\n", inputInfo.devices); |
---|
746 | DeviceIntPtr pDev; |
---|
747 | SpritePtr pSprite; |
---|
748 | c = 0; |
---|
749 | for (pDev = inputInfo.devices; pDev; pDev = pDev->next) |
---|
750 | { |
---|
751 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "device=%p\n", pDev); |
---|
752 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, " enabled=%i\n", pDev->enabled); |
---|
753 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, " coreEvents=%i\n", pDev->coreEvents); |
---|
754 | if (pDev->config_info!=NULL) |
---|
755 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, " config_info=%p\n", pDev->config_info); |
---|
756 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, " spriteInfo=%p\n", pDev->spriteInfo); |
---|
757 | if (pDev->spriteInfo) |
---|
758 | { |
---|
759 | pSprite = pDev->spriteInfo->sprite; |
---|
760 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, " pSprite[%d]=%p\n", c, pSprite); |
---|
761 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, " hotLimits=%i,%i,%i,%i\n", pSprite->hotLimits.x1, pSprite->hotLimits.y1, pSprite->hotLimits.x2, pSprite->hotLimits.y2); |
---|
762 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, " physLimits=%i,%i,%i,%i\n", pSprite->physLimits.x1, pSprite->physLimits.y1, pSprite->physLimits.x2, pSprite->physLimits.y2); |
---|
763 | } |
---|
764 | c++; |
---|
765 | } |
---|
766 | |
---|
767 | |
---|
768 | //RRCrtcPtr rrcrtc = xf86GetPrimaryCrtc(pScrn->pScreen)->randr_crtc; |
---|
769 | //xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "crtc: %p\n", rrcrtc); |
---|
770 | //rrcrtc = xf86CompatRRCrtc(pScrn); |
---|
771 | //xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "crtc: %p\n", rrcrtc); |
---|
772 | |
---|
773 | //xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); |
---|
774 | //xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "config: %p\n", config); |
---|
775 | //lazy: just update all the crtcs! |
---|
776 | /*for (c = 0; c < config->num_crtc; c++) { |
---|
777 | xf86CrtcPtr crtc = config->crtc[c]; |
---|
778 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "CRTC: %i: %p\n", c, crtc); |
---|
779 | if (crtc!=NULL) { |
---|
780 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "CRTC: %i: active=%i\n", c, crtc->active); |
---|
781 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, " bounds: %i,%i,%i,%i", crtc->bounds.x1, crtc->bounds.y1, crtc->bounds.x2, crtc->bounds.y2); |
---|
782 | } |
---|
783 | //crtc->bounds = NULL; |
---|
784 | }*/ |
---|
785 | //BarrierScreenPtr cs = GetBarrierScreen(screen); |
---|
786 | //XIBarrierInit() |
---|
787 | //XIBarrierReset(); |
---|
788 | //XFixesDestroyPointerBarrier(); |
---|
789 | //BarrierScreenPtr cs = GetBarrierScreen(pScreen); |
---|
790 | //XFixesDestroyPointerBarrier(Display *dpy, PointerBarrier b); |
---|
791 | //xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Screen: %ix%i\n", pScrn->displayWidth, pScrn->displayHeight); |
---|
792 | |
---|
793 | return TRUE; |
---|
794 | } |
---|
795 | |
---|
796 | /* Mandatory */ |
---|
797 | void |
---|
798 | DUMMYAdjustFrame(ADJUST_FRAME_ARGS_DECL) |
---|
799 | { |
---|
800 | SCRN_INFO_PTR(arg); |
---|
801 | int Base; |
---|
802 | |
---|
803 | Base = (y * pScrn->displayWidth + x) >> 2; |
---|
804 | |
---|
805 | /* Scale Base by the number of bytes per pixel. */ |
---|
806 | switch (pScrn->depth) { |
---|
807 | case 8 : |
---|
808 | break; |
---|
809 | case 15 : |
---|
810 | case 16 : |
---|
811 | Base *= 2; |
---|
812 | break; |
---|
813 | case 24 : |
---|
814 | Base *= 3; |
---|
815 | break; |
---|
816 | default : |
---|
817 | break; |
---|
818 | } |
---|
819 | } |
---|
820 | |
---|
821 | /* Mandatory */ |
---|
822 | static Bool |
---|
823 | DUMMYCloseScreen(CLOSE_SCREEN_ARGS_DECL) |
---|
824 | { |
---|
825 | ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
---|
826 | DUMMYPtr dPtr = DUMMYPTR(pScrn); |
---|
827 | |
---|
828 | if(pScrn->vtSema){ |
---|
829 | dummyRestore(pScrn, TRUE); |
---|
830 | free(dPtr->FBBase); |
---|
831 | } |
---|
832 | |
---|
833 | if (dPtr->CursorInfo) |
---|
834 | xf86DestroyCursorInfoRec(dPtr->CursorInfo); |
---|
835 | |
---|
836 | pScrn->vtSema = FALSE; |
---|
837 | pScreen->CloseScreen = dPtr->CloseScreen; |
---|
838 | return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS); |
---|
839 | } |
---|
840 | |
---|
841 | /* Optional */ |
---|
842 | static void |
---|
843 | DUMMYFreeScreen(FREE_SCREEN_ARGS_DECL) |
---|
844 | { |
---|
845 | SCRN_INFO_PTR(arg); |
---|
846 | DUMMYFreeRec(pScrn); |
---|
847 | } |
---|
848 | |
---|
849 | static Bool |
---|
850 | DUMMYSaveScreen(ScreenPtr pScreen, int mode) |
---|
851 | { |
---|
852 | ScrnInfoPtr pScrn = NULL; |
---|
853 | DUMMYPtr dPtr; |
---|
854 | |
---|
855 | if (pScreen != NULL) { |
---|
856 | pScrn = xf86ScreenToScrn(pScreen); |
---|
857 | dPtr = DUMMYPTR(pScrn); |
---|
858 | |
---|
859 | dPtr->screenSaver = xf86IsUnblank(mode); |
---|
860 | } |
---|
861 | return TRUE; |
---|
862 | } |
---|
863 | |
---|
864 | /* Optional */ |
---|
865 | static ModeStatus |
---|
866 | DUMMYValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags) |
---|
867 | { |
---|
868 | return(MODE_OK); |
---|
869 | } |
---|
870 | |
---|
871 | static void |
---|
872 | dummySave(ScrnInfoPtr pScrn) |
---|
873 | { |
---|
874 | } |
---|
875 | |
---|
876 | static void |
---|
877 | dummyRestore(ScrnInfoPtr pScrn, Bool restoreText) |
---|
878 | { |
---|
879 | } |
---|
880 | |
---|
881 | static Bool |
---|
882 | dummyModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) |
---|
883 | { |
---|
884 | dummyRestore(pScrn, FALSE); |
---|
885 | |
---|
886 | return(TRUE); |
---|
887 | } |
---|
888 | |
---|
889 | Atom VFB_PROP = 0; |
---|
890 | #define VFB_PROP_NAME "VFB_IDENT" |
---|
891 | |
---|
892 | static Bool |
---|
893 | DUMMYCreateWindow(WindowPtr pWin) |
---|
894 | { |
---|
895 | ScreenPtr pScreen = pWin->drawable.pScreen; |
---|
896 | DUMMYPtr dPtr = DUMMYPTR(DUMMYScrn); |
---|
897 | WindowPtr pWinRoot; |
---|
898 | int ret; |
---|
899 | |
---|
900 | pScreen->CreateWindow = dPtr->CreateWindow; |
---|
901 | ret = pScreen->CreateWindow(pWin); |
---|
902 | dPtr->CreateWindow = pScreen->CreateWindow; |
---|
903 | pScreen->CreateWindow = DUMMYCreateWindow; |
---|
904 | |
---|
905 | if(ret != TRUE) |
---|
906 | return(ret); |
---|
907 | |
---|
908 | if(dPtr->prop == FALSE) { |
---|
909 | #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 8 |
---|
910 | pWinRoot = WindowTable[DUMMYScrn->pScreen->myNum]; |
---|
911 | #else |
---|
912 | pWinRoot = DUMMYScrn->pScreen->root; |
---|
913 | #endif |
---|
914 | if (! ValidAtom(VFB_PROP)) |
---|
915 | VFB_PROP = MakeAtom(VFB_PROP_NAME, strlen(VFB_PROP_NAME), 1); |
---|
916 | |
---|
917 | ret = ChangeWindowProperty(pWinRoot, VFB_PROP, XA_STRING, |
---|
918 | 8, PropModeReplace, (int)4, (pointer)"TRUE", FALSE); |
---|
919 | if( ret != Success) |
---|
920 | ErrorF("Could not set VFB root window property"); |
---|
921 | dPtr->prop = TRUE; |
---|
922 | |
---|
923 | return TRUE; |
---|
924 | } |
---|
925 | return TRUE; |
---|
926 | } |
---|
927 | |
---|
928 | #ifndef HW_SKIP_CONSOLE |
---|
929 | #define HW_SKIP_CONSOLE 4 |
---|
930 | #endif |
---|
931 | |
---|
932 | static Bool |
---|
933 | dummyDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, pointer ptr) |
---|
934 | { |
---|
935 | CARD32 *flag; |
---|
936 | |
---|
937 | switch (op) { |
---|
938 | case GET_REQUIRED_HW_INTERFACES: |
---|
939 | flag = (CARD32*)ptr; |
---|
940 | (*flag) = HW_SKIP_CONSOLE; |
---|
941 | return TRUE; |
---|
942 | default: |
---|
943 | return FALSE; |
---|
944 | } |
---|
945 | } |
---|