Loading system/hci/include/userial.h +28 −53 Original line number Diff line number Diff line Loading @@ -24,61 +24,45 @@ * ******************************************************************************/ #ifndef USERIAL_H #define USERIAL_H #pragma once /****************************************************************************** ** Constants & Macros ******************************************************************************/ #include <stdbool.h> #include <stdint.h> /**** port IDs ****/ #define USERIAL_PORT_1 0 #define USERIAL_PORT_2 1 #define USERIAL_PORT_3 2 #define USERIAL_PORT_4 3 #define USERIAL_PORT_5 4 #define USERIAL_PORT_6 5 #define USERIAL_PORT_7 6 #define USERIAL_PORT_8 7 #define USERIAL_PORT_9 8 #define USERIAL_PORT_10 9 #define USERIAL_PORT_11 10 #define USERIAL_PORT_12 11 #define USERIAL_PORT_13 12 #define USERIAL_PORT_14 13 #define USERIAL_PORT_15 14 #define USERIAL_PORT_16 15 #define USERIAL_PORT_17 16 #define USERIAL_PORT_18 17 typedef enum { USERIAL_PORT_1, USERIAL_PORT_2, USERIAL_PORT_3, USERIAL_PORT_4, USERIAL_PORT_5, USERIAL_PORT_6, USERIAL_PORT_7, USERIAL_PORT_8, USERIAL_PORT_9, USERIAL_PORT_10, USERIAL_PORT_11, USERIAL_PORT_12, USERIAL_PORT_13, USERIAL_PORT_14, USERIAL_PORT_15, USERIAL_PORT_16, USERIAL_PORT_17, USERIAL_PORT_18, } userial_port_t; typedef enum { USERIAL_OP_INIT, USERIAL_OP_RXFLOW_ON, USERIAL_OP_RXFLOW_OFF, } userial_ioctl_op_t; /****************************************************************************** ** Type definitions ******************************************************************************/ /****************************************************************************** ** Extern variables and functions ******************************************************************************/ /****************************************************************************** ** Functions ******************************************************************************/ /******************************************************************************* ** ** Function userial_init ** ** Description Initializes the userial driver ** ** Returns TRUE/FALSE ** *******************************************************************************/ uint8_t userial_init(void); bool userial_init(void); /******************************************************************************* ** Loading @@ -86,10 +70,8 @@ uint8_t userial_init(void); ** ** Description Open Bluetooth device with the port ID ** ** Returns TRUE/FALSE ** *******************************************************************************/ uint8_t userial_open(uint8_t port); bool userial_open(userial_port_t port); /******************************************************************************* ** Loading @@ -113,7 +95,7 @@ uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len); ** may be less than len. ** *******************************************************************************/ uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len); uint16_t userial_write(uint16_t msg_id, const uint8_t *p_data, uint16_t len); /******************************************************************************* ** Loading @@ -121,8 +103,6 @@ uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len); ** ** Description Close the userial port ** ** Returns None ** *******************************************************************************/ void userial_close(void); Loading @@ -132,10 +112,5 @@ void userial_close(void); ** ** Description ioctl inteface ** ** Returns None ** *******************************************************************************/ void userial_ioctl(userial_ioctl_op_t op, void *p_data); #endif /* USERIAL_H */ void userial_ioctl(userial_ioctl_op_t op); system/hci/src/bt_hci_bdroid.c +1 −2 Original line number Diff line number Diff line Loading @@ -337,8 +337,7 @@ static int set_rxflow(bt_rx_flow_state_t state) BTHCDBG("set_rxflow %d", state); userial_ioctl(\ ((state == BT_RXFLOW_ON) ? USERIAL_OP_RXFLOW_ON : USERIAL_OP_RXFLOW_OFF), \ NULL); ((state == BT_RXFLOW_ON) ? USERIAL_OP_RXFLOW_ON : USERIAL_OP_RXFLOW_OFF)); return BT_HC_STATUS_SUCCESS; } Loading system/hci/src/userial.c +13 −25 Original line number Diff line number Diff line Loading @@ -313,29 +313,24 @@ static void *userial_read_thread(void *arg) ** ** Description Initializes the userial driver ** ** Returns TRUE/FALSE ** *******************************************************************************/ uint8_t userial_init(void) bool userial_init(void) { USERIALDBG("userial_init"); memset(&userial_cb, 0, sizeof(tUSERIAL_CB)); userial_cb.fd = -1; utils_queue_init(&(userial_cb.rx_q)); return TRUE; return true; } /******************************************************************************* ** ** Function userial_open ** ** Description Open Bluetooth device with the port ID ** ** Returns TRUE/FALSE ** *******************************************************************************/ uint8_t userial_open(uint8_t port) bool userial_open(userial_port_t port) { struct sched_param param; int policy, result; Loading @@ -354,7 +349,7 @@ uint8_t userial_open(uint8_t port) if (port >= MAX_SERIAL_PORT) { ALOGE("Port > MAX_SERIAL_PORT"); return FALSE; return false; } /* Calling vendor-specific part */ Loading @@ -368,7 +363,7 @@ uint8_t userial_open(uint8_t port) result); ALOGE("userial_open: HCI UART expects only one open fd"); bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL); return FALSE; return false; } userial_cb.fd = fd_array[0]; Loading @@ -377,13 +372,13 @@ uint8_t userial_open(uint8_t port) { ALOGE("userial_open: missing vendor lib interface !!!"); ALOGE("userial_open: unable to open UART port"); return FALSE; return false; } if (userial_cb.fd == -1) { ALOGE("userial_open: failed to open UART port"); return FALSE; return false; } USERIALDBG( "fd = %d", userial_cb.fd); Loading @@ -396,7 +391,7 @@ uint8_t userial_open(uint8_t port) userial_read_thread, NULL) != 0 ) { ALOGE("pthread_create failed!"); return FALSE; return false; } if(pthread_getschedparam(userial_cb.read_thread, &policy, ¶m)==0) Loading @@ -415,7 +410,7 @@ uint8_t userial_open(uint8_t port) } } return TRUE; return true; } /******************************************************************************* Loading Loading @@ -483,7 +478,7 @@ uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len) ** may be less than len. ** *******************************************************************************/ uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len) uint16_t userial_write(uint16_t msg_id, const uint8_t *p_data, uint16_t len) { int ret, total = 0; UNUSED(msg_id); Loading @@ -507,8 +502,6 @@ uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len) ** ** Description Close the userial port ** ** Returns None ** *******************************************************************************/ void userial_close(void) { Loading Loading @@ -544,13 +537,9 @@ void userial_close(void) ** ** Description ioctl inteface ** ** Returns None ** *******************************************************************************/ void userial_ioctl(userial_ioctl_op_t op, void *p_data) void userial_ioctl(userial_ioctl_op_t op) { UNUSED(p_data); switch(op) { case USERIAL_OP_RXFLOW_ON: Loading @@ -563,9 +552,8 @@ void userial_ioctl(userial_ioctl_op_t op, void *p_data) send_wakeup_signal(USERIAL_RX_FLOW_OFF); break; case USERIAL_OP_INIT: default: ALOGE("%s invalid operation: %d", __func__, op); break; } } system/hci/src/userial_mct.c +13 −22 Original line number Diff line number Diff line Loading @@ -226,10 +226,8 @@ static void *userial_read_thread(void *arg) ** ** Description Initializes the userial driver ** ** Returns TRUE/FALSE ** *******************************************************************************/ uint8_t userial_init(void) bool userial_init(void) { int idx; Loading @@ -238,7 +236,7 @@ uint8_t userial_init(void) for (idx=0; idx < CH_MAX; idx++) userial_cb.fd[idx] = -1; utils_queue_init(&(userial_cb.rx_q)); return TRUE; return true; } Loading @@ -248,10 +246,8 @@ uint8_t userial_init(void) ** ** Description Open Bluetooth device with the port ID ** ** Returns TRUE/FALSE ** *******************************************************************************/ uint8_t userial_open(uint8_t port) bool userial_open(userial_port_t port) { struct sched_param param; int policy, result; Loading @@ -269,7 +265,7 @@ uint8_t userial_open(uint8_t port) if (port >= MAX_SERIAL_PORT) { ALOGE("Port > MAX_SERIAL_PORT"); return FALSE; return false; } /* Calling vendor-specific part */ Loading @@ -283,14 +279,14 @@ uint8_t userial_open(uint8_t port) result); ALOGE("userial_open: HCI MCT expects 2 or 4 open file descriptors"); bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL); return FALSE; return false; } } else { ALOGE("userial_open: missing vendor lib interface !!!"); ALOGE("userial_open: unable to open BT transport"); return FALSE; return false; } ALOGI("CMD=%d, EVT=%d, ACL_Out=%d, ACL_In=%d", \ Loading @@ -302,7 +298,7 @@ uint8_t userial_open(uint8_t port) { ALOGE("userial_open: failed to open BT transport"); bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL); return FALSE; return false; } userial_cb.port = port; Loading @@ -315,7 +311,7 @@ uint8_t userial_open(uint8_t port) { ALOGE("pthread_create failed!"); bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL); return FALSE; return false; } if(pthread_getschedparam(userial_cb.read_thread, &policy, ¶m)==0) Loading @@ -334,7 +330,7 @@ uint8_t userial_open(uint8_t port) } } return TRUE; return true; } /******************************************************************************* Loading Loading @@ -369,7 +365,7 @@ uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len) ** may be less than len. ** *******************************************************************************/ uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len) uint16_t userial_write(uint16_t msg_id, const uint8_t *p_data, uint16_t len) { int ret, total = 0; int ch_idx = (msg_id == MSG_STACK_TO_HC_HCI_CMD) ? CH_CMD : CH_ACL_OUT; Loading @@ -390,8 +386,6 @@ uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len) ** ** Description Close the userial port ** ** Returns None ** *******************************************************************************/ void userial_close(void) { Loading Loading @@ -419,10 +413,8 @@ void userial_close(void) ** ** Description ioctl inteface ** ** Returns None ** *******************************************************************************/ void userial_ioctl(userial_ioctl_op_t op, void *p_data) void userial_ioctl(userial_ioctl_op_t op) { switch(op) { Loading @@ -436,9 +428,8 @@ void userial_ioctl(userial_ioctl_op_t op, void *p_data) send_wakeup_signal(USERIAL_RX_FLOW_OFF); break; case USERIAL_OP_INIT: default: ALOGE("%s invalid operation: %d", __func__, op); break; } } Loading
system/hci/include/userial.h +28 −53 Original line number Diff line number Diff line Loading @@ -24,61 +24,45 @@ * ******************************************************************************/ #ifndef USERIAL_H #define USERIAL_H #pragma once /****************************************************************************** ** Constants & Macros ******************************************************************************/ #include <stdbool.h> #include <stdint.h> /**** port IDs ****/ #define USERIAL_PORT_1 0 #define USERIAL_PORT_2 1 #define USERIAL_PORT_3 2 #define USERIAL_PORT_4 3 #define USERIAL_PORT_5 4 #define USERIAL_PORT_6 5 #define USERIAL_PORT_7 6 #define USERIAL_PORT_8 7 #define USERIAL_PORT_9 8 #define USERIAL_PORT_10 9 #define USERIAL_PORT_11 10 #define USERIAL_PORT_12 11 #define USERIAL_PORT_13 12 #define USERIAL_PORT_14 13 #define USERIAL_PORT_15 14 #define USERIAL_PORT_16 15 #define USERIAL_PORT_17 16 #define USERIAL_PORT_18 17 typedef enum { USERIAL_PORT_1, USERIAL_PORT_2, USERIAL_PORT_3, USERIAL_PORT_4, USERIAL_PORT_5, USERIAL_PORT_6, USERIAL_PORT_7, USERIAL_PORT_8, USERIAL_PORT_9, USERIAL_PORT_10, USERIAL_PORT_11, USERIAL_PORT_12, USERIAL_PORT_13, USERIAL_PORT_14, USERIAL_PORT_15, USERIAL_PORT_16, USERIAL_PORT_17, USERIAL_PORT_18, } userial_port_t; typedef enum { USERIAL_OP_INIT, USERIAL_OP_RXFLOW_ON, USERIAL_OP_RXFLOW_OFF, } userial_ioctl_op_t; /****************************************************************************** ** Type definitions ******************************************************************************/ /****************************************************************************** ** Extern variables and functions ******************************************************************************/ /****************************************************************************** ** Functions ******************************************************************************/ /******************************************************************************* ** ** Function userial_init ** ** Description Initializes the userial driver ** ** Returns TRUE/FALSE ** *******************************************************************************/ uint8_t userial_init(void); bool userial_init(void); /******************************************************************************* ** Loading @@ -86,10 +70,8 @@ uint8_t userial_init(void); ** ** Description Open Bluetooth device with the port ID ** ** Returns TRUE/FALSE ** *******************************************************************************/ uint8_t userial_open(uint8_t port); bool userial_open(userial_port_t port); /******************************************************************************* ** Loading @@ -113,7 +95,7 @@ uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len); ** may be less than len. ** *******************************************************************************/ uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len); uint16_t userial_write(uint16_t msg_id, const uint8_t *p_data, uint16_t len); /******************************************************************************* ** Loading @@ -121,8 +103,6 @@ uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len); ** ** Description Close the userial port ** ** Returns None ** *******************************************************************************/ void userial_close(void); Loading @@ -132,10 +112,5 @@ void userial_close(void); ** ** Description ioctl inteface ** ** Returns None ** *******************************************************************************/ void userial_ioctl(userial_ioctl_op_t op, void *p_data); #endif /* USERIAL_H */ void userial_ioctl(userial_ioctl_op_t op);
system/hci/src/bt_hci_bdroid.c +1 −2 Original line number Diff line number Diff line Loading @@ -337,8 +337,7 @@ static int set_rxflow(bt_rx_flow_state_t state) BTHCDBG("set_rxflow %d", state); userial_ioctl(\ ((state == BT_RXFLOW_ON) ? USERIAL_OP_RXFLOW_ON : USERIAL_OP_RXFLOW_OFF), \ NULL); ((state == BT_RXFLOW_ON) ? USERIAL_OP_RXFLOW_ON : USERIAL_OP_RXFLOW_OFF)); return BT_HC_STATUS_SUCCESS; } Loading
system/hci/src/userial.c +13 −25 Original line number Diff line number Diff line Loading @@ -313,29 +313,24 @@ static void *userial_read_thread(void *arg) ** ** Description Initializes the userial driver ** ** Returns TRUE/FALSE ** *******************************************************************************/ uint8_t userial_init(void) bool userial_init(void) { USERIALDBG("userial_init"); memset(&userial_cb, 0, sizeof(tUSERIAL_CB)); userial_cb.fd = -1; utils_queue_init(&(userial_cb.rx_q)); return TRUE; return true; } /******************************************************************************* ** ** Function userial_open ** ** Description Open Bluetooth device with the port ID ** ** Returns TRUE/FALSE ** *******************************************************************************/ uint8_t userial_open(uint8_t port) bool userial_open(userial_port_t port) { struct sched_param param; int policy, result; Loading @@ -354,7 +349,7 @@ uint8_t userial_open(uint8_t port) if (port >= MAX_SERIAL_PORT) { ALOGE("Port > MAX_SERIAL_PORT"); return FALSE; return false; } /* Calling vendor-specific part */ Loading @@ -368,7 +363,7 @@ uint8_t userial_open(uint8_t port) result); ALOGE("userial_open: HCI UART expects only one open fd"); bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL); return FALSE; return false; } userial_cb.fd = fd_array[0]; Loading @@ -377,13 +372,13 @@ uint8_t userial_open(uint8_t port) { ALOGE("userial_open: missing vendor lib interface !!!"); ALOGE("userial_open: unable to open UART port"); return FALSE; return false; } if (userial_cb.fd == -1) { ALOGE("userial_open: failed to open UART port"); return FALSE; return false; } USERIALDBG( "fd = %d", userial_cb.fd); Loading @@ -396,7 +391,7 @@ uint8_t userial_open(uint8_t port) userial_read_thread, NULL) != 0 ) { ALOGE("pthread_create failed!"); return FALSE; return false; } if(pthread_getschedparam(userial_cb.read_thread, &policy, ¶m)==0) Loading @@ -415,7 +410,7 @@ uint8_t userial_open(uint8_t port) } } return TRUE; return true; } /******************************************************************************* Loading Loading @@ -483,7 +478,7 @@ uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len) ** may be less than len. ** *******************************************************************************/ uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len) uint16_t userial_write(uint16_t msg_id, const uint8_t *p_data, uint16_t len) { int ret, total = 0; UNUSED(msg_id); Loading @@ -507,8 +502,6 @@ uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len) ** ** Description Close the userial port ** ** Returns None ** *******************************************************************************/ void userial_close(void) { Loading Loading @@ -544,13 +537,9 @@ void userial_close(void) ** ** Description ioctl inteface ** ** Returns None ** *******************************************************************************/ void userial_ioctl(userial_ioctl_op_t op, void *p_data) void userial_ioctl(userial_ioctl_op_t op) { UNUSED(p_data); switch(op) { case USERIAL_OP_RXFLOW_ON: Loading @@ -563,9 +552,8 @@ void userial_ioctl(userial_ioctl_op_t op, void *p_data) send_wakeup_signal(USERIAL_RX_FLOW_OFF); break; case USERIAL_OP_INIT: default: ALOGE("%s invalid operation: %d", __func__, op); break; } }
system/hci/src/userial_mct.c +13 −22 Original line number Diff line number Diff line Loading @@ -226,10 +226,8 @@ static void *userial_read_thread(void *arg) ** ** Description Initializes the userial driver ** ** Returns TRUE/FALSE ** *******************************************************************************/ uint8_t userial_init(void) bool userial_init(void) { int idx; Loading @@ -238,7 +236,7 @@ uint8_t userial_init(void) for (idx=0; idx < CH_MAX; idx++) userial_cb.fd[idx] = -1; utils_queue_init(&(userial_cb.rx_q)); return TRUE; return true; } Loading @@ -248,10 +246,8 @@ uint8_t userial_init(void) ** ** Description Open Bluetooth device with the port ID ** ** Returns TRUE/FALSE ** *******************************************************************************/ uint8_t userial_open(uint8_t port) bool userial_open(userial_port_t port) { struct sched_param param; int policy, result; Loading @@ -269,7 +265,7 @@ uint8_t userial_open(uint8_t port) if (port >= MAX_SERIAL_PORT) { ALOGE("Port > MAX_SERIAL_PORT"); return FALSE; return false; } /* Calling vendor-specific part */ Loading @@ -283,14 +279,14 @@ uint8_t userial_open(uint8_t port) result); ALOGE("userial_open: HCI MCT expects 2 or 4 open file descriptors"); bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL); return FALSE; return false; } } else { ALOGE("userial_open: missing vendor lib interface !!!"); ALOGE("userial_open: unable to open BT transport"); return FALSE; return false; } ALOGI("CMD=%d, EVT=%d, ACL_Out=%d, ACL_In=%d", \ Loading @@ -302,7 +298,7 @@ uint8_t userial_open(uint8_t port) { ALOGE("userial_open: failed to open BT transport"); bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL); return FALSE; return false; } userial_cb.port = port; Loading @@ -315,7 +311,7 @@ uint8_t userial_open(uint8_t port) { ALOGE("pthread_create failed!"); bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL); return FALSE; return false; } if(pthread_getschedparam(userial_cb.read_thread, &policy, ¶m)==0) Loading @@ -334,7 +330,7 @@ uint8_t userial_open(uint8_t port) } } return TRUE; return true; } /******************************************************************************* Loading Loading @@ -369,7 +365,7 @@ uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len) ** may be less than len. ** *******************************************************************************/ uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len) uint16_t userial_write(uint16_t msg_id, const uint8_t *p_data, uint16_t len) { int ret, total = 0; int ch_idx = (msg_id == MSG_STACK_TO_HC_HCI_CMD) ? CH_CMD : CH_ACL_OUT; Loading @@ -390,8 +386,6 @@ uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len) ** ** Description Close the userial port ** ** Returns None ** *******************************************************************************/ void userial_close(void) { Loading Loading @@ -419,10 +413,8 @@ void userial_close(void) ** ** Description ioctl inteface ** ** Returns None ** *******************************************************************************/ void userial_ioctl(userial_ioctl_op_t op, void *p_data) void userial_ioctl(userial_ioctl_op_t op) { switch(op) { Loading @@ -436,9 +428,8 @@ void userial_ioctl(userial_ioctl_op_t op, void *p_data) send_wakeup_signal(USERIAL_RX_FLOW_OFF); break; case USERIAL_OP_INIT: default: ALOGE("%s invalid operation: %d", __func__, op); break; } }