diff options
author | Luke Zhang <lukez@qca.qualcomm.com> | 2015-11-05 18:23:07 -0800 |
---|---|---|
committer | Luke Zhang <lukez@codeaurora.org> | 2015-11-11 10:46:56 -0800 |
commit | 706b26755fadb2b85879aead142a9b65feca8505 (patch) | |
tree | 9f8110de6b9327d6b1f30553f56231f51c550d50 /hci | |
parent | cb9d1396b2af487176b402179717c26d9e82378e (diff) | |
download | android_system_bt-706b26755fadb2b85879aead142a9b65feca8505.tar.gz android_system_bt-706b26755fadb2b85879aead142a9b65feca8505.tar.bz2 android_system_bt-706b26755fadb2b85879aead142a9b65feca8505.zip |
Fix the command timeout issue with TX idle timer
Start the idle timer after sending out each command to prevent power
collapse.
CRs-fixed:926763
Change-Id: I98e649fa40a4622e3c6bce4ea5c53d51e25413b3
Diffstat (limited to 'hci')
-rw-r--r-- | hci/include/low_power_manager.h | 3 | ||||
-rw-r--r-- | hci/src/hci_layer.c | 4 | ||||
-rw-r--r-- | hci/src/low_power_manager.c | 20 |
3 files changed, 17 insertions, 10 deletions
diff --git a/hci/include/low_power_manager.h b/hci/include/low_power_manager.h index 95f990af4..138b3ebed 100644 --- a/hci/include/low_power_manager.h +++ b/hci/include/low_power_manager.h @@ -41,6 +41,9 @@ typedef struct low_power_manager_t { // Tell the low power manager that you're done transmitting data. Must be // called on the thread provided at initialization time. void (*transmit_done)(void); + + void (*start_idle_timer)(bool check_LPM); + void (*stop_idle_timer)(); } low_power_manager_t; const low_power_manager_t *low_power_manager_get_interface(); diff --git a/hci/src/hci_layer.c b/hci/src/hci_layer.c index fb2bb972e..45dfd7990 100644 --- a/hci/src/hci_layer.c +++ b/hci/src/hci_layer.c @@ -467,9 +467,9 @@ static void event_command_ready(fixed_queue_t *queue, UNUSED_ATTR void *context) pthread_mutex_unlock(&commands_pending_response_lock); // Send it off - low_power_manager->wake_assert(); + low_power_manager->stop_idle_timer(); packet_fragmenter->fragment_and_dispatch(wait_entry->command); - low_power_manager->transmit_done(); + low_power_manager->start_idle_timer(false); non_repeating_timer_restart_if(command_response_timer, !list_is_empty(commands_pending_response)); } diff --git a/hci/src/low_power_manager.c b/hci/src/low_power_manager.c index 9435e4fe1..bec968b72 100644 --- a/hci/src/low_power_manager.c +++ b/hci/src/low_power_manager.c @@ -55,8 +55,8 @@ static void event_allow_device_sleep(void *context); static void event_idle_timeout(void *context); static void reset_state(); -static void start_idle_timer(); -static void stop_idle_timer(); +void start_idle_timer(bool check_LPM); +void stop_idle_timer(); static thread_fn event_functions[] = { event_disable, @@ -123,7 +123,7 @@ static void transmit_done() { transmit_is_done = true; if (wake_state == LPM_WAKE_W4_TX_DONE) { wake_state = LPM_WAKE_W4_TIMEOUT; - start_idle_timer(); + start_idle_timer(true); } } @@ -155,7 +155,7 @@ static void allow_device_sleep() { if (state == LPM_ENABLED && wake_state == LPM_WAKE_ASSERTED) { if (transmit_is_done) { wake_state = LPM_WAKE_W4_TIMEOUT; - start_idle_timer(); + start_idle_timer(true); } else { wake_state = LPM_WAKE_W4_TX_DONE; } @@ -182,14 +182,16 @@ static void idle_timer_expired(UNUSED_ATTR void *context) { thread_post(thread, event_idle_timeout, NULL); } -static void start_idle_timer() { - if (state == LPM_ENABLED) { +void start_idle_timer(bool check_LPM) { + if (state == LPM_ENABLED || !check_LPM) { alarm_set(idle_alarm, idle_timeout_ms, idle_timer_expired, NULL); + LOG_DEBUG("%s check_LPM = %d", __func__, check_LPM); } } -static void stop_idle_timer() { +void stop_idle_timer() { alarm_cancel(idle_alarm); + LOG_DEBUG("%s", __func__); } static void event_disable(UNUSED_ATTR void *context) { @@ -228,7 +230,9 @@ static const low_power_manager_t interface = { cleanup, post_command, wake_assert, - transmit_done + transmit_done, + start_idle_timer, + stop_idle_timer }; const low_power_manager_t *low_power_manager_get_interface() { |