Tue Nov 4 22:20:39 2008 UTC ()
add hw cursor support and unbork shadow fb support.
TODO: find out how shadow fb is supposed to work in Xorg


(macallan)
diff -r0 -r1.1 xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb.h
diff -r0 -r1.1 xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_cursor.c
diff -r1.1.1.1 -r1.2 xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c

File Added: xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb.h
/* $OpenBSD: wsfb_driver.c,v 1.18 2003/04/02 16:42:13 jason Exp $ */
/*
 * Copyright (c) 2001 Matthieu Herrb
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *    - Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *    - Redistributions in binary form must reproduce the above
 *      copyright notice, this list of conditions and the following
 *      disclaimer in the documentation and/or other materials provided
 *      with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */

/*
 * Based on fbdev.c written by:
 *
 * Authors:  Alan Hourihane, <alanh@fairlite.demon.co.uk>
 *	     Michel Dänzer, <michdaen@iiic.ethz.ch>
 */
 
#include <fcntl.h>
#include <sys/types.h>
#include <sys/time.h>
#include <dev/wscons/wsconsio.h>

#include "xf86.h"
#include "xf86_OSproc.h"
#include "xf86_ansic.h"

#include "xf86RamDac.h"

#ifndef WSFB_H
#define WSFB_H

/* private data */
typedef struct {
	int			fd; /* file descriptor of open device */
	struct wsdisplay_fbinfo info; /* frame buffer characteristics */
	int			linebytes; /* number of bytes per row */
	int			rotate;
	unsigned char*		fbstart;
	unsigned char*		fbmem;
	size_t			fbmem_len;
	//void *			shadow;
	Bool			shadowFB;
	Bool			HWCursor;
	CloseScreenProcPtr	CloseScreen;
	CreateScreenResourcesProcPtr CreateScreenResources;
	void                    (*PointerMoved)(int, int, int);
	EntityInfoPtr		pEnt;
	struct wsdisplay_cmap	saved_cmap;

	struct wsdisplay_cursor cursor;
	int			maskoffset;
	xf86CursorInfoPtr	CursorInfoRec;
#ifdef XFreeXDGA
	/* DGA info */
	DGAModePtr		pDGAMode;
	int			nDGAMode;
#endif
	OptionInfoPtr		Options;
} WsfbRec, *WsfbPtr;

#define WSFBPTR(p) ((WsfbPtr)((p)->driverPrivate))

Bool WsfbSetupCursor(ScreenPtr);

#endif

File Added: xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_cursor.c
/* $NetBSD: wsfb_cursor.c,v 1.1 2008/11/04 22:20:39 macallan Exp $ */
/*
 * Copyright (c) 2005 Michael Lorenz
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *    - Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *    - Redistributions in binary form must reproduce the above
 *      copyright notice, this list of conditions and the following
 *      disclaimer in the documentation and/or other materials provided
 *      with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */

/*
 * Based on fbdev.c written by:
 *
 * Authors:  Alan Hourihane, <alanh@fairlite.demon.co.uk>
 *	     Michel Dänzer, <michdaen@iiic.ethz.ch>
 */

#include <fcntl.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/endian.h>
#include <dev/wscons/wsconsio.h>
#include <errno.h>

/* all driver need this */
#include "xf86.h"
#include "xf86_OSproc.h"
#include "xf86_ansic.h"

#include "wsfb.h"

static void WsfbLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src);
static void WsfbSetCursorPosition(ScrnInfoPtr pScrn, int x, int y);
static void WsfbSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg);

static void
WsfbLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
{
	WsfbPtr pWsfb = WSFBPTR(pScrn);
	int err, i;
	
	pWsfb->cursor.which = WSDISPLAY_CURSOR_DOALL;
	pWsfb->cursor.image = src;
	pWsfb->cursor.mask = src + pWsfb->maskoffset;
	if(ioctl(pWsfb->fd, WSDISPLAYIO_SCURSOR, &pWsfb->cursor) == -1)
		xf86Msg(X_ERROR, "WsfbLoadCursorImage: %d\n", errno);
}

