All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] common/lcd: use lcd_setcolreg() to setup CLUT
@ 2012-11-02 14:18 Andreas Bießmann
  2012-11-06 10:13 ` [U-Boot] [PATCH v3 0/2] rework common/lcd Andreas Bießmann
  0 siblings, 1 reply; 14+ messages in thread
From: Andreas Bießmann @ 2012-11-02 14:18 UTC (permalink / raw)
  To: u-boot

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

This patch requires http://patchwork.ozlabs.org/patch/194861/ to compile all
arm boards cleanly!

Runtime tested on at91sam9263ek, please test and comment
Build tested for AVR32 and arm

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

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++) {
-- 
1.7.10.4

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

end of thread, other threads:[~2012-11-10 13:13 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-02 14:18 [U-Boot] [PATCH v2] common/lcd: use lcd_setcolreg() to setup CLUT Andreas Bießmann
2012-11-06 10:13 ` [U-Boot] [PATCH v3 0/2] rework common/lcd Andreas Bießmann
2012-11-06 10:13   ` [U-Boot] [PATCH v3 1/2] video: atmel: implement lcd_setcolreg funtion Andreas Bießmann
2012-11-06 22:54     ` Marek Vasut
2012-11-07  1:26       ` Bo Shen
2012-11-07 13:26         ` Marek Vasut
2012-11-08  3:06           ` Bo Shen
2012-11-08  7:53             ` Andreas Bießmann
2012-11-08  9:10     ` [U-Boot] [PATCH v4] " Bo Shen
2012-11-08 13:08       ` Marek Vasut
2012-11-09  3:46         ` Bo Shen
2012-11-09  3:49     ` [U-Boot] [Patch v5] video: atmel: implement lcd_setcolreg function Bo Shen
2012-11-10 13:13       ` Anatolij Gustschin
2012-11-06 10:13   ` [U-Boot] [PATCH v3 2/2] common/lcd: use lcd_setcolreg() to setup CLUT Andreas Bießmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.