Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 13b9158f authored by Dmitry Grinberg's avatar Dmitry Grinberg Committed by Android Git Automerger
Browse files

am 532448f9: add wakelock control callback

* commit '532448f9':
  add wakelock control callback
parents f277320a 532448f9
Loading
Loading
Loading
Loading
+28 −8
Original line number Diff line number Diff line
@@ -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;
@@ -113,6 +112,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
@@ -122,13 +122,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);
}


/*****************************************************************************
**
@@ -527,8 +547,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;
    }
}
@@ -569,14 +589,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;
+3 −0
Original line number Diff line number Diff line
@@ -68,6 +68,8 @@ bt_callbacks_t *bt_hal_cbacks = NULL;
**  Externs
************************************************************************************/

extern bt_wakelock_callback config_wakelock_callback;

/* list all extended interfaces here */

/* handsfree profile */
@@ -119,6 +121,7 @@ static int init(bt_callbacks_t* callbacks )

    /* store reference to user callbacks */
    bt_hal_cbacks = callbacks;
    config_wakelock_callback = callbacks->bt_wakelock_cb;

    /* add checks for individual callbacks ? */