diff options
Diffstat (limited to 'firmware/target/arm/imx31/gigabeat-s/button-imx31.c')
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/button-imx31.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/button-imx31.c b/firmware/target/arm/imx31/gigabeat-s/button-imx31.c index 602f41abb9..c85fe5e37e 100644 --- a/firmware/target/arm/imx31/gigabeat-s/button-imx31.c +++ b/firmware/target/arm/imx31/gigabeat-s/button-imx31.c | |||
@@ -29,7 +29,8 @@ | |||
29 | /* Most code in here is taken from the Linux BSP provided by Freescale | 29 | /* Most code in here is taken from the Linux BSP provided by Freescale |
30 | * Copyright 2004-2006 Freescale Semiconductor, Inc. All Rights Reserved. */ | 30 | * Copyright 2004-2006 Freescale Semiconductor, Inc. All Rights Reserved. */ |
31 | 31 | ||
32 | static uint32_t int_btn = BUTTON_NONE; | 32 | static bool headphones_detect = false; |
33 | static uint32_t int_btn = BUTTON_NONE; | ||
33 | static bool hold_button = false; | 34 | static bool hold_button = false; |
34 | static bool hold_button_old = false; | 35 | static bool hold_button_old = false; |
35 | #define _button_hold() (GPIO3_DR & 0x10) | 36 | #define _button_hold() (GPIO3_DR & 0x10) |
@@ -48,7 +49,8 @@ static __attribute__((interrupt("IRQ"))) void KPP_HANDLER(void) | |||
48 | unsigned short reg_val; | 49 | unsigned short reg_val; |
49 | int col, row; | 50 | int col, row; |
50 | int i; | 51 | int i; |
51 | int button = BUTTON_NONE; | 52 | /* Power button is handled separately on PMIC */ |
53 | int button = int_btn & BUTTON_POWER; | ||
52 | 54 | ||
53 | /* 1. Disable both (depress and release) keypad interrupts. */ | 55 | /* 1. Disable both (depress and release) keypad interrupts. */ |
54 | KPP_KPSR &= ~(KPP_KPSR_KRIE | KPP_KPSR_KDIE); | 56 | KPP_KPSR &= ~(KPP_KPSR_KRIE | KPP_KPSR_KDIE); |
@@ -161,3 +163,35 @@ int button_read_device(void) | |||
161 | /* If hold, ignore any pressed button */ | 163 | /* If hold, ignore any pressed button */ |
162 | return hold_button ? BUTTON_NONE : int_btn; | 164 | return hold_button ? BUTTON_NONE : int_btn; |
163 | } | 165 | } |
166 | |||
167 | /* This is called from the mc13783 interrupt thread */ | ||
168 | void button_power_set_state(bool pressed) | ||
169 | { | ||
170 | /* Prevent KPP_HANDLER from changing things */ | ||
171 | int oldlevel = disable_irq_save(); | ||
172 | |||
173 | if (pressed) | ||
174 | { | ||
175 | int_btn |= BUTTON_POWER; | ||
176 | } | ||
177 | else | ||
178 | { | ||
179 | int_btn &= ~BUTTON_POWER; | ||
180 | } | ||
181 | |||
182 | restore_irq(oldlevel); | ||
183 | } | ||
184 | |||
185 | /* This is called from the mc13783 interrupt thread */ | ||
186 | void set_headphones_inserted(bool inserted) | ||
187 | { | ||
188 | headphones_detect = inserted; | ||
189 | } | ||
190 | |||
191 | /* This is called from the mc13783 interrupt thread */ | ||
192 | /* TODO: Just do a post to the button queue directly - implement the | ||
193 | * appropriate variant in the driver. */ | ||
194 | bool headphones_inserted(void) | ||
195 | { | ||
196 | return headphones_detect; | ||
197 | } | ||