Straigten-out lcd sleeping on Gigabeat F/X. Add a service function to backlight.c to handle lcd sleep timer. Make HAVE_LCD_SLEEP useable without a setting and use HAVE_LCD_SLEEP_SETTING when a setting is available in addition to HCD_HAVE_SLEEP. If a setting isn't used, the target must define the timeout to be used in the config.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17505 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
bdc6e624bc
commit
009cebeab2
16 changed files with 118 additions and 70 deletions
|
@ -94,7 +94,7 @@ MENUITEM_SETTING(backlight_fade_out, &global_settings.backlight_fade_out, NULL);
|
|||
MENUITEM_SETTING(bl_filter_first_keypress,
|
||||
&global_settings.bl_filter_first_keypress,
|
||||
filterfirstkeypress_callback);
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
#ifdef HAVE_LCD_SLEEP_SETTING
|
||||
MENUITEM_SETTING(lcd_sleep_after_backlight_off,
|
||||
&global_settings.lcd_sleep_after_backlight_off, NULL);
|
||||
#endif
|
||||
|
@ -130,7 +130,7 @@ MAKE_MENU(lcd_settings,ID2P(LANG_LCD_MENU),
|
|||
,&backlight_fade_in, &backlight_fade_out
|
||||
# endif
|
||||
,&bl_filter_first_keypress
|
||||
# ifdef HAVE_LCD_SLEEP
|
||||
# ifdef HAVE_LCD_SLEEP_SETTING
|
||||
,&lcd_sleep_after_backlight_off
|
||||
# endif
|
||||
# ifdef HAVE_BACKLIGHT_BRIGHTNESS
|
||||
|
|
|
@ -924,7 +924,7 @@ void settings_apply(bool read_disk)
|
|||
#ifdef HAS_BUTTON_HOLD
|
||||
backlight_set_on_button_hold(global_settings.backlight_on_button_hold);
|
||||
#endif
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
#ifdef HAVE_LCD_SLEEP_SETTING
|
||||
lcd_set_sleep_after_backlight_off(global_settings.lcd_sleep_after_backlight_off);
|
||||
#endif
|
||||
#endif /* HAVE_BACKLIGHT */
|
||||
|
|
|
@ -646,7 +646,7 @@ struct user_settings
|
|||
int backlight_on_button_hold; /* what to do with backlight when hold
|
||||
switch is on */
|
||||
#endif
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
#ifdef HAVE_LCD_SLEEP_SETTING
|
||||
int lcd_sleep_after_backlight_off; /* when to put lcd to sleep after backlight
|
||||
has turned off */
|
||||
#endif
|
||||
|
|
|
@ -1126,7 +1126,7 @@ const struct settings_list settings[] = {
|
|||
ID2P(LANG_NORMAL), ID2P(LANG_OFF), ID2P(LANG_ON)),
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
#ifdef HAVE_LCD_SLEEP_SETTING
|
||||
STRINGCHOICE_SETTING(0, lcd_sleep_after_backlight_off,
|
||||
LANG_LCD_SLEEP_AFTER_BACKLIGHT_OFF, 3,
|
||||
"lcd sleep after backlight off",
|
||||
|
@ -1137,7 +1137,7 @@ const struct settings_list settings[] = {
|
|||
TALK_ID(20, UNIT_SEC), TALK_ID(30, UNIT_SEC),
|
||||
TALK_ID(45, UNIT_SEC),TALK_ID(60, UNIT_SEC),
|
||||
TALK_ID(90, UNIT_SEC)),
|
||||
#endif
|
||||
#endif /* HAVE_LCD_SLEEP_SETTING */
|
||||
#endif /* HAVE_BACKLIGHT */
|
||||
|
||||
OFFON_SETTING(0, hold_lr_for_scroll_in_list, -1, true,
|
||||
|
|
|
@ -184,14 +184,41 @@ static int remote_backlight_on_button_hold = 0;
|
|||
#endif /* HAVE_REMOTE_LCD */
|
||||
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
#ifdef HAVE_LCD_SLEEP_SETTING
|
||||
const signed char lcd_sleep_timeout_value[10] =
|
||||
{
|
||||
-1, 0, 5, 10, 15, 20, 30, 45, 60, 90
|
||||
};
|
||||
int _lcd_sleep_timer;
|
||||
int _lcd_sleep_timeout = 10*HZ;
|
||||
static int lcd_sleep_timeout = 10*HZ;
|
||||
#else
|
||||
/* Target defines needed value */
|
||||
static const int lcd_sleep_timeout = LCD_SLEEP_TIMEOUT;
|
||||
#endif
|
||||
|
||||
static int lcd_sleep_timer = 0;
|
||||
|
||||
void backlight_lcd_sleep_countdown(bool start)
|
||||
{
|
||||
if (!start)
|
||||
{
|
||||
/* Cancel the LCD sleep countdown */
|
||||
lcd_sleep_timer = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Start LCD sleep countdown */
|
||||
if (lcd_sleep_timeout < 0)
|
||||
{
|
||||
lcd_sleep_timer = 0; /* Setting == Always */
|
||||
lcd_sleep();
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd_sleep_timer = lcd_sleep_timeout;
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_LCD_SLEEP */
|
||||
|
||||
#if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
|
||||
/* backlight fading */
|
||||
#define BL_PWM_INTERVAL 5 /* Cycle interval in ms */
|
||||
|
@ -328,8 +355,9 @@ static void _backlight_on(void)
|
|||
bl_dim_fraction = (BL_PWM_COUNT<<16);
|
||||
_backlight_on_normal();
|
||||
}
|
||||
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
_lcd_sleep_timer = 0; /* LCD should be awake already */
|
||||
backlight_lcd_sleep(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -344,15 +372,9 @@ static void _backlight_off(void)
|
|||
bl_dim_target = bl_dim_fraction = 0;
|
||||
_backlight_off_normal();
|
||||
}
|
||||
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
/* Start LCD sleep countdown */
|
||||
if (_lcd_sleep_timeout < 0)
|
||||
{
|
||||
_lcd_sleep_timer = 0; /* Setting == Always */
|
||||
lcd_sleep();
|
||||
}
|
||||
else
|
||||
_lcd_sleep_timer = _lcd_sleep_timeout;
|
||||
backlight_start_lcd_sleep_counter(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -580,10 +602,10 @@ static void backlight_tick(void)
|
|||
}
|
||||
}
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
else if(_lcd_sleep_timer)
|
||||
else if(lcd_sleep_timer)
|
||||
{
|
||||
_lcd_sleep_timer--;
|
||||
if(_lcd_sleep_timer == 0)
|
||||
lcd_sleep_timer--;
|
||||
if(lcd_sleep_timer == 0)
|
||||
{
|
||||
/* Queue on bl thread or freeze! */
|
||||
queue_post(&backlight_queue, LCD_SLEEP, 0);
|
||||
|
@ -716,26 +738,26 @@ void backlight_set_on_button_hold(int index)
|
|||
}
|
||||
#endif /* HAS_BUTTON_HOLD */
|
||||
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
#ifdef HAVE_LCD_SLEEP_SETTING
|
||||
void lcd_set_sleep_after_backlight_off(int index)
|
||||
{
|
||||
if ((unsigned)index >= sizeof(lcd_sleep_timeout_value))
|
||||
/* if given a weird value, use default */
|
||||
index = 3;
|
||||
|
||||
_lcd_sleep_timeout = HZ * lcd_sleep_timeout_value[index];
|
||||
lcd_sleep_timeout = HZ * lcd_sleep_timeout_value[index];
|
||||
|
||||
if (backlight_timer > 0 || backlight_get_current_timeout() == 0)
|
||||
/* Timer will be set when bl turns off or bl set to on. */
|
||||
return;
|
||||
|
||||
/* Backlight is Off */
|
||||
if (_lcd_sleep_timeout < 0)
|
||||
_lcd_sleep_timer = 1; /* Always - sleep next tick */
|
||||
if (lcd_sleep_timeout < 0)
|
||||
lcd_sleep_timer = 1; /* Always - sleep next tick */
|
||||
else
|
||||
_lcd_sleep_timer = _lcd_sleep_timeout; /* Never, other */
|
||||
lcd_sleep_timer = lcd_sleep_timeout; /* Never, other */
|
||||
}
|
||||
#endif /* HAVE_LCD_SLEEP */
|
||||
#endif /* HAVE_LCD_SLEEP_SETTING */
|
||||
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
void remote_backlight_on(void)
|
||||
|
|
|
@ -45,8 +45,10 @@ void backlight_set_on_button_hold(int index);
|
|||
#endif
|
||||
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
void backlight_lcd_sleep_countdown(bool start);
|
||||
#ifdef HAVE_LCD_SLEEP_SETTING
|
||||
void lcd_set_sleep_after_backlight_off(int index);
|
||||
extern const signed char lcd_sleep_timeout_value[];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else /* !HAVE_BACKLIGHT */
|
||||
|
@ -89,9 +91,5 @@ void buttonlight_set_timeout(int value);
|
|||
#ifdef HAVE_BUTTON_LIGHT
|
||||
extern int _buttonlight_timeout;
|
||||
#endif
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
extern int _lcd_sleep_timer;
|
||||
extern int _lcd_sleep_timeout;
|
||||
#endif
|
||||
|
||||
#endif /* BACKLIGHT_H */
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
|
||||
should be defined as well. */
|
||||
/* TODO: #define HAVE_LCD_SLEEP */
|
||||
/* TODO: #define HAVE_LCD_SLEEP_SETTING <= optional */
|
||||
|
||||
/* define this if you can flip your LCD */
|
||||
#define HAVE_LCD_FLIP
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
|
||||
should be defined as well. */
|
||||
#define HAVE_LCD_SLEEP
|
||||
#define HAVE_LCD_SLEEP_SETTING
|
||||
|
||||
/* define this if you can flip your LCD */
|
||||
#define HAVE_LCD_FLIP
|
||||
|
|
|
@ -41,6 +41,13 @@
|
|||
/* Define this if your LCD can be enabled/disabled */
|
||||
#define HAVE_LCD_ENABLE
|
||||
|
||||
/* 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)
|
||||
|
||||
#define CONFIG_KEYPAD GIGABEAT_PAD
|
||||
|
||||
/* Define this if you do software codec */
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
* should be defined as well.
|
||||
* We can currently put the lcd to sleep but it won't wake up properly */
|
||||
#define HAVE_LCD_SLEEP
|
||||
#define HAVE_LCD_SLEEP_SETTING
|
||||
|
||||
/* define this if you can flip your LCD */
|
||||
#define HAVE_LCD_FLIP
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
|
||||
should be defined as well. */
|
||||
#define HAVE_LCD_SLEEP
|
||||
#define HAVE_LCD_SLEEP_SETTING
|
||||
|
||||
#define CONFIG_KEYPAD IAUDIO_X5M5_PAD
|
||||
|
||||
|
|
|
@ -126,6 +126,7 @@
|
|||
* should be defined as well.
|
||||
* We can currently put the lcd to sleep but it won't wake up properly */
|
||||
/*TODO: #define HAVE_LCD_SLEEP*/
|
||||
/*TODO: #define HAVE_LCD_SLEEP_SETTING <= optional */
|
||||
|
||||
/* We're able to shut off power to the HDD */
|
||||
#define HAVE_ATA_POWER_OFF
|
||||
|
|
|
@ -25,8 +25,10 @@
|
|||
void _backlight_on(void)
|
||||
{
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
lcd_enable(true);
|
||||
_lcd_sleep_timer = 0;
|
||||
backlight_lcd_sleep_countdown(false); /* stop counter */
|
||||
#endif
|
||||
#ifdef HAVE_LCD_ENABLE
|
||||
lcd_enable(true); /* power on lcd + visible display */
|
||||
#endif
|
||||
GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x20);
|
||||
}
|
||||
|
@ -34,15 +36,10 @@ void _backlight_on(void)
|
|||
void _backlight_off(void)
|
||||
{
|
||||
GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x20);
|
||||
#ifdef HAVE_LCD_ENABLE
|
||||
lcd_enable(false); /* power off visible display */
|
||||
#endif
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
lcd_enable(false);
|
||||
/* Start LCD sleep countdown */
|
||||
if (_lcd_sleep_timeout < 0)
|
||||
{
|
||||
_lcd_sleep_timer = 0; /* Setting == Always */
|
||||
lcd_sleep();
|
||||
}
|
||||
else
|
||||
_lcd_sleep_timer = _lcd_sleep_timeout;
|
||||
backlight_lcd_sleep_countdown(true); /* start countdown */
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -314,11 +314,6 @@ static void led_control_service(void)
|
|||
sc606_control=SC606_CONTROL_IDLE;
|
||||
break;
|
||||
}
|
||||
|
||||
if(sc606regCONFval&0x03)
|
||||
lcd_enable(true);
|
||||
else
|
||||
lcd_enable(false);
|
||||
}
|
||||
#endif /* BOOTLOADER */
|
||||
|
||||
|
@ -340,13 +335,22 @@ static void __backlight_dim(bool dim_now)
|
|||
|
||||
void _backlight_on(void)
|
||||
{
|
||||
lcd_enable(true);
|
||||
#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_dim(false);
|
||||
}
|
||||
|
||||
void _backlight_off(void)
|
||||
{
|
||||
__backlight_dim(true);
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
/* Disable lcd after fade completes (when lcd_sleep timeout expires) */
|
||||
backlight_lcd_sleep_countdown(true); /* start countdown */
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void __buttonlight_on(void)
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
|
||||
#define LCDADDR(x, y) (&lcd_framebuffer[(y)][(x)])
|
||||
|
||||
static volatile bool lcd_on = true;
|
||||
static bool lcd_on = true;
|
||||
static bool lcd_powered = true;
|
||||
static unsigned lcd_yuv_options = 0;
|
||||
/*
|
||||
** This is imported from lcd-16bit.c
|
||||
|
@ -174,6 +175,8 @@ void LCD_SPI_powerdown(void)
|
|||
0,0x04,1,0x00
|
||||
};
|
||||
|
||||
lcd_powered = false;
|
||||
|
||||
LCD_SPI_start();
|
||||
|
||||
LCD_SPI_send(powerdncmd, sizeof(powerdncmd));
|
||||
|
@ -198,6 +201,8 @@ void LCD_SPI_powerup(void)
|
|||
LCD_SPI_send(powerupcmd, sizeof(powerupcmd));
|
||||
|
||||
LCD_SPI_stop();
|
||||
|
||||
lcd_powered = true;
|
||||
}
|
||||
|
||||
void LCD_SPI_init(void)
|
||||
|
@ -266,23 +271,40 @@ void lcd_init_device(void)
|
|||
LCD_SPI_init();
|
||||
}
|
||||
|
||||
void lcd_sleep(void)
|
||||
{
|
||||
if (lcd_powered)
|
||||
{
|
||||
/* "not powered" implies "disabled" */
|
||||
if (lcd_on)
|
||||
lcd_enable(false);
|
||||
|
||||
LCD_SPI_powerdown();
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_enable(bool state)
|
||||
{
|
||||
if (state == lcd_on)
|
||||
return;
|
||||
|
||||
if(state)
|
||||
{
|
||||
if(!lcd_on)
|
||||
/* "enabled" implies "powered" */
|
||||
if (!lcd_powered)
|
||||
{
|
||||
lcd_on = true;
|
||||
lcd_update();
|
||||
LCD_SPI_powerup();
|
||||
/* Wait long enough for a frame to be written - yes, it
|
||||
* takes awhile. */
|
||||
sleep(HZ/5);
|
||||
}
|
||||
|
||||
lcd_on = true;
|
||||
lcd_update();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(lcd_on) {
|
||||
lcd_on = false;
|
||||
LCD_SPI_powerdown();
|
||||
}
|
||||
lcd_on = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,11 +38,11 @@ void _backlight_set_brightness(int brightness)
|
|||
|
||||
void _backlight_on(void)
|
||||
{
|
||||
#ifdef HAVE_LCD_ENABLE
|
||||
lcd_enable(true); /* power on lcd */
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
backlight_lcd_sleep_countdown(false); /* stop counter */
|
||||
#endif
|
||||
#if defined(HAVE_LCD_SLEEP) && !defined(BOOTLOADER)
|
||||
_lcd_sleep_timer = 0; /* LCD should be awake already */
|
||||
#ifdef HAVE_LCD_ENABLE
|
||||
lcd_enable(true); /* power on lcd + visible display */
|
||||
#endif
|
||||
pp_i2c_send(AS3514_I2C_ADDR, AS3514_DCDC15, backlight_brightness);
|
||||
}
|
||||
|
@ -51,17 +51,10 @@ void _backlight_off(void)
|
|||
{
|
||||
pp_i2c_send(AS3514_I2C_ADDR, AS3514_DCDC15, 0x0);
|
||||
#ifdef HAVE_LCD_ENABLE
|
||||
lcd_enable(false); /* power off lcd */
|
||||
lcd_enable(false); /* power off visible display */
|
||||
#endif
|
||||
#if defined(HAVE_LCD_SLEEP) && !defined(BOOTLOADER)
|
||||
/* Start LCD sleep countdown */
|
||||
if (_lcd_sleep_timeout < 0)
|
||||
{
|
||||
_lcd_sleep_timer = 0; /* Setting == Always */
|
||||
lcd_sleep();
|
||||
}
|
||||
else
|
||||
_lcd_sleep_timer = _lcd_sleep_timeout;
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
backlight_lcd_sleep_countdown(true); /* start countdown */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue