summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBertrik Sikken <bertrik@sikken.nl>2009-06-23 18:11:03 +0000
committerBertrik Sikken <bertrik@sikken.nl>2009-06-23 18:11:03 +0000
commit743dcf7f69c4afa1efd2f84a2bd0b5e23d53b0b9 (patch)
treecbd5bb40837fb4ba624edd5ae768fd8e9aa8dfa7
parentd86cf998e887d6e1bac2754b3087710926c74a19 (diff)
downloadrockbox-743dcf7f69c4afa1efd2f84a2bd0b5e23d53b0b9.tar.gz
rockbox-743dcf7f69c4afa1efd2f84a2bd0b5e23d53b0b9.zip
Implement PWM backlight driver for the Meizus. Update Meizu M3 bootloader to control brightness with the touch strip.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21478 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--bootloader/meizu_m3.c7
-rw-r--r--firmware/SOURCES1
-rw-r--r--firmware/export/config-meizu-m3.h7
-rw-r--r--firmware/target/arm/s5l8700/backlight-meizu.c111
-rw-r--r--firmware/target/arm/s5l8700/backlight-target.h (renamed from firmware/target/arm/s5l8700/meizu-m3/backlight-target.h)0
-rw-r--r--firmware/target/arm/s5l8700/meizu-m6sl/backlight-target.h29
-rw-r--r--firmware/target/arm/s5l8700/meizu-m6sp/backlight-target.h29
-rw-r--r--firmware/target/arm/s5l8700/system-s5l8700.c11
8 files changed, 126 insertions, 69 deletions
diff --git a/bootloader/meizu_m3.c b/bootloader/meizu_m3.c
index 2fb0b551a0..84961228b7 100644
--- a/bootloader/meizu_m3.c
+++ b/bootloader/meizu_m3.c
@@ -43,7 +43,7 @@
43#include "rbunicode.h" 43#include "rbunicode.h"
44#include "usb.h" 44#include "usb.h"
45#include "qt1106.h" 45#include "qt1106.h"
46#include "rockboxlogo.h" 46#include "bitmaps/rockboxlogo.h"
47 47
48 48
49#include <stdarg.h> 49#include <stdarg.h>
@@ -108,7 +108,7 @@ void main(void)
108 int oldval = PCON0; 108 int oldval = PCON0;
109 PCON0 = ((oldval & ~(3 << 4)) | (1 << 4)); 109 PCON0 = ((oldval & ~(3 << 4)) | (1 << 4));
110 PDAT0 |= (1 << 2); 110 PDAT0 |= (1 << 2);
111 111
112 //power on 112 //power on
113// oldval = PCON1; 113// oldval = PCON1;
114// PCON1 = ((oldval & ~(0xf << 12)) | (1 << 12)); 114// PCON1 = ((oldval & ~(0xf << 12)) | (1 << 12));
@@ -128,6 +128,7 @@ void main(void)
128 EINTMSK = 0x11; 128 EINTMSK = 0x11;
129 asm volatile("msr cpsr_c, #0x13\n\t"); // enable interrupts 129 asm volatile("msr cpsr_c, #0x13\n\t"); // enable interrupts
130 130
131 backlight_init();
131 lcd_init(); 132 lcd_init();
132 lcd_update(); 133 lcd_update();
133 134
@@ -157,6 +158,8 @@ void main(void)
157 if(slider & 0x008000) 158 if(slider & 0x008000)
158 bl_debug_count(((slider&0xff)) + 1); 159 bl_debug_count(((slider&0xff)) + 1);
159 */ 160 */
161
162 _backlight_set_brightness(slider & 0xFF);
160 } 163 }
161 164
162 //power off 165 //power off
diff --git a/firmware/SOURCES b/firmware/SOURCES
index a7741c1870..0eff012660 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1241,6 +1241,7 @@ target/arm/s5l8700/meizu-m6sp/lcd-m6sp.c
1241#endif /* MEIZU_M6SP */ 1241#endif /* MEIZU_M6SP */
1242 1242
1243#ifdef MEIZU_M3 1243#ifdef MEIZU_M3
1244target/arm/s5l8700/backlight-meizu.c
1244target/arm/s5l8700/meizu-m3/lcd-m3.c 1245target/arm/s5l8700/meizu-m3/lcd-m3.c
1245drivers/qt1106.c 1246drivers/qt1106.c
1246#ifndef SIMULATOR 1247#ifndef SIMULATOR
diff --git a/firmware/export/config-meizu-m3.h b/firmware/export/config-meizu-m3.h
index 2ad20550d0..9e2d6cbf4e 100644
--- a/firmware/export/config-meizu-m3.h
+++ b/firmware/export/config-meizu-m3.h
@@ -178,8 +178,7 @@
178#define DEFAULT_CONTRAST_SETTING 19 /* Match boot contrast */ 178#define DEFAULT_CONTRAST_SETTING 19 /* Match boot contrast */
179 179
180/* Main LCD backlight brightness range and defaults */ 180/* Main LCD backlight brightness range and defaults */
181/* PCF50506 can output 0%-100% duty cycle but D305A expects %15-100%. */ 181#define MIN_BRIGHTNESS_SETTING 0
182#define MIN_BRIGHTNESS_SETTING 1 /* 15/16 (93.75%) */ 182#define MAX_BRIGHTNESS_SETTING 255
183#define MAX_BRIGHTNESS_SETTING 13 /* 3/16 (18.75%) */ 183#define DEFAULT_BRIGHTNESS_SETTING 200
184#define DEFAULT_BRIGHTNESS_SETTING 8 /* 8/16 (50.00%) = x5 boot default */
185 184
diff --git a/firmware/target/arm/s5l8700/backlight-meizu.c b/firmware/target/arm/s5l8700/backlight-meizu.c
new file mode 100644
index 0000000000..43cbb16a2d
--- /dev/null
+++ b/firmware/target/arm/s5l8700/backlight-meizu.c
@@ -0,0 +1,111 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2009 by Bertrik Sikken
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include <stdbool.h>
22
23#include "config.h"
24#include "backlight.h"
25#include "backlight-target.h"
26#include "system.h"
27
28/*
29 Interrupt-driven backlight driver using the PWM mode of a hardware timer.
30
31 Backlight brightness is implemented by configuring one of the timers in
32 the SoC for PWM mode. In this mode, two interrupts are generated for each
33 cycle, one at the start of the cycle and another one sometime between the
34 first interrupt and the start of the next cycle. The backlight is switched
35 on at the first interrupt and switched off at the second interrupt. This
36 way, the position in time of the second interrupt determines the duty cycle
37 and thereby the brightness of the backlight.
38 The backlight is switched on and off by means of a GPIO pin.
39 */
40
41void INT_TIMERA(void)
42{
43 unsigned int tacon = TACON;
44
45 /* clear interrupts */
46 TACON = tacon;
47
48 /* TA_INT1, start of PWM cycle: enable backlight */
49 if (tacon & (1 << 17)) {
50 PDAT0 |= (1 << 2);
51 }
52
53 /* TA_INT0, disable backlight until next cycle */
54 if (tacon & (1 << 16)) {
55 PDAT0 &= ~(1 << 2);
56 }
57}
58
59void _backlight_set_brightness(int brightness)
60{
61 if (brightness == MIN_BRIGHTNESS_SETTING) {
62 /* turn backlight fully off and disable interrupt */
63 PDAT0 &= ~(1 << 2);
64 INTMSK &= ~(1 << 5);
65 }
66 else if (brightness == MAX_BRIGHTNESS_SETTING) {
67 /* turn backlight fully on and disable interrupt */
68 PDAT0 |= (1 << 2);
69 INTMSK &= ~(1 << 5);
70 }
71 else {
72 /* set PWM width and enable interrupt */
73 TADATA0 = brightness;
74 INTMSK |= (1 << 5);
75 }
76}
77
78void _backlight_on(void)
79{
80 _backlight_set_brightness(backlight_brightness);
81}
82
83void _backlight_off(void)
84{
85 _backlight_set_brightness(MIN_BRIGHTNESS_SETTING);
86}
87
88bool _backlight_init(void)
89{
90 /* enable backlight pin as GPIO */
91 PCON0 = ((PCON0 & ~(3 << 4)) | (1 << 4));
92
93 /* enable timer clock */
94 PWRCON &= ~(1 << 4);
95
96 /* configure timer */
97 TACMD = (1 << 1); /* TA_CLR */
98 TACMD = (1 << 0); /* TA_EN */
99 TACON = (1 << 13) | /* TA_INT1_EN */
100 (1 << 12) | /* TA_INT0_EN */
101 (1 << 11) | /* TA_START */
102 (3 << 8) | /* TA_CS = PCLK / 64 */
103 (1 << 4); /* TA_MODE_SEL = PWM mode */
104 TADATA1 = MAX_BRIGHTNESS_SETTING; /* set PWM period */
105 TAPRE = 100; /* prescaler */
106
107 _backlight_on();
108
109 return true;
110}
111
diff --git a/firmware/target/arm/s5l8700/meizu-m3/backlight-target.h b/firmware/target/arm/s5l8700/backlight-target.h
index 91579b080d..91579b080d 100644
--- a/firmware/target/arm/s5l8700/meizu-m3/backlight-target.h
+++ b/firmware/target/arm/s5l8700/backlight-target.h
diff --git a/firmware/target/arm/s5l8700/meizu-m6sl/backlight-target.h b/firmware/target/arm/s5l8700/meizu-m6sl/backlight-target.h
deleted file mode 100644
index 91579b080d..0000000000
--- a/firmware/target/arm/s5l8700/meizu-m6sl/backlight-target.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Marcoen Hirschberg
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef BACKLIGHT_TARGET_H
22#define BACKLIGHT_TARGET_H
23
24bool _backlight_init(void);
25void _backlight_on(void);
26void _backlight_off(void);
27void _backlight_set_brightness(int brightness);
28
29#endif
diff --git a/firmware/target/arm/s5l8700/meizu-m6sp/backlight-target.h b/firmware/target/arm/s5l8700/meizu-m6sp/backlight-target.h
deleted file mode 100644
index 91579b080d..0000000000
--- a/firmware/target/arm/s5l8700/meizu-m6sp/backlight-target.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Marcoen Hirschberg
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef BACKLIGHT_TARGET_H
22#define BACKLIGHT_TARGET_H
23
24bool _backlight_init(void);
25void _backlight_on(void);
26void _backlight_off(void);
27void _backlight_set_brightness(int brightness);
28
29#endif
diff --git a/firmware/target/arm/s5l8700/system-s5l8700.c b/firmware/target/arm/s5l8700/system-s5l8700.c
index c535a0d955..48c50645e9 100644
--- a/firmware/target/arm/s5l8700/system-s5l8700.c
+++ b/firmware/target/arm/s5l8700/system-s5l8700.c
@@ -95,12 +95,13 @@ void irq_handler(void)
95 asm volatile( "stmfd sp!, {r0-r7, ip, lr} \n" /* Store context */ 95 asm volatile( "stmfd sp!, {r0-r7, ip, lr} \n" /* Store context */
96 "sub sp, sp, #8 \n"); /* Reserve stack */ 96 "sub sp, sp, #8 \n"); /* Reserve stack */
97 97
98 int irq_no = INTOFFSET; /* Read clears the corresponding IRQ status */ 98 int irq_no = INTOFFSET;
99 99
100 if ((irq_no & (1<<31)) == 0) /* Ensure invalid flag is not set */ 100 irqvector[irq_no]();
101 { 101
102 irqvector[irq_no](); 102 /* clear interrupt */
103 } 103 SRCPND = (1 << irq_no);
104 INTPND = INTPND;
104 105
105 asm volatile( "add sp, sp, #8 \n" /* Cleanup stack */ 106 asm volatile( "add sp, sp, #8 \n" /* Cleanup stack */
106 "ldmfd sp!, {r0-r7, ip, lr} \n" /* Restore context */ 107 "ldmfd sp!, {r0-r7, ip, lr} \n" /* Restore context */