]>
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
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 void lcd_setup(int lcd
, int config
)
36 * Set endianess and reset lcd controller 0 (small)
38 out32(GPIO0_OR
, in32(GPIO0_OR
) & ~CFG_LCD0_RST
); /* set reset to low */
39 udelay(10); /* wait 10us */
41 out32(GPIO0_OR
, in32(GPIO0_OR
) | CFG_LCD_ENDIAN
); /* big-endian */
43 out32(GPIO0_OR
, in32(GPIO0_OR
) & ~CFG_LCD_ENDIAN
); /* little-endian */
45 udelay(10); /* wait 10us */
46 out32(GPIO0_OR
, in32(GPIO0_OR
) | CFG_LCD0_RST
); /* set reset to high */
49 * Set endianess and reset lcd controller 1 (big)
51 out32(GPIO0_OR
, in32(GPIO0_OR
) & ~CFG_LCD1_RST
); /* set reset to low */
52 udelay(10); /* wait 10us */
54 out32(GPIO0_OR
, in32(GPIO0_OR
) | CFG_LCD_ENDIAN
); /* big-endian */
56 out32(GPIO0_OR
, in32(GPIO0_OR
) & ~CFG_LCD_ENDIAN
); /* little-endian */
58 udelay(10); /* wait 10us */
59 out32(GPIO0_OR
, in32(GPIO0_OR
) | CFG_LCD1_RST
); /* set reset to high */
63 * CFG_LCD_ENDIAN may also be FPGA_RESET, so set inactive
65 out32(GPIO0_OR
, in32(GPIO0_OR
) | CFG_LCD_ENDIAN
); /* set reset high again */
67 #endif /* #ifdef CFG_LCD_ENDIAN */
70 void lcd_init(uchar
*lcd_reg
, uchar
*lcd_mem
, S1D_REGS
*regs
, int reg_count
,
71 uchar
*logo_bmp
, ulong len
)
81 int width
, height
, bpp
, colors
, line_size
;
84 unsigned char r
, g
, b
;
85 BITMAPINFOHEADER
*bm_info
;
91 if (lcd_reg
[0] == 0x1c) {
95 reg_byte_swap
= FALSE
;
96 palette_index
= 0x1e2;
97 palette_value
= 0x1e4;
98 puts("LCD: S1D13806");
99 } else if (lcd_reg
[1] == 0x1c) {
101 * Big epson detected (with register swap bug)
103 reg_byte_swap
= TRUE
;
104 palette_index
= 0x1e3;
105 palette_value
= 0x1e5;
106 puts("LCD: S1D13806S");
107 } else if (lcd_reg
[0] == 0x18) {
109 * Small epson detected (704)
111 reg_byte_swap
= FALSE
;
112 palette_index
= 0x15;
113 palette_value
= 0x17;
114 puts("LCD: S1D13704");
115 } else if (lcd_reg
[0x10000] == 0x24) {
117 * Small epson detected (705)
119 reg_byte_swap
= FALSE
;
120 palette_index
= 0x15;
121 palette_value
= 0x17;
122 lcd_reg
+= 0x10000; /* add offset for 705 regs */
123 puts("LCD: S1D13705");
125 puts("LCD: No controller detected!\n");
129 for (i
= 0; i
<reg_count
; i
++) {
130 s1dReg
= regs
[i
].Index
;
132 if ((s1dReg
& 0x0001) == 0)
137 s1dValue
= regs
[i
].Value
;
138 lcd_reg
[s1dReg
] = s1dValue
;
142 * Decompress bmp image
144 dst
= malloc(CFG_LCD_LOGO_MAX_SIZE
);
145 if (gunzip(dst
, CFG_LCD_LOGO_MAX_SIZE
, (uchar
*)logo_bmp
, &len
) != 0) {
150 * Check for bmp mark 'BM'
152 if (*(ushort
*)dst
!= 0x424d) {
153 printf("LCD: Unknown image format!\n");
159 * Get image info from bmp-header
161 bm_info
= (BITMAPINFOHEADER
*)(dst
+ 14);
162 bpp
= LOAD_SHORT(bm_info
->biBitCount
);
163 width
= LOAD_LONG(bm_info
->biWidth
);
164 height
= LOAD_LONG(bm_info
->biHeight
);
168 line_size
= width
>> 3;
172 line_size
= width
>> 1;
180 line_size
= width
* 3;
183 printf("LCD: Unknown bpp (%d) im image!\n", bpp
);
187 printf(" (%d*%d, %dbpp)\n", width
, height
, bpp
);
190 * Write color palette
193 ptr
= (unsigned char *)(dst
+ 14 + 40);
194 for (i
=0; i
<colors
; i
++) {
199 S1D_WRITE_PALETTE(lcd_reg
, i
, r
, g
, b
);
204 * Write bitmap data into framebuffer
207 ptr2
= (ushort
*)lcd_mem
;
208 header_size
= 14 + 40 + 4*colors
; /* skip bmp header */
209 for (y
=0; y
<height
; y
++) {
210 bmp
= &dst
[(height
-1-y
)*line_size
+ header_size
];
212 for (x
=0; x
<width
; x
++) {
214 * Generate epson 16bpp fb-format from 24bpp image
219 val
= ((r
& 0x1f) << 11) | ((g
& 0x3f) << 5) | (b
& 0x1f);
223 for (x
=0; x
<line_size
; x
++) {