From 64faa58668e2013d683254f20fc35756ce5f490b Mon Sep 17 00:00:00 2001 From: Antonino Daplas Date: Sun, 22 Aug 2004 22:50:12 -0700 Subject: [PATCH] [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: Antonino Daplas Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/video/68328fb.c | 13 +++++++++++++ drivers/video/bw2.c | 6 +++++- drivers/video/cirrusfb.c | 6 ++++++ drivers/video/dnfb.c | 3 +++ drivers/video/macfb.c | 3 +++ drivers/video/stifb.c | 1 + drivers/video/tx3912fb.c | 3 +++ 7 files changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/video/68328fb.c b/drivers/video/68328fb.c index 5e9bcf5a89bb4..856e954322b26 100644 --- a/drivers/video/68328fb.c +++ b/drivers/video/68328fb.c @@ -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; diff --git a/drivers/video/bw2.c b/drivers/video/bw2.c index b3ab23b0725bc..0a67639e21c42 100644 --- a/drivers/video/bw2.c +++ b/drivers/video/bw2.c @@ -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, diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c index 82c26b15c2254..8d1df8a67791b 100644 --- a/drivers/video/cirrusfb.c +++ b/drivers/video/cirrusfb.c @@ -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: diff --git a/drivers/video/dnfb.c b/drivers/video/dnfb.c index 11ba053b5e10f..fa58cde1e9e7b 100644 --- a/drivers/video/dnfb.c +++ b/drivers/video/dnfb.c @@ -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); diff --git a/drivers/video/macfb.c b/drivers/video/macfb.c index 9baa40a0bf4a9..67e21aac80c74 100644 --- a/drivers/video/macfb.c +++ b/drivers/video/macfb.c @@ -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; diff --git a/drivers/video/stifb.c b/drivers/video/stifb.c index 9a1561503e185..6463bcc8c669f 100644 --- a/drivers/video/stifb.c +++ b/drivers/video/stifb.c @@ -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; diff --git a/drivers/video/tx3912fb.c b/drivers/video/tx3912fb.c index f060c0ac3f89f..0e60059c4976d 100644 --- a/drivers/video/tx3912fb.c +++ b/drivers/video/tx3912fb.c @@ -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, -- 2.53.0