summaryrefslogtreecommitdiff
path: root/firmware/target/arm/rk27xx/hm801
diff options
context:
space:
mode:
authorAndrew Ryabinin <ryabinin.a.a@gmail.com>2012-12-29 00:19:23 +0400
committerAndrew Ryabinin <ryabinin.a.a@gmail.com>2012-12-29 00:19:23 +0400
commit97250a0156acda59575330575648062a7ccab689 (patch)
tree14a9e45fdf3416c157f506bdf300f48285199e68 /firmware/target/arm/rk27xx/hm801
parent362ade3892f40ee1b0360f3af1ab013a6ef32e5e (diff)
downloadrockbox-97250a0156acda59575330575648062a7ccab689.tar.gz
rockbox-97250a0156acda59575330575648062a7ccab689.zip
hm60x/hm801: Add hold button support.
Change-Id: I05557ecfbf0bd821d8966862a38f7f22656b36ef
Diffstat (limited to 'firmware/target/arm/rk27xx/hm801')
-rw-r--r--firmware/target/arm/rk27xx/hm801/button-hm801.c27
-rw-r--r--firmware/target/arm/rk27xx/hm801/button-target.h2
2 files changed, 28 insertions, 1 deletions
diff --git a/firmware/target/arm/rk27xx/hm801/button-hm801.c b/firmware/target/arm/rk27xx/hm801/button-hm801.c
index d0323e6f4d..0ac1b3b0aa 100644
--- a/firmware/target/arm/rk27xx/hm801/button-hm801.c
+++ b/firmware/target/arm/rk27xx/hm801/button-hm801.c
@@ -23,6 +23,7 @@
23#include "system.h" 23#include "system.h"
24#include "button.h" 24#include "button.h"
25#include "adc.h" 25#include "adc.h"
26#include "backlight.h"
26 27
27enum keyboard_type_t { 28enum keyboard_type_t {
28 KEYBOARD_V1, 29 KEYBOARD_V1,
@@ -34,6 +35,12 @@ static enum keyboard_type_t kbd_type;
34void button_init_device(void) { 35void button_init_device(void) {
35 /* setup button gpio as input */ 36 /* setup button gpio as input */
36 GPIO_PCCON &= ~(POWEROFF_BUTTON); 37 GPIO_PCCON &= ~(POWEROFF_BUTTON);
38 GPIO_PACON &= ~1;
39
40
41 /* setup button gpio as pulldown */
42 SCU_GPIOUPCON |= (1<<17) |
43 1 ;
37 44
38 /* identify keyboard type */ 45 /* identify keyboard type */
39 SCU_IOMUXB_CON &= ~(1<<2); 46 SCU_IOMUXB_CON &= ~(1<<2);
@@ -45,6 +52,10 @@ void button_init_device(void) {
45 } 52 }
46} 53}
47 54
55bool button_hold() {
56 return (GPIO_PADR & 1);
57}
58
48static int button_read_device_v1(void) { 59static int button_read_device_v1(void) {
49 int adc_val = adc_read(ADC_BUTTONS); 60 int adc_val = adc_read(ADC_BUTTONS);
50 int button = 0; 61 int button = 0;
@@ -125,7 +136,21 @@ static int button_read_device_v2(void) {
125} 136}
126 137
127int button_read_device(void) { 138int button_read_device(void) {
128 if (kbd_type == KEYBOARD_V1) { 139 static bool hold_button = false;
140 bool hold_button_old;
141
142 hold_button_old = hold_button;
143 hold_button = button_hold();
144
145#ifndef BOOTLOADER
146 if (hold_button != hold_button_old) {
147 backlight_hold_changed(hold_button);
148 }
149#endif
150
151 if (hold_button) {
152 return 0;
153 } else if (kbd_type == KEYBOARD_V1) {
129 return button_read_device_v1(); 154 return button_read_device_v1();
130 } else { 155 } else {
131 return button_read_device_v2(); 156 return button_read_device_v2();
diff --git a/firmware/target/arm/rk27xx/hm801/button-target.h b/firmware/target/arm/rk27xx/hm801/button-target.h
index 7754f867e5..29c31d0df6 100644
--- a/firmware/target/arm/rk27xx/hm801/button-target.h
+++ b/firmware/target/arm/rk27xx/hm801/button-target.h
@@ -21,6 +21,8 @@
21#ifndef _BUTTON_TARGET_H_ 21#ifndef _BUTTON_TARGET_H_
22#define _BUTTON_TARGET_H_ 22#define _BUTTON_TARGET_H_
23 23
24#define HAS_BUTTON_HOLD
25
24#define BUTTON_UP 0x00000001 26#define BUTTON_UP 0x00000001
25#define BUTTON_POWER 0x00000002 27#define BUTTON_POWER 0x00000002
26#define BUTTON_DOWN 0x00000004 28#define BUTTON_DOWN 0x00000004