]> git.sur5r.net Git - u-boot/blobdiff - board/esd/common/lcd.c
ppc4xx: use correct io accessors for esd's LCD code
[u-boot] / board / esd / common / lcd.c
index 22b49ce25684ed7962bcc83c93f3d4ffca477813..71d5058e4046fd29dd7703fbdbaa41ab3721cf1c 100644 (file)
@@ -24,6 +24,7 @@
  * MA 02111-1307 USA
  */
 
+#include "asm/io.h"
 #include "lcd.h"
 
 
@@ -81,7 +82,7 @@ void lcd_bmp(uchar *logo_bmp)
        uchar *ptr;
        ushort *ptr2;
        ushort val;
-       unsigned char *dst;
+       unsigned char *dst = NULL;
        int x, y;
        int width, height, bpp, colors, line_size;
        int header_size;
@@ -89,7 +90,6 @@ void lcd_bmp(uchar *logo_bmp)
        unsigned char r, g, b;
        BITMAPINFOHEADER *bm_info;
        ulong len;
-       int do_free = 0;
 
        /*
         * Check for bmp mark 'BM'
@@ -100,11 +100,17 @@ void lcd_bmp(uchar *logo_bmp)
                 * Decompress bmp image
                 */
                len = CFG_VIDEO_LOGO_MAX_SIZE;
-               dst = malloc(CFG_LCD_LOGO_MAX_SIZE);
-               do_free = 1;
-               if (gunzip(dst, CFG_LCD_LOGO_MAX_SIZE, (uchar *)logo_bmp, &len) != 0) {
+               dst = malloc(CFG_VIDEO_LOGO_MAX_SIZE);
+               if (dst == NULL) {
+                       printf("Error: malloc in gunzip failed!\n");
                        return;
                }
+               if (gunzip(dst, CFG_VIDEO_LOGO_MAX_SIZE, (uchar *)logo_bmp, &len) != 0) {
+                       return;
+               }
+               if (len == CFG_VIDEO_LOGO_MAX_SIZE) {
+                       printf("Image could be truncated (increase CFG_VIDEO_LOGO_MAX_SIZE)!\n");
+               }
 
                /*
                 * Check for bmp mark 'BM'
@@ -147,7 +153,9 @@ void lcd_bmp(uchar *logo_bmp)
                break;
        default:
                printf("LCD: Unknown bpp (%d) im image!\n", bpp);
-               free(dst);
+               if ((dst != NULL) && (dst != (uchar *)logo_bmp)) {
+                       free(dst);
+               }
                return;
        }
        printf(" (%d*%d, %dbpp)\n", width, height, bpp);
@@ -205,7 +213,7 @@ void lcd_bmp(uchar *logo_bmp)
                }
        }
 
-       if (do_free) {
+       if ((dst != NULL) && (dst != (uchar *)logo_bmp)) {
                free(dst);
        }
 }
@@ -222,7 +230,10 @@ void lcd_init(uchar *lcd_reg, uchar *lcd_mem, S1D_REGS *regs, int reg_count,
        /*
         * Detect epson
         */
-       if (lcd_reg[0] == 0x1c) {
+       out_8(&lcd_reg[0], 0x00);
+       out_8(&lcd_reg[1], 0x00);
+
+             if (in_8(&lcd_reg[0]) == 0x1c) {
                /*
                 * Big epson detected
                 */
@@ -231,7 +242,7 @@ void lcd_init(uchar *lcd_reg, uchar *lcd_mem, S1D_REGS *regs, int reg_count,
                palette_value = 0x1e4;
                lcd_depth = 16;
                puts("LCD:   S1D13806");
-       } else if (lcd_reg[1] == 0x1c) {
+             } else if (in_8(&lcd_reg[1]) == 0x1c) {
                /*
                 * Big epson detected (with register swap bug)
                 */
@@ -240,7 +251,7 @@ void lcd_init(uchar *lcd_reg, uchar *lcd_mem, S1D_REGS *regs, int reg_count,
                palette_value = 0x1e5;
                lcd_depth = 16;
                puts("LCD:   S1D13806S");
-       } else if (lcd_reg[0] == 0x18) {
+             } else if (in_8(&lcd_reg[0]) == 0x18) {
                /*
                 * Small epson detected (704)
                 */
@@ -249,7 +260,7 @@ void lcd_init(uchar *lcd_reg, uchar *lcd_mem, S1D_REGS *regs, int reg_count,
                palette_value = 0x17;
                lcd_depth = 8;
                puts("LCD:   S1D13704");
-       } else if (lcd_reg[0x10000] == 0x24) {
+             } else if (in_8(&lcd_reg[0x10000]) == 0x24) {
                /*
                 * Small epson detected (705)
                 */
@@ -267,7 +278,7 @@ void lcd_init(uchar *lcd_reg, uchar *lcd_mem, S1D_REGS *regs, int reg_count,
        /*
         * Setup lcd controller regs
         */
-       for (i = 0; i<reg_count; i++) {
+       for (i = 0; i < reg_count; i++) {
                s1dReg = regs[i].Index;
                if (reg_byte_swap) {
                        if ((s1dReg & 0x0001) == 0)
@@ -291,7 +302,7 @@ void lcd_init(uchar *lcd_reg, uchar *lcd_mem, S1D_REGS *regs, int reg_count,
        lcd_bmp(logo_bmp);
 }
 
-
+#ifdef CONFIG_VIDEO_SM501
 int do_esdbmp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
        ulong addr;
@@ -324,3 +335,4 @@ U_BOOT_CMD(
        "esdbmp   - display BMP image\n",
        "<imageAddr> - display image\n"
 );
+#endif