summaryrefslogtreecommitdiff
path: root/firmware/target/arm/ipod
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2008-04-01 17:52:22 +0000
committerJens Arnold <amiconn@rockbox.org>2008-04-01 17:52:22 +0000
commite249ecc85b30687764289a500c92d32dd2d10b0a (patch)
tree1659da11ed2aab32316979c4f1a0b9dea8e895be /firmware/target/arm/ipod
parent74fec27968aa04eb6aaf27e58134477e12f68af8 (diff)
iPod 1st..3rd Gen and Mini 1st Gen fixes/improvements: * Remove the unnecessary 'reverse' parameter from handle_scroll_wheel() (a remnant from IPL that's not needed in rockbox), and make it static. * Wheel power saving on 1st Gen needs to disable the respective GPIO interrupts as well, otherwise every wheel check might fire interrupts. Make wheel power saving more self-contained as well.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16916 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/ipod')
-rw-r--r--firmware/target/arm/ipod/button-1g-3g.c49
-rw-r--r--firmware/target/arm/ipod/button-mini1g.c25
-rw-r--r--firmware/target/arm/ipod/button-target.h1
3 files changed, 24 insertions, 51 deletions
diff --git a/firmware/target/arm/ipod/button-1g-3g.c b/firmware/target/arm/ipod/button-1g-3g.c
index d5592f0447..74af4c2cd2 100644
--- a/firmware/target/arm/ipod/button-1g-3g.c
+++ b/firmware/target/arm/ipod/button-1g-3g.c
@@ -47,11 +47,9 @@ static int int_btn = BUTTON_NONE;
* we only enable it for a very short time to check for changes every
* tick, and only keep it enabled if there is activity. */
#define WHEEL_TIMEOUT (HZ/4)
-static int wheel_timeout = 0;
#endif
-/* iPod 3G and mini 1G, mini 2G uses iPod 4G code */
-void handle_scroll_wheel(int new_scroll, int was_hold, int reverse)
+static void handle_scroll_wheel(int new_scroll, int was_hold)
{
int wheel_keycode = BUTTON_NONE;
static int prev_scroll = -1;
@@ -64,10 +62,6 @@ void handle_scroll_wheel(int new_scroll, int was_hold, int reverse)
{0, -1, 1, 0}
};
-#ifdef IPOD_1G2G
- wheel_timeout = WHEEL_TIMEOUT;
-#endif
-
if ( prev_scroll == -1 ) {
prev_scroll = new_scroll;
}
@@ -80,26 +74,14 @@ void handle_scroll_wheel(int new_scroll, int was_hold, int reverse)
reset_poweroff_timer();
if (++count == 6) { /* reduce sensitivity */
count = 0;
+ /* 1st..3rd Gen wheel has inverse direction mapping
+ * compared to Mini 1st Gen wheel. */
switch (direction) {
case 1:
- if (reverse) {
- /* 'r' keypress */
- wheel_keycode = BUTTON_SCROLL_FWD;
- }
- else {
- /* 'l' keypress */
- wheel_keycode = BUTTON_SCROLL_BACK;
- }
+ wheel_keycode = BUTTON_SCROLL_BACK;
break;
case -1:
- if (reverse) {
- /* 'l' keypress */
- wheel_keycode = BUTTON_SCROLL_BACK;
- }
- else {
- /* 'r' keypress */
- wheel_keycode = BUTTON_SCROLL_FWD;
- }
+ wheel_keycode = BUTTON_SCROLL_FWD;
break;
default:
/* only happens if we get out of sync */
@@ -174,7 +156,7 @@ static int ipod_3g_button_read(void)
}
if (source & 0xc0) {
- handle_scroll_wheel((state & 0xc0) >> 6, was_hold, 0);
+ handle_scroll_wheel((state & 0xc0) >> 6, was_hold);
}
/* ack any active interrupts */
@@ -219,6 +201,7 @@ int button_read_device(void)
static bool hold_button = false;
bool hold_button_old;
#ifdef IPOD_1G2G
+ static int wheel_timeout = 0;
static unsigned char last_wheel_value = 0;
unsigned char wheel_value;
@@ -228,17 +211,21 @@ int button_read_device(void)
{
GPIOB_OUTPUT_VAL |= 0x01; /* enable wheel */
udelay(50); /* let the voltage settle */
- wheel_value = GPIOA_INPUT_VAL >> 6;
- if (wheel_value != last_wheel_value)
- {
- last_wheel_value = wheel_value;
- wheel_timeout = WHEEL_TIMEOUT; /* keep wheel enabled */
- }
- }
+ GPIOA_INT_EN = 0xff; /* enable wheel interrupts */
+ }
+ wheel_value = GPIOA_INPUT_VAL >> 6;
+ if (wheel_value != last_wheel_value)
+ {
+ last_wheel_value = wheel_value;
+ wheel_timeout = WHEEL_TIMEOUT; /* keep wheel enabled */
+ }
if (wheel_timeout)
wheel_timeout--;
else
+ {
+ GPIOA_INT_EN = 0x3f; /* disable wheel interrupts */
GPIOB_OUTPUT_VAL &= ~0x01; /* disable wheel */
+ }
}
#endif
diff --git a/firmware/target/arm/ipod/button-mini1g.c b/firmware/target/arm/ipod/button-mini1g.c
index f02e6acaac..1ff0a19bdb 100644
--- a/firmware/target/arm/ipod/button-mini1g.c
+++ b/firmware/target/arm/ipod/button-mini1g.c
@@ -47,8 +47,7 @@ int int_btn = BUTTON_NONE;
static bool send_events = true;
#endif
-/* iPod 3G and mini 1G, mini 2G uses iPod 4G code */
-void handle_scroll_wheel(int new_scroll, int was_hold, int reverse)
+static void handle_scroll_wheel(int new_scroll, int was_hold)
{
int wheel_keycode = BUTTON_NONE;
static int prev_scroll = -1;
@@ -73,26 +72,14 @@ void handle_scroll_wheel(int new_scroll, int was_hold, int reverse)
reset_poweroff_timer();
if (++count == 6) { /* reduce sensitivity */
count = 0;
+ /* Mini 1st Gen wheel has inverse direction mapping
+ * compared to 1st..3rd Gen wheel. */
switch (direction) {
case 1:
- if (reverse) {
- /* 'r' keypress */
- wheel_keycode = BUTTON_SCROLL_FWD;
- }
- else {
- /* 'l' keypress */
- wheel_keycode = BUTTON_SCROLL_BACK;
- }
+ wheel_keycode = BUTTON_SCROLL_FWD;
break;
case -1:
- if (reverse) {
- /* 'l' keypress */
- wheel_keycode = BUTTON_SCROLL_BACK;
- }
- else {
- /* 'r' keypress */
- wheel_keycode = BUTTON_SCROLL_FWD;
- }
+ wheel_keycode = BUTTON_SCROLL_BACK;
break;
default:
/* only happens if we get out of sync */
@@ -147,7 +134,7 @@ static int ipod_mini_button_read(void)
btn |= BUTTON_LEFT;
if (wheel_source & 0x30) {
- handle_scroll_wheel((wheel_state & 0x30) >> 4, was_hold, 1);
+ handle_scroll_wheel((wheel_state & 0x30) >> 4, was_hold);
}
}
diff --git a/firmware/target/arm/ipod/button-target.h b/firmware/target/arm/ipod/button-target.h
index d736effb72..540981af8f 100644
--- a/firmware/target/arm/ipod/button-target.h
+++ b/firmware/target/arm/ipod/button-target.h
@@ -28,7 +28,6 @@ bool button_hold(void);
void button_init_device(void);
int button_read_device(void);
-void handle_scroll_wheel(int new_scroll, int was_hold, int reverse);
void ipod_mini_button_int(void);
void ipod_4g_button_int(void);