Skip to contentSkip to conversation

color map 565 support

PATCH New Rodolfo Giometti 1 participant 1 message Jul 12, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 color map 565 support

Hello,

here a patch to add color map 565 support.

The main trick is to modify the tool "tools/bmp_logo.c" in such a way to save full color map (8bits for red, green and blue) into bmp_logo_palette[] vector and then convert the color map to 444 or 565 as defined by CFG_LOGO_CMAP_MODE define.

Ciao,

Rodolfo

Signature · 5 lines
GNU/Linux Solutions                  e-mail:    giometti at enneenne.com
Linux Device Driver                             giometti at gnudd.com
Embedded Systems                     		giometti at linux.it
UNIX programming                     phone:     +39 349 2432127
-------------- next part --------------
README +4 -0
index 9c1905e..a145086 100644
@@ -2184,6 +2184,10 @@ Low Level (hardware related) configurati
   CFG_POCMR2_MASK_ATTRIB: (MPC826x only)
 		Overrides the default PCI memory map in cpu/mpc8260/pci.c if set.
 
+- CFG_LOGO_CMAP_MODE
+		Define the current LCD color map mode. Default value is 444 but
+		565 can also be used.
+
 - CONFIG_ETHER_ON_FEC[12]
 		Define to enable FEC[12] on a 8xx series processor.
 
common/lcd.c +31 -4
index f6065f8..7750cbf 100644
@@ -52,6 +52,10 @@ #endif
 
 #ifdef CONFIG_LCD
 
+#ifndef CFG_LOGO_CMAP_MODE
+#define CFG_LOGO_CMAP_MODE	444	/* the default */
+#endif
+
 /************************************************************************/
 /* ** FONT DATA								*/
 /************************************************************************/
@@ -526,10 +530,11 @@ #elif defined(CONFIG_MPC823)
 #elif defined(CONFIG_AU1X00)
 	uint *cmap;
 #endif
+	uint palette;
 
 	debug ("Logo: width %d  height %d  colors %d  cmap %d\n",
 		BMP_LOGO_WIDTH, BMP_LOGO_HEIGHT, BMP_LOGO_COLORS,
-		sizeof(bmp_logo_palette)/(sizeof(ushort)));
+		sizeof(bmp_logo_palette)/(sizeof(uint)));
 
 	bmap = &bmp_logo_bitmap[0];
 	fb   = (uchar *)(lcd_base + y * lcd_line_length + x);
@@ -547,8 +552,20 @@ #endif
 		WATCHDOG_RESET();
 
 		/* Set color map */
-		for (i=0; i<(sizeof(bmp_logo_palette)/(sizeof(ushort))); ++i) {
-			ushort colreg = bmp_logo_palette[i];
+		for (i=0; i<(sizeof(bmp_logo_palette)/(sizeof(uint))); ++i) {
+			palette = bmp_logo_palette[i];
+#if CFG_LOGO_CMAP_MODE == 444
+			ushort colreg = ((palette & 0xf00000)>>12) | \
+					((palette & 0x00f000)>>8)  | \
+					((palette & 0x0000f0)>>4);
+#elif CFG_LOGO_CMAP_MODE == 565
+			ushort colreg = ((palette & 0xf80000)>>8) | \
+					((palette & 0x00fc00)>>5) | \
+					((palette & 0x0000f8)>>3);
+#else
+# error "Unsupported CMAP mode"
+#endif
+
 #ifdef  CFG_INVERT_COLORS
 			*cmap++ = 0xffff - colreg;
 #else
@@ -568,8 +585,18 @@ #endif
 		fb16 = (ushort *)(lcd_base + y * lcd_line_length + x);
 		for (i=0; i<BMP_LOGO_HEIGHT; ++i) {
 			for (j=0; j<BMP_LOGO_WIDTH; j++) {
-				fb16[j] = bmp_logo_palette[(bmap[j])];
+				palette = bmp_logo_palette[bmap[j]-BMP_LOGO_OFFSET];
+#if CFG_LOGO_CMAP_MODE == 444
+				fb16[j] = ((palette & 0xf00000)>>12) | \
+					  ((palette & 0x00f000)>>8)  | \
+					  ((palette & 0x0000f0)>>4);
+#elif CFG_LOGO_CMAP_MODE == 565
+				fb16[j] = ((palette & 0xf80000)>>8) | \
+					  ((palette & 0x00fc00)>>5) | \
+					  ((palette & 0x0000f8)>>3);
+#endif
 				}
+
 			bmap += BMP_LOGO_WIDTH;
 			fb16 += panel_info.vl_col;
 		}
tools/bmp_logo.c +37 -19

112 lines not on this page · raw message