wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Common LCD routines for supported CPUs |
| 3 | * |
| 4 | * (C) Copyright 2001-2002 |
| 5 | * Wolfgang Denk, DENX Software Engineering -- wd@denx.de |
| 6 | * |
Wolfgang Denk | 3765b3e | 2013-10-07 13:07:26 +0200 | [diff] [blame] | 7 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | /************************************************************************/ |
| 11 | /* ** HEADER FILES */ |
| 12 | /************************************************************************/ |
| 13 | |
| 14 | /* #define DEBUG */ |
| 15 | |
| 16 | #include <config.h> |
| 17 | #include <common.h> |
| 18 | #include <command.h> |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 19 | #include <stdarg.h> |
Nikita Kiryanov | c088048 | 2013-02-24 21:28:43 +0000 | [diff] [blame] | 20 | #include <search.h> |
| 21 | #include <env_callback.h> |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 22 | #include <linux/types.h> |
Jean-Christophe PLAGNIOL-VILLARD | 52cb4d4 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 23 | #include <stdio_dev.h> |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 24 | #if defined(CONFIG_POST) |
| 25 | #include <post.h> |
| 26 | #endif |
| 27 | #include <lcd.h> |
wdenk | 8b0bfc6 | 2005-04-03 23:11:38 +0000 | [diff] [blame] | 28 | #include <watchdog.h> |
Przemyslaw Marczak | dca2a1c | 2014-01-22 11:24:13 +0100 | [diff] [blame] | 29 | #include <asm/unaligned.h> |
Robert Winkler | dd4425e | 2013-06-17 11:31:29 -0700 | [diff] [blame] | 30 | #include <splash.h> |
Simon Glass | 7d95f2a | 2014-02-27 13:26:19 -0700 | [diff] [blame] | 31 | #include <asm/io.h> |
| 32 | #include <asm/unaligned.h> |
Hans de Goede | 11b8dfa | 2014-11-19 13:53:27 +0100 | [diff] [blame] | 33 | #include <fdt_support.h> |
Robert Winkler | dd4425e | 2013-06-17 11:31:29 -0700 | [diff] [blame] | 34 | |
Marek Vasut | abc20ab | 2011-11-26 07:20:07 +0100 | [diff] [blame] | 35 | #if defined(CONFIG_CPU_PXA25X) || defined(CONFIG_CPU_PXA27X) || \ |
| 36 | defined(CONFIG_CPU_MONAHANS) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 37 | #include <asm/byteorder.h> |
| 38 | #endif |
| 39 | |
| 40 | #if defined(CONFIG_MPC823) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 41 | #include <lcdvideo.h> |
| 42 | #endif |
| 43 | |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 44 | #if defined(CONFIG_ATMEL_LCD) |
| 45 | #include <atmel_lcdc.h> |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 46 | #endif |
| 47 | |
Stephen Warren | 6a195d2 | 2013-05-27 18:31:17 +0000 | [diff] [blame] | 48 | #if defined(CONFIG_LCD_DT_SIMPLEFB) |
| 49 | #include <libfdt.h> |
| 50 | #endif |
| 51 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 52 | /************************************************************************/ |
| 53 | /* ** FONT DATA */ |
| 54 | /************************************************************************/ |
| 55 | #include <video_font.h> /* Get font data, width and height */ |
| 56 | |
wdenk | 88804d1 | 2005-07-04 00:03:16 +0000 | [diff] [blame] | 57 | /************************************************************************/ |
| 58 | /* ** LOGO DATA */ |
| 59 | /************************************************************************/ |
| 60 | #ifdef CONFIG_LCD_LOGO |
| 61 | # include <bmp_logo.h> /* Get logo data, width and height */ |
Che-Liang Chiou | c270730 | 2011-10-20 23:04:20 +0000 | [diff] [blame] | 62 | # include <bmp_logo_data.h> |
Alessandro Rubini | acb1386 | 2010-03-13 17:44:08 +0100 | [diff] [blame] | 63 | # if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET) && (LCD_BPP != LCD_COLOR16) |
wdenk | 88804d1 | 2005-07-04 00:03:16 +0000 | [diff] [blame] | 64 | # error Default Color Map overlaps with Logo Color Map |
| 65 | # endif |
| 66 | #endif |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 67 | |
Simon Glass | 7d95f2a | 2014-02-27 13:26:19 -0700 | [diff] [blame] | 68 | #ifdef CONFIG_SANDBOX |
| 69 | #include <asm/sdl.h> |
| 70 | #endif |
| 71 | |
Simon Glass | 676d319 | 2012-10-17 13:24:54 +0000 | [diff] [blame] | 72 | #ifndef CONFIG_LCD_ALIGNMENT |
| 73 | #define CONFIG_LCD_ALIGNMENT PAGE_SIZE |
| 74 | #endif |
| 75 | |
Nikita Kiryanov | a7de295 | 2014-12-08 17:14:42 +0200 | [diff] [blame] | 76 | #if (LCD_BPP != LCD_COLOR8) && (LCD_BPP != LCD_COLOR16) && \ |
| 77 | (LCD_BPP != LCD_COLOR32) |
Jeroen Hofstee | a5796c5 | 2013-01-12 12:07:59 +0000 | [diff] [blame] | 78 | # error Unsupported LCD BPP. |
| 79 | #endif |
| 80 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 81 | DECLARE_GLOBAL_DATA_PTR; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 82 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 83 | static int lcd_init(void *lcdbase); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 84 | |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 85 | static void *lcd_logo(void); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 86 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 87 | static void lcd_setfgcolor(int color); |
| 88 | static void lcd_setbgcolor(int color); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 89 | |
Wolfgang Denk | 46d1d5d | 2013-01-05 09:45:48 +0000 | [diff] [blame] | 90 | static int lcd_color_fg; |
| 91 | static int lcd_color_bg; |
Jeroen Hofstee | f1d205a | 2013-01-22 10:44:11 +0000 | [diff] [blame] | 92 | int lcd_line_length; |
Wolfgang Denk | 46d1d5d | 2013-01-05 09:45:48 +0000 | [diff] [blame] | 93 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 94 | char lcd_is_enabled = 0; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 95 | |
Jeroen Hofstee | 00a0ca5 | 2013-01-22 10:44:12 +0000 | [diff] [blame] | 96 | static void *lcd_base; /* Start of framebuffer memory */ |
Jeroen Hofstee | f1d205a | 2013-01-22 10:44:11 +0000 | [diff] [blame] | 97 | |
Simon Glass | 9a8efc4 | 2012-10-30 13:40:18 +0000 | [diff] [blame] | 98 | static char lcd_flush_dcache; /* 1 to flush dcache after each lcd update */ |
| 99 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 100 | /************************************************************************/ |
| 101 | |
Simon Glass | 9a8efc4 | 2012-10-30 13:40:18 +0000 | [diff] [blame] | 102 | /* Flush LCD activity to the caches */ |
| 103 | void lcd_sync(void) |
| 104 | { |
| 105 | /* |
| 106 | * flush_dcache_range() is declared in common.h but it seems that some |
| 107 | * architectures do not actually implement it. Is there a way to find |
| 108 | * out whether it exists? For now, ARM is safe. |
| 109 | */ |
| 110 | #if defined(CONFIG_ARM) && !defined(CONFIG_SYS_DCACHE_OFF) |
| 111 | int line_length; |
| 112 | |
| 113 | if (lcd_flush_dcache) |
| 114 | flush_dcache_range((u32)lcd_base, |
| 115 | (u32)(lcd_base + lcd_get_size(&line_length))); |
Simon Glass | 7d95f2a | 2014-02-27 13:26:19 -0700 | [diff] [blame] | 116 | #elif defined(CONFIG_SANDBOX) && defined(CONFIG_VIDEO_SANDBOX_SDL) |
| 117 | static ulong last_sync; |
| 118 | |
| 119 | if (get_timer(last_sync) > 10) { |
| 120 | sandbox_sdl_sync(lcd_base); |
| 121 | last_sync = get_timer(0); |
| 122 | } |
Simon Glass | 9a8efc4 | 2012-10-30 13:40:18 +0000 | [diff] [blame] | 123 | #endif |
| 124 | } |
| 125 | |
| 126 | void lcd_set_flush_dcache(int flush) |
| 127 | { |
| 128 | lcd_flush_dcache = (flush != 0); |
| 129 | } |
| 130 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 131 | /*----------------------------------------------------------------------*/ |
| 132 | |
Simon Glass | 709ea54 | 2014-07-23 06:54:59 -0600 | [diff] [blame] | 133 | static void lcd_stub_putc(struct stdio_dev *dev, const char c) |
| 134 | { |
| 135 | lcd_putc(c); |
| 136 | } |
| 137 | |
Simon Glass | 709ea54 | 2014-07-23 06:54:59 -0600 | [diff] [blame] | 138 | static void lcd_stub_puts(struct stdio_dev *dev, const char *s) |
| 139 | { |
| 140 | lcd_puts(s); |
| 141 | } |
| 142 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 143 | /************************************************************************/ |
| 144 | /** Small utility to check that you got the colours right */ |
| 145 | /************************************************************************/ |
| 146 | #ifdef LCD_TEST_PATTERN |
| 147 | |
| 148 | #define N_BLK_VERT 2 |
| 149 | #define N_BLK_HOR 3 |
| 150 | |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 151 | static int test_colors[N_BLK_HOR * N_BLK_VERT] = { |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 152 | CONSOLE_COLOR_RED, CONSOLE_COLOR_GREEN, CONSOLE_COLOR_YELLOW, |
| 153 | CONSOLE_COLOR_BLUE, CONSOLE_COLOR_MAGENTA, CONSOLE_COLOR_CYAN, |
| 154 | }; |
| 155 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 156 | static void test_pattern(void) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 157 | { |
| 158 | ushort v_max = panel_info.vl_row; |
| 159 | ushort h_max = panel_info.vl_col; |
| 160 | ushort v_step = (v_max + N_BLK_VERT - 1) / N_BLK_VERT; |
| 161 | ushort h_step = (h_max + N_BLK_HOR - 1) / N_BLK_HOR; |
| 162 | ushort v, h; |
| 163 | uchar *pix = (uchar *)lcd_base; |
| 164 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 165 | printf("[LCD] Test Pattern: %d x %d [%d x %d]\n", |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 166 | h_max, v_max, h_step, v_step); |
| 167 | |
| 168 | /* WARNING: Code silently assumes 8bit/pixel */ |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 169 | for (v = 0; v < v_max; ++v) { |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 170 | uchar iy = v / v_step; |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 171 | for (h = 0; h < h_max; ++h) { |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 172 | uchar ix = N_BLK_HOR * iy + h / h_step; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 173 | *pix++ = test_colors[ix]; |
| 174 | } |
| 175 | } |
| 176 | } |
| 177 | #endif /* LCD_TEST_PATTERN */ |
| 178 | |
| 179 | |
| 180 | /************************************************************************/ |
| 181 | /* ** GENERIC Initialization Routines */ |
| 182 | /************************************************************************/ |
Anatolij Gustschin | cefa471 | 2013-11-09 11:00:09 +0100 | [diff] [blame] | 183 | /* |
| 184 | * With most lcd drivers the line length is set up |
| 185 | * by calculating it from panel_info parameters. Some |
| 186 | * drivers need to calculate the line length differently, |
| 187 | * so make the function weak to allow overriding it. |
| 188 | */ |
| 189 | __weak int lcd_get_size(int *line_length) |
Simon Glass | 676d319 | 2012-10-17 13:24:54 +0000 | [diff] [blame] | 190 | { |
| 191 | *line_length = (panel_info.vl_col * NBITS(panel_info.vl_bpix)) / 8; |
| 192 | return *line_length * panel_info.vl_row; |
| 193 | } |
| 194 | |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 195 | int drv_lcd_init(void) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 196 | { |
Jean-Christophe PLAGNIOL-VILLARD | 52cb4d4 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 197 | struct stdio_dev lcddev; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 198 | int rc; |
| 199 | |
Simon Glass | 7d95f2a | 2014-02-27 13:26:19 -0700 | [diff] [blame] | 200 | lcd_base = map_sysmem(gd->fb_base, 0); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 201 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 202 | lcd_init(lcd_base); /* LCD initialization */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 203 | |
| 204 | /* Device initialization */ |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 205 | memset(&lcddev, 0, sizeof(lcddev)); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 206 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 207 | strcpy(lcddev.name, "lcd"); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 208 | lcddev.ext = 0; /* No extensions */ |
| 209 | lcddev.flags = DEV_FLAGS_OUTPUT; /* Output only */ |
Simon Glass | 709ea54 | 2014-07-23 06:54:59 -0600 | [diff] [blame] | 210 | lcddev.putc = lcd_stub_putc; /* 'putc' function */ |
| 211 | lcddev.puts = lcd_stub_puts; /* 'puts' function */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 212 | |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 213 | rc = stdio_register(&lcddev); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 214 | |
| 215 | return (rc == 0) ? 1 : rc; |
| 216 | } |
| 217 | |
| 218 | /*----------------------------------------------------------------------*/ |
Che-Liang Chiou | 0211090 | 2011-10-20 23:07:03 +0000 | [diff] [blame] | 219 | void lcd_clear(void) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 220 | { |
Nikita Kiryanov | 140beb9 | 2014-12-08 17:14:41 +0200 | [diff] [blame] | 221 | short console_rows, console_cols; |
Nikita Kiryanov | 4d03634 | 2014-12-08 17:14:43 +0200 | [diff] [blame] | 222 | int bg_color; |
Nikita Kiryanov | f4469f5 | 2014-12-08 17:14:38 +0200 | [diff] [blame] | 223 | #if LCD_BPP == LCD_COLOR8 |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 224 | /* Setting the palette */ |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 225 | lcd_setcolreg(CONSOLE_COLOR_BLACK, 0, 0, 0); |
| 226 | lcd_setcolreg(CONSOLE_COLOR_RED, 0xFF, 0, 0); |
| 227 | lcd_setcolreg(CONSOLE_COLOR_GREEN, 0, 0xFF, 0); |
| 228 | lcd_setcolreg(CONSOLE_COLOR_YELLOW, 0xFF, 0xFF, 0); |
| 229 | lcd_setcolreg(CONSOLE_COLOR_BLUE, 0, 0, 0xFF); |
| 230 | lcd_setcolreg(CONSOLE_COLOR_MAGENTA, 0xFF, 0, 0xFF); |
| 231 | lcd_setcolreg(CONSOLE_COLOR_CYAN, 0, 0xFF, 0xFF); |
| 232 | lcd_setcolreg(CONSOLE_COLOR_GREY, 0xAA, 0xAA, 0xAA); |
| 233 | lcd_setcolreg(CONSOLE_COLOR_WHITE, 0xFF, 0xFF, 0xFF); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 234 | #endif |
| 235 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 236 | #ifndef CONFIG_SYS_WHITE_ON_BLACK |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 237 | lcd_setfgcolor(CONSOLE_COLOR_BLACK); |
| 238 | lcd_setbgcolor(CONSOLE_COLOR_WHITE); |
Nikita Kiryanov | 4d03634 | 2014-12-08 17:14:43 +0200 | [diff] [blame] | 239 | bg_color = CONSOLE_COLOR_WHITE; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 240 | #else |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 241 | lcd_setfgcolor(CONSOLE_COLOR_WHITE); |
| 242 | lcd_setbgcolor(CONSOLE_COLOR_BLACK); |
Nikita Kiryanov | 4d03634 | 2014-12-08 17:14:43 +0200 | [diff] [blame] | 243 | bg_color = CONSOLE_COLOR_BLACK; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 244 | #endif /* CONFIG_SYS_WHITE_ON_BLACK */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 245 | |
| 246 | #ifdef LCD_TEST_PATTERN |
| 247 | test_pattern(); |
| 248 | #else |
| 249 | /* set framebuffer to background color */ |
Hannes Petermaier | 57d76a8 | 2014-03-07 18:55:40 +0100 | [diff] [blame] | 250 | #if (LCD_BPP != LCD_COLOR32) |
Nikita Kiryanov | 4d03634 | 2014-12-08 17:14:43 +0200 | [diff] [blame] | 251 | memset((char *)lcd_base, bg_color, lcd_line_length * panel_info.vl_row); |
Hannes Petermaier | 57d76a8 | 2014-03-07 18:55:40 +0100 | [diff] [blame] | 252 | #else |
| 253 | u32 *ppix = lcd_base; |
| 254 | u32 i; |
| 255 | for (i = 0; |
| 256 | i < (lcd_line_length * panel_info.vl_row)/NBYTES(panel_info.vl_bpix); |
| 257 | i++) { |
Nikita Kiryanov | 4d03634 | 2014-12-08 17:14:43 +0200 | [diff] [blame] | 258 | *ppix++ = bg_color; |
Hannes Petermaier | 57d76a8 | 2014-03-07 18:55:40 +0100 | [diff] [blame] | 259 | } |
| 260 | #endif |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 261 | #endif |
| 262 | /* Paint the logo and retrieve LCD base address */ |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 263 | debug("[LCD] Drawing the logo...\n"); |
Nikita Kiryanov | efd7c4a | 2014-12-08 17:14:40 +0200 | [diff] [blame] | 264 | #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO) |
| 265 | console_rows = (panel_info.vl_row - BMP_LOGO_HEIGHT); |
| 266 | console_rows /= VIDEO_FONT_HEIGHT; |
| 267 | #else |
| 268 | console_rows = panel_info.vl_row / VIDEO_FONT_HEIGHT; |
| 269 | #endif |
| 270 | console_cols = panel_info.vl_col / VIDEO_FONT_WIDTH; |
Bo Shen | 2af13d6 | 2015-01-28 09:13:22 +0800 | [diff] [blame] | 271 | lcd_init_console(lcd_base, console_rows, console_cols); |
Nikita Kiryanov | 140beb9 | 2014-12-08 17:14:41 +0200 | [diff] [blame] | 272 | lcd_init_console(lcd_logo(), console_rows, console_cols); |
Simon Glass | 9a8efc4 | 2012-10-30 13:40:18 +0000 | [diff] [blame] | 273 | lcd_sync(); |
| 274 | } |
| 275 | |
| 276 | static int do_lcd_clear(cmd_tbl_t *cmdtp, int flag, int argc, |
| 277 | char *const argv[]) |
| 278 | { |
| 279 | lcd_clear(); |
| 280 | return 0; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | U_BOOT_CMD( |
Che-Liang Chiou | 0211090 | 2011-10-20 23:07:03 +0000 | [diff] [blame] | 284 | cls, 1, 1, do_lcd_clear, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 285 | "clear screen", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 286 | "" |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 287 | ); |
| 288 | |
| 289 | /*----------------------------------------------------------------------*/ |
| 290 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 291 | static int lcd_init(void *lcdbase) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 292 | { |
| 293 | /* Initialize the lcd controller */ |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 294 | debug("[LCD] Initializing LCD frambuffer at %p\n", lcdbase); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 295 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 296 | lcd_ctrl_init(lcdbase); |
Anatolij Gustschin | 1d3dea1 | 2013-03-29 14:00:13 +0100 | [diff] [blame] | 297 | |
| 298 | /* |
Stephen Warren | 9316e14 | 2014-11-19 20:41:03 -0700 | [diff] [blame] | 299 | * lcd_ctrl_init() of some drivers (i.e. bcm2835 on rpi) ignores |
Anatolij Gustschin | 1d3dea1 | 2013-03-29 14:00:13 +0100 | [diff] [blame] | 300 | * the 'lcdbase' argument and uses custom lcd base address |
| 301 | * by setting up gd->fb_base. Check for this condition and fixup |
| 302 | * 'lcd_base' address. |
| 303 | */ |
Simon Glass | 7d95f2a | 2014-02-27 13:26:19 -0700 | [diff] [blame] | 304 | if (map_to_sysmem(lcdbase) != gd->fb_base) |
| 305 | lcd_base = map_sysmem(gd->fb_base, 0); |
Anatolij Gustschin | 1d3dea1 | 2013-03-29 14:00:13 +0100 | [diff] [blame] | 306 | |
| 307 | debug("[LCD] Using LCD frambuffer at %p\n", lcd_base); |
| 308 | |
Stephen Warren | 6d33071 | 2013-01-29 16:37:38 +0000 | [diff] [blame] | 309 | lcd_get_size(&lcd_line_length); |
Haavard Skinnemoen | 6f93d2b | 2008-09-01 16:21:21 +0200 | [diff] [blame] | 310 | lcd_is_enabled = 1; |
Che-Liang Chiou | 0211090 | 2011-10-20 23:07:03 +0000 | [diff] [blame] | 311 | lcd_clear(); |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 312 | lcd_enable(); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 313 | |
| 314 | /* Initialize the console */ |
Nikita Kiryanov | 140beb9 | 2014-12-08 17:14:41 +0200 | [diff] [blame] | 315 | lcd_set_col(0); |
wdenk | 88804d1 | 2005-07-04 00:03:16 +0000 | [diff] [blame] | 316 | #ifdef CONFIG_LCD_INFO_BELOW_LOGO |
Nikita Kiryanov | 140beb9 | 2014-12-08 17:14:41 +0200 | [diff] [blame] | 317 | lcd_set_row(7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 318 | #else |
Nikita Kiryanov | 140beb9 | 2014-12-08 17:14:41 +0200 | [diff] [blame] | 319 | lcd_set_row(1); /* leave 1 blank line below logo */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 320 | #endif |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 321 | |
| 322 | return 0; |
| 323 | } |
| 324 | |
| 325 | |
| 326 | /************************************************************************/ |
| 327 | /* ** ROM capable initialization part - needed to reserve FB memory */ |
| 328 | /************************************************************************/ |
| 329 | /* |
| 330 | * This is called early in the system initialization to grab memory |
| 331 | * for the LCD controller. |
| 332 | * Returns new address for monitor, after reserving LCD buffer memory |
| 333 | * |
| 334 | * Note that this is running from ROM, so no write access to global data. |
| 335 | */ |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 336 | ulong lcd_setmem(ulong addr) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 337 | { |
| 338 | ulong size; |
Simon Glass | 676d319 | 2012-10-17 13:24:54 +0000 | [diff] [blame] | 339 | int line_length; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 340 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 341 | debug("LCD panel info: %d x %d, %d bit/pix\n", panel_info.vl_col, |
| 342 | panel_info.vl_row, NBITS(panel_info.vl_bpix)); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 343 | |
Simon Glass | 676d319 | 2012-10-17 13:24:54 +0000 | [diff] [blame] | 344 | size = lcd_get_size(&line_length); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 345 | |
Simon Glass | 676d319 | 2012-10-17 13:24:54 +0000 | [diff] [blame] | 346 | /* Round up to nearest full page, or MMU section if defined */ |
| 347 | size = ALIGN(size, CONFIG_LCD_ALIGNMENT); |
| 348 | addr = ALIGN(addr - CONFIG_LCD_ALIGNMENT + 1, CONFIG_LCD_ALIGNMENT); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 349 | |
| 350 | /* Allocate pages for the frame buffer. */ |
| 351 | addr -= size; |
| 352 | |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 353 | debug("Reserving %ldk for LCD Framebuffer at: %08lx\n", |
| 354 | size >> 10, addr); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 355 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 356 | return addr; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | /*----------------------------------------------------------------------*/ |
| 360 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 361 | static void lcd_setfgcolor(int color) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 362 | { |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 363 | lcd_color_fg = color; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 364 | } |
| 365 | |
Nikita Kiryanov | 4d03634 | 2014-12-08 17:14:43 +0200 | [diff] [blame] | 366 | int lcd_getfgcolor(void) |
| 367 | { |
| 368 | return lcd_color_fg; |
| 369 | } |
| 370 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 371 | /*----------------------------------------------------------------------*/ |
| 372 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 373 | static void lcd_setbgcolor(int color) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 374 | { |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 375 | lcd_color_bg = color; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 376 | } |
| 377 | |
Nikita Kiryanov | 4d03634 | 2014-12-08 17:14:43 +0200 | [diff] [blame] | 378 | int lcd_getbgcolor(void) |
| 379 | { |
| 380 | return lcd_color_bg; |
| 381 | } |
| 382 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 383 | /************************************************************************/ |
| 384 | /* ** Chipset depending Bitmap / Logo stuff... */ |
| 385 | /************************************************************************/ |
Nikita Kiryanov | 203c37b | 2012-08-09 00:14:52 +0000 | [diff] [blame] | 386 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 387 | #ifdef CONFIG_LCD_LOGO |
Nikita Kiryanov | a02e948 | 2015-02-03 13:32:24 +0200 | [diff] [blame^] | 388 | __weak void lcd_logo_set_cmap(void) |
| 389 | { |
| 390 | } |
| 391 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 392 | void bitmap_plot(int x, int y) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 393 | { |
Nikita Kiryanov | 203c37b | 2012-08-09 00:14:52 +0000 | [diff] [blame] | 394 | ushort *cmap = (ushort *)bmp_logo_palette; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 395 | ushort i, j; |
| 396 | uchar *bmap; |
| 397 | uchar *fb; |
| 398 | ushort *fb16; |
Nikita Kiryanov | 203c37b | 2012-08-09 00:14:52 +0000 | [diff] [blame] | 399 | #if defined(CONFIG_MPC823) |
| 400 | immap_t *immr = (immap_t *) CONFIG_SYS_IMMR; |
| 401 | cpm8xx_t *cp = &(immr->im_cpm); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 402 | #endif |
Andre Renaud | 317461c | 2013-02-13 17:48:00 +0000 | [diff] [blame] | 403 | unsigned bpix = NBITS(panel_info.vl_bpix); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 404 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 405 | debug("Logo: width %d height %d colors %d cmap %d\n", |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 406 | BMP_LOGO_WIDTH, BMP_LOGO_HEIGHT, BMP_LOGO_COLORS, |
Anatolij Gustschin | 095407d | 2012-04-27 04:41:06 +0000 | [diff] [blame] | 407 | ARRAY_SIZE(bmp_logo_palette)); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 408 | |
| 409 | bmap = &bmp_logo_bitmap[0]; |
Andre Renaud | 317461c | 2013-02-13 17:48:00 +0000 | [diff] [blame] | 410 | fb = (uchar *)(lcd_base + y * lcd_line_length + x * bpix / 8); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 411 | |
Andre Renaud | 317461c | 2013-02-13 17:48:00 +0000 | [diff] [blame] | 412 | if (bpix < 12) { |
Nikita Kiryanov | 203c37b | 2012-08-09 00:14:52 +0000 | [diff] [blame] | 413 | /* Leave room for default color map |
| 414 | * default case: generic system with no cmap (most likely 16bpp) |
| 415 | * cmap was set to the source palette, so no change is done. |
| 416 | * This avoids even more ifdefs in the next stanza |
| 417 | */ |
| 418 | #if defined(CONFIG_MPC823) |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 419 | cmap = (ushort *) &(cp->lcd_cmap[BMP_LOGO_OFFSET * sizeof(ushort)]); |
Alessandro Rubini | acb1386 | 2010-03-13 17:44:08 +0100 | [diff] [blame] | 420 | #else |
Nikita Kiryanov | 203c37b | 2012-08-09 00:14:52 +0000 | [diff] [blame] | 421 | cmap = configuration_get_cmap(); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 422 | #endif |
| 423 | |
| 424 | WATCHDOG_RESET(); |
| 425 | |
| 426 | /* Set color map */ |
Nikita Kiryanov | a02e948 | 2015-02-03 13:32:24 +0200 | [diff] [blame^] | 427 | #ifdef CONFIG_ATMEL_LCD |
| 428 | lcd_logo_set_cmap(); |
| 429 | #else |
Anatolij Gustschin | 095407d | 2012-04-27 04:41:06 +0000 | [diff] [blame] | 430 | for (i = 0; i < ARRAY_SIZE(bmp_logo_palette); ++i) { |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 431 | ushort colreg = bmp_logo_palette[i]; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 432 | *cmap++ = colreg; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 433 | } |
Nikita Kiryanov | a02e948 | 2015-02-03 13:32:24 +0200 | [diff] [blame^] | 434 | #endif |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 435 | |
| 436 | WATCHDOG_RESET(); |
| 437 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 438 | for (i = 0; i < BMP_LOGO_HEIGHT; ++i) { |
| 439 | memcpy(fb, bmap, BMP_LOGO_WIDTH); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 440 | bmap += BMP_LOGO_WIDTH; |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 441 | fb += panel_info.vl_col; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 442 | } |
| 443 | } |
| 444 | else { /* true color mode */ |
Alessandro Rubini | acb1386 | 2010-03-13 17:44:08 +0100 | [diff] [blame] | 445 | u16 col16; |
Andre Renaud | 317461c | 2013-02-13 17:48:00 +0000 | [diff] [blame] | 446 | fb16 = (ushort *)fb; |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 447 | for (i = 0; i < BMP_LOGO_HEIGHT; ++i) { |
| 448 | for (j = 0; j < BMP_LOGO_WIDTH; j++) { |
Alessandro Rubini | acb1386 | 2010-03-13 17:44:08 +0100 | [diff] [blame] | 449 | col16 = bmp_logo_palette[(bmap[j]-16)]; |
| 450 | fb16[j] = |
| 451 | ((col16 & 0x000F) << 1) | |
| 452 | ((col16 & 0x00F0) << 3) | |
| 453 | ((col16 & 0x0F00) << 4); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 454 | } |
| 455 | bmap += BMP_LOGO_WIDTH; |
| 456 | fb16 += panel_info.vl_col; |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | WATCHDOG_RESET(); |
Simon Glass | 9a8efc4 | 2012-10-30 13:40:18 +0000 | [diff] [blame] | 461 | lcd_sync(); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 462 | } |
Anatolij Gustschin | 2b5cb3d | 2012-04-27 04:41:27 +0000 | [diff] [blame] | 463 | #else |
| 464 | static inline void bitmap_plot(int x, int y) {} |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 465 | #endif /* CONFIG_LCD_LOGO */ |
| 466 | |
| 467 | /*----------------------------------------------------------------------*/ |
Jon Loeliger | c3517f9 | 2007-07-08 18:10:08 -0500 | [diff] [blame] | 468 | #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 469 | /* |
| 470 | * Display the BMP file located at address bmp_image. |
| 471 | * Only uncompressed. |
| 472 | */ |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 473 | |
| 474 | #ifdef CONFIG_SPLASH_SCREEN_ALIGN |
| 475 | #define BMP_ALIGN_CENTER 0x7FFF |
Nikita Kiryanov | 7c7e280 | 2012-08-09 00:14:51 +0000 | [diff] [blame] | 476 | |
| 477 | static void splash_align_axis(int *axis, unsigned long panel_size, |
| 478 | unsigned long picture_size) |
| 479 | { |
| 480 | unsigned long panel_picture_delta = panel_size - picture_size; |
| 481 | unsigned long axis_alignment; |
| 482 | |
| 483 | if (*axis == BMP_ALIGN_CENTER) |
| 484 | axis_alignment = panel_picture_delta / 2; |
| 485 | else if (*axis < 0) |
| 486 | axis_alignment = panel_picture_delta + *axis + 1; |
| 487 | else |
| 488 | return; |
| 489 | |
Masahiro Yamada | b414119 | 2014-11-07 03:03:31 +0900 | [diff] [blame] | 490 | *axis = max(0, (int)axis_alignment); |
Nikita Kiryanov | 7c7e280 | 2012-08-09 00:14:51 +0000 | [diff] [blame] | 491 | } |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 492 | #endif |
| 493 | |
Tom Wai-Hong Tam | 45d7f52 | 2012-09-28 15:11:16 +0000 | [diff] [blame] | 494 | |
| 495 | #ifdef CONFIG_LCD_BMP_RLE8 |
| 496 | |
| 497 | #define BMP_RLE8_ESCAPE 0 |
| 498 | #define BMP_RLE8_EOL 0 |
| 499 | #define BMP_RLE8_EOBMP 1 |
| 500 | #define BMP_RLE8_DELTA 2 |
| 501 | |
| 502 | static void draw_unencoded_bitmap(ushort **fbp, uchar *bmap, ushort *cmap, |
| 503 | int cnt) |
| 504 | { |
| 505 | while (cnt > 0) { |
| 506 | *(*fbp)++ = cmap[*bmap++]; |
| 507 | cnt--; |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | static void draw_encoded_bitmap(ushort **fbp, ushort c, int cnt) |
| 512 | { |
| 513 | ushort *fb = *fbp; |
| 514 | int cnt_8copy = cnt >> 3; |
| 515 | |
| 516 | cnt -= cnt_8copy << 3; |
| 517 | while (cnt_8copy > 0) { |
| 518 | *fb++ = c; |
| 519 | *fb++ = c; |
| 520 | *fb++ = c; |
| 521 | *fb++ = c; |
| 522 | *fb++ = c; |
| 523 | *fb++ = c; |
| 524 | *fb++ = c; |
| 525 | *fb++ = c; |
| 526 | cnt_8copy--; |
| 527 | } |
| 528 | while (cnt > 0) { |
| 529 | *fb++ = c; |
| 530 | cnt--; |
| 531 | } |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 532 | *fbp = fb; |
Tom Wai-Hong Tam | 45d7f52 | 2012-09-28 15:11:16 +0000 | [diff] [blame] | 533 | } |
| 534 | |
| 535 | /* |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 536 | * Do not call this function directly, must be called from lcd_display_bitmap. |
Tom Wai-Hong Tam | 45d7f52 | 2012-09-28 15:11:16 +0000 | [diff] [blame] | 537 | */ |
| 538 | static void lcd_display_rle8_bitmap(bmp_image_t *bmp, ushort *cmap, uchar *fb, |
| 539 | int x_off, int y_off) |
| 540 | { |
| 541 | uchar *bmap; |
| 542 | ulong width, height; |
| 543 | ulong cnt, runlen; |
| 544 | int x, y; |
| 545 | int decode = 1; |
| 546 | |
Przemyslaw Marczak | dca2a1c | 2014-01-22 11:24:13 +0100 | [diff] [blame] | 547 | width = get_unaligned_le32(&bmp->header.width); |
| 548 | height = get_unaligned_le32(&bmp->header.height); |
| 549 | bmap = (uchar *)bmp + get_unaligned_le32(&bmp->header.data_offset); |
Tom Wai-Hong Tam | 45d7f52 | 2012-09-28 15:11:16 +0000 | [diff] [blame] | 550 | |
| 551 | x = 0; |
| 552 | y = height - 1; |
| 553 | |
| 554 | while (decode) { |
| 555 | if (bmap[0] == BMP_RLE8_ESCAPE) { |
| 556 | switch (bmap[1]) { |
| 557 | case BMP_RLE8_EOL: |
| 558 | /* end of line */ |
| 559 | bmap += 2; |
| 560 | x = 0; |
| 561 | y--; |
| 562 | /* 16bpix, 2-byte per pixel, width should *2 */ |
| 563 | fb -= (width * 2 + lcd_line_length); |
| 564 | break; |
| 565 | case BMP_RLE8_EOBMP: |
| 566 | /* end of bitmap */ |
| 567 | decode = 0; |
| 568 | break; |
| 569 | case BMP_RLE8_DELTA: |
| 570 | /* delta run */ |
| 571 | x += bmap[2]; |
| 572 | y -= bmap[3]; |
| 573 | /* 16bpix, 2-byte per pixel, x should *2 */ |
| 574 | fb = (uchar *) (lcd_base + (y + y_off - 1) |
| 575 | * lcd_line_length + (x + x_off) * 2); |
| 576 | bmap += 4; |
| 577 | break; |
| 578 | default: |
| 579 | /* unencoded run */ |
| 580 | runlen = bmap[1]; |
| 581 | bmap += 2; |
| 582 | if (y < height) { |
| 583 | if (x < width) { |
| 584 | if (x + runlen > width) |
| 585 | cnt = width - x; |
| 586 | else |
| 587 | cnt = runlen; |
| 588 | draw_unencoded_bitmap( |
| 589 | (ushort **)&fb, |
| 590 | bmap, cmap, cnt); |
| 591 | } |
| 592 | x += runlen; |
| 593 | } |
| 594 | bmap += runlen; |
| 595 | if (runlen & 1) |
| 596 | bmap++; |
| 597 | } |
| 598 | } else { |
| 599 | /* encoded run */ |
| 600 | if (y < height) { |
| 601 | runlen = bmap[0]; |
| 602 | if (x < width) { |
| 603 | /* aggregate the same code */ |
| 604 | while (bmap[0] == 0xff && |
| 605 | bmap[2] != BMP_RLE8_ESCAPE && |
| 606 | bmap[1] == bmap[3]) { |
| 607 | runlen += bmap[2]; |
| 608 | bmap += 2; |
| 609 | } |
| 610 | if (x + runlen > width) |
| 611 | cnt = width - x; |
| 612 | else |
| 613 | cnt = runlen; |
| 614 | draw_encoded_bitmap((ushort **)&fb, |
| 615 | cmap[bmap[1]], cnt); |
| 616 | } |
| 617 | x += runlen; |
| 618 | } |
| 619 | bmap += 2; |
| 620 | } |
| 621 | } |
| 622 | } |
| 623 | #endif |
| 624 | |
Nikita Kiryanov | 27fad01 | 2015-02-03 13:32:23 +0200 | [diff] [blame] | 625 | __weak void fb_put_byte(uchar **fb, uchar **from) |
| 626 | { |
| 627 | *(*fb)++ = *(*from)++; |
| 628 | } |
Nikita Kiryanov | bfdcc65 | 2012-08-09 00:14:53 +0000 | [diff] [blame] | 629 | |
| 630 | #if defined(CONFIG_BMP_16BPP) |
Nikita Kiryanov | b3d12e9 | 2015-02-03 13:32:22 +0200 | [diff] [blame] | 631 | __weak void fb_put_word(uchar **fb, uchar **from) |
Nikita Kiryanov | bfdcc65 | 2012-08-09 00:14:53 +0000 | [diff] [blame] | 632 | { |
| 633 | *(*fb)++ = *(*from)++; |
| 634 | *(*fb)++ = *(*from)++; |
| 635 | } |
Nikita Kiryanov | bfdcc65 | 2012-08-09 00:14:53 +0000 | [diff] [blame] | 636 | #endif /* CONFIG_BMP_16BPP */ |
| 637 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 638 | int lcd_display_bitmap(ulong bmp_image, int x, int y) |
| 639 | { |
Anatolij Gustschin | 00cc559 | 2009-02-25 20:28:13 +0100 | [diff] [blame] | 640 | ushort *cmap = NULL; |
Anatolij Gustschin | 00cc559 | 2009-02-25 20:28:13 +0100 | [diff] [blame] | 641 | ushort *cmap_base = NULL; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 642 | ushort i, j; |
| 643 | uchar *fb; |
Simon Glass | 7d95f2a | 2014-02-27 13:26:19 -0700 | [diff] [blame] | 644 | bmp_image_t *bmp = (bmp_image_t *)map_sysmem(bmp_image, 0); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 645 | uchar *bmap; |
Tom Wai-Hong Tam | fecac46 | 2012-09-28 15:11:14 +0000 | [diff] [blame] | 646 | ushort padded_width; |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 647 | unsigned long width, height, byte_width; |
Wolfgang Denk | e8143e7 | 2006-08-30 23:09:00 +0200 | [diff] [blame] | 648 | unsigned long pwidth = panel_info.vl_col; |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 649 | unsigned colors, bpix, bmp_bpix; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 650 | |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 651 | if (!bmp || !(bmp->header.signature[0] == 'B' && |
| 652 | bmp->header.signature[1] == 'M')) { |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 653 | printf("Error: no valid bmp image at %lx\n", bmp_image); |
| 654 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 655 | return 1; |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 656 | } |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 657 | |
Przemyslaw Marczak | dca2a1c | 2014-01-22 11:24:13 +0100 | [diff] [blame] | 658 | width = get_unaligned_le32(&bmp->header.width); |
| 659 | height = get_unaligned_le32(&bmp->header.height); |
| 660 | bmp_bpix = get_unaligned_le16(&bmp->header.bit_count); |
| 661 | |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 662 | colors = 1 << bmp_bpix; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 663 | |
| 664 | bpix = NBITS(panel_info.vl_bpix); |
| 665 | |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 666 | if (bpix != 1 && bpix != 8 && bpix != 16 && bpix != 32) { |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 667 | printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n", |
| 668 | bpix, bmp_bpix); |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 669 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 670 | return 1; |
| 671 | } |
| 672 | |
Hannes Petermaier | a305fb1 | 2014-07-15 16:28:46 +0200 | [diff] [blame] | 673 | /* |
| 674 | * We support displaying 8bpp BMPs on 16bpp LCDs |
| 675 | * and displaying 24bpp BMPs on 32bpp LCDs |
| 676 | * */ |
| 677 | if (bpix != bmp_bpix && |
| 678 | !(bmp_bpix == 8 && bpix == 16) && |
| 679 | !(bmp_bpix == 24 && bpix == 32)) { |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 680 | printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n", |
Przemyslaw Marczak | dca2a1c | 2014-01-22 11:24:13 +0100 | [diff] [blame] | 681 | bpix, get_unaligned_le16(&bmp->header.bit_count)); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 682 | return 1; |
| 683 | } |
| 684 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 685 | debug("Display-bmp: %d x %d with %d colors\n", |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 686 | (int)width, (int)height, (int)colors); |
| 687 | |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 688 | if (bmp_bpix == 8) { |
Nikita Kiryanov | 203c37b | 2012-08-09 00:14:52 +0000 | [diff] [blame] | 689 | cmap = configuration_get_cmap(); |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 690 | cmap_base = cmap; |
| 691 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 692 | /* Set color map */ |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 693 | for (i = 0; i < colors; ++i) { |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 694 | bmp_color_table_entry_t cte = bmp->color_table[i]; |
Mark Jackson | 1464eff | 2008-08-01 09:48:29 +0100 | [diff] [blame] | 695 | #if !defined(CONFIG_ATMEL_LCD) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 696 | ushort colreg = |
| 697 | ( ((cte.red) << 8) & 0xf800) | |
Wolfgang Denk | 59d80bf | 2005-09-21 15:24:52 +0200 | [diff] [blame] | 698 | ( ((cte.green) << 3) & 0x07e0) | |
| 699 | ( ((cte.blue) >> 3) & 0x001f) ; |
wdenk | 25d6712 | 2004-12-10 11:40:40 +0000 | [diff] [blame] | 700 | *cmap = colreg; |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 701 | #if defined(CONFIG_MPC823) |
wdenk | 25d6712 | 2004-12-10 11:40:40 +0000 | [diff] [blame] | 702 | cmap--; |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 703 | #else |
| 704 | cmap++; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 705 | #endif |
Mark Jackson | 1464eff | 2008-08-01 09:48:29 +0100 | [diff] [blame] | 706 | #else /* CONFIG_ATMEL_LCD */ |
| 707 | lcd_setcolreg(i, cte.red, cte.green, cte.blue); |
| 708 | #endif |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 709 | } |
| 710 | } |
Wolfgang Denk | e8143e7 | 2006-08-30 23:09:00 +0200 | [diff] [blame] | 711 | |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 712 | padded_width = (width & 0x3 ? (width & ~0x3) + 4 : width); |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 713 | |
| 714 | #ifdef CONFIG_SPLASH_SCREEN_ALIGN |
Nikita Kiryanov | 7c7e280 | 2012-08-09 00:14:51 +0000 | [diff] [blame] | 715 | splash_align_axis(&x, pwidth, width); |
| 716 | splash_align_axis(&y, panel_info.vl_row, height); |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 717 | #endif /* CONFIG_SPLASH_SCREEN_ALIGN */ |
| 718 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 719 | if ((x + width) > pwidth) |
Wolfgang Denk | e8143e7 | 2006-08-30 23:09:00 +0200 | [diff] [blame] | 720 | width = pwidth - x; |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 721 | if ((y + height) > panel_info.vl_row) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 722 | height = panel_info.vl_row - y; |
| 723 | |
Przemyslaw Marczak | dca2a1c | 2014-01-22 11:24:13 +0100 | [diff] [blame] | 724 | bmap = (uchar *)bmp + get_unaligned_le32(&bmp->header.data_offset); |
| 725 | fb = (uchar *)(lcd_base + |
Liu Ying | 8d46d5b | 2011-01-11 15:29:58 +0800 | [diff] [blame] | 726 | (y + height - 1) * lcd_line_length + x * bpix / 8); |
Mark Jackson | a303dfb | 2009-02-06 10:37:49 +0100 | [diff] [blame] | 727 | |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 728 | switch (bmp_bpix) { |
Mark Jackson | a303dfb | 2009-02-06 10:37:49 +0100 | [diff] [blame] | 729 | case 1: /* pass through */ |
Simon Glass | 0156444 | 2014-10-15 04:53:04 -0600 | [diff] [blame] | 730 | case 8: { |
Tom Wai-Hong Tam | 45d7f52 | 2012-09-28 15:11:16 +0000 | [diff] [blame] | 731 | #ifdef CONFIG_LCD_BMP_RLE8 |
Przemyslaw Marczak | dca2a1c | 2014-01-22 11:24:13 +0100 | [diff] [blame] | 732 | u32 compression = get_unaligned_le32(&bmp->header.compression); |
| 733 | if (compression == BMP_BI_RLE8) { |
Tom Wai-Hong Tam | 45d7f52 | 2012-09-28 15:11:16 +0000 | [diff] [blame] | 734 | if (bpix != 16) { |
| 735 | /* TODO implement render code for bpix != 16 */ |
| 736 | printf("Error: only support 16 bpix"); |
| 737 | return 1; |
| 738 | } |
| 739 | lcd_display_rle8_bitmap(bmp, cmap_base, fb, x, y); |
| 740 | break; |
| 741 | } |
| 742 | #endif |
| 743 | |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 744 | if (bpix != 16) |
| 745 | byte_width = width; |
| 746 | else |
| 747 | byte_width = width * 2; |
| 748 | |
Mark Jackson | a303dfb | 2009-02-06 10:37:49 +0100 | [diff] [blame] | 749 | for (i = 0; i < height; ++i) { |
| 750 | WATCHDOG_RESET(); |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 751 | for (j = 0; j < width; j++) { |
| 752 | if (bpix != 16) { |
Nikita Kiryanov | 27fad01 | 2015-02-03 13:32:23 +0200 | [diff] [blame] | 753 | fb_put_byte(&fb, &bmap); |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 754 | } else { |
| 755 | *(uint16_t *)fb = cmap_base[*(bmap++)]; |
| 756 | fb += sizeof(uint16_t) / sizeof(*fb); |
| 757 | } |
| 758 | } |
Tom Wai-Hong Tam | fecac46 | 2012-09-28 15:11:14 +0000 | [diff] [blame] | 759 | bmap += (padded_width - width); |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 760 | fb -= byte_width + lcd_line_length; |
Mark Jackson | a303dfb | 2009-02-06 10:37:49 +0100 | [diff] [blame] | 761 | } |
| 762 | break; |
Simon Glass | 0156444 | 2014-10-15 04:53:04 -0600 | [diff] [blame] | 763 | } |
Mark Jackson | a303dfb | 2009-02-06 10:37:49 +0100 | [diff] [blame] | 764 | #if defined(CONFIG_BMP_16BPP) |
| 765 | case 16: |
| 766 | for (i = 0; i < height; ++i) { |
| 767 | WATCHDOG_RESET(); |
Nikita Kiryanov | bfdcc65 | 2012-08-09 00:14:53 +0000 | [diff] [blame] | 768 | for (j = 0; j < width; j++) |
| 769 | fb_put_word(&fb, &bmap); |
| 770 | |
Tom Wai-Hong Tam | fecac46 | 2012-09-28 15:11:14 +0000 | [diff] [blame] | 771 | bmap += (padded_width - width) * 2; |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 772 | fb -= width * 2 + lcd_line_length; |
Mark Jackson | a303dfb | 2009-02-06 10:37:49 +0100 | [diff] [blame] | 773 | } |
| 774 | break; |
| 775 | #endif /* CONFIG_BMP_16BPP */ |
Hannes Petermaier | a305fb1 | 2014-07-15 16:28:46 +0200 | [diff] [blame] | 776 | #if defined(CONFIG_BMP_24BMP) |
| 777 | case 24: |
| 778 | for (i = 0; i < height; ++i) { |
| 779 | for (j = 0; j < width; j++) { |
| 780 | *(fb++) = *(bmap++); |
| 781 | *(fb++) = *(bmap++); |
| 782 | *(fb++) = *(bmap++); |
| 783 | *(fb++) = 0; |
| 784 | } |
| 785 | fb -= lcd_line_length + width * (bpix / 8); |
| 786 | } |
| 787 | break; |
| 788 | #endif /* CONFIG_BMP_24BMP */ |
Donghwa Lee | fb6a9aa | 2012-05-09 19:23:37 +0000 | [diff] [blame] | 789 | #if defined(CONFIG_BMP_32BPP) |
| 790 | case 32: |
| 791 | for (i = 0; i < height; ++i) { |
| 792 | for (j = 0; j < width; j++) { |
| 793 | *(fb++) = *(bmap++); |
| 794 | *(fb++) = *(bmap++); |
| 795 | *(fb++) = *(bmap++); |
| 796 | *(fb++) = *(bmap++); |
| 797 | } |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 798 | fb -= lcd_line_length + width * (bpix / 8); |
Donghwa Lee | fb6a9aa | 2012-05-09 19:23:37 +0000 | [diff] [blame] | 799 | } |
| 800 | break; |
| 801 | #endif /* CONFIG_BMP_32BPP */ |
Mark Jackson | a303dfb | 2009-02-06 10:37:49 +0100 | [diff] [blame] | 802 | default: |
| 803 | break; |
| 804 | }; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 805 | |
Simon Glass | 9a8efc4 | 2012-10-30 13:40:18 +0000 | [diff] [blame] | 806 | lcd_sync(); |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 807 | return 0; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 808 | } |
Jon Loeliger | c3517f9 | 2007-07-08 18:10:08 -0500 | [diff] [blame] | 809 | #endif |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 810 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 811 | static void *lcd_logo(void) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 812 | { |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 813 | #ifdef CONFIG_SPLASH_SCREEN |
| 814 | char *s; |
| 815 | ulong addr; |
| 816 | static int do_splash = 1; |
| 817 | |
| 818 | if (do_splash && (s = getenv("splashimage")) != NULL) { |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 819 | int x = 0, y = 0; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 820 | do_splash = 0; |
| 821 | |
Nikita Kiryanov | 581bb41 | 2013-01-30 21:39:57 +0000 | [diff] [blame] | 822 | if (splash_screen_prepare()) |
Robert Winkler | dd4425e | 2013-06-17 11:31:29 -0700 | [diff] [blame] | 823 | return (void *)lcd_base; |
Nikita Kiryanov | 581bb41 | 2013-01-30 21:39:57 +0000 | [diff] [blame] | 824 | |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 825 | addr = simple_strtoul (s, NULL, 16); |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 826 | |
Anatolij Gustschin | ff8fb56 | 2013-07-02 00:04:05 +0200 | [diff] [blame] | 827 | splash_get_pos(&x, &y); |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 828 | |
Nikita Kiryanov | d3a555e | 2012-08-09 00:14:50 +0000 | [diff] [blame] | 829 | if (bmp_display(addr, x, y) == 0) |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 830 | return (void *)lcd_base; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 831 | } |
| 832 | #endif /* CONFIG_SPLASH_SCREEN */ |
| 833 | |
Anatolij Gustschin | 2b5cb3d | 2012-04-27 04:41:27 +0000 | [diff] [blame] | 834 | bitmap_plot(0, 0); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 835 | |
Haavard Skinnemoen | 6b59e03 | 2008-09-01 16:21:22 +0200 | [diff] [blame] | 836 | #ifdef CONFIG_LCD_INFO |
Nikita Kiryanov | 140beb9 | 2014-12-08 17:14:41 +0200 | [diff] [blame] | 837 | lcd_set_col(LCD_INFO_X / VIDEO_FONT_WIDTH); |
| 838 | lcd_set_row(LCD_INFO_Y / VIDEO_FONT_HEIGHT); |
Haavard Skinnemoen | 6b59e03 | 2008-09-01 16:21:22 +0200 | [diff] [blame] | 839 | lcd_show_board_info(); |
| 840 | #endif /* CONFIG_LCD_INFO */ |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 841 | |
wdenk | 88804d1 | 2005-07-04 00:03:16 +0000 | [diff] [blame] | 842 | #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO) |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 843 | return (void *)((ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 844 | #else |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 845 | return (void *)lcd_base; |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 846 | #endif /* CONFIG_LCD_LOGO && !defined(CONFIG_LCD_INFO_BELOW_LOGO) */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 847 | } |
| 848 | |
Nikita Kiryanov | c088048 | 2013-02-24 21:28:43 +0000 | [diff] [blame] | 849 | #ifdef CONFIG_SPLASHIMAGE_GUARD |
| 850 | static int on_splashimage(const char *name, const char *value, enum env_op op, |
| 851 | int flags) |
| 852 | { |
| 853 | ulong addr; |
| 854 | int aligned; |
| 855 | |
| 856 | if (op == env_op_delete) |
| 857 | return 0; |
| 858 | |
| 859 | addr = simple_strtoul(value, NULL, 16); |
| 860 | /* See README.displaying-bmps */ |
| 861 | aligned = (addr % 4 == 2); |
| 862 | if (!aligned) { |
| 863 | printf("Invalid splashimage value. Value must be 16 bit aligned, but not 32 bit aligned\n"); |
| 864 | return -1; |
| 865 | } |
| 866 | |
| 867 | return 0; |
| 868 | } |
| 869 | |
| 870 | U_BOOT_ENV_CALLBACK(splashimage, on_splashimage); |
| 871 | #endif |
| 872 | |
Vadim Bendebury | 395166c | 2012-09-28 15:11:13 +0000 | [diff] [blame] | 873 | int lcd_get_pixel_width(void) |
| 874 | { |
| 875 | return panel_info.vl_col; |
| 876 | } |
| 877 | |
| 878 | int lcd_get_pixel_height(void) |
| 879 | { |
| 880 | return panel_info.vl_row; |
| 881 | } |
| 882 | |
Stephen Warren | 6a195d2 | 2013-05-27 18:31:17 +0000 | [diff] [blame] | 883 | #if defined(CONFIG_LCD_DT_SIMPLEFB) |
| 884 | static int lcd_dt_simplefb_configure_node(void *blob, int off) |
| 885 | { |
Stephen Warren | 6a195d2 | 2013-05-27 18:31:17 +0000 | [diff] [blame] | 886 | #if LCD_BPP == LCD_COLOR16 |
Hans de Goede | 11b8dfa | 2014-11-19 13:53:27 +0100 | [diff] [blame] | 887 | return fdt_setup_simplefb_node(blob, off, gd->fb_base, |
| 888 | panel_info.vl_col, panel_info.vl_row, |
| 889 | panel_info.vl_col * 2, "r5g6b5"); |
Stephen Warren | 6a195d2 | 2013-05-27 18:31:17 +0000 | [diff] [blame] | 890 | #else |
Hans de Goede | 11b8dfa | 2014-11-19 13:53:27 +0100 | [diff] [blame] | 891 | return -1; |
Stephen Warren | 6a195d2 | 2013-05-27 18:31:17 +0000 | [diff] [blame] | 892 | #endif |
Stephen Warren | 6a195d2 | 2013-05-27 18:31:17 +0000 | [diff] [blame] | 893 | } |
| 894 | |
| 895 | int lcd_dt_simplefb_add_node(void *blob) |
| 896 | { |
Stephen Warren | 5af7d0f | 2013-06-13 17:13:11 -0600 | [diff] [blame] | 897 | static const char compat[] = "simple-framebuffer"; |
| 898 | static const char disabled[] = "disabled"; |
Stephen Warren | 6a195d2 | 2013-05-27 18:31:17 +0000 | [diff] [blame] | 899 | int off, ret; |
| 900 | |
| 901 | off = fdt_add_subnode(blob, 0, "framebuffer"); |
| 902 | if (off < 0) |
| 903 | return -1; |
| 904 | |
| 905 | ret = fdt_setprop(blob, off, "status", disabled, sizeof(disabled)); |
| 906 | if (ret < 0) |
| 907 | return -1; |
| 908 | |
| 909 | ret = fdt_setprop(blob, off, "compatible", compat, sizeof(compat)); |
| 910 | if (ret < 0) |
| 911 | return -1; |
| 912 | |
| 913 | return lcd_dt_simplefb_configure_node(blob, off); |
| 914 | } |
| 915 | |
| 916 | int lcd_dt_simplefb_enable_existing_node(void *blob) |
| 917 | { |
| 918 | int off; |
| 919 | |
| 920 | off = fdt_node_offset_by_compatible(blob, -1, "simple-framebuffer"); |
| 921 | if (off < 0) |
| 922 | return -1; |
| 923 | |
| 924 | return lcd_dt_simplefb_configure_node(blob, off); |
| 925 | } |
| 926 | #endif |