]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/lcd.c
Merge branch 'master' of git://git.denx.de/u-boot-mpc85xx
[karo-tx-uboot.git] / common / lcd.c
index 56bf067fb5e13dcc8c769044b844836d01ad92e2..feb913a7201354729d9f08b539352d66ad90cd55 100644 (file)
 #endif
 #include <lcd.h>
 #include <watchdog.h>
-
+#include <asm/unaligned.h>
 #include <splash.h>
+#include <asm/io.h>
+#include <asm/unaligned.h>
 
 #if defined(CONFIG_CPU_PXA25X) || defined(CONFIG_CPU_PXA27X) || \
        defined(CONFIG_CPU_MONAHANS)
 # endif
 #endif
 
+#ifdef CONFIG_SANDBOX
+#include <asm/sdl.h>
+#endif
+
 #ifndef CONFIG_LCD_ALIGNMENT
 #define CONFIG_LCD_ALIGNMENT PAGE_SIZE
 #endif
@@ -144,6 +150,13 @@ void lcd_sync(void)
        if (lcd_flush_dcache)
                flush_dcache_range((u32)lcd_base,
                        (u32)(lcd_base + lcd_get_size(&line_length)));
+#elif defined(CONFIG_SANDBOX) && defined(CONFIG_VIDEO_SANDBOX_SDL)
+       static ulong last_sync;
+
+       if (get_timer(last_sync) > 10) {
+               sandbox_sdl_sync(lcd_base);
+               last_sync = get_timer(0);
+       }
 #endif
 }
 
@@ -201,6 +214,11 @@ static inline void console_newline(void)
 
 /*----------------------------------------------------------------------*/
 
+static void lcd_stub_putc(struct stdio_dev *dev, const char c)
+{
+       lcd_putc(c);
+}
+
 void lcd_putc(const char c)
 {
        if (!lcd_is_enabled) {
@@ -240,6 +258,11 @@ void lcd_putc(const char c)
 
 /*----------------------------------------------------------------------*/
 
+static void lcd_stub_puts(struct stdio_dev *dev, const char *s)
+{
+       lcd_puts(s);
+}
+
 void lcd_puts(const char *s)
 {
        if (!lcd_is_enabled) {
@@ -403,7 +426,7 @@ int drv_lcd_init(void)
        struct stdio_dev lcddev;
        int rc;
 
-       lcd_base = (void *) gd->fb_base;
+       lcd_base = map_sysmem(gd->fb_base, 0);
 
        lcd_init(lcd_base);             /* LCD initialization */
 
@@ -413,8 +436,8 @@ int drv_lcd_init(void)
        strcpy(lcddev.name, "lcd");
        lcddev.ext   = 0;                       /* No extensions */
        lcddev.flags = DEV_FLAGS_OUTPUT;        /* Output only */
-       lcddev.putc  = lcd_putc;                /* 'putc' function */
-       lcddev.puts  = lcd_puts;                /* 'puts' function */
+       lcddev.putc  = lcd_stub_putc;           /* 'putc' function */
+       lcddev.puts  = lcd_stub_puts;           /* 'puts' function */
 
        rc = stdio_register(&lcddev);
 
@@ -494,8 +517,8 @@ static int lcd_init(void *lcdbase)
         * by setting up gd->fb_base. Check for this condition and fixup
         * 'lcd_base' address.
         */
-       if ((unsigned long)lcdbase != gd->fb_base)
-               lcd_base = (void *)gd->fb_base;
+       if (map_to_sysmem(lcdbase) != gd->fb_base)
+               lcd_base = map_sysmem(gd->fb_base, 0);
 
        debug("[LCD] Using LCD frambuffer at %p\n", lcd_base);
 
@@ -777,9 +800,9 @@ static void lcd_display_rle8_bitmap(bmp_image_t *bmp, ushort *cmap, uchar *fb,
        int x, y;
        int decode = 1;
 
-       width = le32_to_cpu(bmp->header.width);
-       height = le32_to_cpu(bmp->header.height);
-       bmap = (uchar *)bmp + le32_to_cpu(bmp->header.data_offset);
+       width = get_unaligned_le32(&bmp->header.width);
+       height = get_unaligned_le32(&bmp->header.height);
+       bmap = (uchar *)bmp + get_unaligned_le32(&bmp->header.data_offset);
 
        x = 0;
        y = height - 1;
@@ -886,7 +909,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
        ushort *cmap_base = NULL;
        ushort i, j;
        uchar *fb;
-       bmp_image_t *bmp=(bmp_image_t *)bmp_image;
+       bmp_image_t *bmp = (bmp_image_t *)map_sysmem(bmp_image, 0);
        uchar *bmap;
        ushort padded_width;
        unsigned long width, height, byte_width;
@@ -900,9 +923,10 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
                return 1;
        }
 
-       width = le32_to_cpu(bmp->header.width);
-       height = le32_to_cpu(bmp->header.height);
-       bmp_bpix = le16_to_cpu(bmp->header.bit_count);
+       width = get_unaligned_le32(&bmp->header.width);
+       height = get_unaligned_le32(&bmp->header.height);
+       bmp_bpix = get_unaligned_le16(&bmp->header.bit_count);
+
        colors = 1 << bmp_bpix;
 
        bpix = NBITS(panel_info.vl_bpix);
@@ -917,9 +941,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
        /* We support displaying 8bpp BMPs on 16bpp LCDs */
        if (bpix != bmp_bpix && !(bmp_bpix == 8 && bpix == 16)) {
                printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
-                       bpix,
-                       le16_to_cpu(bmp->header.bit_count));
-
+                       bpix, get_unaligned_le16(&bmp->header.bit_count));
                return 1;
        }
 
@@ -956,7 +978,6 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
                }
        }
 #endif
-
        /*
         *  BMP format for Monochrome assumes that the state of a
         * pixel is described on a per Bit basis, not per Byte.
@@ -987,15 +1008,16 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
        if ((y + height) > panel_info.vl_row)
                height = panel_info.vl_row - y;
 
-       bmap = (uchar *) bmp + le32_to_cpu(bmp->header.data_offset);
-       fb   = (uchar *) (lcd_base +
+       bmap = (uchar *)bmp + get_unaligned_le32(&bmp->header.data_offset);
+       fb   = (uchar *)(lcd_base +
                (y + height - 1) * lcd_line_length + x * bpix / 8);
 
        switch (bmp_bpix) {
        case 1: /* pass through */
        case 8:
 #ifdef CONFIG_LCD_BMP_RLE8
-               if (le32_to_cpu(bmp->header.compression) == BMP_BI_RLE8) {
+               u32 compression = get_unaligned_le32(&bmp->header.compression);
+               if (compression == BMP_BI_RLE8) {
                        if (bpix != 16) {
                                /* TODO implement render code for bpix != 16 */
                                printf("Error: only support 16 bpix");