diff options
author | Mark Arigo <markarigo@gmail.com> | 2009-06-19 02:48:15 +0000 |
---|---|---|
committer | Mark Arigo <markarigo@gmail.com> | 2009-06-19 02:48:15 +0000 |
commit | 4c58ad26ba462309f95790c32421130a73909f05 (patch) | |
tree | 96af9c1cda5f21e5af6443b13171ed66ccb1d9d1 /firmware/target/arm/philips | |
parent | 753064fccf270643edc8d60e46886e327b099c49 (diff) | |
download | rockbox-4c58ad26ba462309f95790c32421130a73909f05.tar.gz rockbox-4c58ad26ba462309f95790c32421130a73909f05.zip |
Clean up the Synaptics touchpad driver.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21344 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/philips')
4 files changed, 36 insertions, 94 deletions
diff --git a/firmware/target/arm/philips/hdd1630/backlight-hdd1630.c b/firmware/target/arm/philips/hdd1630/backlight-hdd1630.c index eafce13759..cc8f04dda9 100755 --- a/firmware/target/arm/philips/hdd1630/backlight-hdd1630.c +++ b/firmware/target/arm/philips/hdd1630/backlight-hdd1630.c | |||
@@ -47,41 +47,15 @@ void _backlight_off(void) | |||
47 | } | 47 | } |
48 | 48 | ||
49 | #ifdef HAVE_BUTTON_LIGHT | 49 | #ifdef HAVE_BUTTON_LIGHT |
50 | |||
51 | #define BUTTONLIGHT_MASK 0x7f | 50 | #define BUTTONLIGHT_MASK 0x7f |
52 | |||
53 | static unsigned short buttonight_brightness = DEFAULT_BRIGHTNESS_SETTING - 1; | 51 | static unsigned short buttonight_brightness = DEFAULT_BRIGHTNESS_SETTING - 1; |
54 | static unsigned short buttonlight_status = 0; | 52 | static unsigned short buttonlight_status = 0; |
55 | 53 | ||
56 | static void set_buttonlight(int brightness) | ||
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 | } | ||
78 | } | ||
79 | |||
80 | void _buttonlight_on(void) | 54 | void _buttonlight_on(void) |
81 | { | 55 | { |
82 | if (!buttonlight_status) | 56 | if (!buttonlight_status) |
83 | { | 57 | { |
84 | set_buttonlight(buttonight_brightness); | 58 | touchpad_set_buttonlights(BUTTONLIGHT_MASK, buttonight_brightness); |
85 | buttonlight_status = 1; | 59 | buttonlight_status = 1; |
86 | } | 60 | } |
87 | } | 61 | } |
@@ -90,7 +64,7 @@ void _buttonlight_off(void) | |||
90 | { | 64 | { |
91 | if (buttonlight_status) | 65 | if (buttonlight_status) |
92 | { | 66 | { |
93 | set_buttonlight(0); | 67 | touchpad_set_buttonlights(BUTTONLIGHT_MASK, 0); |
94 | buttonlight_status = 0; | 68 | buttonlight_status = 0; |
95 | } | 69 | } |
96 | } | 70 | } |
@@ -98,7 +72,7 @@ void _buttonlight_off(void) | |||
98 | void _buttonlight_set_brightness(int brightness) | 72 | void _buttonlight_set_brightness(int brightness) |
99 | { | 73 | { |
100 | buttonight_brightness = brightness - 1; | 74 | buttonight_brightness = brightness - 1; |
101 | set_buttonlight(buttonight_brightness); | 75 | touchpad_set_buttonlights(BUTTONLIGHT_MASK, buttonight_brightness); |
102 | buttonlight_status = 1; | 76 | buttonlight_status = 1; |
103 | } | 77 | } |
104 | #endif | 78 | #endif |
diff --git a/firmware/target/arm/philips/hdd1630/button-hdd1630.c b/firmware/target/arm/philips/hdd1630/button-hdd1630.c index e8214edf91..d45944ef10 100755 --- a/firmware/target/arm/philips/hdd1630/button-hdd1630.c +++ b/firmware/target/arm/philips/hdd1630/button-hdd1630.c | |||
@@ -27,10 +27,6 @@ | |||
27 | #define LOGF_ENABLE | 27 | #define LOGF_ENABLE |
28 | #include "logf.h" | 28 | #include "logf.h" |
29 | 29 | ||
30 | #define MEP_BUTTON_HEADER 0x19 | ||
31 | #define MEP_BUTTON_ID 0x9 | ||
32 | #define MEP_ABSOLUTE_HEADER 0x0b | ||
33 | |||
34 | static int int_btn = BUTTON_NONE; | 30 | static int int_btn = BUTTON_NONE; |
35 | 31 | ||
36 | /* | 32 | /* |
@@ -48,10 +44,8 @@ void button_click(void) | |||
48 | #ifndef BOOTLOADER | 44 | #ifndef BOOTLOADER |
49 | void button_init_device(void) | 45 | void button_init_device(void) |
50 | { | 46 | { |
51 | if (!syn_get_status()) | 47 | /* The touchpad is powered on and initialized in power-hdd1630.c |
52 | { | 48 | since it needs to be ready for both buttons and button lights. */ |
53 | logf("button_init_dev: touchpad not ready"); | ||
54 | } | ||
55 | } | 49 | } |
56 | 50 | ||
57 | /* | 51 | /* |
@@ -59,66 +53,33 @@ void button_init_device(void) | |||
59 | */ | 53 | */ |
60 | void button_int(void) | 54 | void button_int(void) |
61 | { | 55 | { |
62 | int data[4]; | 56 | char data[4]; |
63 | int val, id; | 57 | int val; |
64 | 58 | ||
65 | int_btn = BUTTON_NONE; | 59 | int_btn = BUTTON_NONE; |
66 | 60 | ||
67 | if (syn_get_status()) | 61 | val = touchpad_read_device(data, 4); |
62 | |||
63 | if (val == MEP_BUTTON_HEADER) | ||
64 | { | ||
65 | /* Buttons packet */ | ||
66 | if (data[1] & 0x1) | ||
67 | int_btn |= BUTTON_LEFT; | ||
68 | if (data[1] & 0x2) | ||
69 | int_btn |= BUTTON_RIGHT; | ||
70 | } | ||
71 | else if (val == MEP_ABSOLUTE_HEADER) | ||
68 | { | 72 | { |
69 | /* disable interrupt while we read the touchpad */ | 73 | /* Absolute packet - the finger is on the vertical strip. |
70 | syn_int_enable(false); | 74 | Position ranges from 1-4095, with 1 at the bottom. */ |
71 | 75 | val = ((data[1] >> 4) << 8) | data[2]; /* position */ | |
72 | val = syn_read(data, 4); | 76 | |
73 | if (val > 0) | 77 | if ((val > 0) && (val <= 1365)) |
74 | { | 78 | int_btn |= BUTTON_DOWN; |
75 | val = data[0] & 0xff; /* packet header */ | 79 | else if ((val > 1365) && (val <= 2730)) |
76 | id = (data[1] >> 4) & 0xf; /* packet id */ | 80 | int_btn |= BUTTON_SELECT; |
77 | 81 | else if ((val > 2730) && (val <= 4095)) | |
78 | logf("syn_read:"); | 82 | int_btn |= BUTTON_UP; |
79 | logf(" data[0] = 0x%08x", data[0]); | ||
80 | logf(" data[1] = 0x%08x", data[1]); | ||
81 | logf(" data[2] = 0x%08x", data[2]); | ||
82 | logf(" data[3] = 0x%08x", data[3]); | ||
83 | |||
84 | if ((val == MEP_BUTTON_HEADER) && (id == MEP_BUTTON_ID)) | ||
85 | { | ||
86 | /* Buttons packet */ | ||
87 | if (data[1] & 0x1) | ||
88 | int_btn |= BUTTON_LEFT; | ||
89 | if (data[1] & 0x2) | ||
90 | int_btn |= BUTTON_RIGHT; | ||
91 | |||
92 | /* An Absolute packet should follow which we ignore */ | ||
93 | val = syn_read(data, 4); | ||
94 | logf(" int_btn = 0x%04x", int_btn); | ||
95 | } | ||
96 | else if (val == MEP_ABSOLUTE_HEADER) | ||
97 | { | ||
98 | /* Absolute packet - the finger is on the vertical strip. | ||
99 | Position ranges from 1-4095, with 1 at the bottom. */ | ||
100 | val = ((data[1] >> 4) << 8) | data[2]; /* position */ | ||
101 | |||
102 | logf(" pos %d", val); | ||
103 | logf(" z %d", data[3]); | ||
104 | logf(" finger %d", data[1] & 0x1); | ||
105 | logf(" gesture %d", data[1] & 0x2); | ||
106 | logf(" RelPosVld %d", data[1] & 0x4); | ||
107 | |||
108 | if(data[1] & 0x1) /* if finger on touch strip */ | ||
109 | { | ||
110 | if ((val > 0) && (val <= 1365)) | ||
111 | int_btn |= BUTTON_DOWN; | ||
112 | else if ((val > 1365) && (val <= 2730)) | ||
113 | int_btn |= BUTTON_SELECT; | ||
114 | else if ((val > 2730) && (val <= 4095)) | ||
115 | int_btn |= BUTTON_UP; | ||
116 | } | ||
117 | } | ||
118 | } | ||
119 | |||
120 | /* re-enable interrupts */ | ||
121 | syn_int_enable(true); | ||
122 | } | 83 | } |
123 | } | 84 | } |
124 | #else | 85 | #else |
diff --git a/firmware/target/arm/philips/hdd1630/button-target.h b/firmware/target/arm/philips/hdd1630/button-target.h index cd5b13775e..b7fc21aca2 100755 --- a/firmware/target/arm/philips/hdd1630/button-target.h +++ b/firmware/target/arm/philips/hdd1630/button-target.h | |||
@@ -25,6 +25,10 @@ | |||
25 | #include <stdbool.h> | 25 | #include <stdbool.h> |
26 | #include "config.h" | 26 | #include "config.h" |
27 | 27 | ||
28 | #define MEP_BUTTON_HEADER 0x19 | ||
29 | #define MEP_BUTTON_ID 0x9 | ||
30 | #define MEP_ABSOLUTE_HEADER 0x0b | ||
31 | |||
28 | #define HAS_BUTTON_HOLD | 32 | #define HAS_BUTTON_HOLD |
29 | 33 | ||
30 | bool button_hold(void); | 34 | bool button_hold(void); |
diff --git a/firmware/target/arm/philips/hdd1630/power-hdd1630.c b/firmware/target/arm/philips/hdd1630/power-hdd1630.c index 81d5040d23..c348567529 100755 --- a/firmware/target/arm/philips/hdd1630/power-hdd1630.c +++ b/firmware/target/arm/philips/hdd1630/power-hdd1630.c | |||
@@ -65,7 +65,10 @@ void power_init(void) | |||
65 | GPIOA_OUTPUT_EN |= 0x10; /* set DATA */ | 65 | GPIOA_OUTPUT_EN |= 0x10; /* set DATA */ |
66 | GPIOA_OUTPUT_VAL |= 0x10; /* high */ | 66 | GPIOA_OUTPUT_VAL |= 0x10; /* high */ |
67 | 67 | ||
68 | syn_init(); | 68 | if (!touchpad_init()) |
69 | { | ||
70 | logf("touchpad not ready"); | ||
71 | } | ||
69 | #endif | 72 | #endif |
70 | } | 73 | } |
71 | 74 | ||