1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Jens Arnold 2008-03-12 23:08:33 +00:00
parent 579089afa5
commit 17bc340f1f
7 changed files with 69 additions and 59 deletions

View file

@ -65,7 +65,7 @@ static struct viewport default_vp =
.bg_pattern = LCDM(DEFAULT_BG) .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 fg_pattern IBSS_ATTR;
static unsigned bg_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 */ /* LCD init */
void LCDFN(init)(void) void LCDFN(init)(void)
{ {
LCDFN(set_viewport)(NULL);
LCDFN(clear_display)(); LCDFN(clear_display)();
#ifndef SIMULATOR #ifndef SIMULATOR
LCDFN(init_device)(); LCDFN(init_device)();

View file

@ -56,9 +56,11 @@ typedef unsigned short fb_remote_data;
typedef unsigned long fb_remote_data; typedef unsigned long fb_remote_data;
#endif #endif
#ifndef LCD_REMOTE_FBWIDTH /* common functions */
#define LCD_REMOTE_FBWIDTH LCD_REMOTE_WIDTH void lcd_remote_init(void);
#endif 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 */ /* Low-level drawing function types */
typedef void lcd_remote_pixelfunc_type(int x, int y); typedef void lcd_remote_pixelfunc_type(int x, int y);

View file

@ -59,7 +59,6 @@ static int cached_contrast = DEFAULT_REMOTE_CONTRAST_SETTING;
bool remote_initialized = false; bool remote_initialized = false;
static void remote_tick(void);
/* Standard low-level byte writer. Requires CLK high on entry */ /* Standard low-level byte writer. Requires CLK high on entry */
static inline void _write_byte(unsigned data) static inline void _write_byte(unsigned data)
@ -269,9 +268,10 @@ void lcd_remote_write_command_ex(int cmd, int data)
CS_HI; 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; RS_HI;
CS_LO; CS_LO;
@ -320,24 +320,6 @@ bool remote_detect(void)
return (GPIO_READ & 0x01000000)?false:true; 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) void lcd_remote_on(void)
{ {
CS_HI; 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_SET_BIAS | 6); /* 1/11 */
lcd_remote_write_command(LCD_CONTROL_POWER | 7); /* All circuits ON */ lcd_remote_write_command(LCD_CONTROL_POWER | 7); /* All circuits ON */
sleep(30); sleep(30);
lcd_remote_write_command_ex(LCD_SET_GRAY | 0, 0x00); 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); lcd_remote_write_command(LCD_SET_POWER_SAVE | 1);
} }
#ifndef BOOTLOADER
/* Monitor remote hotswap */ /* Monitor remote hotswap */
static void remote_tick(void) 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. /* Update the display.
This must be called after all other LCD functions that change 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. */ have to update one page at a time. */
lcd_remote_write_command(LCD_SET_PAGE | (y>5?y+2:y)); 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_command_ex(LCD_SET_COLUMN | 0, 0);
lcd_remote_write_data((unsigned char *)lcd_remote_framebuffer[y], lcd_remote_write_data(lcd_remote_framebuffer[y], LCD_REMOTE_WIDTH);
LCD_REMOTE_WIDTH*2);
} }
} }
} }
@ -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), lcd_remote_write_command_ex(LCD_SET_COLUMN | ((x >> 4) & 0xf),
x & 0xf); x & 0xf);
lcd_remote_write_data ( lcd_remote_write_data(&lcd_remote_framebuffer[y][x], width);
(unsigned char *)&lcd_remote_framebuffer[y][x], width*2); }
}
} }
} }

View file

@ -23,9 +23,6 @@
#define REMOTE_DEINIT_LCD 2 #define REMOTE_DEINIT_LCD 2
void lcd_remote_init_device(void); 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); bool remote_detect(void);
void lcd_remote_powersave(bool on); void lcd_remote_powersave(bool on);
void lcd_remote_set_contrast(int val); void lcd_remote_set_contrast(int val);

View file

@ -60,7 +60,6 @@ static int cached_contrast = DEFAULT_CONTRAST_SETTING;
bool initialized = false; bool initialized = false;
static void lcd_tick(void);
/* Standard low-level byte writer. Requires CLK high on entry */ /* Standard low-level byte writer. Requires CLK high on entry */
static inline void _write_byte(unsigned data) static inline void _write_byte(unsigned data)
@ -295,7 +294,7 @@ int lcd_default_contrast(void)
return DEFAULT_CONTRAST_SETTING; return DEFAULT_CONTRAST_SETTING;
} }
void lcdset_contrast(int val) void lcd_set_contrast(int val)
{ {
if (val < 0) if (val < 0)
val = 0; val = 0;
@ -312,29 +311,11 @@ bool remote_detect(void)
return (GPIO_READ & 0x40000000) == 0; 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) void lcd_on(void)
{ {
CS_HI; CS_HI;
CLK_HI; CLK_HI;
sleep(10); sleep(HZ/100);
lcd_write_command(LCD_SET_DUTY_RATIO); lcd_write_command(LCD_SET_DUTY_RATIO);
lcd_write_command(0x70); /* 1/128 */ lcd_write_command(0x70); /* 1/128 */
@ -349,7 +330,7 @@ void lcd_on(void)
lcd_write_command(LCD_CONTROL_POWER | 7); /* All circuits ON */ 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 | 0, 0x00);
lcd_write_command_e(LCD_SET_GRAY | 1, 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); lcd_write_command(LCD_SET_POWER_SAVE | 1);
} }
#ifndef BOOTLOADER
/* Monitor remote hotswap */ /* Monitor remote hotswap */
static void lcd_tick(void) 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. /* Update the display.
This must be called after all other LCD functions that change the display. */ This must be called after all other LCD functions that change the display. */

View file

@ -53,6 +53,10 @@ const unsigned short percent_to_volt_charge[11] =
/* Returns battery voltage from ADC [millivolts] */ /* Returns battery voltage from ADC [millivolts] */
unsigned int battery_adc_voltage(void) 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; return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
#endif
} }

View file

@ -22,9 +22,6 @@
#define REMOTE_INIT_LCD 1 #define REMOTE_INIT_LCD 1
#define REMOTE_DEINIT_LCD 2 #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 #ifdef HAVE_REMOTE_LCD_TICKING
void lcd_remote_emireduce(bool state); void lcd_remote_emireduce(bool state);
#endif #endif