Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implement libbt-vendor for BTS4025

  • Loading branch information...
commit 47cbfcb39e0324c29511eb15d072bfac5f59cc86 1 parent 4c7439e
@Ganster41 Ganster41 authored
View
2  BoardConfig.mk
@@ -54,8 +54,6 @@ BOARD_USE_LEGACY_TOUCHSCREEN := true
# Bluetooth
BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/zte/blade/bluetooth
-BOARD_HAVE_BLUETOOTH_BCM := true
-BOARD_BLUEDROID_VENDOR_CONF := device/zte/blade/bluetooth/libbt_vndcfg.txt
# GPS
BOARD_USES_QCOM_GPS := true
View
1  bluetooth/Android.mk
@@ -0,0 +1 @@
+include $(call all-named-subdir-makefiles,libbt-vendor)
View
54 bluetooth/CleanSpec.mk
@@ -0,0 +1,54 @@
+# Copyright (C) 2007 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# If you don't need to do a full clean build but would like to touch
+# a file or delete some intermediate files, add a clean step to the end
+# of the list. These steps will only be run once, if they haven't been
+# run before.
+#
+# E.g.:
+# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
+# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
+#
+# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
+# files that are missing or have been moved.
+#
+# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
+# Use $(OUT_DIR) to refer to the "out" directory.
+#
+# If you need to re-do something that's already mentioned, just copy
+# the command and add it to the bottom of the list. E.g., if a change
+# that you made last week required touching a file and a change you
+# made today requires touching the same file, just copy the old
+# touch step and add it to the end of the list.
+#
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+
+# For example:
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
+#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
+
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libbt-vendor_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/NOTICE_FILES/src/system/vendor/lib/libbt-vendor.so.txt)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/libbt-vendor.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/symbols/system/vendor/lib/libbt-vendor.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/vendor/lib/libbt-vendor.so)
View
44 bluetooth/libbt-vendor/Android.mk
@@ -0,0 +1,44 @@
+#
+# Copyright 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+BDROID_DIR:= external/bluetooth/bluedroid
+
+LOCAL_SRC_FILES := \
+ src/bt_vendor_qcom.c \
+ src/hardware.c \
+ src/userial_vendor.c \
+ src/bt_power.c
+
+LOCAL_C_INCLUDES += \
+ $(LOCAL_PATH)/include \
+ $(BDROID_DIR)/hci/include
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils
+
+LOCAL_MODULE := libbt-vendor
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_OWNER := qcom
+LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)
+
+include $(LOCAL_PATH)/vnd_buildcfg.mk
+
+include $(BUILD_SHARED_LIBRARY)
View
190 bluetooth/libbt-vendor/NOTICE
@@ -0,0 +1,190 @@
+
+ Copyright (c) 2005-2012, The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
View
25 bluetooth/libbt-vendor/include/bt_power.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BT_POWER_H
+#define BT_POWER_H
+
+#define BT_POWER_OFF "0"
+#define BT_POWER_ON "1"
+
+int set_bluetooth_power(char *power);
+
+#endif /* BT_POWER_H */
View
38 bluetooth/libbt-vendor/include/bt_vendor_qcom.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BT_VENDOR_QCOM_H
+#define BT_VENDOR_QCOM_H
+
+#include "bt_vendor_lib.h"
+#include "vnd_buildcfg.h"
+#include "userial_vendor.h"
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#ifndef TRUE
+#define TRUE (!FALSE)
+#endif
+
+// File discriptor using Transport
+extern int fd;
+
+extern bt_vendor_callbacks_t *bt_vendor_cbacks;
+
+#endif /* BT_VENDOR_BRCM_H */
+
View
37 bluetooth/libbt-vendor/include/userial_vendor.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/******************************************************************************
+ *
+ * Filename: userial_vendor.h
+ *
+ * Description: Contains vendor-specific definitions used in serial port
+ * controls
+ *
+ ******************************************************************************/
+
+#ifndef USERIAL_VENDOR_H
+#define USERIAL_VENDOR_H
+
+#define BT_HS_UART_DEVICE "/dev/ttyHS0"
+#define BT_RFKILL_DEVICE "/sys/class/rfkill/rfkill0/state"
+
+int bt_hci_init_transport ();
+
+int bt_hci_deinit_transport(int pFd);
+
+#endif /* USERIAL_VENDOR_H */
+
View
9 bluetooth/libbt-vendor/include/vnd_blade.txt
@@ -0,0 +1,9 @@
+BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyHS0"
+FW_PATCHFILE_LOCATION = "/system/bin/"
+BT_WAKE_VIA_USERIAL_IOCTL = TRUE
+LPM_IDLE_TIMEOUT_MULTIPLE = 5
+SCO_USE_I2S_INTERFACE = TRUE
+BTVND_DBG = FALSE
+BTHW_DBG = TRUE
+VNDUSERIAL_DBG = FALSE
+UPIO_DBG = FALSE
View
9 bluetooth/libbt-vendor/include/vnd_generic.txt
@@ -0,0 +1,9 @@
+BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyO1"
+FW_PATCHFILE_LOCATION = "/vendor/firmware/"
+BT_WAKE_VIA_USERIAL_IOCTL = TRUE
+LPM_IDLE_TIMEOUT_MULTIPLE = 5
+SCO_USE_I2S_INTERFACE = TRUE
+BTVND_DBG = FALSE
+BTHW_DBG = TRUE
+VNDUSERIAL_DBG = FALSE
+UPIO_DBG = FALSE
View
86 bluetooth/libbt-vendor/src/bt_power.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/******************************************************************************
+ *
+ * Filename: bt_power.c
+ *
+ * Description: Contains Bluetooth power control functions via rfkill
+ *
+ ******************************************************************************/
+
+#define LOG_TAG "bt_power"
+
+#include <utils/Log.h>
+#include <fcntl.h>
+#include <errno.h>
+#include "bt_power.h"
+
+static char *rfkill_state_path = NULL;
+
+static int init_rfkill()
+{
+ char path[64];
+ char buf[16];
+ int fd, sz, id;
+
+ for (id = 0; ; id++) {
+ snprintf(path, sizeof(path), "/sys/class/rfkill/rfkill%d/type", id);
+ fd = open(path, O_RDONLY);
+ if (fd < 0) {
+ ALOGE("init_rfkill : open(%s) failed: %s (%d)\n", \
+ path, strerror(errno), errno);
+ return 0;
+ }
+
+ sz = read(fd, &buf, sizeof(buf));
+ close(fd);
+
+ if (sz >= 9 && memcmp(buf, "bluetooth", 9) == 0) {
+ asprintf(&rfkill_state_path, "/sys/class/rfkill/rfkill%d/state", id);
+ break;
+ }
+ }
+
+ return 1;
+}
+
+int set_bluetooth_power(char *power) {
+ int ret = 1;
+
+ ALOGI("Trying to set Bluetooth power %s", *power == '1' ? "ON" : "OFF");
+
+ if(rfkill_state_path == NULL) {
+ init_rfkill();
+ }
+
+ int fd = open(rfkill_state_path, O_WRONLY);
+
+ if(fd < 0) {
+ ALOGE("Can't open %s", rfkill_state_path);
+ return 0;
+ }
+
+ int sz = write(fd, power, 1);
+
+ if(sz < 0) {
+ ALOGE("Can't write to %s", rfkill_state_path);
+ ret = 0;
+ }
+
+ close(fd);
+ return ret;
+}
View
194 bluetooth/libbt-vendor/src/bt_vendor_qcom.c
@@ -0,0 +1,194 @@
+/*
+ * Copyright 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/******************************************************************************
+ *
+ * Filename: bt_vendor_qcom.c
+ *
+ * Description: Qualcomm BTS4025 vendor specific library implementation
+ *
+ ******************************************************************************/
+
+#define LOG_TAG "bt_vendor"
+
+#include <utils/Log.h>
+#include <fcntl.h>
+#include <termios.h>
+#include "bt_vendor_qcom.h"
+#include "userial_vendor.h"
+#include "bt_power.h"
+
+/******************************************************************************
+** Externs
+******************************************************************************/
+extern int hw_config(int nState);
+
+extern int is_hw_ready();
+
+/******************************************************************************
+** Variables
+******************************************************************************/
+int pFd = 0;
+
+bt_vendor_callbacks_t *bt_vendor_cbacks = NULL;
+uint8_t vnd_local_bd_addr[6]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+/******************************************************************************
+** Local type definitions
+******************************************************************************/
+
+
+/******************************************************************************
+** Functions
+******************************************************************************/
+
+/*****************************************************************************
+**
+** BLUETOOTH VENDOR INTERFACE LIBRARY FUNCTIONS
+**
+*****************************************************************************/
+
+static int init(const bt_vendor_callbacks_t* p_cb, unsigned char *local_bdaddr)
+{
+ ALOGI("bt-vendor : init");
+
+ if (p_cb == NULL)
+ {
+ ALOGE("init failed with no user callbacks!");
+ return -1;
+ }
+
+ /* store reference to user callbacks */
+ bt_vendor_cbacks = (bt_vendor_callbacks_t *) p_cb;
+
+ /* This is handed over from the stack */
+ memcpy(vnd_local_bd_addr, local_bdaddr, 6);
+
+ return 0;
+}
+
+/** Requested operations */
+static int op(bt_vendor_opcode_t opcode, void *param)
+{
+ int retval = 0;
+ int nCnt = 0;
+ int nState = -1;
+
+ ALOGV("bt-vendor : op for %d", opcode);
+
+ switch(opcode)
+ {
+ case BT_VND_OP_POWER_CTRL:
+ {
+ int *state = (int *)param;
+
+ if (*state == BT_VND_PWR_OFF) {
+ if(!set_bluetooth_power(BT_POWER_OFF))
+ return 0;
+ } else if (*state == BT_VND_PWR_ON) {
+ if(!set_bluetooth_power(BT_POWER_ON))
+ return 0;
+ }
+
+ nState = *(int *) param;
+ retval = hw_config(nState);
+ if(nState == BT_VND_PWR_ON
+ && retval == 0
+ && is_hw_ready() == TRUE){
+ retval = 0;
+ }
+ else {
+ retval = -1;
+ }
+ }
+ break;
+
+ case BT_VND_OP_FW_CFG:
+ {
+ // call hciattach to initalize the stack
+ if(bt_vendor_cbacks){
+ ALOGI("Bluetooth Firmware and UART is initialized");
+ bt_vendor_cbacks->fwcfg_cb(BT_VND_OP_RESULT_SUCCESS);
+ }
+ else{
+ ALOGE("Error: hci, UART initialization Error");
+ bt_vendor_cbacks->fwcfg_cb(BT_VND_OP_RESULT_FAIL);
+ }
+ }
+ break;
+
+ case BT_VND_OP_SCO_CFG:
+ {
+ bt_vendor_cbacks->scocfg_cb(BT_VND_OP_RESULT_SUCCESS); //dummy
+ }
+ break;
+
+ case BT_VND_OP_USERIAL_OPEN:
+ {
+ pFd = bt_hci_init_transport();
+ if(pFd != -1){
+ int (*fd_array)[] = (int (*) []) param;
+ int idx;
+ for (idx=0; idx < CH_MAX; idx++)
+ (*fd_array)[idx] = pFd;
+ }
+ else {
+ retval = -1;
+ break;
+ }
+ retval = 1;
+ }
+ break;
+
+ case BT_VND_OP_USERIAL_CLOSE:
+ {
+ bt_hci_deinit_transport(pFd);
+ }
+ break;
+
+ case BT_VND_OP_GET_LPM_IDLE_TIMEOUT:
+ break;
+
+ case BT_VND_OP_LPM_SET_MODE:
+ {
+ bt_vendor_cbacks->lpm_cb(BT_VND_OP_RESULT_SUCCESS); //dummy
+ }
+ break;
+
+ case BT_VND_OP_LPM_WAKE_SET_STATE:
+ break;
+ }
+
+ return retval;
+}
+
+/** Closes the interface */
+static void cleanup( void )
+{
+ ALOGI("cleanup");
+
+ //upio_cleanup();
+
+ bt_vendor_cbacks = NULL;
+}
+
+// Entry point of DLib
+const bt_vendor_interface_t BLUETOOTH_VENDOR_LIB_INTERFACE = {
+ sizeof(bt_vendor_interface_t),
+ init,
+ op,
+ cleanup
+};
View
95 bluetooth/libbt-vendor/src/hardware.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/******************************************************************************
+ *
+ * Filename: hardware.c
+ *
+ * Description: Contains controller-specific functions, like
+ * firmware patch download
+ * low power mode operations
+ *
+ ******************************************************************************/
+
+#define LOG_TAG "bt_hwcfg"
+
+#include <utils/Log.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <signal.h>
+#include <time.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <ctype.h>
+#include <cutils/properties.h>
+#include <stdlib.h>
+#include "bt_hci_bdroid.h"
+#include "bt_vendor_qcom.h"
+
+#define MAX_CNT_RETRY 100
+
+int hw_config(int nState)
+{
+ ALOGI("Starting hciattach daemon");
+ char *szState[] = {"true", "false"};
+ char *szReqSt = NULL;
+
+ if(nState == BT_VND_PWR_OFF)
+ szReqSt = szState[1];
+ else
+ szReqSt = szState[0];
+
+ ALOGI("try to set %s", szReqSt);
+
+ if (property_set("bluetooth.hciattach", szReqSt) < 0){
+ ALOGE("Property Setting fail");
+ return -1;
+ }
+
+ return 0;
+}
+
+int readTrpState()
+{
+ char szBtStatus[20] = {0, };
+ if(property_get("bluetooth.status", szBtStatus, "") < 0){
+ ALOGE("Fail to get bluetooth satus");
+ return FALSE;
+ }
+
+ if(!strncmp(szBtStatus, "on", strlen("on"))){
+ ALOGI("bluetooth satus is on");
+ return TRUE;
+ }
+ return FALSE;
+}
+
+int is_hw_ready()
+{
+ int i=0;
+ char szStatus[10] = {0,};
+
+ for(i=MAX_CNT_RETRY; i>0; i--){
+ usleep(50*1000);
+ //TODO :: checking routine
+ if(readTrpState()==TRUE){
+ break;
+ }
+ }
+
+ return (i==0)? FALSE:TRUE;
+}
View
101 bluetooth/libbt-vendor/src/userial_vendor.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/******************************************************************************
+ *
+ * Filename: userial_vendor.c
+ *
+ * Description: Contains vendor-specific userial functions
+ *
+ ******************************************************************************/
+
+#define LOG_TAG "bt_userial_vendor"
+
+#include <utils/Log.h>
+#include <termios.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdio.h>
+#include "bt_vendor_qcom.h"
+#include "userial_vendor.h"
+
+int bt_hci_init_transport()
+{
+ struct termios term;
+ int fd = -1;
+ int retry = 0;
+
+ fd = open(BLUETOOTH_UART_DEVICE_PORT, (O_RDWR | O_NOCTTY));
+
+ while ((fd == -1) && (retry < 7)) {
+ ALOGE("init_transport: Cannot open %s: %s\n. Retry after 2 seconds",
+ BLUETOOTH_UART_DEVICE_PORT, strerror(errno));
+ usleep(2000000);
+ fd = open(BLUETOOTH_UART_DEVICE_PORT, (O_RDWR | O_NOCTTY));
+ retry++;
+ }
+
+ if (fd == -1)
+ {
+ ALOGE("init_transport: Cannot open %s: %s\n",
+ BLUETOOTH_UART_DEVICE_PORT, strerror(errno));
+ return -1;
+ }
+
+ /* Sleep (0.5sec) added giving time for the smd port to be successfully
+ opened internally. Currently successful return from open doesn't
+ ensure the smd port is successfully opened.
+ TODO: Following sleep to be removed once SMD port is successfully
+ opened immediately on return from the aforementioned open call */
+ usleep(500000);
+
+ if (tcflush(fd, TCIOFLUSH) < 0)
+ {
+ ALOGE("init_uart: Cannot flush %s\n", BLUETOOTH_UART_DEVICE_PORT);
+ close(fd);
+ return -1;
+ }
+
+ if (tcgetattr(fd, &term) < 0)
+ {
+ ALOGE("init_uart: Error while getting attributes\n");
+ close(fd);
+ return -1;
+ }
+
+ cfmakeraw(&term);
+
+ /* JN: Do I need to make flow control configurable, since 4020 cannot
+ * disable it?
+ */
+ term.c_cflag |= (CRTSCTS | CLOCAL);
+
+ if (tcsetattr(fd, TCSANOW, &term) < 0)
+ {
+ ALOGE("init_uart: Error while getting attributes\n");
+ close(fd);
+ return -1;
+ }
+
+ ALOGI("Done intiailizing UART\n");
+ return fd;
+}
+
+int bt_hci_deinit_transport(int pFd)
+{
+ close(pFd);
+ return TRUE;
+}
View
32 bluetooth/libbt-vendor/vnd_buildcfg.mk
@@ -0,0 +1,32 @@
+#
+# Copyright 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+intermediates := $(local-intermediates-dir)
+
+SRC := $(call my-dir)/include/$(addprefix vnd_, $(addsuffix .txt,$(basename $(TARGET_DEVICE))))
+ifeq (,$(wildcard $(SRC)))
+# configuration file does not exist. Use default one
+SRC := $(call my-dir)/include/vnd_generic.txt
+endif
+GEN := $(intermediates)/vnd_buildcfg.h
+TOOL := $(TOP_DIR)external/bluetooth/bluedroid/tools/gen-buildcfg.sh
+
+$(GEN): PRIVATE_PATH := $(call my-dir)
+$(GEN): PRIVATE_CUSTOM_TOOL = $(TOOL) $< $@
+$(GEN): $(SRC) $(TOOL)
+ $(transform-generated-source)
+
+LOCAL_GENERATED_SOURCES += $(GEN)
View
12 prebuilt/root/init.blade.rc
@@ -22,17 +22,17 @@ on boot
chown system system /sys/module/msm_battery/parameters/usb_chg_enable
# Setup bluetooth
- chown bluetooth net_bt_stack /sys/module/bluetooth_power/parameters/power
- chown bluetooth net_bt_stack /sys/class/rfkill/rfkill0/type
- chown bluetooth net_bt_stack /sys/class/rfkill/rfkill0/state
- chown bluetooth net_bt_stack /proc/bluetooth/sleep/proto
+ chown bluetooth bluetooth /sys/module/bluetooth_power/parameters/power
+ chown bluetooth bluetooth /sys/class/rfkill/rfkill0/type
+ chown bluetooth bluetooth /sys/class/rfkill/rfkill0/state
+ chown bluetooth bluetooth /proc/bluetooth/sleep/proto
chown system system /sys/module/sco/parameters/disable_esco
chmod 0660 /sys/module/bluetooth_power/parameters/power
chmod 0660 /sys/class/rfkill/rfkill0/state
chmod 0660 /proc/bluetooth/sleep/proto
- chown bluetooth net_bt_stack /dev/ttyHS0
+ chown bluetooth bluetooth /dev/ttyHS0
chmod 0666 /dev/ttyHS0
- chown bluetooth net_bt_stack /sys/devices/platform/msm_serial_hs.0/clock
+ chown bluetooth bluetooth /sys/devices/platform/msm_serial_hs.0/clock
chmod 0660 /sys/devices/platform/msm_serial_hs.0/clock
# Create WIFI filesystem structure
View
2  prebuilt/root/ueventd.blade.rc
@@ -20,5 +20,5 @@
/dev/msm_wmapro 0660 system audio
/dev/system_bus_freq 0666 system system
/dev/genlock 0666 root system
-/dev/ttyHS0 0660 bluetooth net_bt_stack
+/dev/ttyHS0 0660 bluetooth bluetooth
/dev/graphics/fb0 0666 graphics graphics
View
43 prebuilt/system/etc/init.bt.sh
@@ -30,8 +30,6 @@ BLUETOOTH_SLEEP_PATH=/proc/bluetooth/sleep/proto
LOG_TAG="qcom-bluetooth"
LOG_NAME="${0}:"
-hciattach_pid=""
-
loge ()
{
/system/bin/log -t $LOG_TAG -p e "$LOG_NAME $@"
@@ -49,44 +47,12 @@ failed ()
exit $2
}
-start_hciattach ()
-{
- echo 1 > $BLUETOOTH_SLEEP_PATH
- /system/bin/hciattach -n $QSOC_DEVICE $QSOC_TYPE $QSOC_BAUD &
- hciattach_pid=$!
- logi "start_hciattach: pid = $hciattach_pid"
-}
-
-kill_hciattach ()
-{
- logi "kill_hciattach: pid = $hciattach_pid"
- ## careful not to kill zero or null!
- kill -TERM $hciattach_pid
- echo 0 > $BLUETOOTH_SLEEP_PATH
- # this shell doesn't exit now -- wait returns for normal exit
-}
-
-# mimic hciattach options parsing -- maybe a waste of effort
-USAGE="hciattach [-n] [-p] [-b] [-t timeout] [-s initial_speed] <tty> <type | id> [speed] [flow|noflow] [bdaddr]"
-
-while getopts "blnpt:s:" f
-do
- case $f in
- b | l | n | p) opt_flags="$opt_flags -$f" ;;
- t) timeout=$OPTARG;;
- s) initial_speed=$OPTARG;;
- \?) echo $USAGE; exit 1;;
- esac
-done
-shift $(($OPTIND-1))
-
setprop bluetooth.status off
QSOC_DEVICE=${1:-"/dev/ttyHS0"}
-QSOC_TYPE=${2:-"any"}
QSOC_BAUD=${3:-"3000000"}
-echo 1 > $BLUETOOTH_SLEEP_PATH
+# echo 1 > $BLUETOOTH_SLEEP_PATH
/system/bin/hci_qcomm_init -d $QSOC_DEVICE -s $QSOC_BAUD
@@ -97,15 +63,8 @@ case $exit_code_hci_qcomm_init in
*) failed "Bluetooth QSoC firmware download failed" $exit_code_hci_qcomm_init;;
esac
-# init does SIGTERM on ctl.stop for service
-# trap "kill_hciattach" TERM INT
-
-# start_hciattach
-
setprop bluetooth.status on
-# wait $hciattach_pid
-
logi "start bluetooth transport"
exit 0
Please sign in to comment.
Something went wrong with that request. Please try again.