diff options
author | Andrii Beregovenko <a.beregovenko@ti.com> | 2013-01-31 19:42:47 +0200 |
---|---|---|
committer | Oleg Drokin <green@linuxhacker.ru> | 2013-06-28 01:30:58 -0400 |
commit | dbcd8668ad59d5c59a21c6835926b471ea133255 (patch) | |
tree | da95966d7a8f21240156c147511d7335b787ec91 | |
parent | 70d3d9f7c230387fcdcb1eefb79a8e3e0208e33e (diff) | |
download | android_hardware_ti_wpan-dbcd8668ad59d5c59a21c6835926b471ea133255.tar.gz android_hardware_ti_wpan-dbcd8668ad59d5c59a21c6835926b471ea133255.tar.bz2 android_hardware_ti_wpan-dbcd8668ad59d5c59a21c6835926b471ea133255.zip |
libbt-vendor: rework structure of source codecm-10.1.3-RC2cm-10.1.3-RC1cm-10.1.3cm-10.1
Before complete implementation rework basic structure of code:
- split actions to related functions
- implement constants
- remove useless log message
There aren't changes in logic.
Change-Id: I9cfa0782f78839f94085ab7d1b561925f34b5765
Signed-off-by: Andrii Beregovenko <a.beregovenko@ti.com>
-rw-r--r-- | bluedroid_wilink/libbt-vendor-ti.c | 63 |
1 files changed, 48 insertions, 15 deletions
diff --git a/bluedroid_wilink/libbt-vendor-ti.c b/bluedroid_wilink/libbt-vendor-ti.c index a1eb81a..fa9393c 100644 --- a/bluedroid_wilink/libbt-vendor-ti.c +++ b/bluedroid_wilink/libbt-vendor-ti.c @@ -16,6 +16,8 @@ * limitations under the License. */ +#define LOG_TAG "libbt_ti" + #include <stdio.h> #include <dlfcn.h> #include <utils/Log.h> @@ -27,6 +29,14 @@ #include <bt_hci_bdroid.h> #include <utils.h> +/** + * TODO: check/fix this value + * Low power mode: default transport idle timer + */ +#define WL_DEFAULT_LPM_IDLE_TIMEOUT 200 + +#define BT_HCI_TTY_DEVICE_NAME "/dev/hci_tty" + bt_vendor_callbacks_t *bt_vendor_cbacks = NULL; unsigned int hci_tty_fd = -1; void hw_config_cback(HC_BT_HDR *p_evt_buf); @@ -63,37 +73,60 @@ void ti_cleanup(void) { bt_vendor_cbacks = NULL; } -int ti_op(bt_vendor_opcode_t opcode, void **param) { + +int ti_hcitty_open(int *fd_array) { int fd; - int *fd_array = (int (*)[]) param; + fd = open(BT_HCI_TTY_DEVICE_NAME, O_RDWR); + if (fd < 0) { + ALOGE(" Can't open hci_tty"); + return -1; + } + fd_array[CH_CMD] = fd; + hci_tty_fd = fd; /* for userial_close op */ + return 1; /* CMD/EVT/ACL on same fd */ +} + +int ti_hcitty_close() { + if (hci_tty_fd == (unsigned int) -1) + return -1; + return close(hci_tty_fd); +} + +int ti_op(bt_vendor_opcode_t opcode, void **param) { + int ret = 0; - ALOGI("vendor op - %d", opcode); switch(opcode) { + case BT_VND_OP_POWER_CTRL: + break; + case BT_VND_OP_SCO_CFG: + break; + case BT_VND_OP_GET_LPM_IDLE_TIMEOUT: + *((uint32_t *) param) = WL_DEFAULT_LPM_IDLE_TIMEOUT; + break; + case BT_VND_OP_LPM_SET_MODE: + break; + case BT_VND_OP_LPM_WAKE_SET_STATE: + break; case BT_VND_OP_USERIAL_OPEN: - fd = open("/dev/hci_tty", O_RDWR); - if (fd < 0) { - ALOGE(" Can't open hci_tty"); - return -1; - } - fd_array[CH_CMD] = fd; - hci_tty_fd = fd; /* for userial_close op */ - return 1; /* CMD/EVT/ACL on same fd */ + ret = ti_hcitty_open(param); + break; case BT_VND_OP_USERIAL_CLOSE: - close(hci_tty_fd); - return 0; + ret = ti_hcitty_close(); + break; /* Since new stack expects fwcfg_cb we are returning SUCCESS here * in actual, firmware download is already happened when /dev/hci_tty * opened. */ case BT_VND_OP_FW_CFG: bt_vendor_cbacks->fwcfg_cb(BT_VND_OP_RESULT_SUCCESS); - return 0; + break; default: + ALOGW("Unknown opcode: %d", opcode); break; } - return 0; + return ret; } const bt_vendor_interface_t BLUETOOTH_VENDOR_LIB_INTERFACE = { .init = ti_init, |