From 17bc340f1f0571dc90c91e6f39f93448151d557e Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Wed, 12 Mar 2008 23:08:33 +0000 Subject: 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 --- firmware/drivers/lcd-2bit-vi.c | 3 +- firmware/export/lcd-remote.h | 8 +-- .../target/coldfire/iaudio/lcd-remote-iaudio.c | 58 ++++++++++++---------- .../target/coldfire/iaudio/lcd-remote-target.h | 3 -- firmware/target/coldfire/iaudio/m3/lcd-m3.c | 49 ++++++++++-------- firmware/target/coldfire/iaudio/powermgmt-iaudio.c | 4 ++ .../target/coldfire/iriver/lcd-remote-target.h | 3 -- 7 files changed, 69 insertions(+), 59 deletions(-) (limited to 'firmware') 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 = .bg_pattern = LCDM(DEFAULT_BG) }; -static struct viewport IDATA_ATTR *current_vp = &default_vp; +static struct viewport *current_vp IBSS_ATTR; static unsigned fg_pattern IBSS_ATTR; static unsigned bg_pattern IBSS_ATTR; @@ -97,6 +97,7 @@ void LCDFN(update_viewport_rect)(int x, int y, int width, int height) /* LCD init */ void LCDFN(init)(void) { + LCDFN(set_viewport)(NULL); LCDFN(clear_display)(); #ifndef SIMULATOR 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; typedef unsigned long fb_remote_data; #endif -#ifndef LCD_REMOTE_FBWIDTH -#define LCD_REMOTE_FBWIDTH LCD_REMOTE_WIDTH -#endif +/* common functions */ +void lcd_remote_init(void); +void lcd_remote_write_command(int cmd); +void lcd_remote_write_command_ex(int cmd, int data); +void lcd_remote_write_data(const fb_remote_data *data, int count); /* Low-level drawing function types */ typedef 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; bool remote_initialized = false; -static void remote_tick(void); /* Standard low-level byte writer. Requires CLK high on entry */ static inline void _write_byte(unsigned data) @@ -269,9 +268,10 @@ void lcd_remote_write_command_ex(int cmd, int data) CS_HI; } -void lcd_remote_write_data(const unsigned char* p_bytes, int count) +void lcd_remote_write_data(const fb_remote_data *p_words, int count) { - const unsigned char *p_end = p_bytes + count; + const unsigned char *p_bytes = (const unsigned char *)p_words; + const unsigned char *p_end = (const unsigned char *)(p_words + count); RS_HI; CS_LO; @@ -320,24 +320,6 @@ bool remote_detect(void) return (GPIO_READ & 0x01000000)?false:true; } -void lcd_remote_init_device(void) -{ - or_l(0x0000e000, &GPIO_OUT); - or_l(0x0000e000, &GPIO_ENABLE); - or_l(0x0000e000, &GPIO_FUNCTION); - - or_l(0x00000020, &GPIO1_OUT); - or_l(0x00000020, &GPIO1_ENABLE); - or_l(0x00000020, &GPIO1_FUNCTION); - - and_l(~0x01000000, &GPIO_OUT); - and_l(~0x01000000, &GPIO_ENABLE); - or_l(0x01000000, &GPIO_FUNCTION); - - lcd_remote_clear_display(); - tick_add_task(remote_tick); -} - void lcd_remote_on(void) { CS_HI; @@ -356,7 +338,7 @@ void lcd_remote_on(void) lcd_remote_write_command(LCD_SET_BIAS | 6); /* 1/11 */ lcd_remote_write_command(LCD_CONTROL_POWER | 7); /* All circuits ON */ - + sleep(30); lcd_remote_write_command_ex(LCD_SET_GRAY | 0, 0x00); @@ -393,6 +375,7 @@ void lcd_remote_poweroff(void) lcd_remote_write_command(LCD_SET_POWER_SAVE | 1); } +#ifndef BOOTLOADER /* Monitor remote hotswap */ static void remote_tick(void) { @@ -430,6 +413,29 @@ static void remote_tick(void) } } } +#endif + +void lcd_remote_init_device(void) +{ + or_l(0x0000e000, &GPIO_OUT); + or_l(0x0000e000, &GPIO_ENABLE); + or_l(0x0000e000, &GPIO_FUNCTION); + + or_l(0x00000020, &GPIO1_OUT); + or_l(0x00000020, &GPIO1_ENABLE); + or_l(0x00000020, &GPIO1_FUNCTION); + + and_l(~0x01000000, &GPIO_OUT); + and_l(~0x01000000, &GPIO_ENABLE); + or_l(0x01000000, &GPIO_FUNCTION); + + lcd_remote_clear_display(); +#ifdef BOOTLOADER + lcd_remote_on(); +#else + tick_add_task(remote_tick); +#endif +} /* Update the display. This must be called after all other LCD functions that change the display. */ @@ -445,8 +451,7 @@ void lcd_remote_update(void) have to update one page at a time. */ lcd_remote_write_command(LCD_SET_PAGE | (y>5?y+2:y)); lcd_remote_write_command_ex(LCD_SET_COLUMN | 0, 0); - lcd_remote_write_data((unsigned char *)lcd_remote_framebuffer[y], - LCD_REMOTE_WIDTH*2); + lcd_remote_write_data(lcd_remote_framebuffer[y], LCD_REMOTE_WIDTH); } } } @@ -478,9 +483,8 @@ void lcd_remote_update_rect(int x, int y, int width, int height) lcd_remote_write_command_ex(LCD_SET_COLUMN | ((x >> 4) & 0xf), x & 0xf); - lcd_remote_write_data ( - (unsigned char *)&lcd_remote_framebuffer[y][x], width*2); - } + lcd_remote_write_data(&lcd_remote_framebuffer[y][x], width); + } } } 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 @@ #define REMOTE_DEINIT_LCD 2 void lcd_remote_init_device(void); -void lcd_remote_write_command(int cmd); -void lcd_remote_write_command_ex(int cmd, int data); -void lcd_remote_write_data(const unsigned char* p_bytes, int count); bool remote_detect(void); void lcd_remote_powersave(bool on); void 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; bool initialized = false; -static void lcd_tick(void); /* Standard low-level byte writer. Requires CLK high on entry */ static inline void _write_byte(unsigned data) @@ -295,7 +294,7 @@ int lcd_default_contrast(void) return DEFAULT_CONTRAST_SETTING; } -void lcdset_contrast(int val) +void lcd_set_contrast(int val) { if (val < 0) val = 0; @@ -312,29 +311,11 @@ bool remote_detect(void) return (GPIO_READ & 0x40000000) == 0; } -void lcd_init_device(void) -{ - or_l(0x24000000, &GPIO_OUT); - or_l(0x24000000, &GPIO_ENABLE); - or_l(0x24000000, &GPIO_FUNCTION); - - or_l(0x00011000, &GPIO1_OUT); - or_l(0x00011000, &GPIO1_ENABLE); - or_l(0x00011000, &GPIO1_FUNCTION); - - and_l(~0x40000000, &GPIO_OUT); - and_l(~0x40000000, &GPIO_ENABLE); - or_l(0x40000000, &GPIO_FUNCTION); - - lcd_clear_display(); - tick_add_task(lcd_tick); -} - void lcd_on(void) { CS_HI; CLK_HI; - sleep(10); + sleep(HZ/100); lcd_write_command(LCD_SET_DUTY_RATIO); lcd_write_command(0x70); /* 1/128 */ @@ -349,7 +330,7 @@ void lcd_on(void) lcd_write_command(LCD_CONTROL_POWER | 7); /* All circuits ON */ - sleep(30); + sleep(3*HZ/100); lcd_write_command_e(LCD_SET_GRAY | 0, 0x00); lcd_write_command_e(LCD_SET_GRAY | 1, 0x00); @@ -385,6 +366,7 @@ void lcd_poweroff(void) lcd_write_command(LCD_SET_POWER_SAVE | 1); } +#ifndef BOOTLOADER /* Monitor remote hotswap */ static void lcd_tick(void) { @@ -422,6 +404,29 @@ static void lcd_tick(void) } } } +#endif + +void lcd_init_device(void) +{ + or_l(0x24000000, &GPIO_OUT); + or_l(0x24000000, &GPIO_ENABLE); + or_l(0x24000000, &GPIO_FUNCTION); + + or_l(0x00011000, &GPIO1_OUT); + or_l(0x00011000, &GPIO1_ENABLE); + or_l(0x00011000, &GPIO1_FUNCTION); + + and_l(~0x40000000, &GPIO_OUT); + and_l(~0x40000000, &GPIO_ENABLE); + or_l(0x40000000, &GPIO_FUNCTION); + + lcd_clear_display(); +#ifdef BOOTLOADER + lcd_on(); +#else + tick_add_task(lcd_tick); +#endif +} /* Update the display. 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] = /* Returns battery voltage from ADC [millivolts] */ unsigned int battery_adc_voltage(void) { +#ifdef IAUDIO_M3 + return 4000; /* FIXME: fake value - no ADC yet */ +#else return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; +#endif } 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 @@ #define REMOTE_INIT_LCD 1 #define REMOTE_DEINIT_LCD 2 -void lcd_remote_write_command(int cmd); -void lcd_remote_write_command_ex(int cmd, int data); -void lcd_remote_write_data(const unsigned char* p_bytes, int count); #ifdef HAVE_REMOTE_LCD_TICKING void lcd_remote_emireduce(bool state); #endif -- cgit v1.2.3