summaryrefslogtreecommitdiffstats
path: root/hci/src/userial.c
diff options
context:
space:
mode:
Diffstat (limited to 'hci/src/userial.c')
-rw-r--r--hci/src/userial.c95
1 files changed, 52 insertions, 43 deletions
diff --git a/hci/src/userial.c b/hci/src/userial.c
index 0b37c3f..71f5ae8 100644
--- a/hci/src/userial.c
+++ b/hci/src/userial.c
@@ -3,44 +3,44 @@
* Copyright (C) 2009-2012 Broadcom Corporation
*
* This program is the proprietary software of Broadcom Corporation and/or its
- * licensors, and may only be used, duplicated, modified or distributed
- * pursuant to the terms and conditions of a separate, written license
- * agreement executed between you and Broadcom (an "Authorized License").
- * Except as set forth in an Authorized License, Broadcom grants no license
- * (express or implied), right to use, or waiver of any kind with respect to
- * the Software, and Broadcom expressly reserves all rights in and to the
- * Software and all intellectual property rights therein.
- * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS
- * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
- * ALL USE OF THE SOFTWARE.
+ * licensors, and may only be used, duplicated, modified or distributed
+ * pursuant to the terms and conditions of a separate, written license
+ * agreement executed between you and Broadcom (an "Authorized License").
+ * Except as set forth in an Authorized License, Broadcom grants no license
+ * (express or implied), right to use, or waiver of any kind with respect to
+ * the Software, and Broadcom expressly reserves all rights in and to the
+ * Software and all intellectual property rights therein.
+ * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS
+ * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
+ * ALL USE OF THE SOFTWARE.
*
* Except as expressly set forth in the Authorized License,
*
- * 1. This program, including its structure, sequence and organization,
- * constitutes the valuable trade secrets of Broadcom, and you shall
- * use all reasonable efforts to protect the confidentiality thereof,
- * and to use this information only in connection with your use of
+ * 1. This program, including its structure, sequence and organization,
+ * constitutes the valuable trade secrets of Broadcom, and you shall
+ * use all reasonable efforts to protect the confidentiality thereof,
+ * and to use this information only in connection with your use of
* Broadcom integrated circuit products.
*
- * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED
- * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
- * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
- * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY
- * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
- * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
- * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
+ * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED
+ * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
+ * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
+ * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY
+ * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
+ * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
+ * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
* CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT
* OF USE OR PERFORMANCE OF THE SOFTWARE.
*
* 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR
- * ITS LICENSORS BE LIABLE FOR
- * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY
- * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO
- * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM
- * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR
- * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE
- * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
- * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF
+ * ITS LICENSORS BE LIABLE FOR
+ * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY
+ * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO
+ * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM
+ * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR
+ * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE
+ * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
+ * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF
* ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.
*
******************************************************************************/
@@ -101,7 +101,7 @@ extern bt_vendor_interface_t *bt_vnd_if;
typedef struct
{
- int sock;
+ int fd;
uint8_t port;
pthread_t read_thread;
BUFFER_Q rx_q;
@@ -262,7 +262,7 @@ static void *userial_read_thread(void *arg)
p_buf->layer_specific = 0;
p = (uint8_t *) (p_buf + 1);
- rx_length = select_read(userial_cb.sock, p, READ_LIMIT);
+ rx_length = select_read(userial_cb.fd, p, READ_LIMIT);
}
else
{
@@ -315,7 +315,7 @@ uint8_t userial_init(void)
{
USERIALDBG("userial_init");
memset(&userial_cb, 0, sizeof(tUSERIAL_CB));
- userial_cb.sock = -1;
+ userial_cb.fd = -1;
utils_queue_init(&(userial_cb.rx_q));
return TRUE;
}
@@ -335,6 +335,7 @@ uint8_t userial_open(uint8_t port)
struct sched_param param;
int policy, result;
pthread_attr_t thread_attr;
+ int fd_array[CH_MAX];
USERIALDBG("userial_open(port:%d)", port);
@@ -354,7 +355,18 @@ uint8_t userial_open(uint8_t port)
/* Calling vendor-specific part */
if (bt_vnd_if)
{
- userial_cb.sock = bt_vnd_if->op(BT_VND_OP_USERIAL_OPEN, NULL);
+ result = bt_vnd_if->op(BT_VND_OP_USERIAL_OPEN, &fd_array);
+
+ if (result != 1)
+ {
+ ALOGE("userial_open: wrong numbers of open fd in vendor lib [%d]!",
+ result);
+ ALOGE("userial_open: HCI UART expects only one open fd");
+ bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL);
+ return FALSE;
+ }
+
+ userial_cb.fd = fd_array[0];
}
else
{
@@ -363,13 +375,13 @@ uint8_t userial_open(uint8_t port)
return FALSE;
}
- if (userial_cb.sock == -1)
+ if (userial_cb.fd == -1)
{
ALOGE("userial_open: failed to open UART port");
return FALSE;
}
- USERIALDBG( "sock = %d", userial_cb.sock);
+ USERIALDBG( "fd = %d", userial_cb.fd);
userial_cb.port = port;
@@ -409,7 +421,7 @@ uint8_t userial_open(uint8_t port)
** copied into p_data. This may be less than len.
**
*******************************************************************************/
-uint16_t userial_read(uint8_t *p_buffer, uint16_t len)
+uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len)
{
uint16_t total_len = 0;
uint16_t copy_len = 0;
@@ -463,13 +475,13 @@ uint16_t userial_read(uint8_t *p_buffer, uint16_t len)
** may be less than len.
**
*******************************************************************************/
-uint16_t userial_write(uint8_t *p_data, uint16_t len)
+uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len)
{
int ret, total = 0;
while(len != 0)
{
- ret = write(userial_cb.sock, p_data+total, len);
+ ret = write(userial_cb.fd, p_data+total, len);
total += ret;
len -= ret;
}
@@ -491,7 +503,7 @@ void userial_close(void)
int result;
TRANSAC p_buf;
- USERIALDBG("userial_close(sock:%d)", userial_cb.sock);
+ USERIALDBG("userial_close(fd:%d)", userial_cb.fd);
if (userial_running)
send_wakeup_signal(USERIAL_RX_EXIT);
@@ -503,10 +515,7 @@ void userial_close(void)
if (bt_vnd_if)
bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL);
- if ((result=close(userial_cb.sock)) < 0)
- ALOGE( "close(sock:%d) FAILED result:%d", userial_cb.sock, result);
-
- userial_cb.sock = -1;
+ userial_cb.fd = -1;
if (bt_hc_cbacks)
{