From b7049f8573901ca12738fc47508a31ccb1de1c1c Mon Sep 17 00:00:00 2001 From: YK Jeffrey Chao Date: Mon, 6 Aug 2012 18:38:17 -0700 Subject: Revise BT vendor lib interface (1/2) 1. Move UART port configuration into vendor lib to respect the fact that each vendor might have different UART port settings for its own chipsets. 2. Detail bt_vendor_lib.h header file with usage instructions. Change-Id: I10dc44afd9b3cc1985769166a717089728281296 --- hci/src/bt_hci_bdroid.c | 8 +------- hci/src/hci_h4.c | 15 ++++++++++++++- hci/src/lpm.c | 3 ++- hci/src/userial.c | 33 ++++----------------------------- 4 files changed, 21 insertions(+), 38 deletions(-) (limited to 'hci/src') diff --git a/hci/src/bt_hci_bdroid.c b/hci/src/bt_hci_bdroid.c index 85199ec..91a80e7 100644 --- a/hci/src/bt_hci_bdroid.c +++ b/hci/src/bt_hci_bdroid.c @@ -122,12 +122,6 @@ static volatile uint8_t lib_running = 0; static volatile uint16_t ready_events = 0; static volatile uint8_t tx_cmd_pkts_pending = FALSE; -static const tUSERIAL_CFG userial_init_cfg = -{ - (USERIAL_DATABITS_8 | USERIAL_PARITY_NONE | USERIAL_STOPBITS_1), - USERIAL_BAUD_115200 -}; - /****************************************************************************** ** Functions ******************************************************************************/ @@ -398,7 +392,7 @@ static void *bt_hc_worker_thread(void *arg) if (events & HC_EVENT_PRELOAD) { - userial_open(USERIAL_PORT_1, (tUSERIAL_CFG *) &userial_init_cfg); + userial_open(USERIAL_PORT_1); /* Calling vendor-specific part */ if (bt_vnd_if) diff --git a/hci/src/hci_h4.c b/hci/src/hci_h4.c index b10d173..36c692a 100644 --- a/hci/src/hci_h4.c +++ b/hci/src/hci_h4.c @@ -304,7 +304,20 @@ uint8_t internal_event_intercept(void) HCIH4DBG( \ "Intercept CommandCompleteEvent for internal command (0x%04X)",\ opcode); - p_cb->int_cmd[p_cb->int_cmd_rd_idx].cback(p_cb->p_rcv_msg); + if (p_cb->int_cmd[p_cb->int_cmd_rd_idx].cback != NULL) + { + p_cb->int_cmd[p_cb->int_cmd_rd_idx].cback(p_cb->p_rcv_msg); + } + else + { + // Missing cback function! + // Release the p_rcv_msg buffer. + if (bt_hc_cbacks) + { + bt_hc_cbacks->dealloc((TRANSAC) p_cb->p_rcv_msg, \ + (char *) (p_cb->p_rcv_msg + 1)); + } + } p_cb->int_cmd_rd_idx = ((p_cb->int_cmd_rd_idx+1) & \ INT_CMD_PKT_IDX_MASK); p_cb->int_cmd_rsp_pending--; diff --git a/hci/src/lpm.c b/hci/src/lpm.c index 74d0809..78ee7dc 100644 --- a/hci/src/lpm.c +++ b/hci/src/lpm.c @@ -336,8 +336,9 @@ void lpm_enable(uint8_t turn_on) /* Calling vendor-specific part */ if (bt_vnd_if) { + uint8_t lpm_cmd = (turn_on) ? BT_VND_LPM_ENABLE : BT_VND_LPM_DISABLE; bt_lpm_cb.state = (turn_on) ? LPM_ENABLING : LPM_DISABLING; - bt_vnd_if->op(BT_VND_OP_LPM_SET_MODE, &turn_on); + bt_vnd_if->op(BT_VND_OP_LPM_SET_MODE, &lpm_cmd); } } diff --git a/hci/src/userial.c b/hci/src/userial.c index 92540c9..0b37c3f 100644 --- a/hci/src/userial.c +++ b/hci/src/userial.c @@ -104,7 +104,6 @@ typedef struct int sock; uint8_t port; pthread_t read_thread; - tUSERIAL_CFG cfg; BUFFER_Q rx_q; HC_BT_HDR *p_rx_hdr; } tUSERIAL_CB; @@ -326,18 +325,18 @@ uint8_t userial_init(void) ** ** Function userial_open ** -** Description Open the indicated serial port with the given configuration +** Description Open Bluetooth device with the port ID ** ** Returns TRUE/FALSE ** *******************************************************************************/ -uint8_t userial_open(uint8_t port, tUSERIAL_CFG *p_cfg) +uint8_t userial_open(uint8_t port) { struct sched_param param; int policy, result; pthread_attr_t thread_attr; - USERIALDBG("userial_open(port:%d, baud:%d)", port, p_cfg->baud); + USERIALDBG("userial_open(port:%d)", port); if (userial_running) { @@ -355,7 +354,7 @@ uint8_t userial_open(uint8_t port, tUSERIAL_CFG *p_cfg) /* Calling vendor-specific part */ if (bt_vnd_if) { - userial_cb.sock = bt_vnd_if->op(BT_VND_OP_USERIAL_OPEN, p_cfg); + userial_cb.sock = bt_vnd_if->op(BT_VND_OP_USERIAL_OPEN, NULL); } else { @@ -373,7 +372,6 @@ uint8_t userial_open(uint8_t port, tUSERIAL_CFG *p_cfg) USERIALDBG( "sock = %d", userial_cb.sock); userial_cb.port = port; - memcpy(&userial_cb.cfg, p_cfg, sizeof(tUSERIAL_CFG)); pthread_attr_init(&thread_attr); @@ -521,29 +519,6 @@ void userial_close(void) /******************************************************************************* ** -** Function userial_change_baud -** -** Description Change baud rate of userial port -** -** Returns None -** -*******************************************************************************/ -void userial_change_baud(uint8_t baud) -{ - /* Calling vendor-specific part */ - if (bt_vnd_if) - { - bt_vnd_if->op(BT_VND_OP_USERIAL_SET_BAUD, &baud); - } - else - { - ALOGE("userial_change_baud: missing vendor lib interface !!!"); - ALOGE("userial_change_baud: unable to change UART baud rate"); - } -} - -/******************************************************************************* -** ** Function userial_ioctl ** ** Description ioctl inteface -- cgit v1.1