diff options
Diffstat (limited to 'xorg-server/hw/kdrive/fbdev')
-rw-r--r-- | xorg-server/hw/kdrive/fbdev/fbdev.c | 228 | ||||
-rw-r--r-- | xorg-server/hw/kdrive/fbdev/fbdev.h | 44 | ||||
-rw-r--r-- | xorg-server/hw/kdrive/fbdev/fbinit.c | 14 |
3 files changed, 124 insertions, 162 deletions
diff --git a/xorg-server/hw/kdrive/fbdev/fbdev.c b/xorg-server/hw/kdrive/fbdev/fbdev.c index 4eeca289a..d4604ad29 100644 --- a/xorg-server/hw/kdrive/fbdev/fbdev.c +++ b/xorg-server/hw/kdrive/fbdev/fbdev.c @@ -32,32 +32,31 @@ extern int KdTsPhyScreen; char *fbdevDevicePath = NULL; -Bool +static Bool fbdevInitialize (KdCardInfo *card, FbdevPriv *priv) { - int k; unsigned long off; - if (fbdevDevicePath == NULL) + if (fbdevDevicePath == NULL) fbdevDevicePath = "/dev/fb0"; if ((priv->fd = open(fbdevDevicePath, O_RDWR)) < 0) { - ErrorF("Error opening framebuffer %s: %s\n", + ErrorF("Error opening framebuffer %s: %s\n", fbdevDevicePath, strerror(errno)); return FALSE; } /* quiet valgrind */ memset (&priv->fix, '\0', sizeof (priv->fix)); - if ((k=ioctl(priv->fd, FBIOGET_FSCREENINFO, &priv->fix)) < 0) { + if (ioctl(priv->fd, FBIOGET_FSCREENINFO, &priv->fix) < 0) { perror("Error with /dev/fb ioctl FIOGET_FSCREENINFO"); close (priv->fd); return FALSE; } /* quiet valgrind */ memset (&priv->var, '\0', sizeof (priv->var)); - if ((k=ioctl(priv->fd, FBIOGET_VSCREENINFO, &priv->var)) < 0) { + if (ioctl(priv->fd, FBIOGET_VSCREENINFO, &priv->var) < 0) { perror("Error with /dev/fb ioctl FIOGET_VSCREENINFO"); close (priv->fd); return FALSE; @@ -68,8 +67,8 @@ fbdevInitialize (KdCardInfo *card, FbdevPriv *priv) 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); @@ -88,14 +87,14 @@ fbdevCardInit (KdCardInfo *card) priv = (FbdevPriv *) xalloc (sizeof (FbdevPriv)); if (!priv) return FALSE; - + if (!fbdevInitialize (card, priv)) { xfree (priv); return FALSE; } card->driver = priv; - + return TRUE; } @@ -124,7 +123,7 @@ static void fbdevConvertMonitorTiming (const KdMonitorTiming *t, struct fb_var_screeninfo *var) { memset (var, 0, sizeof (struct fb_var_screeninfo)); - + var->xres = t->horizontal; var->yres = t->vertical; var->xres_virtual = t->horizontal; @@ -148,7 +147,7 @@ fbdevConvertMonitorTiming (const KdMonitorTiming *t, struct fb_var_screeninfo *v var->sync |= FB_SYNC_VERT_HIGH_ACT; } -Bool +static Bool fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv) { FbdevPriv *priv = screen->card->driver; @@ -160,10 +159,10 @@ fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv) int k; k = ioctl (priv->fd, FBIOGET_VSCREENINFO, &var); - + if (!screen->width || !screen->height) { - if (k >= 0) + if (k >= 0) { screen->width = var.xres; screen->height = var.yres; @@ -175,12 +174,12 @@ fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv) } screen->rate = 103; /* FIXME: should get proper value from fb driver */ } - if (!screen->fb[0].depth) + if (!screen->fb.depth) { - if (k >= 0) - screen->fb[0].depth = var.bits_per_pixel; + if (k >= 0) + screen->fb.depth = var.bits_per_pixel; else - screen->fb[0].depth = 16; + screen->fb.depth = 16; } if ((screen->width != var.xres) || (screen->height != var.yres)) @@ -196,7 +195,7 @@ fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv) } var.activate = FB_ACTIVATE_NOW; - var.bits_per_pixel = screen->fb[0].depth; + var.bits_per_pixel = screen->fb.depth; var.nonstd = 0; var.grayscale = 0; @@ -217,65 +216,65 @@ fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv) 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[0].visuals = (1 << StaticGray); + screen->fb.visuals = (1 << StaticGray); /* could also support GrayScale, but what's the point? */ } else { - screen->fb[0].visuals = ((1 << StaticGray) | + screen->fb.visuals = ((1 << StaticGray) | (1 << GrayScale) | (1 << StaticColor) | (1 << PseudoColor) | (1 << TrueColor) | (1 << DirectColor)); } - screen->fb[0].blueMask = 0x00; - screen->fb[0].greenMask = 0x00; - screen->fb[0].redMask = 0x00; + screen->fb.blueMask = 0x00; + screen->fb.greenMask = 0x00; + screen->fb.redMask = 0x00; break; case FB_VISUAL_STATIC_PSEUDOCOLOR: if (gray) { - screen->fb[0].visuals = (1 << StaticGray); + screen->fb.visuals = (1 << StaticGray); } else { - screen->fb[0].visuals = (1 << StaticColor); + screen->fb.visuals = (1 << StaticColor); } - screen->fb[0].blueMask = 0x00; - screen->fb[0].greenMask = 0x00; - screen->fb[0].redMask = 0x00; + screen->fb.blueMask = 0x00; + screen->fb.greenMask = 0x00; + screen->fb.redMask = 0x00; break; case FB_VISUAL_TRUECOLOR: case FB_VISUAL_DIRECTCOLOR: - screen->fb[0].visuals = (1 << TrueColor); + screen->fb.visuals = (1 << TrueColor); #define Mask(o,l) (((1 << l) - 1) << o) - screen->fb[0].redMask = Mask (priv->var.red.offset, priv->var.red.length); - screen->fb[0].greenMask = Mask (priv->var.green.offset, priv->var.green.length); - screen->fb[0].blueMask = Mask (priv->var.blue.offset, priv->var.blue.length); + 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[0].redMask = fbdevMakeContig (screen->fb[0].redMask, - screen->fb[0].greenMask| - screen->fb[0].blueMask); + screen->fb.redMask = fbdevMakeContig (screen->fb.redMask, + screen->fb.greenMask| + screen->fb.blueMask); - screen->fb[0].greenMask = fbdevMakeContig (screen->fb[0].greenMask, - screen->fb[0].redMask| - screen->fb[0].blueMask); + screen->fb.greenMask = fbdevMakeContig (screen->fb.greenMask, + screen->fb.redMask| + screen->fb.blueMask); - screen->fb[0].blueMask = fbdevMakeContig (screen->fb[0].blueMask, - screen->fb[0].redMask| - screen->fb[0].greenMask); + screen->fb.blueMask = fbdevMakeContig (screen->fb.blueMask, + screen->fb.redMask| + screen->fb.greenMask); - allbits = screen->fb[0].redMask | screen->fb[0].greenMask | screen->fb[0].blueMask; + allbits = screen->fb.redMask | screen->fb.greenMask | screen->fb.blueMask; depth = 32; while (depth && !(allbits & (1 << (depth - 1)))) depth--; @@ -284,8 +283,8 @@ fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv) return FALSE; break; } - screen->fb[0].depth = depth; - screen->fb[0].bitsPerPixel = priv->var.bits_per_pixel; + screen->fb.depth = depth; + screen->fb.bitsPerPixel = priv->var.bits_per_pixel; scrpriv->randr = screen->randr; @@ -309,8 +308,8 @@ fbdevScreenInit (KdScreenInfo *screen) } return TRUE; } - -void * + +static void * fbdevWindowLinear (ScreenPtr pScreen, CARD32 row, CARD32 offset, @@ -338,36 +337,32 @@ fbdevMapFramebuffer (KdScreenInfo *screen) scrpriv->shadow = TRUE; else scrpriv->shadow = FALSE; - + KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height); - + KdSetPointerMatrix (&m); - + screen->width = priv->var.xres; screen->height = priv->var.yres; - screen->memory_base = (CARD8 *) (priv->fb); - screen->memory_size = priv->fix.smem_len; - + if (scrpriv->shadow) { - if (!KdShadowFbAlloc (screen, 0, + if (!KdShadowFbAlloc (screen, scrpriv->randr & (RR_Rotate_90|RR_Rotate_270))) return FALSE; - screen->off_screen_base = screen->memory_size; } else { - screen->fb[0].byteStride = priv->fix.line_length; - screen->fb[0].pixelStride = (priv->fix.line_length * 8 / + screen->fb.byteStride = priv->fix.line_length; + screen->fb.pixelStride = (priv->fix.line_length * 8 / priv->var.bits_per_pixel); - screen->fb[0].frameBuffer = (CARD8 *) (priv->fb); - screen->off_screen_base = screen->fb[0].byteStride * screen->height; + screen->fb.frameBuffer = (CARD8 *) (priv->fb); } - + return TRUE; } -void +static void fbdevSetScreenSizes (ScreenPtr pScreen) { KdScreenPriv(pScreen); @@ -391,14 +386,14 @@ fbdevSetScreenSizes (ScreenPtr pScreen) } } -Bool +static Bool fbdevUnmapFramebuffer (KdScreenInfo *screen) { - KdShadowFbFree (screen, 0); + KdShadowFbFree (screen); return TRUE; } -Bool +static Bool fbdevSetShadow (ScreenPtr pScreen) { KdScreenPriv(pScreen); @@ -449,7 +444,7 @@ fbdevSetShadow (ScreenPtr pScreen) #ifdef RANDR -Bool +static Bool fbdevRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) { KdScreenPriv(pScreen); @@ -458,29 +453,29 @@ fbdevRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) RRScreenSizePtr pSize; Rotation randr; int n; - + *rotations = RR_Rotate_All|RR_Reflect_All; - + for (n = 0; n < pScreen->numDepths; n++) if (pScreen->allowedDepths[n].numVids) break; if (n == pScreen->numDepths) return FALSE; - + pSize = RRRegisterSize (pScreen, screen->width, screen->height, screen->width_mm, screen->height_mm); - + randr = KdSubRotation (scrpriv->randr, screen->randr); - + RRSetCurrentConfig (pScreen, randr, 0, pSize); - + return TRUE; } -Bool +static Bool fbdevRandRSetConfig (ScreenPtr pScreen, Rotation randr, int rate, @@ -512,20 +507,20 @@ fbdevRandRSetConfig (ScreenPtr pScreen, KdDisableScreen (pScreen); oldscr = *scrpriv; - + oldwidth = screen->width; oldheight = screen->height; oldmmwidth = pScreen->mmWidth; oldmmheight = pScreen->mmHeight; - + /* * Set new configuration */ - + scrpriv->randr = KdAddRotation (screen->randr, randr); fbdevUnmapFramebuffer (screen); - + if (!fbdevMapFramebuffer (screen)) goto bail4; @@ -542,13 +537,13 @@ fbdevRandRSetConfig (ScreenPtr pScreen, (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen), pScreen->width, pScreen->height, - screen->fb[0].depth, - screen->fb[0].bitsPerPixel, - screen->fb[0].byteStride, - screen->fb[0].frameBuffer); - + screen->fb.depth, + screen->fb.bitsPerPixel, + screen->fb.byteStride, + screen->fb.frameBuffer); + /* set the subpixel order */ - + KdSetSubpixelOrder (pScreen, scrpriv->randr); if (wasEnabled) KdEnableScreen (pScreen); @@ -563,17 +558,17 @@ bail4: pScreen->height = oldheight; pScreen->mmWidth = oldmmwidth; pScreen->mmHeight = oldmmheight; - + if (wasEnabled) KdEnableScreen (pScreen); return FALSE; } -Bool +static Bool fbdevRandRInit (ScreenPtr pScreen) { rrScrPrivPtr pScrPriv; - + if (!RRScreenInit (pScreen)) return FALSE; @@ -584,7 +579,7 @@ fbdevRandRInit (ScreenPtr pScreen) } #endif -Bool +static Bool fbdevCreateColormap (ColormapPtr pmap) { ScreenPtr pScreen = pmap->pScreen; @@ -594,7 +589,7 @@ fbdevCreateColormap (ColormapPtr pmap) int i; int nent; xColorItem *pdefs; - + switch (priv->fix.visual) { case FB_VISUAL_STATIC_PSEUDOCOLOR: pVisual = pmap->pVisual; @@ -604,7 +599,7 @@ fbdevCreateColormap (ColormapPtr pmap) return FALSE; for (i = 0; i < nent; i++) pdefs[i].pixel = i; - fbdevGetColors (pScreen, 0, nent, pdefs); + fbdevGetColors (pScreen, nent, pdefs); for (i = 0; i < nent; i++) { pmap->red[i].co.local.red = pdefs[i].red; @@ -639,7 +634,7 @@ fbdevFinishInitScreen (ScreenPtr pScreen) if (!fbdevRandRInit (pScreen)) return FALSE; #endif - + return TRUE; } @@ -655,6 +650,21 @@ fbdevPreserve (KdCardInfo *card) { } +static int +fbdevUpdateFbColormap(FbdevPriv *priv, int minidx, int maxidx) +{ + struct fb_cmap cmap; + + cmap.start = minidx; + cmap.len = maxidx - minidx + 1; + cmap.red = &priv->red[minidx]; + cmap.green = &priv->green[minidx]; + cmap.blue = &priv->blue[minidx]; + cmap.transp = 0; + + return ioctl(priv->fd, FBIOPUTCMAP, &cmap); +} + Bool fbdevEnable (ScreenPtr pScreen) { @@ -663,7 +673,7 @@ fbdevEnable (ScreenPtr pScreen) int k; 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) @@ -671,13 +681,12 @@ fbdevEnable (ScreenPtr pScreen) perror ("FBIOPUT_VSCREENINFO"); return FALSE; } - + if (priv->fix.visual == FB_VISUAL_DIRECTCOLOR) { - struct fb_cmap cmap; int i; - for (i = 0; + for (i = 0; i < (1 << priv->var.red.length) || i < (1 << priv->var.green.length) || i < (1 << priv->var.blue.length); i++) @@ -686,13 +695,8 @@ fbdevEnable (ScreenPtr pScreen) priv->green[i] = i * 65535 / ((1 << priv->var.green.length) - 1); priv->blue[i] = i * 65535 / ((1 << priv->var.blue.length) - 1); } - cmap.start = 0; - cmap.len = i; - cmap.red = &priv->red[0]; - cmap.green = &priv->green[0]; - cmap.blue = &priv->blue[0]; - cmap.transp = 0; - ioctl (priv->fd, FBIOPUTCMAP, &cmap); + + fbdevUpdateFbColormap(priv, 0, i); } return TRUE; } @@ -742,14 +746,17 @@ void fbdevCardFini (KdCardInfo *card) { FbdevPriv *priv = card->driver; - + munmap (priv->fb_base, priv->fix.smem_len); close (priv->fd); xfree (priv); } +/* + * Retrieve actual colormap and return selected n entries in pdefs. + */ void -fbdevGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs) +fbdevGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs) { KdScreenPriv(pScreen); FbdevPriv *priv = pScreenPriv->card->driver; @@ -789,12 +796,14 @@ fbdevGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs) } } +/* + * Change colormap by updating n entries described in pdefs. + */ void -fbdevPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs) +fbdevPutColors (ScreenPtr pScreen, int n, xColorItem *pdefs) { KdScreenPriv(pScreen); FbdevPriv *priv = pScreenPriv->card->driver; - struct fb_cmap cmap; int p; int min, max; @@ -812,11 +821,6 @@ fbdevPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs) max = p; pdefs++; } - cmap.start = min; - cmap.len = max - min + 1; - cmap.red = &priv->red[min]; - cmap.green = &priv->green[min]; - cmap.blue = &priv->blue[min]; - cmap.transp = 0; - ioctl (priv->fd, FBIOPUTCMAP, &cmap); + + fbdevUpdateFbColormap(priv, min, max); } diff --git a/xorg-server/hw/kdrive/fbdev/fbdev.h b/xorg-server/hw/kdrive/fbdev/fbdev.h index 3da8e4753..ebac6ad8b 100644 --- a/xorg-server/hw/kdrive/fbdev/fbdev.h +++ b/xorg-server/hw/kdrive/fbdev/fbdev.h @@ -52,18 +52,12 @@ extern KdCardFuncs fbdevFuncs; extern char* fbdevDevicePath; Bool -fbdevInitialize (KdCardInfo *card, FbdevPriv *priv); - -Bool fbdevCardInit (KdCardInfo *card); Bool fbdevScreenInit (KdScreenInfo *screen); Bool -fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv); - -Bool fbdevInitScreen (ScreenPtr pScreen); Bool @@ -94,46 +88,12 @@ void fbdevCardFini (KdCardInfo *card); void -fbdevGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs); +fbdevGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs); void -fbdevPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs); +fbdevPutColors (ScreenPtr pScreen, int n, xColorItem *pdefs); Bool fbdevMapFramebuffer (KdScreenInfo *screen); -void * -fbdevWindowLinear (ScreenPtr pScreen, - CARD32 row, - CARD32 offset, - int mode, - CARD32 *size, - void *closure); - -void -fbdevSetScreenSizes (ScreenPtr pScreen); - -Bool -fbdevUnmapFramebuffer (KdScreenInfo *screen); - -Bool -fbdevSetShadow (ScreenPtr pScreen); - -Bool -fbdevCreateColormap (ColormapPtr pmap); - -#ifdef RANDR -Bool -fbdevRandRGetInfo (ScreenPtr pScreen, Rotation *rotations); - -Bool -fbdevRandRSetConfig (ScreenPtr pScreen, - Rotation randr, - int rate, - RRScreenSizePtr pSize); -Bool -fbdevRandRInit (ScreenPtr pScreen); - -#endif - #endif /* _FBDEV_H_ */ diff --git a/xorg-server/hw/kdrive/fbdev/fbinit.c b/xorg-server/hw/kdrive/fbdev/fbinit.c index de80c79aa..93646f6d7 100644 --- a/xorg-server/hw/kdrive/fbdev/fbinit.c +++ b/xorg-server/hw/kdrive/fbdev/fbinit.c @@ -28,9 +28,7 @@ void InitCard (char *name) { - KdCardAttr attr; - - KdCardInfoAdd (&fbdevFuncs, &attr, 0); + KdCardInfoAdd (&fbdevFuncs, 0); } void @@ -60,11 +58,11 @@ ddxProcessArgument (int argc, char **argv, int i) { if (!strcmp (argv[i], "-fb")) { - if (i+1 < argc) + if (i+1 < argc) { fbdevDevicePath = argv[i+1]; return 2; - } + } UseMsg(); exit(1); } @@ -86,18 +84,18 @@ KdCardFuncs fbdevFuncs = { fbdevRestore, /* restore */ fbdevScreenFini, /* scrfini */ fbdevCardFini, /* cardfini */ - + 0, /* initCursor */ 0, /* enableCursor */ 0, /* disableCursor */ 0, /* finiCursor */ 0, /* recolorCursor */ - + 0, /* initAccel */ 0, /* enableAccel */ 0, /* disableAccel */ 0, /* finiAccel */ - + fbdevGetColors, /* getColors */ fbdevPutColors, /* putColors */ }; |