]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/esd/common/lcd.c
2 * (C) Copyright 2003-2004
3 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
6 * Stefan Roese, DENX Software Engineering, sr@denx.de.
8 * See file CREDITS for list of people who contributed to this
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 extern int video_display_bitmap (ulong
, int, int);
36 unsigned char *glob_lcd_reg
;
37 unsigned char *glob_lcd_mem
;
40 void lcd_setup(int lcd
, int config
)
44 * Set endianess and reset lcd controller 0 (small)
46 out32(GPIO0_OR
, in32(GPIO0_OR
) & ~CFG_LCD0_RST
); /* set reset to low */
47 udelay(10); /* wait 10us */
49 out32(GPIO0_OR
, in32(GPIO0_OR
) | CFG_LCD_ENDIAN
); /* big-endian */
51 out32(GPIO0_OR
, in32(GPIO0_OR
) & ~CFG_LCD_ENDIAN
); /* little-endian */
53 udelay(10); /* wait 10us */
54 out32(GPIO0_OR
, in32(GPIO0_OR
) | CFG_LCD0_RST
); /* set reset to high */
57 * Set endianess and reset lcd controller 1 (big)
59 out32(GPIO0_OR
, in32(GPIO0_OR
) & ~CFG_LCD1_RST
); /* set reset to low */
60 udelay(10); /* wait 10us */
62 out32(GPIO0_OR
, in32(GPIO0_OR
) | CFG_LCD_ENDIAN
); /* big-endian */
64 out32(GPIO0_OR
, in32(GPIO0_OR
) & ~CFG_LCD_ENDIAN
); /* little-endian */
66 udelay(10); /* wait 10us */
67 out32(GPIO0_OR
, in32(GPIO0_OR
) | CFG_LCD1_RST
); /* set reset to high */
71 * CFG_LCD_ENDIAN may also be FPGA_RESET, so set inactive
73 out32(GPIO0_OR
, in32(GPIO0_OR
) | CFG_LCD_ENDIAN
); /* set reset high again */
75 #endif /* #ifdef CFG_LCD_ENDIAN */
78 void lcd_bmp(uchar
*logo_bmp
)
86 int width
, height
, bpp
, colors
, line_size
;
89 unsigned char r
, g
, b
;
90 BITMAPINFOHEADER
*bm_info
;
95 * Check for bmp mark 'BM'
97 if (*(ushort
*)logo_bmp
!= 0x424d) {
100 * Decompress bmp image
102 len
= CFG_VIDEO_LOGO_MAX_SIZE
;
103 dst
= malloc(CFG_LCD_LOGO_MAX_SIZE
);
105 if (gunzip(dst
, CFG_LCD_LOGO_MAX_SIZE
, (uchar
*)logo_bmp
, &len
) != 0) {
110 * Check for bmp mark 'BM'
112 if (*(ushort
*)dst
!= 0x424d) {
113 printf("LCD: Unknown image format!\n");
119 * Uncompressed BMP image, just use this pointer
121 dst
= (uchar
*)logo_bmp
;
125 * Get image info from bmp-header
127 bm_info
= (BITMAPINFOHEADER
*)(dst
+ 14);
128 bpp
= LOAD_SHORT(bm_info
->biBitCount
);
129 width
= LOAD_LONG(bm_info
->biWidth
);
130 height
= LOAD_LONG(bm_info
->biHeight
);
134 line_size
= width
>> 3;
138 line_size
= width
>> 1;
146 line_size
= width
* 3;
149 printf("LCD: Unknown bpp (%d) im image!\n", bpp
);
153 printf(" (%d*%d, %dbpp)\n", width
, height
, bpp
);
156 * Write color palette
158 if ((colors
<= 256) && (lcd_depth
<= 8)) {
159 ptr
= (unsigned char *)(dst
+ 14 + 40);
160 for (i
=0; i
<colors
; i
++) {
165 S1D_WRITE_PALETTE(glob_lcd_reg
, i
, r
, g
, b
);
170 * Write bitmap data into framebuffer
173 ptr2
= (ushort
*)glob_lcd_mem
;
174 header_size
= 14 + 40 + 4*colors
; /* skip bmp header */
175 for (y
=0; y
<height
; y
++) {
176 bmp
= &dst
[(height
-1-y
)*line_size
+ header_size
];
177 if (lcd_depth
== 16) {
179 for (x
=0; x
<width
; x
++) {
181 * Generate epson 16bpp fb-format from 24bpp image
186 val
= ((r
& 0x1f) << 11) | ((g
& 0x3f) << 5) | (b
& 0x1f);
189 } else if (bpp
== 8) {
190 for (x
=0; x
<line_size
; x
++) {
191 /* query rgb value from palette */
192 ptr
= (unsigned char *)(dst
+ 14 + 40) ;
193 ptr
+= (*bmp
++) << 2;
197 val
= ((r
& 0x1f) << 11) | ((g
& 0x3f) << 5) | (b
& 0x1f);
202 for (x
=0; x
<line_size
; x
++) {
214 void lcd_init(uchar
*lcd_reg
, uchar
*lcd_mem
, S1D_REGS
*regs
, int reg_count
,
215 uchar
*logo_bmp
, ulong len
)
225 if (lcd_reg
[0] == 0x1c) {
229 reg_byte_swap
= FALSE
;
230 palette_index
= 0x1e2;
231 palette_value
= 0x1e4;
233 puts("LCD: S1D13806");
234 } else if (lcd_reg
[1] == 0x1c) {
236 * Big epson detected (with register swap bug)
238 reg_byte_swap
= TRUE
;
239 palette_index
= 0x1e3;
240 palette_value
= 0x1e5;
242 puts("LCD: S1D13806S");
243 } else if (lcd_reg
[0] == 0x18) {
245 * Small epson detected (704)
247 reg_byte_swap
= FALSE
;
248 palette_index
= 0x15;
249 palette_value
= 0x17;
251 puts("LCD: S1D13704");
252 } else if (lcd_reg
[0x10000] == 0x24) {
254 * Small epson detected (705)
256 reg_byte_swap
= FALSE
;
257 palette_index
= 0x15;
258 palette_value
= 0x17;
260 lcd_reg
+= 0x10000; /* add offset for 705 regs */
261 puts("LCD: S1D13705");
263 puts("LCD: No controller detected!\n");
268 * Setup lcd controller regs
270 for (i
= 0; i
<reg_count
; i
++) {
271 s1dReg
= regs
[i
].Index
;
273 if ((s1dReg
& 0x0001) == 0)
278 s1dValue
= regs
[i
].Value
;
279 lcd_reg
[s1dReg
] = s1dValue
;
283 * Save reg & mem pointer for later usage (e.g. bmp command)
285 glob_lcd_reg
= lcd_reg
;
286 glob_lcd_mem
= lcd_mem
;
295 int do_esdbmp(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
301 printf ("Usage:\n%s\n", cmdtp
->usage
);
305 addr
= simple_strtoul(argv
[1], NULL
, 16);
307 str
= getenv("bd_type");
308 if ((strcmp(str
, "ppc221") == 0) || (strcmp(str
, "ppc231") == 0)) {
310 * SM501 available, use standard bmp command
312 return (video_display_bitmap(addr
, 0, 0));
315 * No SM501 available, use esd epson bmp command
317 lcd_bmp((uchar
*)addr
);
323 esdbmp
, 2, 1, do_esdbmp
,
324 "esdbmp - display BMP image\n",
325 "<imageAddr> - display image\n"