Remove Profile Build Dependency: do it at runtime 04/93404/5
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Tue, 29 Nov 2016 08:22:50 +0000 (17:22 +0900)
committerPyun DoHyun <dh79.pyun@samsung.com>
Mon, 5 Dec 2016 05:30:55 +0000 (21:30 -0800)
- This is for Tizen 4.0.

  : Tizen 4.0 Configurability and Build Blocks require
  to remove all profile-depending build options in spec files.
  (No More profile macros)

  : It is recommended to distinguish features/profiles at runtime.
 unless it incurs too much overhead, which requires you to
 create multiple binaries and subpackages.

  : Options not distinguished at runtime:
    TM1
    (Product only) Wearable.
    For non-production, the profile==wearable is not required.

- When you send SR of this commit, you need to create
JIRA-TRE issue of:

  . Add bluez-profile_mobile for mobile profile if it has bluez
  . Add bluez-profile_wearable for wearble profile if it has bluez
  . Add bluez-profile_tv for tv profile if it has bluez
  . Add bluez-profile_ivi for ivi profile if it has bluez
  . Add bluez-profile_common for common profile if it has bluez

Change-Id: Ia4cf6c31f574dd3c0323e5695e09b46b4472352d
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
12 files changed:
Makefile.am
Makefile.obexd
Makefile.plugins
Makefile.tools
configure.ac
lib/hci.h
obexd/plugins/messages-tizen.c
packaging/bluez.spec
profile.h [new file with mode: 0644]
profiles/audio/avdtp.c
src/device.c
tools/hciattach.c

index 39de339..9c12a5e 100644 (file)
@@ -191,7 +191,7 @@ src_bluetoothd_SOURCES = $(builtin_sources) \
 src_bluetoothd_LDADD = lib/libbluetooth-internal.la \
                        gdbus/libgdbus-internal.la \
                        src/libshared-glib.la \
-                       @BACKTRACE_LIBS@ @GLIB_LIBS@ @DBUS_LIBS@ -ldl -lrt
+                       @BACKTRACE_LIBS@ @GLIB_LIBS@ @DBUS_LIBS@ @CAPI_SYSTEM_INFO_LIBS@ -ldl -lrt
 src_bluetoothd_LDFLAGS = $(AM_LDFLAGS) -Wl,--export-dynamic \
                                -Wl,--version-script=$(srcdir)/src/bluetooth.ver
 
@@ -212,15 +212,9 @@ CLEANFILES += $(builtin_files) src/bluetooth.service
 
 man_MANS = src/bluetoothd.8
 
-if WEARABLE
 EXTRA_DIST += src/genbuiltin src/bluetooth.conf \
-                       src/main_w.conf profiles/network/network.conf \
+                       src/main_m.conf src/main_w.conf profiles/network/network.conf \
                        profiles/input/input.conf profiles/proximity/proximity.conf
-else
-EXTRA_DIST += src/genbuiltin src/bluetooth.conf \
-                       src/main_m.conf profiles/network/network.conf \
-                       profiles/input/input.conf profiles/proximity/proximity.conf
-endif
 
 test_scripts =
 unit_tests =
@@ -270,7 +264,7 @@ EXTRA_DIST += doc/pics-opp.txt doc/pixit-opp.txt \
 
 EXTRA_DIST += tools/magic.btsnoop
 
-AM_CFLAGS += @DBUS_CFLAGS@ @GLIB_CFLAGS@
+AM_CFLAGS += @DBUS_CFLAGS@ @GLIB_CFLAGS@ @CAPI_SYSTEM_INFO_CFLAGS@
 
 AM_CPPFLAGS = -I$(builddir)/lib
 
index 42135a9..83eb147 100644 (file)
@@ -82,11 +82,13 @@ obexd_src_obexd_SOURCES = $(btio_sources) $(gobex_sources) \
                        obexd/src/map_ap.h
 obexd_src_obexd_LDADD = lib/libbluetooth-internal.la \
                        gdbus/libgdbus-internal.la \
-                       @ICAL_LIBS@ @DBUS_LIBS@ @GLIB_LIBS@ -ldl
+                       @ICAL_LIBS@ @DBUS_LIBS@ @GLIB_LIBS@ \
+                       @CAPI_SYSTEM_INFO_LIBS@ -ldl
 
 obexd_src_obexd_LDFLAGS = -Wl,--export-dynamic
 
 obexd_src_obexd_CFLAGS = $(AM_CFLAGS) @GLIB_CFLAGS@ @DBUS_CFLAGS@ \
+                               @CAPI_SYSTEM_INFO_CFLAGS@ \
                                @ICAL_CFLAGS@ -DOBEX_PLUGIN_BUILTIN \
                                -DPLUGINDIR=\""$(obex_plugindir)"\" \
                                -fPIC -D_FILE_OFFSET_BITS=64 -pie
index 178eb31..abe387f 100644 (file)
@@ -151,6 +151,6 @@ if SIXAXIS
 plugin_LTLIBRARIES += plugins/sixaxis.la
 plugins_sixaxis_la_SOURCES = plugins/sixaxis.c
 plugins_sixaxis_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version \
