summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2024-03-30 22:37:34 -0400
committerWilliam Wilgus <me.theuser@yahoo.com>2024-03-31 01:25:16 -0400
commit4f652b49ae239314f6cb7134845d160df31f11c7 (patch)
treeaa0380b77d166e08a211d6b57e02224169c20bf7
parent8bdf08cd2d5e1fc8c8846869d443e67f8cf96753 (diff)
downloadrockbox-4f652b49ae239314f6cb7134845d160df31f11c7.tar.gz
rockbox-4f652b49ae239314f6cb7134845d160df31f11c7.zip
clipzip clean up lcd driver a bit
consolidate some of the lcd cmd / data calls Change-Id: I2e2ccc7833806f7bf931138a04c48aa55ef4a13d
-rw-r--r--firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c94
1 files changed, 36 insertions, 58 deletions
diff --git a/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c b/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c
index 48594a2ac9..1760e505e8 100644
--- a/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c
+++ b/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c
@@ -116,6 +116,13 @@ static void lcd_write_dat(uint8_t data)
116 SSP_DATA = data; 116 SSP_DATA = data;
117} 117}
118 118
119/* writes 2 data bytes to the LCD */
120static void lcd_write_dat_word(uint8_t data1, uint8_t data2)
121{
122 lcd_write_dat(data1);
123 lcd_write_dat(data2);
124}
125
119/* writes both a command and data value to the lcd */ 126/* writes both a command and data value to the lcd */
120static void lcd_write(uint8_t cmd, uint8_t data) 127static void lcd_write(uint8_t cmd, uint8_t data)
121{ 128{
@@ -167,8 +174,7 @@ static void lcd_init_type0(void)
167/* writes a table entry (for type 1 LCDs) */ 174/* writes a table entry (for type 1 LCDs) */
168static void lcd_write_nibbles(uint8_t val) 175static void lcd_write_nibbles(uint8_t val)
169{ 176{
170 lcd_write_dat((val >> 4) & 0x0F); 177 lcd_write_dat_word((val >> 4) & 0x0F, (val >> 0) & 0x0F);
171 lcd_write_dat((val >> 0) & 0x0F);
172} 178}
173 179
174/* Initialises lcd type 1 180/* Initialises lcd type 1
@@ -191,38 +197,27 @@ static void lcd_init_type1(void)
191 }; 197 };
192 int i; 198 int i;
193 199
194 lcd_write_cmd(0x02); 200 lcd_write(0x02, 0x00);
195 lcd_write_dat(0x00);
196 201
197 lcd_write_cmd(0x01); 202 lcd_write_cmd(0x01);
198 203
199 lcd_write_cmd(0x03); 204 lcd_write(0x03, 0x00);
200 lcd_write_dat(0x00);
201 205
202 lcd_write_cmd(0x04); 206 lcd_write(0x04, 0x03);
203 lcd_write_dat(0x03);
204 207
205 lcd_write_cmd(0x05); 208 lcd_write(0x05, 0x00); /* 0x08 results in BGR colour */
206 lcd_write_dat(0x00); /* 0x08 results in BGR colour */
207 209
208 lcd_write_cmd(0x06); 210 lcd_write(0x06, 0x00);
209 lcd_write_dat(0x00);
210 211
211 lcd_write_cmd(0x07); 212 lcd_write(0x07, 0x00);
212 lcd_write_dat(0x00); 213 lcd_write_dat_word(0x00, 0x04);
213 lcd_write_dat(0x00); 214 lcd_write_dat_word(0x1F, 0x00);
214 lcd_write_dat(0x04); 215 lcd_write_dat_word(0x00, 0x05);
215 lcd_write_dat(0x1F);
216 lcd_write_dat(0x00);
217 lcd_write_dat(0x00);
218 lcd_write_dat(0x05);
219 lcd_write_dat(0x0F); 216 lcd_write_dat(0x0F);
220 217
221 lcd_write_cmd(0x08); 218 lcd_write(0x08, 0x01);
222 lcd_write_dat(0x01);
223 219
224 lcd_write_cmd(0x09); 220 lcd_write(0x09, 0x07);
225 lcd_write_dat(0x07);
226 221
227 lcd_write_cmd(0x0A); 222 lcd_write_cmd(0x0A);
228 lcd_write_nibbles(0); 223 lcd_write_nibbles(0);
@@ -230,10 +225,8 @@ static void lcd_init_type1(void)
230 lcd_write_nibbles(0); 225 lcd_write_nibbles(0);
231 lcd_write_nibbles(LCD_HEIGHT - 1); 226 lcd_write_nibbles(LCD_HEIGHT - 1);
232 227
233 lcd_write_cmd(0x0B); 228 lcd_write(0x0B, 0x00);
234 lcd_write_dat(0x00); 229 lcd_write_dat_word(0x00, 0x00);
235 lcd_write_dat(0x00);
236 lcd_write_dat(0x00);
237 lcd_write_dat(0x00); 230 lcd_write_dat(0x00);
238 231
239 lcd_write_cmd(0x0E); 232 lcd_write_cmd(0x0E);
@@ -241,38 +234,28 @@ static void lcd_init_type1(void)
241 lcd_write_nibbles(0x25); 234 lcd_write_nibbles(0x25);
242 lcd_write_nibbles(0x3F); 235 lcd_write_nibbles(0x3F);
243 236
244 lcd_write_cmd(0x0F); 237 lcd_write(0x0F, 0x0A);
245 lcd_write_dat(0x0A); 238 lcd_write_dat_word(0x0A, 0x0A);
246 lcd_write_dat(0x0A);
247 lcd_write_dat(0x0A);
248 239
249 lcd_write_cmd(0x1C); 240 lcd_write(0x1C, 0x08);
250 lcd_write_dat(0x08);
251 241
252 lcd_write_cmd(0x1D); 242 lcd_write(0x1D, 0x00);
253 lcd_write_dat(0x00); 243 lcd_write_dat_word(0x00, 0x00);
254 lcd_write_dat(0x00);
255 lcd_write_dat(0x00);
256 244
257 lcd_write_cmd(0x1E); 245 lcd_write(0x1E, 0x05);
258 lcd_write_dat(0x05);
259 246
260 lcd_write_cmd(0x1F); 247 lcd_write(0x1F, 0x00);
261 lcd_write_dat(0x00);
262 248
263 lcd_write_cmd(0x30); 249 lcd_write(0x30, 0x10);
264 lcd_write_dat(0x10);
265 250
266 lcd_write_cmd(0x3A); 251 lcd_write_cmd(0x3A);
267 for (i = 0; i < 128; i++) { 252 for (i = 0; i < 128; i++) {
268 lcd_write_nibbles(curve[i]); 253 lcd_write_nibbles(curve[i]);
269 } 254 }
270 255
271 lcd_write_cmd(0x3C); 256 lcd_write(0x3C, 0x00);
272 lcd_write_dat(0x00);
273 257
274 lcd_write_cmd(0x3D); 258 lcd_write(0x3D, 0x00);
275 lcd_write_dat(0x00);
276} 259}
277 260
278#ifdef HAVE_LCD_ENABLE 261#ifdef HAVE_LCD_ENABLE
@@ -305,18 +288,14 @@ void lcd_enable(bool on)
305 } 288 }
306 else { 289 else {
307 if (on) { 290 if (on) {
308 lcd_write_cmd(0x03); 291 lcd_write(0x03, 0x00);
309 lcd_write_dat(0x00);
310 292
311 lcd_write_cmd(0x02); 293 lcd_write(0x02, 0x01);
312 lcd_write_dat(0x01);
313 } 294 }
314 else { 295 else {
315 lcd_write_cmd(0x02); 296 lcd_write(0x02, 0x00);
316 lcd_write_dat(0x00);
317 297
318 lcd_write_cmd(0x03); 298 lcd_write(0x03, 0x01);
319 lcd_write_dat(0x01);
320 } 299 }
321 } 300 }
322 301
@@ -398,8 +377,7 @@ void lcd_write_data(const fb_data *data, int count)
398 377
399 while (count--) { 378 while (count--) {
400 pixel = *data++; 379 pixel = *data++;
401 lcd_write_dat((pixel >> 8) & 0xFF); 380 lcd_write_dat_word((pixel >> 8) & 0xFF, (pixel >> 0) & 0xFF);
402 lcd_write_dat((pixel >> 0) & 0xFF);
403 } 381 }
404} 382}
405 383