void 
WsfbShowCursor(ScrnInfoPtr pScrn)
{
	WsfbPtr pWsfb = WSFBPTR(pScrn);

	pWsfb->cursor.which = WSDISPLAY_CURSOR_DOCUR;
	pWsfb->cursor.enable = 1;
	if(ioctl(pWsfb->fd, WSDISPLAYIO_SCURSOR, &pWsfb->cursor) == -1)
		xf86Msg(X_ERROR, "WsfbShowCursor: %d\n", errno);
}

void
WsfbHideCursor(ScrnInfoPtr pScrn)
{
	WsfbPtr pWsfb = WSFBPTR(pScrn);

	pWsfb->cursor.which = WSDISPLAY_CURSOR_DOCUR;
	pWsfb->cursor.enable = 0;
	if(ioctl(pWsfb->fd, WSDISPLAYIO_SCURSOR, &pWsfb->cursor) == -1)
		xf86Msg(X_ERROR, "WsfbHideCursor: %d\n", errno);
}

static void
WsfbSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
{
	WsfbPtr pWsfb = WSFBPTR(pScrn);
	int xoff = 0, yoff = 0;
	
	pWsfb->cursor.which = WSDISPLAY_CURSOR_DOPOS | WSDISPLAY_CURSOR_DOHOT;
	
	if (x < 0) {
		xoff = -x;
		x = 0;
	}
	if (y < 0) {
		yoff = -y;
		y = 0;
	}
	
	pWsfb->cursor.pos.x = x;
	pWsfb->cursor.hot.x = xoff;
	pWsfb->cursor.pos.y = y;
	pWsfb->cursor.hot.y = yoff;
	
	if(ioctl(pWsfb->fd, WSDISPLAYIO_SCURSOR, &pWsfb->cursor) == -1)
		xf86Msg(X_ERROR, "WsfbSetCursorPosition: %d\n", errno);
}

static void
WsfbSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
{
	WsfbPtr pWsfb = WSFBPTR(pScrn);
	u_char r[4], g[4], b[4];
	
	pWsfb->cursor.which = WSDISPLAY_CURSOR_DOCMAP;
	pWsfb->cursor.cmap.red = r;
	pWsfb->cursor.cmap.green = g;
	pWsfb->cursor.cmap.blue = b;
	r[1] = fg & 0xff;
	g[1] = (fg & 0xff00) >> 8;
	b[1] = (fg & 0xff0000) >> 16;
	r[0] = bg & 0xff;
	g[0] = (bg & 0xff00) >> 8;
	b[0] = (bg & 0xff0000) >> 16;
	pWsfb->cursor.cmap.index = 0;
	pWsfb->cursor.cmap.count = 2;
	if(ioctl(pWsfb->fd, WSDISPLAYIO_SCURSOR, &pWsfb->cursor) == -1)
		xf86Msg(X_ERROR, "WsfbSetCursorColors: %d\n", errno);
}

