Patchwork [U-Boot,v3,2/2] common/lcd: use lcd_setcolreg() to setup CLUT

login
register
mail settings
Submitter Andreas Bießmann
Date Nov. 6, 2012, 10:13 a.m.
Message ID <1352196829-27879-3-git-send-email-andreas.devel@googlemail.com>
Download mbox | patch
Permalink /patch/197443/
State Under Review
Delegated to: Anatolij Gustschin
Headers show

Comments

Andreas Bießmann - Nov. 6, 2012, 10:13 a.m.
The lcd_setcolreg() is a API provided by the lcd driver and used to setup the
color lookup table. However the lcd driver setup the CLUT by using a lot of
ifdiffery and accessing the CLUT arrays directly instead. Remove that and use
the API.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Anatolij Gustschin <agust@denx.de>
---
since v1:
 * also use lcd_setcolreg() in lcd_display_bitmap()
 * remove RFC

since v2:
 * no change

 common/lcd.c |   79 ++++++++++++----------------------------------------------
 1 file changed, 16 insertions(+), 63 deletions(-)

Patch

diff --git a/common/lcd.c b/common/lcd.c
index b6be800..6835e65 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -523,11 +523,6 @@  static inline ushort *configuration_get_cmap(void)
 #ifdef CONFIG_LCD_LOGO
 void bitmap_plot(int x, int y)
 {
-#ifdef CONFIG_ATMEL_LCD
-	uint *cmap = (uint *)bmp_logo_palette;
-#else
-	ushort *cmap = (ushort *)bmp_logo_palette;
-#endif
 	ushort i, j;
 	uchar *bmap;
 	uchar *fb;
@@ -545,44 +540,20 @@  void bitmap_plot(int x, int y)
 	fb   = (uchar *)(lcd_base + y * lcd_line_length + x);
 
 	if (NBITS(panel_info.vl_bpix) < 12) {
-		/* Leave room for default color map
-		 * default case: generic system with no cmap (most likely 16bpp)
-		 * cmap was set to the source palette, so no change is done.
-		 * This avoids even more ifdefs in the next stanza
-		 */
-#if defined(CONFIG_MPC823)
-		cmap = (ushort *) &(cp->lcd_cmap[BMP_LOGO_OFFSET * sizeof(ushort)]);
-#elif defined(CONFIG_ATMEL_LCD)
-		cmap = (uint *)configuration_get_cmap();
-#else
-		cmap = configuration_get_cmap();
-#endif
 
 		WATCHDOG_RESET();
 
 		/* Set color map */
 		for (i = 0; i < ARRAY_SIZE(bmp_logo_palette); ++i) {
-			ushort colreg = bmp_logo_palette[i];
-#ifdef CONFIG_ATMEL_LCD
-			uint lut_entry;
-#ifdef CONFIG_ATMEL_LCD_BGR555
-			lut_entry = ((colreg & 0x000F) << 11) |
-					((colreg & 0x00F0) <<  2) |
-					((colreg & 0x0F00) >>  7);
-#else /* CONFIG_ATMEL_LCD_RGB565 */
-			lut_entry = ((colreg & 0x000F) << 1) |
-					((colreg & 0x00F0) << 3) |
-					((colreg & 0x0F00) << 4);
-#endif
-			*(cmap + BMP_LOGO_OFFSET) = lut_entry;
-			cmap++;
-#else /* !CONFIG_ATMEL_LCD */
-#ifdef  CONFIG_SYS_INVERT_COLORS
-			*cmap++ = 0xffff - colreg;
-#else
-			*cmap++ = colreg;
-#endif
-#endif /* CONFIG_ATMEL_LCD */
+			/* use the most significant bits here */
+			uint8_t red   = ((bmp_logo_palette[i] >> 4) & 0xF0);
+			uint8_t green = ((bmp_logo_palette[i] >> 0) & 0xF0);
+			uint8_t blue  = ((bmp_logo_palette[i] << 4) & 0xF0);
+			debug("LCD: setup colreg %u with "
+			      "R: 0x%02x G: 0x%02x B: 0x%02x (0x%04x)\n",
+			      i+BMP_LOGO_OFFSET, red, green, blue, bmp_logo_palette[i]);
+			/* leave room for the default colormap here */
+			lcd_setcolreg(i+BMP_LOGO_OFFSET, red, green, blue);
 		}
 
 		WATCHDOG_RESET();
@@ -667,9 +638,6 @@  static inline void fb_put_word(uchar **fb, uchar **from)
 
 int lcd_display_bitmap(ulong bmp_image, int x, int y)
 {
-#if !defined(CONFIG_MCC200)
-	ushort *cmap = NULL;
-#endif
 	ushort *cmap_base = NULL;
 	ushort i, j;
 	uchar *fb;
@@ -716,34 +684,18 @@  int lcd_display_bitmap(ulong bmp_image, int x, int y)
 #if !defined(CONFIG_MCC200)
 	/* MCC200 LCD doesn't need CMAP, supports 1bpp b&w only */
 	if (bmp_bpix == 8) {
-		cmap = configuration_get_cmap();
-		cmap_base = cmap;
+		cmap_base = configuration_get_cmap();
 
 		/* Set color map */
 		for (i = 0; i < colors; ++i) {
 			bmp_color_table_entry_t cte = bmp->color_table[i];
-#if !defined(CONFIG_ATMEL_LCD)
-			ushort colreg =
-				( ((cte.red)   << 8) & 0xf800) |
-				( ((cte.green) << 3) & 0x07e0) |
-				( ((cte.blue)  >> 3) & 0x001f) ;
-#ifdef CONFIG_SYS_INVERT_COLORS
-			*cmap = 0xffff - colreg;
-#else
-			*cmap = colreg;
-#endif
-#if defined(CONFIG_MPC823)
-			cmap--;
-#else
-			cmap++;
-#endif
-#else /* CONFIG_ATMEL_LCD */
+			debug("LCD: setup colreg %u with "
+			      "R: 0x%02x G: 0x%02x B: 0x%02x\n",
+			      i, cte.red, cte.green, cte.blue);
 			lcd_setcolreg(i, cte.red, cte.green, cte.blue);
-#endif
 		}
 	}
-#endif
-
+#else
 	/*
 	 *  BMP format for Monochrome assumes that the state of a
 	 * pixel is described on a per Bit basis, not per Byte.
@@ -754,7 +706,6 @@  int lcd_display_bitmap(ulong bmp_image, int x, int y)
 	 * their own ways, so make the converting to be MCC200
 	 * specific.
 	 */
-#if defined(CONFIG_MCC200)
 	if (bpix == 1) {
 		width = ((width + 7) & ~7) >> 3;
 		x     = ((x + 7) & ~7) >> 3;
@@ -786,6 +737,8 @@  int lcd_display_bitmap(ulong bmp_image, int x, int y)
 		else
 			byte_width = width * 2;
 
+		debug("LCD: draw %i b/pix image on %i b/pix display\n", bmp_bpix, bpix);
+
 		for (i = 0; i < height; ++i) {
 			WATCHDOG_RESET();
 			for (j = 0; j < width; j++) {