system/bt
Revisão | 5a234ca06c185f336a6398efe09f78c4d0dacf0b (tree) |
---|---|
Hora | 2016-09-13 16:29:34 |
Autor | Luke Zhang <lukez@qca....> |
Commiter | Ivan Grinko |
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
@@ -41,6 +41,9 @@ typedef struct low_power_manager_t { | ||
41 | 41 | // Tell the low power manager that you're done transmitting data. Must be |
42 | 42 | // called on the thread provided at initialization time. |
43 | 43 | void (*transmit_done)(void); |
44 | + | |
45 | + void (*start_idle_timer)(bool check_LPM); | |
46 | + void (*stop_idle_timer)(); | |
44 | 47 | } low_power_manager_t; |
45 | 48 | |
46 | 49 | const low_power_manager_t *low_power_manager_get_interface(); |
@@ -534,9 +534,9 @@ static void event_command_ready(fixed_queue_t *queue, UNUSED_ATTR void *context) | ||
534 | 534 | pthread_mutex_unlock(&commands_pending_response_lock); |
535 | 535 | |
536 | 536 | // Send it off |
537 | - low_power_manager->wake_assert(); | |
537 | + low_power_manager->stop_idle_timer(); | |
538 | 538 | packet_fragmenter->fragment_and_dispatch(wait_entry->command); |
539 | - low_power_manager->transmit_done(); | |
539 | + low_power_manager->start_idle_timer(false); | |
540 | 540 | |
541 | 541 | update_command_response_timer(); |
542 | 542 | } |
@@ -61,8 +61,8 @@ static void event_allow_device_sleep(void *context); | ||
61 | 61 | static void event_idle_timeout(void *context); |
62 | 62 | |
63 | 63 | static void reset_state(); |
64 | -static void start_idle_timer(); | |
65 | -static void stop_idle_timer(); | |
64 | +void start_idle_timer(bool check_LPM); | |
65 | +void stop_idle_timer(); | |
66 | 66 | |
67 | 67 | static thread_fn event_functions[] = { |
68 | 68 | event_disable, |
@@ -129,7 +129,7 @@ static void transmit_done() { | ||
129 | 129 | transmit_is_done = true; |
130 | 130 | if (wake_state == LPM_WAKE_W4_TX_DONE) { |
131 | 131 | wake_state = LPM_WAKE_W4_TIMEOUT; |
132 | - start_idle_timer(); | |
132 | + start_idle_timer(true); | |
133 | 133 | } |
134 | 134 | } |
135 | 135 |
@@ -163,7 +163,7 @@ static void allow_device_sleep() { | ||
163 | 163 | if (state == LPM_ENABLED && wake_state == LPM_WAKE_ASSERTED) { |
164 | 164 | if (transmit_is_done) { |
165 | 165 | wake_state = LPM_WAKE_W4_TIMEOUT; |
166 | - start_idle_timer(); | |
166 | + start_idle_timer(true); | |
167 | 167 | } else { |
168 | 168 | wake_state = LPM_WAKE_W4_TX_DONE; |
169 | 169 | } |
@@ -190,8 +190,8 @@ static void idle_timer_expired(UNUSED_ATTR void *context) { | ||
190 | 190 | thread_post(thread, event_idle_timeout, NULL); |
191 | 191 | } |
192 | 192 | |
193 | -static void start_idle_timer() { | |
194 | - if (state == LPM_ENABLED) { | |
193 | +void start_idle_timer(bool check_LPM) { | |
194 | + if (state == LPM_ENABLED || !check_LPM) { | |
195 | 195 | if (idle_timeout_ms == 0) { |
196 | 196 | wake_deassert(); |
197 | 197 | } else { |
@@ -200,8 +200,9 @@ static void start_idle_timer() { | ||
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | -static void stop_idle_timer() { | |
203 | +void stop_idle_timer() { | |
204 | 204 | alarm_cancel(idle_alarm); |
205 | + LOG_DEBUG("%s", __func__); | |
205 | 206 | } |
206 | 207 | |
207 | 208 | static void event_disable(UNUSED_ATTR void *context) { |
@@ -240,7 +241,9 @@ static const low_power_manager_t interface = { | ||
240 | 241 | cleanup, |
241 | 242 | post_command, |
242 | 243 | wake_assert, |
243 | - transmit_done | |
244 | + transmit_done, | |
245 | + start_idle_timer, | |
246 | + stop_idle_timer | |
244 | 247 | }; |
245 | 248 | |
246 | 249 | const low_power_manager_t *low_power_manager_get_interface() { |