Bool 
WsfbSetupCursor(ScreenPtr pScreen)
{
	ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
	WsfbPtr pWsfb = WSFBPTR(pScrn);
	xf86CursorInfoPtr infoPtr;
	
	pWsfb->cursor.pos.x = 0;
	pWsfb->cursor.pos.y = 0;
	pWsfb->cursor.enable = 0;

	infoPtr = xf86CreateCursorInfoRec();
	if(!infoPtr) return FALSE;
    
	pWsfb->CursorInfoRec = infoPtr;
	if(ioctl(pWsfb->fd, WSDISPLAYIO_GCURMAX, &pWsfb->cursor.size) == -1) {
		xf86Msg(X_WARNING, "No HW cursor support found\n");
		return FALSE;
	}
		
	xf86Msg(X_INFO, "HW cursor enabled\n");

	infoPtr->MaxWidth = pWsfb->cursor.size.x;
	infoPtr->MaxHeight = pWsfb->cursor.size.y;
	pWsfb->maskoffset = ( pWsfb->cursor.size.x >> 3) * pWsfb->cursor.size.y;
	
	pWsfb->cursor.hot.x = 0;
	pWsfb->cursor.hot.y = 0;
	pWsfb->cursor.which = WSDISPLAY_CURSOR_DOHOT | WSDISPLAY_CURSOR_DOCUR |
	    WSDISPLAY_CURSOR_DOPOS;
	if(ioctl(pWsfb->fd, WSDISPLAYIO_SCURSOR, &pWsfb->cursor) == -1)
		xf86Msg(X_ERROR, "WSDISPLAYIO_SCURSOR: %d\n", errno);
	
	infoPtr->Flags = HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
	    HARDWARE_CURSOR_TRUECOLOR_AT_8BPP
/* XXX not sure why exactly we need this */
#if BYTE_ORDER == BIG_ENDIAN
	    | HARDWARE_CURSOR_BIT_ORDER_MSBFIRST
#endif
	;
	infoPtr->SetCursorColors = WsfbSetCursorColors;
	infoPtr->SetCursorPosition = WsfbSetCursorPosition;
	infoPtr->LoadCursorImage = WsfbLoadCursorImage;
	infoPtr->HideCursor = WsfbHideCursor;
	infoPtr->ShowCursor = WsfbShowCursor;
	infoPtr->UseHWCursor = NULL;

	return xf86InitCursor(pScreen, infoPtr);
}

cvs diff -r1.1.1.1 -r1.2 xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c (expand / switch to unified diff)

--- xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c 2008/08/02 05:18:51 1.1.1.1
+++ xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c 2008/11/04 22:20:39 1.2
@@ -60,26 +60,28 @@ @@ -60,26 +60,28 @@
60 60
61/* for visuals */ 61/* for visuals */
62#include "xf1bpp.h" 62#include "xf1bpp.h"
63#include "xf4bpp.h" 63#include "xf4bpp.h"
64#include "fb.h" 64#include "fb.h"
65 65
66#include "xf86Resources.h" 66#include "xf86Resources.h"
67#include "xf86RAC.h" 67#include "xf86RAC.h"
68 68
69#ifdef XvExtension 69#ifdef XvExtension
70#include "xf86xv.h" 70#include "xf86xv.h"
71#endif 71#endif
72 72
 73#include "wsfb.h"
 74
