forked from len0rd/rockbox
rk27xx - fix backlight driver - now one can set brightness
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30138 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
302c0b7484
commit
cad91ed938
2 changed files with 24 additions and 15 deletions
|
@ -113,9 +113,12 @@
|
|||
|
||||
/* Define this for LCD backlight available */
|
||||
#define HAVE_BACKLIGHT
|
||||
#define HAVE_BACKLIGHT_BRIGHTNESS
|
||||
|
||||
/* Doesn't work so comment it out for now */
|
||||
/* #define HAVE_BACKLIGHT_BRIGHTNESS */
|
||||
/* Main LCD backlight brightness range and defaults */
|
||||
#define MIN_BRIGHTNESS_SETTING 0
|
||||
#define MAX_BRIGHTNESS_SETTING 31
|
||||
#define DEFAULT_BRIGHTNESS_SETTING 18
|
||||
|
||||
/* Define this if you have a software controlled poweroff */
|
||||
#define HAVE_SW_POWEROFF
|
||||
|
|
|
@ -25,6 +25,14 @@
|
|||
#include "backlight-target.h"
|
||||
#include "system.h"
|
||||
|
||||
static int brightness = DEFAULT_BRIGHTNESS_SETTING;
|
||||
static const unsigned short log_brightness[] = {
|
||||
0x2710, 0x27ac, 0x2849, 0x2983, 0x2abd, 0x2c93, 0x2e6a, 0x30dd,
|
||||
0x3351, 0x3661, 0x3971, 0x3d1f, 0x40cc, 0x4516, 0x4960, 0x4e47,
|
||||
0x532e, 0x58b1, 0x5e35, 0x6456, 0x6a76, 0x7134, 0x77f1, 0x7f4c,
|
||||
0x86a6, 0x8e9d, 0x9695, 0x9f29, 0xa7bd, 0xb0ee, 0xba1f, 0xc350
|
||||
};
|
||||
|
||||
bool _backlight_init(void)
|
||||
{
|
||||
/* configure PD4 as output */
|
||||
|
@ -36,15 +44,18 @@ bool _backlight_init(void)
|
|||
/* IOMUXB - set PWM0 pin as GPIO */
|
||||
SCU_IOMUXB_CON &= ~(1 << 11); /* type<<11<<channel */
|
||||
|
||||
/* setup pwm */
|
||||
/* DIV/2, PWM reset */
|
||||
PWMT0_CTRL = (0<<9) | (1<<7);
|
||||
|
||||
/* set pwm frequency ~10kHz */
|
||||
/* (apb_freq/pwm_freq)/pwm_div = (50 000 000/10 000)/2 */
|
||||
PWMT0_LRC = 2500;
|
||||
PWMT0_HRC = 1;
|
||||
/* set pwm frequency to 500Hz - my lcd panel can't cope more reliably */
|
||||
/* (apb_freq/pwm_freq)/pwm_div = (50 000 000/500)/2 */
|
||||
PWMT0_LRC = 50000;
|
||||
PWMT0_HRC = log_brightness[brightness];
|
||||
|
||||
/* reset counter */
|
||||
PWMT0_CNTR = 0x00;
|
||||
|
||||
/* DIV/2, PWM output enable, PWM timer enable */
|
||||
PWMT0_CTRL = (0<<9) | (1<<3) | (1<<0);
|
||||
|
||||
return true;
|
||||
|
@ -58,11 +69,6 @@ void _backlight_on(void)
|
|||
/* set output pin as PWM pin */
|
||||
SCU_IOMUXB_CON |= (1<<11); /* type<<11<<channel */
|
||||
|
||||
/* 100% duty cycle. Other settings doesn't work for
|
||||
* unknown reason
|
||||
*/
|
||||
PWMT0_HRC = PWMT0_LRC;
|
||||
|
||||
/* pwm enable */
|
||||
PWMT0_CTRL |= (1<<3) | (1<<0);
|
||||
}
|
||||
|
@ -79,8 +85,8 @@ void _backlight_off(void)
|
|||
SCU_CLKCFG |= (1<<29);
|
||||
}
|
||||
|
||||
void _backlight_set_brightness(int brightness)
|
||||
void _backlight_set_brightness(int val)
|
||||
{
|
||||
(void)brightness;
|
||||
/* doesn't work for unknown reason */
|
||||
brightness = val & 0x1f;
|
||||
PWMT0_HRC = log_brightness[brightness];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue