Merge branch 'master' into tizen_2.1
authorDoHyun Pyun <dh79.pyun@samsung.com>
Thu, 21 Mar 2013 23:48:29 +0000 (08:48 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Thu, 21 Mar 2013 23:48:29 +0000 (08:48 +0900)
Change-Id: I68ecb9f9f58954c847085c996e53cbe094fcf8db

14 files changed:
AUTHORS [new file with mode: 0644]
CMakeLists.txt
LICENSE.APLv2 [new file with mode: 0644]
LICENSE.Broadcom [new file with mode: 0644]
NOTICE [new file with mode: 0644]
NOTICE.APLv2.0 [new file with mode: 0644]
packaging/bluetooth-firmware-bcm-e4412.spec
packaging/bluetooth-firmware-bcm.spec
scripts/bt-dev-end.sh
scripts/bt-dev-start-c210.sh
scripts/bt-dev-start-e4412.sh
scripts/bt-set-addr.sh
set-address/setbd.c
tools/bcmtool_4330b1.c

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..46d1687
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,2 @@
+Jinmin Jung <jinmin@samsung.com>
+DoHyun Pyun <dh79.pyun@samsung.com>
index c0285fa..cabe6eb 100644 (file)
@@ -1,7 +1,7 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(package REQUIRED glib-2.0 vconf)
+pkg_check_modules(package REQUIRED glib-2.0 tapi)
 
 FOREACH(flag ${package_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
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/NOTICE.APLv2.0 b/NOTICE.APLv2.0
new file mode 100644 (file)
index 0000000..ccdad52
--- /dev/null
@@ -0,0 +1,3 @@
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE file for Apache License terms and conditions.
index 345d4cf..beb1fbd 100644 (file)
@@ -2,8 +2,8 @@ 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
+Group:      Hardware Support/Handset
+License:    Apache License, Version 2.0
 Source0:    bluetooth-firmware-bcm-%{version}.tar.gz
 
 BuildRequires:  pkgconfig(vconf)
index 792051b..bfa91fa 100644 (file)
@@ -6,19 +6,35 @@ 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
+Source0:    bluetooth-firmware-bcm-%{version}.tar.gz
 
-BuildRequires:  pkgconfig(vconf)
 BuildRequires:  cmake
+BuildRequires:  pkgconfig(tapi)
 
 %description
- firmware and tools for bluetooth
+firmware and tools for bluetooth
 
+%package c210
+Summary:    c210 firmware and tools for bluetooth
+Group:      TO_BE/FILLED
+
+%description c210
+c210 firmware and tools for bluetooth
+
+%package e4412
+Summary:    e4412 firmware and tools for bluetooth
+Group:      TO_BE/FILLED
+
+%description e4412
+e4412 firmware and tools for bluetooth
 
 %prep
-%setup -q
+%setup -q -n bluetooth-firmware-bcm-%{version}
 
 %build
+export CFLAGS+=" -fpie -fvisibility=hidden"
+export LDFLAGS+=" -Wl,--rpath=/usr/lib -Wl,--as-needed -Wl,--unresolved-symbols=ignore-in-shared-libs -pie"
+
 cmake ./ -DCMAKE_INSTALL_PREFIX=%{_prefix} -DPLUGIN_INSTALL_PREFIX=%{_prefix}
 make %{?jobs:-j%jobs}
 
@@ -26,17 +42,30 @@ make %{?jobs:-j%jobs}
 rm -rf %{buildroot}
 %make_install
 
-cp -rf %{buildroot}%{_prefix}/etc/bluetooth/bt-dev-start-c210.sh  %{buildroot}%{_prefix}/etc/bluetooth/bt-dev-start.sh
+%post c210
+rm -rf %{_prefix}/etc/bluetooth/bt-dev-start.sh
+ln -s %{_prefix}/etc/bluetooth/bt-dev-start-c210.sh %{_prefix}/etc/bluetooth/bt-dev-start.sh
+
+%post e4412
+rm -rf %{_prefix}/etc/bluetooth/bt-dev-start.sh
+ln -s %{_prefix}/etc/bluetooth/bt-dev-start-e4412.sh %{_prefix}/etc/bluetooth/bt-dev-start.sh
 
-%files
+%files c210
 %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-dev-start-c210.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
+
+%files e4412
+%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-e4412.sh
+%attr(755,-,-) %{_prefix}/etc/bluetooth/bt-set-addr.sh
\ No newline at end of file
index ef4731e..cb57537 100755 (executable)
@@ -17,11 +17,11 @@ if [ $REVISION_NUM == "0006" ]; then
        exit 0
 fi
 
-killall hciattach
-
 # Turn off Bluetooth Chip
 rfkill block bluetooth
 
+killall hciattach
+
 #if [ -e /sys/class/gpio/gpio17/value ]
 #then
 #      # Reset BT chip
index d87f35d..386fd24 100755 (executable)
@@ -22,7 +22,7 @@ then
        mknod $BT_UART_DEVICE c 204 64
 fi
 
-if [ ! -e /opt/etc/.bd_addr ]
+if [ ! -e /csa/bluetooth/.bd_addr ]
 then
        # Set BT address
        /usr/bin/setbd
@@ -39,7 +39,7 @@ 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
+       $BCM_TOOL $BT_UART_DEVICE -FILE=/usr/etc/bluetooth/$BCM_FIRMWARE -BAUD=$UART_SPEED -ADDR=/csa/bluetooth/.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
index 96023e5..5c58e8c 100755 (executable)
@@ -25,7 +25,7 @@ then
        mknod $BT_UART_DEVICE c 204 64
 fi
 
-if [ ! -e /opt/etc/.bd_addr ]
+if [ ! -e /csa/bluetooth/.bd_addr ]
 then
        # Set BT address
        /usr/bin/setbd
index 57b2d02..8fcb3f2 100755 (executable)
@@ -4,7 +4,7 @@
 # Script for setting Bluetooth Address
 #
 
-if [ -e /opt/etc/.bd_addr ]
+if [ -e /csa/bluetooth/.bd_addr ]
 then
        echo "Already .bd_addr exists"
        exit 0
index 092da16..f9543e4 100644 (file)
@@ -1,11 +1,7 @@
 /*
  * 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 <fcntl.h>
 #include <unistd.h>
 #include <time.h>
-#include <vconf.h>
 #include <glib.h>
+#include <dirent.h>
+#include <tapi_common.h>
+#include <ITapiModem.h>
 
 #ifdef __TI_PATCH__
 #define BT_CHIP_TI
 #define APP_DEBUG(format, args...)
 #endif
 
-#define        BD_ADDR_FILE    "/opt/etc/.bd_addr"
-#define        PSKEY_TEMP_FILE "/opt/etc/.bluetooth.psr"
-#define PSR_FILE       "/opt/etc/bluetooth/bluetooth.psr"
+#define        BD_ADDR_PATH    "/csa/bluetooth"
+#define        BD_ADDR_FILE    "/csa/bluetooth/.bd_addr"
+#define        PSKEY_TEMP_FILE "/csa/bluetooth/.bluetooth.psr"
+#define PSR_FILE       "/csa/bluetooth/bluetooth.psr"
 
 #define        BD_ADDR_LEN     14
 #define BD_PREFIX      "0002\n"
 
 #define READ_BD_FILE_MAX       300
 
-static int success_make_bt_address_from_imei=-1;
-static GMainLoop * loop;
-const char *DEFAULT_IMEI="004999010640000";
-static gboolean is_default_imei=FALSE;
+static int success_make_bt_address_from_imei = -1;
+static GMainLoop *loop;
+const char *DEFAULT_IMEI = "004999010640000";
 
 #if defined(BT_CHIP_CSR) || defined(BT_CHIP_BROADCOM)
-int addremoveBD(char* path, char* pskey){
+int addremoveBD(char *path, char *pskey)
+{
        FILE *fd, *new;
        int ret;
        char cmp[READ_BD_FILE_MAX];
        char *result;
 
        fd = fopen(path, "r");
-       if(NULL == fd){
+       if (NULL == fd) {
                APP_DBG("Error open psr file\r\n");
                return -21;
        }
 
        new = fopen(PSKEY_TEMP_FILE, "w");
-       if(NULL == new){
+       if (NULL == new) {
                APP_DBG("Error creat temp file\r\n");
                fclose(fd);
                return -22;
        }
 
-       ret = fputs(pskey,new);
+       ret = fputs(pskey, new);
 
-       while(1){
+       while (1) {
                result = fgets(cmp, READ_BD_FILE_MAX, fd);
 
                APP_DBG("PSR : [%s]\r\n", cmp);
 
-               if((NULL != result) && (0 == strncmp(cmp, "&0001", 5))){
+               if ((NULL != result) && (0 == strncmp(cmp, "&0001", 5))) {
                        APP_DBG("Find BD address set script\r\n");
                        continue;
                }
 
-               if(NULL == result){
+               if (NULL == result) {
                        APP_DBG("EOF reaches\r\n");
                        fclose(fd);
                        fclose(new);
                        return 1;
                }
 
-               ret = fputs(cmp,new);
+               ret = fputs(cmp, new);
        }
 
        return 0;
 }
-void makeRandomBD(unsigned char* buf){
+
+void makeRandomBD(unsigned char *buf)
+{
        int ran;
        int i;
        unsigned int seed;
        memcpy(buf, BD_PREFIX, 5);
        seed = time(NULL);
-       for(i=5;i<14;i++){
-               if(7==i){
-                       buf[i]='\n';
+       for (i = 5; i < BD_ADDR_LEN; i++) {
+               if (7 == i) {
+                       buf[i] = '\n';
                        continue;
                }
-               ran = rand_r(&seed)%16;
-               if(10>ran)
-                       ran+=0x30;
+               ran = rand_r(&seed) % 16;
+               if (10 > ran)
+                       ran += 0x30;
                else
-                       ran+=0x57;
-               buf[i]=ran;
+                       ran += 0x57;
+               buf[i] = ran;
        }
        APP_DEBUG("Random number is\r\n");
-       for(i=0;i<BD_ADDR_LEN;i++){
-               APP_DEBUG("%c",buf[i]);
+       for (i = 0; i < BD_ADDR_LEN; i++) {
+               APP_DEBUG("%c", buf[i]);
        }
        APP_DEBUG("\r\n");
 }
 #endif
 
 #ifdef BT_CHIP_TI
-int readBDaddrTI(void){
-       int i, cnt_lap=0, cnt_uap=0, cnt_nap=0;
+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){
+       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){
+       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)){
+       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])
+       for (i = 0; i < 17; i++) {
+               if (':' == address[i])
                        continue;
 
-               if(5>i)
+               if (5 > i)
                        nap[cnt_nap++] = address[i];
-               else if(8>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]);
+       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){
+       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;
        }
@@ -196,59 +197,58 @@ int readBDaddrTI(void){
        return 0;
 }
 #endif
-int make_bt_address_from_tapi_imei(unsigned char * bt_address)
+int make_bt_address_from_tapi_imei(unsigned char *bt_address)
 {
-       char * temp=NULL;
-       int tapi_state=0;
-       int ret=-1;
-       int i=0;
+       int i = 0;
+       TapiHandle *handler;
+       char *imei_no;
 
-       if(bt_address==NULL)
+       if (bt_address == NULL)
                return -EBADR;
 
-       ret=vconf_get_int(VCONFKEY_TELEPHONY_TAPI_STATE,&tapi_state);
-       if(tapi_state==VCONFKEY_TELEPHONY_TAPI_STATE_READY && ret==0){
-               temp=vconf_get_str(VCONFKEY_TELEPHONY_IMEI);
-               APP_DEBUG("TAPI_IMEI: %s\n",temp);
+       handler = tel_init(NULL);
+       if (!handler) {
+               APP_DEBUG("Telephony initilization failed\n");
+               return -ENODATA;
+       }
 
-#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;
+       imei_no = tel_get_misc_me_imei_sync(handler);
+       tel_deinit(handler);
+       if (!imei_no) {
+               APP_DEBUG("Telephony IMEI getting failed \n");
                return -ENODATA;
-#endif
+       }
 
-               if(strcmp(temp,"")==0)
-                       return -ENODATA;
+       if (strlen(imei_no) < BD_ADDR_LEN) {
+               free(imei_no);
+               APP_DEBUG("TAPI_IMEI Reading Error\n");
+               return -ENODATA;
+       }
 
-               if(strlen(temp)<14)
-                       return -ENODATA;
+       APP_DEBUG("TAPI_IMEI: %s\n", imei_no);
 
-               memcpy(bt_address, BD_PREFIX, 5);
+       if (strcmp(imei_no, DEFAULT_IMEI) == 0) {
+               APP_DEBUG("TAPI_IMEI is defulat IMEI\n");
+               free(imei_no);
+               return -ENODATA;
+       }
 
-               for(i=5 ;i<14;i++){
-                       if(i==7){
-                               bt_address[i]='\n';
-                               continue;
-                       }
+       memcpy(bt_address, BD_PREFIX, 5);
 
-                       bt_address[i]=temp[i];
+       for (i = 5; i < BD_ADDR_LEN; i++) {
+               if (i == 7) {
+                       bt_address[i] = '\n';
+                       continue;
                }
 
-       }else{
-               APP_DEBUG("TAPI_IMEI Reading Error\n");
-               return -ENODATA;
+               bt_address[i] = imei_no[i];
        }
 
+       free(imei_no);
+
        APP_DEBUG("Bluetooth Address\n");
-       for(i=0;i<BD_ADDR_LEN;i++)
-               APP_DEBUG("%c",bt_address[i]);
+       for (i = 0; i < BD_ADDR_LEN; i++)
+               APP_DEBUG("%c", bt_address[i]);
 
        APP_DEBUG("\n");
 
@@ -256,6 +256,23 @@ int make_bt_address_from_tapi_imei(unsigned char * bt_address)
 
 }
 
+void make_bt_address_folder(void)
+{
+       DIR *dp;
+       int err;
+
+       dp = opendir(BD_ADDR_PATH);
+       if (dp == NULL) {
+               if (mkdir(BD_ADDR_PATH, 0755) < 0) {
+                       err = -errno;
+                       APP_DEBUG("mkdir: %s(%d)", strerror(-err), -err);
+               }
+               return;
+       }
+
+       closedir(dp);
+}
+
 int make_bt_address(gboolean overwrite_bt_address)
 {
 #if defined(BT_CHIP_CSR) || defined(BT_CHIP_BROADCOM)
@@ -263,40 +280,42 @@ int make_bt_address(gboolean overwrite_bt_address)
        int fd;
        int i;
        unsigned char txt[BD_ADDR_LEN];
-       unsigned char nap[4+1], uap[2+1], lap[6+1];
-       char pskey[PSKEY_LEN+3];
+       unsigned char nap[4 + 1], uap[2 + 1], lap[6 + 1];
+       char pskey[PSKEY_LEN + 3];
        int ret;
 
-       fd=open(BD_ADDR_FILE, O_RDONLY | O_SYNC);
+       make_bt_address_folder();
 
-       if(fd<0 || overwrite_bt_address==TRUE){
-               if(fd<0)
+       fd = open(BD_ADDR_FILE, O_RDONLY | O_SYNC);
+
+       if (fd < 0 || overwrite_bt_address == TRUE) {
+               if (fd < 0)
                        APP_DEBUG("File not exist\n");
                else
                        close(fd);
 
-               if(overwrite_bt_address)
-               {
+               if (overwrite_bt_address) {
                        APP_DEBUG("Overwrite BT address because TAPI write correct IMEI.\n");
                }
 
-               fd=open(BD_ADDR_FILE, O_RDWR | O_CREAT | O_TRUNC | O_SYNC, 0644);
+               fd = open(BD_ADDR_FILE, O_RDWR | O_CREAT | O_TRUNC | O_SYNC,
+                         0644);
 
-               if (fd <0)
-               {
+               if (fd < 0) {
                        APP_DEBUG("Can't open address file\n");
                        return 0;
                }
-               success_make_bt_address_from_imei=make_bt_address_from_tapi_imei(txt);
+               success_make_bt_address_from_imei =
+                   make_bt_address_from_tapi_imei(txt);
 
-               if(success_make_bt_address_from_imei<0)
+               if (success_make_bt_address_from_imei < 0)
                        makeRandomBD(txt);
 
                ret = write(fd, txt, BD_ADDR_LEN);
                lseek(fd, 0, SEEK_SET);
-       }else{
-               APP_DEBUG("%s is already existed\n",BD_ADDR_FILE);
-               success_make_bt_address_from_imei=0;
+       } else {
+               APP_DEBUG("%s is already existed\n", BD_ADDR_FILE);
+               success_make_bt_address_from_imei = 0;
        }
 
        ret = read(fd, nap, 5);
@@ -306,27 +325,26 @@ int make_bt_address(gboolean overwrite_bt_address)
 
 #if defined(BT_CHIP_CSR)
        APP_DEBUG("nap[");
-       for(i=0;i<4;i++)
-               APP_DEBUG("%c",nap[i]);
+       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]);
+       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]);
+       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]);
+       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++)
+       for (i = 0; i < PSKEY_LEN; i++)
                APP_DEBUG("%c", pskey[i]);
        APP_DEBUG("]\r\n");
 
@@ -337,14 +355,14 @@ int make_bt_address(gboolean overwrite_bt_address)
        int fd;
        int ret;
 
-       fd=open(BD_ADDR_FILE, O_RDONLY, 0644);
-       if(0>fd){
+       fd = open(BD_ADDR_FILE, O_RDONLY, 0644);
+       if (0 > fd) {
                APP_DBG("File not exists\r\n");
-               ret=readBDaddrTI();
-       }else{
+               ret = readBDaddrTI();
+       } else {
                APP_DBG("File exists\r\n");
                close(fd);
-               ret=0;
+               ret = 0;
        }
 
        return ret;
@@ -354,32 +372,6 @@ int make_bt_address(gboolean overwrite_bt_address)
 #endif
 }
 
-void vconf_cb(keynode_t *key, void * data)
-{
-       char * key_string=NULL;
-
-       switch(vconf_keynode_get_type(key))
-       {
-               case VCONF_TYPE_STRING:
-                       key_string=vconf_keynode_get_str(key);
-                       if(strcmp(key_string,"")!=0)
-                       {
-                               APP_DEBUG("Vconf Call back trial\n");
-                               /* This case means TAPI writes IMEI correctly */
-                               /* Because we write BT address which comes from IMEI again  */
-                               make_bt_address(TRUE);
-                               g_main_loop_quit(loop);
-                       }
-
-                       break;
-
-
-               default:
-                       break;
-       }
-       return;
-}
-
 gboolean exit_cb(gpointer data)
 {
 
@@ -388,26 +380,12 @@ gboolean exit_cb(gpointer data)
 
        return FALSE;
 }
+
 int main()
 {
-       loop=g_main_loop_new(NULL,FALSE);
+       loop = g_main_loop_new(NULL, FALSE);
        APP_DEBUG("Bluetooth Address Setting\n");
        make_bt_address(FALSE);
 
-       /* When we get proper BT address by IMEI or
-        * randome BT address due to default IMEI
-        * We don't need to wait for telephony activation, timeout */
-       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;
 }
index 6350a06..7fac3f7 100644 (file)
@@ -1,11 +1,23 @@
-/*****************************************************************************
-**                                                                           
-**  Name:          bcmtool.c
-**
-**  Description:   Download a patchram files for the HCD format
-**
-**  Copyright (c) 2000-2009, Broadcom Corp., All Rights Reserved.
-******************************************************************************/
+/*
+ * 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>
@@ -360,7 +372,7 @@ UINT8 DownloadPatchram( char *patchram1 )
     alarm(0);
     
 #if ( HIGH_SPEED_PATCHRAM_DOWNLOAD == TRUE )
-    ChangeBaudRate(921600);
+    ChangeBaudRate(3000000);
 #endif
 
     strcpy(prm, patchram1);