73/* #include "wsconsio.h" */ 75/* #include "wsconsio.h" */
74 76
75#ifndef XFree86LOADER 77#ifndef XFree86LOADER
76#include <sys/mman.h> 78#include <sys/mman.h>
77#endif 79#endif
78 80
79#ifdef USE_PRIVSEP 81#ifdef USE_PRIVSEP
80extern int priv_open_device(const char *); 82extern int priv_open_device(const char *);
81#else 83#else
82#define priv_open_device(n) open(n,O_RDWR|O_NONBLOCK|O_EXCL) 84#define priv_open_device(n) open(n,O_RDWR|O_NONBLOCK|O_EXCL)
83#endif 85#endif
84 86
85#if defined(__NetBSD__) 87#if defined(__NetBSD__)
@@ -165,51 +167,60 @@ _X_EXPORT DriverRec WSFB = { @@ -165,51 +167,60 @@ _X_EXPORT DriverRec WSFB = {
165 0, 167 0,
166 WsfbDriverFunc 168 WsfbDriverFunc
167}; 169};
168 170
169/* Supported "chipsets" */ 171/* Supported "chipsets" */
170static SymTabRec WsfbChipsets[] = { 172static SymTabRec WsfbChipsets[] = {
171 { 0, "wsfb" }, 173 { 0, "wsfb" },
172 { -1, NULL } 174 { -1, NULL }
173}; 175};
174 176
175/* Supported options */ 177/* Supported options */
176typedef enum { 178typedef enum {
177 OPTION_SHADOW_FB, 179 OPTION_SHADOW_FB,
178 OPTION_ROTATE 180 OPTION_ROTATE,
 181 OPTION_HW_CURSOR,
 182 OPTION_SW_CURSOR
179} WsfbOpts; 183} WsfbOpts;
180 184
181static const OptionInfoRec WsfbOptions[] = { 185static const OptionInfoRec WsfbOptions[] = {
182 { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE}, 186 { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE},
183 { OPTION_ROTATE, "Rotate", OPTV_STRING, {0}, FALSE}, 187 { OPTION_ROTATE, "Rotate", OPTV_STRING, {0}, FALSE},
184 { -1, NULL, OPTV_NONE, {0}, FALSE} 188 { -1, NULL, OPTV_NONE, {0}, FALSE}
185}; 189};
186 190
187/* Symbols needed from other modules */ 191/* Symbols needed from other modules */
188static const char *fbSymbols[] = { 192static const char *fbSymbols[] = {
189 "fbPictureInit", 193 "fbPictureInit",
190 "fbScreenInit", 194 "fbScreenInit",
191 NULL 195 NULL
192}; 196};
193static const char *shadowSymbols[] = { 197static const char *shadowSymbols[] = {
194 "shadowAdd", 198 "shadowAdd",
195 "shadowSetup", 199 "shadowSetup",
196 "shadowUpdatePacked", 200 "shadowUpdatePacked",
197 "shadowUpdatePackedWeak", 201 "shadowUpdatePackedWeak",
198 "shadowUpdateRotatePacked", 202 "shadowUpdateRotatePacked",
199 "shadowUpdateRotatePackedWeak", 203 "shadowUpdateRotatePackedWeak",
200 NULL 204 NULL
201}; 205};
202 206
 207static const char *ramdacSymbols[] = {
 208 "xf86CreateCursorInfoRec",
 209 "xf86DestroyCursorInfoRec",
 210 "xf86InitCursor",
 211 NULL
 212};
 213
