summaryrefslogtreecommitdiff
path: root/firmware/target/arm
diff options
context:
space:
mode:
authorMark Arigo <markarigo@gmail.com>2009-02-18 02:19:22 +0000
committerMark Arigo <markarigo@gmail.com>2009-02-18 02:19:22 +0000
commitf34cd80f638a6ca3b336f6ebd14cd958974b2760 (patch)
tree91195848e098a6f0f6372d39424306e32d3df9d2 /firmware/target/arm
parent42ef5b0c88f92418c79e7414063c808b7c36a9be (diff)
downloadrockbox-f34cd80f638a6ca3b336f6ebd14cd958974b2760.tar.gz
rockbox-f34cd80f638a6ca3b336f6ebd14cd958974b2760.zip
Backlight brightness and button lights for the Philips HDD1630
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20035 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm')
-rw-r--r--firmware/target/arm/olympus/mrobe-100/button-mr100.c30
-rwxr-xr-xfirmware/target/arm/philips/hdd1630/backlight-hdd1630.c59
-rwxr-xr-xfirmware/target/arm/philips/hdd1630/backlight-target.h2
-rwxr-xr-xfirmware/target/arm/philips/hdd1630/button-hdd1630.c48
-rwxr-xr-xfirmware/target/arm/philips/hdd1630/power-hdd1630.c23
5 files changed, 92 insertions, 70 deletions
diff --git a/firmware/target/arm/olympus/mrobe-100/button-mr100.c b/firmware/target/arm/olympus/mrobe-100/button-mr100.c
index 9cfd8affa9..130c32739a 100644
--- a/firmware/target/arm/olympus/mrobe-100/button-mr100.c
+++ b/firmware/target/arm/olympus/mrobe-100/button-mr100.c
@@ -35,8 +35,6 @@
35static int int_btn = BUTTON_NONE; 35static int int_btn = BUTTON_NONE;
36 36
37#ifndef BOOTLOADER 37#ifndef BOOTLOADER
38static int syn_status = 0;
39
40void button_init_device(void) 38void button_init_device(void)
41{ 39{
42 /* enable touchpad leds */ 40 /* enable touchpad leds */
@@ -58,21 +56,9 @@ void button_init_device(void)
58 GPIOD_OUTPUT_EN |= 0x4; /* DATA */ 56 GPIOD_OUTPUT_EN |= 0x4; /* DATA */
59 GPIOD_OUTPUT_VAL |= 0x4; /* high */ 57 GPIOD_OUTPUT_VAL |= 0x4; /* high */
60 58
61 if (syn_init()) 59 if (!syn_init())
62 { 60 {
63#ifdef ROCKBOX_HAS_LOGF 61 logf("button_init_dev: touchpad not ready");
64 syn_info();
65#endif
66
67 syn_status = 1;
68
69 /* enable interrupts */
70 GPIOD_INT_LEV &= ~0x2;
71 GPIOD_INT_CLR |= 0x2;
72 GPIOD_INT_EN |= 0x2;
73
74 CPU_INT_EN |= HI_MASK;
75 CPU_HI_INT_EN |= GPIO0_MASK;
76 } 62 }
77} 63}
78 64
@@ -86,13 +72,12 @@ void button_int(void)
86 72
87 int_btn = BUTTON_NONE; 73 int_btn = BUTTON_NONE;
88 74
89 if (syn_status) 75 if (syn_get_status())
90 { 76 {
91 /* disable interrupt while we read the touchpad */ 77 /* disable interrupt while we read the touchpad */
92 GPIOD_INT_EN &= ~0x2; 78 syn_int_enable(false);
93 GPIOD_INT_CLR |= 0x2;
94 79
95 val = syn_read_device(data, 4); 80 val = syn_read(data, 4);
96 if (val > 0) 81 if (val > 0)
97 { 82 {
98 val = data[0] & 0xff; /* packet header */ 83 val = data[0] & 0xff; /* packet header */
@@ -119,7 +104,7 @@ void button_int(void)
119 int_btn |= BUTTON_RIGHT; 104 int_btn |= BUTTON_RIGHT;
120 105
121 /* An Absolute packet should follow which we ignore */ 106 /* An Absolute packet should follow which we ignore */
122 val = syn_read_device(data, 4); 107 val = syn_read(data, 4);
123 108
124 logf(" int_btn = 0x%04x", int_btn); 109 logf(" int_btn = 0x%04x", int_btn);
125 } 110 }
@@ -148,8 +133,7 @@ void button_int(void)
148 } 133 }
149 134
150 /* re-enable interrupts */ 135 /* re-enable interrupts */
151 GPIOD_INT_LEV &= ~0x2; 136 syn_int_enable(true);
152 GPIOD_INT_EN |= 0x2;
153 } 137 }
154} 138}
155#else 139#else
diff --git a/firmware/target/arm/philips/hdd1630/backlight-hdd1630.c b/firmware/target/arm/philips/hdd1630/backlight-hdd1630.c
index eb2c2731ac..eafce13759 100755
--- a/firmware/target/arm/philips/hdd1630/backlight-hdd1630.c
+++ b/firmware/target/arm/philips/hdd1630/backlight-hdd1630.c
@@ -21,35 +21,84 @@
21#include "config.h" 21#include "config.h"
22#include "backlight-target.h" 22#include "backlight-target.h"
23#include "system.h" 23#include "system.h"
24#include "lcd.h"
25#include "backlight.h" 24#include "backlight.h"
25#include "synaptics-mep.h"
26 26
27#ifdef HAVE_BACKLIGHT_BRIGHTNESS 27#ifdef HAVE_BACKLIGHT_BRIGHTNESS
28static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING; 28static const int brightness_vals[16] =
29 {255,237,219,201,183,165,147,130,112,94,76,58,40,22,5,0};
29 30
30void _backlight_set_brightness(int brightness) 31void _backlight_set_brightness(int brightness)
31{ 32{
33 outl(0x80000000 | (brightness_vals[brightness-1] << 16), 0x7000a000);
32} 34}
33#endif 35#endif
34 36
35void _backlight_on(void) 37void _backlight_on(void)
36{ 38{
37 GPO32_VAL &= ~0x1000000; 39 GPO32_VAL &= ~0x1000000;
38 GPO32_ENABLE &= ~0x1000000; 40 GPO32_ENABLE &= ~0x1000000;
39} 41}
40 42
41void _backlight_off(void) 43void _backlight_off(void)
42{ 44{
43 GPO32_VAL |= 0x1000000; 45 GPO32_VAL |= 0x1000000;
44 GPO32_ENABLE |= 0x1000000; 46 GPO32_ENABLE |= 0x1000000;
45} 47}
46 48
47#ifdef HAVE_BUTTON_LIGHT 49#ifdef HAVE_BUTTON_LIGHT
48void _buttonlight_on(void) 50
51#define BUTTONLIGHT_MASK 0x7f
52
53static unsigned short buttonight_brightness = DEFAULT_BRIGHTNESS_SETTING - 1;
54static unsigned short buttonlight_status = 0;
55
56static void set_buttonlight(int brightness)
49{ 57{
58 int data[6];
59
60 if (syn_get_status())
61 {
62 syn_int_enable(false);
63
64 /* turn on all touchpad leds */
65 data[0] = 0x05;
66 data[1] = 0x31;
67 data[2] = (brightness & 0xff) << 4;
68 data[3] = 0x00;
69 data[4] = 0x00;
70 data[5] = BUTTONLIGHT_MASK;
71 syn_send(data, 6);
72
73 /* device responds with a single-byte ACK packet */
74 syn_read(data, 2);
75
76 syn_int_enable(true);
77 }
50} 78}
51 79
80void _buttonlight_on(void)
81{
82 if (!buttonlight_status)
83 {
84 set_buttonlight(buttonight_brightness);
85 buttonlight_status = 1;
86 }
87}
88
52void _buttonlight_off(void) 89void _buttonlight_off(void)
53{ 90{
91 if (buttonlight_status)
92 {
93 set_buttonlight(0);
94 buttonlight_status = 0;
95 }
96}
97
98void _buttonlight_set_brightness(int brightness)
99{
100 buttonight_brightness = brightness - 1;
101 set_buttonlight(buttonight_brightness);
102 buttonlight_status = 1;
54} 103}
55#endif 104#endif
diff --git a/firmware/target/arm/philips/hdd1630/backlight-target.h b/firmware/target/arm/philips/hdd1630/backlight-target.h
index 8fb5fa1a56..c7aca54a23 100755
--- a/firmware/target/arm/philips/hdd1630/backlight-target.h
+++ b/firmware/target/arm/philips/hdd1630/backlight-target.h
@@ -24,7 +24,6 @@
24#define _backlight_init() true 24#define _backlight_init() true
25void _backlight_on(void); 25void _backlight_on(void);
26void _backlight_off(void); 26void _backlight_off(void);
27int __backlight_is_on(void);
28 27
29#ifdef HAVE_BACKLIGHT_BRIGHTNESS 28#ifdef HAVE_BACKLIGHT_BRIGHTNESS
30void _backlight_set_brightness(int brightness); 29void _backlight_set_brightness(int brightness);
@@ -33,6 +32,7 @@ void _backlight_set_brightness(int brightness);
33#ifdef HAVE_BUTTON_LIGHT 32#ifdef HAVE_BUTTON_LIGHT
34void _buttonlight_on(void); 33void _buttonlight_on(void);
35void _buttonlight_off(void); 34void _buttonlight_off(void);
35void _buttonlight_set_brightness(int brightness);
36#endif 36#endif
37 37
38#endif 38#endif
diff --git a/firmware/target/arm/philips/hdd1630/button-hdd1630.c b/firmware/target/arm/philips/hdd1630/button-hdd1630.c
index c0ac8d7c10..e8214edf91 100755
--- a/firmware/target/arm/philips/hdd1630/button-hdd1630.c
+++ b/firmware/target/arm/philips/hdd1630/button-hdd1630.c
@@ -46,41 +46,11 @@ void button_click(void)
46} 46}
47 47
48#ifndef BOOTLOADER 48#ifndef BOOTLOADER
49static int syn_status = 0;
50
51void button_init_device(void) 49void button_init_device(void)
52{ 50{
53 /* enable touchpad */ 51 if (!syn_get_status())
54 GPO32_ENABLE |= 0x80;
55 GPO32_VAL &= ~0x80;
56 udelay(1000);
57
58 /* enable ACK, CLK, DATA lines */
59 GPIOD_ENABLE |= 0x80;
60 GPIOA_ENABLE |= (0x10 | 0x20);
61
62 GPIOD_OUTPUT_EN |= 0x80; /* ACK */
63 GPIOD_OUTPUT_VAL |= 0x80; /* high */
64
65 GPIOA_OUTPUT_EN &= ~0x20; /* CLK */
66
67 GPIOA_OUTPUT_EN |= 0x10; /* DATA */
68 GPIOA_OUTPUT_VAL |= 0x10; /* high */
69
70 if (syn_init())
71 { 52 {
72#ifdef ROCKBOX_HAS_LOGF 53 logf("button_init_dev: touchpad not ready");
73 syn_info();
74#endif
75 syn_status = 1;
76
77 /* enable interrupts */
78 GPIOA_INT_LEV &= ~0x20;
79 GPIOA_INT_CLR |= 0x20;
80 GPIOA_INT_EN |= 0x20;
81
82 CPU_INT_EN |= HI_MASK;
83 CPU_HI_INT_EN |= GPIO0_MASK;
84 } 54 }
85} 55}
86 56
@@ -94,19 +64,18 @@ void button_int(void)
94 64
95 int_btn = BUTTON_NONE; 65 int_btn = BUTTON_NONE;
96 66
97 if (syn_status) 67 if (syn_get_status())
98 { 68 {
99 /* disable interrupt while we read the touchpad */ 69 /* disable interrupt while we read the touchpad */
100 GPIOA_INT_EN &= ~0x20; 70 syn_int_enable(false);
101 GPIOA_INT_CLR |= 0x20;
102 71
103 val = syn_read_device(data, 4); 72 val = syn_read(data, 4);
104 if (val > 0) 73 if (val > 0)
105 { 74 {
106 val = data[0] & 0xff; /* packet header */ 75 val = data[0] & 0xff; /* packet header */
107 id = (data[1] >> 4) & 0xf; /* packet id */ 76 id = (data[1] >> 4) & 0xf; /* packet id */
108 77
109 logf("button_read_device..."); 78 logf("syn_read:");
110 logf(" data[0] = 0x%08x", data[0]); 79 logf(" data[0] = 0x%08x", data[0]);
111 logf(" data[1] = 0x%08x", data[1]); 80 logf(" data[1] = 0x%08x", data[1]);
112 logf(" data[2] = 0x%08x", data[2]); 81 logf(" data[2] = 0x%08x", data[2]);
@@ -121,7 +90,7 @@ void button_int(void)
121 int_btn |= BUTTON_RIGHT; 90 int_btn |= BUTTON_RIGHT;
122 91
123 /* An Absolute packet should follow which we ignore */ 92 /* An Absolute packet should follow which we ignore */
124 val = syn_read_device(data, 4); 93 val = syn_read(data, 4);
125 logf(" int_btn = 0x%04x", int_btn); 94 logf(" int_btn = 0x%04x", int_btn);
126 } 95 }
127 else if (val == MEP_ABSOLUTE_HEADER) 96 else if (val == MEP_ABSOLUTE_HEADER)
@@ -149,8 +118,7 @@ void button_int(void)
149 } 118 }
150 119
151 /* re-enable interrupts */ 120 /* re-enable interrupts */
152 GPIOA_INT_LEV &= ~0x20; 121 syn_int_enable(true);
153 GPIOA_INT_EN |= 0x20;
154 } 122 }
155} 123}
156#else 124#else
diff --git a/firmware/target/arm/philips/hdd1630/power-hdd1630.c b/firmware/target/arm/philips/hdd1630/power-hdd1630.c
index 22e11c803a..02279fd560 100755
--- a/firmware/target/arm/philips/hdd1630/power-hdd1630.c
+++ b/firmware/target/arm/philips/hdd1630/power-hdd1630.c
@@ -28,6 +28,7 @@
28#include "power.h" 28#include "power.h"
29#include "logf.h" 29#include "logf.h"
30#include "usb.h" 30#include "usb.h"
31#include "synaptics-mep.h"
31 32
32void power_init(void) 33void power_init(void)
33{ 34{
@@ -46,6 +47,27 @@ void power_init(void)
46 GPIOE_OUTPUT_EN |= 0x40; 47 GPIOE_OUTPUT_EN |= 0x40;
47 GPIOE_OUTPUT_VAL &= ~0x40; /* off */ 48 GPIOE_OUTPUT_VAL &= ~0x40; /* off */
48#endif 49#endif
50
51#ifndef BOOTLOADER
52 /* enable touchpad here because we need it for
53 both buttons and button lights */
54 GPO32_ENABLE |= 0x80;
55 GPO32_VAL &= ~0x80;
56 udelay(1000);
57
58 GPIOD_ENABLE |= 0x80; /* enable ACK */
59 GPIOA_ENABLE |= (0x10 | 0x20); /* enable DATA, CLK */
60
61 GPIOD_OUTPUT_EN |= 0x80; /* set ACK */
62 GPIOD_OUTPUT_VAL |= 0x80; /* high */
63
64 GPIOA_OUTPUT_EN &= ~0x20; /* CLK */
65
66 GPIOA_OUTPUT_EN |= 0x10; /* set DATA */
67 GPIOA_OUTPUT_VAL |= 0x10; /* high */
68
69 syn_init();
70#endif
49} 71}
50 72
51unsigned int power_input_status(void) 73unsigned int power_input_status(void)
@@ -70,7 +92,6 @@ void ide_power_enable(bool on)
70 /* We do nothing */ 92 /* We do nothing */
71} 93}
72 94
73
74bool ide_powered(void) 95bool ide_powered(void)
75{ 96{
76 /* pretend we are always powered - we don't turn it off */ 97 /* pretend we are always powered - we don't turn it off */