]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
lcd: atmel: introduce lcd_logo_set_cmap
authorNikita Kiryanov <nikita@compulab.co.il>
Tue, 3 Feb 2015 11:32:24 +0000 (13:32 +0200)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 1 Sep 2015 11:41:25 +0000 (13:41 +0200)
Reduce the bitmap_plot #ifdef complexity by extracting Atmel-specific code for
setting cmap into a new function lcd_logo_set_cmap(), which is implemented in
atmel_lcdfb driver and defined as part of common/lcd.c api with a weak dummy
version. In the Atmel implementation, ARRAY_SIZE(bmp_logo_palette) is
switched for BMP_LOGO_COLORS to avoid having to include bmp_logo_data.h, which
would cause a compilation error because the logo data and palette arrays would
be defined twice.

This is a step towards cleaning bitmap_plot() of platform-specific code.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Bo Shen <voice.shen@atmel.com>
Tested-by: Josh Wu <josh.wu@atmel.com>
Cc: Bo Shen <voice.shen@atmel.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Anatolij Gustschin <agust@denx.de>
common/lcd.c
drivers/video/atmel_lcdfb.c

index 47a4f3533b09ab513d5f8acc3a189c9c2e649016..7a6e33c62be5621a3b6c2475401033d8800c13e2 100644 (file)
@@ -397,13 +397,13 @@ int lcd_getbgcolor(void)
 /************************************************************************/
 
 #ifdef CONFIG_LCD_LOGO
+__weak void lcd_logo_set_cmap(void)
+{
+}
+
 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;
@@ -429,8 +429,6 @@ void bitmap_plot(int x, int y)
                 */
 #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
@@ -438,25 +436,14 @@ void bitmap_plot(int x, int y)
                WATCHDOG_RESET();
 
                /* Set color map */
+#ifdef CONFIG_ATMEL_LCD
+               lcd_logo_set_cmap();
+#else
                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 */
                        *cmap++ = colreg;
-#endif /* CONFIG_ATMEL_LCD */
                }
+#endif
 
                WATCHDOG_RESET();
 
index 055c717f0db433014ba578ab0362a09e293ecd84..dea126c95f790a87a10c013022e29633628ffa09 100644 (file)
@@ -43,6 +43,32 @@ void fb_put_word(uchar **fb, uchar **from)
 }
 #endif
 
+#ifdef CONFIG_LCD_LOGO
+#include <bmp_logo.h>
+void lcd_logo_set_cmap(void)
+{
+       int i;
+       uint lut_entry;
+       ushort colreg;
+       uint *cmap = (uint *)configuration_get_cmap();
+
+       for (i = 0; i < BMP_LOGO_COLORS; ++i) {
+               colreg = bmp_logo_palette[i];
+#ifdef CONFIG_ATMEL_LCD_BGR555
+               lut_entry = ((colreg & 0x000F) << 11) |
+                               ((colreg & 0x00F0) <<  2) |
+                               ((colreg & 0x0F00) >>  7);
+#else
+               lut_entry = ((colreg & 0x000F) << 1) |
+                               ((colreg & 0x00F0) << 3) |
+                               ((colreg & 0x0F00) << 4);
+#endif
+               *(cmap + BMP_LOGO_OFFSET) = lut_entry;
+               cmap++;
+       }
+}
+#endif
+
 void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
 {
 #if defined(CONFIG_ATMEL_LCD_BGR555)