Subject: [E3-hacking] LCD colour fix patch

From: Mark Underwood <[email-masked]>
Date: Tue, 14 Mar 2006 20:17:01 +0000 (GMT)

The patch fixes the palette for 12-bit so you get a nice tux and white text :)

Mark

___________________________________________________________ 
NEW Yahoo! Cars - sell your car and browse thousands of new and used cars online! http://uk.cars.yahoo.com/

diff -uprN linux-2.6.15-omap1-e3/drivers/video/omap/lcd_ams_delta.c linux-2.6.15-omap1-e3-mark/drivers/video/omap/lcd_ams_delta.c
--- linux-2.6.15-omap1-e3/drivers/video/omap/lcd_ams_delta.c	2006-03-14 19:10:12.000000000 +0000
+++ linux-2.6.15-omap1-e3-mark/drivers/video/omap/lcd_ams_delta.c	2006-03-14 19:22:17.000000000 +0000
@@ -96,7 +96,7 @@ struct lcd_panel ams_delta_panel = {
 	.name		= "ams-delta",
 	.config		= 0,
 
-	.bpp		= 16,
+	.bpp		= 12,
 	.data_lines	= 16,
 	.x_res		= 480,
 	.y_res		= 320,
diff -uprN linux-2.6.15-omap1-e3/drivers/video/omap/lcdc.c linux-2.6.15-omap1-e3-mark/drivers/video/omap/lcdc.c
--- linux-2.6.15-omap1-e3/drivers/video/omap/lcdc.c	2006-03-14 19:10:12.000000000 +0000
+++ linux-2.6.15-omap1-e3-mark/drivers/video/omap/lcdc.c	2006-03-14 19:56:37.000000000 +0000
@@ -333,6 +333,7 @@ static int omap_lcdc_setup_plane(int pla
 		omap_lcdc.palette_size = 512;
 		break;
 	case OMAPFB_COLOR_RGB565:
+	case OMAPFB_COLOR_RGB444:
 		omap_lcdc.bpp = 16;
 		omap_lcdc.palette_code = 0x4000;
 		omap_lcdc.palette_size = 32;
@@ -620,7 +621,11 @@ static int omap_lcdc_init(struct omapfb_
 		goto fail3;
 	}
 
-	frame_size = panel->x_res * panel->bpp * panel->y_res / 8;
+	if (panel->bpp == 12)
+		frame_size = panel->x_res * 16 * panel->y_res / 8;
+	else
+		frame_size = panel->x_res * panel->bpp * panel->y_res / 8;
+
 	if (req_vram_size > frame_size)
 		frame_size = req_vram_size;
 	omap_lcdc.vram_size = PAGE_ALIGN(MAX_PALETTE_SIZE) + frame_size;
diff -uprN linux-2.6.15-omap1-e3/drivers/video/omap/omapfb_main.c linux-2.6.15-omap1-e3-mark/drivers/video/omap/omapfb_main.c
--- linux-2.6.15-omap1-e3/drivers/video/omap/omapfb_main.c	2006-03-14 19:10:12.000000000 +0000
+++ linux-2.6.15-omap1-e3-mark/drivers/video/omap/omapfb_main.c	2006-03-14 19:22:01.000000000 +0000
@@ -264,6 +264,7 @@ static int _setcolreg(struct fb_info *in
 			u_int blue, u_int transp, int update_hw_pal)
 {
 	struct omapfb_device *fbdev = (struct omapfb_device *)info->par;
+	struct fb_var_screeninfo *var = &info->var;
 	int r = 0;
 
 	switch (fbdev->color_mode) {
@@ -280,6 +281,7 @@ static int _setcolreg(struct fb_info *in
 							transp, update_hw_pal);
 		/* Fallthrough */
 	case OMAPFB_COLOR_RGB565:
+	case OMAPFB_COLOR_RGB444:
 		if (r != 0)
 			break;
 
@@ -290,8 +292,9 @@ static int _setcolreg(struct fb_info *in
 
 		if (regno < 16) {
 			u16 pal;
-			pal = ((red >> 11) << 11) | ((green >> 10) << 5) |
-				(blue >> 11);
+			pal = ((red >> (16 - var->red.length)) << var->red.offset) |
+				((green >> (16 - var->green.length)) << var->green.offset) |
+				(blue >> (16 - var->blue.length));
 			((u32 *)(info->pseudo_palette))[regno] = pal;
 		}
 		break;
@@ -428,12 +431,18 @@ static int set_fb_var(struct omapfb_devi
 	unsigned long	line_size;
 	struct lcd_panel *panel = fbdev->panel;
 
-	bpp = var->bits_per_pixel = panel->bpp;
+	if (panel->bpp == 12)
+		bpp = var->bits_per_pixel = 16;	/* 12-bit bpp mode stores colours in 16-bits */
+	else
+		bpp = var->bits_per_pixel = panel->bpp;
 
-	switch (bpp) {
+	switch (panel->bpp) {
 	case 16:
 		fbdev->color_mode = OMAPFB_COLOR_RGB565;
 		break;
+	case 12:
+		fbdev->color_mode = OMAPFB_COLOR_RGB444;
+		break;
 	case 8:
 		fbdev->color_mode = OMAPFB_COLOR_CLUT_8BPP;
 		break;
@@ -479,9 +488,18 @@ static int set_fb_var(struct omapfb_devi
 		var->yoffset = var->yres_virtual - var->yres;
 	line_size = var->xres * bpp / 8;
 
-	var->red.offset	 = 11; var->red.length	 = 5; var->red.msb_right   = 0;
-	var->green.offset= 5;  var->green.length = 6; var->green.msb_right = 0;
-	var->blue.offset = 0;  var->blue.length  = 5; var->blue.msb_right  = 0;
+	if (fbdev->color_mode == OMAPFB_COLOR_RGB444)
+	{
+		var->red.offset	 = 8; var->red.length	 = 4; var->red.msb_right   = 0;
+		var->green.offset= 4;  var->green.length = 4; var->green.msb_right = 0;
+		var->blue.offset = 0;  var->blue.length  = 4; var->blue.msb_right  = 0;
+	}
+	else
+	{
+		var->red.offset	 = 11; var->red.length	 = 5; var->red.msb_right   = 0;
+		var->green.offset= 5;  var->green.length = 6; var->green.msb_right = 0;
+		var->blue.offset = 0;  var->blue.length  = 5; var->blue.msb_right  = 0;
+	}
 
 	var->height		= -1;
 	var->width		= -1;
diff -uprN linux-2.6.15-omap1-e3/include/asm-arm/arch-omap/omapfb.h linux-2.6.15-omap1-e3-mark/include/asm-arm/arch-omap/omapfb.h
--- linux-2.6.15-omap1-e3/include/asm-arm/arch-omap/omapfb.h	2006-01-03 03:21:10.000000000 +0000
+++ linux-2.6.15-omap1-e3-mark/include/asm-arm/arch-omap/omapfb.h	2006-03-14 19:23:20.000000000 +0000
@@ -63,6 +63,7 @@ enum omapfb_color_format {
 	OMAPFB_COLOR_CLUT_4BPP,
 	OMAPFB_COLOR_CLUT_2BPP,
 	OMAPFB_COLOR_CLUT_1BPP,
+	OMAPFB_COLOR_RGB444,
 };
 
 struct omapfb_update_window {