summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/ypr0/button-ypr0.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/hosted/ypr0/button-ypr0.c')
-rw-r--r--firmware/target/hosted/ypr0/button-ypr0.c13
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 */
33enum ypr0_buttons { 34enum ypr0_buttons {
@@ -45,6 +46,7 @@ enum ypr0_buttons {
45 46
46 47
47static int r0_btn_fd = 0; 48static 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 :( */
49static enum ypr0_buttons r0_read_key(void) 51static 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
87bool 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 */
87void button_init_device(void) 94void 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 */