Problem with current fb_get_color_depth function

From: Joshua Kwan
Date: Sun Oct 10 2004 - 18:00:58 EST


Hi Antonino, lists, etc.,

I noticed that after 2.6.9-rc1 or so my framebuffer logo stopped
appearing. Well, I dove into the fb layer code, noticed this change from
you:

int fb_get_color_depth(struct fb_info *info)
{
struct fb_var_screeninfo *var = &info->var;

if (var->green.length == var->blue.length &&
var->green.length == var->red.length &&
!var->green.offset && !var->blue.offset &&
!var->red.offset)
return var->green.length;
else
return (var->green.length + var->red.length +
var->blue.length);
}

That was interesting, because here's what radeonfb does:

switch (var_to_depth(&v)) {
[...]
case 16:
nom = 2;
den = 1;
v.red.offset = 11;
v.green.offset = 5;
v.blue.offset = 0;
v.red.length = 5;
v.green.length = 6;
v.blue.length = 5;
v.transp.offset = v.transp.length = 0;
break;
[...]

So somehow that first conditional was firing, although I'm not sure how,
because a printk showed that the depth returned was 6. (fb_get_color_depth
should have jumped to the return (R + G + B) part right after it noticed
blue length was not equal to green length. Creepy.)

Well, whatever. The 224-color logo was ignored. This is what I did to
fix it:

--- a/drivers/video/fbmem.c 2004/09/23 01:19:45 1.102
+++ b/drivers/video/fbmem.c 2004/10/10 22:47:14
@@ -65,10 +65,8 @@
{
struct fb_var_screeninfo *var = &info->var;

- if (var->green.length == var->blue.length &&
- var->green.length == var->red.length &&
- !var->green.offset && !var->blue.offset &&
- !var->red.offset)
+ /* If grayscale, all values will be equal */
+ if (var->grayscale)
return var->green.length;
else
return (var->green.length + var->red.length +

because on advice from Andrew Suffield and Matthew Garrett the first
conditional was a roundabout way to check for grayscale displays, where
you can't actually have 24 bits (8 + 8 + 8) of gray. So it is suitable
to just return one of the values arbitrarily. But I noticed there was
also a grayscale variable, so I substituted that for the conditional
and my logo reappeared again :)

So is radeonfb or fb_get_color_depth at fault here? Or was the logo
never appropriate for my display in the first place? (Unlikely, the
CLUT224 linux logo always displayed perfectly for me until now.)

Thanks.

--
Joshua Kwan

Attachment: signature.asc
Description: Digital signature