203#ifdef XFree86LOADER 214#ifdef XFree86LOADER
204static XF86ModuleVersionInfo WsfbVersRec = { 215static XF86ModuleVersionInfo WsfbVersRec = {
205 "wsfb", 216 "wsfb",
206 MODULEVENDORSTRING, 217 MODULEVENDORSTRING,
207 MODINFOSTRING1, 218 MODINFOSTRING1,
208 MODINFOSTRING2, 219 MODINFOSTRING2,
209 XORG_VERSION_CURRENT, 220 XORG_VERSION_CURRENT,
210 PACKAGE_VERSION_MAJOR,  221 PACKAGE_VERSION_MAJOR,
211 PACKAGE_VERSION_MINOR,  222 PACKAGE_VERSION_MINOR,
212 PACKAGE_VERSION_PATCHLEVEL, 223 PACKAGE_VERSION_PATCHLEVEL,
213 ABI_CLASS_VIDEODRV, 224 ABI_CLASS_VIDEODRV,
214 ABI_VIDEODRV_VERSION, 225 ABI_VIDEODRV_VERSION,
215 NULL, 226 NULL,
@@ -227,63 +238,37 @@ WsfbSetup(pointer module, pointer opts,  @@ -227,63 +238,37 @@ WsfbSetup(pointer module, pointer opts,
227 /* Check that we're being loaded on a OpenBSD or NetBSD system */ 238 /* Check that we're being loaded on a OpenBSD or NetBSD system */
228 LoaderGetOS(&osname, NULL, NULL, NULL); 239 LoaderGetOS(&osname, NULL, NULL, NULL);
229 if (!osname || (strcmp(osname, "openbsd") != 0 && 240 if (!osname || (strcmp(osname, "openbsd") != 0 &&
230 strcmp(osname, "netbsd") != 0)) { 241 strcmp(osname, "netbsd") != 0)) {
231 if (errmaj) 242 if (errmaj)
232 *errmaj = LDR_BADOS; 243 *errmaj = LDR_BADOS;
233 if (errmin) 244 if (errmin)
234 *errmin = 0; 245 *errmin = 0;
235 return NULL; 246 return NULL;
236 } 247 }
237 if (!setupDone) { 248 if (!setupDone) {
238 setupDone = TRUE; 249 setupDone = TRUE;
239 xf86AddDriver(&WSFB, module, HaveDriverFuncs); 250 xf86AddDriver(&WSFB, module, HaveDriverFuncs);
240 LoaderRefSymLists(fbSymbols, shadowSymbols, NULL); 251 LoaderRefSymLists(fbSymbols, shadowSymbols, ramdacSymbols,
 252 NULL);
241 return (pointer)1; 253 return (pointer)1;
242 } else { 254 } else {
243 if (errmaj != NULL) 255 if (errmaj != NULL)
244 *errmaj = LDR_ONCEONLY; 256 *errmaj = LDR_ONCEONLY;
245 return NULL; 257 return NULL;
246 } 258 }
247} 259}
248#endif /* XFree86LOADER */ 260#endif /* XFree86LOADER */
249 261
250/* private data */ 
251typedef struct { 
252 int fd; /* file descriptor of open device */ 
253 struct wsdisplay_fbinfo info; /* frame buffer characteristics */ 
254 int linebytes; /* number of bytes per row */ 
255 unsigned char* fbstart; 
256 unsigned char* fbmem; 
257 size_t fbmem_len; 
258 int rotate; 
259 Bool shadowFB; 
260 void * shadow; 
261 CloseScreenProcPtr CloseScreen; 
262 CreateScreenResourcesProcPtr CreateScreenResources; 
263 void (*PointerMoved)(int, int, int); 
264 EntityInfoPtr pEnt; 
265 struct wsdisplay_cmap saved_cmap; 
266 
267#ifdef XFreeXDGA 
268 /* DGA info */ 
269 DGAModePtr pDGAMode; 
270 int nDGAMode; 
271#endif 
272 OptionInfoPtr Options; 
273} WsfbRec, *WsfbPtr; 
274 
275#define WSFBPTR(p) ((WsfbPtr)((p)->driverPrivate)) 
276 
277static Bool 262static Bool
278WsfbGetRec(ScrnInfoPtr pScrn) 263WsfbGetRec(ScrnInfoPtr pScrn)
279{ 264{
280 265
281 if (pScrn->driverPrivate != NULL) 266 if (pScrn->driverPrivate != NULL)
282 return TRUE; 267 return TRUE;
283 268
284 pScrn->driverPrivate = xnfcalloc(sizeof(WsfbRec), 1); 269 pScrn->driverPrivate = xnfcalloc(sizeof(WsfbRec), 1);
285 return TRUE; 270 return TRUE;
286} 271}
287 272
288static void 273static void
289WsfbFreeRec(ScrnInfoPtr pScrn) 274WsfbFreeRec(ScrnInfoPtr pScrn)
@@ -339,27 +324,27 @@ wsfb_mmap(size_t len, off_t off, int fd) @@ -339,27 +324,27 @@ wsfb_mmap(size_t len, off_t off, int fd)
339 324
340 pagemask = getpagesize() - 1; 325 pagemask = getpagesize() - 1;
341 mapsize = ((int) len + pagemask) & ~pagemask; 326 mapsize = ((int) len + pagemask) & ~pagemask;
342 addr = 0; 327 addr = 0;
343 328
344 /* 329 /*
345 * try and make it private first, that way once we get it, an 330 * try and make it private first, that way once we get it, an
346 * interloper, e.g. another server, can't get this frame buffer, 331 * interloper, e.g. another server, can't get this frame buffer,
347 * and if another server already has it, this one won't. 332 * and if another server already has it, this one won't.
348 */ 333 */
349 mapaddr = (pointer) mmap(addr, mapsize, 334 mapaddr = (pointer) mmap(addr, mapsize,
350 PROT_READ | PROT_WRITE, MAP_SHARED, 335 PROT_READ | PROT_WRITE, MAP_SHARED,
351 fd, off); 336 fd, off);
352 if (mapaddr == (pointer) -1) { 337 if (mapaddr == MAP_FAILED) {
353 mapaddr = NULL; 338 mapaddr = NULL;
354 } 339 }
355#if DEBUG 340#if DEBUG
356 ErrorF("mmap returns: addr %p len 0x%x\n", mapaddr, mapsize); 341 ErrorF("mmap returns: addr %p len 0x%x\n", mapaddr, mapsize);
357#endif 342#endif
358 return mapaddr; 343 return mapaddr;
359} 344}
360 345
361static Bool 346static Bool
362WsfbProbe(DriverPtr drv, int flags) 347WsfbProbe(DriverPtr drv, int flags)
363{ 348{
364 int i, fd, entity; 349 int i, fd, entity;
365 GDevPtr *devSections; 350 GDevPtr *devSections;
@@ -410,26 +395,27 @@ WsfbProbe(DriverPtr drv, int flags) @@ -410,26 +395,27 @@ WsfbProbe(DriverPtr drv, int flags)
410 return foundScreen; 395 return foundScreen;
411} 396}
412 397
413static Bool 398static Bool
414WsfbPreInit(ScrnInfoPtr pScrn, int flags) 399WsfbPreInit(ScrnInfoPtr pScrn, int flags)
415{ 400{
416 WsfbPtr fPtr; 401 WsfbPtr fPtr;
417 int default_depth, wstype; 402 int default_depth, wstype;
418 char *dev, *s; 403 char *dev, *s;
419 char *mod = NULL; 404 char *mod = NULL;
420 const char *reqSym = NULL; 405 const char *reqSym = NULL;
421 Gamma zeros = {0.0, 0.0, 0.0}; 406 Gamma zeros = {0.0, 0.0, 0.0};
422 DisplayModePtr mode; 407 DisplayModePtr mode;
 408 MessageType from;
423 409
424 if (flags & PROBE_DETECT) return FALSE; 410 if (flags & PROBE_DETECT) return FALSE;
425 411
426 TRACE_ENTER("PreInit"); 412 TRACE_ENTER("PreInit");
427 413
428 if (pScrn->numEntities != 1) return FALSE; 414 if (pScrn->numEntities != 1) return FALSE;
429 415
430 pScrn->monitor = pScrn->confScreen->monitor; 416 pScrn->monitor = pScrn->confScreen->monitor;
431 417
432 WsfbGetRec(pScrn); 418 WsfbGetRec(pScrn);
433 fPtr = WSFBPTR(pScrn); 419 fPtr = WSFBPTR(pScrn);
434 420
435 fPtr->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); 421 fPtr->pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
@@ -630,56 +616,74 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags @@ -630,56 +616,74 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags
630 mode->Flags = 0; 616 mode->Flags = 0;
631 if (pScrn->modes != NULL) { 617 if (pScrn->modes != NULL) {
632 xf86DrvMsg(pScrn->scrnIndex, X_INFO, 618 xf86DrvMsg(pScrn->scrnIndex, X_INFO,
633 "Ignoring mode specification from screen section\n"); 619 "Ignoring mode specification from screen section\n");
634 } 620 }
635 pScrn->currentMode = pScrn->modes = mode; 621 pScrn->currentMode = pScrn->modes = mode;
636 pScrn->virtualX = fPtr->info.width; 622 pScrn->virtualX = fPtr->info.width;
637 pScrn->virtualY = fPtr->info.height; 623 pScrn->virtualY = fPtr->info.height;
638 pScrn->displayWidth = pScrn->virtualX; 624 pScrn->displayWidth = pScrn->virtualX;
639 625
640 /* Set the display resolution */ 626 /* Set the display resolution */
641 xf86SetDpi(pScrn, 0, 0); 627 xf86SetDpi(pScrn, 0, 0);
642 628
 629 from = X_DEFAULT;
 630 fPtr->HWCursor = TRUE;
 631 if (xf86GetOptValBool(fPtr->Options, OPTION_HW_CURSOR, &fPtr->HWCursor))
 632 from = X_CONFIG;
 633 if (xf86ReturnOptValBool(fPtr->Options, OPTION_SW_CURSOR, FALSE)) {
 634 from = X_CONFIG;
 635 fPtr->HWCursor = FALSE;
 636 }
 637 xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n",
 638 fPtr->HWCursor ? "HW" : "SW");
 639
