Add support for powering down the LCD (saves 50 mA when disabled)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20547 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Karl Kurbjun 2009-03-26 22:20:46 +00:00
parent b084d60356
commit 9d1b99534e
3 changed files with 74 additions and 7 deletions

View file

@ -72,7 +72,17 @@
#define LCD_PIXELFORMAT RGB565 /* rgb565 */ #define LCD_PIXELFORMAT RGB565 /* rgb565 */
/* Define this if your LCD can be enabled/disabled */ /* Define this if your LCD can be enabled/disabled */
//#define HAVE_LCD_ENABLE #define HAVE_LCD_ENABLE
#define HAVE_LCD_SLEEP_SETTING
/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
should be defined as well. */
#define HAVE_LCD_SLEEP
/* We don't use a setting but a fixed delay after the backlight has
* turned off */
#define LCD_SLEEP_TIMEOUT (5*HZ)
/* remote LCD */ /* remote LCD */
//#define HAVE_REMOTE_LCD //#define HAVE_REMOTE_LCD

View file

@ -30,12 +30,22 @@
void _backlight_on(void) void _backlight_on(void)
{ {
#ifdef HAVE_LCD_SLEEP
backlight_lcd_sleep_countdown(false); /* stop counter */
#endif
#ifdef HAVE_LCD_ENABLE
lcd_enable(true); /* power on lcd + visible display */
#endif
_backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING); _backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING);
} }
void _backlight_off(void) void _backlight_off(void)
{ {
_backlight_set_brightness(0); _backlight_set_brightness(0);
#ifdef HAVE_LCD_SLEEP
/* Disable lcd after fade completes (when lcd_sleep timeout expires) */
backlight_lcd_sleep_countdown(true); /* start countdown */
#endif
} }
/* Assumes that the backlight has been initialized */ /* Assumes that the backlight has been initialized */

View file

@ -38,7 +38,11 @@
extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src, extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src,
int width, int height); int width, int height);
static volatile bool lcd_on = true; static bool lcd_on = true;
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
static bool lcd_powered = true;
#endif
volatile bool lcd_poweroff = false; volatile bool lcd_poweroff = false;
/* /*
** These are imported from lcd-16bit.c ** These are imported from lcd-16bit.c
@ -46,10 +50,55 @@ volatile bool lcd_poweroff = false;
extern unsigned fg_pattern; extern unsigned fg_pattern;
extern unsigned bg_pattern; extern unsigned bg_pattern;
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
bool lcd_active(void) bool lcd_active(void)
{ {
return lcd_on; return lcd_on;
} }
#endif
#if defined(HAVE_LCD_SLEEP)
void lcd_sleep()
{
if (lcd_powered)
{
/* "not powered" implies "disabled" */
if (lcd_on)
lcd_enable(false);
IO_GIO_BITCLR2=1<<4;
lcd_powered=false;
}
}
#endif
#if defined(HAVE_LCD_ENABLE)
void lcd_enable(bool state)
{
if (state == lcd_on)
return;
if(state)
{
/* "enabled" implies "powered" */
if (!lcd_powered)
{
lcd_powered=true;
IO_GIO_BITSET2=1<<4;
/* Wait long enough for a frame to be written - yes, it
* takes awhile. */
sleep(HZ/5);
}
lcd_on = true;
lcd_update();
lcd_activation_call_hook();
}
else
{
lcd_on = false;
}
}
#endif
/* LCD init - based on code from ingenient-bsp/bootloader/board/dm320/splash.c /* LCD init - based on code from ingenient-bsp/bootloader/board/dm320/splash.c
* and code by Catalin Patulea from the M:Robe 500i linux port * and code by Catalin Patulea from the M:Robe 500i linux port
@ -80,6 +129,9 @@ void lcd_init_device(void)
IO_OSD_OSDWIN0YP=0; IO_OSD_OSDWIN0YP=0;
IO_OSD_OSDWIN0XL=480; IO_OSD_OSDWIN0XL=480;
IO_OSD_OSDWIN0YL=640; IO_OSD_OSDWIN0YL=640;
/* Set pin 36 to an output */
IO_GIO_DIR2&=!(1<<4);
} }
/* Update a fraction of the display. */ /* Update a fraction of the display. */
@ -138,11 +190,6 @@ void lcd_update_rect(int x, int y, int width, int height)
#endif #endif
} }
void lcd_enable(bool state)
{
(void)state;
}
/* 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. */
void lcd_update(void) void lcd_update(void)