diff options
Diffstat (limited to 'firmware/target/arm/olympus/mrobe-100/lcd-mr100.c')
-rw-r--r-- | firmware/target/arm/olympus/mrobe-100/lcd-mr100.c | 192 |
1 files changed, 192 insertions, 0 deletions
diff --git a/firmware/target/arm/olympus/mrobe-100/lcd-mr100.c b/firmware/target/arm/olympus/mrobe-100/lcd-mr100.c new file mode 100644 index 0000000000..501a0942e5 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-100/lcd-mr100.c | |||
@@ -0,0 +1,192 @@ | |||
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 | /* send LCD data */ | ||
26 | static void lcd_send_data(unsigned data) | ||
27 | { | ||
28 | while (LCD1_CONTROL & LCD1_BUSY_MASK); /* wait for LCD */ | ||
29 | LCD1_DATA = data; | ||
30 | } | ||
31 | |||
32 | /* send LCD command */ | ||
33 | static void lcd_send_command(unsigned cmd) | ||
34 | { | ||
35 | while (LCD1_CONTROL & LCD1_BUSY_MASK); /* wait for LCD */ | ||
36 | LCD1_CMD = cmd; | ||
37 | } | ||
38 | |||
39 | /* LCD init */ | ||
40 | void lcd_init_device(void) | ||
41 | { | ||
42 | int i; | ||
43 | |||
44 | DEV_INIT1 &= ~0xfc000000; | ||
45 | |||
46 | i = DEV_INIT1; | ||
47 | DEV_INIT1 = i; | ||
48 | |||
49 | DEV_INIT2 &= ~0x400; | ||
50 | udelay(10000); | ||
51 | |||
52 | LCD1_CONTROL &= ~0x4; | ||
53 | udelay(15); | ||
54 | |||
55 | LCD1_CONTROL |= 0x4; | ||
56 | udelay(10); | ||
57 | |||
58 | LCD1_CONTROL = 0x690; | ||
59 | LCD1_CONTROL = 0x694; | ||
60 | |||
61 | /* OF just reads these */ | ||
62 | i = LCD1_CONTROL; | ||
63 | i = inl(0x70003004); | ||
64 | i = LCD1_CMD; | ||
65 | i = inl(0x7000300c); | ||
66 | |||
67 | #if 0 | ||
68 | /* this is skipped in the OF */ | ||
69 | LCD1_CONTROL &= ~0x200; | ||
70 | LCD1_CONTROL &= ~0x800; | ||
71 | LCD1_CONTROL &= ~0x400; | ||
72 | #endif | ||
73 | |||
74 | LCD1_CONTROL |= 0x1; | ||
75 | udelay(15000); | ||
76 | |||
77 | lcd_send_command(0xe2); | ||
78 | lcd_send_command(0x2f); | ||
79 | lcd_send_command(0x26); | ||
80 | lcd_send_command(0xcc); | ||
81 | lcd_send_command(0xe8); | ||
82 | lcd_send_command(0x81); | ||
83 | lcd_send_command(0); | ||
84 | lcd_send_command(0x40); | ||
85 | lcd_send_command(0xa6); | ||
86 | lcd_send_command(0x88); | ||
87 | lcd_send_command(0xb0); | ||
88 | lcd_send_command(0x10); | ||
89 | lcd_send_command(0); | ||
90 | } | ||
91 | |||
92 | /*** hardware configuration ***/ | ||
93 | int lcd_default_contrast(void) | ||
94 | { | ||
95 | return DEFAULT_CONTRAST_SETTING; | ||
96 | } | ||
97 | |||
98 | void lcd_set_contrast(int val) | ||
99 | { | ||
100 | lcd_send_command(0x81); | ||
101 | lcd_send_command(val); | ||
102 | } | ||
103 | |||
104 | void lcd_set_invert_display(bool yesno) | ||
105 | { | ||
106 | /* TODO: Implement lcd_set_invert_display() */ | ||
107 | (void)yesno; | ||
108 | } | ||
109 | |||
110 | /* turn the display upside down (call lcd_update() afterwards) */ | ||
111 | void lcd_set_flip(bool yesno) | ||
112 | { | ||
113 | /* TODO: Implement lcd_set_flip() */ | ||
114 | (void)yesno; | ||
115 | } | ||
116 | |||
117 | /*** update functions ***/ | ||
118 | |||
119 | /* Performance function that works with an external buffer | ||
120 | note that by and bheight are in 4-pixel units! */ | ||
121 | void lcd_blit(const fb_data* data, int x, int by, int width, | ||
122 | int bheight, int stride) | ||
123 | { | ||
124 | /* TODO: Implement lcd_blit() */ | ||
125 | (void)data; | ||
126 | (void)x; | ||
127 | (void)by; | ||
128 | (void)width; | ||
129 | (void)bheight; | ||
130 | (void)stride; | ||
131 | } | ||
132 | |||
133 | /* Performance function to blit a YUV bitmap directly to the LCD */ | ||
134 | void lcd_yuv_blit(unsigned char * const src[3], | ||
135 | int src_x, int src_y, int stride, | ||
136 | int x, int y, int width, int height) | ||
137 | { | ||
138 | (void)src; | ||
139 | (void)src_x; | ||
140 | (void)src_y; | ||
141 | (void)stride; | ||
142 | (void)x; | ||
143 | (void)y; | ||
144 | (void)width; | ||
145 | (void)height; | ||
146 | } | ||
147 | |||
148 | /* Update the display. | ||
149 | This must be called after all other LCD functions that change the display. */ | ||
150 | void lcd_update(void) | ||
151 | { | ||
152 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); | ||
153 | } | ||
154 | |||
155 | /* Update a fraction of the display. */ | ||
156 | void lcd_update_rect(int x0, int y0, int width, int height) | ||
157 | { | ||
158 | unsigned char *addr; | ||
159 | unsigned int cmd0, cmd1, cmd2; | ||
160 | int r, c, x1, y1, start_row, last_row; | ||
161 | |||
162 | x1 = (x0 + width) - 1; | ||
163 | y1 = (y0 + height) - 1; | ||
164 | if ((x1 <= 0) || (y1 <= 0)) | ||
165 | return; | ||
166 | |||
167 | if(x1 >= LCD_WIDTH) | ||
168 | x1 = LCD_WIDTH - 1; | ||
169 | |||
170 | if(y1 >= LCD_HEIGHT) | ||
171 | y1 = LCD_HEIGHT - 1; | ||
172 | |||
173 | start_row = y0/8; | ||
174 | last_row = y1/8; | ||
175 | |||
176 | cmd1 = (x0 & 0xff) >> 4; | ||
177 | cmd1 = (cmd1 + 5) | 0x10; | ||
178 | cmd2 = x0 & 0xf; | ||
179 | |||
180 | for (r = start_row; r <= last_row; r++) { | ||
181 | cmd0 = (r & 0xff) | 0xb0; | ||
182 | lcd_send_command(cmd0); | ||
183 | lcd_send_command(cmd1); | ||
184 | lcd_send_command(cmd2); | ||
185 | |||
186 | addr = (unsigned char*)&lcd_framebuffer[r][x0]; | ||
187 | for (c = x0; c <= x1; c++) | ||
188 | lcd_send_data(*(addr++)); | ||
189 | } | ||
190 | |||
191 | lcd_send_command(0xaf); | ||
192 | } | ||