Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH v4] android: Add support for Valgrind in debug variants
From: Andrzej Kaczmarek @ 2014-02-11 14:28 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek

This patch allows bluetoothd to be run with Valgrind easily in debug
variants.

For userdebug and eng variants bluetoothd is renamed to bluetoothd-main
and bluetoothd acts a wrapper to launch it either with or without
Valgrind (this is decided by value of persist.sys.bluetooth.valgrind
property).
---
 android/Android.mk           | 42 ++++++++++++++++++++++++
 android/bluetoothd-wrapper.c | 76 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 118 insertions(+)
 create mode 100644 android/bluetoothd-wrapper.c

diff --git a/android/Android.mk b/android/Android.mk
index b82ef84..84e96fe 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -91,7 +91,15 @@ $(shell mkdir -p $(LOCAL_PATH)/bluez/lib/bluetooth)
 $(foreach file,$(lib_headers), $(shell ln -sf ../$(file) $(LOCAL_PATH)/bluez/lib/bluetooth/$(file)))
 
 LOCAL_MODULE_TAGS := optional
+
+# for userdebug/eng this module is bluetoothd-main since bluetoothd is used as
+# wrapper to launch bluetooth with Valgrind
+ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
+LOCAL_MODULE := bluetoothd-main
+LOCAL_STRIP_MODULE := false
+else
 LOCAL_MODULE := bluetoothd
+endif
 
 include $(BUILD_EXECUTABLE)
 
@@ -415,3 +423,37 @@ LOCAL_CFLAGS:= \
 LOCAL_MODULE := libsbc
 
 include $(BUILD_SHARED_LIBRARY)
+
+ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
+
+#
+# bluetoothd (debug)
+# this is just a wrapper used in userdebug/eng to launch bluetoothd-main
+# with/without Valgrind
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	bluez/android/bluetoothd-wrapper.c
+
+LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
+
+LOCAL_SHARED_LIBRARIES := \
+	libcutils \
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := bluetoothd
+
+LOCAL_REQUIRED_MODULES := \
+	bluetoothd-main \
+	valgrind \
+	memcheck-$(TARGET_ARCH)-linux \
+	vgpreload_core-$(TARGET_ARCH)-linux \
+	vgpreload_memcheck-$(TARGET_ARCH)-linux \
+	default.supp
+
+include $(BUILD_EXECUTABLE)
+
+endif
\ No newline at end of file
diff --git a/android/bluetoothd-wrapper.c b/android/bluetoothd-wrapper.c
new file mode 100644
index 0000000..122e6b0
--- /dev/null
+++ b/android/bluetoothd-wrapper.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <cutils/properties.h>
+
+#define PROPERTY_NAME "persist.sys.bluetooth.valgrind"
+
+#define VALGRIND_BIN "/system/bin/valgrind"
+
+#define BLUETOOTHD_BIN "/system/bin/bluetoothd-main"
+
+static void run_valgrind(void)
+{
+	char *prg_argv[4];
+	char *prg_envp[3];
+
+	prg_argv[0] = VALGRIND_BIN;
+	prg_argv[1] = "--leak-check=full";
+	prg_argv[2] = BLUETOOTHD_BIN;
+	prg_argv[3] = NULL;
+
+	prg_envp[0] = "G_SLICE=always-malloc";
+	prg_envp[1] = "G_DEBUG=gc-friendly";
+	prg_envp[2] = NULL;
+
+	execve(prg_argv[0], prg_argv, prg_envp);
+}
+
+static void run_bluetoothd(void)
+{
+	char *prg_argv[2];
+	char *prg_envp[1];
+
+	prg_argv[0] = BLUETOOTHD_BIN;
+	prg_argv[1] = NULL;
+
+	prg_envp[0] = NULL;
+
+	execve(prg_argv[0], prg_argv, prg_envp);
+}
+
+int main(int argc, char *argv[])
+{
+	char value[PROPERTY_VALUE_MAX];
+
+	if (property_get(PROPERTY_NAME, value, "") > 0 &&
+			(!strcasecmp(value, "true") || atoi(value) > 0))
+		run_valgrind();
+
+	/* In case we failed to execute Valgrind, try to run bluetoothd
+	 * without it
+	 */
+
+	run_bluetoothd();
+
+	return 0;
+}
-- 
1.8.5.3


^ permalink raw reply related

* AW: Bluetooth with full AMP
From: Viswanatham, RaviTeja @ 2014-02-11 13:38 UTC (permalink / raw)
  To: Andrei Emeltchenko
  Cc: Marcel Holtmann,
	bluez mailin list (linux-bluetooth@vger.kernel.org),
	bzhao@marvell.com
In-Reply-To: <20140211122616.GF8980@aemeltch-MOBL1>



-----Urspr=FCngliche Nachricht-----
Von: linux-bluetooth-owner@vger.kernel.org [mailto:linux-bluetooth-owner@vg=
er.kernel.org] Im Auftrag von Andrei Emeltchenko
Gesendet: Dienstag, 11. Februar 2014 13:27
An: Viswanatham, RaviTeja
Cc: Marcel Holtmann; bluez mailin list (linux-bluetooth@vger.kernel.org); b=
zhao@marvell.com
Betreff: Re: Bluetooth with full AMP

Hi Raviteja,

> On Mon, Feb 10, 2014 at 10:35:24AM -0800, Marcel Holtmann wrote:
> > Hi Ravi,
> >=20
> > > I am working on Ubuntu 12.04 with a Bluetooth 3.0 +HS + wifi combo=20
> > > USB dongle.
> > >=20
> > > I want to reach a data transfer speed of up to 24 Mbit/s.=20
> > >=20
> > > My Questions: Does Bluez support high speed data transfer rates up=20
> > > to
> > > 24 Mbit/s (Bluetooth 3.0+HS) ?=20
> > >=20
> > > If it does, is there any user configuration involved to achieve that?
> > > What other requirements need to be met?  Does, Bluetooth enables=20
> > > AMP function to communicate 802.11n channel to support high speed=20
> > > or it has to be configure with any other drivers?
> > >=20
> > > I am new to Linux a detail explanation would be really appreciated.
> > > Thank you in advance for your support.
> >=20
> > we do support Bluetooth HS operation. However your WiFi device needs=20
> > to be exposed as AMP Controller. Most WiFi hardware needs a special=20
> > driver to expose itself as AMP Controller. There is no generic=20
> > driver for mac80211 subsystem in the kernel.
>=20
> Some devices have AMP Controller implemented in firmware.  I was using=20
> Marvell SD8787, probably newer Marvell devices also works.
>=20
> You may check drivers/bluetooth/btmrvl_main.c to see how HCI dev_type=20
> HCI_AMP is assigned.
>=20
> Thanks for replying me. I would like to know some more information=20
> about the Bluetooth dongle. As you said the Marvell SD8787 is kind of=20
> a SoC chipset. Is there any USB Bluetooth  device available in the=20
> market which supports out of the box.

The only possibility I know is Marvell development board like:
http://avnetexpress.avnet.com/store/em/EMController/Development-Kits/Marvel=
l/RD-88W-SD-8787-A0/_/R-10001817/A-10001817/An-0?action=3Dpart&catalogId=3D=
500201&langId=3D-1&storeId=3D500201


> I am running 3.11 kernel and I already build the Marvell option inside=20
> the kernel.
>=20
> Is there any dongles available in the market which supports full AMP.=20

