summaryrefslogtreecommitdiff
path: root/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/philips/hdd1630/lcd-hdd1630.c')
-rwxr-xr-xfirmware/target/arm/philips/hdd1630/lcd-hdd1630.c266
1 files changed, 266 insertions, 0 deletions
diff --git a/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c b/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c
new file mode 100755
index 0000000000..5e6d3ace42
--- /dev/null
+++ b/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c
@@ -0,0 +1,266 @@
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 int i = 0;
32 while (LCD2_PORT & LCD2_BUSY_MASK)
33 {
34 if (i < 2000)
35 i++;
36 else
37 LCD2_PORT &= ~LCD2_BUSY_MASK;
38 }
39}
40
41/* send LCD data */
42static void lcd_send_data(unsigned data)
43{
44 lcd_wait_write();
45 LCD2_PORT = LCD2_DATA_MASK | (data & 0xff);
46}
47
48/* send LCD command */
49static void lcd_send_cmd(unsigned cmd)
50{
51 lcd_wait_write();
52 LCD2_PORT = LCD2_CMD_MASK | (cmd & 0xff);
53 lcd_wait_write();
54}
55
56static inline void lcd_send_pixel(unsigned pixel)
57{
58 lcd_send_data(pixel >> 8);
59 lcd_send_data(pixel);
60}
61
62void lcd_init_device(void)
63{
64#if 0
65 /* this sequence from the OF bootloader */
66
67 DEV_EN2 |= 0x2000;
68 outl(inl(0x70000014) & ~0xf000000, 0x70000014);
69 outl(inl(0x70000014) | 0xa000000, 0x70000014);
70 DEV_INIT1 &= 0xc000;
71 DEV_INIT1 |= 0x8000;
72 MLCD_SCLK_DIV &= ~0x800;
73 CLCD_CLOCK_SRC |= 0xc0000000;
74 DEV_INIT2 &= ~0x400;
75 outl(inl(0x7000002c) | ((1<<4)<<24), 0x7000002c);
76 DEV_INIT2 &= ~((1<<4)<<24);
77 udelay(10000);
78
79 DEV_INIT2 |= ((1<<4)<<24);
80 outl(0x220, 0x70008a00);
81 outl(0x1f00, 0x70008a04);
82 LCD2_BLOCK_CTRL = 0x10008080;
83 LCD2_BLOCK_CONFIG = 0xF00000;
84
85 GPIOJ_ENABLE |= 0x4;
86 GPIOJ_OUTPUT_VAL |= 0x4;
87 GPIOJ_OUTPUT_EN |= 0x4;
88
89 lcd_send_cmd(0x1);
90 udelay(10000);
91
92 lcd_send_cmd(0x25);
93 lcd_send_data(0x3f);
94
95 lcd_send_cmd(0x11);
96 udelay(120000);
97
98 lcd_send_cmd(0x20);
99 lcd_send_cmd(0x38);
100 lcd_send_cmd(0x13);
101
102 lcd_send_cmd(0xb4);
103 lcd_send_data(0x2);
104 lcd_send_data(0x6);
105 lcd_send_data(0x8);
106 lcd_send_data(0xd);
107
108 lcd_send_cmd(0xb5);
109 lcd_send_data(0x2);
110 lcd_send_data(0x6);
111 lcd_send_data(0x8);
112 lcd_send_data(0xd);
113
114 lcd_send_cmd(0xb6);
115 lcd_send_data(0x19);
116 lcd_send_data(0x23);
117 lcd_send_data(0x2d);
118
119 lcd_send_cmd(0xb7);
120 lcd_send_data(0x5);
121
122 lcd_send_cmd(0xba);
123 lcd_send_data(0x7);
124 lcd_send_data(0x18);
125
126 lcd_send_cmd(0x36);
127 lcd_send_data(0);
128
129 lcd_send_cmd(0x3a);
130 lcd_send_data(0x5);
131
132 lcd_send_cmd(0x2d);
133 lcd_send_data(0x1);
134 lcd_send_data(0x2);
135 lcd_send_data(0x3);
136 lcd_send_data(0x4);
137 lcd_send_data(0x5);
138 lcd_send_data(0x6);
139 lcd_send_data(0x7);
140 lcd_send_data(0x8);
141 lcd_send_data(0x9);
142 lcd_send_data(0xa);
143 lcd_send_data(0xb);
144 lcd_send_data(0xc);
145 lcd_send_data(0xd);
146 lcd_send_data(0xe);
147 lcd_send_data(0xf);
148 lcd_send_data(0x10);
149 lcd_send_data(0x11);
150 lcd_send_data(0x12);
151 lcd_send_data(0x13);
152 lcd_send_data(0x14);
153 lcd_send_data(0x15);
154 lcd_send_data(0x16);
155 lcd_send_data(0x17);
156 lcd_send_data(0x18);
157 lcd_send_data(0x19);
158 lcd_send_data(0x1a);
159 lcd_send_data(0x1b);
160 lcd_send_data(0x1c);
161 lcd_send_data(0x1d);
162 lcd_send_data(0x1e);
163 lcd_send_data(0x1f);
164 lcd_send_data(0x20);
165 lcd_send_data(0x21);
166 lcd_send_data(0x22);
167 lcd_send_data(0x23);
168 lcd_send_data(0x24);
169 lcd_send_data(0x25);
170 lcd_send_data(0x26);
171 lcd_send_data(0x27);
172 lcd_send_data(0x28);
173 lcd_send_data(0x29);
174 lcd_send_data(0x2a);
175 lcd_send_data(0x2b);
176 lcd_send_data(0x2c);
177 lcd_send_data(0x2d);
178 lcd_send_data(0x2e);
179 lcd_send_data(0x2f);
180 lcd_send_data(0x30);
181
182 lcd_send_cmd(0x29);
183#endif
184}
185
186/*** hardware configuration ***/
187int lcd_default_contrast(void)
188{
189 return DEFAULT_CONTRAST_SETTING;
190}
191
192void lcd_set_contrast(int val)
193{
194 (void)val;
195}
196
197void lcd_set_invert_display(bool yesno)
198{
199 (void)yesno;
200}
201
202/* turn the display upside down (call lcd_update() afterwards) */
203void lcd_set_flip(bool yesno)
204{
205 (void)yesno;
206}
207
208void lcd_yuv_set_options(unsigned options)
209{
210 lcd_yuv_options = options;
211}
212
213/* Performance function to blit a YUV bitmap directly to the LCD */
214void lcd_blit_yuv(unsigned char * const src[3],
215 int src_x, int src_y, int stride,
216 int x, int y, int width, int height)
217{
218 (void)src;
219 (void)src_x;
220 (void)src_y;
221 (void)stride;
222 (void)x;
223 (void)y;
224 (void)width;
225 (void)height;
226}
227
228/* Update the display.
229 This must be called after all other LCD functions that change the display. */
230void lcd_update(void)
231{
232 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
233}
234
235/* Update a fraction of the display. */
236void lcd_update_rect(int x, int y, int width, int height)
237{
238 const fb_data *addr;
239
240 if (x + width >= LCD_WIDTH)
241 width = LCD_WIDTH - x;
242 if (y + height >= LCD_HEIGHT)
243 height = LCD_HEIGHT - y;
244
245 if ((width <= 0) || (height <= 0))
246 return; /* Nothing left to do. */
247
248 addr = &lcd_framebuffer[y][x];
249
250 lcd_send_cmd(0x2a);
251 lcd_send_data(x);
252 lcd_send_data(x + width - 1);
253
254 lcd_send_cmd(0x2b);
255 lcd_send_data(y);
256 lcd_send_data(y + height - 1);
257
258 lcd_send_cmd(0x2c);
259 do {
260 int w = width;
261 do {
262 lcd_send_pixel(*addr++);
263 } while (--w > 0);
264 addr += LCD_WIDTH - width;
265 } while (--height > 0);
266}