FM: synchronization for FM_TX path
- if que is not empty don't wait
- added more logs in tx path
Change-Id: Iec29ce9134da98e3c41e75480b3a1aba4a59b198
diff --git a/fm_hci/fm_hci.cpp b/fm_hci/fm_hci.cpp
index 18ffc19..6c1e07e 100644
--- a/fm_hci/fm_hci.cpp
+++ b/fm_hci/fm_hci.cpp
@@ -185,13 +185,14 @@
*******************************************************************************/
static int enqueue_fm_tx_cmd(struct fm_command_header_t *hdr)
{
- ALOGI("%s: opcode 0x%x len:%d", __func__, hdr->opcode, hdr->len);
+ ALOGI("%s: opcode 0x%x len:%d tx_processing %d", __func__, hdr->opcode, hdr->len, hci.is_tx_processing);
hci.tx_queue_mtx.lock();
hci.tx_cmd_queue.push(hdr);
hci.tx_queue_mtx.unlock();
if (hci.is_tx_processing == false) {
+ ALOGI("%s: notifying tx_processing %d", __func__,hci.is_tx_processing);
hci.tx_cond.notify_all();
}
@@ -221,18 +222,21 @@
while (1) {
hci.tx_queue_mtx.lock();
+ ALOGI("%s inside while(1) %d", __func__,hci.tx_cmd_queue.empty());
if(hci.tx_cmd_queue.empty()){
- ALOGI("No more FM CMDs are available in the Queue");
+ ALOGI(" %s No more FM CMDs are available in the Queue",__func__);
hci.is_tx_processing = false;
hci.tx_queue_mtx.unlock();
return;
} else {
+ ALOGI("%s tx_processing", __func__);
hci.is_tx_processing = true;
}
hdr = hci.tx_cmd_queue.front();
hci.tx_cmd_queue.pop();
hci.tx_queue_mtx.unlock();
+ ALOGI("%s: packet popped %d credits", __func__,hci.command_credits);
Lock lk(hci.credit_mtx);
while (hci.command_credits == 0) {
@@ -245,6 +249,7 @@
}
hci.command_credits--;
hci_transmit(hdr);
+ ALOGI("%s: packet transmitted %d credits", __func__,hci.command_credits);
}
}
@@ -268,9 +273,18 @@
while (hci.state != FM_RADIO_DISABLING && hci.state != FM_RADIO_DISABLED) {
//wait for tx cmd
+ ALOGV("%s: acquiring lock %d credits!!!" , __func__,hci.command_credits);
Lock lk(hci.tx_cond_mtx);
- hci.tx_cond.wait(lk);
- ALOGV("%s: dequeueing the tx cmd!!!" , __func__);
+ if(hci.tx_cmd_queue.empty())
+ {
+ ALOGI("%s: before wait %d credits!!!" , __func__,hci.command_credits);
+ hci.tx_cond.wait(lk);
+ }
+ else
+ {
+ ALOGI("%s:queue is not empty dont wait" , __func__);
+ }
+ ALOGV("%s: after wait dequeueing the tx cmd!!!" , __func__);
dequeue_fm_tx_cmd();
}