am d6da4d4f: am 47cca063: Merge changes Idcb48155,Iecb8c3db,I4924134b into ics-mr0

* commit 'd6da4d4fa58b40f66a4bb5b7b0d15bfe7ab7d8c9':
  charger: ignore key event if value didn't change
  charger: sync with the current key state on boot
  charger: print last_kmsg directly using klog_write
This commit is contained in:
Dima Zavin 2011-10-13 14:08:49 -07:00 committed by Android Git Automerger
commit 489ddab36e
1 changed files with 30 additions and 14 deletions

View File

@ -224,7 +224,7 @@ static void dump_last_kmsg(void)
yoink = ptr[cnt];
ptr[cnt] = '\0';
KLOG_INFO("", "%s", ptr);
klog_write(6, "<6>%s", ptr);
ptr[cnt] = yoink;
len -= cnt;
@ -745,30 +745,44 @@ static void update_screen_state(struct charger *charger, int64_t now)
}
}
static void update_input_state(struct charger *charger,
struct input_event *ev,
int64_t now)
static int set_key_callback(int code, int value, void *data)
{
int down = !!ev->value;
struct charger *charger = data;
int64_t now = curr_time_ms();
int down = !!value;
if (ev->type != EV_KEY || ev->code > KEY_MAX)
return;
if (code > KEY_MAX)
return -1;
/* ignore events that don't modify our state */
if (charger->keys[code].down == down)
return -1;
/* only record the down even timestamp, as the amount
* of time the key spent not being pressed is not useful */
if (down)
charger->keys[ev->code].timestamp = now;
charger->keys[ev->code].down = down;
charger->keys[ev->code].pending = true;
charger->keys[code].timestamp = now;
charger->keys[code].down = down;
charger->keys[code].pending = true;
if (down) {
LOGV("[%lld] key[%d] down\n", now, ev->code);
LOGV("[%lld] key[%d] down\n", now, code);
} else {
int64_t duration = now - charger->keys[ev->code].timestamp;
int64_t duration = now - charger->keys[code].timestamp;
int64_t secs = duration / 1000;
int64_t msecs = duration - secs * 1000;
LOGV("[%lld] key[%d] up (was down for %lld.%lldsec)\n", now,
ev->code, secs, msecs);
code, secs, msecs);
}
return 0;
}
static void update_input_state(struct charger *charger,
struct input_event *ev)
{
if (ev->type != EV_KEY)
return;
set_key_callback(ev->code, ev->value, charger);
}
static void set_next_key_check(struct charger *charger,
@ -876,7 +890,7 @@ static int input_callback(int fd, short revents, void *data)
ret = ev_get_input(fd, revents, &ev);
if (ret)
return -1;
update_input_state(charger, &ev, curr_time_ms());
update_input_state(charger, &ev);
return 0;
}
@ -949,6 +963,8 @@ int main(int argc, char **argv)
}
}
ev_sync_key_state(set_key_callback, charger);
gr_fb_blank(true);
charger->next_screen_transition = now - 1;