diff options
Diffstat (limited to 'firmware/target/hosted/samsungypr/ypr0/button-ypr0.c')
-rw-r--r-- | firmware/target/hosted/samsungypr/ypr0/button-ypr0.c | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/firmware/target/hosted/samsungypr/ypr0/button-ypr0.c b/firmware/target/hosted/samsungypr/ypr0/button-ypr0.c new file mode 100644 index 0000000000..e3ad309187 --- /dev/null +++ b/firmware/target/hosted/samsungypr/ypr0/button-ypr0.c | |||
@@ -0,0 +1,87 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: button-sdl.c 30482 2011-09-08 14:53:28Z kugel $ | ||
9 | * | ||
10 | * Copyright (C) 2011 Lorenzo Miori | ||
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 "config.h" | ||
23 | #include "button.h" | ||
24 | #include "kernel.h" | ||
25 | #include "system.h" | ||
26 | #include "button-target.h" | ||
27 | #include <gpio-target.h> /* For headphones sense and buttons */ | ||
28 | |||
29 | int button_read_device(void) | ||
30 | { | ||
31 | int key = BUTTON_NONE; | ||
32 | |||
33 | /* Check for all the keys */ | ||
34 | if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_USER_KEY, 0, 0)) { | ||
35 | key |= BUTTON_USER; | ||
36 | } | ||
37 | if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_CENTRAL_KEY, 0, 0)) { | ||
38 | key |= BUTTON_SELECT; | ||
39 | } | ||
40 | if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_UP_KEY, 0, 0)) { | ||
41 | key |= BUTTON_UP; | ||
42 | } | ||
43 | if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_DOWN_KEY, 0, 0)) { | ||
44 | key |= BUTTON_DOWN; | ||
45 | } | ||
46 | if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_LEFT_KEY, 0, 0)) { | ||
47 | key |= BUTTON_LEFT; | ||
48 | } | ||
49 | if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_RIGHT_KEY, 0, 0)) { | ||
50 | key |= BUTTON_RIGHT; | ||
51 | } | ||
52 | if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_MENU_KEY, 0, 0)) { | ||
53 | key |= BUTTON_MENU; | ||
54 | } | ||
55 | if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_BACK_KEY, 0, 0)) { | ||
56 | key |= BUTTON_BACK; | ||
57 | } | ||
58 | if (gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_POWER_KEY, 0, 0)) { | ||
59 | key |= BUTTON_POWER; | ||
60 | } | ||
61 | |||
62 | return key; | ||
63 | } | ||
64 | |||
65 | bool headphones_inserted(void) | ||
66 | { | ||
67 | /* GPIO low - 0 - means headphones inserted */ | ||
68 | return !gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_HEADPHONE_SENSE, 0, 0); | ||
69 | } | ||
70 | |||
71 | void button_init_device(void) | ||
72 | { | ||
73 | /* Setup GPIO pin for headphone sense, copied from OF */ | ||
74 | gpio_control(DEV_CTRL_GPIO_SET_MUX, GPIO_HEADPHONE_SENSE, CONFIG_SION, PAD_CTL_47K_PU); | ||
75 | gpio_control(DEV_CTRL_GPIO_SET_INPUT, GPIO_HEADPHONE_SENSE, CONFIG_SION, PAD_CTL_47K_PU); | ||
76 | |||
77 | /* No need to initialize any GPIO pin, since this is done loading the r0Btn module */ | ||
78 | } | ||
79 | |||
80 | #ifdef BUTTON_DRIVER_CLOSE | ||
81 | /* I'm not sure it's called at shutdown...give a check! */ | ||
82 | void button_close_device(void) | ||
83 | { | ||
84 | /* Don't know the precise meaning, but it's done as in the OF, so copied there */ | ||
85 | gpio_control(DEV_CTRL_GPIO_UNSET_MUX, GPIO_HEADPHONE_SENSE, CONFIG_SION, 0); | ||
86 | } | ||
87 | #endif /* BUTTON_DRIVER_CLOSE */ | ||