-                                               -no-undefined @UDEV_LIBS@
-plugins_sixaxis_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden @UDEV_CFLAGS@
+                                               -no-undefined @UDEV_LIBS@ @CAPI_SYSTEM_INFO_LIBS@
+plugins_sixaxis_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden @UDEV_CFLAGS@ @CAPI_SYSTEM_INFO_CFLAGS@
 endif
index 115a240..45193d8 100644 (file)
@@ -166,7 +166,7 @@ tools_hciattach_SOURCES = tools/hciattach.c tools/hciattach.h \
                                                tools/hciattach_sprd.c \
                                                tools/pskey_get.c \
                                                tools/hciattach_bcm43xx.c
-tools_hciattach_LDADD = lib/libbluetooth-internal.la
+tools_hciattach_LDADD = lib/libbluetooth-internal.la @CAPI_SYSTEM_INFO_LIBS@
 
 tools_hciconfig_SOURCES = tools/hciconfig.c tools/csr.h tools/csr.c
 tools_hciconfig_LDADD = lib/libbluetooth-internal.la
index b199715..0363b14 100644 (file)
@@ -74,6 +74,10 @@ PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.6, dummy=yes,
 AC_SUBST(DBUS_CFLAGS)
 AC_SUBST(DBUS_LIBS)
 
+PKG_CHECK_MODULES(CAPI_SYSTEM_INFO, capi-system-info)
+AC_SUBST(CAPI_SYSTEM_INFO_CFLAGS)
+AC_SUBST(CAPI_SYSTEM_INFO_LIBS)
+
 AC_ARG_WITH([dbusconfdir], AC_HELP_STRING([--with-dbusconfdir=DIR],
                                [path to D-Bus configuration directory]),
                                        [path_dbusconfdir=${withval}])
