| 560 |
theseven |
1 |
|
| 513 |
theseven |
2 |
//
|
|
|
3 |
//
|
|
|
4 |
// Copyright 2010 TheSeven
|
|
|
5 |
//
|
|
|
6 |
//
|
|
|
7 |
// This file is part of emCORE.
|
|
|
8 |
//
|
|
|
9 |
// emCORE is free software: you can redistribute it and/or
|
|
|
10 |
// modify it under the terms of the GNU General Public License as
|
|
|
11 |
// published by the Free Software Foundation, either version 2 of the
|
|
|
12 |
// License, or (at your option) any later version.
|
|
|
13 |
//
|
|
|
14 |
// emCORE is distributed in the hope that it will be useful,
|
|
|
15 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
16 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
17 |
// See the GNU General Public License for more details.
|
|
|
18 |
//
|
|
|
19 |
// You should have received a copy of the GNU General Public License along
|
|
|
20 |
// with emCORE. If not, see <http://www.gnu.org/licenses/>.
|
|
|
21 |
//
|
|
|
22 |
//
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
#include "global.h"
|
|
|
26 |
#include "thread.h"
|
|
|
27 |
#include "s5l8702.h"
|
|
|
28 |
#include "util.h"
|
| 560 |
theseven |
29 |
#include "clockgates-target.h"
|
| 513 |
theseven |
30 |
|
|
|
31 |
|
|
|
32 |
static struct dma_lli lcd_lli[(LCD_WIDTH * LCD_HEIGHT - 1) / 0xfff]
|
|
|
33 |
IDATA_ATTR __attribute__((aligned(16)));
|
|
|
34 |
|
|
|
35 |
static uint16_t lcd_color IDATA_ATTR;
|
|
|
36 |
|
| 560 |
theseven |
37 |
static struct mutex lcd_mutex IDATA_ATTR;
|
|
|
38 |
static struct wakeup lcd_wakeup IDATA_ATTR;
|
| 513 |
theseven |
39 |
|
| 560 |
theseven |
40 |
static bool lcd_dma_busy IDATA_ATTR;
|
|
|
41 |
static bool lcd_in_irq IDATA_ATTR;
|
| 513 |
theseven |
42 |
|
| 560 |
theseven |
43 |
|
| 513 |
theseven |
44 |
int lcd_get_width()
|
|
|
45 |
{
|
|
|
46 |
return LCD_WIDTH;
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
int lcd_get_height()
|
|
|
50 |
{
|
|
|
51 |
return LCD_HEIGHT;
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
int lcd_get_bytes_per_pixel()
|
|
|
55 |
{
|
|
|
56 |
return LCD_BYTESPERPIXEL;
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
int lcd_get_format()
|
|
|
60 |
{
|
|
|
61 |
return LCD_FORMAT;
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
static void lcd_send_cmd(uint16_t cmd) ICODE_ATTR __attribute__((noinline));
|
|
|
65 |
static void lcd_send_cmd(uint16_t cmd)
|
|
|
66 |
{
|
|
|
67 |
while (LCDSTATUS & 0x10);
|
|
|
68 |
LCDWCMD = cmd;
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
static void lcd_send_data(uint16_t data) ICODE_ATTR __attribute__((noinline));
|
|
|
72 |
static void lcd_send_data(uint16_t data)
|
|
|
73 |
{
|
|
|
74 |
while (LCDSTATUS & 0x10);
|
|
|
75 |
LCDWDATA = (data & 0xff) | ((data & 0x7f00) << 1);
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
static uint32_t lcd_detect() ICODE_ATTR;
|
|
|
79 |
static uint32_t lcd_detect()
|
|
|
80 |
{
|
|
|
81 |
return (PDAT6 & 0x30) >> 4;
|
|
|
82 |
}
|
|
|
83 |
|
| 581 |
theseven |
84 |
void lcd_init()
|
|
|
85 |
{
|
|
|
86 |
mutex_init(&lcd_mutex);
|
|
|
87 |
wakeup_init(&lcd_wakeup);
|
|
|
88 |
lcd_in_irq = false;
|
|
|
89 |
lcd_dma_busy = true;
|
|
|
90 |
clockgate_dma(0, 4, true);
|
|
|
91 |
if (!(DMAC0C4CONFIG & 1))
|
|
|
92 |
{
|
|
|
93 |
lcd_dma_busy = false;
|
|
|
94 |
clockgate_dma(0, 4, false);
|
|
|
95 |
}
|
|
|
96 |
switch (lcd_detect())
|
|
|
97 |
{
|
| 648 |
theseven |
98 |
// case 0:
|
|
|
99 |
// pmu_write(0x31, 0x0b); // Vlcd @ 2.000V
|
|
|
100 |
// break;
|
| 581 |
theseven |
101 |
case 1:
|
| 683 |
theseven |
102 |
// pmu_write(0x31, 0x0e); // Vlcd @ 2.300V
|
| 648 |
theseven |
103 |
break;
|
| 581 |
theseven |
104 |
case 2:
|
| 683 |
theseven |
105 |
// pmu_write(0x31, 0x12); // Vlcd @ 2.700V
|
| 648 |
theseven |
106 |
break;
|
|
|
107 |
// case 3:
|
|
|
108 |
// pmu_write(0x31, 0x0b); // Vlcd @ 2.000V
|
|
|
109 |
// break;
|
| 683 |
theseven |
110 |
// default:
|
|
|
111 |
// pmu_write(0x31, 0x0b); // Vlcd @ 2.000V
|
| 648 |
theseven |
112 |
}
|
| 581 |
theseven |
113 |
}
|
|
|
114 |
|
| 513 |
theseven |
115 |
bool displaylcd_busy() ICODE_ATTR;
|
|
|
116 |
bool displaylcd_busy()
|
|
|
117 |
{
|
| 560 |
theseven |
118 |
return lcd_dma_busy;
|
| 513 |
theseven |
119 |
}
|
|
|
120 |
|
|
|
121 |
bool displaylcd_safe()
|
|
|
122 |
{
|
| 560 |
theseven |
123 |
lcd_in_irq = true;
|
|
|
124 |
if (!lcd_dma_busy) return true;
|
| 513 |
theseven |
125 |
return !(DMAC0C4CONFIG & 1);
|
|
|
126 |
}
|
|
|
127 |
|
|
|
128 |
void displaylcd_sync() ICODE_ATTR;
|
|
|
129 |
void displaylcd_sync()
|
|
|
130 |
{
|
| 560 |
theseven |
131 |
mutex_lock(&lcd_mutex, TIMEOUT_BLOCK);
|
|
|
132 |
while (displaylcd_busy()) wakeup_wait(&lcd_wakeup, TIMEOUT_BLOCK);
|
|
|
133 |
mutex_unlock(&lcd_mutex);
|
| 513 |
theseven |
134 |
}
|
|
|
135 |
|
|
|
136 |
void displaylcd_setup(unsigned int startx, unsigned int endx,
|
|
|
137 |
unsigned int starty, unsigned int endy) ICODE_ATTR;
|
|
|
138 |
void displaylcd_setup(unsigned int startx, unsigned int endx,
|
|
|
139 |
unsigned int starty, unsigned int endy)
|
|
|
140 |
{
|
| 560 |
theseven |
141 |
if (!lcd_in_irq)
|
|
|
142 |
{
|
|
|
143 |
mutex_lock(&lcd_mutex, TIMEOUT_BLOCK);
|
|
|
144 |
displaylcd_sync();
|
|
|
145 |
}
|
| 513 |
theseven |
146 |
if (lcd_detect() & 2)
|
|
|
147 |
{
|
|
|
148 |
lcd_send_cmd(0x210);
|
|
|
149 |
lcd_send_data(startx);
|
|
|
150 |
lcd_send_cmd(0x211);
|
|
|
151 |
lcd_send_data(endx);
|
|
|
152 |
lcd_send_cmd(0x212);
|
|
|
153 |
lcd_send_data(starty);
|
|
|
154 |
lcd_send_cmd(0x213);
|
|
|
155 |
lcd_send_data(endy);
|
|
|
156 |
lcd_send_cmd(0x200);
|
|
|
157 |
lcd_send_data(startx);
|
|
|
158 |
lcd_send_cmd(0x201);
|
|
|
159 |
lcd_send_data(starty);
|
|
|
160 |
lcd_send_cmd(0x202);
|
|
|
161 |
}
|
|
|
162 |
else
|
|
|
163 |
{
|
|
|
164 |
lcd_send_cmd(0x2a);
|
|
|
165 |
lcd_send_data(startx >> 8);
|
|
|
166 |
lcd_send_data(startx & 0xff);
|
|
|
167 |
lcd_send_data(endx >> 8);
|
|
|
168 |
lcd_send_data(endx & 0xff);
|
|
|
169 |
lcd_send_cmd(0x2b);
|
|
|
170 |
lcd_send_data(starty >> 8);
|
|
|
171 |
lcd_send_data(starty & 0xff);
|
|
|
172 |
lcd_send_data(endy >> 8);
|
|
|
173 |
lcd_send_data(endy & 0xff);
|
|
|
174 |
lcd_send_cmd(0x2c);
|
|
|
175 |
}
|
|
|
176 |
}
|
|
|
177 |
|
|
|
178 |
static void displaylcd_dma(void* data, int pixels, bool solid) ICODE_ATTR;
|
|
|
179 |
static void displaylcd_dma(void* data, int pixels, bool solid)
|
|
|
180 |
{
|
|
|
181 |
int i;
|
| 560 |
theseven |
182 |
lcd_dma_busy = true;
|
|
|
183 |
clockgate_dma(0, 4, true);
|
| 513 |
theseven |
184 |
for (i = -1; i < (int)ARRAYLEN(lcd_lli) && pixels > 0; i++, pixels -= 0xfff)
|
|
|
185 |
{
|
|
|
186 |
bool last = i + 1 >= ARRAYLEN(lcd_lli) || pixels <= 0xfff;
|
|
|
187 |
struct dma_lli* lli = i < 0 ? (struct dma_lli*)((int)&DMAC0C4LLI) : &lcd_lli[i];
|
|
|
188 |
lli->srcaddr = data;
|
|
|
189 |
lli->dstaddr = (void*)((int)&LCDWDATA);
|
|
|
190 |
lli->nextlli = last ? NULL : &lcd_lli[i + 1];
|
|
|
191 |
lli->control = 0x70240000 | (last ? pixels : 0xfff)
|
|
|
192 |
| (last ? 0x80000000 : 0) | (solid ? 0 : 0x4000000);
|
| 648 |
theseven |
193 |
if (!solid) data += 0x1ffe;
|
| 513 |
theseven |
194 |
}
|
|
|
195 |
clean_dcache();
|
|
|
196 |
DMAC0C4CONFIG = 0x88c1;
|
|
|
197 |
}
|
|
|
198 |
|
|
|
199 |
void displaylcd_native(unsigned int startx, unsigned int endx,
|
|
|
200 |
unsigned int starty, unsigned int endy, void* data)
|
|
|
201 |
{
|
|
|
202 |
int pixels = (endx - startx + 1) * (endy - starty + 1);
|
|
|
203 |
if (pixels <= 0) return;
|
|
|
204 |
displaylcd_setup(startx, endx, starty, endy);
|
|
|
205 |
displaylcd_dma(data, pixels, false);
|
| 560 |
theseven |
206 |
if (!lcd_in_irq) mutex_unlock(&lcd_mutex);
|
| 513 |
theseven |
207 |
}
|
|
|
208 |
|
|
|
209 |
void filllcd_native(unsigned int startx, unsigned int endx,
|
|
|
210 |
unsigned int starty, unsigned int endy, int color)
|
|
|
211 |
{
|
|
|
212 |
int pixels = (endx - startx + 1) * (endy - starty + 1);
|
|
|
213 |
if (pixels <= 0) return;
|
|
|
214 |
displaylcd_setup(startx, endx, starty, endy);
|
|
|
215 |
lcd_color = color;
|
|
|
216 |
displaylcd_dma(&lcd_color, pixels, true);
|
| 560 |
theseven |
217 |
if (!lcd_in_irq) mutex_unlock(&lcd_mutex);
|
| 513 |
theseven |
218 |
}
|
|
|
219 |
|
|
|
220 |
void displaylcd_dither(unsigned int x, unsigned int y, unsigned int width,
|
|
|
221 |
unsigned int height, void* data, unsigned int datax,
|
|
|
222 |
unsigned int datay, unsigned int stride, bool solid)
|
|
|
223 |
ICODE_ATTR __attribute__((naked,noinline));
|
|
|
224 |
void displaylcd_dither(unsigned int x, unsigned int y, unsigned int width,
|
|
|
225 |
unsigned int height, void* data, unsigned int datax,
|
|
|
226 |
unsigned int datay, unsigned int stride, bool solid)
|
|
|
227 |
{
|
|
|
228 |
__asm__ volatile(" muls r12, r2, r3 \n");
|
|
|
229 |
__asm__ volatile(" bxeq lr \n");
|
|
|
230 |
__asm__ volatile(" stmfd sp!, {r2-r11,lr} \n");
|
|
|
231 |
__asm__ volatile(" mov r12, r2 \n");
|
|
|
232 |
__asm__ volatile(" add r8, r2, r2,lsl#1 \n");
|
|
|
233 |
__asm__ volatile(" add r3, r1, r3 \n");
|
|
|
234 |
__asm__ volatile(" sub r3, r3, #1 \n");
|
|
|
235 |
__asm__ volatile(" mov r2, r1 \n");
|
|
|
236 |
__asm__ volatile(" add r1, r0, r12 \n");
|
|
|
237 |
__asm__ volatile(" sub r1, r1, #1 \n");
|
|
|
238 |
__asm__ volatile(" bl displaylcd_setup \n");
|
|
|
239 |
__asm__ volatile(" mov r0, r8 \n");
|
|
|
240 |
__asm__ volatile(" bl malloc \n");
|
|
|
241 |
__asm__ volatile(" cmp r0, #0 \n");
|
|
|
242 |
__asm__ volatile(" beq displaylcd_dither_unlock \n");
|
|
|
243 |
__asm__ volatile(" mov r2, r8 \n");
|
|
|
244 |
__asm__ volatile(" mov r1, #0 \n");
|
|
|
245 |
__asm__ volatile(" mov r8, r0 \n");
|
|
|
246 |
__asm__ volatile(" bl memset \n");
|
|
|
247 |
__asm__ volatile(" ldr r0, [sp,#0x30] \n");
|
|
|
248 |
__asm__ volatile(" ldr r1, [sp,#0x34] \n");
|
|
|
249 |
__asm__ volatile(" ldr r11, [sp,#0x38] \n");
|
|
|
250 |
__asm__ volatile(" ldr r3, [sp,#0x2c] \n");
|
|
|
251 |
__asm__ volatile(" mla r0, r1, r11, r0 \n");
|
|
|
252 |
__asm__ volatile(" ldr r12, [sp,#0x04] \n");
|
|
|
253 |
__asm__ volatile(" ldr r2, [sp,#0x3c] \n");
|
|
|
254 |
__asm__ volatile(" add r3, r3, r0,lsl#1 \n");
|
|
|
255 |
__asm__ volatile(" cmp r2, #0 \n");
|
|
|
256 |
__asm__ volatile(" ldreq r1, [sp] \n");
|
|
|
257 |
__asm__ volatile(" add r3, r3, r0 \n");
|
|
|
258 |
__asm__ volatile(" subeq r11, r11, r1 \n");
|
|
|
259 |
__asm__ volatile(" add r11, r11, r11,lsl#1 \n");
|
|
|
260 |
__asm__ volatile(" movne r10, #3 \n");
|
|
|
261 |
__asm__ volatile(" moveq r10, #0 \n");
|
|
|
262 |
__asm__ volatile(" ldr r9, =0x38300040 \n");
|
|
|
263 |
__asm__ volatile("displaylcd_dither_y: \n");
|
|
|
264 |
__asm__ volatile(" ldr lr, [sp] \n");
|
|
|
265 |
__asm__ volatile(" mov r4, #0 \n");
|
|
|
266 |
__asm__ volatile(" mov r5, #0 \n");
|
|
|
267 |
__asm__ volatile(" mov r6, #0 \n");
|
|
|
268 |
__asm__ volatile(" mov r7, r8 \n");
|
|
|
269 |
__asm__ volatile("displaylcd_dither_x: \n");
|
|
|
270 |
__asm__ volatile(" mov r2, #0 \n");
|
|
|
271 |
__asm__ volatile(" ldrb r1, [r3], #1 \n");
|
|
|
272 |
__asm__ volatile(" ldrsb r0, [r7] \n");
|
|
|
273 |
__asm__ volatile(" add r1, r1, r4 \n");
|
|
|
274 |
__asm__ volatile(" add r1, r1, r0 \n");
|
|
|
275 |
__asm__ volatile(" cmp r1, #0xff \n");
|
| 648 |
theseven |
276 |
__asm__ volatile(" mvnhi r1, r1,asr#31 \n");
|
|
|
277 |
__asm__ volatile(" andhi r1, r1, #0xff \n");
|
| 513 |
theseven |
278 |
__asm__ volatile(" mov r0, r1,lsr#3 \n");
|
|
|
279 |
__asm__ volatile(" orr r2, r0,lsl#11 \n");
|
|
|
280 |
__asm__ volatile(" sub r1, r1, r0,lsl#3 \n");
|
|
|
281 |
__asm__ volatile(" sub r1, r1, r0,lsr#2 \n");
|
|
|
282 |
__asm__ volatile(" mov r4, r4,lsr#1 \n");
|
|
|
283 |
__asm__ volatile(" add r4, r4, r1,lsr#2 \n");
|
|
|
284 |
__asm__ volatile(" strb r4, [r7], #1 \n");
|
|
|
285 |
__asm__ volatile(" mov r4, r1,asr#1 \n");
|
|
|
286 |
__asm__ volatile(" ldrb r1, [r3], #1 \n");
|
|
|
287 |
__asm__ volatile(" ldrsb r0, [r7] \n");
|
|
|
288 |
__asm__ volatile(" add r1, r1, r5 \n");
|
|
|
289 |
__asm__ volatile(" add r1, r1, r0 \n");
|
|
|
290 |
__asm__ volatile(" cmp r1, #0xff \n");
|
| 648 |
theseven |
291 |
__asm__ volatile(" mvnhi r1, r1,asr#31 \n");
|
|
|
292 |
__asm__ volatile(" andhi r1, r1, #0xff \n");
|
| 513 |
theseven |
293 |
__asm__ volatile(" mov r0, r1,lsr#2 \n");
|
|
|
294 |
__asm__ volatile(" orr r2, r0,lsl#5 \n");
|
|
|
295 |
__asm__ volatile(" sub r1, r1, r0,lsl#2 \n");
|
|
|
296 |
__asm__ volatile(" sub r1, r1, r0,lsr#4 \n");
|
|
|
297 |
__asm__ volatile(" mov r5, r5,lsr#1 \n");
|
|
|
298 |
__asm__ volatile(" add r5, r5, r1,lsr#2 \n");
|
|
|
299 |
__asm__ volatile(" strb r5, [r7], #1 \n");
|
|
|
300 |
__asm__ volatile(" mov r5, r1,asr#1 \n");
|
|
|
301 |
__asm__ volatile(" ldrb r1, [r3], #1 \n");
|
|
|
302 |
__asm__ volatile(" ldrsb r0, [r7] \n");
|
|
|
303 |
__asm__ volatile(" add r1, r1, r6 \n");
|
|
|
304 |
__asm__ volatile(" add r1, r1, r0 \n");
|
|
|
305 |
__asm__ volatile(" cmp r1, #0xff \n");
|
| 648 |
theseven |
306 |
__asm__ volatile(" mvnhi r1, r1,asr#31 \n");
|
|
|
307 |
__asm__ volatile(" andhi r1, r1, #0xff \n");
|
| 513 |
theseven |
308 |
__asm__ volatile(" mov r0, r1,lsr#3 \n");
|
|
|
309 |
__asm__ volatile(" orr r2, r0 \n");
|
|
|
310 |
__asm__ volatile(" sub r1, r1, r0,lsl#3 \n");
|
|
|
311 |
__asm__ volatile(" sub r1, r1, r0,lsr#2 \n");
|
|
|
312 |
__asm__ volatile(" mov r6, r6,lsr#1 \n");
|
|
|
313 |
__asm__ volatile(" add r6, r6, r1,lsr#2 \n");
|
|
|
314 |
__asm__ volatile(" strb r6, [r7], #1 \n");
|
|
|
315 |
__asm__ volatile(" mov r6, r1,asr#1 \n");
|
|
|
316 |
__asm__ volatile(" str r2, [r9] \n");
|
|
|
317 |
__asm__ volatile(" sub r3, r3, r10 \n");
|
|
|
318 |
__asm__ volatile(" subs lr, lr, #1 \n");
|
|
|
319 |
__asm__ volatile(" bne displaylcd_dither_x \n");
|
|
|
320 |
__asm__ volatile(" add r3, r3, r11 \n");
|
|
|
321 |
__asm__ volatile(" subs r12, r12, #1 \n");
|
|
|
322 |
__asm__ volatile(" bne displaylcd_dither_y \n");
|
|
|
323 |
__asm__ volatile("displaylcd_dither_free: \n");
|
|
|
324 |
__asm__ volatile(" mov r0, r8 \n");
|
|
|
325 |
__asm__ volatile(" bl free \n");
|
|
|
326 |
__asm__ volatile("displaylcd_dither_unlock: \n");
|
|
|
327 |
__asm__ volatile(" ldr r0, =lcd_mutex \n");
|
|
|
328 |
__asm__ volatile(" bl mutex_unlock \n");
|
|
|
329 |
__asm__ volatile(" ldmfd sp!, {r2-r11,pc} \n");
|
|
|
330 |
}
|
|
|
331 |
|
|
|
332 |
void displaylcd(unsigned int x, unsigned int y, unsigned int width, unsigned int height,
|
|
|
333 |
void* data, unsigned int datax, unsigned int datay, unsigned int stride)
|
|
|
334 |
{
|
|
|
335 |
displaylcd_dither(x, y, width, height, data, datax, datay, stride, false);
|
|
|
336 |
}
|
|
|
337 |
|
|
|
338 |
void filllcd(unsigned int x, unsigned int y, unsigned int width, unsigned int height, int color)
|
|
|
339 |
{
|
|
|
340 |
if (width * height <= 0) return;
|
| 560 |
theseven |
341 |
mutex_lock(&lcd_mutex, TIMEOUT_BLOCK);
|
| 521 |
theseven |
342 |
displaylcd_sync();
|
| 513 |
theseven |
343 |
lcd_color = color;
|
|
|
344 |
displaylcd_dither(x, y, width, height, &lcd_color, 0, 0, 0, true);
|
|
|
345 |
mutex_unlock(&lcd_mutex);
|
|
|
346 |
}
|
|
|
347 |
|
|
|
348 |
void lcd_shutdown()
|
|
|
349 |
{
|
| 683 |
theseven |
350 |
mutex_lock(&lcd_mutex, TIMEOUT_BLOCK);
|
| 513 |
theseven |
351 |
displaylcd_sync();
|
|
|
352 |
uint32_t type = lcd_detect();
|
|
|
353 |
if (type & 2)
|
|
|
354 |
{
|
|
|
355 |
lcd_send_cmd(0x7);
|
|
|
356 |
lcd_send_data(0x172);
|
|
|
357 |
lcd_send_cmd(0x30);
|
|
|
358 |
lcd_send_data(0x3ff);
|
|
|
359 |
sleep(90000);
|
|
|
360 |
lcd_send_cmd(0x7);
|
|
|
361 |
lcd_send_data(0x120);
|
|
|
362 |
lcd_send_cmd(0x30);
|
|
|
363 |
lcd_send_data(0x0);
|
|
|
364 |
lcd_send_cmd(0x100);
|
|
|
365 |
lcd_send_data(0x780);
|
|
|
366 |
lcd_send_cmd(0x7);
|
|
|
367 |
lcd_send_data(0x0);
|
|
|
368 |
lcd_send_cmd(0x101);
|
|
|
369 |
lcd_send_data(0x260);
|
|
|
370 |
lcd_send_cmd(0x102);
|
|
|
371 |
lcd_send_data(0xa9);
|
|
|
372 |
sleep(30000);
|
|
|
373 |
lcd_send_cmd(0x100);
|
|
|
374 |
lcd_send_data(0x700);
|
|
|
375 |
lcd_send_cmd(0x100);
|
|
|
376 |
lcd_send_data(0x704);
|
|
|
377 |
}
|
|
|
378 |
else if (type == 1)
|
|
|
379 |
{
|
|
|
380 |
lcd_send_cmd(0x28);
|
|
|
381 |
lcd_send_cmd(0x10);
|
|
|
382 |
sleep(100000);
|
|
|
383 |
}
|
|
|
384 |
else
|
|
|
385 |
{
|
|
|
386 |
lcd_send_cmd(0x28);
|
|
|
387 |
sleep(50000);
|
|
|
388 |
lcd_send_cmd(0x10);
|
|
|
389 |
sleep(50000);
|
|
|
390 |
}
|
|
|
391 |
}
|
|
|
392 |
|
|
|
393 |
void INT_DMAC0C4()
|
|
|
394 |
{
|
|
|
395 |
DMAC0INTTCCLR = 0x10;
|
| 560 |
theseven |
396 |
lcd_in_irq = true;
|
|
|
397 |
lcd_dma_busy = false;
|
|
|
398 |
clockgate_dma(0, 4, false);
|
| 513 |
theseven |
399 |
lcdconsole_callback();
|
| 560 |
theseven |
400 |
wakeup_signal(&lcd_wakeup);
|
|
|
401 |
lcd_in_irq = false;
|
| 513 |
theseven |
402 |
}
|
|
|
403 |
|
|
|
404 |
int lcd_translate_color(uint8_t alpha, uint8_t red, uint8_t green, uint8_t blue)
|
|
|
405 |
ICODE_ATTR __attribute__((naked, noinline));
|
|
|
406 |
int lcd_translate_color(uint8_t alpha, uint8_t red, uint8_t green, uint8_t blue)
|
|
|
407 |
{
|
|
|
408 |
asm volatile(
|
|
|
409 |
"cmp r0, #0xff \n\t"
|
|
|
410 |
"moveq r0, #-1 \n\t"
|
|
|
411 |
"moveq pc, lr \n\t"
|
|
|
412 |
"cmp r0, #0 \n\t"
|
|
|
413 |
"movne r0, #0xff000000 \n\t"
|
|
|
414 |
"orrne r0, r0, #0xff0000 \n\t"
|
|
|
415 |
"mov r2, r2,lsr#2 \n\t"
|
|
|
416 |
"orr r0, r0, r3,lsr#3 \n\t"
|
|
|
417 |
"mov r1, r1,lsr#3 \n\t"
|
|
|
418 |
"orr r0, r0, r2,lsl#5 \n\t"
|
|
|
419 |
"orr r0, r0, r1,lsl#11 \n\t"
|
|
|
420 |
"mov pc, lr \n\t"
|
|
|
421 |
);
|
|
|
422 |
}
|