1
0
Fork 0
forked from len0rd/rockbox

Implement backlight brightness for iPod G4 greyscale and iPod Color/Photo.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26573 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2010-06-05 11:48:12 +00:00
parent 8598a2c821
commit 57dcfe0eee
4 changed files with 42 additions and 10 deletions

View file

@ -115,6 +115,12 @@
/* Define this for LCD backlight available */
#define HAVE_BACKLIGHT
#define HAVE_BACKLIGHT_BRIGHTNESS
/* Main LCD backlight brightness range and defaults */
#define MIN_BRIGHTNESS_SETTING 1
#define MAX_BRIGHTNESS_SETTING 31
#define DEFAULT_BRIGHTNESS_SETTING 20
/* define this if the unit uses a scrollwheel for navigation */
#define HAVE_SCROLLWHEEL

View file

@ -99,6 +99,12 @@
/* Define this for LCD backlight available */
#define HAVE_BACKLIGHT
#define HAVE_BACKLIGHT_BRIGHTNESS
/* Main LCD backlight brightness range and defaults */
#define MIN_BRIGHTNESS_SETTING 1
#define MAX_BRIGHTNESS_SETTING 31
#define DEFAULT_BRIGHTNESS_SETTING 20
/* define this if the unit uses a scrollwheel for navigation */
#define HAVE_SCROLLWHEEL

View file

@ -34,28 +34,47 @@
#include "backlight.h"
#include "backlight-target.h"
/* Index 0 is a dummy, 1..31 are used */
static unsigned char log_brightness[32] = {
0, 1, 2, 4, 6, 9, 12, 16, 20, 25, 30, 36,
42, 49, 56, 64, 72, 81, 90, 100, 110, 121, 132, 144,
156, 169, 182, 196, 210, 225, 240, 255
};
static unsigned brightness = 100; /* 1 to 255 */
static bool enabled = false;
/* Handling B03 in _backlight_on() and _backlight_off() makes backlight go off
* without delay. Not doing that does a short (fixed) fade out. Opt for the
* latter. */
void _backlight_on(void)
{
/* brightness full */
outl(0x80000000 | (0xff << 16), 0x7000a010);
/* set port b bit 3 on */
GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x08);
outl(0x80000000 | (brightness << 16), 0x7000a010);
/* GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x08); */
enabled = true;
}
void _backlight_off(void)
{
/* fades backlight off on 4g */
GPO32_ENABLE &= ~0x2000000;
outl(0x80000000, 0x7000a010);
/* GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x08); */
enabled = false;
}
void _backlight_set_brightness(int val)
{
brightness = log_brightness[val];
if (enabled)
outl(0x80000000 | (brightness << 16), 0x7000a010);
}
bool _backlight_init(void)
{
GPIOB_ENABLE |= 0x4; /* B02 enable */
GPIOB_ENABLE |= 0x8; /* B03 enable */
GPO32_ENABLE |= 0x2000000; /* D01 enable */
GPO32_VAL |= 0x2000000; /* D01 =1 */
GPIO_SET_BITWISE(GPIOB_ENABLE, 0x0c); /* B02 and B03 enable */
GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x08); /* B03 = 1 */
GPO32_ENABLE &= ~0x2000000; /* D01 disable, so pwm takes over */
DEV_EN |= DEV_PWM; /* PWM enable */
_backlight_on();

View file

@ -53,6 +53,7 @@ void lcd_awake(void);
bool _backlight_init(void);
void _backlight_on(void);
void _backlight_off(void);
void _backlight_set_brightness(int val);
#elif defined(IPOD_MINI) || defined(IPOD_MINI2G)