target: Modify API for detecting volume up key in timer callback
Modify function for detecting volume up key in timer callback
Change-Id: I54eccca8c9429fe66745592cc01089e3e7c05bd7
diff --git a/target/msm8996/init.c b/target/msm8996/init.c
index 63c3b2d..a67c3da 100644
--- a/target/msm8996/init.c
+++ b/target/msm8996/init.c
@@ -99,19 +99,24 @@
/* Return 1 if vol_up pressed */
int target_volume_up()
{
+ static uint8_t first_time = 0;
uint8_t status = 0;
struct pm8x41_gpio gpio;
- /* Configure the GPIO */
- gpio.direction = PM_GPIO_DIR_IN;
- gpio.function = 0;
- gpio.pull = PM_GPIO_PULL_UP_30;
- gpio.vin_sel = 2;
+ if (!first_time) {
+ /* Configure the GPIO */
+ gpio.direction = PM_GPIO_DIR_IN;
+ gpio.function = 0;
+ gpio.pull = PM_GPIO_PULL_UP_30;
+ gpio.vin_sel = 2;
- pm8x41_gpio_config(2, &gpio);
+ pm8x41_gpio_config(2, &gpio);
- /* Wait for the pmic gpio config to take effect */
- thread_sleep(1);
+ /* Wait for the pmic gpio config to take effect */
+ udelay(10000);
+
+ first_time = 1;
+ }
/* Get status of P_GPIO_5 */
pm8x41_gpio_get(2, &status);