Commit 8655b6f8603f12099e534a10f7840630b3e93026
1 parent
30d56fae23
Exists in
master
and in
54 other branches
* Clean up tools/bmp_logo.c to not add trailing white space
* Patch by Hinko Kocevar, 21 Aug 2004: - Group common framebuffer functions in common/lcd.c - Group common framebuffer macros and #defines in include/lcd.h - Provide calc_fbsize() for video ATAG
Showing 10 changed files with 1205 additions and 1608 deletions Side-by-side Diff
CHANGELOG
... | ... | @@ -2,13 +2,20 @@ |
2 | 2 | Changes since U-Boot 1.1.1: |
3 | 3 | ====================================================================== |
4 | 4 | |
5 | +* Clean up tools/bmp_logo.c to not add trailing white space | |
6 | + | |
7 | +* Patch by Hinko Kocevar, 21 Aug 2004: | |
8 | + - Group common framebuffer functions in common/lcd.c | |
9 | + - Group common framebuffer macros and #defines in include/lcd.h | |
10 | + - Provide calc_fbsize() for video ATAG | |
11 | + | |
5 | 12 | * Patch by Sam Song, 21 August 2004: |
6 | 13 | - Fix a typo in README |
7 | 14 | - Align "(RO)" output for "flinfo" after "protect on" |
8 | 15 | - Add RESET support for RPXlite_DW board; adjust CPU:BUS frequency |
9 | 16 | ratio 1:1 when core frequency less than 50MHz |
10 | 17 | |
11 | -* Patches by himba, 21 Aug 2004: | |
18 | +* Patches by Hinko Kocevar, 21 Aug 2004: | |
12 | 19 | - fix some "use of label at end of compound statement" warnings |
13 | 20 | - Define type of LCD panel on lubbock board if CONFIG_LCD is used |
14 | 21 |
common/Makefile
... | ... | @@ -27,7 +27,7 @@ |
27 | 27 | |
28 | 28 | AOBJS = |
29 | 29 | |
30 | -COBJS = main.o ACEX1K.o altera.o bedbug.o \ | |
30 | +COBJS = main.o ACEX1K.o altera.o bedbug.o circbuf.o \ | |
31 | 31 | cmd_ace.o cmd_autoscript.o \ |
32 | 32 | cmd_bdinfo.o cmd_bedbug.o cmd_bmp.o cmd_boot.o cmd_bootm.o \ |
33 | 33 | cmd_cache.o cmd_console.o \ |
34 | 34 | |
... | ... | @@ -44,10 +44,11 @@ |
44 | 44 | environment.o env_common.o \ |
45 | 45 | env_nand.o env_dataflash.o env_flash.o env_eeprom.o env_nvram.o env_nowhere.o exports.o \ |
46 | 46 | flash.o fpga.o \ |
47 | - hush.o kgdb.o lists.o lynxkdi.o memsize.o miiphybb.o miiphyutil.o \ | |
47 | + hush.o kgdb.o lcd.o lists.o lynxkdi.o \ | |
48 | + memsize.o miiphybb.o miiphyutil.o \ | |
48 | 49 | s_record.o serial.o soft_i2c.o soft_spi.o spartan2.o \ |
49 | 50 | usb.o usb_kbd.o usb_storage.o \ |
50 | - virtex2.o xilinx.o circbuf.o | |
51 | + virtex2.o xilinx.o | |
51 | 52 | |
52 | 53 | OBJS = $(AOBJS) $(COBJS) |
53 | 54 |
common/cmd_bmp.c
common/lcd.c
1 | +/* | |
2 | + * Common LCD routines for supported CPUs | |
3 | + * | |
4 | + * (C) Copyright 2001-2002 | |
5 | + * Wolfgang Denk, DENX Software Engineering -- wd@denx.de | |
6 | + * | |
7 | + * See file CREDITS for list of people who contributed to this | |
8 | + * project. | |
9 | + * | |
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 | |
12 | + * published by the Free Software Foundation; either version 2 of | |
13 | + * the License, or (at your option) any later version. | |
14 | + * | |
15 | + * This program is distributed in the hope that it will be useful, | |
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | + * GNU General Public License for more details. | |
19 | + * | |
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 | |
22 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | |
23 | + * MA 02111-1307 USA | |
24 | + */ | |
25 | + | |
26 | +/************************************************************************/ | |
27 | +/* ** HEADER FILES */ | |
28 | +/************************************************************************/ | |
29 | + | |
30 | +/* #define DEBUG */ | |
31 | + | |
32 | +#include <config.h> | |
33 | +#include <common.h> | |
34 | +#include <command.h> | |
35 | +#include <version.h> | |
36 | +#include <stdarg.h> | |
37 | +#include <linux/types.h> | |
38 | +#include <devices.h> | |
39 | +#if defined(CONFIG_POST) | |
40 | +#include <post.h> | |
41 | +#endif | |
42 | +#include <lcd.h> | |
43 | + | |
44 | +#if defined(CONFIG_PXA250) | |
45 | +#include <asm/byteorder.h> | |
46 | +#endif | |
47 | + | |
48 | +#if defined(CONFIG_MPC823) | |
49 | +#include <watchdog.h> | |
50 | +#include <lcdvideo.h> | |
51 | +#endif | |
52 | + | |
53 | + | |
54 | +#ifdef CONFIG_LCD | |
55 | + | |
56 | +/************************************************************************/ | |
57 | +/* ** FONT DATA */ | |
58 | +/************************************************************************/ | |
59 | +#include <video_font.h> /* Get font data, width and height */ | |
60 | + | |
61 | + | |
62 | +ulong lcd_setmem (ulong addr); | |
63 | + | |
64 | +static void lcd_drawchars (ushort x, ushort y, uchar *str, int count); | |
65 | +static inline void lcd_puts_xy (ushort x, ushort y, uchar *s); | |
66 | +static inline void lcd_putc_xy (ushort x, ushort y, uchar c); | |
67 | + | |
68 | +static int lcd_init (void *lcdbase); | |
69 | + | |
70 | +static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]); | |
71 | +extern void lcd_ctrl_init (void *lcdbase); | |
72 | +extern void lcd_enable (void); | |
73 | +static void *lcd_logo (void); | |
74 | + | |
75 | + | |
76 | +#if LCD_BPP == LCD_COLOR8 | |
77 | +extern void lcd_setcolreg (ushort regno, | |
78 | + ushort red, ushort green, ushort blue); | |
79 | +#endif | |
80 | +#if LCD_BPP == LCD_MONOCHROME | |
81 | +extern void lcd_initcolregs (void); | |
82 | +#endif | |
83 | + | |
84 | +static int lcd_getbgcolor (void); | |
85 | +static void lcd_setfgcolor (int color); | |
86 | +static void lcd_setbgcolor (int color); | |
87 | + | |
88 | +char lcd_is_enabled = 0; | |
89 | +extern vidinfo_t panel_info; | |
90 | + | |
91 | +#ifdef NOT_USED_SO_FAR | |
92 | +static void lcd_getcolreg (ushort regno, | |
93 | + ushort *red, ushort *green, ushort *blue); | |
94 | +static int lcd_getfgcolor (void); | |
95 | +#endif /* NOT_USED_SO_FAR */ | |
96 | + | |
97 | +/************************************************************************/ | |
98 | + | |
99 | +/*----------------------------------------------------------------------*/ | |
100 | + | |
101 | +static void console_scrollup (void) | |
102 | +{ | |
103 | +#if 1 | |
104 | + /* Copy up rows ignoring the first one */ | |
105 | + memcpy (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, CONSOLE_SCROLL_SIZE); | |
106 | + | |
107 | + /* Clear the last one */ | |
108 | + memset (CONSOLE_ROW_LAST, COLOR_MASK(lcd_color_bg), CONSOLE_ROW_SIZE); | |
109 | +#else | |
110 | + /* | |
111 | + * Poor attempt to optimize speed by moving "long"s. | |
112 | + * But the code is ugly, and not a bit faster :-( | |
113 | + */ | |
114 | + ulong *t = (ulong *)CONSOLE_ROW_FIRST; | |
115 | + ulong *s = (ulong *)CONSOLE_ROW_SECOND; | |
116 | + ulong l = CONSOLE_SCROLL_SIZE / sizeof(ulong); | |
117 | + uchar c = lcd_color_bg & 0xFF; | |
118 | + ulong val= (c<<24) | (c<<16) | (c<<8) | c; | |
119 | + | |
120 | + while (l--) | |
121 | + *t++ = *s++; | |
122 | + | |
123 | + t = (ulong *)CONSOLE_ROW_LAST; | |
124 | + l = CONSOLE_ROW_SIZE / sizeof(ulong); | |
125 | + | |
126 | + while (l-- > 0) | |
127 | + *t++ = val; | |
128 | +#endif | |
129 | +} | |
130 | + | |
131 | +/*----------------------------------------------------------------------*/ | |
132 | + | |
133 | +static inline void console_back (void) | |
134 | +{ | |
135 | + if (--console_col < 0) { | |
136 | + console_col = CONSOLE_COLS-1 ; | |
137 | + if (--console_row < 0) { | |
138 | + console_row = 0; | |
139 | + } | |
140 | + } | |
141 | + | |
142 | + lcd_putc_xy (console_col * VIDEO_FONT_WIDTH, | |
143 | + console_row * VIDEO_FONT_HEIGHT, | |
144 | + ' '); | |
145 | +} | |
146 | + | |
147 | +/*----------------------------------------------------------------------*/ | |
148 | + | |
149 | +static inline void console_newline (void) | |
150 | +{ | |
151 | + ++console_row; | |
152 | + console_col = 0; | |
153 | + | |
154 | + /* Check if we need to scroll the terminal */ | |
155 | + if (console_row >= CONSOLE_ROWS) { | |
156 | + /* Scroll everything up */ | |
157 | + console_scrollup () ; | |
158 | + --console_row; | |
159 | + } | |
160 | +} | |
161 | + | |
162 | +/*----------------------------------------------------------------------*/ | |
163 | + | |
164 | +void lcd_putc (const char c) | |
165 | +{ | |
166 | + if (!lcd_is_enabled) { | |
167 | + serial_putc(c); | |
168 | + return; | |
169 | + } | |
170 | + | |
171 | + switch (c) { | |
172 | + case '\r': console_col = 0; | |
173 | + return; | |
174 | + | |
175 | + case '\n': console_newline(); | |
176 | + return; | |
177 | + | |
178 | + case '\t': /* Tab (8 chars alignment) */ | |
179 | + console_col |= 8; | |
180 | + console_col &= ~7; | |
181 | + | |
182 | + if (console_col >= CONSOLE_COLS) { | |
183 | + console_newline(); | |
184 | + } | |
185 | + return; | |
186 | + | |
187 | + case '\b': console_back(); | |
188 | + return; | |
189 | + | |
190 | + default: lcd_putc_xy (console_col * VIDEO_FONT_WIDTH, | |
191 | + console_row * VIDEO_FONT_HEIGHT, | |
192 | + c); | |
193 | + if (++console_col >= CONSOLE_COLS) { | |
194 | + console_newline(); | |
195 | + } | |
196 | + return; | |
197 | + } | |
198 | + /* NOTREACHED */ | |
199 | +} | |
200 | + | |
201 | +/*----------------------------------------------------------------------*/ | |
202 | + | |
203 | +void lcd_puts (const char *s) | |
204 | +{ | |
205 | + if (!lcd_is_enabled) { | |
206 | + serial_puts (s); | |
207 | + return; | |
208 | + } | |
209 | + | |
210 | + while (*s) { | |
211 | + lcd_putc (*s++); | |
212 | + } | |
213 | +} | |
214 | + | |
215 | +/************************************************************************/ | |
216 | +/* ** Low-Level Graphics Routines */ | |
217 | +/************************************************************************/ | |
218 | + | |
219 | +static void lcd_drawchars (ushort x, ushort y, uchar *str, int count) | |
220 | +{ | |
221 | + uchar *dest; | |
222 | + ushort off, row; | |
223 | + | |
224 | + dest = (uchar *)(lcd_base + y * lcd_line_length + x * (1 << LCD_BPP) / 8); | |
225 | + off = x * (1 << LCD_BPP) % 8; | |
226 | + | |
227 | + for (row=0; row < VIDEO_FONT_HEIGHT; ++row, dest += lcd_line_length) { | |
228 | + uchar *s = str; | |
229 | + uchar *d = dest; | |
230 | + int i; | |
231 | + | |
232 | +#if LCD_BPP == LCD_MONOCHROME | |
233 | + uchar rest = *d & -(1 << (8-off)); | |
234 | + uchar sym; | |
235 | +#endif | |
236 | + for (i=0; i<count; ++i) { | |
237 | + uchar c, bits; | |
238 | + | |
239 | + c = *s++; | |
240 | + bits = video_fontdata[c * VIDEO_FONT_HEIGHT + row]; | |
241 | + | |
242 | +#if LCD_BPP == LCD_MONOCHROME | |
243 | + sym = (COLOR_MASK(lcd_color_fg) & bits) | | |
244 | + (COLOR_MASK(lcd_color_bg) & ~bits); | |
245 | + | |
246 | + *d++ = rest | (sym >> off); | |
247 | + rest = sym << (8-off); | |
248 | +#elif LCD_BPP == LCD_COLOR8 | |
249 | + for (c=0; c<8; ++c) { | |
250 | + *d++ = (bits & 0x80) ? | |
251 | + lcd_color_fg : lcd_color_bg; | |
252 | + bits <<= 1; | |
253 | + } | |
254 | +#elif LCD_BPP == LCD_COLOR16 | |
255 | + for (c=0; c<16; ++c) { | |
256 | + *d++ = (bits & 0x80) ? | |
257 | + lcd_color_fg : lcd_color_bg; | |
258 | + bits <<= 1; | |
259 | + } | |
260 | +#endif | |
261 | + } | |
262 | +#if LCD_BPP == LCD_MONOCHROME | |
263 | + *d = rest | (*d & ((1 << (8-off)) - 1)); | |
264 | +#endif | |
265 | + } | |
266 | +} | |
267 | + | |
268 | +/*----------------------------------------------------------------------*/ | |
269 | + | |
270 | +static inline void lcd_puts_xy (ushort x, ushort y, uchar *s) | |
271 | +{ | |
272 | +#if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO) | |
273 | + lcd_drawchars (x, y+BMP_LOGO_HEIGHT, s, strlen (s)); | |
274 | +#else | |
275 | + lcd_drawchars (x, y, s, strlen (s)); | |
276 | +#endif | |
277 | +} | |
278 | + | |
279 | +/*----------------------------------------------------------------------*/ | |
280 | + | |
281 | +static inline void lcd_putc_xy (ushort x, ushort y, uchar c) | |
282 | +{ | |
283 | +#if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO) | |
284 | + lcd_drawchars (x, y+BMP_LOGO_HEIGHT, &c, 1); | |
285 | +#else | |
286 | + lcd_drawchars (x, y, &c, 1); | |
287 | +#endif | |
288 | +} | |
289 | + | |
290 | +/************************************************************************/ | |
291 | +/** Small utility to check that you got the colours right */ | |
292 | +/************************************************************************/ | |
293 | +#ifdef LCD_TEST_PATTERN | |
294 | + | |
295 | +#define N_BLK_VERT 2 | |
296 | +#define N_BLK_HOR 3 | |
297 | + | |
298 | +static int test_colors[N_BLK_HOR*N_BLK_VERT] = { | |
299 | + CONSOLE_COLOR_RED, CONSOLE_COLOR_GREEN, CONSOLE_COLOR_YELLOW, | |
300 | + CONSOLE_COLOR_BLUE, CONSOLE_COLOR_MAGENTA, CONSOLE_COLOR_CYAN, | |
301 | +}; | |
302 | + | |
303 | +static void test_pattern (void) | |
304 | +{ | |
305 | + ushort v_max = panel_info.vl_row; | |
306 | + ushort h_max = panel_info.vl_col; | |
307 | + ushort v_step = (v_max + N_BLK_VERT - 1) / N_BLK_VERT; | |
308 | + ushort h_step = (h_max + N_BLK_HOR - 1) / N_BLK_HOR; | |
309 | + ushort v, h; | |
310 | + uchar *pix = (uchar *)lcd_base; | |
311 | + | |
312 | + printf ("[LCD] Test Pattern: %d x %d [%d x %d]\n", | |
313 | + h_max, v_max, h_step, v_step); | |
314 | + | |
315 | + /* WARNING: Code silently assumes 8bit/pixel */ | |
316 | + for (v=0; v<v_max; ++v) { | |
317 | + uchar iy = v / v_step; | |
318 | + for (h=0; h<h_max; ++h) { | |
319 | + uchar ix = N_BLK_HOR * iy + (h/h_step); | |
320 | + *pix++ = test_colors[ix]; | |
321 | + } | |
322 | + } | |
323 | +} | |
324 | +#endif /* LCD_TEST_PATTERN */ | |
325 | + | |
326 | + | |
327 | +/************************************************************************/ | |
328 | +/* ** GENERIC Initialization Routines */ | |
329 | +/************************************************************************/ | |
330 | + | |
331 | +int drv_lcd_init (void) | |
332 | +{ | |
333 | + DECLARE_GLOBAL_DATA_PTR; | |
334 | + | |
335 | + device_t lcddev; | |
336 | + int rc; | |
337 | + | |
338 | + lcd_base = (void *)(gd->fb_base); | |
339 | + | |
340 | + lcd_line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8; | |
341 | + | |
342 | + lcd_init (lcd_base); /* LCD initialization */ | |
343 | + | |
344 | + /* Device initialization */ | |
345 | + memset (&lcddev, 0, sizeof (lcddev)); | |
346 | + | |
347 | + strcpy (lcddev.name, "lcd"); | |
348 | + lcddev.ext = 0; /* No extensions */ | |
349 | + lcddev.flags = DEV_FLAGS_OUTPUT; /* Output only */ | |
350 | + lcddev.putc = lcd_putc; /* 'putc' function */ | |
351 | + lcddev.puts = lcd_puts; /* 'puts' function */ | |
352 | + | |
353 | + rc = device_register (&lcddev); | |
354 | + | |
355 | + return (rc == 0) ? 1 : rc; | |
356 | +} | |
357 | + | |
358 | +/*----------------------------------------------------------------------*/ | |
359 | +static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) | |
360 | +{ | |
361 | +#if LCD_BPP == LCD_MONOCHROME | |
362 | + /* Setting the palette */ | |
363 | + lcd_initcolregs(); | |
364 | + | |
365 | +#elif LCD_BPP == LCD_COLOR8 | |
366 | + /* Setting the palette */ | |
367 | + lcd_setcolreg (CONSOLE_COLOR_BLACK, 0, 0, 0); | |
368 | + lcd_setcolreg (CONSOLE_COLOR_RED, 0xFF, 0, 0); | |
369 | + lcd_setcolreg (CONSOLE_COLOR_GREEN, 0, 0xFF, 0); | |
370 | + lcd_setcolreg (CONSOLE_COLOR_YELLOW, 0xFF, 0xFF, 0); | |
371 | + lcd_setcolreg (CONSOLE_COLOR_BLUE, 0, 0, 0xFF); | |
372 | + lcd_setcolreg (CONSOLE_COLOR_MAGENTA, 0xFF, 0, 0xFF); | |
373 | + lcd_setcolreg (CONSOLE_COLOR_CYAN, 0, 0xFF, 0xFF); | |
374 | + lcd_setcolreg (CONSOLE_COLOR_GREY, 0xAA, 0xAA, 0xAA); | |
375 | + lcd_setcolreg (CONSOLE_COLOR_WHITE, 0xFF, 0xFF, 0xFF); | |
376 | +#endif | |
377 | + | |
378 | +#ifndef CFG_WHITE_ON_BLACK | |
379 | + lcd_setfgcolor (CONSOLE_COLOR_BLACK); | |
380 | + lcd_setbgcolor (CONSOLE_COLOR_WHITE); | |
381 | +#else | |
382 | + lcd_setfgcolor (CONSOLE_COLOR_WHITE); | |
383 | + lcd_setbgcolor (CONSOLE_COLOR_BLACK); | |
384 | +#endif /* CFG_WHITE_ON_BLACK */ | |
385 | + | |
386 | +#ifdef LCD_TEST_PATTERN | |
387 | + test_pattern(); | |
388 | +#else | |
389 | + /* set framebuffer to background color */ | |
390 | + memset ((char *)lcd_base, | |
391 | + COLOR_MASK(lcd_getbgcolor()), | |
392 | + lcd_line_length*panel_info.vl_row); | |
393 | +#endif | |
394 | + /* Paint the logo and retrieve LCD base address */ | |
395 | + debug ("[LCD] Drawing the logo...\n"); | |
396 | + lcd_console_address = lcd_logo (); | |
397 | + | |
398 | + console_col = 0; | |
399 | + console_row = 0; | |
400 | + | |
401 | + return (0); | |
402 | +} | |
403 | + | |
404 | +U_BOOT_CMD( | |
405 | + cls, 1, 1, lcd_clear, | |
406 | + "cls - clear screen\n", | |
407 | + NULL | |
408 | +); | |
409 | + | |
410 | +/*----------------------------------------------------------------------*/ | |
411 | + | |
412 | +static int lcd_init (void *lcdbase) | |
413 | +{ | |
414 | + /* Initialize the lcd controller */ | |
415 | + debug ("[LCD] Initializing LCD frambuffer at %p\n", lcdbase); | |
416 | + | |
417 | + lcd_ctrl_init (lcdbase); | |
418 | + lcd_clear (NULL, 1, 1, NULL); /* dummy args */ | |
419 | + lcd_enable (); | |
420 | + | |
421 | + /* Initialize the console */ | |
422 | + console_col = 0; | |
423 | +#ifdef LCD_INFO_BELOW_LOGO | |
424 | + console_row = 7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT; | |
425 | +#else | |
426 | + console_row = 1; /* leave 1 blank line below logo */ | |
427 | +#endif | |
428 | + lcd_is_enabled = 1; | |
429 | + | |
430 | + return 0; | |
431 | +} | |
432 | + | |
433 | + | |
434 | +/************************************************************************/ | |
435 | +/* ** ROM capable initialization part - needed to reserve FB memory */ | |
436 | +/************************************************************************/ | |
437 | +/* | |
438 | + * This is called early in the system initialization to grab memory | |
439 | + * for the LCD controller. | |
440 | + * Returns new address for monitor, after reserving LCD buffer memory | |
441 | + * | |
442 | + * Note that this is running from ROM, so no write access to global data. | |
443 | + */ | |
444 | +ulong lcd_setmem (ulong addr) | |
445 | +{ | |
446 | + ulong size; | |
447 | + int line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8; | |
448 | + | |
449 | + debug ("LCD panel info: %d x %d, %d bit/pix\n", | |
450 | + panel_info.vl_col, panel_info.vl_row, NBITS (panel_info.vl_bpix) ); | |
451 | + | |
452 | + size = line_length * panel_info.vl_row; | |
453 | + | |
454 | + /* Round up to nearest full page */ | |
455 | + size = (size + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); | |
456 | + | |
457 | + /* Allocate pages for the frame buffer. */ | |
458 | + addr -= size; | |
459 | + | |
460 | + debug ("Reserving %ldk for LCD Framebuffer at: %08lx\n", size>>10, addr); | |
461 | + | |
462 | + return (addr); | |
463 | +} | |
464 | + | |
465 | +/*----------------------------------------------------------------------*/ | |
466 | + | |
467 | +static void lcd_setfgcolor (int color) | |
468 | +{ | |
469 | + lcd_color_fg = color & 0x0F; | |
470 | +} | |
471 | + | |
472 | +/*----------------------------------------------------------------------*/ | |
473 | + | |
474 | +static void lcd_setbgcolor (int color) | |
475 | +{ | |
476 | + lcd_color_bg = color & 0x0F; | |
477 | +} | |
478 | + | |
479 | +/*----------------------------------------------------------------------*/ | |
480 | + | |
481 | +#ifdef NOT_USED_SO_FAR | |
482 | +static int lcd_getfgcolor (void) | |
483 | +{ | |
484 | + return lcd_color_fg; | |
485 | +} | |
486 | +#endif /* NOT_USED_SO_FAR */ | |
487 | + | |
488 | +/*----------------------------------------------------------------------*/ | |
489 | + | |
490 | +static int lcd_getbgcolor (void) | |
491 | +{ | |
492 | + return lcd_color_bg; | |
493 | +} | |
494 | + | |
495 | +/*----------------------------------------------------------------------*/ | |
496 | + | |
497 | +/************************************************************************/ | |
498 | +/* ** Chipset depending Bitmap / Logo stuff... */ | |
499 | +/************************************************************************/ | |
500 | +#ifdef CONFIG_LCD_LOGO | |
501 | +void bitmap_plot (int x, int y) | |
502 | +{ | |
503 | + ushort *cmap; | |
504 | + ushort i, j; | |
505 | + uchar *bmap; | |
506 | + uchar *fb; | |
507 | + ushort *fb16; | |
508 | +#if defined(CONFIG_PXA250) | |
509 | + struct pxafb_info *fbi = &panel_info.pxa; | |
510 | +#elif defined(CONFIG_MPC823) | |
511 | + volatile immap_t *immr = (immap_t *) CFG_IMMR; | |
512 | + volatile cpm8xx_t *cp = &(immr->im_cpm); | |
513 | +#endif | |
514 | + | |
515 | + debug ("Logo: width %d height %d colors %d cmap %d\n", | |
516 | + BMP_LOGO_WIDTH, BMP_LOGO_HEIGHT, BMP_LOGO_COLORS, | |
517 | + sizeof(bmp_logo_palette)/(sizeof(ushort))); | |
518 | + | |
519 | + bmap = &bmp_logo_bitmap[0]; | |
520 | + fb = (char *)(lcd_base + y * lcd_line_length + x); | |
521 | + | |
522 | + if (NBITS(panel_info.vl_bpix) < 12) { | |
523 | + /* Leave room for default color map */ | |
524 | +#if defined(CONFIG_PXA250) | |
525 | + cmap = (ushort *)fbi->palette; | |
526 | +#elif defined(CONFIG_MPC823) | |
527 | + cmap = (ushort *)&(cp->lcd_cmap[BMP_LOGO_OFFSET*sizeof(ushort)]); | |
528 | +#endif | |
529 | + | |
530 | + WATCHDOG_RESET(); | |
531 | + | |
532 | + /* Set color map */ | |
533 | + for (i=0; i<(sizeof(bmp_logo_palette)/(sizeof(ushort))); ++i) { | |
534 | + ushort colreg = bmp_logo_palette[i]; | |
535 | +#ifdef CFG_INVERT_COLORS | |
536 | + *cmap++ = 0xffff - colreg; | |
537 | +#else | |
538 | + *cmap++ = colreg; | |
539 | +#endif | |
540 | + } | |
541 | + | |
542 | + WATCHDOG_RESET(); | |
543 | + | |
544 | + for (i=0; i<BMP_LOGO_HEIGHT; ++i) { | |
545 | + memcpy (fb, bmap, BMP_LOGO_WIDTH); | |
546 | + bmap += BMP_LOGO_WIDTH; | |
547 | + fb += panel_info.vl_col; | |
548 | + } | |
549 | + } | |
550 | + else { /* true color mode */ | |
551 | + fb16 = (ushort *)(lcd_base + y * lcd_line_length + x); | |
552 | + for (i=0; i<BMP_LOGO_HEIGHT; ++i) { | |
553 | + for (j=0; j<BMP_LOGO_WIDTH; j++) { | |
554 | + fb16[j] = bmp_logo_palette[(bmap[j])]; | |
555 | + } | |
556 | + bmap += BMP_LOGO_WIDTH; | |
557 | + fb16 += panel_info.vl_col; | |
558 | + } | |
559 | + } | |
560 | + | |
561 | + WATCHDOG_RESET(); | |
562 | +} | |
563 | +#endif /* CONFIG_LCD_LOGO */ | |
564 | + | |
565 | +/*----------------------------------------------------------------------*/ | |
566 | +#if (CONFIG_COMMANDS & CFG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN) | |
567 | +/* | |
568 | + * Display the BMP file located at address bmp_image. | |
569 | + * Only uncompressed. | |
570 | + */ | |
571 | +int lcd_display_bitmap(ulong bmp_image, int x, int y) | |
572 | +{ | |
573 | + ushort *cmap; | |
574 | + ushort i, j; | |
575 | + uchar *fb; | |
576 | + bmp_image_t *bmp=(bmp_image_t *)bmp_image; | |
577 | + uchar *bmap; | |
578 | + ushort padded_line; | |
579 | + unsigned long width, height; | |
580 | + unsigned colors,bpix; | |
581 | + unsigned long compression; | |
582 | +#if defined(CONFIG_PXA250) | |
583 | + struct pxafb_info *fbi = &panel_info.pxa; | |
584 | +#elif defined(CONFIG_MPC823) | |
585 | + volatile immap_t *immr = (immap_t *) CFG_IMMR; | |
586 | + volatile cpm8xx_t *cp = &(immr->im_cpm); | |
587 | +#endif | |
588 | + | |
589 | + if (!((bmp->header.signature[0]=='B') && | |
590 | + (bmp->header.signature[1]=='M'))) { | |
591 | + printf ("Error: no valid bmp image at %lx\n", bmp_image); | |
592 | + return 1; | |
593 | +} | |
594 | + | |
595 | + width = le32_to_cpu (bmp->header.width); | |
596 | + height = le32_to_cpu (bmp->header.height); | |
597 | + colors = 1<<le16_to_cpu (bmp->header.bit_count); | |
598 | + compression = le32_to_cpu (bmp->header.compression); | |
599 | + | |
600 | + bpix = NBITS(panel_info.vl_bpix); | |
601 | + | |
602 | + if ((bpix != 1) && (bpix != 8)) { | |
603 | + printf ("Error: %d bit/pixel mode not supported by U-Boot\n", | |
604 | + bpix); | |
605 | + return 1; | |
606 | + } | |
607 | + | |
608 | + if (bpix != le16_to_cpu(bmp->header.bit_count)) { | |
609 | + printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n", | |
610 | + bpix, | |
611 | + le16_to_cpu(bmp->header.bit_count)); | |
612 | + return 1; | |
613 | + } | |
614 | + | |
615 | + debug ("Display-bmp: %d x %d with %d colors\n", | |
616 | + (int)width, (int)height, (int)colors); | |
617 | + | |
618 | + if (bpix==8) { | |
619 | +#if defined(CONFIG_PXA250) | |
620 | + cmap = (ushort *)fbi->palette; | |
621 | +#elif defined(CONFIG_MPC823) | |
622 | + cmap = (ushort *)&(cp->lcd_cmap[255*sizeof(ushort)]); | |
623 | +#endif | |
624 | + | |
625 | + /* Set color map */ | |
626 | + for (i=0; i<colors; ++i) { | |
627 | + bmp_color_table_entry_t cte = bmp->color_table[i]; | |
628 | + ushort colreg = | |
629 | + ( ((cte.red) << 8) & 0xf800) | | |
630 | + ( ((cte.green) << 4) & 0x07e0) | | |
631 | + ( (cte.blue) & 0x001f) ; | |
632 | + | |
633 | +#ifdef CFG_INVERT_COLORS | |
634 | + *cmap++ = 0xffff - colreg; | |
635 | +#else | |
636 | + *cmap++ = colreg; | |
637 | +#endif | |
638 | + } | |
639 | + } | |
640 | + | |
641 | + padded_line = (width&0x3) ? ((width&~0x3)+4) : (width); | |
642 | + if ((x + width)>panel_info.vl_col) | |
643 | + width = panel_info.vl_col - x; | |
644 | + if ((y + height)>panel_info.vl_row) | |
645 | + height = panel_info.vl_row - y; | |
646 | + | |
647 | + bmap = (uchar *)bmp + le32_to_cpu (bmp->header.data_offset); | |
648 | + fb = (uchar *) (lcd_base + | |
649 | + (y + height - 1) * lcd_line_length + x); | |
650 | + for (i = 0; i < height; ++i) { | |
651 | + for (j = 0; j < width ; j++) | |
652 | +#if defined(CONFIG_PXA250) | |
653 | + *(fb++)=*(bmap++); | |
654 | +#elif defined(CONFIG_MPC823) | |
655 | + *(fb++)=255-*(bmap++); | |
656 | +#endif | |
657 | + bmap += (width - padded_line); | |
658 | + fb -= (width + lcd_line_length); | |
659 | + } | |
660 | + | |
661 | + return (0); | |
662 | +} | |
663 | +#endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) || CONFIG_SPLASH_SCREEN */ | |
664 | + | |
665 | + | |
666 | +static void *lcd_logo (void) | |
667 | +{ | |
668 | +#ifdef LCD_INFO | |
669 | + DECLARE_GLOBAL_DATA_PTR; | |
670 | + | |
671 | + char info[80]; | |
672 | + char temp[32]; | |
673 | +#endif /* LCD_INFO */ | |
674 | + | |
675 | +#ifdef CONFIG_SPLASH_SCREEN | |
676 | + char *s; | |
677 | + ulong addr; | |
678 | + static int do_splash = 1; | |
679 | + | |
680 | + if (do_splash && (s = getenv("splashimage")) != NULL) { | |
681 | + addr = simple_strtoul(s, NULL, 16); | |
682 | + do_splash = 0; | |
683 | + | |
684 | + if (lcd_display_bitmap (addr, 0, 0) == 0) { | |
685 | + return ((void *)lcd_base); | |
686 | + } | |
687 | + } | |
688 | +#endif /* CONFIG_SPLASH_SCREEN */ | |
689 | + | |
690 | +#ifdef CONFIG_LCD_LOGO | |
691 | + bitmap_plot (0, 0); | |
692 | +#endif /* CONFIG_LCD_LOGO */ | |
693 | + | |
694 | +#ifdef CONFIG_MPC823 | |
695 | +#ifdef LCD_INFO | |
696 | + sprintf (info, "%s (%s - %s) ", U_BOOT_VERSION, __DATE__, __TIME__); | |
697 | + lcd_drawchars (LCD_INFO_X, LCD_INFO_Y, info, strlen(info)); | |
698 | + | |
699 | + sprintf (info, "(C) 2004 DENX Software Engineering"); | |
700 | + lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT, | |
701 | + info, strlen(info)); | |
702 | + | |
703 | + sprintf (info, " Wolfgang DENK, wd@denx.de"); | |
704 | + lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 2, | |
705 | + info, strlen(info)); | |
706 | +#ifdef LCD_INFO_BELOW_LOGO | |
707 | + sprintf (info, "MPC823 CPU at %s MHz", | |
708 | + strmhz(temp, gd->cpu_clk)); | |
709 | + lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 3, | |
710 | + info, strlen(info)); | |
711 | + sprintf (info, " %ld MB RAM, %ld MB Flash", | |
712 | + gd->ram_size >> 20, | |
713 | + gd->bd->bi_flashsize >> 20 ); | |
714 | + lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4, | |
715 | + info, strlen(info)); | |
716 | +#else | |
717 | + /* leave one blank line */ | |
718 | + | |
719 | + sprintf (info, "MPC823 CPU at %s MHz, %ld MB RAM, %ld MB Flash", | |
720 | + strmhz(temp, gd->cpu_clk), | |
721 | + gd->ram_size >> 20, | |
722 | + gd->bd->bi_flashsize >> 20 ); | |
723 | + lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4, | |
724 | + info, strlen(info)); | |
725 | + | |
726 | +#endif /* CONFIG_MPC823 */ | |
727 | +#endif /* LCD_INFO_BELOW_LOGO */ | |
728 | +#endif /* LCD_INFO */ | |
729 | + | |
730 | +#if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO) | |
731 | + return ((void *)((ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length)); | |
732 | +#else | |
733 | + return ((void *)lcd_base); | |
734 | +#endif /* CONFIG_LCD_LOGO */ | |
735 | +} | |
736 | + | |
737 | +/************************************************************************/ | |
738 | +/************************************************************************/ | |
739 | + | |
740 | +#endif /* CONFIG_LCD */ |
cpu/mpc8xx/lcd.c
Changes suppressed. Click to show
... | ... | @@ -54,74 +54,6 @@ |
54 | 54 | #undef LCD_INFO |
55 | 55 | #endif |
56 | 56 | |
57 | -/* #define LCD_TEST_PATTERN */ /* color backgnd for frame/color adjust */ | |
58 | -/* #define CFG_INVERT_COLORS */ /* Not needed - adjust vl_dp instead */ | |
59 | -/************************************************************************/ | |
60 | - | |
61 | -/************************************************************************/ | |
62 | -/* ** BITMAP DISPLAY SUPPORT -- should probably be moved elsewhere */ | |
63 | -/************************************************************************/ | |
64 | - | |
65 | -#if (CONFIG_COMMANDS & CFG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN) | |
66 | -#include <bmp_layout.h> | |
67 | -#endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) || CONFIG_SPLASH_SCREEN */ | |
68 | - | |
69 | -/************************************************************************/ | |
70 | -/* ** FONT AND LOGO DATA */ | |
71 | -/************************************************************************/ | |
72 | - | |
73 | -#include <video_font.h> /* Get font data, width and height */ | |
74 | - | |
75 | -#ifdef CONFIG_LCD_LOGO | |
76 | -# include <bmp_logo.h> /* Get logo data, width and height */ | |
77 | -#endif | |
78 | - | |
79 | -/************************************************************************/ | |
80 | -/************************************************************************/ | |
81 | - | |
82 | -/* | |
83 | - * Information about displays we are using. This is for configuring | |
84 | - * the LCD controller and memory allocation. Someone has to know what | |
85 | - * is connected, as we can't autodetect anything. | |
86 | - */ | |
87 | -#define CFG_HIGH 0 /* Pins are active high */ | |
88 | -#define CFG_LOW 1 /* Pins are active low */ | |
89 | - | |
90 | -typedef struct vidinfo { | |
91 | - ushort vl_col; /* Number of columns (i.e. 640) */ | |
92 | - ushort vl_row; /* Number of rows (i.e. 480) */ | |
93 | - ushort vl_width; /* Width of display area in millimeters */ | |
94 | - ushort vl_height; /* Height of display area in millimeters */ | |
95 | - | |
96 | - /* LCD configuration register. | |
97 | - */ | |
98 | - u_char vl_clkp; /* Clock polarity */ | |
99 | - u_char vl_oep; /* Output Enable polarity */ | |
100 | - u_char vl_hsp; /* Horizontal Sync polarity */ | |
101 | - u_char vl_vsp; /* Vertical Sync polarity */ | |
102 | - u_char vl_dp; /* Data polarity */ | |
103 | - u_char vl_bpix; /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8 */ | |
104 | - u_char vl_lbw; /* LCD Bus width, 0 = 4, 1 = 8 */ | |
105 | - u_char vl_splt; /* Split display, 0 = single-scan, 1 = dual-scan */ | |
106 | - u_char vl_clor; /* Color, 0 = mono, 1 = color */ | |
107 | - u_char vl_tft; /* 0 = passive, 1 = TFT */ | |
108 | - | |
109 | - /* Horizontal control register. Timing from data sheet. | |
110 | - */ | |
111 | - ushort vl_wbl; /* Wait between lines */ | |
112 | - | |
113 | - /* Vertical control register. | |
114 | - */ | |
115 | - u_char vl_vpw; /* Vertical sync pulse width */ | |
116 | - u_char vl_lcdac; /* LCD AC timing */ | |
117 | - u_char vl_wbf; /* Wait between frames */ | |
118 | -} vidinfo_t; | |
119 | - | |
120 | -#define LCD_MONOCHROME 0 | |
121 | -#define LCD_COLOR2 1 | |
122 | -#define LCD_COLOR4 2 | |
123 | -#define LCD_COLOR8 3 | |
124 | - | |
125 | 57 | /*----------------------------------------------------------------------*/ |
126 | 58 | #ifdef CONFIG_KYOCERA_KCS057QV1AJ |
127 | 59 | /* |
... | ... | @@ -129,7 +61,7 @@ |
129 | 61 | */ |
130 | 62 | #define LCD_BPP LCD_COLOR4 |
131 | 63 | |
132 | -static vidinfo_t panel_info = { | |
64 | +vidinfo_t panel_info = { | |
133 | 65 | 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, |
134 | 66 | LCD_BPP, 1, 0, 1, 0, 5, 0, 0, 0 |
135 | 67 | /* wbl, vpw, lcdac, wbf */ |
... | ... | @@ -142,7 +74,7 @@ |
142 | 74 | /* |
143 | 75 | * Hitachi SP19X001-. Active, color, single scan. |
144 | 76 | */ |
145 | -static vidinfo_t panel_info = { | |
77 | +vidinfo_t panel_info = { | |
146 | 78 | 640, 480, 154, 116, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, |
147 | 79 | LCD_COLOR8, 1, 0, 1, 0, 0, 0, 0, 0 |
148 | 80 | /* wbl, vpw, lcdac, wbf */ |
... | ... | @@ -155,7 +87,7 @@ |
155 | 87 | /* |
156 | 88 | * NEC NL6448AC33-18. Active, color, single scan. |
157 | 89 | */ |
158 | -static vidinfo_t panel_info = { | |
90 | +vidinfo_t panel_info = { | |
159 | 91 | 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
160 | 92 | 3, 0, 0, 1, 1, 144, 2, 0, 33 |
161 | 93 | /* wbl, vpw, lcdac, wbf */ |
... | ... | @@ -167,7 +99,7 @@ |
167 | 99 | /* |
168 | 100 | * NEC NL6448BC20-08. 6.5", 640x480. Active, color, single scan. |
169 | 101 | */ |
170 | -static vidinfo_t panel_info = { | |
102 | +vidinfo_t panel_info = { | |
171 | 103 | 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
172 | 104 | 3, 0, 0, 1, 1, 144, 2, 0, 33 |
173 | 105 | /* wbl, vpw, lcdac, wbf */ |
... | ... | @@ -179,7 +111,7 @@ |
179 | 111 | /* |
180 | 112 | * NEC NL6448BC33-54. 10.4", 640x480. Active, color, single scan. |
181 | 113 | */ |
182 | -static vidinfo_t panel_info = { | |
114 | +vidinfo_t panel_info = { | |
183 | 115 | 640, 480, 212, 158, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
184 | 116 | 3, 0, 0, 1, 1, 144, 2, 0, 33 |
185 | 117 | /* wbl, vpw, lcdac, wbf */ |
... | ... | @@ -191,7 +123,7 @@ |
191 | 123 | /* |
192 | 124 | * SHARP LQ104V7DS01. 6.5", 640x480. Active, color, single scan. |
193 | 125 | */ |
194 | -static vidinfo_t panel_info = { | |
126 | +vidinfo_t panel_info = { | |
195 | 127 | 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_LOW, |
196 | 128 | 3, 0, 0, 1, 1, 25, 1, 0, 33 |
197 | 129 | /* wbl, vpw, lcdac, wbf */ |
... | ... | @@ -204,7 +136,7 @@ |
204 | 136 | * Sharp 320x240. Active, color, single scan. It isn't 16x9, and I am |
205 | 137 | * not sure what it is....... |
206 | 138 | */ |
207 | -static vidinfo_t panel_info = { | |
139 | +vidinfo_t panel_info = { | |
208 | 140 | 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, |
209 | 141 | 3, 0, 0, 1, 1, 15, 4, 0, 3 |
210 | 142 | }; |
211 | 143 | |
... | ... | @@ -215,9 +147,10 @@ |
215 | 147 | /* |
216 | 148 | * Sharp LQ057Q3DC02 display. Active, color, single scan. |
217 | 149 | */ |
150 | +#undef LCD_DF | |
218 | 151 | #define LCD_DF 12 |
219 | 152 | |
220 | -static vidinfo_t panel_info = { | |
153 | +vidinfo_t panel_info = { | |
221 | 154 | 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
222 | 155 | 3, 0, 0, 1, 1, 15, 4, 0, 3 |
223 | 156 | /* wbl, vpw, lcdac, wbf */ |
... | ... | @@ -230,7 +163,7 @@ |
230 | 163 | /* |
231 | 164 | * Sharp LQ64D341 display, 640x480. Active, color, single scan. |
232 | 165 | */ |
233 | -static vidinfo_t panel_info = { | |
166 | +vidinfo_t panel_info = { | |
234 | 167 | 640, 480, 0, 0, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
235 | 168 | 3, 0, 0, 1, 1, 128, 16, 0, 32 |
236 | 169 | /* wbl, vpw, lcdac, wbf */ |
... | ... | @@ -241,7 +174,7 @@ |
241 | 174 | /* |
242 | 175 | * Sharp LQ065T9DR51U display, 400x240. Active, color, single scan. |
243 | 176 | */ |
244 | -static vidinfo_t panel_info = { | |
177 | +vidinfo_t panel_info = { | |
245 | 178 | 400, 240, 143, 79, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, |
246 | 179 | 3, 0, 0, 1, 1, 248, 4, 0, 35 |
247 | 180 | /* wbl, vpw, lcdac, wbf */ |
... | ... | @@ -253,7 +186,7 @@ |
253 | 186 | /* |
254 | 187 | * Sharp LQ084V1DG21 display, 640x480. Active, color, single scan. |
255 | 188 | */ |
256 | -static vidinfo_t panel_info = { | |
189 | +vidinfo_t panel_info = { | |
257 | 190 | 640, 480, 171, 129, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_LOW, |
258 | 191 | 3, 0, 0, 1, 1, 160, 3, 0, 48 |
259 | 192 | /* wbl, vpw, lcdac, wbf */ |
... | ... | @@ -266,7 +199,7 @@ |
266 | 199 | /* |
267 | 200 | * HLD1045 display, 640x480. Active, color, single scan. |
268 | 201 | */ |
269 | -static vidinfo_t panel_info = { | |
202 | +vidinfo_t panel_info = { | |
270 | 203 | 640, 480, 0, 0, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
271 | 204 | 3, 0, 0, 1, 1, 160, 3, 0, 48 |
272 | 205 | /* wbl, vpw, lcdac, wbf */ |
... | ... | @@ -278,7 +211,7 @@ |
278 | 211 | /* |
279 | 212 | * Prime View V16C6448AC |
280 | 213 | */ |
281 | -static vidinfo_t panel_info = { | |
214 | +vidinfo_t panel_info = { | |
282 | 215 | 640, 480, 130, 98, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
283 | 216 | 3, 0, 0, 1, 1, 144, 2, 0, 35 |
284 | 217 | /* wbl, vpw, lcdac, wbf */ |
... | ... | @@ -300,7 +233,7 @@ |
300 | 233 | #define OPTREX_BPP 0 /* 0 - monochrome, 1 bpp */ |
301 | 234 | /* 1 - 4 grey levels, 2 bpp */ |
302 | 235 | /* 2 - 16 grey levels, 4 bpp */ |
303 | -static vidinfo_t panel_info = { | |
236 | +vidinfo_t panel_info = { | |
304 | 237 | 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_LOW, |
305 | 238 | OPTREX_BPP, 0, 0, 0, 0, 0, 0, 0, 0, 4 |
306 | 239 | }; |
307 | 240 | |
308 | 241 | |
309 | 242 | |
310 | 243 | |
311 | 244 | |
312 | 245 | |
313 | 246 | |
314 | 247 | |
315 | 248 | |
316 | 249 | |
317 | 250 | |
318 | 251 | |
319 | 252 | |
320 | 253 | |
321 | 254 | |
322 | 255 | |
323 | 256 | |
324 | 257 | |
325 | 258 | |
326 | 259 | |
327 | 260 | |
... | ... | @@ -314,525 +247,64 @@ |
314 | 247 | #define LCD_BPP LCD_MONOCHROME |
315 | 248 | #define LCD_DF 10 |
316 | 249 | |
317 | -static vidinfo_t panel_info = { | |
250 | +vidinfo_t panel_info = { | |
318 | 251 | 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_LOW, |
319 | 252 | LCD_BPP, 0, 0, 0, 0, 33, 0, 0, 0 |
320 | 253 | }; |
321 | 254 | #endif |
322 | 255 | /*----------------------------------------------------------------------*/ |
323 | 256 | |
324 | -#if defined(LCD_INFO_BELOW_LOGO) | |
325 | -# define LCD_INFO_X 0 | |
326 | -# define LCD_INFO_Y (BMP_LOGO_HEIGHT + VIDEO_FONT_HEIGHT) | |
327 | -#elif defined(CONFIG_LCD_LOGO) | |
328 | -# define LCD_INFO_X (BMP_LOGO_WIDTH + 4 * VIDEO_FONT_WIDTH) | |
329 | -# define LCD_INFO_Y (VIDEO_FONT_HEIGHT) | |
330 | -#else | |
331 | -# define LCD_INFO_X (VIDEO_FONT_WIDTH) | |
332 | -# define LCD_INFO_Y (VIDEO_FONT_HEIGHT) | |
333 | -#endif | |
334 | 257 | |
335 | -#ifndef LCD_BPP | |
336 | -#define LCD_BPP LCD_COLOR8 | |
337 | -#endif | |
338 | -#ifndef LCD_DF | |
339 | -#define LCD_DF 1 | |
340 | -#endif | |
258 | +int lcd_line_length; | |
341 | 259 | |
342 | -#define NBITS(bit_code) (1 << (bit_code)) | |
343 | -#define NCOLORS(bit_code) (1 << NBITS(bit_code)) | |
260 | +int lcd_color_fg; | |
261 | +int lcd_color_bg; | |
344 | 262 | |
345 | -static int lcd_line_length; | |
346 | - | |
347 | -static int lcd_color_fg; | |
348 | -static int lcd_color_bg; | |
349 | - | |
350 | -char lcd_is_enabled = 0; /* Indicate that LCD is enabled */ | |
351 | - | |
352 | 263 | /* |
353 | 264 | * Frame buffer memory information |
354 | 265 | */ |
355 | -static void *lcd_base; /* Start of framebuffer memory */ | |
356 | -static void *lcd_console_address; /* Start of console buffer */ | |
266 | +void *lcd_base; /* Start of framebuffer memory */ | |
267 | +void *lcd_console_address; /* Start of console buffer */ | |
357 | 268 | |
269 | +short console_col; | |
270 | +short console_row; | |
358 | 271 | |
359 | 272 | /************************************************************************/ |
360 | -/* ** CONSOLE CONSTANTS */ | |
361 | -/************************************************************************/ | |
362 | 273 | |
363 | -#if LCD_BPP == LCD_MONOCHROME | |
364 | - | |
365 | -/* | |
366 | - * Simple color definitions | |
367 | - */ | |
368 | -#define CONSOLE_COLOR_BLACK 0 | |
369 | -#define CONSOLE_COLOR_WHITE 1 /* Must remain last / highest */ | |
370 | - | |
371 | -#else | |
372 | - | |
373 | -/* | |
374 | - * Simple color definitions | |
375 | - */ | |
376 | -#define CONSOLE_COLOR_BLACK 0 | |
377 | -#define CONSOLE_COLOR_RED 1 | |
378 | -#define CONSOLE_COLOR_GREEN 2 | |
379 | -#define CONSOLE_COLOR_YELLOW 3 | |
380 | -#define CONSOLE_COLOR_BLUE 4 | |
381 | -#define CONSOLE_COLOR_MAGENTA 5 | |
382 | -#define CONSOLE_COLOR_CYAN 6 | |
383 | -#define CONSOLE_COLOR_GREY 14 | |
384 | -#define CONSOLE_COLOR_WHITE 15 /* Must remain last / highest */ | |
385 | - | |
386 | -#endif | |
387 | - | |
388 | -#if defined(CONFIG_LCD_LOGO) && (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET) | |
389 | -#error Default Color Map overlaps with Logo Color Map | |
390 | -#endif | |
391 | - | |
392 | -/************************************************************************/ | |
393 | - | |
394 | -#ifndef PAGE_SIZE | |
395 | -#define PAGE_SIZE 4096 | |
396 | -#endif | |
397 | - | |
398 | - | |
399 | -/************************************************************************/ | |
400 | -/* ** CONSOLE DEFINITIONS & FUNCTIONS */ | |
401 | -/************************************************************************/ | |
402 | - | |
403 | -#if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO) | |
404 | -#define CONSOLE_ROWS ((panel_info.vl_row-BMP_LOGO_HEIGHT) \ | |
405 | - / VIDEO_FONT_HEIGHT) | |
406 | -#else | |
407 | -#define CONSOLE_ROWS (panel_info.vl_row / VIDEO_FONT_HEIGHT) | |
408 | -#endif | |
409 | -#define CONSOLE_COLS (panel_info.vl_col / VIDEO_FONT_WIDTH) | |
410 | -#define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * lcd_line_length) | |
411 | -#define CONSOLE_ROW_FIRST (lcd_console_address) | |
412 | -#define CONSOLE_ROW_SECOND (lcd_console_address + CONSOLE_ROW_SIZE) | |
413 | -#define CONSOLE_ROW_LAST (lcd_console_address + CONSOLE_SIZE \ | |
414 | - - CONSOLE_ROW_SIZE) | |
415 | -#define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS) | |
416 | -#define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE) | |
417 | - | |
418 | -#if LCD_BPP == LCD_MONOCHROME | |
419 | -#define COLOR_MASK(c) ((c) | (c) << 1 | (c) << 2 | (c) << 3 | \ | |
420 | - (c) << 4 | (c) << 5 | (c) << 6 | (c) << 7) | |
421 | -#elif LCD_BPP == LCD_COLOR8 | |
422 | -#define COLOR_MASK(c) (c) | |
423 | -#else | |
424 | -#error Unsupported LCD BPP. | |
425 | -#endif | |
426 | - | |
427 | -static short console_col; | |
428 | -static short console_row; | |
429 | - | |
430 | -/************************************************************************/ | |
431 | - | |
432 | -ulong lcd_setmem (ulong addr); | |
433 | - | |
434 | -static void lcd_drawchars (ushort x, ushort y, uchar *str, int count); | |
435 | -static inline void lcd_puts_xy (ushort x, ushort y, uchar *s); | |
436 | -static inline void lcd_putc_xy (ushort x, ushort y, uchar c); | |
437 | - | |
438 | -static int lcd_init (void *lcdbase); | |
439 | - | |
440 | -static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]); | |
441 | -static void lcd_ctrl_init (void *lcdbase); | |
442 | -static void lcd_enable (void); | |
443 | -static void *lcd_logo (void); | |
274 | +void lcd_ctrl_init (void *lcdbase); | |
275 | +void lcd_enable (void); | |
444 | 276 | #if LCD_BPP == LCD_COLOR8 |
445 | -static void lcd_setcolreg (ushort regno, | |
277 | +void lcd_setcolreg (ushort regno, | |
446 | 278 | ushort red, ushort green, ushort blue); |
447 | 279 | #endif |
448 | 280 | #if LCD_BPP == LCD_MONOCHROME |
449 | -static void lcd_initcolregs (void); | |
281 | +void lcd_initcolregs (void); | |
450 | 282 | #endif |
451 | -static int lcd_getbgcolor (void); | |
452 | -static void lcd_setfgcolor (int color); | |
453 | -static void lcd_setbgcolor (int color); | |
454 | 283 | |
455 | 284 | #if defined(CONFIG_RBC823) |
456 | -void lcd_disable (void); | |
285 | +void lcd_disable (void); | |
457 | 286 | #endif |
458 | 287 | |
459 | -#ifdef NOT_USED_SO_FAR | |
460 | -static void lcd_getcolreg (ushort regno, | |
461 | - ushort *red, ushort *green, ushort *blue); | |
462 | -static int lcd_getfgcolor (void); | |
463 | -#endif /* NOT_USED_SO_FAR */ | |
464 | - | |
465 | 288 | /************************************************************************/ |
466 | 289 | |
467 | -/*----------------------------------------------------------------------*/ | |
468 | - | |
469 | -static void console_scrollup (void) | |
470 | -{ | |
471 | -#if 1 | |
472 | - /* Copy up rows ignoring the first one */ | |
473 | - memcpy (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, CONSOLE_SCROLL_SIZE); | |
474 | - | |
475 | - /* Clear the last one */ | |
476 | - memset (CONSOLE_ROW_LAST, COLOR_MASK(lcd_color_bg), CONSOLE_ROW_SIZE); | |
477 | -#else | |
478 | - /* | |
479 | - * Poor attempt to optimize speed by moving "long"s. | |
480 | - * But the code is ugly, and not a bit faster :-( | |
481 | - */ | |
482 | - ulong *t = (ulong *)CONSOLE_ROW_FIRST; | |
483 | - ulong *s = (ulong *)CONSOLE_ROW_SECOND; | |
484 | - ulong l = CONSOLE_SCROLL_SIZE / sizeof(ulong); | |
485 | - uchar c = lcd_color_bg & 0xFF; | |
486 | - ulong val= (c<<24) | (c<<16) | (c<<8) | c; | |
487 | - | |
488 | - while (l--) | |
489 | - *t++ = *s++; | |
490 | - | |
491 | - t = (ulong *)CONSOLE_ROW_LAST; | |
492 | - l = CONSOLE_ROW_SIZE / sizeof(ulong); | |
493 | - | |
494 | - while (l-- > 0) | |
495 | - *t++ = val; | |
496 | -#endif | |
497 | -} | |
498 | - | |
499 | -/*----------------------------------------------------------------------*/ | |
500 | - | |
501 | -static inline void console_back (void) | |
502 | -{ | |
503 | - if (--console_col < 0) { | |
504 | - console_col = CONSOLE_COLS-1 ; | |
505 | - if (--console_row < 0) { | |
506 | - console_row = 0; | |
507 | - } | |
508 | - } | |
509 | - | |
510 | - lcd_putc_xy (console_col * VIDEO_FONT_WIDTH, | |
511 | - console_row * VIDEO_FONT_HEIGHT, | |
512 | - ' '); | |
513 | -} | |
514 | - | |
515 | -/*----------------------------------------------------------------------*/ | |
516 | - | |
517 | -static inline void console_newline (void) | |
518 | -{ | |
519 | - ++console_row; | |
520 | - console_col = 0; | |
521 | - | |
522 | - /* Check if we need to scroll the terminal */ | |
523 | - if (console_row >= CONSOLE_ROWS) { | |
524 | - /* Scroll everything up */ | |
525 | - console_scrollup () ; | |
526 | - --console_row; | |
527 | - } | |
528 | -} | |
529 | - | |
530 | -/*----------------------------------------------------------------------*/ | |
531 | - | |
532 | -void lcd_putc (const char c) | |
533 | -{ | |
534 | - if (!lcd_is_enabled) { | |
535 | - serial_putc(c); | |
536 | - return; | |
537 | - } | |
538 | - | |
539 | - switch (c) { | |
540 | - case '\r': console_col = 0; | |
541 | - return; | |
542 | - | |
543 | - case '\n': console_newline(); | |
544 | - return; | |
545 | - | |
546 | - case '\t': /* Tab (8 chars alignment) */ | |
547 | - console_col |= 8; | |
548 | - console_col &= ~7; | |
549 | - | |
550 | - if (console_col >= CONSOLE_COLS) { | |
551 | - console_newline(); | |
552 | - } | |
553 | - return; | |
554 | - | |
555 | - case '\b': console_back(); | |
556 | - return; | |
557 | - | |
558 | - default: lcd_putc_xy (console_col * VIDEO_FONT_WIDTH, | |
559 | - console_row * VIDEO_FONT_HEIGHT, | |
560 | - c); | |
561 | - if (++console_col >= CONSOLE_COLS) { | |
562 | - console_newline(); | |
563 | - } | |
564 | - return; | |
565 | - } | |
566 | - /* NOTREACHED */ | |
567 | -} | |
568 | - | |
569 | -/*----------------------------------------------------------------------*/ | |
570 | - | |
571 | -void lcd_puts (const char *s) | |
572 | -{ | |
573 | - if (!lcd_is_enabled) { | |
574 | - serial_puts (s); | |
575 | - return; | |
576 | - } | |
577 | - | |
578 | - while (*s) { | |
579 | - lcd_putc (*s++); | |
580 | - } | |
581 | -} | |
582 | - | |
583 | 290 | /************************************************************************/ |
584 | -/* ** Low-Level Graphics Routines */ | |
291 | +/* ----------------- chipset specific functions ----------------------- */ | |
585 | 292 | /************************************************************************/ |
586 | 293 | |
587 | -static void lcd_drawchars (ushort x, ushort y, uchar *str, int count) | |
588 | -{ | |
589 | - uchar *dest; | |
590 | - ushort off, row; | |
591 | - | |
592 | - dest = (uchar *)(lcd_base + y * lcd_line_length + x * (1 << LCD_BPP) / 8); | |
593 | - off = x * (1 << LCD_BPP) % 8; | |
594 | - | |
595 | - for (row=0; row < VIDEO_FONT_HEIGHT; ++row, dest += lcd_line_length) { | |
596 | - uchar *s = str; | |
597 | - uchar *d = dest; | |
598 | - int i; | |
599 | - | |
600 | -#if LCD_BPP == LCD_MONOCHROME | |
601 | - uchar rest = *d & -(1 << (8-off)); | |
602 | - uchar sym; | |
603 | -#endif | |
604 | - for (i=0; i<count; ++i) { | |
605 | - uchar c, bits; | |
606 | - | |
607 | - c = *s++; | |
608 | - bits = video_fontdata[c * VIDEO_FONT_HEIGHT + row]; | |
609 | - | |
610 | -#if LCD_BPP == LCD_MONOCHROME | |
611 | - sym = (COLOR_MASK(lcd_color_fg) & bits) | | |
612 | - (COLOR_MASK(lcd_color_bg) & ~bits); | |
613 | - | |
614 | - *d++ = rest | (sym >> off); | |
615 | - rest = sym << (8-off); | |
616 | -#elif LCD_BPP == LCD_COLOR8 | |
617 | - for (c=0; c<8; ++c) { | |
618 | - *d++ = (bits & 0x80) ? | |
619 | - lcd_color_fg : lcd_color_bg; | |
620 | - bits <<= 1; | |
621 | - } | |
622 | -#endif | |
623 | - } | |
624 | - | |
625 | -#if LCD_BPP == LCD_MONOCHROME | |
626 | - *d = rest | (*d & ((1 << (8-off)) - 1)); | |
627 | -#endif | |
628 | - } | |
629 | -} | |
630 | - | |
631 | -/*----------------------------------------------------------------------*/ | |
632 | - | |
633 | -static inline void lcd_puts_xy (ushort x, ushort y, uchar *s) | |
634 | -{ | |
635 | -#if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO) | |
636 | - lcd_drawchars (x, y+BMP_LOGO_HEIGHT, s, strlen (s)); | |
637 | -#else | |
638 | - lcd_drawchars (x, y, s, strlen (s)); | |
639 | -#endif | |
640 | -} | |
641 | - | |
642 | -/*----------------------------------------------------------------------*/ | |
643 | - | |
644 | -static inline void lcd_putc_xy (ushort x, ushort y, uchar c) | |
645 | -{ | |
646 | -#if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO) | |
647 | - lcd_drawchars (x, y+BMP_LOGO_HEIGHT, &c, 1); | |
648 | -#else | |
649 | - lcd_drawchars (x, y, &c, 1); | |
650 | -#endif | |
651 | -} | |
652 | - | |
653 | -/************************************************************************/ | |
654 | -/** Small utility to check that you got the colours right */ | |
655 | -/************************************************************************/ | |
656 | -#ifdef LCD_TEST_PATTERN | |
657 | - | |
658 | -#define N_BLK_VERT 2 | |
659 | -#define N_BLK_HOR 3 | |
660 | - | |
661 | -static int test_colors[N_BLK_HOR*N_BLK_VERT] = { | |
662 | - CONSOLE_COLOR_RED, CONSOLE_COLOR_GREEN, CONSOLE_COLOR_YELLOW, | |
663 | - CONSOLE_COLOR_BLUE, CONSOLE_COLOR_MAGENTA, CONSOLE_COLOR_CYAN, | |
664 | -}; | |
665 | - | |
666 | -static void test_pattern (void) | |
667 | -{ | |
668 | - ushort v_max = panel_info.vl_row; | |
669 | - ushort h_max = panel_info.vl_col; | |
670 | - ushort v_step = (v_max + N_BLK_VERT - 1) / N_BLK_VERT; | |
671 | - ushort h_step = (h_max + N_BLK_HOR - 1) / N_BLK_HOR; | |
672 | - ushort v, h; | |
673 | - uchar *pix = (uchar *)lcd_base; | |
674 | - | |
675 | - printf ("[LCD] Test Pattern: %d x %d [%d x %d]\n", | |
676 | - h_max, v_max, h_step, v_step); | |
677 | - | |
678 | - /* WARNING: Code silently assumes 8bit/pixel */ | |
679 | - for (v=0; v<v_max; ++v) { | |
680 | - uchar iy = v / v_step; | |
681 | - for (h=0; h<h_max; ++h) { | |
682 | - uchar ix = N_BLK_HOR * iy + (h/h_step); | |
683 | - *pix++ = test_colors[ix]; | |
684 | - } | |
685 | - } | |
686 | -} | |
687 | -#endif /* LCD_TEST_PATTERN */ | |
688 | - | |
689 | - | |
690 | -/************************************************************************/ | |
691 | -/* ** GENERIC Initialization Routines */ | |
692 | -/************************************************************************/ | |
693 | - | |
694 | -int drv_lcd_init (void) | |
695 | -{ | |
696 | - DECLARE_GLOBAL_DATA_PTR; | |
697 | - | |
698 | - device_t lcddev; | |
699 | - int rc; | |
700 | - | |
701 | - lcd_base = (void *)(gd->fb_base); | |
702 | - | |
703 | - lcd_line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8; | |
704 | - | |
705 | - lcd_init (lcd_base); /* LCD initialization */ | |
706 | - | |
707 | - /* Device initialization */ | |
708 | - memset (&lcddev, 0, sizeof (lcddev)); | |
709 | - | |
710 | - strcpy (lcddev.name, "lcd"); | |
711 | - lcddev.ext = 0; /* No extensions */ | |
712 | - lcddev.flags = DEV_FLAGS_OUTPUT; /* Output only */ | |
713 | - lcddev.putc = lcd_putc; /* 'putc' function */ | |
714 | - lcddev.puts = lcd_puts; /* 'puts' function */ | |
715 | - | |
716 | - rc = device_register (&lcddev); | |
717 | - | |
718 | - return (rc == 0) ? 1 : rc; | |
719 | -} | |
720 | - | |
721 | -/*----------------------------------------------------------------------*/ | |
722 | - | |
723 | -static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) | |
724 | -{ | |
725 | -#if LCD_BPP == LCD_MONOCHROME | |
726 | - /* Setting the palette */ | |
727 | - lcd_initcolregs(); | |
728 | - | |
729 | -#elif LCD_BPP == LCD_COLOR8 | |
730 | - /* Setting the palette */ | |
731 | - lcd_setcolreg (CONSOLE_COLOR_BLACK, 0, 0, 0); | |
732 | - lcd_setcolreg (CONSOLE_COLOR_RED, 0xFF, 0, 0); | |
733 | - lcd_setcolreg (CONSOLE_COLOR_GREEN, 0, 0xFF, 0); | |
734 | - lcd_setcolreg (CONSOLE_COLOR_YELLOW, 0xFF, 0xFF, 0); | |
735 | - lcd_setcolreg (CONSOLE_COLOR_BLUE, 0, 0, 0xFF); | |
736 | - lcd_setcolreg (CONSOLE_COLOR_MAGENTA, 0xFF, 0, 0xFF); | |
737 | - lcd_setcolreg (CONSOLE_COLOR_CYAN, 0, 0xFF, 0xFF); | |
738 | - lcd_setcolreg (CONSOLE_COLOR_GREY, 0xAA, 0xAA, 0xAA); | |
739 | - lcd_setcolreg (CONSOLE_COLOR_WHITE, 0xFF, 0xFF, 0xFF); | |
740 | -#endif | |
741 | - | |
742 | -#ifndef CFG_WHITE_ON_BLACK | |
743 | - lcd_setfgcolor (CONSOLE_COLOR_BLACK); | |
744 | - lcd_setbgcolor (CONSOLE_COLOR_WHITE); | |
745 | -#else | |
746 | - lcd_setfgcolor (CONSOLE_COLOR_WHITE); | |
747 | - lcd_setbgcolor (CONSOLE_COLOR_BLACK); | |
748 | -#endif /* CFG_WHITE_ON_BLACK */ | |
749 | - | |
750 | -#ifdef LCD_TEST_PATTERN | |
751 | - test_pattern(); | |
752 | -#else | |
753 | - /* set framebuffer to background color */ | |
754 | - memset ((char *)lcd_base, | |
755 | - COLOR_MASK(lcd_getbgcolor()), | |
756 | - lcd_line_length*panel_info.vl_row); | |
757 | -#endif | |
758 | - /* Paint the logo and retrieve LCD base address */ | |
759 | - debug ("[LCD] Drawing the logo...\n"); | |
760 | - lcd_console_address = lcd_logo (); | |
761 | - | |
762 | - console_col = 0; | |
763 | - console_row = 0; | |
764 | - | |
765 | - return (0); | |
766 | -} | |
767 | - | |
768 | -U_BOOT_CMD( | |
769 | - cls, 1, 1, lcd_clear, | |
770 | - "cls - clear screen\n", | |
771 | - NULL | |
772 | -); | |
773 | - | |
774 | -/*----------------------------------------------------------------------*/ | |
775 | - | |
776 | -static int lcd_init (void *lcdbase) | |
777 | -{ | |
778 | - /* Initialize the lcd controller */ | |
779 | - debug ("[LCD] Initializing LCD frambuffer at %p\n", lcdbase); | |
780 | - | |
781 | - lcd_ctrl_init (lcdbase); | |
782 | - lcd_clear (NULL, 1, 1, NULL); /* dummy args */ | |
783 | - lcd_enable (); | |
784 | - | |
785 | - /* Initialize the console */ | |
786 | - console_col = 0; | |
787 | -#ifdef LCD_INFO_BELOW_LOGO | |
788 | - console_row = 7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT; | |
789 | -#else | |
790 | - console_row = 1; /* leave 1 blank line below logo */ | |
791 | -#endif | |
792 | - lcd_is_enabled = 1; | |
793 | - | |
794 | - return 0; | |
795 | -} | |
796 | - | |
797 | - | |
798 | -/************************************************************************/ | |
799 | -/* ** ROM capable initialization part - needed to reserve FB memory */ | |
800 | -/************************************************************************/ | |
801 | - | |
802 | 294 | /* |
803 | - * This is called early in the system initialization to grab memory | |
804 | - * for the LCD controller. | |
805 | - * Returns new address for monitor, after reserving LCD buffer memory | |
806 | - * | |
807 | - * Note that this is running from ROM, so no write access to global data. | |
295 | + * Calculate fb size for VIDEOLFB_ATAG. | |
808 | 296 | */ |
809 | -ulong lcd_setmem (ulong addr) | |
297 | +ulong calc_fbsize (void) | |
810 | 298 | { |
811 | 299 | ulong size; |
812 | 300 | int line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8; |
813 | 301 | |
814 | - debug ("LCD panel info: %d x %d, %d bit/pix\n", | |
815 | - panel_info.vl_col, panel_info.vl_row, NBITS (panel_info.vl_bpix) ); | |
816 | - | |
817 | 302 | size = line_length * panel_info.vl_row; |
818 | 303 | |
819 | - /* Round up to nearest full page */ | |
820 | - size = (size + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); | |
821 | - | |
822 | - /* Allocate pages for the frame buffer. */ | |
823 | - addr -= size; | |
824 | - | |
825 | - debug ("Reserving %ldk for LCD Framebuffer at: %08lx\n", size>>10, addr); | |
826 | - | |
827 | - return (addr); | |
304 | + return size; | |
828 | 305 | } |
829 | 306 | |
830 | - | |
831 | -/************************************************************************/ | |
832 | -/* ----------------- chipset specific functions ----------------------- */ | |
833 | -/************************************************************************/ | |
834 | - | |
835 | -static void lcd_ctrl_init (void *lcdbase) | |
307 | +void lcd_ctrl_init (void *lcdbase) | |
836 | 308 | { |
837 | 309 | volatile immap_t *immr = (immap_t *) CFG_IMMR; |
838 | 310 | volatile lcd823_t *lcdp = &immr->im_lcd; |
... | ... | @@ -983,7 +455,7 @@ |
983 | 455 | /*----------------------------------------------------------------------*/ |
984 | 456 | |
985 | 457 | #if LCD_BPP == LCD_COLOR8 |
986 | -static void | |
458 | +void | |
987 | 459 | lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue) |
988 | 460 | { |
989 | 461 | volatile immap_t *immr = (immap_t *) CFG_IMMR; |
990 | 462 | |
... | ... | @@ -1026,38 +498,8 @@ |
1026 | 498 | |
1027 | 499 | /*----------------------------------------------------------------------*/ |
1028 | 500 | |
1029 | -static void lcd_setfgcolor (int color) | |
501 | +void lcd_enable (void) | |
1030 | 502 | { |
1031 | - lcd_color_fg = color & 0x0F; | |
1032 | -} | |
1033 | - | |
1034 | -/*----------------------------------------------------------------------*/ | |
1035 | - | |
1036 | -static void lcd_setbgcolor (int color) | |
1037 | -{ | |
1038 | - lcd_color_bg = color & 0x0F; | |
1039 | -} | |
1040 | - | |
1041 | -/*----------------------------------------------------------------------*/ | |
1042 | - | |
1043 | -#ifdef NOT_USED_SO_FAR | |
1044 | -static int lcd_getfgcolor (void) | |
1045 | -{ | |
1046 | - return lcd_color_fg; | |
1047 | -} | |
1048 | -#endif /* NOT_USED_SO_FAR */ | |
1049 | - | |
1050 | -/*----------------------------------------------------------------------*/ | |
1051 | - | |
1052 | -static int lcd_getbgcolor (void) | |
1053 | -{ | |
1054 | - return lcd_color_bg; | |
1055 | -} | |
1056 | - | |
1057 | -/*----------------------------------------------------------------------*/ | |
1058 | - | |
1059 | -static void lcd_enable (void) | |
1060 | -{ | |
1061 | 503 | volatile immap_t *immr = (immap_t *) CFG_IMMR; |
1062 | 504 | volatile lcd823_t *lcdp = &immr->im_lcd; |
1063 | 505 | |
... | ... | @@ -1173,224 +615,6 @@ |
1173 | 615 | #endif /* NOT_USED_SO_FAR || CONFIG_RBC823 */ |
1174 | 616 | |
1175 | 617 | |
1176 | -/************************************************************************/ | |
1177 | -/* ** Chipset depending Bitmap / Logo stuff... */ | |
1178 | -/************************************************************************/ | |
1179 | - | |
1180 | - | |
1181 | -#ifdef CONFIG_LCD_LOGO | |
1182 | -static void bitmap_plot (int x, int y) | |
1183 | -{ | |
1184 | - volatile immap_t *immr = (immap_t *) CFG_IMMR; | |
1185 | - volatile cpm8xx_t *cp = &(immr->im_cpm); | |
1186 | - ushort *cmap; | |
1187 | - ushort i; | |
1188 | - uchar *bmap; | |
1189 | - uchar *fb; | |
1190 | - | |
1191 | - debug ("Logo: width %d height %d colors %d cmap %d\n", | |
1192 | - BMP_LOGO_WIDTH, BMP_LOGO_HEIGHT, BMP_LOGO_COLORS, | |
1193 | - sizeof(bmp_logo_palette)/(sizeof(ushort)) | |
1194 | - ); | |
1195 | - | |
1196 | - /* Leave room for default color map */ | |
1197 | - cmap = (ushort *)&(cp->lcd_cmap[BMP_LOGO_OFFSET*sizeof(ushort)]); | |
1198 | - | |
1199 | - WATCHDOG_RESET(); | |
1200 | - | |
1201 | - /* Set color map */ | |
1202 | - for (i=0; i<(sizeof(bmp_logo_palette)/(sizeof(ushort))); ++i) { | |
1203 | - ushort colreg = bmp_logo_palette[i]; | |
1204 | -#ifdef CFG_INVERT_COLORS | |
1205 | - colreg ^= 0xFFF; | |
1206 | -#endif | |
1207 | - *cmap++ = colreg; | |
1208 | - } | |
1209 | - | |
1210 | - bmap = &bmp_logo_bitmap[0]; | |
1211 | - fb = (char *)(lcd_base + y * lcd_line_length + x); | |
1212 | - | |
1213 | - WATCHDOG_RESET(); | |
1214 | - | |
1215 | - for (i=0; i<BMP_LOGO_HEIGHT; ++i) { | |
1216 | - memcpy (fb, bmap, BMP_LOGO_WIDTH); | |
1217 | - bmap += BMP_LOGO_WIDTH; | |
1218 | - fb += panel_info.vl_col; | |
1219 | - } | |
1220 | - | |
1221 | - WATCHDOG_RESET(); | |
1222 | -} | |
1223 | -#endif /* CONFIG_LCD_LOGO */ | |
1224 | - | |
1225 | -#if (CONFIG_COMMANDS & CFG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN) | |
1226 | -/* | |
1227 | - * Display the BMP file located at address bmp_image. | |
1228 | - * Only uncompressed | |
1229 | - */ | |
1230 | -int lcd_display_bitmap(ulong bmp_image, int x, int y) | |
1231 | -{ | |
1232 | - volatile immap_t *immr = (immap_t *) CFG_IMMR; | |
1233 | - volatile cpm8xx_t *cp = &(immr->im_cpm); | |
1234 | - ushort *cmap; | |
1235 | - ushort i, j; | |
1236 | - uchar *fb; | |
1237 | - bmp_image_t *bmp=(bmp_image_t *)bmp_image; | |
1238 | - uchar *bmap; | |
1239 | - ushort padded_line; | |
1240 | - unsigned long width, height; | |
1241 | - unsigned colors,bpix; | |
1242 | - unsigned long compression; | |
1243 | - | |
1244 | - WATCHDOG_RESET(); | |
1245 | - | |
1246 | - if (!((bmp->header.signature[0]=='B') && | |
1247 | - (bmp->header.signature[1]=='M'))) { | |
1248 | - printf ("Error: no valid bmp image at %lx\n", bmp_image); | |
1249 | - return 1; | |
1250 | - } | |
1251 | - | |
1252 | - width = le32_to_cpu (bmp->header.width); | |
1253 | - height = le32_to_cpu (bmp->header.height); | |
1254 | - colors = 1<<le16_to_cpu (bmp->header.bit_count); | |
1255 | - compression = le32_to_cpu (bmp->header.compression); | |
1256 | - | |
1257 | - bpix = NBITS(panel_info.vl_bpix); | |
1258 | - | |
1259 | - if ((bpix != 1) && (bpix != 8)) { | |
1260 | - printf ("Error: %d bit/pixel mode not supported by U-Boot\n", | |
1261 | - bpix); | |
1262 | - return 1; | |
1263 | - } | |
1264 | - | |
1265 | - if (bpix != le16_to_cpu(bmp->header.bit_count)) { | |
1266 | - printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n", | |
1267 | - bpix, | |
1268 | - le16_to_cpu(bmp->header.bit_count)); | |
1269 | - return 1; | |
1270 | - } | |
1271 | - | |
1272 | - if (compression!=BMP_BI_RGB) { | |
1273 | - printf ("Error: compression type %ld not supported\n", | |
1274 | - compression); | |
1275 | - return 1; | |
1276 | - } | |
1277 | - | |
1278 | - debug ("Display-bmp: %d x %d with %d colors\n", | |
1279 | - width, height, colors); | |
1280 | - | |
1281 | - if (bpix==8) { | |
1282 | - /* Fill the entire color map */ | |
1283 | - cmap = (ushort *)&(cp->lcd_cmap[255*sizeof(ushort)]); | |
1284 | - | |
1285 | - /* Set color map */ | |
1286 | - for (i = 0; i < colors; ++i) { | |
1287 | - bmp_color_table_entry_t cte = bmp->color_table[i]; | |
1288 | - ushort colreg = | |
1289 | - ((cte.red>>4) << 8) | | |
1290 | - ((cte.green>>4) << 4) | | |
1291 | - (cte.blue>>4) ; | |
1292 | -#ifdef CFG_INVERT_COLORS | |
1293 | - colreg ^= 0xFFF; | |
1294 | -#endif | |
1295 | - *cmap-- = colreg; | |
1296 | - } | |
1297 | - | |
1298 | - WATCHDOG_RESET(); | |
1299 | - } | |
1300 | - | |
1301 | - padded_line = (width&0x3) ? ((width&~0x3)+4) : (width); | |
1302 | - if ((x + width)>panel_info.vl_col) | |
1303 | - width = panel_info.vl_col - x; | |
1304 | - if ((y + height)>panel_info.vl_row) | |
1305 | - height = panel_info.vl_row - y; | |
1306 | - | |
1307 | - bmap = (uchar *)bmp + le32_to_cpu (bmp->header.data_offset); | |
1308 | - fb = (uchar *) (lcd_base + | |
1309 | - (y + height - 1) * lcd_line_length + x); | |
1310 | - for (i = 0; i < height; ++i) { | |
1311 | - WATCHDOG_RESET(); | |
1312 | - for (j = 0; j < width ; j++) | |
1313 | - *(fb++)=255-*(bmap++); | |
1314 | - bmap += (width - padded_line); | |
1315 | - fb -= (width + lcd_line_length); | |
1316 | - } | |
1317 | - | |
1318 | - return (0); | |
1319 | -} | |
1320 | -#endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) || CONFIG_SPLASH_SCREEN */ | |
1321 | - | |
1322 | -/*----------------------------------------------------------------------*/ | |
1323 | - | |
1324 | -static void *lcd_logo (void) | |
1325 | -{ | |
1326 | -#ifdef LCD_INFO | |
1327 | - DECLARE_GLOBAL_DATA_PTR; | |
1328 | - | |
1329 | - char info[80]; | |
1330 | - char temp[32]; | |
1331 | -#endif /* LCD_INFO */ | |
1332 | - | |
1333 | -#ifdef CONFIG_SPLASH_SCREEN | |
1334 | - char *s; | |
1335 | - ulong addr; | |
1336 | - static int do_splash = 1; | |
1337 | - | |
1338 | - if (do_splash && (s = getenv("splashimage")) != NULL) { | |
1339 | - addr = simple_strtoul(s, NULL, 16); | |
1340 | - do_splash = 0; | |
1341 | - | |
1342 | - if (lcd_display_bitmap (addr, 0, 0) == 0) { | |
1343 | - return ((void *)lcd_base); | |
1344 | - } | |
1345 | - } | |
1346 | -#endif /* CONFIG_SPLASH_SCREEN */ | |
1347 | - | |
1348 | -#ifdef CONFIG_LCD_LOGO | |
1349 | - bitmap_plot (0, 0); | |
1350 | -#endif /* CONFIG_LCD_LOGO */ | |
1351 | - | |
1352 | - | |
1353 | -#ifdef LCD_INFO | |
1354 | - sprintf (info, "%s (%s - %s) ", U_BOOT_VERSION, __DATE__, __TIME__); | |
1355 | - lcd_drawchars (LCD_INFO_X, LCD_INFO_Y, info, strlen(info)); | |
1356 | - | |
1357 | - sprintf (info, "(C) 2004 DENX Software Engineering"); | |
1358 | - lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT, | |
1359 | - info, strlen(info)); | |
1360 | - | |
1361 | - sprintf (info, " Wolfgang DENK, wd@denx.de"); | |
1362 | - lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 2, | |
1363 | - info, strlen(info)); | |
1364 | -#ifdef LCD_INFO_BELOW_LOGO | |
1365 | - sprintf (info, "MPC823 CPU at %s MHz", | |
1366 | - strmhz(temp, gd->cpu_clk)); | |
1367 | - lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 3, | |
1368 | - info, strlen(info)); | |
1369 | - sprintf (info, " %ld MB RAM, %ld MB Flash", | |
1370 | - gd->ram_size >> 20, | |
1371 | - gd->bd->bi_flashsize >> 20 ); | |
1372 | - lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4, | |
1373 | - info, strlen(info)); | |
1374 | -#else | |
1375 | - /* leave one blank line */ | |
1376 | - | |
1377 | - sprintf (info, "MPC823 CPU at %s MHz, %ld MB RAM, %ld MB Flash", | |
1378 | - strmhz(temp, gd->cpu_clk), | |
1379 | - gd->ram_size >> 20, | |
1380 | - gd->bd->bi_flashsize >> 20 ); | |
1381 | - lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4, | |
1382 | - info, strlen(info)); | |
1383 | -#endif /* LCD_INFO_BELOW_LOGO */ | |
1384 | -#endif /* LCD_INFO */ | |
1385 | - | |
1386 | -#if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO) | |
1387 | - return ((void *)((ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length)); | |
1388 | -#else | |
1389 | - return ((void *)lcd_base); | |
1390 | -#endif /* CONFIG_LCD_LOGO */ | |
1391 | -} | |
1392 | - | |
1393 | -/************************************************************************/ | |
1394 | 618 | /************************************************************************/ |
1395 | 619 | |
1396 | 620 | #endif /* CONFIG_LCD */ |
cpu/pxa/pxafb.c
Changes suppressed. Click to show
1 | 1 | /* |
2 | + * PXA LCD Controller | |
3 | + * | |
2 | 4 | * (C) Copyright 2001-2002 |
3 | 5 | * Wolfgang Denk, DENX Software Engineering -- wd@denx.de |
4 | 6 | * |
5 | 7 | |
6 | 8 | |
7 | 9 | |
8 | 10 | |
9 | 11 | |
10 | 12 | |
11 | 13 | |
12 | 14 | |
13 | 15 | |
14 | 16 | |
15 | 17 | |
16 | 18 | |
17 | 19 | |
18 | 20 | |
19 | 21 | |
20 | 22 | |
21 | 23 | |
22 | 24 | |
23 | 25 | |
24 | 26 | |
25 | 27 | |
26 | 28 | |
27 | 29 | |
28 | 30 | |
29 | 31 | |
30 | 32 | |
31 | 33 | |
32 | 34 | |
33 | 35 | |
34 | 36 | |
35 | 37 | |
36 | 38 | |
37 | 39 | |
38 | 40 | |
39 | 41 | |
... | ... | @@ -25,702 +27,164 @@ |
25 | 27 | /* ** HEADER FILES */ |
26 | 28 | /************************************************************************/ |
27 | 29 | |
28 | -#define DEBUG 1 | |
29 | 30 | #include <config.h> |
30 | 31 | #include <common.h> |
31 | 32 | #include <version.h> |
32 | 33 | #include <stdarg.h> |
33 | -#include <lcdvideo.h> | |
34 | 34 | #include <linux/types.h> |
35 | 35 | #include <devices.h> |
36 | +#include <lcd.h> | |
36 | 37 | #include <asm/arch/pxa-regs.h> |
37 | 38 | |
39 | +/* #define DEBUG */ | |
40 | + | |
38 | 41 | #ifdef CONFIG_LCD |
39 | 42 | |
40 | -/************************************************************************/ | |
41 | -/* ** CONFIG STUFF -- should be moved to board config file */ | |
42 | -/************************************************************************/ | |
43 | -#ifndef CONFIG_EDT32F10 | |
44 | -#define CONFIG_LCD_LOGO | |
45 | -#define LCD_INFO /* Display Logo, (C) and system info */ | |
46 | -#endif | |
47 | - | |
48 | -#ifdef CONFIG_V37 | |
49 | -#undef CONFIG_LCD_LOGO | |
50 | -#undef LCD_INFO | |
51 | -#endif | |
52 | - | |
53 | -#undef CONFIG_LCD_LOGO | |
54 | - | |
55 | -#define LCD_TEST_PATTERN | |
56 | -/* #define LCD_TEST_PATTERN */ /* color backgnd for frame/color adjust */ | |
57 | -/* #define CFG_INVERT_COLORS */ /* Not needed - adjust vl_dp instead */ | |
58 | -/************************************************************************/ | |
59 | - | |
60 | -/************************************************************************/ | |
61 | -/* ** FONT AND LOGO DATA */ | |
62 | -/************************************************************************/ | |
63 | - | |
64 | -#include <video_font.h> /* Get font data, width and height */ | |
65 | - | |
66 | -#ifdef CONFIG_LCD_LOGO | |
67 | -# include <bmp_nexus.h> /* Get logo data, width and height */ | |
68 | -#endif | |
69 | - | |
70 | -/************************************************************************/ | |
71 | -/************************************************************************/ | |
72 | - | |
43 | +/*----------------------------------------------------------------------*/ | |
73 | 44 | /* |
74 | - * Information about displays we are using. This is for configuring | |
75 | - * the LCD controller and memory allocation. Someone has to know what | |
76 | - * is connected, as we can't autodetect anything. | |
45 | + * Define panel bpp, LCCR0, LCCR3 and panel_info video struct for | |
46 | + * your display. | |
77 | 47 | */ |
78 | -#define CFG_HIGH 0 /* Pins are active high */ | |
79 | -#define CFG_LOW 1 /* Pins are active low */ | |
80 | 48 | |
81 | -/* PXA LCD DMA descriptor */ | |
82 | -struct pxafb_dma_descriptor { | |
83 | - u_long fdadr; | |
84 | - u_long fsadr; | |
85 | - u_long fidr; | |
86 | - u_long ldcmd; | |
87 | -}; | |
88 | - | |
89 | -/* PXA LCD info */ | |
90 | -struct pxafb_info { | |
91 | - | |
92 | - /* Misc registers */ | |
93 | - u_long reg_lccr3; | |
94 | - u_long reg_lccr2; | |
95 | - u_long reg_lccr1; | |
96 | - u_long reg_lccr0; | |
97 | - u_long fdadr0; | |
98 | - u_long fdadr1; | |
99 | - | |
100 | - /* DMA descriptors */ | |
101 | - struct pxafb_dma_descriptor * dmadesc_fblow; | |
102 | - struct pxafb_dma_descriptor * dmadesc_fbhigh; | |
103 | - struct pxafb_dma_descriptor * dmadesc_palette; | |
104 | - | |
105 | - u_long screen; /* physical address of frame buffer */ | |
106 | - u_long palette; /* physical address of palette memory */ | |
107 | - u_int palette_size; | |
108 | -}; | |
109 | - | |
110 | -typedef struct vidinfo { | |
111 | - ushort vl_col; /* Number of columns (i.e. 640) */ | |
112 | - ushort vl_row; /* Number of rows (i.e. 480) */ | |
113 | - ushort vl_width; /* Width of display area in millimeters */ | |
114 | - ushort vl_height; /* Height of display area in millimeters */ | |
115 | - | |
116 | - /* LCD configuration register. | |
117 | - */ | |
118 | - u_char vl_clkp; /* Clock polarity */ | |
119 | - u_char vl_oep; /* Output Enable polarity */ | |
120 | - u_char vl_hsp; /* Horizontal Sync polarity */ | |
121 | - u_char vl_vsp; /* Vertical Sync polarity */ | |
122 | - u_char vl_dp; /* Data polarity */ | |
123 | - u_char vl_bpix; /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8, 4 = 16 */ | |
124 | - u_char vl_lbw; /* LCD Bus width, 0 = 4, 1 = 8 */ | |
125 | - u_char vl_splt; /* Split display, 0 = single-scan, 1 = dual-scan */ | |
126 | - u_char vl_clor; /* Color, 0 = mono, 1 = color */ | |
127 | - u_char vl_tft; /* 0 = passive, 1 = TFT */ | |
128 | - | |
129 | - /* Horizontal control register. Timing from data sheet. | |
130 | - */ | |
131 | - ushort vl_hpw; /* Horz sync pulse width */ | |
132 | - u_char vl_blw; /* Wait before of line */ | |
133 | - u_char vl_elw; /* Wait end of line */ | |
134 | - | |
135 | - /* Vertical control register. | |
136 | - */ | |
137 | - u_char vl_vpw; /* Vertical sync pulse width */ | |
138 | - u_char vl_bfw; /* Wait before of frame */ | |
139 | - u_char vl_efw; /* Wait end of frame */ | |
140 | - | |
141 | - u_char vl_lcdac; /* LCD AC timing */ | |
142 | - | |
143 | - /* PXA LCD controller params | |
144 | - */ | |
145 | - struct pxafb_info pxa; | |
146 | - | |
147 | -} vidinfo_t; | |
148 | - | |
149 | -#define LCD_MONOCHROME 0 | |
150 | -#define LCD_COLOR2 1 | |
151 | -#define LCD_COLOR4 2 | |
152 | -#define LCD_COLOR8 3 | |
153 | -#define LCD_COLOR16 4 | |
154 | - | |
155 | -/*----------------------------------------------------------------------*/ | |
156 | -#define CONFIG_PXA_VGA | |
157 | 49 | #ifdef CONFIG_PXA_VGA |
158 | -/* | |
159 | - * LCD outputs connected to a video DAC | |
160 | - */ | |
50 | +/* LCD outputs connected to a video DAC */ | |
51 | +# define LCD_BPP LCD_COLOR8 | |
161 | 52 | |
162 | -#define LCD_BPP LCD_COLOR8 | |
163 | - | |
164 | 53 | /* you have to set lccr0 and lccr3 (including pcd) */ |
165 | -#define REG_LCCR0 0x003008f8 | |
166 | -#define REG_LCCR3 0x0300FF01 | |
54 | +# define REG_LCCR0 0x003008f8 | |
55 | +# define REG_LCCR3 0x0300FF01 | |
167 | 56 | |
168 | 57 | /* 640x480x16 @ 61 Hz */ |
169 | -static vidinfo_t panel_info = { | |
170 | - vl_col: 640, | |
171 | - vl_row: 480, | |
172 | - vl_width: 640, | |
173 | - vl_height: 480, | |
174 | - vl_clkp: CFG_HIGH, | |
175 | - vl_oep: CFG_HIGH, | |
176 | - vl_hsp: CFG_HIGH, | |
177 | - vl_vsp: CFG_HIGH, | |
178 | - vl_dp: CFG_HIGH, | |
179 | - vl_bpix: LCD_BPP, | |
180 | - vl_lbw: 0, | |
181 | - vl_splt: 0, | |
182 | - vl_clor: 0, | |
183 | - vl_lcdac: 0, | |
184 | - vl_tft: 1, | |
185 | - vl_hpw: 40, | |
186 | - vl_blw: 56, | |
187 | - vl_elw: 56, | |
188 | - vl_vpw: 20, | |
189 | - vl_bfw: 8, | |
190 | - vl_efw: 8, | |
58 | +vidinfo_t panel_info = { | |
59 | + vl_col: 640, | |
60 | + vl_row: 480, | |
61 | + vl_width: 640, | |
62 | + vl_height: 480, | |
63 | + vl_clkp: CFG_HIGH, | |
64 | + vl_oep: CFG_HIGH, | |
65 | + vl_hsp: CFG_HIGH, | |
66 | + vl_vsp: CFG_HIGH, | |
67 | + vl_dp: CFG_HIGH, | |
68 | + vl_bpix: LCD_BPP, | |
69 | + vl_lbw: 0, | |
70 | + vl_splt: 0, | |
71 | + vl_clor: 0, | |
72 | + vl_tft: 1, | |
73 | + vl_hpw: 40, | |
74 | + vl_blw: 56, | |
75 | + vl_elw: 56, | |
76 | + vl_vpw: 20, | |
77 | + vl_bfw: 8, | |
78 | + vl_efw: 8, | |
191 | 79 | }; |
192 | 80 | #endif /* CONFIG_PXA_VIDEO */ |
193 | 81 | |
82 | +/*----------------------------------------------------------------------*/ | |
194 | 83 | #ifdef CONFIG_SHARP_LM8V31 |
195 | 84 | |
196 | -#define LCD_BPP LCD_COLOR8 | |
197 | -#define LCD_INVERT_COLORS /* Needed for colors to be correct, but why? */ | |
85 | +# define LCD_BPP LCD_COLOR8 | |
86 | +# define LCD_INVERT_COLORS /* Needed for colors to be correct, but why? */ | |
198 | 87 | |
199 | 88 | /* you have to set lccr0 and lccr3 (including pcd) */ |
200 | -#define REG_LCCR0 0x0030087C | |
201 | -#define REG_LCCR3 0x0340FF08 | |
89 | +# define REG_LCCR0 0x0030087C | |
90 | +# define REG_LCCR3 0x0340FF08 | |
202 | 91 | |
203 | -static vidinfo_t panel_info = { | |
204 | - vl_col: 640, | |
205 | - vl_row: 480, | |
206 | - vl_width: 157, | |
207 | - vl_height: 118, | |
208 | - vl_clkp: CFG_HIGH, | |
209 | - vl_oep: CFG_HIGH, | |
210 | - vl_hsp: CFG_HIGH, | |
211 | - vl_vsp: CFG_HIGH, | |
212 | - vl_dp: CFG_HIGH, | |
213 | - vl_bpix: LCD_BPP, | |
214 | - vl_lbw: 0, | |
215 | - vl_splt: 1, | |
216 | - vl_clor: 1, | |
217 | - vl_lcdac: 0, | |
218 | - vl_tft: 0, | |
219 | - vl_hpw: 1, | |
220 | - vl_blw: 3, | |
221 | - vl_elw: 3, | |
222 | - vl_vpw: 1, | |
223 | - vl_bfw: 0, | |
224 | - vl_efw: 0, | |
92 | +vidinfo_t panel_info = { | |
93 | + vl_col: 640, | |
94 | + vl_row: 480, | |
95 | + vl_width: 157, | |
96 | + vl_height: 118, | |
97 | + vl_clkp: CFG_HIGH, | |
98 | + vl_oep: CFG_HIGH, | |
99 | + vl_hsp: CFG_HIGH, | |
100 | + vl_vsp: CFG_HIGH, | |
101 | + vl_dp: CFG_HIGH, | |
102 | + vl_bpix: LCD_BPP, | |
103 | + vl_lbw: 0, | |
104 | + vl_splt: 1, | |
105 | + vl_clor: 1, | |
106 | + vl_tft: 0, | |
107 | + vl_hpw: 1, | |
108 | + vl_blw: 3, | |
109 | + vl_elw: 3, | |
110 | + vl_vpw: 1, | |
111 | + vl_bfw: 0, | |
112 | + vl_efw: 0, | |
225 | 113 | }; |
226 | 114 | #endif /* CONFIG_SHARP_LM8V31 */ |
227 | 115 | |
228 | 116 | /*----------------------------------------------------------------------*/ |
117 | +#ifdef CONFIG_HITACHI_SX14 | |
118 | +/* Hitachi SX14Q004-ZZA color STN LCD */ | |
119 | +#define LCD_BPP LCD_COLOR8 | |
229 | 120 | |
230 | -/*----------------------------------------------------------------------*/ | |
121 | +/* you have to set lccr0 and lccr3 (including pcd) */ | |
122 | +#define REG_LCCR0 0x00301079 | |
123 | +#define REG_LCCR3 0x0340FF20 | |
231 | 124 | |
232 | -#if defined(LCD_INFO_BELOW_LOGO) | |
233 | -# define LCD_INFO_X 0 | |
234 | -# define LCD_INFO_Y (BMP_LOGO_HEIGHT + VIDEO_FONT_HEIGHT) | |
235 | -#elif defined(CONFIG_LCD_LOGO) | |
236 | -# define LCD_INFO_X (BMP_LOGO_WIDTH + 4 * VIDEO_FONT_WIDTH) | |
237 | -# define LCD_INFO_Y (VIDEO_FONT_HEIGHT) | |
238 | -#else | |
239 | -# define LCD_INFO_X (VIDEO_FONT_WIDTH) | |
240 | -# define LCD_INFO_Y (VIDEO_FONT_HEIGHT) | |
241 | -#endif | |
125 | +vidinfo_t panel_info = { | |
126 | + vl_col: 320, | |
127 | + vl_row: 240, | |
128 | + vl_width: 167, | |
129 | + vl_height: 109, | |
130 | + vl_clkp: CFG_HIGH, | |
131 | + vl_oep: CFG_HIGH, | |
132 | + vl_hsp: CFG_HIGH, | |
133 | + vl_vsp: CFG_HIGH, | |
134 | + vl_dp: CFG_HIGH, | |
135 | + vl_bpix: LCD_BPP, | |
136 | + vl_lbw: 1, | |
137 | + vl_splt: 0, | |
138 | + vl_clor: 1, | |
139 | + vl_tft: 0, | |
140 | + vl_hpw: 1, | |
141 | + vl_blw: 1, | |
142 | + vl_elw: 1, | |
143 | + vl_vpw: 7, | |
144 | + vl_bfw: 0, | |
145 | + vl_efw: 0, | |
146 | +}; | |
147 | +#endif /* CONFIG_HITACHI_SX14 */ | |
242 | 148 | |
243 | -#ifndef LCD_BPP | |
244 | -#define LCD_BPP LCD_COLOR8 | |
245 | -#endif | |
246 | -#ifndef LCD_DF | |
247 | -#define LCD_DF 1 | |
248 | -#endif | |
149 | +/*----------------------------------------------------------------------*/ | |
249 | 150 | |
250 | -#define NBITS(bit_code) (1 << (bit_code)) | |
251 | -#define NCOLORS(bit_code) (1 << NBITS(bit_code)) | |
252 | - | |
253 | -static int lcd_line_length; | |
254 | - | |
255 | -static int lcd_color_fg; | |
256 | -static int lcd_color_bg; | |
257 | - | |
258 | -static char lcd_is_enabled = 0; /* Indicate that LCD is enabled */ | |
259 | - | |
260 | -/* | |
261 | - * Frame buffer memory information | |
262 | - */ | |
263 | -static void *lcd_base; /* Start of framebuffer memory */ | |
264 | -static void *lcd_console_address; /* Start of console buffer */ | |
265 | - | |
266 | - | |
267 | -/************************************************************************/ | |
268 | -/* ** CONSOLE CONSTANTS */ | |
269 | -/************************************************************************/ | |
270 | - | |
271 | -#if LCD_BPP == LCD_MONOCHROME | |
272 | - | |
273 | -/* | |
274 | - * Simple color definitions | |
275 | - */ | |
276 | -#define CONSOLE_COLOR_BLACK 0 | |
277 | -#define CONSOLE_COLOR_WHITE 1 /* Must remain last / highest */ | |
278 | - | |
279 | -#elif LCD_BPP == LCD_COLOR8 | |
280 | - | |
281 | -/* | |
282 | - * Simple color definitions | |
283 | - */ | |
284 | -#define CONSOLE_COLOR_BLACK 0 | |
285 | -#define CONSOLE_COLOR_RED 1 | |
286 | -#define CONSOLE_COLOR_GREEN 2 | |
287 | -#define CONSOLE_COLOR_YELLOW 3 | |
288 | -#define CONSOLE_COLOR_BLUE 4 | |
289 | -#define CONSOLE_COLOR_MAGENTA 5 | |
290 | -#define CONSOLE_COLOR_CYAN 6 | |
291 | -#define CONSOLE_COLOR_GREY 14 | |
292 | -#define CONSOLE_COLOR_WHITE 15 /* Must remain last / highest */ | |
293 | - | |
294 | -#else /* 16 bit */ | |
295 | - | |
296 | -#define CONSOLE_COLOR_BLACK 0x0000 | |
297 | -#define CONSOLE_COLOR_WHITE 0xffff /* Must remain last / highest */ | |
298 | - | |
299 | -#endif | |
300 | - | |
301 | -#if defined(CONFIG_LCD_LOGO) && (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET) | |
302 | -#error Default Color Map overlaps with Logo Color Map | |
303 | -#endif | |
304 | - | |
305 | -/************************************************************************/ | |
306 | - | |
307 | -#ifndef PAGE_SIZE | |
308 | -#define PAGE_SIZE 4096 | |
309 | -#endif | |
310 | - | |
311 | - | |
312 | -/************************************************************************/ | |
313 | -/* ** CONSOLE DEFINITIONS & FUNCTIONS */ | |
314 | -/************************************************************************/ | |
315 | - | |
316 | -#if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO) | |
317 | -#define CONSOLE_ROWS ((panel_info.vl_row-BMP_LOGO_HEIGHT) \ | |
318 | - / VIDEO_FONT_HEIGHT) | |
319 | -#else | |
320 | -#define CONSOLE_ROWS (panel_info.vl_row / VIDEO_FONT_HEIGHT) | |
321 | -#endif | |
322 | -#define CONSOLE_COLS (panel_info.vl_col / VIDEO_FONT_WIDTH) | |
323 | -#define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * lcd_line_length) | |
324 | -#define CONSOLE_ROW_FIRST (lcd_console_address) | |
325 | -#define CONSOLE_ROW_SECOND (lcd_console_address + CONSOLE_ROW_SIZE) | |
326 | -#define CONSOLE_ROW_LAST (lcd_console_address + CONSOLE_SIZE \ | |
327 | - - CONSOLE_ROW_SIZE) | |
328 | -#define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS) | |
329 | -#define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE) | |
330 | - | |
331 | -#if LCD_BPP == LCD_MONOCHROME | |
332 | -#define COLOR_MASK(c) ((c) | (c) << 1 | (c) << 2 | (c) << 3 | \ | |
333 | - (c) << 4 | (c) << 5 | (c) << 6 | (c) << 7) | |
334 | -#elif LCD_BPP == LCD_COLOR8 | |
335 | -#define COLOR_MASK(c) (c) | |
336 | -#elif LCD_BPP == LCD_COLOR16 | |
337 | -#define COLOR_MASK(c) (c) | |
338 | -#else | |
339 | -#error Unsupported LCD BPP. | |
340 | -#endif | |
341 | - | |
342 | -static short console_col; | |
343 | -static short console_row; | |
344 | - | |
345 | -/************************************************************************/ | |
346 | - | |
347 | -ulong lcd_setmem (ulong addr); | |
348 | - | |
349 | -static void lcd_drawchars (ushort x, ushort y, uchar *str, int count); | |
350 | -static inline void lcd_puts_xy (ushort x, ushort y, uchar *s); | |
351 | -static inline void lcd_putc_xy (ushort x, ushort y, uchar c); | |
352 | - | |
353 | -static int lcd_init (void *lcdbase); | |
354 | -static void lcd_ctrl_init (void *lcdbase); | |
355 | -static void lcd_enable (void); | |
356 | -static void *lcd_logo (void); | |
357 | 151 | #if LCD_BPP == LCD_COLOR8 |
358 | -static void lcd_setcolreg (ushort regno, | |
359 | - ushort red, ushort green, ushort blue); | |
152 | +void lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue); | |
360 | 153 | #endif |
361 | 154 | #if LCD_BPP == LCD_MONOCHROME |
362 | -static void lcd_initcolregs (void); | |
155 | +void lcd_initcolregs (void); | |
363 | 156 | #endif |
364 | -static void lcd_setfgcolor (int color); | |
365 | -static void lcd_setbgcolor (int color); | |
366 | 157 | |
367 | -#ifdef NOT_USED_SO_FAR | |
368 | -static int lcd_getbgcolor (void); | |
369 | -static void lcd_disable (void); | |
370 | -static void lcd_getcolreg (ushort regno, | |
371 | - ushort *red, ushort *green, ushort *blue); | |
372 | -static int lcd_getfgcolor (void); | |
373 | -#endif /* NOT_USED_SO_FAR */ | |
158 | +#ifdef NOT_USED_SO_FAR | |
159 | +void lcd_disable (void); | |
160 | +void lcd_getcolreg (ushort regno, ushort *red, ushort *green, ushort *blue); | |
161 | +#endif /* NOT_USED_SO_FAR */ | |
374 | 162 | |
163 | +void lcd_ctrl_init (void *lcdbase); | |
164 | +void lcd_enable (void); | |
375 | 165 | |
376 | -static int pxafb_init_mem(void *lcdbase, vidinfo_t *vid); | |
377 | -static void pxafb_setup_gpio(vidinfo_t *vid); | |
378 | -static void pxafb_enable_controller(vidinfo_t *vid); | |
379 | -static int pxafb_init(vidinfo_t *vid); | |
166 | +int lcd_line_length; | |
167 | +int lcd_color_fg; | |
168 | +int lcd_color_bg; | |
380 | 169 | |
381 | -/************************************************************************/ | |
170 | +void *lcd_base; /* Start of framebuffer memory */ | |
171 | +void *lcd_console_address; /* Start of console buffer */ | |
382 | 172 | |
383 | -/*----------------------------------------------------------------------*/ | |
173 | +short console_col; | |
174 | +short console_row; | |
384 | 175 | |
385 | -static void console_scrollup (void) | |
386 | -{ | |
387 | - /* Copy up rows ignoring the first one */ | |
388 | - memcpy (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, CONSOLE_SCROLL_SIZE); | |
389 | - | |
390 | - /* Clear the last one */ | |
391 | - memset (CONSOLE_ROW_LAST, COLOR_MASK(lcd_color_bg), CONSOLE_ROW_SIZE); | |
392 | -} | |
393 | - | |
394 | -/*----------------------------------------------------------------------*/ | |
395 | - | |
396 | -static inline void console_back (void) | |
397 | -{ | |
398 | - if (--console_col < 0) { | |
399 | - console_col = CONSOLE_COLS-1 ; | |
400 | - if (--console_row < 0) { | |
401 | - console_row = 0; | |
402 | - } | |
403 | - } | |
404 | - | |
405 | - lcd_putc_xy (console_col * VIDEO_FONT_WIDTH, | |
406 | - console_row * VIDEO_FONT_HEIGHT, | |
407 | - ' '); | |
408 | -} | |
409 | - | |
410 | -/*----------------------------------------------------------------------*/ | |
411 | - | |
412 | -static inline void console_newline (void) | |
413 | -{ | |
414 | - ++console_row; | |
415 | - console_col = 0; | |
416 | - | |
417 | - /* Check if we need to scroll the terminal */ | |
418 | - if (console_row >= CONSOLE_ROWS) { | |
419 | - /* Scroll everything up */ | |
420 | - console_scrollup () ; | |
421 | - --console_row; | |
422 | - } | |
423 | -} | |
424 | - | |
425 | -/*----------------------------------------------------------------------*/ | |
426 | - | |
427 | -void lcd_putc (const char c) | |
428 | -{ | |
429 | - if (!lcd_is_enabled) { | |
430 | - serial_putc(c); | |
431 | - return; | |
432 | - } | |
433 | - | |
434 | - switch (c) { | |
435 | - case '\r': console_col = 0; | |
436 | - return; | |
437 | - | |
438 | - case '\n': console_newline(); | |
439 | - return; | |
440 | - | |
441 | - case '\t': /* Tab (8 chars alignment) */ | |
442 | - console_col |= 8; | |
443 | - console_col &= ~7; | |
444 | - | |
445 | - if (console_col >= CONSOLE_COLS) { | |
446 | - console_newline(); | |
447 | - } | |
448 | - return; | |
449 | - | |
450 | - case '\b': console_back(); | |
451 | - return; | |
452 | - | |
453 | - default: lcd_putc_xy (console_col * VIDEO_FONT_WIDTH, | |
454 | - console_row * VIDEO_FONT_HEIGHT, | |
455 | - c); | |
456 | - if (++console_col >= CONSOLE_COLS) { | |
457 | - console_newline(); | |
458 | - } | |
459 | - return; | |
460 | - } | |
461 | - /* NOTREACHED */ | |
462 | -} | |
463 | - | |
464 | -/*----------------------------------------------------------------------*/ | |
465 | - | |
466 | -void lcd_puts (const char *s) | |
467 | -{ | |
468 | - if (!lcd_is_enabled) { | |
469 | - serial_puts (s); | |
470 | - return; | |
471 | - } | |
472 | - | |
473 | - while (*s) { | |
474 | - lcd_putc (*s++); | |
475 | - } | |
476 | -} | |
477 | - | |
176 | +static int pxafb_init_mem (void *lcdbase, vidinfo_t *vid); | |
177 | +static void pxafb_setup_gpio (vidinfo_t *vid); | |
178 | +static void pxafb_enable_controller (vidinfo_t *vid); | |
179 | +static int pxafb_init (vidinfo_t *vid); | |
478 | 180 | /************************************************************************/ |
479 | -/* ** Low-Level Graphics Routines */ | |
480 | -/************************************************************************/ | |
481 | 181 | |
482 | -static void lcd_drawchars (ushort x, ushort y, uchar *str, int count) | |
483 | -{ | |
484 | - uchar *dest; | |
485 | - ushort off, row; | |
486 | - | |
487 | - dest = (uchar *)(lcd_base + y * lcd_line_length + x * (1 << LCD_BPP) / 8); | |
488 | - off = x * (1 << LCD_BPP) % 8; | |
489 | - | |
490 | - for (row=0; row < VIDEO_FONT_HEIGHT; ++row, dest += lcd_line_length) { | |
491 | - uchar *s = str; | |
492 | - uchar *d = dest; | |
493 | - int i; | |
494 | - | |
495 | -#if LCD_BPP == LCD_MONOCHROME | |
496 | - uchar rest = *d & -(1 << (8-off)); | |
497 | - uchar sym; | |
498 | -#endif | |
499 | - for (i=0; i<count; ++i) { | |
500 | - uchar c, bits; | |
501 | - | |
502 | - c = *s++; | |
503 | - bits = video_fontdata[c * VIDEO_FONT_HEIGHT + row]; | |
504 | - | |
505 | -#if LCD_BPP == LCD_MONOCHROME | |
506 | - sym = (COLOR_MASK(lcd_color_fg) & bits) | | |
507 | - (COLOR_MASK(lcd_color_bg) & ~bits); | |
508 | - | |
509 | - *d++ = rest | (sym >> off); | |
510 | - rest = sym << (8-off); | |
511 | -#elif LCD_BPP == LCD_COLOR8 | |
512 | - for (c=0; c<8; ++c) { | |
513 | - *d++ = (bits & 0x80) ? | |
514 | - lcd_color_fg : lcd_color_bg; | |
515 | - bits <<= 1; | |
516 | - } | |
517 | -#elif LCD_BPP == LCD_COLOR16 | |
518 | - for (c=0; c<16; ++c) { | |
519 | - *d++ = (bits & 0x80) ? | |
520 | - lcd_color_fg : lcd_color_bg; | |
521 | - bits <<= 1; | |
522 | - } | |
523 | -#endif | |
524 | - } | |
525 | - | |
526 | -#if LCD_BPP == LCD_MONOCHROME | |
527 | - *d = rest | (*d & ((1 << (8-off)) - 1)); | |
528 | -#endif | |
529 | - } | |
530 | -} | |
531 | - | |
532 | -/*----------------------------------------------------------------------*/ | |
533 | - | |
534 | -static inline void lcd_puts_xy (ushort x, ushort y, uchar *s) | |
535 | -{ | |
536 | -#if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO) | |
537 | - lcd_drawchars (x, y+BMP_LOGO_HEIGHT, s, strlen (s)); | |
538 | -#else | |
539 | - lcd_drawchars (x, y, s, strlen (s)); | |
540 | -#endif | |
541 | -} | |
542 | - | |
543 | -/*----------------------------------------------------------------------*/ | |
544 | - | |
545 | -static inline void lcd_putc_xy (ushort x, ushort y, uchar c) | |
546 | -{ | |
547 | -#if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO) | |
548 | - lcd_drawchars (x, y+BMP_LOGO_HEIGHT, &c, 1); | |
549 | -#else | |
550 | - lcd_drawchars (x, y, &c, 1); | |
551 | -#endif | |
552 | -} | |
553 | - | |
554 | 182 | /************************************************************************/ |
555 | -/** Small utility to check that you got the colours right */ | |
183 | +/* --------------- PXA chipset specific functions ------------------- */ | |
556 | 184 | /************************************************************************/ |
557 | -#ifdef LCD_TEST_PATTERN | |
558 | 185 | |
559 | -#define N_BLK_VERT 2 | |
560 | -#define N_BLK_HOR 3 | |
561 | - | |
562 | -static int test_colors[N_BLK_HOR*N_BLK_VERT] = { | |
563 | - CONSOLE_COLOR_RED, CONSOLE_COLOR_GREEN, CONSOLE_COLOR_YELLOW, | |
564 | - CONSOLE_COLOR_BLUE, CONSOLE_COLOR_MAGENTA, CONSOLE_COLOR_CYAN, | |
565 | -}; | |
566 | - | |
567 | -static void test_pattern (void) | |
186 | +void lcd_ctrl_init (void *lcdbase) | |
568 | 187 | { |
569 | - ushort v_max = panel_info.vl_row; | |
570 | - ushort h_max = panel_info.vl_col; | |
571 | - ushort v_step = (v_max + N_BLK_VERT - 1) / N_BLK_VERT; | |
572 | - ushort h_step = (h_max + N_BLK_HOR - 1) / N_BLK_HOR; | |
573 | - ushort v, h; | |
574 | - uchar *pix = (uchar *)lcd_base; | |
575 | - | |
576 | - printf ("[LCD] Test Pattern: %d x %d [%d x %d]\n", | |
577 | - h_max, v_max, h_step, v_step); | |
578 | - | |
579 | - /* WARNING: Code silently assumes 8bit/pixel */ | |
580 | - for (v=0; v<v_max; ++v) { | |
581 | - uchar iy = v / v_step; | |
582 | - for (h=0; h<h_max; ++h) { | |
583 | - uchar ix = N_BLK_HOR * iy + (h/h_step); | |
584 | - *pix++ = test_colors[ix]; | |
585 | - } | |
586 | - } | |
587 | -} | |
588 | -#endif /* LCD_TEST_PATTERN */ | |
589 | - | |
590 | - | |
591 | -/************************************************************************/ | |
592 | -/* ** GENERIC Initialization Routines */ | |
593 | -/************************************************************************/ | |
594 | - | |
595 | -int drv_lcd_init (void) | |
596 | -{ | |
597 | - DECLARE_GLOBAL_DATA_PTR; | |
598 | - | |
599 | - device_t lcddev; | |
600 | - int rc; | |
601 | - | |
602 | - lcd_base = (void *)(gd->fb_base); | |
603 | - | |
604 | - lcd_line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8; | |
605 | - | |
606 | - lcd_init (lcd_base); /* LCD initialization */ | |
607 | - | |
608 | - /* Device initialization */ | |
609 | - memset (&lcddev, 0, sizeof (lcddev)); | |
610 | - | |
611 | - strcpy (lcddev.name, "lcd"); | |
612 | - lcddev.ext = 0; /* No extensions */ | |
613 | - lcddev.flags = DEV_FLAGS_OUTPUT; /* Output only */ | |
614 | - lcddev.putc = lcd_putc; /* 'putc' function */ | |
615 | - lcddev.puts = lcd_puts; /* 'puts' function */ | |
616 | - | |
617 | - rc = device_register (&lcddev); | |
618 | - return (rc == 0) ? 1 : rc; | |
619 | -} | |
620 | - | |
621 | -/*----------------------------------------------------------------------*/ | |
622 | - | |
623 | -static int lcd_init (void *lcdbase) | |
624 | -{ | |
625 | - /* Initialize the lcd controller */ | |
626 | - debug ("[LCD] Initializing LCD frambuffer at %p\n", lcdbase); | |
627 | - | |
628 | - lcd_ctrl_init (lcdbase); | |
629 | - | |
630 | -#if LCD_BPP == LCD_MONOCHROME | |
631 | - /* Setting the palette */ | |
632 | - lcd_initcolregs(); | |
633 | - | |
634 | -#elif LCD_BPP == LCD_COLOR8 | |
635 | - /* Setting the palette */ | |
636 | - lcd_setcolreg (CONSOLE_COLOR_BLACK, 0, 0, 0); | |
637 | - lcd_setcolreg (CONSOLE_COLOR_RED, 0xFF, 0, 0); | |
638 | - lcd_setcolreg (CONSOLE_COLOR_GREEN, 0, 0xFF, 0); | |
639 | - lcd_setcolreg (CONSOLE_COLOR_YELLOW, 0xFF, 0xFF, 0); | |
640 | - lcd_setcolreg (CONSOLE_COLOR_BLUE, 0, 0, 0xFF); | |
641 | - lcd_setcolreg (CONSOLE_COLOR_MAGENTA, 0xFF, 0, 0xFF); | |
642 | - lcd_setcolreg (CONSOLE_COLOR_CYAN, 0, 0xFF, 0xFF); | |
643 | - lcd_setcolreg (CONSOLE_COLOR_GREY, 0xAA, 0xAA, 0xAA); | |
644 | - lcd_setcolreg (CONSOLE_COLOR_WHITE, 0xFF, 0xFF, 0xFF); | |
645 | -#endif | |
646 | - | |
647 | -#define CFG_WHITE_ON_BLACK | |
648 | -#ifndef CFG_WHITE_ON_BLACK | |
649 | - lcd_setfgcolor (CONSOLE_COLOR_BLACK); | |
650 | - lcd_setbgcolor (CONSOLE_COLOR_WHITE); | |
651 | -#else | |
652 | - lcd_setfgcolor (CONSOLE_COLOR_WHITE); | |
653 | - lcd_setbgcolor (CONSOLE_COLOR_BLACK); | |
654 | -#endif /* CFG_WHITE_ON_BLACK */ | |
655 | - | |
656 | -#ifdef LCD_TEST_PATTERN | |
657 | - test_pattern(); | |
658 | -#else | |
659 | - /* set framebuffer to background color */ | |
660 | - memset ((char *)lcd_base, | |
661 | - COLOR_MASK(lcd_getbgcolor()), | |
662 | - lcd_line_length*panel_info.vl_row); | |
663 | -#endif | |
664 | - | |
665 | - lcd_enable (); | |
666 | - | |
667 | - /* Paint the logo and retrieve LCD base address */ | |
668 | - debug ("[LCD] Drawing the logo...\n"); | |
669 | - lcd_console_address = lcd_logo (); | |
670 | - | |
671 | - /* Initialize the console */ | |
672 | - console_col = 0; | |
673 | -#ifdef LCD_INFO_BELOW_LOGO | |
674 | - console_row = 7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT; | |
675 | -#else | |
676 | - console_row = 1; /* leave 1 blank line below logo */ | |
677 | -#endif | |
678 | - lcd_is_enabled = 1; | |
679 | - | |
680 | - return 0; | |
681 | -} | |
682 | - | |
683 | - | |
684 | -/************************************************************************/ | |
685 | -/* ** ROM capable initialization part - needed to reserve FB memory */ | |
686 | -/************************************************************************/ | |
687 | - | |
688 | -/* | |
689 | - * This is called early in the system initialization to grab memory | |
690 | - * for the LCD controller. | |
691 | - * Returns new address for monitor, after reserving LCD buffer memory | |
692 | - * | |
693 | - * Note that this is running from ROM, so no write access to global data. | |
694 | - */ | |
695 | -ulong lcd_setmem (ulong addr) | |
696 | -{ | |
697 | - ulong size; | |
698 | - int line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8; | |
699 | - | |
700 | - debug ("LCD panel info: %d x %d, %d bit/pix\n", | |
701 | - panel_info.vl_col, panel_info.vl_row, NBITS (panel_info.vl_bpix) ); | |
702 | - | |
703 | - /* extra page for dma descriptors and palette */ | |
704 | - size = line_length * panel_info.vl_row + PAGE_SIZE; | |
705 | - | |
706 | - /* Round up to nearest full page */ | |
707 | - size = (size + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); | |
708 | - | |
709 | - /* Allocate pages for the frame buffer. */ | |
710 | - addr -= size; | |
711 | - | |
712 | - debug ("Reserving %ldk for LCD Framebuffer at: %08lx\n", size>>10, addr); | |
713 | - | |
714 | - return (addr); | |
715 | -} | |
716 | - | |
717 | - | |
718 | -/************************************************************************/ | |
719 | -/* ----------------- chipset specific functions ----------------------- */ | |
720 | -/************************************************************************/ | |
721 | - | |
722 | -static void lcd_ctrl_init (void *lcdbase) | |
723 | -{ | |
724 | 188 | pxafb_init_mem(lcdbase, &panel_info); |
725 | 189 | pxafb_init(&panel_info); |
726 | 190 | pxafb_setup_gpio(&panel_info); |
727 | 191 | |
728 | 192 | |
729 | 193 | |
... | ... | @@ -728,18 +192,16 @@ |
728 | 192 | } |
729 | 193 | |
730 | 194 | /*----------------------------------------------------------------------*/ |
731 | - | |
732 | -#ifdef NOT_USED_SO_FAR | |
733 | -static void | |
195 | +#ifdef NOT_USED_SO_FAR | |
196 | +void | |
734 | 197 | lcd_getcolreg (ushort regno, ushort *red, ushort *green, ushort *blue) |
735 | 198 | { |
736 | 199 | } |
737 | -#endif /* NOT_USED_SO_FAR */ | |
200 | +#endif /* NOT_USED_SO_FAR */ | |
738 | 201 | |
739 | 202 | /*----------------------------------------------------------------------*/ |
740 | - | |
741 | 203 | #if LCD_BPP == LCD_COLOR8 |
742 | -static void | |
204 | +void | |
743 | 205 | lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue) |
744 | 206 | { |
745 | 207 | struct pxafb_info *fbi = &panel_info.pxa; |
... | ... | @@ -754,7 +216,7 @@ |
754 | 216 | #ifdef LCD_INVERT_COLORS |
755 | 217 | palette[regno] = ~val; |
756 | 218 | #else |
757 | - palette[regno] = ~val; | |
219 | + palette[regno] = val; | |
758 | 220 | #endif |
759 | 221 | } |
760 | 222 | |
761 | 223 | |
762 | 224 | |
763 | 225 | |
764 | 226 | |
765 | 227 | |
766 | 228 | |
767 | 229 | |
768 | 230 | |
769 | 231 | |
770 | 232 | |
771 | 233 | |
772 | 234 | |
773 | 235 | |
774 | 236 | |
775 | 237 | |
776 | 238 | |
777 | 239 | |
778 | 240 | |
779 | 241 | |
780 | 242 | |
... | ... | @@ -763,138 +225,58 @@ |
763 | 225 | red, green, blue, |
764 | 226 | palette[regno]); |
765 | 227 | } |
766 | -#endif /* LCD_COLOR8 */ | |
228 | +#endif /* LCD_COLOR8 */ | |
767 | 229 | |
768 | 230 | /*----------------------------------------------------------------------*/ |
769 | - | |
770 | 231 | #if LCD_BPP == LCD_MONOCHROME |
771 | -static | |
772 | 232 | void lcd_initcolregs (void) |
773 | 233 | { |
774 | - volatile immap_t *immr = (immap_t *) CFG_IMMR; | |
775 | - volatile cpm8xx_t *cp = &(immr->im_cpm); | |
234 | + struct pxafb_info *fbi = &panel_info.pxa; | |
235 | + cmap = (ushort *)fbi->palette; | |
776 | 236 | ushort regno; |
777 | 237 | |
778 | 238 | for (regno = 0; regno < 16; regno++) { |
779 | - cp->lcd_cmap[regno * 2] = 0; | |
780 | - cp->lcd_cmap[(regno * 2) + 1] = regno & 0x0f; | |
239 | + cmap[regno * 2] = 0; | |
240 | + cmap[(regno * 2) + 1] = regno & 0x0f; | |
781 | 241 | } |
782 | 242 | } |
783 | -#endif | |
243 | +#endif /* LCD_MONOCHROME */ | |
784 | 244 | |
785 | 245 | /*----------------------------------------------------------------------*/ |
786 | - | |
787 | -static void lcd_setfgcolor (int color) | |
246 | +void lcd_enable (void) | |
788 | 247 | { |
789 | - lcd_color_fg = color & 0x0F; | |
790 | 248 | } |
791 | 249 | |
792 | 250 | /*----------------------------------------------------------------------*/ |
793 | - | |
794 | -static void lcd_setbgcolor (int color) | |
795 | -{ | |
796 | - lcd_color_bg = color & 0x0F; | |
797 | -} | |
798 | - | |
799 | -/*----------------------------------------------------------------------*/ | |
800 | - | |
801 | 251 | #ifdef NOT_USED_SO_FAR |
802 | -static int lcd_getfgcolor (void) | |
252 | +static void lcd_disable (void) | |
803 | 253 | { |
804 | - return lcd_color_fg; | |
805 | 254 | } |
806 | -#endif /* NOT_USED_SO_FAR */ | |
255 | +#endif /* NOT_USED_SO_FAR */ | |
807 | 256 | |
808 | 257 | /*----------------------------------------------------------------------*/ |
809 | 258 | |
810 | -#ifdef NOT_USED_SO_FAR | |
811 | -static int lcd_getbgcolor (void) | |
812 | -{ | |
813 | - return lcd_color_bg; | |
814 | -} | |
815 | -#endif /* NOT_USED_SO_FAR */ | |
816 | - | |
817 | -/*----------------------------------------------------------------------*/ | |
818 | - | |
819 | -static void lcd_enable (void) | |
820 | -{ | |
821 | -} | |
822 | - | |
823 | -/*----------------------------------------------------------------------*/ | |
824 | - | |
825 | -#ifdef NOT_USED_SO_FAR | |
826 | -static void lcd_disable (void) | |
827 | -{ | |
828 | -} | |
829 | -#endif /* NOT_USED_SO_FAR */ | |
830 | - | |
831 | - | |
832 | 259 | /************************************************************************/ |
833 | -/* ** Chipset depending Bitmap / Logo stuff... */ | |
260 | +/* ** PXA255 specific routines */ | |
834 | 261 | /************************************************************************/ |
835 | 262 | |
836 | -#ifdef CONFIG_LCD_LOGO | |
837 | -static void bitmap_plot (int x, int y) | |
263 | +/* | |
264 | + * Calculate fb size for VIDEOLFB_ATAG. Size returned contains fb, | |
265 | + * descriptors and palette areas. | |
266 | + */ | |
267 | +ulong calc_fbsize (void) | |
838 | 268 | { |
839 | - ushort *cmap; | |
840 | - ushort i; | |
841 | - uchar *bmap; | |
842 | - uchar *fb; | |
843 | - struct pxafb_info *fbi = &panel_info.pxa; | |
269 | + ulong size; | |
270 | + int line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8; | |
844 | 271 | |
845 | - debug ("Logo: width %d height %d colors %d cmap %d\n", | |
846 | - BMP_LOGO_WIDTH, BMP_LOGO_HEIGHT, BMP_LOGO_COLORS, | |
847 | - sizeof(bmp_logo_palette)/(sizeof(ushort)) | |
848 | - ); | |
272 | + size = line_length * panel_info.vl_row; | |
273 | + size += PAGE_SIZE; | |
849 | 274 | |
850 | - /* Leave room for default color map */ | |
851 | - cmap = (ushort *)fbi->palette; | |
852 | - | |
853 | - /* Set color map */ | |
854 | - for (i=0; i<(sizeof(bmp_logo_palette)/(sizeof(ushort))); ++i) { | |
855 | - ushort colreg = bmp_logo_palette[i]; | |
856 | -#ifdef CFG_INVERT_COLORS | |
857 | - colreg ^= 0xFFF; | |
858 | -#endif | |
859 | - *cmap++ = colreg; | |
860 | - } | |
861 | - | |
862 | - bmap = &bmp_logo_bitmap[0]; | |
863 | - fb = (char *)(lcd_base + y * lcd_line_length + x); | |
864 | - | |
865 | - for (i=0; i<BMP_LOGO_HEIGHT; ++i) { | |
866 | - memcpy (fb, bmap, BMP_LOGO_WIDTH); | |
867 | - bmap += BMP_LOGO_WIDTH; | |
868 | - fb += panel_info.vl_col; | |
869 | - } | |
275 | + return size; | |
870 | 276 | } |
871 | -#endif /* CONFIG_LCD_LOGO */ | |
872 | 277 | |
873 | -/*----------------------------------------------------------------------*/ | |
874 | - | |
875 | -static void *lcd_logo (void) | |
278 | +static int pxafb_init_mem (void *lcdbase, vidinfo_t *vid) | |
876 | 279 | { |
877 | -#ifdef CONFIG_LCD_LOGO | |
878 | - DECLARE_GLOBAL_DATA_PTR; | |
879 | - char info[80]; | |
880 | - char temp[32]; | |
881 | - | |
882 | - bitmap_plot (0, 0); | |
883 | -#endif /* CONFIG_LCD_LOGO */ | |
884 | - | |
885 | -#if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO) | |
886 | - return ((void *)((ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length)); | |
887 | -#else | |
888 | - return ((void *)lcd_base); | |
889 | -#endif /* CONFIG_LCD_LOGO */ | |
890 | -} | |
891 | - | |
892 | -/************************************************************************ | |
893 | - PXA255 specific routines | |
894 | -************************************************************************/ | |
895 | - | |
896 | -static int pxafb_init_mem(void *lcdbase, vidinfo_t *vid) | |
897 | -{ | |
898 | 280 | u_long palette_mem_size; |
899 | 281 | struct pxafb_info *fbi = &vid->pxa; |
900 | 282 | int fb_size = vid->vl_row * (vid->vl_col * NBITS (vid->vl_bpix)) / 8; |
901 | 283 | |
902 | 284 | |
... | ... | @@ -903,14 +285,15 @@ |
903 | 285 | |
904 | 286 | fbi->palette_size = NBITS(vid->vl_bpix) == 8 ? 256 : 16; |
905 | 287 | palette_mem_size = fbi->palette_size * sizeof(u16); |
288 | + | |
906 | 289 | debug("palette_mem_size = 0x%08lx\n", (u_long) palette_mem_size); |
907 | 290 | /* locate palette and descs at end of page following fb */ |
908 | - fbi->palette = (u_long)lcdbase + fb_size + 2*PAGE_SIZE - palette_mem_size; | |
291 | + fbi->palette = (u_long)lcdbase + fb_size + PAGE_SIZE - palette_mem_size; | |
909 | 292 | |
910 | 293 | return 0; |
911 | 294 | } |
912 | 295 | |
913 | -static void pxafb_setup_gpio(vidinfo_t *vid) | |
296 | +static void pxafb_setup_gpio (vidinfo_t *vid) | |
914 | 297 | { |
915 | 298 | u_long lccr0; |
916 | 299 | |
... | ... | @@ -935,7 +318,7 @@ |
935 | 318 | |
936 | 319 | /* 8 bit interface */ |
937 | 320 | else if (((lccr0 & LCCR0_CMS) && ((lccr0 & LCCR0_SDS) || (lccr0 & LCCR0_DPD))) || |
938 | - (!(lccr0 & LCCR0_CMS) && !(lccr0 & LCCR0_PAS) && !(lccr0 & LCCR0_SDS))) | |
321 | + (!(lccr0 & LCCR0_CMS) && !(lccr0 & LCCR0_PAS) && !(lccr0 & LCCR0_SDS))) | |
939 | 322 | { |
940 | 323 | debug("Setting GPIO for 8 bit data\n"); |
941 | 324 | /* bits 58-65 */ |
... | ... | @@ -967,7 +350,7 @@ |
967 | 350 | } |
968 | 351 | } |
969 | 352 | |
970 | -static void pxafb_enable_controller(vidinfo_t *vid) | |
353 | +static void pxafb_enable_controller (vidinfo_t *vid) | |
971 | 354 | { |
972 | 355 | debug("Enabling LCD controller\n"); |
973 | 356 | |
... | ... | @@ -990,7 +373,7 @@ |
990 | 373 | debug("LCCR3 = 0x%08x\n", (unsigned int)LCCR3); |
991 | 374 | } |
992 | 375 | |
993 | -static int pxafb_init(vidinfo_t *vid) | |
376 | +static int pxafb_init (vidinfo_t *vid) | |
994 | 377 | { |
995 | 378 | struct pxafb_info *fbi = &vid->pxa; |
996 | 379 | |
... | ... | @@ -1019,9 +402,8 @@ |
1019 | 402 | LCCR2_EndFrmDel(vid->vl_efw); |
1020 | 403 | |
1021 | 404 | fbi->reg_lccr3 = REG_LCCR3 & ~(LCCR3_HSP | LCCR3_VSP); |
1022 | - fbi->reg_lccr3 |= | |
1023 | - (vid->vl_hsp ? LCCR3_HorSnchL : LCCR3_HorSnchH) | |
1024 | - | (vid->vl_vsp ? LCCR3_VrtSnchL : LCCR3_VrtSnchH); | |
405 | + fbi->reg_lccr3 |= (vid->vl_hsp ? LCCR3_HorSnchL : LCCR3_HorSnchH) | |
406 | + | (vid->vl_vsp ? LCCR3_VrtSnchL : LCCR3_VrtSnchH); | |
1025 | 407 | |
1026 | 408 | |
1027 | 409 | /* setup dma descriptors */ |
include/bmp_logo.h
... | ... | @@ -18,7 +18,7 @@ |
18 | 18 | 0x0343, 0x0454, 0x0565, 0x0565, 0x0676, 0x0787, 0x0898, 0x0999, |
19 | 19 | 0x0AAA, 0x0ABA, 0x0BCB, 0x0CCC, 0x0DDD, 0x0EEE, 0x0FFF, 0x0FB3, |
20 | 20 | 0x0FB4, 0x0FC4, 0x0FC5, 0x0FC6, 0x0FD7, 0x0FD8, 0x0FD9, 0x0FDA, |
21 | - 0x0FEA, 0x0FEB, 0x0FEC, 0x0FFD, 0x0FFE, 0x0FFF, 0x0FFF, | |
21 | + 0x0FEA, 0x0FEB, 0x0FEC, 0x0FFD, 0x0FFE, 0x0FFF, 0x0FFF, | |
22 | 22 | }; |
23 | 23 | |
24 | 24 | unsigned char bmp_logo_bitmap[] = { |
include/lcd.h
1 | 1 | /* |
2 | - * MPC823 LCD Controller | |
2 | + * MPC823 and PXA LCD Controller | |
3 | 3 | * |
4 | 4 | * Modeled after video interface by Paolo Scaffardi |
5 | 5 | * |
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 | * |
18 | 18 | * This program is distributed in the hope that it will be useful, |
19 | 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | 21 | * GNU General Public License for more details. |
22 | 22 | * |
23 | 23 | * You should have received a copy of the GNU General Public License |
24 | 24 | |
25 | 25 | |
26 | 26 | |
27 | 27 | |
... | ... | @@ -29,18 +29,267 @@ |
29 | 29 | #ifndef _LCD_H_ |
30 | 30 | #define _LCD_H_ |
31 | 31 | |
32 | -#if defined(CONFIG_RBC823) | |
33 | -void lcd_disable (void); | |
34 | -#endif | |
35 | - | |
36 | 32 | extern char lcd_is_enabled; |
37 | 33 | |
34 | +extern int lcd_line_length; | |
35 | +extern int lcd_color_fg; | |
36 | +extern int lcd_color_bg; | |
37 | + | |
38 | +/* | |
39 | + * Frame buffer memory information | |
40 | + */ | |
41 | +extern void *lcd_base; /* Start of framebuffer memory */ | |
42 | +extern void *lcd_console_address; /* Start of console buffer */ | |
43 | + | |
44 | +extern short console_col; | |
45 | +extern short console_row; | |
46 | + | |
47 | +#if defined CONFIG_MPC823 | |
48 | +/* | |
49 | + * LCD controller stucture for MPC823 CPU | |
50 | + */ | |
51 | +typedef struct vidinfo { | |
52 | + ushort vl_col; /* Number of columns (i.e. 640) */ | |
53 | + ushort vl_row; /* Number of rows (i.e. 480) */ | |
54 | + ushort vl_width; /* Width of display area in millimeters */ | |
55 | + ushort vl_height; /* Height of display area in millimeters */ | |
56 | + | |
57 | + /* LCD configuration register */ | |
58 | + u_char vl_clkp; /* Clock polarity */ | |
59 | + u_char vl_oep; /* Output Enable polarity */ | |
60 | + u_char vl_hsp; /* Horizontal Sync polarity */ | |
61 | + u_char vl_vsp; /* Vertical Sync polarity */ | |
62 | + u_char vl_dp; /* Data polarity */ | |
63 | + u_char vl_bpix; /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8 */ | |
64 | + u_char vl_lbw; /* LCD Bus width, 0 = 4, 1 = 8 */ | |
65 | + u_char vl_splt; /* Split display, 0 = single-scan, 1 = dual-scan */ | |
66 | + u_char vl_clor; /* Color, 0 = mono, 1 = color */ | |
67 | + u_char vl_tft; /* 0 = passive, 1 = TFT */ | |
68 | + | |
69 | + /* Horizontal control register. Timing from data sheet */ | |
70 | + ushort vl_wbl; /* Wait between lines */ | |
71 | + | |
72 | + /* Vertical control register */ | |
73 | + u_char vl_vpw; /* Vertical sync pulse width */ | |
74 | + u_char vl_lcdac; /* LCD AC timing */ | |
75 | + u_char vl_wbf; /* Wait between frames */ | |
76 | +} vidinfo_t; | |
77 | + | |
78 | +extern vidinfo_t panel_info; | |
79 | + | |
80 | +#elif defined CONFIG_PXA250 | |
81 | +/* | |
82 | + * PXA LCD DMA descriptor | |
83 | + */ | |
84 | +struct pxafb_dma_descriptor { | |
85 | + u_long fdadr; /* Frame descriptor address register */ | |
86 | + u_long fsadr; /* Frame source address register */ | |
87 | + u_long fidr; /* Frame ID register */ | |
88 | + u_long ldcmd; /* Command register */ | |
89 | +}; | |
90 | + | |
91 | +/* | |
92 | + * PXA LCD info | |
93 | + */ | |
94 | +struct pxafb_info { | |
95 | + | |
96 | + /* Misc registers */ | |
97 | + u_long reg_lccr3; | |
98 | + u_long reg_lccr2; | |
99 | + u_long reg_lccr1; | |
100 | + u_long reg_lccr0; | |
101 | + u_long fdadr0; | |
102 | + u_long fdadr1; | |
103 | + | |
104 | + /* DMA descriptors */ | |
105 | + struct pxafb_dma_descriptor * dmadesc_fblow; | |
106 | + struct pxafb_dma_descriptor * dmadesc_fbhigh; | |
107 | + struct pxafb_dma_descriptor * dmadesc_palette; | |
108 | + | |
109 | + u_long screen; /* physical address of frame buffer */ | |
110 | + u_long palette; /* physical address of palette memory */ | |
111 | + u_int palette_size; | |
112 | +}; | |
113 | + | |
114 | +/* | |
115 | + * LCD controller stucture for PXA CPU | |
116 | + */ | |
117 | +typedef struct vidinfo { | |
118 | + ushort vl_col; /* Number of columns (i.e. 640) */ | |
119 | + ushort vl_row; /* Number of rows (i.e. 480) */ | |
120 | + ushort vl_width; /* Width of display area in millimeters */ | |
121 | + ushort vl_height; /* Height of display area in millimeters */ | |
122 | + | |
123 | + /* LCD configuration register */ | |
124 | + u_char vl_clkp; /* Clock polarity */ | |
125 | + u_char vl_oep; /* Output Enable polarity */ | |
126 | + u_char vl_hsp; /* Horizontal Sync polarity */ | |
127 | + u_char vl_vsp; /* Vertical Sync polarity */ | |
128 | + u_char vl_dp; /* Data polarity */ | |
129 | + u_char vl_bpix; /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8, 4 = 16 */ | |
130 | + u_char vl_lbw; /* LCD Bus width, 0 = 4, 1 = 8 */ | |
131 | + u_char vl_splt; /* Split display, 0 = single-scan, 1 = dual-scan */ | |
132 | + u_char vl_clor; /* Color, 0 = mono, 1 = color */ | |
133 | + u_char vl_tft; /* 0 = passive, 1 = TFT */ | |
134 | + | |
135 | + /* Horizontal control register. Timing from data sheet */ | |
136 | + ushort vl_hpw; /* Horz sync pulse width */ | |
137 | + u_char vl_blw; /* Wait before of line */ | |
138 | + u_char vl_elw; /* Wait end of line */ | |
139 | + | |
140 | + /* Vertical control register. */ | |
141 | + u_char vl_vpw; /* Vertical sync pulse width */ | |
142 | + u_char vl_bfw; /* Wait before of frame */ | |
143 | + u_char vl_efw; /* Wait end of frame */ | |
144 | + | |
145 | + /* PXA LCD controller params */ | |
146 | + struct pxafb_info pxa; | |
147 | +} vidinfo_t; | |
148 | + | |
149 | +extern vidinfo_t panel_info; | |
150 | + | |
151 | +#endif /* CONFIG_MPC823 or CONFIG_PXA250 */ | |
152 | + | |
38 | 153 | /* Video functions */ |
39 | 154 | |
155 | +#if defined(CONFIG_RBC823) | |
156 | +void lcd_disable (void); | |
157 | +#endif | |
158 | + | |
159 | + | |
40 | 160 | /* int lcd_init (void *lcdbase); */ |
41 | 161 | void lcd_putc (const char c); |
42 | 162 | void lcd_puts (const char *s); |
43 | 163 | void lcd_printf (const char *fmt, ...); |
44 | 164 | |
165 | + | |
166 | +/************************************************************************/ | |
167 | +/* ** BITMAP DISPLAY SUPPORT */ | |
168 | +/************************************************************************/ | |
169 | +#if (CONFIG_COMMANDS & CFG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN) | |
170 | +# include <bmp_layout.h> | |
171 | +# include <asm/byteorder.h> | |
172 | +#endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) || CONFIG_SPLASH_SCREEN */ | |
173 | + | |
174 | +/************************************************************************/ | |
175 | +/* ** LOGO DATA */ | |
176 | +/************************************************************************/ | |
177 | +#ifdef CONFIG_LCD_LOGO | |
178 | +# include <bmp_logo.h> /* Get logo data, width and height */ | |
45 | 179 | #endif |
180 | + | |
181 | +/* | |
182 | + * Information about displays we are using. This is for configuring | |
183 | + * the LCD controller and memory allocation. Someone has to know what | |
184 | + * is connected, as we can't autodetect anything. | |
185 | + */ | |
186 | +#define CFG_HIGH 0 /* Pins are active high */ | |
187 | +#define CFG_LOW 1 /* Pins are active low */ | |
188 | + | |
189 | +#define LCD_MONOCHROME 0 | |
190 | +#define LCD_COLOR2 1 | |
191 | +#define LCD_COLOR4 2 | |
192 | +#define LCD_COLOR8 3 | |
193 | +#define LCD_COLOR16 4 | |
194 | + | |
195 | +/*----------------------------------------------------------------------*/ | |
196 | +#if defined(LCD_INFO_BELOW_LOGO) | |
197 | +# define LCD_INFO_X 0 | |
198 | +# define LCD_INFO_Y (BMP_LOGO_HEIGHT + VIDEO_FONT_HEIGHT) | |
199 | +#elif defined(CONFIG_LCD_LOGO) | |
200 | +# define LCD_INFO_X (BMP_LOGO_WIDTH + 4 * VIDEO_FONT_WIDTH) | |
201 | +# define LCD_INFO_Y (VIDEO_FONT_HEIGHT) | |
202 | +#else | |
203 | +# define LCD_INFO_X (VIDEO_FONT_WIDTH) | |
204 | +# define LCD_INFO_Y (VIDEO_FONT_HEIGHT) | |
205 | +#endif | |
206 | + | |
207 | +/* Default to 8bpp if bit depth not specified */ | |
208 | +#ifndef LCD_BPP | |
209 | +# define LCD_BPP LCD_COLOR8 | |
210 | +#endif | |
211 | +#ifndef LCD_DF | |
212 | +# define LCD_DF 1 | |
213 | +#endif | |
214 | + | |
215 | +/* Calculate nr. of bits per pixel and nr. of colors */ | |
216 | +#define NBITS(bit_code) (1 << (bit_code)) | |
217 | +#define NCOLORS(bit_code) (1 << NBITS(bit_code)) | |
218 | + | |
219 | +/************************************************************************/ | |
220 | +/* ** CONSOLE CONSTANTS */ | |
221 | +/************************************************************************/ | |
222 | +#if LCD_BPP == LCD_MONOCHROME | |
223 | + | |
224 | +/* | |
225 | + * Simple black/white definitions | |
226 | + */ | |
227 | +# define CONSOLE_COLOR_BLACK 0 | |
228 | +# define CONSOLE_COLOR_WHITE 1 /* Must remain last / highest */ | |
229 | + | |
230 | +#elif LCD_BPP == LCD_COLOR8 | |
231 | + | |
232 | +/* | |
233 | + * 8bpp color definitions | |
234 | + */ | |
235 | +# define CONSOLE_COLOR_BLACK 0 | |
236 | +# define CONSOLE_COLOR_RED 1 | |
237 | +# define CONSOLE_COLOR_GREEN 2 | |
238 | +# define CONSOLE_COLOR_YELLOW 3 | |
239 | +# define CONSOLE_COLOR_BLUE 4 | |
240 | +# define CONSOLE_COLOR_MAGENTA 5 | |
241 | +# define CONSOLE_COLOR_CYAN 6 | |
242 | +# define CONSOLE_COLOR_GREY 14 | |
243 | +# define CONSOLE_COLOR_WHITE 15 /* Must remain last / highest */ | |
244 | + | |
245 | +#else | |
246 | + | |
247 | +/* | |
248 | + * 16bpp color definitions | |
249 | + */ | |
250 | +# define CONSOLE_COLOR_BLACK 0x0000 | |
251 | +# define CONSOLE_COLOR_WHITE 0xffff /* Must remain last / highest */ | |
252 | + | |
253 | +#endif /* color definitions */ | |
254 | + | |
255 | +#if defined(CONFIG_LCD_LOGO) && (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET) | |
256 | +# error Default Color Map overlaps with Logo Color Map | |
257 | +#endif | |
258 | + | |
259 | +/************************************************************************/ | |
260 | +#ifndef PAGE_SIZE | |
261 | +# define PAGE_SIZE 4096 | |
262 | +#endif | |
263 | + | |
264 | +/************************************************************************/ | |
265 | +/* ** CONSOLE DEFINITIONS & FUNCTIONS */ | |
266 | +/************************************************************************/ | |
267 | +#if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO) | |
268 | +# define CONSOLE_ROWS ((panel_info.vl_row-BMP_LOGO_HEIGHT) \ | |
269 | + / VIDEO_FONT_HEIGHT) | |
270 | +#else | |
271 | +# define CONSOLE_ROWS (panel_info.vl_row / VIDEO_FONT_HEIGHT) | |
272 | +#endif | |
273 | + | |
274 | +#define CONSOLE_COLS (panel_info.vl_col / VIDEO_FONT_WIDTH) | |
275 | +#define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * lcd_line_length) | |
276 | +#define CONSOLE_ROW_FIRST (lcd_console_address) | |
277 | +#define CONSOLE_ROW_SECOND (lcd_console_address + CONSOLE_ROW_SIZE) | |
278 | +#define CONSOLE_ROW_LAST (lcd_console_address + CONSOLE_SIZE \ | |
279 | + - CONSOLE_ROW_SIZE) | |
280 | +#define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS) | |
281 | +#define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE) | |
282 | + | |
283 | +#if LCD_BPP == LCD_MONOCHROME | |
284 | +# define COLOR_MASK(c) ((c) | (c) << 1 | (c) << 2 | (c) << 3 | \ | |
285 | + (c) << 4 | (c) << 5 | (c) << 6 | (c) << 7) | |
286 | +#elif LCD_BPP == LCD_COLOR8 | |
287 | +# define COLOR_MASK(c) (c) | |
288 | +#else | |
289 | +# error Unsupported LCD BPP. | |
290 | +#endif | |
291 | + | |
292 | +/************************************************************************/ | |
293 | + | |
294 | +#endif /* _LCD_H_ */ |
lib_arm/armlinux.c
... | ... | @@ -38,7 +38,8 @@ |
38 | 38 | defined (CONFIG_INITRD_TAG) || \ |
39 | 39 | defined (CONFIG_SERIAL_TAG) || \ |
40 | 40 | defined (CONFIG_REVISION_TAG) || \ |
41 | - defined (CONFIG_VFD) | |
41 | + defined (CONFIG_VFD) || \ | |
42 | + defined (CONFIG_LCD) | |
42 | 43 | static void setup_start_tag (bd_t *bd); |
43 | 44 | |
44 | 45 | # ifdef CONFIG_SETUP_MEMORY_TAGS |
... | ... | @@ -55,7 +56,7 @@ |
55 | 56 | # endif |
56 | 57 | static void setup_end_tag (bd_t *bd); |
57 | 58 | |
58 | -# if defined (CONFIG_VFD) | |
59 | +# if defined (CONFIG_VFD) || defined (CONFIG_LCD) | |
59 | 60 | static void setup_videolfb_tag (gd_t *gd); |
60 | 61 | # endif |
61 | 62 | |
... | ... | @@ -229,6 +230,7 @@ |
229 | 230 | defined (CONFIG_INITRD_TAG) || \ |
230 | 231 | defined (CONFIG_SERIAL_TAG) || \ |
231 | 232 | defined (CONFIG_REVISION_TAG) || \ |
233 | + defined (CONFIG_LCD) || \ | |
232 | 234 | defined (CONFIG_VFD) |
233 | 235 | setup_start_tag (bd); |
234 | 236 | #ifdef CONFIG_SERIAL_TAG |
... | ... | @@ -247,7 +249,7 @@ |
247 | 249 | if (initrd_start && initrd_end) |
248 | 250 | setup_initrd_tag (bd, initrd_start, initrd_end); |
249 | 251 | #endif |
250 | -#if defined (CONFIG_VFD) | |
252 | +#if defined (CONFIG_VFD) || defined (CONFIG_LCD) | |
251 | 253 | setup_videolfb_tag ((gd_t *) gd); |
252 | 254 | #endif |
253 | 255 | setup_end_tag (bd); |
... | ... | @@ -274,6 +276,7 @@ |
274 | 276 | defined (CONFIG_INITRD_TAG) || \ |
275 | 277 | defined (CONFIG_SERIAL_TAG) || \ |
276 | 278 | defined (CONFIG_REVISION_TAG) || \ |
279 | + defined (CONFIG_LCD) || \ | |
277 | 280 | defined (CONFIG_VFD) |
278 | 281 | static void setup_start_tag (bd_t *bd) |
279 | 282 | { |
... | ... | @@ -351,7 +354,8 @@ |
351 | 354 | #endif /* CONFIG_INITRD_TAG */ |
352 | 355 | |
353 | 356 | |
354 | -#if defined (CONFIG_VFD) | |
357 | +#if defined (CONFIG_VFD) || defined (CONFIG_LCD) | |
358 | +extern ulong calc_fbsize (void); | |
355 | 359 | static void setup_videolfb_tag (gd_t *gd) |
356 | 360 | { |
357 | 361 | /* An ATAG_VIDEOLFB node tells the kernel where and how large |
358 | 362 | |
... | ... | @@ -365,12 +369,13 @@ |
365 | 369 | params->hdr.size = tag_size (tag_videolfb); |
366 | 370 | |
367 | 371 | params->u.videolfb.lfb_base = (u32) gd->fb_base; |
368 | - /* 7168 = 256*4*56/8 - actually 2 pages (8192 bytes) are allocated */ | |
369 | - params->u.videolfb.lfb_size = 7168; | |
372 | + /* Fb size is calculated according to parameters for our panel | |
373 | + */ | |
374 | + params->u.videolfb.lfb_size = calc_fbsize(); | |
370 | 375 | |
371 | 376 | params = tag_next (params); |
372 | 377 | } |
373 | -#endif | |
378 | +#endif /* CONFIG_VFD || CONFIG_LCD */ | |
374 | 379 | |
375 | 380 | static void setup_end_tag (bd_t *bd) |
376 | 381 | { |
tools/bmp_logo.c
... | ... | @@ -120,25 +120,13 @@ |
120 | 120 | b->palette[(int)(i*3+0)] = fgetc(fp); |
121 | 121 | x=fgetc(fp); |
122 | 122 | |
123 | -#if 0 | |
124 | - if ((i%4) == 0) | |
125 | - putchar ('\t'); | |
126 | - printf ("0x%02X, 0x%02X, 0x%02X,%s", | |
127 | - b->palette[(int)(i*3+0)], | |
128 | - b->palette[(int)(i*3+1)], | |
129 | - b->palette[(int)(i*3+2)], | |
130 | - ((i%4) == 3) ? "\n" : " " | |
131 | - ); | |
132 | -#else | |
133 | - if ((i%8) == 0) | |
134 | - putchar ('\t'); | |
135 | - printf ("0x0%X%X%X,%s", | |
123 | + printf ("%s0x0%X%X%X,%s", | |
124 | + ((i%8) == 0) ? "\t" : " ", | |
136 | 125 | (b->palette[(int)(i*3+0)] >> 4) & 0x0F, |
137 | 126 | (b->palette[(int)(i*3+1)] >> 4) & 0x0F, |
138 | 127 | (b->palette[(int)(i*3+2)] >> 4) & 0x0F, |
139 | - ((i%8) == 7) ? "\n" : " " | |
128 | + ((i%8) == 7) ? "\n" : "" | |
140 | 129 | ); |
141 | -#endif | |
142 | 130 | } |
143 | 131 | |
144 | 132 | /* read the bitmap; leave room for default color map */ |