summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
authorAmaury Pouly <pamaury@rockbox.org>2011-10-27 10:38:19 +0000
committerAmaury Pouly <pamaury@rockbox.org>2011-10-27 10:38:19 +0000
commitf5d664ad934d74b8444c2432c3c37c0571fa8e4a (patch)
tree9565f7582ebd2c7977e5af9518f24445843ec350 /firmware/target
parent320c3c2ca9839e17db222f25da3ef00c42bcde01 (diff)
downloadrockbox-f5d664ad934d74b8444c2432c3c37c0571fa8e4a.tar.gz
rockbox-f5d664ad934d74b8444c2432c3c37c0571fa8e4a.zip
fuzeplus: rework button handling to use a queue instead of a blocking semaphore in the thread
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30844 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c
index 3ee72ac6d7..fdcc214ae6 100644
--- a/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c
+++ b/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c
@@ -26,6 +26,7 @@
26#include "synaptics-rmi.h" 26#include "synaptics-rmi.h"
27#include "lcd.h" 27#include "lcd.h"
28#include "string.h" 28#include "string.h"
29#include "usb.h"
29 30
30#ifndef BOOTLOADER 31#ifndef BOOTLOADER
31 32
@@ -186,10 +187,12 @@ static struct button_area_t button_areas[] =
186 {0, 0, 0, 0, 0}, 187 {0, 0, 0, 0, 0},
187}; 188};
188 189
190#define RMI_INTERRUPT 1
191
189static int touchpad_btns = 0; 192static int touchpad_btns = 0;
190static long rmi_stack [DEFAULT_STACK_SIZE/sizeof(long)]; 193static long rmi_stack [DEFAULT_STACK_SIZE/sizeof(long)];
191static const char rmi_thread_name[] = "rmi"; 194static const char rmi_thread_name[] = "rmi";
192static struct semaphore rmi_sema; 195static struct event_queue rmi_queue;
193 196
194static int find_button(int x, int y) 197static int find_button(int x, int y)
195{ 198{
@@ -212,16 +215,26 @@ void rmi_attn_cb(int bank, int pin)
212{ 215{
213 (void) bank; 216 (void) bank;
214 (void) pin; 217 (void) pin;
215 semaphore_release(&rmi_sema); 218 /* the callback will not be fired until interrupt is enabled back so
219 * the queue will not overflow or contain multiple RMI_INTERRUPT events */
220 queue_post(&rmi_queue, RMI_INTERRUPT, 0);
216} 221}
217 222
218void rmi_thread(void) 223void rmi_thread(void)
219{ 224{
220 semaphore_init(&rmi_sema, 1, 0); 225 struct queue_event ev;
226
221 while(1) 227 while(1)
222 { 228 {
223 imx233_setup_pin_irq(0, 27, true, true, false, &rmi_attn_cb); 229 queue_wait(&rmi_queue, &ev);
224 semaphore_wait(&rmi_sema, TIMEOUT_BLOCK); 230 /* handle usb connect and ignore all messages except rmi interrupts */
231 if(ev.id == SYS_USB_CONNECTED)
232 {
233 usb_acknowledge(SYS_USB_CONNECTED_ACK);
234 continue;
235 }
236 else if(ev.id != RMI_INTERRUPT)
237 continue;
225 /* clear interrupt */ 238 /* clear interrupt */
226 rmi_read_single(RMI_INTERRUPT_REQUEST); 239 rmi_read_single(RMI_INTERRUPT_REQUEST);
227 /* read data */ 240 /* read data */
@@ -244,6 +257,8 @@ void rmi_thread(void)
244 touchpad_btns = 0; 257 touchpad_btns = 0;
245 else 258 else
246 touchpad_btns = find_button(absolute_x, absolute_y); 259 touchpad_btns = find_button(absolute_x, absolute_y);
260 /* enable interrupt */
261 imx233_setup_pin_irq(0, 27, true, true, false, &rmi_attn_cb);
247 } 262 }
248} 263}
249 264
@@ -286,8 +301,11 @@ void button_init_device(void)
286 RMI_2D_GESTURE_FLICK_DIST_4MM << RMI_2D_GESTURE_FLICK_DIST_BP | 301 RMI_2D_GESTURE_FLICK_DIST_4MM << RMI_2D_GESTURE_FLICK_DIST_BP |
287 RMI_2D_GESTURE_FLICK_TIME_700MS << RMI_2D_GESTURE_FLICK_TIME_BP); 302 RMI_2D_GESTURE_FLICK_TIME_700MS << RMI_2D_GESTURE_FLICK_TIME_BP);
288 303
304 queue_init(&rmi_queue, true);
289 create_thread(rmi_thread, rmi_stack, sizeof(rmi_stack), 0, 305 create_thread(rmi_thread, rmi_stack, sizeof(rmi_stack), 0,
290 rmi_thread_name IF_PRIO(, PRIORITY_USER_INTERFACE) IF_COP(, CPU)); 306 rmi_thread_name IF_PRIO(, PRIORITY_USER_INTERFACE) IF_COP(, CPU));
307 /* enable interrupt */
308 imx233_setup_pin_irq(0, 27, true, true, false, &rmi_attn_cb);
291} 309}
292 310
293#else 311#else