643 /* Load bpp-specific modules */ 640 /* Load bpp-specific modules */
644 switch(pScrn->bitsPerPixel) { 641 switch(pScrn->bitsPerPixel) {
645 case 1: 642 case 1:
646 mod = "xf1bpp"; 643 mod = "xf1bpp";
647 reqSym = "xf1bppScreenInit"; 644 reqSym = "xf1bppScreenInit";
648 break; 645 break;
649 case 4: 646 case 4:
650 mod = "xf4bpp"; 647 mod = "xf4bpp";
651 reqSym = "xf4bppScreenInit"; 648 reqSym = "xf4bppScreenInit";
652 break; 649 break;
653 default: 650 default:
654 mod = "fb"; 651 mod = "fb";
655 break; 652 break;
656 } 653 }
657 654
658 655
659 /* Load shadow if needed */ 656 /* Load shadow if needed */
660 if (fPtr->shadowFB) { 657 if (fPtr->shadowFB) {
661 xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, 658 xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
662 "Using \"Shadow Framebuffer\"\n"); 659 "Using \"Shadow Framebuffer\"\n");
663 if (xf86LoadSubModule(pScrn, "shadow") == NULL) { 660 if (xf86LoadSubModule(pScrn, "shadow") == NULL) {
664 WsfbFreeRec(pScrn); 661 WsfbFreeRec(pScrn);
665 return FALSE; 662 return FALSE;
666 } 663 }
667 xf86LoaderReqSymLists(shadowSymbols, NULL); 664 xf86LoaderReqSymLists(shadowSymbols, NULL);
668 } 665 }
 666
