Index: [thread] [date] [subject] [author]
  From: Andrew Apted <ajapted@netspace.net.au>
  To  : ggi-develop@eskimo.com
  Date: Sat, 15 Aug 1998 16:47:40 +1000

Change in fbcon API

Hi folks,

The internal fbcon API has been changed WRT to the palette
setting/getting functions.  Below is the message that was posted to
linux-m68k.  [The driver is now responsible for downscaling the colors,
which is a Good Thing (tm)].  This change has already hit the VGER
kernel tree, and should hit Linus' tree in 2.1.116 or 117 (I'm guessing).

I'm going update my fbcon-kgi.c (so it actually works here :-), but I
won't commit it until this change hits Linus' tree, since that would
break it for everyone else.

Cheers,
_____________________________________________  ____
                                               \  /
  Andrew Apted   <andrew@ggi-project.org>       \/
  

===========================================================================


Paul Mackerras pointed out a problem with the frame buffer colormap code and
DIRECTCOLOR visuals.

fb_{get,set}_cmap() rounds the color values down to the hardware's capabilities
according to the `length' field in the fb_bitfield structure (in struct
fb_var_screeninfo). However, in DIRECTCOLOR there's no relation between the
size of the entries in the hardware colormap and the `length' field in
fb_bitfield.

Therefore Paul and I agreed to remove the downscaling in fb_{get,set}_cmap().
Now it's the full responsibility of the frame buffer device itself to scale the
16 bit color values to the resolution the hardware requires (and vice versa).
I'm updating all frame buffer devices; for most of them the changes are trivial
(8 bit color). Atafb (3/4/6 bit color?) and amifb (2/4/8 bit color) are the
notable exceptions. I already did amifb myself, but I'm not sufficiently
familiar with Atari hardware.

Can someone please make the required changes to the *{set,get}colreg()
functions in drivers/video/atafb.c and send me the patches? Thx!

For reference, here are the changes to the generic code:

--- include/linux/fb.h.orig	Sat Aug  8 15:08:18 1998
+++ include/linux/fb.h	Sun Aug  9 14:07:11 1998
@@ -394,14 +394,13 @@
 extern int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp);
 extern void fb_copy_cmap(struct fb_cmap *from, struct fb_cmap *to,
 			 int fsfromto);
-extern int fb_get_cmap(struct fb_cmap *cmap, struct fb_var_screeninfo *var,
-		       int kspc, int (*getcolreg)(u_int, u_int *, u_int *,
-						  u_int *, u_int *,
-						  struct fb_info *),
+extern int fb_get_cmap(struct fb_cmap *cmap, int kspc,
+		       int (*getcolreg)(u_int, u_int *, u_int *, u_int *,
+					u_int *, struct fb_info *),
 		       struct fb_info *fb_info);
-extern int fb_set_cmap(struct fb_cmap *cmap, struct fb_var_screeninfo *var,
-		       int kspc, int (*setcolreg)(u_int, u_int, u_int, u_int,
-						  u_int, struct fb_info *),
+extern int fb_set_cmap(struct fb_cmap *cmap, int kspc,
+		       int (*setcolreg)(u_int, u_int, u_int, u_int, u_int,
+					struct fb_info *),
 		       struct fb_info *fb_info);
 extern struct fb_cmap *fb_default_cmap(int len);
 extern void fb_invert_cmaps(void);
--- drivers/video/fbcmap.c.orig	Sat Jul 25 15:38:19 1998
+++ drivers/video/fbcmap.c	Sun Aug  9 14:07:35 1998
@@ -31,10 +31,6 @@
     }
 }
 
-#define CNVT_TOHW(val,width)	((((val)<<(width))+0x7fff-(val))>>16)
-#define CNVT_FROMHW(val,width)	(((width) ? ((((val)<<16)-(val)) / \
-					((1<<(width))-1)) : 0))
-
 static u16 red2[] = {
     0x0000, 0xaaaa
 };
@@ -163,9 +159,10 @@
      *  Get the colormap for a screen
      */
 
-int fb_get_cmap(struct fb_cmap *cmap, struct fb_var_screeninfo *var, int kspc,
+int fb_get_cmap(struct fb_cmap *cmap, int kspc,
     	    	int (*getcolreg)(u_int, u_int *, u_int *, u_int *, u_int *,
-				 struct fb_info *), struct fb_info *info)
+				 struct fb_info *),
+		struct fb_info *info)
 {
     int i, start;
     u16 *red, *green, *blue, *transp;
@@ -181,10 +178,6 @@
     for (i = 0; i < cmap->len; i++) {
 	if (getcolreg(start++, &hred, &hgreen, &hblue, &htransp, info))
 	    return 0;
-	hred = CNVT_FROMHW(hred, var->red.length);
-	hgreen = CNVT_FROMHW(hgreen, var->green.length);
-	hblue = CNVT_FROMHW(hblue, var->blue.length);
-	htransp = CNVT_FROMHW(htransp, var->transp.length);
 	if (kspc) {
 	    *red = hred;
 	    *green = hgreen;
@@ -212,9 +205,10 @@
      *  Set the colormap for a screen
      */
 
-int fb_set_cmap(struct fb_cmap *cmap, struct fb_var_screeninfo *var, int kspc,
+int fb_set_cmap(struct fb_cmap *cmap, int kspc,
     	    	int (*setcolreg)(u_int, u_int, u_int, u_int, u_int,
-				 struct fb_info *), struct fb_info *info)
+				 struct fb_info *),
+		struct fb_info *info)
 {
     int i, start;
     u16 *red, *green, *blue, *transp;
@@ -243,10 +237,6 @@
 	    else
 		htransp = 0;
 	}
-	hred = CNVT_TOHW(hred, var->red.length);
-	hgreen = CNVT_TOHW(hgreen, var->green.length);
-	hblue = CNVT_TOHW(hblue, var->blue.length);
-	htransp = CNVT_TOHW(htransp, var->transp.length);
 	red++;
 	green++;
 	blue++;

Greetings,

						Geert

--
Geert Uytterhoeven                     Geert.Uytterhoeven@cs.kuleuven.ac.be
Wavelets, Linux/{m68k~Amiga,PPC~CHRP}  http://www.cs.kuleuven.ac.be/~geert/
Department of Computer Science -- Katholieke Universiteit Leuven -- Belgium

Index: [thread] [date] [subject] [author]