]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
lcd: introduce lcd_set_cmap
authorNikita Kiryanov <nikita@compulab.co.il>
Tue, 3 Feb 2015 11:32:27 +0000 (13:32 +0200)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 1 Sep 2015 11:45:16 +0000 (13:45 +0200)
Reduce the lcd_display_bitmap #ifdef complexity by extracting Atmel-specific
code for setting cmap for bitmap images into a new function lcd_set_cmap().
A default version is implemented with the remainder of the 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 2e968cc609fd900aa311b21efef326d3b0847728..705c66d06f8745817733eb4cda15e5637a4def2f 100644 (file)
@@ -639,15 +639,27 @@ __weak void fb_put_word(uchar **fb, uchar **from)
 }
 #endif /* CONFIG_BMP_16BPP */
 
-static inline bmp_color_table_entry_t *get_color_table(bmp_image_t *bmp)
+__weak void lcd_set_cmap(bmp_image_t *bmp, unsigned colors)
 {
-       bmp_header_t *bh = &bmp->header;
-       return (void *)bmp + offsetof(bmp_header_t, size) + bh->size;
+       int i;
+       bmp_color_table_entry_t cte;
+       ushort *cmap = configuration_get_cmap();
+
+       for (i = 0; i < colors; ++i) {
+               cte = bmp->color_table[i];
+               *cmap = (((cte.red)   << 8) & 0xf800) |
+                       (((cte.green) << 3) & 0x07e0) |
+                       (((cte.blue)  >> 3) & 0x001f);
+#if defined(CONFIG_MPC823)
+               cmap--;
+#else
+               cmap++;
+#endif
+       }
 }
 
 int lcd_display_bitmap(ulong bmp_image, int x, int y)
 {
-       ushort *cmap = NULL;
        ushort *cmap_base = NULL;
        ushort i, j;
        uchar *fb;
@@ -697,29 +709,8 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
        debug("Display-bmp: %lu x %lu  with %llu colors\n",
                width, height, colors);
 
-       cte = get_color_table(bmp);
-       if (bmp_bpix == 8) {
-               cmap = configuration_get_cmap();
-               cmap_base = cmap;
-
-               /* Set color map */
-               for (i = 0; i < colors; ++i) {
-#if !defined(CONFIG_ATMEL_LCD)
-                       ushort colreg =
-                               ( ((cte[i].red)   << 8) & 0xf800) |
-                               ( ((cte[i].green) << 3) & 0x07e0) |
-                               ( ((cte[i].blue)  >> 3) & 0x001f) ;
-                       *cmap = colreg;
-#if defined(CONFIG_MPC823)
-                       cmap--;
-#else
-                       cmap++;
-#endif
-#else /* CONFIG_ATMEL_LCD */
-                       lcd_setcolreg(i, cte[i].red, cte[i].green, cte[i].blue);
-#endif
-               }
-       }
+       if (bmp_bpix == 8)
+               lcd_set_cmap(bmp, colors);
 
        padded_width = ALIGN(width, 4);
 
@@ -742,6 +733,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
        switch (bmp_bpix) {
        case 1: /* pass through */
        case 8: {
+               cmap_base = configuration_get_cmap();
 #ifdef CONFIG_LCD_BMP_RLE8
                u32 compression = get_unaligned_le32(&bmp->header.compression);
                if (compression == BMP_BI_RLE8) {
index dea126c95f790a87a10c013022e29633628ffa09..4ed3a49beca894ec797b71196702555478b838af 100644 (file)
@@ -11,6 +11,7 @@
 #include <asm/arch/gpio.h>
 #include <asm/arch/clk.h>
 #include <lcd.h>
+#include <bmp_layout.h>
 #include <atmel_lcdc.h>
 
 /* configurable parameters */
@@ -80,6 +81,16 @@ void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
 #endif
 }
 
+void lcd_set_cmap(bmp_image_t *bmp, unsigned colors)
+{
+       int i;
+
+       for (i = 0; i < colors; ++i) {
+               bmp_color_table_entry_t cte = bmp->color_table[i];
+               lcd_setcolreg(i, cte.red, cte.green, cte.blue);
+       }
+}
+
 void lcd_ctrl_init(void *lcdbase)
 {
        unsigned long value;