diff options
Diffstat (limited to 'firmware/target')
6 files changed, 66 insertions, 163 deletions
diff --git a/firmware/target/arm/olympus/mrobe-100/button-mr100.c b/firmware/target/arm/olympus/mrobe-100/button-mr100.c index 130c32739a..d4479278ef 100644 --- a/firmware/target/arm/olympus/mrobe-100/button-mr100.c +++ b/firmware/target/arm/olympus/mrobe-100/button-mr100.c | |||
@@ -28,10 +28,6 @@ | |||
28 | #define LOGF_ENABLE | 28 | #define LOGF_ENABLE |
29 | #include "logf.h" | 29 | #include "logf.h" |
30 | 30 | ||
31 | #define MEP_BUTTON_HEADER 0x1a | ||
32 | #define MEP_BUTTON_ID 0x9 | ||
33 | #define MEP_ABSOLUTE_HEADER 0x0b | ||
34 | |||
35 | static int int_btn = BUTTON_NONE; | 31 | static int int_btn = BUTTON_NONE; |
36 | 32 | ||
37 | #ifndef BOOTLOADER | 33 | #ifndef BOOTLOADER |
@@ -56,9 +52,9 @@ void button_init_device(void) | |||
56 | GPIOD_OUTPUT_EN |= 0x4; /* DATA */ | 52 | GPIOD_OUTPUT_EN |= 0x4; /* DATA */ |
57 | GPIOD_OUTPUT_VAL |= 0x4; /* high */ | 53 | GPIOD_OUTPUT_VAL |= 0x4; /* high */ |
58 | 54 | ||
59 | if (!syn_init()) | 55 | if (!touchpad_init()) |
60 | { | 56 | { |
61 | logf("button_init_dev: touchpad not ready"); | 57 | logf("touchpad not ready"); |
62 | } | 58 | } |
63 | } | 59 | } |
64 | 60 | ||
@@ -67,73 +63,34 @@ void button_init_device(void) | |||
67 | */ | 63 | */ |
68 | void button_int(void) | 64 | void button_int(void) |
69 | { | 65 | { |
70 | int data[4]; | 66 | char data[4]; |
71 | int val, id; | 67 | int val; |
72 | 68 | ||
73 | int_btn = BUTTON_NONE; | 69 | int_btn = BUTTON_NONE; |
74 | 70 | ||
75 | if (syn_get_status()) | 71 | val = touchpad_read_device(data, 4); |
72 | |||
73 | if (val == MEP_BUTTON_HEADER) | ||
74 | { | ||
75 | /* Buttons packet - touched one of the 5 "buttons" */ | ||
76 | if (data[1] & 0x1) int_btn |= BUTTON_PLAY; | ||
77 | if (data[1] & 0x2) int_btn |= BUTTON_MENU; | ||
78 | if (data[1] & 0x4) int_btn |= BUTTON_LEFT; | ||
79 | if (data[1] & 0x8) int_btn |= BUTTON_DISPLAY; | ||
80 | if (data[2] & 0x1) int_btn |= BUTTON_RIGHT; | ||
81 | } | ||
82 | else if (val == MEP_ABSOLUTE_HEADER) | ||
76 | { | 83 | { |
77 | /* disable interrupt while we read the touchpad */ | 84 | /* Absolute packet - the finger is on the vertical strip. |
78 | syn_int_enable(false); | 85 | Position ranges from 1-4095, with 1 at the bottom. */ |
79 | 86 | val = ((data[1] >> 4) << 8) | data[2]; /* position */ | |
80 | val = syn_read(data, 4); | 87 | |
81 | if (val > 0) | 88 | if ((val > 0) && (val <= 1365)) |
82 | { | 89 | int_btn |= BUTTON_DOWN; |
83 | val = data[0] & 0xff; /* packet header */ | 90 | else if ((val > 1365) && (val <= 2730)) |
84 | id = (data[1] >> 4) & 0xf; /* packet id */ | 91 | int_btn |= BUTTON_SELECT; |
85 | 92 | else if ((val > 2730) && (val <= 4095)) | |
86 | logf("button_read_device..."); | 93 | int_btn |= BUTTON_UP; |
87 | logf(" data[0] = 0x%08x", data[0]); | ||
88 | logf(" data[1] = 0x%08x", data[1]); | ||
89 | logf(" data[2] = 0x%08x", data[2]); | ||
90 | logf(" data[3] = 0x%08x", data[3]); | ||
91 | |||
92 | if ((val == MEP_BUTTON_HEADER) && (id == MEP_BUTTON_ID)) | ||
93 | { | ||
94 | /* Buttons packet - touched one of the 5 "buttons" */ | ||
95 | if (data[1] & 0x1) | ||
96 | int_btn |= BUTTON_PLAY; | ||
97 | if (data[1] & 0x2) | ||
98 | int_btn |= BUTTON_MENU; | ||
99 | if (data[1] & 0x4) | ||
100 | int_btn |= BUTTON_LEFT; | ||
101 | if (data[1] & 0x8) | ||
102 | int_btn |= BUTTON_DISPLAY; | ||
103 | if (data[2] & 0x1) | ||
104 | int_btn |= BUTTON_RIGHT; | ||
105 | |||
106 | /* An Absolute packet should follow which we ignore */ | ||
107 | val = syn_read(data, 4); | ||
108 | |||
109 | logf(" int_btn = 0x%04x", int_btn); | ||
110 | } | ||
111 | else if (val == MEP_ABSOLUTE_HEADER) | ||
112 | { | ||
113 | /* Absolute packet - the finger is on the vertical strip. | ||
114 | Position ranges from 1-4095, with 1 at the bottom. */ | ||
115 | val = ((data[1] >> 4) << 8) | data[2]; /* position */ | ||
116 | |||
117 | logf(" pos %d", val); | ||
118 | logf(" z %d", data[3]); | ||
119 | logf(" finger %d", data[1] & 0x1); | ||
120 | logf(" gesture %d", data[1] & 0x2); | ||
121 | logf(" RelPosVld %d", data[1] & 0x4); | ||
122 | |||
123 | if(data[1] & 0x1) /* if finger on touch strip */ | ||
124 | { | ||
125 | if ((val > 0) && (val <= 1365)) | ||
126 | int_btn |= BUTTON_DOWN; | ||
127 | else if ((val > 1365) && (val <= 2730)) | ||
128 | int_btn |= BUTTON_SELECT; | ||
129 | else if ((val > 2730) && (val <= 4095)) | ||
130 | int_btn |= BUTTON_UP; | ||
131 | } | ||
132 | } | ||
133 | } | ||
134 | |||
135 | /* re-enable interrupts */ | ||
136 | syn_int_enable(true); | ||
137 | } | 94 | } |
138 | } | 95 | } |
139 | #else | 96 | #else |
diff --git a/firmware/target/arm/olympus/mrobe-100/button-target.h b/firmware/target/arm/olympus/mrobe-100/button-target.h index c6b2c1067f..900211ebe4 100644 --- a/firmware/target/arm/olympus/mrobe-100/button-target.h +++ b/firmware/target/arm/olympus/mrobe-100/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 0x1a | ||
29 | #define MEP_BUTTON_ID 0x09 | ||
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/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 | ||