[PATCH] vesa framebuffer with 24 bits per pixel

Jose Alonso (alonso@agencia.oesp.com.br)
Wed, 2 Sep 1998 12:56:26 -0300 (EST)


Patches to use vesa framebuffer with 24 bits per pixel
linux-2.1.119 and XF68_FBDev

I tested on a board based on chipset SiS6326 (www.sis.com.tw)
- AGP, 4MB, Vesa 2.0, linear frame buffer, 24 bits per pixel when
using 16M colors. (1024x768 16M - lilo param: VESA=792)

Description of the patches:
linux-2.1.119
. Terminate the implementation of 24 bpp
. Little endian bug
Xfree86 - X332servonly.tgz
. Terminate the implementation of 24 bpp
. Comment FB_VISUAL_STATIC_DIRECTCOLOR (not in kernel includes)
. Use of the routine cfbSetColorMasks to pass the color masks
and offsets (patch from Gerd Knorr).
. Missing return TRUE (near #ifdef GLX_MODULE)
(Gerd: I think that this explains the problem you found using gcc)

alonso

---------------linux-2.1.119 patches-----------------------------------

--- linux/drivers/video/fbcon-cfb24.c.ORIG Tue Aug 4 21:30:24 1998
+++ linux/drivers/video/fbcon-cfb24.c Sat Aug 29 23:10:44 1998
@@ -80,9 +80,9 @@
*dest++ = (d2<<16) | (d3>>8);
*dest++ = (d3<<24) | d4;
#elif defined(__LITTLE_ENDIAN)
- *dest++ = (d1<<8) | (d2>>16);
- *dest++ = (d2<<16) | (d3>>8);
- *dest++ = (d3<<24) | d4;
+ *dest++ = d1 | (d2<<24);
+ *dest++ = (d2>>8) | (d3<<16);
+ *dest++ = (d3>>16) | (d4<<8);
#else
#error FIXME: No endianness??
#endif
--- linux/drivers/video/vesafb.c.ORIG Tue Aug 4 21:30:25 1998
+++ linux/drivers/video/vesafb.c Sun Aug 30 21:08:09 1998
@@ -27,6 +27,7 @@
#include "fbcon.h"
#include "fbcon-cfb8.h"
#include "fbcon-cfb16.h"
+#include "fbcon-cfb24.h"
#include "fbcon-cfb32.h"

#define dac_reg (0x3c8)
@@ -181,6 +182,11 @@
sw = &fbcon_cfb16;
break;
#endif
+#ifdef FBCON_HAS_CFB24
+ case 24:
+ sw = &fbcon_cfb24;
+ break;
+#endif
#ifdef FBCON_HAS_CFB32
case 32:
sw = &fbcon_cfb32;
@@ -259,7 +265,10 @@
#endif
#ifdef FBCON_HAS_CFB24
case 24:
- /* FIXME: todo */
+ fbcon_cfb24_cmap[regno] =
+ (red << vesafb_defined.red.offset) |
+ (green << vesafb_defined.green.offset) |
+ (blue << vesafb_defined.blue.offset);
break;
#endif
#ifdef FBCON_HAS_CFB32

---------------------XFree86 - X332servonly.tgz------------------

--- xc/config/cf/xfree86.cf.ORIG Mon Mar 2 08:55:22 1998
+++ xc/config/cf/xfree86.cf Wed Sep 2 10:09:18 1998
@@ -73,6 +73,9 @@
#ifndef XF86I128Server
#define XF86I128Server YES
#endif
+#ifndef XF68FBDevServer
+#define XF68FBDevServer YES
+#endif
#endif

/*
@@ -449,10 +452,13 @@
# define XF68FBDevCFB8 YES
# endif
# ifndef XF68FBDevCFB16
-# define XF68FBDevCFB16 NO
+# define XF68FBDevCFB16 YES
+# endif
+# ifndef XF68FBDevCFB24
+# define XF68FBDevCFB24 YES
# endif
# ifndef XF68FBDevCFB32
-# define XF68FBDevCFB32 NO
+# define XF68FBDevCFB32 YES
# endif
#else
# ifndef XF68FBDevIPLAN2p2
@@ -475,6 +481,9 @@
# endif
# ifndef XF68FBDevCFB16
# define XF68FBDevCFB16 NO
+# endif
+# ifndef XF68FBDevCFB24
+# define XF68FBDevCFB24 NO
# endif
# ifndef XF68FBDevCFB32
# define XF68FBDevCFB32 NO
--- xc/programs/Xserver/cfb/cfbcmap.c.ORIG Sun May 11 02:04:17 1997
+++ xc/programs/Xserver/cfb/cfbcmap.c Wed Sep 2 11:21:14 1998
@@ -413,6 +413,25 @@
return TRUE;
}

+static int cfbRedBits;
+static int cfbRedOffset;
+static int cfbGreenBits;
+static int cfbGreenOffset;
+static int cfbBlueBits;
+static int cfbBlueOffset;
+
+Bool
+cfbSetColorMasks(rb, ro, gb, go, bb, bo)
+ int rb, ro, gb, go, bb, bo;
+{
+ cfbRedBits = rb;
+ cfbRedOffset = ro;
+ cfbGreenBits = gb;
+ cfbGreenOffset = go;
+ cfbBlueBits = bb;
+ cfbBlueOffset = bo;
+}
+
/*
* Given a list of formats for a screen, create a list
* of visuals and depths for the screen which coorespond to
@@ -524,12 +543,21 @@
visual->ColormapEntries = _CE(d);
/* fall through */
case StaticColor:
- visual->redMask = _RM(d);
- visual->greenMask = _GM(d);
- visual->blueMask = _BM(d);
- visual->offsetRed = _RS(d);
- visual->offsetGreen = _GS(d);
- visual->offsetBlue = _BS(d);
+ if (cfbRedBits) {
+ visual->redMask = ((1 << cfbRedBits) - 1) << cfbRedOffset;
+ visual->greenMask = ((1 << cfbGreenBits) - 1) << cfbGreenOffset;
+ visual->blueMask = ((1 << cfbBlueBits) - 1) << cfbBlueOffset;
+ visual->offsetRed = cfbRedOffset;
+ visual->offsetGreen = cfbGreenOffset;
+ visual->offsetBlue = cfbBlueOffset;
+ } else {
+ visual->redMask = _RM(d);
+ visual->greenMask = _GM(d);
+ visual->blueMask = _BM(d);
+ visual->offsetRed = _RS(d);
+ visual->offsetGreen = _GS(d);
+ visual->offsetBlue = _BS(d);
+ }
}
vid++;
visual++;
@@ -566,8 +594,9 @@

