summaryrefslogtreecommitdiff
path: root/firmware/target/arm/philips/sa9200/lcd-sa9200.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/philips/sa9200/lcd-sa9200.c')
-rwxr-xr-xfirmware/target/arm/philips/sa9200/lcd-sa9200.c205
1 files changed, 205 insertions, 0 deletions
diff --git a/firmware/target/arm/philips/sa9200/lcd-sa9200.c b/firmware/target/arm/philips/sa9200/lcd-sa9200.c
new file mode 100755
index 0000000000..b06dcd952b
--- /dev/null
+++ b/firmware/target/arm/philips/sa9200/lcd-sa9200.c
@@ -0,0 +1,205 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Mark Arigo
11 *
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.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "config.h"
20#include "cpu.h"
21#include "lcd.h"
22#include "kernel.h"
23#include "system.h"
24
25/* Display status */
26static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0;
27
28/* wait for LCD */
29static inline void lcd_wait_write(void)
30{
31 while (LCD1_CONTROL & LCD1_BUSY_MASK);
32}
33
34/* send LCD data */
35static void lcd_send_data(unsigned data)
36{
37 lcd_wait_write();
38 LCD1_DATA = data >> 8;
39 lcd_wait_write();
40 LCD1_DATA = data & 0xff;
41}
42
43/* send LCD command */
44static void lcd_send_command(unsigned cmd)
45{
46 lcd_wait_write();
47 LCD1_CMD = cmd >> 8;
48 lcd_wait_write();
49 LCD1_CMD = cmd & 0xff;
50}
51
52static void lcd_write_reg(unsigned reg, unsigned data)
53{
54 lcd_send_command(reg);
55 lcd_send_data(data);
56}
57
58void lcd_init_device(void)
59{
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;
67
68 LCD1_CONTROL = 0x4680;
69 udelay(1500);
70 LCD1_CONTROL = 0x4684;
71
72 outl(1, 0x70003018);
73
74 LCD1_CONTROL &= ~0x200;
75 LCD1_CONTROL &= ~0x800;
76 LCD1_CONTROL &= ~0x400;
77 udelay(30000);
78
79 LCD1_CONTROL |= 0x1;
80
81 lcd_write_reg(0x0000, 0x0001);
82 udelay(50000);
83
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);
90
91 lcd_write_reg(0x0013, 0x081C);
92 udelay(200000);
93
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);
118
119 lcd_write_reg(0x0007, 0x0021);
120 udelay(40000);
121 lcd_write_reg(0x0007, 0x0023);
122 udelay(40000);
123 lcd_write_reg(0x0007, 0x1037);
124
125 lcd_write_reg(0x0021, 0x0000);
126#endif
127}
128
129/*** hardware configuration ***/
130#if 0
131int lcd_default_contrast(void)
132{
133 return DEFAULT_CONTRAST_SETTING;
134}
135#endif
136
137void lcd_set_contrast(int val)
138{
139 (void)val;
140}
141
142void lcd_set_invert_display(bool yesno)
143{
144 (void)yesno;
145}
146
147/* turn the display upside down (call lcd_update() afterwards) */
148void lcd_set_flip(bool yesno)
149{
150 (void)yesno;
151}
152
153void lcd_yuv_set_options(unsigned options)
154{
155 lcd_yuv_options = options;
156}
157
158/* Performance function to blit a YUV bitmap directly to the LCD */
159void 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)
162{
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;
171}
172
173/* Update the display.
174 This must be called after all other LCD functions that change the display. */
175void lcd_update(void)
176{
177 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
178}
179
180/* Update a fraction of the display. */
181void lcd_update_rect(int x, int y, int width, int height)
182{
183 const fb_data *addr;
184
185 if (x + width >= LCD_WIDTH)
186 width = LCD_WIDTH - x;
187 if (y + height >= LCD_HEIGHT)
188 height = LCD_HEIGHT - y;
189
190 if ((width <= 0) || (height <= 0))
191 return; /* Nothing left to do. */
192
193 addr = &lcd_framebuffer[y][x];
194
195 do {
196 lcd_write_reg(0x0021, ((y++ & 0xff) << 8) | (x & 0xff));
197 lcd_send_command(0x0022);
198
199 int w = width;
200 do {
201 lcd_send_data(*addr++);
202 } while (--w > 0);
203 addr += LCD_WIDTH - width;
204 } while (--height > 0);
205}