sansa clipzip: implement lcd_enable

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30407 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Bertrik Sikken 2011-09-01 16:59:30 +00:00
parent d87f9fc909
commit 6a9aac7a5f
3 changed files with 66 additions and 1 deletions

View file

@ -48,7 +48,7 @@
#define LCD_PIXELFORMAT RGB565SWAPPED /* rgb565 swapped */ #define LCD_PIXELFORMAT RGB565SWAPPED /* rgb565 swapped */
/* define this if you have LCD enable function */ /* define this if you have LCD enable function */
//#define HAVE_LCD_ENABLE #define HAVE_LCD_ENABLE
#ifndef BOOTLOADER #ifndef BOOTLOADER
/* Define this if your LCD can be put to sleep. /* Define this if your LCD can be put to sleep.

View file

@ -39,10 +39,18 @@ void _backlight_on(void)
ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x91); ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x91);
sleep(1); sleep(1);
ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x91); ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x91);
#ifdef HAVE_LCD_ENABLE
lcd_enable(true);
#endif
} }
void _backlight_off(void) void _backlight_off(void)
{ {
#ifdef HAVE_LCD_ENABLE
lcd_enable(false);
#endif
GPIOB_PIN(1) = 0; GPIOB_PIN(1) = 0;
ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x91); ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x91);

View file

@ -29,6 +29,11 @@
/* the detected lcd type (0 or 1) */ /* the detected lcd type (0 or 1) */
static int lcd_type; static int lcd_type;
#ifdef HAVE_LCD_ENABLE
/* whether the lcd is currently enabled or not */
static bool lcd_enabled;
#endif
/* initialises the host lcd hardware, returns the lcd type */ /* initialises the host lcd hardware, returns the lcd type */
int lcd_hw_init(void) int lcd_hw_init(void)
{ {
@ -262,6 +267,57 @@ static void lcd_init_type1(void)
lcd_write_dat(0x00); lcd_write_dat(0x00);
} }
#ifdef HAVE_LCD_ENABLE
/* enables/disables the lcd */
void lcd_enable(bool on)
{
lcd_enabled = on;
if (lcd_type == 0) {
if (on) {
lcd_write(0x14, 0x00);
lcd_write(0x02, 0x01);
lcd_write(0xD2, 0x04);
lcd_write(0xD0, 0x80);
sleep(HZ * 100/1000);
lcd_write(0xD0, 0x00);
}
else {
lcd_write(0xD2, 0x05);
lcd_write(0xD0, 0x80);
sleep(HZ * 100/1000);
lcd_write(0x02, 0x00);
lcd_write(0xD0, 0x00);
lcd_write(0x14, 0x01);
}
}
else {
if (on) {
lcd_write_cmd(0x03);
lcd_write_dat(0x00);
lcd_write_cmd(0x02);
lcd_write_dat(0x01);
}
else {
lcd_write_cmd(0x02);
lcd_write_dat(0x00);
lcd_write_cmd(0x03);
lcd_write_dat(0x01);
}
}
}
/* returns true if the lcd is enabled */
bool lcd_active(void)
{
return lcd_enabled;
}
#endif /* HAVE_LCD_ENABLE */
/* initialises the lcd */ /* initialises the lcd */
void lcd_init_device(void) void lcd_init_device(void)
{ {
@ -272,6 +328,7 @@ void lcd_init_device(void)
else { else {
lcd_init_type1(); lcd_init_type1();
} }
lcd_enable(true);
} }
/* sets up the lcd to receive frame buffer data */ /* sets up the lcd to receive frame buffer data */