mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
Sansa Connect: Power off LCD to save power
Prevent startup screen flash by properly using AVR LCM functions. Power off LCD when not needed to improve battery runtime. Change-Id: I76e3c5c0208774f189fbc6f7d7b3c9e22c062285
This commit is contained in:
parent
89d3ca77b6
commit
2acf8db3e1
5 changed files with 92 additions and 48 deletions
|
@ -239,9 +239,7 @@ void main(void)
|
||||||
font_init();
|
font_init();
|
||||||
button_init();
|
button_init();
|
||||||
|
|
||||||
#ifdef HAVE_LCD_ENABLE
|
|
||||||
lcd_enable(true);
|
lcd_enable(true);
|
||||||
#endif
|
|
||||||
lcd_setfont(FONT_SYSFIXED);
|
lcd_setfont(FONT_SYSFIXED);
|
||||||
reset_screen();
|
reset_screen();
|
||||||
show_logo();
|
show_logo();
|
||||||
|
@ -288,10 +286,12 @@ void main(void)
|
||||||
|
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
{
|
{
|
||||||
|
lcd_enable(false);
|
||||||
system_prepare_fw_start();
|
system_prepare_fw_start();
|
||||||
|
|
||||||
kernel_entry = (void*)0x01008000;
|
kernel_entry = (void*)0x01008000;
|
||||||
ret = kernel_entry();
|
ret = kernel_entry();
|
||||||
|
lcd_enable(true);
|
||||||
printf("FAILED to boot OF");
|
printf("FAILED to boot OF");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -309,10 +309,12 @@ void main(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
lcd_enable(false);
|
||||||
system_prepare_fw_start();
|
system_prepare_fw_start();
|
||||||
|
|
||||||
kernel_entry = (void*) loadbuffer;
|
kernel_entry = (void*) loadbuffer;
|
||||||
ret = kernel_entry();
|
ret = kernel_entry();
|
||||||
|
lcd_enable(true);
|
||||||
printf("FAILED!");
|
printf("FAILED!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,9 +81,8 @@
|
||||||
#define LCD_PIXELFORMAT RGB565 /* rgb565 */
|
#define LCD_PIXELFORMAT RGB565 /* rgb565 */
|
||||||
|
|
||||||
#define HAVE_LCD_ENABLE
|
#define HAVE_LCD_ENABLE
|
||||||
#ifndef BOOTLOADER
|
|
||||||
#define HAVE_LCD_SLEEP
|
#define HAVE_LCD_SLEEP
|
||||||
#endif
|
#define HAVE_LCD_SHUTDOWN
|
||||||
|
|
||||||
#define LCD_SLEEP_TIMEOUT (2*HZ)
|
#define LCD_SLEEP_TIMEOUT (2*HZ)
|
||||||
|
|
||||||
|
|
|
@ -857,8 +857,3 @@ bool button_hold(void)
|
||||||
{
|
{
|
||||||
return hold_switch;
|
return hold_switch;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_enable(bool on)
|
|
||||||
{
|
|
||||||
(void)on;
|
|
||||||
}
|
|
||||||
|
|
|
@ -52,13 +52,12 @@ static void _backlight_write_brightness(int brightness)
|
||||||
|
|
||||||
void backlight_hw_on(void)
|
void backlight_hw_on(void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LCD_SLEEP
|
|
||||||
if (!lcd_active())
|
if (!lcd_active())
|
||||||
{
|
{
|
||||||
lcd_awake();
|
lcd_awake();
|
||||||
lcd_update();
|
lcd_update();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* set GIO34 as PWM1 */
|
/* set GIO34 as PWM1 */
|
||||||
IO_GIO_FSEL3 = (IO_GIO_FSEL3 & 0xFFF3) | (1 << 2);
|
IO_GIO_FSEL3 = (IO_GIO_FSEL3 & 0xFFF3) | (1 << 2);
|
||||||
|
|
||||||
|
|
|
@ -29,49 +29,98 @@
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
#include "lcd-target.h"
|
#include "lcd-target.h"
|
||||||
#include "avr-sansaconnect.h"
|
#include "avr-sansaconnect.h"
|
||||||
|
#include "backlight-target.h"
|
||||||
|
|
||||||
extern bool lcd_on; /* lcd-memframe.c */
|
/* See lcd-memframe.c */
|
||||||
|
extern void lcd_set_active(bool active);
|
||||||
|
|
||||||
|
static bool lcd_powered;
|
||||||
|
|
||||||
#if defined(HAVE_LCD_SLEEP)
|
|
||||||
void lcd_sleep(void)
|
void lcd_sleep(void)
|
||||||
{
|
{
|
||||||
if (lcd_on)
|
if (lcd_powered)
|
||||||
{
|
{
|
||||||
lcd_on = false;
|
lcd_set_active(false);
|
||||||
|
|
||||||
avr_hid_lcm_sleep();
|
avr_hid_lcm_power_off();
|
||||||
sleep(HZ/20);
|
mdelay(100);
|
||||||
|
|
||||||
|
/* Disable OSD window */
|
||||||
|
bitclr16(&IO_OSD_OSDWINMD0, 0x01);
|
||||||
/* disable video encoder */
|
/* disable video encoder */
|
||||||
bitclr16(&IO_VID_ENC_VMOD, 0x01);
|
bitclr16(&IO_VID_ENC_VMOD, VENC_VMOD_VENC);
|
||||||
|
mdelay(66);
|
||||||
|
|
||||||
sleep(HZ/20);
|
/* disable video encoder and OSD clocks */
|
||||||
|
bitclr16(&IO_CLK_MOD1, CLK_MOD1_VENC | CLK_MOD1_OSD);
|
||||||
|
|
||||||
/* disable video encoder clock */
|
lcd_powered = false;
|
||||||
bitclr16(&IO_CLK_MOD1, CLK_MOD1_VENC);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_awake(void)
|
void lcd_awake(void)
|
||||||
{
|
{
|
||||||
if (!lcd_on)
|
if (!lcd_powered)
|
||||||
{
|
{
|
||||||
lcd_on = true;
|
/* Enable Video Encoder and OSD clocks */
|
||||||
|
bitset16(&IO_CLK_MOD1, CLK_MOD1_VENC | CLK_MOD1_OSD);
|
||||||
/* enable video encoder clock */
|
/* Enable OSD window */
|
||||||
bitset16(&IO_CLK_MOD1, CLK_MOD1_VENC);
|
bitset16(&IO_OSD_OSDWINMD0, 0x01);
|
||||||
|
/* Enable video encoder */
|
||||||
/* enable video encoder */
|
bitset16(&IO_VID_ENC_VMOD, VENC_VMOD_VENC);
|
||||||
bitset16(&IO_VID_ENC_VMOD, 0x01);
|
|
||||||
|
|
||||||
|
avr_hid_lcm_power_on();
|
||||||
|
lcd_set_active(true);
|
||||||
avr_hid_lcm_wake();
|
avr_hid_lcm_wake();
|
||||||
|
|
||||||
|
lcd_powered = true;
|
||||||
send_event(LCD_EVENT_ACTIVATION, NULL);
|
send_event(LCD_EVENT_ACTIVATION, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lcd_update();
|
void lcd_shutdown(void)
|
||||||
|
{
|
||||||
|
backlight_hw_off();
|
||||||
|
lcd_sleep();
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_enable(bool enable)
|
||||||
|
{
|
||||||
|
if (lcd_active() == enable)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lcd_set_active(enable);
|
||||||
|
|
||||||
|
if (enable)
|
||||||
|
{
|
||||||
|
/* Enable Video Encoder and OSD clocks */
|
||||||
|
bitset16(&IO_CLK_MOD1, CLK_MOD1_VENC | CLK_MOD1_OSD);
|
||||||
|
/* Enable OSD window */
|
||||||
|
bitset16(&IO_OSD_OSDWINMD0, 0x01);
|
||||||
|
/* Enable video encoder */
|
||||||
|
bitset16(&IO_VID_ENC_VMOD, VENC_VMOD_VENC);
|
||||||
|
|
||||||
|
avr_hid_lcm_wake();
|
||||||
|
mdelay(30);
|
||||||
|
|
||||||
|
send_event(LCD_EVENT_ACTIVATION, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mdelay(30);
|
||||||
|
avr_hid_lcm_sleep();
|
||||||
|
mdelay(10);
|
||||||
|
|
||||||
|
/* Disable OSD window */
|
||||||
|
bitclr16(&IO_OSD_OSDWINMD0, 0x01);
|
||||||
|
/* disable video encoder */
|
||||||
|
bitclr16(&IO_VID_ENC_VMOD, VENC_VMOD_VENC);
|
||||||
|
mdelay(66);
|
||||||
|
|
||||||
|
/* disable video encoder and OSD clocks */
|
||||||
|
bitclr16(&IO_CLK_MOD1, CLK_MOD1_VENC | CLK_MOD1_OSD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void lcd_init_device(void)
|
void lcd_init_device(void)
|
||||||
{
|
{
|
||||||
|
@ -121,10 +170,9 @@ void lcd_init_device(void)
|
||||||
IO_VID_ENC_VMOD = 0x2015; /* OF sets 0x2011 */
|
IO_VID_ENC_VMOD = 0x2015; /* OF sets 0x2011 */
|
||||||
|
|
||||||
/* Copy Rockbox frame buffer to the second framebuffer */
|
/* Copy Rockbox frame buffer to the second framebuffer */
|
||||||
|
lcd_set_active(true);
|
||||||
lcd_update();
|
lcd_update();
|
||||||
|
|
||||||
avr_hid_lcm_power_on();
|
|
||||||
|
|
||||||
/* set framebuffer address - OF sets RAM start address to 0x1000000 */
|
/* set framebuffer address - OF sets RAM start address to 0x1000000 */
|
||||||
addr = ((int)FRAME-CONFIG_SDRAM_START)/32;
|
addr = ((int)FRAME-CONFIG_SDRAM_START)/32;
|
||||||
|
|
||||||
|
@ -149,8 +197,9 @@ void lcd_init_device(void)
|
||||||
|
|
||||||
/* Enable Video Encoder - RGB666, custom timing */
|
/* Enable Video Encoder - RGB666, custom timing */
|
||||||
IO_VID_ENC_VMOD = 0x2015;
|
IO_VID_ENC_VMOD = 0x2015;
|
||||||
|
|
||||||
|
lcd_powered = true;
|
||||||
avr_hid_lcm_wake();
|
avr_hid_lcm_wake();
|
||||||
lcd_on = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LCD_USE_DMA
|
#ifdef LCD_USE_DMA
|
||||||
|
@ -246,7 +295,7 @@ void lcd_update_rect(int x, int y, int width, int height)
|
||||||
__attribute__ ((section(".icode")));
|
__attribute__ ((section(".icode")));
|
||||||
void lcd_update_rect(int x, int y, int width, int height)
|
void lcd_update_rect(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
if (!lcd_on)
|
if (!lcd_active())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((width | height) < 0)
|
if ((width | height) < 0)
|
||||||
|
@ -270,7 +319,7 @@ void lcd_update_rect(int x, int y, int width, int height)
|
||||||
void lcd_update(void) __attribute__ ((section(".icode")));
|
void lcd_update(void) __attribute__ ((section(".icode")));
|
||||||
void lcd_update(void)
|
void lcd_update(void)
|
||||||
{
|
{
|
||||||
if (!lcd_on)
|
if (!lcd_active())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
|
lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue