linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Fix 8bpp RGB fields length
@ 2009-03-01 20:55 Krzysztof Helt
  2009-03-02 13:02 ` Ville Syrjälä
  0 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Helt @ 2009-03-01 20:55 UTC (permalink / raw)
  To: spock; +Cc: Linux-fbdev-devel

Hi,

I found that some fbdev drivers set RGB field's lengths incorrectly
to 6 bits. This is incorrect as the field's length says how many bits
has a color index when using color palette (6 bits = 64 colors).

Fix this error in uvesafb by dropping DAC switching to 8 bits 
completely. Advantage of this approach is making the driver shorter,
disadvantage is that some color fidelity is lost.

Regards,
Krzysztof


diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
index 6c2d37f..76661bf 100644
--- a/drivers/video/uvesafb.c
+++ b/drivers/video/uvesafb.c
@@ -300,22 +300,10 @@ static void uvesafb_setup_var(struct fb_var_screeninfo *var,
 		var->blue.offset   = 0;
 		var->transp.offset = 0;
 
-		/*
-		 * We're assuming that we can switch the DAC to 8 bits. If
-		 * this proves to be incorrect, we'll update the fields
-		 * later in set_par().
-		 */
-		if (par->vbe_ib.capabilities & VBE_CAP_CAN_SWITCH_DAC) {
-			var->red.length    = 8;
-			var->green.length  = 8;
-			var->blue.length   = 8;
-			var->transp.length = 0;
-		} else {
-			var->red.length    = 6;
-			var->green.length  = 6;
-			var->blue.length   = 6;
-			var->transp.length = 0;
-		}
+		var->red.length    = 8;
+		var->green.length  = 8;
+		var->blue.length   = 8;
+		var->transp.length = 0;
 	}
 }
 
@@ -998,16 +986,15 @@ static int uvesafb_setcolreg(unsigned regno, unsigned red, unsigned green,
 		struct fb_info *info)
 {
 	struct uvesafb_pal_entry entry;
-	int shift = 16 - info->var.green.length;
 	int err = 0;
 
 	if (regno >= info->cmap.len)
 		return -EINVAL;
 
 	if (info->var.bits_per_pixel == 8) {
-		entry.red   = red   >> shift;
-		entry.green = green >> shift;
-		entry.blue  = blue  >> shift;
+		entry.red   = red   >> 10;
+		entry.green = green >> 10;
+		entry.blue  = blue  >> 10;
 		entry.pad   = 0;
 
 		err = uvesafb_setpalette(&entry, 1, regno, info);
@@ -1047,7 +1034,6 @@ static int uvesafb_setcolreg(unsigned regno, unsigned red, unsigned green,
 static int uvesafb_setcmap(struct fb_cmap *cmap, struct fb_info *info)
 {
 	struct uvesafb_pal_entry *entries;
-	int shift = 16 - info->var.green.length;
 	int i, err = 0;
 
 	if (info->var.bits_per_pixel == 8) {
@@ -1060,9 +1046,9 @@ static int uvesafb_setcmap(struct fb_cmap *cmap, struct fb_info *info)
 			return -ENOMEM;
 
 		for (i = 0; i < cmap->len; i++) {
-			entries[i].red   = cmap->red[i]   >> shift;
-			entries[i].green = cmap->green[i] >> shift;
-			entries[i].blue  = cmap->blue[i]  >> shift;
+			entries[i].red   = cmap->red[i]   >> 10;
+			entries[i].green = cmap->green[i] >> 10;
+			entries[i].blue  = cmap->blue[i]  >> 10;
 			entries[i].pad   = 0;
 		}
 		err = uvesafb_setpalette(entries, cmap->len, cmap->start, info);
@@ -1299,26 +1285,6 @@ setmode:
 	}
 	par->mode_idx = i;
 
-	/* For 8bpp modes, always try to set the DAC to 8 bits. */
-	if (par->vbe_ib.capabilities & VBE_CAP_CAN_SWITCH_DAC &&
-	    mode->bits_per_pixel <= 8) {
-		uvesafb_reset(task);
-		task->t.regs.eax = 0x4f08;
-		task->t.regs.ebx = 0x0800;
-
-		err = uvesafb_exec(task);
-		if (err || (task->t.regs.eax & 0xffff) != 0x004f ||
-		    ((task->t.regs.ebx & 0xff00) >> 8) != 8) {
-			/*
-			 * We've failed to set the DAC palette format -
-			 * time to correct var.
-			 */
-			info->var.red.length    = 6;
-			info->var.green.length  = 6;
-			info->var.blue.length   = 6;
-		}
-	}
-
 	info->fix.visual = (info->var.bits_per_pixel == 8) ?
 				FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
 	info->fix.line_length = mode->bytes_per_scan_line;

----------------------------------------------------------------------
Dodatkowy dzien wolny od pracy? Wypowiedz sie i wygraj nagrode!
Wejdz >>  http://link.interia.pl/f2077 


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-03-29 21:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-01 20:55 Fix 8bpp RGB fields length Krzysztof Helt
2009-03-02 13:02 ` Ville Syrjälä
2009-03-02 17:02   ` Krzysztof Helt
2009-03-02 17:40     ` Ville Syrjälä
2009-03-29 19:14     ` Michal Januszewski
2009-03-29 19:26       ` Geert Uytterhoeven
2009-03-29 21:18         ` Ville Syrjälä

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).