index 549bacb..311390c 100644 (file)
--- a/lib/hci.h
+++ b/lib/hci.h
@@ -1791,7 +1791,6 @@ typedef struct {
 #define OGF_VENDOR_CMD         0x3f
 
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-#ifdef TIZEN_FEATURE_BLUEZ_BRCM_QOS
 #define BRCM_QOS_PRIORITY_NORMAL       0x00
 #define BRCM_QOS_PRIORITY_HIGH         0xFF
 #define BROADCOM_QOS_CMD       0xFC57  /* Only for bcm4329/bcm4330/bcm4334 chipsets */
@@ -1800,7 +1799,6 @@ typedef struct {
         uint8_t priority;
 } __attribute__ ((__packed__)) broadcom_qos_cp;
 #define BROADCOM_QOS_CP_SIZE 3
-#endif /* TIZEN_FEATURE_BLUEZ_BRCM_QOS */
 #endif /* TIZEN_FEATURE_BLUEZ_MODIFY */
 
 /* ---- HCI Events ---- */
index 8f684fc..e59c37b 100644 (file)
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include "log.h"
 #include "messages.h"
+#include "../../profile.h"
 
 #include <dbus/dbus.h>
 
@@ -1340,7 +1341,6 @@ int messages_get_message(void *session,
        return 1;
 }
 
-#ifndef TIZEN_FEATURE_BLUEZ_SMS_ONLY
 static void message_update_msg(DBusPendingCall *call, void *user_data)
 {
        DBusMessage *reply = dbus_pending_call_steal_reply(call);
@@ -1367,19 +1367,19 @@ static void message_update_msg(DBusPendingCall *call, void *user_data)
        dbus_message_unref(reply);
        DBG("-\n");
 }
-#endif
 
 int messages_update_inbox(void *session,
                                        messages_status_cb callback,
                                        void *user_data)
 {
-#ifdef TIZEN_FEATURE_BLUEZ_SMS_ONLY
-       /* MAP.TS.1.0.3 : TP/MMB/BV-16-I
-          Currently support is only for SMS, Since SMS service does not
-          allow the polling of its mailbox, it must return Not implemented */
+       if (TIZEN_FEATURE_BLUEZ_SMS_ONLY) {
+               /* MAP.TS.1.0.3 : TP/MMB/BV-16-I
+                  Currently support is only for SMS, Since SMS service does not
+                  allow the polling of its mailbox, it must return Not implemented */
+
+               return -ENOSYS;
+       }
 
-       return -ENOSYS;
-#else
        DBusPendingCall *call;
        DBusMessage *message;
        struct session *s = session;
@@ -1408,7 +1408,6 @@ int messages_update_inbox(void *session,
        dbus_message_unref(message);
        DBG("-\n");
        return 1;
-#endif
 }
 
 static void message_status_msg(DBusPendingCall *call, void *user_data)
index adcb7ea..21d1d12 100644 (file)
@@ -45,6 +45,9 @@ BuildRequires:  pkg-config
 BuildRequires:  readline-devel
 BuildRequires:  udev
 BuildRequires:  pkgconfig(libtzplatform-config)
+BuildRequires:  pkgconfig(capi-system-info)
+Requires:      %{name}-compat = %{version}-%{release}
+Recommends:    %{name}-profile_common = %{version}-%{release}
 
 %description
 The Bluetooth stack for Linux.
@@ -87,6 +90,32 @@ Requires:       python-gobject
 Contains a few tools for testing various bluetooth functions. The
 BLUETOOTH trademarks are owned by Bluetooth SIG, Inc., U.S.A.
 
+%package profile_common
+Summary:       Modified bluez for mobile/common profile
+Provides:      %{name}-compat = %{version}-%{release}
+Provides:      %{name}-profile_mobile = %{version}-%{release}
+Provides:      %{name}-profile_ivi = %{version}-%{release}
+Conflicts:     %{name}-profile_wearable
+Conflicts:     %{name}-profile_tv
+%description profile_common
+Bluez default service script for Tizen (mobile/common profile)
+
+%package profile_wearable
+Summary:       Modified bluez for wearable profile
+Provides:      %{name}-compat = %{version}-%{release}
+Conflicts:     %{name}-profile_common
+Conflicts:     %{name}-profile_tv
+%description profile_wearable
+Bluez modified service script for Tizen wearable
+
+%package profile_tv
+Summary:       Modified bluez for wearable profile
+Provides:      %{name}-compat = %{version}-%{release}
+Conflicts:     %{name}-profile_common
+Conflicts:     %{name}-profile_wearable
+%description profile_tv
+Bluez modified service script for Tizen TV
+
 %prep
 %setup -q
 cp %{SOURCE1001} .
@@ -94,20 +123,26 @@ cp %{SOURCE1001} .
 %build
 autoreconf -fiv
 
-%if "%{?tizen_target_name}" == "TM1" || "%{?profile}" == "ivi"
 %if "%{?tizen_target_name}" == "TM1"
 export CFLAGS="${CFLAGS} -DTIZEN_FEATURE_BLUEZ_SPRD_QOS -DTIZEN_FEATURE_BLUEZ_SPRD_PAGE_SCAN"
-%endif
-%else
-export CFLAGS="${CFLAGS} -DTIZEN_FEATURE_BLUEZ_BRCM_CHIP"
+# TIZEN_FEATURE_BLUEZ_SPRD_QOS: only in profiles/audio/avdtp.c
+# TIZEN_FEATURE_BLUEZ_SPRD_PAGE_SCAN: src/adapter.c
 %endif
 
-%if "%{?profile}" == "wearable"
-export CFLAGS="${CFLAGS} -DTIZEN_FEATURE_BLUEZ_SMS_ONLY -DTIZEN_FEATURE_BLUEZ_BRCM_QOS -DTIZEN_FEATURE_BLUEZ_ROLE_CHANGE -DTIZEN_FEATURE_BLUEZ_CONFIRM_ONLY"
-%endif
+#if "{?profile}" == "ivi"
+# TIZEN_FEATURE_BLUEZ_BRCM_CHIP: only in tools/hciattach.c ==> RUNTIME! (profile.h)
+#endif
+
+#if "{?profile}" == "wearable"
+# TIZEN_FEATURE_BLUEZ_SMS_ONLY: only in obexd/plugins/messages-tizen.c ==> RUNTIME! (profile.h)
+# TIZEN_FEATURE_BLUEZ_BRCM_QOS: only in profiles/audio/avdtp.c ==> RUNTIME! (profile.h)
+# TIZEN_FEATURE_BLUEZ_ROLE_CHANGE: only in profiles/audio/avdtp.c ==> RUNTIME! (profile.h)
+# TIZEN_FEATURE_BLUEZ_CONFIRM_ONLY: only in src/device.c ==> RUNTIME! (profile.h)
+#endif
 
 export LDFLAGS=" -lncurses -Wl,--as-needed "
 export CFLAGS+=" -DTIZEN_FEATURE_BLUEZ_MODIFY -DTIZEN_FEATURE_BLUEZ_PBAP_SIM -DTIZEN_FEATURE_BLUEZ_AVRCP_TARGET"
+
 %reconfigure --disable-static \
                        --sysconfdir=%{_sysconfdir} \
                        --localstatedir=%{_localstatedir} \
@@ -139,11 +174,15 @@ export CFLAGS+=" -DTIZEN_FEATURE_BLUEZ_MODIFY -DTIZEN_FEATURE_BLUEZ_PBAP_SIM -DT
                        --enable-autopair=no \
 %if "%{?profile}" == "wearable"
                         --enable-wearable \
-%else
-                       --enable-network \
 %endif
                        --enable-hid=yes \
                        --enable-tizenunusedplugin=no
+# The if/endif for wearable above if only for PRODUCT optimization
+
+# enable-wearable disables "TIZEN_HID_PLUGIN / TIZEN_UNUSED_PLUGIN" (input / hog)
+# TIZEN_UNUSED_PLUGIN is "no" regardless of enable-wearable.
+# TIZEN_HID_PLUGIN only matters.
+# enable-network is not used in configure.
 
 
 make %{?_smp_mflags} all V=1
@@ -162,11 +201,8 @@ install --mode=0644 -D %{S:7} $RPM_BUILD_ROOT/%{_sysconfdir}/modprobe.d/50-bluet
 # no idea why this is suddenly necessary...
 install --mode 0755 -d $RPM_BUILD_ROOT/var/lib/bluetooth
 
-%if "%{?profile}" == "wearable"
-install -D -m 0644 src/main_w.conf %{buildroot}%{_sysconfdir}/bluetooth/main.conf
-%else
+install -D -m 0644 src/main_w.conf %{buildroot}%{_sysconfdir}/bluetooth/main.conf.wearable
 install -D -m 0644 src/main_m.conf %{buildroot}%{_sysconfdir}/bluetooth/main.conf
-%endif
 
 
 #install -D -m 0644 src/bluetooth.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/bluetooth.conf
@@ -192,11 +228,11 @@ install -D -m 0755 attrib/gatttool $RPM_BUILD_ROOT/%{_bindir}/
 install -D -m 0755 tools/obexctl %{buildroot}%{_bindir}/obexctl
 
 #test
-%if "%{?profile}" == "tv"
+#if "tv"
 mkdir -p %{buildroot}%{_libpath}/systemd/system/multi-user.target.wants/
 ln -sf bluetooth.service %{buildroot}%{_libpath}/systemd/system/dbus-org.bluez.service
 ln -sf ../bluetooth-frwk.service %{buildroot}%{_libpath}/systemd/system/multi-user.target.wants/bluetooth.service
-%endif
+#endif
 
 mkdir -p %{buildroot}%{upgrade_script_path}
 cp -f packaging/bluetoothd_upgrade.sh %{buildroot}%{upgrade_script_path}
@@ -210,7 +246,6 @@ cp -f packaging/bluetoothd_upgrade.sh %{buildroot}%{upgrade_script_path}
 %defattr(-, root, root)
 %license COPYING
 #%{_sysconfdir}/bluetooth/audio.conf
-%{_sysconfdir}/bluetooth/main.conf
 #%{_sysconfdir}/bluetooth/network.conf
 #%{_sysconfdir}/bluetooth/rfcomm.conf
 #%{_sysconfdir}/dbus-1/system.d/bluetooth.conf
@@ -234,16 +269,9 @@ cp -f packaging/bluetoothd_upgrade.sh %{buildroot}%{upgrade_script_path}
 %{upgrade_script_path}/bluetoothd_upgrade.sh
 
 #test -2
-%if "%{?profile}" == "tv"
-%{_libpath}/systemd/system/bluetooth.service
-%{_libpath}/systemd/system/multi-user.target.wants/bluetooth.service
-%{_libpath}/systemd/system/dbus-org.bluez.service
-%{_datadir}/dbus-1/system-services/org.bluez.service
-%else
 %exclude /%{_libpath}/systemd/system/bluetooth.service
 %exclude %{_libpath}/systemd/system/multi-user.target.wants/bluetooth.service
 %exclude /%{_datadir}/dbus-1/system-services/org.bluez.service
-%endif
 %config %{_sysconfdir}/dbus-1/system.d/bluetooth.conf
 %dir /var/lib/bluetooth
 %dir %{_sysconfdir}/modprobe.d
@@ -298,4 +326,21 @@ cp -f packaging/bluetoothd_upgrade.sh %{buildroot}%{upgrade_script_path}
 
 %docs_package
 
+%post profile_wearable
+ln -sf main.conf.wearable %{_sysconfdir}/bluetooth/main.conf
+%preun profile_wearable
+rm %{_sysconfdir}/bluetooth/main.conf
+%files profile_wearable
+%{_sysconfdir}/bluetooth/main.conf.wearable
+
+%files profile_tv
+%{_sysconfdir}/bluetooth/main.conf
+%{_libpath}/systemd/system/bluetooth.service
+%{_libpath}/systemd/system/multi-user.target.wants/bluetooth.service
+%{_libpath}/systemd/system/dbus-org.bluez.service
+%{_datadir}/dbus-1/system-services/org.bluez.service
+
+%files profile_common
+%{_sysconfdir}/bluetooth/main.conf
+
 %changelog
diff --git a/profile.h b/profile.h
new file mode 100644 (file)
index 0000000..a2019e2
--- /dev/null
+++ b/profile.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd 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.
+ */
+
+#ifndef __TIZEN_PROFILE_H__
+#define __TIZEN_PROFILE_H__
+
+#include <stdlib.h>
+#include <system_info.h>
+
+typedef enum {
+       TIZEN_PROFILE_UNKNOWN = 0,
+       TIZEN_PROFILE_MOBILE = 0x1,
+       TIZEN_PROFILE_WEARABLE = 0x2,
+       TIZEN_PROFILE_TV = 0x4,
+       TIZEN_PROFILE_IVI = 0x8,
+       TIZEN_PROFILE_COMMON = 0x10,
+} tizen_profile_t;
+
+static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
+static inline tizen_profile_t _get_tizen_profile()
+{
+       char *profileName;
+
+       if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
+               return profile;
+
+       system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+       switch (*profileName) {
+               case 'm':
+               case 'M':
+                       profile = TIZEN_PROFILE_MOBILE;
+                       break;
+               case 'w':
+               case 'W':
+                       profile = TIZEN_PROFILE_WEARABLE;
+                       break;
+               case 't':
+               case 'T':
+                       profile = TIZEN_PROFILE_TV;
+                       break;
+               case 'i':
+               case 'I':
+                       profile = TIZEN_PROFILE_IVI;
+                       break;
+               default: // common or unknown ==> ALL ARE COMMON.
+                       profile = TIZEN_PROFILE_COMMON;
+       }
+       free(profileName);
+
+       return profile;
+}
+#define TIZEN_FEATURE_BLUEZ_BRCM_CHIP ((_get_tizen_profile()) == TIZEN_PROFILE_IVI)
+#define TIZEN_FEATURE_BLUEZ_SMS_ONLY ((_get_tizen_profile()) == TIZEN_PROFILE_WEARABLE)
+#define TIZEN_FEATURE_BLUEZ_BRCM_QOS ((_get_tizen_profile()) == TIZEN_PROFILE_WEARABLE)
+#define TIZEN_FEATURE_BLUEZ_ROLE_CHANGE ((_get_tizen_profile()) == TIZEN_PROFILE_WEARABLE)
+#define TIZEN_FEATURE_BLUEZ_CONFIRM_ONLY ((_get_tizen_profile()) == TIZEN_PROFILE_WEARABLE)
+
+
+#endif /* __TIZEN_PROFILE_H__ */
+
index df54a41..ed06f01 100644 (file)
 #include "lib/uuid.h"
 
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-#if defined(TIZEN_FEATURE_BLUEZ_BRCM_QOS) || defined(TIZEN_FEATURE_BLUEZ_SPRD_QOS)
 #include <sys/ioctl.h>
 #include <bluetooth/hci.h>
-#endif /* TIZEN_FEATURE_BLUEZ_BRCM_QOS */
 #endif /* TIZEN_FEATURE_BLUEZ_MODIFY */
 
 #include "btio/btio.h"
@@ -62,6 +60,7 @@
 #include "avdtp.h"
 #include "sink.h"
 #include "source.h"
+#include "../../profile.h"
 
 #define AVDTP_PSM 25
 
@@ -966,7 +965,6 @@ static void handle_unanswered_req(struct avdtp *session,
 }
 
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-#ifdef TIZEN_FEATURE_BLUEZ_BRCM_QOS
 static gboolean send_broadcom_a2dp_qos(const bdaddr_t *dst, gboolean qos_high)
 {
        int dd;
@@ -1012,7 +1010,6 @@ static gboolean send_broadcom_a2dp_qos(const bdaddr_t *dst, gboolean qos_high)
 
        return TRUE;
 }
-#endif /* TIZEN_FEATURE_BLUEZ_BRCM_QOS */
 
 #ifdef TIZEN_FEATURE_BLUEZ_SPRD_QOS
 static gboolean send_sprd_a2dp_qos(bdaddr_t *dst, gboolean qos_high)
@@ -1069,7 +1066,6 @@ static gboolean send_sprd_a2dp_qos(bdaddr_t *dst, gboolean qos_high)
 }
 #endif /* TIZEN_FEATURE_BLUEZ_SPRD_QOS */
 
-#ifdef TIZEN_FEATURE_BLUEZ_ROLE_CHANGE
 static gboolean fix_role_to_master(const bdaddr_t *dst, gboolean fix_to_master)
 {
        int dd;
@@ -1128,7 +1124,6 @@ static gboolean fix_role_to_master(const bdaddr_t *dst, gboolean fix_to_master)
 
        return TRUE;
 }
-#endif /* TIZEN_FEATURE_BLUEZ_ROLE_CHANGE */
 #endif /* TIZEN_FEATURE_BLUEZ_MODIFY */
 
 static void avdtp_sep_set_state(struct avdtp *session,
@@ -1137,10 +1132,12 @@ static void avdtp_sep_set_state(struct avdtp *session,
 {
        struct avdtp_stream *stream = sep->stream;
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-#if (defined(TIZEN_FEATURE_BLUEZ_BRCM_QOS) || defined(TIZEN_FEATURE_BLUEZ_ROLE_CHANGE)) || \
-       defined(TIZEN_FEATURE_BLUEZ_SPRD_QOS)
        const bdaddr_t *dst;
+#if defined(TIZEN_FEATURE_BLUEZ_SPRD_QOS)
        dst = device_get_address(session->device);
+#else
+       if (TIZEN_FEATURE_BLUEZ_BRCM_QOS || TIZEN_FEATURE_BLUEZ_ROLE_CHANGE)
+               dst = device_get_address(session->device);
 #endif
 #endif
        avdtp_state_t old_state;
@@ -1174,15 +1171,16 @@ static void avdtp_sep_set_state(struct avdtp *session,
        case AVDTP_STATE_OPEN:
                stream->starting = FALSE;
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-#ifdef TIZEN_FEATURE_BLUEZ_BRCM_QOS
-               send_broadcom_a2dp_qos(dst, FALSE);
-#elif defined(TIZEN_FEATURE_BLUEZ_SPRD_QOS)
-               if (old_state == AVDTP_STATE_STREAMING)
-                       send_sprd_a2dp_qos(dst, FALSE);
+               if (TIZEN_FEATURE_BLUEZ_BRCM_QOS) {
+                       send_broadcom_a2dp_qos(dst, FALSE);
+               } else {
+#if defined(TIZEN_FEATURE_BLUEZ_SPRD_QOS)
+                       if (old_state == AVDTP_STATE_STREAMING)
+                               send_sprd_a2dp_qos(dst, FALSE);
 #endif
-#ifdef TIZEN_FEATURE_BLUEZ_ROLE_CHANGE
-               fix_role_to_master(dst, FALSE);
-#endif /* TIZEN_FEATURE_BLUEZ_ROLE_CHANGE */
+               }
+               if (TIZEN_FEATURE_BLUEZ_ROLE_CHANGE)
+                       fix_role_to_master(dst, FALSE);
 #endif /* TIZEN_FEATURE_BLUEZ_MODIFY */
 
                break;
@@ -1193,15 +1191,16 @@ static void avdtp_sep_set_state(struct avdtp *session,
                }
 
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-#ifdef TIZEN_FEATURE_BLUEZ_BRCM_QOS
-               send_broadcom_a2dp_qos(dst, TRUE);
-#elif defined(TIZEN_FEATURE_BLUEZ_SPRD_QOS)
-               if (old_state == AVDTP_STATE_OPEN)
-                       send_sprd_a2dp_qos(dst, TRUE);
+               if (TIZEN_FEATURE_BLUEZ_BRCM_QOS) {
+                       send_broadcom_a2dp_qos(dst, TRUE);
+               } else {
+#if defined(TIZEN_FEATURE_BLUEZ_SPRD_QOS)
+                       if (old_state == AVDTP_STATE_OPEN)
+                               send_sprd_a2dp_qos(dst, TRUE);
 #endif
-#ifdef TIZEN_FEATURE_BLUEZ_ROLE_CHANGE
-               fix_role_to_master(dst, TRUE);
-#endif /* TIZEN_FEATURE_BLUEZ_ROLE_CHANGE */
+               }
+               if (TIZEN_FEATURE_BLUEZ_ROLE_CHANGE)
+                       fix_role_to_master(dst, TRUE);
 #endif /* TIZEN_FEATURE_BLUEZ_MODIFY */
                stream->open_acp = FALSE;
                break;
index 618d5bb..377e51a 100644 (file)
@@ -75,6 +75,7 @@
 #include "storage.h"
 #include "attrib-server.h"
 #include "eir.h"
+#include "../profile.h"
 
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
 #include "sdp-xml.h"
@@ -7837,12 +7838,10 @@ int device_confirm_passkey(struct btd_device *device, uint32_t passkey,
 
        auth->passkey = passkey;
 
-#ifndef TIZEN_FEATURE_BLUEZ_CONFIRM_ONLY
-       if (confirm_hint)
+       if (!TIZEN_FEATURE_BLUEZ_CONFIRM_ONLY && confirm_hint)
                err = agent_request_authorization(auth->agent, device,
                                                confirm_cb, auth, NULL);
        else
-#endif
                err = agent_request_confirmation(auth->agent, device, passkey,
                                                confirm_cb, auth, NULL);
 
index 2ef6fb5..0aa4e3b 100644 (file)
@@ -50,6 +50,7 @@
 #include "lib/hci_lib.h"
 
 #include "hciattach.h"
+#include "../profile.h"
 
 struct uart_t {
        char *type;
@@ -75,7 +76,7 @@ struct uart_t {
 #endif
 
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-#if defined(__TI_PATCH__) || defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
+#if defined(__TI_PATCH__) || 1
 #define TIOSETBRFPOWER         0x6000
 #define BRF_DEEP_SLEEP_OPCODE_BYTE_1   0x0c
 #define BRF_DEEP_SLEEP_OPCODE_BYTE_2   0xfd
@@ -1023,76 +1024,78 @@ static int bcm2035(int fd, struct uart_t *u, struct termios *ti)
        memset(resp, 0, sizeof(resp));
 
 /* TIZEN_FEATURE_BLUEZ_MODIFY */
-#if defined(TIZEN_FEATURE_BLUEZ_MODIFY) && !defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
-       cmd[0] = HCI_COMMAND_PKT;
-       cmd[1] = 0x18;
-       cmd[2] = 0xfc;
-       cmd[3] = 0x02;
-       switch (u->speed) {
-       case 57600:
-               cmd[4] = 0x00;
-               cmd[5] = 0xe6;
-               break;
-       case 230400:
-               cmd[4] = 0x22;
-               cmd[5] = 0xfa;
-               break;
-       case 460800:
-               cmd[4] = 0x22;
-               cmd[5] = 0xfd;
-               break;
-       case 921600:
-               cmd[4] = 0x55;
-               cmd[5] = 0xff;
-               break;
-       default:
-               /* Default is 115200 */
-               cmd[4] = 0x00;
-               cmd[5] = 0xf3;
-               break;
-       }
-       fprintf(stderr, "Baud rate parameters: DHBR=0x%2x,DLBR=0x%2x\n",
-               cmd[4], cmd[5]);
+#if defined(TIZEN_FEATURE_BLUEZ_MODIFY)
+       if (TIZEN_FEATURE_BLUEZ_BRCM_CHIP) {
+               cmd[0] = HCI_COMMAND_PKT;
+               cmd[1] = 0x18;
+               cmd[2] = 0xfc;
+               cmd[3] = 0x02;
+               switch (u->speed) {
+               case 57600:
+                       cmd[4] = 0x00;
+                       cmd[5] = 0xe6;
+                       break;
+               case 230400:
+                       cmd[4] = 0x22;
+                       cmd[5] = 0xfa;
+                       break;
+               case 460800:
+                       cmd[4] = 0x22;
+                       cmd[5] = 0xfd;
+                       break;
+               case 921600:
+                       cmd[4] = 0x55;
+                       cmd[5] = 0xff;
+                       break;
+               default:
+                       /* Default is 115200 */
+                       cmd[4] = 0x00;
+                       cmd[5] = 0xf3;
+                       break;
+               }
+               fprintf(stderr, "Baud rate parameters: DHBR=0x%2x,DLBR=0x%2x\n",
+                       cmd[4], cmd[5]);
 
-       /* Send command */
-       if (write(fd, cmd, 6) != 6) {
-               fprintf(stderr, "Failed to write \"set baud rate\" command\n");
-               return -1;
-       }
-#else
-       cmd[0] = HCI_COMMAND_PKT;
-       cmd[1] = 0x18;
-       cmd[2] = 0xfc;
+               /* Send command */
+               if (write(fd, cmd, 6) != 6) {
+                       fprintf(stderr, "Failed to write \"set baud rate\" command\n");
+                       return -1;
+               }
+       } else
+#endif
+       {
+               cmd[0] = HCI_COMMAND_PKT;
+               cmd[1] = 0x18;
+               cmd[2] = 0xfc;
 
-       switch (u->speed) {
-       case 57600:
-       case 230400:
-       case 460800:
-       case 921600:
-       case 3000000:
-               break;
-       default:
-               break;
-       }
+               switch (u->speed) {
+               case 57600:
+               case 230400:
+               case 460800:
+               case 921600:
+               case 3000000:
+                       break;
+               default:
+                       break;
+               }
 
-       cmd[3] = 0x06;
-       cmd[4] = 0x00;
-       cmd[5] = 0x00;
-       cmd[6] = u->speed & 0xFF;
-       cmd[7] = (u->speed >> 8) & 0xFF;
-       cmd[8] = (u->speed >> 16) & 0xFF;
-       cmd[9] = (u->speed >> 24) & 0xFF;
+               cmd[3] = 0x06;
+               cmd[4] = 0x00;
+               cmd[5] = 0x00;
+               cmd[6] = u->speed & 0xFF;
+               cmd[7] = (u->speed >> 8) & 0xFF;
+               cmd[8] = (u->speed >> 16) & 0xFF;
+               cmd[9] = (u->speed >> 24) & 0xFF;
 
-       fprintf(stderr, "Set the baud rate %d : 0x%02x,0x%02x,0x%02x,0x%02x\n",u->speed,cmd[6],cmd[7],cmd[8],cmd[9] );
+               fprintf(stderr, "Set the baud rate %d : 0x%02x,0x%02x,0x%02x,0x%02x\n",u->speed,cmd[6],cmd[7],cmd[8],cmd[9] );
 
-       /* Send command */
-       if (write(fd, cmd, 10) != 10) {
-               fprintf(stderr, "Failed to write \"set baud rate\" command\n");
-               return -1;
+               /* Send command */
+               if (write(fd, cmd, 10) != 10) {
+                       fprintf(stderr, "Failed to write \"set baud rate\" command\n");
+                       return -1;
+               }
        }
 
-#endif
-
        if ((n = read_hci_event(fd, resp, 6)) < 0) {
                fprintf(stderr, "Failed to set baud rate\n");
                return -1;
@@ -1260,7 +1263,7 @@ static struct uart_t * get_by_type(char *type)
        return NULL;
 }
 
-#if defined TIZEN_FEATURE_BLUEZ_MODIFY && defined TIZEN_FEATURE_BLUEZ_BRCM_CHIP
+#if defined TIZEN_FEATURE_BLUEZ_MODIFY
 static int enable_hci(char *dev, struct uart_t *u)
 {
        int fd, i;
@@ -1298,8 +1301,7 @@ static int enable_hci(char *dev, struct uart_t *u)
 
        return fd;
 }
-
-#else  /* TIZEN_FEATURE_BLUEZ_BRCM_CHIP */
+#endif /* TIZEN_FEATURE_BLUEZ_MODIFY */
 
 /* Initialize UART driver */
 static int init_uart(char *dev, struct uart_t *u, int send_break, int raw)
@@ -1310,7 +1312,7 @@ static int init_uart(char *dev, struct uart_t *u, int send_break, int raw)
 
 /* TIZEN_FEATURE_BLUEZ_MODIFY */
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-#if defined(__TI_PATCH__) || defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
+#if defined(__TI_PATCH__) || 1
        int power;
 #endif
 #endif
@@ -1337,12 +1339,14 @@ static int init_uart(char *dev, struct uart_t *u, int send_break, int raw)
        cfmakeraw(&ti);
 
 /* TIZEN_FEATURE_BLUEZ_MODIFY */
-#if defined(TIZEN_FEATURE_BLUEZ_MODIFY) && !defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
-       ti.c_cflag |= CLOCAL;
-       if (u->flags & FLOW_CTL)
-               ti.c_cflag |= CRTSCTS;
-       else
-               ti.c_cflag &= ~CRTSCTS;
+#if defined(TIZEN_FEATURE_BLUEZ_MODIFY)
+       if (!TIZEN_FEATURE_BLUEZ_BRCM_CHIP) {
+               ti.c_cflag |= CLOCAL;
+               if (u->flags & FLOW_CTL)
+                       ti.c_cflag |= CRTSCTS;
+               else
+                       ti.c_cflag &= ~CRTSCTS;
+       }
 #endif
 
        if (tcsetattr(fd, TCSANOW, &ti) < 0) {
@@ -1365,10 +1369,16 @@ static int init_uart(char *dev, struct uart_t *u, int send_break, int raw)
 
 /* TIZEN_FEATURE_BLUEZ_MODIFY */
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-#if defined(__TI_PATCH__) || defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
+#if defined(__TI_PATCH__)
        /* Power up the BRF chip */
        power = 1;
        ioctl(fd, TIOSETBRFPOWER, &power);
+#else
+       if (TIZEN_FEATURE_BLUEZ_BRCM_CHIP) {
+               /* Power up the BRF chip */
+               power = 1;
+               ioctl(fd, TIOSETBRFPOWER, &power);
+       }
 #endif
 #ifdef __TI_PATCH__
        usleep(500000);
@@ -1415,8 +1425,6 @@ fail:
        return -1;
 }
 
-#endif /* TIZEN_FEATURE_BLUEZ_BRCM_CHIP */
-
 static void usage(void)
 {
        printf("hciattach - HCI UART driver initialization utility\n");
@@ -1441,14 +1449,14 @@ static void usage(void)
 int main(int argc, char *argv[])
 {
        struct uart_t *u = NULL;
-#if defined(TIZEN_FEATURE_BLUEZ_MODIFY) && !defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
+#if defined(TIZEN_FEATURE_BLUEZ_MODIFY)
        int detach, printpid, raw, opt, i, n, ld, err;
 #else
        int detach, printpid, opt, i, n, ld, err;
 #endif
        int to = 10;
        int init_speed = 0;
-#if defined(TIZEN_FEATURE_BLUEZ_MODIFY) && !defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
+#if defined(TIZEN_FEATURE_BLUEZ_MODIFY)
        int send_break = 0;
 #endif
        pid_t pid;
@@ -1458,8 +1466,8 @@ int main(int argc, char *argv[])
        char dev[PATH_MAX];
 
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+#if defined(__TI_PATCH__) || 1
 /* TIZEN_FEATURE_BLUEZ_MODIFY */
-#if defined(__TI_PATCH__) || defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
        int power;
 #endif
 #endif
@@ -1470,7 +1478,7 @@ int main(int argc, char *argv[])
 #endif
        detach = 1;
        printpid = 0;
-#if defined(TIZEN_FEATURE_BLUEZ_MODIFY) && !defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
+#if defined(TIZEN_FEATURE_BLUEZ_MODIFY)
        raw = 0;
 #endif
 #if defined(TIZEN_FEATURE_BLUEZ_MODIFY) && !defined(__TI_PATCH__)
@@ -1480,8 +1488,9 @@ int main(int argc, char *argv[])
 #endif
                switch(opt) {
                case 'b':
-#if defined(TIZEN_FEATURE_BLUEZ_MODIFY) && !defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
-                       send_break = 1;
+#if defined(TIZEN_FEATURE_BLUEZ_MODIFY)
+                       if (!TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
+                               send_break = 1;
 #endif
                        break;
 
@@ -1523,8 +1532,9 @@ int main(int argc, char *argv[])
                        exit(0);
 
                case 'r':
-#if defined(TIZEN_FEATURE_BLUEZ_MODIFY) && !defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
-                       raw = 1;
+#if defined(TIZEN_FEATURE_BLUEZ_MODIFY)
+                       if (!TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
+                               raw = 1;
 #endif
                        break;
 
@@ -1647,8 +1657,11 @@ int main(int argc, char *argv[])
        /* 10 seconds should be enough for initialization */
        alarm(to);
        bcsp_max_retries = to;
-#if defined TIZEN_FEATURE_BLUEZ_MODIFY && defined TIZEN_FEATURE_BLUEZ_BRCM_CHIP
-       n = enable_hci(dev, u);
+#if defined TIZEN_FEATURE_BLUEZ_MODIFY
+       if (TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
+               n = enable_hci(dev, u);
+       else
+               n = init_uart(dev, u, send_break, raw);
 #else
        n = init_uart(dev, u, send_break, raw);
 #endif
@@ -1714,10 +1727,16 @@ int main(int argc, char *argv[])
 
 /* TIZEN_FEATURE_BLUEZ_MODIFY */
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-#if defined(__TI_PATCH__) || defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
+#if defined(__TI_PATCH__)
        /* Power down the BRF or BCMchip */
        power = 0;
        ioctl(n, TIOSETBRFPOWER, &power);
+#else
+       if (TIZEN_FEATURE_BLUEZ_BRCM_CHIP) {
+               /* Power down the BRF or BCMchip */
+               power = 0;
+               ioctl(n, TIOSETBRFPOWER, &power);
+       }
 #endif
 #endif
        return 0;