diff options
author | Jens Arnold <amiconn@rockbox.org> | 2007-03-26 07:52:13 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2007-03-26 07:52:13 +0000 |
commit | ad4e3d665734b14a28f1ba5fa874663772dab3e7 (patch) | |
tree | bff44652495f1319a4d11ed63b3d4e90cb11197f /firmware/target/sh | |
parent | 165f62d0cd771660e4b8d2ba7475e14d0d6f2e9f (diff) | |
download | rockbox-ad4e3d665734b14a28f1ba5fa874663772dab3e7.tar.gz rockbox-ad4e3d665734b14a28f1ba5fa874663772dab3e7.zip |
First step of charcell LCD code rework: * Make it fully unicode aware so that adding non-ISO8859-1 scripts becomes possible (limited by the LCD capabilities of course). * Make the API more similar to the bitmap LCD code's API. * Moved hardware dependent parts to target tree. * Simplified code. * Jumpscroll temporarily non-functional.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12916 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/sh')
-rw-r--r-- | firmware/target/sh/archos/player/lcd-player.c | 235 |
1 files changed, 235 insertions, 0 deletions
diff --git a/firmware/target/sh/archos/player/lcd-player.c b/firmware/target/sh/archos/player/lcd-player.c new file mode 100644 index 0000000000..7018b2277a --- /dev/null +++ b/firmware/target/sh/archos/player/lcd-player.c | |||
@@ -0,0 +1,235 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: lcd-player.c 12835 2007-03-18 17:58:49Z amiconn $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Jens Arnold | ||
11 | * Based on the work of Alan Korr, Kjell Ericson and others | ||
12 | * | ||
13 | * All files in this archive are subject to the GNU General Public License. | ||
14 | * See the file COPYING in the source tree root for full license agreement. | ||
15 | * | ||
16 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
17 | * KIND, either express or implied. | ||
18 | * | ||
19 | ****************************************************************************/ | ||
20 | |||
21 | #include "config.h" | ||
22 | #include <string.h> | ||
23 | #include "hwcompat.h" | ||
24 | #include "system.h" | ||
25 | #include "lcd.h" | ||
26 | |||
27 | #define OLD_LCD_CRAM ((char)0xB0) /* Characters */ | ||
28 | #define OLD_LCD_PRAM ((char)0x80) /* Patterns */ | ||
29 | #define OLD_LCD_IRAM ((char)0xE0) /* Icons */ | ||
30 | #define OLD_LCD_CONTRAST_SET ((char)0xA8) | ||
31 | |||
32 | #define NEW_LCD_CRAM ((char)0x80) /* Characters */ | ||
33 | #define NEW_LCD_PRAM ((char)0xC0) /* Patterns */ | ||
34 | #define NEW_LCD_IRAM ((char)0x40) /* Icons */ | ||
35 | #define NEW_LCD_CONTRAST_SET ((char)0x50) | ||
36 | #define NEW_LCD_FUNCTION_SET ((char)0x10) | ||
37 | #define NEW_LCD_POWER_SAVE_MODE_OSC_CONTROL_SET ((char)0x0c) | ||
38 | #define NEW_LCD_POWER_CONTROL_REGISTER_SET ((char)0x20) | ||
39 | #define NEW_LCD_DISPLAY_CONTROL_SET ((char)0x28) | ||
40 | #define NEW_LCD_SET_DOUBLE_HEIGHT ((char)0x08) | ||
41 | |||
42 | #define LCD_CURSOR(x,y) ((char)(lcd_cram+((y)*16+(x)))) | ||
43 | #define LCD_ICON(i) ((char)(lcd_iram+i)) | ||
44 | |||
45 | static bool new_lcd; | ||
46 | static char lcd_contrast_set; | ||
47 | static char lcd_cram; | ||
48 | static char lcd_pram; | ||
49 | static char lcd_iram; | ||
50 | |||
51 | /* hardware configuration */ | ||
52 | |||
53 | int lcd_default_contrast(void) | ||
54 | { | ||
55 | return 30; | ||
56 | } | ||
57 | |||
58 | void lcd_set_contrast(int val) | ||
59 | { | ||
60 | lcd_write_command_e(lcd_contrast_set, 31 - val); | ||
61 | } | ||
62 | |||
63 | /* charcell specific */ | ||
64 | |||
65 | void lcd_double_height(bool on) | ||
66 | { | ||
67 | if(new_lcd) | ||
68 | lcd_write_command(on ? (NEW_LCD_SET_DOUBLE_HEIGHT|1) | ||
69 | : NEW_LCD_SET_DOUBLE_HEIGHT); | ||
70 | } | ||
71 | |||
72 | void lcd_put_hw_char(int x, int y, unsigned char hw_char) | ||
73 | { | ||
74 | lcd_write_command_e(LCD_CURSOR(x, y), hw_char); | ||
75 | } | ||
76 | |||
77 | void lcd_define_hw_pattern (int which, const char *pattern) | ||
78 | { | ||
79 | lcd_write_command(lcd_pram | (which << 3)); | ||
80 | lcd_write_data(pattern, 7); | ||
81 | } | ||
82 | |||
83 | void lcd_icon(int icon, bool enable) | ||
84 | { | ||
85 | static const struct { | ||
86 | char pos; | ||
87 | char mask; | ||
88 | } icontab[] = { | ||
89 | { 0, 0x02}, { 0, 0x08}, { 0, 0x04}, { 0, 0x10}, /* Battery */ | ||
90 | { 2, 0x04}, /* USB */ | ||
91 | { 3, 0x10}, /* Play */ | ||
92 | { 4, 0x10}, /* Record */ | ||
93 | { 5, 0x02}, /* Pause */ | ||
94 | { 5, 0x10}, /* Audio */ | ||
95 | { 6, 0x02}, /* Repeat */ | ||
96 | { 7, 0x01}, /* 1 */ | ||
97 | { 9, 0x04}, /* Volume */ | ||
98 | { 9, 0x02}, { 9, 0x01}, {10, 0x08}, {10, 0x04}, {10, 0x01}, /* Vol 1-5 */ | ||
99 | {10, 0x10}, /* Param */ | ||
100 | }; | ||
101 | static char icon_mirror[11] = {0}; | ||
102 | |||
103 | int pos, mask; | ||
104 | |||
105 | pos = icontab[icon].pos; | ||
106 | mask = icontab[icon].mask; | ||
107 | |||
108 | if (enable) | ||
109 | icon_mirror[pos] |= mask; | ||
110 | else | ||
111 | icon_mirror[pos] &= ~mask; | ||
112 | |||
113 | lcd_write_command_e(LCD_ICON(pos), icon_mirror[pos]); | ||
114 | } | ||
115 | |||
116 | /* device specific init */ | ||
117 | void lcd_init_device(void) | ||
118 | { | ||
119 | unsigned char data_vector[64]; | ||
120 | |||
121 | new_lcd = is_new_player(); | ||
122 | |||
123 | if (new_lcd) | ||
124 | { | ||
125 | lcd_contrast_set = NEW_LCD_CONTRAST_SET; | ||
126 | lcd_cram = NEW_LCD_CRAM; | ||
127 | lcd_pram = NEW_LCD_PRAM; | ||
128 | lcd_iram = NEW_LCD_IRAM; | ||
129 | |||
130 | /* LCD init for cold start */ | ||
131 | PBCR2 &= 0xff00; /* Set PB0..PB3 to GPIO */ | ||
132 | or_b(0x0f, &PBDRL); /* ... high */ | ||
133 | or_b(0x0f, &PBIORL); /* ... and output */ | ||
134 | |||
135 | lcd_write_command(NEW_LCD_FUNCTION_SET + 1); /* CGRAM selected */ | ||
136 | lcd_write_command_e(NEW_LCD_CONTRAST_SET, 0x08); | ||
137 | lcd_write_command(NEW_LCD_POWER_SAVE_MODE_OSC_CONTROL_SET + 2); | ||
138 | /* oscillator on */ | ||
139 | lcd_write_command(NEW_LCD_POWER_CONTROL_REGISTER_SET + 7); | ||
140 | /* opamp buffer + voltage booster on*/ | ||
141 | |||
142 | memset(data_vector, 0x20, 64); | ||
143 | lcd_write_command(NEW_LCD_CRAM); /* Set DDRAM address */ | ||
144 | lcd_write_data(data_vector, 64); /* all spaces */ | ||
145 | |||
146 | memset(data_vector, 0, 64); | ||
147 | lcd_write_command(NEW_LCD_PRAM); /* Set CGRAM address */ | ||
148 | lcd_write_data(data_vector, 64); /* zero out */ | ||
149 | lcd_write_command(NEW_LCD_IRAM); /* Set ICONRAM address */ | ||
150 | lcd_write_data(data_vector, 16); /* zero out */ | ||
151 | |||
152 | lcd_write_command(NEW_LCD_DISPLAY_CONTROL_SET + 1); /* display on */ | ||
153 | } | ||
154 | else | ||
155 | { | ||
156 | lcd_contrast_set = OLD_LCD_CONTRAST_SET; | ||
157 | lcd_cram = OLD_LCD_CRAM; | ||
158 | lcd_pram = OLD_LCD_PRAM; | ||
159 | lcd_iram = OLD_LCD_IRAM; | ||
160 | |||
161 | #if 1 | ||
162 | /* LCD init for cold start */ | ||
163 | PBCR2 &= 0xff00; /* Set PB0..PB3 to GPIO */ | ||
164 | or_b(0x0f, &PBDRL); /* ... high */ | ||
165 | or_b(0x0f, &PBIORL); /* ... and output */ | ||
166 | |||
167 | lcd_write_command(0x61); | ||
168 | lcd_write_command(0x42); | ||
169 | lcd_write_command(0x57); | ||
170 | |||
171 | memset(data_vector, 0x24, 13); | ||
172 | lcd_write_command(OLD_LCD_CRAM); /* Set DDRAM address */ | ||
173 | lcd_write_data(data_vector, 13); /* all spaces */ | ||
174 | lcd_write_command(OLD_LCD_CRAM + 0x10); | ||
175 | lcd_write_data(data_vector, 13); | ||
176 | lcd_write_command(OLD_LCD_CRAM + 0x20); | ||
177 | lcd_write_data(data_vector, 13); | ||
178 | |||
179 | memset(data_vector, 0, 32); | ||
180 | lcd_write_command(OLD_LCD_PRAM); /* Set CGRAM address */ | ||
181 | lcd_write_data(data_vector, 32); /* zero out */ | ||
182 | lcd_write_command(OLD_LCD_IRAM); /* Set ICONRAM address */ | ||
183 | lcd_write_data(data_vector, 13); /* zero out */ | ||
184 | lcd_write_command(OLD_LCD_IRAM + 0x10); | ||
185 | lcd_write_data(data_vector, 13); | ||
186 | |||
187 | lcd_write_command(0x31); | ||
188 | #else | ||
189 | /* archos look-alike code, left here for reference. As soon as the | ||
190 | * rockbox version is confirmed working, this will go away */ | ||
191 | { | ||
192 | int i; | ||
193 | |||
194 | PBCR2 &= 0xc000; | ||
195 | PBIOR |= 0x000f; | ||
196 | PBDR |= 0x0002; | ||
197 | PBDR |= 0x0001; | ||
198 | PBDR |= 0x0004; | ||
199 | PBDR |= 0x0008; | ||
200 | |||
201 | for (i=0; i<200; i++) asm volatile ("nop"); /* wait 100 us */ | ||
202 | |||
203 | PBDR &= 0xfffd; /* CS low (assert) */ | ||
204 | |||
205 | for (i=0; i<100; i++) asm volatile ("nop"); /* wait 50 us */ | ||
206 | |||
207 | lcd_write_command(0x61); | ||
208 | lcd_write_command(0x42); | ||
209 | lcd_write_command(0x57); | ||
210 | |||
211 | memset(data_vector, 0x24, 13); | ||
212 | lcd_write_command(0xb0); /* Set DDRAM address */ | ||
213 | lcd_write_data(data_vector, 13); /* all spaces */ | ||
214 | lcd_write_command(0xc0); | ||
215 | lcd_write_data(data_vector, 13); | ||
216 | lcd_write_command(0xd0); | ||
217 | lcd_write_data(data_vector, 13); | ||
218 | |||
219 | memset(data_vector, 0, 32); | ||
220 | lcd_write_command(0x80); /* Set CGRAM address */ | ||
221 | lcd_write_data(data_vector, 32); /* zero out */ | ||
222 | lcd_write_command(0xe0); /* Set ICONRAM address */ | ||
223 | lcd_write_data(data_vector, 13); /* zero out */ | ||
224 | lcd_write_command(0xf0); | ||
225 | lcd_write_data(data_vector, 13); | ||
226 | |||
227 | for (i=0; i<300000; i++) asm volatile ("nop"); /* wait 150 ms */ | ||
228 | |||
229 | lcd_write_command(0x31); | ||
230 | lcd_write_command_e(0xa8, 0); /* Set contrast control */ | ||
231 | } | ||
232 | #endif | ||
233 | } | ||
234 | lcd_set_contrast(lcd_default_contrast()); | ||
235 | } | ||