summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2008-03-12 23:08:33 +0000
committerJens Arnold <amiconn@rockbox.org>2008-03-12 23:08:33 +0000
commit17bc340f1f0571dc90c91e6f39f93448151d557e (patch)
tree53fccad5fe81875497f717f9fe71b498bde5fc83
parent579089afa546d72c0a05815ed3abfff069ed520b (diff)
downloadrockbox-17bc340f1f0571dc90c91e6f39f93448151d557e.tar.gz
rockbox-17bc340f1f0571dc90c91e6f39f93448151d557e.zip
Make the LCD remote work in the iAudio M3, M5 and X5 bootloaders. * Fix viewport related init bug in the 2 bit vertically interleaved LCD driver. * Fix low bat warning in iaudio bootloader - voltages are in millivolts now.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16648 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/lcd-2bit-vi.c3
-rw-r--r--firmware/export/lcd-remote.h8
-rw-r--r--firmware/target/coldfire/iaudio/lcd-remote-iaudio.c58
-rw-r--r--firmware/target/coldfire/iaudio/lcd-remote-target.h3
-rw-r--r--firmware/target/coldfire/iaudio/m3/lcd-m3.c49
-rw-r--r--firmware/target/coldfire/iaudio/powermgmt-iaudio.c4
-rwxr-xr-xfirmware/target/coldfire/iriver/lcd-remote-target.h3
7 files changed, 69 insertions, 59 deletions
diff --git a/firmware/drivers/lcd-2bit-vi.c b/firmware/drivers/lcd-2bit-vi.c
index d0ef79bcd8..01037b3c80 100644
--- a/firmware/drivers/lcd-2bit-vi.c
+++ b/firmware/drivers/lcd-2bit-vi.c
@@ -65,7 +65,7 @@ static struct viewport default_vp =
65 .bg_pattern = LCDM(DEFAULT_BG) 65 .bg_pattern = LCDM(DEFAULT_BG)
66}; 66};
67 67
68static struct viewport IDATA_ATTR *current_vp = &default_vp; 68static struct viewport *current_vp IBSS_ATTR;
69 69
70static unsigned fg_pattern IBSS_ATTR; 70static unsigned fg_pattern IBSS_ATTR;
71static unsigned bg_pattern IBSS_ATTR; 71static unsigned bg_pattern IBSS_ATTR;
@@ -97,6 +97,7 @@ void LCDFN(update_viewport_rect)(int x, int y, int width, int height)
97/* LCD init */ 97/* LCD init */
98void LCDFN(init)(void) 98void LCDFN(init)(void)
99{ 99{
100 LCDFN(set_viewport)(NULL);
100 LCDFN(clear_display)(); 101 LCDFN(clear_display)();
101#ifndef SIMULATOR 102#ifndef SIMULATOR
102 LCDFN(init_device)(); 103 LCDFN(init_device)();
diff --git a/firmware/export/lcd-remote.h b/firmware/export/lcd-remote.h
index cdd48e5fa3..b046c0736d 100644
--- a/firmware/export/lcd-remote.h
+++ b/firmware/export/lcd-remote.h
@@ -56,9 +56,11 @@ typedef unsigned short fb_remote_data;
56typedef unsigned long fb_remote_data; 56typedef unsigned long fb_remote_data;
57#endif 57#endif
58 58
59#ifndef LCD_REMOTE_FBWIDTH 59/* common functions */
60#define LCD_REMOTE_FBWIDTH LCD_REMOTE_WIDTH 60void lcd_remote_init(void);
61#endif 61void lcd_remote_write_command(int cmd);
62void lcd_remote_write_command_ex(int cmd, int data);
63void lcd_remote_write_data(const fb_remote_data *data, int count);
62 64
63/* Low-level drawing function types */ 65/* Low-level drawing function types */
64typedef void lcd_remote_pixelfunc_type(int x, int y); 66typedef void lcd_remote_pixelfunc_type(int x, int y);
diff --git a/firmware/target/coldfire/iaudio/lcd-remote-iaudio.c b/firmware/target/coldfire/iaudio/lcd-remote-iaudio.c
index 9940017dd9..3c14bb61a0 100644
--- a/firmware/target/coldfire/iaudio/lcd-remote-iaudio.c
+++ b/firmware/target/coldfire/iaudio/lcd-remote-iaudio.c
@@ -59,7 +59,6 @@ static int cached_contrast = DEFAULT_REMOTE_CONTRAST_SETTING;
59 59
60bool remote_initialized = false; 60bool remote_initialized = false;
61 61
62static void remote_tick(void);
63 62
64/* Standard low-level byte writer. Requires CLK high on entry */ 63/* Standard low-level byte writer. Requires CLK high on entry */
65static inline void _write_byte(unsigned data) 64static inline void _write_byte(unsigned data)
@@ -269,9 +268,10 @@ void lcd_remote_write_command_ex(int cmd, int data)
269 CS_HI; 268 CS_HI;
270} 269}
271 270
272void lcd_remote_write_data(const unsigned char* p_bytes, int count) 271void lcd_remote_write_data(const fb_remote_data *p_words, int count)
273{ 272{
274 const unsigned char *p_end = p_bytes + count; 273 const unsigned char *p_bytes = (const unsigned char *)p_words;
274 const unsigned char *p_end = (const unsigned char *)(p_words + count);
275 275
276 RS_HI; 276 RS_HI;
277 CS_LO; 277 CS_LO;
@@ -320,24 +320,6 @@ bool remote_detect(void)
320 return (GPIO_READ & 0x01000000)?false:true; 320 return (GPIO_READ & 0x01000000)?false:true;
321} 321}
322 322
323void lcd_remote_init_device(void)
324{
325 or_l(0x0000e000, &GPIO_OUT);
326 or_l(0x0000e000, &GPIO_ENABLE);
327 or_l(0x0000e000, &GPIO_FUNCTION);
328
329 or_l(0x00000020, &GPIO1_OUT);
330 or_l(0x00000020, &GPIO1_ENABLE);
331 or_l(0x00000020, &GPIO1_FUNCTION);
332
333 and_l(~0x01000000, &GPIO_OUT);
334 and_l(~0x01000000, &GPIO_ENABLE);
335 or_l(0x01000000, &GPIO_FUNCTION);
336
337 lcd_remote_clear_display();
338 tick_add_task(remote_tick);
339}
340
341void lcd_remote_on(void) 323void lcd_remote_on(void)
342{ 324{
343 CS_HI; 325 CS_HI;
@@ -356,7 +338,7 @@ void lcd_remote_on(void)
356 lcd_remote_write_command(LCD_SET_BIAS | 6); /* 1/11 */ 338 lcd_remote_write_command(LCD_SET_BIAS | 6); /* 1/11 */
357 339
358 lcd_remote_write_command(LCD_CONTROL_POWER | 7); /* All circuits ON */ 340 lcd_remote_write_command(LCD_CONTROL_POWER | 7); /* All circuits ON */
359 341
360 sleep(30); 342 sleep(30);
361 343
362 lcd_remote_write_command_ex(LCD_SET_GRAY | 0, 0x00); 344 lcd_remote_write_command_ex(LCD_SET_GRAY | 0, 0x00);
@@ -393,6 +375,7 @@ void lcd_remote_poweroff(void)
393 lcd_remote_write_command(LCD_SET_POWER_SAVE | 1); 375 lcd_remote_write_command(LCD_SET_POWER_SAVE | 1);
394} 376}
395 377
378#ifndef BOOTLOADER
396/* Monitor remote hotswap */ 379/* Monitor remote hotswap */
397static void remote_tick(void) 380static void remote_tick(void)
398{ 381{
@@ -430,6 +413,29 @@ static void remote_tick(void)
430 } 413 }
431 } 414 }
432} 415}
416#endif
417
418void lcd_remote_init_device(void)
419{
420 or_l(0x0000e000, &GPIO_OUT);
421 or_l(0x0000e000, &GPIO_ENABLE);
422 or_l(0x0000e000, &GPIO_FUNCTION);
423
424 or_l(0x00000020, &GPIO1_OUT);
425 or_l(0x00000020, &GPIO1_ENABLE);
426 or_l(0x00000020, &GPIO1_FUNCTION);
427
428 and_l(~0x01000000, &GPIO_OUT);
429 and_l(~0x01000000, &GPIO_ENABLE);
430 or_l(0x01000000, &GPIO_FUNCTION);
431
432 lcd_remote_clear_display();
433#ifdef BOOTLOADER
434 lcd_remote_on();
435#else
436 tick_add_task(remote_tick);
437#endif
438}
433 439
434/* Update the display. 440/* Update the display.
435 This must be called after all other LCD functions that change the display. */ 441 This must be called after all other LCD functions that change the display. */
@@ -445,8 +451,7 @@ void lcd_remote_update(void)
445 have to update one page at a time. */ 451 have to update one page at a time. */
446 lcd_remote_write_command(LCD_SET_PAGE | (y>5?y+2:y)); 452 lcd_remote_write_command(LCD_SET_PAGE | (y>5?y+2:y));
447 lcd_remote_write_command_ex(LCD_SET_COLUMN | 0, 0); 453 lcd_remote_write_command_ex(LCD_SET_COLUMN | 0, 0);
448 lcd_remote_write_data((unsigned char *)lcd_remote_framebuffer[y], 454 lcd_remote_write_data(lcd_remote_framebuffer[y], LCD_REMOTE_WIDTH);
449 LCD_REMOTE_WIDTH*2);
450 } 455 }
451 } 456 }
452} 457}
@@ -478,9 +483,8 @@ void lcd_remote_update_rect(int x, int y, int width, int height)
478 lcd_remote_write_command_ex(LCD_SET_COLUMN | ((x >> 4) & 0xf), 483 lcd_remote_write_command_ex(LCD_SET_COLUMN | ((x >> 4) & 0xf),
479 x & 0xf); 484 x & 0xf);
480 485
481 lcd_remote_write_data ( 486 lcd_remote_write_data(&lcd_remote_framebuffer[y][x], width);
482 (unsigned char *)&lcd_remote_framebuffer[y][x], width*2); 487 }
483 }
484 } 488 }
485} 489}
486 490
diff --git a/firmware/target/coldfire/iaudio/lcd-remote-target.h b/firmware/target/coldfire/iaudio/lcd-remote-target.h
index 86c361097b..1671082654 100644
--- a/firmware/target/coldfire/iaudio/lcd-remote-target.h
+++ b/firmware/target/coldfire/iaudio/lcd-remote-target.h
@@ -23,9 +23,6 @@
23#define REMOTE_DEINIT_LCD 2 23#define REMOTE_DEINIT_LCD 2
24 24
25void lcd_remote_init_device(void); 25void lcd_remote_init_device(void);
26void lcd_remote_write_command(int cmd);
27void lcd_remote_write_command_ex(int cmd, int data);
28void lcd_remote_write_data(const unsigned char* p_bytes, int count);
29bool remote_detect(void); 26bool remote_detect(void);
30void lcd_remote_powersave(bool on); 27void lcd_remote_powersave(bool on);
31void lcd_remote_set_contrast(int val); 28void lcd_remote_set_contrast(int val);
diff --git a/firmware/target/coldfire/iaudio/m3/lcd-m3.c b/firmware/target/coldfire/iaudio/m3/lcd-m3.c
index ac60006565..d54e0596ab 100644
--- a/firmware/target/coldfire/iaudio/m3/lcd-m3.c
+++ b/firmware/target/coldfire/iaudio/m3/lcd-m3.c
@@ -60,7 +60,6 @@ static int cached_contrast = DEFAULT_CONTRAST_SETTING;
60 60
61bool initialized = false; 61bool initialized = false;
62 62
63static void lcd_tick(void);
64 63
65/* Standard low-level byte writer. Requires CLK high on entry */ 64/* Standard low-level byte writer. Requires CLK high on entry */
66static inline void _write_byte(unsigned data) 65static inline void _write_byte(unsigned data)
@@ -295,7 +294,7 @@ int lcd_default_contrast(void)
295 return DEFAULT_CONTRAST_SETTING; 294 return DEFAULT_CONTRAST_SETTING;
296} 295}
297 296
298void lcdset_contrast(int val) 297void lcd_set_contrast(int val)
299{ 298{
300 if (val < 0) 299 if (val < 0)
301 val = 0; 300 val = 0;
@@ -312,29 +311,11 @@ bool remote_detect(void)
312 return (GPIO_READ & 0x40000000) == 0; 311 return (GPIO_READ & 0x40000000) == 0;
313} 312}
314 313
315void lcd_init_device(void)
316{
317 or_l(0x24000000, &GPIO_OUT);
318 or_l(0x24000000, &GPIO_ENABLE);
319 or_l(0x24000000, &GPIO_FUNCTION);
320
321 or_l(0x00011000, &GPIO1_OUT);
322 or_l(0x00011000, &GPIO1_ENABLE);
323 or_l(0x00011000, &GPIO1_FUNCTION);
324
325 and_l(~0x40000000, &GPIO_OUT);
326 and_l(~0x40000000, &GPIO_ENABLE);
327 or_l(0x40000000, &GPIO_FUNCTION);
328
329 lcd_clear_display();
330 tick_add_task(lcd_tick);
331}
332
333void lcd_on(void) 314void lcd_on(void)
334{ 315{
335 CS_HI; 316 CS_HI;
336 CLK_HI; 317 CLK_HI;
337 sleep(10); 318 sleep(HZ/100);
338 319
339 lcd_write_command(LCD_SET_DUTY_RATIO); 320 lcd_write_command(LCD_SET_DUTY_RATIO);
340 lcd_write_command(0x70); /* 1/128 */ 321 lcd_write_command(0x70); /* 1/128 */
@@ -349,7 +330,7 @@ void lcd_on(void)
349 330
350 lcd_write_command(LCD_CONTROL_POWER | 7); /* All circuits ON */ 331 lcd_write_command(LCD_CONTROL_POWER | 7); /* All circuits ON */
351 332
352 sleep(30); 333 sleep(3*HZ/100);
353 334
354 lcd_write_command_e(LCD_SET_GRAY | 0, 0x00); 335 lcd_write_command_e(LCD_SET_GRAY | 0, 0x00);
355 lcd_write_command_e(LCD_SET_GRAY | 1, 0x00); 336 lcd_write_command_e(LCD_SET_GRAY | 1, 0x00);
@@ -385,6 +366,7 @@ void lcd_poweroff(void)
385 lcd_write_command(LCD_SET_POWER_SAVE | 1); 366 lcd_write_command(LCD_SET_POWER_SAVE | 1);
386} 367}
387 368
369#ifndef BOOTLOADER
388/* Monitor remote hotswap */ 370/* Monitor remote hotswap */
389static void lcd_tick(void) 371static void lcd_tick(void)
390{ 372{
@@ -422,6 +404,29 @@ static void lcd_tick(void)
422 } 404 }
423 } 405 }
424} 406}
407#endif
408
409void lcd_init_device(void)
410{
411 or_l(0x24000000, &GPIO_OUT);
412 or_l(0x24000000, &GPIO_ENABLE);
413 or_l(0x24000000, &GPIO_FUNCTION);
414
415 or_l(0x00011000, &GPIO1_OUT);
416 or_l(0x00011000, &GPIO1_ENABLE);
417 or_l(0x00011000, &GPIO1_FUNCTION);
418
419 and_l(~0x40000000, &GPIO_OUT);
420 and_l(~0x40000000, &GPIO_ENABLE);
421 or_l(0x40000000, &GPIO_FUNCTION);
422
423 lcd_clear_display();
424#ifdef BOOTLOADER
425 lcd_on();
426#else
427 tick_add_task(lcd_tick);
428#endif
429}
425 430
426/* Update the display. 431/* Update the display.
427 This must be called after all other LCD functions that change the display. */ 432 This must be called after all other LCD functions that change the display. */
diff --git a/firmware/target/coldfire/iaudio/powermgmt-iaudio.c b/firmware/target/coldfire/iaudio/powermgmt-iaudio.c
index 6e2b19d9b6..c4d64e6155 100644
--- a/firmware/target/coldfire/iaudio/powermgmt-iaudio.c
+++ b/firmware/target/coldfire/iaudio/powermgmt-iaudio.c
@@ -53,6 +53,10 @@ const unsigned short percent_to_volt_charge[11] =
53/* Returns battery voltage from ADC [millivolts] */ 53/* Returns battery voltage from ADC [millivolts] */
54unsigned int battery_adc_voltage(void) 54unsigned int battery_adc_voltage(void)
55{ 55{
56#ifdef IAUDIO_M3
57 return 4000; /* FIXME: fake value - no ADC yet */
58#else
56 return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; 59 return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
60#endif
57} 61}
58 62
diff --git a/firmware/target/coldfire/iriver/lcd-remote-target.h b/firmware/target/coldfire/iriver/lcd-remote-target.h
index a95f9adade..52c62d9375 100755
--- a/firmware/target/coldfire/iriver/lcd-remote-target.h
+++ b/firmware/target/coldfire/iriver/lcd-remote-target.h
@@ -22,9 +22,6 @@
22#define REMOTE_INIT_LCD 1 22#define REMOTE_INIT_LCD 1
23#define REMOTE_DEINIT_LCD 2 23#define REMOTE_DEINIT_LCD 2
24 24
25void lcd_remote_write_command(int cmd);
26void lcd_remote_write_command_ex(int cmd, int data);
27void lcd_remote_write_data(const unsigned char* p_bytes, int count);
28#ifdef HAVE_REMOTE_LCD_TICKING 25#ifdef HAVE_REMOTE_LCD_TICKING
29void lcd_remote_emireduce(bool state); 26void lcd_remote_emireduce(bool state);
30#endif 27#endif