Commit ff8fb56b6f7edafc1bcba8ef008b3f368cabe60d

Authored by Anatolij Gustschin
1 parent 327598945b

video: consolidate splash screen alignment code

Code for checking "splashpos" environment variable is
duplicated in drivers, move it to the common function.
Call this function also in the bmp display command to
consider "splashpos" settings.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Acked-by: Otavio Salvador <otavio@ossystems.com.br>

Showing 5 changed files with 39 additions and 39 deletions Inline Diff

1 /* 1 /*
2 * (C) Copyright 2002 2 * (C) Copyright 2002
3 * Detlev Zundel, DENX Software Engineering, dzu@denx.de. 3 * Detlev Zundel, DENX Software Engineering, dzu@denx.de.
4 * 4 *
5 * See file CREDITS for list of people who contributed to this 5 * See file CREDITS for list of people who contributed to this
6 * project. 6 * project.
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of 10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version. 11 * the License, or (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA 21 * MA 02111-1307 USA
22 */ 22 */
23 23
24 /* 24 /*
25 * BMP handling routines 25 * BMP handling routines
26 */ 26 */
27 27
28 #include <common.h> 28 #include <common.h>
29 #include <lcd.h> 29 #include <lcd.h>
30 #include <bmp_layout.h> 30 #include <bmp_layout.h>
31 #include <command.h> 31 #include <command.h>
32 #include <asm/byteorder.h> 32 #include <asm/byteorder.h>
33 #include <malloc.h> 33 #include <malloc.h>
34 #include <splash.h>
34 #include <video.h> 35 #include <video.h>
35 36
36 static int bmp_info (ulong addr); 37 static int bmp_info (ulong addr);
37 38
38 /* 39 /*
39 * Allocate and decompress a BMP image using gunzip(). 40 * Allocate and decompress a BMP image using gunzip().
40 * 41 *
41 * Returns a pointer to the decompressed image data. This pointer is 42 * Returns a pointer to the decompressed image data. This pointer is
42 * aligned to 32-bit-aligned-address + 2. 43 * aligned to 32-bit-aligned-address + 2.
43 * See doc/README.displaying-bmps for explanation. 44 * See doc/README.displaying-bmps for explanation.
44 * 45 *
45 * The allocation address is passed to 'alloc_addr' and must be freed 46 * The allocation address is passed to 'alloc_addr' and must be freed
46 * by the caller after use. 47 * by the caller after use.
47 * 48 *
48 * Returns NULL if decompression failed, or if the decompressed data 49 * Returns NULL if decompression failed, or if the decompressed data
49 * didn't contain a valid BMP signature. 50 * didn't contain a valid BMP signature.
50 */ 51 */
51 #ifdef CONFIG_VIDEO_BMP_GZIP 52 #ifdef CONFIG_VIDEO_BMP_GZIP
52 bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp, 53 bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp,
53 void **alloc_addr) 54 void **alloc_addr)
54 { 55 {
55 void *dst; 56 void *dst;
56 unsigned long len; 57 unsigned long len;
57 bmp_image_t *bmp; 58 bmp_image_t *bmp;
58 59
59 /* 60 /*
60 * Decompress bmp image 61 * Decompress bmp image
61 */ 62 */
62 len = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE; 63 len = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE;
63 /* allocate extra 3 bytes for 32-bit-aligned-address + 2 alignment */ 64 /* allocate extra 3 bytes for 32-bit-aligned-address + 2 alignment */
64 dst = malloc(CONFIG_SYS_VIDEO_LOGO_MAX_SIZE + 3); 65 dst = malloc(CONFIG_SYS_VIDEO_LOGO_MAX_SIZE + 3);
65 if (dst == NULL) { 66 if (dst == NULL) {
66 puts("Error: malloc in gunzip failed!\n"); 67 puts("Error: malloc in gunzip failed!\n");
67 return NULL; 68 return NULL;
68 } 69 }
69 70
70 bmp = dst; 71 bmp = dst;
71 72
72 /* align to 32-bit-aligned-address + 2 */ 73 /* align to 32-bit-aligned-address + 2 */
73 bmp = (bmp_image_t *)((((unsigned int)dst + 1) & ~3) + 2); 74 bmp = (bmp_image_t *)((((unsigned int)dst + 1) & ~3) + 2);
74 75
75 if (gunzip(bmp, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE, (uchar *)addr, &len) != 0) { 76 if (gunzip(bmp, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE, (uchar *)addr, &len) != 0) {
76 free(dst); 77 free(dst);
77 return NULL; 78 return NULL;
78 } 79 }
79 if (len == CONFIG_SYS_VIDEO_LOGO_MAX_SIZE) 80 if (len == CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)
80 puts("Image could be truncated" 81 puts("Image could be truncated"
81 " (increase CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)!\n"); 82 " (increase CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)!\n");
82 83
83 /* 84 /*
84 * Check for bmp mark 'BM' 85 * Check for bmp mark 'BM'
85 */ 86 */
86 if (!((bmp->header.signature[0] == 'B') && 87 if (!((bmp->header.signature[0] == 'B') &&
87 (bmp->header.signature[1] == 'M'))) { 88 (bmp->header.signature[1] == 'M'))) {
88 free(dst); 89 free(dst);
89 return NULL; 90 return NULL;
90 } 91 }
91 92
92 debug("Gzipped BMP image detected!\n"); 93 debug("Gzipped BMP image detected!\n");
93 94
94 *alloc_addr = dst; 95 *alloc_addr = dst;
95 return bmp; 96 return bmp;
96 } 97 }
97 #else 98 #else
98 bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp, 99 bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp,
99 void **alloc_addr) 100 void **alloc_addr)
100 { 101 {
101 return NULL; 102 return NULL;
102 } 103 }
103 #endif 104 #endif
104 105
105 static int do_bmp_info(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) 106 static int do_bmp_info(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
106 { 107 {
107 ulong addr; 108 ulong addr;
108 109
109 switch (argc) { 110 switch (argc) {
110 case 1: /* use load_addr as default address */ 111 case 1: /* use load_addr as default address */
111 addr = load_addr; 112 addr = load_addr;
112 break; 113 break;
113 case 2: /* use argument */ 114 case 2: /* use argument */
114 addr = simple_strtoul(argv[1], NULL, 16); 115 addr = simple_strtoul(argv[1], NULL, 16);
115 break; 116 break;
116 default: 117 default:
117 return CMD_RET_USAGE; 118 return CMD_RET_USAGE;
118 } 119 }
119 120
120 return (bmp_info(addr)); 121 return (bmp_info(addr));
121 } 122 }
122 123
123 static int do_bmp_display(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) 124 static int do_bmp_display(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
124 { 125 {
125 ulong addr; 126 ulong addr;
126 int x = 0, y = 0; 127 int x = 0, y = 0;
128
129 splash_get_pos(&x, &y);
127 130
128 switch (argc) { 131 switch (argc) {
129 case 1: /* use load_addr as default address */ 132 case 1: /* use load_addr as default address */
130 addr = load_addr; 133 addr = load_addr;
131 break; 134 break;
132 case 2: /* use argument */ 135 case 2: /* use argument */
133 addr = simple_strtoul(argv[1], NULL, 16); 136 addr = simple_strtoul(argv[1], NULL, 16);
134 break; 137 break;
135 case 4: 138 case 4:
136 addr = simple_strtoul(argv[1], NULL, 16); 139 addr = simple_strtoul(argv[1], NULL, 16);
137 x = simple_strtoul(argv[2], NULL, 10); 140 x = simple_strtoul(argv[2], NULL, 10);
138 y = simple_strtoul(argv[3], NULL, 10); 141 y = simple_strtoul(argv[3], NULL, 10);
139 break; 142 break;
140 default: 143 default:
141 return CMD_RET_USAGE; 144 return CMD_RET_USAGE;
142 } 145 }
143 146
144 return (bmp_display(addr, x, y)); 147 return (bmp_display(addr, x, y));
145 } 148 }
146 149
147 static cmd_tbl_t cmd_bmp_sub[] = { 150 static cmd_tbl_t cmd_bmp_sub[] = {
148 U_BOOT_CMD_MKENT(info, 3, 0, do_bmp_info, "", ""), 151 U_BOOT_CMD_MKENT(info, 3, 0, do_bmp_info, "", ""),
149 U_BOOT_CMD_MKENT(display, 5, 0, do_bmp_display, "", ""), 152 U_BOOT_CMD_MKENT(display, 5, 0, do_bmp_display, "", ""),
150 }; 153 };
151 154
152 #ifdef CONFIG_NEEDS_MANUAL_RELOC 155 #ifdef CONFIG_NEEDS_MANUAL_RELOC
153 void bmp_reloc(void) { 156 void bmp_reloc(void) {
154 fixup_cmdtable(cmd_bmp_sub, ARRAY_SIZE(cmd_bmp_sub)); 157 fixup_cmdtable(cmd_bmp_sub, ARRAY_SIZE(cmd_bmp_sub));
155 } 158 }
156 #endif 159 #endif
157 160
158 /* 161 /*
159 * Subroutine: do_bmp 162 * Subroutine: do_bmp
160 * 163 *
161 * Description: Handler for 'bmp' command.. 164 * Description: Handler for 'bmp' command..
162 * 165 *
163 * Inputs: argv[1] contains the subcommand 166 * Inputs: argv[1] contains the subcommand
164 * 167 *
165 * Return: None 168 * Return: None
166 * 169 *
167 */ 170 */
168 static int do_bmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 171 static int do_bmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
169 { 172 {
170 cmd_tbl_t *c; 173 cmd_tbl_t *c;
171 174
172 /* Strip off leading 'bmp' command argument */ 175 /* Strip off leading 'bmp' command argument */
173 argc--; 176 argc--;
174 argv++; 177 argv++;
175 178
176 c = find_cmd_tbl(argv[0], &cmd_bmp_sub[0], ARRAY_SIZE(cmd_bmp_sub)); 179 c = find_cmd_tbl(argv[0], &cmd_bmp_sub[0], ARRAY_SIZE(cmd_bmp_sub));
177 180
178 if (c) 181 if (c)
179 return c->cmd(cmdtp, flag, argc, argv); 182 return c->cmd(cmdtp, flag, argc, argv);
180 else 183 else
181 return CMD_RET_USAGE; 184 return CMD_RET_USAGE;
182 } 185 }
183 186
184 U_BOOT_CMD( 187 U_BOOT_CMD(
185 bmp, 5, 1, do_bmp, 188 bmp, 5, 1, do_bmp,
186 "manipulate BMP image data", 189 "manipulate BMP image data",
187 "info <imageAddr> - display image info\n" 190 "info <imageAddr> - display image info\n"
188 "bmp display <imageAddr> [x y] - display image at x,y" 191 "bmp display <imageAddr> [x y] - display image at x,y"
189 ); 192 );
190 193
191 /* 194 /*
192 * Subroutine: bmp_info 195 * Subroutine: bmp_info
193 * 196 *
194 * Description: Show information about bmp file in memory 197 * Description: Show information about bmp file in memory
195 * 198 *
196 * Inputs: addr address of the bmp file 199 * Inputs: addr address of the bmp file
197 * 200 *
198 * Return: None 201 * Return: None
199 * 202 *
200 */ 203 */
201 static int bmp_info(ulong addr) 204 static int bmp_info(ulong addr)
202 { 205 {
203 bmp_image_t *bmp=(bmp_image_t *)addr; 206 bmp_image_t *bmp=(bmp_image_t *)addr;
204 void *bmp_alloc_addr = NULL; 207 void *bmp_alloc_addr = NULL;
205 unsigned long len; 208 unsigned long len;
206 209
207 if (!((bmp->header.signature[0]=='B') && 210 if (!((bmp->header.signature[0]=='B') &&
208 (bmp->header.signature[1]=='M'))) 211 (bmp->header.signature[1]=='M')))
209 bmp = gunzip_bmp(addr, &len, &bmp_alloc_addr); 212 bmp = gunzip_bmp(addr, &len, &bmp_alloc_addr);
210 213
211 if (bmp == NULL) { 214 if (bmp == NULL) {
212 printf("There is no valid bmp file at the given address\n"); 215 printf("There is no valid bmp file at the given address\n");
213 return 1; 216 return 1;
214 } 217 }
215 218
216 printf("Image size : %d x %d\n", le32_to_cpu(bmp->header.width), 219 printf("Image size : %d x %d\n", le32_to_cpu(bmp->header.width),
217 le32_to_cpu(bmp->header.height)); 220 le32_to_cpu(bmp->header.height));
218 printf("Bits per pixel: %d\n", le16_to_cpu(bmp->header.bit_count)); 221 printf("Bits per pixel: %d\n", le16_to_cpu(bmp->header.bit_count));
219 printf("Compression : %d\n", le32_to_cpu(bmp->header.compression)); 222 printf("Compression : %d\n", le32_to_cpu(bmp->header.compression));
220 223
221 if (bmp_alloc_addr) 224 if (bmp_alloc_addr)
222 free(bmp_alloc_addr); 225 free(bmp_alloc_addr);
223 226
224 return(0); 227 return(0);
225 } 228 }
226 229
227 /* 230 /*
228 * Subroutine: bmp_display 231 * Subroutine: bmp_display
229 * 232 *
230 * Description: Display bmp file located in memory 233 * Description: Display bmp file located in memory
231 * 234 *
232 * Inputs: addr address of the bmp file 235 * Inputs: addr address of the bmp file
233 * 236 *
234 * Return: None 237 * Return: None
235 * 238 *
236 */ 239 */
237 int bmp_display(ulong addr, int x, int y) 240 int bmp_display(ulong addr, int x, int y)
238 { 241 {
239 int ret; 242 int ret;
240 bmp_image_t *bmp = (bmp_image_t *)addr; 243 bmp_image_t *bmp = (bmp_image_t *)addr;
241 void *bmp_alloc_addr = NULL; 244 void *bmp_alloc_addr = NULL;
242 unsigned long len; 245 unsigned long len;
243 246
244 if (!((bmp->header.signature[0]=='B') && 247 if (!((bmp->header.signature[0]=='B') &&
245 (bmp->header.signature[1]=='M'))) 248 (bmp->header.signature[1]=='M')))
246 bmp = gunzip_bmp(addr, &len, &bmp_alloc_addr); 249 bmp = gunzip_bmp(addr, &len, &bmp_alloc_addr);
247 250
248 if (!bmp) { 251 if (!bmp) {
249 printf("There is no valid bmp file at the given address\n"); 252 printf("There is no valid bmp file at the given address\n");
250 return 1; 253 return 1;
251 } 254 }
252 255
253 #if defined(CONFIG_LCD) 256 #if defined(CONFIG_LCD)
254 ret = lcd_display_bitmap((ulong)bmp, x, y); 257 ret = lcd_display_bitmap((ulong)bmp, x, y);
255 #elif defined(CONFIG_VIDEO) 258 #elif defined(CONFIG_VIDEO)
256 ret = video_display_bitmap((unsigned long)bmp, x, y); 259 ret = video_display_bitmap((unsigned long)bmp, x, y);
257 #else 260 #else
258 # error bmp_display() requires CONFIG_LCD or CONFIG_VIDEO 261 # error bmp_display() requires CONFIG_LCD or CONFIG_VIDEO
259 #endif 262 #endif
260 263
261 if (bmp_alloc_addr) 264 if (bmp_alloc_addr)
262 free(bmp_alloc_addr); 265 free(bmp_alloc_addr);
263 266
264 return ret; 267 return ret;
265 } 268 }
266 269
1 /* 1 /*
2 * Common LCD routines for supported CPUs 2 * Common LCD routines for supported CPUs
3 * 3 *
4 * (C) Copyright 2001-2002 4 * (C) Copyright 2001-2002
5 * Wolfgang Denk, DENX Software Engineering -- wd@denx.de 5 * Wolfgang Denk, DENX Software Engineering -- wd@denx.de
6 * 6 *
7 * See file CREDITS for list of people who contributed to this 7 * See file CREDITS for list of people who contributed to this
8 * project. 8 * project.
9 * 9 *
10 * This program is free software; you can redistribute it and/or 10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as 11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of 12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version. 13 * the License, or (at your option) any later version.
14 * 14 *
15 * This program is distributed in the hope that it will be useful, 15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 18 * GNU General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * MA 02111-1307 USA 23 * MA 02111-1307 USA
24 */ 24 */
25 25
26 /************************************************************************/ 26 /************************************************************************/
27 /* ** HEADER FILES */ 27 /* ** HEADER FILES */
28 /************************************************************************/ 28 /************************************************************************/
29 29
30 /* #define DEBUG */ 30 /* #define DEBUG */
31 31
32 #include <config.h> 32 #include <config.h>
33 #include <common.h> 33 #include <common.h>
34 #include <command.h> 34 #include <command.h>
35 #include <stdarg.h> 35 #include <stdarg.h>
36 #include <search.h> 36 #include <search.h>
37 #include <env_callback.h> 37 #include <env_callback.h>
38 #include <linux/types.h> 38 #include <linux/types.h>
39 #include <stdio_dev.h> 39 #include <stdio_dev.h>
40 #if defined(CONFIG_POST) 40 #if defined(CONFIG_POST)
41 #include <post.h> 41 #include <post.h>
42 #endif 42 #endif
43 #include <lcd.h> 43 #include <lcd.h>
44 #include <watchdog.h> 44 #include <watchdog.h>
45 45
46 #include <splash.h> 46 #include <splash.h>
47 47
48 #if defined(CONFIG_CPU_PXA25X) || defined(CONFIG_CPU_PXA27X) || \ 48 #if defined(CONFIG_CPU_PXA25X) || defined(CONFIG_CPU_PXA27X) || \
49 defined(CONFIG_CPU_MONAHANS) 49 defined(CONFIG_CPU_MONAHANS)
50 #define CONFIG_CPU_PXA 50 #define CONFIG_CPU_PXA
51 #include <asm/byteorder.h> 51 #include <asm/byteorder.h>
52 #endif 52 #endif
53 53
54 #if defined(CONFIG_MPC823) 54 #if defined(CONFIG_MPC823)
55 #include <lcdvideo.h> 55 #include <lcdvideo.h>
56 #endif 56 #endif
57 57
58 #if defined(CONFIG_ATMEL_LCD) 58 #if defined(CONFIG_ATMEL_LCD)
59 #include <atmel_lcdc.h> 59 #include <atmel_lcdc.h>
60 #endif 60 #endif
61 61
62 #if defined(CONFIG_LCD_DT_SIMPLEFB) 62 #if defined(CONFIG_LCD_DT_SIMPLEFB)
63 #include <libfdt.h> 63 #include <libfdt.h>
64 #endif 64 #endif
65 65
66 /************************************************************************/ 66 /************************************************************************/
67 /* ** FONT DATA */ 67 /* ** FONT DATA */
68 /************************************************************************/ 68 /************************************************************************/
69 #include <video_font.h> /* Get font data, width and height */ 69 #include <video_font.h> /* Get font data, width and height */
70 #include <video_font_data.h> 70 #include <video_font_data.h>
71 71
72 /************************************************************************/ 72 /************************************************************************/
73 /* ** LOGO DATA */ 73 /* ** LOGO DATA */
74 /************************************************************************/ 74 /************************************************************************/
75 #ifdef CONFIG_LCD_LOGO 75 #ifdef CONFIG_LCD_LOGO
76 # include <bmp_logo.h> /* Get logo data, width and height */ 76 # include <bmp_logo.h> /* Get logo data, width and height */
77 # include <bmp_logo_data.h> 77 # include <bmp_logo_data.h>
78 # if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET) && (LCD_BPP != LCD_COLOR16) 78 # if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET) && (LCD_BPP != LCD_COLOR16)
79 # error Default Color Map overlaps with Logo Color Map 79 # error Default Color Map overlaps with Logo Color Map
80 # endif 80 # endif
81 #endif 81 #endif
82 82
83 #ifndef CONFIG_LCD_ALIGNMENT 83 #ifndef CONFIG_LCD_ALIGNMENT
84 #define CONFIG_LCD_ALIGNMENT PAGE_SIZE 84 #define CONFIG_LCD_ALIGNMENT PAGE_SIZE
85 #endif 85 #endif
86 86
87 /* By default we scroll by a single line */ 87 /* By default we scroll by a single line */
88 #ifndef CONFIG_CONSOLE_SCROLL_LINES 88 #ifndef CONFIG_CONSOLE_SCROLL_LINES
89 #define CONFIG_CONSOLE_SCROLL_LINES 1 89 #define CONFIG_CONSOLE_SCROLL_LINES 1
90 #endif 90 #endif
91 91
92 /************************************************************************/ 92 /************************************************************************/
93 /* ** CONSOLE DEFINITIONS & FUNCTIONS */ 93 /* ** CONSOLE DEFINITIONS & FUNCTIONS */
94 /************************************************************************/ 94 /************************************************************************/
95 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO) 95 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
96 # define CONSOLE_ROWS ((panel_info.vl_row-BMP_LOGO_HEIGHT) \ 96 # define CONSOLE_ROWS ((panel_info.vl_row-BMP_LOGO_HEIGHT) \
97 / VIDEO_FONT_HEIGHT) 97 / VIDEO_FONT_HEIGHT)
98 #else 98 #else
99 # define CONSOLE_ROWS (panel_info.vl_row / VIDEO_FONT_HEIGHT) 99 # define CONSOLE_ROWS (panel_info.vl_row / VIDEO_FONT_HEIGHT)
100 #endif 100 #endif
101 101
102 #define CONSOLE_COLS (panel_info.vl_col / VIDEO_FONT_WIDTH) 102 #define CONSOLE_COLS (panel_info.vl_col / VIDEO_FONT_WIDTH)
103 #define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * lcd_line_length) 103 #define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * lcd_line_length)
104 #define CONSOLE_ROW_FIRST lcd_console_address 104 #define CONSOLE_ROW_FIRST lcd_console_address
105 #define CONSOLE_ROW_SECOND (lcd_console_address + CONSOLE_ROW_SIZE) 105 #define CONSOLE_ROW_SECOND (lcd_console_address + CONSOLE_ROW_SIZE)
106 #define CONSOLE_ROW_LAST (lcd_console_address + CONSOLE_SIZE \ 106 #define CONSOLE_ROW_LAST (lcd_console_address + CONSOLE_SIZE \
107 - CONSOLE_ROW_SIZE) 107 - CONSOLE_ROW_SIZE)
108 #define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS) 108 #define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS)
109 #define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE) 109 #define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE)
110 110
111 #if LCD_BPP == LCD_MONOCHROME 111 #if LCD_BPP == LCD_MONOCHROME
112 # define COLOR_MASK(c) ((c) | (c) << 1 | (c) << 2 | (c) << 3 | \ 112 # define COLOR_MASK(c) ((c) | (c) << 1 | (c) << 2 | (c) << 3 | \
113 (c) << 4 | (c) << 5 | (c) << 6 | (c) << 7) 113 (c) << 4 | (c) << 5 | (c) << 6 | (c) << 7)
114 #elif (LCD_BPP == LCD_COLOR8) || (LCD_BPP == LCD_COLOR16) 114 #elif (LCD_BPP == LCD_COLOR8) || (LCD_BPP == LCD_COLOR16)
115 # define COLOR_MASK(c) (c) 115 # define COLOR_MASK(c) (c)
116 #else 116 #else
117 # error Unsupported LCD BPP. 117 # error Unsupported LCD BPP.
118 #endif 118 #endif
119 119
120 DECLARE_GLOBAL_DATA_PTR; 120 DECLARE_GLOBAL_DATA_PTR;
121 121
122 static void lcd_drawchars(ushort x, ushort y, uchar *str, int count); 122 static void lcd_drawchars(ushort x, ushort y, uchar *str, int count);
123 static inline void lcd_puts_xy(ushort x, ushort y, uchar *s); 123 static inline void lcd_puts_xy(ushort x, ushort y, uchar *s);
124 static inline void lcd_putc_xy(ushort x, ushort y, uchar c); 124 static inline void lcd_putc_xy(ushort x, ushort y, uchar c);
125 125
126 static int lcd_init(void *lcdbase); 126 static int lcd_init(void *lcdbase);
127 127
128 static void *lcd_logo(void); 128 static void *lcd_logo(void);
129 129
130 static int lcd_getbgcolor(void); 130 static int lcd_getbgcolor(void);
131 static void lcd_setfgcolor(int color); 131 static void lcd_setfgcolor(int color);
132 static void lcd_setbgcolor(int color); 132 static void lcd_setbgcolor(int color);
133 133
134 static int lcd_color_fg; 134 static int lcd_color_fg;
135 static int lcd_color_bg; 135 static int lcd_color_bg;
136 int lcd_line_length; 136 int lcd_line_length;
137 137
138 char lcd_is_enabled = 0; 138 char lcd_is_enabled = 0;
139 139
140 static short console_col; 140 static short console_col;
141 static short console_row; 141 static short console_row;
142 142
143 static void *lcd_console_address; 143 static void *lcd_console_address;
144 static void *lcd_base; /* Start of framebuffer memory */ 144 static void *lcd_base; /* Start of framebuffer memory */
145 145
146 static char lcd_flush_dcache; /* 1 to flush dcache after each lcd update */ 146 static char lcd_flush_dcache; /* 1 to flush dcache after each lcd update */
147 147
148 /************************************************************************/ 148 /************************************************************************/
149 149
150 /* Flush LCD activity to the caches */ 150 /* Flush LCD activity to the caches */
151 void lcd_sync(void) 151 void lcd_sync(void)
152 { 152 {
153 /* 153 /*
154 * flush_dcache_range() is declared in common.h but it seems that some 154 * flush_dcache_range() is declared in common.h but it seems that some
155 * architectures do not actually implement it. Is there a way to find 155 * architectures do not actually implement it. Is there a way to find
156 * out whether it exists? For now, ARM is safe. 156 * out whether it exists? For now, ARM is safe.
157 */ 157 */
158 #if defined(CONFIG_ARM) && !defined(CONFIG_SYS_DCACHE_OFF) 158 #if defined(CONFIG_ARM) && !defined(CONFIG_SYS_DCACHE_OFF)
159 int line_length; 159 int line_length;
160 160
161 if (lcd_flush_dcache) 161 if (lcd_flush_dcache)
162 flush_dcache_range((u32)lcd_base, 162 flush_dcache_range((u32)lcd_base,
163 (u32)(lcd_base + lcd_get_size(&line_length))); 163 (u32)(lcd_base + lcd_get_size(&line_length)));
164 #endif 164 #endif
165 } 165 }
166 166
167 void lcd_set_flush_dcache(int flush) 167 void lcd_set_flush_dcache(int flush)
168 { 168 {
169 lcd_flush_dcache = (flush != 0); 169 lcd_flush_dcache = (flush != 0);
170 } 170 }
171 171
172 /*----------------------------------------------------------------------*/ 172 /*----------------------------------------------------------------------*/
173 173
174 static void console_scrollup(void) 174 static void console_scrollup(void)
175 { 175 {
176 const int rows = CONFIG_CONSOLE_SCROLL_LINES; 176 const int rows = CONFIG_CONSOLE_SCROLL_LINES;
177 177
178 /* Copy up rows ignoring those that will be overwritten */ 178 /* Copy up rows ignoring those that will be overwritten */
179 memcpy(CONSOLE_ROW_FIRST, 179 memcpy(CONSOLE_ROW_FIRST,
180 lcd_console_address + CONSOLE_ROW_SIZE * rows, 180 lcd_console_address + CONSOLE_ROW_SIZE * rows,
181 CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows); 181 CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows);
182 182
183 /* Clear the last rows */ 183 /* Clear the last rows */
184 memset(lcd_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows, 184 memset(lcd_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows,
185 COLOR_MASK(lcd_color_bg), 185 COLOR_MASK(lcd_color_bg),
186 CONSOLE_ROW_SIZE * rows); 186 CONSOLE_ROW_SIZE * rows);
187 187
188 lcd_sync(); 188 lcd_sync();
189 console_row -= rows; 189 console_row -= rows;
190 } 190 }
191 191
192 /*----------------------------------------------------------------------*/ 192 /*----------------------------------------------------------------------*/
193 193
194 static inline void console_back(void) 194 static inline void console_back(void)
195 { 195 {
196 if (--console_col < 0) { 196 if (--console_col < 0) {
197 console_col = CONSOLE_COLS-1 ; 197 console_col = CONSOLE_COLS-1 ;
198 if (--console_row < 0) 198 if (--console_row < 0)
199 console_row = 0; 199 console_row = 0;
200 } 200 }
201 201
202 lcd_putc_xy(console_col * VIDEO_FONT_WIDTH, 202 lcd_putc_xy(console_col * VIDEO_FONT_WIDTH,
203 console_row * VIDEO_FONT_HEIGHT, ' '); 203 console_row * VIDEO_FONT_HEIGHT, ' ');
204 } 204 }
205 205
206 /*----------------------------------------------------------------------*/ 206 /*----------------------------------------------------------------------*/
207 207
208 static inline void console_newline(void) 208 static inline void console_newline(void)
209 { 209 {
210 console_col = 0; 210 console_col = 0;
211 211
212 /* Check if we need to scroll the terminal */ 212 /* Check if we need to scroll the terminal */
213 if (++console_row >= CONSOLE_ROWS) 213 if (++console_row >= CONSOLE_ROWS)
214 console_scrollup(); 214 console_scrollup();
215 else 215 else
216 lcd_sync(); 216 lcd_sync();
217 } 217 }
218 218
219 /*----------------------------------------------------------------------*/ 219 /*----------------------------------------------------------------------*/
220 220
221 void lcd_putc(const char c) 221 void lcd_putc(const char c)
222 { 222 {
223 if (!lcd_is_enabled) { 223 if (!lcd_is_enabled) {
224 serial_putc(c); 224 serial_putc(c);
225 225
226 return; 226 return;
227 } 227 }
228 228
229 switch (c) { 229 switch (c) {
230 case '\r': 230 case '\r':
231 console_col = 0; 231 console_col = 0;
232 232
233 return; 233 return;
234 case '\n': 234 case '\n':
235 console_newline(); 235 console_newline();
236 236
237 return; 237 return;
238 case '\t': /* Tab (8 chars alignment) */ 238 case '\t': /* Tab (8 chars alignment) */
239 console_col += 8; 239 console_col += 8;
240 console_col &= ~7; 240 console_col &= ~7;
241 241
242 if (console_col >= CONSOLE_COLS) 242 if (console_col >= CONSOLE_COLS)
243 console_newline(); 243 console_newline();
244 244
245 return; 245 return;
246 case '\b': 246 case '\b':
247 console_back(); 247 console_back();
248 248
249 return; 249 return;
250 default: 250 default:
251 lcd_putc_xy(console_col * VIDEO_FONT_WIDTH, 251 lcd_putc_xy(console_col * VIDEO_FONT_WIDTH,
252 console_row * VIDEO_FONT_HEIGHT, c); 252 console_row * VIDEO_FONT_HEIGHT, c);
253 if (++console_col >= CONSOLE_COLS) 253 if (++console_col >= CONSOLE_COLS)
254 console_newline(); 254 console_newline();
255 } 255 }
256 } 256 }
257 257
258 /*----------------------------------------------------------------------*/ 258 /*----------------------------------------------------------------------*/
259 259
260 void lcd_puts(const char *s) 260 void lcd_puts(const char *s)
261 { 261 {
262 if (!lcd_is_enabled) { 262 if (!lcd_is_enabled) {
263 serial_puts(s); 263 serial_puts(s);
264 264
265 return; 265 return;
266 } 266 }
267 267
268 while (*s) 268 while (*s)
269 lcd_putc(*s++); 269 lcd_putc(*s++);
270 270
271 lcd_sync(); 271 lcd_sync();
272 } 272 }
273 273
274 /*----------------------------------------------------------------------*/ 274 /*----------------------------------------------------------------------*/
275 275
276 void lcd_printf(const char *fmt, ...) 276 void lcd_printf(const char *fmt, ...)
277 { 277 {
278 va_list args; 278 va_list args;
279 char buf[CONFIG_SYS_PBSIZE]; 279 char buf[CONFIG_SYS_PBSIZE];
280 280
281 va_start(args, fmt); 281 va_start(args, fmt);
282 vsprintf(buf, fmt, args); 282 vsprintf(buf, fmt, args);
283 va_end(args); 283 va_end(args);
284 284
285 lcd_puts(buf); 285 lcd_puts(buf);
286 } 286 }
287 287
288 /************************************************************************/ 288 /************************************************************************/
289 /* ** Low-Level Graphics Routines */ 289 /* ** Low-Level Graphics Routines */
290 /************************************************************************/ 290 /************************************************************************/
291 291
292 static void lcd_drawchars(ushort x, ushort y, uchar *str, int count) 292 static void lcd_drawchars(ushort x, ushort y, uchar *str, int count)
293 { 293 {
294 uchar *dest; 294 uchar *dest;
295 ushort row; 295 ushort row;
296 296
297 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO) 297 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
298 y += BMP_LOGO_HEIGHT; 298 y += BMP_LOGO_HEIGHT;
299 #endif 299 #endif
300 300
301 #if LCD_BPP == LCD_MONOCHROME 301 #if LCD_BPP == LCD_MONOCHROME
302 ushort off = x * (1 << LCD_BPP) % 8; 302 ushort off = x * (1 << LCD_BPP) % 8;
303 #endif 303 #endif
304 304
305 dest = (uchar *)(lcd_base + y * lcd_line_length + x * (1 << LCD_BPP) / 8); 305 dest = (uchar *)(lcd_base + y * lcd_line_length + x * (1 << LCD_BPP) / 8);
306 306
307 for (row = 0; row < VIDEO_FONT_HEIGHT; ++row, dest += lcd_line_length) { 307 for (row = 0; row < VIDEO_FONT_HEIGHT; ++row, dest += lcd_line_length) {
308 uchar *s = str; 308 uchar *s = str;
309 int i; 309 int i;
310 #if LCD_BPP == LCD_COLOR16 310 #if LCD_BPP == LCD_COLOR16
311 ushort *d = (ushort *)dest; 311 ushort *d = (ushort *)dest;
312 #else 312 #else
313 uchar *d = dest; 313 uchar *d = dest;
314 #endif 314 #endif
315 315
316 #if LCD_BPP == LCD_MONOCHROME 316 #if LCD_BPP == LCD_MONOCHROME
317 uchar rest = *d & -(1 << (8 - off)); 317 uchar rest = *d & -(1 << (8 - off));
318 uchar sym; 318 uchar sym;
319 #endif 319 #endif
320 for (i = 0; i < count; ++i) { 320 for (i = 0; i < count; ++i) {
321 uchar c, bits; 321 uchar c, bits;
322 322
323 c = *s++; 323 c = *s++;
324 bits = video_fontdata[c * VIDEO_FONT_HEIGHT + row]; 324 bits = video_fontdata[c * VIDEO_FONT_HEIGHT + row];
325 325
326 #if LCD_BPP == LCD_MONOCHROME 326 #if LCD_BPP == LCD_MONOCHROME
327 sym = (COLOR_MASK(lcd_color_fg) & bits) | 327 sym = (COLOR_MASK(lcd_color_fg) & bits) |
328 (COLOR_MASK(lcd_color_bg) & ~bits); 328 (COLOR_MASK(lcd_color_bg) & ~bits);
329 329
330 *d++ = rest | (sym >> off); 330 *d++ = rest | (sym >> off);
331 rest = sym << (8-off); 331 rest = sym << (8-off);
332 #elif LCD_BPP == LCD_COLOR8 332 #elif LCD_BPP == LCD_COLOR8
333 for (c = 0; c < 8; ++c) { 333 for (c = 0; c < 8; ++c) {
334 *d++ = (bits & 0x80) ? 334 *d++ = (bits & 0x80) ?
335 lcd_color_fg : lcd_color_bg; 335 lcd_color_fg : lcd_color_bg;
336 bits <<= 1; 336 bits <<= 1;
337 } 337 }
338 #elif LCD_BPP == LCD_COLOR16 338 #elif LCD_BPP == LCD_COLOR16
339 for (c = 0; c < 8; ++c) { 339 for (c = 0; c < 8; ++c) {
340 *d++ = (bits & 0x80) ? 340 *d++ = (bits & 0x80) ?
341 lcd_color_fg : lcd_color_bg; 341 lcd_color_fg : lcd_color_bg;
342 bits <<= 1; 342 bits <<= 1;
343 } 343 }
344 #endif 344 #endif
345 } 345 }
346 #if LCD_BPP == LCD_MONOCHROME 346 #if LCD_BPP == LCD_MONOCHROME
347 *d = rest | (*d & ((1 << (8 - off)) - 1)); 347 *d = rest | (*d & ((1 << (8 - off)) - 1));
348 #endif 348 #endif
349 } 349 }
350 } 350 }
351 351
352 /*----------------------------------------------------------------------*/ 352 /*----------------------------------------------------------------------*/
353 353
354 static inline void lcd_puts_xy(ushort x, ushort y, uchar *s) 354 static inline void lcd_puts_xy(ushort x, ushort y, uchar *s)
355 { 355 {
356 lcd_drawchars(x, y, s, strlen((char *)s)); 356 lcd_drawchars(x, y, s, strlen((char *)s));
357 } 357 }
358 358
359 /*----------------------------------------------------------------------*/ 359 /*----------------------------------------------------------------------*/
360 360
361 static inline void lcd_putc_xy(ushort x, ushort y, uchar c) 361 static inline void lcd_putc_xy(ushort x, ushort y, uchar c)
362 { 362 {
363 lcd_drawchars(x, y, &c, 1); 363 lcd_drawchars(x, y, &c, 1);
364 } 364 }
365 365
366 /************************************************************************/ 366 /************************************************************************/
367 /** Small utility to check that you got the colours right */ 367 /** Small utility to check that you got the colours right */
368 /************************************************************************/ 368 /************************************************************************/
369 #ifdef LCD_TEST_PATTERN 369 #ifdef LCD_TEST_PATTERN
370 370
371 #define N_BLK_VERT 2 371 #define N_BLK_VERT 2
372 #define N_BLK_HOR 3 372 #define N_BLK_HOR 3
373 373
374 static int test_colors[N_BLK_HOR * N_BLK_VERT] = { 374 static int test_colors[N_BLK_HOR * N_BLK_VERT] = {
375 CONSOLE_COLOR_RED, CONSOLE_COLOR_GREEN, CONSOLE_COLOR_YELLOW, 375 CONSOLE_COLOR_RED, CONSOLE_COLOR_GREEN, CONSOLE_COLOR_YELLOW,
376 CONSOLE_COLOR_BLUE, CONSOLE_COLOR_MAGENTA, CONSOLE_COLOR_CYAN, 376 CONSOLE_COLOR_BLUE, CONSOLE_COLOR_MAGENTA, CONSOLE_COLOR_CYAN,
377 }; 377 };
378 378
379 static void test_pattern(void) 379 static void test_pattern(void)
380 { 380 {
381 ushort v_max = panel_info.vl_row; 381 ushort v_max = panel_info.vl_row;
382 ushort h_max = panel_info.vl_col; 382 ushort h_max = panel_info.vl_col;
383 ushort v_step = (v_max + N_BLK_VERT - 1) / N_BLK_VERT; 383 ushort v_step = (v_max + N_BLK_VERT - 1) / N_BLK_VERT;
384 ushort h_step = (h_max + N_BLK_HOR - 1) / N_BLK_HOR; 384 ushort h_step = (h_max + N_BLK_HOR - 1) / N_BLK_HOR;
385 ushort v, h; 385 ushort v, h;
386 uchar *pix = (uchar *)lcd_base; 386 uchar *pix = (uchar *)lcd_base;
387 387
388 printf("[LCD] Test Pattern: %d x %d [%d x %d]\n", 388 printf("[LCD] Test Pattern: %d x %d [%d x %d]\n",
389 h_max, v_max, h_step, v_step); 389 h_max, v_max, h_step, v_step);
390 390
391 /* WARNING: Code silently assumes 8bit/pixel */ 391 /* WARNING: Code silently assumes 8bit/pixel */
392 for (v = 0; v < v_max; ++v) { 392 for (v = 0; v < v_max; ++v) {
393 uchar iy = v / v_step; 393 uchar iy = v / v_step;
394 for (h = 0; h < h_max; ++h) { 394 for (h = 0; h < h_max; ++h) {
395 uchar ix = N_BLK_HOR * iy + h / h_step; 395 uchar ix = N_BLK_HOR * iy + h / h_step;
396 *pix++ = test_colors[ix]; 396 *pix++ = test_colors[ix];
397 } 397 }
398 } 398 }
399 } 399 }
400 #endif /* LCD_TEST_PATTERN */ 400 #endif /* LCD_TEST_PATTERN */
401 401
402 402
403 /************************************************************************/ 403 /************************************************************************/
404 /* ** GENERIC Initialization Routines */ 404 /* ** GENERIC Initialization Routines */
405 /************************************************************************/ 405 /************************************************************************/
406 406
407 int lcd_get_size(int *line_length) 407 int lcd_get_size(int *line_length)
408 { 408 {
409 *line_length = (panel_info.vl_col * NBITS(panel_info.vl_bpix)) / 8; 409 *line_length = (panel_info.vl_col * NBITS(panel_info.vl_bpix)) / 8;
410 return *line_length * panel_info.vl_row; 410 return *line_length * panel_info.vl_row;
411 } 411 }
412 412
413 int drv_lcd_init(void) 413 int drv_lcd_init(void)
414 { 414 {
415 struct stdio_dev lcddev; 415 struct stdio_dev lcddev;
416 int rc; 416 int rc;
417 417
418 lcd_base = (void *) gd->fb_base; 418 lcd_base = (void *) gd->fb_base;
419 419
420 lcd_init(lcd_base); /* LCD initialization */ 420 lcd_init(lcd_base); /* LCD initialization */
421 421
422 /* Device initialization */ 422 /* Device initialization */
423 memset(&lcddev, 0, sizeof(lcddev)); 423 memset(&lcddev, 0, sizeof(lcddev));
424 424
425 strcpy(lcddev.name, "lcd"); 425 strcpy(lcddev.name, "lcd");
426 lcddev.ext = 0; /* No extensions */ 426 lcddev.ext = 0; /* No extensions */
427 lcddev.flags = DEV_FLAGS_OUTPUT; /* Output only */ 427 lcddev.flags = DEV_FLAGS_OUTPUT; /* Output only */
428 lcddev.putc = lcd_putc; /* 'putc' function */ 428 lcddev.putc = lcd_putc; /* 'putc' function */
429 lcddev.puts = lcd_puts; /* 'puts' function */ 429 lcddev.puts = lcd_puts; /* 'puts' function */
430 430
431 rc = stdio_register(&lcddev); 431 rc = stdio_register(&lcddev);
432 432
433 return (rc == 0) ? 1 : rc; 433 return (rc == 0) ? 1 : rc;
434 } 434 }
435 435
436 /*----------------------------------------------------------------------*/ 436 /*----------------------------------------------------------------------*/
437 void lcd_clear(void) 437 void lcd_clear(void)
438 { 438 {
439 #if LCD_BPP == LCD_MONOCHROME 439 #if LCD_BPP == LCD_MONOCHROME
440 /* Setting the palette */ 440 /* Setting the palette */
441 lcd_initcolregs(); 441 lcd_initcolregs();
442 442
443 #elif LCD_BPP == LCD_COLOR8 443 #elif LCD_BPP == LCD_COLOR8
444 /* Setting the palette */ 444 /* Setting the palette */
445 lcd_setcolreg(CONSOLE_COLOR_BLACK, 0, 0, 0); 445 lcd_setcolreg(CONSOLE_COLOR_BLACK, 0, 0, 0);
446 lcd_setcolreg(CONSOLE_COLOR_RED, 0xFF, 0, 0); 446 lcd_setcolreg(CONSOLE_COLOR_RED, 0xFF, 0, 0);
447 lcd_setcolreg(CONSOLE_COLOR_GREEN, 0, 0xFF, 0); 447 lcd_setcolreg(CONSOLE_COLOR_GREEN, 0, 0xFF, 0);
448 lcd_setcolreg(CONSOLE_COLOR_YELLOW, 0xFF, 0xFF, 0); 448 lcd_setcolreg(CONSOLE_COLOR_YELLOW, 0xFF, 0xFF, 0);
449 lcd_setcolreg(CONSOLE_COLOR_BLUE, 0, 0, 0xFF); 449 lcd_setcolreg(CONSOLE_COLOR_BLUE, 0, 0, 0xFF);
450 lcd_setcolreg(CONSOLE_COLOR_MAGENTA, 0xFF, 0, 0xFF); 450 lcd_setcolreg(CONSOLE_COLOR_MAGENTA, 0xFF, 0, 0xFF);
451 lcd_setcolreg(CONSOLE_COLOR_CYAN, 0, 0xFF, 0xFF); 451 lcd_setcolreg(CONSOLE_COLOR_CYAN, 0, 0xFF, 0xFF);
452 lcd_setcolreg(CONSOLE_COLOR_GREY, 0xAA, 0xAA, 0xAA); 452 lcd_setcolreg(CONSOLE_COLOR_GREY, 0xAA, 0xAA, 0xAA);
453 lcd_setcolreg(CONSOLE_COLOR_WHITE, 0xFF, 0xFF, 0xFF); 453 lcd_setcolreg(CONSOLE_COLOR_WHITE, 0xFF, 0xFF, 0xFF);
454 #endif 454 #endif
455 455
456 #ifndef CONFIG_SYS_WHITE_ON_BLACK 456 #ifndef CONFIG_SYS_WHITE_ON_BLACK
457 lcd_setfgcolor(CONSOLE_COLOR_BLACK); 457 lcd_setfgcolor(CONSOLE_COLOR_BLACK);
458 lcd_setbgcolor(CONSOLE_COLOR_WHITE); 458 lcd_setbgcolor(CONSOLE_COLOR_WHITE);
459 #else 459 #else
460 lcd_setfgcolor(CONSOLE_COLOR_WHITE); 460 lcd_setfgcolor(CONSOLE_COLOR_WHITE);
461 lcd_setbgcolor(CONSOLE_COLOR_BLACK); 461 lcd_setbgcolor(CONSOLE_COLOR_BLACK);
462 #endif /* CONFIG_SYS_WHITE_ON_BLACK */ 462 #endif /* CONFIG_SYS_WHITE_ON_BLACK */
463 463
464 #ifdef LCD_TEST_PATTERN 464 #ifdef LCD_TEST_PATTERN
465 test_pattern(); 465 test_pattern();
466 #else 466 #else
467 /* set framebuffer to background color */ 467 /* set framebuffer to background color */
468 memset((char *)lcd_base, 468 memset((char *)lcd_base,
469 COLOR_MASK(lcd_getbgcolor()), 469 COLOR_MASK(lcd_getbgcolor()),
470 lcd_line_length * panel_info.vl_row); 470 lcd_line_length * panel_info.vl_row);
471 #endif 471 #endif
472 /* Paint the logo and retrieve LCD base address */ 472 /* Paint the logo and retrieve LCD base address */
473 debug("[LCD] Drawing the logo...\n"); 473 debug("[LCD] Drawing the logo...\n");
474 lcd_console_address = lcd_logo(); 474 lcd_console_address = lcd_logo();
475 475
476 console_col = 0; 476 console_col = 0;
477 console_row = 0; 477 console_row = 0;
478 lcd_sync(); 478 lcd_sync();
479 } 479 }
480 480
481 static int do_lcd_clear(cmd_tbl_t *cmdtp, int flag, int argc, 481 static int do_lcd_clear(cmd_tbl_t *cmdtp, int flag, int argc,
482 char *const argv[]) 482 char *const argv[])
483 { 483 {
484 lcd_clear(); 484 lcd_clear();
485 return 0; 485 return 0;
486 } 486 }
487 487
488 U_BOOT_CMD( 488 U_BOOT_CMD(
489 cls, 1, 1, do_lcd_clear, 489 cls, 1, 1, do_lcd_clear,
490 "clear screen", 490 "clear screen",
491 "" 491 ""
492 ); 492 );
493 493
494 /*----------------------------------------------------------------------*/ 494 /*----------------------------------------------------------------------*/
495 495
496 static int lcd_init(void *lcdbase) 496 static int lcd_init(void *lcdbase)
497 { 497 {
498 /* Initialize the lcd controller */ 498 /* Initialize the lcd controller */
499 debug("[LCD] Initializing LCD frambuffer at %p\n", lcdbase); 499 debug("[LCD] Initializing LCD frambuffer at %p\n", lcdbase);
500 500
501 lcd_ctrl_init(lcdbase); 501 lcd_ctrl_init(lcdbase);
502 502
503 /* 503 /*
504 * lcd_ctrl_init() of some drivers (i.e. bcm2835 on rpi_b) ignores 504 * lcd_ctrl_init() of some drivers (i.e. bcm2835 on rpi_b) ignores
505 * the 'lcdbase' argument and uses custom lcd base address 505 * the 'lcdbase' argument and uses custom lcd base address
506 * by setting up gd->fb_base. Check for this condition and fixup 506 * by setting up gd->fb_base. Check for this condition and fixup
507 * 'lcd_base' address. 507 * 'lcd_base' address.
508 */ 508 */
509 if ((unsigned long)lcdbase != gd->fb_base) 509 if ((unsigned long)lcdbase != gd->fb_base)
510 lcd_base = (void *)gd->fb_base; 510 lcd_base = (void *)gd->fb_base;
511 511
512 debug("[LCD] Using LCD frambuffer at %p\n", lcd_base); 512 debug("[LCD] Using LCD frambuffer at %p\n", lcd_base);
513 513
514 lcd_get_size(&lcd_line_length); 514 lcd_get_size(&lcd_line_length);
515 lcd_line_length = (panel_info.vl_col * NBITS(panel_info.vl_bpix)) / 8; 515 lcd_line_length = (panel_info.vl_col * NBITS(panel_info.vl_bpix)) / 8;
516 lcd_is_enabled = 1; 516 lcd_is_enabled = 1;
517 lcd_clear(); 517 lcd_clear();
518 lcd_enable(); 518 lcd_enable();
519 519
520 /* Initialize the console */ 520 /* Initialize the console */
521 console_col = 0; 521 console_col = 0;
522 #ifdef CONFIG_LCD_INFO_BELOW_LOGO 522 #ifdef CONFIG_LCD_INFO_BELOW_LOGO
523 console_row = 7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT; 523 console_row = 7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT;
524 #else 524 #else
525 console_row = 1; /* leave 1 blank line below logo */ 525 console_row = 1; /* leave 1 blank line below logo */
526 #endif 526 #endif
527 527
528 return 0; 528 return 0;
529 } 529 }
530 530
531 531
532 /************************************************************************/ 532 /************************************************************************/
533 /* ** ROM capable initialization part - needed to reserve FB memory */ 533 /* ** ROM capable initialization part - needed to reserve FB memory */
534 /************************************************************************/ 534 /************************************************************************/
535 /* 535 /*
536 * This is called early in the system initialization to grab memory 536 * This is called early in the system initialization to grab memory
537 * for the LCD controller. 537 * for the LCD controller.
538 * Returns new address for monitor, after reserving LCD buffer memory 538 * Returns new address for monitor, after reserving LCD buffer memory
539 * 539 *
540 * Note that this is running from ROM, so no write access to global data. 540 * Note that this is running from ROM, so no write access to global data.
541 */ 541 */
542 ulong lcd_setmem(ulong addr) 542 ulong lcd_setmem(ulong addr)
543 { 543 {
544 ulong size; 544 ulong size;
545 int line_length; 545 int line_length;
546 546
547 debug("LCD panel info: %d x %d, %d bit/pix\n", panel_info.vl_col, 547 debug("LCD panel info: %d x %d, %d bit/pix\n", panel_info.vl_col,
548 panel_info.vl_row, NBITS(panel_info.vl_bpix)); 548 panel_info.vl_row, NBITS(panel_info.vl_bpix));
549 549
550 size = lcd_get_size(&line_length); 550 size = lcd_get_size(&line_length);
551 551
552 /* Round up to nearest full page, or MMU section if defined */ 552 /* Round up to nearest full page, or MMU section if defined */
553 size = ALIGN(size, CONFIG_LCD_ALIGNMENT); 553 size = ALIGN(size, CONFIG_LCD_ALIGNMENT);
554 addr = ALIGN(addr - CONFIG_LCD_ALIGNMENT + 1, CONFIG_LCD_ALIGNMENT); 554 addr = ALIGN(addr - CONFIG_LCD_ALIGNMENT + 1, CONFIG_LCD_ALIGNMENT);
555 555
556 /* Allocate pages for the frame buffer. */ 556 /* Allocate pages for the frame buffer. */
557 addr -= size; 557 addr -= size;
558 558
559 debug("Reserving %ldk for LCD Framebuffer at: %08lx\n", 559 debug("Reserving %ldk for LCD Framebuffer at: %08lx\n",
560 size >> 10, addr); 560 size >> 10, addr);
561 561
562 return addr; 562 return addr;
563 } 563 }
564 564
565 /*----------------------------------------------------------------------*/ 565 /*----------------------------------------------------------------------*/
566 566
567 static void lcd_setfgcolor(int color) 567 static void lcd_setfgcolor(int color)
568 { 568 {
569 lcd_color_fg = color; 569 lcd_color_fg = color;
570 } 570 }
571 571
572 /*----------------------------------------------------------------------*/ 572 /*----------------------------------------------------------------------*/
573 573
574 static void lcd_setbgcolor(int color) 574 static void lcd_setbgcolor(int color)
575 { 575 {
576 lcd_color_bg = color; 576 lcd_color_bg = color;
577 } 577 }
578 578
579 /*----------------------------------------------------------------------*/ 579 /*----------------------------------------------------------------------*/
580 580
581 int lcd_getfgcolor(void) 581 int lcd_getfgcolor(void)
582 { 582 {
583 return lcd_color_fg; 583 return lcd_color_fg;
584 } 584 }
585 585
586 /*----------------------------------------------------------------------*/ 586 /*----------------------------------------------------------------------*/
587 587
588 static int lcd_getbgcolor(void) 588 static int lcd_getbgcolor(void)
589 { 589 {
590 return lcd_color_bg; 590 return lcd_color_bg;
591 } 591 }
592 592
593 /************************************************************************/ 593 /************************************************************************/
594 /* ** Chipset depending Bitmap / Logo stuff... */ 594 /* ** Chipset depending Bitmap / Logo stuff... */
595 /************************************************************************/ 595 /************************************************************************/
596 static inline ushort *configuration_get_cmap(void) 596 static inline ushort *configuration_get_cmap(void)
597 { 597 {
598 #if defined CONFIG_CPU_PXA 598 #if defined CONFIG_CPU_PXA
599 struct pxafb_info *fbi = &panel_info.pxa; 599 struct pxafb_info *fbi = &panel_info.pxa;
600 return (ushort *)fbi->palette; 600 return (ushort *)fbi->palette;
601 #elif defined(CONFIG_MPC823) 601 #elif defined(CONFIG_MPC823)
602 immap_t *immr = (immap_t *) CONFIG_SYS_IMMR; 602 immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
603 cpm8xx_t *cp = &(immr->im_cpm); 603 cpm8xx_t *cp = &(immr->im_cpm);
604 return (ushort *)&(cp->lcd_cmap[255 * sizeof(ushort)]); 604 return (ushort *)&(cp->lcd_cmap[255 * sizeof(ushort)]);
605 #elif defined(CONFIG_ATMEL_LCD) 605 #elif defined(CONFIG_ATMEL_LCD)
606 return (ushort *)(panel_info.mmio + ATMEL_LCDC_LUT(0)); 606 return (ushort *)(panel_info.mmio + ATMEL_LCDC_LUT(0));
607 #elif !defined(CONFIG_ATMEL_HLCD) && !defined(CONFIG_EXYNOS_FB) 607 #elif !defined(CONFIG_ATMEL_HLCD) && !defined(CONFIG_EXYNOS_FB)
608 return panel_info.cmap; 608 return panel_info.cmap;
609 #elif defined(CONFIG_LCD_LOGO) 609 #elif defined(CONFIG_LCD_LOGO)
610 return bmp_logo_palette; 610 return bmp_logo_palette;
611 #else 611 #else
612 return NULL; 612 return NULL;
613 #endif 613 #endif
614 } 614 }
615 615
616 #ifdef CONFIG_LCD_LOGO 616 #ifdef CONFIG_LCD_LOGO
617 void bitmap_plot(int x, int y) 617 void bitmap_plot(int x, int y)
618 { 618 {
619 #ifdef CONFIG_ATMEL_LCD 619 #ifdef CONFIG_ATMEL_LCD
620 uint *cmap = (uint *)bmp_logo_palette; 620 uint *cmap = (uint *)bmp_logo_palette;
621 #else 621 #else
622 ushort *cmap = (ushort *)bmp_logo_palette; 622 ushort *cmap = (ushort *)bmp_logo_palette;
623 #endif 623 #endif
624 ushort i, j; 624 ushort i, j;
625 uchar *bmap; 625 uchar *bmap;
626 uchar *fb; 626 uchar *fb;
627 ushort *fb16; 627 ushort *fb16;
628 #if defined(CONFIG_MPC823) 628 #if defined(CONFIG_MPC823)
629 immap_t *immr = (immap_t *) CONFIG_SYS_IMMR; 629 immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
630 cpm8xx_t *cp = &(immr->im_cpm); 630 cpm8xx_t *cp = &(immr->im_cpm);
631 #endif 631 #endif
632 unsigned bpix = NBITS(panel_info.vl_bpix); 632 unsigned bpix = NBITS(panel_info.vl_bpix);
633 633
634 debug("Logo: width %d height %d colors %d cmap %d\n", 634 debug("Logo: width %d height %d colors %d cmap %d\n",
635 BMP_LOGO_WIDTH, BMP_LOGO_HEIGHT, BMP_LOGO_COLORS, 635 BMP_LOGO_WIDTH, BMP_LOGO_HEIGHT, BMP_LOGO_COLORS,
636 ARRAY_SIZE(bmp_logo_palette)); 636 ARRAY_SIZE(bmp_logo_palette));
637 637
638 bmap = &bmp_logo_bitmap[0]; 638 bmap = &bmp_logo_bitmap[0];
639 fb = (uchar *)(lcd_base + y * lcd_line_length + x * bpix / 8); 639 fb = (uchar *)(lcd_base + y * lcd_line_length + x * bpix / 8);
640 640
641 if (bpix < 12) { 641 if (bpix < 12) {
642 /* Leave room for default color map 642 /* Leave room for default color map
643 * default case: generic system with no cmap (most likely 16bpp) 643 * default case: generic system with no cmap (most likely 16bpp)
644 * cmap was set to the source palette, so no change is done. 644 * cmap was set to the source palette, so no change is done.
645 * This avoids even more ifdefs in the next stanza 645 * This avoids even more ifdefs in the next stanza
646 */ 646 */
647 #if defined(CONFIG_MPC823) 647 #if defined(CONFIG_MPC823)
648 cmap = (ushort *) &(cp->lcd_cmap[BMP_LOGO_OFFSET * sizeof(ushort)]); 648 cmap = (ushort *) &(cp->lcd_cmap[BMP_LOGO_OFFSET * sizeof(ushort)]);
649 #elif defined(CONFIG_ATMEL_LCD) 649 #elif defined(CONFIG_ATMEL_LCD)
650 cmap = (uint *)configuration_get_cmap(); 650 cmap = (uint *)configuration_get_cmap();
651 #else 651 #else
652 cmap = configuration_get_cmap(); 652 cmap = configuration_get_cmap();
653 #endif 653 #endif
654 654
655 WATCHDOG_RESET(); 655 WATCHDOG_RESET();
656 656
657 /* Set color map */ 657 /* Set color map */
658 for (i = 0; i < ARRAY_SIZE(bmp_logo_palette); ++i) { 658 for (i = 0; i < ARRAY_SIZE(bmp_logo_palette); ++i) {
659 ushort colreg = bmp_logo_palette[i]; 659 ushort colreg = bmp_logo_palette[i];
660 #ifdef CONFIG_ATMEL_LCD 660 #ifdef CONFIG_ATMEL_LCD
661 uint lut_entry; 661 uint lut_entry;
662 #ifdef CONFIG_ATMEL_LCD_BGR555 662 #ifdef CONFIG_ATMEL_LCD_BGR555
663 lut_entry = ((colreg & 0x000F) << 11) | 663 lut_entry = ((colreg & 0x000F) << 11) |
664 ((colreg & 0x00F0) << 2) | 664 ((colreg & 0x00F0) << 2) |
665 ((colreg & 0x0F00) >> 7); 665 ((colreg & 0x0F00) >> 7);
666 #else /* CONFIG_ATMEL_LCD_RGB565 */ 666 #else /* CONFIG_ATMEL_LCD_RGB565 */
667 lut_entry = ((colreg & 0x000F) << 1) | 667 lut_entry = ((colreg & 0x000F) << 1) |
668 ((colreg & 0x00F0) << 3) | 668 ((colreg & 0x00F0) << 3) |
669 ((colreg & 0x0F00) << 4); 669 ((colreg & 0x0F00) << 4);
670 #endif 670 #endif
671 *(cmap + BMP_LOGO_OFFSET) = lut_entry; 671 *(cmap + BMP_LOGO_OFFSET) = lut_entry;
672 cmap++; 672 cmap++;
673 #else /* !CONFIG_ATMEL_LCD */ 673 #else /* !CONFIG_ATMEL_LCD */
674 #ifdef CONFIG_SYS_INVERT_COLORS 674 #ifdef CONFIG_SYS_INVERT_COLORS
675 *cmap++ = 0xffff - colreg; 675 *cmap++ = 0xffff - colreg;
676 #else 676 #else
677 *cmap++ = colreg; 677 *cmap++ = colreg;
678 #endif 678 #endif
679 #endif /* CONFIG_ATMEL_LCD */ 679 #endif /* CONFIG_ATMEL_LCD */
680 } 680 }
681 681
682 WATCHDOG_RESET(); 682 WATCHDOG_RESET();
683 683
684 for (i = 0; i < BMP_LOGO_HEIGHT; ++i) { 684 for (i = 0; i < BMP_LOGO_HEIGHT; ++i) {
685 memcpy(fb, bmap, BMP_LOGO_WIDTH); 685 memcpy(fb, bmap, BMP_LOGO_WIDTH);
686 bmap += BMP_LOGO_WIDTH; 686 bmap += BMP_LOGO_WIDTH;
687 fb += panel_info.vl_col; 687 fb += panel_info.vl_col;
688 } 688 }
689 } 689 }
690 else { /* true color mode */ 690 else { /* true color mode */
691 u16 col16; 691 u16 col16;
692 fb16 = (ushort *)fb; 692 fb16 = (ushort *)fb;
693 for (i = 0; i < BMP_LOGO_HEIGHT; ++i) { 693 for (i = 0; i < BMP_LOGO_HEIGHT; ++i) {
694 for (j = 0; j < BMP_LOGO_WIDTH; j++) { 694 for (j = 0; j < BMP_LOGO_WIDTH; j++) {
695 col16 = bmp_logo_palette[(bmap[j]-16)]; 695 col16 = bmp_logo_palette[(bmap[j]-16)];
696 fb16[j] = 696 fb16[j] =
697 ((col16 & 0x000F) << 1) | 697 ((col16 & 0x000F) << 1) |
698 ((col16 & 0x00F0) << 3) | 698 ((col16 & 0x00F0) << 3) |
699 ((col16 & 0x0F00) << 4); 699 ((col16 & 0x0F00) << 4);
700 } 700 }
701 bmap += BMP_LOGO_WIDTH; 701 bmap += BMP_LOGO_WIDTH;
702 fb16 += panel_info.vl_col; 702 fb16 += panel_info.vl_col;
703 } 703 }
704 } 704 }
705 705
706 WATCHDOG_RESET(); 706 WATCHDOG_RESET();
707 lcd_sync(); 707 lcd_sync();
708 } 708 }
709 #else 709 #else
710 static inline void bitmap_plot(int x, int y) {} 710 static inline void bitmap_plot(int x, int y) {}
711 #endif /* CONFIG_LCD_LOGO */ 711 #endif /* CONFIG_LCD_LOGO */
712 712
713 /*----------------------------------------------------------------------*/ 713 /*----------------------------------------------------------------------*/
714 #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN) 714 #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
715 /* 715 /*
716 * Display the BMP file located at address bmp_image. 716 * Display the BMP file located at address bmp_image.
717 * Only uncompressed. 717 * Only uncompressed.
718 */ 718 */
719 719
720 #ifdef CONFIG_SPLASH_SCREEN_ALIGN 720 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
721 #define BMP_ALIGN_CENTER 0x7FFF 721 #define BMP_ALIGN_CENTER 0x7FFF
722 722
723 static void splash_align_axis(int *axis, unsigned long panel_size, 723 static void splash_align_axis(int *axis, unsigned long panel_size,
724 unsigned long picture_size) 724 unsigned long picture_size)
725 { 725 {
726 unsigned long panel_picture_delta = panel_size - picture_size; 726 unsigned long panel_picture_delta = panel_size - picture_size;
727 unsigned long axis_alignment; 727 unsigned long axis_alignment;
728 728
729 if (*axis == BMP_ALIGN_CENTER) 729 if (*axis == BMP_ALIGN_CENTER)
730 axis_alignment = panel_picture_delta / 2; 730 axis_alignment = panel_picture_delta / 2;
731 else if (*axis < 0) 731 else if (*axis < 0)
732 axis_alignment = panel_picture_delta + *axis + 1; 732 axis_alignment = panel_picture_delta + *axis + 1;
733 else 733 else
734 return; 734 return;
735 735
736 *axis = max(0, axis_alignment); 736 *axis = max(0, axis_alignment);
737 } 737 }
738 #endif 738 #endif
739 739
740 740
741 #ifdef CONFIG_LCD_BMP_RLE8 741 #ifdef CONFIG_LCD_BMP_RLE8
742 742
743 #define BMP_RLE8_ESCAPE 0 743 #define BMP_RLE8_ESCAPE 0
744 #define BMP_RLE8_EOL 0 744 #define BMP_RLE8_EOL 0
745 #define BMP_RLE8_EOBMP 1 745 #define BMP_RLE8_EOBMP 1
746 #define BMP_RLE8_DELTA 2 746 #define BMP_RLE8_DELTA 2
747 747
748 static void draw_unencoded_bitmap(ushort **fbp, uchar *bmap, ushort *cmap, 748 static void draw_unencoded_bitmap(ushort **fbp, uchar *bmap, ushort *cmap,
749 int cnt) 749 int cnt)
750 { 750 {
751 while (cnt > 0) { 751 while (cnt > 0) {
752 *(*fbp)++ = cmap[*bmap++]; 752 *(*fbp)++ = cmap[*bmap++];
753 cnt--; 753 cnt--;
754 } 754 }
755 } 755 }
756 756
757 static void draw_encoded_bitmap(ushort **fbp, ushort c, int cnt) 757 static void draw_encoded_bitmap(ushort **fbp, ushort c, int cnt)
758 { 758 {
759 ushort *fb = *fbp; 759 ushort *fb = *fbp;
760 int cnt_8copy = cnt >> 3; 760 int cnt_8copy = cnt >> 3;
761 761
762 cnt -= cnt_8copy << 3; 762 cnt -= cnt_8copy << 3;
763 while (cnt_8copy > 0) { 763 while (cnt_8copy > 0) {
764 *fb++ = c; 764 *fb++ = c;
765 *fb++ = c; 765 *fb++ = c;
766 *fb++ = c; 766 *fb++ = c;
767 *fb++ = c; 767 *fb++ = c;
768 *fb++ = c; 768 *fb++ = c;
769 *fb++ = c; 769 *fb++ = c;
770 *fb++ = c; 770 *fb++ = c;
771 *fb++ = c; 771 *fb++ = c;
772 cnt_8copy--; 772 cnt_8copy--;
773 } 773 }
774 while (cnt > 0) { 774 while (cnt > 0) {
775 *fb++ = c; 775 *fb++ = c;
776 cnt--; 776 cnt--;
777 } 777 }
778 *fbp = fb; 778 *fbp = fb;
779 } 779 }
780 780
781 /* 781 /*
782 * Do not call this function directly, must be called from lcd_display_bitmap. 782 * Do not call this function directly, must be called from lcd_display_bitmap.
783 */ 783 */
784 static void lcd_display_rle8_bitmap(bmp_image_t *bmp, ushort *cmap, uchar *fb, 784 static void lcd_display_rle8_bitmap(bmp_image_t *bmp, ushort *cmap, uchar *fb,
785 int x_off, int y_off) 785 int x_off, int y_off)
786 { 786 {
787 uchar *bmap; 787 uchar *bmap;
788 ulong width, height; 788 ulong width, height;
789 ulong cnt, runlen; 789 ulong cnt, runlen;
790 int x, y; 790 int x, y;
791 int decode = 1; 791 int decode = 1;
792 792
793 width = le32_to_cpu(bmp->header.width); 793 width = le32_to_cpu(bmp->header.width);
794 height = le32_to_cpu(bmp->header.height); 794 height = le32_to_cpu(bmp->header.height);
795 bmap = (uchar *)bmp + le32_to_cpu(bmp->header.data_offset); 795 bmap = (uchar *)bmp + le32_to_cpu(bmp->header.data_offset);
796 796
797 x = 0; 797 x = 0;
798 y = height - 1; 798 y = height - 1;
799 799
800 while (decode) { 800 while (decode) {
801 if (bmap[0] == BMP_RLE8_ESCAPE) { 801 if (bmap[0] == BMP_RLE8_ESCAPE) {
802 switch (bmap[1]) { 802 switch (bmap[1]) {
803 case BMP_RLE8_EOL: 803 case BMP_RLE8_EOL:
804 /* end of line */ 804 /* end of line */
805 bmap += 2; 805 bmap += 2;
806 x = 0; 806 x = 0;
807 y--; 807 y--;
808 /* 16bpix, 2-byte per pixel, width should *2 */ 808 /* 16bpix, 2-byte per pixel, width should *2 */
809 fb -= (width * 2 + lcd_line_length); 809 fb -= (width * 2 + lcd_line_length);
810 break; 810 break;
811 case BMP_RLE8_EOBMP: 811 case BMP_RLE8_EOBMP:
812 /* end of bitmap */ 812 /* end of bitmap */
813 decode = 0; 813 decode = 0;
814 break; 814 break;
815 case BMP_RLE8_DELTA: 815 case BMP_RLE8_DELTA:
816 /* delta run */ 816 /* delta run */
817 x += bmap[2]; 817 x += bmap[2];
818 y -= bmap[3]; 818 y -= bmap[3];
819 /* 16bpix, 2-byte per pixel, x should *2 */ 819 /* 16bpix, 2-byte per pixel, x should *2 */
820 fb = (uchar *) (lcd_base + (y + y_off - 1) 820 fb = (uchar *) (lcd_base + (y + y_off - 1)
821 * lcd_line_length + (x + x_off) * 2); 821 * lcd_line_length + (x + x_off) * 2);
822 bmap += 4; 822 bmap += 4;
823 break; 823 break;
824 default: 824 default:
825 /* unencoded run */ 825 /* unencoded run */
826 runlen = bmap[1]; 826 runlen = bmap[1];
827 bmap += 2; 827 bmap += 2;
828 if (y < height) { 828 if (y < height) {
829 if (x < width) { 829 if (x < width) {
830 if (x + runlen > width) 830 if (x + runlen > width)
831 cnt = width - x; 831 cnt = width - x;
832 else 832 else
833 cnt = runlen; 833 cnt = runlen;
834 draw_unencoded_bitmap( 834 draw_unencoded_bitmap(
835 (ushort **)&fb, 835 (ushort **)&fb,
836 bmap, cmap, cnt); 836 bmap, cmap, cnt);
837 } 837 }
838 x += runlen; 838 x += runlen;
839 } 839 }
840 bmap += runlen; 840 bmap += runlen;
841 if (runlen & 1) 841 if (runlen & 1)
842 bmap++; 842 bmap++;
843 } 843 }
844 } else { 844 } else {
845 /* encoded run */ 845 /* encoded run */
846 if (y < height) { 846 if (y < height) {
847 runlen = bmap[0]; 847 runlen = bmap[0];
848 if (x < width) { 848 if (x < width) {
849 /* aggregate the same code */ 849 /* aggregate the same code */
850 while (bmap[0] == 0xff && 850 while (bmap[0] == 0xff &&
851 bmap[2] != BMP_RLE8_ESCAPE && 851 bmap[2] != BMP_RLE8_ESCAPE &&
852 bmap[1] == bmap[3]) { 852 bmap[1] == bmap[3]) {
853 runlen += bmap[2]; 853 runlen += bmap[2];
854 bmap += 2; 854 bmap += 2;
855 } 855 }
856 if (x + runlen > width) 856 if (x + runlen > width)
857 cnt = width - x; 857 cnt = width - x;
858 else 858 else
859 cnt = runlen; 859 cnt = runlen;
860 draw_encoded_bitmap((ushort **)&fb, 860 draw_encoded_bitmap((ushort **)&fb,
861 cmap[bmap[1]], cnt); 861 cmap[bmap[1]], cnt);
862 } 862 }
863 x += runlen; 863 x += runlen;
864 } 864 }
865 bmap += 2; 865 bmap += 2;
866 } 866 }
867 } 867 }
868 } 868 }
869 #endif 869 #endif
870 870
871 #if defined(CONFIG_MPC823) || defined(CONFIG_MCC200) 871 #if defined(CONFIG_MPC823) || defined(CONFIG_MCC200)
872 #define FB_PUT_BYTE(fb, from) *(fb)++ = (255 - *(from)++) 872 #define FB_PUT_BYTE(fb, from) *(fb)++ = (255 - *(from)++)
873 #else 873 #else
874 #define FB_PUT_BYTE(fb, from) *(fb)++ = *(from)++ 874 #define FB_PUT_BYTE(fb, from) *(fb)++ = *(from)++
875 #endif 875 #endif
876 876
877 #if defined(CONFIG_BMP_16BPP) 877 #if defined(CONFIG_BMP_16BPP)
878 #if defined(CONFIG_ATMEL_LCD_BGR555) 878 #if defined(CONFIG_ATMEL_LCD_BGR555)
879 static inline void fb_put_word(uchar **fb, uchar **from) 879 static inline void fb_put_word(uchar **fb, uchar **from)
880 { 880 {
881 *(*fb)++ = (((*from)[0] & 0x1f) << 2) | ((*from)[1] & 0x03); 881 *(*fb)++ = (((*from)[0] & 0x1f) << 2) | ((*from)[1] & 0x03);
882 *(*fb)++ = ((*from)[0] & 0xe0) | (((*from)[1] & 0x7c) >> 2); 882 *(*fb)++ = ((*from)[0] & 0xe0) | (((*from)[1] & 0x7c) >> 2);
883 *from += 2; 883 *from += 2;
884 } 884 }
885 #else 885 #else
886 static inline void fb_put_word(uchar **fb, uchar **from) 886 static inline void fb_put_word(uchar **fb, uchar **from)
887 { 887 {
888 *(*fb)++ = *(*from)++; 888 *(*fb)++ = *(*from)++;
889 *(*fb)++ = *(*from)++; 889 *(*fb)++ = *(*from)++;
890 } 890 }
891 #endif 891 #endif
892 #endif /* CONFIG_BMP_16BPP */ 892 #endif /* CONFIG_BMP_16BPP */
893 893
894 int lcd_display_bitmap(ulong bmp_image, int x, int y) 894 int lcd_display_bitmap(ulong bmp_image, int x, int y)
895 { 895 {
896 #if !defined(CONFIG_MCC200) 896 #if !defined(CONFIG_MCC200)
897 ushort *cmap = NULL; 897 ushort *cmap = NULL;
898 #endif 898 #endif
899 ushort *cmap_base = NULL; 899 ushort *cmap_base = NULL;
900 ushort i, j; 900 ushort i, j;
901 uchar *fb; 901 uchar *fb;
902 bmp_image_t *bmp=(bmp_image_t *)bmp_image; 902 bmp_image_t *bmp=(bmp_image_t *)bmp_image;
903 uchar *bmap; 903 uchar *bmap;
904 ushort padded_width; 904 ushort padded_width;
905 unsigned long width, height, byte_width; 905 unsigned long width, height, byte_width;
906 unsigned long pwidth = panel_info.vl_col; 906 unsigned long pwidth = panel_info.vl_col;
907 unsigned colors, bpix, bmp_bpix; 907 unsigned colors, bpix, bmp_bpix;
908 908
909 if (!bmp || !(bmp->header.signature[0] == 'B' && 909 if (!bmp || !(bmp->header.signature[0] == 'B' &&
910 bmp->header.signature[1] == 'M')) { 910 bmp->header.signature[1] == 'M')) {
911 printf("Error: no valid bmp image at %lx\n", bmp_image); 911 printf("Error: no valid bmp image at %lx\n", bmp_image);
912 912
913 return 1; 913 return 1;
914 } 914 }
915 915
916 width = le32_to_cpu(bmp->header.width); 916 width = le32_to_cpu(bmp->header.width);
917 height = le32_to_cpu(bmp->header.height); 917 height = le32_to_cpu(bmp->header.height);
918 bmp_bpix = le16_to_cpu(bmp->header.bit_count); 918 bmp_bpix = le16_to_cpu(bmp->header.bit_count);
919 colors = 1 << bmp_bpix; 919 colors = 1 << bmp_bpix;
920 920
921 bpix = NBITS(panel_info.vl_bpix); 921 bpix = NBITS(panel_info.vl_bpix);
922 922
923 if (bpix != 1 && bpix != 8 && bpix != 16 && bpix != 32) { 923 if (bpix != 1 && bpix != 8 && bpix != 16 && bpix != 32) {
924 printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n", 924 printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
925 bpix, bmp_bpix); 925 bpix, bmp_bpix);
926 926
927 return 1; 927 return 1;
928 } 928 }
929 929
930 /* We support displaying 8bpp BMPs on 16bpp LCDs */ 930 /* We support displaying 8bpp BMPs on 16bpp LCDs */
931 if (bpix != bmp_bpix && !(bmp_bpix == 8 && bpix == 16)) { 931 if (bpix != bmp_bpix && !(bmp_bpix == 8 && bpix == 16)) {
932 printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n", 932 printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
933 bpix, 933 bpix,
934 le16_to_cpu(bmp->header.bit_count)); 934 le16_to_cpu(bmp->header.bit_count));
935 935
936 return 1; 936 return 1;
937 } 937 }
938 938
939 debug("Display-bmp: %d x %d with %d colors\n", 939 debug("Display-bmp: %d x %d with %d colors\n",
940 (int)width, (int)height, (int)colors); 940 (int)width, (int)height, (int)colors);
941 941
942 #if !defined(CONFIG_MCC200) 942 #if !defined(CONFIG_MCC200)
943 /* MCC200 LCD doesn't need CMAP, supports 1bpp b&w only */ 943 /* MCC200 LCD doesn't need CMAP, supports 1bpp b&w only */
944 if (bmp_bpix == 8) { 944 if (bmp_bpix == 8) {
945 cmap = configuration_get_cmap(); 945 cmap = configuration_get_cmap();
946 cmap_base = cmap; 946 cmap_base = cmap;
947 947
948 /* Set color map */ 948 /* Set color map */
949 for (i = 0; i < colors; ++i) { 949 for (i = 0; i < colors; ++i) {
950 bmp_color_table_entry_t cte = bmp->color_table[i]; 950 bmp_color_table_entry_t cte = bmp->color_table[i];
951 #if !defined(CONFIG_ATMEL_LCD) 951 #if !defined(CONFIG_ATMEL_LCD)
952 ushort colreg = 952 ushort colreg =
953 ( ((cte.red) << 8) & 0xf800) | 953 ( ((cte.red) << 8) & 0xf800) |
954 ( ((cte.green) << 3) & 0x07e0) | 954 ( ((cte.green) << 3) & 0x07e0) |
955 ( ((cte.blue) >> 3) & 0x001f) ; 955 ( ((cte.blue) >> 3) & 0x001f) ;
956 #ifdef CONFIG_SYS_INVERT_COLORS 956 #ifdef CONFIG_SYS_INVERT_COLORS
957 *cmap = 0xffff - colreg; 957 *cmap = 0xffff - colreg;
958 #else 958 #else
959 *cmap = colreg; 959 *cmap = colreg;
960 #endif 960 #endif
961 #if defined(CONFIG_MPC823) 961 #if defined(CONFIG_MPC823)
962 cmap--; 962 cmap--;
963 #else 963 #else
964 cmap++; 964 cmap++;
965 #endif 965 #endif
966 #else /* CONFIG_ATMEL_LCD */ 966 #else /* CONFIG_ATMEL_LCD */
967 lcd_setcolreg(i, cte.red, cte.green, cte.blue); 967 lcd_setcolreg(i, cte.red, cte.green, cte.blue);
968 #endif 968 #endif
969 } 969 }
970 } 970 }
971 #endif 971 #endif
972 972
973 /* 973 /*
974 * BMP format for Monochrome assumes that the state of a 974 * BMP format for Monochrome assumes that the state of a
975 * pixel is described on a per Bit basis, not per Byte. 975 * pixel is described on a per Bit basis, not per Byte.
976 * So, in case of Monochrome BMP we should align widths 976 * So, in case of Monochrome BMP we should align widths
977 * on a byte boundary and convert them from Bit to Byte 977 * on a byte boundary and convert them from Bit to Byte
978 * units. 978 * units.
979 * Probably, PXA250 and MPC823 process 1bpp BMP images in 979 * Probably, PXA250 and MPC823 process 1bpp BMP images in
980 * their own ways, so make the converting to be MCC200 980 * their own ways, so make the converting to be MCC200
981 * specific. 981 * specific.
982 */ 982 */
983 #if defined(CONFIG_MCC200) 983 #if defined(CONFIG_MCC200)
984 if (bpix == 1) { 984 if (bpix == 1) {
985 width = ((width + 7) & ~7) >> 3; 985 width = ((width + 7) & ~7) >> 3;
986 x = ((x + 7) & ~7) >> 3; 986 x = ((x + 7) & ~7) >> 3;
987 pwidth= ((pwidth + 7) & ~7) >> 3; 987 pwidth= ((pwidth + 7) & ~7) >> 3;
988 } 988 }
989 #endif 989 #endif
990 990
991 padded_width = (width & 0x3 ? (width & ~0x3) + 4 : width); 991 padded_width = (width & 0x3 ? (width & ~0x3) + 4 : width);
992 992
993 #ifdef CONFIG_SPLASH_SCREEN_ALIGN 993 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
994 splash_align_axis(&x, pwidth, width); 994 splash_align_axis(&x, pwidth, width);
995 splash_align_axis(&y, panel_info.vl_row, height); 995 splash_align_axis(&y, panel_info.vl_row, height);
996 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */ 996 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
997 997
998 if ((x + width) > pwidth) 998 if ((x + width) > pwidth)
999 width = pwidth - x; 999 width = pwidth - x;
1000 if ((y + height) > panel_info.vl_row) 1000 if ((y + height) > panel_info.vl_row)
1001 height = panel_info.vl_row - y; 1001 height = panel_info.vl_row - y;
1002 1002
1003 bmap = (uchar *) bmp + le32_to_cpu(bmp->header.data_offset); 1003 bmap = (uchar *) bmp + le32_to_cpu(bmp->header.data_offset);
1004 fb = (uchar *) (lcd_base + 1004 fb = (uchar *) (lcd_base +
1005 (y + height - 1) * lcd_line_length + x * bpix / 8); 1005 (y + height - 1) * lcd_line_length + x * bpix / 8);
1006 1006
1007 switch (bmp_bpix) { 1007 switch (bmp_bpix) {
1008 case 1: /* pass through */ 1008 case 1: /* pass through */
1009 case 8: 1009 case 8:
1010 #ifdef CONFIG_LCD_BMP_RLE8 1010 #ifdef CONFIG_LCD_BMP_RLE8
1011 if (le32_to_cpu(bmp->header.compression) == BMP_BI_RLE8) { 1011 if (le32_to_cpu(bmp->header.compression) == BMP_BI_RLE8) {
1012 if (bpix != 16) { 1012 if (bpix != 16) {
1013 /* TODO implement render code for bpix != 16 */ 1013 /* TODO implement render code for bpix != 16 */
1014 printf("Error: only support 16 bpix"); 1014 printf("Error: only support 16 bpix");
1015 return 1; 1015 return 1;
1016 } 1016 }
1017 lcd_display_rle8_bitmap(bmp, cmap_base, fb, x, y); 1017 lcd_display_rle8_bitmap(bmp, cmap_base, fb, x, y);
1018 break; 1018 break;
1019 } 1019 }
1020 #endif 1020 #endif
1021 1021
1022 if (bpix != 16) 1022 if (bpix != 16)
1023 byte_width = width; 1023 byte_width = width;
1024 else 1024 else
1025 byte_width = width * 2; 1025 byte_width = width * 2;
1026 1026
1027 for (i = 0; i < height; ++i) { 1027 for (i = 0; i < height; ++i) {
1028 WATCHDOG_RESET(); 1028 WATCHDOG_RESET();
1029 for (j = 0; j < width; j++) { 1029 for (j = 0; j < width; j++) {
1030 if (bpix != 16) { 1030 if (bpix != 16) {
1031 FB_PUT_BYTE(fb, bmap); 1031 FB_PUT_BYTE(fb, bmap);
1032 } else { 1032 } else {
1033 *(uint16_t *)fb = cmap_base[*(bmap++)]; 1033 *(uint16_t *)fb = cmap_base[*(bmap++)];
1034 fb += sizeof(uint16_t) / sizeof(*fb); 1034 fb += sizeof(uint16_t) / sizeof(*fb);
1035 } 1035 }
1036 } 1036 }
1037 bmap += (padded_width - width); 1037 bmap += (padded_width - width);
1038 fb -= byte_width + lcd_line_length; 1038 fb -= byte_width + lcd_line_length;
1039 } 1039 }
1040 break; 1040 break;
1041 1041
1042 #if defined(CONFIG_BMP_16BPP) 1042 #if defined(CONFIG_BMP_16BPP)
1043 case 16: 1043 case 16:
1044 for (i = 0; i < height; ++i) { 1044 for (i = 0; i < height; ++i) {
1045 WATCHDOG_RESET(); 1045 WATCHDOG_RESET();
1046 for (j = 0; j < width; j++) 1046 for (j = 0; j < width; j++)
1047 fb_put_word(&fb, &bmap); 1047 fb_put_word(&fb, &bmap);
1048 1048
1049 bmap += (padded_width - width) * 2; 1049 bmap += (padded_width - width) * 2;
1050 fb -= width * 2 + lcd_line_length; 1050 fb -= width * 2 + lcd_line_length;
1051 } 1051 }
1052 break; 1052 break;
1053 #endif /* CONFIG_BMP_16BPP */ 1053 #endif /* CONFIG_BMP_16BPP */
1054 1054
1055 #if defined(CONFIG_BMP_32BPP) 1055 #if defined(CONFIG_BMP_32BPP)
1056 case 32: 1056 case 32:
1057 for (i = 0; i < height; ++i) { 1057 for (i = 0; i < height; ++i) {
1058 for (j = 0; j < width; j++) { 1058 for (j = 0; j < width; j++) {
1059 *(fb++) = *(bmap++); 1059 *(fb++) = *(bmap++);
1060 *(fb++) = *(bmap++); 1060 *(fb++) = *(bmap++);
1061 *(fb++) = *(bmap++); 1061 *(fb++) = *(bmap++);
1062 *(fb++) = *(bmap++); 1062 *(fb++) = *(bmap++);
1063 } 1063 }
1064 fb -= lcd_line_length + width * (bpix / 8); 1064 fb -= lcd_line_length + width * (bpix / 8);
1065 } 1065 }
1066 break; 1066 break;
1067 #endif /* CONFIG_BMP_32BPP */ 1067 #endif /* CONFIG_BMP_32BPP */
1068 default: 1068 default:
1069 break; 1069 break;
1070 }; 1070 };
1071 1071
1072 lcd_sync(); 1072 lcd_sync();
1073 return 0; 1073 return 0;
1074 } 1074 }
1075 #endif 1075 #endif
1076 1076
1077 static void *lcd_logo(void) 1077 static void *lcd_logo(void)
1078 { 1078 {
1079 #ifdef CONFIG_SPLASH_SCREEN 1079 #ifdef CONFIG_SPLASH_SCREEN
1080 char *s; 1080 char *s;
1081 ulong addr; 1081 ulong addr;
1082 static int do_splash = 1; 1082 static int do_splash = 1;
1083 1083
1084 if (do_splash && (s = getenv("splashimage")) != NULL) { 1084 if (do_splash && (s = getenv("splashimage")) != NULL) {
1085 int x = 0, y = 0; 1085 int x = 0, y = 0;
1086 do_splash = 0; 1086 do_splash = 0;
1087 1087
1088 if (splash_screen_prepare()) 1088 if (splash_screen_prepare())
1089 return (void *)lcd_base; 1089 return (void *)lcd_base;
1090 1090
1091 addr = simple_strtoul (s, NULL, 16); 1091 addr = simple_strtoul (s, NULL, 16);
1092 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
1093 s = getenv("splashpos");
1094 if (s != NULL) {
1095 if (s[0] == 'm')
1096 x = BMP_ALIGN_CENTER;
1097 else
1098 x = simple_strtol(s, NULL, 0);
1099 1092
1100 s = strchr(s + 1, ','); 1093 splash_get_pos(&x, &y);
1101 if (s != NULL) {
1102 if (s[1] == 'm')
1103 y = BMP_ALIGN_CENTER;
1104 else
1105 y = simple_strtol (s + 1, NULL, 0);
1106 }
1107 }
1108 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
1109 1094
1110 if (bmp_display(addr, x, y) == 0) 1095 if (bmp_display(addr, x, y) == 0)
1111 return (void *)lcd_base; 1096 return (void *)lcd_base;
1112 } 1097 }
1113 #endif /* CONFIG_SPLASH_SCREEN */ 1098 #endif /* CONFIG_SPLASH_SCREEN */
1114 1099
1115 bitmap_plot(0, 0); 1100 bitmap_plot(0, 0);
1116 1101
1117 #ifdef CONFIG_LCD_INFO 1102 #ifdef CONFIG_LCD_INFO
1118 console_col = LCD_INFO_X / VIDEO_FONT_WIDTH; 1103 console_col = LCD_INFO_X / VIDEO_FONT_WIDTH;
1119 console_row = LCD_INFO_Y / VIDEO_FONT_HEIGHT; 1104 console_row = LCD_INFO_Y / VIDEO_FONT_HEIGHT;
1120 lcd_show_board_info(); 1105 lcd_show_board_info();
1121 #endif /* CONFIG_LCD_INFO */ 1106 #endif /* CONFIG_LCD_INFO */
1122 1107
1123 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO) 1108 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
1124 return (void *)((ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length); 1109 return (void *)((ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length);
1125 #else 1110 #else
1126 return (void *)lcd_base; 1111 return (void *)lcd_base;
1127 #endif /* CONFIG_LCD_LOGO && !defined(CONFIG_LCD_INFO_BELOW_LOGO) */ 1112 #endif /* CONFIG_LCD_LOGO && !defined(CONFIG_LCD_INFO_BELOW_LOGO) */
1128 } 1113 }
1129 1114
1130 #ifdef CONFIG_SPLASHIMAGE_GUARD 1115 #ifdef CONFIG_SPLASHIMAGE_GUARD
1131 static int on_splashimage(const char *name, const char *value, enum env_op op, 1116 static int on_splashimage(const char *name, const char *value, enum env_op op,
1132 int flags) 1117 int flags)
1133 { 1118 {
1134 ulong addr; 1119 ulong addr;
1135 int aligned; 1120 int aligned;
1136 1121
1137 if (op == env_op_delete) 1122 if (op == env_op_delete)
1138 return 0; 1123 return 0;
1139 1124
1140 addr = simple_strtoul(value, NULL, 16); 1125 addr = simple_strtoul(value, NULL, 16);
1141 /* See README.displaying-bmps */ 1126 /* See README.displaying-bmps */
1142 aligned = (addr % 4 == 2); 1127 aligned = (addr % 4 == 2);
1143 if (!aligned) { 1128 if (!aligned) {
1144 printf("Invalid splashimage value. Value must be 16 bit aligned, but not 32 bit aligned\n"); 1129 printf("Invalid splashimage value. Value must be 16 bit aligned, but not 32 bit aligned\n");
1145 return -1; 1130 return -1;
1146 } 1131 }
1147 1132
1148 return 0; 1133 return 0;
1149 } 1134 }
1150 1135
1151 U_BOOT_ENV_CALLBACK(splashimage, on_splashimage); 1136 U_BOOT_ENV_CALLBACK(splashimage, on_splashimage);
1152 #endif 1137 #endif
1153 1138
1154 void lcd_position_cursor(unsigned col, unsigned row) 1139 void lcd_position_cursor(unsigned col, unsigned row)
1155 { 1140 {
1156 console_col = min(col, CONSOLE_COLS - 1); 1141 console_col = min(col, CONSOLE_COLS - 1);
1157 console_row = min(row, CONSOLE_ROWS - 1); 1142 console_row = min(row, CONSOLE_ROWS - 1);
1158 } 1143 }
1159 1144
1160 int lcd_get_pixel_width(void) 1145 int lcd_get_pixel_width(void)
1161 { 1146 {
1162 return panel_info.vl_col; 1147 return panel_info.vl_col;
1163 } 1148 }
1164 1149
1165 int lcd_get_pixel_height(void) 1150 int lcd_get_pixel_height(void)
1166 { 1151 {
1167 return panel_info.vl_row; 1152 return panel_info.vl_row;
1168 } 1153 }
1169 1154
1170 int lcd_get_screen_rows(void) 1155 int lcd_get_screen_rows(void)
1171 { 1156 {
1172 return CONSOLE_ROWS; 1157 return CONSOLE_ROWS;
1173 } 1158 }
1174 1159
1175 int lcd_get_screen_columns(void) 1160 int lcd_get_screen_columns(void)
1176 { 1161 {
1177 return CONSOLE_COLS; 1162 return CONSOLE_COLS;
1178 } 1163 }
1179 1164
1180 #if defined(CONFIG_LCD_DT_SIMPLEFB) 1165 #if defined(CONFIG_LCD_DT_SIMPLEFB)
1181 static int lcd_dt_simplefb_configure_node(void *blob, int off) 1166 static int lcd_dt_simplefb_configure_node(void *blob, int off)
1182 { 1167 {
1183 u32 stride; 1168 u32 stride;
1184 fdt32_t cells[2]; 1169 fdt32_t cells[2];
1185 int ret; 1170 int ret;
1186 static const char format[] = 1171 static const char format[] =
1187 #if LCD_BPP == LCD_COLOR16 1172 #if LCD_BPP == LCD_COLOR16
1188 "r5g6b5"; 1173 "r5g6b5";
1189 #else 1174 #else
1190 ""; 1175 "";
1191 #endif 1176 #endif
1192 1177
1193 if (!format[0]) 1178 if (!format[0])
1194 return -1; 1179 return -1;
1195 1180
1196 stride = panel_info.vl_col * 2; 1181 stride = panel_info.vl_col * 2;
1197 1182
1198 cells[0] = cpu_to_fdt32(gd->fb_base); 1183 cells[0] = cpu_to_fdt32(gd->fb_base);
1199 cells[1] = cpu_to_fdt32(stride * panel_info.vl_row); 1184 cells[1] = cpu_to_fdt32(stride * panel_info.vl_row);
1200 ret = fdt_setprop(blob, off, "reg", cells, sizeof(cells[0]) * 2); 1185 ret = fdt_setprop(blob, off, "reg", cells, sizeof(cells[0]) * 2);
1201 if (ret < 0) 1186 if (ret < 0)
1202 return -1; 1187 return -1;
1203 1188
1204 cells[0] = cpu_to_fdt32(panel_info.vl_col); 1189 cells[0] = cpu_to_fdt32(panel_info.vl_col);
1205 ret = fdt_setprop(blob, off, "width", cells, sizeof(cells[0])); 1190 ret = fdt_setprop(blob, off, "width", cells, sizeof(cells[0]));
1206 if (ret < 0) 1191 if (ret < 0)
1207 return -1; 1192 return -1;
1208 1193
1209 cells[0] = cpu_to_fdt32(panel_info.vl_row); 1194 cells[0] = cpu_to_fdt32(panel_info.vl_row);
1210 ret = fdt_setprop(blob, off, "height", cells, sizeof(cells[0])); 1195 ret = fdt_setprop(blob, off, "height", cells, sizeof(cells[0]));
1211 if (ret < 0) 1196 if (ret < 0)
1212 return -1; 1197 return -1;
1213 1198
1214 cells[0] = cpu_to_fdt32(stride); 1199 cells[0] = cpu_to_fdt32(stride);
1215 ret = fdt_setprop(blob, off, "stride", cells, sizeof(cells[0])); 1200 ret = fdt_setprop(blob, off, "stride", cells, sizeof(cells[0]));
1216 if (ret < 0) 1201 if (ret < 0)
1217 return -1; 1202 return -1;
1218 1203
1219 ret = fdt_setprop(blob, off, "format", format, strlen(format) + 1); 1204 ret = fdt_setprop(blob, off, "format", format, strlen(format) + 1);
1220 if (ret < 0) 1205 if (ret < 0)
1221 return -1; 1206 return -1;
1222 1207
1223 ret = fdt_delprop(blob, off, "status"); 1208 ret = fdt_delprop(blob, off, "status");
1224 if (ret < 0) 1209 if (ret < 0)
1225 return -1; 1210 return -1;
1226 1211
1227 return 0; 1212 return 0;
1228 } 1213 }
1229 1214
1230 int lcd_dt_simplefb_add_node(void *blob) 1215 int lcd_dt_simplefb_add_node(void *blob)
1231 { 1216 {
1232 static const char compat[] = "simple-framebuffer"; 1217 static const char compat[] = "simple-framebuffer";
1233 static const char disabled[] = "disabled"; 1218 static const char disabled[] = "disabled";
1234 int off, ret; 1219 int off, ret;
1235 1220
1236 off = fdt_add_subnode(blob, 0, "framebuffer"); 1221 off = fdt_add_subnode(blob, 0, "framebuffer");
1237 if (off < 0) 1222 if (off < 0)
1238 return -1; 1223 return -1;
1239 1224
1240 ret = fdt_setprop(blob, off, "status", disabled, sizeof(disabled)); 1225 ret = fdt_setprop(blob, off, "status", disabled, sizeof(disabled));
1241 if (ret < 0) 1226 if (ret < 0)
1242 return -1; 1227 return -1;
1243 1228
1244 ret = fdt_setprop(blob, off, "compatible", compat, sizeof(compat)); 1229 ret = fdt_setprop(blob, off, "compatible", compat, sizeof(compat));
1245 if (ret < 0) 1230 if (ret < 0)
1246 return -1; 1231 return -1;
1247 1232
1248 return lcd_dt_simplefb_configure_node(blob, off); 1233 return lcd_dt_simplefb_configure_node(blob, off);
1249 } 1234 }
1250 1235
1251 int lcd_dt_simplefb_enable_existing_node(void *blob) 1236 int lcd_dt_simplefb_enable_existing_node(void *blob)
1252 { 1237 {
1253 int off; 1238 int off;
1254 1239
1255 off = fdt_node_offset_by_compatible(blob, -1, "simple-framebuffer"); 1240 off = fdt_node_offset_by_compatible(blob, -1, "simple-framebuffer");
1256 if (off < 0) 1241 if (off < 0)
1257 return -1; 1242 return -1;
1258 1243
1259 return lcd_dt_simplefb_configure_node(blob, off); 1244 return lcd_dt_simplefb_configure_node(blob, off);
1260 } 1245 }
1261 #endif 1246 #endif
1262 1247
1 /* 1 /*
2 * Copyright (C) 2013, Boundary Devices <info@boundarydevices.com> 2 * Copyright (C) 2013, Boundary Devices <info@boundarydevices.com>
3 * 3 *
4 * See file CREDITS for list of people who contributed to this 4 * See file CREDITS for list of people who contributed to this
5 * project. 5 * project.
6 * 6 *
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as 8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of 9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version. 10 * the License, or (at your option) any later version.
11 * 11 *
12 * This program is distributed in the hope that it will be useful, 12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License 17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., http://www.fsf.org/about/contact/ 19 * Foundation, Inc., http://www.fsf.org/about/contact/
20 * 20 *
21 */ 21 */
22 22
23 #include <common.h>
23 #include <splash.h> 24 #include <splash.h>
24 25
25 int __splash_screen_prepare(void) 26 int __splash_screen_prepare(void)
26 { 27 {
27 return 0; 28 return 0;
28 } 29 }
29 30
30 int splash_screen_prepare(void) 31 int splash_screen_prepare(void)
31 __attribute__ ((weak, alias("__splash_screen_prepare"))); 32 __attribute__ ((weak, alias("__splash_screen_prepare")));
33
34
35 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
36 void splash_get_pos(int *x, int *y)
37 {
38 char *s = getenv("splashpos");
39
40 if (!s)
41 return;
42
43 if (s[0] == 'm')
44 *x = BMP_ALIGN_CENTER;
45 else
46 *x = simple_strtol(s, NULL, 0);
47
48 s = strchr(s + 1, ',');
49 if (s != NULL) {
50 if (s[1] == 'm')
51 *y = BMP_ALIGN_CENTER;
52 else
53 *y = simple_strtol(s + 1, NULL, 0);
54 }
55 }
56 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
32 57
drivers/video/cfb_console.c
1 /* 1 /*
2 * (C) Copyright 2002 ELTEC Elektronik AG 2 * (C) Copyright 2002 ELTEC Elektronik AG
3 * Frank Gottschling <fgottschling@eltec.de> 3 * Frank Gottschling <fgottschling@eltec.de>
4 * 4 *
5 * See file CREDITS for list of people who contributed to this 5 * See file CREDITS for list of people who contributed to this
6 * project. 6 * project.
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of 10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version. 11 * the License, or (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA 21 * MA 02111-1307 USA
22 */ 22 */
23 23
24 /* 24 /*
25 * cfb_console.c 25 * cfb_console.c
26 * 26 *
27 * Color Framebuffer Console driver for 8/15/16/24/32 bits per pixel. 27 * Color Framebuffer Console driver for 8/15/16/24/32 bits per pixel.
28 * 28 *
29 * At the moment only the 8x16 font is tested and the font fore- and 29 * At the moment only the 8x16 font is tested and the font fore- and
30 * background color is limited to black/white/gray colors. The Linux 30 * background color is limited to black/white/gray colors. The Linux
31 * logo can be placed in the upper left corner and additional board 31 * logo can be placed in the upper left corner and additional board
32 * information strings (that normally goes to serial port) can be drawn. 32 * information strings (that normally goes to serial port) can be drawn.
33 * 33 *
34 * The console driver can use the standard PC keyboard interface (i8042) 34 * The console driver can use the standard PC keyboard interface (i8042)
35 * for character input. Character output goes to a memory mapped video 35 * for character input. Character output goes to a memory mapped video
36 * framebuffer with little or big-endian organisation. 36 * framebuffer with little or big-endian organisation.
37 * With environment setting 'console=serial' the console i/o can be 37 * With environment setting 'console=serial' the console i/o can be
38 * forced to serial port. 38 * forced to serial port.
39 * 39 *
40 * The driver uses graphic specific defines/parameters/functions: 40 * The driver uses graphic specific defines/parameters/functions:
41 * 41 *
42 * (for SMI LynxE graphic chip) 42 * (for SMI LynxE graphic chip)
43 * 43 *
44 * CONFIG_VIDEO_SMI_LYNXEM - use graphic driver for SMI 710,712,810 44 * CONFIG_VIDEO_SMI_LYNXEM - use graphic driver for SMI 710,712,810
45 * VIDEO_FB_LITTLE_ENDIAN - framebuffer organisation default: big endian 45 * VIDEO_FB_LITTLE_ENDIAN - framebuffer organisation default: big endian
46 * VIDEO_HW_RECTFILL - graphic driver supports hardware rectangle fill 46 * VIDEO_HW_RECTFILL - graphic driver supports hardware rectangle fill
47 * VIDEO_HW_BITBLT - graphic driver supports hardware bit blt 47 * VIDEO_HW_BITBLT - graphic driver supports hardware bit blt
48 * 48 *
49 * Console Parameters are set by graphic drivers global struct: 49 * Console Parameters are set by graphic drivers global struct:
50 * 50 *
51 * VIDEO_VISIBLE_COLS - x resolution 51 * VIDEO_VISIBLE_COLS - x resolution
52 * VIDEO_VISIBLE_ROWS - y resolution 52 * VIDEO_VISIBLE_ROWS - y resolution
53 * VIDEO_PIXEL_SIZE - storage size in byte per pixel 53 * VIDEO_PIXEL_SIZE - storage size in byte per pixel
54 * VIDEO_DATA_FORMAT - graphical data format GDF 54 * VIDEO_DATA_FORMAT - graphical data format GDF
55 * VIDEO_FB_ADRS - start of video memory 55 * VIDEO_FB_ADRS - start of video memory
56 * 56 *
57 * CONFIG_I8042_KBD - AT Keyboard driver for i8042 57 * CONFIG_I8042_KBD - AT Keyboard driver for i8042
58 * VIDEO_KBD_INIT_FCT - init function for keyboard 58 * VIDEO_KBD_INIT_FCT - init function for keyboard
59 * VIDEO_TSTC_FCT - keyboard_tstc function 59 * VIDEO_TSTC_FCT - keyboard_tstc function
60 * VIDEO_GETC_FCT - keyboard_getc function 60 * VIDEO_GETC_FCT - keyboard_getc function
61 * 61 *
62 * CONFIG_CONSOLE_CURSOR - on/off drawing cursor is done with 62 * CONFIG_CONSOLE_CURSOR - on/off drawing cursor is done with
63 * delay loop in VIDEO_TSTC_FCT (i8042) 63 * delay loop in VIDEO_TSTC_FCT (i8042)
64 * 64 *
65 * CONFIG_SYS_CONSOLE_BLINK_COUNT - value for delay loop - blink rate 65 * CONFIG_SYS_CONSOLE_BLINK_COUNT - value for delay loop - blink rate
66 * CONFIG_CONSOLE_TIME - display time/date in upper right 66 * CONFIG_CONSOLE_TIME - display time/date in upper right
67 * corner, needs CONFIG_CMD_DATE and 67 * corner, needs CONFIG_CMD_DATE and
68 * CONFIG_CONSOLE_CURSOR 68 * CONFIG_CONSOLE_CURSOR
69 * CONFIG_VIDEO_LOGO - display Linux Logo in upper left corner. 69 * CONFIG_VIDEO_LOGO - display Linux Logo in upper left corner.
70 * Use CONFIG_SPLASH_SCREEN_ALIGN with 70 * Use CONFIG_SPLASH_SCREEN_ALIGN with
71 * environment variable "splashpos" to place 71 * environment variable "splashpos" to place
72 * the logo on other position. In this case 72 * the logo on other position. In this case
73 * no CONSOLE_EXTRA_INFO is possible. 73 * no CONSOLE_EXTRA_INFO is possible.
74 * CONFIG_VIDEO_BMP_LOGO - use bmp_logo instead of linux_logo 74 * CONFIG_VIDEO_BMP_LOGO - use bmp_logo instead of linux_logo
75 * CONFIG_CONSOLE_EXTRA_INFO - display additional board information 75 * CONFIG_CONSOLE_EXTRA_INFO - display additional board information
76 * strings that normaly goes to serial 76 * strings that normaly goes to serial
77 * port. This define requires a board 77 * port. This define requires a board
78 * specific function: 78 * specific function:
79 * video_drawstring (VIDEO_INFO_X, 79 * video_drawstring (VIDEO_INFO_X,
80 * VIDEO_INFO_Y + i*VIDEO_FONT_HEIGHT, 80 * VIDEO_INFO_Y + i*VIDEO_FONT_HEIGHT,
81 * info); 81 * info);
82 * that fills a info buffer at i=row. 82 * that fills a info buffer at i=row.
83 * s.a: board/eltec/bab7xx. 83 * s.a: board/eltec/bab7xx.
84 * CONFIG_VGA_AS_SINGLE_DEVICE - If set the framebuffer device will be 84 * CONFIG_VGA_AS_SINGLE_DEVICE - If set the framebuffer device will be
85 * initialized as an output only device. 85 * initialized as an output only device.
86 * The Keyboard driver will not be 86 * The Keyboard driver will not be
87 * set-up. This may be used, if you have 87 * set-up. This may be used, if you have
88 * no or more than one Keyboard devices 88 * no or more than one Keyboard devices
89 * (USB Keyboard, AT Keyboard). 89 * (USB Keyboard, AT Keyboard).
90 * 90 *
91 * CONFIG_VIDEO_SW_CURSOR: - Draws a cursor after the last 91 * CONFIG_VIDEO_SW_CURSOR: - Draws a cursor after the last
92 * character. No blinking is provided. 92 * character. No blinking is provided.
93 * Uses the macros CURSOR_SET and 93 * Uses the macros CURSOR_SET and
94 * CURSOR_OFF. 94 * CURSOR_OFF.
95 * 95 *
96 * CONFIG_VIDEO_HW_CURSOR: - Uses the hardware cursor capability 96 * CONFIG_VIDEO_HW_CURSOR: - Uses the hardware cursor capability
97 * of the graphic chip. Uses the macro 97 * of the graphic chip. Uses the macro
98 * CURSOR_SET. ATTENTION: If booting an 98 * CURSOR_SET. ATTENTION: If booting an
99 * OS, the display driver must disable 99 * OS, the display driver must disable
100 * the hardware register of the graphic 100 * the hardware register of the graphic
101 * chip. Otherwise a blinking field is 101 * chip. Otherwise a blinking field is
102 * displayed. 102 * displayed.
103 */ 103 */
104 104
105 #include <common.h> 105 #include <common.h>
106 #include <version.h> 106 #include <version.h>
107 #include <malloc.h> 107 #include <malloc.h>
108 #include <linux/compiler.h> 108 #include <linux/compiler.h>
109 109
110 /* 110 /*
111 * Console device defines with SMI graphic 111 * Console device defines with SMI graphic
112 * Any other graphic must change this section 112 * Any other graphic must change this section
113 */ 113 */
114 114
115 #ifdef CONFIG_VIDEO_SMI_LYNXEM 115 #ifdef CONFIG_VIDEO_SMI_LYNXEM
116 116
117 #define VIDEO_FB_LITTLE_ENDIAN 117 #define VIDEO_FB_LITTLE_ENDIAN
118 #define VIDEO_HW_RECTFILL 118 #define VIDEO_HW_RECTFILL
119 #define VIDEO_HW_BITBLT 119 #define VIDEO_HW_BITBLT
120 #endif 120 #endif
121 121
122 /* 122 /*
123 * Defines for the CT69000 driver 123 * Defines for the CT69000 driver
124 */ 124 */
125 #ifdef CONFIG_VIDEO_CT69000 125 #ifdef CONFIG_VIDEO_CT69000
126 126
127 #define VIDEO_FB_LITTLE_ENDIAN 127 #define VIDEO_FB_LITTLE_ENDIAN
128 #define VIDEO_HW_RECTFILL 128 #define VIDEO_HW_RECTFILL
129 #define VIDEO_HW_BITBLT 129 #define VIDEO_HW_BITBLT
130 #endif 130 #endif
131 131
132 /* 132 /*
133 * Defines for the SED13806 driver 133 * Defines for the SED13806 driver
134 */ 134 */
135 #ifdef CONFIG_VIDEO_SED13806 135 #ifdef CONFIG_VIDEO_SED13806
136 136
137 #ifndef CONFIG_TOTAL5200 137 #ifndef CONFIG_TOTAL5200
138 #define VIDEO_FB_LITTLE_ENDIAN 138 #define VIDEO_FB_LITTLE_ENDIAN
139 #endif 139 #endif
140 #define VIDEO_HW_RECTFILL 140 #define VIDEO_HW_RECTFILL
141 #define VIDEO_HW_BITBLT 141 #define VIDEO_HW_BITBLT
142 #endif 142 #endif
143 143
144 /* 144 /*
145 * Defines for the SED13806 driver 145 * Defines for the SED13806 driver
146 */ 146 */
147 #ifdef CONFIG_VIDEO_SM501 147 #ifdef CONFIG_VIDEO_SM501
148 148
149 #ifdef CONFIG_HH405 149 #ifdef CONFIG_HH405
150 #define VIDEO_FB_LITTLE_ENDIAN 150 #define VIDEO_FB_LITTLE_ENDIAN
151 #endif 151 #endif
152 #endif 152 #endif
153 153
154 #ifdef CONFIG_VIDEO_MXS 154 #ifdef CONFIG_VIDEO_MXS
155 #define VIDEO_FB_16BPP_WORD_SWAP 155 #define VIDEO_FB_16BPP_WORD_SWAP
156 #endif 156 #endif
157 157
158 /* 158 /*
159 * Defines for the MB862xx driver 159 * Defines for the MB862xx driver
160 */ 160 */
161 #ifdef CONFIG_VIDEO_MB862xx 161 #ifdef CONFIG_VIDEO_MB862xx
162 162
163 #ifdef CONFIG_VIDEO_CORALP 163 #ifdef CONFIG_VIDEO_CORALP
164 #define VIDEO_FB_LITTLE_ENDIAN 164 #define VIDEO_FB_LITTLE_ENDIAN
165 #endif 165 #endif
166 #ifdef CONFIG_VIDEO_MB862xx_ACCEL 166 #ifdef CONFIG_VIDEO_MB862xx_ACCEL
167 #define VIDEO_HW_RECTFILL 167 #define VIDEO_HW_RECTFILL
168 #define VIDEO_HW_BITBLT 168 #define VIDEO_HW_BITBLT
169 #endif 169 #endif
170 #endif 170 #endif
171 171
172 /* 172 /*
173 * Defines for the i.MX31 driver (mx3fb.c) 173 * Defines for the i.MX31 driver (mx3fb.c)
174 */ 174 */
175 #if defined(CONFIG_VIDEO_MX3) || defined(CONFIG_VIDEO_IPUV3) 175 #if defined(CONFIG_VIDEO_MX3) || defined(CONFIG_VIDEO_IPUV3)
176 #define VIDEO_FB_16BPP_WORD_SWAP 176 #define VIDEO_FB_16BPP_WORD_SWAP
177 #endif 177 #endif
178 178
179 /* 179 /*
180 * Include video_fb.h after definitions of VIDEO_HW_RECTFILL etc. 180 * Include video_fb.h after definitions of VIDEO_HW_RECTFILL etc.
181 */ 181 */
182 #include <video_fb.h> 182 #include <video_fb.h>
183 183
184 #include <splash.h> 184 #include <splash.h>
185 185
186 /* 186 /*
187 * some Macros 187 * some Macros
188 */ 188 */
189 #define VIDEO_VISIBLE_COLS (pGD->winSizeX) 189 #define VIDEO_VISIBLE_COLS (pGD->winSizeX)
190 #define VIDEO_VISIBLE_ROWS (pGD->winSizeY) 190 #define VIDEO_VISIBLE_ROWS (pGD->winSizeY)
191 #define VIDEO_PIXEL_SIZE (pGD->gdfBytesPP) 191 #define VIDEO_PIXEL_SIZE (pGD->gdfBytesPP)
192 #define VIDEO_DATA_FORMAT (pGD->gdfIndex) 192 #define VIDEO_DATA_FORMAT (pGD->gdfIndex)
193 #define VIDEO_FB_ADRS (pGD->frameAdrs) 193 #define VIDEO_FB_ADRS (pGD->frameAdrs)
194 194
195 /* 195 /*
196 * Console device defines with i8042 keyboard controller 196 * Console device defines with i8042 keyboard controller
197 * Any other keyboard controller must change this section 197 * Any other keyboard controller must change this section
198 */ 198 */
199 199
200 #ifdef CONFIG_I8042_KBD 200 #ifdef CONFIG_I8042_KBD
201 #include <i8042.h> 201 #include <i8042.h>
202 202
203 #define VIDEO_KBD_INIT_FCT i8042_kbd_init() 203 #define VIDEO_KBD_INIT_FCT i8042_kbd_init()
204 #define VIDEO_TSTC_FCT i8042_tstc 204 #define VIDEO_TSTC_FCT i8042_tstc
205 #define VIDEO_GETC_FCT i8042_getc 205 #define VIDEO_GETC_FCT i8042_getc
206 #endif 206 #endif
207 207
208 /* 208 /*
209 * Console device 209 * Console device
210 */ 210 */
211 211
212 #include <version.h> 212 #include <version.h>
213 #include <linux/types.h> 213 #include <linux/types.h>
214 #include <stdio_dev.h> 214 #include <stdio_dev.h>
215 #include <video_font.h> 215 #include <video_font.h>
216 #include <video_font_data.h> 216 #include <video_font_data.h>
217 217
218 #if defined(CONFIG_CMD_DATE) 218 #if defined(CONFIG_CMD_DATE)
219 #include <rtc.h> 219 #include <rtc.h>
220 #endif 220 #endif
221 221
222 #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN) 222 #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
223 #include <watchdog.h> 223 #include <watchdog.h>
224 #include <bmp_layout.h> 224 #include <bmp_layout.h>
225 225 #include <splash.h>
226 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
227 #define BMP_ALIGN_CENTER 0x7FFF
228 #endif 226 #endif
229 227
230 #endif
231
232 /* 228 /*
233 * Cursor definition: 229 * Cursor definition:
234 * CONFIG_CONSOLE_CURSOR: Uses a timer function (see drivers/input/i8042.c) 230 * CONFIG_CONSOLE_CURSOR: Uses a timer function (see drivers/input/i8042.c)
235 * to let the cursor blink. Uses the macros 231 * to let the cursor blink. Uses the macros
236 * CURSOR_OFF and CURSOR_ON. 232 * CURSOR_OFF and CURSOR_ON.
237 * CONFIG_VIDEO_SW_CURSOR: Draws a cursor after the last character. No 233 * CONFIG_VIDEO_SW_CURSOR: Draws a cursor after the last character. No
238 * blinking is provided. Uses the macros CURSOR_SET 234 * blinking is provided. Uses the macros CURSOR_SET
239 * and CURSOR_OFF. 235 * and CURSOR_OFF.
240 * CONFIG_VIDEO_HW_CURSOR: Uses the hardware cursor capability of the 236 * CONFIG_VIDEO_HW_CURSOR: Uses the hardware cursor capability of the
241 * graphic chip. Uses the macro CURSOR_SET. 237 * graphic chip. Uses the macro CURSOR_SET.
242 * ATTENTION: If booting an OS, the display driver 238 * ATTENTION: If booting an OS, the display driver
243 * must disable the hardware register of the graphic 239 * must disable the hardware register of the graphic
244 * chip. Otherwise a blinking field is displayed 240 * chip. Otherwise a blinking field is displayed
245 */ 241 */
246 #if !defined(CONFIG_CONSOLE_CURSOR) && \ 242 #if !defined(CONFIG_CONSOLE_CURSOR) && \
247 !defined(CONFIG_VIDEO_SW_CURSOR) && \ 243 !defined(CONFIG_VIDEO_SW_CURSOR) && \
248 !defined(CONFIG_VIDEO_HW_CURSOR) 244 !defined(CONFIG_VIDEO_HW_CURSOR)
249 /* no Cursor defined */ 245 /* no Cursor defined */
250 #define CURSOR_ON 246 #define CURSOR_ON
251 #define CURSOR_OFF 247 #define CURSOR_OFF
252 #define CURSOR_SET 248 #define CURSOR_SET
253 #endif 249 #endif
254 250
255 #if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR) 251 #if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR)
256 #if defined(CURSOR_ON) || \ 252 #if defined(CURSOR_ON) || \
257 (defined(CONFIG_CONSOLE_CURSOR) && defined(CONFIG_VIDEO_SW_CURSOR)) 253 (defined(CONFIG_CONSOLE_CURSOR) && defined(CONFIG_VIDEO_SW_CURSOR))
258 #error only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \ 254 #error only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \
259 or CONFIG_VIDEO_HW_CURSOR can be defined 255 or CONFIG_VIDEO_HW_CURSOR can be defined
260 #endif 256 #endif
261 void console_cursor(int state); 257 void console_cursor(int state);
262 258
263 #define CURSOR_ON console_cursor(1) 259 #define CURSOR_ON console_cursor(1)
264 #define CURSOR_OFF console_cursor(0) 260 #define CURSOR_OFF console_cursor(0)
265 #define CURSOR_SET video_set_cursor() 261 #define CURSOR_SET video_set_cursor()
266 #endif /* CONFIG_CONSOLE_CURSOR || CONFIG_VIDEO_SW_CURSOR */ 262 #endif /* CONFIG_CONSOLE_CURSOR || CONFIG_VIDEO_SW_CURSOR */
267 263
268 #ifdef CONFIG_CONSOLE_CURSOR 264 #ifdef CONFIG_CONSOLE_CURSOR
269 #ifndef CONFIG_CONSOLE_TIME 265 #ifndef CONFIG_CONSOLE_TIME
270 #error CONFIG_CONSOLE_CURSOR must be defined for CONFIG_CONSOLE_TIME 266 #error CONFIG_CONSOLE_CURSOR must be defined for CONFIG_CONSOLE_TIME
271 #endif 267 #endif
272 #ifndef CONFIG_I8042_KBD 268 #ifndef CONFIG_I8042_KBD
273 #warning Cursor drawing on/off needs timer function s.a. drivers/input/i8042.c 269 #warning Cursor drawing on/off needs timer function s.a. drivers/input/i8042.c
274 #endif 270 #endif
275 #endif /* CONFIG_CONSOLE_CURSOR */ 271 #endif /* CONFIG_CONSOLE_CURSOR */
276 272
277 273
278 #ifdef CONFIG_VIDEO_HW_CURSOR 274 #ifdef CONFIG_VIDEO_HW_CURSOR
279 #ifdef CURSOR_ON 275 #ifdef CURSOR_ON
280 #error only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \ 276 #error only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \
281 or CONFIG_VIDEO_HW_CURSOR can be defined 277 or CONFIG_VIDEO_HW_CURSOR can be defined
282 #endif 278 #endif
283 #define CURSOR_ON 279 #define CURSOR_ON
284 #define CURSOR_OFF 280 #define CURSOR_OFF
285 #define CURSOR_SET video_set_hw_cursor(console_col * VIDEO_FONT_WIDTH, \ 281 #define CURSOR_SET video_set_hw_cursor(console_col * VIDEO_FONT_WIDTH, \
286 (console_row * VIDEO_FONT_HEIGHT) + video_logo_height) 282 (console_row * VIDEO_FONT_HEIGHT) + video_logo_height)
287 #endif /* CONFIG_VIDEO_HW_CURSOR */ 283 #endif /* CONFIG_VIDEO_HW_CURSOR */
288 284
289 #ifdef CONFIG_VIDEO_LOGO 285 #ifdef CONFIG_VIDEO_LOGO
290 #ifdef CONFIG_VIDEO_BMP_LOGO 286 #ifdef CONFIG_VIDEO_BMP_LOGO
291 #include <bmp_logo.h> 287 #include <bmp_logo.h>
292 #include <bmp_logo_data.h> 288 #include <bmp_logo_data.h>
293 #define VIDEO_LOGO_WIDTH BMP_LOGO_WIDTH 289 #define VIDEO_LOGO_WIDTH BMP_LOGO_WIDTH
294 #define VIDEO_LOGO_HEIGHT BMP_LOGO_HEIGHT 290 #define VIDEO_LOGO_HEIGHT BMP_LOGO_HEIGHT
295 #define VIDEO_LOGO_LUT_OFFSET BMP_LOGO_OFFSET 291 #define VIDEO_LOGO_LUT_OFFSET BMP_LOGO_OFFSET
296 #define VIDEO_LOGO_COLORS BMP_LOGO_COLORS 292 #define VIDEO_LOGO_COLORS BMP_LOGO_COLORS
297 293
298 #else /* CONFIG_VIDEO_BMP_LOGO */ 294 #else /* CONFIG_VIDEO_BMP_LOGO */
299 #define LINUX_LOGO_WIDTH 80 295 #define LINUX_LOGO_WIDTH 80
300 #define LINUX_LOGO_HEIGHT 80 296 #define LINUX_LOGO_HEIGHT 80
301 #define LINUX_LOGO_COLORS 214 297 #define LINUX_LOGO_COLORS 214
302 #define LINUX_LOGO_LUT_OFFSET 0x20 298 #define LINUX_LOGO_LUT_OFFSET 0x20
303 #define __initdata 299 #define __initdata
304 #include <linux_logo.h> 300 #include <linux_logo.h>
305 #define VIDEO_LOGO_WIDTH LINUX_LOGO_WIDTH 301 #define VIDEO_LOGO_WIDTH LINUX_LOGO_WIDTH
306 #define VIDEO_LOGO_HEIGHT LINUX_LOGO_HEIGHT 302 #define VIDEO_LOGO_HEIGHT LINUX_LOGO_HEIGHT
307 #define VIDEO_LOGO_LUT_OFFSET LINUX_LOGO_LUT_OFFSET 303 #define VIDEO_LOGO_LUT_OFFSET LINUX_LOGO_LUT_OFFSET
308 #define VIDEO_LOGO_COLORS LINUX_LOGO_COLORS 304 #define VIDEO_LOGO_COLORS LINUX_LOGO_COLORS
309 #endif /* CONFIG_VIDEO_BMP_LOGO */ 305 #endif /* CONFIG_VIDEO_BMP_LOGO */
310 #define VIDEO_INFO_X (VIDEO_LOGO_WIDTH) 306 #define VIDEO_INFO_X (VIDEO_LOGO_WIDTH)
311 #define VIDEO_INFO_Y (VIDEO_FONT_HEIGHT/2) 307 #define VIDEO_INFO_Y (VIDEO_FONT_HEIGHT/2)
312 #else /* CONFIG_VIDEO_LOGO */ 308 #else /* CONFIG_VIDEO_LOGO */
313 #define VIDEO_LOGO_WIDTH 0 309 #define VIDEO_LOGO_WIDTH 0
314 #define VIDEO_LOGO_HEIGHT 0 310 #define VIDEO_LOGO_HEIGHT 0
315 #endif /* CONFIG_VIDEO_LOGO */ 311 #endif /* CONFIG_VIDEO_LOGO */
316 312
317 #define VIDEO_COLS VIDEO_VISIBLE_COLS 313 #define VIDEO_COLS VIDEO_VISIBLE_COLS
318 #define VIDEO_ROWS VIDEO_VISIBLE_ROWS 314 #define VIDEO_ROWS VIDEO_VISIBLE_ROWS
319 #define VIDEO_SIZE (VIDEO_ROWS*VIDEO_COLS*VIDEO_PIXEL_SIZE) 315 #define VIDEO_SIZE (VIDEO_ROWS*VIDEO_COLS*VIDEO_PIXEL_SIZE)
320 #define VIDEO_PIX_BLOCKS (VIDEO_SIZE >> 2) 316 #define VIDEO_PIX_BLOCKS (VIDEO_SIZE >> 2)
321 #define VIDEO_LINE_LEN (VIDEO_COLS*VIDEO_PIXEL_SIZE) 317 #define VIDEO_LINE_LEN (VIDEO_COLS*VIDEO_PIXEL_SIZE)
322 #define VIDEO_BURST_LEN (VIDEO_COLS/8) 318 #define VIDEO_BURST_LEN (VIDEO_COLS/8)
323 319
324 #ifdef CONFIG_VIDEO_LOGO 320 #ifdef CONFIG_VIDEO_LOGO
325 #define CONSOLE_ROWS ((VIDEO_ROWS - video_logo_height) / VIDEO_FONT_HEIGHT) 321 #define CONSOLE_ROWS ((VIDEO_ROWS - video_logo_height) / VIDEO_FONT_HEIGHT)
326 #else 322 #else
327 #define CONSOLE_ROWS (VIDEO_ROWS / VIDEO_FONT_HEIGHT) 323 #define CONSOLE_ROWS (VIDEO_ROWS / VIDEO_FONT_HEIGHT)
328 #endif 324 #endif
329 325
330 #define CONSOLE_COLS (VIDEO_COLS / VIDEO_FONT_WIDTH) 326 #define CONSOLE_COLS (VIDEO_COLS / VIDEO_FONT_WIDTH)
331 #define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * VIDEO_LINE_LEN) 327 #define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * VIDEO_LINE_LEN)
332 #define CONSOLE_ROW_FIRST (video_console_address) 328 #define CONSOLE_ROW_FIRST (video_console_address)
333 #define CONSOLE_ROW_SECOND (video_console_address + CONSOLE_ROW_SIZE) 329 #define CONSOLE_ROW_SECOND (video_console_address + CONSOLE_ROW_SIZE)
334 #define CONSOLE_ROW_LAST (video_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE) 330 #define CONSOLE_ROW_LAST (video_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE)
335 #define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS) 331 #define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS)
336 #define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE) 332 #define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE)
337 333
338 /* Macros */ 334 /* Macros */
339 #ifdef VIDEO_FB_LITTLE_ENDIAN 335 #ifdef VIDEO_FB_LITTLE_ENDIAN
340 #define SWAP16(x) ((((x) & 0x00ff) << 8) | \ 336 #define SWAP16(x) ((((x) & 0x00ff) << 8) | \
341 ((x) >> 8) \ 337 ((x) >> 8) \
342 ) 338 )
343 #define SWAP32(x) ((((x) & 0x000000ff) << 24) | \ 339 #define SWAP32(x) ((((x) & 0x000000ff) << 24) | \
344 (((x) & 0x0000ff00) << 8) | \ 340 (((x) & 0x0000ff00) << 8) | \
345 (((x) & 0x00ff0000) >> 8) | \ 341 (((x) & 0x00ff0000) >> 8) | \
346 (((x) & 0xff000000) >> 24) \ 342 (((x) & 0xff000000) >> 24) \
347 ) 343 )
348 #define SHORTSWAP32(x) ((((x) & 0x000000ff) << 8) | \ 344 #define SHORTSWAP32(x) ((((x) & 0x000000ff) << 8) | \
349 (((x) & 0x0000ff00) >> 8) | \ 345 (((x) & 0x0000ff00) >> 8) | \
350 (((x) & 0x00ff0000) << 8) | \ 346 (((x) & 0x00ff0000) << 8) | \
351 (((x) & 0xff000000) >> 8) \ 347 (((x) & 0xff000000) >> 8) \
352 ) 348 )
353 #else 349 #else
354 #define SWAP16(x) (x) 350 #define SWAP16(x) (x)
355 #define SWAP32(x) (x) 351 #define SWAP32(x) (x)
356 #if defined(VIDEO_FB_16BPP_WORD_SWAP) 352 #if defined(VIDEO_FB_16BPP_WORD_SWAP)
357 #define SHORTSWAP32(x) (((x) >> 16) | ((x) << 16)) 353 #define SHORTSWAP32(x) (((x) >> 16) | ((x) << 16))
358 #else 354 #else
359 #define SHORTSWAP32(x) (x) 355 #define SHORTSWAP32(x) (x)
360 #endif 356 #endif
361 #endif 357 #endif
362 358
363 #ifdef CONFIG_CONSOLE_EXTRA_INFO 359 #ifdef CONFIG_CONSOLE_EXTRA_INFO
364 /* 360 /*
365 * setup a board string: type, speed, etc. 361 * setup a board string: type, speed, etc.
366 * 362 *
367 * line_number: location to place info string beside logo 363 * line_number: location to place info string beside logo
368 * info: buffer for info string 364 * info: buffer for info string
369 */ 365 */
370 extern void video_get_info_str(int line_number, char *info); 366 extern void video_get_info_str(int line_number, char *info);
371 #endif 367 #endif
372 368
373 DECLARE_GLOBAL_DATA_PTR; 369 DECLARE_GLOBAL_DATA_PTR;
374 370
375 /* Locals */ 371 /* Locals */
376 static GraphicDevice *pGD; /* Pointer to Graphic array */ 372 static GraphicDevice *pGD; /* Pointer to Graphic array */
377 373
378 static void *video_fb_address; /* frame buffer address */ 374 static void *video_fb_address; /* frame buffer address */
379 static void *video_console_address; /* console buffer start address */ 375 static void *video_console_address; /* console buffer start address */
380 376
381 static int video_logo_height = VIDEO_LOGO_HEIGHT; 377 static int video_logo_height = VIDEO_LOGO_HEIGHT;
382 378
383 static int __maybe_unused cursor_state; 379 static int __maybe_unused cursor_state;
384 static int __maybe_unused old_col; 380 static int __maybe_unused old_col;
385 static int __maybe_unused old_row; 381 static int __maybe_unused old_row;
386 382
387 static int console_col; /* cursor col */ 383 static int console_col; /* cursor col */
388 static int console_row; /* cursor row */ 384 static int console_row; /* cursor row */
389 385
390 static u32 eorx, fgx, bgx; /* color pats */ 386 static u32 eorx, fgx, bgx; /* color pats */
391 387
392 static int cfb_do_flush_cache; 388 static int cfb_do_flush_cache;
393 389
394 #ifdef CONFIG_CFB_CONSOLE_ANSI 390 #ifdef CONFIG_CFB_CONSOLE_ANSI
395 static char ansi_buf[10]; 391 static char ansi_buf[10];
396 static int ansi_buf_size; 392 static int ansi_buf_size;
397 static int ansi_colors_need_revert; 393 static int ansi_colors_need_revert;
398 static int ansi_cursor_hidden; 394 static int ansi_cursor_hidden;
399 #endif 395 #endif
400 396
401 static const int video_font_draw_table8[] = { 397 static const int video_font_draw_table8[] = {
402 0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff, 398 0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff,
403 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff, 399 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff,
404 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff, 400 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff,
405 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff 401 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff
406 }; 402 };
407 403
408 static const int video_font_draw_table15[] = { 404 static const int video_font_draw_table15[] = {
409 0x00000000, 0x00007fff, 0x7fff0000, 0x7fff7fff 405 0x00000000, 0x00007fff, 0x7fff0000, 0x7fff7fff
410 }; 406 };
411 407
412 static const int video_font_draw_table16[] = { 408 static const int video_font_draw_table16[] = {
413 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff 409 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff
414 }; 410 };
415 411
416 static const int video_font_draw_table24[16][3] = { 412 static const int video_font_draw_table24[16][3] = {
417 {0x00000000, 0x00000000, 0x00000000}, 413 {0x00000000, 0x00000000, 0x00000000},
418 {0x00000000, 0x00000000, 0x00ffffff}, 414 {0x00000000, 0x00000000, 0x00ffffff},
419 {0x00000000, 0x0000ffff, 0xff000000}, 415 {0x00000000, 0x0000ffff, 0xff000000},
420 {0x00000000, 0x0000ffff, 0xffffffff}, 416 {0x00000000, 0x0000ffff, 0xffffffff},
421 {0x000000ff, 0xffff0000, 0x00000000}, 417 {0x000000ff, 0xffff0000, 0x00000000},
422 {0x000000ff, 0xffff0000, 0x00ffffff}, 418 {0x000000ff, 0xffff0000, 0x00ffffff},
423 {0x000000ff, 0xffffffff, 0xff000000}, 419 {0x000000ff, 0xffffffff, 0xff000000},
424 {0x000000ff, 0xffffffff, 0xffffffff}, 420 {0x000000ff, 0xffffffff, 0xffffffff},
425 {0xffffff00, 0x00000000, 0x00000000}, 421 {0xffffff00, 0x00000000, 0x00000000},
426 {0xffffff00, 0x00000000, 0x00ffffff}, 422 {0xffffff00, 0x00000000, 0x00ffffff},
427 {0xffffff00, 0x0000ffff, 0xff000000}, 423 {0xffffff00, 0x0000ffff, 0xff000000},
428 {0xffffff00, 0x0000ffff, 0xffffffff}, 424 {0xffffff00, 0x0000ffff, 0xffffffff},
429 {0xffffffff, 0xffff0000, 0x00000000}, 425 {0xffffffff, 0xffff0000, 0x00000000},
430 {0xffffffff, 0xffff0000, 0x00ffffff}, 426 {0xffffffff, 0xffff0000, 0x00ffffff},
431 {0xffffffff, 0xffffffff, 0xff000000}, 427 {0xffffffff, 0xffffffff, 0xff000000},
432 {0xffffffff, 0xffffffff, 0xffffffff} 428 {0xffffffff, 0xffffffff, 0xffffffff}
433 }; 429 };
434 430
435 static const int video_font_draw_table32[16][4] = { 431 static const int video_font_draw_table32[16][4] = {
436 {0x00000000, 0x00000000, 0x00000000, 0x00000000}, 432 {0x00000000, 0x00000000, 0x00000000, 0x00000000},
437 {0x00000000, 0x00000000, 0x00000000, 0x00ffffff}, 433 {0x00000000, 0x00000000, 0x00000000, 0x00ffffff},
438 {0x00000000, 0x00000000, 0x00ffffff, 0x00000000}, 434 {0x00000000, 0x00000000, 0x00ffffff, 0x00000000},
439 {0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff}, 435 {0x00000000, 0x00000000, 0x00ffffff, 0x00ffffff},
440 {0x00000000, 0x00ffffff, 0x00000000, 0x00000000}, 436 {0x00000000, 0x00ffffff, 0x00000000, 0x00000000},
441 {0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff}, 437 {0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff},
442 {0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000}, 438 {0x00000000, 0x00ffffff, 0x00ffffff, 0x00000000},
443 {0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff}, 439 {0x00000000, 0x00ffffff, 0x00ffffff, 0x00ffffff},
444 {0x00ffffff, 0x00000000, 0x00000000, 0x00000000}, 440 {0x00ffffff, 0x00000000, 0x00000000, 0x00000000},
445 {0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff}, 441 {0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff},
446 {0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000}, 442 {0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000},
447 {0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff}, 443 {0x00ffffff, 0x00000000, 0x00ffffff, 0x00ffffff},
448 {0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000}, 444 {0x00ffffff, 0x00ffffff, 0x00000000, 0x00000000},
449 {0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff}, 445 {0x00ffffff, 0x00ffffff, 0x00000000, 0x00ffffff},
450 {0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000}, 446 {0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00000000},
451 {0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff} 447 {0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff}
452 }; 448 };
453 449
454 static void video_drawchars(int xx, int yy, unsigned char *s, int count) 450 static void video_drawchars(int xx, int yy, unsigned char *s, int count)
455 { 451 {
456 u8 *cdat, *dest, *dest0; 452 u8 *cdat, *dest, *dest0;
457 int rows, offset, c; 453 int rows, offset, c;
458 454
459 offset = yy * VIDEO_LINE_LEN + xx * VIDEO_PIXEL_SIZE; 455 offset = yy * VIDEO_LINE_LEN + xx * VIDEO_PIXEL_SIZE;
460 dest0 = video_fb_address + offset; 456 dest0 = video_fb_address + offset;
461 457
462 switch (VIDEO_DATA_FORMAT) { 458 switch (VIDEO_DATA_FORMAT) {
463 case GDF__8BIT_INDEX: 459 case GDF__8BIT_INDEX:
464 case GDF__8BIT_332RGB: 460 case GDF__8BIT_332RGB:
465 while (count--) { 461 while (count--) {
466 c = *s; 462 c = *s;
467 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT; 463 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
468 for (rows = VIDEO_FONT_HEIGHT, dest = dest0; 464 for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
469 rows--; dest += VIDEO_LINE_LEN) { 465 rows--; dest += VIDEO_LINE_LEN) {
470 u8 bits = *cdat++; 466 u8 bits = *cdat++;
471 467
472 ((u32 *) dest)[0] = 468 ((u32 *) dest)[0] =
473 (video_font_draw_table8[bits >> 4] & 469 (video_font_draw_table8[bits >> 4] &
474 eorx) ^ bgx; 470 eorx) ^ bgx;
475 ((u32 *) dest)[1] = 471 ((u32 *) dest)[1] =
476 (video_font_draw_table8[bits & 15] & 472 (video_font_draw_table8[bits & 15] &
477 eorx) ^ bgx; 473 eorx) ^ bgx;
478 } 474 }
479 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE; 475 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
480 s++; 476 s++;
481 } 477 }
482 break; 478 break;
483 479
484 case GDF_15BIT_555RGB: 480 case GDF_15BIT_555RGB:
485 while (count--) { 481 while (count--) {
486 c = *s; 482 c = *s;
487 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT; 483 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
488 for (rows = VIDEO_FONT_HEIGHT, dest = dest0; 484 for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
489 rows--; dest += VIDEO_LINE_LEN) { 485 rows--; dest += VIDEO_LINE_LEN) {
490 u8 bits = *cdat++; 486 u8 bits = *cdat++;
491 487
492 ((u32 *) dest)[0] = 488 ((u32 *) dest)[0] =
493 SHORTSWAP32((video_font_draw_table15 489 SHORTSWAP32((video_font_draw_table15
494 [bits >> 6] & eorx) ^ 490 [bits >> 6] & eorx) ^
495 bgx); 491 bgx);
496 ((u32 *) dest)[1] = 492 ((u32 *) dest)[1] =
497 SHORTSWAP32((video_font_draw_table15 493 SHORTSWAP32((video_font_draw_table15
498 [bits >> 4 & 3] & eorx) ^ 494 [bits >> 4 & 3] & eorx) ^
499 bgx); 495 bgx);
500 ((u32 *) dest)[2] = 496 ((u32 *) dest)[2] =
501 SHORTSWAP32((video_font_draw_table15 497 SHORTSWAP32((video_font_draw_table15
502 [bits >> 2 & 3] & eorx) ^ 498 [bits >> 2 & 3] & eorx) ^
503 bgx); 499 bgx);
504 ((u32 *) dest)[3] = 500 ((u32 *) dest)[3] =
505 SHORTSWAP32((video_font_draw_table15 501 SHORTSWAP32((video_font_draw_table15
506 [bits & 3] & eorx) ^ 502 [bits & 3] & eorx) ^
507 bgx); 503 bgx);
508 } 504 }
509 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE; 505 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
510 s++; 506 s++;
511 } 507 }
512 break; 508 break;
513 509
514 case GDF_16BIT_565RGB: 510 case GDF_16BIT_565RGB:
515 while (count--) { 511 while (count--) {
516 c = *s; 512 c = *s;
517 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT; 513 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
518 for (rows = VIDEO_FONT_HEIGHT, dest = dest0; 514 for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
519 rows--; dest += VIDEO_LINE_LEN) { 515 rows--; dest += VIDEO_LINE_LEN) {
520 u8 bits = *cdat++; 516 u8 bits = *cdat++;
521 517
522 ((u32 *) dest)[0] = 518 ((u32 *) dest)[0] =
523 SHORTSWAP32((video_font_draw_table16 519 SHORTSWAP32((video_font_draw_table16
524 [bits >> 6] & eorx) ^ 520 [bits >> 6] & eorx) ^
525 bgx); 521 bgx);
526 ((u32 *) dest)[1] = 522 ((u32 *) dest)[1] =
527 SHORTSWAP32((video_font_draw_table16 523 SHORTSWAP32((video_font_draw_table16
528 [bits >> 4 & 3] & eorx) ^ 524 [bits >> 4 & 3] & eorx) ^
529 bgx); 525 bgx);
530 ((u32 *) dest)[2] = 526 ((u32 *) dest)[2] =
531 SHORTSWAP32((video_font_draw_table16 527 SHORTSWAP32((video_font_draw_table16
532 [bits >> 2 & 3] & eorx) ^ 528 [bits >> 2 & 3] & eorx) ^
533 bgx); 529 bgx);
534 ((u32 *) dest)[3] = 530 ((u32 *) dest)[3] =
535 SHORTSWAP32((video_font_draw_table16 531 SHORTSWAP32((video_font_draw_table16
536 [bits & 3] & eorx) ^ 532 [bits & 3] & eorx) ^
537 bgx); 533 bgx);
538 } 534 }
539 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE; 535 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
540 s++; 536 s++;
541 } 537 }
542 break; 538 break;
543 539
544 case GDF_32BIT_X888RGB: 540 case GDF_32BIT_X888RGB:
545 while (count--) { 541 while (count--) {
546 c = *s; 542 c = *s;
547 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT; 543 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
548 for (rows = VIDEO_FONT_HEIGHT, dest = dest0; 544 for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
549 rows--; dest += VIDEO_LINE_LEN) { 545 rows--; dest += VIDEO_LINE_LEN) {
550 u8 bits = *cdat++; 546 u8 bits = *cdat++;
551 547
552 ((u32 *) dest)[0] = 548 ((u32 *) dest)[0] =
553 SWAP32((video_font_draw_table32 549 SWAP32((video_font_draw_table32
554 [bits >> 4][0] & eorx) ^ bgx); 550 [bits >> 4][0] & eorx) ^ bgx);
555 ((u32 *) dest)[1] = 551 ((u32 *) dest)[1] =
556 SWAP32((video_font_draw_table32 552 SWAP32((video_font_draw_table32
557 [bits >> 4][1] & eorx) ^ bgx); 553 [bits >> 4][1] & eorx) ^ bgx);
558 ((u32 *) dest)[2] = 554 ((u32 *) dest)[2] =
559 SWAP32((video_font_draw_table32 555 SWAP32((video_font_draw_table32
560 [bits >> 4][2] & eorx) ^ bgx); 556 [bits >> 4][2] & eorx) ^ bgx);
561 ((u32 *) dest)[3] = 557 ((u32 *) dest)[3] =
562 SWAP32((video_font_draw_table32 558 SWAP32((video_font_draw_table32
563 [bits >> 4][3] & eorx) ^ bgx); 559 [bits >> 4][3] & eorx) ^ bgx);
564 ((u32 *) dest)[4] = 560 ((u32 *) dest)[4] =
565 SWAP32((video_font_draw_table32 561 SWAP32((video_font_draw_table32
566 [bits & 15][0] & eorx) ^ bgx); 562 [bits & 15][0] & eorx) ^ bgx);
567 ((u32 *) dest)[5] = 563 ((u32 *) dest)[5] =
568 SWAP32((video_font_draw_table32 564 SWAP32((video_font_draw_table32
569 [bits & 15][1] & eorx) ^ bgx); 565 [bits & 15][1] & eorx) ^ bgx);
570 ((u32 *) dest)[6] = 566 ((u32 *) dest)[6] =
571 SWAP32((video_font_draw_table32 567 SWAP32((video_font_draw_table32
572 [bits & 15][2] & eorx) ^ bgx); 568 [bits & 15][2] & eorx) ^ bgx);
573 ((u32 *) dest)[7] = 569 ((u32 *) dest)[7] =
574 SWAP32((video_font_draw_table32 570 SWAP32((video_font_draw_table32
575 [bits & 15][3] & eorx) ^ bgx); 571 [bits & 15][3] & eorx) ^ bgx);
576 } 572 }
577 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE; 573 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
578 s++; 574 s++;
579 } 575 }
580 break; 576 break;
581 577
582 case GDF_24BIT_888RGB: 578 case GDF_24BIT_888RGB:
583 while (count--) { 579 while (count--) {
584 c = *s; 580 c = *s;
585 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT; 581 cdat = video_fontdata + c * VIDEO_FONT_HEIGHT;
586 for (rows = VIDEO_FONT_HEIGHT, dest = dest0; 582 for (rows = VIDEO_FONT_HEIGHT, dest = dest0;
587 rows--; dest += VIDEO_LINE_LEN) { 583 rows--; dest += VIDEO_LINE_LEN) {
588 u8 bits = *cdat++; 584 u8 bits = *cdat++;
589 585
590 ((u32 *) dest)[0] = 586 ((u32 *) dest)[0] =
591 (video_font_draw_table24[bits >> 4][0] 587 (video_font_draw_table24[bits >> 4][0]
592 & eorx) ^ bgx; 588 & eorx) ^ bgx;
593 ((u32 *) dest)[1] = 589 ((u32 *) dest)[1] =
594 (video_font_draw_table24[bits >> 4][1] 590 (video_font_draw_table24[bits >> 4][1]
595 & eorx) ^ bgx; 591 & eorx) ^ bgx;
596 ((u32 *) dest)[2] = 592 ((u32 *) dest)[2] =
597 (video_font_draw_table24[bits >> 4][2] 593 (video_font_draw_table24[bits >> 4][2]
598 & eorx) ^ bgx; 594 & eorx) ^ bgx;
599 ((u32 *) dest)[3] = 595 ((u32 *) dest)[3] =
600 (video_font_draw_table24[bits & 15][0] 596 (video_font_draw_table24[bits & 15][0]
601 & eorx) ^ bgx; 597 & eorx) ^ bgx;
602 ((u32 *) dest)[4] = 598 ((u32 *) dest)[4] =
603 (video_font_draw_table24[bits & 15][1] 599 (video_font_draw_table24[bits & 15][1]
604 & eorx) ^ bgx; 600 & eorx) ^ bgx;
605 ((u32 *) dest)[5] = 601 ((u32 *) dest)[5] =
606 (video_font_draw_table24[bits & 15][2] 602 (video_font_draw_table24[bits & 15][2]
607 & eorx) ^ bgx; 603 & eorx) ^ bgx;
608 } 604 }
609 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE; 605 dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
610 s++; 606 s++;
611 } 607 }
612 break; 608 break;
613 } 609 }
614 } 610 }
615 611
616 static inline void video_drawstring(int xx, int yy, unsigned char *s) 612 static inline void video_drawstring(int xx, int yy, unsigned char *s)
617 { 613 {
618 video_drawchars(xx, yy, s, strlen((char *) s)); 614 video_drawchars(xx, yy, s, strlen((char *) s));
619 } 615 }
620 616
621 static void video_putchar(int xx, int yy, unsigned char c) 617 static void video_putchar(int xx, int yy, unsigned char c)
622 { 618 {
623 video_drawchars(xx, yy + video_logo_height, &c, 1); 619 video_drawchars(xx, yy + video_logo_height, &c, 1);
624 } 620 }
625 621
626 #if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR) 622 #if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR)
627 static void video_set_cursor(void) 623 static void video_set_cursor(void)
628 { 624 {
629 if (cursor_state) 625 if (cursor_state)
630 console_cursor(0); 626 console_cursor(0);
631 console_cursor(1); 627 console_cursor(1);
632 } 628 }
633 629
634 static void video_invertchar(int xx, int yy) 630 static void video_invertchar(int xx, int yy)
635 { 631 {
636 int firstx = xx * VIDEO_PIXEL_SIZE; 632 int firstx = xx * VIDEO_PIXEL_SIZE;
637 int lastx = (xx + VIDEO_FONT_WIDTH) * VIDEO_PIXEL_SIZE; 633 int lastx = (xx + VIDEO_FONT_WIDTH) * VIDEO_PIXEL_SIZE;
638 int firsty = yy * VIDEO_LINE_LEN; 634 int firsty = yy * VIDEO_LINE_LEN;
639 int lasty = (yy + VIDEO_FONT_HEIGHT) * VIDEO_LINE_LEN; 635 int lasty = (yy + VIDEO_FONT_HEIGHT) * VIDEO_LINE_LEN;
640 int x, y; 636 int x, y;
641 for (y = firsty; y < lasty; y += VIDEO_LINE_LEN) { 637 for (y = firsty; y < lasty; y += VIDEO_LINE_LEN) {
642 for (x = firstx; x < lastx; x++) { 638 for (x = firstx; x < lastx; x++) {
643 u8 *dest = (u8 *)(video_fb_address) + x + y; 639 u8 *dest = (u8 *)(video_fb_address) + x + y;
644 *dest = ~*dest; 640 *dest = ~*dest;
645 } 641 }
646 } 642 }
647 } 643 }
648 644
649 void console_cursor(int state) 645 void console_cursor(int state)
650 { 646 {
651 #ifdef CONFIG_CONSOLE_TIME 647 #ifdef CONFIG_CONSOLE_TIME
652 struct rtc_time tm; 648 struct rtc_time tm;
653 char info[16]; 649 char info[16];
654 650
655 /* time update only if cursor is on (faster scroll) */ 651 /* time update only if cursor is on (faster scroll) */
656 if (state) { 652 if (state) {
657 rtc_get(&tm); 653 rtc_get(&tm);
658 654
659 sprintf(info, " %02d:%02d:%02d ", tm.tm_hour, tm.tm_min, 655 sprintf(info, " %02d:%02d:%02d ", tm.tm_hour, tm.tm_min,
660 tm.tm_sec); 656 tm.tm_sec);
661 video_drawstring(VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH, 657 video_drawstring(VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH,
662 VIDEO_INFO_Y, (uchar *) info); 658 VIDEO_INFO_Y, (uchar *) info);
663 659
664 sprintf(info, "%02d.%02d.%04d", tm.tm_mday, tm.tm_mon, 660 sprintf(info, "%02d.%02d.%04d", tm.tm_mday, tm.tm_mon,
665 tm.tm_year); 661 tm.tm_year);
666 video_drawstring(VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH, 662 video_drawstring(VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH,
667 VIDEO_INFO_Y + 1 * VIDEO_FONT_HEIGHT, 663 VIDEO_INFO_Y + 1 * VIDEO_FONT_HEIGHT,
668 (uchar *) info); 664 (uchar *) info);
669 } 665 }
670 #endif 666 #endif
671 667
672 if (cursor_state != state) { 668 if (cursor_state != state) {
673 if (cursor_state) { 669 if (cursor_state) {
674 /* turn off the cursor */ 670 /* turn off the cursor */
675 video_invertchar(old_col * VIDEO_FONT_WIDTH, 671 video_invertchar(old_col * VIDEO_FONT_WIDTH,
676 old_row * VIDEO_FONT_HEIGHT + 672 old_row * VIDEO_FONT_HEIGHT +
677 video_logo_height); 673 video_logo_height);
678 } else { 674 } else {
679 /* turn off the cursor and record where it is */ 675 /* turn off the cursor and record where it is */
680 video_invertchar(console_col * VIDEO_FONT_WIDTH, 676 video_invertchar(console_col * VIDEO_FONT_WIDTH,
681 console_row * VIDEO_FONT_HEIGHT + 677 console_row * VIDEO_FONT_HEIGHT +
682 video_logo_height); 678 video_logo_height);
683 old_col = console_col; 679 old_col = console_col;
684 old_row = console_row; 680 old_row = console_row;
685 } 681 }
686 cursor_state = state; 682 cursor_state = state;
687 } 683 }
688 if (cfb_do_flush_cache) 684 if (cfb_do_flush_cache)
689 flush_cache(VIDEO_FB_ADRS, VIDEO_SIZE); 685 flush_cache(VIDEO_FB_ADRS, VIDEO_SIZE);
690 } 686 }
691 #endif 687 #endif
692 688
693 #ifndef VIDEO_HW_RECTFILL 689 #ifndef VIDEO_HW_RECTFILL
694 static void memsetl(int *p, int c, int v) 690 static void memsetl(int *p, int c, int v)
695 { 691 {
696 while (c--) 692 while (c--)
697 *(p++) = v; 693 *(p++) = v;
698 } 694 }
699 #endif 695 #endif
700 696
701 #ifndef VIDEO_HW_BITBLT 697 #ifndef VIDEO_HW_BITBLT
702 static void memcpyl(int *d, int *s, int c) 698 static void memcpyl(int *d, int *s, int c)
703 { 699 {
704 while (c--) 700 while (c--)
705 *(d++) = *(s++); 701 *(d++) = *(s++);
706 } 702 }
707 #endif 703 #endif
708 704
709 static void console_clear_line(int line, int begin, int end) 705 static void console_clear_line(int line, int begin, int end)
710 { 706 {
711 #ifdef VIDEO_HW_RECTFILL 707 #ifdef VIDEO_HW_RECTFILL
712 video_hw_rectfill(VIDEO_PIXEL_SIZE, /* bytes per pixel */ 708 video_hw_rectfill(VIDEO_PIXEL_SIZE, /* bytes per pixel */
713 VIDEO_FONT_WIDTH * begin, /* dest pos x */ 709 VIDEO_FONT_WIDTH * begin, /* dest pos x */
714 video_logo_height + 710 video_logo_height +
715 VIDEO_FONT_HEIGHT * line, /* dest pos y */ 711 VIDEO_FONT_HEIGHT * line, /* dest pos y */
716 VIDEO_FONT_WIDTH * (end - begin + 1), /* fr. width */ 712 VIDEO_FONT_WIDTH * (end - begin + 1), /* fr. width */
717 VIDEO_FONT_HEIGHT, /* frame height */ 713 VIDEO_FONT_HEIGHT, /* frame height */
718 bgx /* fill color */ 714 bgx /* fill color */
719 ); 715 );
720 #else 716 #else
721 if (begin == 0 && (end + 1) == CONSOLE_COLS) { 717 if (begin == 0 && (end + 1) == CONSOLE_COLS) {
722 memsetl(CONSOLE_ROW_FIRST + 718 memsetl(CONSOLE_ROW_FIRST +
723 CONSOLE_ROW_SIZE * line, /* offset of row */ 719 CONSOLE_ROW_SIZE * line, /* offset of row */
724 CONSOLE_ROW_SIZE >> 2, /* length of row */ 720 CONSOLE_ROW_SIZE >> 2, /* length of row */
725 bgx /* fill color */ 721 bgx /* fill color */
726 ); 722 );
727 } else { 723 } else {
728 void *offset; 724 void *offset;
729 int i, size; 725 int i, size;
730 726
731 offset = CONSOLE_ROW_FIRST + 727 offset = CONSOLE_ROW_FIRST +
732 CONSOLE_ROW_SIZE * line + /* offset of row */ 728 CONSOLE_ROW_SIZE * line + /* offset of row */
733 VIDEO_FONT_WIDTH * 729 VIDEO_FONT_WIDTH *
734 VIDEO_PIXEL_SIZE * begin; /* offset of col */ 730 VIDEO_PIXEL_SIZE * begin; /* offset of col */
735 size = VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE * (end - begin + 1); 731 size = VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE * (end - begin + 1);
736 size >>= 2; /* length to end for memsetl() */ 732 size >>= 2; /* length to end for memsetl() */
737 /* fill at col offset of i'th line using bgx as fill color */ 733 /* fill at col offset of i'th line using bgx as fill color */
738 for (i = 0; i < VIDEO_FONT_HEIGHT; i++) 734 for (i = 0; i < VIDEO_FONT_HEIGHT; i++)
739 memsetl(offset + i * VIDEO_LINE_LEN, size, bgx); 735 memsetl(offset + i * VIDEO_LINE_LEN, size, bgx);
740 } 736 }
741 #endif 737 #endif
742 } 738 }
743 739
744 static void console_scrollup(void) 740 static void console_scrollup(void)
745 { 741 {
746 /* copy up rows ignoring the first one */ 742 /* copy up rows ignoring the first one */
747 743
748 #ifdef VIDEO_HW_BITBLT 744 #ifdef VIDEO_HW_BITBLT
749 video_hw_bitblt(VIDEO_PIXEL_SIZE, /* bytes per pixel */ 745 video_hw_bitblt(VIDEO_PIXEL_SIZE, /* bytes per pixel */
750 0, /* source pos x */ 746 0, /* source pos x */
751 video_logo_height + 747 video_logo_height +
752 VIDEO_FONT_HEIGHT, /* source pos y */ 748 VIDEO_FONT_HEIGHT, /* source pos y */
753 0, /* dest pos x */ 749 0, /* dest pos x */
754 video_logo_height, /* dest pos y */ 750 video_logo_height, /* dest pos y */
755 VIDEO_VISIBLE_COLS, /* frame width */ 751 VIDEO_VISIBLE_COLS, /* frame width */
756 VIDEO_VISIBLE_ROWS 752 VIDEO_VISIBLE_ROWS
757 - video_logo_height 753 - video_logo_height
758 - VIDEO_FONT_HEIGHT /* frame height */ 754 - VIDEO_FONT_HEIGHT /* frame height */
759 ); 755 );
760 #else 756 #else
761 memcpyl(CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, 757 memcpyl(CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND,
762 CONSOLE_SCROLL_SIZE >> 2); 758 CONSOLE_SCROLL_SIZE >> 2);
763 #endif 759 #endif
764 /* clear the last one */ 760 /* clear the last one */
765 console_clear_line(CONSOLE_ROWS - 1, 0, CONSOLE_COLS - 1); 761 console_clear_line(CONSOLE_ROWS - 1, 0, CONSOLE_COLS - 1);
766 } 762 }
767 763
768 static void console_back(void) 764 static void console_back(void)
769 { 765 {
770 console_col--; 766 console_col--;
771 767
772 if (console_col < 0) { 768 if (console_col < 0) {
773 console_col = CONSOLE_COLS - 1; 769 console_col = CONSOLE_COLS - 1;
774 console_row--; 770 console_row--;
775 if (console_row < 0) 771 if (console_row < 0)
776 console_row = 0; 772 console_row = 0;
777 } 773 }
778 } 774 }
779 775
780 #ifdef CONFIG_CFB_CONSOLE_ANSI 776 #ifdef CONFIG_CFB_CONSOLE_ANSI
781 777
782 static void console_clear(void) 778 static void console_clear(void)
783 { 779 {
784 #ifdef VIDEO_HW_RECTFILL 780 #ifdef VIDEO_HW_RECTFILL
785 video_hw_rectfill(VIDEO_PIXEL_SIZE, /* bytes per pixel */ 781 video_hw_rectfill(VIDEO_PIXEL_SIZE, /* bytes per pixel */
786 0, /* dest pos x */ 782 0, /* dest pos x */
787 video_logo_height, /* dest pos y */ 783 video_logo_height, /* dest pos y */
788 VIDEO_VISIBLE_COLS, /* frame width */ 784 VIDEO_VISIBLE_COLS, /* frame width */
789 VIDEO_VISIBLE_ROWS, /* frame height */ 785 VIDEO_VISIBLE_ROWS, /* frame height */
790 bgx /* fill color */ 786 bgx /* fill color */
791 ); 787 );
792 #else 788 #else
793 memsetl(CONSOLE_ROW_FIRST, CONSOLE_SIZE, bgx); 789 memsetl(CONSOLE_ROW_FIRST, CONSOLE_SIZE, bgx);
794 #endif 790 #endif
795 } 791 }
796 792
797 static void console_cursor_fix(void) 793 static void console_cursor_fix(void)
798 { 794 {
799 if (console_row < 0) 795 if (console_row < 0)
800 console_row = 0; 796 console_row = 0;
801 if (console_row >= CONSOLE_ROWS) 797 if (console_row >= CONSOLE_ROWS)
802 console_row = CONSOLE_ROWS - 1; 798 console_row = CONSOLE_ROWS - 1;
803 if (console_col < 0) 799 if (console_col < 0)
804 console_col = 0; 800 console_col = 0;
805 if (console_col >= CONSOLE_COLS) 801 if (console_col >= CONSOLE_COLS)
806 console_col = CONSOLE_COLS - 1; 802 console_col = CONSOLE_COLS - 1;
807 } 803 }
808 804
809 static void console_cursor_up(int n) 805 static void console_cursor_up(int n)
810 { 806 {
811 console_row -= n; 807 console_row -= n;
812 console_cursor_fix(); 808 console_cursor_fix();
813 } 809 }
814 810
815 static void console_cursor_down(int n) 811 static void console_cursor_down(int n)
816 { 812 {
817 console_row += n; 813 console_row += n;
818 console_cursor_fix(); 814 console_cursor_fix();
819 } 815 }
820 816
821 static void console_cursor_left(int n) 817 static void console_cursor_left(int n)
822 { 818 {
823 console_col -= n; 819 console_col -= n;
824 console_cursor_fix(); 820 console_cursor_fix();
825 } 821 }
826 822
827 static void console_cursor_right(int n) 823 static void console_cursor_right(int n)
828 { 824 {
829 console_col += n; 825 console_col += n;
830 console_cursor_fix(); 826 console_cursor_fix();
831 } 827 }
832 828
833 static void console_cursor_set_position(int row, int col) 829 static void console_cursor_set_position(int row, int col)
834 { 830 {
835 if (console_row != -1) 831 if (console_row != -1)
836 console_row = row; 832 console_row = row;
837 if (console_col != -1) 833 if (console_col != -1)
838 console_col = col; 834 console_col = col;
839 console_cursor_fix(); 835 console_cursor_fix();
840 } 836 }
841 837
842 static void console_previousline(int n) 838 static void console_previousline(int n)
843 { 839 {
844 /* FIXME: also scroll terminal ? */ 840 /* FIXME: also scroll terminal ? */
845 console_row -= n; 841 console_row -= n;
846 console_cursor_fix(); 842 console_cursor_fix();
847 } 843 }
848 844
849 static void console_swap_colors(void) 845 static void console_swap_colors(void)
850 { 846 {
851 eorx = fgx; 847 eorx = fgx;
852 fgx = bgx; 848 fgx = bgx;
853 bgx = eorx; 849 bgx = eorx;
854 eorx = fgx ^ bgx; 850 eorx = fgx ^ bgx;
855 } 851 }
856 852
857 static inline int console_cursor_is_visible(void) 853 static inline int console_cursor_is_visible(void)
858 { 854 {
859 return !ansi_cursor_hidden; 855 return !ansi_cursor_hidden;
860 } 856 }
861 #else 857 #else
862 static inline int console_cursor_is_visible(void) 858 static inline int console_cursor_is_visible(void)
863 { 859 {
864 return 1; 860 return 1;
865 } 861 }
866 #endif 862 #endif
867 863
868 static void console_newline(int n) 864 static void console_newline(int n)
869 { 865 {
870 console_row += n; 866 console_row += n;
871 console_col = 0; 867 console_col = 0;
872 868
873 /* Check if we need to scroll the terminal */ 869 /* Check if we need to scroll the terminal */
874 if (console_row >= CONSOLE_ROWS) { 870 if (console_row >= CONSOLE_ROWS) {
875 /* Scroll everything up */ 871 /* Scroll everything up */
876 console_scrollup(); 872 console_scrollup();
877 873
878 /* Decrement row number */ 874 /* Decrement row number */
879 console_row = CONSOLE_ROWS - 1; 875 console_row = CONSOLE_ROWS - 1;
880 } 876 }
881 } 877 }
882 878
883 static void console_cr(void) 879 static void console_cr(void)
884 { 880 {
885 console_col = 0; 881 console_col = 0;
886 } 882 }
887 883
888 static void parse_putc(const char c) 884 static void parse_putc(const char c)
889 { 885 {
890 static int nl = 1; 886 static int nl = 1;
891 887
892 if (console_cursor_is_visible()) 888 if (console_cursor_is_visible())
893 CURSOR_OFF; 889 CURSOR_OFF;
894 890
895 switch (c) { 891 switch (c) {
896 case 13: /* back to first column */ 892 case 13: /* back to first column */
897 console_cr(); 893 console_cr();
898 break; 894 break;
899 895
900 case '\n': /* next line */ 896 case '\n': /* next line */
901 if (console_col || (!console_col && nl)) 897 if (console_col || (!console_col && nl))
902 console_newline(1); 898 console_newline(1);
903 nl = 1; 899 nl = 1;
904 break; 900 break;
905 901
906 case 9: /* tab 8 */ 902 case 9: /* tab 8 */
907 console_col |= 0x0008; 903 console_col |= 0x0008;
908 console_col &= ~0x0007; 904 console_col &= ~0x0007;
909 905
910 if (console_col >= CONSOLE_COLS) 906 if (console_col >= CONSOLE_COLS)
911 console_newline(1); 907 console_newline(1);
912 break; 908 break;
913 909
914 case 8: /* backspace */ 910 case 8: /* backspace */
915 console_back(); 911 console_back();
916 break; 912 break;
917 913
918 case 7: /* bell */ 914 case 7: /* bell */
919 break; /* ignored */ 915 break; /* ignored */
920 916
921 default: /* draw the char */ 917 default: /* draw the char */
922 video_putchar(console_col * VIDEO_FONT_WIDTH, 918 video_putchar(console_col * VIDEO_FONT_WIDTH,
923 console_row * VIDEO_FONT_HEIGHT, c); 919 console_row * VIDEO_FONT_HEIGHT, c);
924 console_col++; 920 console_col++;
925 921
926 /* check for newline */ 922 /* check for newline */
927 if (console_col >= CONSOLE_COLS) { 923 if (console_col >= CONSOLE_COLS) {
928 console_newline(1); 924 console_newline(1);
929 nl = 0; 925 nl = 0;
930 } 926 }
931 } 927 }
932 928
933 if (console_cursor_is_visible()) 929 if (console_cursor_is_visible())
934 CURSOR_SET; 930 CURSOR_SET;
935 } 931 }
936 932
937 void video_putc(const char c) 933 void video_putc(const char c)
938 { 934 {
939 #ifdef CONFIG_CFB_CONSOLE_ANSI 935 #ifdef CONFIG_CFB_CONSOLE_ANSI
940 int i; 936 int i;
941 937
942 if (c == 27) { 938 if (c == 27) {
943 for (i = 0; i < ansi_buf_size; ++i) 939 for (i = 0; i < ansi_buf_size; ++i)
944 parse_putc(ansi_buf[i]); 940 parse_putc(ansi_buf[i]);
945 ansi_buf[0] = 27; 941 ansi_buf[0] = 27;
946 ansi_buf_size = 1; 942 ansi_buf_size = 1;
947 return; 943 return;
948 } 944 }
949 945
950 if (ansi_buf_size > 0) { 946 if (ansi_buf_size > 0) {
951 /* 947 /*
952 * 0 - ESC 948 * 0 - ESC
953 * 1 - [ 949 * 1 - [
954 * 2 - num1 950 * 2 - num1
955 * 3 - .. 951 * 3 - ..
956 * 4 - ; 952 * 4 - ;
957 * 5 - num2 953 * 5 - num2
958 * 6 - .. 954 * 6 - ..
959 * - cchar 955 * - cchar
960 */ 956 */
961 int next = 0; 957 int next = 0;
962 958
963 int flush = 0; 959 int flush = 0;
964 int fail = 0; 960 int fail = 0;
965 961
966 int num1 = 0; 962 int num1 = 0;
967 int num2 = 0; 963 int num2 = 0;
968 int cchar = 0; 964 int cchar = 0;
969 965
970 ansi_buf[ansi_buf_size++] = c; 966 ansi_buf[ansi_buf_size++] = c;
971 967
972 if (ansi_buf_size >= sizeof(ansi_buf)) 968 if (ansi_buf_size >= sizeof(ansi_buf))
973 fail = 1; 969 fail = 1;
974 970
975 for (i = 0; i < ansi_buf_size; ++i) { 971 for (i = 0; i < ansi_buf_size; ++i) {
976 if (fail) 972 if (fail)
977 break; 973 break;
978 974
979 switch (next) { 975 switch (next) {
980 case 0: 976 case 0:
981 if (ansi_buf[i] == 27) 977 if (ansi_buf[i] == 27)
982 next = 1; 978 next = 1;
983 else 979 else
984 fail = 1; 980 fail = 1;
985 break; 981 break;
986 982
987 case 1: 983 case 1:
988 if (ansi_buf[i] == '[') 984 if (ansi_buf[i] == '[')
989 next = 2; 985 next = 2;
990 else 986 else
991 fail = 1; 987 fail = 1;
992 break; 988 break;
993 989
994 case 2: 990 case 2:
995 if (ansi_buf[i] >= '0' && ansi_buf[i] <= '9') { 991 if (ansi_buf[i] >= '0' && ansi_buf[i] <= '9') {
996 num1 = ansi_buf[i]-'0'; 992 num1 = ansi_buf[i]-'0';
997 next = 3; 993 next = 3;
998 } else if (ansi_buf[i] != '?') { 994 } else if (ansi_buf[i] != '?') {
999 --i; 995 --i;
1000 num1 = 1; 996 num1 = 1;
1001 next = 4; 997 next = 4;
1002 } 998 }
1003 break; 999 break;
1004 1000
1005 case 3: 1001 case 3:
1006 if (ansi_buf[i] >= '0' && ansi_buf[i] <= '9') { 1002 if (ansi_buf[i] >= '0' && ansi_buf[i] <= '9') {
1007 num1 *= 10; 1003 num1 *= 10;
1008 num1 += ansi_buf[i]-'0'; 1004 num1 += ansi_buf[i]-'0';
1009 } else { 1005 } else {
1010 --i; 1006 --i;
1011 next = 4; 1007 next = 4;
1012 } 1008 }
1013 break; 1009 break;
1014 1010
1015 case 4: 1011 case 4:
1016 if (ansi_buf[i] != ';') { 1012 if (ansi_buf[i] != ';') {
1017 --i; 1013 --i;
1018 next = 7; 1014 next = 7;
1019 } else 1015 } else
1020 next = 5; 1016 next = 5;
1021 break; 1017 break;
1022 1018
1023 case 5: 1019 case 5:
1024 if (ansi_buf[i] >= '0' && ansi_buf[i] <= '9') { 1020 if (ansi_buf[i] >= '0' && ansi_buf[i] <= '9') {
1025 num2 = ansi_buf[i]-'0'; 1021 num2 = ansi_buf[i]-'0';
1026 next = 6; 1022 next = 6;
1027 } else 1023 } else
1028 fail = 1; 1024 fail = 1;
1029 break; 1025 break;
1030 1026
1031 case 6: 1027 case 6:
1032 if (ansi_buf[i] >= '0' && ansi_buf[i] <= '9') { 1028 if (ansi_buf[i] >= '0' && ansi_buf[i] <= '9') {
1033 num2 *= 10; 1029 num2 *= 10;
1034 num2 += ansi_buf[i]-'0'; 1030 num2 += ansi_buf[i]-'0';
1035 } else { 1031 } else {
1036 --i; 1032 --i;
1037 next = 7; 1033 next = 7;
1038 } 1034 }
1039 break; 1035 break;
1040 1036
1041 case 7: 1037 case 7:
1042 if ((ansi_buf[i] >= 'A' && ansi_buf[i] <= 'H') 1038 if ((ansi_buf[i] >= 'A' && ansi_buf[i] <= 'H')
1043 || ansi_buf[i] == 'J' 1039 || ansi_buf[i] == 'J'
1044 || ansi_buf[i] == 'K' 1040 || ansi_buf[i] == 'K'
1045 || ansi_buf[i] == 'h' 1041 || ansi_buf[i] == 'h'
1046 || ansi_buf[i] == 'l' 1042 || ansi_buf[i] == 'l'
1047 || ansi_buf[i] == 'm') { 1043 || ansi_buf[i] == 'm') {
1048 cchar = ansi_buf[i]; 1044 cchar = ansi_buf[i];
1049 flush = 1; 1045 flush = 1;
1050 } else 1046 } else
1051 fail = 1; 1047 fail = 1;
1052 break; 1048 break;
1053 } 1049 }
1054 } 1050 }
1055 1051
1056 if (fail) { 1052 if (fail) {
1057 for (i = 0; i < ansi_buf_size; ++i) 1053 for (i = 0; i < ansi_buf_size; ++i)
1058 parse_putc(ansi_buf[i]); 1054 parse_putc(ansi_buf[i]);
1059 ansi_buf_size = 0; 1055 ansi_buf_size = 0;
1060 return; 1056 return;
1061 } 1057 }
1062 1058
1063 if (flush) { 1059 if (flush) {
1064 if (!ansi_cursor_hidden) 1060 if (!ansi_cursor_hidden)
1065 CURSOR_OFF; 1061 CURSOR_OFF;
1066 ansi_buf_size = 0; 1062 ansi_buf_size = 0;
1067 switch (cchar) { 1063 switch (cchar) {
1068 case 'A': 1064 case 'A':
1069 /* move cursor num1 rows up */ 1065 /* move cursor num1 rows up */
1070 console_cursor_up(num1); 1066 console_cursor_up(num1);
1071 break; 1067 break;
1072 case 'B': 1068 case 'B':
1073 /* move cursor num1 rows down */ 1069 /* move cursor num1 rows down */
1074 console_cursor_down(num1); 1070 console_cursor_down(num1);
1075 break; 1071 break;
1076 case 'C': 1072 case 'C':
1077 /* move cursor num1 columns forward */ 1073 /* move cursor num1 columns forward */
1078 console_cursor_right(num1); 1074 console_cursor_right(num1);
1079 break; 1075 break;
1080 case 'D': 1076 case 'D':
1081 /* move cursor num1 columns back */ 1077 /* move cursor num1 columns back */
1082 console_cursor_left(num1); 1078 console_cursor_left(num1);
1083 break; 1079 break;
1084 case 'E': 1080 case 'E':
1085 /* move cursor num1 rows up at begin of row */ 1081 /* move cursor num1 rows up at begin of row */
1086 console_previousline(num1); 1082 console_previousline(num1);
1087 break; 1083 break;
1088 case 'F': 1084 case 'F':
1089 /* move cursor num1 rows down at begin of row */ 1085 /* move cursor num1 rows down at begin of row */
1090 console_newline(num1); 1086 console_newline(num1);
1091 break; 1087 break;
1092 case 'G': 1088 case 'G':
1093 /* move cursor to column num1 */ 1089 /* move cursor to column num1 */
1094 console_cursor_set_position(-1, num1-1); 1090 console_cursor_set_position(-1, num1-1);
1095 break; 1091 break;
1096 case 'H': 1092 case 'H':
1097 /* move cursor to row num1, column num2 */ 1093 /* move cursor to row num1, column num2 */
1098 console_cursor_set_position(num1-1, num2-1); 1094 console_cursor_set_position(num1-1, num2-1);
1099 break; 1095 break;
1100 case 'J': 1096 case 'J':
1101 /* clear console and move cursor to 0, 0 */ 1097 /* clear console and move cursor to 0, 0 */
1102 console_clear(); 1098 console_clear();
1103 console_cursor_set_position(0, 0); 1099 console_cursor_set_position(0, 0);
1104 break; 1100 break;
1105 case 'K': 1101 case 'K':
1106 /* clear line */ 1102 /* clear line */
1107 if (num1 == 0) 1103 if (num1 == 0)
1108 console_clear_line(console_row, 1104 console_clear_line(console_row,
1109 console_col, 1105 console_col,
1110 CONSOLE_COLS-1); 1106 CONSOLE_COLS-1);
1111 else if (num1 == 1) 1107 else if (num1 == 1)
1112 console_clear_line(console_row, 1108 console_clear_line(console_row,
1113 0, console_col); 1109 0, console_col);
1114 else 1110 else
1115 console_clear_line(console_row, 1111 console_clear_line(console_row,
1116 0, CONSOLE_COLS-1); 1112 0, CONSOLE_COLS-1);
1117 break; 1113 break;
1118 case 'h': 1114 case 'h':
1119 ansi_cursor_hidden = 0; 1115 ansi_cursor_hidden = 0;
1120 break; 1116 break;
1121 case 'l': 1117 case 'l':
1122 ansi_cursor_hidden = 1; 1118 ansi_cursor_hidden = 1;
1123 break; 1119 break;
1124 case 'm': 1120 case 'm':
1125 if (num1 == 0) { /* reset swapped colors */ 1121 if (num1 == 0) { /* reset swapped colors */
1126 if (ansi_colors_need_revert) { 1122 if (ansi_colors_need_revert) {
1127 console_swap_colors(); 1123 console_swap_colors();
1128 ansi_colors_need_revert = 0; 1124 ansi_colors_need_revert = 0;
1129 } 1125 }
1130 } else if (num1 == 7) { /* once swap colors */ 1126 } else if (num1 == 7) { /* once swap colors */
1131 if (!ansi_colors_need_revert) { 1127 if (!ansi_colors_need_revert) {
1132 console_swap_colors(); 1128 console_swap_colors();
1133 ansi_colors_need_revert = 1; 1129 ansi_colors_need_revert = 1;
1134 } 1130 }
1135 } 1131 }
1136 break; 1132 break;
1137 } 1133 }
1138 if (!ansi_cursor_hidden) 1134 if (!ansi_cursor_hidden)
1139 CURSOR_SET; 1135 CURSOR_SET;
1140 } 1136 }
1141 } else { 1137 } else {
1142 parse_putc(c); 1138 parse_putc(c);
1143 } 1139 }
1144 #else 1140 #else
1145 parse_putc(c); 1141 parse_putc(c);
1146 #endif 1142 #endif
1147 if (cfb_do_flush_cache) 1143 if (cfb_do_flush_cache)
1148 flush_cache(VIDEO_FB_ADRS, VIDEO_SIZE); 1144 flush_cache(VIDEO_FB_ADRS, VIDEO_SIZE);
1149 } 1145 }
1150 1146
1151 void video_puts(const char *s) 1147 void video_puts(const char *s)
1152 { 1148 {
1153 int count = strlen(s); 1149 int count = strlen(s);
1154 1150
1155 while (count--) 1151 while (count--)
1156 video_putc(*s++); 1152 video_putc(*s++);
1157 } 1153 }
1158 1154
1159 /* 1155 /*
1160 * Do not enforce drivers (or board code) to provide empty 1156 * Do not enforce drivers (or board code) to provide empty
1161 * video_set_lut() if they do not support 8 bpp format. 1157 * video_set_lut() if they do not support 8 bpp format.
1162 * Implement weak default function instead. 1158 * Implement weak default function instead.
1163 */ 1159 */
1164 void __video_set_lut(unsigned int index, unsigned char r, 1160 void __video_set_lut(unsigned int index, unsigned char r,
1165 unsigned char g, unsigned char b) 1161 unsigned char g, unsigned char b)
1166 { 1162 {
1167 } 1163 }
1168 1164
1169 void video_set_lut(unsigned int, unsigned char, unsigned char, unsigned char) 1165 void video_set_lut(unsigned int, unsigned char, unsigned char, unsigned char)
1170 __attribute__ ((weak, alias("__video_set_lut"))); 1166 __attribute__ ((weak, alias("__video_set_lut")));
1171 1167
1172 #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN) 1168 #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
1173 1169
1174 #define FILL_8BIT_332RGB(r,g,b) { \ 1170 #define FILL_8BIT_332RGB(r,g,b) { \
1175 *fb = ((r>>5)<<5) | ((g>>5)<<2) | (b>>6); \ 1171 *fb = ((r>>5)<<5) | ((g>>5)<<2) | (b>>6); \
1176 fb ++; \ 1172 fb ++; \
1177 } 1173 }
1178 1174
1179 #define FILL_15BIT_555RGB(r,g,b) { \ 1175 #define FILL_15BIT_555RGB(r,g,b) { \
1180 *(unsigned short *)fb = \ 1176 *(unsigned short *)fb = \
1181 SWAP16((unsigned short)(((r>>3)<<10) | \ 1177 SWAP16((unsigned short)(((r>>3)<<10) | \
1182 ((g>>3)<<5) | \ 1178 ((g>>3)<<5) | \
1183 (b>>3))); \ 1179 (b>>3))); \
1184 fb += 2; \ 1180 fb += 2; \
1185 } 1181 }
1186 1182
1187 #define FILL_16BIT_565RGB(r,g,b) { \ 1183 #define FILL_16BIT_565RGB(r,g,b) { \
1188 *(unsigned short *)fb = \ 1184 *(unsigned short *)fb = \
1189 SWAP16((unsigned short)((((r)>>3)<<11)| \ 1185 SWAP16((unsigned short)((((r)>>3)<<11)| \
1190 (((g)>>2)<<5) | \ 1186 (((g)>>2)<<5) | \
1191 ((b)>>3))); \ 1187 ((b)>>3))); \
1192 fb += 2; \ 1188 fb += 2; \
1193 } 1189 }
1194 1190
1195 #define FILL_32BIT_X888RGB(r,g,b) { \ 1191 #define FILL_32BIT_X888RGB(r,g,b) { \
1196 *(unsigned long *)fb = \ 1192 *(unsigned long *)fb = \
1197 SWAP32((unsigned long)(((r<<16) | \ 1193 SWAP32((unsigned long)(((r<<16) | \
1198 (g<<8) | \ 1194 (g<<8) | \
1199 b))); \ 1195 b))); \
1200 fb += 4; \ 1196 fb += 4; \
1201 } 1197 }
1202 1198
1203 #ifdef VIDEO_FB_LITTLE_ENDIAN 1199 #ifdef VIDEO_FB_LITTLE_ENDIAN
1204 #define FILL_24BIT_888RGB(r,g,b) { \ 1200 #define FILL_24BIT_888RGB(r,g,b) { \
1205 fb[0] = b; \ 1201 fb[0] = b; \
1206 fb[1] = g; \ 1202 fb[1] = g; \
1207 fb[2] = r; \ 1203 fb[2] = r; \
1208 fb += 3; \ 1204 fb += 3; \
1209 } 1205 }
1210 #else 1206 #else
1211 #define FILL_24BIT_888RGB(r,g,b) { \ 1207 #define FILL_24BIT_888RGB(r,g,b) { \
1212 fb[0] = r; \ 1208 fb[0] = r; \
1213 fb[1] = g; \ 1209 fb[1] = g; \
1214 fb[2] = b; \ 1210 fb[2] = b; \
1215 fb += 3; \ 1211 fb += 3; \
1216 } 1212 }
1217 #endif 1213 #endif
1218 1214
1219 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP) 1215 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
1220 static inline void fill_555rgb_pswap(uchar *fb, int x, u8 r, u8 g, u8 b) 1216 static inline void fill_555rgb_pswap(uchar *fb, int x, u8 r, u8 g, u8 b)
1221 { 1217 {
1222 ushort *dst = (ushort *) fb; 1218 ushort *dst = (ushort *) fb;
1223 ushort color = (ushort) (((r >> 3) << 10) | 1219 ushort color = (ushort) (((r >> 3) << 10) |
1224 ((g >> 3) << 5) | 1220 ((g >> 3) << 5) |
1225 (b >> 3)); 1221 (b >> 3));
1226 if (x & 1) 1222 if (x & 1)
1227 *(--dst) = color; 1223 *(--dst) = color;
1228 else 1224 else
1229 *(++dst) = color; 1225 *(++dst) = color;
1230 } 1226 }
1231 #endif 1227 #endif
1232 1228
1233 /* 1229 /*
1234 * RLE8 bitmap support 1230 * RLE8 bitmap support
1235 */ 1231 */
1236 1232
1237 #ifdef CONFIG_VIDEO_BMP_RLE8 1233 #ifdef CONFIG_VIDEO_BMP_RLE8
1238 /* Pre-calculated color table entry */ 1234 /* Pre-calculated color table entry */
1239 struct palette { 1235 struct palette {
1240 union { 1236 union {
1241 unsigned short w; /* word */ 1237 unsigned short w; /* word */
1242 unsigned int dw; /* double word */ 1238 unsigned int dw; /* double word */
1243 } ce; /* color entry */ 1239 } ce; /* color entry */
1244 }; 1240 };
1245 1241
1246 /* 1242 /*
1247 * Helper to draw encoded/unencoded run. 1243 * Helper to draw encoded/unencoded run.
1248 */ 1244 */
1249 static void draw_bitmap(uchar **fb, uchar *bm, struct palette *p, 1245 static void draw_bitmap(uchar **fb, uchar *bm, struct palette *p,
1250 int cnt, int enc) 1246 int cnt, int enc)
1251 { 1247 {
1252 ulong addr = (ulong) *fb; 1248 ulong addr = (ulong) *fb;
1253 int *off; 1249 int *off;
1254 int enc_off = 1; 1250 int enc_off = 1;
1255 int i; 1251 int i;
1256 1252
1257 /* 1253 /*
1258 * Setup offset of the color index in the bitmap. 1254 * Setup offset of the color index in the bitmap.
1259 * Color index of encoded run is at offset 1. 1255 * Color index of encoded run is at offset 1.
1260 */ 1256 */
1261 off = enc ? &enc_off : &i; 1257 off = enc ? &enc_off : &i;
1262 1258
1263 switch (VIDEO_DATA_FORMAT) { 1259 switch (VIDEO_DATA_FORMAT) {
1264 case GDF__8BIT_INDEX: 1260 case GDF__8BIT_INDEX:
1265 for (i = 0; i < cnt; i++) 1261 for (i = 0; i < cnt; i++)
1266 *(unsigned char *) addr++ = bm[*off]; 1262 *(unsigned char *) addr++ = bm[*off];
1267 break; 1263 break;
1268 case GDF_15BIT_555RGB: 1264 case GDF_15BIT_555RGB:
1269 case GDF_16BIT_565RGB: 1265 case GDF_16BIT_565RGB:
1270 /* differences handled while pre-calculating palette */ 1266 /* differences handled while pre-calculating palette */
1271 for (i = 0; i < cnt; i++) { 1267 for (i = 0; i < cnt; i++) {
1272 *(unsigned short *) addr = p[bm[*off]].ce.w; 1268 *(unsigned short *) addr = p[bm[*off]].ce.w;
1273 addr += 2; 1269 addr += 2;
1274 } 1270 }
1275 break; 1271 break;
1276 case GDF_32BIT_X888RGB: 1272 case GDF_32BIT_X888RGB:
1277 for (i = 0; i < cnt; i++) { 1273 for (i = 0; i < cnt; i++) {
1278 *(unsigned long *) addr = p[bm[*off]].ce.dw; 1274 *(unsigned long *) addr = p[bm[*off]].ce.dw;
1279 addr += 4; 1275 addr += 4;
1280 } 1276 }
1281 break; 1277 break;
1282 } 1278 }
1283 *fb = (uchar *) addr; /* return modified address */ 1279 *fb = (uchar *) addr; /* return modified address */
1284 } 1280 }
1285 1281
1286 static int display_rle8_bitmap(bmp_image_t *img, int xoff, int yoff, 1282 static int display_rle8_bitmap(bmp_image_t *img, int xoff, int yoff,
1287 int width, int height) 1283 int width, int height)
1288 { 1284 {
1289 unsigned char *bm; 1285 unsigned char *bm;
1290 unsigned char *fbp; 1286 unsigned char *fbp;
1291 unsigned int cnt, runlen; 1287 unsigned int cnt, runlen;
1292 int decode = 1; 1288 int decode = 1;
1293 int x, y, bpp, i, ncolors; 1289 int x, y, bpp, i, ncolors;
1294 struct palette p[256]; 1290 struct palette p[256];
1295 bmp_color_table_entry_t cte; 1291 bmp_color_table_entry_t cte;
1296 int green_shift, red_off; 1292 int green_shift, red_off;
1297 int limit = VIDEO_COLS * VIDEO_ROWS; 1293 int limit = VIDEO_COLS * VIDEO_ROWS;
1298 int pixels = 0; 1294 int pixels = 0;
1299 1295
1300 x = 0; 1296 x = 0;
1301 y = __le32_to_cpu(img->header.height) - 1; 1297 y = __le32_to_cpu(img->header.height) - 1;
1302 ncolors = __le32_to_cpu(img->header.colors_used); 1298 ncolors = __le32_to_cpu(img->header.colors_used);
1303 bpp = VIDEO_PIXEL_SIZE; 1299 bpp = VIDEO_PIXEL_SIZE;
1304 fbp = (unsigned char *) ((unsigned int) video_fb_address + 1300 fbp = (unsigned char *) ((unsigned int) video_fb_address +
1305 (((y + yoff) * VIDEO_COLS) + xoff) * bpp); 1301 (((y + yoff) * VIDEO_COLS) + xoff) * bpp);
1306 1302
1307 bm = (uchar *) img + __le32_to_cpu(img->header.data_offset); 1303 bm = (uchar *) img + __le32_to_cpu(img->header.data_offset);
1308 1304
1309 /* pre-calculate and setup palette */ 1305 /* pre-calculate and setup palette */
1310 switch (VIDEO_DATA_FORMAT) { 1306 switch (VIDEO_DATA_FORMAT) {
1311 case GDF__8BIT_INDEX: 1307 case GDF__8BIT_INDEX:
1312 for (i = 0; i < ncolors; i++) { 1308 for (i = 0; i < ncolors; i++) {
1313 cte = img->color_table[i]; 1309 cte = img->color_table[i];
1314 video_set_lut(i, cte.red, cte.green, cte.blue); 1310 video_set_lut(i, cte.red, cte.green, cte.blue);
1315 } 1311 }
1316 break; 1312 break;
1317 case GDF_15BIT_555RGB: 1313 case GDF_15BIT_555RGB:
1318 case GDF_16BIT_565RGB: 1314 case GDF_16BIT_565RGB:
1319 if (VIDEO_DATA_FORMAT == GDF_15BIT_555RGB) { 1315 if (VIDEO_DATA_FORMAT == GDF_15BIT_555RGB) {
1320 green_shift = 3; 1316 green_shift = 3;
1321 red_off = 10; 1317 red_off = 10;
1322 } else { 1318 } else {
1323 green_shift = 2; 1319 green_shift = 2;
1324 red_off = 11; 1320 red_off = 11;
1325 } 1321 }
1326 for (i = 0; i < ncolors; i++) { 1322 for (i = 0; i < ncolors; i++) {
1327 cte = img->color_table[i]; 1323 cte = img->color_table[i];
1328 p[i].ce.w = SWAP16((unsigned short) 1324 p[i].ce.w = SWAP16((unsigned short)
1329 (((cte.red >> 3) << red_off) | 1325 (((cte.red >> 3) << red_off) |
1330 ((cte.green >> green_shift) << 5) | 1326 ((cte.green >> green_shift) << 5) |
1331 cte.blue >> 3)); 1327 cte.blue >> 3));
1332 } 1328 }
1333 break; 1329 break;
1334 case GDF_32BIT_X888RGB: 1330 case GDF_32BIT_X888RGB:
1335 for (i = 0; i < ncolors; i++) { 1331 for (i = 0; i < ncolors; i++) {
1336 cte = img->color_table[i]; 1332 cte = img->color_table[i];
1337 p[i].ce.dw = SWAP32((cte.red << 16) | 1333 p[i].ce.dw = SWAP32((cte.red << 16) |
1338 (cte.green << 8) | 1334 (cte.green << 8) |
1339 cte.blue); 1335 cte.blue);
1340 } 1336 }
1341 break; 1337 break;
1342 default: 1338 default:
1343 printf("RLE Bitmap unsupported in video mode 0x%x\n", 1339 printf("RLE Bitmap unsupported in video mode 0x%x\n",
1344 VIDEO_DATA_FORMAT); 1340 VIDEO_DATA_FORMAT);
1345 return -1; 1341 return -1;
1346 } 1342 }
1347 1343
1348 while (decode) { 1344 while (decode) {
1349 switch (bm[0]) { 1345 switch (bm[0]) {
1350 case 0: 1346 case 0:
1351 switch (bm[1]) { 1347 switch (bm[1]) {
1352 case 0: 1348 case 0:
1353 /* scan line end marker */ 1349 /* scan line end marker */
1354 bm += 2; 1350 bm += 2;
1355 x = 0; 1351 x = 0;
1356 y--; 1352 y--;
1357 fbp = (unsigned char *) 1353 fbp = (unsigned char *)
1358 ((unsigned int) video_fb_address + 1354 ((unsigned int) video_fb_address +
1359 (((y + yoff) * VIDEO_COLS) + 1355 (((y + yoff) * VIDEO_COLS) +
1360 xoff) * bpp); 1356 xoff) * bpp);
1361 continue; 1357 continue;
1362 case 1: 1358 case 1:
1363 /* end of bitmap data marker */ 1359 /* end of bitmap data marker */
1364 decode = 0; 1360 decode = 0;
1365 break; 1361 break;
1366 case 2: 1362 case 2:
1367 /* run offset marker */ 1363 /* run offset marker */
1368 x += bm[2]; 1364 x += bm[2];
1369 y -= bm[3]; 1365 y -= bm[3];
1370 fbp = (unsigned char *) 1366 fbp = (unsigned char *)
1371 ((unsigned int) video_fb_address + 1367 ((unsigned int) video_fb_address +
1372 (((y + yoff) * VIDEO_COLS) + 1368 (((y + yoff) * VIDEO_COLS) +
1373 x + xoff) * bpp); 1369 x + xoff) * bpp);
1374 bm += 4; 1370 bm += 4;
1375 break; 1371 break;
1376 default: 1372 default:
1377 /* unencoded run */ 1373 /* unencoded run */
1378 cnt = bm[1]; 1374 cnt = bm[1];
1379 runlen = cnt; 1375 runlen = cnt;
1380 pixels += cnt; 1376 pixels += cnt;
1381 if (pixels > limit) 1377 if (pixels > limit)
1382 goto error; 1378 goto error;
1383 1379
1384 bm += 2; 1380 bm += 2;
1385 if (y < height) { 1381 if (y < height) {
1386 if (x >= width) { 1382 if (x >= width) {
1387 x += runlen; 1383 x += runlen;
1388 goto next_run; 1384 goto next_run;
1389 } 1385 }
1390 if (x + runlen > width) 1386 if (x + runlen > width)
1391 cnt = width - x; 1387 cnt = width - x;
1392 draw_bitmap(&fbp, bm, p, cnt, 0); 1388 draw_bitmap(&fbp, bm, p, cnt, 0);
1393 x += runlen; 1389 x += runlen;
1394 } 1390 }
1395 next_run: 1391 next_run:
1396 bm += runlen; 1392 bm += runlen;
1397 if (runlen & 1) 1393 if (runlen & 1)
1398 bm++; /* 0 padding if length is odd */ 1394 bm++; /* 0 padding if length is odd */
1399 } 1395 }
1400 break; 1396 break;
1401 default: 1397 default:
1402 /* encoded run */ 1398 /* encoded run */
1403 cnt = bm[0]; 1399 cnt = bm[0];
1404 runlen = cnt; 1400 runlen = cnt;
1405 pixels += cnt; 1401 pixels += cnt;
1406 if (pixels > limit) 1402 if (pixels > limit)
1407 goto error; 1403 goto error;
1408 1404
1409 if (y < height) { /* only draw into visible area */ 1405 if (y < height) { /* only draw into visible area */
1410 if (x >= width) { 1406 if (x >= width) {
1411 x += runlen; 1407 x += runlen;
1412 bm += 2; 1408 bm += 2;
1413 continue; 1409 continue;
1414 } 1410 }
1415 if (x + runlen > width) 1411 if (x + runlen > width)
1416 cnt = width - x; 1412 cnt = width - x;
1417 draw_bitmap(&fbp, bm, p, cnt, 1); 1413 draw_bitmap(&fbp, bm, p, cnt, 1);
1418 x += runlen; 1414 x += runlen;
1419 } 1415 }
1420 bm += 2; 1416 bm += 2;
1421 break; 1417 break;
1422 } 1418 }
1423 } 1419 }
1424 return 0; 1420 return 0;
1425 error: 1421 error:
1426 printf("Error: Too much encoded pixel data, validate your bitmap\n"); 1422 printf("Error: Too much encoded pixel data, validate your bitmap\n");
1427 return -1; 1423 return -1;
1428 } 1424 }
1429 #endif 1425 #endif
1430 1426
1431 /* 1427 /*
1432 * Display the BMP file located at address bmp_image. 1428 * Display the BMP file located at address bmp_image.
1433 */ 1429 */
1434 int video_display_bitmap(ulong bmp_image, int x, int y) 1430 int video_display_bitmap(ulong bmp_image, int x, int y)
1435 { 1431 {
1436 ushort xcount, ycount; 1432 ushort xcount, ycount;
1437 uchar *fb; 1433 uchar *fb;
1438 bmp_image_t *bmp = (bmp_image_t *) bmp_image; 1434 bmp_image_t *bmp = (bmp_image_t *) bmp_image;
1439 uchar *bmap; 1435 uchar *bmap;
1440 ushort padded_line; 1436 ushort padded_line;
1441 unsigned long width, height, bpp; 1437 unsigned long width, height, bpp;
1442 unsigned colors; 1438 unsigned colors;
1443 unsigned long compression; 1439 unsigned long compression;
1444 bmp_color_table_entry_t cte; 1440 bmp_color_table_entry_t cte;
1445 1441
1446 #ifdef CONFIG_VIDEO_BMP_GZIP 1442 #ifdef CONFIG_VIDEO_BMP_GZIP
1447 unsigned char *dst = NULL; 1443 unsigned char *dst = NULL;
1448 ulong len; 1444 ulong len;
1449 #endif 1445 #endif
1450 1446
1451 WATCHDOG_RESET(); 1447 WATCHDOG_RESET();
1452 1448
1453 if (!((bmp->header.signature[0] == 'B') && 1449 if (!((bmp->header.signature[0] == 'B') &&
1454 (bmp->header.signature[1] == 'M'))) { 1450 (bmp->header.signature[1] == 'M'))) {
1455 1451
1456 #ifdef CONFIG_VIDEO_BMP_GZIP 1452 #ifdef CONFIG_VIDEO_BMP_GZIP
1457 /* 1453 /*
1458 * Could be a gzipped bmp image, try to decrompress... 1454 * Could be a gzipped bmp image, try to decrompress...
1459 */ 1455 */
1460 len = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE; 1456 len = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE;
1461 dst = malloc(CONFIG_SYS_VIDEO_LOGO_MAX_SIZE); 1457 dst = malloc(CONFIG_SYS_VIDEO_LOGO_MAX_SIZE);
1462 if (dst == NULL) { 1458 if (dst == NULL) {
1463 printf("Error: malloc in gunzip failed!\n"); 1459 printf("Error: malloc in gunzip failed!\n");
1464 return 1; 1460 return 1;
1465 } 1461 }
1466 if (gunzip(dst, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE, 1462 if (gunzip(dst, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE,
1467 (uchar *) bmp_image, 1463 (uchar *) bmp_image,
1468 &len) != 0) { 1464 &len) != 0) {
1469 printf("Error: no valid bmp or bmp.gz image at %lx\n", 1465 printf("Error: no valid bmp or bmp.gz image at %lx\n",
1470 bmp_image); 1466 bmp_image);
1471 free(dst); 1467 free(dst);
1472 return 1; 1468 return 1;
1473 } 1469 }
1474 if (len == CONFIG_SYS_VIDEO_LOGO_MAX_SIZE) { 1470 if (len == CONFIG_SYS_VIDEO_LOGO_MAX_SIZE) {
1475 printf("Image could be truncated " 1471 printf("Image could be truncated "
1476 "(increase CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)!\n"); 1472 "(increase CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)!\n");
1477 } 1473 }
1478 1474
1479 /* 1475 /*
1480 * Set addr to decompressed image 1476 * Set addr to decompressed image
1481 */ 1477 */
1482 bmp = (bmp_image_t *) dst; 1478 bmp = (bmp_image_t *) dst;
1483 1479
1484 if (!((bmp->header.signature[0] == 'B') && 1480 if (!((bmp->header.signature[0] == 'B') &&
1485 (bmp->header.signature[1] == 'M'))) { 1481 (bmp->header.signature[1] == 'M'))) {
1486 printf("Error: no valid bmp.gz image at %lx\n", 1482 printf("Error: no valid bmp.gz image at %lx\n",
1487 bmp_image); 1483 bmp_image);
1488 free(dst); 1484 free(dst);
1489 return 1; 1485 return 1;
1490 } 1486 }
1491 #else 1487 #else
1492 printf("Error: no valid bmp image at %lx\n", bmp_image); 1488 printf("Error: no valid bmp image at %lx\n", bmp_image);
1493 return 1; 1489 return 1;
1494 #endif /* CONFIG_VIDEO_BMP_GZIP */ 1490 #endif /* CONFIG_VIDEO_BMP_GZIP */
1495 } 1491 }
1496 1492
1497 width = le32_to_cpu(bmp->header.width); 1493 width = le32_to_cpu(bmp->header.width);
1498 height = le32_to_cpu(bmp->header.height); 1494 height = le32_to_cpu(bmp->header.height);
1499 bpp = le16_to_cpu(bmp->header.bit_count); 1495 bpp = le16_to_cpu(bmp->header.bit_count);
1500 colors = le32_to_cpu(bmp->header.colors_used); 1496 colors = le32_to_cpu(bmp->header.colors_used);
1501 compression = le32_to_cpu(bmp->header.compression); 1497 compression = le32_to_cpu(bmp->header.compression);
1502 1498
1503 debug("Display-bmp: %ld x %ld with %d colors\n", 1499 debug("Display-bmp: %ld x %ld with %d colors\n",
1504 width, height, colors); 1500 width, height, colors);
1505 1501
1506 if (compression != BMP_BI_RGB 1502 if (compression != BMP_BI_RGB
1507 #ifdef CONFIG_VIDEO_BMP_RLE8 1503 #ifdef CONFIG_VIDEO_BMP_RLE8
1508 && compression != BMP_BI_RLE8 1504 && compression != BMP_BI_RLE8
1509 #endif 1505 #endif
1510 ) { 1506 ) {
1511 printf("Error: compression type %ld not supported\n", 1507 printf("Error: compression type %ld not supported\n",
1512 compression); 1508 compression);
1513 #ifdef CONFIG_VIDEO_BMP_GZIP 1509 #ifdef CONFIG_VIDEO_BMP_GZIP
1514 if (dst) 1510 if (dst)
1515 free(dst); 1511 free(dst);
1516 #endif 1512 #endif
1517 return 1; 1513 return 1;
1518 } 1514 }
1519 1515
1520 padded_line = (((width * bpp + 7) / 8) + 3) & ~0x3; 1516 padded_line = (((width * bpp + 7) / 8) + 3) & ~0x3;
1521 1517
1522 #ifdef CONFIG_SPLASH_SCREEN_ALIGN 1518 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
1523 if (x == BMP_ALIGN_CENTER) 1519 if (x == BMP_ALIGN_CENTER)
1524 x = max(0, (VIDEO_VISIBLE_COLS - width) / 2); 1520 x = max(0, (VIDEO_VISIBLE_COLS - width) / 2);
1525 else if (x < 0) 1521 else if (x < 0)
1526 x = max(0, VIDEO_VISIBLE_COLS - width + x + 1); 1522 x = max(0, VIDEO_VISIBLE_COLS - width + x + 1);
1527 1523
1528 if (y == BMP_ALIGN_CENTER) 1524 if (y == BMP_ALIGN_CENTER)
1529 y = max(0, (VIDEO_VISIBLE_ROWS - height) / 2); 1525 y = max(0, (VIDEO_VISIBLE_ROWS - height) / 2);
1530 else if (y < 0) 1526 else if (y < 0)
1531 y = max(0, VIDEO_VISIBLE_ROWS - height + y + 1); 1527 y = max(0, VIDEO_VISIBLE_ROWS - height + y + 1);
1532 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */ 1528 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
1533 1529
1534 /* 1530 /*
1535 * Just ignore elements which are completely beyond screen 1531 * Just ignore elements which are completely beyond screen
1536 * dimensions. 1532 * dimensions.
1537 */ 1533 */
1538 if ((x >= VIDEO_VISIBLE_COLS) || (y >= VIDEO_VISIBLE_ROWS)) 1534 if ((x >= VIDEO_VISIBLE_COLS) || (y >= VIDEO_VISIBLE_ROWS))
1539 return 0; 1535 return 0;
1540 1536
1541 if ((x + width) > VIDEO_VISIBLE_COLS) 1537 if ((x + width) > VIDEO_VISIBLE_COLS)
1542 width = VIDEO_VISIBLE_COLS - x; 1538 width = VIDEO_VISIBLE_COLS - x;
1543 if ((y + height) > VIDEO_VISIBLE_ROWS) 1539 if ((y + height) > VIDEO_VISIBLE_ROWS)
1544 height = VIDEO_VISIBLE_ROWS - y; 1540 height = VIDEO_VISIBLE_ROWS - y;
1545 1541
1546 bmap = (uchar *) bmp + le32_to_cpu(bmp->header.data_offset); 1542 bmap = (uchar *) bmp + le32_to_cpu(bmp->header.data_offset);
1547 fb = (uchar *) (video_fb_address + 1543 fb = (uchar *) (video_fb_address +
1548 ((y + height - 1) * VIDEO_COLS * VIDEO_PIXEL_SIZE) + 1544 ((y + height - 1) * VIDEO_COLS * VIDEO_PIXEL_SIZE) +
1549 x * VIDEO_PIXEL_SIZE); 1545 x * VIDEO_PIXEL_SIZE);
1550 1546
1551 #ifdef CONFIG_VIDEO_BMP_RLE8 1547 #ifdef CONFIG_VIDEO_BMP_RLE8
1552 if (compression == BMP_BI_RLE8) { 1548 if (compression == BMP_BI_RLE8) {
1553 return display_rle8_bitmap(bmp, x, y, width, height); 1549 return display_rle8_bitmap(bmp, x, y, width, height);
1554 } 1550 }
1555 #endif 1551 #endif
1556 1552
1557 /* We handle only 4, 8, or 24 bpp bitmaps */ 1553 /* We handle only 4, 8, or 24 bpp bitmaps */
1558 switch (le16_to_cpu(bmp->header.bit_count)) { 1554 switch (le16_to_cpu(bmp->header.bit_count)) {
1559 case 4: 1555 case 4:
1560 padded_line -= width / 2; 1556 padded_line -= width / 2;
1561 ycount = height; 1557 ycount = height;
1562 1558
1563 switch (VIDEO_DATA_FORMAT) { 1559 switch (VIDEO_DATA_FORMAT) {
1564 case GDF_32BIT_X888RGB: 1560 case GDF_32BIT_X888RGB:
1565 while (ycount--) { 1561 while (ycount--) {
1566 WATCHDOG_RESET(); 1562 WATCHDOG_RESET();
1567 /* 1563 /*
1568 * Don't assume that 'width' is an 1564 * Don't assume that 'width' is an
1569 * even number 1565 * even number
1570 */ 1566 */
1571 for (xcount = 0; xcount < width; xcount++) { 1567 for (xcount = 0; xcount < width; xcount++) {
1572 uchar idx; 1568 uchar idx;
1573 1569
1574 if (xcount & 1) { 1570 if (xcount & 1) {
1575 idx = *bmap & 0xF; 1571 idx = *bmap & 0xF;
1576 bmap++; 1572 bmap++;
1577 } else 1573 } else
1578 idx = *bmap >> 4; 1574 idx = *bmap >> 4;
1579 cte = bmp->color_table[idx]; 1575 cte = bmp->color_table[idx];
1580 FILL_32BIT_X888RGB(cte.red, cte.green, 1576 FILL_32BIT_X888RGB(cte.red, cte.green,
1581 cte.blue); 1577 cte.blue);
1582 } 1578 }
1583 bmap += padded_line; 1579 bmap += padded_line;
1584 fb -= (VIDEO_VISIBLE_COLS + width) * 1580 fb -= (VIDEO_VISIBLE_COLS + width) *
1585 VIDEO_PIXEL_SIZE; 1581 VIDEO_PIXEL_SIZE;
1586 } 1582 }
1587 break; 1583 break;
1588 default: 1584 default:
1589 puts("4bpp bitmap unsupported with current " 1585 puts("4bpp bitmap unsupported with current "
1590 "video mode\n"); 1586 "video mode\n");
1591 break; 1587 break;
1592 } 1588 }
1593 break; 1589 break;
1594 1590
1595 case 8: 1591 case 8:
1596 padded_line -= width; 1592 padded_line -= width;
1597 if (VIDEO_DATA_FORMAT == GDF__8BIT_INDEX) { 1593 if (VIDEO_DATA_FORMAT == GDF__8BIT_INDEX) {
1598 /* Copy colormap */ 1594 /* Copy colormap */
1599 for (xcount = 0; xcount < colors; ++xcount) { 1595 for (xcount = 0; xcount < colors; ++xcount) {
1600 cte = bmp->color_table[xcount]; 1596 cte = bmp->color_table[xcount];
1601 video_set_lut(xcount, cte.red, cte.green, 1597 video_set_lut(xcount, cte.red, cte.green,
1602 cte.blue); 1598 cte.blue);
1603 } 1599 }
1604 } 1600 }
1605 ycount = height; 1601 ycount = height;
1606 switch (VIDEO_DATA_FORMAT) { 1602 switch (VIDEO_DATA_FORMAT) {
1607 case GDF__8BIT_INDEX: 1603 case GDF__8BIT_INDEX:
1608 while (ycount--) { 1604 while (ycount--) {
1609 WATCHDOG_RESET(); 1605 WATCHDOG_RESET();
1610 xcount = width; 1606 xcount = width;
1611 while (xcount--) { 1607 while (xcount--) {
1612 *fb++ = *bmap++; 1608 *fb++ = *bmap++;
1613 } 1609 }
1614 bmap += padded_line; 1610 bmap += padded_line;
1615 fb -= (VIDEO_VISIBLE_COLS + width) * 1611 fb -= (VIDEO_VISIBLE_COLS + width) *
1616 VIDEO_PIXEL_SIZE; 1612 VIDEO_PIXEL_SIZE;
1617 } 1613 }
1618 break; 1614 break;
1619 case GDF__8BIT_332RGB: 1615 case GDF__8BIT_332RGB:
1620 while (ycount--) { 1616 while (ycount--) {
1621 WATCHDOG_RESET(); 1617 WATCHDOG_RESET();
1622 xcount = width; 1618 xcount = width;
1623 while (xcount--) { 1619 while (xcount--) {
1624 cte = bmp->color_table[*bmap++]; 1620 cte = bmp->color_table[*bmap++];
1625 FILL_8BIT_332RGB(cte.red, cte.green, 1621 FILL_8BIT_332RGB(cte.red, cte.green,
1626 cte.blue); 1622 cte.blue);
1627 } 1623 }
1628 bmap += padded_line; 1624 bmap += padded_line;
1629 fb -= (VIDEO_VISIBLE_COLS + width) * 1625 fb -= (VIDEO_VISIBLE_COLS + width) *
1630 VIDEO_PIXEL_SIZE; 1626 VIDEO_PIXEL_SIZE;
1631 } 1627 }
1632 break; 1628 break;
1633 case GDF_15BIT_555RGB: 1629 case GDF_15BIT_555RGB:
1634 while (ycount--) { 1630 while (ycount--) {
1635 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP) 1631 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
1636 int xpos = x; 1632 int xpos = x;
1637 #endif 1633 #endif
1638 WATCHDOG_RESET(); 1634 WATCHDOG_RESET();
1639 xcount = width; 1635 xcount = width;
1640 while (xcount--) { 1636 while (xcount--) {
1641 cte = bmp->color_table[*bmap++]; 1637 cte = bmp->color_table[*bmap++];
1642 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP) 1638 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
1643 fill_555rgb_pswap(fb, xpos++, cte.red, 1639 fill_555rgb_pswap(fb, xpos++, cte.red,
1644 cte.green, 1640 cte.green,
1645 cte.blue); 1641 cte.blue);
1646 fb += 2; 1642 fb += 2;
1647 #else 1643 #else
1648 FILL_15BIT_555RGB(cte.red, cte.green, 1644 FILL_15BIT_555RGB(cte.red, cte.green,
1649 cte.blue); 1645 cte.blue);
1650 #endif 1646 #endif
1651 } 1647 }
1652 bmap += padded_line; 1648 bmap += padded_line;
1653 fb -= (VIDEO_VISIBLE_COLS + width) * 1649 fb -= (VIDEO_VISIBLE_COLS + width) *
1654 VIDEO_PIXEL_SIZE; 1650 VIDEO_PIXEL_SIZE;
1655 } 1651 }
1656 break; 1652 break;
1657 case GDF_16BIT_565RGB: 1653 case GDF_16BIT_565RGB:
1658 while (ycount--) { 1654 while (ycount--) {
1659 WATCHDOG_RESET(); 1655 WATCHDOG_RESET();
1660 xcount = width; 1656 xcount = width;
1661 while (xcount--) { 1657 while (xcount--) {
1662 cte = bmp->color_table[*bmap++]; 1658 cte = bmp->color_table[*bmap++];
1663 FILL_16BIT_565RGB(cte.red, cte.green, 1659 FILL_16BIT_565RGB(cte.red, cte.green,
1664 cte.blue); 1660 cte.blue);
1665 } 1661 }
1666 bmap += padded_line; 1662 bmap += padded_line;
1667 fb -= (VIDEO_VISIBLE_COLS + width) * 1663 fb -= (VIDEO_VISIBLE_COLS + width) *
1668 VIDEO_PIXEL_SIZE; 1664 VIDEO_PIXEL_SIZE;
1669 } 1665 }
1670 break; 1666 break;
1671 case GDF_32BIT_X888RGB: 1667 case GDF_32BIT_X888RGB:
1672 while (ycount--) { 1668 while (ycount--) {
1673 WATCHDOG_RESET(); 1669 WATCHDOG_RESET();
1674 xcount = width; 1670 xcount = width;
1675 while (xcount--) { 1671 while (xcount--) {
1676 cte = bmp->color_table[*bmap++]; 1672 cte = bmp->color_table[*bmap++];
1677 FILL_32BIT_X888RGB(cte.red, cte.green, 1673 FILL_32BIT_X888RGB(cte.red, cte.green,
1678 cte.blue); 1674 cte.blue);
1679 } 1675 }
1680 bmap += padded_line; 1676 bmap += padded_line;
1681 fb -= (VIDEO_VISIBLE_COLS + width) * 1677 fb -= (VIDEO_VISIBLE_COLS + width) *
1682 VIDEO_PIXEL_SIZE; 1678 VIDEO_PIXEL_SIZE;
1683 } 1679 }
1684 break; 1680 break;
1685 case GDF_24BIT_888RGB: 1681 case GDF_24BIT_888RGB:
1686 while (ycount--) { 1682 while (ycount--) {
1687 WATCHDOG_RESET(); 1683 WATCHDOG_RESET();
1688 xcount = width; 1684 xcount = width;
1689 while (xcount--) { 1685 while (xcount--) {
1690 cte = bmp->color_table[*bmap++]; 1686 cte = bmp->color_table[*bmap++];
1691 FILL_24BIT_888RGB(cte.red, cte.green, 1687 FILL_24BIT_888RGB(cte.red, cte.green,
1692 cte.blue); 1688 cte.blue);
1693 } 1689 }
1694 bmap += padded_line; 1690 bmap += padded_line;
1695 fb -= (VIDEO_VISIBLE_COLS + width) * 1691 fb -= (VIDEO_VISIBLE_COLS + width) *
1696 VIDEO_PIXEL_SIZE; 1692 VIDEO_PIXEL_SIZE;
1697 } 1693 }
1698 break; 1694 break;
1699 } 1695 }
1700 break; 1696 break;
1701 case 24: 1697 case 24:
1702 padded_line -= 3 * width; 1698 padded_line -= 3 * width;
1703 ycount = height; 1699 ycount = height;
1704 switch (VIDEO_DATA_FORMAT) { 1700 switch (VIDEO_DATA_FORMAT) {
1705 case GDF__8BIT_332RGB: 1701 case GDF__8BIT_332RGB:
1706 while (ycount--) { 1702 while (ycount--) {
1707 WATCHDOG_RESET(); 1703 WATCHDOG_RESET();
1708 xcount = width; 1704 xcount = width;
1709 while (xcount--) { 1705 while (xcount--) {
1710 FILL_8BIT_332RGB(bmap[2], bmap[1], 1706 FILL_8BIT_332RGB(bmap[2], bmap[1],
1711 bmap[0]); 1707 bmap[0]);
1712 bmap += 3; 1708 bmap += 3;
1713 } 1709 }
1714 bmap += padded_line; 1710 bmap += padded_line;
1715 fb -= (VIDEO_VISIBLE_COLS + width) * 1711 fb -= (VIDEO_VISIBLE_COLS + width) *
1716 VIDEO_PIXEL_SIZE; 1712 VIDEO_PIXEL_SIZE;
1717 } 1713 }
1718 break; 1714 break;
1719 case GDF_15BIT_555RGB: 1715 case GDF_15BIT_555RGB:
1720 while (ycount--) { 1716 while (ycount--) {
1721 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP) 1717 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
1722 int xpos = x; 1718 int xpos = x;
1723 #endif 1719 #endif
1724 WATCHDOG_RESET(); 1720 WATCHDOG_RESET();
1725 xcount = width; 1721 xcount = width;
1726 while (xcount--) { 1722 while (xcount--) {
1727 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP) 1723 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
1728 fill_555rgb_pswap(fb, xpos++, bmap[2], 1724 fill_555rgb_pswap(fb, xpos++, bmap[2],
1729 bmap[1], bmap[0]); 1725 bmap[1], bmap[0]);
1730 fb += 2; 1726 fb += 2;
1731 #else 1727 #else
1732 FILL_15BIT_555RGB(bmap[2], bmap[1], 1728 FILL_15BIT_555RGB(bmap[2], bmap[1],
1733 bmap[0]); 1729 bmap[0]);
1734 #endif 1730 #endif
1735 bmap += 3; 1731 bmap += 3;
1736 } 1732 }
1737 bmap += padded_line; 1733 bmap += padded_line;
1738 fb -= (VIDEO_VISIBLE_COLS + width) * 1734 fb -= (VIDEO_VISIBLE_COLS + width) *
1739 VIDEO_PIXEL_SIZE; 1735 VIDEO_PIXEL_SIZE;
1740 } 1736 }
1741 break; 1737 break;
1742 case GDF_16BIT_565RGB: 1738 case GDF_16BIT_565RGB:
1743 while (ycount--) { 1739 while (ycount--) {
1744 WATCHDOG_RESET(); 1740 WATCHDOG_RESET();
1745 xcount = width; 1741 xcount = width;
1746 while (xcount--) { 1742 while (xcount--) {
1747 FILL_16BIT_565RGB(bmap[2], bmap[1], 1743 FILL_16BIT_565RGB(bmap[2], bmap[1],
1748 bmap[0]); 1744 bmap[0]);
1749 bmap += 3; 1745 bmap += 3;
1750 } 1746 }
1751 bmap += padded_line; 1747 bmap += padded_line;
1752 fb -= (VIDEO_VISIBLE_COLS + width) * 1748 fb -= (VIDEO_VISIBLE_COLS + width) *
1753 VIDEO_PIXEL_SIZE; 1749 VIDEO_PIXEL_SIZE;
1754 } 1750 }
1755 break; 1751 break;
1756 case GDF_32BIT_X888RGB: 1752 case GDF_32BIT_X888RGB:
1757 while (ycount--) { 1753 while (ycount--) {
1758 WATCHDOG_RESET(); 1754 WATCHDOG_RESET();
1759 xcount = width; 1755 xcount = width;
1760 while (xcount--) { 1756 while (xcount--) {
1761 FILL_32BIT_X888RGB(bmap[2], bmap[1], 1757 FILL_32BIT_X888RGB(bmap[2], bmap[1],
1762 bmap[0]); 1758 bmap[0]);
1763 bmap += 3; 1759 bmap += 3;
1764 } 1760 }
1765 bmap += padded_line; 1761 bmap += padded_line;
1766 fb -= (VIDEO_VISIBLE_COLS + width) * 1762 fb -= (VIDEO_VISIBLE_COLS + width) *
1767 VIDEO_PIXEL_SIZE; 1763 VIDEO_PIXEL_SIZE;
1768 } 1764 }
1769 break; 1765 break;
1770 case GDF_24BIT_888RGB: 1766 case GDF_24BIT_888RGB:
1771 while (ycount--) { 1767 while (ycount--) {
1772 WATCHDOG_RESET(); 1768 WATCHDOG_RESET();
1773 xcount = width; 1769 xcount = width;
1774 while (xcount--) { 1770 while (xcount--) {
1775 FILL_24BIT_888RGB(bmap[2], bmap[1], 1771 FILL_24BIT_888RGB(bmap[2], bmap[1],
1776 bmap[0]); 1772 bmap[0]);
1777 bmap += 3; 1773 bmap += 3;
1778 } 1774 }
1779 bmap += padded_line; 1775 bmap += padded_line;
1780 fb -= (VIDEO_VISIBLE_COLS + width) * 1776 fb -= (VIDEO_VISIBLE_COLS + width) *
1781 VIDEO_PIXEL_SIZE; 1777 VIDEO_PIXEL_SIZE;
1782 } 1778 }
1783 break; 1779 break;
1784 default: 1780 default:
1785 printf("Error: 24 bits/pixel bitmap incompatible " 1781 printf("Error: 24 bits/pixel bitmap incompatible "
1786 "with current video mode\n"); 1782 "with current video mode\n");
1787 break; 1783 break;
1788 } 1784 }
1789 break; 1785 break;
1790 default: 1786 default:
1791 printf("Error: %d bit/pixel bitmaps not supported by U-Boot\n", 1787 printf("Error: %d bit/pixel bitmaps not supported by U-Boot\n",
1792 le16_to_cpu(bmp->header.bit_count)); 1788 le16_to_cpu(bmp->header.bit_count));
1793 break; 1789 break;
1794 } 1790 }
1795 1791
1796 #ifdef CONFIG_VIDEO_BMP_GZIP 1792 #ifdef CONFIG_VIDEO_BMP_GZIP
1797 if (dst) { 1793 if (dst) {
1798 free(dst); 1794 free(dst);
1799 } 1795 }
1800 #endif 1796 #endif
1801 1797
1802 if (cfb_do_flush_cache) 1798 if (cfb_do_flush_cache)
1803 flush_cache(VIDEO_FB_ADRS, VIDEO_SIZE); 1799 flush_cache(VIDEO_FB_ADRS, VIDEO_SIZE);
1804 return (0); 1800 return (0);
1805 } 1801 }
1806 #endif 1802 #endif
1807 1803
1808 1804
1809 #ifdef CONFIG_VIDEO_LOGO 1805 #ifdef CONFIG_VIDEO_LOGO
1810 static int video_logo_xpos; 1806 static int video_logo_xpos;
1811 static int video_logo_ypos; 1807 static int video_logo_ypos;
1812 1808
1813 static void plot_logo_or_black(void *screen, int width, int x, int y, \ 1809 static void plot_logo_or_black(void *screen, int width, int x, int y, \
1814 int black); 1810 int black);
1815 1811
1816 static void logo_plot(void *screen, int width, int x, int y) 1812 static void logo_plot(void *screen, int width, int x, int y)
1817 { 1813 {
1818 plot_logo_or_black(screen, width, x, y, 0); 1814 plot_logo_or_black(screen, width, x, y, 0);
1819 } 1815 }
1820 1816
1821 static void logo_black(void) 1817 static void logo_black(void)
1822 { 1818 {
1823 plot_logo_or_black(video_fb_address, \ 1819 plot_logo_or_black(video_fb_address, \
1824 VIDEO_COLS, \ 1820 VIDEO_COLS, \
1825 video_logo_xpos, \ 1821 video_logo_xpos, \
1826 video_logo_ypos, \ 1822 video_logo_ypos, \
1827 1); 1823 1);
1828 } 1824 }
1829 1825
1830 static int do_clrlogo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 1826 static int do_clrlogo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
1831 { 1827 {
1832 if (argc != 1) 1828 if (argc != 1)
1833 return cmd_usage(cmdtp); 1829 return cmd_usage(cmdtp);
1834 1830
1835 logo_black(); 1831 logo_black();
1836 return 0; 1832 return 0;
1837 } 1833 }
1838 1834
1839 U_BOOT_CMD( 1835 U_BOOT_CMD(
1840 clrlogo, 1, 0, do_clrlogo, 1836 clrlogo, 1, 0, do_clrlogo,
1841 "fill the boot logo area with black", 1837 "fill the boot logo area with black",
1842 " " 1838 " "
1843 ); 1839 );
1844 1840
1845 static void plot_logo_or_black(void *screen, int width, int x, int y, int black) 1841 static void plot_logo_or_black(void *screen, int width, int x, int y, int black)
1846 { 1842 {
1847 1843
1848 int xcount, i; 1844 int xcount, i;
1849 int skip = (width - VIDEO_LOGO_WIDTH) * VIDEO_PIXEL_SIZE; 1845 int skip = (width - VIDEO_LOGO_WIDTH) * VIDEO_PIXEL_SIZE;
1850 int ycount = video_logo_height; 1846 int ycount = video_logo_height;
1851 unsigned char r, g, b, *logo_red, *logo_blue, *logo_green; 1847 unsigned char r, g, b, *logo_red, *logo_blue, *logo_green;
1852 unsigned char *source; 1848 unsigned char *source;
1853 unsigned char *dest; 1849 unsigned char *dest;
1854 1850
1855 #ifdef CONFIG_SPLASH_SCREEN_ALIGN 1851 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
1856 if (x == BMP_ALIGN_CENTER) 1852 if (x == BMP_ALIGN_CENTER)
1857 x = max(0, (VIDEO_VISIBLE_COLS - VIDEO_LOGO_WIDTH) / 2); 1853 x = max(0, (VIDEO_VISIBLE_COLS - VIDEO_LOGO_WIDTH) / 2);
1858 else if (x < 0) 1854 else if (x < 0)
1859 x = max(0, VIDEO_VISIBLE_COLS - VIDEO_LOGO_WIDTH + x + 1); 1855 x = max(0, VIDEO_VISIBLE_COLS - VIDEO_LOGO_WIDTH + x + 1);
1860 1856
1861 if (y == BMP_ALIGN_CENTER) 1857 if (y == BMP_ALIGN_CENTER)
1862 y = max(0, (VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT) / 2); 1858 y = max(0, (VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT) / 2);
1863 else if (y < 0) 1859 else if (y < 0)
1864 y = max(0, VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT + y + 1); 1860 y = max(0, VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT + y + 1);
1865 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */ 1861 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
1866 1862
1867 dest = (unsigned char *)screen + (y * width + x) * VIDEO_PIXEL_SIZE; 1863 dest = (unsigned char *)screen + (y * width + x) * VIDEO_PIXEL_SIZE;
1868 1864
1869 #ifdef CONFIG_VIDEO_BMP_LOGO 1865 #ifdef CONFIG_VIDEO_BMP_LOGO
1870 source = bmp_logo_bitmap; 1866 source = bmp_logo_bitmap;
1871 1867
1872 /* Allocate temporary space for computing colormap */ 1868 /* Allocate temporary space for computing colormap */
1873 logo_red = malloc(BMP_LOGO_COLORS); 1869 logo_red = malloc(BMP_LOGO_COLORS);
1874 logo_green = malloc(BMP_LOGO_COLORS); 1870 logo_green = malloc(BMP_LOGO_COLORS);
1875 logo_blue = malloc(BMP_LOGO_COLORS); 1871 logo_blue = malloc(BMP_LOGO_COLORS);
1876 /* Compute color map */ 1872 /* Compute color map */
1877 for (i = 0; i < VIDEO_LOGO_COLORS; i++) { 1873 for (i = 0; i < VIDEO_LOGO_COLORS; i++) {
1878 logo_red[i] = (bmp_logo_palette[i] & 0x0f00) >> 4; 1874 logo_red[i] = (bmp_logo_palette[i] & 0x0f00) >> 4;
1879 logo_green[i] = (bmp_logo_palette[i] & 0x00f0); 1875 logo_green[i] = (bmp_logo_palette[i] & 0x00f0);
1880 logo_blue[i] = (bmp_logo_palette[i] & 0x000f) << 4; 1876 logo_blue[i] = (bmp_logo_palette[i] & 0x000f) << 4;
1881 } 1877 }
1882 #else 1878 #else
1883 source = linux_logo; 1879 source = linux_logo;
1884 logo_red = linux_logo_red; 1880 logo_red = linux_logo_red;
1885 logo_green = linux_logo_green; 1881 logo_green = linux_logo_green;
1886 logo_blue = linux_logo_blue; 1882 logo_blue = linux_logo_blue;
1887 #endif 1883 #endif
1888 1884
1889 if (VIDEO_DATA_FORMAT == GDF__8BIT_INDEX) { 1885 if (VIDEO_DATA_FORMAT == GDF__8BIT_INDEX) {
1890 for (i = 0; i < VIDEO_LOGO_COLORS; i++) { 1886 for (i = 0; i < VIDEO_LOGO_COLORS; i++) {
1891 video_set_lut(i + VIDEO_LOGO_LUT_OFFSET, 1887 video_set_lut(i + VIDEO_LOGO_LUT_OFFSET,
1892 logo_red[i], logo_green[i], 1888 logo_red[i], logo_green[i],
1893 logo_blue[i]); 1889 logo_blue[i]);
1894 } 1890 }
1895 } 1891 }
1896 1892
1897 while (ycount--) { 1893 while (ycount--) {
1898 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP) 1894 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
1899 int xpos = x; 1895 int xpos = x;
1900 #endif 1896 #endif
1901 xcount = VIDEO_LOGO_WIDTH; 1897 xcount = VIDEO_LOGO_WIDTH;
1902 while (xcount--) { 1898 while (xcount--) {
1903 if (black) { 1899 if (black) {
1904 r = 0x00; 1900 r = 0x00;
1905 g = 0x00; 1901 g = 0x00;
1906 b = 0x00; 1902 b = 0x00;
1907 } else { 1903 } else {
1908 r = logo_red[*source - VIDEO_LOGO_LUT_OFFSET]; 1904 r = logo_red[*source - VIDEO_LOGO_LUT_OFFSET];
1909 g = logo_green[*source - VIDEO_LOGO_LUT_OFFSET]; 1905 g = logo_green[*source - VIDEO_LOGO_LUT_OFFSET];
1910 b = logo_blue[*source - VIDEO_LOGO_LUT_OFFSET]; 1906 b = logo_blue[*source - VIDEO_LOGO_LUT_OFFSET];
1911 } 1907 }
1912 1908
1913 switch (VIDEO_DATA_FORMAT) { 1909 switch (VIDEO_DATA_FORMAT) {
1914 case GDF__8BIT_INDEX: 1910 case GDF__8BIT_INDEX:
1915 *dest = *source; 1911 *dest = *source;
1916 break; 1912 break;
1917 case GDF__8BIT_332RGB: 1913 case GDF__8BIT_332RGB:
1918 *dest = ((r >> 5) << 5) | 1914 *dest = ((r >> 5) << 5) |
1919 ((g >> 5) << 2) | 1915 ((g >> 5) << 2) |
1920 (b >> 6); 1916 (b >> 6);
1921 break; 1917 break;
1922 case GDF_15BIT_555RGB: 1918 case GDF_15BIT_555RGB:
1923 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP) 1919 #if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
1924 fill_555rgb_pswap(dest, xpos++, r, g, b); 1920 fill_555rgb_pswap(dest, xpos++, r, g, b);
1925 #else 1921 #else
1926 *(unsigned short *) dest = 1922 *(unsigned short *) dest =
1927 SWAP16((unsigned short) ( 1923 SWAP16((unsigned short) (
1928 ((r >> 3) << 10) | 1924 ((r >> 3) << 10) |
1929 ((g >> 3) << 5) | 1925 ((g >> 3) << 5) |
1930 (b >> 3))); 1926 (b >> 3)));
1931 #endif 1927 #endif
1932 break; 1928 break;
1933 case GDF_16BIT_565RGB: 1929 case GDF_16BIT_565RGB:
1934 *(unsigned short *) dest = 1930 *(unsigned short *) dest =
1935 SWAP16((unsigned short) ( 1931 SWAP16((unsigned short) (
1936 ((r >> 3) << 11) | 1932 ((r >> 3) << 11) |
1937 ((g >> 2) << 5) | 1933 ((g >> 2) << 5) |
1938 (b >> 3))); 1934 (b >> 3)));
1939 break; 1935 break;
1940 case GDF_32BIT_X888RGB: 1936 case GDF_32BIT_X888RGB:
1941 *(unsigned long *) dest = 1937 *(unsigned long *) dest =
1942 SWAP32((unsigned long) ( 1938 SWAP32((unsigned long) (
1943 (r << 16) | 1939 (r << 16) |
1944 (g << 8) | 1940 (g << 8) |
1945 b)); 1941 b));
1946 break; 1942 break;
1947 case GDF_24BIT_888RGB: 1943 case GDF_24BIT_888RGB:
1948 #ifdef VIDEO_FB_LITTLE_ENDIAN 1944 #ifdef VIDEO_FB_LITTLE_ENDIAN
1949 dest[0] = b; 1945 dest[0] = b;
1950 dest[1] = g; 1946 dest[1] = g;
1951 dest[2] = r; 1947 dest[2] = r;
1952 #else 1948 #else
1953 dest[0] = r; 1949 dest[0] = r;
1954 dest[1] = g; 1950 dest[1] = g;
1955 dest[2] = b; 1951 dest[2] = b;
1956 #endif 1952 #endif
1957 break; 1953 break;
1958 } 1954 }
1959 source++; 1955 source++;
1960 dest += VIDEO_PIXEL_SIZE; 1956 dest += VIDEO_PIXEL_SIZE;
1961 } 1957 }
1962 dest += skip; 1958 dest += skip;
1963 } 1959 }
1964 #ifdef CONFIG_VIDEO_BMP_LOGO 1960 #ifdef CONFIG_VIDEO_BMP_LOGO
1965 free(logo_red); 1961 free(logo_red);
1966 free(logo_green); 1962 free(logo_green);
1967 free(logo_blue); 1963 free(logo_blue);
1968 #endif 1964 #endif
1969 } 1965 }
1970 1966
1971 static void *video_logo(void) 1967 static void *video_logo(void)
1972 { 1968 {
1973 char info[128]; 1969 char info[128];
1974 int space, len; 1970 int space, len;
1975 __maybe_unused int y_off = 0; 1971 __maybe_unused int y_off = 0;
1976 __maybe_unused ulong addr; 1972 __maybe_unused ulong addr;
1977 __maybe_unused char *s; 1973 __maybe_unused char *s;
1978 1974
1979 #ifdef CONFIG_SPLASH_SCREEN_ALIGN 1975 splash_get_pos(&video_logo_xpos, &video_logo_ypos);
1980 s = getenv("splashpos");
1981 if (s != NULL) {
1982 if (s[0] == 'm')
1983 video_logo_xpos = BMP_ALIGN_CENTER;
1984 else
1985 video_logo_xpos = simple_strtol(s, NULL, 0);
1986
1987 s = strchr(s + 1, ',');
1988 if (s != NULL) {
1989 if (s[1] == 'm')
1990 video_logo_ypos = BMP_ALIGN_CENTER;
1991 else
1992 video_logo_ypos = simple_strtol(s + 1, NULL, 0);
1993 }
1994 }
1995 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
1996 1976
1997 #ifdef CONFIG_SPLASH_SCREEN 1977 #ifdef CONFIG_SPLASH_SCREEN
1998 s = getenv("splashimage"); 1978 s = getenv("splashimage");
1999 if (s != NULL) { 1979 if (s != NULL) {
2000 splash_screen_prepare(); 1980 splash_screen_prepare();
2001 addr = simple_strtoul(s, NULL, 16); 1981 addr = simple_strtoul(s, NULL, 16);
2002 1982
2003 if (video_display_bitmap(addr, 1983 if (video_display_bitmap(addr,
2004 video_logo_xpos, 1984 video_logo_xpos,
2005 video_logo_ypos) == 0) { 1985 video_logo_ypos) == 0) {
2006 video_logo_height = 0; 1986 video_logo_height = 0;
2007 return ((void *) (video_fb_address)); 1987 return ((void *) (video_fb_address));
2008 } 1988 }
2009 } 1989 }
2010 #endif /* CONFIG_SPLASH_SCREEN */ 1990 #endif /* CONFIG_SPLASH_SCREEN */
2011 1991
2012 logo_plot(video_fb_address, VIDEO_COLS, 1992 logo_plot(video_fb_address, VIDEO_COLS,
2013 video_logo_xpos, video_logo_ypos); 1993 video_logo_xpos, video_logo_ypos);
2014 1994
2015 #ifdef CONFIG_SPLASH_SCREEN_ALIGN 1995 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
2016 /* 1996 /*
2017 * when using splashpos for video_logo, skip any info 1997 * when using splashpos for video_logo, skip any info
2018 * output on video console if the logo is not at 0,0 1998 * output on video console if the logo is not at 0,0
2019 */ 1999 */
2020 if (video_logo_xpos || video_logo_ypos) { 2000 if (video_logo_xpos || video_logo_ypos) {
2021 /* 2001 /*
2022 * video_logo_height is used in text and cursor offset 2002 * video_logo_height is used in text and cursor offset
2023 * calculations. Since the console is below the logo, 2003 * calculations. Since the console is below the logo,
2024 * we need to adjust the logo height 2004 * we need to adjust the logo height
2025 */ 2005 */
2026 if (video_logo_ypos == BMP_ALIGN_CENTER) 2006 if (video_logo_ypos == BMP_ALIGN_CENTER)
2027 video_logo_height += max(0, (VIDEO_VISIBLE_ROWS - \ 2007 video_logo_height += max(0, (VIDEO_VISIBLE_ROWS - \
2028 VIDEO_LOGO_HEIGHT) / 2); 2008 VIDEO_LOGO_HEIGHT) / 2);
2029 else if (video_logo_ypos > 0) 2009 else if (video_logo_ypos > 0)
2030 video_logo_height += video_logo_ypos; 2010 video_logo_height += video_logo_ypos;
2031 2011
2032 return video_fb_address + video_logo_height * VIDEO_LINE_LEN; 2012 return video_fb_address + video_logo_height * VIDEO_LINE_LEN;
2033 } 2013 }
2034 #endif 2014 #endif
2035 2015
2036 sprintf(info, " %s", version_string); 2016 sprintf(info, " %s", version_string);
2037 2017
2038 space = (VIDEO_LINE_LEN / 2 - VIDEO_INFO_X) / VIDEO_FONT_WIDTH; 2018 space = (VIDEO_LINE_LEN / 2 - VIDEO_INFO_X) / VIDEO_FONT_WIDTH;
2039 len = strlen(info); 2019 len = strlen(info);
2040 2020
2041 if (len > space) { 2021 if (len > space) {
2042 video_drawchars(VIDEO_INFO_X, VIDEO_INFO_Y, 2022 video_drawchars(VIDEO_INFO_X, VIDEO_INFO_Y,
2043 (uchar *) info, space); 2023 (uchar *) info, space);
2044 video_drawchars(VIDEO_INFO_X + VIDEO_FONT_WIDTH, 2024 video_drawchars(VIDEO_INFO_X + VIDEO_FONT_WIDTH,
2045 VIDEO_INFO_Y + VIDEO_FONT_HEIGHT, 2025 VIDEO_INFO_Y + VIDEO_FONT_HEIGHT,
2046 (uchar *) info + space, len - space); 2026 (uchar *) info + space, len - space);
2047 y_off = 1; 2027 y_off = 1;
2048 } else 2028 } else
2049 video_drawstring(VIDEO_INFO_X, VIDEO_INFO_Y, (uchar *) info); 2029 video_drawstring(VIDEO_INFO_X, VIDEO_INFO_Y, (uchar *) info);
2050 2030
2051 #ifdef CONFIG_CONSOLE_EXTRA_INFO 2031 #ifdef CONFIG_CONSOLE_EXTRA_INFO
2052 { 2032 {
2053 int i, n = 2033 int i, n =
2054 ((video_logo_height - 2034 ((video_logo_height -
2055 VIDEO_FONT_HEIGHT) / VIDEO_FONT_HEIGHT); 2035 VIDEO_FONT_HEIGHT) / VIDEO_FONT_HEIGHT);
2056 2036
2057 for (i = 1; i < n; i++) { 2037 for (i = 1; i < n; i++) {
2058 video_get_info_str(i, info); 2038 video_get_info_str(i, info);
2059 if (!*info) 2039 if (!*info)
2060 continue; 2040 continue;
2061 2041
2062 len = strlen(info); 2042 len = strlen(info);
2063 if (len > space) { 2043 if (len > space) {
2064 video_drawchars(VIDEO_INFO_X, 2044 video_drawchars(VIDEO_INFO_X,
2065 VIDEO_INFO_Y + 2045 VIDEO_INFO_Y +
2066 (i + y_off) * 2046 (i + y_off) *
2067 VIDEO_FONT_HEIGHT, 2047 VIDEO_FONT_HEIGHT,
2068 (uchar *) info, space); 2048 (uchar *) info, space);
2069 y_off++; 2049 y_off++;
2070 video_drawchars(VIDEO_INFO_X + 2050 video_drawchars(VIDEO_INFO_X +
2071 VIDEO_FONT_WIDTH, 2051 VIDEO_FONT_WIDTH,
2072 VIDEO_INFO_Y + 2052 VIDEO_INFO_Y +
2073 (i + y_off) * 2053 (i + y_off) *
2074 VIDEO_FONT_HEIGHT, 2054 VIDEO_FONT_HEIGHT,
2075 (uchar *) info + space, 2055 (uchar *) info + space,
2076 len - space); 2056 len - space);
2077 } else { 2057 } else {
2078 video_drawstring(VIDEO_INFO_X, 2058 video_drawstring(VIDEO_INFO_X,
2079 VIDEO_INFO_Y + 2059 VIDEO_INFO_Y +
2080 (i + y_off) * 2060 (i + y_off) *
2081 VIDEO_FONT_HEIGHT, 2061 VIDEO_FONT_HEIGHT,
2082 (uchar *) info); 2062 (uchar *) info);
2083 } 2063 }
2084 } 2064 }
2085 } 2065 }
2086 #endif 2066 #endif
2087 2067
2088 return (video_fb_address + video_logo_height * VIDEO_LINE_LEN); 2068 return (video_fb_address + video_logo_height * VIDEO_LINE_LEN);
2089 } 2069 }
2090 #endif 2070 #endif
2091 2071
2092 static int cfb_fb_is_in_dram(void) 2072 static int cfb_fb_is_in_dram(void)
2093 { 2073 {
2094 bd_t *bd = gd->bd; 2074 bd_t *bd = gd->bd;
2095 #if defined(CONFIG_ARM) || defined(CONFIG_AVR32) || defined(COFNIG_NDS32) || \ 2075 #if defined(CONFIG_ARM) || defined(CONFIG_AVR32) || defined(COFNIG_NDS32) || \
2096 defined(CONFIG_SANDBOX) || defined(CONFIG_X86) 2076 defined(CONFIG_SANDBOX) || defined(CONFIG_X86)
2097 ulong start, end; 2077 ulong start, end;
2098 int i; 2078 int i;
2099 2079
2100 for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) { 2080 for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
2101 start = bd->bi_dram[i].start; 2081 start = bd->bi_dram[i].start;
2102 end = bd->bi_dram[i].start + bd->bi_dram[i].size - 1; 2082 end = bd->bi_dram[i].start + bd->bi_dram[i].size - 1;
2103 if ((ulong)video_fb_address >= start && 2083 if ((ulong)video_fb_address >= start &&
2104 (ulong)video_fb_address < end) 2084 (ulong)video_fb_address < end)
2105 return 1; 2085 return 1;
2106 } 2086 }
2107 #else 2087 #else
2108 if ((ulong)video_fb_address >= bd->bi_memstart && 2088 if ((ulong)video_fb_address >= bd->bi_memstart &&
2109 (ulong)video_fb_address < bd->bi_memstart + bd->bi_memsize) 2089 (ulong)video_fb_address < bd->bi_memstart + bd->bi_memsize)
2110 return 1; 2090 return 1;
2111 #endif 2091 #endif
2112 return 0; 2092 return 0;
2113 } 2093 }
2114 2094
2115 static int video_init(void) 2095 static int video_init(void)
2116 { 2096 {
2117 unsigned char color8; 2097 unsigned char color8;
2118 2098
2119 pGD = video_hw_init(); 2099 pGD = video_hw_init();
2120 if (pGD == NULL) 2100 if (pGD == NULL)
2121 return -1; 2101 return -1;
2122 2102
2123 video_fb_address = (void *) VIDEO_FB_ADRS; 2103 video_fb_address = (void *) VIDEO_FB_ADRS;
2124 #ifdef CONFIG_VIDEO_HW_CURSOR 2104 #ifdef CONFIG_VIDEO_HW_CURSOR
2125 video_init_hw_cursor(VIDEO_FONT_WIDTH, VIDEO_FONT_HEIGHT); 2105 video_init_hw_cursor(VIDEO_FONT_WIDTH, VIDEO_FONT_HEIGHT);
2126 #endif 2106 #endif
2127 2107
2128 cfb_do_flush_cache = cfb_fb_is_in_dram() && dcache_status(); 2108 cfb_do_flush_cache = cfb_fb_is_in_dram() && dcache_status();
2129 2109
2130 /* Init drawing pats */ 2110 /* Init drawing pats */
2131 switch (VIDEO_DATA_FORMAT) { 2111 switch (VIDEO_DATA_FORMAT) {
2132 case GDF__8BIT_INDEX: 2112 case GDF__8BIT_INDEX:
2133 video_set_lut(0x01, CONSOLE_FG_COL, CONSOLE_FG_COL, 2113 video_set_lut(0x01, CONSOLE_FG_COL, CONSOLE_FG_COL,
2134 CONSOLE_FG_COL); 2114 CONSOLE_FG_COL);
2135 video_set_lut(0x00, CONSOLE_BG_COL, CONSOLE_BG_COL, 2115 video_set_lut(0x00, CONSOLE_BG_COL, CONSOLE_BG_COL,
2136 CONSOLE_BG_COL); 2116 CONSOLE_BG_COL);
2137 fgx = 0x01010101; 2117 fgx = 0x01010101;
2138 bgx = 0x00000000; 2118 bgx = 0x00000000;
2139 break; 2119 break;
2140 case GDF__8BIT_332RGB: 2120 case GDF__8BIT_332RGB:
2141 color8 = ((CONSOLE_FG_COL & 0xe0) | 2121 color8 = ((CONSOLE_FG_COL & 0xe0) |
2142 ((CONSOLE_FG_COL >> 3) & 0x1c) | 2122 ((CONSOLE_FG_COL >> 3) & 0x1c) |
2143 CONSOLE_FG_COL >> 6); 2123 CONSOLE_FG_COL >> 6);
2144 fgx = (color8 << 24) | (color8 << 16) | (color8 << 8) | 2124 fgx = (color8 << 24) | (color8 << 16) | (color8 << 8) |
2145 color8; 2125 color8;
2146 color8 = ((CONSOLE_BG_COL & 0xe0) | 2126 color8 = ((CONSOLE_BG_COL & 0xe0) |
2147 ((CONSOLE_BG_COL >> 3) & 0x1c) | 2127 ((CONSOLE_BG_COL >> 3) & 0x1c) |
2148 CONSOLE_BG_COL >> 6); 2128 CONSOLE_BG_COL >> 6);
2149 bgx = (color8 << 24) | (color8 << 16) | (color8 << 8) | 2129 bgx = (color8 << 24) | (color8 << 16) | (color8 << 8) |
2150 color8; 2130 color8;
2151 break; 2131 break;
2152 case GDF_15BIT_555RGB: 2132 case GDF_15BIT_555RGB:
2153 fgx = (((CONSOLE_FG_COL >> 3) << 26) | 2133 fgx = (((CONSOLE_FG_COL >> 3) << 26) |
2154 ((CONSOLE_FG_COL >> 3) << 21) | 2134 ((CONSOLE_FG_COL >> 3) << 21) |
2155 ((CONSOLE_FG_COL >> 3) << 16) | 2135 ((CONSOLE_FG_COL >> 3) << 16) |
2156 ((CONSOLE_FG_COL >> 3) << 10) | 2136 ((CONSOLE_FG_COL >> 3) << 10) |
2157 ((CONSOLE_FG_COL >> 3) << 5) | 2137 ((CONSOLE_FG_COL >> 3) << 5) |
2158 (CONSOLE_FG_COL >> 3)); 2138 (CONSOLE_FG_COL >> 3));
2159 bgx = (((CONSOLE_BG_COL >> 3) << 26) | 2139 bgx = (((CONSOLE_BG_COL >> 3) << 26) |
2160 ((CONSOLE_BG_COL >> 3) << 21) | 2140 ((CONSOLE_BG_COL >> 3) << 21) |
2161 ((CONSOLE_BG_COL >> 3) << 16) | 2141 ((CONSOLE_BG_COL >> 3) << 16) |
2162 ((CONSOLE_BG_COL >> 3) << 10) | 2142 ((CONSOLE_BG_COL >> 3) << 10) |
2163 ((CONSOLE_BG_COL >> 3) << 5) | 2143 ((CONSOLE_BG_COL >> 3) << 5) |
2164 (CONSOLE_BG_COL >> 3)); 2144 (CONSOLE_BG_COL >> 3));
2165 break; 2145 break;
2166 case GDF_16BIT_565RGB: 2146 case GDF_16BIT_565RGB:
2167 fgx = (((CONSOLE_FG_COL >> 3) << 27) | 2147 fgx = (((CONSOLE_FG_COL >> 3) << 27) |
2168 ((CONSOLE_FG_COL >> 2) << 21) | 2148 ((CONSOLE_FG_COL >> 2) << 21) |
2169 ((CONSOLE_FG_COL >> 3) << 16) | 2149 ((CONSOLE_FG_COL >> 3) << 16) |
2170 ((CONSOLE_FG_COL >> 3) << 11) | 2150 ((CONSOLE_FG_COL >> 3) << 11) |
2171 ((CONSOLE_FG_COL >> 2) << 5) | 2151 ((CONSOLE_FG_COL >> 2) << 5) |
2172 (CONSOLE_FG_COL >> 3)); 2152 (CONSOLE_FG_COL >> 3));
2173 bgx = (((CONSOLE_BG_COL >> 3) << 27) | 2153 bgx = (((CONSOLE_BG_COL >> 3) << 27) |
2174 ((CONSOLE_BG_COL >> 2) << 21) | 2154 ((CONSOLE_BG_COL >> 2) << 21) |
2175 ((CONSOLE_BG_COL >> 3) << 16) | 2155 ((CONSOLE_BG_COL >> 3) << 16) |
2176 ((CONSOLE_BG_COL >> 3) << 11) | 2156 ((CONSOLE_BG_COL >> 3) << 11) |
2177 ((CONSOLE_BG_COL >> 2) << 5) | 2157 ((CONSOLE_BG_COL >> 2) << 5) |
2178 (CONSOLE_BG_COL >> 3)); 2158 (CONSOLE_BG_COL >> 3));
2179 break; 2159 break;
2180 case GDF_32BIT_X888RGB: 2160 case GDF_32BIT_X888RGB:
2181 fgx = (CONSOLE_FG_COL << 16) | 2161 fgx = (CONSOLE_FG_COL << 16) |
2182 (CONSOLE_FG_COL << 8) | 2162 (CONSOLE_FG_COL << 8) |
2183 CONSOLE_FG_COL; 2163 CONSOLE_FG_COL;
2184 bgx = (CONSOLE_BG_COL << 16) | 2164 bgx = (CONSOLE_BG_COL << 16) |
2185 (CONSOLE_BG_COL << 8) | 2165 (CONSOLE_BG_COL << 8) |
2186 CONSOLE_BG_COL; 2166 CONSOLE_BG_COL;
2187 break; 2167 break;
2188 case GDF_24BIT_888RGB: 2168 case GDF_24BIT_888RGB:
2189 fgx = (CONSOLE_FG_COL << 24) | 2169 fgx = (CONSOLE_FG_COL << 24) |
2190 (CONSOLE_FG_COL << 16) | 2170 (CONSOLE_FG_COL << 16) |
2191 (CONSOLE_FG_COL << 8) | 2171 (CONSOLE_FG_COL << 8) |
2192 CONSOLE_FG_COL; 2172 CONSOLE_FG_COL;
2193 bgx = (CONSOLE_BG_COL << 24) | 2173 bgx = (CONSOLE_BG_COL << 24) |
2194 (CONSOLE_BG_COL << 16) | 2174 (CONSOLE_BG_COL << 16) |
2195 (CONSOLE_BG_COL << 8) | 2175 (CONSOLE_BG_COL << 8) |
2196 CONSOLE_BG_COL; 2176 CONSOLE_BG_COL;
2197 break; 2177 break;
2198 } 2178 }
2199 eorx = fgx ^ bgx; 2179 eorx = fgx ^ bgx;
2200 2180
2201 #ifdef CONFIG_VIDEO_LOGO 2181 #ifdef CONFIG_VIDEO_LOGO
2202 /* Plot the logo and get start point of console */ 2182 /* Plot the logo and get start point of console */
2203 debug("Video: Drawing the logo ...\n"); 2183 debug("Video: Drawing the logo ...\n");
2204 video_console_address = video_logo(); 2184 video_console_address = video_logo();
2205 #else 2185 #else
2206 video_console_address = video_fb_address; 2186 video_console_address = video_fb_address;
2207 #endif 2187 #endif
2208 2188
2209 /* Initialize the console */ 2189 /* Initialize the console */
2210 console_col = 0; 2190 console_col = 0;
2211 console_row = 0; 2191 console_row = 0;
2212 2192
2213 if (cfb_do_flush_cache) 2193 if (cfb_do_flush_cache)
2214 flush_cache(VIDEO_FB_ADRS, VIDEO_SIZE); 2194 flush_cache(VIDEO_FB_ADRS, VIDEO_SIZE);
2215 2195
2216 return 0; 2196 return 0;
2217 } 2197 }
2218 2198
2219 /* 2199 /*
2220 * Implement a weak default function for boards that optionally 2200 * Implement a weak default function for boards that optionally
2221 * need to skip the video initialization. 2201 * need to skip the video initialization.
2222 */ 2202 */
2223 int __board_video_skip(void) 2203 int __board_video_skip(void)
2224 { 2204 {
2225 /* As default, don't skip test */ 2205 /* As default, don't skip test */
2226 return 0; 2206 return 0;
2227 } 2207 }
2228 2208
2229 int board_video_skip(void) 2209 int board_video_skip(void)
2230 __attribute__ ((weak, alias("__board_video_skip"))); 2210 __attribute__ ((weak, alias("__board_video_skip")));
2231 2211
2232 int drv_video_init(void) 2212 int drv_video_init(void)
2233 { 2213 {
2234 int skip_dev_init; 2214 int skip_dev_init;
2235 struct stdio_dev console_dev; 2215 struct stdio_dev console_dev;
2236 2216
2237 /* Check if video initialization should be skipped */ 2217 /* Check if video initialization should be skipped */
2238 if (board_video_skip()) 2218 if (board_video_skip())
2239 return 0; 2219 return 0;
2240 2220
2241 /* Init video chip - returns with framebuffer cleared */ 2221 /* Init video chip - returns with framebuffer cleared */
2242 skip_dev_init = (video_init() == -1); 2222 skip_dev_init = (video_init() == -1);
2243 2223
2244 #if !defined(CONFIG_VGA_AS_SINGLE_DEVICE) 2224 #if !defined(CONFIG_VGA_AS_SINGLE_DEVICE)
2245 debug("KBD: Keyboard init ...\n"); 2225 debug("KBD: Keyboard init ...\n");
2246 skip_dev_init |= (VIDEO_KBD_INIT_FCT == -1); 2226 skip_dev_init |= (VIDEO_KBD_INIT_FCT == -1);
2247 #endif 2227 #endif
2248 2228
2249 if (skip_dev_init) 2229 if (skip_dev_init)
2250 return 0; 2230 return 0;
2251 2231
2252 /* Init vga device */ 2232 /* Init vga device */
2253 memset(&console_dev, 0, sizeof(console_dev)); 2233 memset(&console_dev, 0, sizeof(console_dev));
2254 strcpy(console_dev.name, "vga"); 2234 strcpy(console_dev.name, "vga");
2255 console_dev.ext = DEV_EXT_VIDEO; /* Video extensions */ 2235 console_dev.ext = DEV_EXT_VIDEO; /* Video extensions */
2256 console_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_SYSTEM; 2236 console_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_SYSTEM;
2257 console_dev.putc = video_putc; /* 'putc' function */ 2237 console_dev.putc = video_putc; /* 'putc' function */
2258 console_dev.puts = video_puts; /* 'puts' function */ 2238 console_dev.puts = video_puts; /* 'puts' function */
2259 console_dev.tstc = NULL; /* 'tstc' function */ 2239 console_dev.tstc = NULL; /* 'tstc' function */
2260 console_dev.getc = NULL; /* 'getc' function */ 2240 console_dev.getc = NULL; /* 'getc' function */
2261 2241
2262 #if !defined(CONFIG_VGA_AS_SINGLE_DEVICE) 2242 #if !defined(CONFIG_VGA_AS_SINGLE_DEVICE)
2263 /* Also init console device */ 2243 /* Also init console device */
2264 console_dev.flags |= DEV_FLAGS_INPUT; 2244 console_dev.flags |= DEV_FLAGS_INPUT;
2265 console_dev.tstc = VIDEO_TSTC_FCT; /* 'tstc' function */ 2245 console_dev.tstc = VIDEO_TSTC_FCT; /* 'tstc' function */
2266 console_dev.getc = VIDEO_GETC_FCT; /* 'getc' function */ 2246 console_dev.getc = VIDEO_GETC_FCT; /* 'getc' function */
2267 #endif /* CONFIG_VGA_AS_SINGLE_DEVICE */ 2247 #endif /* CONFIG_VGA_AS_SINGLE_DEVICE */
2268 2248
2269 if (stdio_register(&console_dev) != 0) 2249 if (stdio_register(&console_dev) != 0)
2270 return 0; 2250 return 0;
2271 2251
2272 /* Return success */ 2252 /* Return success */
2273 return 1; 2253 return 1;
2274 } 2254 }
2275 2255
2276 void video_position_cursor(unsigned col, unsigned row) 2256 void video_position_cursor(unsigned col, unsigned row)
2277 { 2257 {
2278 console_col = min(col, CONSOLE_COLS - 1); 2258 console_col = min(col, CONSOLE_COLS - 1);
2279 console_row = min(row, CONSOLE_ROWS - 1); 2259 console_row = min(row, CONSOLE_ROWS - 1);
2280 } 2260 }
2281 2261
2282 int video_get_pixel_width(void) 2262 int video_get_pixel_width(void)
2283 { 2263 {
2284 return VIDEO_VISIBLE_COLS; 2264 return VIDEO_VISIBLE_COLS;
2285 } 2265 }
2286 2266
2287 int video_get_pixel_height(void) 2267 int video_get_pixel_height(void)
2288 { 2268 {
2289 return VIDEO_VISIBLE_ROWS; 2269 return VIDEO_VISIBLE_ROWS;
2290 } 2270 }
2291 2271
2292 int video_get_screen_rows(void) 2272 int video_get_screen_rows(void)
2293 { 2273 {
2294 return CONSOLE_ROWS; 2274 return CONSOLE_ROWS;
2295 } 2275 }
2296 2276
2297 int video_get_screen_columns(void) 2277 int video_get_screen_columns(void)
2298 { 2278 {
2299 return CONSOLE_COLS; 2279 return CONSOLE_COLS;
2300 } 2280 }
2301 2281
2302 void video_clear(void) 2282 void video_clear(void)
2303 { 2283 {
2304 if (!video_fb_address) 2284 if (!video_fb_address)
2305 return; 2285 return;
2306 #ifdef VIDEO_HW_RECTFILL 2286 #ifdef VIDEO_HW_RECTFILL
2307 video_hw_rectfill(VIDEO_PIXEL_SIZE, /* bytes per pixel */ 2287 video_hw_rectfill(VIDEO_PIXEL_SIZE, /* bytes per pixel */
2308 0, /* dest pos x */ 2288 0, /* dest pos x */
2309 0, /* dest pos y */ 2289 0, /* dest pos y */
2310 VIDEO_VISIBLE_COLS, /* frame width */ 2290 VIDEO_VISIBLE_COLS, /* frame width */
2311 VIDEO_VISIBLE_ROWS, /* frame height */ 2291 VIDEO_VISIBLE_ROWS, /* frame height */
2312 bgx /* fill color */ 2292 bgx /* fill color */
2313 ); 2293 );
2314 #else 2294 #else
2315 memsetl(video_fb_address, 2295 memsetl(video_fb_address,
2316 (VIDEO_VISIBLE_ROWS * VIDEO_LINE_LEN) / sizeof(int), bgx); 2296 (VIDEO_VISIBLE_ROWS * VIDEO_LINE_LEN) / sizeof(int), bgx);
2317 #endif 2297 #endif
2318 } 2298 }
2319 2299
1 /* 1 /*
2 * Copyright (C) 2013, Boundary Devices <info@boundarydevices.com> 2 * Copyright (C) 2013, Boundary Devices <info@boundarydevices.com>
3 * 3 *
4 * See file CREDITS for list of people who contributed to this 4 * See file CREDITS for list of people who contributed to this
5 * project. 5 * project.
6 * 6 *
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as 8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of 9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version. 10 * the License, or (at your option) any later version.
11 * 11 *
12 * This program is distributed in the hope that it will be useful, 12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License 17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., http://www.fsf.org/about/contact/ 19 * Foundation, Inc., http://www.fsf.org/about/contact/
20 */ 20 */
21 21
22 #ifndef _SPLASH_H_ 22 #ifndef _SPLASH_H_
23 #define _SPLASH_H_ 23 #define _SPLASH_H_
24 24
25 25
26 int splash_screen_prepare(void); 26 int splash_screen_prepare(void);
27 27
28 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
29 void splash_get_pos(int *x, int *y);
30 #else
31 static inline void splash_get_pos(int *x, int *y) { }
32 #endif
33
34 #define BMP_ALIGN_CENTER 0x7FFF
28 35
29 #endif 36 #endif
30 37