aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasily Khoruzhick <anarsoul@gmail.com>2012-01-12 22:30:34 +0300
committerAndrzej Zaborowski <andrew.zaborowski@intel.com>2012-01-17 01:48:47 +0100
commit753a97c6b40c9ade45aae2e96ed44268aa7007e6 (patch)
treec5c42fa865a11bfed2c0001f27005c5e93e8ee94
parent7ab3aedfe3a302f47be1a11be4a63ef5f38de262 (diff)
pxa2xx_keypad: make single automatic scans work
u-boot uses single automatic scans and polling in pxa2xx_keypad driver, so clear KPC_AS bit immediately and update keys state even if KPC_AS and KPC_ASACT are cleared. Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
-rw-r--r--hw/pxa2xx_keypad.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/hw/pxa2xx_keypad.c b/hw/pxa2xx_keypad.c
index a97d445495..0e80212804 100644
--- a/hw/pxa2xx_keypad.c
+++ b/hw/pxa2xx_keypad.c
@@ -129,48 +129,45 @@ static void pxa27x_keyboard_event (PXA2xxKeyPadState *kp, int keycode)
if(!(kp->kpc & KPC_ME)) /* skip if not enabled */
return;
- if(kp->kpc & KPC_AS || kp->kpc & KPC_ASACT) {
- if(kp->kpc & KPC_AS)
- kp->kpc &= ~(KPC_AS);
-
- rel = (keycode & 0x80) ? 1 : 0; /* key release from qemu */
- keycode &= ~(0x80); /* strip qemu key release bit */
- if (kp->alt_code) {
- keycode |= 0x80;
- kp->alt_code = 0;
- }
+ rel = (keycode & 0x80) ? 1 : 0; /* key release from qemu */
+ keycode &= ~0x80; /* strip qemu key release bit */
+ if (kp->alt_code) {
+ keycode |= 0x80;
+ kp->alt_code = 0;
+ }
- row = kp->map[keycode].row;
- col = kp->map[keycode].column;
- if(row == -1 || col == -1)
- return;
+ row = kp->map[keycode].row;
+ col = kp->map[keycode].column;
+ if (row == -1 || col == -1) {
+ return;
+ }
- val = KPASMKPx_MKC(row, col);
- if (rel) {
- if (kp->kpasmkp[col / 2] & val) {
- kp->kpasmkp[col / 2] &= ~val;
- kp->pressed_cnt--;
- assert_irq = 1;
- }
- } else {
- if (!(kp->kpasmkp[col / 2] & val)) {
- kp->kpasmkp[col / 2] |= val;
- kp->pressed_cnt++;
- assert_irq = 1;
- }
+ val = KPASMKPx_MKC(row, col);
+ if (rel) {
+ if (kp->kpasmkp[col / 2] & val) {
+ kp->kpasmkp[col / 2] &= ~val;
+ kp->pressed_cnt--;
+ assert_irq = 1;
}
- kp->kpas = ((kp->pressed_cnt & 0x1f) << 26) | (0xf << 4) | 0xf;
- if (kp->pressed_cnt == 1) {
- kp->kpas &= ~((0xf << 4) | 0xf);
- if (rel)
- pxa27x_keypad_find_pressed_key(kp, &row, &col);
- kp->kpas |= ((row & 0xf) << 4) | (col & 0xf);
+ } else {
+ if (!(kp->kpasmkp[col / 2] & val)) {
+ kp->kpasmkp[col / 2] |= val;
+ kp->pressed_cnt++;
+ assert_irq = 1;
}
- goto out;
}
- return;
+ kp->kpas = ((kp->pressed_cnt & 0x1f) << 26) | (0xf << 4) | 0xf;
+ if (kp->pressed_cnt == 1) {
+ kp->kpas &= ~((0xf << 4) | 0xf);
+ if (rel) {
+ pxa27x_keypad_find_pressed_key(kp, &row, &col);
+ }
+ kp->kpas |= ((row & 0xf) << 4) | (col & 0xf);
+ }
+
+ if (!(kp->kpc & (KPC_AS | KPC_ASACT))
+ assert_irq = 0;
-out:
if (assert_irq && (kp->kpc & KPC_MIE)) {
kp->kpc |= KPC_MI;
qemu_irq_raise(kp->irq);
@@ -248,6 +245,9 @@ static void pxa2xx_keypad_write(void *opaque, target_phys_addr_t offset,
switch (offset) {
case KPC:
s->kpc = value;
+ if (s->kpc & KPC_AS) {
+ s->kpc &= ~(KPC_AS);
+ }
break;
case KPDK:
s->kpdk = value;