Philips GoGear SA9200 port. Working bootloader and normal builds, including sound...
[Rockbox.git] / firmware / target / arm / philips / sa9200 / lcd-sa9200.c
blobb06dcd952b55c945a2a3941ca625ab1828cd27eb
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2008 by Mark Arigo
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
19 #include "config.h"
20 #include "cpu.h"
21 #include "lcd.h"
22 #include "kernel.h"
23 #include "system.h"
25 /* Display status */
26 static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0;
28 /* wait for LCD */
29 static inline void lcd_wait_write(void)
31 while (LCD1_CONTROL & LCD1_BUSY_MASK);
34 /* send LCD data */
35 static void lcd_send_data(unsigned data)
37 lcd_wait_write();
38 LCD1_DATA = data >> 8;
39 lcd_wait_write();
40 LCD1_DATA = data & 0xff;
43 /* send LCD command */
44 static void lcd_send_command(unsigned cmd)
46 lcd_wait_write();
47 LCD1_CMD = cmd >> 8;
48 lcd_wait_write();
49 LCD1_CMD = cmd & 0xff;
52 static void lcd_write_reg(unsigned reg, unsigned data)
54 lcd_send_command(reg);
55 lcd_send_data(data);
58 void lcd_init_device(void)
60 #if 0
61 /* This is the init done by the OF bootloader.
62 Re-initializing the lcd causes it to flash
63 a white screen, so for now disable this. */
64 DEV_INIT1 &= ~0x3000;
65 DEV_INIT1 = DEV_INIT1;
66 DEV_INIT2 &= ~0x400;
68 LCD1_CONTROL = 0x4680;
69 udelay(1500);
70 LCD1_CONTROL = 0x4684;
72 outl(1, 0x70003018);
74 LCD1_CONTROL &= ~0x200;
75 LCD1_CONTROL &= ~0x800;
76 LCD1_CONTROL &= ~0x400;
77 udelay(30000);
79 LCD1_CONTROL |= 0x1;
81 lcd_write_reg(0x0000, 0x0001);
82 udelay(50000);
84 lcd_write_reg(0x0011, 0x171f);
85 lcd_write_reg(0x0012, 0x0001);
86 lcd_write_reg(0x0013, 0x08cd);
87 lcd_write_reg(0x0014, 0x0416);
88 lcd_write_reg(0x0010, 0x1208);
89 udelay(50000);
91 lcd_write_reg(0x0013, 0x081C);
92 udelay(200000);
94 lcd_write_reg(0x0001, 0x0a0c);
95 lcd_write_reg(0x0002, 0x0200);
96 lcd_write_reg(0x0003, 0x1030);
97 lcd_write_reg(0x0007, 0x0005);
98 lcd_write_reg(0x0008, 0x030a);
99 lcd_write_reg(0x000b, 0x0000);
100 lcd_write_reg(0x000c, 0x0000);
101 lcd_write_reg(0x0030, 0x0000);
102 lcd_write_reg(0x0031, 0x0204);
103 lcd_write_reg(0x0032, 0x0001);
104 lcd_write_reg(0x0033, 0x0600);
105 lcd_write_reg(0x0034, 0x0607);
106 lcd_write_reg(0x0035, 0x0305);
107 lcd_write_reg(0x0036, 0x0707);
108 lcd_write_reg(0x0037, 0x0006);
109 lcd_write_reg(0x0038, 0x0400);
110 lcd_write_reg(0x0040, 0x0000);
111 lcd_write_reg(0x0042, 0x9f00);
112 lcd_write_reg(0x0043, 0x0000);
113 lcd_write_reg(0x0044, 0x7f00);
114 lcd_write_reg(0x0045, 0x9f00);
115 lcd_write_reg(0x00a8, 0x0125);
116 lcd_write_reg(0x00a9, 0x0014);
117 lcd_write_reg(0x00a7, 0x0022);
119 lcd_write_reg(0x0007, 0x0021);
120 udelay(40000);
121 lcd_write_reg(0x0007, 0x0023);
122 udelay(40000);
123 lcd_write_reg(0x0007, 0x1037);
125 lcd_write_reg(0x0021, 0x0000);
126 #endif
129 /*** hardware configuration ***/
130 #if 0
131 int lcd_default_contrast(void)
133 return DEFAULT_CONTRAST_SETTING;
135 #endif
137 void lcd_set_contrast(int val)
139 (void)val;
142 void lcd_set_invert_display(bool yesno)
144 (void)yesno;
147 /* turn the display upside down (call lcd_update() afterwards) */
148 void lcd_set_flip(bool yesno)
150 (void)yesno;
153 void lcd_yuv_set_options(unsigned options)
155 lcd_yuv_options = options;
158 /* Performance function to blit a YUV bitmap directly to the LCD */
159 void lcd_blit_yuv(unsigned char * const src[3],
160 int src_x, int src_y, int stride,
161 int x, int y, int width, int height)
163 (void)src;
164 (void)src_x;
165 (void)src_y;
166 (void)stride;
167 (void)x;
168 (void)y;
169 (void)width;
170 (void)height;
173 /* Update the display.
174 This must be called after all other LCD functions that change the display. */
175 void lcd_update(void)
177 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
180 /* Update a fraction of the display. */
181 void lcd_update_rect(int x, int y, int width, int height)
183 const fb_data *addr;
185 if (x + width >= LCD_WIDTH)
186 width = LCD_WIDTH - x;
187 if (y + height >= LCD_HEIGHT)
188 height = LCD_HEIGHT - y;
190 if ((width <= 0) || (height <= 0))
191 return; /* Nothing left to do. */
193 addr = &lcd_framebuffer[y][x];
195 do {
196 lcd_write_reg(0x0021, ((y++ & 0xff) << 8) | (x & 0xff));
197 lcd_send_command(0x0022);
199 int w = width;
200 do {
201 lcd_send_data(*addr++);
202 } while (--w > 0);
203 addr += LCD_WIDTH - width;
204 } while (--height > 0);