summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-01-20 17:11:23 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-01-20 17:11:23 +0000
commit2da0f9bcfdf056255b298c0e61f0f4f0f950f869 (patch)
tree4bb8e4de0f500f73b6e81ce347c0b36ab763e4bf
parent5f52f6ee01fdd060fab9b72736daf06b3dbda212 (diff)
downloadrockbox-2da0f9bcfdf056255b298c0e61f0f4f0f950f869.tar.gz
rockbox-2da0f9bcfdf056255b298c0e61f0f4f0f950f869.zip
Fuze v2: Do button reading more efficiently by mapping button codes directly to the GPIO pin states where possible (all but 'home' and hold). This makes plugins incompatible; up the min version and sort things.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29097 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugin.c8
-rw-r--r--apps/plugin.h20
-rw-r--r--firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c24
-rw-r--r--firmware/target/arm/as3525/sansa-fuzev2/button-target.h9
4 files changed, 27 insertions, 34 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index 20ff190e37..690aee9bf3 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -382,6 +382,7 @@ static const struct plugin_api rockbox_api = {
382 file_exists, 382 file_exists,
383 strip_extension, 383 strip_extension,
384 crc_32, 384 crc_32,
385 filetype_get_attr,
385 386
386 /* dir */ 387 /* dir */
387 (opendir_func)PREFIX(opendir), 388 (opendir_func)PREFIX(opendir),
@@ -392,6 +393,10 @@ static const struct plugin_api rockbox_api = {
392 dir_exists, 393 dir_exists,
393 dir_get_info, 394 dir_get_info,
394 395
396 /* browsing */
397 browse_context_init,
398 rockbox_browse,
399
395 /* kernel/ system */ 400 /* kernel/ system */
396#if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE 401#if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE
397 __div0, 402 __div0,
@@ -772,9 +777,6 @@ static const struct plugin_api rockbox_api = {
772 777
773 /* new stuff at the end, sort into place next time 778 /* new stuff at the end, sort into place next time
774 the API gets incompatible */ 779 the API gets incompatible */
775 filetype_get_attr,
776 browse_context_init,
777 rockbox_browse,
778}; 780};
779 781
780int plugin_load(const char* plugin, const void* parameter) 782int plugin_load(const char* plugin, const void* parameter)
diff --git a/apps/plugin.h b/apps/plugin.h
index cd53ac6574..4b11ac31e9 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -149,12 +149,12 @@ void* plugin_get_buffer(size_t *buffer_size);
149#define PLUGIN_MAGIC 0x526F634B /* RocK */ 149#define PLUGIN_MAGIC 0x526F634B /* RocK */
150 150
151/* increase this every time the api struct changes */ 151/* increase this every time the api struct changes */
152#define PLUGIN_API_VERSION 197 152#define PLUGIN_API_VERSION 198
153 153
154/* update this to latest version if a change to the api struct breaks 154/* update this to latest version if a change to the api struct breaks
155 backwards compatibility (and please take the opportunity to sort in any 155 backwards compatibility (and please take the opportunity to sort in any
156 new function which are "waiting" at the end of the function table) */ 156 new function which are "waiting" at the end of the function table) */
157#define PLUGIN_MIN_API_VERSION 196 157#define PLUGIN_MIN_API_VERSION 198
158 158
159/* plugin return codes */ 159/* plugin return codes */
160/* internal returns start at 0x100 to make exit(1..255) work */ 160/* internal returns start at 0x100 to make exit(1..255) work */
@@ -448,6 +448,9 @@ struct plugin_api {
448 char* (*strip_extension)(char* buffer, int buffer_size, const char *filename); 448 char* (*strip_extension)(char* buffer, int buffer_size, const char *filename);
449 unsigned (*crc_32)(const void *src, unsigned len, unsigned crc32); 449 unsigned (*crc_32)(const void *src, unsigned len, unsigned crc32);
450 450
451 int (*filetype_get_attr)(const char* file);
452
453
451 454
452 /* dir */ 455 /* dir */
453 DIR* (*opendir)(const char* name); 456 DIR* (*opendir)(const char* name);
@@ -458,6 +461,13 @@ struct plugin_api {
458 bool (*dir_exists)(const char *path); 461 bool (*dir_exists)(const char *path);
459 struct dirinfo (*dir_get_info)(DIR* parent, struct dirent *entry); 462 struct dirinfo (*dir_get_info)(DIR* parent, struct dirent *entry);
460 463
464 /* browsing */
465 void (*browse_context_init)(struct browse_context *browse,
466 int dirfilter, unsigned flags,
467 char *title, enum themable_icons icon,
468 const char *root, const char *selected);
469 int (*rockbox_browse)(struct browse_context *browse);
470
461 /* kernel/ system */ 471 /* kernel/ system */
462#if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE 472#if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE
463 void (*__div0)(void); 473 void (*__div0)(void);
@@ -901,12 +911,6 @@ struct plugin_api {
901 911
902 /* new stuff at the end, sort into place next time 912 /* new stuff at the end, sort into place next time
903 the API gets incompatible */ 913 the API gets incompatible */
904 int (*filetype_get_attr)(const char* file);
905 void (*browse_context_init)(struct browse_context *browse,
906 int dirfilter, unsigned flags,
907 char *title, enum themable_icons icon,
908 const char *root, const char *selected);
909 int (*rockbox_browse)(struct browse_context *browse);
910}; 914};
911 915
912/* plugin header */ 916/* plugin header */
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
index 4907de11f3..30f2c0df16 100644
--- a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
+++ b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
@@ -213,9 +213,9 @@ void button_gpioa_isr(void)
213 */ 213 */
214int button_read_device(void) 214int button_read_device(void)
215{ 215{
216 int btn = 0;
217 static long power_counter = 0; 216 static long power_counter = 0;
218 bool hold = false; 217 bool hold = false;
218 int btn;
219 unsigned gpiod6; 219 unsigned gpiod6;
220 220
221 /* if we don't wait for the fifo to empty, we'll see screen corruption 221 /* if we don't wait for the fifo to empty, we'll see screen corruption
@@ -240,28 +240,16 @@ int button_read_device(void)
240 GPIOB_PIN(0) = 0; 240 GPIOB_PIN(0) = 0;
241 udelay(2); 241 udelay(2);
242 242
243 if (GPIOC_PIN(1) & 1<<1) 243 btn = GPIOC_PIN_MASK(0x3e) | (GPIOB_PIN(1) >> 1);
244 btn |= BUTTON_DOWN; 244
245 if (GPIOC_PIN(2) & 1<<2)
246 btn |= BUTTON_UP;
247 if (GPIOC_PIN(3) & 1<<3)
248 btn |= BUTTON_LEFT;
249 if (GPIOC_PIN(4) & 1<<4)
250 btn |= BUTTON_SELECT;
251 if (GPIOC_PIN(5) & 1<<5)
252 btn |= BUTTON_RIGHT;
253 if (GPIOB_PIN(1) & 1<<1)
254 btn |= BUTTON_HOME;
255 if (amsv2_variant == 1) 245 if (amsv2_variant == 1)
256 btn ^= BUTTON_HOME; 246 btn ^= BUTTON_HOME;
257 247
258 if (gpiod6 & 1<<6) 248 if (gpiod6)
259 { /* power/hold is on the same pin. we know it's hold if the bit isn't 249 { /* power/hold is on the same pin. we know it's hold if the bit isn't
260 * set now anymore */ 250 * set now anymore */
261 if (GPIOD_PIN(6) & 1<<6) 251 btn |= GPIOD_PIN(6);
262 btn |= BUTTON_POWER; 252 hold = !(btn & BUTTON_POWER);
263 else
264 hold = true;
265 } 253 }
266 254
267 if(gpiob_pin0_dir) 255 if(gpiob_pin0_dir)
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/button-target.h b/firmware/target/arm/as3525/sansa-fuzev2/button-target.h
index c64c68f951..596ac01262 100644
--- a/firmware/target/arm/as3525/sansa-fuzev2/button-target.h
+++ b/firmware/target/arm/as3525/sansa-fuzev2/button-target.h
@@ -32,15 +32,14 @@ bool button_hold(void);
32int button_read_device(void); 32int button_read_device(void);
33/* Sandisk Sansa Fuze button codes */ 33/* Sandisk Sansa Fuze button codes */
34 34
35/* Main unit's buttons */ 35/* Main unit's buttons - mapped for optimal reading */
36#define BUTTON_HOME 0x00000001 36#define BUTTON_HOME 0x00000001
37
38#define BUTTON_DOWN 0x00000002 37#define BUTTON_DOWN 0x00000002
39#define BUTTON_RIGHT 0x00000004 38#define BUTTON_UP 0x00000004
40
41#define BUTTON_LEFT 0x00000008 39#define BUTTON_LEFT 0x00000008
42#define BUTTON_SELECT 0x00000010 40#define BUTTON_SELECT 0x00000010
43#define BUTTON_UP 0x00000020 41#define BUTTON_RIGHT 0x00000020
42
44#define BUTTON_POWER 0x00000040 43#define BUTTON_POWER 0x00000040
45 44
46#define BUTTON_SCROLL_BACK 0x00000080 45#define BUTTON_SCROLL_BACK 0x00000080