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
This commit is contained in:
Michael Sevakis 2011-01-20 17:11:23 +00:00
parent 5f52f6ee01
commit 2da0f9bcfd
4 changed files with 27 additions and 34 deletions

View file

@ -382,6 +382,7 @@ static const struct plugin_api rockbox_api = {
file_exists, file_exists,
strip_extension, strip_extension,
crc_32, crc_32,
filetype_get_attr,
/* dir */ /* dir */
(opendir_func)PREFIX(opendir), (opendir_func)PREFIX(opendir),
@ -392,6 +393,10 @@ static const struct plugin_api rockbox_api = {
dir_exists, dir_exists,
dir_get_info, dir_get_info,
/* browsing */
browse_context_init,
rockbox_browse,
/* kernel/ system */ /* kernel/ system */
#if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE #if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE
__div0, __div0,
@ -772,9 +777,6 @@ static const struct plugin_api rockbox_api = {
/* new stuff at the end, sort into place next time /* new stuff at the end, sort into place next time
the API gets incompatible */ the API gets incompatible */
filetype_get_attr,
browse_context_init,
rockbox_browse,
}; };
int plugin_load(const char* plugin, const void* parameter) int plugin_load(const char* plugin, const void* parameter)

View file

@ -149,12 +149,12 @@ void* plugin_get_buffer(size_t *buffer_size);
#define PLUGIN_MAGIC 0x526F634B /* RocK */ #define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */ /* increase this every time the api struct changes */
#define PLUGIN_API_VERSION 197 #define PLUGIN_API_VERSION 198
/* update this to latest version if a change to the api struct breaks /* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */ new function which are "waiting" at the end of the function table) */
#define PLUGIN_MIN_API_VERSION 196 #define PLUGIN_MIN_API_VERSION 198
/* plugin return codes */ /* plugin return codes */
/* internal returns start at 0x100 to make exit(1..255) work */ /* internal returns start at 0x100 to make exit(1..255) work */
@ -448,6 +448,9 @@ struct plugin_api {
char* (*strip_extension)(char* buffer, int buffer_size, const char *filename); char* (*strip_extension)(char* buffer, int buffer_size, const char *filename);
unsigned (*crc_32)(const void *src, unsigned len, unsigned crc32); unsigned (*crc_32)(const void *src, unsigned len, unsigned crc32);
int (*filetype_get_attr)(const char* file);
/* dir */ /* dir */
DIR* (*opendir)(const char* name); DIR* (*opendir)(const char* name);
@ -458,6 +461,13 @@ struct plugin_api {
bool (*dir_exists)(const char *path); bool (*dir_exists)(const char *path);
struct dirinfo (*dir_get_info)(DIR* parent, struct dirent *entry); struct dirinfo (*dir_get_info)(DIR* parent, struct dirent *entry);
/* browsing */
void (*browse_context_init)(struct browse_context *browse,
int dirfilter, unsigned flags,
char *title, enum themable_icons icon,
const char *root, const char *selected);
int (*rockbox_browse)(struct browse_context *browse);
/* kernel/ system */ /* kernel/ system */
#if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE #if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE
void (*__div0)(void); void (*__div0)(void);
@ -901,12 +911,6 @@ struct plugin_api {
/* new stuff at the end, sort into place next time /* new stuff at the end, sort into place next time
the API gets incompatible */ the API gets incompatible */
int (*filetype_get_attr)(const char* file);
void (*browse_context_init)(struct browse_context *browse,
int dirfilter, unsigned flags,
char *title, enum themable_icons icon,
const char *root, const char *selected);
int (*rockbox_browse)(struct browse_context *browse);
}; };
/* plugin header */ /* plugin header */

View file

@ -213,9 +213,9 @@ void button_gpioa_isr(void)
*/ */
int button_read_device(void) int button_read_device(void)
{ {
int btn = 0;
static long power_counter = 0; static long power_counter = 0;
bool hold = false; bool hold = false;
int btn;
unsigned gpiod6; unsigned gpiod6;
/* if we don't wait for the fifo to empty, we'll see screen corruption /* if we don't wait for the fifo to empty, we'll see screen corruption
@ -240,28 +240,16 @@ int button_read_device(void)
GPIOB_PIN(0) = 0; GPIOB_PIN(0) = 0;
udelay(2); udelay(2);
if (GPIOC_PIN(1) & 1<<1) btn = GPIOC_PIN_MASK(0x3e) | (GPIOB_PIN(1) >> 1);
btn |= BUTTON_DOWN;
if (GPIOC_PIN(2) & 1<<2)
btn |= BUTTON_UP;
if (GPIOC_PIN(3) & 1<<3)
btn |= BUTTON_LEFT;
if (GPIOC_PIN(4) & 1<<4)
btn |= BUTTON_SELECT;
if (GPIOC_PIN(5) & 1<<5)
btn |= BUTTON_RIGHT;
if (GPIOB_PIN(1) & 1<<1)
btn |= BUTTON_HOME;
if (amsv2_variant == 1) if (amsv2_variant == 1)
btn ^= BUTTON_HOME; btn ^= BUTTON_HOME;
if (gpiod6 & 1<<6) if (gpiod6)
{ /* power/hold is on the same pin. we know it's hold if the bit isn't { /* power/hold is on the same pin. we know it's hold if the bit isn't
* set now anymore */ * set now anymore */
if (GPIOD_PIN(6) & 1<<6) btn |= GPIOD_PIN(6);
btn |= BUTTON_POWER; hold = !(btn & BUTTON_POWER);
else
hold = true;
} }
if(gpiob_pin0_dir) if(gpiob_pin0_dir)

View file

@ -32,15 +32,14 @@ bool button_hold(void);
int button_read_device(void); int button_read_device(void);
/* Sandisk Sansa Fuze button codes */ /* Sandisk Sansa Fuze button codes */
/* Main unit's buttons */ /* Main unit's buttons - mapped for optimal reading */
#define BUTTON_HOME 0x00000001 #define BUTTON_HOME 0x00000001
#define BUTTON_DOWN 0x00000002 #define BUTTON_DOWN 0x00000002
#define BUTTON_RIGHT 0x00000004 #define BUTTON_UP 0x00000004
#define BUTTON_LEFT 0x00000008 #define BUTTON_LEFT 0x00000008
#define BUTTON_SELECT 0x00000010 #define BUTTON_SELECT 0x00000010
#define BUTTON_UP 0x00000020 #define BUTTON_RIGHT 0x00000020
#define BUTTON_POWER 0x00000040 #define BUTTON_POWER 0x00000040
#define BUTTON_SCROLL_BACK 0x00000080 #define BUTTON_SCROLL_BACK 0x00000080