At least I couldn't find one. If you find it let us know ;)

> If
> not are there any other possibilities to fix the Marvell driver with=20
> the existing dongle. Please any hints as I am working on ARM board I=20
> need to fix the USB Bluetooth device which can transfer with high speed.
>=20

Try to contact Marvell and ask which one supports FullAMP.

Thanks for the reply. I will try to find out about the hardware while conta=
cting Marvell. :)

I bought a USB Bluetooth 3.0 HS + wlan combo dongle. The wlan driver is bas=
ed on realtek8192cu  in the mailing list they mentioned it is based on soft=
 AMP. I found that the realtek they didn't upgrade new driver which support=
s new kernel (3.11 and above). =20

As I understood that Marvell they developed the driver with the FullAMP so =
that the device can run  with high speed. In the same way is there any othe=
r possibilities drivers or else patches available. Any suggestion or hint c=
ould be really appreciated.=20

Thanks in advance,
=20
Regards,
Raviteja

^ permalink raw reply

* Re: Some patches applied on Fedora that maybe should be considered for being applied upstream
From: Bastien Nocera @ 2014-02-11 13:27 UTC (permalink / raw)
  To: Pacho Ramos; +Cc: BlueZ development
In-Reply-To: <1392062509.4911.0.camel@belkin5>

On Mon, 2014-02-10 at 21:01 +0100, Pacho Ramos wrote:
> El lun, 10-02-2014 a las 14:40 +0100, Bastien Nocera escribió:
> > On Sun, 2014-02-09 at 09:53 +0100, Pacho Ramos wrote:
> > > Hello
> > > 
> > > I was looking at bluez package and found some patches that maybe could
> > > be upstreamed. Also, I would like to know the reasons for not accepting
> > > them to ensure they are safe to be applied downstream by us too :)
> > > 
> > > http://pkgs.fedoraproject.org/cgit/bluez.git/tree/0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch -> Does this cause any issues with systemd --user setups?
> > 
> > Giovanni already posted this patch earlier. There's no distribution
> > using systemd sessions, so this doesn't work yet.
> > 
> > > http://pkgs.fedoraproject.org/cgit/bluez.git/tree/0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch
> > > http://pkgs.fedoraproject.org/cgit/bluez.git/tree/0002-autopair-Don-t-handle-the-iCade.patch
> > > http://pkgs.fedoraproject.org/cgit/bluez.git/tree/0004-agent-Assert-possible-infinite-loop.patch
> > > -> Any reason for not applying it upstream too?
> > 
> > I've posted those patches to the list as well.
> 
> And, do you know why they weren't accepted? (it's for trying to get them
> merged and not needing to carry them forever)

Read the threads for the various patches?

Mailing-lists, awful at tracking patches since forever...


^ permalink raw reply

* Re: [PATCH v3] android: Add support for Valgrind in debug variants
From: Szymon Janc @ 2014-02-11 13:25 UTC (permalink / raw)
  To: Andrzej Kaczmarek; +Cc: linux-bluetooth
In-Reply-To: <1391680239-5396-1-git-send-email-andrzej.kaczmarek@tieto.com>

Hi Andrzej,

On Thursday 06 of February 2014 10:50:39 Andrzej Kaczmarek wrote:
> This patch allows bluetoothd to be run with Valgrind easily in debug
> variants.
> 
> For userdebug and eng variants bluetoothd is renamed to bluetoothd-main
> and bluetoothd acts a wrapper to launch it either with or without
> Valgrind (this is decided by value of persist.sys.bluetooth.valgrind
> property).
> ---
>  android/Android.mk           | 42 ++++++++++++++++++++++++
>  android/bluetoothd-wrapper.c | 76
> ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 118
> insertions(+)
>  create mode 100644 android/bluetoothd-wrapper.c
> 
> diff --git a/android/Android.mk b/android/Android.mk
> index 20105e6..52745fe 100644
> --- a/android/Android.mk
> +++ b/android/Android.mk
> @@ -82,7 +82,15 @@ $(shell mkdir -p $(LOCAL_PATH)/bluez/lib/bluetooth)
>  $(foreach file,$(lib_headers), $(shell ln -sf ../$(file)
> $(LOCAL_PATH)/bluez/lib/bluetooth/$(file)))
> 
>  LOCAL_MODULE_TAGS := optional
> +
> +# for userdebug/eng this module is bluetoothd-main since bluetoothd is used
> as +# wrapper to launch bluetooth with Valgrind
> +ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
> +LOCAL_MODULE := bluetoothd-main
> +LOCAL_STRIP_MODULE := false
> +else
>  LOCAL_MODULE := bluetoothd
> +endif
> 
>  include $(BUILD_EXECUTABLE)
> 
> @@ -406,3 +414,37 @@ LOCAL_CFLAGS:= \
>  LOCAL_MODULE := libsbc
> 
>  include $(BUILD_SHARED_LIBRARY)
> +
> +ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
> +
> +#
> +# bluetoothd (debug)
> +# this is just a wrapper used in userdebug/eng to launch bluetoothd-main
> +# with/without Valgrind
> +#
> +
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> +	bluez/android/bluetoothd-wrapper.c
> +
> +LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
> +
> +LOCAL_SHARED_LIBRARIES := \
> +	libcutils \
> +
> +LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)
> +LOCAL_MODULE_TAGS := optional
> +LOCAL_MODULE := bluetoothd
> +
> +LOCAL_REQUIRED_MODULES := \
> +	bluetoothd-main \
> +	valgrind \
> +	memcheck-$(TARGET_ARCH)-linux \
> +	vgpreload_core-$(TARGET_ARCH)-linux \
> +	vgpreload_memcheck-$(TARGET_ARCH)-linux \
> +	default.supp
> +
> +include $(BUILD_EXECUTABLE)
> +
> +endif
> \ No newline at end of file
> diff --git a/android/bluetoothd-wrapper.c b/android/bluetoothd-wrapper.c
> new file mode 100644
> index 0000000..e90277f
> --- /dev/null
> +++ b/android/bluetoothd-wrapper.c
> @@ -0,0 +1,76 @@
> +/*
> + * Copyright (C) 2014 Intel Corporation
> + *
> + * 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 <stdlib.h>
> +#include <string.h>
> +#include <unistd.h>
> +
> +#include <cutils/properties.h>
> +
> +#define PROPERTY_NAME "persist.sys.bluetooth.valgrind"
> +
> +#define VALGRIND_BIN "/system/bin/valgrind"
> +
> +#define BLUETOOTHD_BIN "/system/bin/bluetoothd-main"
> +
> +void run_valgrind(void)
> +{
> +	char *prg_argv[4];
> +	char *prg_envp[3];
> +
> +	prg_argv[0] = VALGRIND_BIN;
> +	prg_argv[1] = "--leak-check=full";
> +	prg_argv[2] = BLUETOOTHD_BIN;
> +	prg_argv[3] = NULL;
> +
> +	prg_envp[0] = "G_SLICE=always-malloc";
> +	prg_envp[1] = "G_DEBUG=gc-friendly";
> +	prg_envp[2] = NULL;
> +
> +	execve(prg_argv[0], prg_argv, prg_envp);
> +}
> +
> +void run_bluetoothd(void)
> +{
> +	char *prg_argv[2];
> +	char *prg_envp[1];
> +
> +	prg_argv[0] = BLUETOOTHD_BIN;
> +	prg_argv[1] = NULL;
> +
> +	prg_envp[0] = NULL;
> +
> +	execve(prg_argv[0], prg_argv, prg_envp);
> +}
> +
> +int main(int argc, char *argv[])
> +{
> +	char value[PROPERTY_VALUE_MAX];
> +
> +	if (property_get(PROPERTY_NAME, value, "") > 0 &&
> +			(!strcasecmp(value, "true") || atoi(value) > 0))
> +		run_valgrind();
> +
> +	/* In case we failed to execute Valgrind, try to run bluetoothd
> +	 * without it
> +	 */
> +
> +	run_bluetoothd();
> +
> +	return 0;
> +}

