forked from len0rd/rockbox
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
This commit is contained in:
parent
74fec27968
commit
e249ecc85b
3 changed files with 24 additions and 51 deletions
|
|
@ -47,11 +47,9 @@ static int int_btn = BUTTON_NONE;
|
||||||
* we only enable it for a very short time to check for changes every
|
* we only enable it for a very short time to check for changes every
|
||||||
* tick, and only keep it enabled if there is activity. */
|
* tick, and only keep it enabled if there is activity. */
|
||||||
#define WHEEL_TIMEOUT (HZ/4)
|
#define WHEEL_TIMEOUT (HZ/4)
|
||||||
static int wheel_timeout = 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* iPod 3G and mini 1G, mini 2G uses iPod 4G code */
|
static void handle_scroll_wheel(int new_scroll, int was_hold)
|
||||||
void handle_scroll_wheel(int new_scroll, int was_hold, int reverse)
|
|
||||||
{
|
{
|
||||||
int wheel_keycode = BUTTON_NONE;
|
int wheel_keycode = BUTTON_NONE;
|
||||||
static int prev_scroll = -1;
|
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}
|
{0, -1, 1, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef IPOD_1G2G
|
|
||||||
wheel_timeout = WHEEL_TIMEOUT;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ( prev_scroll == -1 ) {
|
if ( prev_scroll == -1 ) {
|
||||||
prev_scroll = new_scroll;
|
prev_scroll = new_scroll;
|
||||||
}
|
}
|
||||||
|
|
@ -80,26 +74,14 @@ void handle_scroll_wheel(int new_scroll, int was_hold, int reverse)
|
||||||
reset_poweroff_timer();
|
reset_poweroff_timer();
|
||||||
if (++count == 6) { /* reduce sensitivity */
|
if (++count == 6) { /* reduce sensitivity */
|
||||||
count = 0;
|
count = 0;
|
||||||
|
/* 1st..3rd Gen wheel has inverse direction mapping
|
||||||
|
* compared to Mini 1st Gen wheel. */
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case 1:
|
case 1:
|
||||||
if (reverse) {
|
wheel_keycode = BUTTON_SCROLL_BACK;
|
||||||
/* 'r' keypress */
|
|
||||||
wheel_keycode = BUTTON_SCROLL_FWD;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* 'l' keypress */
|
|
||||||
wheel_keycode = BUTTON_SCROLL_BACK;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
if (reverse) {
|
wheel_keycode = BUTTON_SCROLL_FWD;
|
||||||
/* 'l' keypress */
|
|
||||||
wheel_keycode = BUTTON_SCROLL_BACK;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* 'r' keypress */
|
|
||||||
wheel_keycode = BUTTON_SCROLL_FWD;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* only happens if we get out of sync */
|
/* only happens if we get out of sync */
|
||||||
|
|
@ -174,7 +156,7 @@ static int ipod_3g_button_read(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source & 0xc0) {
|
if (source & 0xc0) {
|
||||||
handle_scroll_wheel((state & 0xc0) >> 6, was_hold, 0);
|
handle_scroll_wheel((state & 0xc0) >> 6, was_hold);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ack any active interrupts */
|
/* ack any active interrupts */
|
||||||
|
|
@ -219,6 +201,7 @@ int button_read_device(void)
|
||||||
static bool hold_button = false;
|
static bool hold_button = false;
|
||||||
bool hold_button_old;
|
bool hold_button_old;
|
||||||
#ifdef IPOD_1G2G
|
#ifdef IPOD_1G2G
|
||||||
|
static int wheel_timeout = 0;
|
||||||
static unsigned char last_wheel_value = 0;
|
static unsigned char last_wheel_value = 0;
|
||||||
unsigned char wheel_value;
|
unsigned char wheel_value;
|
||||||
|
|
||||||
|
|
@ -228,17 +211,21 @@ int button_read_device(void)
|
||||||
{
|
{
|
||||||
GPIOB_OUTPUT_VAL |= 0x01; /* enable wheel */
|
GPIOB_OUTPUT_VAL |= 0x01; /* enable wheel */
|
||||||
udelay(50); /* let the voltage settle */
|
udelay(50); /* let the voltage settle */
|
||||||
wheel_value = GPIOA_INPUT_VAL >> 6;
|
GPIOA_INT_EN = 0xff; /* enable wheel interrupts */
|
||||||
if (wheel_value != last_wheel_value)
|
}
|
||||||
{
|
wheel_value = GPIOA_INPUT_VAL >> 6;
|
||||||
last_wheel_value = wheel_value;
|
if (wheel_value != last_wheel_value)
|
||||||
wheel_timeout = WHEEL_TIMEOUT; /* keep wheel enabled */
|
{
|
||||||
}
|
last_wheel_value = wheel_value;
|
||||||
}
|
wheel_timeout = WHEEL_TIMEOUT; /* keep wheel enabled */
|
||||||
|
}
|
||||||
if (wheel_timeout)
|
if (wheel_timeout)
|
||||||
wheel_timeout--;
|
wheel_timeout--;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
GPIOA_INT_EN = 0x3f; /* disable wheel interrupts */
|
||||||
GPIOB_OUTPUT_VAL &= ~0x01; /* disable wheel */
|
GPIOB_OUTPUT_VAL &= ~0x01; /* disable wheel */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,7 @@ int int_btn = BUTTON_NONE;
|
||||||
static bool send_events = true;
|
static bool send_events = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* iPod 3G and mini 1G, mini 2G uses iPod 4G code */
|
static void handle_scroll_wheel(int new_scroll, int was_hold)
|
||||||
void handle_scroll_wheel(int new_scroll, int was_hold, int reverse)
|
|
||||||
{
|
{
|
||||||
int wheel_keycode = BUTTON_NONE;
|
int wheel_keycode = BUTTON_NONE;
|
||||||
static int prev_scroll = -1;
|
static int prev_scroll = -1;
|
||||||
|
|
@ -73,26 +72,14 @@ void handle_scroll_wheel(int new_scroll, int was_hold, int reverse)
|
||||||
reset_poweroff_timer();
|
reset_poweroff_timer();
|
||||||
if (++count == 6) { /* reduce sensitivity */
|
if (++count == 6) { /* reduce sensitivity */
|
||||||
count = 0;
|
count = 0;
|
||||||
|
/* Mini 1st Gen wheel has inverse direction mapping
|
||||||
|
* compared to 1st..3rd Gen wheel. */
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case 1:
|
case 1:
|
||||||
if (reverse) {
|
wheel_keycode = BUTTON_SCROLL_FWD;
|
||||||
/* 'r' keypress */
|
|
||||||
wheel_keycode = BUTTON_SCROLL_FWD;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* 'l' keypress */
|
|
||||||
wheel_keycode = BUTTON_SCROLL_BACK;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
if (reverse) {
|
wheel_keycode = BUTTON_SCROLL_BACK;
|
||||||
/* 'l' keypress */
|
|
||||||
wheel_keycode = BUTTON_SCROLL_BACK;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* 'r' keypress */
|
|
||||||
wheel_keycode = BUTTON_SCROLL_FWD;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* only happens if we get out of sync */
|
/* only happens if we get out of sync */
|
||||||
|
|
@ -147,7 +134,7 @@ static int ipod_mini_button_read(void)
|
||||||
btn |= BUTTON_LEFT;
|
btn |= BUTTON_LEFT;
|
||||||
|
|
||||||
if (wheel_source & 0x30) {
|
if (wheel_source & 0x30) {
|
||||||
handle_scroll_wheel((wheel_state & 0x30) >> 4, was_hold, 1);
|
handle_scroll_wheel((wheel_state & 0x30) >> 4, was_hold);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ bool button_hold(void);
|
||||||
void button_init_device(void);
|
void button_init_device(void);
|
||||||
int button_read_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_mini_button_int(void);
|
||||||
void ipod_4g_button_int(void);
|
void ipod_4g_button_int(void);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue