Commit 64faa586 authored by Antonino Daplas's avatar Antonino Daplas Committed by Linus Torvalds

[PATCH] fbdev: set color fields correctly

Although the depth can be correctly inferred from bits_per_pixel (if
bits_per_pixel == 1), for the sake of consistency, drivers should still set
the color fields correctly.  True even if the first patch is not applied.

(I've combined everything in a single diff since there is only 1 logical
change)
Signed-off-by: default avatarAntonino Daplas <adaplas@pol.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 37709b41
......@@ -199,6 +199,15 @@ static int mc68x328fb_check_var(struct fb_var_screeninfo *var,
*/
switch (var->bits_per_pixel) {
case 1:
var->red.offset = 0;
var->red.length = 1;
var->green.offset = 0;
var->green.length = 1;
var->blue.offset = 0;
var->blue.length = 1;
var->transp.offset = 0;
var->transp.length = 0;
break;
case 8:
var->red.offset = 0;
var->red.length = 8;
......@@ -452,6 +461,10 @@ int __init mc68x328fb_init(void)
get_line_length(mc68x328fb_default.xres_virtual, mc68x328fb_default.bits_per_pixel);
fb_info.fix.visual = (mc68x328fb_default.bits_per_pixel) == 1 ?
MC68X328FB_MONO_VISUAL : FB_VISUAL_PSEUDOCOLOR;
if (fb_info.var.bits_per_pixel == 1) {
fb_info.var.red.length = fb_info.var.green.length = fb_info.var.blue.length = 1;
fb_info.var.red.offset = fb_info.var.green.offset = fb_info.var.blue.offset = 0;
}
fb_info.pseudo_palette = &mc68x328fb_pseudo_palette;
fb_info.flags = FBINFO_FLAG_DEFAULT;
......
......@@ -323,7 +323,7 @@ static void bw2_init_one(struct sbus_dev *sdev)
resp = &res;
all->info.var.xres = all->info.var.xres_virtual = 1152;
all->info.var.yres = all->info.var.yres_virtual = 900;
all->info.bits_per_pixel = 1;
all->info.var.bits_per_pixel = 1;
linebytes = 1152 / 8;
} else
#else
......@@ -337,6 +337,10 @@ static void bw2_init_one(struct sbus_dev *sdev)
all->info.var.xres);
}
#endif
all->info.var.red.length = all->info.var.green.length =
all->info.var.blue.length = all_info.var.bits_per_pixel;
all->info.var.red.offset = all->info.var.green.offset =
all->info.var.blue.offset = 0;
all->par.regs = (struct bw2_regs *)
sbus_ioremap(resp, BWTWO_REGISTER_OFFSET,
......
......@@ -752,6 +752,12 @@ int cirrusfb_check_var(struct fb_var_screeninfo *var,
switch (var->bits_per_pixel) {
case 1:
var->red.offset = 0;
var->red.length = 1;
var->green.offset = 0;
var->green.length = 1;
var->blue.offset = 0;
var->blue.length = 1;
break;
case 8:
......
......@@ -239,6 +239,9 @@ static int __devinit dnfb_probe(struct device *device)
info->fbops = &dn_fb_ops;
info->fix = dnfb_fix;
info->var = dnfb_var;
info->var.red.length = 1;
info->var.red.offset = 0;
info->var.green = info->var.blue = info->var.red;
info->screen_base = (u_char *) info->fix.smem_start;
err = fb_alloc_cmap(&info->cmap, 2, 0);
......
......@@ -660,6 +660,9 @@ void __init macfb_init(void)
case 1:
/* XXX: I think this will catch any program that tries
to do FBIO_PUTCMAP when the visual is monochrome */
macfb_defined.red.length = macfb_defined.bits_per_pixel;
macfb_defined.green.length = macfb_defined.bits_per_pixel;
macfb_defined.blue.length = macfb_defined.bits_per_pixel;
video_cmap_len = 0;
macfb_fix.visual = FB_VISUAL_MONO01;
break;
......
......@@ -1298,6 +1298,7 @@ stifb_init_fb(struct sti_struct *sti, int force_bpp)
case 1:
fix->type = FB_TYPE_PLANES; /* well, sort of */
fix->visual = FB_VISUAL_MONO10;
var->red.length = var->green.length = var->blue.length = 1;
break;
case 8:
fix->type = FB_TYPE_PACKED_PIXELS;
......
......@@ -60,6 +60,9 @@ static struct fb_var_screeninfo tx3912fb_var = {
.blue = { 0, 2, 0 },
#else
.bits_per_pixel =4,
.red = { 0, 4, 0 }, /* ??? */
.green = { 0, 4, 0 },
.blue = { 0, 4, 0 },
#endif
.activate = FB_ACTIVATE_NOW,
.width = -1,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment