diff options
author | Thomas Martitz <kugel@rockbox.org> | 2012-01-03 21:15:27 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2012-01-03 21:15:27 +0000 |
commit | c08ce1b829be53cdd24bb864cf73b648f44af412 (patch) | |
tree | 54157629b9a6633ed5a0fec2e00004215ce6b412 /firmware/target/hosted/ypr0/button-ypr0.c | |
parent | e9cb9538c76fc6560fc8475a0bfcd9821d0a66be (diff) | |
download | rockbox-c08ce1b829be53cdd24bb864cf73b648f44af412.tar.gz rockbox-c08ce1b829be53cdd24bb864cf73b648f44af412.zip |
ypr0: Enable headphone detection
Author: Lorenzo Miori
Flyspray: FS#12348
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31544 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/hosted/ypr0/button-ypr0.c')
-rw-r--r-- | firmware/target/hosted/ypr0/button-ypr0.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/firmware/target/hosted/ypr0/button-ypr0.c b/firmware/target/hosted/ypr0/button-ypr0.c index 4298410161..5953bcebf9 100644 --- a/firmware/target/hosted/ypr0/button-ypr0.c +++ b/firmware/target/hosted/ypr0/button-ypr0.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "kernel.h" | 28 | #include "kernel.h" |
29 | #include "system.h" | 29 | #include "system.h" |
30 | #include "button-target.h" | 30 | #include "button-target.h" |
31 | #include <gpio_ypr0.h> /* For headphones sense */ | ||
31 | 32 | ||
32 | /* R0 physical key codes */ | 33 | /* R0 physical key codes */ |
33 | enum ypr0_buttons { | 34 | enum ypr0_buttons { |
@@ -45,6 +46,7 @@ enum ypr0_buttons { | |||
45 | 46 | ||
46 | 47 | ||
47 | static int r0_btn_fd = 0; | 48 | static int r0_btn_fd = 0; |
49 | |||
48 | /* Samsung keypad driver doesn't allow multiple key combinations :( */ | 50 | /* Samsung keypad driver doesn't allow multiple key combinations :( */ |
49 | static enum ypr0_buttons r0_read_key(void) | 51 | static enum ypr0_buttons r0_read_key(void) |
50 | { | 52 | { |
@@ -82,6 +84,11 @@ int button_read_device(void) | |||
82 | return key_to_button(r0_read_key()); | 84 | return key_to_button(r0_read_key()); |
83 | } | 85 | } |
84 | 86 | ||
87 | bool headphones_inserted(void) | ||
88 | { | ||
89 | /* GPIO low - 0 - means headphones inserted */ | ||
90 | return !gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_HEADPHONE_SENSE, 0, 0); | ||
91 | } | ||
85 | 92 | ||
86 | /* Open the keypad device: it is offered by r0Btn.ko module */ | 93 | /* Open the keypad device: it is offered by r0Btn.ko module */ |
87 | void button_init_device(void) | 94 | void button_init_device(void) |
@@ -89,6 +96,10 @@ void button_init_device(void) | |||
89 | r0_btn_fd = open("/dev/r0Btn", O_RDONLY); | 96 | r0_btn_fd = open("/dev/r0Btn", O_RDONLY); |
90 | if (r0_btn_fd < 0) | 97 | if (r0_btn_fd < 0) |
91 | printf("/dev/r0Btn open error!"); | 98 | printf("/dev/r0Btn open error!"); |
99 | |||
100 | /* Setup GPIO pin for headphone sense, copied from OF */ | ||
101 | gpio_control(DEV_CTRL_GPIO_SET_MUX, GPIO_HEADPHONE_SENSE, CONFIG_SION, PAD_CTL_47K_PU); | ||
102 | gpio_control(DEV_CTRL_GPIO_SET_INPUT, GPIO_HEADPHONE_SENSE, CONFIG_SION, PAD_CTL_47K_PU); | ||
92 | } | 103 | } |
93 | 104 | ||
94 | #ifdef BUTTON_DRIVER_CLOSE | 105 | #ifdef BUTTON_DRIVER_CLOSE |
@@ -99,5 +110,7 @@ void button_close_device(void) | |||
99 | close(r0_btn_fd); | 110 | close(r0_btn_fd); |
100 | printf("/dev/r0Btn closed!"); | 111 | printf("/dev/r0Btn closed!"); |
101 | } | 112 | } |
113 | /* Don't know the precise meaning, but it's done as in the OF, so copied there */ | ||
114 | gpio_control(DEV_CTRL_GPIO_UNSET_MUX, GPIO_HEADPHONE_SENSE, CONFIG_SION, 0); | ||
102 | } | 115 | } |
103 | #endif /* BUTTON_DRIVER_CLOSE */ | 116 | #endif /* BUTTON_DRIVER_CLOSE */ |