diff options
Diffstat (limited to 'firmware/target/arm/s5l8700/meizu-m6sp/button-m6sp.c')
-rw-r--r-- | firmware/target/arm/s5l8700/meizu-m6sp/button-m6sp.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/firmware/target/arm/s5l8700/meizu-m6sp/button-m6sp.c b/firmware/target/arm/s5l8700/meizu-m6sp/button-m6sp.c new file mode 100644 index 0000000000..a2c7604a85 --- /dev/null +++ b/firmware/target/arm/s5l8700/meizu-m6sp/button-m6sp.c | |||
@@ -0,0 +1,72 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2009 Bertrik Sikken | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <stdbool.h> | ||
23 | #include "config.h" | ||
24 | |||
25 | #include "inttypes.h" | ||
26 | #include "s5l8700.h" | ||
27 | #include "button-target.h" | ||
28 | |||
29 | /* Button driver for the meizu M6SP | ||
30 | |||
31 | Future improvements: | ||
32 | * touch strip support | ||
33 | * left/right buttons (probably part of touch strip) | ||
34 | * unify with m3/m6sl button driver if possible | ||
35 | |||
36 | */ | ||
37 | |||
38 | |||
39 | void button_init_device(void) | ||
40 | { | ||
41 | PCON0 &= ~(0x3 << 10); /* P0.5 hold switch */ | ||
42 | PCON0 &= ~(0x3 << 14); /* P0.7 enter button */ | ||
43 | PCON1 &= ~(0xF << 12); /* P1.3 menu button */ | ||
44 | PCON1 &= ~(0xF << 16); /* P1.4 play button */ | ||
45 | } | ||
46 | |||
47 | int button_read_device(void) | ||
48 | { | ||
49 | int buttons = 0; | ||
50 | |||
51 | if (button_hold()) { | ||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | if ((PDAT0 & (1 << 7)) == 0) { | ||
56 | buttons |= BUTTON_ENTER; | ||
57 | } | ||
58 | if ((PDAT1 & (1 << 3)) == 0) { | ||
59 | buttons |= BUTTON_MENU; | ||
60 | } | ||
61 | if ((PDAT1 & (1 << 4)) == 0) { | ||
62 | buttons |= BUTTON_PLAY; | ||
63 | } | ||
64 | |||
65 | return buttons; | ||
66 | } | ||
67 | |||
68 | bool button_hold(void) | ||
69 | { | ||
70 | return ((PDAT0 & (1 << 5)) != 0); | ||
71 | } | ||
72 | |||