Tizen 2.1 base
authorJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:36:28 +0000 (01:36 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:36:28 +0000 (01:36 +0900)
25 files changed:
AUTHORS
CMakeLists.txt
LICENSE.APLv2 [new file with mode: 0644]
LICENSE.Broadcom [new file with mode: 0644]
NOTICE [new file with mode: 0644]
bluetooth-firmware-bcm.manifest [new file with mode: 0644]
debian/bluetooth-firmware-bcm.install [new file with mode: 0644]
debian/bluetooth-firmware-bcm.postinst.in [new file with mode: 0644]
debian/changelog
debian/control
debian/rules
firmware/BCM4330B1_002.001.003.0221.0265.hcd [new file with mode: 0644]
firmware/BCM4334B0_002.001.013.0079.0081.hcd [new file with mode: 0644]
firmware/CMakeLists.txt [new file with mode: 0755]
packaging/bluetooth-firmware-bcm-e4412.spec [new file with mode: 0644]
packaging/bluetooth-firmware-bcm.spec [new file with mode: 0644]
scripts/CMakeLists.txt
scripts/bt-dev-end.sh [new file with mode: 0755]
scripts/bt-dev-start-c210.sh [new file with mode: 0755]
scripts/bt-dev-start-e4412.sh [new file with mode: 0755]
scripts/bt-set-addr.sh [new file with mode: 0755]
set-address/CMakeLists.txt
set-address/setbd.c
tools/CMakeLists.txt [new file with mode: 0644]
tools/bcmtool_4330b1.c [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
index 71e3ece..46d1687 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,2 +1,2 @@
-HyeongBae Park <jupio.park@samsung.com>\r
-Ankur Gandhi <a.gandhi@samsung.com>\r
+Jinmin Jung <jinmin@samsung.com>
+DoHyun Pyun <dh79.pyun@samsung.com>
index defa1dd..c0285fa 100644 (file)
@@ -1,4 +1,15 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
+INCLUDE(FindPkgConfig)
+pkg_check_modules(package REQUIRED glib-2.0 vconf)
+
+FOREACH(flag ${package_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
 ADD_SUBDIRECTORY(set-address)
+ADD_SUBDIRECTORY(tools)
+ADD_SUBDIRECTORY(firmware)
 ADD_SUBDIRECTORY(scripts)
diff --git a/LICENSE.APLv2 b/LICENSE.APLv2
new file mode 100644 (file)
index 0000000..6b0b127
--- /dev/null
@@ -0,0 +1,203 @@
+
+                                 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
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.
+
diff --git a/LICENSE.Broadcom b/LICENSE.Broadcom
new file mode 100644 (file)
index 0000000..b39ee62
--- /dev/null
@@ -0,0 +1,66 @@
+SOFTWARE LICENSE AGREEMENT\r
+\r
+The accompanying software in binary code form ("Software"), is licensed to you,\r
+or, if you are accepting on behalf of an entity, the entity and its affiliates\r
+exercising rights hereunder ("Licensee") subject to the terms of this software\r
+license agreement ("Agreement"), unless Licensee and Broadcom Corporation\r
+("Broadcom") execute a separate written software license agreement governing\r
+use of the Software. ANY USE, REPRODUCTION, OR DISTRIBUTION OF THE SOFTWARE\r
+CONSTITUTES LICENSEE'S ACCEPTANCE OF THIS AGREEMENT.\r
+\r
+1.     License. Subject to the terms and conditions of this Agreement,\r
+Broadcom hereby grants to Licensee a limited, non-exclusive, non-transferable,\r
+royalty-free license: (i) to use and integrate the Software with any other\r
+software; and (ii) to reproduce and distribute the Software complete,\r
+unmodified, and as provided by Broadcom, solely for use with Broadcom\r
+proprietary integrated circuit product(s) sold by Broadcom with which the\r
+Software was designed to be used, or their successors.\r
+\r
+2.     Restrictions. Licensee shall distribute Software with a copy of this\r
+Agreement. Licensee shall not remove, efface or obscure any copyright or\r
+trademark notices from the Software. Reproductions of the Broadcom copyright\r
+notice shall be included with each copy of the Software, except where such\r
+Software is embedded in a manner not readily accessible to the end user.\r
+Licensee shall not: (i) use, license, sell or otherwise distribute the Software\r
+except as provided in this Agreement; (ii) attempt to modify in any way,\r
+reverse engineer, decompile or disassemble any portion of the Software; or\r
+(iii) use the Software or other material in violation of any applicable law or\r
+regulation, including but not limited to any regulatory agency. This Agreement\r
+shall automatically terminate upon Licensee’s failure to comply with any of the\r
+terms of this Agreement. In such event, Licensee will destroy all copies of the\r
+Software and its component parts.\r
+\r
+3.     Ownership. The Software is licensed and not sold.  Title to and\r
+ownership of the Software, including all intellectual property rights thereto,\r
+and any portion thereof remain with Broadcom or its licensors. Licensee hereby\r
+covenants that it will not assert any claim that the Software created by or for\r
+Broadcom infringe any intellectual property right owned or controlled by\r
+Licensee.\r
+\r
+4.     Disclaimer. THE SOFTWARE IS OFFERED "AS IS," AND BROADCOM PROVIDES AND\r
+GRANTS AND LICENSEE RECEIVES NO SUPPORT AND NO WARRANTIES OF ANY KIND, EXPRESS\r
+OR IMPLIED, BY STATUTE, COMMUNICATION OR CONDUCT WITH LICENSEE, OR OTHERWISE.\r
+BROADCOM SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY,\r
+FITNESS FOR A SPECIFIC PURPOSE, OR NONINFRINGEMENT CONCERNING THE SOFTWARE OR\r
+ANY UPGRADES TO OR DOCUMENTATION FOR THE SOFTWARE. WITHOUT LIMITATION OF THE\r
+ABOVE, BROADCOM GRANTS NO WARRANTY THAT THE SOFTWARE IS ERROR-FREE OR WILL\r
+OPERATE WITHOUT INTERRUPTION, AND GRANTS NO WARRANTY REGARDING ITS USE OR THE\r
+RESULTS THEREFROM INCLUDING, WITHOUT LIMITATION, ITS CORRECTNESS, ACCURACY, OR\r
+RELIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM\r
+OR ANY OF ITS LICENSORS HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,\r
+INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED AND ON ANY THEORY\r
+OF LIABILITY, WHETHER FOR BREACH OF CONTRACT, TORT (INCLUDING NEGLIGENCE) OR\r
+OTHERWISE, ARISING OUT OF THIS AGREEMENT OR USE, REPRODUCTION, OR DISTRIBUTION\r
+OF THE SOFTWARE, INCLUDING BUT NOT LIMITED TO LOSS OF DATA AND LOSS OF PROFITS,\r
+EVEN IF SUCH PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THESE\r
+LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF ANY\r
+LIMITED REMEDY.\r
+\r
+5.     Export Laws.  LICENSEE UNDERSTANDS AND AGREES THAT THE SOFTWARE IS\r
+SUBJECT TO UNITED STATES AND OTHER APPLICABLE EXPORT-RELATED LAWS AND\r
+REGULATIONS AND THAT LICENSEE MAY NOT EXPORT, RE-EXPORT OR TRANSFER THE\r
+SOFTWARE OR ANY DIRECT PRODUCT OF THE SOFTWARE EXCEPT AS PERMITTED UNDER THOSE\r
+LAWS. WITHOUT LIMITING THE FOREGOING, EXPORT, RE-EXPORT, OR TRANSFER OF THE\r
+SOFTWARE TO CUBA, IRAN, NORTH KOREA, SUDAN, AND SYRIA IS PROHIBITED.\r
+\r
+\r
diff --git a/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..411d0c9
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,10 @@
+Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE.APLv2 file for Apache License terms and conditions.
+
+The following files are copyrighted by Broadcom and licensed under
+a separate license. Please, see the LICENSE.Broadcom file for
+license terms and conditions.
+
+Copyright (c) 2012 Broadcom Co., Ltd. All rights reserved.
+- firmware/*.hcd
diff --git a/bluetooth-firmware-bcm.manifest b/bluetooth-firmware-bcm.manifest
new file mode 100644 (file)
index 0000000..a3dc534
--- /dev/null
@@ -0,0 +1,8 @@
+<manifest>
+    <define>
+        <domain name="bt_firmware"/>
+    </define>
+    <request>
+        <domain name="bt_firmware"/>
+    </request>
+</manifest>
diff --git a/debian/bluetooth-firmware-bcm.install b/debian/bluetooth-firmware-bcm.install
new file mode 100644 (file)
index 0000000..a99d1b4
--- /dev/null
@@ -0,0 +1,2 @@
+usr/bin/*
+usr/etc/bluetooth/BCM4330B1_002.001.003.0221.0265.hcd
diff --git a/debian/bluetooth-firmware-bcm.postinst.in b/debian/bluetooth-firmware-bcm.postinst.in
new file mode 100644 (file)
index 0000000..cb03b3c
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# Change File Permission
+chmod 644 @PREFIX@/etc/bluetooth/BCM4330B1_002.001.003.0221.0265.hcd
+
+# root case
+if [ ${USER} = "root" ]
+then
+       chown root:root @PREFIX@/etc/bluetooth/BCM4330B1_002.001.003.0221.0265.hcd
+fi
index 7f8f38e..bb496ac 100755 (executable)
@@ -1,3 +1,33 @@
+bluetooth-firmware-bcm (0.2.28) precise; urgency=low
+
+  * Synchronize the code with Private git
+
+ -- Jaekyun Lee <jkyun.ee@samsung.com>  Fri, 07 Dec 2012 14:53:59 +0900
+
+bluetooth-firmware-bcm (0.1.4) unstable; urgency=low
+
+  * Add e4412 firmware
+
+ -- Jaekyun Lee <jkyun.lee@samsung.com>  Wed, 17 Oct 2012 11:50:43 +0900
+
+bluetooth-firmware-bcm (0.1.3) unstable; urgency=low
+
+  * rename bt-firmware-43xx to bluetooth-firmware-bcm
+
+ -- Jaekyun Lee <jkyun.lee@samsung.com>  Sat, 11 Aug 2012 14:26:05 +0900
+
+bt-firmware-43xx (0.1.2) unstable; urgency=low
+
+  * Fix set bd bug as TAPI IMEI API deprecated
+
+ -- Jaekyun Lee <jkyun.lee@samsung.com>  Mon, 26 Mar 2012 15:13:31 +0900
+
+bt-firmware-43xx (0.1.1) unstable; urgency=low
+
+  * common script moved to bluetooth-tools
+
+ -- Jaekyun Lee <jkyun.lee@samsung.com>  Fri, 23 Mar 2012 11:29:47 +0900
+
 bt-firmware-43xx (0.1.0) unstable; urgency=low
 
   * Initail Release
index 32b94e0..91d830a 100644 (file)
@@ -1,21 +1,25 @@
-Source: bt-firmware-43xx
+Source: bluetooth-firmware-bcm
 Section: devel
 Priority: optional
-Maintainer: DoHyun Pyun <dh79.pyun@samsung.com>, ChanYeol Park <chanyeol.park@samsung.com>, Girish A J <girish.joshi@samsung.com>, InJun Yang <injun.yang@samsung.com>
+Maintainer: DoHyun Pyun <dh79.pyun@samsung.com>, ChanYeol Park <chanyeol.park@samsung.com>, Girish A J <girish.joshi@samsung.com>, InJun Yang <injun.yang@samsung.com>, Jaekyun Lee <jkyun.lee@samsung.com>
 Uploaders: Sunil Behera <sunil.behera@samsung.com>, Syam Sidhardhan <s.syam@samsung.com>
-Build-Depends: debhelper (>= 5), libglib2.0-dev, libdbus-glib-1-dev, libvconf-dev
+Build-Depends: debhelper (>= 5), libglib2.0-dev, libvconf-dev
 Standards-Version: 3.7.2
 Homepage: N/A
 
-Package: bt-firmware-43xx
+Package: bluetooth-firmware-bcm
 Architecture: any
 Section: utils
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: Tools and scripts for Bluetooth stack
+Depends: ${shlibs:Depends}, ${misc:Depends}, bluetooth-tools
+Description: firmware and tools
+ firmware and tools
 
-Package: bt-firmware-43xx-dbg
+Package: bluetooth-firmware-bcm-dbg
 Section: debug
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, bt-firmware-43xx (= ${Source-Version})
-Description: Tools and scripts for Bluetooth stack (unstripped)
+Depends: ${shlibs:Depends}, ${misc:Depends}, bluetooth-firmware-bcm (= ${Source-Version})
+Description: Tools for bluetooth-firmware-bcm (unstripped)
  The package contains detached debugging symbols for the binary packages
+ produced by the bt-firmware-43xx soruce.
+
+
index bc4025a..531d1a1 100755 (executable)
@@ -4,11 +4,13 @@
 #export DH_VERBOSE=1
 
 CFLAGS ?= -Wall -g
-LDFLAGS ?= 
+LDFLAGS ?=
 PREFIX ?= /usr
 DATADIR ?= /opt
 PLUGIN_PREFIX ?= /usr
 
+CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp
+
 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
        CFLAGS += -O0
 else
@@ -21,18 +23,20 @@ configure: configure-stamp
 configure-stamp:
        dh_testdir
        # Add here commands to configure the package.
+       mkdir -p $(CMAKE_BUILD_DIR) && \
+       cd $(CMAKE_BUILD_DIR) && \
        CFLAGS="$(CFLAGS) -fpie" LDFLAGS="$(LDFLAGS) -pie" \
-              cmake . -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DPLUGIN_INSTALL_PREFIX=$(PLUGIN_PREFIX)
+       cmake .. -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DPLUGIN_INSTALL_PREFIX=$(PLUGIN_PREFIX)
 
        touch configure-stamp
 
 build: build-stamp
 
-build-stamp: configure-stamp 
+build-stamp: configure-stamp
        dh_testdir
 
        # Add here commands to compile the package.
-       $(MAKE)
+       cd $(CMAKE_BUILD_DIR) && $(MAKE)
 
        for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
                cat $$f > $${f%.in}; \
@@ -49,51 +53,25 @@ clean:
        rm -f build-stamp configure-stamp
 
        # Add here commands to clean up after the build process.
-       -$(MAKE) clean
-
-
-       for f in `find $(CURDIR)/ -name "CMakeCache.txt"`; do \
-               rm -f $${f}; \
-       done
-       for f in `find $(CURDIR)/ -name "CMakeFiles"`; do \
-               rm -rf $${f}; \
-       done
-       for f in `find $(CURDIR)/ -name "cmake_install.cmake"`; do \
-               rm -f $${f}; \
-       done
-       for f in `find $(CURDIR)/ -name "Makefile"`; do \
-               rm -f $${f}; \
-       done
-       for f in `find $(CURDIR)/ -name "install_manifest.txt"`; do \
-               rm -f $${f}; \
-       done
-
+       -rm -rf $(CMAKE_BUILD_DIR)
        for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
                rm -f $${f%.in}; \
        done
 
-       rm -f scripts/BCM_FIRMWARE*.hcd
-       rm -f scripts/bt-dev-end.sh
-       rm -f scripts/bt-dev-start.sh
-       rm -f scripts/bt-set-addr.sh
-
-       dh_clean 
+       dh_clean
 
 install: build
        dh_testdir
        dh_testroot
-       dh_clean -k 
+       dh_clean -k
        dh_installdirs
 
        # Add here commands to install the package into debian/wavplayer.
-       $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+       cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+
 
        # Booting script
-       $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
-       mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc3.d
-       mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc5.d
-       ln -s ../init.d/bluetooth-address $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/S60bluetooth-address
-       ln -s ../init.d/bluetooth-address $(CURDIR)/debian/tmp/etc/rc.d/rc5.d/S60bluetooth-address
 
 # Build architecture-independent files here.
 binary-indep: build install
@@ -103,12 +81,12 @@ binary-indep: build install
 binary-arch: build install
        dh_testdir
        dh_testroot
-       dh_installchangelogs 
+       dh_installchangelogs
        dh_installdocs
        dh_installexamples
        dh_install --sourcedir=debian/tmp
 #      dh_installmenu
-#      dh_installdebconf       
+#      dh_installdebconf
 #      dh_installlogrotate
 #      dh_installemacsen
 #      dh_installpam
@@ -119,7 +97,7 @@ binary-arch: build install
 #      dh_installinfo
        dh_installman
        dh_link
-       dh_strip --dbg-package=bt-firmware-43xx-dbg
+       dh_strip --dbg-package=bluetooth-firmware-bcm-dbg
        dh_compress
        dh_fixperms
 #      dh_perl
diff --git a/firmware/BCM4330B1_002.001.003.0221.0265.hcd b/firmware/BCM4330B1_002.001.003.0221.0265.hcd
new file mode 100644 (file)
index 0000000..a8c7f30
Binary files /dev/null and b/firmware/BCM4330B1_002.001.003.0221.0265.hcd differ
diff --git a/firmware/BCM4334B0_002.001.013.0079.0081.hcd b/firmware/BCM4334B0_002.001.013.0079.0081.hcd
new file mode 100644 (file)
index 0000000..ff13214
Binary files /dev/null and b/firmware/BCM4334B0_002.001.013.0079.0081.hcd differ
diff --git a/firmware/CMakeLists.txt b/firmware/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..750e004
--- /dev/null
@@ -0,0 +1,3 @@
+# install firmware
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/BCM4330B1_002.001.003.0221.0265.hcd DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/BCM4334B0_002.001.013.0079.0081.hcd DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
diff --git a/packaging/bluetooth-firmware-bcm-e4412.spec b/packaging/bluetooth-firmware-bcm-e4412.spec
new file mode 100644 (file)
index 0000000..345d4cf
--- /dev/null
@@ -0,0 +1,40 @@
+Name:       bluetooth-firmware-bcm-e4412
+Summary:    firmware and tools for bluetooth
+Version:    0.2.28
+Release:    1
+Group:      TO_BE_FILLED
+License:    TO_BE_FILLED
+Source0:    bluetooth-firmware-bcm-%{version}.tar.gz
+
+BuildRequires:  pkgconfig(vconf)
+BuildRequires:  cmake
+
+%description
+firmware and tools for bluetooth
+
+
+%prep
+%setup -q -n bluetooth-firmware-bcm-%{version}
+
+%build
+cmake ./ -DCMAKE_INSTALL_PREFIX=%{_prefix} -DPLUGIN_INSTALL_PREFIX=%{_prefix}
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+cp -rf %{buildroot}%{_prefix}/etc/bluetooth/bt-dev-start-e4412.sh  %{buildroot}%{_prefix}/etc/bluetooth/bt-dev-start.sh
+
+%files
+%manifest bluetooth-firmware-bcm.manifest
+%defattr(-,root,root,-)
+%{_bindir}/bcmtool_4330b1
+%{_bindir}/setbd
+%{_prefix}/etc/bluetooth/BCM4334B0_002.001.013.0079.0081.hcd
+%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-dev-end.sh
+%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-dev-start.sh
+%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-set-addr.sh
+%exclude %{_prefix}/etc/bluetooth/BCM4330B1_002.001.003.0221.0265.hcd
+%exclude %{_prefix}/etc/bluetooth/bt-dev-start-c210.sh
+%exclude %{_prefix}/etc/bluetooth/bt-dev-start-e4412.sh
diff --git a/packaging/bluetooth-firmware-bcm.spec b/packaging/bluetooth-firmware-bcm.spec
new file mode 100644 (file)
index 0000000..792051b
--- /dev/null
@@ -0,0 +1,42 @@
+Name:       bluetooth-firmware-bcm
+Summary:    firmware and tools for bluetooth
+Version:    0.2.28
+Release:    1
+Group:      Hardware Support/Handset
+License:    Apache
+# NOTE: Source name does not match package name.  This should be
+# resolved in the future, by I don't have that power. - Ryan Ware
+Source0:    %{name}-%{version}.tar.gz
+
+BuildRequires:  pkgconfig(vconf)
+BuildRequires:  cmake
+
+%description
+ firmware and tools for bluetooth
+
+
+%prep
+%setup -q
+
+%build
+cmake ./ -DCMAKE_INSTALL_PREFIX=%{_prefix} -DPLUGIN_INSTALL_PREFIX=%{_prefix}
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+cp -rf %{buildroot}%{_prefix}/etc/bluetooth/bt-dev-start-c210.sh  %{buildroot}%{_prefix}/etc/bluetooth/bt-dev-start.sh
+
+%files
+%manifest bluetooth-firmware-bcm.manifest
+%defattr(-,root,root,-)
+%{_bindir}/bcmtool_4330b1
+%{_bindir}/setbd
+%{_prefix}/etc/bluetooth/BCM4330B1_002.001.003.0221.0265.hcd
+%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-dev-end.sh
+%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-dev-start.sh
+%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-set-addr.sh
+%exclude %{_prefix}/etc/bluetooth/BCM4334B0_002.001.013.0079.0081.hcd
+%exclude %{_prefix}/etc/bluetooth/bt-dev-start-c210.sh
+%exclude %{_prefix}/etc/bluetooth/bt-dev-start-e4412.sh
index e12875e..c432239 100755 (executable)
@@ -1,48 +1,5 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(bcmtool C)
-
-SET(SRCS_4330B1 broadcom/bcmtool_4330b1.c)
-
-SET(BCMTOOL_4330B1 ${PROJECT_NAME}_4330b1)
-
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(package REQUIRED glib-2.0 dbus-glib-1)
-
-FOREACH(flag ${package_CFLAGS})
-       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-
-FIND_PROGRAM(UNAME NAMES uname)
-EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
-IF("${ARCH}" STREQUAL "arm")
-       ADD_DEFINITIONS("-DTARGET")
-       MESSAGE("add -DTARGET")
-ENDIF("${ARCH}" STREQUAL "arm")
-
-ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
-ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
-
-ADD_EXECUTABLE(${BCMTOOL_4330B1} ${SRCS_4330B1})
-
-TARGET_LINK_LIBRARIES(${BCMTOOL_4330B1} ${package_LDFLAGS})
-
 # install firmware
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/broadcom/BCM4330B1_002.001.003.0221.0265.hcd DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
-
-# install binary file
-INSTALL(TARGETS ${BCMTOOL_4330B1} DESTINATION ${PLUGIN_INSTALL_PREFIX}/bin)
-
-# install script files
-INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/broadcom/bt-dev-start.sh.broadcom DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
-INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/broadcom/bt-dev-end.sh.broadcom DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
-INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/broadcom/bt-set-addr.sh.broadcom DESTINATION etc/bluetooth)
-INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bt-stack-up.sh DESTINATION etc/bluetooth)
-INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bt-stack-down.sh DESTINATION etc/bluetooth)
-INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bt-reset-env.sh DESTINATION etc/bluetooth)
-
-# install booting script
-INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-address DESTINATION /etc/rc.d/init.d)
+INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bt-dev-end.sh DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
+INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bt-dev-start-c210.sh DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
+INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bt-dev-start-e4412.sh DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
+INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bt-set-addr.sh DESTINATION ${PLUGIN_INSTALL_PREFIX}/etc/bluetooth)
diff --git a/scripts/bt-dev-end.sh b/scripts/bt-dev-end.sh
new file mode 100755 (executable)
index 0000000..ef4731e
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+#
+# Script for stopping Broadcom UART Bluetooth stack
+#
+
+# Device down
+/usr/sbin/hciconfig hci0 down
+
+# OMAP4
+REVISION_NUM=`grep Revision /proc/cpuinfo | awk "{print \\$3}"`
+if [ $REVISION_NUM == "0006" ]; then
+       rmmod bt_drv.ko
+       rmmod st_drv.ko
+       sleep 1
+       killall uim_rfkill
+       exit 0
+fi
+
+killall hciattach
+
+# Turn off Bluetooth Chip
+rfkill block bluetooth
+
+#if [ -e /sys/class/gpio/gpio17/value ]
+#then
+#      # Reset BT chip
+#      echo 0 > /sys/class/gpio/gpio17/value
+#      sleep 0.1
+#      echo 1 > /sys/class/gpio/gpio17/value
+#fi
+
diff --git a/scripts/bt-dev-start-c210.sh b/scripts/bt-dev-start-c210.sh
new file mode 100755 (executable)
index 0000000..d87f35d
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+# Script for registering Broadcom UART BT device
+BT_UART_DEVICE=/dev/ttySAC0
+BT_CHIP_TYPE=bcm2035
+BCM_TOOL=/usr/bin/bcmtool_4330b1
+
+BT_PLATFORM_DEFAULT_HCI_NAME="TIZEN-Mobile"
+UART_SPEED=3000000
+
+#set default firmware
+BCM_FIRMWARE=BCM4330B1_002.001.003.0221.0265.hcd
+
+REVISION_NUM=`grep Revision /proc/cpuinfo | awk "{print \\$3}"`
+REVISION_HIGH=`echo $REVISION_NUM| cut -c1-2`
+REVISION_LOW=`echo $REVISION_NUM| cut -c3-`
+
+HARDWARE=`grep Hardware /proc/cpuinfo | awk "{print \\$3}"`
+
+if [ ! -e "$BT_UART_DEVICE" ]
+then
+       mknod $BT_UART_DEVICE c 204 64
+fi
+
+if [ ! -e /opt/etc/.bd_addr ]
+then
+       # Set BT address
+       /usr/bin/setbd
+fi
+
+# Trun-on Bluetooth Chip
+rfkill unblock bluetooth
+
+echo "Check for Bluetooth device status"
+if (/usr/sbin/hciconfig | grep hci); then
+       echo "Bluetooth device is UP"
+       /usr/sbin/hciconfig hci0 up
+else
+       echo "Bluetooth device is DOWN"
+       echo "Registering Bluetooth device"
+
+       $BCM_TOOL $BT_UART_DEVICE -FILE=/usr/etc/bluetooth/$BCM_FIRMWARE -BAUD=$UART_SPEED -ADDR=/opt/etc/.bd_addr -SETSCO=0,0,0,0,0,0,0,3,3,0 -LP > /dev/null 2>&1
+
+       # Attaching Broadcom device
+       if (/usr/sbin/hciattach $BT_UART_DEVICE -s $UART_SPEED $BT_CHIP_TYPE $UART_SPEED flow); then
+               sleep 0.1
+               /usr/sbin/hciconfig hci0 up
+               /usr/sbin/hciconfig hci0 name $BT_PLATFORM_DEFAULT_HCI_NAME
+               /usr/sbin/hciconfig hci0 sspmode 1
+               echo "HCIATTACH success"
+       else
+               echo "HCIATTACH failed"
+               rfkill block bluetooth
+       fi
+fi
diff --git a/scripts/bt-dev-start-e4412.sh b/scripts/bt-dev-start-e4412.sh
new file mode 100755 (executable)
index 0000000..96023e5
--- /dev/null
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+# Script for registering Broadcom UART BT device
+BT_UART_DEVICE=/dev/ttySAC0
+BT_CHIP_TYPE=bcm2035
+BCM_TOOL=/usr/bin/bcmtool_4330b1
+
+BT_PLATFORM_DEFAULT_HCI_NAME="TIZEN-Mobile"
+UART_SPEED=3000000
+
+# defult firmware
+# SEMCO external LNA, I2S slave
+BCM_FIRMWARE=BCM4334B0_002.001.013.0079.0081.hcd
+
+REVISION_NUM=`grep Revision /proc/cpuinfo | awk "{print \\$3}"`
+REVISION_HIGH=`echo $REVISION_NUM| cut -c1-2`
+REVISION_LOW=`echo $REVISION_NUM| cut -c3-`
+
+#HARDWARE=`grep Hardware /proc/cpuinfo | awk "{print \\$3}"`
+
+echo $BCM_FIRMWARE
+
+if [ ! -e "$BT_UART_DEVICE" ]
+then
+       mknod $BT_UART_DEVICE c 204 64
+fi
+
+if [ ! -e /opt/etc/.bd_addr ]
+then
+       # Set BT address
+       /usr/bin/setbd
+fi
+
+rfkill unblock bluetooth
+
+echo "Check for Bluetooth device status"
+if (/usr/sbin/hciconfig | grep hci); then
+       echo "Bluetooth device is UP"
+       /usr/sbin/hciconfig hci0 up
+else
+       echo "Bluetooth device is DOWN"
+       echo "Registering Bluetooth device"
+
+       $BCM_TOOL $BT_UART_DEVICE -FILE=/usr/etc/bluetooth/$BCM_FIRMWARE -BAUD=$UART_SPEED -ADDR=/opt/etc/.bd_addr -SETSCO=0,0,0,0,0,0,0,3,3,0 -LP > /dev/null 2>&1
+
+       # Attaching Broadcom device
+       if (/usr/sbin/hciattach $BT_UART_DEVICE -s $UART_SPEED $BT_CHIP_TYPE $UART_SPEED flow); then
+               sleep 0.1
+               /usr/sbin/hciconfig hci0 up
+               /usr/sbin/hciconfig hci0 name $BT_PLATFORM_DEFAULT_HCI_NAME
+               /usr/sbin/hciconfig hci0 sspmode 1
+               echo "HCIATTACH success"
+       else
+               echo "HCIATTACH failed"
+               rfkill block bluetooth
+       fi
+fi
+
+#/usr/sbin/hciconfig hci0 down
+
diff --git a/scripts/bt-set-addr.sh b/scripts/bt-set-addr.sh
new file mode 100755 (executable)
index 0000000..57b2d02
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+#
+# Script for setting Bluetooth Address
+#
+
+if [ -e /opt/etc/.bd_addr ]
+then
+       echo "Already .bd_addr exists"
+       exit 0
+fi
+
+/usr/bin/setbd
+
+echo "Set BT address successes"
+
index da25e14..2ff386b 100644 (file)
@@ -5,15 +5,6 @@ SET(SRCS setbd.c)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
-INCLUDE(FindPkgConfig)
-pkg_check_modules(package REQUIRED glib-2.0 dbus-glib-1 vconf)
-
-FOREACH(flag ${package_CFLAGS})
-       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-
 FIND_PROGRAM(UNAME NAMES uname)
 EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
 IF("${ARCH}" STREQUAL "arm")
@@ -23,6 +14,7 @@ ENDIF("${ARCH}" STREQUAL "arm")
 
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
+ADD_DEFINITIONS("-D__BROADCOM_PATCH__")
 ADD_DEFINITIONS("-DDEBUG_EN")
 
 ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
index 7c4919c..ffc1f9f 100644 (file)
@@ -1,11 +1,7 @@
 /*
- *  bluetooth-dev-tool
+ * setbd.c
  *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved
- *
- * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
- *           GirishAshok Joshi <girish.joshi@samsung.com>
- *           DoHyun Pyun <dh79.pyun@samsung.com>
+ * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <vconf.h>
 #include <glib.h>
 
+#ifdef __TI_PATCH__
+#define BT_CHIP_TI
+#else
+#ifdef __BROADCOM_PATCH__
+#define BT_CHIP_BROADCOM
+#else
+#define BT_CHIP_CSR
+#endif
+#endif
+
 #ifdef DEBUG_EN
 #define APP_DBG(format, args...)       printf("%s(), line[%d]: " format, __FUNCTION__, __LINE__, ##args)
 #define APP_DEBUG(format, args...)     printf(format, ##args)
@@ -56,6 +62,7 @@ static GMainLoop * loop;
 const char *DEFAULT_IMEI="004999010640000";
 static gboolean is_default_imei=FALSE;
 
+#if defined(BT_CHIP_CSR) || defined(BT_CHIP_BROADCOM)
 int addremoveBD(char* path, char* pskey){
        FILE *fd, *new;
        int ret;
@@ -96,7 +103,7 @@ int addremoveBD(char* path, char* pskey){
 
                ret = fputs(cmp,new);
        }
-       
+
        return 0;
 }
 void makeRandomBD(unsigned char* buf){
@@ -123,7 +130,68 @@ void makeRandomBD(unsigned char* buf){
        }
        APP_DEBUG("\r\n");
 }
+#endif
+
+#ifdef BT_CHIP_TI
+int readBDaddrTI(void){
+       int i, cnt_lap=0, cnt_uap=0, cnt_nap=0;
+       int dev_id, fd, filedesc;
+       BD_ADDR_T bdaddr;
+       char address[18];
+       char nap[4], uap[2], lap[6];
+       int ret = 0;
+       dev_id=hci_get_route(NULL);
+       if(dev_id<0){
+               APP_DBG("Bluetooth device not available!!!\r\n");
+               return -1;
+       }
+       fd=hci_open_dev(dev_id);
+       if(fd<0){
+               APP_DBG("HCI open fail!!!\r\n");
+               return -2;
+       }
+
+       if(0>hci_read_bd_addr(fd, &bdaddr, 1000)){
+               APP_DBG("Read BD ADDR failed!!!\r\n");
+               return -3;
+       }
+       hci_close_dev(fd);
+
+       ba2str(&bdaddr, address);
+       for(i=0;i<17;i++){
+               if(':' == address[i])
+                       continue;
+
+               if(5>i)
+                       nap[cnt_nap++] = address[i];
+               else if(8>i)
+                       uap[cnt_uap++] = address[i];
+               else
+                       lap[cnt_lap++] = address[i];
+       }
+
+       APP_DBG("BT address [%s], nap[%c%c%c%c], uap[%c%c], lap[%c%c%c%c%c%c]\r\n",\
+        address, nap[0], nap[1], nap[2], nap[3]\
+       , uap[0],uap[1]\
+       ,lap[0], lap[1],lap[2],lap[3],lap[4],lap[5]);
+
+
+       filedesc=open(BD_ADDR_FILE, O_RDWR | O_CREAT | O_TRUNC | O_SYNC, 0644);
+       if(0>filedesc){
+               APP_DBG("File creation fail!!!\r\n");
+               return -4;
+       }
+       ret = write(filedesc, nap, 4);
+       ret = write(filedesc, "\n", 1);
+       ret = write(filedesc, uap, 2);
+       ret = write(filedesc, "\n", 1);
+       ret = write(filedesc, lap, 6);
+       ret = write(filedesc, "\n", 1);
+       close(filedesc);
 
+       return 0;
+}
+#endif
 int make_bt_address_from_tapi_imei(unsigned char * bt_address)
 {
        char * temp=NULL;
@@ -139,11 +207,18 @@ int make_bt_address_from_tapi_imei(unsigned char * bt_address)
                temp=vconf_get_str(VCONFKEY_TELEPHONY_IMEI);
                APP_DEBUG("TAPI_IMEI: %s\n",temp);
 
+#ifdef IMEI_BASED_RAND_FEATURE
                if(strcmp(temp,DEFAULT_IMEI)==0){
                        APP_DEBUG("TAPI_IMEI is defulat IMEI\n");
                        is_default_imei=TRUE;
                        return -ENODATA;
                }
+#else
+               APP_DEBUG("Temporarily we skip reading TAPI_IMEI\n");
+               APP_DEBUG("  due to TAPI IMEI API is deprecated\n");
+               is_default_imei=TRUE;
+               return -ENODATA;
+#endif
 
                if(strcmp(temp,"")==0)
                        return -ENODATA;
@@ -179,6 +254,8 @@ int make_bt_address_from_tapi_imei(unsigned char * bt_address)
 
 int make_bt_address(gboolean overwrite_bt_address)
 {
+#if defined(BT_CHIP_CSR) || defined(BT_CHIP_BROADCOM)
+
        int fd;
        int i;
        unsigned char txt[BD_ADDR_LEN];
@@ -217,13 +294,60 @@ int make_bt_address(gboolean overwrite_bt_address)
                APP_DEBUG("%s is already existed\n",BD_ADDR_FILE);
                success_make_bt_address_from_imei=0;
        }
-               
+
        ret = read(fd, nap, 5);
        ret = read(fd, uap, 3);
        ret = read(fd, lap, 7);
        close(fd);
 
+#if defined(BT_CHIP_CSR)
+       APP_DEBUG("nap[");
+       for(i=0;i<4;i++)
+               APP_DEBUG("%c",nap[i]);
+       APP_DEBUG("]\r\n");
+
+       APP_DEBUG("uap[");
+       for(i=0;i<2;i++)
+               APP_DEBUG("%c",uap[i]);
+       APP_DEBUG("]\r\n");
+
+       APP_DEBUG("lap[");
+       for(i=0;i<6;i++)
+               APP_DEBUG("%c",lap[i]);
+       APP_DEBUG("]\r\n");
+
+       sprintf(pskey, "&0001 = 0012 %c%c%c%c %c%c%c%c %c%c%c%c\r\n",\
+        lap[0], lap[1], lap[2], lap[3], lap[4], lap[5],\
+        uap[0], uap[1],\
+        nap[0], nap[1], nap[2], nap[3]);
+
+       APP_DEBUG("BD PSKEY [");
+       for(i=0;i<PSKEY_LEN;i++)
+               APP_DEBUG("%c", pskey[i]);
+       APP_DEBUG("]\r\n");
+
+       ret = addremoveBD(PSR_FILE, pskey);
+#endif
        return ret;
+#elif defined(BT_CHIP_TI)
+       int fd;
+       int ret;
+
+       fd=open(BD_ADDR_FILE, O_RDONLY, 0644);
+       if(0>fd){
+               APP_DBG("File not exists\r\n");
+               ret=readBDaddrTI();
+       }else{
+               APP_DBG("File exists\r\n");
+               close(fd);
+               ret=0;
+       }
+
+       return ret;
+#else
+       printf("error BT CHIP not defined!!!\n");
+       return 0;
+#endif
 }
 
 void vconf_cb(keynode_t *key, void * data)
@@ -272,12 +396,14 @@ int main()
        if(success_make_bt_address_from_imei==0 || is_default_imei==TRUE)
                exit(0);
 
+#ifdef IMEI_BASED_RAND_FEATURE
        vconf_notify_key_changed(VCONFKEY_TELEPHONY_IMEI,vconf_cb,NULL);
 
        g_timeout_add_seconds(10,exit_cb,NULL);
        g_main_loop_run(loop);
 
        vconf_ignore_key_changed(VCONFKEY_TELEPHONY_IMEI,vconf_cb);
+#endif
 
        return 0;
 }
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
new file mode 100644 (file)
index 0000000..85e215b
--- /dev/null
@@ -0,0 +1,25 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(bcmtool C)
+
+SET(SRCS_4330B1 bcmtool_4330b1.c)
+
+SET(BCMTOOL_4330B1 ${PROJECT_NAME}_4330b1)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+       ADD_DEFINITIONS("-DTARGET")
+       MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
+
+ADD_EXECUTABLE(${BCMTOOL_4330B1} ${SRCS_4330B1})
+
+TARGET_LINK_LIBRARIES(${BCMTOOL_4330B1} ${package_LDFLAGS})
+
+# install binary file
+INSTALL(TARGETS ${BCMTOOL_4330B1} DESTINATION ${PLUGIN_INSTALL_PREFIX}/bin)
diff --git a/tools/bcmtool_4330b1.c b/tools/bcmtool_4330b1.c
new file mode 100644 (file)
index 0000000..886650d
--- /dev/null
@@ -0,0 +1,877 @@
+/*
+ * Name: bcmtool_4330b1.c
+ *
+ * Description: Download a patchram files for the HCD format
+ *
+ * Copyright (c) 2012-2013, Broadcom Corp., All Rights Reserved.
+ *
+ * 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.
+ *
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <time.h>
+#include <string.h>
+#include <signal.h>
+#include <unistd.h>
+#include <sys/termios.h>
+#include <sys/ioctl.h>
+#include <limits.h>
+
+#define N_HCI  15
+#define HCI_UART_H4            0
+#define HCI_UART_BCSP  1
+#define HCI_UART_3WIRE 2
+#define HCI_UART_H4DS  3
+#define HCI_UART_LL            4
+#define HCIUARTSETPROTO                _IOW('U', 200, int)
+#define HCIUARTGETPROTO                _IOR('U', 201, int)
+#define HCIUARTGETDEVICE       _IOR('U', 202, int)
+
+/* Pre baudrate change for fast download */
+#define HIGH_SPEED_PATCHRAM_DOWNLOAD  TRUE
+
+/* Host Stack Idle Threshold */
+#define HCILP_IDLE_THRESHOLD          0x01
+
+/* Host Controller Idle Threshold */
+#define HCILP_HC_IDLE_THRESHOLD       0x01
+
+/* BT_WAKE Polarity - 0=Active Low, 1= Active High */
+#define HCILP_BT_WAKE_POLARITY        1
+
+/* HOST_WAKE Polarity - 0=Active Low, 1= Active High */
+#define HCILP_HOST_WAKE_POLARITY      1
+
+/* Local Feature */
+#define BCM_DISABLE_RF_PWRCTRL        FALSE
+
+
+
+
+#define RELEASE_DATE "2011.02.07"
+#define DEBUG 1
+
+typedef unsigned char   UINT8;
+typedef unsigned short  UINT16;
+typedef unsigned long   UINT32;
+typedef signed   long   INT32;
+typedef signed   char   INT8;
+typedef signed   short  INT16;
+typedef unsigned char   BOOLEAN;
+
+#define FALSE    0
+#define TRUE     (!FALSE)
+
+#define BD_ADDR_LEN     6                   /* Device address length */
+typedef UINT8 BD_ADDR[BD_ADDR_LEN];         /* Device address */
+
+
+
+#define HCI_GRP_LINK_CONTROL_CMDS                 (0x01 << 10)
+#define HCI_GRP_LINK_POLICY_CMDS                  (0x02 << 10)
+#define HCI_GRP_HOST_CONT_BASEBAND_CMDS           (0x03 << 10)
+#define HCI_GRP_INFORMATIONAL_PARAMS              (0x04 << 10)
+#define HCI_GRP_STATUS_PARAMS                     (0x05 << 10)
+#define HCI_GRP_TESTING_CMDS                      (0x06 << 10)
+#define HCI_GRP_L2CAP_CMDS                        (0x07 << 10)
+#define HCI_GRP_L2CAP_HCI_EVTS                    (0x08 << 10)
+#define HCI_GRP_VENDOR_SPECIFIC                   (0x3F << 10)
+
+
+#define HCI_RESET                                 (0x0003 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_SET_EVENT_FILTER                      (0x0005 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_READ_SCAN_ENABLE                      (0x0019 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+#define HCI_WRITE_SCAN_ENABLE                     (0x001A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
+
+#define HCI_READ_LOCAL_VERSION_INFO               (0x0001 | HCI_GRP_INFORMATIONAL_PARAMS)
+#define HCI_READ_LOCAL_FEATURES                   (0x0003 | HCI_GRP_INFORMATIONAL_PARAMS)
+
+#define HCI_ENABLE_DEV_UNDER_TEST_MODE            (0x0003 | HCI_GRP_TESTING_CMDS)
+
+#define HCI_BRCM_SUPER_PEEK_POKE                  (0x000A | HCI_GRP_VENDOR_SPECIFIC)
+#define VSC_WRITE_BD_ADDR                         (0x0001 | HCI_GRP_VENDOR_SPECIFIC)
+#define VSC_HCI_CMD_SET_LOC_FEATURES_CMD          (0x000B | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_BRCM_UPDATE_BAUDRATE_CMD              (0x0018 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_BRCM_WRITE_SCO_PCM_INT_PARAM          (0x001C | HCI_GRP_VENDOR_SPECIFIC)
+#define VSC_WRITE_PCM_DATA_FORMAT_PARAM           (0x001E | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_BRCM_WRITE_SLEEP_MODE                 (0x0027 | HCI_GRP_VENDOR_SPECIFIC)
+#define HCI_BRCM_DOWNLOAD_MINI_DRV                (0x002E | HCI_GRP_VENDOR_SPECIFIC)
+#define VSC_WRITE_UART_CLOCK_SETTING              (0x0045 | HCI_GRP_VENDOR_SPECIFIC)
+
+
+#define VOICE_SETTING_MU_LAW_MD                   0x0100
+#define VOICE_SETTING_LINEAR_MD                   0x0060
+
+#define HCI_ARM_MEM_PEEK                          0x04
+#define HCI_ARM_MEM_POKE                          0x05
+
+#define BTUI_MAX_STRING_LENGTH_PER_LINE           255
+#define HCI_BRCM_WRITE_SLEEP_MODE_LENGTH          10
+
+#define HCI_BRCM_UPDATE_BAUD_RATE_ENCODED_LENGTH    0x02
+#define HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH  0x06
+
+#define VSC_WRITE_UART_CLOCK_SETTING_LEN          1
+
+/* print string with time stamp */
+#define TDEBUG0(m)                               if(debug_mode) {print_time();fprintf(stderr,m);}
+#define TDEBUG1(m,n1)                            if(debug_mode) {print_time();fprintf(stderr,m,n1);}
+#define TDEBUG2(m,n1,n2)                         if(debug_mode) {print_time();fprintf(stderr,m,n1,n2);}
+#define TDEBUG3(m,n1,n2,n3)                      if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3);}
+#define TDEBUG4(m,n1,n2,n3,n4)                   if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3,n4);}
+#define TDEBUG5(m,n1,n2,n3,n4,n5)                if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3,n4,n5);}
+#define TDEBUG6(m,n1,n2,n3,n4,n5,n6)             if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3,n4,n5,n6);}
+
+/* print just string */
+#define DEBUG0(m)                               if(debug_mode) {fprintf(stderr,m);}
+#define DEBUG1(m,n1)                            if(debug_mode) {fprintf(stderr,m,n1);}
+#define DEBUG2(m,n1,n2)                         if(debug_mode) {fprintf(stderr,m,n1,n2);}
+#define DEBUG3(m,n1,n2,n3)                      if(debug_mode) {fprintf(stderr,m,n1,n2,n3);}
+#define DEBUG4(m,n1,n2,n3,n4)                   if(debug_mode) {fprintf(stderr,m,n1,n2,n3,n4);}
+#define DEBUG5(m,n1,n2,n3,n4,n5)                if(debug_mode) {fprintf(stderr,m,n1,n2,n3,n4,n5);}
+#define DEBUG6(m,n1,n2,n3,n4,n5,n6)             if(debug_mode) {fprintf(stderr,m,n1,n2,n3,n4,n5,n6);}
+
+
+#define STREAM_TO_UINT8(u8, p)   {u8 = (UINT8)(*(p)); (p) += 1;}
+#define STREAM_TO_UINT16(u16, p) {u16 = ((UINT16)(*(p)) + (((UINT16)(*((p) + 1))) << 8)); (p) += 2;}
+#define STREAM_TO_UINT32(u32, p) {u32 = (((UINT32)(*(p))) + ((((UINT32)(*((p) + 1)))) << 8) + ((((UINT32)(*((p) + 2)))) << 16) + ((((UINT32)(*((p) + 3)))) << 24)); (p) += 4;}
+
+#define ROTATE_BD_ADDR(p1, p2)    \
+                                                                       do                 \
+                                                                       {                                                       \
+                                                                               p1[0] = p2[5];          \
+                                                                               p1[1] = p2[4];          \
+                                                                               p1[2] = p2[3];          \
+                                                                               p1[3] = p2[2];          \
+                                                                               p1[4] = p2[1];          \
+                                                                               p1[5] = p2[0];          \
+                                                                       } while (0)     
+
+
+UINT8 vsc_for_pcm_config[5] = {0x00, 0x00, 0x03, 0x03, 0x00};
+/*
+                    Byte1 -- 0 for MSb first
+                    Byte2 -- 0 Fill value
+                    Byte3 -- 1 Fill option (0:0's, 1:1's , 2:Signed, 3:Programmable)
+                    Byte4 -- 1 Number of fill bits
+                    Byte5 -- 1 Right justified (0 for left justified)
+*/
+
+UINT8 vsc_for_sco_pcm[5]    = {0x00, 0x01, 0x00, 0x01, 0x01};
+/*
+                    Neverland : PCM, 256, short, master ,master
+                    Volance   : PCM, 256, short, master ,master
+                    
+                    Byte1 -- 0 for PCM 1 for UART or USB
+                    Byte2 -- 0 : 128, 1: 256, 2:512, 3:1024, 4:2048 Khz
+                    Byte3 -- 0 for short frame sync 1 for long frame sync
+                    Byte4 -- 0 Clock direction 0 for same as sync 1 for opposite direction
+                    Byte5 -- 0 for slave 1 for master
+*/                    
+
+int fd;    /* HCI handle */
+
+BOOLEAN debug_mode = FALSE;    /* Debug Mode Enable */
+
+unsigned char buffer[1024];
+
+struct termios termios;
+
+void ChangeBaudRate(UINT32 baudrate);
+
+
+void exit_err(UINT8 err)
+{
+#if ( HIGH_SPEED_PATCHRAM_DOWNLOAD == TRUE )
+    ChangeBaudRate(115200);
+#endif
+    exit(err);
+}
+
+void print_time(void)
+{
+#if 0
+    struct timespec tp;
+    int rs;
+
+    rs = clock_gettime(CLOCK_REALTIME,&tp);
+    fprintf(stderr, "[%04d : %06d]\n", tp.tv_sec, tp.tv_nsec/1000);
+    return;
+#endif
+}
+
+void dump(unsigned char *out, int len)
+{
+    int i;
+    
+    for (i = 0; i < len; i++)
+    {
+        if (!(i % 16)) 
+        {
+            DEBUG0( "\n");
+        }    
+        DEBUG1( "%02x ", out[i]);
+    }
+    DEBUG0( "\n\n");
+}
+
+UINT8 SendCommand(UINT16 opcode, UINT8 param_len, UINT8 *p_param_buf)
+{
+    UINT8 pbuf[255] = {0,};
+    UINT8 i=0;
+    
+    pbuf[0] = 0x1;
+    pbuf[1] = (UINT8)(opcode);
+    pbuf[2] = (UINT8)(opcode >>8);
+    pbuf[3] = param_len;
+
+    for (i=0; i<param_len; i++)
+    {        
+        pbuf[i+4] = *p_param_buf++;
+    }
+
+    DEBUG1( "Send %d",param_len+4);     
+
+    dump(pbuf, param_len+4);
+
+    write(fd, pbuf, param_len+4);
+    return 0;
+}
+
+void expired(int sig)
+{
+    static UINT8 count = 0;
+    DEBUG0( "expired try again\n");
+    SendCommand(HCI_RESET, 0, NULL);
+    alarm(1);
+    count++;
+
+    if(count > 3)
+    {
+        fprintf(stderr, "[ERR] HCI reset time expired\n");
+        exit(1);
+    }
+}
+
+void read_event(int fd, unsigned char *buffer)
+{
+    int i = 0;
+    int len = 3;
+    int count;
+
+    while ((count = read(fd, &buffer[i], len)) < len) 
+    {
+        i += count;
+        len -= count;
+    }
+
+    i += count;
+    len = buffer[2];
+
+    while ((count = read(fd, &buffer[i], len)) < len) 
+    {
+        i += count;
+        len -= count;
+    }
+
+#ifdef DEBUG
+    count += i;
+
+    DEBUG1( "\nreceived %d", count);
+    dump(buffer, count);
+#endif
+}
+
+INT32 filesize (char *name) 
+{
+    INT32 size;
+    int flag;
+    struct stat buf;
+
+    flag = stat (name,&buf);
+    if (flag == -1) 
+        return -1;
+
+    size = buf.st_size;
+    return (size);
+}
+
+void DisplayProgress(int total, int val)
+{
+#if 0
+    #define PROGRESS_NUM 20
+    
+    int p;
+    int i;
+    char text[PROGRESS_NUM+2]={0,};
+    
+    text[0]='[';
+    text[PROGRESS_NUM+1]=']';
+    p=(val*PROGRESS_NUM)/total;
+    
+    for ( i=1; i<=p; i++)
+    {
+        text[i]='=';
+    }
+    
+    for ( i=p+1; i<=PROGRESS_NUM; i++)
+    {
+        text[i]=' ';
+    }
+    
+    
+    for ( i=0; i<=(PROGRESS_NUM+1); i++)
+    {
+        fprintf(stderr, "%c",text[i]);
+    }
+    
+    if( p >= PROGRESS_NUM)
+        fprintf(stderr, "  %6d/%6d\n",val,total);
+    else
+        fprintf(stderr, "  %6d/%6d\r",val,total);
+#else
+    if( val == total)
+        fprintf(stderr, " %6d/%6d\n",val,total);
+    else
+        fprintf(stderr, " %6d/%6d\r",val,total);
+#endif
+}
+
+UINT8 DownloadPatchram( char *patchram1 )
+{
+    UINT32 len;
+    char   prm[128] ={0,};
+    FILE* pFile = NULL;
+
+    INT32 FileSize=0;
+    INT32 SentSize=0;
+    
+    DEBUG1( "\n%s\n", patchram1);
+
+    /* HCI reset */
+    DEBUG0( "HCI reset\n");
+    SendCommand(HCI_RESET, 0, NULL);
+    alarm(1);
+    read_event(fd, buffer);
+    alarm(0);
+    
+#if ( HIGH_SPEED_PATCHRAM_DOWNLOAD == TRUE )
+    ChangeBaudRate(921600);
+#endif
+
+    strcpy(prm, patchram1);    
+
+    fprintf(stderr, "Download Start\n");
+
+    if ((pFile = fopen(prm, "r")) == NULL) 
+    {
+        fprintf(stderr, "file %s could not be opened, error %d\n", prm, errno);
+        exit_err(1);
+    }
+    FileSize = filesize(prm);
+       
+    SendCommand(HCI_BRCM_DOWNLOAD_MINI_DRV, 0, NULL);
+    read_event(fd, buffer);
+
+       usleep(50000);
+
+    while (fread(&buffer[1], sizeof(UINT8), 3 ,pFile)) 
+    {
+        buffer[0] = 0x01;
+
+        len = buffer[3];
+
+        fread(&buffer[4],sizeof(UINT8),len, pFile);
+
+        write(fd, buffer, len + 4);
+
+        /* dispaly progress*/
+        SentSize += (len + 3);
+        DisplayProgress(FileSize,SentSize);
+        /* dispaly progress*/
+        
+        read_event(fd, buffer);
+
+    }
+    fclose(pFile);
+
+    usleep(100000);    /*100ms delay */
+
+    tcflush(fd, TCIOFLUSH);
+    tcgetattr(fd, &termios);
+    cfmakeraw(&termios);
+    termios.c_cflag |= CRTSCTS;
+    tcsetattr(fd, TCSANOW, &termios);
+    tcflush(fd, TCIOFLUSH);
+    tcsetattr(fd, TCSANOW, &termios);
+    tcflush(fd, TCIOFLUSH);
+    tcflush(fd, TCIOFLUSH);
+    cfsetospeed(&termios, B115200);
+    cfsetispeed(&termios, B115200);
+    tcsetattr(fd, TCSANOW, &termios);
+
+    /* Send HCI_RESET Command and process event */
+    DEBUG0( "HCI reset\n");
+    SendCommand(HCI_RESET, 0, NULL);
+    alarm(1);
+    read_event(fd, buffer);
+    alarm(0);
+    fprintf(stderr,"Download Complete\n");
+
+    return 0;
+}
+
+void SetScanEnable(void)
+{
+    UINT8 scan_data[1] ;
+
+   /* 0x00: No scan enabled                            */
+   /* 0x01: Inquiry scan enabled  | Page scan disabled */
+   /* 0x02: Inquiry scan disabled | Page scan enabled  */
+   /* 0x03: Inquiry scan enabled  | Page scan enabled  */
+
+    scan_data[0]= 0x03;
+    SendCommand(HCI_WRITE_SCAN_ENABLE, 1, &scan_data[0]);
+    read_event(fd, buffer);
+}
+
+void SetAudio(void)
+{
+    fprintf(stderr,"Write Audio parameter\n");
+
+    DEBUG5( "vsc_for_sco_pcm = {%d,%d,%d,%d,%d}\n", vsc_for_sco_pcm[0],
+                                         vsc_for_sco_pcm[1],vsc_for_sco_pcm[2],
+                                         vsc_for_sco_pcm[3],vsc_for_sco_pcm[4]);
+
+    SendCommand(HCI_BRCM_WRITE_SCO_PCM_INT_PARAM, 5, (UINT8 *)vsc_for_sco_pcm);
+    read_event(fd, buffer);
+
+    DEBUG5( "vsc_for_pcm_config = {%d,%d,%d,%d,%d}\n", vsc_for_pcm_config[0],
+                                        vsc_for_pcm_config[1], vsc_for_pcm_config[2],
+                                        vsc_for_pcm_config[3], vsc_for_pcm_config[4]);
+
+    SendCommand(VSC_WRITE_PCM_DATA_FORMAT_PARAM, 5, (UINT8 *)vsc_for_pcm_config);
+    read_event(fd, buffer);
+}
+
+void SetPcmConf( UINT8 p0, UINT8 p1, UINT8 p2, UINT8 p3, UINT8 p4 )
+{
+    vsc_for_pcm_config[0] = p0;
+    vsc_for_pcm_config[1] = p1;
+    vsc_for_pcm_config[2] = p2;
+    vsc_for_pcm_config[3] = p3;
+    vsc_for_pcm_config[4] = p4;
+}
+
+void SetScoConf( UINT8 p0, UINT8 p1, UINT8 p2, UINT8 p3, UINT8 p4 )
+{
+    vsc_for_sco_pcm[0] = p0;
+    vsc_for_sco_pcm[1] = p1;
+    vsc_for_sco_pcm[2] = p2;
+    vsc_for_sco_pcm[3] = p3;
+    vsc_for_sco_pcm[4] = p4;
+}
+
+void HCILP_Enable(BOOLEAN on)
+{
+    fprintf(stderr,"Set Low Power mode %d\n",on);
+    UINT8 data[HCI_BRCM_WRITE_SLEEP_MODE_LENGTH] = {
+    0x01,                        /* Sleep Mode algorithm 1 */
+    HCILP_IDLE_THRESHOLD,        /* Host Idle Treshold in 300ms */
+    HCILP_HC_IDLE_THRESHOLD,     /* Host Controller Idle Treshold in 300ms */ /* this should be less than scan interval.*/
+    HCILP_BT_WAKE_POLARITY,      /* BT_WAKE Polarity - 0=Active Low, 1= Active High*/
+    HCILP_HOST_WAKE_POLARITY,    /* HOST_WAKE Polarity - 0=Active Low, 1= Active High */
+    0x01,                        /* Allow host Sleep during SCO */
+    0x01,                        /* Combine Sleep Mode and LPM - The device will not sleep in mode 0 if this flag is set to 1,*/
+    0x00,                        /* UART_TXD Tri-State : 0x00 = Do not tri-state UART_TXD in sleep mode */
+    0x00,                        /* NA to Mode 1 */
+    0x00,                        /* NA to Mode 1 */
+    };
+
+    if(on)
+    {
+        data[0] = 0x01;
+    }
+    else
+    {
+        data[0] = 0x00;
+    }
+
+    SendCommand(HCI_BRCM_WRITE_SLEEP_MODE, HCI_BRCM_WRITE_SLEEP_MODE_LENGTH, (UINT8 *)data);
+    read_event(fd, buffer);
+}
+
+UINT32 uart_speed(UINT32 Speed)
+{
+       switch (Speed) 
+       {
+       case 115200:
+               return B115200;
+       case 230400:
+               return B230400;
+       case 460800:
+               return B460800;
+       case 921600:
+               return B921600;
+       case 1000000:
+               return B1000000;
+       case 1500000:
+               return B1500000;
+       case 2000000:
+               return B2000000;
+       case 2500000:
+               return B2500000;
+       case 3000000:
+               return B3000000;
+       case 4000000:
+               return B4000000;
+       default:
+               return B115200;
+       }
+}
+
+void ChangeBaudRate(UINT32 baudrate)
+{
+    UINT8 hci_data[HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+    UINT8 uart_clock_24 = 0x2;    /* 0x1 - UART Clock 48MHz, 0x2 - UART Clock 24MHz */    
+    UINT8 uart_clock_48 = 0x1;    /* 0x1 - UART Clock 48MHz, 0x2 - UART Clock 24MHz */
+
+    switch(baudrate)
+    {
+        case 115200:
+        case 230400:
+        case 460800:
+        case 921600:
+        case 1000000:
+        case 1500000:
+        case 2000000:
+        case 2500000:
+            /* Write UART Clock setting of 24MHz */
+            DEBUG0( "Change UART_CLOCK 24Mhz\n");    
+            SendCommand( VSC_WRITE_UART_CLOCK_SETTING, VSC_WRITE_UART_CLOCK_SETTING_LEN, (UINT8 *)&uart_clock_24);
+            read_event(fd, buffer);        
+            break;        
+
+        case 3000000:
+        case 4000000:
+            /* Write UART Clock setting of 48MHz */
+            DEBUG0( "Change UART_CLOCK 48Mh\nz");    
+            SendCommand( VSC_WRITE_UART_CLOCK_SETTING, VSC_WRITE_UART_CLOCK_SETTING_LEN, (UINT8 *)&uart_clock_48);
+            read_event(fd, buffer);        
+            break;
+            
+        default:
+            fprintf(stderr,"Not Support baudrate = %ld\n", baudrate);
+            exit_err(1);
+            break;
+    }
+
+    hci_data[2] = baudrate & 0xFF;
+    hci_data[3] = (baudrate >> 8) & 0xFF;
+    hci_data[4] = (baudrate >> 16) & 0xFF;
+    hci_data[5] = (baudrate >> 24) & 0xFF;
+    
+    DEBUG1( "Change Baudrate %ld\n",baudrate);    
+
+    SendCommand( HCI_BRCM_UPDATE_BAUDRATE_CMD, HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH, (UINT8 *)hci_data);
+    read_event(fd, buffer);
+
+    
+    tcflush(fd, TCIOFLUSH);
+    tcgetattr(fd, &termios);
+    cfmakeraw(&termios);
+    termios.c_cflag |= CRTSCTS;
+    tcsetattr(fd, TCSANOW, &termios);
+    tcflush(fd, TCIOFLUSH);
+    tcsetattr(fd, TCSANOW, &termios);
+    tcflush(fd, TCIOFLUSH);
+    tcflush(fd, TCIOFLUSH);
+    cfsetospeed(&termios, uart_speed(baudrate));
+    cfsetispeed(&termios, uart_speed(baudrate));
+    tcsetattr(fd, TCSANOW, &termios);
+
+}
+
+void EnableTestMode(void)
+{
+    UINT8 filter_data[] = { 0x02, 0x00, 0x02 };
+    
+    /* bt sleep  disable */
+    HCILP_Enable(FALSE);
+
+    /* Enable both Inquiry & Page Scans */
+    SetScanEnable();
+
+    /* Set Event Filter: Enable Auto Connect */
+    SendCommand( HCI_SET_EVENT_FILTER, 0x03, (UINT8 *)filter_data);
+    read_event(fd, buffer);
+
+    /* Enable Device under test */
+    SendCommand( HCI_ENABLE_DEV_UNDER_TEST_MODE, 0x0, NULL);
+    read_event(fd, buffer);
+
+    fprintf(stderr,"Enable Device Under Test\n");
+}
+
+void SetLocalFeatures(void)
+{
+    UINT8  *data = NULL;
+
+    DEBUG0("Read Local Feature\n");    
+    SendCommand(HCI_READ_LOCAL_FEATURES, 0, NULL);
+    read_event(fd, buffer);
+
+    data = &buffer[7];
+
+#if (BCM_DISABLE_RF_PWRCTRL == TRUE)
+    fprintf(stderr,"Remove Power Control\n");
+    data[2] &= 0xFB;    /* Power contrel */
+#endif
+    DEBUG0("Write Local Feature\n");    
+    SendCommand(VSC_HCI_CMD_SET_LOC_FEATURES_CMD, 0x08, (UINT8 *)data);
+    read_event(fd, buffer);
+}
+
+void EnbleHCI(void)
+{
+    int i = N_HCI;
+    int proto = HCI_UART_H4;
+
+    if (ioctl(fd, TIOCSETD, &i) < 0) 
+    {
+        fprintf(stderr, "Can't set line discipline\n");
+        return;
+    }
+    
+    if (ioctl(fd, HCIUARTSETPROTO, proto) < 0) 
+    {
+        fprintf(stderr, "Can't set hci protocol\n");
+        return;
+    }
+    fprintf(stderr, "Done setting line discpline\n");
+    return;
+    
+}
+void print_usage( void )
+{
+    fprintf(stderr,"\n");
+    fprintf(stderr,"BRCM BT tool for Linux    release %s\n",RELEASE_DATE);
+    fprintf(stderr,"\n");
+    fprintf(stderr," Usage: bcmtool <tty Device> <command> [command parameter],....\n\n");    
+    fprintf(stderr,"  -FILE    Patchram file name     EX) -FILE=BCM43xx_xxx.hcd\n");
+    fprintf(stderr,"  -BAUD    Set Baudrate           EX) -BAUD=3000000\n");
+    fprintf(stderr,"  -ADDR    BD addr file name      EX) -ADDR=.bdaddr\n");
+    fprintf(stderr,"  -SCO     Enable SCO/PCM config  EX) -SCO\n");
+    fprintf(stderr,"  -SETSCO  SCO/PCM values verify  EX) -SETSCO=0,1,0,1,1,0,0,3,3,0\n");
+    fprintf(stderr,"  -LP      Enable Low power       EX) -LP\n");
+    fprintf(stderr,"  -FEATURE Set local Feature      EX) -FEATURE\n");
+    fprintf(stderr,"  -DUT     Enable DUT mode(do not use with -LP) EX) -DUT\n");
+    fprintf(stderr,"  -ATTACH  Attach BT controller to BlueZ stack  EX) -ATTACH\n");    
+    fprintf(stderr,"  -DEBUG   Debug message          EX) -DEBUG\n");
+    fprintf(stderr,"\n");
+}
+
+int main(int argc, char *argv[])
+{
+    UINT8 i = 0;
+    
+    if (argc < 2) 
+    {
+        print_usage();
+        exit(1);
+    }
+    else
+    {
+        fprintf(stderr,"BRCM BT tool for Linux    release %s\n",RELEASE_DATE);
+    }
+    
+    /* Open dev port */
+    if ((fd = open(argv[1], O_RDWR | O_NOCTTY)) == -1) 
+    {
+        fprintf(stderr, "port %s could not be opened, error %d\n", argv[1], errno);
+        exit(2);
+    }
+    
+    tcflush(fd, TCIOFLUSH);
+    tcgetattr(fd, &termios);
+    cfmakeraw(&termios);
+    termios.c_cflag |= CRTSCTS;
+    tcsetattr(fd, TCSANOW, &termios);
+    tcflush(fd, TCIOFLUSH);
+    tcsetattr(fd, TCSANOW, &termios);
+    tcflush(fd, TCIOFLUSH);
+    tcflush(fd, TCIOFLUSH);
+    cfsetospeed(&termios, B115200);
+    cfsetispeed(&termios, B115200);
+    tcsetattr(fd, TCSANOW, &termios);
+    
+    signal(SIGALRM, expired);
+
+    for( i=2; i<argc; i++ )
+    {
+        char *ptr = argv[i];
+
+        if( strstr(ptr,"-DEBUG") )
+        {
+            debug_mode = TRUE;
+            DEBUG0("DEBUG On\n");
+            break;
+        }
+    }
+    
+    for( i=2; i<argc; i++ )
+    {
+        char *ptr = argv[i];
+       
+       if(ptr == NULL)
+               continue;
+       
+        fprintf(stderr,"[%d] %s\n", i-1, ptr);
+        
+        if( strstr(ptr,"-FILE=") )
+        {
+            char prm_name[128];
+
+            ptr += 6;
+
+            strncpy(prm_name,ptr, 127);
+            DownloadPatchram( prm_name );
+
+        }
+        else if( strstr(ptr,"-BAUD=") )
+        {
+            UINT32  baudrate;
+
+            ptr += 6;
+            baudrate = atoi(ptr);
+
+            ChangeBaudRate(baudrate);
+        }
+        else if( strstr(ptr,"-ADDR=") )
+        {
+            char *bdaddr_filename;
+            FILE* pFile = NULL;
+
+            int bdaddr[10];         /* Displayed BD Address */
+            
+            BD_ADDR local_addr;       /* BD Address for write */
+
+#if 0            
+            ptr += 6;
+            if( sscanf(ptr,"%02X:%02X:%02X:%02X:%02X:%02X",&bdaddr[0],&bdaddr[1],&bdaddr[2],&bdaddr[3],&bdaddr[4],&bdaddr[5]) != 6 )
+            {
+                fprintf(stderr,"-ADDR: Parameter error");
+                exit_err(1);
+            }
+            bte_write_bdaddr(bdaddr);
+#endif
+            ptr += 6;
+            bdaddr_filename = ptr;
+
+            if(bdaddr_filename)
+            {
+               pFile = fopen(bdaddr_filename, "r");
+            }          
+
+            if(pFile)
+            {
+                char text[BTUI_MAX_STRING_LENGTH_PER_LINE];
+
+                fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE, pFile);
+                sscanf(text,"%02x%02x",&bdaddr[0],&bdaddr[1]);
+
+                fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE, pFile);
+                sscanf(text,"%02x",&bdaddr[2]);
+
+                fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE, pFile);
+                sscanf(text,"%02x%02x%02x",&bdaddr[3],&bdaddr[4],&bdaddr[5]);
+
+                fprintf(stderr,"Writing B/D Address = %02X:%02X:%02X:%02X:%02X:%02X\n",bdaddr[0],bdaddr[1],bdaddr[2],bdaddr[3],bdaddr[4],bdaddr[5]);
+
+                ROTATE_BD_ADDR(local_addr,bdaddr);
+
+                SendCommand(VSC_WRITE_BD_ADDR, BD_ADDR_LEN, (UINT8 *)local_addr);
+                read_event(fd, buffer);
+            }    
+            else
+            {
+                fprintf(stderr, "-ADDR: file open fail\n");
+                exit_err(1);
+            }
+
+        }
+        else if( strstr(ptr,"-SCO") )
+        {
+            SetAudio();
+        
+        }
+        else if( strstr(ptr,"-SETSCO=") )
+        {
+            ptr += 8;
+            int value[10];
+            
+            if( sscanf(ptr,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&value[0],&value[1],&value[2],&value[3],&value[4],
+                                                           &value[5],&value[6],&value[7],&value[8],&value[9]) != 10 )
+            {
+                DEBUG0("PCM / SCO configuration value err\n");
+                DEBUG0("SCO_Routing,PCM_Interface_Rate,Frame_Type,Sync_Mode,Clock_Mode,LSB_First,Fill_bits,Fill_Method,Fill_Num,Right_Justify\n");
+                exit_err(1);
+            }
+
+            SetScoConf( value[0],value[1],value[2],value[3],value[4] );
+            SetPcmConf( value[5],value[6],value[7],value[8],value[9] );
+            SetAudio();
+        }
+        else if( strstr(ptr,"-LP") )
+        {
+            HCILP_Enable(TRUE);
+        }
+        else if( strstr(ptr,"-DUT") )
+        {
+            EnableTestMode();
+        }
+        else if( strstr(ptr,"-FEATURE") )
+        {
+            SetLocalFeatures();
+        }
+        else if( strstr(ptr,"-ATTACH") )
+        {
+            EnbleHCI();
+            while (1) 
+            {
+                sleep(UINT_MAX);
+            }            
+        }
+        else if( strstr(ptr,"-DEBUG") )
+        {
+
+        }
+        else
+        {
+            fprintf(stderr,"Invalid parameter(s)!\n");
+            exit_err(1);
+        }
+    }
+
+    fprintf(stderr, "EXIT\n");
+    close(fd);
+    exit(0);
+
+    return 0;
+}