669 if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { 667 if (mod && xf86LoadSubModule(pScrn, mod) == NULL) {
670 WsfbFreeRec(pScrn); 668 WsfbFreeRec(pScrn);
671 return FALSE; 669 return FALSE;
672 } 670 }
 671
 672 if (xf86LoadSubModule(pScrn, "ramdac") == NULL) {
 673 WsfbFreeRec(pScrn);
 674 return FALSE;
 675 }
 676
673 if (mod) { 677 if (mod) {
674 if (reqSym) { 678 if (reqSym) {
675 xf86LoaderReqSymbols(reqSym, NULL); 679 xf86LoaderReqSymbols(reqSym, NULL);
676 } else { 680 } else {
677 xf86LoaderReqSymLists(fbSymbols, NULL); 681 xf86LoaderReqSymLists(fbSymbols, NULL);
678 } 682 }
679 } 683 }
680 TRACE_EXIT("PreInit"); 684 TRACE_EXIT("PreInit");
681 return TRUE; 685 return TRUE;
682} 686}
683 687
684static Bool 688static Bool
685WsfbCreateScreenResources(ScreenPtr pScreen) 689WsfbCreateScreenResources(ScreenPtr pScreen)
@@ -828,27 +832,27 @@ WsfbScreenInit(int scrnIndex, ScreenPtr  @@ -828,27 +832,27 @@ WsfbScreenInit(int scrnIndex, ScreenPtr
828 pScrn->displayWidth); 832 pScrn->displayWidth);
829 break; 833 break;
830 case 4: 834 case 4:
831 ret = xf4bppScreenInit(pScreen, fPtr->fbstart, 835 ret = xf4bppScreenInit(pScreen, fPtr->fbstart,
832 pScrn->virtualX, pScrn->virtualY, 836 pScrn->virtualX, pScrn->virtualY,
833 pScrn->xDpi, pScrn->yDpi, 837 pScrn->xDpi, pScrn->yDpi,
834 pScrn->displayWidth); 838 pScrn->displayWidth);
835 break; 839 break;
836 case 8: 840 case 8:
837 case 16: 841 case 16:
838 case 24: 842 case 24:
839 case 32: 843 case 32:
840 ret = fbScreenInit(pScreen, 844 ret = fbScreenInit(pScreen,
841 fPtr->shadowFB ? fPtr->shadow : fPtr->fbstart, 845 /*fPtr->shadowFB ? fPtr->shadow :*/ fPtr->fbstart,
842 pScrn->virtualX, pScrn->virtualY, 846 pScrn->virtualX, pScrn->virtualY,
843 pScrn->xDpi, pScrn->yDpi, 847 pScrn->xDpi, pScrn->yDpi,
844 pScrn->displayWidth, pScrn->bitsPerPixel); 848 pScrn->displayWidth, pScrn->bitsPerPixel);
845 break; 849 break;
846 default: 850 default:
847 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, 851 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
848 "Unsupported bpp: %d", pScrn->bitsPerPixel); 852 "Unsupported bpp: %d", pScrn->bitsPerPixel);
849 return FALSE; 853 return FALSE;
850 } /* case */ 854 } /* case */
851 855
852 if (!ret) 856 if (!ret)
853 return FALSE; 857 return FALSE;
854 858
@@ -891,26 +895,30 @@ WsfbScreenInit(int scrnIndex, ScreenPtr  @@ -891,26 +895,30 @@ WsfbScreenInit(int scrnIndex, ScreenPtr
891 xf86DisableRandR(); 895 xf86DisableRandR();
892 if (pScrn->bitsPerPixel == 24)  896 if (pScrn->bitsPerPixel == 24)
893 xf86DrvMsg(scrnIndex, X_WARNING,  897 xf86DrvMsg(scrnIndex, X_WARNING,
894 "Rotation might be broken in 24 bpp\n"); 898 "Rotation might be broken in 24 bpp\n");
895 } 899 }
896 900
897 xf86SetBlackWhitePixels(pScreen); 901 xf86SetBlackWhitePixels(pScreen);
898 miInitializeBackingStore(pScreen); 902 miInitializeBackingStore(pScreen);
899 xf86SetBackingStore(pScreen); 903 xf86SetBackingStore(pScreen);
900 904
901 /* software cursor */ 905 /* software cursor */
902 miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); 906 miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
903 907
 908 /* check for hardware cursor support */
 909 if (fPtr->HWCursor)
 910 WsfbSetupCursor(pScreen);
 911
904 /* colormap */ 912 /* colormap */
905 if (!miCreateDefColormap(pScreen)) 913 if (!miCreateDefColormap(pScreen))
906 return FALSE; 914 return FALSE;
907 flags = CMAP_RELOAD_ON_MODE_SWITCH; 915 flags = CMAP_RELOAD_ON_MODE_SWITCH;
908 ncolors = fPtr->info.cmsize; 916 ncolors = fPtr->info.cmsize;
909 /* on StaticGray visuals, fake a 256 entries colormap */ 917 /* on StaticGray visuals, fake a 256 entries colormap */
910 if (ncolors == 0) 918 if (ncolors == 0)
911 ncolors = 256; 919 ncolors = 256;
912 if(!xf86HandleColormaps(pScreen, ncolors, 8, WsfbLoadPalette, 920 if(!xf86HandleColormaps(pScreen, ncolors, 8, WsfbLoadPalette,
913 NULL, flags)) 921 NULL, flags))
914 return FALSE; 922 return FALSE;
915 923
916 pScreen->SaveScreen = WsfbSaveScreen; 924 pScreen->SaveScreen = WsfbSaveScreen;