summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2007-03-18 17:58:49 +0000
committerJens Arnold <amiconn@rockbox.org>2007-03-18 17:58:49 +0000
commitcb1c9e447ef03ecc7171b512a6aa5754e1e8dd61 (patch)
treed688c8160f70b7a0ce6579a281fefe9fef769c61 /firmware
parentf1bf798b8aa8af2b366060aa6fee81beafdaf3bb (diff)
downloadrockbox-cb1c9e447ef03ecc7171b512a6aa5754e1e8dd61.tar.gz
rockbox-cb1c9e447ef03ecc7171b512a6aa5754e1e8dd61.zip
Archos player: Introduce lcd_write_command_e (only one data byte) in the lcd driver, for cleaner C code.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12835 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/lcd-player.c30
-rw-r--r--firmware/export/lcd.h1
-rw-r--r--firmware/target/sh/archos/player/lcd-as-player.S160
3 files changed, 112 insertions, 79 deletions
diff --git a/firmware/drivers/lcd-player.c b/firmware/drivers/lcd-player.c
index c863c9f188..dd99246611 100644
--- a/firmware/drivers/lcd-player.c
+++ b/firmware/drivers/lcd-player.c
@@ -106,8 +106,6 @@ unsigned short buffer_lcd_mirror[11][2];
106 106
107#ifdef SIMULATOR 107#ifdef SIMULATOR
108unsigned char hardware_buffer_lcd[11][2]; 108unsigned char hardware_buffer_lcd[11][2];
109#else
110static unsigned char lcd_data_byte; /* global write buffer */
111#endif 109#endif
112 110
113#define NO_CHAR -1 111#define NO_CHAR -1
@@ -133,8 +131,7 @@ static void lcd_free_pat(int map_ch)
133#ifdef SIMULATOR 131#ifdef SIMULATOR
134 hardware_buffer_lcd[x][y]=substitute_char; 132 hardware_buffer_lcd[x][y]=substitute_char;
135#else 133#else
136 lcd_write_command(LCD_CURSOR(x, y)); 134 lcd_write_command_e(LCD_CURSOR(x, y), substitute_char);
137 lcd_write_data(&substitute_char, 1);
138#endif 135#endif
139 } 136 }
140 } 137 }
@@ -231,8 +228,7 @@ void xlcd_update(void)
231#ifdef SIMULATOR 228#ifdef SIMULATOR
232 hardware_buffer_lcd[x][y]=hw_ch; 229 hardware_buffer_lcd[x][y]=hw_ch;
233#else 230#else
234 lcd_write_command(LCD_CURSOR(x,y)); 231 lcd_write_command_e(LCD_CURSOR(x,y), hw_ch);
235 lcd_write_data(&hw_ch, 1);
236#endif 232#endif
237 } 233 }
238 } 234 }
@@ -265,9 +261,7 @@ bool lcdx_putc(int x, int y, unsigned short ch)
265#ifdef SIMULATOR 261#ifdef SIMULATOR
266 hardware_buffer_lcd[x][y]=lcd_char; 262 hardware_buffer_lcd[x][y]=lcd_char;
267#else 263#else
268 lcd_data_byte = (unsigned char) lcd_char; 264 lcd_write_command_e(LCD_CURSOR(x, y), lcd_char);
269 lcd_write_command(LCD_CURSOR(x, y));
270 lcd_write_data(&lcd_data_byte, 1);
271#endif 265#endif
272 return false; 266 return false;
273} 267}
@@ -450,15 +444,13 @@ void lcd_icon(int icon, bool enable)
450 444
451 pos = icon_pos[icon]; 445 pos = icon_pos[icon];
452 mask = icon_mask[icon]; 446 mask = icon_mask[icon];
453 447
454 lcd_write_command(LCD_ICON(pos));
455
456 if(enable) 448 if(enable)
457 icon_mirror[pos] |= mask; 449 icon_mirror[pos] |= mask;
458 else 450 else
459 icon_mirror[pos] &= ~mask; 451 icon_mirror[pos] &= ~mask;
460 452
461 lcd_write_data(&icon_mirror[pos], 1); 453 lcd_write_command_e(LCD_ICON(pos), icon_mirror[pos]);
462} 454}
463 455
464int lcd_default_contrast(void) 456int lcd_default_contrast(void)
@@ -468,9 +460,7 @@ int lcd_default_contrast(void)
468 460
469void lcd_set_contrast(int val) 461void lcd_set_contrast(int val)
470{ 462{
471 lcd_data_byte = (unsigned char) (31 - val); 463 lcd_write_command_e(lcd_contrast_set, 31 - val);
472 lcd_write_command(lcd_contrast_set);
473 lcd_write_data(&lcd_data_byte, 1);
474} 464}
475#endif /* SIMULATOR */ 465#endif /* SIMULATOR */
476 466
@@ -500,9 +490,7 @@ void lcd_init (void)
500 or_b(0x0f, &PBDRL); /* ... and high */ 490 or_b(0x0f, &PBDRL); /* ... and high */
501 491
502 lcd_write_command(NEW_LCD_FUNCTION_SET + 1); /* CGRAM selected */ 492 lcd_write_command(NEW_LCD_FUNCTION_SET + 1); /* CGRAM selected */
503 lcd_write_command(NEW_LCD_CONTRAST_SET); 493 lcd_write_command_e(NEW_LCD_CONTRAST_SET, 0x08);
504 lcd_data_byte = 0x08;
505 lcd_write_data(&lcd_data_byte, 1);
506 lcd_write_command(NEW_LCD_POWER_SAVE_MODE_OSC_CONTROL_SET + 2); 494 lcd_write_command(NEW_LCD_POWER_SAVE_MODE_OSC_CONTROL_SET + 2);
507 /* oscillator on */ 495 /* oscillator on */
508 lcd_write_command(NEW_LCD_POWER_CONTROL_REGISTER_SET + 7); 496 lcd_write_command(NEW_LCD_POWER_CONTROL_REGISTER_SET + 7);
@@ -599,9 +587,7 @@ void lcd_init (void)
599 for (i=0; i<300000; i++) asm volatile ("nop"); /* wait 150 ms */ 587 for (i=0; i<300000; i++) asm volatile ("nop"); /* wait 150 ms */
600 588
601 lcd_write_command(0x31); 589 lcd_write_command(0x31);
602 lcd_write_command(0xa8); /* Set contrast control */ 590 lcd_write_command_e(0xa8, 0); /* Set contrast control */
603 lcd_data_byte = 0;
604 lcd_write_data(&lcd_data_byte, 1); /* 0 */
605 } 591 }
606#endif 592#endif
607#endif /* !SIMULATOR */ 593#endif /* !SIMULATOR */
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h
index c4edc478de..cb5ab1dad4 100644
--- a/firmware/export/lcd.h
+++ b/firmware/export/lcd.h
@@ -46,6 +46,7 @@ typedef unsigned long fb_data;
46 46
47/* common functions */ 47/* common functions */
48extern void lcd_write_command(int byte); 48extern void lcd_write_command(int byte);
49extern void lcd_write_command_e(int cmd, int data);
49extern void lcd_write_command_ex(int cmd, int data1, int data2); 50extern void lcd_write_command_ex(int cmd, int data1, int data2);
50extern void lcd_write_data(const fb_data* p_bytes, int count); 51extern void lcd_write_data(const fb_data* p_bytes, int count);
51extern void lcd_init(void); 52extern void lcd_init(void);
diff --git a/firmware/target/sh/archos/player/lcd-as-player.S b/firmware/target/sh/archos/player/lcd-as-player.S
index 7a6324865f..8dc1219e62 100644
--- a/firmware/target/sh/archos/player/lcd-as-player.S
+++ b/firmware/target/sh/archos/player/lcd-as-player.S
@@ -69,30 +69,76 @@
69/* Write a command byte to the lcd controller 69/* Write a command byte to the lcd controller
70 * 70 *
71 * Arguments: 71 * Arguments:
72 * r4 - data byte (int) 72 * r4 - command byte (int)
73 * 73 *
74 * Register usage: 74 * Register usage:
75 * r0 - scratch 75 * r0 - scratch
76 * r1 - data byte (copied) 76 * r1 - command byte (copied)
77 * r2 - precalculated port value (CS, DS and SC low, SD high) 77 * r2 - precalculated port value (CS, DS and SC low, SD high)
78 * r3 - lcd port address 78 * r3 - lcd port address
79 * r5 - 1 (byte count for reuse of the loop in _lcd_write_data) 79 * r5 - 1 (byte count for reuse of the loop in _lcd_write_data)
80 */ 80 */
81 81
82_lcd_write_command: 82_lcd_write_command:
83 mov.l .lcdr,r3 /* put lcd data port address in r3 */ 83 mov.l .lcdr, r3 /* put lcd data port address in r3 */
84 mov r4,r1 /* copy data byte to r1 */ 84 mov r4, r1 /* copy data byte to r1 */
85 mov #1,r5 /* set byte count to 1 (!) */ 85 mov #1, r5 /* set byte count to 1 (!) */
86 86
87 /* This code will fail if an interrupt changes the contents of PBDRL. 87 /* This code will fail if an interrupt changes the contents of PBDRL.
88 * If so, we must disable the interrupt here. */ 88 * If so, we must disable the interrupt here. */
89 89
90 mov.b @r3,r0 /* r0 = PBDRL */ 90 mov.b @r3, r0 /* r0 = PBDRL */
91 or #(LCD_SD),r0 /* r0 |= LCD_SD */ 91 or #(LCD_SD), r0 /* r0 |= LCD_SD */
92 and #(~(LCD_CS|LCD_DS|LCD_SC)),r0 /* r0 &= ~(LCD_CS|LCD_DS|LCD_SC) */ 92 and #(~(LCD_CS|LCD_DS|LCD_SC)),r0 /* r0 &= ~(LCD_CS|LCD_DS|LCD_SC) */
93 93
94 bra .single_transfer /* jump into the transfer loop */ 94 bra .single_transfer /* jump into the transfer loop */
95 mov r0,r2 95 mov r0, r2
96
97
98 .align 2
99 .global _lcd_write_command_e
100 .type _lcd_write_command_e,@function
101
102/* Write a command byte and a data byte to the lcd controller
103 *
104 * Arguments:
105 * r4 - command byte
106 * r5 - data byte
107 *
108 * Register usage:
109 * r0 - scratch
110 * r1 - command/data byte (copied)
111 * r2 - precalculated port value (CS, DS and SC low, SD high)
112 * r3 - lcd port address
113 * r5 - 1 (byte count for reuse of the loop in _lcd_write_data)
114 * r6 - data byte (saved)
115 * r7 - saved pr
116 */
117
118_lcd_write_command_e:
119 mov.l .lcdr, r3 /* put lcd data port address in r3 */
120 mov r4, r1 /* copy data byte to r1 */
121 mov r5, r6
122 mov #1, r5 /* set byte count to 1 (!) */
123
124 /* This code will fail if an interrupt changes the contents of PBDRL.
125 * If so, we must disable the interrupt here. */
126
127 mov.b @r3, r0 /* r0 = PBDRL */
128 or #(LCD_SD), r0 /* r0 |= LCD_SD */
129 and #(~(LCD_CS|LCD_DS|LCD_SC)),r0 /* r0 &= ~(LCD_CS|LCD_DS|LCD_SC) */
130
131 sts pr, r7
132 bsr .single_transfer /* jump into the transfer loop */
133 mov r0, r2
134
135 lds r7, pr
136 mov r6, r1
137 mov #1, r5 /* set byte count to 1 (!) */
138 or #(LCD_DS|LCD_SD), r0 /* r0 |= LCD_DS|LCD_SD */
139 and #(~(LCD_CS|LCD_SC)), r0 /* r0 &= ~(LCD_CS|LCD_SC) */
140 bra .single_transfer /* jump into the transfer loop */
141 mov r0, r2
96 142
97 143
98 .align 2 144 .align 2
@@ -116,7 +162,7 @@ _lcd_write_command:
116 */ 162 */
117 163
118_lcd_write_data: 164_lcd_write_data:
119 mov.l .lcdr,r3 /* put lcd data port address in r3 */ 165 mov.l .lcdr, r3 /* put lcd data port address in r3 */
120 nop /* align here */ 166 nop /* align here */
121 167
122 /* This code will fail if an interrupt changes the contents of PBDRL. 168 /* This code will fail if an interrupt changes the contents of PBDRL.
@@ -126,98 +172,98 @@ _lcd_write_data:
126 * disable/precalculate/transfer/enable for each iteration. However, 172 * disable/precalculate/transfer/enable for each iteration. However,
127 * this would significantly decrease performance. */ 173 * this would significantly decrease performance. */
128 174
129 mov.b @r3,r0 /* r0 = PBDRL */ 175 mov.b @r3, r0 /* r0 = PBDRL */
130 or #(LCD_DS|LCD_SD),r0 /* r0 |= LCD_DS|LCD_SD */ 176 or #(LCD_DS|LCD_SD), r0 /* r0 |= LCD_DS|LCD_SD */
131 and #(~(LCD_CS|LCD_SC)),r0 /* r0 &= ~(LCD_CS|LCD_SC) */ 177 and #(~(LCD_CS|LCD_SC)), r0 /* r0 &= ~(LCD_CS|LCD_SC) */
132 mov r0,r2 178 mov r0, r2
133 179
134 .align 2 180 .align 2
135.multi_transfer: 181.multi_transfer:
136 mov.b @r4+,r1 /* load data byte from memory */ 182 mov.b @r4+, r1 /* load data byte from memory */
137 183
138.single_transfer: 184.single_transfer:
139 shll16 r1 /* shift data to most significant byte */ 185 shll16 r1 /* shift data to most significant byte */
140 shll8 r1 186 shll8 r1
141 187
142 shll r1 /* shift the msb into carry */ 188 shll r1 /* shift the msb into carry */
143 mov r2,r0 /* copy precalculated port value */ 189 mov r2, r0 /* copy precalculated port value */
144 bt 1f /* data bit = 1? */ 190 bt 1f /* data bit = 1? */
145 and #(~LCD_SD),r0 /* no: r0 &= ~LCD_SD */ 191 and #(~LCD_SD), r0 /* no: r0 &= ~LCD_SD */
146 1: 192 1:
147 shll r1 /* next shift here for alignment */ 193 shll r1 /* next shift here for alignment */
148 mov.b r0,@r3 /* set data to port */ 194 mov.b r0, @r3 /* set data to port */
149 or #(LCD_SC),r0 /* rise SC (independent of SD level) */ 195 or #(LCD_SC), r0 /* rise SC (independent of SD level) */
150 mov.b r0,@r3 /* set to port */ 196 mov.b r0, @r3 /* set to port */
151 197
152 mov r2,r0 198 mov r2, r0
153 bt 1f 199 bt 1f
154 and #(~LCD_SD),r0 200 and #(~LCD_SD), r0
155 1: 201 1:
156 mov.b r0,@r3 202 mov.b r0, @r3
157 or #(LCD_SC),r0 203 or #(LCD_SC), r0
158 mov.b r0,@r3 204 mov.b r0, @r3
159 205
160 shll r1 206 shll r1
161 mov r2,r0 207 mov r2, r0
162 bt 1f 208 bt 1f
163 and #(~LCD_SD),r0 209 and #(~LCD_SD), r0
164 1: 210 1:
165 shll r1 211 shll r1
166 mov.b r0,@r3 212 mov.b r0, @r3
167 or #(LCD_SC),r0 213 or #(LCD_SC), r0
168 mov.b r0,@r3 214 mov.b r0, @r3
169 215
170 mov r2,r0 216 mov r2, r0
171 bt 1f 217 bt 1f
172 and #(~LCD_SD),r0 218 and #(~LCD_SD), r0
173 1: 219 1:
174 mov.b r0,@r3 220 mov.b r0, @r3
175 or #(LCD_SC),r0 221 or #(LCD_SC), r0
176 mov.b r0,@r3 222 mov.b r0, @r3
177 223
178 shll r1 224 shll r1
179 mov r2,r0 225 mov r2, r0
180 bt 1f 226 bt 1f
181 and #(~LCD_SD),r0 227 and #(~LCD_SD), r0
182 1: 228 1:
183 shll r1 229 shll r1
184 mov.b r0,@r3 230 mov.b r0, @r3
185 or #(LCD_SC),r0 231 or #(LCD_SC), r0
186 mov.b r0,@r3 232 mov.b r0, @r3
187 233
188 mov r2,r0 234 mov r2, r0
189 bt 1f 235 bt 1f
190 and #(~LCD_SD),r0 236 and #(~LCD_SD), r0
191 1: 237 1:
192 mov.b r0,@r3 238 mov.b r0, @r3
193 or #(LCD_SC),r0 239 or #(LCD_SC), r0
194 mov.b r0,@r3 240 mov.b r0, @r3
195 241
196 shll r1 242 shll r1
197 mov r2,r0 243 mov r2, r0
198 bt 1f 244 bt 1f
199 and #(~LCD_SD),r0 245 and #(~LCD_SD), r0
200 1: 246 1:
201 shll r1 247 shll r1
202 mov.b r0,@r3 248 mov.b r0, @r3
203 or #(LCD_SC),r0 249 or #(LCD_SC), r0
204 mov.b r0,@r3 250 mov.b r0, @r3
205 251
206 mov r2,r0 252 mov r2, r0
207 bt 1f 253 bt 1f
208 and #(~LCD_SD),r0 254 and #(~LCD_SD), r0
209 1: 255 1:
210 mov.b r0,@r3 256 mov.b r0, @r3
211 or #(LCD_SC),r0 257 or #(LCD_SC), r0
212 mov.b r0,@r3 258 mov.b r0, @r3
213 259
214 add #-1,r5 /* decrease byte count */ 260 add #-1, r5 /* decrease byte count */
215 tst r5,r5 /* r5 == 0 ? */ 261 tst r5, r5 /* r5 == 0 ? */
216 bf .multi_transfer /* no: next iteration */ 262 bf .multi_transfer /* no: next iteration */
217 263
218 or #(LCD_CS|LCD_DS|LCD_SD|LCD_SC),r0 /* restore port */ 264 or #(LCD_CS|LCD_DS|LCD_SD|LCD_SC),r0 /* restore port */
219 rts 265 rts
220 mov.b r0,@r3 266 mov.b r0, @r3
221 267
222 /* This is the place to reenable the interrupts, if we have disabled 268 /* This is the place to reenable the interrupts, if we have disabled
223 * them. See above. */ 269 * them. See above. */