]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
common lcd: simplify lcd_display_bitmap
authorNikita Kiryanov <nikita@compulab.co.il>
Thu, 9 Aug 2012 00:14:53 +0000 (00:14 +0000)
committerAnatolij Gustschin <agust@denx.de>
Wed, 5 Sep 2012 08:28:31 +0000 (10:28 +0200)
Move highly platform dependant code into its own functions to reduce the
number of #ifdefs in lcd_display_bitmap

To avoid breaking the mcc200 board which does not #define
CONFIG_CMD_BMP, this patch also implements bmp_display() for mcc200.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
board/mcc200/lcd.c
common/lcd.c

index d8f754c4a18ff0606b585402c9e89762df20e3d6..893f4b7cb8d1462e6cbeea3ffa1807fd69dc0940 100644 (file)
@@ -21,6 +21,7 @@
 #include <common.h>
 #include <lcd.h>
 #include <mpc5xxx.h>
+#include <malloc.h>
 
 #ifdef CONFIG_LCD
 
@@ -210,4 +211,23 @@ void show_progress (int size, int tot)
 }
 
 #endif
+
+int bmp_display(ulong addr, int x, int y)
+{
+       int ret;
+       bmp_image_t *bmp = (bmp_image_t *)addr;
+
+       if (!bmp) {
+               printf("There is no valid bmp file at the given address\n");
+               return 1;
+       }
+
+       ret = lcd_display_bitmap((ulong)bmp, x, y);
+
+       if ((unsigned long)bmp != addr)
+               free(bmp);
+
+       return ret;
+}
+
 #endif /* CONFIG_LCD */
index 0f93eae9df1c54683c4ff2a07bcd49475987172b..88dfa51d779c76b097528235e941102076eaa1b6 100644 (file)
@@ -636,6 +636,29 @@ static void splash_align_axis(int *axis, unsigned long panel_size,
 }
 #endif
 
+#if defined CONFIG_CPU_PXA || defined(CONFIG_ATMEL_LCD)
+#define FB_PUT_BYTE(fb, from) *(fb)++ = *(from)++
+#elif defined(CONFIG_MPC823) || defined(CONFIG_MCC200)
+#define FB_PUT_BYTE(fb, from) *(fb)++ = (255 - *(from)++)
+#endif
+
+#if defined(CONFIG_BMP_16BPP)
+#if defined(CONFIG_ATMEL_LCD_BGR555)
+static inline void fb_put_word(uchar **fb, uchar **from)
+{
+       *(*fb)++ = (((*from)[0] & 0x1f) << 2) | ((*from)[1] & 0x03);
+       *(*fb)++ = ((*from)[0] & 0xe0) | (((*from)[1] & 0x7c) >> 2);
+       *from += 2;
+}
+#else
+static inline void fb_put_word(uchar **fb, uchar **from)
+{
+       *(*fb)++ = *(*from)++;
+       *(*fb)++ = *(*from)++;
+}
+#endif
+#endif /* CONFIG_BMP_16BPP */
+
 int lcd_display_bitmap(ulong bmp_image, int x, int y)
 {
 #if !defined(CONFIG_MCC200)
@@ -761,11 +784,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
                        WATCHDOG_RESET();
                        for (j = 0; j < width; j++) {
                                if (bpix != 16) {
-#if defined(CONFIG_CPU_PXA) || defined(CONFIG_ATMEL_LCD)
-                                       *(fb++) = *(bmap++);
-#elif defined(CONFIG_MPC823) || defined(CONFIG_MCC200)
-                                       *(fb++) = 255 - *(bmap++);
-#endif
+                                       FB_PUT_BYTE(fb, bmap);
                                } else {
                                        *(uint16_t *)fb = cmap_base[*(bmap++)];
                                        fb += sizeof(uint16_t) / sizeof(*fb);
@@ -780,18 +799,9 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
        case 16:
                for (i = 0; i < height; ++i) {
                        WATCHDOG_RESET();
-                       for (j = 0; j < width; j++) {
-#if defined(CONFIG_ATMEL_LCD_BGR555)
-                               *(fb++) = ((bmap[0] & 0x1f) << 2) |
-                                       (bmap[1] & 0x03);
-                               *(fb++) = (bmap[0] & 0xe0) |
-                                       ((bmap[1] & 0x7c) >> 2);
-                               bmap += 2;
-#else
-                               *(fb++) = *(bmap++);
-                               *(fb++) = *(bmap++);
-#endif
-                       }
+                       for (j = 0; j < width; j++)
+                               fb_put_word(&fb, &bmap);
+
                        bmap += (padded_line - width) * 2;
                        fb   -= (width * 2 + lcd_line_length);
                }