Gigabeat S: Turn off backlight LED supply after a 2-second delay and save a little power. Hardware fading required keeping supply enabled during fade out. Let fade happen at poweroff (might as well~~~).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19322 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
dcf28c277e
commit
1616e66e55
5 changed files with 58 additions and 13 deletions
|
@ -76,9 +76,17 @@
|
|||
SAMPR_CAP_24 | SAMPR_CAP_22 | SAMPR_CAP_16 | \
|
||||
SAMPR_CAP_12 | SAMPR_CAP_11 | SAMPR_CAP_8)
|
||||
|
||||
/* Define this if your LCD can be put to sleep. */
|
||||
#define HAVE_LCD_SLEEP
|
||||
/* We don't use a setting but a fixed delay after the backlight has
|
||||
* turned off */
|
||||
#define LCD_SLEEP_TIMEOUT (2*HZ)
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
/* Not for bootloader */
|
||||
#if 0
|
||||
/* Define this if your LCD can be enabled/disabled */
|
||||
#define HAVE_LCD_ENABLE
|
||||
#endif
|
||||
|
||||
#define HAVE_BACKLIGHT_BRIGHTNESS
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ static const struct
|
|||
|
||||
/* Bits always combined with ramping bits */
|
||||
#define MC13783_LED_CONTROL0_BITS \
|
||||
(MC13783_LEDEN | MC13783_BOOSTEN | MC13783_ABMODE_MONCH_LEDMD1234 | \
|
||||
(MC13783_BOOSTEN | MC13783_ABMODE_MONCH_LEDMD1234 | \
|
||||
MC13783_ABREF_400MV)
|
||||
|
||||
static struct mutex backlight_mutex; /* Block brightness change while
|
||||
|
@ -83,7 +83,8 @@ bool _backlight_init(void)
|
|||
mutex_init(&backlight_mutex);
|
||||
|
||||
/* Set default LED register value */
|
||||
mc13783_write(MC13783_LED_CONTROL0, MC13783_LED_CONTROL0_BITS);
|
||||
mc13783_write(MC13783_LED_CONTROL0,
|
||||
MC13783_LED_CONTROL0_BITS | MC13783_LEDEN);
|
||||
|
||||
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
|
||||
/* Our PWM and I-Level is different than retailos (but same apparent
|
||||
|
@ -125,8 +126,13 @@ void _backlight_on(void)
|
|||
|
||||
mutex_lock(&backlight_mutex);
|
||||
|
||||
/* Set/clear LEDRAMPUP bit, clear LEDRAMPDOWN bit */
|
||||
data[0] = MC13783_LED_CONTROL0_BITS;
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
backlight_lcd_sleep_countdown(false); /* stop counter */
|
||||
#endif
|
||||
|
||||
/* Set/clear LEDRAMPUP bit, clear LEDRAMPDOWN bit,
|
||||
* Ensure LED supply is on. */
|
||||
data[0] = MC13783_LED_CONTROL0_BITS | MC13783_LEDEN;
|
||||
|
||||
if (!backlight_on_status)
|
||||
data[0] |= led_ramp_mask & MC13783_LEDMDRAMPUP;
|
||||
|
@ -150,7 +156,7 @@ void _backlight_on(void)
|
|||
|
||||
void _backlight_off(void)
|
||||
{
|
||||
uint32_t ctrl0 = MC13783_LED_CONTROL0_BITS;
|
||||
uint32_t ctrl0 = MC13783_LED_CONTROL0_BITS | MC13783_LEDEN;
|
||||
|
||||
mutex_lock(&backlight_mutex);
|
||||
|
||||
|
@ -169,6 +175,11 @@ void _backlight_off(void)
|
|||
mc13783_write_masked(MC13783_LED_CONTROL2, MC13783_LEDMDDCw(0),
|
||||
MC13783_LEDMDDC);
|
||||
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
/* Disable lcd after fade completes (when lcd_sleep timeout expires) */
|
||||
backlight_lcd_sleep_countdown(true); /* start countdown */
|
||||
#endif
|
||||
|
||||
mutex_unlock(&backlight_mutex);
|
||||
}
|
||||
|
||||
|
@ -192,3 +203,15 @@ void _backlight_set_brightness(int brightness)
|
|||
mutex_unlock(&backlight_mutex);
|
||||
}
|
||||
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
|
||||
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
/* Turn off LED supply */
|
||||
void _backlight_lcd_sleep(void)
|
||||
{
|
||||
mutex_lock(&backlight_mutex);
|
||||
|
||||
mc13783_clear(MC13783_LED_CONTROL0, MC13783_LEDEN);
|
||||
|
||||
mutex_unlock(&backlight_mutex);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -32,4 +32,6 @@ void _backlight_on(void);
|
|||
void _backlight_off(void);
|
||||
void _backlight_set_brightness(int brightness);
|
||||
|
||||
void _backlight_lcd_sleep(void);
|
||||
|
||||
#endif /* BACKLIGHT_TARGET_H */
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "lcd.h"
|
||||
#include "kernel.h"
|
||||
#include "lcd-target.h"
|
||||
#include "backlight-target.h"
|
||||
|
||||
#define LCDADDR(x, y) (&lcd_framebuffer[(y)][(x)])
|
||||
|
||||
|
@ -42,13 +43,6 @@ extern struct viewport* current_vp;
|
|||
extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src,
|
||||
int width, int height);
|
||||
|
||||
#if 0
|
||||
bool lcd_enabled()
|
||||
{
|
||||
return lcd_on;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* LCD init */
|
||||
void lcd_init_device(void)
|
||||
{
|
||||
|
@ -94,6 +88,14 @@ void lcd_update_rect(int x, int y, int width, int height)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_LCD_SLEEP
|
||||
void lcd_sleep(void)
|
||||
{
|
||||
_backlight_lcd_sleep();
|
||||
}
|
||||
#endif /* HAVE_LCD_SLEEP */
|
||||
|
||||
#if 0
|
||||
void lcd_enable(bool state)
|
||||
{
|
||||
(void)state;
|
||||
|
@ -103,6 +105,7 @@ bool lcd_enabled(void)
|
|||
{
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Update the display.
|
||||
This must be called after all other LCD functions that change the display. */
|
||||
|
|
|
@ -81,9 +81,18 @@ bool ide_powered(void)
|
|||
|
||||
void power_off(void)
|
||||
{
|
||||
/* Cut backlight */
|
||||
_backlight_off();
|
||||
|
||||
/* Let it fade */
|
||||
sleep(5*HZ/4);
|
||||
|
||||
/* Set user off mode */
|
||||
mc13783_set(MC13783_POWER_CONTROL0, MC13783_USEROFFSPI);
|
||||
|
||||
/* Wait for power cut */
|
||||
disable_interrupt(IRQ_FIQ_STATUS);
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue