2 * S5PC100 and S5PC110 LCD Controller driver.
4 * Author: InKi Dae <inki.dae@samsung.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 #include <linux/types.h>
28 #include <asm/arch/cpu.h>
32 #include "opening_wvga_32.h"
33 //#include "logo_rgb24_wvga_portrait.h"
34 //#include "opening_logo_rgb24_143_44.h"
36 #define PANEL_WIDTH 480
37 #define PANEL_HEIGHT 800
38 #define S5P_LCD_BPP 32
40 extern void tl2796_panel_power_on(void);
41 extern void tl2796_panel_enable(void);
42 extern void tl2796_panel_init(void);
49 void *lcd_console_address;
54 static unsigned short makepixel565(char r, char g, char b)
56 return (unsigned short)(((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3));
59 static unsigned int makepixel8888(char a, char r, char g, char b)
61 return (unsigned int)((a << 24) | (r << 16) | (g << 8) | b);
64 static void read_image16(char* pImg, int x1pos, int y1pos, int x2pos,
65 int y2pos, unsigned short pixel)
67 unsigned short *pDst = (unsigned short *)pImg;
68 unsigned int offset_s;
71 for(i = y1pos; i < y2pos; i++) {
72 for(j = x1pos; j < x2pos; j++) {
73 offset_s = i * PANEL_WIDTH + j;
74 *(pDst + offset_s) = pixel;
79 static void read_image32(char* pImg, int x1pos, int y1pos, int x2pos,
80 int y2pos, unsigned int pixel)
82 unsigned int *pDst = (unsigned int *)pImg;
83 unsigned int offset_s;
86 for(i = y1pos; i < y2pos; i++) {
87 for(j = x1pos; j < x2pos; j++) {
88 offset_s = i * PANEL_WIDTH + j;
89 *(pDst+offset_s) = pixel;
95 vidinfo_t panel_info = {
96 .vl_col = PANEL_WIDTH,
97 .vl_row = PANEL_HEIGHT,
98 .vl_width = PANEL_WIDTH,
99 .vl_height = PANEL_HEIGHT,
100 .vl_clkp = CONFIG_SYS_HIGH,
101 .vl_hsp = CONFIG_SYS_LOW,
102 .vl_vsp = CONFIG_SYS_LOW,
103 .vl_dp = CONFIG_SYS_HIGH,
104 .vl_bpix = S5P_LCD_BPP,
119 static void s5pc_lcd_init_mem(void *lcdbase, vidinfo_t *vid)
121 unsigned long palette_size, palette_mem_size;
122 unsigned int fb_size;
124 fb_size = vid->vl_row * vid->vl_col * (vid->vl_bpix / 8);
128 palette_size = NBITS(vid->vl_bpix) == 8 ? 256 : 16;
129 palette_mem_size = palette_size * sizeof(u32);
131 s5pc_fimd_lcd_init_mem((unsigned long)lcd_base, (unsigned long)fb_size, palette_size);
133 udebug("fb_size=%d, screen_base=%x, palette_size=%d, palettle_mem_size=%d\n",
134 fb_size, (unsigned int)lcd_base, (int)palette_size, (int)palette_mem_size);
137 static void s5pc_gpio_setup(void)
139 if (cpu_is_s5pc100())
140 s5pc_c100_gpio_setup();
142 s5pc_c110_gpio_setup();
145 static void s5pc_lcd_init(vidinfo_t *vid)
147 s5pc_fimd_lcd_init(vid);
150 static void lcd_test(void)
153 read_image32((char *)lcd_base, 0, 0, 480, 200,
154 makepixel8888(0, 255, 0, 0));
156 read_image32((char *)lcd_base, 0, 200, 480, 400,
157 makepixel8888(0, 0, 255, 0));
159 read_image32((char *)lcd_base, 0, 400, 480, 600,
160 makepixel8888(0, 0, 0, 255));
162 read_image32((char *)lcd_base, 0, 600, 480, 800,
163 makepixel8888(0, 255, 255, 255));
166 void draw_bitmap(void *lcdbase, int x, int y, int w, int h, unsigned long *bmp)
169 unsigned long *fb = (unsigned long*)lcdbase;
171 for (j = y; j < (y + h); j++) {
172 for (i = x; i < (x + w); i++)
173 *(fb + (j * PANEL_WIDTH) + i) = *(bmp + k++);
177 static void draw_samsung_logo(void* lcdbase)
181 x = (PANEL_WIDTH - 138) / 2;
182 y = (PANEL_HEIGHT - 28) / 2 - 5;
184 draw_bitmap(lcdbase, x, y, 138, 28, (unsigned long *)opening_32);
187 static void lcd_panel_on(void)
189 if (cpu_is_s5pc100()) {
190 tl2796_c100_panel_init();
191 tl2796_c100_panel_power_on();
193 tl2796_c110_panel_init();
194 tl2796_c110_panel_power_on();
197 tl2796_panel_enable();
200 void lcd_ctrl_init(void *lcdbase)
204 s5pc_lcd_init_mem(lcdbase, &panel_info);
206 option = getenv("lcd");
209 if (strcmp(option, "test") == 0) {
210 memset(lcdbase, 0, PANEL_WIDTH*PANEL_HEIGHT*S5P_LCD_BPP >> 3);
212 } else if (strcmp(option, "image") == 0)
213 memcpy(lcdbase, LOGO_RGB24, PANEL_WIDTH*PANEL_HEIGHT*S5P_LCD_BPP >> 3);
215 memset(lcdbase, 0, PANEL_WIDTH*PANEL_HEIGHT*S5P_LCD_BPP >> 3);
216 draw_samsung_logo(lcdbase);
220 memset(lcdbase, 0, PANEL_WIDTH*PANEL_HEIGHT*S5P_LCD_BPP >> 3);
221 draw_samsung_logo(lcdbase);
225 s5pc_lcd_init(&panel_info);
229 void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blud)
234 void lcd_enable(void)
239 ulong calc_fbsize(void)
241 return s5pc_fimd_calc_fbsize();
244 void s5pc1xxfb_test(void *lcdbase)
246 lcd_ctrl_init(lcdbase);
249 //memcpy(lcdbase, LOGO_RGB24, PANEL_WIDTH*PANEL_HEIGHT*S5P_LCD_BPP >> 3);