summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2008-03-25 23:21:36 +0000
committerJens Arnold <amiconn@rockbox.org>2008-03-25 23:21:36 +0000
commit40919d7db29d036033f57fe6fbf9e3f562e61c0d (patch)
treeb04fa272f6cee51639b7307ee5fcd9b4f9737fde
parent6ceaf321f3aadc804b1daa8fb10607a7ae209351 (diff)
downloadrockbox-40919d7db29d036033f57fe6fbf9e3f562e61c0d.tar.gz
rockbox-40919d7db29d036033f57fe6fbf9e3f562e61c0d.zip
iAudio M3: Optimised LCD driver, with more/better assembly code. Speedup is ~80% when boosted, ~15% when unboosted. Also implemented grey phase blitting. * Adapted the greyscale library, and the plugins using it. * Fixed a bug in greyscale scroll down for vertically packed pixels.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16809 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/SOURCES4
-rw-r--r--apps/plugins/SUBDIRS4
-rw-r--r--apps/plugins/doom/i_video.c10
-rw-r--r--apps/plugins/greyscale.c11
-rw-r--r--apps/plugins/jpeg.c12
-rw-r--r--apps/plugins/lib/SOURCES3
-rw-r--r--apps/plugins/lib/grey.h6
-rw-r--r--apps/plugins/lib/grey_coldfire.S27
-rw-r--r--apps/plugins/lib/grey_core.c87
-rw-r--r--apps/plugins/lib/grey_draw.c8
-rw-r--r--apps/plugins/lib/grey_parm.c4
-rw-r--r--apps/plugins/lib/grey_scroll.c11
-rw-r--r--apps/plugins/mandelbrot.c16
-rw-r--r--apps/plugins/mpegplayer/mpeg_settings.c8
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.c9
-rw-r--r--apps/plugins/plasma.c13
-rw-r--r--apps/plugins/test_fps.c4
-rw-r--r--firmware/SOURCES1
-rw-r--r--firmware/target/coldfire/iaudio/m3/lcd-as-m3.S516
-rw-r--r--firmware/target/coldfire/iaudio/m3/lcd-m3.c305
20 files changed, 744 insertions, 315 deletions
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES
index 23c22f9826..b6603a44c0 100644
--- a/apps/plugins/SOURCES
+++ b/apps/plugins/SOURCES
@@ -46,18 +46,16 @@ flipit.c
46#ifdef HAVE_LCD_BITMAP /* Not for the Player */ 46#ifdef HAVE_LCD_BITMAP /* Not for the Player */
47brickmania.c 47brickmania.c
48maze.c 48maze.c
49mazezam.c 49mazezam.c
50text_editor.c 50text_editor.c
51wavview.c 51wavview.c
52robotfindskitten.c 52robotfindskitten.c
53 53
54/* Plugins needing the grayscale lib on low-depth LCDs */ 54/* Plugins needing the grayscale lib on low-depth LCDs */
55#ifndef IAUDIO_M3 /* FIXME: no greyscale library yet */
56fire.c 55fire.c
57jpeg.c 56jpeg.c
58mandelbrot.c 57mandelbrot.c
59plasma.c 58plasma.c
60#endif
61 59
62blackjack.c 60blackjack.c
63bounce.c 61bounce.c
diff --git a/apps/plugins/SUBDIRS b/apps/plugins/SUBDIRS
index 9bda7c2715..b0bffc73eb 100644
--- a/apps/plugins/SUBDIRS
+++ b/apps/plugins/SUBDIRS
@@ -34,7 +34,7 @@ pacbox
34 34
35/* For all the color targets */ 35/* For all the color targets */
36#if defined(HAVE_LCD_COLOR) || \ 36#if defined(HAVE_LCD_COLOR) || \
37 (LCD_DEPTH == 2) && !defined(ARCHOS_AV300) && !defined(IAUDIO_M3) 37 (LCD_DEPTH == 2) && !defined(ARCHOS_AV300)
38doom 38doom
39#endif 39#endif
40 40
@@ -42,9 +42,7 @@ doom
42#if CONFIG_CODEC == SWCODEC 42#if CONFIG_CODEC == SWCODEC
43midi 43midi
44/* beatbox */ 44/* beatbox */
45#ifndef IAUDIO_M3 /* TODO: no greyscale lib yet */
46mpegplayer 45mpegplayer
47#endif 46#endif
48#endif
49 47
50#endif /* IRIVER_IFP7XX_SERIES */ 48#endif /* IRIVER_IFP7XX_SERIES */
diff --git a/apps/plugins/doom/i_video.c b/apps/plugins/doom/i_video.c
index bc0f204d3b..ce4b670583 100644
--- a/apps/plugins/doom/i_video.c
+++ b/apps/plugins/doom/i_video.c
@@ -235,6 +235,16 @@ void I_ShutdownGraphics(void)
235#define DOOMBUTTON_ESC BUTTON_OFF 235#define DOOMBUTTON_ESC BUTTON_OFF
236#define DOOMBUTTON_ENTER BUTTON_SELECT 236#define DOOMBUTTON_ENTER BUTTON_SELECT
237#define DOOMBUTTON_WEAPON BUTTON_ON 237#define DOOMBUTTON_WEAPON BUTTON_ON
238#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
239#define DOOMBUTTON_ESC BUTTON_RC_REC
240#define DOOMBUTTON_UP BUTTON_RC_VOL_UP
241#define DOOMBUTTON_DOWN BUTTON_RC_VOL_DOWN
242#define DOOMBUTTON_LEFT BUTTON_RC_REW
243#define DOOMBUTTON_RIGHT BUTTON_RC_FF
244#define DOOMBUTTON_OPEN BUTTON_RC_PLAY
245#define DOOMBUTTON_SHOOT BUTTON_RC_MODE
246#define DOOMBUTTON_ENTER BUTTON_RC_PLAY
247#define DOOMBUTTON_WEAPON BUTTON_RC_MENU
238#elif CONFIG_KEYPAD == COWOND2_PAD 248#elif CONFIG_KEYPAD == COWOND2_PAD
239#define DOOMBUTTON_ESC BUTTON_POWER 249#define DOOMBUTTON_ESC BUTTON_POWER
240#define DOOMBUTTON_UP BUTTON_UP 250#define DOOMBUTTON_UP BUTTON_UP
diff --git a/apps/plugins/greyscale.c b/apps/plugins/greyscale.c
index 522a81fc28..42ba08f22e 100644
--- a/apps/plugins/greyscale.c
+++ b/apps/plugins/greyscale.c
@@ -78,6 +78,17 @@ PLUGIN_HEADER
78#define GREYSCALE_LEFT BUTTON_LEFT 78#define GREYSCALE_LEFT BUTTON_LEFT
79#define GREYSCALE_RIGHT BUTTON_RIGHT 79#define GREYSCALE_RIGHT BUTTON_RIGHT
80#define GREYSCALE_OFF BUTTON_EQ 80#define GREYSCALE_OFF BUTTON_EQ
81
82#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
83#define GREYSCALE_SHIFT BUTTON_RC_PLAY /* somewhat dangerous... */
84#define GREYSCALE_UP BUTTON_RC_VOL_UP
85#define GREYSCALE_DOWN BUTTON_RC_VOL_DOWN
86#define GREYSCALE_LEFT BUTTON_RC_REW
87#define GREYSCALE_RIGHT BUTTON_RC_FF
88#define GREYSCALE_OFF BUTTON_RC_REC
89
90#define GREYSCALE_RC_OFF BUTTON_REC
91
81#endif 92#endif
82 93
83#define GFX_HEIGHT (LCD_HEIGHT-8) 94#define GFX_HEIGHT (LCD_HEIGHT-8)
diff --git a/apps/plugins/jpeg.c b/apps/plugins/jpeg.c
index e2c1b4861b..f128558c5a 100644
--- a/apps/plugins/jpeg.c
+++ b/apps/plugins/jpeg.c
@@ -198,6 +198,18 @@ PLUGIN_HEADER
198#define JPEG_NEXT (BUTTON_DISPLAY | BUTTON_RIGHT) 198#define JPEG_NEXT (BUTTON_DISPLAY | BUTTON_RIGHT)
199#define JPEG_PREVIOUS (BUTTON_DISPLAY | BUTTON_LEFT) 199#define JPEG_PREVIOUS (BUTTON_DISPLAY | BUTTON_LEFT)
200 200
201#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
202#define JPEG_ZOOM_PRE BUTTON_RC_PLAY
203#define JPEG_ZOOM_IN (BUTTON_RC_PLAY|BUTTON_REL)
204#define JPEG_ZOOM_OUT (BUTTON_RC_PLAY|BUTTON_REPEAT)
205#define JPEG_UP BUTTON_RC_VOL_UP
206#define JPEG_DOWN BUTTON_RC_VOL_DOWN
207#define JPEG_LEFT BUTTON_RC_REW
208#define JPEG_RIGHT BUTTON_RC_FF
209#define JPEG_MENU BUTTON_RC_REC
210#define JPEG_NEXT BUTTON_RC_MODE
211#define JPEG_PREVIOUS BUTTON_RC_MENU
212
201#elif CONFIG_KEYPAD == COWOND2_PAD 213#elif CONFIG_KEYPAD == COWOND2_PAD
202#define JPEG_ZOOM_IN BUTTON_PLUS 214#define JPEG_ZOOM_IN BUTTON_PLUS
203#define JPEG_ZOOM_OUT BUTTON_MINUS 215#define JPEG_ZOOM_OUT BUTTON_MINUS
diff --git a/apps/plugins/lib/SOURCES b/apps/plugins/lib/SOURCES
index f1aded6122..6a44c80ffa 100644
--- a/apps/plugins/lib/SOURCES
+++ b/apps/plugins/lib/SOURCES
@@ -3,8 +3,7 @@ configfile.c
3fixedpoint.c 3fixedpoint.c
4playback_control.c 4playback_control.c
5rgb_hsv.c 5rgb_hsv.c
6#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) \ 6#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4)
7 && !defined(IAUDIO_M3) /* TODO: Test whether it can be implemented */
8grey_core.c 7grey_core.c
9grey_draw.c 8grey_draw.c
10grey_parm.c 9grey_parm.c
diff --git a/apps/plugins/lib/grey.h b/apps/plugins/lib/grey.h
index ce37e17829..4298ae3ada 100644
--- a/apps/plugins/lib/grey.h
+++ b/apps/plugins/lib/grey.h
@@ -134,8 +134,8 @@ void grey_ub_scroll_down(int count);
134 134
135#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 135#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
136#define _GREY_BSHIFT 0 136#define _GREY_BSHIFT 0
137#else 137#else /* vertical packing or vertical interleaved */
138#if LCD_DEPTH == 1 138#if (LCD_DEPTH == 1) || (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)
139#define _GREY_BSHIFT 3 139#define _GREY_BSHIFT 3
140#elif LCD_DEPTH == 2 140#elif LCD_DEPTH == 2
141#define _GREY_BSHIFT 2 141#define _GREY_BSHIFT 2
@@ -155,7 +155,7 @@ struct _grey_info
155#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 155#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
156 int bx; /* 8-pixel units */ 156 int bx; /* 8-pixel units */
157 int bwidth; /* 8-pixel units */ 157 int bwidth; /* 8-pixel units */
158#else /* vertical packing */ 158#else /* vertical packing or vertical interleaved */
159 int by; /* 4-pixel or 8-pixel units */ 159 int by; /* 4-pixel or 8-pixel units */
160 int bheight; /* 4-pixel or 8-pixel units */ 160 int bheight; /* 4-pixel or 8-pixel units */
161#endif 161#endif
diff --git a/apps/plugins/lib/grey_coldfire.S b/apps/plugins/lib/grey_coldfire.S
index 39df087a85..a040193956 100644
--- a/apps/plugins/lib/grey_coldfire.S
+++ b/apps/plugins/lib/grey_coldfire.S
@@ -31,7 +31,14 @@
31 .global _grey_line1 31 .global _grey_line1
32 .type _grey_line1, @function 32 .type _grey_line1, @function
33 33
34#if (LCD_PIXELFORMAT == VERTICAL_PACKING) && (LCD_DEPTH == 2) 34#if (LCD_PIXELFORMAT == VERTICAL_PACKING) \
35 || (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)
36
37#if (LCD_DEPTH == 1) || (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)
38#define GREY_BSIZE 8
39#elif LCD_DEPTH == 2
40#define GREY_BSIZE 4
41#endif
35 42
36/**************************************************************************** 43/****************************************************************************
37 * void _grey_line1(int width, 44 * void _grey_line1(int width,
@@ -52,7 +59,7 @@ _grey_line1:
52 59
53 move.b (%a1)+, %d0 60 move.b (%a1)+, %d0
54 move.b (%d0.l, %a2), (%a0) 61 move.b (%d0.l, %a2), (%a0)
55 addq.l #4, %a0 62 addq.l #GREY_BSIZE, %a0
56 subq.l #1, %d2 63 subq.l #1, %d2
57.p1_h_end: 64.p1_h_end:
58 65
@@ -66,10 +73,10 @@ _grey_line1:
66 move.w %d1, %d0 73 move.w %d1, %d0
67 lsr.l #8, %d0 74 lsr.l #8, %d0
68 move.b (%d0.l, %a2), (%a0) 75 move.b (%d0.l, %a2), (%a0)
69 addq.l #4, %a0 76 addq.l #GREY_BSIZE, %a0
70 move.b %d1, %d0 77 move.b %d1, %d0
71 move.b (%d0.l, %a2), (%a0) 78 move.b (%d0.l, %a2), (%a0)
72 addq.l #4, %a0 79 addq.l #GREY_BSIZE, %a0
73 subq.l #2, %d2 80 subq.l #2, %d2
74.p2_h_end: 81.p2_h_end:
75 82
@@ -82,18 +89,18 @@ _grey_line1:
82 move.w %d1, %d0 89 move.w %d1, %d0
83 lsr.l #8, %d0 90 lsr.l #8, %d0
84 move.b (%d0.l, %a2), (%a0) 91 move.b (%d0.l, %a2), (%a0)
85 addq.l #4, %a0 92 addq.l #GREY_BSIZE, %a0
86 move.b %d1, %d0 93 move.b %d1, %d0
87 move.b (%d0.l, %a2), (%a0) 94 move.b (%d0.l, %a2), (%a0)
88 addq.l #4, %a0 95 addq.l #GREY_BSIZE, %a0
89 swap %d1 96 swap %d1
90 move.w %d1, %d0 97 move.w %d1, %d0
91 lsr.l #8, %d0 98 lsr.l #8, %d0
92 move.b (%d0.l, %a2), (%a0) 99 move.b (%d0.l, %a2), (%a0)
93 addq.l #4, %a0 100 addq.l #GREY_BSIZE, %a0
94 move.b %d1, %d0 101 move.b %d1, %d0
95 move.b (%d0.l, %a2), (%a0) 102 move.b (%d0.l, %a2), (%a0)
96 addq.l #4, %a0 103 addq.l #GREY_BSIZE, %a0
97 subq.l #4, %d2 104 subq.l #4, %d2
98 bhs.s .p4_loop 105 bhs.s .p4_loop
99 106
@@ -107,10 +114,10 @@ _grey_line1:
107 move.w %d1, %d0 114 move.w %d1, %d0
108 lsr.l #8, %d0 115 lsr.l #8, %d0
109 move.b (%d0.l, %a2), (%a0) 116 move.b (%d0.l, %a2), (%a0)
110 addq.l #4, %a0 117 addq.l #GREY_BSIZE, %a0
111 move.b %d1, %d0 118 move.b %d1, %d0
112 move.b (%d0.l, %a2), (%a0) 119 move.b (%d0.l, %a2), (%a0)
113 addq.l #4, %a0 120 addq.l #GREY_BSIZE, %a0
114.p2_t_end: 121.p2_t_end:
115 122
116 btst.l #0, %d2 123 btst.l #0, %d2
diff --git a/apps/plugins/lib/grey_core.c b/apps/plugins/lib/grey_core.c
index caa7af2f25..8a30faa5f8 100644
--- a/apps/plugins/lib/grey_core.c
+++ b/apps/plugins/lib/grey_core.c
@@ -26,7 +26,8 @@
26#include "plugin.h" 26#include "plugin.h"
27#include "grey.h" 27#include "grey.h"
28 28
29#if defined(CPU_PP) && defined(HAVE_ADJUSTABLE_CPU_FREQ) 29#if defined(HAVE_ADJUSTABLE_CPU_FREQ) && \
30 (defined(CPU_PP) || (CONFIG_LCD == LCD_TL0350A))
30#define NEED_BOOST 31#define NEED_BOOST
31#endif 32#endif
32 33
@@ -143,6 +144,42 @@ static const unsigned char lcdlinear[256] = {
143 203, 206, 209, 212, 215, 219, 222, 226, 144 203, 206, 209, 212, 215, 219, 222, 226,
144 229, 233, 236, 240, 244, 248, 251, 255 145 229, 233, 236, 240, 244, 248, 251, 255
145}; 146};
147#elif CONFIG_LCD == LCD_TL0350A
148/* measured and interpolated curve for iaudio remote */
149static const unsigned char lcdlinear[256] = {
150 5, 9, 13, 17, 21, 25, 29, 33,
151 36, 39, 42, 45, 48, 51, 54, 57,
152 60, 62, 65, 67, 70, 72, 75, 77,
153 80, 82, 84, 86, 87, 89, 91, 93,
154 94, 95, 96, 97, 97, 98, 99, 99,
155 100, 100, 101, 102, 103, 103, 104, 105,
156 106, 106, 107, 108, 108, 109, 110, 111,
157 112, 112, 113, 113, 114, 114, 115, 115,
158 116, 116, 117, 117, 118, 118, 119, 119,
159 120, 120, 121, 121, 122, 122, 123, 123,
160 124, 124, 124, 125, 125, 126, 126, 126,
161 127, 127, 127, 128, 128, 129, 129, 129,
162 130, 130, 131, 131, 132, 132, 133, 133,
163 134, 134, 135, 135, 136, 136, 137, 137,
164 138, 138, 139, 139, 140, 140, 141, 141,
165 142, 142, 143, 143, 144, 144, 145, 145,
166 146, 146, 147, 147, 148, 149, 149, 150,
167 151, 151, 152, 152, 153, 154, 154, 155,
168 156, 156, 157, 157, 158, 159, 159, 160,
169 161, 161, 162, 163, 164, 164, 165, 166,
170 167, 167, 168, 169, 170, 170, 171, 172,
171 173, 173, 174, 175, 176, 176, 177, 178,
172 179, 179, 180, 181, 182, 182, 183, 184,
173 185, 186, 187, 188, 188, 189, 191, 191,
174 192, 193, 194, 195, 195, 196, 197, 198,
175 199, 200, 201, 202, 203, 204, 205, 206,
176 207, 208, 209, 210, 211, 212, 213, 214,
177 215, 216, 217, 218, 219, 220, 222, 223,
178 224, 225, 226, 227, 228, 229, 230, 231,
179 232, 233, 234, 235, 236, 237, 238, 239,
180 240, 240, 241, 242, 243, 243, 244, 245,
181 246, 246, 247, 248, 249, 250, 251, 252
182};
146#endif 183#endif
147#else /* SIMULATOR */ 184#else /* SIMULATOR */
148/* undo a (generic) PC display gamma of 2.0 to simulate target behaviour */ 185/* undo a (generic) PC display gamma of 2.0 to simulate target behaviour */
@@ -225,7 +262,7 @@ static unsigned long _grey_get_pixel(int x, int y)
225 int yg = y - _grey_info.y; 262 int yg = y - _grey_info.y;
226#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 263#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
227 int idx = _grey_info.width * yg + xg; 264 int idx = _grey_info.width * yg + xg;
228#else 265#else /* vertical packing or vertical interleaved */
229 int idx = _grey_info.width * (yg & ~_GREY_BMASK) 266 int idx = _grey_info.width * (yg & ~_GREY_BMASK)
230 + (xg << _GREY_BSHIFT) + (~yg & _GREY_BMASK); 267 + (xg << _GREY_BSHIFT) + (~yg & _GREY_BMASK);
231#endif 268#endif
@@ -243,7 +280,7 @@ static void _timer_isr(void)
243 _grey_info.bx, _grey_info.y, 280 _grey_info.bx, _grey_info.y,
244 _grey_info.bwidth, _grey_info.height, 281 _grey_info.bwidth, _grey_info.height,
245 _grey_info.width); 282 _grey_info.width);
246#else 283#else /* vertical packing or vertical interleaved */
247 _grey_info.rb->lcd_blit_grey_phase(_grey_info.values, _grey_info.phases, 284 _grey_info.rb->lcd_blit_grey_phase(_grey_info.values, _grey_info.phases,
248 _grey_info.x, _grey_info.by, 285 _grey_info.x, _grey_info.by,
249 _grey_info.width, _grey_info.bheight, 286 _grey_info.width, _grey_info.bheight,
@@ -355,8 +392,8 @@ bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
355#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 392#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
356 bdim = (width + 7) >> 3; 393 bdim = (width + 7) >> 3;
357 width = bdim << 3; 394 width = bdim << 3;
358#else /* vertical packing */ 395#else /* vertical packing or vertical interleaved */
359#if LCD_DEPTH == 1 396#if (LCD_DEPTH == 1) || (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)
360 bdim = (height + 7) >> 3; 397 bdim = (height + 7) >> 3;
361 height = bdim << 3; 398 height = bdim << 3;
362#elif LCD_DEPTH == 2 399#elif LCD_DEPTH == 2
@@ -408,7 +445,7 @@ bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
408#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 445#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
409 _grey_info.bx = 0; 446 _grey_info.bx = 0;
410 _grey_info.bwidth = bdim; 447 _grey_info.bwidth = bdim;
411#else 448#else /* vertical packing or vertical interleaved */
412 _grey_info.by = 0; 449 _grey_info.by = 0;
413 _grey_info.bheight = bdim; 450 _grey_info.bheight = bdim;
414#endif 451#endif
@@ -491,6 +528,9 @@ void grey_show(bool enable)
491 _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 83, 1, _timer_isr); 528 _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 83, 1, _timer_isr);
492#elif CONFIG_LCD == LCD_MROBE100 529#elif CONFIG_LCD == LCD_MROBE100
493 _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 83, 1, _timer_isr); /* not calibrated/tested */ 530 _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 83, 1, _timer_isr); /* not calibrated/tested */
531#elif CONFIG_LCD == LCD_TL0350A
532 _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / 75, 1, _timer_isr); /* verified */
533 /* This is half of the actual frame frequency, but 150Hz is too much */
494#endif /* CONFIG_LCD */ 534#endif /* CONFIG_LCD */
495#endif /* !SIMULATOR */ 535#endif /* !SIMULATOR */
496 _grey_info.rb->screen_dump_set_hook(grey_screendump_hook); 536 _grey_info.rb->screen_dump_set_hook(grey_screendump_hook);
@@ -607,8 +647,11 @@ static void grey_screendump_hook(int fd)
607#elif LCD_DEPTH == 2 647#elif LCD_DEPTH == 2
608 int shift; 648 int shift;
609#endif 649#endif
610#endif /* LCD_PIXELFORMAT == VERTICAL_PACKING */ 650#elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED
611 unsigned char *lcdptr; 651 unsigned data;
652 int shift;
653#endif /* LCD_PIXELFORMAT */
654 fb_data *lcdptr;
612 unsigned char *clut_entry; 655 unsigned char *clut_entry;
613 unsigned char linebuf[MAX(4*BMP_VARCOLORS,BMP_LINESIZE)]; 656 unsigned char linebuf[MAX(4*BMP_VARCOLORS,BMP_LINESIZE)];
614 657
@@ -660,7 +703,7 @@ static void grey_screendump_hook(int fd)
660 lcdptr++; 703 lcdptr++;
661 } 704 }
662#endif /* LCD_DEPTH */ 705#endif /* LCD_DEPTH */
663#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */ 706#elif LCD_PIXELFORMAT == VERTICAL_PACKING
664#if LCD_DEPTH == 1 707#if LCD_DEPTH == 1
665 mask = 1 << (y & 7); 708 mask = 1 << (y & 7);
666 lcdptr = _grey_info.rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3); 709 lcdptr = _grey_info.rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3);
@@ -708,6 +751,32 @@ static void grey_screendump_hook(int fd)
708 lcdptr++; 751 lcdptr++;
709 } 752 }
710#endif /* LCD_DEPTH */ 753#endif /* LCD_DEPTH */
754#elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED
755#if LCD_DEPTH == 2
756 shift = y & 7;
757 lcdptr = _grey_info.rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3);
758
759 for (x = 0; x < LCD_WIDTH; x++)
760 {
761 gx = x - _grey_info.x;
762
763 if (((unsigned)gy < (unsigned)_grey_info.height)
764 && ((unsigned)gx < (unsigned)_grey_info.width))
765 {
766 linebuf[x] = BMP_FIXEDCOLORS
767 + _grey_info.values[_GREY_MULUQ(_grey_info.width,
768 gy & ~_GREY_BMASK)
769 + (gx << _GREY_BSHIFT)
770 + (~gy & _GREY_BMASK)];
771 }
772 else
773 {
774 data = (*lcdptr >> shift) & 0x0101;
775 linebuf[x] = ((data >> 7) | data) & 3;
776 }
777 lcdptr++;
778 }
779#endif /* LCD_DEPTH */
711#endif /* LCD_PIXELFORMAT */ 780#endif /* LCD_PIXELFORMAT */
712 781
713 _grey_info.rb->write(fd, linebuf, BMP_LINESIZE); 782 _grey_info.rb->write(fd, linebuf, BMP_LINESIZE);
diff --git a/apps/plugins/lib/grey_draw.c b/apps/plugins/lib/grey_draw.c
index 7b24ba4c70..6c2508327b 100644
--- a/apps/plugins/lib/grey_draw.c
+++ b/apps/plugins/lib/grey_draw.c
@@ -630,14 +630,14 @@ void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
630 { 630 {
631#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 631#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
632 int idx = _GREY_MULUQ(_grey_info.width, yc); 632 int idx = _GREY_MULUQ(_grey_info.width, yc);
633#else 633#else /* vertical packing or vertical interleaved */
634 int idx = _GREY_MULUQ(_grey_info.width, yc & ~_GREY_BMASK) 634 int idx = _GREY_MULUQ(_grey_info.width, yc & ~_GREY_BMASK)
635 + (~yc & _GREY_BMASK); 635 + (~yc & _GREY_BMASK);
636#endif /* LCD_PIXELFORMAT */ 636#endif /* LCD_PIXELFORMAT */
637 637
638#if (LCD_PIXELFORMAT == VERTICAL_PACKING) && \ 638#if ((LCD_PIXELFORMAT == VERTICAL_PACKING) && (LCD_DEPTH == 1) && (CONFIG_CPU == SH7034)) \
639 ((LCD_DEPTH == 2) && defined(CPU_COLDFIRE) \ 639 || ((LCD_PIXELFORMAT == VERTICAL_PACKING) && (LCD_DEPTH == 2) && defined(CPU_COLDFIRE)) \
640 || (LCD_DEPTH == 1) && (CONFIG_CPU == SH7034)) 640 || ((LCD_PIXELFORMAT == VERTICAL_INTERLEAVED) && defined(CPU_COLDFIRE))
641 _grey_line1(width, dst + idx, src, _grey_info.gvalue); 641 _grey_line1(width, dst + idx, src, _grey_info.gvalue);
642#else 642#else
643 unsigned char *dst_row = dst + idx; 643 unsigned char *dst_row = dst + idx;
diff --git a/apps/plugins/lib/grey_parm.c b/apps/plugins/lib/grey_parm.c
index 63d09dfd72..e4aaec3efd 100644
--- a/apps/plugins/lib/grey_parm.c
+++ b/apps/plugins/lib/grey_parm.c
@@ -34,8 +34,8 @@ void grey_set_position(int x, int y)
34#if LCD_PIXELFORMAT == HORIZONTAL_PACKING 34#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
35 _grey_info.bx = (x + 4) >> 3; 35 _grey_info.bx = (x + 4) >> 3;
36 x = 8 * _grey_info.bx; 36 x = 8 * _grey_info.bx;
37#else 37#else /* vertical packing or vertical interleaved */
38#if LCD_DEPTH == 1 38#if (LCD_DEPTH == 1) || (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)
39 _grey_info.by = (y + 4) >> 3; 39 _grey_info.by = (y + 4) >> 3;
40 y = 8 * _grey_info.by; 40 y = 8 * _grey_info.by;
41#elif LCD_DEPTH == 2 41#elif LCD_DEPTH == 2
diff --git a/apps/plugins/lib/grey_scroll.c b/apps/plugins/lib/grey_scroll.c
index 12a27daf23..56021d149a 100644
--- a/apps/plugins/lib/grey_scroll.c
+++ b/apps/plugins/lib/grey_scroll.c
@@ -191,7 +191,8 @@ void grey_ub_scroll_up(int count)
191 _grey_info.fg_brightness : 191 _grey_info.fg_brightness :
192 _grey_info.bg_brightness]; 192 _grey_info.bg_brightness];
193 193
194#if LCD_PIXELFORMAT == VERTICAL_PACKING 194#if (LCD_PIXELFORMAT == VERTICAL_PACKING) \
195 || (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)
195 if (count & _GREY_BMASK) 196 if (count & _GREY_BMASK)
196 { 197 {
197 /* Scrolling by fractional blocks - move pixel wise. */ 198 /* Scrolling by fractional blocks - move pixel wise. */
@@ -262,7 +263,8 @@ void grey_ub_scroll_down(int count)
262 _grey_info.fg_brightness : 263 _grey_info.fg_brightness :
263 _grey_info.bg_brightness]; 264 _grey_info.bg_brightness];
264 265
265#if LCD_PIXELFORMAT == VERTICAL_PACKING 266#if (LCD_PIXELFORMAT == VERTICAL_PACKING) \
267 || (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)
266 if (count & _GREY_BMASK) 268 if (count & _GREY_BMASK)
267 { 269 {
268 /* Scrolling by fractional blocks - move pixel wise. */ 270 /* Scrolling by fractional blocks - move pixel wise. */
@@ -302,6 +304,9 @@ void grey_ub_scroll_down(int count)
302 } 304 }
303 while (dst < line_end); 305 while (dst < line_end);
304 } 306 }
307 /* Top pixel in a block has the highest address, but dst must point
308 * to the lowest address in that block for the subsequent fill. */
309 dst -= _GREY_BMASK;
305 } 310 }
306 else 311 else
307#endif 312#endif
@@ -311,7 +316,7 @@ void grey_ub_scroll_down(int count)
311 dst -= blen; 316 dst -= blen;
312 _grey_info.rb->memmove(dst, start, blen); 317 _grey_info.rb->memmove(dst, start, blen);
313 } 318 }
314 _grey_info.rb->memset(start, blank, dst - start); 319 _grey_info.rb->memset(start, blank, dst - start);
315 /* Fill remainder at once. */ 320 /* Fill remainder at once. */
316#ifdef SIMULATOR 321#ifdef SIMULATOR
317 _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, 322 _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y,
diff --git a/apps/plugins/mandelbrot.c b/apps/plugins/mandelbrot.c
index 26ec3e4ab9..4a4872b827 100644
--- a/apps/plugins/mandelbrot.c
+++ b/apps/plugins/mandelbrot.c
@@ -202,6 +202,22 @@ PLUGIN_HEADER
202#define MANDELBROT_MAXITER_DEC BUTTON_PLAY 202#define MANDELBROT_MAXITER_DEC BUTTON_PLAY
203#define MANDELBROT_RESET BUTTON_DISPLAY 203#define MANDELBROT_RESET BUTTON_DISPLAY
204 204
205#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
206#define MANDELBROT_QUIT BUTTON_RC_REC
207#define MANDELBROT_UP BUTTON_RC_VOL_UP
208#define MANDELBROT_DOWN BUTTON_RC_VOL_DOWN
209#define MANDELBROT_LEFT BUTTON_RC_REW
210#define MANDELBROT_RIGHT BUTTON_RC_FF
211#define MANDELBROT_ZOOM_IN_PRE BUTTON_RC_PLAY
212#define MANDELBROT_ZOOM_IN (BUTTON_RC_PLAY | BUTTON_REL)
213#define MANDELBROT_ZOOM_OUT_PRE BUTTON_RC_PLAY
214#define MANDELBROT_ZOOM_OUT (BUTTON_RC_PLAY | BUTTON_REPEAT)
215#define MANDELBROT_MAXITER_INC_PRE BUTTON_RC_MODE
216#define MANDELBROT_MAXITER_INC (BUTTON_RC_MODE|BUTTON_REL)
217#define MANDELBROT_MAXITER_DEC_PRE BUTTON_RC_MODE
218#define MANDELBROT_MAXITER_DEC (BUTTON_RC_MODE|BUTTON_REPEAT)
219#define MANDELBROT_RESET BUTTON_RC_MENU
220
205#elif CONFIG_KEYPAD == COWOND2_PAD 221#elif CONFIG_KEYPAD == COWOND2_PAD
206#define MANDELBROT_QUIT BUTTON_POWER 222#define MANDELBROT_QUIT BUTTON_POWER
207#define MANDELBROT_UP BUTTON_UP 223#define MANDELBROT_UP BUTTON_UP
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c
index 7dfdd36927..b7b7def729 100644
--- a/apps/plugins/mpegplayer/mpeg_settings.c
+++ b/apps/plugins/mpegplayer/mpeg_settings.c
@@ -102,6 +102,14 @@ struct mpeg_settings settings;
102#define MPEG_START_TIME_SCROLL_UP BUTTON_PLAY 102#define MPEG_START_TIME_SCROLL_UP BUTTON_PLAY
103#define MPEG_START_TIME_EXIT BUTTON_POWER 103#define MPEG_START_TIME_EXIT BUTTON_POWER
104 104
105#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
106#define MPEG_START_TIME_SELECT BUTTON_RC_PLAY
107#define MPEG_START_TIME_LEFT BUTTON_RC_REW
108#define MPEG_START_TIME_RIGHT BUTTON_RC_FF
109#define MPEG_START_TIME_UP BUTTON_RC_VOL_UP
110#define MPEG_START_TIME_DOWN BUTTON_RC_VOL_DOWN
111#define MPEG_START_TIME_EXIT BUTTON_RC_REC
112
105#elif CONFIG_KEYPAD == COWOND2_PAD 113#elif CONFIG_KEYPAD == COWOND2_PAD
106#define MPEG_START_TIME_SELECT BUTTON_SELECT 114#define MPEG_START_TIME_SELECT BUTTON_SELECT
107#define MPEG_START_TIME_SCROLL_UP BUTTON_PLUS 115#define MPEG_START_TIME_SCROLL_UP BUTTON_PLUS
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c
index d068fd8254..8a947904a3 100644
--- a/apps/plugins/mpegplayer/mpegplayer.c
+++ b/apps/plugins/mpegplayer/mpegplayer.c
@@ -202,6 +202,15 @@ PLUGIN_IRAM_DECLARE
202#define MPEG_RW BUTTON_LEFT 202#define MPEG_RW BUTTON_LEFT
203#define MPEG_FF BUTTON_RIGHT 203#define MPEG_FF BUTTON_RIGHT
204 204
205#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
206#define MPEG_MENU BUTTON_RC_MENU
207#define MPEG_STOP BUTTON_RC_REC
208#define MPEG_PAUSE BUTTON_RC_PLAY
209#define MPEG_VOLDOWN BUTTON_RC_VOL_DOWN
210#define MPEG_VOLUP BUTTON_RC_VOL_UP
211#define MPEG_RW BUTTON_RC_REW
212#define MPEG_FF BUTTON_RC_FF
213
205#elif CONFIG_KEYPAD == COWOND2_PAD 214#elif CONFIG_KEYPAD == COWOND2_PAD
206#define MPEG_MENU BUTTON_MENU 215#define MPEG_MENU BUTTON_MENU
207#define MPEG_STOP BUTTON_POWER 216#define MPEG_STOP BUTTON_POWER
diff --git a/apps/plugins/plasma.c b/apps/plugins/plasma.c
index d5c1ef427f..2e04bd59b5 100644
--- a/apps/plugins/plasma.c
+++ b/apps/plugins/plasma.c
@@ -59,6 +59,7 @@ static int plasma_frequency;
59#define PLASMA_QUIT BUTTON_MENU 59#define PLASMA_QUIT BUTTON_MENU
60#define PLASMA_INCREASE_FREQUENCY BUTTON_SCROLL_FWD 60#define PLASMA_INCREASE_FREQUENCY BUTTON_SCROLL_FWD
61#define PLASMA_DECREASE_FREQUENCY BUTTON_SCROLL_BACK 61#define PLASMA_DECREASE_FREQUENCY BUTTON_SCROLL_BACK
62
62#elif (CONFIG_KEYPAD == GIGABEAT_PAD) 63#elif (CONFIG_KEYPAD == GIGABEAT_PAD)
63#define PLASMA_QUIT BUTTON_A 64#define PLASMA_QUIT BUTTON_A
64#define PLASMA_INCREASE_FREQUENCY BUTTON_UP 65#define PLASMA_INCREASE_FREQUENCY BUTTON_UP
@@ -74,26 +75,38 @@ static int plasma_frequency;
74#define PLASMA_QUIT BUTTON_POWER 75#define PLASMA_QUIT BUTTON_POWER
75#define PLASMA_INCREASE_FREQUENCY BUTTON_UP 76#define PLASMA_INCREASE_FREQUENCY BUTTON_UP
76#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN 77#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN
78
77#elif (CONFIG_KEYPAD == IRIVER_H10_PAD) 79#elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
78#define PLASMA_QUIT BUTTON_POWER 80#define PLASMA_QUIT BUTTON_POWER
79#define PLASMA_INCREASE_FREQUENCY BUTTON_SCROLL_UP 81#define PLASMA_INCREASE_FREQUENCY BUTTON_SCROLL_UP
80#define PLASMA_DECREASE_FREQUENCY BUTTON_SCROLL_DOWN 82#define PLASMA_DECREASE_FREQUENCY BUTTON_SCROLL_DOWN
83
81#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) 84#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
82#define PLASMA_QUIT BUTTON_BACK 85#define PLASMA_QUIT BUTTON_BACK
83#define PLASMA_INCREASE_FREQUENCY BUTTON_UP 86#define PLASMA_INCREASE_FREQUENCY BUTTON_UP
84#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN 87#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN
88
85#elif (CONFIG_KEYPAD == MROBE100_PAD) 89#elif (CONFIG_KEYPAD == MROBE100_PAD)
86#define PLASMA_QUIT BUTTON_POWER 90#define PLASMA_QUIT BUTTON_POWER
87#define PLASMA_INCREASE_FREQUENCY BUTTON_UP 91#define PLASMA_INCREASE_FREQUENCY BUTTON_UP
88#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN 92#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN
93
94#elif (CONFIG_KEYPAD == IAUDIO_M3_PAD)
95#define PLASMA_QUIT BUTTON_RC_REC
96#define PLASMA_INCREASE_FREQUENCY BUTTON_RC_VOL_UP
97#define PLASMA_DECREASE_FREQUENCY BUTTON_RC_VOL_DOWN
98#define PLASMA_RC_QUIT BUTTON_REC
99
89#elif (CONFIG_KEYPAD == COWOND2_PAD) 100#elif (CONFIG_KEYPAD == COWOND2_PAD)
90#define PLASMA_QUIT BUTTON_POWER 101#define PLASMA_QUIT BUTTON_POWER
91#define PLASMA_INCREASE_FREQUENCY BUTTON_UP 102#define PLASMA_INCREASE_FREQUENCY BUTTON_UP
92#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN 103#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN
104
93#else 105#else
94#define PLASMA_QUIT BUTTON_OFF 106#define PLASMA_QUIT BUTTON_OFF
95#define PLASMA_INCREASE_FREQUENCY BUTTON_UP 107#define PLASMA_INCREASE_FREQUENCY BUTTON_UP
96#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN 108#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN
109
97#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) 110#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
98#define PLASMA_RC_QUIT BUTTON_RC_STOP 111#define PLASMA_RC_QUIT BUTTON_RC_STOP
99#endif 112#endif
diff --git a/apps/plugins/test_fps.c b/apps/plugins/test_fps.c
index 7c86fabdc0..a312c13662 100644
--- a/apps/plugins/test_fps.c
+++ b/apps/plugins/test_fps.c
@@ -260,7 +260,7 @@ static void time_remote_update(void)
260} 260}
261#endif 261#endif
262 262
263#if (LCD_DEPTH < 4) && !defined(IAUDIO_M3) 263#if LCD_DEPTH < 4
264 264
265GREY_INFO_STRUCT_IRAM 265GREY_INFO_STRUCT_IRAM
266static unsigned char greydata[LCD_HEIGHT][LCD_WIDTH]; 266static unsigned char greydata[LCD_HEIGHT][LCD_WIDTH];
@@ -357,7 +357,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
357 log_text("Main LCD YUV"); 357 log_text("Main LCD YUV");
358 time_main_yuv(); 358 time_main_yuv();
359#endif 359#endif
360#if (LCD_DEPTH < 4) && !defined(IAUDIO_M3) 360#if LCD_DEPTH < 4
361 log_text("Greyscale library"); 361 log_text("Greyscale library");
362 time_greyscale(); 362 time_greyscale();
363#endif 363#endif
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 0a8ac2a8e3..1d60ea1016 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -513,6 +513,7 @@ target/coldfire/iaudio/m3/backlight-m3.c
513target/coldfire/iaudio/m3/button-m3.c 513target/coldfire/iaudio/m3/button-m3.c
514target/coldfire/iaudio/m3/fmradio_i2c-m3.c 514target/coldfire/iaudio/m3/fmradio_i2c-m3.c
515target/coldfire/iaudio/m3/lcd-m3.c 515target/coldfire/iaudio/m3/lcd-m3.c
516target/coldfire/iaudio/m3/lcd-as-m3.S
516target/coldfire/iaudio/m3/power-m3.c 517target/coldfire/iaudio/m3/power-m3.c
517target/coldfire/iaudio/m3/powermgmt-m3.c 518target/coldfire/iaudio/m3/powermgmt-m3.c
518target/coldfire/iaudio/m3/system-m3.c 519target/coldfire/iaudio/m3/system-m3.c
diff --git a/firmware/target/coldfire/iaudio/m3/lcd-as-m3.S b/firmware/target/coldfire/iaudio/m3/lcd-as-m3.S
new file mode 100644
index 0000000000..5f77e01e86
--- /dev/null
+++ b/firmware/target/coldfire/iaudio/m3/lcd-as-m3.S
@@ -0,0 +1,516 @@
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 0x20000000
21#define DATA_MASK 0x04000000
22#define GPIO_OUT_ADDR 0x80000004
23
24#define CS_MASK 0x00010000
25#define RS_MASK 0x00001000
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
531:
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 */
651:
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
931:
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 */
1041:
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
1141:
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
1781:
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 */
1921:
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_write_command
218 .type lcd_write_command, @function
219
220lcd_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+CS_MASK), %d0
232 and.l %d0, (%a1)
233
234 bsr.w .write_byte
235
236 move.l #CS_MASK, %d0
237 or.l %d0, (%a1)
238
239 movem.l (%sp), %d2-%d3/%d6-%d7
240 lea.l (4*4, %sp), %sp
241 rts
242
243
244 .global lcd_write_command_e
245 .type lcd_write_command_e, @function
246
247lcd_write_command_e:
248 lea.l (-4*4, %sp), %sp
249 movem.l %d2-%d3/%d6-%d7, (%sp)
250
251 movem.l (4*4+4, %sp), %d2-%d3 /* cmd, data */
252
253 lea.l GPIO_OUT_ADDR, %a0
254 lea.l GPIO1_OUT_ADDR, %a1
255 move.l #DATA_MASK, %d6
256 move.l #CLOCK_MASK, %d7
257
258 move.l #~(RS_MASK+CS_MASK), %d0
259 and.l %d0, (%a1)
260
261 lsl.l #8, %d2
262 or.l %d2, %d3
263 bsr.w .write_word
264
265 move.l #CS_MASK, %d0
266 or.l %d0, (%a1)
267
268 movem.l (%sp), %d2-%d3/%d6-%d7
269 lea.l (4*4, %sp), %sp
270 rts
271
272
273 .global lcd_write_data
274 .type lcd_write_data, @function
275
276lcd_write_data:
277 lea.l (-7*4, %sp), %sp
278 movem.l %d2-%d4/%d6-%d7/%a2-%a3, (%sp)
279
280 move.l (7*4+4, %sp), %a2 /* p_words */
281 move.l (7*4+8, %sp), %d4 /* count */
282
283 lea.l GPIO_OUT_ADDR, %a0
284 lea.l GPIO1_OUT_ADDR, %a1
285 move.l #DATA_MASK, %d6
286 move.l #CLOCK_MASK, %d7
287
288 lea.l .write_word, %a3
289 move.l cpu_frequency, %d0
290 cmp.l #60000000, %d0
291 bhi.b 1f
292 lea.l .write_word_fast, %a3
2931:
294
295 move.l #RS_MASK, %d0
296 or.l %d0, (%a1)
297 move.l #~CS_MASK, %d0
298 and.l %d0, (%a1)
299
300.wd_loop:
301 clr.l %d3
302 move.w (%a2)+, %d3
303 jsr (%a3)
304 subq.l #1, %d4
305 bne.s .wd_loop
306
307 move.l #CS_MASK, %d0
308 or.l %d0, (%a1)
309
310 movem.l (%sp), %d2-%d4/%d6-%d7/%a2-%a3
311 lea.l (7*4, %sp), %sp
312 rts
313
314
315/*** The following functions are only needed for main LCDs ***/
316
317
318 .global lcd_mono_data
319 .type lcd_mono_data, @function
320
321lcd_mono_data:
322 lea.l (-7*4, %sp), %sp
323 movem.l %d2-%d4/%d6-%d7/%a2-%a3, (%sp)
324
325 move.l (7*4+4, %sp), %a2 /* p_bytes */
326 move.l (7*4+8, %sp), %d4 /* count */
327
328 lea.l GPIO_OUT_ADDR, %a0
329 lea.l GPIO1_OUT_ADDR, %a1
330 move.l #DATA_MASK, %d6
331 move.l #CLOCK_MASK, %d7
332
333 lea.l .write_word, %a3
334 move.l cpu_frequency, %d0
335 cmp.l #60000000, %d0
336 bhi.b 1f
337 lea.l .write_word_fast, %a3
3381:
339
340 move.l #RS_MASK, %d0
341 or.l %d0, (%a1)
342 move.l #~CS_MASK, %d0
343 and.l %d0, (%a1)
344
345.md_loop:
346 clr.l %d3
347 move.b (%a2)+, %d3
348 move.l %d3, %d2
349 lsl.l #8, %d2
350 or.l %d2, %d3
351 jsr (%a3)
352 subq.l #1, %d4
353 bne.s .md_loop
354
355 move.l #CS_MASK, %d0
356 or.l %d0, (%a1)
357
358 movem.l (%sp), %d2-%d4/%d6-%d7/%a2-%a3
359 lea.l (7*4, %sp), %sp
360 rts
361
362
363 .global lcd_grey_data
364 .type lcd_grey_data,@function
365
366lcd_grey_data:
367 lea.l (-9*4, %sp), %sp
368 movem.l %d2-%d7/%a2-%a4, (%sp)
369
370 movem.l (9*4+4, %sp), %a2-%a4 /* values, phases, length */
371 add.l %a4, %a4
372 lea.l (%a3, %a4.l*4), %a4 /* end address */
373
374 lea.l GPIO_OUT_ADDR, %a0
375 lea.l GPIO1_OUT_ADDR, %a1
376 move.l #DATA_MASK, %d6
377 move.l #CLOCK_MASK, %d7
378
379 move.l #RS_MASK, %d0
380 or.l %d0, (%a1)
381 move.l #~CS_MASK, %d0
382 and.l %d0, (%a1)
383
384 clr.l %d5
385 move.l (%a3), %d4 /* fetch 4 pixel phases */
386 bclr.l #31, %d4 /* Z = !(p0 & 0x80); p0 &= ~0x80; */
387 seq.b %d5 /* %d5 = ........................00000000 */
388 lsl.l #1, %d5 /* %d5 = .......................00000000. */
389 bclr.l #23, %d4 /* Z = !(p1 & 0x80); p1 &= ~0x80; */
390 seq.b %d5 /* %d5 = .......................011111111 */
391 lsl.l #1, %d5 /* %d5 = ......................011111111. */
392 bclr.l #15, %d4 /* Z = !(p2 & 0x80); p2 &= ~0x80; */
393 seq.b %d5 /* %d5 = ......................0122222222 */
394 lsl.l #1, %d5 /* %d5 = .....................0122222222. */
395 bclr.l #7, %d4 /* Z = !(p3 & 0x80); p3 &= ~0x80; */
396 seq.b %d5 /* %d5 = .....................01233333333 */
397 lsl.l #1, %d5 /* %d5 = ....................01233333333. */
398 add.l (%a2)+, %d4 /* add 4 pixel values to the phases */
399 move.l %d4, (%a3)+ /* store new phases, advance pointer */
400
401 move.l (%a3), %d4 /* fetch 4 pixel phases */
402 bclr.l #31, %d4 /* Z = !(p0 & 0x80); p0 &= ~0x80; */
403 seq.b %d5 /* %d5 = ....................012344444444 */
404 lsl.l #1, %d5 /* %d5 = ...................012344444444. */
405 bclr.l #23, %d4 /* Z = !(p1 & 0x80); p1 &= ~0x80; */
406 seq.b %d5 /* %d5 = ...................0123455555555 */
407 lsl.l #1, %d5 /* %d5 = ..................0123455555555. */
408 bclr.l #15, %d4 /* Z = !(p2 & 0x80); p2 &= ~0x80; */
409 seq.b %d5 /* %d5 = ..................01234566666666 */
410 lsl.l #1, %d5 /* %d5 = .................01234566666666. */
411 bclr.l #7, %d4 /* Z = !(p3 & 0x80); p3 &= ~0x80; */
412 seq.b %d5 /* %d5 = .................012345677777777 */
413 lsr.l #7, %d5 /* %d5 = ........................01234567 */
414 add.l (%a2)+, %d4 /* add 4 pixel values to the phases */
415 move.l %d4, (%a3)+ /* store new phases, advance pointer */
416
417 move.l %d5, %d3
418 lsl.l #8, %d3
419 or.l %d5, %d3
420
421 cmp.l %a3, %a4
422 bls.w .gd_last
423
424.gd_loop:
425 move.w %sr, %d2
426 move.w #0x2700, %sr
427
428 move.l (%a0), %d0 /* Get current state of data port */
429 move.l %d0, %d1
430 and.l %d6, %d1 /* Check current state of data line */
431 beq.s 1f /* and set it as previous-state bit */
432 bset #16, %d3
4331:
434 move.l %d3, %d1 /* Compute the 'bit derivative', i.e. a value */
435 lsr.l #1, %d1 /* with 1's where the data changes from the */
436 eor.l %d1, %d3 /* previous state, and 0's where it doesn't */
437 swap %d3 /* Shift data to upper word */
438
439 eor.l %d7, %d0 /* precalculate opposite state of clock line */
440
441 lsl.l #1,%d3 /* Shift out MSB */
442 bcc.s 1f
443 eor.l %d6, %d0 /* 1: Flip data bit */
4441:
445 move.l %d0, %d1
446 move.l %d0, (%a0) /* Output new state and set CLK = 0*/
447 eor.l %d7, %d1
448
449 move.l (%a3), %d4 /* fetch 4 pixel phases */
450 bit_out
451 bclr.l #31, %d4 /* Z = !(p0 & 0x80); p0 &= ~0x80; */
452 seq.b %d5 /* %d5 = ........................00000000 */
453 lsl.l #1, %d5 /* %d5 = .......................00000000. */
454 bit_out
455 bclr.l #23, %d4 /* Z = !(p1 & 0x80); p1 &= ~0x80; */
456 seq.b %d5 /* %d5 = .......................011111111 */
457 lsl.l #1, %d5 /* %d5 = ......................011111111. */
458 bit_out
459 bclr.l #15, %d4 /* Z = !(p2 & 0x80); p2 &= ~0x80; */
460 seq.b %d5 /* %d5 = ......................0122222222 */
461 lsl.l #1, %d5 /* %d5 = .....................0122222222. */
462 bit_out
463 bclr.l #7, %d4 /* Z = !(p3 & 0x80); p3 &= ~0x80; */
464 seq.b %d5 /* %d5 = .....................01233333333 */
465 lsl.l #1, %d5 /* %d5 = ....................01233333333. */
466 bit_out
467 add.l (%a2)+, %d4 /* add 4 pixel values to the phases */
468 bit_out
469 move.l %d4, (%a3)+ /* store new phases, advance pointer */
470
471 bit_out
472 move.l (%a3), %d4 /* fetch 4 pixel phases */
473 bit_out
474 bclr.l #31, %d4 /* Z = !(p0 & 0x80); p0 &= ~0x80; */
475 seq.b %d5 /* %d5 = ....................012344444444 */
476 lsl.l #1, %d5 /* %d5 = ...................012344444444. */
477 bit_out
478 bclr.l #23, %d4 /* Z = !(p1 & 0x80); p1 &= ~0x80; */
479 seq.b %d5 /* %d5 = ...................0123455555555 */
480 lsl.l #1, %d5 /* %d5 = ..................0123455555555. */
481 bit_out
482 bclr.l #15, %d4 /* Z = !(p2 & 0x80); p2 &= ~0x80; */
483 seq.b %d5 /* %d5 = ..................01234566666666 */
484 lsl.l #1, %d5 /* %d5 = .................01234566666666. */
485 bit_out
486 bclr.l #7, %d4 /* Z = !(p3 & 0x80); p3 &= ~0x80; */
487 seq.b %d5 /* %d5 = .................012345677777777 */
488 lsr.l #7, %d5 /* %d5 = ........................01234567 */
489 bit_out
490 add.l (%a2)+, %d4 /* add 4 pixel values to the phases */
491 bit_out
492 move.l %d4, (%a3)+ /* store new phases, advance pointer */
493
494 bit_out
495 nop
496 bit_out
497 move.l %d5, %d3
498 lsl.l #8, %d3
499 or.l %d5, %d3
500
501 nop
502 move.l %d1, (%a0) /* Set CLK = 1 (delayed) */
503 move.w %d2, %sr
504
505 cmp.l %a3, %a4
506 bhi.w .gd_loop
507
508.gd_last:
509 bsr.w .write_word
510
511 move.l #CS_MASK, %d0
512 or.l %d0, (%a1)
513
514 movem.l (%sp), %d2-%d7/%a2-%a4
515 lea.l (9*4, %sp), %sp
516 rts
diff --git a/firmware/target/coldfire/iaudio/m3/lcd-m3.c b/firmware/target/coldfire/iaudio/m3/lcd-m3.c
index ae72832a82..81f19bd73f 100644
--- a/firmware/target/coldfire/iaudio/m3/lcd-m3.c
+++ b/firmware/target/coldfire/iaudio/m3/lcd-m3.c
@@ -61,263 +61,6 @@ static int cached_contrast = DEFAULT_CONTRAST_SETTING;
61bool initialized = false; 61bool initialized = false;
62 62
63 63
64/* Standard low-level byte writer. Requires CLK high on entry */
65static inline void _write_byte(unsigned data)
66{
67 asm volatile (
68 "move.l (%[gpo0]), %%d0 \n" /* Get current state of data line */
69 "and.l %[dbit], %%d0 \n"
70 "beq.s 1f \n" /* and set it as previous-state bit */
71 "bset #8, %[data] \n"
72 "1: \n"
73 "move.l %[data], %%d0 \n" /* Compute the 'bit derivative', i.e. a value */
74 "lsr.l #1, %%d0 \n" /* with 1's where the data changes from the */
75 "eor.l %%d0, %[data] \n" /* previous state, and 0's where it doesn't */
76 "swap %[data] \n" /* Shift data to upper byte */
77 "lsl.l #8, %[data] \n"
78
79 "move.l %[cbit], %%d1 \n" /* Prepare mask for flipping CLK */
80 "or.l %[dbit], %%d1 \n" /* and DATA at once */
81
82 "lsl.l #1,%[data] \n" /* Shift out MSB */
83 "bcc.s 1f \n"
84 "eor.l %%d1, (%[gpo0]) \n" /* 1: Flip both CLK and DATA */
85 ".word 0x51fa \n" /* (trapf.w - shadow next insn) */
86 "1: \n"
87 "eor.l %[cbit], (%[gpo0]) \n" /* else flip CLK only */
88 "eor.l %[cbit], (%[gpo0]) \n" /* Flip CLK again */
89
90 "lsl.l #1,%[data] \n" /* ..unrolled.. */
91 "bcc.s 1f \n"
92 "eor.l %%d1, (%[gpo0]) \n"
93 ".word 0x51fa \n"
94 "1: \n"
95 "eor.l %[cbit], (%[gpo0]) \n"
96 "eor.l %[cbit], (%[gpo0]) \n"
97
98 "lsl.l #1,%[data] \n"
99 "bcc.s 1f \n"
100 "eor.l %%d1, (%[gpo0]) \n"
101 ".word 0x51fa \n"
102 "1: \n"
103 "eor.l %[cbit], (%[gpo0]) \n"
104 "eor.l %[cbit], (%[gpo0]) \n"
105
106 "lsl.l #1,%[data] \n"
107 "bcc.s 1f \n"
108 "eor.l %%d1, (%[gpo0]) \n"
109 ".word 0x51fa \n"
110 "1: \n"
111 "eor.l %[cbit], (%[gpo0]) \n"
112 "eor.l %[cbit], (%[gpo0]) \n"
113
114 "lsl.l #1,%[data] \n"
115 "bcc.s 1f \n"
116 "eor.l %%d1, (%[gpo0]) \n"
117 ".word 0x51fa \n"
118 "1: \n"
119 "eor.l %[cbit], (%[gpo0]) \n"
120 "eor.l %[cbit], (%[gpo0]) \n"
121
122 "lsl.l #1,%[data] \n"
123 "bcc.s 1f \n"
124 "eor.l %%d1, (%[gpo0]) \n"
125 ".word 0x51fa \n"
126 "1: \n"
127 "eor.l %[cbit], (%[gpo0]) \n"
128 "eor.l %[cbit], (%[gpo0]) \n"
129
130 "lsl.l #1,%[data] \n"
131 "bcc.s 1f \n"
132 "eor.l %%d1, (%[gpo0]) \n"
133 ".word 0x51fa \n"
134 "1: \n"
135 "eor.l %[cbit], (%[gpo0]) \n"
136 "eor.l %[cbit], (%[gpo0]) \n"
137
138 "lsl.l #1,%[data] \n"
139 "bcc.s 1f \n"
140 "eor.l %%d1, (%[gpo0]) \n"
141 ".word 0x51fa \n"
142 "1: \n"
143 "eor.l %[cbit], (%[gpo0]) \n"
144 "eor.l %[cbit], (%[gpo0]) \n"
145 : /* outputs */
146 [data]"+d"(data)
147 : /* inputs */
148 [gpo0]"a"(&GPIO_OUT),
149 [cbit]"d"(0x20000000),
150 [dbit]"d"(0x04000000)
151 : /* clobbers */
152 "d0", "d1"
153 );
154}
155
156/* Fast low-level byte writer. Don't use with high CPU clock.
157 * Requires CLK high on entry */
158static inline void _write_fast(unsigned data)
159{
160 asm volatile (
161 "move.w %%sr,%%d3 \n" /* Get current interrupt level */
162 "move.w #0x2700,%%sr \n" /* Disable interrupts */
163
164 "move.l (%[gpo0]), %%d0 \n" /* Get current state of data port */
165 "move.l %%d0, %%d1 \n"
166 "and.l %[dbit], %%d1 \n" /* Check current state of data line */
167 "beq.s 1f \n" /* and set it as previous-state bit */
168 "bset #8, %[data] \n"
169 "1: \n"
170 "move.l %[data], %%d1 \n" /* Compute the 'bit derivative', i.e. a value */
171 "lsr.l #1, %%d1 \n" /* with 1's where the data changes from the */
172 "eor.l %%d1, %[data] \n" /* previous state, and 0's where it doesn't */
173 "swap %[data] \n" /* Shift data to upper byte */
174 "lsl.l #8, %[data] \n"
175
176 "move.l %%d0, %%d1 \n" /* precalculate opposite state of clock line */
177 "eor.l %[cbit], %%d1 \n"
178
179 "lsl.l #1,%[data] \n" /* Shift out MSB */
180 "bcc.s 1f \n"
181 "eor.l %[dbit], %%d0 \n" /* 1: Flip data bit */
182 "eor.l %[dbit], %%d1 \n" /* for both clock states */
183 "1: \n"
184 "move.l %%d1, (%[gpo0]) \n" /* Output new state and set CLK */
185 "move.l %%d0, (%[gpo0]) \n" /* reset CLK */
186
187 "lsl.l #1,%[data] \n" /* ..unrolled.. */
188 "bcc.s 1f \n"
189 "eor.l %[dbit], %%d0 \n"
190 "eor.l %[dbit], %%d1 \n"
191 "1: \n"
192 "move.l %%d1, (%[gpo0]) \n"
193 "move.l %%d0, (%[gpo0]) \n"
194
195 "lsl.l #1,%[data] \n"
196 "bcc.s 1f \n"
197 "eor.l %[dbit], %%d0 \n"
198 "eor.l %[dbit], %%d1 \n"
199 "1: \n"
200 "move.l %%d1, (%[gpo0]) \n"
201 "move.l %%d0, (%[gpo0]) \n"
202
203 "lsl.l #1,%[data] \n"
204 "bcc.s 1f \n"
205 "eor.l %[dbit], %%d0 \n"
206 "eor.l %[dbit], %%d1 \n"
207 "1: \n"
208 "move.l %%d1, (%[gpo0]) \n"
209 "move.l %%d0, (%[gpo0]) \n"
210
211 "lsl.l #1,%[data] \n"
212 "bcc.s 1f \n"
213 "eor.l %[dbit], %%d0 \n"
214 "eor.l %[dbit], %%d1 \n"
215 "1: \n"
216 "move.l %%d1, (%[gpo0]) \n"
217 "move.l %%d0, (%[gpo0]) \n"
218
219 "lsl.l #1,%[data] \n"
220 "bcc.s 1f \n"
221 "eor.l %[dbit], %%d0 \n"
222 "eor.l %[dbit], %%d1 \n"
223 "1: \n"
224 "move.l %%d1, (%[gpo0]) \n"
225 "move.l %%d0, (%[gpo0]) \n"
226
227 "lsl.l #1,%[data] \n"
228 "bcc.s 1f \n"
229 "eor.l %[dbit], %%d0 \n"
230 "eor.l %[dbit], %%d1 \n"
231 "1: \n"
232 "move.l %%d1, (%[gpo0]) \n"
233 "move.l %%d0, (%[gpo0]) \n"
234
235 "lsl.l #1,%[data] \n"
236 "bcc.s 1f \n"
237 "eor.l %[dbit], %%d0 \n"
238 "eor.l %[dbit], %%d1 \n"
239 "1: \n"
240 "move.l %%d1, (%[gpo0]) \n"
241 "move.l %%d0, (%[gpo0]) \n"
242
243 "move.w %%d3, %%sr \n" /* Restore interrupt level */
244 : /* outputs */
245 [data]"+d"(data)
246 : /* inputs */
247 [gpo0]"a"(&GPIO_OUT),
248 [cbit]"d"(0x20000000),
249 [dbit]"d"(0x04000000)
250 : /* clobbers */
251 "d0", "d1", "d2", "d3"
252 );
253}
254
255void lcd_write_command(int cmd)
256{
257 RS_LO;
258 CS_LO;
259 _write_byte(cmd);
260 CS_HI;
261}
262
263void lcd_write_command_e(int cmd, int data)
264{
265 RS_LO;
266 CS_LO;
267 _write_byte(cmd);
268 _write_byte(data);
269 CS_HI;
270}
271
272void lcd_write_data(const fb_data *p_words, int count)
273{
274 const unsigned char *p_bytes = (const unsigned char *)p_words;
275 const unsigned char *p_end = (const unsigned char *)(p_words + count);
276
277 RS_HI;
278 CS_LO;
279 if (cpu_frequency < 50000000)
280 {
281 while (p_bytes < p_end)
282 _write_fast(*p_bytes++);
283 }
284 else
285 {
286 while (p_bytes < p_end)
287 _write_byte(*p_bytes++);
288 }
289 CS_HI;
290}
291
292static void lcd_mono_data(const unsigned char *p_words, int count)
293{
294 unsigned data;
295 const unsigned char *p_bytes = p_words;
296 const unsigned char *p_end = p_words + count;
297
298 RS_HI;
299 CS_LO;
300 if (cpu_frequency < 50000000)
301 {
302 while (p_bytes < p_end)
303 {
304 data = *p_bytes++;
305 _write_fast(data);
306 _write_fast(data);
307 }
308 }
309 else
310 {
311 while (p_bytes < p_end)
312 {
313 data = *p_bytes++;
314 _write_byte(data);
315 _write_byte(data);
316 }
317 }
318 CS_HI;
319}
320
321int lcd_default_contrast(void) 64int lcd_default_contrast(void)
322{ 65{
323 return DEFAULT_CONTRAST_SETTING; 66 return DEFAULT_CONTRAST_SETTING;
@@ -457,6 +200,9 @@ void lcd_init_device(void)
457#endif 200#endif
458} 201}
459 202
203/* Helper function. */
204void lcd_mono_data(const unsigned char *data, int count);
205
460/* Performance function that works with an external buffer 206/* Performance function that works with an external buffer
461 note that by and bheight are in 8-pixel units! */ 207 note that by and bheight are in 8-pixel units! */
462void lcd_blit_mono(const unsigned char *data, int x, int by, int width, 208void lcd_blit_mono(const unsigned char *data, int x, int by, int width,
@@ -477,36 +223,44 @@ void lcd_blit_mono(const unsigned char *data, int x, int by, int width,
477 } 223 }
478} 224}
479 225
480/* TODO: implement grey blit function */ 226/* Helper function for lcd_grey_phase_blit(). */
227void lcd_grey_data(unsigned char *values, unsigned char *phases, int count);
481 228
482/* Performance function that works with an external buffer 229/* Performance function that works with an external buffer
483 note that by and bheight are in 8-pixel units! */ 230 note that by and bheight are in 8-pixel units! */
484void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases, 231void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases,
485 int x, int by, int width, int bheight, int stride) 232 int x, int by, int width, int bheight, int stride)
486{ 233{
487 (void)values; 234 if (initialized)
488 (void)phases; 235 {
489 (void)x; 236 stride <<= 3; /* 8 pixels per block */
490 (void)by; 237 while (bheight--)
491 (void)width; 238 {
492 (void)bheight; 239 lcd_write_command(LCD_SET_PAGE | ((by > 5 ? by + 2 : by) & 0xf));
493 (void)stride; 240 lcd_write_command_e(LCD_SET_COLUMN | ((x >> 4) & 0xf), x & 0xf);
241
242 lcd_grey_data(values, phases, width);
243 values += stride;
244 phases += stride;
245 by++;
246 }
247 }
494} 248}
495 249
496/* Update the display. 250/* Update the display.
497 This must be called after all other LCD functions that change the display. */ 251 This must be called after all other LCD functions that change the display. */
498void lcd_update(void) ICODE_ATTR;
499void lcd_update(void) 252void lcd_update(void)
500{ 253{
501 int y; 254 int y;
502 if (initialized) 255 if (initialized)
503 { 256 {
504 for(y = 0;y < LCD_FBHEIGHT;y++) { 257 for(y = 0;y < LCD_FBHEIGHT;y++)
258 {
505 /* Copy display bitmap to hardware. 259 /* Copy display bitmap to hardware.
506 The COM48-COM63 lines are not connected so we have to skip 260 The COM48-COM63 lines are not connected so we have to skip
507 them. Further, the column address doesn't wrap, so we 261 them. Further, the column address doesn't wrap, so we
508 have to update one page at a time. */ 262 have to update one page at a time. */
509 lcd_write_command(LCD_SET_PAGE | (y>5?y+2:y)); 263 lcd_write_command(LCD_SET_PAGE | (y > 5 ? y + 2 : y));
510 lcd_write_command_e(LCD_SET_COLUMN | 0, 0); 264 lcd_write_command_e(LCD_SET_COLUMN | 0, 0);
511 lcd_write_data(lcd_framebuffer[y], LCD_WIDTH); 265 lcd_write_data(lcd_framebuffer[y], LCD_WIDTH);
512 } 266 }
@@ -514,7 +268,6 @@ void lcd_update(void)
514} 268}
515 269
516/* Update a fraction of the display. */ 270/* Update a fraction of the display. */
517void lcd_update_rect(int, int, int, int) ICODE_ATTR;
518void lcd_update_rect(int x, int y, int width, int height) 271void lcd_update_rect(int x, int y, int width, int height)
519{ 272{
520 if (initialized) 273 if (initialized)
@@ -536,7 +289,7 @@ void lcd_update_rect(int x, int y, int width, int height)
536 COM48-COM63 are not connected, so we need to skip those */ 289 COM48-COM63 are not connected, so we need to skip those */
537 for (; y <= ymax; y++) 290 for (; y <= ymax; y++)
538 { 291 {
539 lcd_write_command(LCD_SET_PAGE | ((y > 5?y + 2:y) & 0xf)); 292 lcd_write_command(LCD_SET_PAGE | ((y > 5 ? y + 2 : y) & 0xf));
540 lcd_write_command_e(LCD_SET_COLUMN | ((x >> 4) & 0xf), x & 0xf); 293 lcd_write_command_e(LCD_SET_COLUMN | ((x >> 4) & 0xf), x & 0xf);
541 294
542 lcd_write_data(&lcd_framebuffer[y][x], width); 295 lcd_write_data(&lcd_framebuffer[y][x], width);
@@ -547,19 +300,23 @@ void lcd_update_rect(int x, int y, int width, int height)
547void lcd_set_invert_display(bool yesno) 300void lcd_set_invert_display(bool yesno)
548{ 301{
549 cached_invert = yesno; 302 cached_invert = yesno;
550 if(initialized) 303 if (initialized)
551 lcd_write_command(LCD_REVERSE | yesno); 304 lcd_write_command(LCD_REVERSE | yesno);
552} 305}
553 306
554void lcd_set_flip(bool yesno) 307void lcd_set_flip(bool yesno)
555{ 308{
556 cached_flip = yesno; 309 cached_flip = yesno;
557 if(initialized) { 310 if (initialized)
558 if(yesno) { 311 {
312 if(yesno)
313 {
559 lcd_write_command(LCD_SELECT_ADC | 0); 314 lcd_write_command(LCD_SELECT_ADC | 0);
560 lcd_write_command(LCD_SELECT_SHL | 0); 315 lcd_write_command(LCD_SELECT_SHL | 0);
561 lcd_write_command_e(LCD_SET_COM0, 16); 316 lcd_write_command_e(LCD_SET_COM0, 16);
562 } else { 317 }
318 else
319 {
563 lcd_write_command(LCD_SELECT_ADC | 1); 320 lcd_write_command(LCD_SELECT_ADC | 1);
564 lcd_write_command(LCD_SELECT_SHL | 8); 321 lcd_write_command(LCD_SELECT_SHL | 8);
565 lcd_write_command_e(LCD_SET_COM0, 0); 322 lcd_write_command_e(LCD_SET_COM0, 0);