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> |
| 31 | |
Marek Vasut | abc20ab | 2011-11-26 07:20:07 +0100 | [diff] [blame] | 32 | #if defined(CONFIG_CPU_PXA25X) || defined(CONFIG_CPU_PXA27X) || \ |
| 33 | defined(CONFIG_CPU_MONAHANS) |
| 34 | #define CONFIG_CPU_PXA |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 35 | #include <asm/byteorder.h> |
| 36 | #endif |
| 37 | |
| 38 | #if defined(CONFIG_MPC823) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 39 | #include <lcdvideo.h> |
| 40 | #endif |
| 41 | |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 42 | #if defined(CONFIG_ATMEL_LCD) |
| 43 | #include <atmel_lcdc.h> |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 44 | #endif |
| 45 | |
Stephen Warren | 6a195d2 | 2013-05-27 18:31:17 +0000 | [diff] [blame] | 46 | #if defined(CONFIG_LCD_DT_SIMPLEFB) |
| 47 | #include <libfdt.h> |
| 48 | #endif |
| 49 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 50 | /************************************************************************/ |
| 51 | /* ** FONT DATA */ |
| 52 | /************************************************************************/ |
| 53 | #include <video_font.h> /* Get font data, width and height */ |
| 54 | |
wdenk | 88804d1 | 2005-07-04 00:03:16 +0000 | [diff] [blame] | 55 | /************************************************************************/ |
| 56 | /* ** LOGO DATA */ |
| 57 | /************************************************************************/ |
| 58 | #ifdef CONFIG_LCD_LOGO |
| 59 | # include <bmp_logo.h> /* Get logo data, width and height */ |
Che-Liang Chiou | c270730 | 2011-10-20 23:04:20 +0000 | [diff] [blame] | 60 | # include <bmp_logo_data.h> |
Alessandro Rubini | acb1386 | 2010-03-13 17:44:08 +0100 | [diff] [blame] | 61 | # if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET) && (LCD_BPP != LCD_COLOR16) |
wdenk | 88804d1 | 2005-07-04 00:03:16 +0000 | [diff] [blame] | 62 | # error Default Color Map overlaps with Logo Color Map |
| 63 | # endif |
| 64 | #endif |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 65 | |
Simon Glass | 676d319 | 2012-10-17 13:24:54 +0000 | [diff] [blame] | 66 | #ifndef CONFIG_LCD_ALIGNMENT |
| 67 | #define CONFIG_LCD_ALIGNMENT PAGE_SIZE |
| 68 | #endif |
| 69 | |
Simon Glass | 0d89efe | 2012-10-17 13:24:59 +0000 | [diff] [blame] | 70 | /* By default we scroll by a single line */ |
| 71 | #ifndef CONFIG_CONSOLE_SCROLL_LINES |
| 72 | #define CONFIG_CONSOLE_SCROLL_LINES 1 |
| 73 | #endif |
| 74 | |
Jeroen Hofstee | a5796c5 | 2013-01-12 12:07:59 +0000 | [diff] [blame] | 75 | /************************************************************************/ |
| 76 | /* ** CONSOLE DEFINITIONS & FUNCTIONS */ |
| 77 | /************************************************************************/ |
| 78 | #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO) |
| 79 | # define CONSOLE_ROWS ((panel_info.vl_row-BMP_LOGO_HEIGHT) \ |
| 80 | / VIDEO_FONT_HEIGHT) |
| 81 | #else |
| 82 | # define CONSOLE_ROWS (panel_info.vl_row / VIDEO_FONT_HEIGHT) |
| 83 | #endif |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 84 | |
Jeroen Hofstee | a5796c5 | 2013-01-12 12:07:59 +0000 | [diff] [blame] | 85 | #define CONSOLE_COLS (panel_info.vl_col / VIDEO_FONT_WIDTH) |
| 86 | #define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * lcd_line_length) |
| 87 | #define CONSOLE_ROW_FIRST lcd_console_address |
| 88 | #define CONSOLE_ROW_SECOND (lcd_console_address + CONSOLE_ROW_SIZE) |
| 89 | #define CONSOLE_ROW_LAST (lcd_console_address + CONSOLE_SIZE \ |
| 90 | - CONSOLE_ROW_SIZE) |
| 91 | #define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS) |
| 92 | #define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE) |
| 93 | |
| 94 | #if LCD_BPP == LCD_MONOCHROME |
| 95 | # define COLOR_MASK(c) ((c) | (c) << 1 | (c) << 2 | (c) << 3 | \ |
| 96 | (c) << 4 | (c) << 5 | (c) << 6 | (c) << 7) |
| 97 | #elif (LCD_BPP == LCD_COLOR8) || (LCD_BPP == LCD_COLOR16) |
| 98 | # define COLOR_MASK(c) (c) |
| 99 | #else |
| 100 | # error Unsupported LCD BPP. |
| 101 | #endif |
| 102 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 103 | DECLARE_GLOBAL_DATA_PTR; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 104 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 105 | static void lcd_drawchars(ushort x, ushort y, uchar *str, int count); |
| 106 | static inline void lcd_puts_xy(ushort x, ushort y, uchar *s); |
| 107 | static inline void lcd_putc_xy(ushort x, ushort y, uchar c); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 108 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 109 | static int lcd_init(void *lcdbase); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 110 | |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 111 | static void *lcd_logo(void); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 112 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 113 | static int lcd_getbgcolor(void); |
| 114 | static void lcd_setfgcolor(int color); |
| 115 | static void lcd_setbgcolor(int color); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 116 | |
Wolfgang Denk | 46d1d5d | 2013-01-05 09:45:48 +0000 | [diff] [blame] | 117 | static int lcd_color_fg; |
| 118 | static int lcd_color_bg; |
Jeroen Hofstee | f1d205a | 2013-01-22 10:44:11 +0000 | [diff] [blame] | 119 | int lcd_line_length; |
Wolfgang Denk | 46d1d5d | 2013-01-05 09:45:48 +0000 | [diff] [blame] | 120 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 121 | char lcd_is_enabled = 0; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 122 | |
Jeroen Hofstee | f1d205a | 2013-01-22 10:44:11 +0000 | [diff] [blame] | 123 | static short console_col; |
| 124 | static short console_row; |
| 125 | |
| 126 | static void *lcd_console_address; |
Jeroen Hofstee | 00a0ca5 | 2013-01-22 10:44:12 +0000 | [diff] [blame] | 127 | static void *lcd_base; /* Start of framebuffer memory */ |
Jeroen Hofstee | f1d205a | 2013-01-22 10:44:11 +0000 | [diff] [blame] | 128 | |
Simon Glass | 9a8efc4 | 2012-10-30 13:40:18 +0000 | [diff] [blame] | 129 | static char lcd_flush_dcache; /* 1 to flush dcache after each lcd update */ |
| 130 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 131 | /************************************************************************/ |
| 132 | |
Simon Glass | 9a8efc4 | 2012-10-30 13:40:18 +0000 | [diff] [blame] | 133 | /* Flush LCD activity to the caches */ |
| 134 | void lcd_sync(void) |
| 135 | { |
| 136 | /* |
| 137 | * flush_dcache_range() is declared in common.h but it seems that some |
| 138 | * architectures do not actually implement it. Is there a way to find |
| 139 | * out whether it exists? For now, ARM is safe. |
| 140 | */ |
| 141 | #if defined(CONFIG_ARM) && !defined(CONFIG_SYS_DCACHE_OFF) |
| 142 | int line_length; |
| 143 | |
| 144 | if (lcd_flush_dcache) |
| 145 | flush_dcache_range((u32)lcd_base, |
| 146 | (u32)(lcd_base + lcd_get_size(&line_length))); |
| 147 | #endif |
| 148 | } |
| 149 | |
| 150 | void lcd_set_flush_dcache(int flush) |
| 151 | { |
| 152 | lcd_flush_dcache = (flush != 0); |
| 153 | } |
| 154 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 155 | /*----------------------------------------------------------------------*/ |
| 156 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 157 | static void console_scrollup(void) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 158 | { |
Simon Glass | 0d89efe | 2012-10-17 13:24:59 +0000 | [diff] [blame] | 159 | const int rows = CONFIG_CONSOLE_SCROLL_LINES; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 160 | |
Simon Glass | 0d89efe | 2012-10-17 13:24:59 +0000 | [diff] [blame] | 161 | /* Copy up rows ignoring those that will be overwritten */ |
| 162 | memcpy(CONSOLE_ROW_FIRST, |
| 163 | lcd_console_address + CONSOLE_ROW_SIZE * rows, |
| 164 | CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows); |
| 165 | |
| 166 | /* Clear the last rows */ |
| 167 | memset(lcd_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows, |
| 168 | COLOR_MASK(lcd_color_bg), |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 169 | CONSOLE_ROW_SIZE * rows); |
Simon Glass | 0d89efe | 2012-10-17 13:24:59 +0000 | [diff] [blame] | 170 | |
Simon Glass | 9a8efc4 | 2012-10-30 13:40:18 +0000 | [diff] [blame] | 171 | lcd_sync(); |
Simon Glass | 0d89efe | 2012-10-17 13:24:59 +0000 | [diff] [blame] | 172 | console_row -= rows; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | /*----------------------------------------------------------------------*/ |
| 176 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 177 | static inline void console_back(void) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 178 | { |
| 179 | if (--console_col < 0) { |
| 180 | console_col = CONSOLE_COLS-1 ; |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 181 | if (--console_row < 0) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 182 | console_row = 0; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 183 | } |
| 184 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 185 | lcd_putc_xy(console_col * VIDEO_FONT_WIDTH, |
| 186 | console_row * VIDEO_FONT_HEIGHT, ' '); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | /*----------------------------------------------------------------------*/ |
| 190 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 191 | static inline void console_newline(void) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 192 | { |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 193 | console_col = 0; |
| 194 | |
| 195 | /* Check if we need to scroll the terminal */ |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 196 | if (++console_row >= CONSOLE_ROWS) |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 197 | console_scrollup(); |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 198 | else |
Simon Glass | 9a8efc4 | 2012-10-30 13:40:18 +0000 | [diff] [blame] | 199 | lcd_sync(); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | /*----------------------------------------------------------------------*/ |
| 203 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 204 | void lcd_putc(const char c) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 205 | { |
| 206 | if (!lcd_is_enabled) { |
| 207 | serial_putc(c); |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 208 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 209 | return; |
| 210 | } |
| 211 | |
| 212 | switch (c) { |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 213 | case '\r': |
| 214 | console_col = 0; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 215 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 216 | return; |
| 217 | case '\n': |
| 218 | console_newline(); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 219 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 220 | return; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 221 | case '\t': /* Tab (8 chars alignment) */ |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 222 | console_col += 8; |
| 223 | console_col &= ~7; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 224 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 225 | if (console_col >= CONSOLE_COLS) |
| 226 | console_newline(); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 227 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 228 | return; |
| 229 | case '\b': |
| 230 | console_back(); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 231 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 232 | return; |
| 233 | default: |
| 234 | lcd_putc_xy(console_col * VIDEO_FONT_WIDTH, |
| 235 | console_row * VIDEO_FONT_HEIGHT, c); |
| 236 | if (++console_col >= CONSOLE_COLS) |
| 237 | console_newline(); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 238 | } |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | /*----------------------------------------------------------------------*/ |
| 242 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 243 | void lcd_puts(const char *s) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 244 | { |
| 245 | if (!lcd_is_enabled) { |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 246 | serial_puts(s); |
| 247 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 248 | return; |
| 249 | } |
| 250 | |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 251 | while (*s) |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 252 | lcd_putc(*s++); |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 253 | |
Simon Glass | 9a8efc4 | 2012-10-30 13:40:18 +0000 | [diff] [blame] | 254 | lcd_sync(); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 255 | } |
| 256 | |
Haavard Skinnemoen | 15b17ab | 2008-09-01 16:21:20 +0200 | [diff] [blame] | 257 | /*----------------------------------------------------------------------*/ |
| 258 | |
| 259 | void lcd_printf(const char *fmt, ...) |
| 260 | { |
| 261 | va_list args; |
| 262 | char buf[CONFIG_SYS_PBSIZE]; |
| 263 | |
| 264 | va_start(args, fmt); |
| 265 | vsprintf(buf, fmt, args); |
| 266 | va_end(args); |
| 267 | |
| 268 | lcd_puts(buf); |
| 269 | } |
| 270 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 271 | /************************************************************************/ |
| 272 | /* ** Low-Level Graphics Routines */ |
| 273 | /************************************************************************/ |
| 274 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 275 | static void lcd_drawchars(ushort x, ushort y, uchar *str, int count) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 276 | { |
| 277 | uchar *dest; |
Marek Vasut | be547c6 | 2011-09-26 02:26:04 +0200 | [diff] [blame] | 278 | ushort row; |
| 279 | |
Anatolij Gustschin | 0f999c4 | 2012-04-27 04:41:16 +0000 | [diff] [blame] | 280 | #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO) |
| 281 | y += BMP_LOGO_HEIGHT; |
| 282 | #endif |
| 283 | |
Marek Vasut | be547c6 | 2011-09-26 02:26:04 +0200 | [diff] [blame] | 284 | #if LCD_BPP == LCD_MONOCHROME |
| 285 | ushort off = x * (1 << LCD_BPP) % 8; |
| 286 | #endif |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 287 | |
| 288 | dest = (uchar *)(lcd_base + y * lcd_line_length + x * (1 << LCD_BPP) / 8); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 289 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 290 | for (row = 0; row < VIDEO_FONT_HEIGHT; ++row, dest += lcd_line_length) { |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 291 | uchar *s = str; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 292 | int i; |
Alessandro Rubini | acb1386 | 2010-03-13 17:44:08 +0100 | [diff] [blame] | 293 | #if LCD_BPP == LCD_COLOR16 |
| 294 | ushort *d = (ushort *)dest; |
| 295 | #else |
| 296 | uchar *d = dest; |
| 297 | #endif |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 298 | |
| 299 | #if LCD_BPP == LCD_MONOCHROME |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 300 | uchar rest = *d & -(1 << (8 - off)); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 301 | uchar sym; |
| 302 | #endif |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 303 | for (i = 0; i < count; ++i) { |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 304 | uchar c, bits; |
| 305 | |
| 306 | c = *s++; |
| 307 | bits = video_fontdata[c * VIDEO_FONT_HEIGHT + row]; |
| 308 | |
| 309 | #if LCD_BPP == LCD_MONOCHROME |
| 310 | sym = (COLOR_MASK(lcd_color_fg) & bits) | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 311 | (COLOR_MASK(lcd_color_bg) & ~bits); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 312 | |
| 313 | *d++ = rest | (sym >> off); |
| 314 | rest = sym << (8-off); |
| 315 | #elif LCD_BPP == LCD_COLOR8 |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 316 | for (c = 0; c < 8; ++c) { |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 317 | *d++ = (bits & 0x80) ? |
| 318 | lcd_color_fg : lcd_color_bg; |
| 319 | bits <<= 1; |
| 320 | } |
| 321 | #elif LCD_BPP == LCD_COLOR16 |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 322 | for (c = 0; c < 8; ++c) { |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 323 | *d++ = (bits & 0x80) ? |
| 324 | lcd_color_fg : lcd_color_bg; |
| 325 | bits <<= 1; |
| 326 | } |
| 327 | #endif |
| 328 | } |
| 329 | #if LCD_BPP == LCD_MONOCHROME |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 330 | *d = rest | (*d & ((1 << (8 - off)) - 1)); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 331 | #endif |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | /*----------------------------------------------------------------------*/ |
| 336 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 337 | static inline void lcd_puts_xy(ushort x, ushort y, uchar *s) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 338 | { |
Anatolij Gustschin | 0f999c4 | 2012-04-27 04:41:16 +0000 | [diff] [blame] | 339 | lcd_drawchars(x, y, s, strlen((char *)s)); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | /*----------------------------------------------------------------------*/ |
| 343 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 344 | static inline void lcd_putc_xy(ushort x, ushort y, uchar c) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 345 | { |
Anatolij Gustschin | 0f999c4 | 2012-04-27 04:41:16 +0000 | [diff] [blame] | 346 | lcd_drawchars(x, y, &c, 1); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | /************************************************************************/ |
| 350 | /** Small utility to check that you got the colours right */ |
| 351 | /************************************************************************/ |
| 352 | #ifdef LCD_TEST_PATTERN |
| 353 | |
| 354 | #define N_BLK_VERT 2 |
| 355 | #define N_BLK_HOR 3 |
| 356 | |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 357 | static int test_colors[N_BLK_HOR * N_BLK_VERT] = { |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 358 | CONSOLE_COLOR_RED, CONSOLE_COLOR_GREEN, CONSOLE_COLOR_YELLOW, |
| 359 | CONSOLE_COLOR_BLUE, CONSOLE_COLOR_MAGENTA, CONSOLE_COLOR_CYAN, |
| 360 | }; |
| 361 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 362 | static void test_pattern(void) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 363 | { |
| 364 | ushort v_max = panel_info.vl_row; |
| 365 | ushort h_max = panel_info.vl_col; |
| 366 | ushort v_step = (v_max + N_BLK_VERT - 1) / N_BLK_VERT; |
| 367 | ushort h_step = (h_max + N_BLK_HOR - 1) / N_BLK_HOR; |
| 368 | ushort v, h; |
| 369 | uchar *pix = (uchar *)lcd_base; |
| 370 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 371 | printf("[LCD] Test Pattern: %d x %d [%d x %d]\n", |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 372 | h_max, v_max, h_step, v_step); |
| 373 | |
| 374 | /* WARNING: Code silently assumes 8bit/pixel */ |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 375 | for (v = 0; v < v_max; ++v) { |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 376 | uchar iy = v / v_step; |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 377 | for (h = 0; h < h_max; ++h) { |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 378 | uchar ix = N_BLK_HOR * iy + h / h_step; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 379 | *pix++ = test_colors[ix]; |
| 380 | } |
| 381 | } |
| 382 | } |
| 383 | #endif /* LCD_TEST_PATTERN */ |
| 384 | |
| 385 | |
| 386 | /************************************************************************/ |
| 387 | /* ** GENERIC Initialization Routines */ |
| 388 | /************************************************************************/ |
Anatolij Gustschin | cefa471 | 2013-11-09 11:00:09 +0100 | [diff] [blame] | 389 | /* |
| 390 | * With most lcd drivers the line length is set up |
| 391 | * by calculating it from panel_info parameters. Some |
| 392 | * drivers need to calculate the line length differently, |
| 393 | * so make the function weak to allow overriding it. |
| 394 | */ |
| 395 | __weak int lcd_get_size(int *line_length) |
Simon Glass | 676d319 | 2012-10-17 13:24:54 +0000 | [diff] [blame] | 396 | { |
| 397 | *line_length = (panel_info.vl_col * NBITS(panel_info.vl_bpix)) / 8; |
| 398 | return *line_length * panel_info.vl_row; |
| 399 | } |
| 400 | |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 401 | int drv_lcd_init(void) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 402 | { |
Jean-Christophe PLAGNIOL-VILLARD | 52cb4d4 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 403 | struct stdio_dev lcddev; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 404 | int rc; |
| 405 | |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 406 | lcd_base = (void *) gd->fb_base; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 407 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 408 | lcd_init(lcd_base); /* LCD initialization */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 409 | |
| 410 | /* Device initialization */ |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 411 | memset(&lcddev, 0, sizeof(lcddev)); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 412 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 413 | strcpy(lcddev.name, "lcd"); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 414 | lcddev.ext = 0; /* No extensions */ |
| 415 | lcddev.flags = DEV_FLAGS_OUTPUT; /* Output only */ |
| 416 | lcddev.putc = lcd_putc; /* 'putc' function */ |
| 417 | lcddev.puts = lcd_puts; /* 'puts' function */ |
| 418 | |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 419 | rc = stdio_register(&lcddev); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 420 | |
| 421 | return (rc == 0) ? 1 : rc; |
| 422 | } |
| 423 | |
| 424 | /*----------------------------------------------------------------------*/ |
Che-Liang Chiou | 0211090 | 2011-10-20 23:07:03 +0000 | [diff] [blame] | 425 | void lcd_clear(void) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 426 | { |
| 427 | #if LCD_BPP == LCD_MONOCHROME |
| 428 | /* Setting the palette */ |
| 429 | lcd_initcolregs(); |
| 430 | |
| 431 | #elif LCD_BPP == LCD_COLOR8 |
| 432 | /* Setting the palette */ |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 433 | lcd_setcolreg(CONSOLE_COLOR_BLACK, 0, 0, 0); |
| 434 | lcd_setcolreg(CONSOLE_COLOR_RED, 0xFF, 0, 0); |
| 435 | lcd_setcolreg(CONSOLE_COLOR_GREEN, 0, 0xFF, 0); |
| 436 | lcd_setcolreg(CONSOLE_COLOR_YELLOW, 0xFF, 0xFF, 0); |
| 437 | lcd_setcolreg(CONSOLE_COLOR_BLUE, 0, 0, 0xFF); |
| 438 | lcd_setcolreg(CONSOLE_COLOR_MAGENTA, 0xFF, 0, 0xFF); |
| 439 | lcd_setcolreg(CONSOLE_COLOR_CYAN, 0, 0xFF, 0xFF); |
| 440 | lcd_setcolreg(CONSOLE_COLOR_GREY, 0xAA, 0xAA, 0xAA); |
| 441 | lcd_setcolreg(CONSOLE_COLOR_WHITE, 0xFF, 0xFF, 0xFF); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 442 | #endif |
| 443 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 444 | #ifndef CONFIG_SYS_WHITE_ON_BLACK |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 445 | lcd_setfgcolor(CONSOLE_COLOR_BLACK); |
| 446 | lcd_setbgcolor(CONSOLE_COLOR_WHITE); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 447 | #else |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 448 | lcd_setfgcolor(CONSOLE_COLOR_WHITE); |
| 449 | lcd_setbgcolor(CONSOLE_COLOR_BLACK); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 450 | #endif /* CONFIG_SYS_WHITE_ON_BLACK */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 451 | |
| 452 | #ifdef LCD_TEST_PATTERN |
| 453 | test_pattern(); |
| 454 | #else |
| 455 | /* set framebuffer to background color */ |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 456 | memset((char *)lcd_base, |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 457 | COLOR_MASK(lcd_getbgcolor()), |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 458 | lcd_line_length * panel_info.vl_row); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 459 | #endif |
| 460 | /* Paint the logo and retrieve LCD base address */ |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 461 | debug("[LCD] Drawing the logo...\n"); |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 462 | lcd_console_address = lcd_logo(); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 463 | |
| 464 | console_col = 0; |
| 465 | console_row = 0; |
Simon Glass | 9a8efc4 | 2012-10-30 13:40:18 +0000 | [diff] [blame] | 466 | lcd_sync(); |
| 467 | } |
| 468 | |
| 469 | static int do_lcd_clear(cmd_tbl_t *cmdtp, int flag, int argc, |
| 470 | char *const argv[]) |
| 471 | { |
| 472 | lcd_clear(); |
| 473 | return 0; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | U_BOOT_CMD( |
Che-Liang Chiou | 0211090 | 2011-10-20 23:07:03 +0000 | [diff] [blame] | 477 | cls, 1, 1, do_lcd_clear, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 478 | "clear screen", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 479 | "" |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 480 | ); |
| 481 | |
| 482 | /*----------------------------------------------------------------------*/ |
| 483 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 484 | static int lcd_init(void *lcdbase) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 485 | { |
| 486 | /* Initialize the lcd controller */ |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 487 | debug("[LCD] Initializing LCD frambuffer at %p\n", lcdbase); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 488 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 489 | lcd_ctrl_init(lcdbase); |
Anatolij Gustschin | 1d3dea1 | 2013-03-29 14:00:13 +0100 | [diff] [blame] | 490 | |
| 491 | /* |
| 492 | * lcd_ctrl_init() of some drivers (i.e. bcm2835 on rpi_b) ignores |
| 493 | * the 'lcdbase' argument and uses custom lcd base address |
| 494 | * by setting up gd->fb_base. Check for this condition and fixup |
| 495 | * 'lcd_base' address. |
| 496 | */ |
| 497 | if ((unsigned long)lcdbase != gd->fb_base) |
| 498 | lcd_base = (void *)gd->fb_base; |
| 499 | |
| 500 | debug("[LCD] Using LCD frambuffer at %p\n", lcd_base); |
| 501 | |
Stephen Warren | 6d33071 | 2013-01-29 16:37:38 +0000 | [diff] [blame] | 502 | lcd_get_size(&lcd_line_length); |
Haavard Skinnemoen | 6f93d2b | 2008-09-01 16:21:21 +0200 | [diff] [blame] | 503 | lcd_is_enabled = 1; |
Che-Liang Chiou | 0211090 | 2011-10-20 23:07:03 +0000 | [diff] [blame] | 504 | lcd_clear(); |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 505 | lcd_enable(); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 506 | |
| 507 | /* Initialize the console */ |
| 508 | console_col = 0; |
wdenk | 88804d1 | 2005-07-04 00:03:16 +0000 | [diff] [blame] | 509 | #ifdef CONFIG_LCD_INFO_BELOW_LOGO |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 510 | console_row = 7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT; |
| 511 | #else |
| 512 | console_row = 1; /* leave 1 blank line below logo */ |
| 513 | #endif |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 514 | |
| 515 | return 0; |
| 516 | } |
| 517 | |
| 518 | |
| 519 | /************************************************************************/ |
| 520 | /* ** ROM capable initialization part - needed to reserve FB memory */ |
| 521 | /************************************************************************/ |
| 522 | /* |
| 523 | * This is called early in the system initialization to grab memory |
| 524 | * for the LCD controller. |
| 525 | * Returns new address for monitor, after reserving LCD buffer memory |
| 526 | * |
| 527 | * Note that this is running from ROM, so no write access to global data. |
| 528 | */ |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 529 | ulong lcd_setmem(ulong addr) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 530 | { |
| 531 | ulong size; |
Simon Glass | 676d319 | 2012-10-17 13:24:54 +0000 | [diff] [blame] | 532 | int line_length; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 533 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 534 | debug("LCD panel info: %d x %d, %d bit/pix\n", panel_info.vl_col, |
| 535 | panel_info.vl_row, NBITS(panel_info.vl_bpix)); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 536 | |
Simon Glass | 676d319 | 2012-10-17 13:24:54 +0000 | [diff] [blame] | 537 | size = lcd_get_size(&line_length); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 538 | |
Simon Glass | 676d319 | 2012-10-17 13:24:54 +0000 | [diff] [blame] | 539 | /* Round up to nearest full page, or MMU section if defined */ |
| 540 | size = ALIGN(size, CONFIG_LCD_ALIGNMENT); |
| 541 | addr = ALIGN(addr - CONFIG_LCD_ALIGNMENT + 1, CONFIG_LCD_ALIGNMENT); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 542 | |
| 543 | /* Allocate pages for the frame buffer. */ |
| 544 | addr -= size; |
| 545 | |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 546 | debug("Reserving %ldk for LCD Framebuffer at: %08lx\n", |
| 547 | size >> 10, addr); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 548 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 549 | return addr; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | /*----------------------------------------------------------------------*/ |
| 553 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 554 | static void lcd_setfgcolor(int color) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 555 | { |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 556 | lcd_color_fg = color; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | /*----------------------------------------------------------------------*/ |
| 560 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 561 | static void lcd_setbgcolor(int color) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 562 | { |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 563 | lcd_color_bg = color; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | /*----------------------------------------------------------------------*/ |
| 567 | |
Wolfgang Denk | 46d1d5d | 2013-01-05 09:45:48 +0000 | [diff] [blame] | 568 | int lcd_getfgcolor(void) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 569 | { |
| 570 | return lcd_color_fg; |
| 571 | } |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 572 | |
| 573 | /*----------------------------------------------------------------------*/ |
| 574 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 575 | static int lcd_getbgcolor(void) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 576 | { |
| 577 | return lcd_color_bg; |
| 578 | } |
| 579 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 580 | /************************************************************************/ |
| 581 | /* ** Chipset depending Bitmap / Logo stuff... */ |
| 582 | /************************************************************************/ |
Nikita Kiryanov | 203c37b | 2012-08-09 00:14:52 +0000 | [diff] [blame] | 583 | static inline ushort *configuration_get_cmap(void) |
| 584 | { |
| 585 | #if defined CONFIG_CPU_PXA |
| 586 | struct pxafb_info *fbi = &panel_info.pxa; |
| 587 | return (ushort *)fbi->palette; |
| 588 | #elif defined(CONFIG_MPC823) |
| 589 | immap_t *immr = (immap_t *) CONFIG_SYS_IMMR; |
| 590 | cpm8xx_t *cp = &(immr->im_cpm); |
| 591 | return (ushort *)&(cp->lcd_cmap[255 * sizeof(ushort)]); |
| 592 | #elif defined(CONFIG_ATMEL_LCD) |
| 593 | return (ushort *)(panel_info.mmio + ATMEL_LCDC_LUT(0)); |
Anatolij Gustschin | d23019f | 2012-09-22 06:55:53 +0000 | [diff] [blame] | 594 | #elif !defined(CONFIG_ATMEL_HLCD) && !defined(CONFIG_EXYNOS_FB) |
| 595 | return panel_info.cmap; |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 596 | #elif defined(CONFIG_LCD_LOGO) |
Anatolij Gustschin | d23019f | 2012-09-22 06:55:53 +0000 | [diff] [blame] | 597 | return bmp_logo_palette; |
| 598 | #else |
| 599 | return NULL; |
| 600 | #endif |
Nikita Kiryanov | 203c37b | 2012-08-09 00:14:52 +0000 | [diff] [blame] | 601 | } |
| 602 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 603 | #ifdef CONFIG_LCD_LOGO |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 604 | void bitmap_plot(int x, int y) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 605 | { |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 606 | #ifdef CONFIG_ATMEL_LCD |
Nikita Kiryanov | 203c37b | 2012-08-09 00:14:52 +0000 | [diff] [blame] | 607 | uint *cmap = (uint *)bmp_logo_palette; |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 608 | #else |
Nikita Kiryanov | 203c37b | 2012-08-09 00:14:52 +0000 | [diff] [blame] | 609 | ushort *cmap = (ushort *)bmp_logo_palette; |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 610 | #endif |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 611 | ushort i, j; |
| 612 | uchar *bmap; |
| 613 | uchar *fb; |
| 614 | ushort *fb16; |
Nikita Kiryanov | 203c37b | 2012-08-09 00:14:52 +0000 | [diff] [blame] | 615 | #if defined(CONFIG_MPC823) |
| 616 | immap_t *immr = (immap_t *) CONFIG_SYS_IMMR; |
| 617 | cpm8xx_t *cp = &(immr->im_cpm); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 618 | #endif |
Andre Renaud | 317461c | 2013-02-13 17:48:00 +0000 | [diff] [blame] | 619 | unsigned bpix = NBITS(panel_info.vl_bpix); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 620 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 621 | debug("Logo: width %d height %d colors %d cmap %d\n", |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 622 | BMP_LOGO_WIDTH, BMP_LOGO_HEIGHT, BMP_LOGO_COLORS, |
Anatolij Gustschin | 095407d | 2012-04-27 04:41:06 +0000 | [diff] [blame] | 623 | ARRAY_SIZE(bmp_logo_palette)); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 624 | |
| 625 | bmap = &bmp_logo_bitmap[0]; |
Andre Renaud | 317461c | 2013-02-13 17:48:00 +0000 | [diff] [blame] | 626 | fb = (uchar *)(lcd_base + y * lcd_line_length + x * bpix / 8); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 627 | |
Andre Renaud | 317461c | 2013-02-13 17:48:00 +0000 | [diff] [blame] | 628 | if (bpix < 12) { |
Nikita Kiryanov | 203c37b | 2012-08-09 00:14:52 +0000 | [diff] [blame] | 629 | /* Leave room for default color map |
| 630 | * default case: generic system with no cmap (most likely 16bpp) |
| 631 | * cmap was set to the source palette, so no change is done. |
| 632 | * This avoids even more ifdefs in the next stanza |
| 633 | */ |
| 634 | #if defined(CONFIG_MPC823) |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 635 | cmap = (ushort *) &(cp->lcd_cmap[BMP_LOGO_OFFSET * sizeof(ushort)]); |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 636 | #elif defined(CONFIG_ATMEL_LCD) |
Nikita Kiryanov | 203c37b | 2012-08-09 00:14:52 +0000 | [diff] [blame] | 637 | cmap = (uint *)configuration_get_cmap(); |
Alessandro Rubini | acb1386 | 2010-03-13 17:44:08 +0100 | [diff] [blame] | 638 | #else |
Nikita Kiryanov | 203c37b | 2012-08-09 00:14:52 +0000 | [diff] [blame] | 639 | cmap = configuration_get_cmap(); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 640 | #endif |
| 641 | |
| 642 | WATCHDOG_RESET(); |
| 643 | |
| 644 | /* Set color map */ |
Anatolij Gustschin | 095407d | 2012-04-27 04:41:06 +0000 | [diff] [blame] | 645 | for (i = 0; i < ARRAY_SIZE(bmp_logo_palette); ++i) { |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 646 | ushort colreg = bmp_logo_palette[i]; |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 647 | #ifdef CONFIG_ATMEL_LCD |
| 648 | uint lut_entry; |
| 649 | #ifdef CONFIG_ATMEL_LCD_BGR555 |
| 650 | lut_entry = ((colreg & 0x000F) << 11) | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 651 | ((colreg & 0x00F0) << 2) | |
| 652 | ((colreg & 0x0F00) >> 7); |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 653 | #else /* CONFIG_ATMEL_LCD_RGB565 */ |
| 654 | lut_entry = ((colreg & 0x000F) << 1) | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 655 | ((colreg & 0x00F0) << 3) | |
| 656 | ((colreg & 0x0F00) << 4); |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 657 | #endif |
| 658 | *(cmap + BMP_LOGO_OFFSET) = lut_entry; |
| 659 | cmap++; |
| 660 | #else /* !CONFIG_ATMEL_LCD */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 661 | #ifdef CONFIG_SYS_INVERT_COLORS |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 662 | *cmap++ = 0xffff - colreg; |
| 663 | #else |
| 664 | *cmap++ = colreg; |
| 665 | #endif |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 666 | #endif /* CONFIG_ATMEL_LCD */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 667 | } |
| 668 | |
| 669 | WATCHDOG_RESET(); |
| 670 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 671 | for (i = 0; i < BMP_LOGO_HEIGHT; ++i) { |
| 672 | memcpy(fb, bmap, BMP_LOGO_WIDTH); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 673 | bmap += BMP_LOGO_WIDTH; |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 674 | fb += panel_info.vl_col; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 675 | } |
| 676 | } |
| 677 | else { /* true color mode */ |
Alessandro Rubini | acb1386 | 2010-03-13 17:44:08 +0100 | [diff] [blame] | 678 | u16 col16; |
Andre Renaud | 317461c | 2013-02-13 17:48:00 +0000 | [diff] [blame] | 679 | fb16 = (ushort *)fb; |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 680 | for (i = 0; i < BMP_LOGO_HEIGHT; ++i) { |
| 681 | for (j = 0; j < BMP_LOGO_WIDTH; j++) { |
Alessandro Rubini | acb1386 | 2010-03-13 17:44:08 +0100 | [diff] [blame] | 682 | col16 = bmp_logo_palette[(bmap[j]-16)]; |
| 683 | fb16[j] = |
| 684 | ((col16 & 0x000F) << 1) | |
| 685 | ((col16 & 0x00F0) << 3) | |
| 686 | ((col16 & 0x0F00) << 4); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 687 | } |
| 688 | bmap += BMP_LOGO_WIDTH; |
| 689 | fb16 += panel_info.vl_col; |
| 690 | } |
| 691 | } |
| 692 | |
| 693 | WATCHDOG_RESET(); |
Simon Glass | 9a8efc4 | 2012-10-30 13:40:18 +0000 | [diff] [blame] | 694 | lcd_sync(); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 695 | } |
Anatolij Gustschin | 2b5cb3d | 2012-04-27 04:41:27 +0000 | [diff] [blame] | 696 | #else |
| 697 | static inline void bitmap_plot(int x, int y) {} |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 698 | #endif /* CONFIG_LCD_LOGO */ |
| 699 | |
| 700 | /*----------------------------------------------------------------------*/ |
Jon Loeliger | c3517f9 | 2007-07-08 18:10:08 -0500 | [diff] [blame] | 701 | #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 702 | /* |
| 703 | * Display the BMP file located at address bmp_image. |
| 704 | * Only uncompressed. |
| 705 | */ |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 706 | |
| 707 | #ifdef CONFIG_SPLASH_SCREEN_ALIGN |
| 708 | #define BMP_ALIGN_CENTER 0x7FFF |
Nikita Kiryanov | 7c7e280 | 2012-08-09 00:14:51 +0000 | [diff] [blame] | 709 | |
| 710 | static void splash_align_axis(int *axis, unsigned long panel_size, |
| 711 | unsigned long picture_size) |
| 712 | { |
| 713 | unsigned long panel_picture_delta = panel_size - picture_size; |
| 714 | unsigned long axis_alignment; |
| 715 | |
| 716 | if (*axis == BMP_ALIGN_CENTER) |
| 717 | axis_alignment = panel_picture_delta / 2; |
| 718 | else if (*axis < 0) |
| 719 | axis_alignment = panel_picture_delta + *axis + 1; |
| 720 | else |
| 721 | return; |
| 722 | |
| 723 | *axis = max(0, axis_alignment); |
| 724 | } |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 725 | #endif |
| 726 | |
Tom Wai-Hong Tam | 45d7f52 | 2012-09-28 15:11:16 +0000 | [diff] [blame] | 727 | |
| 728 | #ifdef CONFIG_LCD_BMP_RLE8 |
| 729 | |
| 730 | #define BMP_RLE8_ESCAPE 0 |
| 731 | #define BMP_RLE8_EOL 0 |
| 732 | #define BMP_RLE8_EOBMP 1 |
| 733 | #define BMP_RLE8_DELTA 2 |
| 734 | |
| 735 | static void draw_unencoded_bitmap(ushort **fbp, uchar *bmap, ushort *cmap, |
| 736 | int cnt) |
| 737 | { |
| 738 | while (cnt > 0) { |
| 739 | *(*fbp)++ = cmap[*bmap++]; |
| 740 | cnt--; |
| 741 | } |
| 742 | } |
| 743 | |
| 744 | static void draw_encoded_bitmap(ushort **fbp, ushort c, int cnt) |
| 745 | { |
| 746 | ushort *fb = *fbp; |
| 747 | int cnt_8copy = cnt >> 3; |
| 748 | |
| 749 | cnt -= cnt_8copy << 3; |
| 750 | while (cnt_8copy > 0) { |
| 751 | *fb++ = c; |
| 752 | *fb++ = c; |
| 753 | *fb++ = c; |
| 754 | *fb++ = c; |
| 755 | *fb++ = c; |
| 756 | *fb++ = c; |
| 757 | *fb++ = c; |
| 758 | *fb++ = c; |
| 759 | cnt_8copy--; |
| 760 | } |
| 761 | while (cnt > 0) { |
| 762 | *fb++ = c; |
| 763 | cnt--; |
| 764 | } |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 765 | *fbp = fb; |
Tom Wai-Hong Tam | 45d7f52 | 2012-09-28 15:11:16 +0000 | [diff] [blame] | 766 | } |
| 767 | |
| 768 | /* |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 769 | * 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] | 770 | */ |
| 771 | static void lcd_display_rle8_bitmap(bmp_image_t *bmp, ushort *cmap, uchar *fb, |
| 772 | int x_off, int y_off) |
| 773 | { |
| 774 | uchar *bmap; |
| 775 | ulong width, height; |
| 776 | ulong cnt, runlen; |
| 777 | int x, y; |
| 778 | int decode = 1; |
| 779 | |
Przemyslaw Marczak | dca2a1c | 2014-01-22 11:24:13 +0100 | [diff] [blame] | 780 | width = get_unaligned_le32(&bmp->header.width); |
| 781 | height = get_unaligned_le32(&bmp->header.height); |
| 782 | bmap = (uchar *)bmp + get_unaligned_le32(&bmp->header.data_offset); |
Tom Wai-Hong Tam | 45d7f52 | 2012-09-28 15:11:16 +0000 | [diff] [blame] | 783 | |
| 784 | x = 0; |
| 785 | y = height - 1; |
| 786 | |
| 787 | while (decode) { |
| 788 | if (bmap[0] == BMP_RLE8_ESCAPE) { |
| 789 | switch (bmap[1]) { |
| 790 | case BMP_RLE8_EOL: |
| 791 | /* end of line */ |
| 792 | bmap += 2; |
| 793 | x = 0; |
| 794 | y--; |
| 795 | /* 16bpix, 2-byte per pixel, width should *2 */ |
| 796 | fb -= (width * 2 + lcd_line_length); |
| 797 | break; |
| 798 | case BMP_RLE8_EOBMP: |
| 799 | /* end of bitmap */ |
| 800 | decode = 0; |
| 801 | break; |
| 802 | case BMP_RLE8_DELTA: |
| 803 | /* delta run */ |
| 804 | x += bmap[2]; |
| 805 | y -= bmap[3]; |
| 806 | /* 16bpix, 2-byte per pixel, x should *2 */ |
| 807 | fb = (uchar *) (lcd_base + (y + y_off - 1) |
| 808 | * lcd_line_length + (x + x_off) * 2); |
| 809 | bmap += 4; |
| 810 | break; |
| 811 | default: |
| 812 | /* unencoded run */ |
| 813 | runlen = bmap[1]; |
| 814 | bmap += 2; |
| 815 | if (y < height) { |
| 816 | if (x < width) { |
| 817 | if (x + runlen > width) |
| 818 | cnt = width - x; |
| 819 | else |
| 820 | cnt = runlen; |
| 821 | draw_unencoded_bitmap( |
| 822 | (ushort **)&fb, |
| 823 | bmap, cmap, cnt); |
| 824 | } |
| 825 | x += runlen; |
| 826 | } |
| 827 | bmap += runlen; |
| 828 | if (runlen & 1) |
| 829 | bmap++; |
| 830 | } |
| 831 | } else { |
| 832 | /* encoded run */ |
| 833 | if (y < height) { |
| 834 | runlen = bmap[0]; |
| 835 | if (x < width) { |
| 836 | /* aggregate the same code */ |
| 837 | while (bmap[0] == 0xff && |
| 838 | bmap[2] != BMP_RLE8_ESCAPE && |
| 839 | bmap[1] == bmap[3]) { |
| 840 | runlen += bmap[2]; |
| 841 | bmap += 2; |
| 842 | } |
| 843 | if (x + runlen > width) |
| 844 | cnt = width - x; |
| 845 | else |
| 846 | cnt = runlen; |
| 847 | draw_encoded_bitmap((ushort **)&fb, |
| 848 | cmap[bmap[1]], cnt); |
| 849 | } |
| 850 | x += runlen; |
| 851 | } |
| 852 | bmap += 2; |
| 853 | } |
| 854 | } |
| 855 | } |
| 856 | #endif |
| 857 | |
Anatolij Gustschin | d23019f | 2012-09-22 06:55:53 +0000 | [diff] [blame] | 858 | #if defined(CONFIG_MPC823) || defined(CONFIG_MCC200) |
Nikita Kiryanov | bfdcc65 | 2012-08-09 00:14:53 +0000 | [diff] [blame] | 859 | #define FB_PUT_BYTE(fb, from) *(fb)++ = (255 - *(from)++) |
Anatolij Gustschin | d23019f | 2012-09-22 06:55:53 +0000 | [diff] [blame] | 860 | #else |
| 861 | #define FB_PUT_BYTE(fb, from) *(fb)++ = *(from)++ |
Nikita Kiryanov | bfdcc65 | 2012-08-09 00:14:53 +0000 | [diff] [blame] | 862 | #endif |
| 863 | |
| 864 | #if defined(CONFIG_BMP_16BPP) |
| 865 | #if defined(CONFIG_ATMEL_LCD_BGR555) |
| 866 | static inline void fb_put_word(uchar **fb, uchar **from) |
| 867 | { |
| 868 | *(*fb)++ = (((*from)[0] & 0x1f) << 2) | ((*from)[1] & 0x03); |
| 869 | *(*fb)++ = ((*from)[0] & 0xe0) | (((*from)[1] & 0x7c) >> 2); |
| 870 | *from += 2; |
| 871 | } |
| 872 | #else |
| 873 | static inline void fb_put_word(uchar **fb, uchar **from) |
| 874 | { |
| 875 | *(*fb)++ = *(*from)++; |
| 876 | *(*fb)++ = *(*from)++; |
| 877 | } |
| 878 | #endif |
| 879 | #endif /* CONFIG_BMP_16BPP */ |
| 880 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 881 | int lcd_display_bitmap(ulong bmp_image, int x, int y) |
| 882 | { |
Anatolij Gustschin | 00cc559 | 2009-02-25 20:28:13 +0100 | [diff] [blame] | 883 | #if !defined(CONFIG_MCC200) |
| 884 | ushort *cmap = NULL; |
| 885 | #endif |
| 886 | ushort *cmap_base = NULL; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 887 | ushort i, j; |
| 888 | uchar *fb; |
| 889 | bmp_image_t *bmp=(bmp_image_t *)bmp_image; |
| 890 | uchar *bmap; |
Tom Wai-Hong Tam | fecac46 | 2012-09-28 15:11:14 +0000 | [diff] [blame] | 891 | ushort padded_width; |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 892 | unsigned long width, height, byte_width; |
Wolfgang Denk | e8143e7 | 2006-08-30 23:09:00 +0200 | [diff] [blame] | 893 | unsigned long pwidth = panel_info.vl_col; |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 894 | unsigned colors, bpix, bmp_bpix; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 895 | |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 896 | if (!bmp || !(bmp->header.signature[0] == 'B' && |
| 897 | bmp->header.signature[1] == 'M')) { |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 898 | printf("Error: no valid bmp image at %lx\n", bmp_image); |
| 899 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 900 | return 1; |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 901 | } |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 902 | |
Przemyslaw Marczak | dca2a1c | 2014-01-22 11:24:13 +0100 | [diff] [blame] | 903 | width = get_unaligned_le32(&bmp->header.width); |
| 904 | height = get_unaligned_le32(&bmp->header.height); |
| 905 | bmp_bpix = get_unaligned_le16(&bmp->header.bit_count); |
| 906 | |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 907 | colors = 1 << bmp_bpix; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 908 | |
| 909 | bpix = NBITS(panel_info.vl_bpix); |
| 910 | |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 911 | if (bpix != 1 && bpix != 8 && bpix != 16 && bpix != 32) { |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 912 | printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n", |
| 913 | bpix, bmp_bpix); |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 914 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 915 | return 1; |
| 916 | } |
| 917 | |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 918 | /* We support displaying 8bpp BMPs on 16bpp LCDs */ |
Nikita Kiryanov | dad631c | 2012-12-20 00:52:34 +0000 | [diff] [blame] | 919 | if (bpix != bmp_bpix && !(bmp_bpix == 8 && bpix == 16)) { |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 920 | 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] | 921 | bpix, get_unaligned_le16(&bmp->header.bit_count)); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 922 | return 1; |
| 923 | } |
| 924 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 925 | debug("Display-bmp: %d x %d with %d colors\n", |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 926 | (int)width, (int)height, (int)colors); |
| 927 | |
Wolfgang Denk | f641471 | 2006-10-20 15:51:21 +0200 | [diff] [blame] | 928 | #if !defined(CONFIG_MCC200) |
| 929 | /* MCC200 LCD doesn't need CMAP, supports 1bpp b&w only */ |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 930 | if (bmp_bpix == 8) { |
Nikita Kiryanov | 203c37b | 2012-08-09 00:14:52 +0000 | [diff] [blame] | 931 | cmap = configuration_get_cmap(); |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 932 | cmap_base = cmap; |
| 933 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 934 | /* Set color map */ |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 935 | for (i = 0; i < colors; ++i) { |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 936 | bmp_color_table_entry_t cte = bmp->color_table[i]; |
Mark Jackson | 1464eff | 2008-08-01 09:48:29 +0100 | [diff] [blame] | 937 | #if !defined(CONFIG_ATMEL_LCD) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 938 | ushort colreg = |
| 939 | ( ((cte.red) << 8) & 0xf800) | |
Wolfgang Denk | 59d80bf | 2005-09-21 15:24:52 +0200 | [diff] [blame] | 940 | ( ((cte.green) << 3) & 0x07e0) | |
| 941 | ( ((cte.blue) >> 3) & 0x001f) ; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 942 | #ifdef CONFIG_SYS_INVERT_COLORS |
wdenk | 25d6712 | 2004-12-10 11:40:40 +0000 | [diff] [blame] | 943 | *cmap = 0xffff - colreg; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 944 | #else |
wdenk | 25d6712 | 2004-12-10 11:40:40 +0000 | [diff] [blame] | 945 | *cmap = colreg; |
| 946 | #endif |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 947 | #if defined(CONFIG_MPC823) |
wdenk | 25d6712 | 2004-12-10 11:40:40 +0000 | [diff] [blame] | 948 | cmap--; |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 949 | #else |
| 950 | cmap++; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 951 | #endif |
Mark Jackson | 1464eff | 2008-08-01 09:48:29 +0100 | [diff] [blame] | 952 | #else /* CONFIG_ATMEL_LCD */ |
| 953 | lcd_setcolreg(i, cte.red, cte.green, cte.blue); |
| 954 | #endif |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 955 | } |
| 956 | } |
Wolfgang Denk | f641471 | 2006-10-20 15:51:21 +0200 | [diff] [blame] | 957 | #endif |
Wolfgang Denk | e8143e7 | 2006-08-30 23:09:00 +0200 | [diff] [blame] | 958 | /* |
| 959 | * BMP format for Monochrome assumes that the state of a |
| 960 | * pixel is described on a per Bit basis, not per Byte. |
| 961 | * So, in case of Monochrome BMP we should align widths |
| 962 | * on a byte boundary and convert them from Bit to Byte |
| 963 | * units. |
Wolfgang Denk | 511d0c7 | 2006-10-09 00:42:01 +0200 | [diff] [blame] | 964 | * Probably, PXA250 and MPC823 process 1bpp BMP images in |
| 965 | * their own ways, so make the converting to be MCC200 |
Wolfgang Denk | e8143e7 | 2006-08-30 23:09:00 +0200 | [diff] [blame] | 966 | * specific. |
| 967 | */ |
| 968 | #if defined(CONFIG_MCC200) |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 969 | if (bpix == 1) { |
Wolfgang Denk | e8143e7 | 2006-08-30 23:09:00 +0200 | [diff] [blame] | 970 | width = ((width + 7) & ~7) >> 3; |
| 971 | x = ((x + 7) & ~7) >> 3; |
| 972 | pwidth= ((pwidth + 7) & ~7) >> 3; |
| 973 | } |
| 974 | #endif |
| 975 | |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 976 | padded_width = (width & 0x3 ? (width & ~0x3) + 4 : width); |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 977 | |
| 978 | #ifdef CONFIG_SPLASH_SCREEN_ALIGN |
Nikita Kiryanov | 7c7e280 | 2012-08-09 00:14:51 +0000 | [diff] [blame] | 979 | splash_align_axis(&x, pwidth, width); |
| 980 | splash_align_axis(&y, panel_info.vl_row, height); |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 981 | #endif /* CONFIG_SPLASH_SCREEN_ALIGN */ |
| 982 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 983 | if ((x + width) > pwidth) |
Wolfgang Denk | e8143e7 | 2006-08-30 23:09:00 +0200 | [diff] [blame] | 984 | width = pwidth - x; |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 985 | if ((y + height) > panel_info.vl_row) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 986 | height = panel_info.vl_row - y; |
| 987 | |
Przemyslaw Marczak | dca2a1c | 2014-01-22 11:24:13 +0100 | [diff] [blame] | 988 | bmap = (uchar *)bmp + get_unaligned_le32(&bmp->header.data_offset); |
| 989 | fb = (uchar *)(lcd_base + |
Liu Ying | 8d46d5b | 2011-01-11 15:29:58 +0800 | [diff] [blame] | 990 | (y + height - 1) * lcd_line_length + x * bpix / 8); |
Mark Jackson | a303dfb | 2009-02-06 10:37:49 +0100 | [diff] [blame] | 991 | |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 992 | switch (bmp_bpix) { |
Mark Jackson | a303dfb | 2009-02-06 10:37:49 +0100 | [diff] [blame] | 993 | case 1: /* pass through */ |
| 994 | case 8: |
Tom Wai-Hong Tam | 45d7f52 | 2012-09-28 15:11:16 +0000 | [diff] [blame] | 995 | #ifdef CONFIG_LCD_BMP_RLE8 |
Przemyslaw Marczak | dca2a1c | 2014-01-22 11:24:13 +0100 | [diff] [blame] | 996 | u32 compression = get_unaligned_le32(&bmp->header.compression); |
| 997 | if (compression == BMP_BI_RLE8) { |
Tom Wai-Hong Tam | 45d7f52 | 2012-09-28 15:11:16 +0000 | [diff] [blame] | 998 | if (bpix != 16) { |
| 999 | /* TODO implement render code for bpix != 16 */ |
| 1000 | printf("Error: only support 16 bpix"); |
| 1001 | return 1; |
| 1002 | } |
| 1003 | lcd_display_rle8_bitmap(bmp, cmap_base, fb, x, y); |
| 1004 | break; |
| 1005 | } |
| 1006 | #endif |
| 1007 | |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 1008 | if (bpix != 16) |
| 1009 | byte_width = width; |
| 1010 | else |
| 1011 | byte_width = width * 2; |
| 1012 | |
Mark Jackson | a303dfb | 2009-02-06 10:37:49 +0100 | [diff] [blame] | 1013 | for (i = 0; i < height; ++i) { |
| 1014 | WATCHDOG_RESET(); |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 1015 | for (j = 0; j < width; j++) { |
| 1016 | if (bpix != 16) { |
Nikita Kiryanov | bfdcc65 | 2012-08-09 00:14:53 +0000 | [diff] [blame] | 1017 | FB_PUT_BYTE(fb, bmap); |
Guennadi Liakhovetski | b245e65 | 2009-02-06 10:37:53 +0100 | [diff] [blame] | 1018 | } else { |
| 1019 | *(uint16_t *)fb = cmap_base[*(bmap++)]; |
| 1020 | fb += sizeof(uint16_t) / sizeof(*fb); |
| 1021 | } |
| 1022 | } |
Tom Wai-Hong Tam | fecac46 | 2012-09-28 15:11:14 +0000 | [diff] [blame] | 1023 | bmap += (padded_width - width); |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 1024 | fb -= byte_width + lcd_line_length; |
Mark Jackson | a303dfb | 2009-02-06 10:37:49 +0100 | [diff] [blame] | 1025 | } |
| 1026 | break; |
| 1027 | |
| 1028 | #if defined(CONFIG_BMP_16BPP) |
| 1029 | case 16: |
| 1030 | for (i = 0; i < height; ++i) { |
| 1031 | WATCHDOG_RESET(); |
Nikita Kiryanov | bfdcc65 | 2012-08-09 00:14:53 +0000 | [diff] [blame] | 1032 | for (j = 0; j < width; j++) |
| 1033 | fb_put_word(&fb, &bmap); |
| 1034 | |
Tom Wai-Hong Tam | fecac46 | 2012-09-28 15:11:14 +0000 | [diff] [blame] | 1035 | bmap += (padded_width - width) * 2; |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 1036 | fb -= width * 2 + lcd_line_length; |
Mark Jackson | a303dfb | 2009-02-06 10:37:49 +0100 | [diff] [blame] | 1037 | } |
| 1038 | break; |
| 1039 | #endif /* CONFIG_BMP_16BPP */ |
| 1040 | |
Donghwa Lee | fb6a9aa | 2012-05-09 19:23:37 +0000 | [diff] [blame] | 1041 | #if defined(CONFIG_BMP_32BPP) |
| 1042 | case 32: |
| 1043 | for (i = 0; i < height; ++i) { |
| 1044 | for (j = 0; j < width; j++) { |
| 1045 | *(fb++) = *(bmap++); |
| 1046 | *(fb++) = *(bmap++); |
| 1047 | *(fb++) = *(bmap++); |
| 1048 | *(fb++) = *(bmap++); |
| 1049 | } |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 1050 | fb -= lcd_line_length + width * (bpix / 8); |
Donghwa Lee | fb6a9aa | 2012-05-09 19:23:37 +0000 | [diff] [blame] | 1051 | } |
| 1052 | break; |
| 1053 | #endif /* CONFIG_BMP_32BPP */ |
Mark Jackson | a303dfb | 2009-02-06 10:37:49 +0100 | [diff] [blame] | 1054 | default: |
| 1055 | break; |
| 1056 | }; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 1057 | |
Simon Glass | 9a8efc4 | 2012-10-30 13:40:18 +0000 | [diff] [blame] | 1058 | lcd_sync(); |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 1059 | return 0; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 1060 | } |
Jon Loeliger | c3517f9 | 2007-07-08 18:10:08 -0500 | [diff] [blame] | 1061 | #endif |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 1062 | |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 1063 | static void *lcd_logo(void) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 1064 | { |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 1065 | #ifdef CONFIG_SPLASH_SCREEN |
| 1066 | char *s; |
| 1067 | ulong addr; |
| 1068 | static int do_splash = 1; |
| 1069 | |
| 1070 | if (do_splash && (s = getenv("splashimage")) != NULL) { |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 1071 | int x = 0, y = 0; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 1072 | do_splash = 0; |
| 1073 | |
Nikita Kiryanov | 581bb41 | 2013-01-30 21:39:57 +0000 | [diff] [blame] | 1074 | if (splash_screen_prepare()) |
Robert Winkler | dd4425e | 2013-06-17 11:31:29 -0700 | [diff] [blame] | 1075 | return (void *)lcd_base; |
Nikita Kiryanov | 581bb41 | 2013-01-30 21:39:57 +0000 | [diff] [blame] | 1076 | |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 1077 | addr = simple_strtoul (s, NULL, 16); |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 1078 | |
Anatolij Gustschin | ff8fb56 | 2013-07-02 00:04:05 +0200 | [diff] [blame] | 1079 | splash_get_pos(&x, &y); |
Matthias Weisser | 1ca298c | 2009-07-09 16:07:30 +0200 | [diff] [blame] | 1080 | |
Nikita Kiryanov | d3a555e | 2012-08-09 00:14:50 +0000 | [diff] [blame] | 1081 | if (bmp_display(addr, x, y) == 0) |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 1082 | return (void *)lcd_base; |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 1083 | } |
| 1084 | #endif /* CONFIG_SPLASH_SCREEN */ |
| 1085 | |
Anatolij Gustschin | 2b5cb3d | 2012-04-27 04:41:27 +0000 | [diff] [blame] | 1086 | bitmap_plot(0, 0); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 1087 | |
Haavard Skinnemoen | 6b59e03 | 2008-09-01 16:21:22 +0200 | [diff] [blame] | 1088 | #ifdef CONFIG_LCD_INFO |
| 1089 | console_col = LCD_INFO_X / VIDEO_FONT_WIDTH; |
| 1090 | console_row = LCD_INFO_Y / VIDEO_FONT_HEIGHT; |
| 1091 | lcd_show_board_info(); |
| 1092 | #endif /* CONFIG_LCD_INFO */ |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 1093 | |
wdenk | 88804d1 | 2005-07-04 00:03:16 +0000 | [diff] [blame] | 1094 | #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO) |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 1095 | return (void *)((ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length); |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 1096 | #else |
Nikita Kiryanov | 8f47d91 | 2012-05-24 01:42:38 +0000 | [diff] [blame] | 1097 | return (void *)lcd_base; |
Jeroen Hofstee | 6b03514 | 2013-01-12 12:07:56 +0000 | [diff] [blame] | 1098 | #endif /* CONFIG_LCD_LOGO && !defined(CONFIG_LCD_INFO_BELOW_LOGO) */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame] | 1099 | } |
| 1100 | |
Nikita Kiryanov | c088048 | 2013-02-24 21:28:43 +0000 | [diff] [blame] | 1101 | #ifdef CONFIG_SPLASHIMAGE_GUARD |
| 1102 | static int on_splashimage(const char *name, const char *value, enum env_op op, |
| 1103 | int flags) |
| 1104 | { |
| 1105 | ulong addr; |
| 1106 | int aligned; |
| 1107 | |
| 1108 | if (op == env_op_delete) |
| 1109 | return 0; |
| 1110 | |
| 1111 | addr = simple_strtoul(value, NULL, 16); |
| 1112 | /* See README.displaying-bmps */ |
| 1113 | aligned = (addr % 4 == 2); |
| 1114 | if (!aligned) { |
| 1115 | printf("Invalid splashimage value. Value must be 16 bit aligned, but not 32 bit aligned\n"); |
| 1116 | return -1; |
| 1117 | } |
| 1118 | |
| 1119 | return 0; |
| 1120 | } |
| 1121 | |
| 1122 | U_BOOT_ENV_CALLBACK(splashimage, on_splashimage); |
| 1123 | #endif |
| 1124 | |
Vadim Bendebury | 395166c | 2012-09-28 15:11:13 +0000 | [diff] [blame] | 1125 | void lcd_position_cursor(unsigned col, unsigned row) |
| 1126 | { |
| 1127 | console_col = min(col, CONSOLE_COLS - 1); |
| 1128 | console_row = min(row, CONSOLE_ROWS - 1); |
| 1129 | } |
| 1130 | |
| 1131 | int lcd_get_pixel_width(void) |
| 1132 | { |
| 1133 | return panel_info.vl_col; |
| 1134 | } |
| 1135 | |
| 1136 | int lcd_get_pixel_height(void) |
| 1137 | { |
| 1138 | return panel_info.vl_row; |
| 1139 | } |
| 1140 | |
| 1141 | int lcd_get_screen_rows(void) |
| 1142 | { |
| 1143 | return CONSOLE_ROWS; |
| 1144 | } |
| 1145 | |
| 1146 | int lcd_get_screen_columns(void) |
| 1147 | { |
| 1148 | return CONSOLE_COLS; |
| 1149 | } |
Stephen Warren | 6a195d2 | 2013-05-27 18:31:17 +0000 | [diff] [blame] | 1150 | |
| 1151 | #if defined(CONFIG_LCD_DT_SIMPLEFB) |
| 1152 | static int lcd_dt_simplefb_configure_node(void *blob, int off) |
| 1153 | { |
| 1154 | u32 stride; |
| 1155 | fdt32_t cells[2]; |
| 1156 | int ret; |
Stephen Warren | 5af7d0f | 2013-06-13 17:13:11 -0600 | [diff] [blame] | 1157 | static const char format[] = |
Stephen Warren | 6a195d2 | 2013-05-27 18:31:17 +0000 | [diff] [blame] | 1158 | #if LCD_BPP == LCD_COLOR16 |
| 1159 | "r5g6b5"; |
| 1160 | #else |
| 1161 | ""; |
| 1162 | #endif |
| 1163 | |
| 1164 | if (!format[0]) |
| 1165 | return -1; |
| 1166 | |
| 1167 | stride = panel_info.vl_col * 2; |
| 1168 | |
| 1169 | cells[0] = cpu_to_fdt32(gd->fb_base); |
| 1170 | cells[1] = cpu_to_fdt32(stride * panel_info.vl_row); |
| 1171 | ret = fdt_setprop(blob, off, "reg", cells, sizeof(cells[0]) * 2); |
| 1172 | if (ret < 0) |
| 1173 | return -1; |
| 1174 | |
| 1175 | cells[0] = cpu_to_fdt32(panel_info.vl_col); |
| 1176 | ret = fdt_setprop(blob, off, "width", cells, sizeof(cells[0])); |
| 1177 | if (ret < 0) |
| 1178 | return -1; |
| 1179 | |
| 1180 | cells[0] = cpu_to_fdt32(panel_info.vl_row); |
| 1181 | ret = fdt_setprop(blob, off, "height", cells, sizeof(cells[0])); |
| 1182 | if (ret < 0) |
| 1183 | return -1; |
| 1184 | |
| 1185 | cells[0] = cpu_to_fdt32(stride); |
| 1186 | ret = fdt_setprop(blob, off, "stride", cells, sizeof(cells[0])); |
| 1187 | if (ret < 0) |
| 1188 | return -1; |
| 1189 | |
| 1190 | ret = fdt_setprop(blob, off, "format", format, strlen(format) + 1); |
| 1191 | if (ret < 0) |
| 1192 | return -1; |
| 1193 | |
| 1194 | ret = fdt_delprop(blob, off, "status"); |
| 1195 | if (ret < 0) |
| 1196 | return -1; |
| 1197 | |
| 1198 | return 0; |
| 1199 | } |
| 1200 | |
| 1201 | int lcd_dt_simplefb_add_node(void *blob) |
| 1202 | { |
Stephen Warren | 5af7d0f | 2013-06-13 17:13:11 -0600 | [diff] [blame] | 1203 | static const char compat[] = "simple-framebuffer"; |
| 1204 | static const char disabled[] = "disabled"; |
Stephen Warren | 6a195d2 | 2013-05-27 18:31:17 +0000 | [diff] [blame] | 1205 | int off, ret; |
| 1206 | |
| 1207 | off = fdt_add_subnode(blob, 0, "framebuffer"); |
| 1208 | if (off < 0) |
| 1209 | return -1; |
| 1210 | |
| 1211 | ret = fdt_setprop(blob, off, "status", disabled, sizeof(disabled)); |
| 1212 | if (ret < 0) |
| 1213 | return -1; |
| 1214 | |
| 1215 | ret = fdt_setprop(blob, off, "compatible", compat, sizeof(compat)); |
| 1216 | if (ret < 0) |
| 1217 | return -1; |
| 1218 | |
| 1219 | return lcd_dt_simplefb_configure_node(blob, off); |
| 1220 | } |
| 1221 | |
| 1222 | int lcd_dt_simplefb_enable_existing_node(void *blob) |
| 1223 | { |
| 1224 | int off; |
| 1225 | |
| 1226 | off = fdt_node_offset_by_compatible(blob, -1, "simple-framebuffer"); |
| 1227 | if (off < 0) |
| 1228 | return -1; |
| 1229 | |
| 1230 | return lcd_dt_simplefb_configure_node(blob, off); |
| 1231 | } |
| 1232 | #endif |