summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2008-10-19 14:11:01 +0000
committerDave Chapman <dave@dchapman.com>2008-10-19 14:11:01 +0000
commit08c41d42bb699a1be99c9696b4d4fb7b40e8723a (patch)
tree2834231979d52b81a7860fd4a5e19ed79b3ffee7 /firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c
parent14ee31865e366dc19fb87caf4877a8d93305a01b (diff)
downloadrockbox-08c41d42bb699a1be99c9696b4d4fb7b40e8723a.tar.gz
rockbox-08c41d42bb699a1be99c9696b4d4fb7b40e8723a.zip
Add e200v2 and m200v2 targets. Move the telechips lcd-ssd1815.c (currently used by Logik DAX and m200v1 ports) driver up in the target tree and share with the m200v2 - as2525 parts contributed by Rafael Carre. Includes the start (but is still very incomplete) of an LCD driver for the e200v2. m200v2 is not yet fully supported by mkamsboot - that will come soon. Also some minor cleanups for the Clip.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18836 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c')
-rw-r--r--firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c385
1 files changed, 385 insertions, 0 deletions
diff --git a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c
new file mode 100644
index 0000000000..e14ad21681
--- /dev/null
+++ b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c
@@ -0,0 +1,385 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2004 by Linus Nielsen Feltzing
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include "config.h"
22
23#include "cpu.h"
24#include "lcd.h"
25#include "kernel.h"
26#include "thread.h"
27#include <string.h>
28#include <stdlib.h>
29#include "file.h"
30#include "debug.h"
31#include "system.h"
32#include "font.h"
33#include "bidi.h"
34
35static bool display_on = false; /* is the display turned on? */
36static bool display_flipped = false;
37static int xoffset = 0; /* needed for flip */
38
39/* register defines */
40#define R_START_OSC 0x00
41#define R_DRV_OUTPUT_CONTROL 0x01
42#define R_DRV_WAVEFORM_CONTROL 0x02
43#define R_ENTRY_MODE 0x03
44#define R_COMPARE_REG1 0x04
45#define R_COMPARE_REG2 0x05
46
47#define R_DISP_CONTROL1 0x07
48#define R_DISP_CONTROL2 0x08
49#define R_DISP_CONTROL3 0x09
50
51#define R_FRAME_CYCLE_CONTROL 0x0b
52#define R_EXT_DISP_IF_CONTROL 0x0c
53
54#define R_POWER_CONTROL1 0x10
55#define R_POWER_CONTROL2 0x11
56#define R_POWER_CONTROL3 0x12
57#define R_POWER_CONTROL4 0x13
58
59#define R_RAM_ADDR_SET 0x21
60#define R_WRITE_DATA_2_GRAM 0x22
61
62#define R_GAMMA_FINE_ADJ_POS1 0x30
63#define R_GAMMA_FINE_ADJ_POS2 0x31
64#define R_GAMMA_FINE_ADJ_POS3 0x32
65#define R_GAMMA_GRAD_ADJ_POS 0x33
66
67#define R_GAMMA_FINE_ADJ_NEG1 0x34
68#define R_GAMMA_FINE_ADJ_NEG2 0x35
69#define R_GAMMA_FINE_ADJ_NEG3 0x36
70#define R_GAMMA_GRAD_ADJ_NEG 0x37
71
72#define R_GAMMA_AMP_ADJ_RES_POS 0x38
73#define R_GAMMA_AMP_AVG_ADJ_RES_NEG 0x39
74
75#define R_GATE_SCAN_POS 0x40
76#define R_VERT_SCROLL_CONTROL 0x41
77#define R_1ST_SCR_DRV_POS 0x42
78#define R_2ND_SCR_DRV_POS 0x43
79#define R_HORIZ_RAM_ADDR_POS 0x44
80#define R_VERT_RAM_ADDR_POS 0x45
81
82#define LCD_CMD (*(volatile unsigned short *)0xf0000000)
83#define LCD_DATA (*(volatile unsigned short *)0xf0000002)
84
85#define R_ENTRY_MODE_HORZ 0x7030
86#define R_ENTRY_MODE_VERT 0x7038
87
88/* TODO: Implement this function */
89static void lcd_delay(int x)
90{
91 (void)x;
92}
93
94/* DBOP initialisation, do what OF does */
95static void ams3525_dbop_init(void)
96{
97
98 /* TODO: More... */
99
100 DBOP_TIMPOL_01 = 0xe167e167;
101 DBOP_TIMPOL_23 = 0xe167006e;
102 DBOP_CTRL = 0x41008;
103
104 GPIOB_AFSEL = 0xfc;
105 GPIOC_AFSEL = 0xff;
106
107 DBOP_TIMPOL_23 = 0x6000e;
108 DBOP_CTRL = 0x51008;
109 DBOP_TIMPOL_01 = 0x6e167;
110 DBOP_TIMPOL_23 = 0xa167e06f;
111
112 /* TODO: More... */
113}
114
115static void lcd_write_reg(int reg, int value)
116{
117 DBOP_CTRL &= ~(1<<14);
118
119 DBOP_TIMPOL_23 = 0xa167006e;
120
121 DBOP_DOUT = reg;
122
123 /* Wait for fifo to empty */
124 while ((DBOP_STAT & (1<<10)) == 0);
125
126 DBOP_TIMPOL_23 = 0xa167e06f;
127
128
129 DBOP_DOUT = value;
130
131 /* Wait for fifo to empty */
132 while ((DBOP_STAT & (1<<10)) == 0);
133}
134
135void lcd_write_data(const fb_data* p_bytes, int count)
136{
137 (void)p_bytes;
138 (void)count;
139}
140
141
142/*** hardware configuration ***/
143
144void lcd_set_contrast(int val)
145{
146 (void)val;
147}
148
149void lcd_set_invert_display(bool yesno)
150{
151 (void)yesno;
152}
153
154static void flip_lcd(bool yesno)
155{
156 (void)yesno;
157}
158
159
160/* turn the display upside down (call lcd_update() afterwards) */
161void lcd_set_flip(bool yesno)
162{
163 display_flipped = yesno;
164 xoffset = yesno ? 4 : 0;
165
166 if (display_on)
167 flip_lcd(yesno);
168}
169
170static void _display_on(void)
171{
172 /* Initialisation the display the same way as the original firmware */
173
174 lcd_write_reg(R_START_OSC, 0x0001); /* Start Oscilation */
175
176 lcd_write_reg(R_DRV_OUTPUT_CONTROL, 0x011b); /* 220 lines, GS=0, SS=1 */
177
178 /* B/C = 1: n-line inversion form
179 * EOR = 1: polarity inversion occurs by applying an EOR to odd/even
180 * frame select signal and an n-line inversion signal.
181 * FLD = 01b: 1 field interlaced scan, external display iface */
182 lcd_write_reg(R_DRV_WAVEFORM_CONTROL, 0x0700);
183
184 /* Address counter updated in horizontal direction; left to right;
185 * vertical increment horizontal increment.
186 * data format for 8bit transfer or spi = 65k (5,6,5) */
187 lcd_write_reg(R_ENTRY_MODE, 0x0030);
188
189 /* Replace data on writing to GRAM */
190 lcd_write_reg(R_COMPARE_REG1, 0);
191 lcd_write_reg(R_COMPARE_REG2, 0);
192
193 lcd_write_reg(R_DISP_CONTROL1, 0x0000); /* GON = 0, DTE = 0, D1-0 = 00b */
194
195 /* Front porch lines: 2; Back porch lines: 2; */
196 lcd_write_reg(R_DISP_CONTROL2, 0x0203);
197
198 /* Scan cycle = 0 frames */
199 lcd_write_reg(R_DISP_CONTROL3, 0x0000);
200
201 /* 16 clocks */
202 lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x0000);
203
204 /* 18-bit RGB interface (one transfer/pixel)
205 * internal clock operation;
206 * System interface/VSYNC interface */
207 lcd_write_reg(R_EXT_DISP_IF_CONTROL, 0x0000);
208
209
210 /* zero everything*/
211 lcd_write_reg(R_POWER_CONTROL1, 0x0000); /* STB = 0, SLP = 0 */
212
213 lcd_delay(10);
214
215 /* initialise power supply */
216
217 /* DC12-10 = 000b: Step-up1 = clock/8,
218 * DC02-00 = 000b: Step-up2 = clock/16,
219 * VC2-0 = 010b: VciOUT = 0.87 * VciLVL */
220 lcd_write_reg(R_POWER_CONTROL2, 0x0002);
221
222 /* VRH3-0 = 1000b: Vreg1OUT = REGP * 1.90 */
223 lcd_write_reg(R_POWER_CONTROL3, 0x0008);
224
225 lcd_delay(40);
226
227 lcd_write_reg(R_POWER_CONTROL4, 0x0000); /* VCOMG = 0 */
228
229 /* This register is unknown */
230 lcd_write_reg(0x56, 0x80f);
231
232
233 lcd_write_reg(R_POWER_CONTROL1, 0x4140);
234
235 lcd_delay(10);
236
237 lcd_write_reg(R_POWER_CONTROL2, 0x0000);
238 lcd_write_reg(R_POWER_CONTROL3, 0x0013);
239
240 lcd_delay(20);
241
242 lcd_write_reg(R_POWER_CONTROL4, 0x6d0e);
243
244 lcd_delay(20);
245
246 lcd_write_reg(R_POWER_CONTROL4, 0x6d0e);
247
248 lcd_write_reg(R_GAMMA_FINE_ADJ_POS1, 0x0002);
249 lcd_write_reg(R_GAMMA_FINE_ADJ_POS2, 0x0707);
250 lcd_write_reg(R_GAMMA_FINE_ADJ_POS3, 0x0182);
251 lcd_write_reg(R_GAMMA_GRAD_ADJ_POS, 0x0203);
252 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG1, 0x0706);
253 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG2, 0x0006);
254 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG3, 0x0706);
255 lcd_write_reg(R_GAMMA_GRAD_ADJ_NEG, 0x0000);
256 lcd_write_reg(R_GAMMA_AMP_ADJ_RES_POS, 0x030f);
257 lcd_write_reg(R_GAMMA_AMP_AVG_ADJ_RES_NEG, 0x0f08);
258
259
260 lcd_write_reg(R_RAM_ADDR_SET, 0);
261 lcd_write_reg(R_GATE_SCAN_POS, 0);
262 lcd_write_reg(R_VERT_SCROLL_CONTROL, 0);
263
264 lcd_write_reg(R_1ST_SCR_DRV_POS, 219 << 8);
265 lcd_write_reg(R_2ND_SCR_DRV_POS, 219 << 8);
266
267 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, 175 << 8);
268 lcd_write_reg(R_VERT_RAM_ADDR_POS, 219 << 8);
269
270
271 lcd_write_reg(R_DISP_CONTROL1, 0x0037);
272
273 display_on=true; /* must be done before calling lcd_update() */
274 lcd_update();
275}
276
277/* LCD init */
278void lcd_init_device(void)
279{
280 ams3525_dbop_init();
281
282 /* Init GPIOs the same as the OF */
283
284 GPIOA_DIR |= (1<<5);
285 GPIOA_PIN(5) = 0;
286
287 GPIOA_PIN(3) = (1<<3);
288
289 GPIOA_DIR |= (3<<3);
290
291 GPIOA_PIN(3) = (1<<3);
292
293 GPIOA_PIN(4) = 0; //c80b0040 := 0;
294
295 GPIOA_DIR |= (1<<7);
296 GPIOA_PIN(7) = 0;
297
298 CCU_IO &= ~(1<<2);
299 CCU_IO &= ~(1<<3);
300
301 GPIOD_DIR |= (1<<7);
302
303#if 0
304 /* TODO: This code is conditional on a variable in the OF init, we need to
305 work out what it means */
306
307 GPIOD_PIN(7) = (1<<7);
308 GPIOD_DIR |= (1<<7);
309#endif
310
311 lcd_delay(1);
312
313 GPIOA_PIN(5) = (1<<5);
314
315 lcd_delay(1);
316
317 _display_on();
318}
319
320void lcd_enable(bool on)
321{
322 if(display_on!=on)
323 {
324 if(on)
325 {
326 _display_on();
327 lcd_call_enable_hook();
328 }
329 else
330 {
331 /* TODO: Implement off sequence */
332 display_on=false;
333 }
334 }
335}
336
337bool lcd_enabled(void)
338{
339 return display_on;
340}
341
342/*** update functions ***/
343
344/* Performance function to blit a YUV bitmap directly to the LCD
345 * src_x, src_y, width and height should be even
346 * x, y, width and height have to be within LCD bounds
347 */
348void lcd_blit_yuv(unsigned char * const src[3],
349 int src_x, int src_y, int stride,
350 int x, int y, int width, int height)
351{
352 (void)src;
353 (void)src_x;
354 (void)src_y;
355 (void)stride;
356 (void)x;
357 (void)y;
358 (void)width;
359 (void)height;
360}
361
362/* Update the display.
363 This must be called after all other LCD functions that change the display. */
364void lcd_update(void) ICODE_ATTR;
365void lcd_update(void)
366{
367 if(display_on){
368 /* TODO */
369 }
370}
371
372
373/* Update a fraction of the display. */
374void lcd_update_rect(int, int, int, int) ICODE_ATTR;
375void lcd_update_rect(int x, int y, int width, int height)
376{
377 (void)x;
378 (void)y;
379 (void)width;
380 (void)height;
381
382 if(display_on) {
383 /* TODO */
384 }
385}