diff options
author | Jens Arnold <amiconn@rockbox.org> | 2008-03-26 00:38:40 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2008-03-26 00:38:40 +0000 |
commit | 74d678fdbcbc427c057e7682ba0a0566e49a8b97 (patch) | |
tree | 9f973bc089114487435e454c6ea7baf3e606e7d9 | |
parent | 40919d7db29d036033f57fe6fbf9e3f562e61c0d (diff) | |
download | rockbox-74d678fdbcbc427c057e7682ba0a0566e49a8b97.tar.gz rockbox-74d678fdbcbc427c057e7682ba0a0566e49a8b97.zip |
Back-ported the iAudio remote LCD driver optimisations to X5 and M5.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16810 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/SOURCES | 2 | ||||
-rw-r--r-- | firmware/target/coldfire/iaudio/lcd-remote-as-iaudio.S | 316 | ||||
-rw-r--r-- | firmware/target/coldfire/iaudio/lcd-remote-iaudio.c | 257 |
3 files changed, 335 insertions, 240 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index 1d60ea1016..699460e0ec 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -463,6 +463,7 @@ target/coldfire/ata-as-coldfire.S | |||
463 | target/coldfire/pcf50606-coldfire.c | 463 | target/coldfire/pcf50606-coldfire.c |
464 | target/coldfire/iaudio/adc-iaudio.c | 464 | target/coldfire/iaudio/adc-iaudio.c |
465 | target/coldfire/iaudio/ata-iaudio.c | 465 | target/coldfire/iaudio/ata-iaudio.c |
466 | target/coldfire/iaudio/lcd-remote-as-iaudio.S | ||
466 | target/coldfire/iaudio/lcd-remote-iaudio.c | 467 | target/coldfire/iaudio/lcd-remote-iaudio.c |
467 | target/coldfire/iaudio/pcf50606-iaudio.c | 468 | target/coldfire/iaudio/pcf50606-iaudio.c |
468 | target/coldfire/iaudio/powermgmt-iaudio.c | 469 | target/coldfire/iaudio/powermgmt-iaudio.c |
@@ -488,6 +489,7 @@ target/coldfire/ata-as-coldfire.S | |||
488 | target/coldfire/pcf50606-coldfire.c | 489 | target/coldfire/pcf50606-coldfire.c |
489 | target/coldfire/iaudio/adc-iaudio.c | 490 | target/coldfire/iaudio/adc-iaudio.c |
490 | target/coldfire/iaudio/ata-iaudio.c | 491 | target/coldfire/iaudio/ata-iaudio.c |
492 | target/coldfire/iaudio/lcd-remote-as-iaudio.S | ||
491 | target/coldfire/iaudio/lcd-remote-iaudio.c | 493 | target/coldfire/iaudio/lcd-remote-iaudio.c |
492 | target/coldfire/iaudio/m5/backlight-m5.c | 494 | target/coldfire/iaudio/m5/backlight-m5.c |
493 | target/coldfire/iaudio/m5/button-m5.c | 495 | target/coldfire/iaudio/m5/button-m5.c |
diff --git a/firmware/target/coldfire/iaudio/lcd-remote-as-iaudio.S b/firmware/target/coldfire/iaudio/lcd-remote-as-iaudio.S new file mode 100644 index 0000000000..18028a81c3 --- /dev/null +++ b/firmware/target/coldfire/iaudio/lcd-remote-as-iaudio.S | |||
@@ -0,0 +1,316 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Jens Arnold | ||
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 | |||
20 | #define CLOCK_MASK 0x00004000 | ||
21 | #define DATA_MASK 0x00002000 | ||
22 | #define RS_MASK 0x00008000 | ||
23 | #define GPIO_OUT_ADDR 0x80000004 | ||
24 | |||
25 | #define CS_MASK 0x00000020 | ||
26 | #define GPIO1_OUT_ADDR 0x800000b4 | ||
27 | |||
28 | .extern cpu_frequency /* Global variable from system.c */ | ||
29 | |||
30 | .section .icode,"ax",@progbits | ||
31 | |||
32 | /* Output 8 bits to the LCD. Instruction order is devised to maximize the | ||
33 | * delay between changing the data line and the CLK L->H transition, which | ||
34 | * makes the LCD controller sample DATA. | ||
35 | * | ||
36 | * Custom calling convention: | ||
37 | * %a0 - GPIO_OUT_ADDR | ||
38 | * %d3 - data byte | ||
39 | * %d6 - DATA_MASK | ||
40 | * %d7 - CLOCK_MASK | ||
41 | * Clobbers: | ||
42 | * %d0..%d3 | ||
43 | */ | ||
44 | .write_byte: | ||
45 | move.w %sr, %d2 | ||
46 | move.w #0x2700, %sr | ||
47 | |||
48 | move.l (%a0), %d0 /* Get current state of data port */ | ||
49 | move.l %d0, %d1 | ||
50 | and.l %d6, %d1 /* Check current state of data line */ | ||
51 | beq.s 1f /* and set it as previous-state bit */ | ||
52 | bset #8, %d3 | ||
53 | 1: | ||
54 | move.l %d3, %d1 /* Compute the 'bit derivative', i.e. a value */ | ||
55 | lsr.l #1, %d1 /* with 1's where the data changes from the */ | ||
56 | eor.l %d1, %d3 /* previous state, and 0's where it doesn't */ | ||
57 | swap %d3 /* Shift data to upper byte */ | ||
58 | lsl.l #8, %d3 | ||
59 | |||
60 | eor.l %d7, %d0 /* precalculate opposite state of clock line */ | ||
61 | |||
62 | lsl.l #1,%d3 /* Shift out MSB */ | ||
63 | bcc.s 1f | ||
64 | eor.l %d6, %d0 /* 1: Flip data bit */ | ||
65 | 1: | ||
66 | move.l %d0, %d1 | ||
67 | move.l %d0, (%a0) /* Output new state and set CLK = 0*/ | ||
68 | eor.l %d7, %d1 | ||
69 | bra.w .wr_bit7 | ||
70 | |||
71 | |||
72 | /* Output 16 bits to the LCD. Instruction order is devised to maximize the | ||
73 | * delay between changing the data line and the CLK L->H transition, which | ||
74 | * makes the LCD controller sample DATA. | ||
75 | * | ||
76 | * Custom calling convention: | ||
77 | * %a0 - GPIO_OUT_ADDR | ||
78 | * %d3 - data word | ||
79 | * %d6 - DATA_MASK | ||
80 | * %d7 - CLOCK_MASK | ||
81 | * Clobbers: | ||
82 | * %d0..%d3 | ||
83 | */ | ||
84 | .write_word: | ||
85 | move.w %sr, %d2 | ||
86 | move.w #0x2700, %sr | ||
87 | |||
88 | move.l (%a0), %d0 /* Get current state of data port */ | ||
89 | move.l %d0, %d1 | ||
90 | and.l %d6, %d1 /* Check current state of data line */ | ||
91 | beq.s 1f /* and set it as previous-state bit */ | ||
92 | bset #16, %d3 | ||
93 | 1: | ||
94 | move.l %d3, %d1 /* Compute the 'bit derivative', i.e. a value */ | ||
95 | lsr.l #1, %d1 /* with 1's where the data changes from the */ | ||
96 | eor.l %d1, %d3 /* previous state, and 0's where it doesn't */ | ||
97 | swap %d3 /* Shift data to upper word */ | ||
98 | |||
99 | eor.l %d7, %d0 /* precalculate opposite state of clock line */ | ||
100 | |||
101 | lsl.l #1,%d3 /* Shift out MSB */ | ||
102 | bcc.s 1f | ||
103 | eor.l %d6, %d0 /* 1: Flip data bit */ | ||
104 | 1: | ||
105 | move.l %d0, %d1 | ||
106 | move.l %d0, (%a0) /* Output new state and set CLK = 0*/ | ||
107 | eor.l %d7, %d1 | ||
108 | nop | ||
109 | |||
110 | .macro bit_out | ||
111 | lsl.l #1,%d3 | ||
112 | bcc.s 1f | ||
113 | eor.l %d6, %d0 | ||
114 | 1: | ||
115 | move.l %d1, (%a0) /* Set CLK = 1 (delayed) */ | ||
116 | move.l %d0, %d1 | ||
117 | move.l %d0, (%a0) | ||
118 | eor.l %d7, %d1 | ||
119 | .endm | ||
120 | bit_out | ||
121 | nop | ||
122 | bit_out | ||
123 | nop | ||
124 | bit_out | ||
125 | nop | ||
126 | bit_out | ||
127 | nop | ||
128 | bit_out | ||
129 | nop | ||
130 | bit_out | ||
131 | nop | ||
132 | bit_out | ||
133 | nop | ||
134 | bit_out | ||
135 | nop | ||
136 | |||
137 | .wr_bit7: | ||
138 | bit_out | ||
139 | nop | ||
140 | bit_out | ||
141 | nop | ||
142 | bit_out | ||
143 | nop | ||
144 | bit_out | ||
145 | nop | ||
146 | bit_out | ||
147 | nop | ||
148 | bit_out | ||
149 | nop | ||
150 | bit_out | ||
151 | nop | ||
152 | |||
153 | nop | ||
154 | move.l %d1, (%a0) /* Set CLK = 1 (delayed) */ | ||
155 | move.w %d2, %sr | ||
156 | rts | ||
157 | |||
158 | |||
159 | /* Output 16 bits to the LCD as fast as possible. Use only at < 60MHz. | ||
160 | * | ||
161 | * Custom calling convention: | ||
162 | * %a0 - GPIO_OUT_ADDR | ||
163 | * %d3 - data word | ||
164 | * %d6 - DATA_MASK | ||
165 | * %d7 - CLOCK_MASK | ||
166 | * Clobbers: | ||
167 | * %d0..%d3 | ||
168 | */ | ||
169 | .write_word_fast: | ||
170 | move.w %sr, %d2 /* Get current interrupt level */ | ||
171 | move.w #0x2700, %sr /* Disable interrupts */ | ||
172 | |||
173 | move.l (%a0), %d0 /* Get current state of data port */ | ||
174 | move.l %d0, %d1 | ||
175 | and.l %d6, %d1 /* Check current state of data line */ | ||
176 | beq.s 1f /* and set it as previous-state bit */ | ||
177 | bset #16, %d3 | ||
178 | 1: | ||
179 | move.l %d3, %d1 /* Compute the 'bit derivative', i.e. a value */ | ||
180 | lsr.l #1, %d1 /* with 1's where the data changes from the */ | ||
181 | eor.l %d1, %d3 /* previous state, and 0's where it doesn't */ | ||
182 | swap %d3 /* Shift data to upper byte */ | ||
183 | |||
184 | move.l %d0, %d1 /* precalculate opposite state of clock line */ | ||
185 | eor.l %d7, %d1 | ||
186 | |||
187 | .macro bit_out_fast | ||
188 | lsl.l #1,%d3 /* Shift out MSB */ | ||
189 | bcc.s 1f | ||
190 | eor.l %d6, %d0 /* 1: Flip data bit */ | ||
191 | eor.l %d6, %d1 /* for both clock states */ | ||
192 | 1: | ||
193 | move.l %d1, (%a0) /* Output new state and set CLK = 0*/ | ||
194 | move.l %d0, (%a0) /* set CLK = 1 */ | ||
195 | .endm | ||
196 | bit_out_fast | ||
197 | bit_out_fast | ||
198 | bit_out_fast | ||
199 | bit_out_fast | ||
200 | bit_out_fast | ||
201 | bit_out_fast | ||
202 | bit_out_fast | ||
203 | bit_out_fast | ||
204 | bit_out_fast | ||
205 | bit_out_fast | ||
206 | bit_out_fast | ||
207 | bit_out_fast | ||
208 | bit_out_fast | ||
209 | bit_out_fast | ||
210 | bit_out_fast | ||
211 | bit_out_fast | ||
212 | |||
213 | move.w %d2, %sr /* Restore interrupt level */ | ||
214 | rts | ||
215 | |||
216 | |||
217 | .global lcd_remote_write_command | ||
218 | .type lcd_remote_write_command, @function | ||
219 | |||
220 | lcd_remote_write_command: | ||
221 | lea.l (-4*4, %sp), %sp | ||
222 | movem.l %d2-%d3/%d6-%d7, (%sp) | ||
223 | |||
224 | move.l (4*4+4, %sp), %d3 /* cmd */ | ||
225 | |||
226 | lea.l GPIO_OUT_ADDR, %a0 | ||
227 | lea.l GPIO1_OUT_ADDR, %a1 | ||
228 | move.l #DATA_MASK, %d6 | ||
229 | move.l #CLOCK_MASK, %d7 | ||
230 | |||
231 | move.l #~RS_MASK, %d0 | ||
232 | and.l %d0, (%a0) | ||
233 | move.l #~CS_MASK, %d0 | ||
234 | and.l %d0, (%a1) | ||
235 | |||
236 | bsr.w .write_byte | ||
237 | |||
238 | move.l #CS_MASK, %d0 | ||
239 | or.l %d0, (%a1) | ||
240 | |||
241 | movem.l (%sp), %d2-%d3/%d6-%d7 | ||
242 | lea.l (4*4, %sp), %sp | ||
243 | rts | ||
244 | |||
245 | |||
246 | .global lcd_remote_write_command_ex | ||
247 | .type lcd_remote_write_command_ex, @function | ||
248 | |||
249 | lcd_remote_write_command_ex: | ||
250 | lea.l (-4*4, %sp), %sp | ||
251 | movem.l %d2-%d3/%d6-%d7, (%sp) | ||
252 | |||
253 | movem.l (4*4+4, %sp), %d2-%d3 /* cmd, data */ | ||
254 | |||
255 | lea.l GPIO_OUT_ADDR, %a0 | ||
256 | lea.l GPIO1_OUT_ADDR, %a1 | ||
257 | move.l #DATA_MASK, %d6 | ||
258 | move.l #CLOCK_MASK, %d7 | ||
259 | |||
260 | move.l #~RS_MASK, %d0 | ||
261 | and.l %d0, (%a0) | ||
262 | move.l #~CS_MASK, %d0 | ||
263 | and.l %d0, (%a1) | ||
264 | |||
265 | lsl.l #8, %d2 | ||
266 | or.l %d2, %d3 | ||
267 | bsr.w .write_word | ||
268 | |||
269 | move.l #CS_MASK, %d0 | ||
270 | or.l %d0, (%a1) | ||
271 | |||
272 | movem.l (%sp), %d2-%d3/%d6-%d7 | ||
273 | lea.l (4*4, %sp), %sp | ||
274 | rts | ||
275 | |||
276 | |||
277 | .global lcd_remote_write_data | ||
278 | .type lcd_remote_write_data, @function | ||
279 | |||
280 | lcd_remote_write_data: | ||
281 | lea.l (-7*4, %sp), %sp | ||
282 | movem.l %d2-%d4/%d6-%d7/%a2-%a3, (%sp) | ||
283 | |||
284 | move.l (7*4+4, %sp), %a2 /* p_words */ | ||
285 | move.l (7*4+8, %sp), %d4 /* count */ | ||
286 | |||
287 | lea.l GPIO_OUT_ADDR, %a0 | ||
288 | lea.l GPIO1_OUT_ADDR, %a1 | ||
289 | move.l #DATA_MASK, %d6 | ||
290 | move.l #CLOCK_MASK, %d7 | ||
291 | |||
292 | lea.l .write_word, %a3 | ||
293 | move.l cpu_frequency, %d0 | ||
294 | cmp.l #60000000, %d0 | ||
295 | bhi.b 1f | ||
296 | lea.l .write_word_fast, %a3 | ||
297 | 1: | ||
298 | |||
299 | move.l #RS_MASK, %d0 | ||
300 | or.l %d0, (%a0) | ||
301 | move.l #~CS_MASK, %d0 | ||
302 | and.l %d0, (%a1) | ||
303 | |||
304 | .wd_loop: | ||
305 | clr.l %d3 | ||
306 | move.w (%a2)+, %d3 | ||
307 | jsr (%a3) | ||
308 | subq.l #1, %d4 | ||
309 | bne.s .wd_loop | ||
310 | |||
311 | move.l #CS_MASK, %d0 | ||
312 | or.l %d0, (%a1) | ||
313 | |||
314 | movem.l (%sp), %d2-%d4/%d6-%d7/%a2-%a3 | ||
315 | lea.l (7*4, %sp), %sp | ||
316 | rts | ||
diff --git a/firmware/target/coldfire/iaudio/lcd-remote-iaudio.c b/firmware/target/coldfire/iaudio/lcd-remote-iaudio.c index 5a03dc6180..8fa473fbdd 100644 --- a/firmware/target/coldfire/iaudio/lcd-remote-iaudio.c +++ b/firmware/target/coldfire/iaudio/lcd-remote-iaudio.c | |||
@@ -60,234 +60,6 @@ static int cached_contrast = DEFAULT_REMOTE_CONTRAST_SETTING; | |||
60 | bool remote_initialized = false; | 60 | bool remote_initialized = false; |
61 | 61 | ||
62 | 62 | ||
63 | /* Standard low-level byte writer. Requires CLK high on entry */ | ||
64 | static inline void _write_byte(unsigned data) | ||
65 | { | ||
66 | asm volatile ( | ||
67 | "move.l (%[gpo0]), %%d0 \n" /* Get current state of data line */ | ||
68 | "and.l %[dbit], %%d0 \n" | ||
69 | "beq.s 1f \n" /* and set it as previous-state bit */ | ||
70 | "bset #8, %[data] \n" | ||
71 | "1: \n" | ||
72 | "move.l %[data], %%d0 \n" /* Compute the 'bit derivative', i.e. a value */ | ||
73 | "lsr.l #1, %%d0 \n" /* with 1's where the data changes from the */ | ||
74 | "eor.l %%d0, %[data] \n" /* previous state, and 0's where it doesn't */ | ||
75 | "swap %[data] \n" /* Shift data to upper byte */ | ||
76 | "lsl.l #8, %[data] \n" | ||
77 | |||
78 | "move.l %[cbit], %%d1 \n" /* Prepare mask for flipping CLK */ | ||
79 | "or.l %[dbit], %%d1 \n" /* and DATA at once */ | ||
80 | |||
81 | "lsl.l #1,%[data] \n" /* Shift out MSB */ | ||
82 | "bcc.s 1f \n" | ||
83 | "eor.l %%d1, (%[gpo0]) \n" /* 1: Flip both CLK and DATA */ | ||
84 | ".word 0x51fa \n" /* (trapf.w - shadow next insn) */ | ||
85 | "1: \n" | ||
86 | "eor.l %[cbit], (%[gpo0]) \n" /* else flip CLK only */ | ||
87 | "eor.l %[cbit], (%[gpo0]) \n" /* Flip CLK again */ | ||
88 | |||
89 | "lsl.l #1,%[data] \n" /* ..unrolled.. */ | ||
90 | "bcc.s 1f \n" | ||
91 | "eor.l %%d1, (%[gpo0]) \n" | ||
92 | ".word 0x51fa \n" | ||
93 | "1: \n" | ||
94 | "eor.l %[cbit], (%[gpo0]) \n" | ||
95 | "eor.l %[cbit], (%[gpo0]) \n" | ||
96 | |||
97 | "lsl.l #1,%[data] \n" | ||
98 | "bcc.s 1f \n" | ||
99 | "eor.l %%d1, (%[gpo0]) \n" | ||
100 | ".word 0x51fa \n" | ||
101 | "1: \n" | ||
102 | "eor.l %[cbit], (%[gpo0]) \n" | ||
103 | "eor.l %[cbit], (%[gpo0]) \n" | ||
104 | |||
105 | "lsl.l #1,%[data] \n" | ||
106 | "bcc.s 1f \n" | ||
107 | "eor.l %%d1, (%[gpo0]) \n" | ||
108 | ".word 0x51fa \n" | ||
109 | "1: \n" | ||
110 | "eor.l %[cbit], (%[gpo0]) \n" | ||
111 | "eor.l %[cbit], (%[gpo0]) \n" | ||
112 | |||
113 | "lsl.l #1,%[data] \n" | ||
114 | "bcc.s 1f \n" | ||
115 | "eor.l %%d1, (%[gpo0]) \n" | ||
116 | ".word 0x51fa \n" | ||
117 | "1: \n" | ||
118 | "eor.l %[cbit], (%[gpo0]) \n" | ||
119 | "eor.l %[cbit], (%[gpo0]) \n" | ||
120 | |||
121 | "lsl.l #1,%[data] \n" | ||
122 | "bcc.s 1f \n" | ||
123 | "eor.l %%d1, (%[gpo0]) \n" | ||
124 | ".word 0x51fa \n" | ||
125 | "1: \n" | ||
126 | "eor.l %[cbit], (%[gpo0]) \n" | ||
127 | "eor.l %[cbit], (%[gpo0]) \n" | ||
128 | |||
129 | "lsl.l #1,%[data] \n" | ||
130 | "bcc.s 1f \n" | ||
131 | "eor.l %%d1, (%[gpo0]) \n" | ||
132 | ".word 0x51fa \n" | ||
133 | "1: \n" | ||
134 | "eor.l %[cbit], (%[gpo0]) \n" | ||
135 | "eor.l %[cbit], (%[gpo0]) \n" | ||
136 | |||
137 | "lsl.l #1,%[data] \n" | ||
138 | "bcc.s 1f \n" | ||
139 | "eor.l %%d1, (%[gpo0]) \n" | ||
140 | ".word 0x51fa \n" | ||
141 | "1: \n" | ||
142 | "eor.l %[cbit], (%[gpo0]) \n" | ||
143 | "eor.l %[cbit], (%[gpo0]) \n" | ||
144 | : /* outputs */ | ||
145 | [data]"+d"(data) | ||
146 | : /* inputs */ | ||
147 | [gpo0]"a"(&GPIO_OUT), | ||
148 | [cbit]"d"(0x00004000), | ||
149 | [dbit]"d"(0x00002000) | ||
150 | : /* clobbers */ | ||
151 | "d0", "d1" | ||
152 | ); | ||
153 | } | ||
154 | |||
155 | /* Fast low-level byte writer. Don't use with high CPU clock. | ||
156 | * Requires CLK high on entry */ | ||
157 | static inline void _write_fast(unsigned data) | ||
158 | { | ||
159 | asm volatile ( | ||
160 | "move.w %%sr,%%d3 \n" /* Get current interrupt level */ | ||
161 | "move.w #0x2700,%%sr \n" /* Disable interrupts */ | ||
162 | |||
163 | "move.l (%[gpo0]), %%d0 \n" /* Get current state of data port */ | ||
164 | "move.l %%d0, %%d1 \n" | ||
165 | "and.l %[dbit], %%d1 \n" /* Check current state of data line */ | ||
166 | "beq.s 1f \n" /* and set it as previous-state bit */ | ||
167 | "bset #8, %[data] \n" | ||
168 | "1: \n" | ||
169 | "move.l %[data], %%d1 \n" /* Compute the 'bit derivative', i.e. a value */ | ||
170 | "lsr.l #1, %%d1 \n" /* with 1's where the data changes from the */ | ||
171 | "eor.l %%d1, %[data] \n" /* previous state, and 0's where it doesn't */ | ||
172 | "swap %[data] \n" /* Shift data to upper byte */ | ||
173 | "lsl.l #8, %[data] \n" | ||
174 | |||
175 | "move.l %%d0, %%d1 \n" /* precalculate opposite state of clock line */ | ||
176 | "eor.l %[cbit], %%d1 \n" | ||
177 | |||
178 | "lsl.l #1,%[data] \n" /* Shift out MSB */ | ||
179 | "bcc.s 1f \n" | ||
180 | "eor.l %[dbit], %%d0 \n" /* 1: Flip data bit */ | ||
181 | "eor.l %[dbit], %%d1 \n" /* for both clock states */ | ||
182 | "1: \n" | ||
183 | "move.l %%d1, (%[gpo0]) \n" /* Output new state and set CLK */ | ||
184 | "move.l %%d0, (%[gpo0]) \n" /* reset CLK */ | ||
185 | |||
186 | "lsl.l #1,%[data] \n" /* ..unrolled.. */ | ||
187 | "bcc.s 1f \n" | ||
188 | "eor.l %[dbit], %%d0 \n" | ||
189 | "eor.l %[dbit], %%d1 \n" | ||
190 | "1: \n" | ||
191 | "move.l %%d1, (%[gpo0]) \n" | ||
192 | "move.l %%d0, (%[gpo0]) \n" | ||
193 | |||
194 | "lsl.l #1,%[data] \n" | ||
195 | "bcc.s 1f \n" | ||
196 | "eor.l %[dbit], %%d0 \n" | ||
197 | "eor.l %[dbit], %%d1 \n" | ||
198 | "1: \n" | ||
199 | "move.l %%d1, (%[gpo0]) \n" | ||
200 | "move.l %%d0, (%[gpo0]) \n" | ||
201 | |||
202 | "lsl.l #1,%[data] \n" | ||
203 | "bcc.s 1f \n" | ||
204 | "eor.l %[dbit], %%d0 \n" | ||
205 | "eor.l %[dbit], %%d1 \n" | ||
206 | "1: \n" | ||
207 | "move.l %%d1, (%[gpo0]) \n" | ||
208 | "move.l %%d0, (%[gpo0]) \n" | ||
209 | |||
210 | "lsl.l #1,%[data] \n" | ||
211 | "bcc.s 1f \n" | ||
212 | "eor.l %[dbit], %%d0 \n" | ||
213 | "eor.l %[dbit], %%d1 \n" | ||
214 | "1: \n" | ||
215 | "move.l %%d1, (%[gpo0]) \n" | ||
216 | "move.l %%d0, (%[gpo0]) \n" | ||
217 | |||
218 | "lsl.l #1,%[data] \n" | ||
219 | "bcc.s 1f \n" | ||
220 | "eor.l %[dbit], %%d0 \n" | ||
221 | "eor.l %[dbit], %%d1 \n" | ||
222 | "1: \n" | ||
223 | "move.l %%d1, (%[gpo0]) \n" | ||
224 | "move.l %%d0, (%[gpo0]) \n" | ||
225 | |||
226 | "lsl.l #1,%[data] \n" | ||
227 | "bcc.s 1f \n" | ||
228 | "eor.l %[dbit], %%d0 \n" | ||
229 | "eor.l %[dbit], %%d1 \n" | ||
230 | "1: \n" | ||
231 | "move.l %%d1, (%[gpo0]) \n" | ||
232 | "move.l %%d0, (%[gpo0]) \n" | ||
233 | |||
234 | "lsl.l #1,%[data] \n" | ||
235 | "bcc.s 1f \n" | ||
236 | "eor.l %[dbit], %%d0 \n" | ||
237 | "eor.l %[dbit], %%d1 \n" | ||
238 | "1: \n" | ||
239 | "move.l %%d1, (%[gpo0]) \n" | ||
240 | "move.l %%d0, (%[gpo0]) \n" | ||
241 | |||
242 | "move.w %%d3, %%sr \n" /* Restore interrupt level */ | ||
243 | : /* outputs */ | ||
244 | [data]"+d"(data) | ||
245 | : /* inputs */ | ||
246 | [gpo0]"a"(&GPIO_OUT), | ||
247 | [cbit]"d"(0x00004000), | ||
248 | [dbit]"d"(0x00002000) | ||
249 | : /* clobbers */ | ||
250 | "d0", "d1", "d2", "d3" | ||
251 | ); | ||
252 | } | ||
253 | |||
254 | void lcd_remote_write_command(int cmd) | ||
255 | { | ||
256 | RS_LO; | ||
257 | CS_LO; | ||
258 | _write_byte(cmd); | ||
259 | CS_HI; | ||
260 | } | ||
261 | |||
262 | void lcd_remote_write_command_ex(int cmd, int data) | ||
263 | { | ||
264 | RS_LO; | ||
265 | CS_LO; | ||
266 | _write_byte(cmd); | ||
267 | _write_byte(data); | ||
268 | CS_HI; | ||
269 | } | ||
270 | |||
271 | void lcd_remote_write_data(const fb_remote_data *p_words, int count) | ||
272 | { | ||
273 | const unsigned char *p_bytes = (const unsigned char *)p_words; | ||
274 | const unsigned char *p_end = (const unsigned char *)(p_words + count); | ||
275 | |||
276 | RS_HI; | ||
277 | CS_LO; | ||
278 | if (cpu_frequency < 50000000) | ||
279 | { | ||
280 | while (p_bytes < p_end) | ||
281 | _write_fast(*p_bytes++); | ||
282 | } | ||
283 | else | ||
284 | { | ||
285 | while (p_bytes < p_end) | ||
286 | _write_byte(*p_bytes++); | ||
287 | } | ||
288 | CS_HI; | ||
289 | } | ||
290 | |||
291 | int lcd_remote_default_contrast(void) | 63 | int lcd_remote_default_contrast(void) |
292 | { | 64 | { |
293 | return DEFAULT_REMOTE_CONTRAST_SETTING; | 65 | return DEFAULT_REMOTE_CONTRAST_SETTING; |
@@ -350,7 +122,7 @@ void lcd_remote_on(void) | |||
350 | lcd_remote_write_command_ex(LCD_SET_GRAY | 6, 0xcc); | 122 | lcd_remote_write_command_ex(LCD_SET_GRAY | 6, 0xcc); |
351 | lcd_remote_write_command_ex(LCD_SET_GRAY | 7, 0x0c); | 123 | lcd_remote_write_command_ex(LCD_SET_GRAY | 7, 0x0c); |
352 | 124 | ||
353 | lcd_remote_write_command(LCD_SET_PWM_FRC | 6); /* 4FRC + 12PWM */ | 125 | lcd_remote_write_command(LCD_SET_PWM_FRC | 6); /* 3FRC + 12PWM */ |
354 | 126 | ||
355 | lcd_remote_write_command(LCD_DISPLAY_ON | 1); /* display on */ | 127 | lcd_remote_write_command(LCD_DISPLAY_ON | 1); /* display on */ |
356 | 128 | ||
@@ -439,17 +211,18 @@ void lcd_remote_init_device(void) | |||
439 | 211 | ||
440 | /* Update the display. | 212 | /* Update the display. |
441 | This must be called after all other LCD functions that change the display. */ | 213 | This must be called after all other LCD functions that change the display. */ |
442 | void lcd_remote_update(void) ICODE_ATTR; | ||
443 | void lcd_remote_update(void) | 214 | void lcd_remote_update(void) |
444 | { | 215 | { |
445 | int y; | 216 | int y; |
446 | if(remote_initialized) { | 217 | if(remote_initialized) |
447 | for(y = 0;y < LCD_REMOTE_FBHEIGHT;y++) { | 218 | { |
219 | for(y = 0;y < LCD_REMOTE_FBHEIGHT;y++) | ||
220 | { | ||
448 | /* Copy display bitmap to hardware. | 221 | /* Copy display bitmap to hardware. |
449 | The COM48-COM63 lines are not connected so we have to skip | 222 | The COM48-COM63 lines are not connected so we have to skip |
450 | them. Further, the column address doesn't wrap, so we | 223 | them. Further, the column address doesn't wrap, so we |
451 | have to update one page at a time. */ | 224 | have to update one page at a time. */ |
452 | lcd_remote_write_command(LCD_SET_PAGE | (y>5?y+2:y)); | 225 | lcd_remote_write_command(LCD_SET_PAGE | (y > 5 ? y + 2 : y)); |
453 | lcd_remote_write_command_ex(LCD_SET_COLUMN | 0, 0); | 226 | lcd_remote_write_command_ex(LCD_SET_COLUMN | 0, 0); |
454 | lcd_remote_write_data(lcd_remote_framebuffer[y], LCD_REMOTE_WIDTH); | 227 | lcd_remote_write_data(lcd_remote_framebuffer[y], LCD_REMOTE_WIDTH); |
455 | } | 228 | } |
@@ -457,10 +230,10 @@ void lcd_remote_update(void) | |||
457 | } | 230 | } |
458 | 231 | ||
459 | /* Update a fraction of the display. */ | 232 | /* Update a fraction of the display. */ |
460 | void lcd_remote_update_rect(int, int, int, int) ICODE_ATTR; | ||
461 | void lcd_remote_update_rect(int x, int y, int width, int height) | 233 | void lcd_remote_update_rect(int x, int y, int width, int height) |
462 | { | 234 | { |
463 | if(remote_initialized) { | 235 | if(remote_initialized) |
236 | { | ||
464 | int ymax; | 237 | int ymax; |
465 | 238 | ||
466 | /* The Y coordinates have to work on even 8 pixel rows */ | 239 | /* The Y coordinates have to work on even 8 pixel rows */ |
@@ -478,8 +251,8 @@ void lcd_remote_update_rect(int x, int y, int width, int height) | |||
478 | COM48-COM63 are not connected, so we need to skip those */ | 251 | COM48-COM63 are not connected, so we need to skip those */ |
479 | for (; y <= ymax; y++) | 252 | for (; y <= ymax; y++) |
480 | { | 253 | { |
481 | lcd_remote_write_command(LCD_SET_PAGE | | 254 | lcd_remote_write_command(LCD_SET_PAGE |
482 | ((y > 5?y + 2:y) & 0xf)); | 255 | | ((y > 5 ? y + 2 : y) & 0xf)); |
483 | lcd_remote_write_command_ex(LCD_SET_COLUMN | ((x >> 4) & 0xf), | 256 | lcd_remote_write_command_ex(LCD_SET_COLUMN | ((x >> 4) & 0xf), |
484 | x & 0xf); | 257 | x & 0xf); |
485 | 258 | ||
@@ -498,12 +271,16 @@ void lcd_remote_set_invert_display(bool yesno) | |||
498 | void lcd_remote_set_flip(bool yesno) | 271 | void lcd_remote_set_flip(bool yesno) |
499 | { | 272 | { |
500 | cached_flip = yesno; | 273 | cached_flip = yesno; |
501 | if(remote_initialized) { | 274 | if(remote_initialized) |
502 | if(yesno) { | 275 | { |
276 | if(yesno) | ||
277 | { | ||
503 | lcd_remote_write_command(LCD_SELECT_ADC | 0); | 278 | lcd_remote_write_command(LCD_SELECT_ADC | 0); |
504 | lcd_remote_write_command(LCD_SELECT_SHL | 0); | 279 | lcd_remote_write_command(LCD_SELECT_SHL | 0); |
505 | lcd_remote_write_command_ex(LCD_SET_COM0, 16); | 280 | lcd_remote_write_command_ex(LCD_SET_COM0, 16); |
506 | } else { | 281 | } |
282 | else | ||
283 | { | ||
507 | lcd_remote_write_command(LCD_SELECT_ADC | 1); | 284 | lcd_remote_write_command(LCD_SELECT_ADC | 1); |
508 | lcd_remote_write_command(LCD_SELECT_SHL | 8); | 285 | lcd_remote_write_command(LCD_SELECT_SHL | 8); |
509 | lcd_remote_write_command_ex(LCD_SET_COM0, 0); | 286 | lcd_remote_write_command_ex(LCD_SET_COM0, 0); |