#ifdef GLXEXT
#ifdef GLX_MODULE
- if( GlxInitVisualsPtr != NULL )
- return (*GlxInitVisualsPtr)
+ if( GlxInitVisualsPtr == NULL )
+ return TRUE;
+ return (*GlxInitVisualsPtr)
#else
return GlxInitVisuals
#endif
--- xc/programs/Xserver/hw/xfree68/fbdev/fbdev.c.ORIG Wed Jun 11 09:08:45 1997
+++ xc/programs/Xserver/hw/xfree68/fbdev/fbdev.c Wed Sep 2 10:20:29 1998
@@ -18,6 +18,7 @@
* - Color, normal bitplanes [afb]
* - Color, chunky 8 bits per pixel [cfb8]
* - Color, chunky 16 bits per pixel [cfb16]
+ * - Color, chunky 24 bits per pixel [cfb24]
* - Color, chunky 32 bits per pixel [cfb32]
*/

@@ -100,6 +101,11 @@
extern void cfb16DoBitblt();
#endif /* CONFIG_CFB16 */

+#ifdef CONFIG_CFB24
+extern int cfb24ScreenPrivateIndex;
+extern void cfb24DoBitblt();
+#endif /* CONFIG_CFB24 */
+
#ifdef CONFIG_CFB32
extern int cfb32ScreenPrivateIndex;
extern void cfb32DoBitblt();
@@ -400,6 +406,9 @@
#ifdef CONFIG_CFB16
ErrorF(", cfb16");
#endif
+#ifdef CONFIG_CFB24
+ ErrorF(", cfb24");
+#endif
#ifdef CONFIG_CFB32
ErrorF(", cfb32");
#endif
@@ -742,7 +751,7 @@
break;

case FB_VISUAL_STATIC_PSEUDOCOLOR:
- case FB_VISUAL_STATIC_DIRECTCOLOR:
+ /* case FB_VISUAL_STATIC_DIRECTCOLOR: */
if (var->grayscale)
visuals = StaticGrayMask;
else
@@ -805,7 +814,7 @@
break;

case FB_VISUAL_STATIC_PSEUDOCOLOR:
- case FB_VISUAL_STATIC_DIRECTCOLOR:
+ /* case FB_VISUAL_STATIC_DIRECTCOLOR: */
if (var->grayscale)
visuals = StaticGrayMask;
else
@@ -834,6 +843,12 @@

case FB_TYPE_PACKED_PIXELS:
width = fb_fix.line_length ? 8*fb_fix.line_length/bpp : xsize;
+ cfbSetColorMasks(initscrvar.red.length,
+ initscrvar.red.offset,
+ initscrvar.green.length,
+ initscrvar.green.offset,
+ initscrvar.blue.length,
+ initscrvar.blue.offset);
switch (bpp) {
#ifdef CONFIG_CFB8
case 8:
@@ -857,6 +872,17 @@
break;
#endif

+#ifdef CONFIG_CFB24
+ case 24:
+ fbtype = "cfb24";
+ cfb24ScreenInit(pScreen, fbdevVirtBase, xsize, ysize,
+ dxres, dyres, width);
+ fbdevPrivateIndexP = &cfb24ScreenPrivateIndex;
+ fbdevBitBlt = cfb24DoBitblt;
+ CreateDefColormap = cfbCreateDefColormap;
+ break;
+#endif
+
#ifdef CONFIG_CFB32
case 32:
fbtype = "cfb32";
--- xc/programs/Xserver/hw/xfree68/fbdev/Imakefile.ORIG Fri Dec 27 04:52:43 1996
+++ xc/programs/Xserver/hw/xfree68/fbdev/Imakefile Wed Sep 2 10:09:18 1998
@@ -32,6 +32,9 @@
#if XF68FBDevCFB16
FB_DEFINES:= $(FB_DEFINES) -DCONFIG_CFB16
#endif
+#if XF68FBDevCFB24
+FB_DEFINES:= $(FB_DEFINES) -DCONFIG_CFB24
+#endif
#if XF68FBDevCFB32
FB_DEFINES:= $(FB_DEFINES) -DCONFIG_CFB32
#endif
--- xc/programs/Xserver/Imakefile.ORIG Mon Mar 2 08:55:22 1998
+++ xc/programs/Xserver/Imakefile Wed Sep 2 10:09:18 1998
@@ -1560,6 +1560,10 @@
CFB16DIR = cfb16
FBDEVFBLIBS:= $(FBDEVFBLIBS) $(CFB16)
#endif
+#if XF68FBDevCFB24
+CFB24DIR = cfb24
+FBDEVFBLIBS:= $(FBDEVFBLIBS) $(CFB24)
+#endif
#if XF68FBDevCFB32
CFB32DIR = cfb32
FBDEVFBLIBS:= $(FBDEVFBLIBS) $(CFB32)

----------------------------end----------------------------------

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html