run_valgrind() and run_bluetooth() should be static.
Other than that this looks good to me.

-- 
BR
Szymon Janc

^ permalink raw reply

* Re: [PATCH 1/4] android/avrcp: Decouple AVRCP logic from btio
From: Andrei Emeltchenko @ 2014-02-11 13:03 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1391702774-18972-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi All

On Thu, Feb 06, 2014 at 06:06:11PM +0200, Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> The patch makes AVRCP to be channel-agnostic so that it might be used in
> unit tests. The idea is that all AVRCP logic would come to avrcp-lib and
> channel stuff got to avrcp.

Any comments regarding this patch?

Best regards 
Andrei Emeltchenko 


> ---
>  android/Android.mk  |  1 +
>  android/Makefile.am |  1 +
>  android/avrcp-lib.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  android/avrcp-lib.h | 34 +++++++++++++++++++++++
>  android/avrcp.c     | 60 ++++++----------------------------------
>  5 files changed, 125 insertions(+), 51 deletions(-)
>  create mode 100644 android/avrcp-lib.c
>  create mode 100644 android/avrcp-lib.h
> 
> diff --git a/android/Android.mk b/android/Android.mk
> index 20105e6..9b10cfe 100644
> --- a/android/Android.mk
> +++ b/android/Android.mk
> @@ -30,6 +30,7 @@ LOCAL_SRC_FILES := \
>  	bluez/android/avdtp.c \
>  	bluez/android/a2dp.c \
>  	bluez/android/avctp.c \
> +	bluez/android/avrcp-lib.c \
>  	bluez/android/avrcp.c \
>  	bluez/android/pan.c \
>  	bluez/android/handsfree.c \
> diff --git a/android/Makefile.am b/android/Makefile.am
> index 5baa8db..3032940 100644
> --- a/android/Makefile.am
> +++ b/android/Makefile.am
> @@ -36,6 +36,7 @@ android_bluetoothd_SOURCES = android/main.c \
>  				android/avdtp.h android/avdtp.c \
>  				android/a2dp.h android/a2dp.c \
>  				android/avctp.h android/avctp.c \
> +				android/avrcp-lib.h android/avrcp-lib.c \
>  				android/avrcp.h android/avrcp.c \
>  				android/socket.h android/socket.c \
>  				android/pan.h android/pan.c \
> diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
> new file mode 100644
> index 0000000..6dcc8ac
> --- /dev/null
> +++ b/android/avrcp-lib.c
> @@ -0,0 +1,80 @@
> +/*
> + *
> + *  BlueZ - Bluetooth protocol stack for Linux
> + *
> + *  Copyright (C) 2014  Intel Corporation. All rights reserved.
> + *
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> + *
> + */
> +
> +#ifdef HAVE_CONFIG_H
> +#include <config.h>
> +#endif
> +
> +#include <stdbool.h>
> +#include <glib.h>
> +
> +#include "lib/bluetooth.h"
> +
> +#include "src/log.h"
> +
> +#include "avctp.h"
> +#include "avrcp-lib.h"
> +
> +static GSList *devices = NULL;
> +
> +void avrcp_device_remove(struct avrcp_device *dev)
> +{
> +	devices = g_slist_remove(devices, dev);
> +	avrcp_device_free(dev);
> +}
> +
> +void avrcp_free_all(void)
> +{
> +	g_slist_free_full(devices, avrcp_device_free);
> +	devices = NULL;
> +}
> +
> +struct avrcp_device *avrcp_device_new(const bdaddr_t *dst)
> +{
> +	struct avrcp_device *dev;
> +
> +	dev = g_new0(struct avrcp_device, 1);
> +	bacpy(&dev->dst, dst);
> +	devices = g_slist_prepend(devices, dev);
> +
> +	return dev;
> +}
> +
> +static int device_cmp(gconstpointer s, gconstpointer user_data)
> +{
> +	const struct avrcp_device *dev = s;
> +	const bdaddr_t *dst = user_data;
> +
> +	return bacmp(&dev->dst, dst);
> +}
> +
> +struct avrcp_device *avrcp_find(const bdaddr_t *dst)
> +{
> +	GSList *l;
> +
> +	l = g_slist_find_custom(devices, dst, device_cmp);
> +	if (!l)
> +		return NULL;
> +
> +	return l->data;
> +}
> diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
> new file mode 100644
> index 0000000..bf6872e
> --- /dev/null
> +++ b/android/avrcp-lib.h
> @@ -0,0 +1,34 @@
> +/*
> + *
> + *  BlueZ - Bluetooth protocol stack for Linux
> + *
> + *  Copyright (C) 2014  Intel Corporation. All rights reserved.
> + *
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> + *
> + */
> +
> +struct avrcp_device {
> +	bdaddr_t	dst;
> +	struct avctp	*session;
> +	GIOChannel      *io;
> +};
> +
> +struct avrcp_device *avrcp_device_new(const bdaddr_t *dst);
> +void avrcp_device_free(void *data);
> +void avrcp_device_remove(struct avrcp_device *dev);
> +void avrcp_free_all(void);
> +struct avrcp_device *avrcp_find(const bdaddr_t *dst);
> diff --git a/android/avrcp.c b/android/avrcp.c
> index 7ee5a8a..22f0a04 100644
> --- a/android/avrcp.c
> +++ b/android/avrcp.c
> @@ -38,6 +38,7 @@
>  #include "hal-msg.h"
>  #include "ipc.h"
>  #include "avctp.h"
> +#include "avrcp-lib.h"
>  
>  #define L2CAP_PSM_AVCTP 0x17
>  
> @@ -48,15 +49,8 @@
>  
>  static bdaddr_t adapter_addr;
>  static uint32_t record_id = 0;
> -static GSList *devices = NULL;
>  static GIOChannel *server = NULL;
>  
> -struct avrcp_device {
> -	bdaddr_t	dst;
> -	struct avctp	*session;
> -	GIOChannel	*io;
> -};
> -
>  static const struct ipc_handler cmd_handlers[] = {
>  };
>  
> @@ -128,7 +122,7 @@ static sdp_record_t *avrcp_record(void)
>  	return record;
>  }
>  
> -static void avrcp_device_free(void *data)
> +void avrcp_device_free(void *data)
>  {
>  	struct avrcp_device *dev = data;
>  
> @@ -143,31 +137,6 @@ static void avrcp_device_free(void *data)
>  	g_free(dev);
>  }
>  
> -static void avrcp_device_remove(struct avrcp_device *dev)
> -{
> -	devices = g_slist_remove(devices, dev);
> -	avrcp_device_free(dev);
> -}
> -
> -static struct avrcp_device *avrcp_device_new(const bdaddr_t *dst)
> -{
> -	struct avrcp_device *dev;
> -
> -	dev = g_new0(struct avrcp_device, 1);
> -	bacpy(&dev->dst, dst);
> -	devices = g_slist_prepend(devices, dev);
> -
> -	return dev;
> -}
> -
> -static int device_cmp(gconstpointer s, gconstpointer user_data)
> -{
> -	const struct avrcp_device *dev = s;
> -	const bdaddr_t *dst = user_data;
> -
> -	return bacmp(&dev->dst, dst);
> -}
> -
>  static void disconnect_cb(void *data)
>  {
>  	struct avrcp_device *dev = data;
> @@ -186,7 +155,6 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
>  	char address[18];
>  	uint16_t imtu, omtu;
>  	GError *gerr = NULL;
> -	GSList *l;
>  	int fd;
>  
>  	if (err) {
> @@ -209,13 +177,9 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
>  
>  	ba2str(&dst, address);
>  
> -	l = g_slist_find_custom(devices, &dst, device_cmp);
> -	if (l) {
> -		dev = l->data;
> -		if (dev->session) {
> -			error("Unexpected connection");
> -			return;
> -		}
> +	if (avrcp_find(&dst)) {
> +		error("Unexpected connection");
> +		return;
>  	} else {
>  		DBG("Incoming connection from %s", address);
>  		dev = avrcp_device_new(&dst);
> @@ -293,8 +257,7 @@ void bt_avrcp_unregister(void)
>  {
>  	DBG("");
>  
> -	g_slist_free_full(devices, avrcp_device_free);
> -	devices = NULL;
> +	avrcp_free_all();
>  
>  	ipc_unregister(HAL_SERVICE_ID_AVRCP);
>  
> @@ -331,12 +294,10 @@ void bt_avrcp_connect(const bdaddr_t *dst)
>  {
>  	struct avrcp_device *dev;
>  	char addr[18];
> -	GSList *l;
>  
>  	DBG("");
>  
> -	l = g_slist_find_custom(devices, dst, device_cmp);
> -	if (l)
> +	if (avrcp_find(dst))
>  		return;
>  
>  	dev = avrcp_device_new(dst);
> @@ -352,16 +313,13 @@ void bt_avrcp_connect(const bdaddr_t *dst)
>  void bt_avrcp_disconnect(const bdaddr_t *dst)
>  {
>  	struct avrcp_device *dev;
> -	GSList *l;
>  
>  	DBG("");
>  
> -	l = g_slist_find_custom(devices, dst, device_cmp);
> -	if (!l)
> +	dev = avrcp_find(dst);
> +	if (!dev)
>  		return;
>  
> -	dev = l->data;
> -
>  	if (dev->session) {
>  		avctp_shutdown(dev->session);
>  		return;
> -- 
> 1.8.3.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: Bluetooth with full AMP
From: Andrei Emeltchenko @ 2014-02-11 12:26 UTC (permalink / raw)
  To: Viswanatham, RaviTeja
  Cc: Marcel Holtmann,
	bluez mailin list (linux-bluetooth@vger.kernel.org), bzhao
In-Reply-To: <9BC883E0D59F6B4DBD525D460025714B08AE363D@deessmx03.dees.eberspaecher.com>

Hi Raviteja,

> On Mon, Feb 10, 2014 at 10:35:24AM -0800, Marcel Holtmann wrote:
> > Hi Ravi,
> > 
> > > I am working on Ubuntu 12.04 with a Bluetooth 3.0 +HS + wifi combo 
> > > USB dongle.
> > > 
> > > I want to reach a data transfer speed of up to 24 Mbit/s. 
> > > 
> > > My Questions: Does Bluez support high speed data transfer rates up 
> > > to
> > > 24 Mbit/s (Bluetooth 3.0+HS) ? 
> > > 
> > > If it does, is there any user configuration involved to achieve that?
> > > What other requirements need to be met?  Does, Bluetooth enables AMP 
> > > function to communicate 802.11n channel to support high speed or it 
> > > has to be configure with any other drivers?
> > > 
> > > I am new to Linux a detail explanation would be really appreciated.
> > > Thank you in advance for your support.
> > 
> > we do support Bluetooth HS operation. However your WiFi device needs 
> > to be exposed as AMP Controller. Most WiFi hardware needs a special 
> > driver to expose itself as AMP Controller. There is no generic driver
> > for mac80211 subsystem in the kernel.
> 
> Some devices have AMP Controller implemented in firmware.  I was using
> Marvell SD8787, probably newer Marvell devices also works.
> 
> You may check drivers/bluetooth/btmrvl_main.c to see how HCI dev_type
> HCI_AMP is assigned.
> 
> Thanks for replying me. I would like to know some more information about
> the Bluetooth dongle. As you said the Marvell SD8787 is kind of a SoC
> chipset. Is there any USB Bluetooth  device available in the market
> which supports out of the box.  

The only possibility I know is Marvell development board like:
http://avnetexpress.avnet.com/store/em/EMController/Development-Kits/Marvell/RD-88W-SD-8787-A0/_/R-10001817/A-10001817/An-0?action=part&catalogId=500201&langId=-1&storeId=500201


> I am running 3.11 kernel and I already
> build the Marvell option inside the kernel. 
> 
> Is there any dongles available in the market which supports full AMP. 

At least I couldn't find one. If you find it let us know ;)

> If
> not are there any other possibilities to fix the Marvell driver with the
> existing dongle. Please any hints as I am working on ARM board I need to
> fix the USB Bluetooth device which can transfer with high speed. 
> 

Try to contact Marvell and ask which one supports FullAMP.

Best regards 
Andrei Emeltchenko 

^ permalink raw reply

* AW: Bluetooth with full AMP
From: Viswanatham, RaviTeja @ 2014-02-11 12:15 UTC (permalink / raw)
  To: Andrei Emeltchenko, Marcel Holtmann
  Cc: bluez mailin list (linux-bluetooth@vger.kernel.org)



-----Urspr=FCngliche Nachricht-----
Von: linux-bluetooth-owner@vger.kernel.org [mailto:linux-bluetooth-owner@vg=
er.kernel.org] Im Auftrag von Andrei Emeltchenko
Gesendet: Dienstag, 11. Februar 2014 08:13
An: Marcel Holtmann
Cc: Viswanatham, RaviTeja; bluez mailin list (linux-bluetooth@vger.kernel.o=
rg)
Betreff: Re:=20

Hi All,

On Mon, Feb 10, 2014 at 10:35:24AM -0800, Marcel Holtmann wrote:
> Hi Ravi,
>=20
> > I am working on Ubuntu 12.04 with a Bluetooth 3.0 +HS + wifi combo=20
> > USB dongle.
> >=20
> > I want to reach a data transfer speed of up to 24 Mbit/s.=20
> >=20
> > My Questions: Does Bluez support high speed data transfer rates up=20
> > to
> > 24 Mbit/s (Bluetooth 3.0+HS) ?=20
> >=20
> > If it does, is there any user configuration involved to achieve that?
> > What other requirements need to be met?  Does, Bluetooth enables AMP=20
> > function to communicate 802.11n channel to support high speed or it=20
> > has to be configure with any other drivers?
> >=20
> > I am new to Linux a detail explanation would be really appreciated.
> > Thank you in advance for your support.
>=20
> we do support Bluetooth HS operation. However your WiFi device needs=20
> to be exposed as AMP Controller. Most WiFi hardware needs a special=20
> driver to expose itself as AMP Controller. There is no generic driver=20
> for
> mac80211 subsystem in the kernel.

Some devices have AMP Controller implemented in firmware.
I was using Marvell SD8787, probably newer Marvell devices also works.

You may check drivers/bluetooth/btmrvl_main.c to see how HCI dev_type HCI_A=
MP is assigned.

Best regards
Andrei Emeltchenko=20

Hello Andrei Emelchenko,

Thanks for replying me. I would like to know some more information about th=
e Bluetooth dongle. As you said the Marvell SD8787 is kind of a SoC chipset=
. Is there any USB Bluetooth  device available in the market which supports=
 out of the box.  I am running 3.11 kernel and I already build the Marvell =
option inside the kernel.=20

Is there any dongles available in the market which supports full AMP. If no=
t are there any other possibilities to fix the Marvell driver with the exis=
ting dongle. Please any hints as I am working on ARM board I need to fix th=
e USB Bluetooth device which can transfer with high speed.=20

Thanks in advance.=20

Regards,
Raviteja=20



--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" =
in the body of a message to majordomo@vger.kernel.org More majordomo info a=
t  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH] Bluetooth: Fix channel check when binding RFCOMM sock
From: Andrzej Kaczmarek @ 2014-02-11 11:50 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek

When binding RFCOMM socket we should only check if there is another
socket bound or listening on the same channel number. In other case,
it won't be possible to bind/listen on a channel in case we have
connection made to remote device on the same channel number.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@tieto.com>
---
 net/bluetooth/rfcomm/sock.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index 00573fb..9912e23 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -331,6 +331,7 @@ static int rfcomm_sock_bind(struct socket *sock, struct sockaddr *addr, int addr
 {
 	struct sockaddr_rc *sa = (struct sockaddr_rc *) addr;
 	struct sock *sk = sock->sk;
+	struct sock *sk1;
 	int err = 0;
 
 	BT_DBG("sk %p %pMR", sk, &sa->rc_bdaddr);
@@ -352,7 +353,9 @@ static int rfcomm_sock_bind(struct socket *sock, struct sockaddr *addr, int addr
 
 	write_lock(&rfcomm_sk_list.lock);
 
-	if (sa->rc_channel && __rfcomm_get_sock_by_addr(sa->rc_channel, &sa->rc_bdaddr)) {
+	sk1 = __rfcomm_get_sock_by_addr(sa->rc_channel, &sa->rc_bdaddr);
+	if (sa->rc_channel && sk1 && (sk1->sk_state == BT_BOUND ||
+						sk1->sk_state == BT_LISTEN)) {
 		err = -EADDRINUSE;
 	} else {
 		/* Save source address */
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH] android/README: Add Valgrind description
From: Andrzej Kaczmarek @ 2014-02-11 11:43 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek

---
 android/README | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/android/README b/android/README
index e3c314f..c7145d5 100644
--- a/android/README
+++ b/android/README
@@ -108,6 +108,22 @@ be found at https://backports.wiki.kernel.org. Sample kernels using backports
 for running BlueZ on Android are available at
 https://code.google.com/p/aosp-bluez.
 
+Running with Valgrind
+=====================
+
+BlueZ for Android is preconfigured to be easily run under Valgrind memcheck.
+Appropriate configuration and required modules are automatically included when
+building either userdebug or eng variant of Android platform.
+
+Valgrind can be enabled in runtime by setting "persist.sys.bluetooth.valgrind"
+property to either literal "true" or any numeric value >0. For example:
+adb root
+adb shell setprop persist.sys.bluetooth.valgrind true
+
+After changing property value Bluetooth need to be restarted to apply changes
+(this can be done using UI, just disable and enable it again). Property is
+persistent, i.e. there's no need to enable Valgrind again after reboot.
+
 =============================
 Building and running on Linux
 =============================
-- 
1.8.5.3


^ permalink raw reply related

* Re: [PATCH 2/3] avrcp: Fix using incorrect buffer for SetVolume
From: Andrei Emeltchenko @ 2014-02-11 11:15 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <20140204140815.GQ2930@aemeltch-MOBL1>

On Tue, Feb 04, 2014 at 04:08:17PM +0200, Andrei Emeltchenko wrote:
> On Thu, Jan 30, 2014 at 06:12:55PM +0200, Andrei Emeltchenko wrote:
> > From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> > 
> > The command requires one parameter.
> 
> ping

ping

> 
> > ---
> >  profiles/audio/avrcp.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
> > index 2e1a940..128f7d3 100644
> > --- a/profiles/audio/avrcp.c
> > +++ b/profiles/audio/avrcp.c
> > @@ -3706,7 +3706,7 @@ int avrcp_set_volume(struct btd_device *dev, uint8_t volume)
> >  {
> >  	struct avrcp_server *server;
> >  	struct avrcp *session;
> > -	uint8_t buf[AVRCP_HEADER_LENGTH + 2];
> > +	uint8_t buf[AVRCP_HEADER_LENGTH + 1];
> >  	struct avrcp_header *pdu = (void *) buf;
> >  
> >  	server = find_server(servers, device_get_adapter(dev));
> > -- 
> > 1.8.3.2
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH 1/2] unit/avctp: Use pre-defined values instead of magic numbers
From: Andrei Emeltchenko @ 2014-02-11 11:12 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1391614102-21639-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

ping

On Wed, Feb 05, 2014 at 05:28:21PM +0200, Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> ---
>  unit/test-avctp.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/unit/test-avctp.c b/unit/test-avctp.c
> index 581f88c..9d94ae0 100644
> --- a/unit/test-avctp.c
> +++ b/unit/test-avctp.c
> @@ -277,8 +277,8 @@ static void test_client(gconstpointer data)
>  {
>  	struct context *context = create_context(0x0100, data);
>  
> -	avctp_send_vendordep_req(context->session, 0, 0, NULL, 0,
> -						handler_response, context);
> +	avctp_send_vendordep_req(context->session, AVC_CTYPE_CONTROL, 0, NULL,
> +						0, handler_response, context);
>  
>  	execute_context(context);
>  }
> @@ -290,8 +290,8 @@ static void test_server(gconstpointer data)
>  	if (g_str_equal(context->data->test_name, "/TP/NFR/BV-03-C")) {
>  		int ret;
>  
> -		ret = avctp_register_pdu_handler(context->session, 0x00,
> -								handler, NULL);
> +		ret = avctp_register_pdu_handler(context->session,
> +					AVC_OP_VENDORDEP, handler, NULL);
>  		DBG("ret %d", ret);
>  		g_assert_cmpint(ret, !=, 0);
>  	}
> -- 
> 1.8.3.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH 5/5] emulator/bthost: Check length of received RFCOMM UIH frames
From: Marcin Kraglak @ 2014-02-11 10:51 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392115862-19752-1-git-send-email-marcin.kraglak@tieto.com>

Add correct calculation of frame length. If frame is too short, ignore it.
---
 emulator/bthost.c | 38 ++++++++++++++++++++++++++++++--------
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/emulator/bthost.c b/emulator/bthost.c
index ab90f4c..8447817 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -1760,17 +1760,30 @@ static void rfcomm_mcc_recv(struct bthost *bthost, struct btconn *conn,
 			struct l2conn *l2conn, const void *data, uint16_t len)
 {
 	const struct rfcomm_mcc *mcc = data;
+	const struct rfcomm_msc *msc;
+	const struct rfcomm_pn *pn;
+
+	if (len < sizeof(*mcc))
+		return;
 
 	switch (RFCOMM_GET_MCC_TYPE(mcc->type)) {
 	case RFCOMM_MSC:
+		if (len - sizeof(*mcc) < sizeof(*msc))
+			break;
+
+		msc = data + sizeof(*mcc);
+
 		rfcomm_msc_recv(bthost, conn, l2conn,
-						RFCOMM_TEST_CR(mcc->type) / 2,
-						data + sizeof(*mcc));
+				RFCOMM_TEST_CR(mcc->type) / 2, msc);
 		break;
 	case RFCOMM_PN:
+		if (len - sizeof(*mcc) < sizeof(*pn))
+			break;
+
+		pn = data + sizeof(*mcc);
+
 		rfcomm_pn_recv(bthost, conn, l2conn,
-					RFCOMM_TEST_CR(mcc->type) / 2,
-					data + sizeof(*mcc));
+				RFCOMM_TEST_CR(mcc->type) / 2, pn);
 		break;
 	default:
 		break;
@@ -1781,18 +1794,27 @@ static void rfcomm_uih_recv(struct bthost *bthost, struct btconn *conn,
 				struct l2conn *l2conn, const void *data,
 				uint16_t len)
 {
-	const struct rfcomm_cmd *hdr = data;
+	const struct rfcomm_hdr *hdr = data;
+	uint16_t hdr_len;
 	const void *p;
 
+	if (len < sizeof(*hdr))
+		return;
+
 	if (RFCOMM_GET_DLCI(hdr->address))
 		return;
 
 	if (RFCOMM_TEST_EA(hdr->length))
-		p = data + sizeof(struct rfcomm_hdr);
+		hdr_len = sizeof(*hdr);
 	else
-		p = data + sizeof(struct rfcomm_hdr) + sizeof(uint8_t);
+		hdr_len = sizeof(*hdr) + sizeof(uint8_t);
+
+	if (len - hdr_len < 0)
+		return;
+
+	p = data + hdr_len;
 
-	rfcomm_mcc_recv(bthost, conn, l2conn, p, p - data);
+	rfcomm_mcc_recv(bthost, conn, l2conn, p, len - hdr_len);
 }
 
 static void process_rfcomm(struct bthost *bthost, struct btconn *conn,
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH 4/5] emulator/bthost: Check length of received RFCOMM UA frames
From: Marcin Kraglak @ 2014-02-11 10:51 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392115862-19752-1-git-send-email-marcin.kraglak@tieto.com>

Check length of RFCOMM UA frames and ignore if frame is too short.
---
 emulator/bthost.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/emulator/bthost.c b/emulator/bthost.c
index 33a0544..ab90f4c 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -1619,14 +1619,20 @@ static void rfcomm_ua_recv(struct bthost *bthost, struct btconn *conn,
 				uint16_t len)
 {
 	const struct rfcomm_cmd *ua_hdr = data;
-	uint8_t channel = RFCOMM_GET_CHANNEL(ua_hdr->address);
+	uint8_t channel;
 	struct rfcomm_connection_data *conn_data = bthost->rfcomm_conn_data;
-	uint8_t type = RFCOMM_GET_TYPE(ua_hdr->control);
+	uint8_t type;
 	uint8_t buf[14];
 	struct rfcomm_hdr *hdr;
 	struct rfcomm_mcc *mcc;
 	struct rfcomm_pn *pn_cmd;
 
+	if (len < sizeof(*ua_hdr))
+		return;
+
+	channel = RFCOMM_GET_CHANNEL(ua_hdr->address);
+	type = RFCOMM_GET_TYPE(ua_hdr->control);
+
 	if (channel && conn_data && conn_data->channel == channel) {
 		if (conn_data->cb)
 			conn_data->cb(conn->handle, l2conn->scid,
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH 3/5] emulator/bthost: Check length of received RFCOMM DM frames
From: Marcin Kraglak @ 2014-02-11 10:51 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392115862-19752-1-git-send-email-marcin.kraglak@tieto.com>

Ignore too short received RFCOMM DM frames.
---
 emulator/bthost.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/emulator/bthost.c b/emulator/bthost.c
index 2cd79bc..33a0544 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -1669,9 +1669,14 @@ static void rfcomm_dm_recv(struct bthost *bthost, struct btconn *conn,
 				uint16_t len)
 {
 	const struct rfcomm_cmd *hdr = data;
-	uint8_t channel = RFCOMM_GET_CHANNEL(hdr->address);
+	uint8_t channel;
 	struct rfcomm_connection_data *conn_data = bthost->rfcomm_conn_data;
 
+	if (len < sizeof(*hdr))
+		return;
+
+	channel = RFCOMM_GET_CHANNEL(hdr->address);
+
 	if (conn_data && conn_data->channel == channel) {
 		if (conn_data->cb)
 			conn_data->cb(conn->handle, l2conn->scid,
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH 2/5] emulator/bthost: Check length of received RFCOMM DISC frame
From: Marcin Kraglak @ 2014-02-11 10:50 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1392115862-19752-1-git-send-email-marcin.kraglak@tieto.com>

Don't access rfcomm_hdr struct and ignore if frame is too short.
---
 emulator/bthost.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/emulator/bthost.c b/emulator/bthost.c
index f92b479..2cd79bc 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -1604,7 +1604,12 @@ static void rfcomm_disc_recv(struct bthost *bthost, struct btconn *conn,
 				uint16_t len)
 {
 	const struct rfcomm_cmd *hdr = data;
-	uint8_t dlci = RFCOMM_GET_DLCI(hdr->address);
+	uint8_t dlci;
+
+	if (len < sizeof(*hdr))
+		return;
+
+	dlci = RFCOMM_GET_DLCI(hdr->address);
 
 	rfcomm_ua_send(bthost, conn, l2conn, 0, dlci);
 }
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH 1/5] emulator/bthost: Check length of received RFCOMM SABM frame
From: Marcin Kraglak @ 2014-02-11 10:50 UTC (permalink / raw)
  To: linux-bluetooth

This will check length of received SABM frame. Ignore frame if
it is too short.
---
 emulator/bthost.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/emulator/bthost.c b/emulator/bthost.c
index 3ff2a36..f92b479 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -1578,9 +1578,15 @@ static void rfcomm_sabm_recv(struct bthost *bthost, struct btconn *conn,
 				uint16_t len)
 {
 	const struct rfcomm_cmd *hdr = data;
-	uint8_t dlci = RFCOMM_GET_DLCI(hdr->address);
+	uint8_t dlci;
 	struct rfcomm_conn_cb_data *cb;
-	uint8_t chan = RFCOMM_GET_CHANNEL(hdr->address);
+	uint8_t chan;
+
+	if (len < sizeof(*hdr))
+		return;
+
+	chan = RFCOMM_GET_CHANNEL(hdr->address);
+	dlci = RFCOMM_GET_DLCI(hdr->address);
 
 	cb = bthost_find_rfcomm_cb_by_channel(bthost, chan);
 	if (!dlci || cb) {
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH v2] android/README: Update with implementation status summary
From: Szymon Janc @ 2014-02-11 10:40 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

This will give a better overview of implemented features.
---
 android/README | 38 +++++++++++++++++++++++++++++++++-----
 1 file changed, 33 insertions(+), 5 deletions(-)

diff --git a/android/README b/android/README
index e3c314f..b987dc9 100644
--- a/android/README
+++ b/android/README
@@ -132,15 +132,43 @@ automatically on HAL library initialization. To deinitialize HAL library and
 stop daemon type 'bluetooth cleanup'. Type 'help' for more information. Tab
 completion is also supported.
 
+=====================
+Implementation status
+=====================
+
+Summary of HALs implementation status.
+
+complete    - implementation is feature complete and Android Framework is able
+              to use it normally
+partial     - implementation is in progress and not all required features are
+              present, Android Framework is able to use some of features
+initial     - only initial implementations is present, Android Framework is
+              able to initialize but most likely not able to use it
+not started - no implementation, Android Framework is not able to initialize it
+
+Profile ID    HAL header         Status
+---------------------------------------
+core          bluetooth.h        complete
+a2dp          bt_av.h            complete
+gatt          bt_gatt.h          not started
+              bt_gatt_client.h   not started
+              bt_gatt_server.h   not started
+handsfree     bt_hf.h            initial
+hidhost       bt_hh.h            complete
+health        bt_hl.h            not started
+pan           bt_pan.h           complete
+avrcp         bt_rc.h            partial
+socket        bt_sock.h          partial
+
 ===========================
 Implementation shortcomings
 ===========================
 
-It is possible that some of HAL functionality is missing implementation due to
-reasons like feature feasibility or necessity for latest Android Framework.
-This sections provides list of such deficiencies. Note that HAL library is
-always expected to fully implement HAL API so missing implementation might
-happen only in daemon.
+It is possible that some of HAL functionality (although being marked as
+complete) is missing implementation due to reasons like feature feasibility or
+necessity for latest Android Framework. This sections provides list of such
+deficiencies. Note that HAL library is always expected to fully implement HAL
+API so missing implementation might happen only in daemon.
 
 HAL Bluetooth
 =============
-- 
1.8.5.3


^ permalink raw reply related

* Re:
From: Andrei Emeltchenko @ 2014-02-11  7:13 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Viswanatham, RaviTeja,
	bluez mailin list (linux-bluetooth@vger.kernel.org)
In-Reply-To: <BE8107B5-0F83-47C5-ADC6-345CFD24BE21@holtmann.org>

Hi All,

On Mon, Feb 10, 2014 at 10:35:24AM -0800, Marcel Holtmann wrote:
> Hi Ravi,
> 
> > I am working on Ubuntu 12.04 with a Bluetooth 3.0 +HS + wifi combo USB
> > dongle. 
> > 
> > I want to reach a data transfer speed of up to 24 Mbit/s. 
> > 
> > My Questions: Does Bluez support high speed data transfer rates up to
> > 24 Mbit/s (Bluetooth 3.0+HS) ? 
> > 
> > If it does, is there any user configuration involved to achieve that?
> > What other requirements need to be met?  Does, Bluetooth enables AMP
> > function to communicate 802.11n channel to support high speed or it
> > has to be configure with any other drivers? 
> > 
> > I am new to Linux a detail explanation would be really appreciated.
> > Thank you in advance for your support.
> 
> we do support Bluetooth HS operation. However your WiFi device needs to
> be exposed as AMP Controller. Most WiFi hardware needs a special driver
> to expose itself as AMP Controller. There is no generic driver for
> mac80211 subsystem in the kernel.

Some devices have AMP Controller implemented in firmware.
I was using Marvell SD8787, probably newer Marvell devices also works.

You may check drivers/bluetooth/btmrvl_main.c to see how HCI dev_type
HCI_AMP is assigned.

Best regards 
Andrei Emeltchenko 

^ permalink raw reply

* Re: [PATCH 00/24] rfcomm fixes
From: Peter Hurley @ 2014-02-10 23:00 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Gustavo F. Padovan, Johan Hedberg, Gianluca Anzolin,
	Alexander Holler, Andrey Vihrov, Sander Eikelenboom,
	bluez mailin list (linux-bluetooth@vger.kernel.org), linux-kernel
In-Reply-To: <3E0F3723-029F-4B12-8D77-9790FDBD3227@holtmann.org>

Hi Marcel,

On 02/10/2014 05:09 PM, Marcel Holtmann wrote:
> Hi Peter,
>
>> This patch series addresses a number of previously unknown issues
>> with the RFCOMM tty device implementation, in addition to
>> addressing the locking regression recently reported [1].
>>
>> As Gianluca suggested and I agree, this series first reverts
>> 3 of the 4 patches of 3.14-rc1 for bluetooth/rfcomm/tty.c.
>
> so for 3.14 we should revert 3 patches. And then the other 21 are
 > intended for 3.15 merge window.

Yep, this is probably best. At least 3.13 & 3.14 will behave the
same wrt rfcomm.

> I realize that we still have to deal with some breakage, but we
 > do not want regressions and I clearly not going to take 24 patches
 > for 3.14 at this point in time.

Yeah, I wasn't expecting you to.

> What I can do is take all 24 patches into bluetooth-next and let
 > them sit for 1 week and have people test them. And then we go ahead
 > with reverting 3 patches from 3.14. Does that make sense?

Yep, that's fine with me. Thanks.

Regards,
Peter Hurley

^ permalink raw reply

* Re: [PATCH 00/24] rfcomm fixes
From: Marcel Holtmann @ 2014-02-10 22:09 UTC (permalink / raw)
  To: Peter Hurley
  Cc: Gustavo F. Padovan, Johan Hedberg, Gianluca Anzolin,
	Alexander Holler, Andrey Vihrov, Sander Eikelenboom,
	bluez mailin list (linux-bluetooth@vger.kernel.org), linux-kernel
In-Reply-To: <1391997564-1805-1-git-send-email-peter@hurleysoftware.com>

Hi Peter,

> This patch series addresses a number of previously unknown issues
> with the RFCOMM tty device implementation, in addition to
> addressing the locking regression recently reported [1].
> 
> As Gianluca suggested and I agree, this series first reverts
> 3 of the 4 patches of 3.14-rc1 for bluetooth/rfcomm/tty.c.

so for 3.14 we should revert 3 patches. And then the other 21 are intended for 3.15 merge window.

I realize that we still have to deal with some breakage, but we do not want regressions and I clearly not going to take 24 patches for 3.14 at this point in time.

What I can do is take all 24 patches into bluetooth-next and let them sit for 1 week and have people test them. And then we go ahead with reverting 3 patches from 3.14. Does that make sense?

Regards

Marcel


^ permalink raw reply

* Re: Some patches applied on Fedora that maybe should be considered for being applied upstream
From: Pacho Ramos @ 2014-02-10 20:01 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: BlueZ development
In-Reply-To: <1392039609.4417.14.camel@nuvo>

El lun, 10-02-2014 a las 14:40 +0100, Bastien Nocera escribió:
> On Sun, 2014-02-09 at 09:53 +0100, Pacho Ramos wrote:
> > Hello
> > 
> > I was looking at bluez package and found some patches that maybe could
> > be upstreamed. Also, I would like to know the reasons for not accepting
> > them to ensure they are safe to be applied downstream by us too :)
> > 
> > http://pkgs.fedoraproject.org/cgit/bluez.git/tree/0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch -> Does this cause any issues with systemd --user setups?
> 
> Giovanni already posted this patch earlier. There's no distribution
> using systemd sessions, so this doesn't work yet.
> 
> > http://pkgs.fedoraproject.org/cgit/bluez.git/tree/0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch
> > http://pkgs.fedoraproject.org/cgit/bluez.git/tree/0002-autopair-Don-t-handle-the-iCade.patch
> > http://pkgs.fedoraproject.org/cgit/bluez.git/tree/0004-agent-Assert-possible-infinite-loop.patch
> > -> Any reason for not applying it upstream too?
> 
> I've posted those patches to the list as well.

And, do you know why they weren't accepted? (it's for trying to get them
merged and not needing to carry them forever)


> 
> > http://pkgs.fedoraproject.org/cgit/bluez.git/tree/0001-work-around-Logitech-diNovo-Edge-keyboard-firmware-i.patch
> > -> Taking care this looks to be a really old issue, maybe using the
> > workaround would be the only option for now :/
> 
> I have no hardware to test this on, I snatched it from Ubuntu's bluez 4
> package.
> 
> Cheers

OK, thanks :)


^ permalink raw reply

* Re: [PATCH] android/README: Update with implementation status summary
From: Marcel Holtmann @ 2014-02-10 18:37 UTC (permalink / raw)
  To: Szymon Janc; +Cc: bluez mailin list (linux-bluetooth@vger.kernel.org)
In-Reply-To: <1392033059-3346-1-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

> This will give a better overview of implemented features.
> ---
> android/README | 37 ++++++++++++++++++++++++++++++++-----
> 1 file changed, 32 insertions(+), 5 deletions(-)
> 
> diff --git a/android/README b/android/README
> index e3c314f..49536e2 100644
> --- a/android/README
> +++ b/android/README
> @@ -132,15 +132,42 @@ automatically on HAL library initialization. To deinitialize HAL library and
> stop daemon type 'bluetooth cleanup'. Type 'help' for more information. Tab
> completion is also supported.
> 
> +=====================
> +Implementation status
> +=====================
> +
> +Summary of HALs implementation status.
> +
> +complete    - implementation is feature complete and Android Framework is able
> +              to use it normally
> +partial     - implementation is in progress and not all required features are
> +              present, Android Framework is able to use some of features
> +initial     - only initial implementations is present, Android Framework is
> +              able to initialize but most likely not able to use it
> +not started - no implementation, Android Framework is not able to initialize it
> +
> +profile ID    HAL header         status

use a ------ line here to separate header for content.


> +core          bluetooth.h        complete
> +a2dp          bt_av.h            complete
> +gatt          bt_gatt.h          not started
> +              bt_gatt_client.h   not started
> +              bt_gatt_server.h   not started
> +handsfree     bt_hf.h            initial
> +hidhost       bt_hh.h            complete
> +health        bt_hl.h            not started
> +pan           bt_pan.h           complete
> +avrcp         bt_rc.h            partial
> +socket        bt_sock.h          complete
> +

Regards

Marcel


^ permalink raw reply

* Re:
From: Marcel Holtmann @ 2014-02-10 18:35 UTC (permalink / raw)
  To: Viswanatham, RaviTeja; +Cc: bluez mailin list (linux-bluetooth@vger.kernel.org)
In-Reply-To: <9BC883E0D59F6B4DBD525D460025714B08AE336F@deessmx03.dees.eberspaecher.com>

Hi Ravi,

> I am working on Ubuntu 12.04 with a Bluetooth 3.0 +HS + wifi combo USB dongle. 
> 
> I want to reach a data transfer speed of up to 24 Mbit/s. 
> 
> My Questions:
> Does Bluez support high speed data transfer rates up to 24 Mbit/s (Bluetooth 3.0+HS) ? 
> 
> If it does, is there any user configuration involved to achieve that? What other requirements need to be met?
> Does, Bluetooth enables AMP function to communicate 802.11n channel to support high speed or it has to be configure with any other drivers? 
> 
> I am new to Linux a detail explanation would be really appreciated. Thank you in advance for your support.

we do support Bluetooth HS operation. However your WiFi device needs to be exposed as AMP Controller. Most WiFi hardware needs a special driver to expose itself as AMP Controller. There is no generic driver for mac80211 subsystem in the kernel.

Regards

Marcel


^ permalink raw reply

* Re: [PATCH] btusb.c add IMC Networks id 13d3:3404 (bcm20702A0)
From: Marcel Holtmann @ 2014-02-10 18:33 UTC (permalink / raw)
  To: Jurgen Kramer; +Cc: BlueZ development
In-Reply-To: <1392031617.5601.11.camel@develbox>

HI Jurgen,

> Attached patch adds support for IMC Networks (13d3:3404) to BCM20702A0
> in btusb.c. This device is used on the Asrock Z87E-ITX motherboard.
> Tested against 3.12.9.
> 
> diff -uNrp
> linux-3.12.9-301.jk1.fc20.x86_64.orig/drivers/bluetooth/btusb.c
> linux-3.12.9-301.jk1.fc20.x86_64.new/drivers/bluetooth/btusb.c
> --- a/drivers/bluetooth/btusb.c	2014-02-10 11:35:08.976975562 +0100
> +++ b/drivers/bluetooth/btusb.c	2014-02-10 11:37:03.864921122 +0100
> @@ -106,6 +106,7 @@ static struct usb_device_id btusb_table[
> 	{ USB_DEVICE(0x04ca, 0x2003) },
> 	{ USB_DEVICE(0x0489, 0xe042) },
> 	{ USB_DEVICE(0x413c, 0x8197) },
> +	{ USB_DEVICE(0x13d3, 0x3404) },
> 
> 	/* Foxconn - Hon Hai */
> 	{ USB_VENDOR_AND_INTERFACE_INFO(0x0489, 0xff, 0x01, 0x01) },
> 
> Signed-off-by: Jurgen Kramer <gtm.kramer@xs4all.nl>
> 
> Jurgen
> <btusb-bcm20702a0-add-imc-networks.patch>

please send patches inline created from git-format-patch and include /sys/kernel/debug/usb/devices details for this device.

Regards

Marcel


^ permalink raw reply

* [PATCH BlueZ 3/3] unit: Fix memory leaks in test-gdbus-client
From: Anderson Lizardo @ 2014-02-10 17:14 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1392052498-9229-1-git-send-email-anderson.lizardo@openbossa.org>

---
 unit/test-gdbus-client.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/unit/test-gdbus-client.c b/unit/test-gdbus-client.c
index 685729a..ee8a760 100644
--- a/unit/test-gdbus-client.c
+++ b/unit/test-gdbus-client.c
@@ -101,6 +101,7 @@ static void destroy_context(struct context *context)
 
 	dbus_connection_flush(context->dbus_conn);
 	dbus_connection_close(context->dbus_conn);
+	dbus_connection_unref(context->dbus_conn);
 
 	g_main_loop_unref(context->main_loop);
 
@@ -956,6 +957,10 @@ static void client_force_disconnect(void)
 
 	g_main_loop_run(context->main_loop);
 
+	g_dbus_unregister_interface(conn, SERVICE_PATH, SERVICE_NAME1);
+	g_dbus_detach_object_manager(conn);
+	dbus_connection_unref(conn);
+
 	destroy_context(context);
 }
 
-- 
1.7.9.5


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox