summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2011-07-14 17:06:44 +0000
committerMarcin Bukat <marcin.bukat@gmail.com>2011-07-14 17:06:44 +0000
commitcad91ed938049037a57e9bcc4c5ad63e45dbc2e6 (patch)
treede37d5a64444632898fac36ca44bdf08afb18299
parent302c0b74847ccfac8fb79869b1bd696334e78e55 (diff)
downloadrockbox-cad91ed938049037a57e9bcc4c5ad63e45dbc2e6.tar.gz
rockbox-cad91ed938049037a57e9bcc4c5ad63e45dbc2e6.zip
rk27xx - fix backlight driver - now one can set brightness
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30138 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/export/config/rk27generic.h7
-rw-r--r--firmware/target/arm/rk27xx/backlight-rk27xx.c32
2 files changed, 24 insertions, 15 deletions
diff --git a/firmware/export/config/rk27generic.h b/firmware/export/config/rk27generic.h
index 5427d1fed4..6ed7353d16 100644
--- a/firmware/export/config/rk27generic.h
+++ b/firmware/export/config/rk27generic.h
@@ -113,9 +113,12 @@
113 113
114/* Define this for LCD backlight available */ 114/* Define this for LCD backlight available */
115#define HAVE_BACKLIGHT 115#define HAVE_BACKLIGHT
116#define HAVE_BACKLIGHT_BRIGHTNESS
116 117
117/* Doesn't work so comment it out for now */ 118/* Main LCD backlight brightness range and defaults */
118/* #define HAVE_BACKLIGHT_BRIGHTNESS */ 119#define MIN_BRIGHTNESS_SETTING 0
120#define MAX_BRIGHTNESS_SETTING 31
121#define DEFAULT_BRIGHTNESS_SETTING 18
119 122
120/* Define this if you have a software controlled poweroff */ 123/* Define this if you have a software controlled poweroff */
121#define HAVE_SW_POWEROFF 124#define HAVE_SW_POWEROFF
diff --git a/firmware/target/arm/rk27xx/backlight-rk27xx.c b/firmware/target/arm/rk27xx/backlight-rk27xx.c
index 0d871924ea..e759220dff 100644
--- a/firmware/target/arm/rk27xx/backlight-rk27xx.c
+++ b/firmware/target/arm/rk27xx/backlight-rk27xx.c
@@ -25,6 +25,14 @@
25#include "backlight-target.h" 25#include "backlight-target.h"
26#include "system.h" 26#include "system.h"
27 27
28static int brightness = DEFAULT_BRIGHTNESS_SETTING;
29static const unsigned short log_brightness[] = {
30 0x2710, 0x27ac, 0x2849, 0x2983, 0x2abd, 0x2c93, 0x2e6a, 0x30dd,
31 0x3351, 0x3661, 0x3971, 0x3d1f, 0x40cc, 0x4516, 0x4960, 0x4e47,
32 0x532e, 0x58b1, 0x5e35, 0x6456, 0x6a76, 0x7134, 0x77f1, 0x7f4c,
33 0x86a6, 0x8e9d, 0x9695, 0x9f29, 0xa7bd, 0xb0ee, 0xba1f, 0xc350
34};
35
28bool _backlight_init(void) 36bool _backlight_init(void)
29{ 37{
30 /* configure PD4 as output */ 38 /* configure PD4 as output */
@@ -36,15 +44,18 @@ bool _backlight_init(void)
36 /* IOMUXB - set PWM0 pin as GPIO */ 44 /* IOMUXB - set PWM0 pin as GPIO */
37 SCU_IOMUXB_CON &= ~(1 << 11); /* type<<11<<channel */ 45 SCU_IOMUXB_CON &= ~(1 << 11); /* type<<11<<channel */
38 46
39 /* setup pwm */ 47 /* DIV/2, PWM reset */
40 PWMT0_CTRL = (0<<9) | (1<<7); 48 PWMT0_CTRL = (0<<9) | (1<<7);
41 49
42 /* set pwm frequency ~10kHz */ 50 /* set pwm frequency to 500Hz - my lcd panel can't cope more reliably */
43 /* (apb_freq/pwm_freq)/pwm_div = (50 000 000/10 000)/2 */ 51 /* (apb_freq/pwm_freq)/pwm_div = (50 000 000/500)/2 */
44 PWMT0_LRC = 2500; 52 PWMT0_LRC = 50000;
45 PWMT0_HRC = 1; 53 PWMT0_HRC = log_brightness[brightness];
46 54
55 /* reset counter */
47 PWMT0_CNTR = 0x00; 56 PWMT0_CNTR = 0x00;
57
58 /* DIV/2, PWM output enable, PWM timer enable */
48 PWMT0_CTRL = (0<<9) | (1<<3) | (1<<0); 59 PWMT0_CTRL = (0<<9) | (1<<3) | (1<<0);
49 60
50 return true; 61 return true;
@@ -58,11 +69,6 @@ void _backlight_on(void)
58 /* set output pin as PWM pin */ 69 /* set output pin as PWM pin */
59 SCU_IOMUXB_CON |= (1<<11); /* type<<11<<channel */ 70 SCU_IOMUXB_CON |= (1<<11); /* type<<11<<channel */
60 71
61 /* 100% duty cycle. Other settings doesn't work for
62 * unknown reason
63 */
64 PWMT0_HRC = PWMT0_LRC;
65
66 /* pwm enable */ 72 /* pwm enable */
67 PWMT0_CTRL |= (1<<3) | (1<<0); 73 PWMT0_CTRL |= (1<<3) | (1<<0);
68} 74}
@@ -79,8 +85,8 @@ void _backlight_off(void)
79 SCU_CLKCFG |= (1<<29); 85 SCU_CLKCFG |= (1<<29);
80} 86}
81 87
82void _backlight_set_brightness(int brightness) 88void _backlight_set_brightness(int val)
83{ 89{
84 (void)brightness; 90 brightness = val & 0x1f;
85 /* doesn't work for unknown reason */ 91 PWMT0_HRC = log_brightness[brightness];
86} 92}