diff options
author | Dmitry Grinberg <dmitrygr@google.com> | 2014-05-23 21:46:01 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-05-23 21:46:01 +0000 |
commit | 8075fbd743d5eb3937a11156abf2c9a4f051434c (patch) | |
tree | 1c35f15eace0aafc053f01380bb9d1f3c3993cbc /gki | |
parent | 63399d943938cb7234a7fba508ea603070720d77 (diff) | |
parent | 262685fe26c0ccc7e196def7db1d7447c51efdbb (diff) | |
download | android_system_bt-8075fbd743d5eb3937a11156abf2c9a4f051434c.tar.gz android_system_bt-8075fbd743d5eb3937a11156abf2c9a4f051434c.tar.bz2 android_system_bt-8075fbd743d5eb3937a11156abf2c9a4f051434c.zip |
am 262685fe: am cd7896c5: add wakelock control callback
* commit '262685fe26c0ccc7e196def7db1d7447c51efdbb':
add wakelock control callback
Diffstat (limited to 'gki')
-rw-r--r-- | gki/ulinux/gki_ulinux.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/gki/ulinux/gki_ulinux.c b/gki/ulinux/gki_ulinux.c index e6f45f42c..e2312dd91 100644 --- a/gki/ulinux/gki_ulinux.c +++ b/gki/ulinux/gki_ulinux.c @@ -29,6 +29,7 @@ #include <stdarg.h> #include <errno.h> #include <sys/times.h> +#include <hardware/bluetooth.h> #include <pthread.h> /* must be 1st header defined */ #include <time.h> @@ -74,8 +75,6 @@ #define UNLOCK(m) pthread_mutex_unlock(&m) #define INIT(m) pthread_mutex_init(&m, NULL) -#define WAKE_LOCK_ID "brcm_btld" -#define PARTIAL_WAKE_LOCK 1 #if GKI_DYNAMIC_MEMORY == FALSE tGKI_CB gki_cb; @@ -111,6 +110,7 @@ typedef struct int g_GkiTimerWakeLockOn = 0; gki_pthread_info_t gki_pthread_info[GKI_MAX_TASKS]; +bt_wakelock_callback config_wakelock_callback = NULL; /***************************************************************************** ** Static functions @@ -120,13 +120,33 @@ gki_pthread_info_t gki_pthread_info[GKI_MAX_TASKS]; ** Externs ******************************************************************************/ -extern int acquire_wake_lock(int lock, const char* id); -extern int release_wake_lock(const char* id); + /***************************************************************************** ** Functions ******************************************************************************/ +/* send a given byte into the wakelock pipe */ +static void wakelock_op_gki(unsigned char op) +{ + if (!config_wakelock_callback) + GKI_ERROR_LOG("Cannot perform wakelock operation with no callback\n"); + else + config_wakelock_callback(op); +} + +/* release a wakelock by sending a zero down the pipe */ +static void release_wake_lock_gki(void) +{ + wakelock_op_gki(0); +} + +/* acquire a wakelock by sending a one down the pipe */ +static void acquire_wake_lock_gki(void) +{ + wakelock_op_gki(1); +} + /***************************************************************************** ** @@ -529,8 +549,8 @@ void GKI_shutdown(void) #endif if (g_GkiTimerWakeLockOn) { - GKI_TRACE("GKI_shutdown : release_wake_lock(brcm_btld)"); - release_wake_lock(WAKE_LOCK_ID); + GKI_TRACE("GKI_shutdown : release_wake_lock_gki()"); + release_wake_lock_gki(); g_GkiTimerWakeLockOn = 0; } } @@ -571,14 +591,14 @@ void gki_system_tick_start_stop_cback(BOOLEAN start) GKI_TIMER_TRACE(">>> STOP GKI_timer_update(), wake_lock_count:%d", --wake_lock_count); - release_wake_lock(WAKE_LOCK_ID); + release_wake_lock_gki(); g_GkiTimerWakeLockOn = 0; } } else { /* restart GKI_timer_update() loop */ - acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_ID); + acquire_wake_lock_gki(); g_GkiTimerWakeLockOn = 1; *p_run_cond = GKI_TIMER_TICK_RUN_COND; |