summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper Lievisse Adriaanse <jasper@openbsd.org>2009-06-01 14:34:39 -0600
committerMatthieu Herrb <matthieu.herrb@laas.fr>2009-06-01 14:35:37 -0600
commitad757e0c29f7e826f48b60df2d5b8b436d243449 (patch)
tree36c20b427d2689cbbae3df01ec9367e796dc6487
parentbce9fd21483fbeddc84672a1ef01fdd9b58c88ed (diff)
add some missing TRACE_EXITs, tweak and clean up comments.
Signed-off-by: Matthieu Herrb <matthieu.herrb@laas.fr>
-rw-r--r--src/wsfb_driver.c127
1 files changed, 70 insertions, 57 deletions
diff --git a/src/wsfb_driver.c b/src/wsfb_driver.c
index f709c51..588a15b 100644
--- a/src/wsfb_driver.c
+++ b/src/wsfb_driver.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsfb_driver.c,v 1.19 2003/04/27 16:42:32 matthieu Exp $ */
+/* $OpenBSD: wsfb_driver.c,v 1.14 2008/09/29 22:04:43 matthieu Exp $ */
/*
* Copyright (c) 2001 Matthieu Herrb
* All rights reserved.
@@ -47,7 +47,7 @@
#include <sys/time.h>
#include <dev/wscons/wsconsio.h>
-/* all driver need this */
+/* All drivers need this. */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -59,7 +59,7 @@
#include "shadow.h"
#include "dgaproc.h"
-/* for visuals */
+/* For visuals */
#ifdef HAVE_XF1BPP
# include "xf1bpp.h"
#endif
@@ -75,7 +75,7 @@
#include "xf86xv.h"
#endif
-#ifdef USE_PRIVSEP
+#ifdef X_PRIVSEP
extern int priv_open_device(const char *);
#else
#define priv_open_device(n) open(n,O_RDWR|O_NONBLOCK|O_EXCL)
@@ -123,7 +123,7 @@ static Bool WsfbSaveScreen(ScreenPtr, int);
static void WsfbSave(ScrnInfoPtr);
static void WsfbRestore(ScrnInfoPtr);
-/* dga stuff */
+/* DGA stuff */
#ifdef XFreeXDGA
static Bool WsfbDGAOpenFramebuffer(ScrnInfoPtr, char **, unsigned char **,
int *, int *, int *);
@@ -134,7 +134,7 @@ static Bool WsfbDGAInit(ScrnInfoPtr, ScreenPtr);
static Bool WsfbDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op,
pointer ptr);
-/* helper functions */
+/* Helper functions */
static int wsfb_open(char *);
static pointer wsfb_mmap(size_t, off_t, int);
@@ -145,8 +145,8 @@ enum { WSFB_ROTATE_NONE = 0,
};
/*
- * This is intentionally screen-independent. It indicates the binding
- * choice made in the first PreInit.
+ * This is intentionally screen-independent.
+ * It indicates the binding choice made in the first PreInit.
*/
static int pix24bpp = 0;
@@ -207,7 +207,7 @@ WsfbSetup(pointer module, pointer opts, int *errmaj, int *errmin)
static Bool setupDone = FALSE;
const char *osname;
- /* Check that we're being loaded on a OpenBSD or NetBSD system */
+ /* Check that we're being loaded on a OpenBSD or NetBSD system. */
LoaderGetOS(&osname, NULL, NULL, NULL);
if (!osname || (strcmp(osname, "openbsd") != 0 &&
strcmp(osname, "netbsd") != 0)) {
@@ -229,11 +229,11 @@ WsfbSetup(pointer module, pointer opts, int *errmaj, int *errmin)
}
#endif /* XFree86LOADER */
-/* private data */
+/* 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 fd; /* File descriptor of open device. */
+ struct wsdisplay_fbinfo info; /* Frame buffer characteristics. */
+ int linebytes; /* Number of bytes per row. */
unsigned char* fbstart;
unsigned char* fbmem;
size_t fbmem_len;
@@ -290,18 +290,18 @@ WsfbIdentify(int flags)
WsfbChipsets);
}
-/* Open the framebuffer device */
+/* Open the framebuffer device. */
static int
wsfb_open(char *dev)
{
int fd = -1;
- /* try argument from XF86Config first */
+ /* Try argument from XF86Config first. */
if (dev == NULL || ((fd = priv_open_device(dev)) == -1)) {
- /* second: environment variable */
+ /* Second: environment variable. */
dev = getenv("XDEVICE");
if (dev == NULL || ((fd = priv_open_device(dev)) == -1)) {
- /* last try: default device */
+ /* Last try: default device. */
dev = WSFB_DEFAULT_DEV;
if ((fd = priv_open_device(dev)) == -1) {
return -1;
@@ -311,7 +311,7 @@ wsfb_open(char *dev)
return fd;
}
-/* Map the framebuffer's memory */
+/* Map the framebuffer's memory. */
static pointer
wsfb_mmap(size_t len, off_t off, int fd)
{
@@ -324,7 +324,7 @@ wsfb_mmap(size_t len, off_t off, int fd)
addr = 0;
/*
- * try and make it private first, that way once we get it, an
+ * Try and make it private first, that way once we get it, an
* interloper, e.g. another server, can't get this frame buffer,
* and if another server already has it, this one won't.
*/
@@ -444,7 +444,7 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags)
return FALSE;
}
/*
- * Allocate room for saving the colormap
+ * Allocate room for saving the colormap.
*/
if (fPtr->info.cmsize != 0) {
fPtr->saved_cmap.red =
@@ -480,7 +480,7 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags)
fPtr->info.depth >= 24 ? Support24bppFb|Support32bppFb : 0))
return FALSE;
- /* Check consistency */
+ /* Check consistency. */
if (pScrn->bitsPerPixel != fPtr->info.depth) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"specified depth (%d) or bpp (%d) doesn't match "
@@ -490,11 +490,11 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags)
}
xf86PrintDepthBpp(pScrn);
- /* Get the depth24 pixmap format */
+ /* Get the depth24 pixmap format. */
if (pScrn->depth == 24 && pix24bpp == 0)
pix24bpp = xf86GetBppFromDepth(pScrn, 24);
- /* color weight */
+ /* Color weight */
if (pScrn->depth > 8) {
rgb zeros = { 0, 0, 0 }, masks;
@@ -516,11 +516,11 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags)
return FALSE;
}
- /* visual init */
+ /* Visual init */
if (!xf86SetDefaultVisual(pScrn, -1))
return FALSE;
- /* We don't currently support DirectColor at > 8bpp */
+ /* We don't currently support DirectColor at > 8bpp . */
if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual"
" (%s) is not supported at depth %d\n",
@@ -539,7 +539,7 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags)
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Vidmem: %dk\n",
pScrn->videoRam/1024);
- /* handle options */
+ /* Handle options. */
xf86CollectOptions(pScrn, NULL);
if (!(fPtr->Options = xalloc(sizeof(WsfbOptions))))
return FALSE;
@@ -547,7 +547,7 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags)
xf86ProcessOptions(pScrn->scrnIndex, fPtr->pEnt->device->options,
fPtr->Options);
- /* use shadow framebuffer by default, on depth >= 8 */
+ /* Use shadow framebuffer by default, on depth >= 8 */
if (pScrn->depth >= 8)
fPtr->shadowFB = xf86ReturnOptValBool(fPtr->Options,
OPTION_SHADOW_FB, TRUE);
@@ -558,7 +558,7 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags)
"Shadow FB option ignored on depth < 8");
}
- /* rotation */
+ /* Rotation */
fPtr->rotate = WSFB_ROTATE_NONE;
if ((s = xf86GetOptValString(fPtr->Options, OPTION_ROTATE))) {
if (pScrn->depth >= 8) {
@@ -591,7 +591,7 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags)
}
}
- /* fake video mode struct */
+ /* Fake video mode struct. */
mode = (DisplayModePtr)xalloc(sizeof(DisplayModeRec));
mode->prev = mode;
mode->next = mode;
@@ -619,10 +619,10 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags)
pScrn->virtualY = fPtr->info.height;
pScrn->displayWidth = pScrn->virtualX;
- /* Set the display resolution */
+ /* Set the display resolution. */
xf86SetDpi(pScrn, 0, 0);
- /* Load bpp-specific modules */
+ /* Load bpp-specific modules. */
switch(pScrn->bitsPerPixel) {
#ifdef HAVE_XF1BPP
case 1:
@@ -642,7 +642,7 @@ WsfbPreInit(ScrnInfoPtr pScrn, int flags)
}
- /* Load shadow if needed */
+ /* Load shadow if needed. */
if (fPtr->shadowFB) {
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
"Using \"Shadow Framebuffer\"\n");
@@ -751,7 +751,7 @@ WsfbScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
"unsupported depth %d\n", fPtr->info.depth);
return FALSE;
}
- /* Switch to graphics mode - required before mmap */
+ /* Switch to graphics mode - required before mmap. */
if (ioctl(fPtr->fd, WSDISPLAYIO_SMODE, &wsmode) == -1) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"ioctl WSDISPLAYIO_SMODE: %s\n",
@@ -770,7 +770,7 @@ WsfbScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
WsfbSave(pScrn);
pScrn->vtSema = TRUE;
- /* mi layer */
+ /* MI layer */
miClearVisualTypes();
if (pScrn->bitsPerPixel > 8) {
if (!miSetVisualTypes(pScrn->depth, TrueColorMask,
@@ -799,16 +799,16 @@ WsfbScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
fPtr->fbstart = fPtr->fbmem;
if (fPtr->shadowFB) {
- fPtr->shadow = xcalloc(1, pScrn->virtualX * pScrn->virtualY *
- pScrn->bitsPerPixel);
-
- if (!fPtr->shadow) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Failed to allocate shadow framebuffer\n");
- return FALSE;
- }
+ fPtr->shadow = xcalloc(1, pScrn->virtualX * pScrn->virtualY *
+ pScrn->bitsPerPixel);
+
+ if (!fPtr->shadow) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Failed to allocate shadow framebuffer\n");
+ return FALSE;
+ }
}
-
+
switch (pScrn->bitsPerPixel) {
case 1:
#ifdef HAVE_XF1BPP
@@ -846,7 +846,7 @@ WsfbScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
return FALSE;
if (pScrn->bitsPerPixel > 8) {
- /* Fixup RGB ordering */
+ /* Fixup RGB ordering. */
visual = pScreen->visuals + pScreen->numVisuals;
while (--visual >= pScreen->visuals) {
if ((visual->class | DynamicClass) == DirectColor) {
@@ -891,15 +891,22 @@ WsfbScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
miInitializeBackingStore(pScreen);
xf86SetBackingStore(pScreen);
- /* software cursor */
+ /* Software cursor. */
miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
- /* colormap */
+ /*
+ * Colormap
+ *
+ * Note that, even on less than 8 bit depth frame buffers, we
+ * expect the colormap to be programmable with 8 bit values.
+ * As of now, this is indeed the case on all OpenBSD supported
+ * graphics hardware.
+ */
if (!miCreateDefColormap(pScreen))
return FALSE;
flags = CMAP_RELOAD_ON_MODE_SWITCH;
ncolors = fPtr->info.cmsize;
- /* on StaticGray visuals, fake a 256 entries colormap */
+ /* On StaticGray visuals, fake a 256 entries colormap. */
if (ncolors == 0)
ncolors = 256;
if(!xf86HandleColormaps(pScreen, ncolors, 8, WsfbLoadPalette,
@@ -919,7 +926,7 @@ WsfbScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
}
#endif
- /* Wrap the current CloseScreen function */
+ /* Wrap the current CloseScreen function. */
fPtr->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = WsfbCloseScreen;
@@ -953,8 +960,9 @@ WsfbCloseScreen(int scrnIndex, ScreenPtr pScreen)
#endif
pScrn->vtSema = FALSE;
- /* unwrap CloseScreen */
+ /* Unwrap CloseScreen. */
pScreen->CloseScreen = fPtr->CloseScreen;
+ TRACE_EXIT("WsfbCloseScreen");
return (*pScreen->CloseScreen)(scrnIndex, pScreen);
}
@@ -1020,6 +1028,7 @@ WsfbEnterVT(int scrnIndex, int flags)
TRACE_ENTER("EnterVT");
pScrn->vtSema = TRUE;
+ TRACE_EXIT("EnterVT");
return TRUE;
}
@@ -1041,7 +1050,7 @@ WsfbSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
#endif
TRACE_ENTER("SwitchMode");
- /* Nothing else to do */
+ /* Nothing else to do. */
return TRUE;
}
@@ -1081,8 +1090,10 @@ WsfbLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
if (ioctl(fPtr->fd,WSDISPLAYIO_PUTCMAP, &cmap) == -1)
ErrorF("ioctl FBIOPUTCMAP: %s\n", strerror(errno));
} else {
- /* Change all colors in 2 syscalls */
- /* and limit the data to be transfered */
+ /*
+ * Change all colors in 2 ioctls
+ * and limit the data to be transfered.
+ */
for (i = 0; i < numColors; i++) {
if (indices[i] < indexMin)
indexMin = indices[i];
@@ -1094,16 +1105,16 @@ WsfbLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
cmap.red = &red[indexMin];
cmap.green = &green[indexMin];
cmap.blue = &blue[indexMin];
- /* Get current map */
+ /* Get current map. */
if (ioctl(fPtr->fd, WSDISPLAYIO_GETCMAP, &cmap) == -1)
ErrorF("ioctl FBIOGETCMAP: %s\n", strerror(errno));
- /* Change the colors that require updating */
+ /* Change the colors that require updating. */
for (i = 0; i < numColors; i++) {
red[indices[i]] = colors[indices[i]].red;
green[indices[i]] = colors[indices[i]].green;
blue[indices[i]] = colors[indices[i]].blue;
}
- /* Write the colormap back */
+ /* Write the colormap back. */
if (ioctl(fPtr->fd,WSDISPLAYIO_PUTCMAP, &cmap) == -1)
ErrorF("ioctl FBIOPUTCMAP: %s\n", strerror(errno));
}
@@ -1128,6 +1139,7 @@ WsfbSaveScreen(ScreenPtr pScreen, int mode)
ioctl(fPtr->fd,
WSDISPLAYIO_SVIDEO, &state);
}
+ TRACE_EXIT("SaveScreen");
return TRUE;
}
@@ -1149,6 +1161,7 @@ WsfbSave(ScrnInfoPtr pScrn)
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"error saving colormap %s\n", strerror(errno));
}
+ TRACE_EXIT("WsfbSave");
}
@@ -1170,10 +1183,10 @@ WsfbRestore(ScrnInfoPtr pScrn)
}
}
- /* Clear the screen */
+ /* Clear the screen. */
memset(fPtr->fbmem, 0, fPtr->fbmem_len);
- /* Restore the text mode */
+ /* Restore the text mode. */
mode = WSDISPLAYIO_MODE_EMUL;
if (ioctl(fPtr->fd, WSDISPLAYIO_SMODE, &mode) == -1) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,