diff options
author | marha <marha@users.sourceforge.net> | 2012-03-23 10:05:55 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-03-23 10:05:55 +0100 |
commit | 0f834b91a4768673833ab4917e87d86c237bb1a6 (patch) | |
tree | 363489504ed4b2d360259b8de4c9e392918e5d02 /xorg-server/hw/kdrive/fbdev/fbdev.c | |
parent | fc72edebf875378459368c5383d9023730cbca54 (diff) | |
download | vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.gz vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.bz2 vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.zip |
libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update
23 Mar 2012
Diffstat (limited to 'xorg-server/hw/kdrive/fbdev/fbdev.c')
-rw-r--r-- | xorg-server/hw/kdrive/fbdev/fbdev.c | 789 |
1 files changed, 376 insertions, 413 deletions
diff --git a/xorg-server/hw/kdrive/fbdev/fbdev.c b/xorg-server/hw/kdrive/fbdev/fbdev.c index 661e5b491..fd14afa92 100644 --- a/xorg-server/hw/kdrive/fbdev/fbdev.c +++ b/xorg-server/hw/kdrive/fbdev/fbdev.c @@ -33,46 +33,43 @@ extern int KdTsPhyScreen; char *fbdevDevicePath = NULL; static Bool -fbdevInitialize (KdCardInfo *card, FbdevPriv *priv) +fbdevInitialize(KdCardInfo * card, FbdevPriv * priv) { - unsigned long off; + unsigned long off; if (fbdevDevicePath == NULL) - fbdevDevicePath = "/dev/fb0"; + fbdevDevicePath = "/dev/fb0"; - if ((priv->fd = open(fbdevDevicePath, O_RDWR)) < 0) - { - ErrorF("Error opening framebuffer %s: %s\n", - fbdevDevicePath, strerror(errno)); + if ((priv->fd = open(fbdevDevicePath, O_RDWR)) < 0) { + ErrorF("Error opening framebuffer %s: %s\n", + fbdevDevicePath, strerror(errno)); return FALSE; - } + } /* quiet valgrind */ - memset (&priv->fix, '\0', sizeof (priv->fix)); + memset(&priv->fix, '\0', sizeof(priv->fix)); if (ioctl(priv->fd, FBIOGET_FSCREENINFO, &priv->fix) < 0) { - perror("Error with /dev/fb ioctl FIOGET_FSCREENINFO"); - close (priv->fd); - return FALSE; + perror("Error with /dev/fb ioctl FIOGET_FSCREENINFO"); + close(priv->fd); + return FALSE; } /* quiet valgrind */ - memset (&priv->var, '\0', sizeof (priv->var)); + memset(&priv->var, '\0', sizeof(priv->var)); if (ioctl(priv->fd, FBIOGET_VSCREENINFO, &priv->var) < 0) { - perror("Error with /dev/fb ioctl FIOGET_VSCREENINFO"); - close (priv->fd); - return FALSE; + perror("Error with /dev/fb ioctl FIOGET_VSCREENINFO"); + close(priv->fd); + return FALSE; } - priv->fb_base = (char *) mmap ((caddr_t) NULL, - priv->fix.smem_len, - PROT_READ|PROT_WRITE, - MAP_SHARED, - priv->fd, 0); + priv->fb_base = (char *) mmap((caddr_t) NULL, + priv->fix.smem_len, + PROT_READ | PROT_WRITE, + MAP_SHARED, priv->fd, 0); - if (priv->fb_base == (char *)-1) - { + if (priv->fb_base == (char *) -1) { perror("ERROR: mmap framebuffer fails!"); - close (priv->fd); - return FALSE; + close(priv->fd); + return FALSE; } off = (unsigned long) priv->fix.smem_start % (unsigned long) getpagesize(); priv->fb = priv->fb_base + off; @@ -80,18 +77,17 @@ fbdevInitialize (KdCardInfo *card, FbdevPriv *priv) } Bool -fbdevCardInit (KdCardInfo *card) +fbdevCardInit(KdCardInfo * card) { - FbdevPriv *priv; + FbdevPriv *priv; - priv = (FbdevPriv *) malloc(sizeof (FbdevPriv)); + priv = (FbdevPriv *) malloc(sizeof(FbdevPriv)); if (!priv) - return FALSE; + return FALSE; - if (!fbdevInitialize (card, priv)) - { - free(priv); - return FALSE; + if (!fbdevInitialize(card, priv)) { + free(priv); + return FALSE; } card->driver = priv; @@ -99,30 +95,29 @@ fbdevCardInit (KdCardInfo *card) } static Pixel -fbdevMakeContig (Pixel orig, Pixel others) +fbdevMakeContig(Pixel orig, Pixel others) { - Pixel low; + Pixel low; - low = lowbit (orig) >> 1; - while (low && (others & low) == 0) - { - orig |= low; - low >>= 1; + low = lowbit(orig) >> 1; + while (low && (others & low) == 0) { + orig |= low; + low >>= 1; } return orig; } static Bool -fbdevModeSupported (KdScreenInfo *screen, - const KdMonitorTiming *t) +fbdevModeSupported(KdScreenInfo * screen, const KdMonitorTiming * t) { return TRUE; } static void -fbdevConvertMonitorTiming (const KdMonitorTiming *t, struct fb_var_screeninfo *var) +fbdevConvertMonitorTiming(const KdMonitorTiming * t, + struct fb_var_screeninfo *var) { - memset (var, 0, sizeof (struct fb_var_screeninfo)); + memset(var, 0, sizeof(struct fb_var_screeninfo)); var->xres = t->horizontal; var->yres = t->vertical; @@ -142,56 +137,51 @@ fbdevConvertMonitorTiming (const KdMonitorTiming *t, struct fb_var_screeninfo *v var->vmode = 0; if (t->hpol == KdSyncPositive) - var->sync |= FB_SYNC_HOR_HIGH_ACT; + var->sync |= FB_SYNC_HOR_HIGH_ACT; if (t->vpol == KdSyncPositive) - var->sync |= FB_SYNC_VERT_HIGH_ACT; + var->sync |= FB_SYNC_VERT_HIGH_ACT; } static Bool -fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv) +fbdevScreenInitialize(KdScreenInfo * screen, FbdevScrPriv * scrpriv) { - FbdevPriv *priv = screen->card->driver; - Pixel allbits; - int depth; - Bool gray; + FbdevPriv *priv = screen->card->driver; + Pixel allbits; + int depth; + Bool gray; struct fb_var_screeninfo var; const KdMonitorTiming *t; int k; - k = ioctl (priv->fd, FBIOGET_VSCREENINFO, &var); - - if (!screen->width || !screen->height) - { - if (k >= 0) - { - screen->width = var.xres; - screen->height = var.yres; - } - else - { - screen->width = 1024; - screen->height = 768; - } - screen->rate = 103; /* FIXME: should get proper value from fb driver */ + k = ioctl(priv->fd, FBIOGET_VSCREENINFO, &var); + + if (!screen->width || !screen->height) { + if (k >= 0) { + screen->width = var.xres; + screen->height = var.yres; + } + else { + screen->width = 1024; + screen->height = 768; + } + screen->rate = 103; /* FIXME: should get proper value from fb driver */ } - if (!screen->fb.depth) - { - if (k >= 0) - screen->fb.depth = var.bits_per_pixel; - else - screen->fb.depth = 16; + if (!screen->fb.depth) { + if (k >= 0) + screen->fb.depth = var.bits_per_pixel; + else + screen->fb.depth = 16; } - if ((screen->width != var.xres) || (screen->height != var.yres)) - { - t = KdFindMode (screen, fbdevModeSupported); - screen->rate = t->rate; - screen->width = t->horizontal; - screen->height = t->vertical; + if ((screen->width != var.xres) || (screen->height != var.yres)) { + t = KdFindMode(screen, fbdevModeSupported); + screen->rate = t->rate; + screen->width = t->horizontal; + screen->height = t->vertical; - /* Now try setting the mode */ - if (k < 0 || (t->horizontal != var.xres || t->vertical != var.yres)) - fbdevConvertMonitorTiming (t, &var); + /* Now try setting the mode */ + if (k < 0 || (t->horizontal != var.xres || t->vertical != var.yres)) + fbdevConvertMonitorTiming(t, &var); } var.activate = FB_ACTIVATE_NOW; @@ -199,163 +189,154 @@ fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv) var.nonstd = 0; var.grayscale = 0; - k = ioctl (priv->fd, FBIOPUT_VSCREENINFO, &var); + k = ioctl(priv->fd, FBIOPUT_VSCREENINFO, &var); - if (k < 0) - { - fprintf (stderr, "error: %s\n", strerror (errno)); - return FALSE; + if (k < 0) { + fprintf(stderr, "error: %s\n", strerror(errno)); + return FALSE; } /* Re-get the "fixed" parameters since they might have changed */ - k = ioctl (priv->fd, FBIOGET_FSCREENINFO, &priv->fix); + k = ioctl(priv->fd, FBIOGET_FSCREENINFO, &priv->fix); if (k < 0) - perror ("FBIOGET_FSCREENINFO"); + perror("FBIOGET_FSCREENINFO"); /* Now get the new screeninfo */ - ioctl (priv->fd, FBIOGET_VSCREENINFO, &priv->var); + ioctl(priv->fd, FBIOGET_VSCREENINFO, &priv->var); depth = priv->var.bits_per_pixel; gray = priv->var.grayscale; switch (priv->fix.visual) { case FB_VISUAL_PSEUDOCOLOR: - if (gray) - { - screen->fb.visuals = (1 << StaticGray); - /* could also support GrayScale, but what's the point? */ - } - else - { - screen->fb.visuals = ((1 << StaticGray) | - (1 << GrayScale) | - (1 << StaticColor) | - (1 << PseudoColor) | - (1 << TrueColor) | - (1 << DirectColor)); - } - screen->fb.blueMask = 0x00; - screen->fb.greenMask = 0x00; - screen->fb.redMask = 0x00; - break; + if (gray) { + screen->fb.visuals = (1 << StaticGray); + /* could also support GrayScale, but what's the point? */ + } + else { + screen->fb.visuals = ((1 << StaticGray) | + (1 << GrayScale) | + (1 << StaticColor) | + (1 << PseudoColor) | + (1 << TrueColor) | (1 << DirectColor)); + } + screen->fb.blueMask = 0x00; + screen->fb.greenMask = 0x00; + screen->fb.redMask = 0x00; + break; case FB_VISUAL_STATIC_PSEUDOCOLOR: - if (gray) - { - screen->fb.visuals = (1 << StaticGray); - } - else - { - screen->fb.visuals = (1 << StaticColor); - } - screen->fb.blueMask = 0x00; - screen->fb.greenMask = 0x00; - screen->fb.redMask = 0x00; - break; + if (gray) { + screen->fb.visuals = (1 << StaticGray); + } + else { + screen->fb.visuals = (1 << StaticColor); + } + screen->fb.blueMask = 0x00; + screen->fb.greenMask = 0x00; + screen->fb.redMask = 0x00; + break; case FB_VISUAL_TRUECOLOR: case FB_VISUAL_DIRECTCOLOR: - screen->fb.visuals = (1 << TrueColor); + screen->fb.visuals = (1 << TrueColor); #define Mask(o,l) (((1 << l) - 1) << o) - screen->fb.redMask = Mask (priv->var.red.offset, priv->var.red.length); - screen->fb.greenMask = Mask (priv->var.green.offset, priv->var.green.length); - screen->fb.blueMask = Mask (priv->var.blue.offset, priv->var.blue.length); - - /* - * This is a kludge so that Render will work -- fill in the gaps - * in the pixel - */ - screen->fb.redMask = fbdevMakeContig (screen->fb.redMask, - screen->fb.greenMask| - screen->fb.blueMask); - - screen->fb.greenMask = fbdevMakeContig (screen->fb.greenMask, - screen->fb.redMask| - screen->fb.blueMask); - - screen->fb.blueMask = fbdevMakeContig (screen->fb.blueMask, - screen->fb.redMask| - screen->fb.greenMask); - - allbits = screen->fb.redMask | screen->fb.greenMask | screen->fb.blueMask; - depth = 32; - while (depth && !(allbits & (1 << (depth - 1)))) - depth--; - break; + screen->fb.redMask = Mask (priv->var.red.offset, priv->var.red.length); + screen->fb.greenMask = + Mask (priv->var.green.offset, priv->var.green.length); + screen->fb.blueMask = + Mask (priv->var.blue.offset, priv->var.blue.length); + + /* + * This is a kludge so that Render will work -- fill in the gaps + * in the pixel + */ + screen->fb.redMask = fbdevMakeContig(screen->fb.redMask, + screen->fb.greenMask | + screen->fb.blueMask); + + screen->fb.greenMask = fbdevMakeContig(screen->fb.greenMask, + screen->fb.redMask | + screen->fb.blueMask); + + screen->fb.blueMask = fbdevMakeContig(screen->fb.blueMask, + screen->fb.redMask | + screen->fb.greenMask); + + allbits = + screen->fb.redMask | screen->fb.greenMask | screen->fb.blueMask; + depth = 32; + while (depth && !(allbits & (1 << (depth - 1)))) + depth--; + break; default: - return FALSE; - break; + return FALSE; + break; } screen->fb.depth = depth; screen->fb.bitsPerPixel = priv->var.bits_per_pixel; scrpriv->randr = screen->randr; - return fbdevMapFramebuffer (screen); + return fbdevMapFramebuffer(screen); } Bool -fbdevScreenInit (KdScreenInfo *screen) +fbdevScreenInit(KdScreenInfo * screen) { FbdevScrPriv *scrpriv; - scrpriv = calloc(1, sizeof (FbdevScrPriv)); + scrpriv = calloc(1, sizeof(FbdevScrPriv)); if (!scrpriv) - return FALSE; + return FALSE; screen->driver = scrpriv; - if (!fbdevScreenInitialize (screen, scrpriv)) - { - screen->driver = 0; - free(scrpriv); - return FALSE; + if (!fbdevScreenInitialize(screen, scrpriv)) { + screen->driver = 0; + free(scrpriv); + return FALSE; } return TRUE; } static void * -fbdevWindowLinear (ScreenPtr pScreen, - CARD32 row, - CARD32 offset, - int mode, - CARD32 *size, - void *closure) +fbdevWindowLinear(ScreenPtr pScreen, + CARD32 row, + CARD32 offset, int mode, CARD32 *size, void *closure) { KdScreenPriv(pScreen); - FbdevPriv *priv = pScreenPriv->card->driver; + FbdevPriv *priv = pScreenPriv->card->driver; if (!pScreenPriv->enabled) - return 0; + return 0; *size = priv->fix.line_length; return (CARD8 *) priv->fb + row * priv->fix.line_length + offset; } Bool -fbdevMapFramebuffer (KdScreenInfo *screen) +fbdevMapFramebuffer(KdScreenInfo * screen) { - FbdevScrPriv *scrpriv = screen->driver; - KdPointerMatrix m; - FbdevPriv *priv = screen->card->driver; + FbdevScrPriv *scrpriv = screen->driver; + KdPointerMatrix m; + FbdevPriv *priv = screen->card->driver; if (scrpriv->randr != RR_Rotate_0) - scrpriv->shadow = TRUE; + scrpriv->shadow = TRUE; else - scrpriv->shadow = FALSE; + scrpriv->shadow = FALSE; - KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height); + KdComputePointerMatrix(&m, scrpriv->randr, screen->width, screen->height); - KdSetPointerMatrix (&m); + KdSetPointerMatrix(&m); screen->width = priv->var.xres; screen->height = priv->var.yres; - if (scrpriv->shadow) - { - if (!KdShadowFbAlloc (screen, - scrpriv->randr & (RR_Rotate_90|RR_Rotate_270))) - return FALSE; + if (scrpriv->shadow) { + if (!KdShadowFbAlloc(screen, + scrpriv->randr & (RR_Rotate_90 | RR_Rotate_270))) + return FALSE; } - else - { + else { screen->fb.byteStride = priv->fix.line_length; screen->fb.pixelStride = (priv->fix.line_length * 8 / - priv->var.bits_per_pixel); + priv->var.bits_per_pixel); screen->fb.frameBuffer = (CARD8 *) (priv->fb); } @@ -363,46 +344,44 @@ fbdevMapFramebuffer (KdScreenInfo *screen) } static void -fbdevSetScreenSizes (ScreenPtr pScreen) +fbdevSetScreenSizes(ScreenPtr pScreen) { KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - FbdevScrPriv *scrpriv = screen->driver; - FbdevPriv *priv = screen->card->driver; - - if (scrpriv->randr & (RR_Rotate_0|RR_Rotate_180)) - { - pScreen->width = priv->var.xres; - pScreen->height = priv->var.yres; - pScreen->mmWidth = screen->width_mm; - pScreen->mmHeight = screen->height_mm; + KdScreenInfo *screen = pScreenPriv->screen; + FbdevScrPriv *scrpriv = screen->driver; + FbdevPriv *priv = screen->card->driver; + + if (scrpriv->randr & (RR_Rotate_0 | RR_Rotate_180)) { + pScreen->width = priv->var.xres; + pScreen->height = priv->var.yres; + pScreen->mmWidth = screen->width_mm; + pScreen->mmHeight = screen->height_mm; } - else - { - pScreen->width = priv->var.yres; - pScreen->height = priv->var.xres; - pScreen->mmWidth = screen->height_mm; - pScreen->mmHeight = screen->width_mm; + else { + pScreen->width = priv->var.yres; + pScreen->height = priv->var.xres; + pScreen->mmWidth = screen->height_mm; + pScreen->mmHeight = screen->width_mm; } } static Bool -fbdevUnmapFramebuffer (KdScreenInfo *screen) +fbdevUnmapFramebuffer(KdScreenInfo * screen) { - KdShadowFbFree (screen); + KdShadowFbFree(screen); return TRUE; } static Bool -fbdevSetShadow (ScreenPtr pScreen) +fbdevSetShadow(ScreenPtr pScreen) { KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - FbdevScrPriv *scrpriv = screen->driver; - FbdevPriv *priv = screen->card->driver; - ShadowUpdateProc update; - ShadowWindowProc window; - int useYX = 0; + KdScreenInfo *screen = pScreenPriv->screen; + FbdevScrPriv *scrpriv = screen->driver; + FbdevPriv *priv = screen->card->driver; + ShadowUpdateProc update; + ShadowWindowProc window; + int useYX = 0; #ifdef __arm__ /* Use variant copy routines that always read left to right in the @@ -414,97 +393,91 @@ fbdevSetShadow (ScreenPtr pScreen) window = fbdevWindowLinear; update = 0; if (scrpriv->randr) - if (priv->var.bits_per_pixel == 16) { - switch (scrpriv->randr) { - case RR_Rotate_90: - if (useYX) - update = shadowUpdateRotate16_90YX; - else - update = shadowUpdateRotate16_90; - break; - case RR_Rotate_180: - update = shadowUpdateRotate16_180; - break; - case RR_Rotate_270: - if (useYX) - update = shadowUpdateRotate16_270YX; - else - update = shadowUpdateRotate16_270; - break; - default: - update = shadowUpdateRotate16; - break; - } - } else - update = shadowUpdateRotatePacked; + if (priv->var.bits_per_pixel == 16) { + switch (scrpriv->randr) { + case RR_Rotate_90: + if (useYX) + update = shadowUpdateRotate16_90YX; + else + update = shadowUpdateRotate16_90; + break; + case RR_Rotate_180: + update = shadowUpdateRotate16_180; + break; + case RR_Rotate_270: + if (useYX) + update = shadowUpdateRotate16_270YX; + else + update = shadowUpdateRotate16_270; + break; + default: + update = shadowUpdateRotate16; + break; + } + } + else + update = shadowUpdateRotatePacked; else - update = shadowUpdatePacked; - return KdShadowSet (pScreen, scrpriv->randr, update, window); + update = shadowUpdatePacked; + return KdShadowSet(pScreen, scrpriv->randr, update, window); } - #ifdef RANDR static Bool -fbdevRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) +fbdevRandRGetInfo(ScreenPtr pScreen, Rotation * rotations) { KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - FbdevScrPriv *scrpriv = screen->driver; - RRScreenSizePtr pSize; - Rotation randr; - int n; + KdScreenInfo *screen = pScreenPriv->screen; + FbdevScrPriv *scrpriv = screen->driver; + RRScreenSizePtr pSize; + Rotation randr; + int n; - *rotations = RR_Rotate_All|RR_Reflect_All; + *rotations = RR_Rotate_All | RR_Reflect_All; for (n = 0; n < pScreen->numDepths; n++) - if (pScreen->allowedDepths[n].numVids) - break; + if (pScreen->allowedDepths[n].numVids) + break; if (n == pScreen->numDepths) - return FALSE; + return FALSE; - pSize = RRRegisterSize (pScreen, - screen->width, - screen->height, - screen->width_mm, - screen->height_mm); + pSize = RRRegisterSize(pScreen, + screen->width, + screen->height, screen->width_mm, screen->height_mm); - randr = KdSubRotation (scrpriv->randr, screen->randr); + randr = KdSubRotation(scrpriv->randr, screen->randr); - RRSetCurrentConfig (pScreen, randr, 0, pSize); + RRSetCurrentConfig(pScreen, randr, 0, pSize); return TRUE; } static Bool -fbdevRandRSetConfig (ScreenPtr pScreen, - Rotation randr, - int rate, - RRScreenSizePtr pSize) +fbdevRandRSetConfig(ScreenPtr pScreen, + Rotation randr, int rate, RRScreenSizePtr pSize) { KdScreenPriv(pScreen); - KdScreenInfo *screen = pScreenPriv->screen; - FbdevScrPriv *scrpriv = screen->driver; - Bool wasEnabled = pScreenPriv->enabled; - FbdevScrPriv oldscr; - int oldwidth; - int oldheight; - int oldmmwidth; - int oldmmheight; - int newwidth, newheight; - - if (screen->randr & (RR_Rotate_0|RR_Rotate_180)) - { - newwidth = pSize->width; - newheight = pSize->height; + KdScreenInfo *screen = pScreenPriv->screen; + FbdevScrPriv *scrpriv = screen->driver; + Bool wasEnabled = pScreenPriv->enabled; + FbdevScrPriv oldscr; + int oldwidth; + int oldheight; + int oldmmwidth; + int oldmmheight; + int newwidth, newheight; + + if (screen->randr & (RR_Rotate_0 | RR_Rotate_180)) { + newwidth = pSize->width; + newheight = pSize->height; } - else - { - newwidth = pSize->height; - newheight = pSize->width; + else { + newwidth = pSize->height; + newheight = pSize->width; } if (wasEnabled) - KdDisableScreen (pScreen); + KdDisableScreen(pScreen); oldscr = *scrpriv; @@ -517,60 +490,60 @@ fbdevRandRSetConfig (ScreenPtr pScreen, * Set new configuration */ - scrpriv->randr = KdAddRotation (screen->randr, randr); + scrpriv->randr = KdAddRotation(screen->randr, randr); - fbdevUnmapFramebuffer (screen); + fbdevUnmapFramebuffer(screen); - if (!fbdevMapFramebuffer (screen)) - goto bail4; + if (!fbdevMapFramebuffer(screen)) + goto bail4; - KdShadowUnset (screen->pScreen); + KdShadowUnset(screen->pScreen); - if (!fbdevSetShadow (screen->pScreen)) - goto bail4; + if (!fbdevSetShadow(screen->pScreen)) + goto bail4; - fbdevSetScreenSizes (screen->pScreen); + fbdevSetScreenSizes(screen->pScreen); /* * Set frame buffer mapping */ - (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen), - pScreen->width, - pScreen->height, - screen->fb.depth, - screen->fb.bitsPerPixel, - screen->fb.byteStride, - screen->fb.frameBuffer); + (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap(pScreen), + pScreen->width, + pScreen->height, + screen->fb.depth, + screen->fb.bitsPerPixel, + screen->fb.byteStride, + screen->fb.frameBuffer); /* set the subpixel order */ - KdSetSubpixelOrder (pScreen, scrpriv->randr); + KdSetSubpixelOrder(pScreen, scrpriv->randr); if (wasEnabled) - KdEnableScreen (pScreen); + KdEnableScreen(pScreen); return TRUE; -bail4: - fbdevUnmapFramebuffer (screen); + bail4: + fbdevUnmapFramebuffer(screen); *scrpriv = oldscr; - (void) fbdevMapFramebuffer (screen); + (void) fbdevMapFramebuffer(screen); pScreen->width = oldwidth; pScreen->height = oldheight; pScreen->mmWidth = oldmmwidth; pScreen->mmHeight = oldmmheight; if (wasEnabled) - KdEnableScreen (pScreen); + KdEnableScreen(pScreen); return FALSE; } static Bool -fbdevRandRInit (ScreenPtr pScreen) +fbdevRandRInit(ScreenPtr pScreen) { - rrScrPrivPtr pScrPriv; + rrScrPrivPtr pScrPriv; - if (!RRScreenInit (pScreen)) - return FALSE; + if (!RRScreenInit(pScreen)) + return FALSE; pScrPriv = rrGetScrPriv(pScreen); pScrPriv->rrGetInfo = fbdevRandRGetInfo; @@ -580,41 +553,41 @@ fbdevRandRInit (ScreenPtr pScreen) #endif static Bool -fbdevCreateColormap (ColormapPtr pmap) +fbdevCreateColormap(ColormapPtr pmap) { - ScreenPtr pScreen = pmap->pScreen; + ScreenPtr pScreen = pmap->pScreen; + KdScreenPriv(pScreen); - FbdevPriv *priv = pScreenPriv->card->driver; - VisualPtr pVisual; - int i; - int nent; - xColorItem *pdefs; + FbdevPriv *priv = pScreenPriv->card->driver; + VisualPtr pVisual; + int i; + int nent; + xColorItem *pdefs; switch (priv->fix.visual) { case FB_VISUAL_STATIC_PSEUDOCOLOR: - pVisual = pmap->pVisual; - nent = pVisual->ColormapEntries; - pdefs = malloc(nent * sizeof (xColorItem)); - if (!pdefs) - return FALSE; - for (i = 0; i < nent; i++) - pdefs[i].pixel = i; - fbdevGetColors (pScreen, nent, pdefs); - for (i = 0; i < nent; i++) - { - pmap->red[i].co.local.red = pdefs[i].red; - pmap->red[i].co.local.green = pdefs[i].green; - pmap->red[i].co.local.blue = pdefs[i].blue; - } - free(pdefs); - return TRUE; + pVisual = pmap->pVisual; + nent = pVisual->ColormapEntries; + pdefs = malloc(nent * sizeof(xColorItem)); + if (!pdefs) + return FALSE; + for (i = 0; i < nent; i++) + pdefs[i].pixel = i; + fbdevGetColors(pScreen, nent, pdefs); + for (i = 0; i < nent; i++) { + pmap->red[i].co.local.red = pdefs[i].red; + pmap->red[i].co.local.green = pdefs[i].green; + pmap->red[i].co.local.blue = pdefs[i].blue; + } + free(pdefs); + return TRUE; default: - return fbInitializeColormap (pmap); + return fbInitializeColormap(pmap); } } Bool -fbdevInitScreen (ScreenPtr pScreen) +fbdevInitScreen(ScreenPtr pScreen) { #ifdef TOUCHSCREEN KdTsPhyScreen = pScreen->myNum; @@ -625,33 +598,32 @@ fbdevInitScreen (ScreenPtr pScreen) } Bool -fbdevFinishInitScreen (ScreenPtr pScreen) +fbdevFinishInitScreen(ScreenPtr pScreen) { - if (!shadowSetup (pScreen)) - return FALSE; + if (!shadowSetup(pScreen)) + return FALSE; #ifdef RANDR - if (!fbdevRandRInit (pScreen)) - return FALSE; + if (!fbdevRandRInit(pScreen)) + return FALSE; #endif return TRUE; } - Bool -fbdevCreateResources (ScreenPtr pScreen) +fbdevCreateResources(ScreenPtr pScreen) { - return fbdevSetShadow (pScreen); + return fbdevSetShadow(pScreen); } void -fbdevPreserve (KdCardInfo *card) +fbdevPreserve(KdCardInfo * card) { } static int -fbdevUpdateFbColormap(FbdevPriv *priv, int minidx, int maxidx) +fbdevUpdateFbColormap(FbdevPriv * priv, int minidx, int maxidx) { struct fb_cmap cmap; @@ -666,89 +638,84 @@ fbdevUpdateFbColormap(FbdevPriv *priv, int minidx, int maxidx) } Bool -fbdevEnable (ScreenPtr pScreen) +fbdevEnable(ScreenPtr pScreen) { KdScreenPriv(pScreen); - FbdevPriv *priv = pScreenPriv->card->driver; - int k; + FbdevPriv *priv = pScreenPriv->card->driver; + int k; - priv->var.activate = FB_ACTIVATE_NOW|FB_CHANGE_CMAP_VBL; + priv->var.activate = FB_ACTIVATE_NOW | FB_CHANGE_CMAP_VBL; /* display it on the LCD */ - k = ioctl (priv->fd, FBIOPUT_VSCREENINFO, &priv->var); - if (k < 0) - { - perror ("FBIOPUT_VSCREENINFO"); - return FALSE; + k = ioctl(priv->fd, FBIOPUT_VSCREENINFO, &priv->var); + if (k < 0) { + perror("FBIOPUT_VSCREENINFO"); + return FALSE; } - if (priv->fix.visual == FB_VISUAL_DIRECTCOLOR) - { - int i; - - for (i = 0; - i < (1 << priv->var.red.length) || - i < (1 << priv->var.green.length) || - i < (1 << priv->var.blue.length); i++) - { - priv->red[i] = i * 65535 / ((1 << priv->var.red.length) - 1); - priv->green[i] = i * 65535 / ((1 << priv->var.green.length) - 1); - priv->blue[i] = i * 65535 / ((1 << priv->var.blue.length) - 1); - } - - fbdevUpdateFbColormap(priv, 0, i); + if (priv->fix.visual == FB_VISUAL_DIRECTCOLOR) { + int i; + + for (i = 0; + i < (1 << priv->var.red.length) || + i < (1 << priv->var.green.length) || + i < (1 << priv->var.blue.length); i++) { + priv->red[i] = i * 65535 / ((1 << priv->var.red.length) - 1); + priv->green[i] = i * 65535 / ((1 << priv->var.green.length) - 1); + priv->blue[i] = i * 65535 / ((1 << priv->var.blue.length) - 1); + } + + fbdevUpdateFbColormap(priv, 0, i); } return TRUE; } Bool -fbdevDPMS (ScreenPtr pScreen, int mode) +fbdevDPMS(ScreenPtr pScreen, int mode) { KdScreenPriv(pScreen); - FbdevPriv *priv = pScreenPriv->card->driver; + FbdevPriv *priv = pScreenPriv->card->driver; static int oldmode = -1; if (mode == oldmode) - return TRUE; + return TRUE; #ifdef FBIOPUT_POWERMODE - if (ioctl (priv->fd, FBIOPUT_POWERMODE, &mode) >= 0) - { - oldmode = mode; - return TRUE; + if (ioctl(priv->fd, FBIOPUT_POWERMODE, &mode) >= 0) { + oldmode = mode; + return TRUE; } #endif #ifdef FBIOBLANK - if (ioctl (priv->fd, FBIOBLANK, mode ? mode + 1 : 0) >= 0) - { - oldmode = mode; - return TRUE; + if (ioctl(priv->fd, FBIOBLANK, mode ? mode + 1 : 0) >= 0) { + oldmode = mode; + return TRUE; } #endif return FALSE; } void -fbdevDisable (ScreenPtr pScreen) +fbdevDisable(ScreenPtr pScreen) { } void -fbdevRestore (KdCardInfo *card) +fbdevRestore(KdCardInfo * card) { } void -fbdevScreenFini (KdScreenInfo *screen) +fbdevScreenFini(KdScreenInfo * screen) { } void -fbdevCardFini (KdCardInfo *card) +fbdevCardFini(KdCardInfo * card) { - FbdevPriv *priv = card->driver; + FbdevPriv *priv = card->driver; - munmap (priv->fb_base, priv->fix.smem_len); - close (priv->fd); + munmap(priv->fb_base, priv->fix.smem_len); + close(priv->fd); free(priv); } @@ -756,23 +723,22 @@ fbdevCardFini (KdCardInfo *card) * Retrieve actual colormap and return selected n entries in pdefs. */ void -fbdevGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs) +fbdevGetColors(ScreenPtr pScreen, int n, xColorItem * pdefs) { KdScreenPriv(pScreen); - FbdevPriv *priv = pScreenPriv->card->driver; - struct fb_cmap cmap; - int p; - int k; - int min, max; + FbdevPriv *priv = pScreenPriv->card->driver; + struct fb_cmap cmap; + int p; + int k; + int min, max; min = 256; max = 0; - for (k = 0; k < n; k++) - { - if (pdefs[k].pixel < min) - min = pdefs[k].pixel; - if (pdefs[k].pixel > max) - max = pdefs[k].pixel; + for (k = 0; k < n; k++) { + if (pdefs[k].pixel < min) + min = pdefs[k].pixel; + if (pdefs[k].pixel > max) + max = pdefs[k].pixel; } cmap.start = min; cmap.len = max - min + 1; @@ -780,19 +746,17 @@ fbdevGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs) cmap.green = &priv->green[min]; cmap.blue = &priv->blue[min]; cmap.transp = 0; - k = ioctl (priv->fd, FBIOGETCMAP, &cmap); - if (k < 0) - { - perror ("can't get colormap"); - return; + k = ioctl(priv->fd, FBIOGETCMAP, &cmap); + if (k < 0) { + perror("can't get colormap"); + return; } - while (n--) - { - p = pdefs->pixel; - pdefs->red = priv->red[p]; - pdefs->green = priv->green[p]; - pdefs->blue = priv->blue[p]; - pdefs++; + while (n--) { + p = pdefs->pixel; + pdefs->red = priv->red[p]; + pdefs->green = priv->green[p]; + pdefs->blue = priv->blue[p]; + pdefs++; } } @@ -800,26 +764,25 @@ fbdevGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs) * Change colormap by updating n entries described in pdefs. */ void -fbdevPutColors (ScreenPtr pScreen, int n, xColorItem *pdefs) +fbdevPutColors(ScreenPtr pScreen, int n, xColorItem * pdefs) { KdScreenPriv(pScreen); - FbdevPriv *priv = pScreenPriv->card->driver; - int p; - int min, max; + FbdevPriv *priv = pScreenPriv->card->driver; + int p; + int min, max; min = 256; max = 0; - while (n--) - { - p = pdefs->pixel; - priv->red[p] = pdefs->red; - priv->green[p] = pdefs->green; - priv->blue[p] = pdefs->blue; - if (p < min) - min = p; - if (p > max) - max = p; - pdefs++; + while (n--) { + p = pdefs->pixel; + priv->red[p] = pdefs->red; + priv->green[p] = pdefs->green; + priv->blue[p] = pdefs->blue; + if (p < min) + min = p; + if (p > max) + max = p; + pdefs++; } fbdevUpdateFbColormap(priv, min, max); |