| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $OpenBSD: wsfb_driver.c,v 1.19 2003/04/27 16:42:32 matthieu Exp $ */ | | 1 | /* $OpenBSD: wsfb_driver.c,v 1.16 2009/09/13 19:33:49 matthieu Exp $ */ |
2 | /* | | 2 | /* |
3 | * Copyright (c) 2001 Matthieu Herrb | | 3 | * Copyright (c) 2001 Matthieu Herrb |
4 | * All rights reserved. | | 4 | * All rights reserved. |
5 | * | | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions | | 7 | * modification, are permitted provided that the following conditions |
8 | * are met: | | 8 | * are met: |
9 | * | | 9 | * |
10 | * - Redistributions of source code must retain the above copyright | | 10 | * - Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * - Redistributions in binary form must reproduce the above | | 12 | * - Redistributions in binary form must reproduce the above |
13 | * copyright notice, this list of conditions and the following | | 13 | * copyright notice, this list of conditions and the following |
14 | * disclaimer in the documentation and/or other materials provided | | 14 | * disclaimer in the documentation and/or other materials provided |
| @@ -30,61 +30,71 @@ | | | @@ -30,61 +30,71 @@ |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | /* | | 32 | /* |
33 | * Based on fbdev.c written by: | | 33 | * Based on fbdev.c written by: |
34 | * | | 34 | * |
35 | * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> | | 35 | * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> |
36 | * Michel Dänzer, <michdaen@iiic.ethz.ch> | | 36 | * Michel Dänzer, <michdaen@iiic.ethz.ch> |
37 | */ | | 37 | */ |
38 | | | 38 | |
39 | #ifdef HAVE_CONFIG_H | | 39 | #ifdef HAVE_CONFIG_H |
40 | #include "config.h" | | 40 | #include "config.h" |
41 | #endif | | 41 | #endif |
42 | | | 42 | |
| | | 43 | #include <errno.h> |
43 | #include <fcntl.h> | | 44 | #include <fcntl.h> |
44 | #include <sys/types.h> | | 45 | #include <sys/types.h> |
| | | 46 | #include <sys/mman.h> |
45 | #include <sys/time.h> | | 47 | #include <sys/time.h> |
46 | #include <errno.h> | | 48 | #include <errno.h> |
47 | #include <dev/wscons/wsconsio.h> | | 49 | #include <dev/wscons/wsconsio.h> |
48 | | | 50 | |
49 | /* all driver need this */ | | 51 | /* All drivers need this. */ |
50 | #include "xf86.h" | | 52 | #include "xf86.h" |
51 | #include "xf86_OSproc.h" | | 53 | #include "xf86_OSproc.h" |
52 | | | 54 | |
53 | #include "mipointer.h" | | 55 | #include "mipointer.h" |
54 | #include "mibstore.h" | | 56 | #include "mibstore.h" |
55 | #include "micmap.h" | | 57 | #include "micmap.h" |
56 | #include "colormapst.h" | | 58 | #include "colormapst.h" |
57 | #include "xf86cmap.h" | | 59 | #include "xf86cmap.h" |
58 | #include "shadow.h" | | 60 | #include "shadow.h" |
59 | #include "dgaproc.h" | | 61 | #include "dgaproc.h" |
60 | | | 62 | |
61 | /* for visuals */ | | 63 | /* For visuals */ |
| | | 64 | #ifdef HAVE_XF1BPP |
| | | 65 | # include "xf1bpp.h" |
| | | 66 | #endif |
| | | 67 | #ifdef HAVE_XF4BPP |
| | | 68 | # include "xf4bpp.h" |
| | | 69 | #endif |
62 | #include "fb.h" | | 70 | #include "fb.h" |
63 | | | 71 | |
| | | 72 | #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 6 |
64 | #include "xf86Resources.h" | | 73 | #include "xf86Resources.h" |
65 | #include "xf86RAC.h" | | 74 | #include "xf86RAC.h" |
| | | 75 | #endif |
66 | | | 76 | |
67 | #ifdef XvExtension | | 77 | #ifdef XvExtension |
68 | #include "xf86xv.h" | | 78 | #include "xf86xv.h" |
69 | #endif | | 79 | #endif |
70 | | | 80 | |
71 | #include "wsfb.h" | | 81 | #include "wsfb.h" |
72 | | | 82 | |
73 | /* #include "wsconsio.h" */ | | 83 | /* #include "wsconsio.h" */ |
74 | | | 84 | |
75 | #include <sys/mman.h> | | 85 | #include <sys/mman.h> |
76 | | | 86 | |
77 | #ifdef USE_PRIVSEP | | 87 | #ifdef X_PRIVSEP |
78 | extern int priv_open_device(const char *); | | 88 | extern int priv_open_device(const char *); |
79 | #else | | 89 | #else |
80 | #define priv_open_device(n) open(n,O_RDWR|O_NONBLOCK|O_EXCL) | | 90 | #define priv_open_device(n) open(n,O_RDWR|O_NONBLOCK|O_EXCL) |
81 | #endif | | 91 | #endif |
82 | | | 92 | |
83 | #if defined(__NetBSD__) | | 93 | #if defined(__NetBSD__) |
84 | #define WSFB_DEFAULT_DEV "/dev/ttyE0" | | 94 | #define WSFB_DEFAULT_DEV "/dev/ttyE0" |
85 | #else | | 95 | #else |
86 | #define WSFB_DEFAULT_DEV "/dev/ttyC0" | | 96 | #define WSFB_DEFAULT_DEV "/dev/ttyC0" |
87 | #endif | | 97 | #endif |
88 | | | 98 | |
89 | #define DEBUG 0 | | 99 | #define DEBUG 0 |
90 | | | 100 | |
| @@ -112,50 +122,50 @@ static Bool WsfbScreenInit(int, ScreenPt | | | @@ -112,50 +122,50 @@ static Bool WsfbScreenInit(int, ScreenPt |
112 | static Bool WsfbCloseScreen(int, ScreenPtr); | | 122 | static Bool WsfbCloseScreen(int, ScreenPtr); |
113 | static void *WsfbWindowLinear(ScreenPtr, CARD32, CARD32, int, CARD32 *, | | 123 | static void *WsfbWindowLinear(ScreenPtr, CARD32, CARD32, int, CARD32 *, |
114 | void *); | | 124 | void *); |
115 | static void WsfbPointerMoved(int, int, int); | | 125 | static void WsfbPointerMoved(int, int, int); |
116 | static Bool WsfbEnterVT(int, int); | | 126 | static Bool WsfbEnterVT(int, int); |
117 | static void WsfbLeaveVT(int, int); | | 127 | static void WsfbLeaveVT(int, int); |
118 | static Bool WsfbSwitchMode(int, DisplayModePtr, int); | | 128 | static Bool WsfbSwitchMode(int, DisplayModePtr, int); |
119 | static int WsfbValidMode(int, DisplayModePtr, Bool, int); | | 129 | static int WsfbValidMode(int, DisplayModePtr, Bool, int); |
120 | static void WsfbLoadPalette(ScrnInfoPtr, int, int *, LOCO *, VisualPtr); | | 130 | static void WsfbLoadPalette(ScrnInfoPtr, int, int *, LOCO *, VisualPtr); |
121 | static Bool WsfbSaveScreen(ScreenPtr, int); | | 131 | static Bool WsfbSaveScreen(ScreenPtr, int); |
122 | static void WsfbSave(ScrnInfoPtr); | | 132 | static void WsfbSave(ScrnInfoPtr); |
123 | static void WsfbRestore(ScrnInfoPtr); | | 133 | static void WsfbRestore(ScrnInfoPtr); |
124 | | | 134 | |
125 | /* dga stuff */ | | 135 | /* DGA stuff */ |
126 | #ifdef XFreeXDGA | | 136 | #ifdef XFreeXDGA |
127 | static Bool WsfbDGAOpenFramebuffer(ScrnInfoPtr, char **, unsigned char **, | | 137 | static Bool WsfbDGAOpenFramebuffer(ScrnInfoPtr, char **, unsigned char **, |
128 | int *, int *, int *); | | 138 | int *, int *, int *); |
129 | static Bool WsfbDGASetMode(ScrnInfoPtr, DGAModePtr); | | 139 | static Bool WsfbDGASetMode(ScrnInfoPtr, DGAModePtr); |
130 | static void WsfbDGASetViewport(ScrnInfoPtr, int, int, int); | | 140 | static void WsfbDGASetViewport(ScrnInfoPtr, int, int, int); |
131 | static Bool WsfbDGAInit(ScrnInfoPtr, ScreenPtr); | | 141 | static Bool WsfbDGAInit(ScrnInfoPtr, ScreenPtr); |
132 | #endif | | 142 | #endif |
133 | static Bool WsfbDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, | | 143 | static Bool WsfbDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, |
134 | pointer ptr); | | 144 | pointer ptr); |
135 | | | 145 | |
136 | /* helper functions */ | | 146 | /* Helper functions */ |
137 | static int wsfb_open(char *); | | 147 | static int wsfb_open(char *); |
138 | static pointer wsfb_mmap(size_t, off_t, int); | | 148 | static pointer wsfb_mmap(size_t, off_t, int); |
139 | | | 149 | |
140 | enum { WSFB_ROTATE_NONE = 0, | | 150 | enum { WSFB_ROTATE_NONE = 0, |
141 | WSFB_ROTATE_CCW = 90, | | 151 | WSFB_ROTATE_CCW = 90, |
142 | WSFB_ROTATE_UD = 180, | | 152 | WSFB_ROTATE_UD = 180, |
143 | WSFB_ROTATE_CW = 270 | | 153 | WSFB_ROTATE_CW = 270 |
144 | }; | | 154 | }; |
145 | | | 155 | |
146 | /* | | 156 | /* |
147 | * This is intentionally screen-independent. It indicates the binding | | 157 | * This is intentionally screen-independent. |
148 | * choice made in the first PreInit. | | 158 | * It indicates the binding choice made in the first PreInit. |
149 | */ | | 159 | */ |
150 | static int pix24bpp = 0; | | 160 | static int pix24bpp = 0; |
151 | | | 161 | |
152 | #define WSFB_VERSION 4000 | | 162 | #define WSFB_VERSION 4000 |
153 | #define WSFB_NAME "wsfb" | | 163 | #define WSFB_NAME "wsfb" |
154 | #define WSFB_DRIVER_NAME "wsfb" | | 164 | #define WSFB_DRIVER_NAME "wsfb" |
155 | | | 165 | |
156 | _X_EXPORT DriverRec WSFB = { | | 166 | _X_EXPORT DriverRec WSFB = { |
157 | WSFB_VERSION, | | 167 | WSFB_VERSION, |
158 | WSFB_DRIVER_NAME, | | 168 | WSFB_DRIVER_NAME, |
159 | WsfbIdentify, | | 169 | WsfbIdentify, |
160 | WsfbProbe, | | 170 | WsfbProbe, |
161 | WsfbAvailableOptions, | | 171 | WsfbAvailableOptions, |
| @@ -221,27 +231,27 @@ static XF86ModuleVersionInfo WsfbVersRec | | | @@ -221,27 +231,27 @@ static XF86ModuleVersionInfo WsfbVersRec |
221 | ABI_VIDEODRV_VERSION, | | 231 | ABI_VIDEODRV_VERSION, |
222 | NULL, | | 232 | NULL, |
223 | {0, 0, 0, 0} | | 233 | {0, 0, 0, 0} |
224 | }; | | 234 | }; |
225 | | | 235 | |
226 | _X_EXPORT XF86ModuleData wsfbModuleData = { &WsfbVersRec, WsfbSetup, NULL }; | | 236 | _X_EXPORT XF86ModuleData wsfbModuleData = { &WsfbVersRec, WsfbSetup, NULL }; |
227 | | | 237 | |
228 | static pointer | | 238 | static pointer |
229 | WsfbSetup(pointer module, pointer opts, int *errmaj, int *errmin) | | 239 | WsfbSetup(pointer module, pointer opts, int *errmaj, int *errmin) |
230 | { | | 240 | { |
231 | static Bool setupDone = FALSE; | | 241 | static Bool setupDone = FALSE; |
232 | const char *osname; | | 242 | const char *osname; |
233 | | | 243 | |
234 | /* Check that we're being loaded on a OpenBSD or NetBSD system */ | | 244 | /* Check that we're being loaded on a OpenBSD or NetBSD system. */ |
235 | LoaderGetOS(&osname, NULL, NULL, NULL); | | 245 | LoaderGetOS(&osname, NULL, NULL, NULL); |
236 | if (!osname || (strcmp(osname, "openbsd") != 0 && | | 246 | if (!osname || (strcmp(osname, "openbsd") != 0 && |
237 | strcmp(osname, "netbsd") != 0)) { | | 247 | strcmp(osname, "netbsd") != 0)) { |
238 | if (errmaj) | | 248 | if (errmaj) |
239 | *errmaj = LDR_BADOS; | | 249 | *errmaj = LDR_BADOS; |
240 | if (errmin) | | 250 | if (errmin) |
241 | *errmin = 0; | | 251 | *errmin = 0; |
242 | return NULL; | | 252 | return NULL; |
243 | } | | 253 | } |
244 | if (!setupDone) { | | 254 | if (!setupDone) { |
245 | setupDone = TRUE; | | 255 | setupDone = TRUE; |
246 | xf86AddDriver(&WSFB, module, HaveDriverFuncs); | | 256 | xf86AddDriver(&WSFB, module, HaveDriverFuncs); |
247 | LoaderRefSymLists(fbSymbols, shadowSymbols, ramdacSymbols, | | 257 | LoaderRefSymLists(fbSymbols, shadowSymbols, ramdacSymbols, |
| @@ -279,61 +289,61 @@ WsfbFreeRec(ScrnInfoPtr pScrn) | | | @@ -279,61 +289,61 @@ WsfbFreeRec(ScrnInfoPtr pScrn) |
279 | static const OptionInfoRec * | | 289 | static const OptionInfoRec * |
280 | WsfbAvailableOptions(int chipid, int busid) | | 290 | WsfbAvailableOptions(int chipid, int busid) |
281 | { | | 291 | { |
282 | return WsfbOptions; | | 292 | return WsfbOptions; |
283 | } | | 293 | } |
284 | | | 294 | |
285 | static void | | 295 | static void |
286 | WsfbIdentify(int flags) | | 296 | WsfbIdentify(int flags) |
287 | { | | 297 | { |
288 | xf86PrintChipsets(WSFB_NAME, "driver for wsdisplay framebuffer", | | 298 | xf86PrintChipsets(WSFB_NAME, "driver for wsdisplay framebuffer", |
289 | WsfbChipsets); | | 299 | WsfbChipsets); |
290 | } | | 300 | } |
291 | | | 301 | |
292 | /* Open the framebuffer device */ | | 302 | /* Open the framebuffer device. */ |
293 | static int | | 303 | static int |
294 | wsfb_open(char *dev) | | 304 | wsfb_open(char *dev) |
295 | { | | 305 | { |
296 | int fd = -1; | | 306 | int fd = -1; |
297 | | | 307 | |
298 | /* try argument from XF86Config first */ | | 308 | /* Try argument from XF86Config first. */ |
299 | if (dev == NULL || ((fd = priv_open_device(dev)) == -1)) { | | 309 | if (dev == NULL || ((fd = priv_open_device(dev)) == -1)) { |
300 | /* second: environment variable */ | | 310 | /* Second: environment variable. */ |
301 | dev = getenv("XDEVICE"); | | 311 | dev = getenv("XDEVICE"); |
302 | if (dev == NULL || ((fd = priv_open_device(dev)) == -1)) { | | 312 | if (dev == NULL || ((fd = priv_open_device(dev)) == -1)) { |
303 | /* last try: default device */ | | 313 | /* Last try: default device. */ |
304 | dev = WSFB_DEFAULT_DEV; | | 314 | dev = WSFB_DEFAULT_DEV; |
305 | if ((fd = priv_open_device(dev)) == -1) { | | 315 | if ((fd = priv_open_device(dev)) == -1) { |
306 | return -1; | | 316 | return -1; |
307 | } | | 317 | } |
308 | } | | 318 | } |
309 | } | | 319 | } |
310 | return fd; | | 320 | return fd; |
311 | } | | 321 | } |
312 | | | 322 | |
313 | /* Map the framebuffer's memory */ | | 323 | /* Map the framebuffer's memory. */ |
314 | static pointer | | 324 | static pointer |
315 | wsfb_mmap(size_t len, off_t off, int fd) | | 325 | wsfb_mmap(size_t len, off_t off, int fd) |
316 | { | | 326 | { |
317 | int pagemask, mapsize; | | 327 | int pagemask, mapsize; |
318 | caddr_t addr; | | 328 | caddr_t addr; |
319 | pointer mapaddr; | | 329 | pointer mapaddr; |
320 | | | 330 | |
321 | pagemask = getpagesize() - 1; | | 331 | pagemask = getpagesize() - 1; |
322 | mapsize = ((int) len + pagemask) & ~pagemask; | | 332 | mapsize = ((int) len + pagemask) & ~pagemask; |
323 | addr = 0; | | 333 | addr = 0; |
324 | | | 334 | |
325 | /* | | 335 | /* |
326 | * try and make it private first, that way once we get it, an | | 336 | * Try and make it private first, that way once we get it, an |
327 | * interloper, e.g. another server, can't get this frame buffer, | | 337 | * interloper, e.g. another server, can't get this frame buffer, |
328 | * and if another server already has it, this one won't. | | 338 | * and if another server already has it, this one won't. |
329 | */ | | 339 | */ |
330 | mapaddr = (pointer) mmap(addr, mapsize, | | 340 | mapaddr = (pointer) mmap(addr, mapsize, |
331 | PROT_READ | PROT_WRITE, MAP_SHARED, | | 341 | PROT_READ | PROT_WRITE, MAP_SHARED, |
332 | fd, off); | | 342 | fd, off); |
333 | if (mapaddr == MAP_FAILED) { | | 343 | if (mapaddr == MAP_FAILED) { |
334 | mapaddr = NULL; | | 344 | mapaddr = NULL; |
335 | } | | 345 | } |
336 | #if DEBUG | | 346 | #if DEBUG |
337 | ErrorF("mmap returns: addr %p len 0x%x\n", mapaddr, mapsize); | | 347 | ErrorF("mmap returns: addr %p len 0x%x\n", mapaddr, mapsize); |
338 | #endif | | 348 | #endif |
339 | return mapaddr; | | 349 | return mapaddr; |
| @@ -406,55 +416,57 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags | | | @@ -406,55 +416,57 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags |
406 | if (flags & PROBE_DETECT) return FALSE; | | 416 | if (flags & PROBE_DETECT) return FALSE; |
407 | | | 417 | |
408 | TRACE_ENTER("PreInit"); | | 418 | TRACE_ENTER("PreInit"); |
409 | | | 419 | |
410 | if (pScrn->numEntities != 1) return FALSE; | | 420 | if (pScrn->numEntities != 1) return FALSE; |
411 | | | 421 | |
412 | pScrn->monitor = pScrn->confScreen->monitor; | | 422 | pScrn->monitor = pScrn->confScreen->monitor; |
413 | | | 423 | |
414 | WsfbGetRec(pScrn); | | 424 | WsfbGetRec(pScrn); |
415 | fPtr = WSFBPTR(pScrn); | | 425 | fPtr = WSFBPTR(pScrn); |
416 | | | 426 | |
417 | fPtr->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); | | 427 | fPtr->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); |
418 | | | 428 | |
| | | 429 | #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 6 |
419 | pScrn->racMemFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT; | | 430 | pScrn->racMemFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT; |
420 | pScrn->racIoFlags = pScrn->racMemFlags; | | 431 | pScrn->racIoFlags = pScrn->racMemFlags; |
| | | 432 | #endif |
421 | | | 433 | |
422 | dev = xf86FindOptionValue(fPtr->pEnt->device->options, "device"); | | 434 | dev = xf86FindOptionValue(fPtr->pEnt->device->options, "device"); |
423 | fPtr->fd = wsfb_open(dev); | | 435 | fPtr->fd = wsfb_open(dev); |
424 | if (fPtr->fd == -1) { | | 436 | if (fPtr->fd == -1) { |
425 | return FALSE; | | 437 | return FALSE; |
426 | } | | 438 | } |
427 | | | 439 | |
428 | if (ioctl(fPtr->fd, WSDISPLAYIO_GINFO, &fPtr->info) == -1) { | | 440 | if (ioctl(fPtr->fd, WSDISPLAYIO_GINFO, &fPtr->info) == -1) { |
429 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 441 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
430 | "ioctl WSDISPLAY_GINFO: %s\n", | | 442 | "ioctl WSDISPLAY_GINFO: %s\n", |
431 | strerror(errno)); | | 443 | strerror(errno)); |
432 | return FALSE; | | 444 | return FALSE; |
433 | } | | 445 | } |
434 | if (ioctl(fPtr->fd, WSDISPLAYIO_GTYPE, &wstype) == -1) { | | 446 | if (ioctl(fPtr->fd, WSDISPLAYIO_GTYPE, &wstype) == -1) { |
435 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 447 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
436 | "ioctl WSDISPLAY_GTYPE: %s\n", | | 448 | "ioctl WSDISPLAY_GTYPE: %s\n", |
437 | strerror(errno)); | | 449 | strerror(errno)); |
438 | return FALSE; | | 450 | return FALSE; |
439 | } | | 451 | } |
440 | if (ioctl(fPtr->fd, WSDISPLAYIO_LINEBYTES, &fPtr->linebytes) == -1) { | | 452 | if (ioctl(fPtr->fd, WSDISPLAYIO_LINEBYTES, &fPtr->linebytes) == -1) { |
441 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 453 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
442 | "ioctl WSDISPLAYIO_LINEBYTES: %s\n", | | 454 | "ioctl WSDISPLAYIO_LINEBYTES: %s\n", |
443 | strerror(errno)); | | 455 | strerror(errno)); |
444 | return FALSE; | | 456 | return FALSE; |
445 | } | | 457 | } |
446 | /* | | 458 | /* |
447 | * Allocate room for saving the colormap | | 459 | * Allocate room for saving the colormap. |
448 | */ | | 460 | */ |
449 | if (fPtr->info.cmsize != 0) { | | 461 | if (fPtr->info.cmsize != 0) { |
450 | fPtr->saved_cmap.red = | | 462 | fPtr->saved_cmap.red = |
451 | (unsigned char *)xalloc(fPtr->info.cmsize); | | 463 | (unsigned char *)xalloc(fPtr->info.cmsize); |
452 | if (fPtr->saved_cmap.red == NULL) { | | 464 | if (fPtr->saved_cmap.red == NULL) { |
453 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 465 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
454 | "Cannot malloc %d bytes\n", fPtr->info.cmsize); | | 466 | "Cannot malloc %d bytes\n", fPtr->info.cmsize); |
455 | return FALSE; | | 467 | return FALSE; |
456 | } | | 468 | } |
457 | fPtr->saved_cmap.green = | | 469 | fPtr->saved_cmap.green = |
458 | (unsigned char *)xalloc(fPtr->info.cmsize); | | 470 | (unsigned char *)xalloc(fPtr->info.cmsize); |
459 | if (fPtr->saved_cmap.green == NULL) { | | 471 | if (fPtr->saved_cmap.green == NULL) { |
460 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 472 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
| @@ -470,105 +482,105 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags | | | @@ -470,105 +482,105 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags |
470 | xfree(fPtr->saved_cmap.red); | | 482 | xfree(fPtr->saved_cmap.red); |
471 | xfree(fPtr->saved_cmap.green); | | 483 | xfree(fPtr->saved_cmap.green); |
472 | return FALSE; | | 484 | return FALSE; |
473 | } | | 485 | } |
474 | } | | 486 | } |
475 | | | 487 | |
476 | /* Handle depth */ | | 488 | /* Handle depth */ |
477 | default_depth = fPtr->info.depth <= 24 ? fPtr->info.depth : 24; | | 489 | default_depth = fPtr->info.depth <= 24 ? fPtr->info.depth : 24; |
478 | if (!xf86SetDepthBpp(pScrn, default_depth, default_depth, | | 490 | if (!xf86SetDepthBpp(pScrn, default_depth, default_depth, |
479 | fPtr->info.depth, | | 491 | fPtr->info.depth, |
480 | fPtr->info.depth >= 24 ? Support24bppFb|Support32bppFb : 0)) | | 492 | fPtr->info.depth >= 24 ? Support24bppFb|Support32bppFb : 0)) |
481 | return FALSE; | | 493 | return FALSE; |
482 | | | 494 | |
483 | /* Check consistency */ | | 495 | /* Check consistency. */ |
484 | if (pScrn->bitsPerPixel != fPtr->info.depth) { | | 496 | if (pScrn->bitsPerPixel != fPtr->info.depth) { |
485 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 497 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
486 | "specified depth (%d) or bpp (%d) doesn't match " | | 498 | "specified depth (%d) or bpp (%d) doesn't match " |
487 | "framebuffer depth (%d)\n", pScrn->depth, | | 499 | "framebuffer depth (%d)\n", pScrn->depth, |
488 | pScrn->bitsPerPixel, fPtr->info.depth); | | 500 | pScrn->bitsPerPixel, fPtr->info.depth); |
489 | return FALSE; | | 501 | return FALSE; |
490 | } | | 502 | } |
491 | xf86PrintDepthBpp(pScrn); | | 503 | xf86PrintDepthBpp(pScrn); |
492 | | | 504 | |
493 | /* Get the depth24 pixmap format */ | | 505 | /* Get the depth24 pixmap format. */ |
494 | if (pScrn->depth == 24 && pix24bpp == 0) | | 506 | if (pScrn->depth == 24 && pix24bpp == 0) |
495 | pix24bpp = xf86GetBppFromDepth(pScrn, 24); | | 507 | pix24bpp = xf86GetBppFromDepth(pScrn, 24); |
496 | | | 508 | |
497 | /* color weight */ | | 509 | /* Color weight */ |
498 | if (pScrn->depth > 8) { | | 510 | if (pScrn->depth > 8) { |
499 | rgb zeros = { 0, 0, 0 }, masks; | | 511 | rgb zeros = { 0, 0, 0 }, masks; |
500 | | | 512 | |
501 | if (wstype == WSDISPLAY_TYPE_SUN24 || | | 513 | if (wstype == WSDISPLAY_TYPE_SUN24 || |
502 | wstype == WSDISPLAY_TYPE_SUNCG12 || | | 514 | wstype == WSDISPLAY_TYPE_SUNCG12 || |
503 | wstype == WSDISPLAY_TYPE_SUNCG14 || | | 515 | wstype == WSDISPLAY_TYPE_SUNCG14 || |
504 | wstype == WSDISPLAY_TYPE_SUNTCX || | | 516 | wstype == WSDISPLAY_TYPE_SUNTCX || |
505 | wstype == WSDISPLAY_TYPE_SUNFFB) { | | 517 | wstype == WSDISPLAY_TYPE_SUNFFB) { |
506 | masks.red = 0x0000ff; | | 518 | masks.red = 0x0000ff; |
507 | masks.green = 0x00ff00; | | 519 | masks.green = 0x00ff00; |
508 | masks.blue = 0xff0000; | | 520 | masks.blue = 0xff0000; |
509 | } else { | | 521 | } else { |
510 | masks.red = 0; | | 522 | masks.red = 0; |
511 | masks.green = 0; | | 523 | masks.green = 0; |
512 | masks.blue = 0; | | 524 | masks.blue = 0; |
513 | } | | 525 | } |
514 | | | 526 | |
515 | if (!xf86SetWeight(pScrn, zeros, masks)) | | 527 | if (!xf86SetWeight(pScrn, zeros, masks)) |
516 | return FALSE; | | 528 | return FALSE; |
517 | } | | 529 | } |
518 | | | 530 | |
519 | /* visual init */ | | 531 | /* Visual init */ |
520 | if (!xf86SetDefaultVisual(pScrn, -1)) | | 532 | if (!xf86SetDefaultVisual(pScrn, -1)) |
521 | return FALSE; | | 533 | return FALSE; |
522 | | | 534 | |
523 | /* We don't currently support DirectColor at > 8bpp */ | | 535 | /* We don't currently support DirectColor at > 8bpp . */ |
524 | if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { | | 536 | if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { |
525 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" | | 537 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" |
526 | " (%s) is not supported at depth %d\n", | | 538 | " (%s) is not supported at depth %d\n", |
527 | xf86GetVisualName(pScrn->defaultVisual), | | 539 | xf86GetVisualName(pScrn->defaultVisual), |
528 | pScrn->depth); | | 540 | pScrn->depth); |
529 | return FALSE; | | 541 | return FALSE; |
530 | } | | 542 | } |
531 | | | 543 | |
532 | xf86SetGamma(pScrn,zeros); | | 544 | xf86SetGamma(pScrn,zeros); |
533 | | | 545 | |
534 | pScrn->progClock = TRUE; | | 546 | pScrn->progClock = TRUE; |
535 | pScrn->rgbBits = 8; | | 547 | pScrn->rgbBits = 8; |
536 | pScrn->chipset = "wsfb"; | | 548 | pScrn->chipset = "wsfb"; |
537 | pScrn->videoRam = fPtr->linebytes * fPtr->info.height; | | 549 | pScrn->videoRam = fPtr->linebytes * fPtr->info.height; |
538 | | | 550 | |
539 | xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Vidmem: %dk\n", | | 551 | xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Vidmem: %dk\n", |
540 | pScrn->videoRam/1024); | | 552 | pScrn->videoRam/1024); |
541 | | | 553 | |
542 | /* handle options */ | | 554 | /* Handle options. */ |
543 | xf86CollectOptions(pScrn, NULL); | | 555 | xf86CollectOptions(pScrn, NULL); |
544 | if (!(fPtr->Options = xalloc(sizeof(WsfbOptions)))) | | 556 | if (!(fPtr->Options = xalloc(sizeof(WsfbOptions)))) |
545 | return FALSE; | | 557 | return FALSE; |
546 | memcpy(fPtr->Options, WsfbOptions, sizeof(WsfbOptions)); | | 558 | memcpy(fPtr->Options, WsfbOptions, sizeof(WsfbOptions)); |
547 | xf86ProcessOptions(pScrn->scrnIndex, fPtr->pEnt->device->options, | | 559 | xf86ProcessOptions(pScrn->scrnIndex, fPtr->pEnt->device->options, |
548 | fPtr->Options); | | 560 | fPtr->Options); |
549 | | | 561 | |
550 | /* use shadow framebuffer by default, on depth >= 8 */ | | 562 | /* Use shadow framebuffer by default, on depth >= 8 */ |
551 | if (pScrn->depth >= 8) | | 563 | if (pScrn->depth >= 8) |
552 | fPtr->shadowFB = xf86ReturnOptValBool(fPtr->Options, | | 564 | fPtr->shadowFB = xf86ReturnOptValBool(fPtr->Options, |
553 | OPTION_SHADOW_FB, TRUE); | | 565 | OPTION_SHADOW_FB, TRUE); |
554 | else | | 566 | else |
555 | if (xf86ReturnOptValBool(fPtr->Options, | | 567 | if (xf86ReturnOptValBool(fPtr->Options, |
556 | OPTION_SHADOW_FB, FALSE)) { | | 568 | OPTION_SHADOW_FB, FALSE)) { |
557 | xf86DrvMsg(pScrn->scrnIndex, X_WARNING, | | 569 | xf86DrvMsg(pScrn->scrnIndex, X_WARNING, |
558 | "Shadow FB option ignored on depth < 8"); | | 570 | "Shadow FB option ignored on depth < 8"); |
559 | } | | 571 | } |
560 | | | 572 | |
561 | /* rotation */ | | 573 | /* Rotation */ |
562 | fPtr->rotate = WSFB_ROTATE_NONE; | | 574 | fPtr->rotate = WSFB_ROTATE_NONE; |
563 | if ((s = xf86GetOptValString(fPtr->Options, OPTION_ROTATE))) { | | 575 | if ((s = xf86GetOptValString(fPtr->Options, OPTION_ROTATE))) { |
564 | if (pScrn->depth >= 8) { | | 576 | if (pScrn->depth >= 8) { |
565 | if (!xf86NameCmp(s, "CW")) { | | 577 | if (!xf86NameCmp(s, "CW")) { |
566 | fPtr->shadowFB = TRUE; | | 578 | fPtr->shadowFB = TRUE; |
567 | fPtr->rotate = WSFB_ROTATE_CW; | | 579 | fPtr->rotate = WSFB_ROTATE_CW; |
568 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, | | 580 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, |
569 | "Rotating screen clockwise\n"); | | 581 | "Rotating screen clockwise\n"); |
570 | } else if (!xf86NameCmp(s, "CCW")) { | | 582 | } else if (!xf86NameCmp(s, "CCW")) { |
571 | fPtr->shadowFB = TRUE; | | 583 | fPtr->shadowFB = TRUE; |
572 | fPtr->rotate = WSFB_ROTATE_CCW; | | 584 | fPtr->rotate = WSFB_ROTATE_CCW; |
573 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, | | 585 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, |
574 | "Rotating screen counter clockwise\n"); | | 586 | "Rotating screen counter clockwise\n"); |
| @@ -581,27 +593,27 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags | | | @@ -581,27 +593,27 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags |
581 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, | | 593 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, |
582 | "\"%s\" is not a valid value for Option " | | 594 | "\"%s\" is not a valid value for Option " |
583 | "\"Rotate\"\n", s); | | 595 | "\"Rotate\"\n", s); |
584 | xf86DrvMsg(pScrn->scrnIndex, X_INFO, | | 596 | xf86DrvMsg(pScrn->scrnIndex, X_INFO, |
585 | "Valid options are \"CW\", \"CCW\"," | | 597 | "Valid options are \"CW\", \"CCW\"," |
586 | " or \"UD\"\n"); | | 598 | " or \"UD\"\n"); |
587 | } | | 599 | } |
588 | } else { | | 600 | } else { |
589 | xf86DrvMsg(pScrn->scrnIndex, X_WARNING, | | 601 | xf86DrvMsg(pScrn->scrnIndex, X_WARNING, |
590 | "Option \"Rotate\" ignored on depth < 8"); | | 602 | "Option \"Rotate\" ignored on depth < 8"); |
591 | } | | 603 | } |
592 | } | | 604 | } |
593 | | | 605 | |
594 | /* fake video mode struct */ | | 606 | /* Fake video mode struct. */ |
595 | mode = (DisplayModePtr)xalloc(sizeof(DisplayModeRec)); | | 607 | mode = (DisplayModePtr)xalloc(sizeof(DisplayModeRec)); |
596 | mode->prev = mode; | | 608 | mode->prev = mode; |
597 | mode->next = mode; | | 609 | mode->next = mode; |
598 | mode->name = "wsfb current mode"; | | 610 | mode->name = "wsfb current mode"; |
599 | mode->status = MODE_OK; | | 611 | mode->status = MODE_OK; |
600 | mode->type = M_T_BUILTIN; | | 612 | mode->type = M_T_BUILTIN; |
601 | mode->Clock = 0; | | 613 | mode->Clock = 0; |
602 | mode->HDisplay = fPtr->info.width; | | 614 | mode->HDisplay = fPtr->info.width; |
603 | mode->HSyncStart = 0; | | 615 | mode->HSyncStart = 0; |
604 | mode->HSyncEnd = 0; | | 616 | mode->HSyncEnd = 0; |
605 | mode->HTotal = 0; | | 617 | mode->HTotal = 0; |
606 | mode->HSkew = 0; | | 618 | mode->HSkew = 0; |
607 | mode->VDisplay = fPtr->info.height; | | 619 | mode->VDisplay = fPtr->info.height; |
| @@ -609,57 +621,68 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags | | | @@ -609,57 +621,68 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags |
609 | mode->VSyncEnd = 0; | | 621 | mode->VSyncEnd = 0; |
610 | mode->VTotal = 0; | | 622 | mode->VTotal = 0; |
611 | mode->VScan = 0; | | 623 | mode->VScan = 0; |
612 | mode->Flags = 0; | | 624 | mode->Flags = 0; |
613 | if (pScrn->modes != NULL) { | | 625 | if (pScrn->modes != NULL) { |
614 | xf86DrvMsg(pScrn->scrnIndex, X_INFO, | | 626 | xf86DrvMsg(pScrn->scrnIndex, X_INFO, |
615 | "Ignoring mode specification from screen section\n"); | | 627 | "Ignoring mode specification from screen section\n"); |
616 | } | | 628 | } |
617 | pScrn->currentMode = pScrn->modes = mode; | | 629 | pScrn->currentMode = pScrn->modes = mode; |
618 | pScrn->virtualX = fPtr->info.width; | | 630 | pScrn->virtualX = fPtr->info.width; |
619 | pScrn->virtualY = fPtr->info.height; | | 631 | pScrn->virtualY = fPtr->info.height; |
620 | pScrn->displayWidth = pScrn->virtualX; | | 632 | pScrn->displayWidth = pScrn->virtualX; |
621 | | | 633 | |
622 | /* Set the display resolution */ | | 634 | /* Set the display resolution. */ |
623 | xf86SetDpi(pScrn, 0, 0); | | 635 | xf86SetDpi(pScrn, 0, 0); |
624 | | | 636 | |
625 | from = X_DEFAULT; | | 637 | from = X_DEFAULT; |
626 | fPtr->HWCursor = TRUE; | | 638 | fPtr->HWCursor = TRUE; |
627 | if (xf86GetOptValBool(fPtr->Options, OPTION_HW_CURSOR, &fPtr->HWCursor)) | | 639 | if (xf86GetOptValBool(fPtr->Options, OPTION_HW_CURSOR, &fPtr->HWCursor)) |
628 | from = X_CONFIG; | | 640 | from = X_CONFIG; |
629 | if (xf86ReturnOptValBool(fPtr->Options, OPTION_SW_CURSOR, FALSE)) { | | 641 | if (xf86ReturnOptValBool(fPtr->Options, OPTION_SW_CURSOR, FALSE)) { |
630 | from = X_CONFIG; | | 642 | from = X_CONFIG; |
631 | fPtr->HWCursor = FALSE; | | 643 | fPtr->HWCursor = FALSE; |
632 | } | | 644 | } |
633 | xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n", | | 645 | xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n", |
634 | fPtr->HWCursor ? "HW" : "SW"); | | 646 | fPtr->HWCursor ? "HW" : "SW"); |
635 | | | 647 | |
636 | /* Load bpp-specific modules */ | | 648 | /* Load bpp-specific modules. */ |
637 | switch(pScrn->bitsPerPixel) { | | 649 | switch(pScrn->bitsPerPixel) { |
| | | 650 | #ifdef HAVE_XF1BPP |
| | | 651 | case 1: |
| | | 652 | mod = "xf1bpp"; |
| | | 653 | reqSym = "xf1bppScreenInit"; |
| | | 654 | break; |
| | | 655 | #endif |
| | | 656 | #ifdef HAVE_XF4BPP |
| | | 657 | case 4: |
| | | 658 | mod = "xf4bpp"; |
| | | 659 | reqSym = "xf4bppScreenInit"; |
| | | 660 | break; |
| | | 661 | #endif |
638 | default: | | 662 | default: |
639 | mod = "fb"; | | 663 | mod = "fb"; |
640 | break; | | 664 | break; |
641 | } | | 665 | } |
642 | | | 666 | |
643 | | | 667 | |
644 | /* Load shadow if needed */ | | 668 | /* Load shadow if needed. */ |
645 | if (fPtr->shadowFB) { | | 669 | if (fPtr->shadowFB) { |
646 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, | | 670 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, |
647 | "Using \"Shadow Framebuffer\"\n"); | | 671 | "Using \"Shadow Framebuffer\"\n"); |
648 | if (xf86LoadSubModule(pScrn, "shadow") == NULL) { | | 672 | if (xf86LoadSubModule(pScrn, "shadow") == NULL) { |
649 | WsfbFreeRec(pScrn); | | 673 | WsfbFreeRec(pScrn); |
650 | return FALSE; | | 674 | return FALSE; |
651 | } | | 675 | } |
652 | xf86LoaderReqSymLists(shadowSymbols, NULL); | | | |
653 | } | | 676 | } |
654 | | | 677 | |
655 | if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { | | 678 | if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { |
656 | WsfbFreeRec(pScrn); | | 679 | WsfbFreeRec(pScrn); |
657 | return FALSE; | | 680 | return FALSE; |
658 | } | | 681 | } |
659 | | | 682 | |
660 | if (xf86LoadSubModule(pScrn, "ramdac") == NULL) { | | 683 | if (xf86LoadSubModule(pScrn, "ramdac") == NULL) { |
661 | WsfbFreeRec(pScrn); | | 684 | WsfbFreeRec(pScrn); |
662 | return FALSE; | | 685 | return FALSE; |
663 | } | | 686 | } |
664 | | | 687 | |
665 | if (mod) { | | 688 | if (mod) { |
| @@ -755,46 +778,46 @@ WsfbScreenInit(int scrnIndex, ScreenPtr | | | @@ -755,46 +778,46 @@ WsfbScreenInit(int scrnIndex, ScreenPtr |
755 | break; | | 778 | break; |
756 | case 32: | | 779 | case 32: |
757 | if (fPtr->linebytes == fPtr->info.width) { | | 780 | if (fPtr->linebytes == fPtr->info.width) { |
758 | len = fPtr->info.width*fPtr->info.height*sizeof(int); | | 781 | len = fPtr->info.width*fPtr->info.height*sizeof(int); |
759 | } else { | | 782 | } else { |
760 | len = fPtr->linebytes*fPtr->info.height; | | 783 | len = fPtr->linebytes*fPtr->info.height; |
761 | } | | 784 | } |
762 | break; | | 785 | break; |
763 | default: | | 786 | default: |
764 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 787 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
765 | "unsupported depth %d\n", fPtr->info.depth); | | 788 | "unsupported depth %d\n", fPtr->info.depth); |
766 | return FALSE; | | 789 | return FALSE; |
767 | } | | 790 | } |
768 | /* Switch to graphics mode - required before mmap */ | | 791 | /* Switch to graphics mode - required before mmap. */ |
769 | if (ioctl(fPtr->fd, WSDISPLAYIO_SMODE, &wsmode) == -1) { | | 792 | if (ioctl(fPtr->fd, WSDISPLAYIO_SMODE, &wsmode) == -1) { |
770 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 793 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
771 | "ioctl WSDISPLAYIO_SMODE: %s\n", | | 794 | "ioctl WSDISPLAYIO_SMODE: %s\n", |
772 | strerror(errno)); | | 795 | strerror(errno)); |
773 | return FALSE; | | 796 | return FALSE; |
774 | } | | 797 | } |
775 | fPtr->fbmem = wsfb_mmap(len, 0, fPtr->fd); | | 798 | fPtr->fbmem = wsfb_mmap(len, 0, fPtr->fd); |
776 | | | 799 | |
777 | if (fPtr->fbmem == NULL) { | | 800 | if (fPtr->fbmem == NULL) { |
778 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 801 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
779 | "wsfb_mmap: %s\n", strerror(errno)); | | 802 | "wsfb_mmap: %s\n", strerror(errno)); |
780 | return FALSE; | | 803 | return FALSE; |
781 | } | | 804 | } |
782 | fPtr->fbmem_len = len; | | 805 | fPtr->fbmem_len = len; |
783 | | | 806 | |
784 | WsfbSave(pScrn); | | 807 | WsfbSave(pScrn); |
785 | pScrn->vtSema = TRUE; | | 808 | pScrn->vtSema = TRUE; |
786 | | | 809 | |
787 | /* mi layer */ | | 810 | /* MI layer */ |
788 | miClearVisualTypes(); | | 811 | miClearVisualTypes(); |
789 | if (pScrn->bitsPerPixel > 8) { | | 812 | if (pScrn->bitsPerPixel > 8) { |
790 | if (!miSetVisualTypes(pScrn->depth, TrueColorMask, | | 813 | if (!miSetVisualTypes(pScrn->depth, TrueColorMask, |
791 | pScrn->rgbBits, TrueColor)) | | 814 | pScrn->rgbBits, TrueColor)) |
792 | return FALSE; | | 815 | return FALSE; |
793 | } else { | | 816 | } else { |
794 | if (!miSetVisualTypes(pScrn->depth, | | 817 | if (!miSetVisualTypes(pScrn->depth, |
795 | miGetDefaultVisualMask(pScrn->depth), | | 818 | miGetDefaultVisualMask(pScrn->depth), |
796 | pScrn->rgbBits, pScrn->defaultVisual)) | | 819 | pScrn->rgbBits, pScrn->defaultVisual)) |
797 | return FALSE; | | 820 | return FALSE; |
798 | } | | 821 | } |
799 | if (!miSetPixmapDepths()) | | 822 | if (!miSetPixmapDepths()) |
800 | return FALSE; | | 823 | return FALSE; |
| @@ -802,48 +825,75 @@ WsfbScreenInit(int scrnIndex, ScreenPtr | | | @@ -802,48 +825,75 @@ WsfbScreenInit(int scrnIndex, ScreenPtr |
802 | if (fPtr->rotate == WSFB_ROTATE_CW | | 825 | if (fPtr->rotate == WSFB_ROTATE_CW |
803 | || fPtr->rotate == WSFB_ROTATE_CCW) { | | 826 | || fPtr->rotate == WSFB_ROTATE_CCW) { |
804 | int tmp = pScrn->virtualX; | | 827 | int tmp = pScrn->virtualX; |
805 | pScrn->virtualX = pScrn->displayWidth = pScrn->virtualY; | | 828 | pScrn->virtualX = pScrn->displayWidth = pScrn->virtualY; |
806 | pScrn->virtualY = tmp; | | 829 | pScrn->virtualY = tmp; |
807 | } | | 830 | } |
808 | if (fPtr->rotate && !fPtr->PointerMoved) { | | 831 | if (fPtr->rotate && !fPtr->PointerMoved) { |
809 | fPtr->PointerMoved = pScrn->PointerMoved; | | 832 | fPtr->PointerMoved = pScrn->PointerMoved; |
810 | pScrn->PointerMoved = WsfbPointerMoved; | | 833 | pScrn->PointerMoved = WsfbPointerMoved; |
811 | } | | 834 | } |
812 | | | 835 | |
813 | fPtr->fbstart = fPtr->fbmem; | | 836 | fPtr->fbstart = fPtr->fbmem; |
814 | | | 837 | |
| | | 838 | if (fPtr->shadowFB) { |
| | | 839 | fPtr->shadow = xcalloc(1, pScrn->virtualX * pScrn->virtualY * |
| | | 840 | pScrn->bitsPerPixel); |
| | | 841 | |
| | | 842 | if (!fPtr->shadow) { |
| | | 843 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
| | | 844 | "Failed to allocate shadow framebuffer\n"); |
| | | 845 | return FALSE; |
| | | 846 | } |
| | | 847 | } |
| | | 848 | |
815 | switch (pScrn->bitsPerPixel) { | | 849 | switch (pScrn->bitsPerPixel) { |
| | | 850 | case 1: |
| | | 851 | #ifdef HAVE_XF1BPP |
| | | 852 | ret = xf1bppScreenInit(pScreen, fPtr->fbstart, |
| | | 853 | pScrn->virtualX, pScrn->virtualY, |
| | | 854 | pScrn->xDpi, pScrn->yDpi, |
| | | 855 | pScrn->displayWidth); |
| | | 856 | break; |
| | | 857 | #endif |
| | | 858 | case 4: |
| | | 859 | #ifdef HAVE_XF4BPP |
| | | 860 | ret = xf4bppScreenInit(pScreen, fPtr->fbstart, |
| | | 861 | pScrn->virtualX, pScrn->virtualY, |
| | | 862 | pScrn->xDpi, pScrn->yDpi, |
| | | 863 | pScrn->displayWidth); |
| | | 864 | break; |
| | | 865 | #endif |
816 | case 8: | | 866 | case 8: |
817 | case 16: | | 867 | case 16: |
818 | case 24: | | 868 | case 24: |
819 | case 32: | | 869 | case 32: |
820 | ret = fbScreenInit(pScreen, | | 870 | ret = fbScreenInit(pScreen, |
821 | /*fPtr->shadowFB ? fPtr->shadow :*/ fPtr->fbstart, | | 871 | /*fPtr->shadowFB ? fPtr->shadow :*/ fPtr->fbstart, |
822 | pScrn->virtualX, pScrn->virtualY, | | 872 | pScrn->virtualX, pScrn->virtualY, |
823 | pScrn->xDpi, pScrn->yDpi, | | 873 | pScrn->xDpi, pScrn->yDpi, |
824 | pScrn->displayWidth, pScrn->bitsPerPixel); | | 874 | pScrn->displayWidth, pScrn->bitsPerPixel); |
825 | break; | | 875 | break; |
826 | default: | | 876 | default: |
827 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 877 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
828 | "Unsupported bpp: %d", pScrn->bitsPerPixel); | | 878 | "Unsupported bpp: %d", pScrn->bitsPerPixel); |
829 | return FALSE; | | 879 | return FALSE; |
830 | } /* case */ | | 880 | } /* case */ |
831 | | | 881 | |
832 | if (!ret) | | 882 | if (!ret) |
833 | return FALSE; | | 883 | return FALSE; |
834 | | | 884 | |
835 | if (pScrn->bitsPerPixel > 8) { | | 885 | if (pScrn->bitsPerPixel > 8) { |
836 | /* Fixup RGB ordering */ | | 886 | /* Fixup RGB ordering. */ |
837 | visual = pScreen->visuals + pScreen->numVisuals; | | 887 | visual = pScreen->visuals + pScreen->numVisuals; |
838 | while (--visual >= pScreen->visuals) { | | 888 | while (--visual >= pScreen->visuals) { |
839 | if ((visual->class | DynamicClass) == DirectColor) { | | 889 | if ((visual->class | DynamicClass) == DirectColor) { |
840 | visual->offsetRed = pScrn->offset.red; | | 890 | visual->offsetRed = pScrn->offset.red; |
841 | visual->offsetGreen = pScrn->offset.green; | | 891 | visual->offsetGreen = pScrn->offset.green; |
842 | visual->offsetBlue = pScrn->offset.blue; | | 892 | visual->offsetBlue = pScrn->offset.blue; |
843 | visual->redMask = pScrn->mask.red; | | 893 | visual->redMask = pScrn->mask.red; |
844 | visual->greenMask = pScrn->mask.green; | | 894 | visual->greenMask = pScrn->mask.green; |
845 | visual->blueMask = pScrn->mask.blue; | | 895 | visual->blueMask = pScrn->mask.blue; |
846 | } | | 896 | } |
847 | } | | 897 | } |
848 | } | | 898 | } |
849 | | | 899 | |
| @@ -868,94 +918,107 @@ WsfbScreenInit(int scrnIndex, ScreenPtr | | | @@ -868,94 +918,107 @@ WsfbScreenInit(int scrnIndex, ScreenPtr |
868 | if (fPtr->rotate) { | | 918 | if (fPtr->rotate) { |
869 | xf86DrvMsg(scrnIndex, X_INFO, "Enabling Driver Rotation, " | | 919 | xf86DrvMsg(scrnIndex, X_INFO, "Enabling Driver Rotation, " |
870 | "disabling RandR\n"); | | 920 | "disabling RandR\n"); |
871 | xf86DisableRandR(); | | 921 | xf86DisableRandR(); |
872 | if (pScrn->bitsPerPixel == 24) | | 922 | if (pScrn->bitsPerPixel == 24) |
873 | xf86DrvMsg(scrnIndex, X_WARNING, | | 923 | xf86DrvMsg(scrnIndex, X_WARNING, |
874 | "Rotation might be broken in 24 bpp\n"); | | 924 | "Rotation might be broken in 24 bpp\n"); |
875 | } | | 925 | } |
876 | | | 926 | |
877 | xf86SetBlackWhitePixels(pScreen); | | 927 | xf86SetBlackWhitePixels(pScreen); |
878 | miInitializeBackingStore(pScreen); | | 928 | miInitializeBackingStore(pScreen); |
879 | xf86SetBackingStore(pScreen); | | 929 | xf86SetBackingStore(pScreen); |
880 | | | 930 | |
881 | /* software cursor */ | | 931 | /* Software cursor. */ |
882 | miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); | | 932 | miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); |
883 | | | 933 | |
884 | /* check for hardware cursor support */ | | 934 | /* check for hardware cursor support */ |
885 | if (fPtr->HWCursor) | | 935 | if (fPtr->HWCursor) |
886 | WsfbSetupCursor(pScreen); | | 936 | WsfbSetupCursor(pScreen); |
887 | | | 937 | |
888 | /* colormap */ | | 938 | /* |
| | | 939 | * Colormap |
| | | 940 | * |
| | | 941 | * Note that, even on less than 8 bit depth frame buffers, we |
| | | 942 | * expect the colormap to be programmable with 8 bit values. |
| | | 943 | * As of now, this is indeed the case on all OpenBSD supported |
| | | 944 | * graphics hardware. |
| | | 945 | */ |
889 | if (!miCreateDefColormap(pScreen)) | | 946 | if (!miCreateDefColormap(pScreen)) |
890 | return FALSE; | | 947 | return FALSE; |
891 | flags = CMAP_RELOAD_ON_MODE_SWITCH; | | 948 | flags = CMAP_RELOAD_ON_MODE_SWITCH; |
892 | ncolors = fPtr->info.cmsize; | | 949 | ncolors = fPtr->info.cmsize; |
893 | /* on StaticGray visuals, fake a 256 entries colormap */ | | 950 | /* On StaticGray visuals, fake a 256 entries colormap. */ |
894 | if (ncolors == 0) | | 951 | if (ncolors == 0) |
895 | ncolors = 256; | | 952 | ncolors = 256; |
896 | if(!xf86HandleColormaps(pScreen, ncolors, 8, WsfbLoadPalette, | | 953 | if(!xf86HandleColormaps(pScreen, ncolors, 8, WsfbLoadPalette, |
897 | NULL, flags)) | | 954 | NULL, flags)) |
898 | return FALSE; | | 955 | return FALSE; |
899 | | | 956 | |
900 | pScreen->SaveScreen = WsfbSaveScreen; | | 957 | pScreen->SaveScreen = WsfbSaveScreen; |
901 | | | 958 | |
902 | #ifdef XvExtension | | 959 | #ifdef XvExtension |
903 | { | | 960 | { |
904 | XF86VideoAdaptorPtr *ptr; | | 961 | XF86VideoAdaptorPtr *ptr; |
905 | | | 962 | |
906 | int n = xf86XVListGenericAdaptors(pScrn,&ptr); | | 963 | int n = xf86XVListGenericAdaptors(pScrn,&ptr); |
907 | if (n) { | | 964 | if (n) { |
908 | xf86XVScreenInit(pScreen,ptr,n); | | 965 | xf86XVScreenInit(pScreen,ptr,n); |
909 | } | | 966 | } |
910 | } | | 967 | } |
911 | #endif | | 968 | #endif |
912 | | | 969 | |
913 | /* Wrap the current CloseScreen function */ | | 970 | /* Wrap the current CloseScreen function. */ |
914 | fPtr->CloseScreen = pScreen->CloseScreen; | | 971 | fPtr->CloseScreen = pScreen->CloseScreen; |
915 | pScreen->CloseScreen = WsfbCloseScreen; | | 972 | pScreen->CloseScreen = WsfbCloseScreen; |
916 | | | 973 | |
917 | TRACE_EXIT("WsfbScreenInit"); | | 974 | TRACE_EXIT("WsfbScreenInit"); |
918 | return TRUE; | | 975 | return TRUE; |
919 | } | | 976 | } |
920 | | | 977 | |
921 | static Bool | | 978 | static Bool |
922 | WsfbCloseScreen(int scrnIndex, ScreenPtr pScreen) | | 979 | WsfbCloseScreen(int scrnIndex, ScreenPtr pScreen) |
923 | { | | 980 | { |
924 | ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; | | 981 | ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; |
| | | 982 | PixmapPtr pPixmap; |
925 | WsfbPtr fPtr = WSFBPTR(pScrn); | | 983 | WsfbPtr fPtr = WSFBPTR(pScrn); |
926 | | | 984 | |
| | | 985 | |
927 | TRACE_ENTER("WsfbCloseScreen"); | | 986 | TRACE_ENTER("WsfbCloseScreen"); |
928 | | | 987 | |
| | | 988 | pPixmap = pScreen->GetScreenPixmap(pScreen); |
| | | 989 | shadowRemove(pScreen, pPixmap); |
| | | 990 | |
929 | if (pScrn->vtSema) { | | 991 | if (pScrn->vtSema) { |
930 | WsfbRestore(pScrn); | | 992 | WsfbRestore(pScrn); |
931 | if (munmap(fPtr->fbmem, fPtr->fbmem_len) == -1) { | | 993 | if (munmap(fPtr->fbmem, fPtr->fbmem_len) == -1) { |
932 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 994 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
933 | "munmap: %s\n", strerror(errno)); | | 995 | "munmap: %s\n", strerror(errno)); |
934 | } | | 996 | } |
935 | | | 997 | |
936 | fPtr->fbmem = NULL; | | 998 | fPtr->fbmem = NULL; |
937 | } | | 999 | } |
938 | #ifdef XFreeXDGA | | 1000 | #ifdef XFreeXDGA |
939 | if (fPtr->pDGAMode) { | | 1001 | if (fPtr->pDGAMode) { |
940 | xfree(fPtr->pDGAMode); | | 1002 | xfree(fPtr->pDGAMode); |
941 | fPtr->pDGAMode = NULL; | | 1003 | fPtr->pDGAMode = NULL; |
942 | fPtr->nDGAMode = 0; | | 1004 | fPtr->nDGAMode = 0; |
943 | } | | 1005 | } |
944 | #endif | | 1006 | #endif |
945 | pScrn->vtSema = FALSE; | | 1007 | pScrn->vtSema = FALSE; |
946 | | | 1008 | |
947 | /* unwrap CloseScreen */ | | 1009 | /* Unwrap CloseScreen. */ |
948 | pScreen->CloseScreen = fPtr->CloseScreen; | | 1010 | pScreen->CloseScreen = fPtr->CloseScreen; |
| | | 1011 | TRACE_EXIT("WsfbCloseScreen"); |
949 | return (*pScreen->CloseScreen)(scrnIndex, pScreen); | | 1012 | return (*pScreen->CloseScreen)(scrnIndex, pScreen); |
950 | } | | 1013 | } |
951 | | | 1014 | |
952 | static void * | | 1015 | static void * |
953 | WsfbWindowLinear(ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode, | | 1016 | WsfbWindowLinear(ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode, |
954 | CARD32 *size, void *closure) | | 1017 | CARD32 *size, void *closure) |
955 | { | | 1018 | { |
956 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; | | 1019 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; |
957 | WsfbPtr fPtr = WSFBPTR(pScrn); | | 1020 | WsfbPtr fPtr = WSFBPTR(pScrn); |
958 | | | 1021 | |
959 | if (fPtr->linebytes) | | 1022 | if (fPtr->linebytes) |
960 | *size = fPtr->linebytes; | | 1023 | *size = fPtr->linebytes; |
961 | else { | | 1024 | else { |
| @@ -1001,48 +1064,49 @@ WsfbPointerMoved(int index, int x, int y | | | @@ -1001,48 +1064,49 @@ WsfbPointerMoved(int index, int x, int y |
1001 | } | | 1064 | } |
1002 | | | 1065 | |
1003 | /* Pass adjusted pointer coordinates to wrapped PointerMoved function. */ | | 1066 | /* Pass adjusted pointer coordinates to wrapped PointerMoved function. */ |
1004 | (*fPtr->PointerMoved)(index, newX, newY); | | 1067 | (*fPtr->PointerMoved)(index, newX, newY); |
1005 | } | | 1068 | } |
1006 | | | 1069 | |
1007 | static Bool | | 1070 | static Bool |
1008 | WsfbEnterVT(int scrnIndex, int flags) | | 1071 | WsfbEnterVT(int scrnIndex, int flags) |
1009 | { | | 1072 | { |
1010 | ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; | | 1073 | ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; |
1011 | | | 1074 | |
1012 | TRACE_ENTER("EnterVT"); | | 1075 | TRACE_ENTER("EnterVT"); |
1013 | pScrn->vtSema = TRUE; | | 1076 | pScrn->vtSema = TRUE; |
| | | 1077 | TRACE_EXIT("EnterVT"); |
1014 | return TRUE; | | 1078 | return TRUE; |
1015 | } | | 1079 | } |
1016 | | | 1080 | |
1017 | static void | | 1081 | static void |
1018 | WsfbLeaveVT(int scrnIndex, int flags) | | 1082 | WsfbLeaveVT(int scrnIndex, int flags) |
1019 | { | | 1083 | { |
1020 | #if DEBUG | | 1084 | #if DEBUG |
1021 | ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; | | 1085 | ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; |
1022 | #endif | | 1086 | #endif |
1023 | | | 1087 | |
1024 | TRACE_ENTER("LeaveVT"); | | 1088 | TRACE_ENTER("LeaveVT"); |
1025 | } | | 1089 | } |
1026 | | | 1090 | |
1027 | static Bool | | 1091 | static Bool |
1028 | WsfbSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) | | 1092 | WsfbSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) |
1029 | { | | 1093 | { |
1030 | #if DEBUG | | 1094 | #if DEBUG |
1031 | ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; | | 1095 | ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; |
1032 | #endif | | 1096 | #endif |
1033 | | | 1097 | |
1034 | TRACE_ENTER("SwitchMode"); | | 1098 | TRACE_ENTER("SwitchMode"); |
1035 | /* Nothing else to do */ | | 1099 | /* Nothing else to do. */ |
1036 | return TRUE; | | 1100 | return TRUE; |
1037 | } | | 1101 | } |
1038 | | | 1102 | |
1039 | static int | | 1103 | static int |
1040 | WsfbValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) | | 1104 | WsfbValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) |
1041 | { | | 1105 | { |
1042 | #if DEBUG | | 1106 | #if DEBUG |
1043 | ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; | | 1107 | ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; |
1044 | #endif | | 1108 | #endif |
1045 | | | 1109 | |
1046 | TRACE_ENTER("ValidMode"); | | 1110 | TRACE_ENTER("ValidMode"); |
1047 | return MODE_OK; | | 1111 | return MODE_OK; |
1048 | } | | 1112 | } |
| @@ -1062,119 +1126,123 @@ WsfbLoadPalette(ScrnInfoPtr pScrn, int n | | | @@ -1062,119 +1126,123 @@ WsfbLoadPalette(ScrnInfoPtr pScrn, int n |
1062 | cmap.red = red; | | 1126 | cmap.red = red; |
1063 | cmap.green = green; | | 1127 | cmap.green = green; |
1064 | cmap.blue = blue; | | 1128 | cmap.blue = blue; |
1065 | | | 1129 | |
1066 | if (numColors == 1) { | | 1130 | if (numColors == 1) { |
1067 | /* Optimisation */ | | 1131 | /* Optimisation */ |
1068 | cmap.index = indices[0]; | | 1132 | cmap.index = indices[0]; |
1069 | red[0] = colors[indices[0]].red; | | 1133 | red[0] = colors[indices[0]].red; |
1070 | green[0] = colors[indices[0]].green; | | 1134 | green[0] = colors[indices[0]].green; |
1071 | blue[0] = colors[indices[0]].blue; | | 1135 | blue[0] = colors[indices[0]].blue; |
1072 | if (ioctl(fPtr->fd,WSDISPLAYIO_PUTCMAP, &cmap) == -1) | | 1136 | if (ioctl(fPtr->fd,WSDISPLAYIO_PUTCMAP, &cmap) == -1) |
1073 | ErrorF("ioctl FBIOPUTCMAP: %s\n", strerror(errno)); | | 1137 | ErrorF("ioctl FBIOPUTCMAP: %s\n", strerror(errno)); |
1074 | } else { | | 1138 | } else { |
1075 | /* Change all colors in 2 syscalls */ | | 1139 | /* |
1076 | /* and limit the data to be transfered */ | | 1140 | * Change all colors in 2 ioctls |
| | | 1141 | * and limit the data to be transfered. |
| | | 1142 | */ |
1077 | for (i = 0; i < numColors; i++) { | | 1143 | for (i = 0; i < numColors; i++) { |
1078 | if (indices[i] < indexMin) | | 1144 | if (indices[i] < indexMin) |
1079 | indexMin = indices[i]; | | 1145 | indexMin = indices[i]; |
1080 | if (indices[i] > indexMax) | | 1146 | if (indices[i] > indexMax) |
1081 | indexMax = indices[i]; | | 1147 | indexMax = indices[i]; |
1082 | } | | 1148 | } |
1083 | cmap.index = indexMin; | | 1149 | cmap.index = indexMin; |
1084 | cmap.count = indexMax - indexMin + 1; | | 1150 | cmap.count = indexMax - indexMin + 1; |
1085 | cmap.red = &red[indexMin]; | | 1151 | cmap.red = &red[indexMin]; |
1086 | cmap.green = &green[indexMin]; | | 1152 | cmap.green = &green[indexMin]; |
1087 | cmap.blue = &blue[indexMin]; | | 1153 | cmap.blue = &blue[indexMin]; |
1088 | /* Get current map */ | | 1154 | /* Get current map. */ |
1089 | if (ioctl(fPtr->fd, WSDISPLAYIO_GETCMAP, &cmap) == -1) | | 1155 | if (ioctl(fPtr->fd, WSDISPLAYIO_GETCMAP, &cmap) == -1) |
1090 | ErrorF("ioctl FBIOGETCMAP: %s\n", strerror(errno)); | | 1156 | ErrorF("ioctl FBIOGETCMAP: %s\n", strerror(errno)); |
1091 | /* Change the colors that require updating */ | | 1157 | /* Change the colors that require updating. */ |
1092 | for (i = 0; i < numColors; i++) { | | 1158 | for (i = 0; i < numColors; i++) { |
1093 | red[indices[i]] = colors[indices[i]].red; | | 1159 | red[indices[i]] = colors[indices[i]].red; |
1094 | green[indices[i]] = colors[indices[i]].green; | | 1160 | green[indices[i]] = colors[indices[i]].green; |
1095 | blue[indices[i]] = colors[indices[i]].blue; | | 1161 | blue[indices[i]] = colors[indices[i]].blue; |
1096 | } | | 1162 | } |
1097 | /* Write the colormap back */ | | 1163 | /* Write the colormap back. */ |
1098 | if (ioctl(fPtr->fd,WSDISPLAYIO_PUTCMAP, &cmap) == -1) | | 1164 | if (ioctl(fPtr->fd,WSDISPLAYIO_PUTCMAP, &cmap) == -1) |
1099 | ErrorF("ioctl FBIOPUTCMAP: %s\n", strerror(errno)); | | 1165 | ErrorF("ioctl FBIOPUTCMAP: %s\n", strerror(errno)); |
1100 | } | | 1166 | } |
1101 | TRACE_EXIT("LoadPalette"); | | 1167 | TRACE_EXIT("LoadPalette"); |
1102 | } | | 1168 | } |
1103 | | | 1169 | |
1104 | static Bool | | 1170 | static Bool |
1105 | WsfbSaveScreen(ScreenPtr pScreen, int mode) | | 1171 | WsfbSaveScreen(ScreenPtr pScreen, int mode) |
1106 | { | | 1172 | { |
1107 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; | | 1173 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; |
1108 | WsfbPtr fPtr = WSFBPTR(pScrn); | | 1174 | WsfbPtr fPtr = WSFBPTR(pScrn); |
1109 | int state; | | 1175 | int state; |
1110 | | | 1176 | |
1111 | TRACE_ENTER("SaveScreen"); | | 1177 | TRACE_ENTER("SaveScreen"); |
1112 | | | 1178 | |
1113 | if (!pScrn->vtSema) | | 1179 | if (!pScrn->vtSema) |
1114 | return TRUE; | | 1180 | return TRUE; |
1115 | | | 1181 | |
1116 | if (mode != SCREEN_SAVER_FORCER) { | | 1182 | if (mode != SCREEN_SAVER_FORCER) { |
1117 | state = xf86IsUnblank(mode)?WSDISPLAYIO_VIDEO_ON: | | 1183 | state = xf86IsUnblank(mode)?WSDISPLAYIO_VIDEO_ON: |
1118 | WSDISPLAYIO_VIDEO_OFF; | | 1184 | WSDISPLAYIO_VIDEO_OFF; |
1119 | ioctl(fPtr->fd, | | 1185 | ioctl(fPtr->fd, |
1120 | WSDISPLAYIO_SVIDEO, &state); | | 1186 | WSDISPLAYIO_SVIDEO, &state); |
1121 | } | | 1187 | } |
| | | 1188 | TRACE_EXIT("SaveScreen"); |
1122 | return TRUE; | | 1189 | return TRUE; |
1123 | } | | 1190 | } |
1124 | | | 1191 | |
1125 | | | 1192 | |
1126 | static void | | 1193 | static void |
1127 | WsfbSave(ScrnInfoPtr pScrn) | | 1194 | WsfbSave(ScrnInfoPtr pScrn) |
1128 | { | | 1195 | { |
1129 | WsfbPtr fPtr = WSFBPTR(pScrn); | | 1196 | WsfbPtr fPtr = WSFBPTR(pScrn); |
1130 | | | 1197 | |
1131 | TRACE_ENTER("WsfbSave"); | | 1198 | TRACE_ENTER("WsfbSave"); |
1132 | | | 1199 | |
1133 | if (fPtr->info.cmsize == 0) | | 1200 | if (fPtr->info.cmsize == 0) |
1134 | return; | | 1201 | return; |
1135 | | | 1202 | |
1136 | fPtr->saved_cmap.index = 0; | | 1203 | fPtr->saved_cmap.index = 0; |
1137 | fPtr->saved_cmap.count = fPtr->info.cmsize; | | 1204 | fPtr->saved_cmap.count = fPtr->info.cmsize; |
1138 | if (ioctl(fPtr->fd, WSDISPLAYIO_GETCMAP, | | 1205 | if (ioctl(fPtr->fd, WSDISPLAYIO_GETCMAP, |
1139 | &(fPtr->saved_cmap)) == -1) { | | 1206 | &(fPtr->saved_cmap)) == -1) { |
1140 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 1207 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
1141 | "error saving colormap %s\n", strerror(errno)); | | 1208 | "error saving colormap %s\n", strerror(errno)); |
1142 | } | | 1209 | } |
| | | 1210 | TRACE_EXIT("WsfbSave"); |
1143 | | | 1211 | |
1144 | } | | 1212 | } |
1145 | | | 1213 | |
1146 | static void | | 1214 | static void |
1147 | WsfbRestore(ScrnInfoPtr pScrn) | | 1215 | WsfbRestore(ScrnInfoPtr pScrn) |
1148 | { | | 1216 | { |
1149 | WsfbPtr fPtr = WSFBPTR(pScrn); | | 1217 | WsfbPtr fPtr = WSFBPTR(pScrn); |
1150 | int mode; | | 1218 | int mode; |
1151 | | | 1219 | |
1152 | TRACE_ENTER("WsfbRestore"); | | 1220 | TRACE_ENTER("WsfbRestore"); |
1153 | | | 1221 | |
1154 | if (fPtr->info.cmsize != 0) { | | 1222 | if (fPtr->info.cmsize != 0) { |
1155 | /* reset colormap for text mode */ | | 1223 | /* reset colormap for text mode */ |
1156 | if (ioctl(fPtr->fd, WSDISPLAYIO_PUTCMAP, | | 1224 | if (ioctl(fPtr->fd, WSDISPLAYIO_PUTCMAP, |
1157 | &(fPtr->saved_cmap)) == -1) { | | 1225 | &(fPtr->saved_cmap)) == -1) { |
1158 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 1226 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
1159 | "error restoring colormap %s\n", | | 1227 | "error restoring colormap %s\n", |
1160 | strerror(errno)); | | 1228 | strerror(errno)); |
1161 | } | | 1229 | } |
1162 | } | | 1230 | } |
1163 | | | 1231 | |
1164 | /* Clear the screen */ | | 1232 | /* Clear the screen. */ |
1165 | memset(fPtr->fbmem, 0, fPtr->fbmem_len); | | 1233 | memset(fPtr->fbmem, 0, fPtr->fbmem_len); |
1166 | | | 1234 | |
1167 | /* Restore the text mode */ | | 1235 | /* Restore the text mode. */ |
1168 | mode = WSDISPLAYIO_MODE_EMUL; | | 1236 | mode = WSDISPLAYIO_MODE_EMUL; |
1169 | if (ioctl(fPtr->fd, WSDISPLAYIO_SMODE, &mode) == -1) { | | 1237 | if (ioctl(fPtr->fd, WSDISPLAYIO_SMODE, &mode) == -1) { |
1170 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 1238 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
1171 | "error setting text mode %s\n", strerror(errno)); | | 1239 | "error setting text mode %s\n", strerror(errno)); |
1172 | } | | 1240 | } |
1173 | TRACE_EXIT("WsfbRestore"); | | 1241 | TRACE_EXIT("WsfbRestore"); |
1174 | } | | 1242 | } |
1175 | | | 1243 | |
1176 | #ifdef XFreeXDGA | | 1244 | #ifdef XFreeXDGA |
1177 | /*********************************************************************** | | 1245 | /*********************************************************************** |
1178 | * DGA stuff | | 1246 | * DGA stuff |
1179 | ***********************************************************************/ | | 1247 | ***********************************************************************/ |
1180 | | | 1248 | |