Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 01/11] android/hidhost: Fix connection state notification on profile unregister
From: Ravi kumar Veeramally @ 2014-01-16 23:25 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1389914751-18545-1-git-send-email-ravikumar.veeramally@linux.intel.com>

Issue found while writing end2end tests. Usually profile unregister is
called when final cleanup of bluetoothd. Freeing connected hid devices
through g_slist_foreach is a asynchronous call. Profile is cleaned up
and and ipc also complete cleanup. But free_hid_devices tries to notify
hal which doesn't exist that time. So behaviour is unexpected.
---
 android/hidhost.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/android/hidhost.c b/android/hidhost.c
index aed9899..c004063 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -1328,7 +1328,6 @@ static void free_hid_devices(gpointer data, gpointer user_data)
 {
 	struct hid_device *dev = data;
 
-	bt_hid_notify_state(dev, HAL_HIDHOST_STATE_DISCONNECTED);
 	hid_device_free(dev);
 }
 
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 00/11] HIDHost E2E tests and fixes
From: Ravi kumar Veeramally @ 2014-01-16 23:25 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally

Patch set contains few fixes which are noticed while writing
tests and success test cases for hidhost.

Ravi kumar Veeramally (11):
  android/hidhost: Fix connection state notification on profile
    unregister
  android/hidhost: Fix miscalculation of get report event struct length
  android/hidhost: Remove unnecessary check
  android/tester: Add HIDhost Connect test
  android/tester: Add HIDhost Disconnect test
  android/tester: Add HIDhost VirtualUnplug test
  android/tester: Add HIDhost GetProtocol test
  android/tester: Add HIDhost SetProtocol test
  android/tester: Add HIDhost GetReport test
  android/tester: Add HIDhost SetReport test
  android/tester: Add HIDhost SendData test

 android/android-tester.c | 517 ++++++++++++++++++++++++++++++++++++++++++++++-
 android/hal-hidhost.c    |   3 +-
 android/hidhost.c        |  14 +-
 3 files changed, 511 insertions(+), 23 deletions(-)

-- 
1.8.3.2


^ permalink raw reply

* Re: Questions on BlueZ 5.13: device creation API + persistent hid/input pipeline
From: Petri Gynther @ 2014-01-16 23:03 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth@vger.kernel.org development
In-Reply-To: <F4C3DE28-E297-42B1-9FA2-B3335DF0F080@holtmann.org>

Hi Marcel,

Thanks for your reply. Please see inline.

On Thu, Jan 16, 2014 at 2:30 PM, Marcel Holtmann <marcel@holtmann.org> wrot=
e:
> Hi Petri,
>
>> I'm running BlueZ 5.13 userland + backported BlueZ kernel modules on
>> an embedded system that I'm working on. The kernel on the system is
>> 2.6.37-based. I ported uhid driver manually from 3.12.
>>
>> I'm successfully using Bluetooth classic HID remote control and
>> Bluetooth LE HoG remote control on this system. However, I have two
>> questions:
>>
>> 1) The Bluetooth classic remote that I'm using is not discoverable. It
>> is only connectable. When the remote is not paired, it sends its
>> Bluetooth MAC address to the host via IR, and the host needs to add
>> this device to BlueZ's discovered devices database. But, how can I do
>> that via D-Bus API? BlueZ 5 porting guide specifically mentions that "
>> ... we decided to simply get rid of explicit CreateDevice /
>> CreatePairedDevice methods and instead dynamically create device
>> objects as they are discovered during device discovery."
>>
>> So, is there no API available to add non-discoverable devices in BlueZ 5=
?
>>
>> I have worked around this issue by manually adding this remote to
>> <storage path>, so that bluetoothd creates the device on reboot via
>> device_create_from_storage(). But, I would prefer not to restart
>> bluetoothd every time a non-discoverable device needs to be added.
>
> I have never heard of a remote that uses IR to setup the pairing. A creat=
ive way of doing out-of-band pairing.
>
> What I think you are looking for is what the PS3 controllers do when the =
share their details over USB and then after that connect over Bluetooth HID=
. Have a look at plugins/sixaxis.c to see how they do it. BlueZ has a plugi=
n API for doing exactly these kind of automated setup/pairing type of cases=
.
>
> So you want to write a plugin for this remote.
>
> The other plugin you might want to look at is plugins/autopair.c if it ac=
tually requires to also create an encrypted link.
>

Thank you for this info. I will look into plugins/sixaxis.c and
plugins/autopair.c.

>> 2) There is a difference in HID vs HoG hid/input pipeline persistence.
>> When the Bluetooth classic HID remote disconnects, the corresponding
>> hid and input kernel devices are destroyed. And when it reconnects,
>> hid and input devices are created again. This adds a lot of
>> unnecessary delay at reconnect. And, the first keypress is always lost
>> on reconnect.
>>
>> In contrast, for the Bluetooth LE HoG remote, the hid/input pipeline
>> is persistent. When HoG remote disconnects, hid and input devices
>> remain in the system and are reused when the HoG remote reconnects.
>>
>> Is there a way to make Bluetooth classic HID behave the same as HoG,
>> i.e. retain the hid and input kernel devices on disconnect and reuse
>> them on reconnect?
>
> HID and HoG work a little bit different. HID uses a kernel transport driv=
er while HoG uses /dev/uhid to do the work. Porting HID over to use /dev/uh=
id is certainly a possibility. We have considered that, but nobody has done=
 that work yet.
>
> Please remember that HID (with HIDP) is finding its right place in /sys d=
evice tree. While all HoG using /dev/uhid are considered virtual devices. T=
here is a semi proposal that we agreed on New Orleans during the PlumbersCo=
nf, but I have no idea if David actually implemented it.
>
> Another option is to make the HIDP transport smarter and persistent by in=
tegrating it into BlueZ 5=E2=80=99s kernel mgmt support. That however means=
 you will need a much more recent Bluetooth subsystem. So 2.6.37 is not get=
ting you anywhere near that even if we change HIDP support.
>
> Regards
>
> Marcel
>

I'm using BlueZ kernel modules (bluetooth, hidp) from Linux
backports-3.13-rc2-1, so that is pretty recent code. Works fine on top
of 2.6.37. However, my HID and input drivers come from 2.6.37, as they
are not available in backports-3.13-rc2-1.

I understand the difference between HID and HoG. Both hidp and uhid
are hid_ll_drivers. HID input reports stay entirely in kernel, whereas
HoG is handled in bluetoothd and input reports are passed back to
kernel via /dev/uhid.

Assuming the latest HIDP code, what kind of effort would it be to make
the hid/input pipeline persistent when HID remote disconnects and
reconnects?

-- Petri

^ permalink raw reply

* Re: [PATCH] enable Atheros 0cf3:311e for firmware upload
From: Marcel Holtmann @ 2014-01-16 22:48 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: Yu-Chen Cho, Gustavo F. Padovan, Johan Hedberg,
	linux-bluetooth@vger.kernel.org development, Oliver Neukum
In-Reply-To: <1389883031-10752-2-git-send-email-oliver@neukum.org>

Hi Oliver,

> The device will bind to btusb without firmware, but with the original
> buggy firmware device discovery does not work. No devices are detected.
> 
> Device descriptor without firmware:
> T:  Bus=03 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#=  2 Spd=12   MxCh= 0
> D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
> P:  Vendor=0cf3 ProdID=311e Rev= 0.01
> C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
> I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
> E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
> E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
> I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
> E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
> I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
> E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
> I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
> I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
> I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
> I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
> 
> with firmware:
> T:  Bus=03 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#=  3 Spd=12   MxCh= 0
> D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
> P:  Vendor=0cf3 ProdID=311e Rev= 0.02
> C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
> I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
> E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
> E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
> I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
> E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
> I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
> E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
> I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
> I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
> I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
> I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
> E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
> 
> Signed-off-by: Oliver Neukum <oneukum@suse.de>
> ---
> drivers/bluetooth/ath3k.c | 2 ++
> drivers/bluetooth/btusb.c | 1 +
> 2 files changed, 3 insertions(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply

* Re: [PATCH] add firmware update for Atheros 0cf3:311f
From: Marcel Holtmann @ 2014-01-16 22:48 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: Yu-Chen Cho, Gustavo F. Padovan, Johan Hedberg,
	linux-bluetooth@vger.kernel.org development, Oliver Neukum
In-Reply-To: <1389884578-18479-2-git-send-email-oliver@neukum.org>

Hi Oliver,

> The device is not functional without firmware.
> 
> The device without firmware:
> T:  Bus=02 Lev=02 Prnt=02 Port=05 Cnt=01 Dev#=  3 Spd=12  MxCh= 0
> D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
> P:  Vendor=0cf3 ProdID=311f Rev=00.01
> C:  #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
> I:  If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> I:  If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> 
> The device with firmware:
> T:  Bus=02 Lev=02 Prnt=02 Port=05 Cnt=01 Dev#=  4 Spd=12  MxCh= 0
> D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
> P:  Vendor=0cf3 ProdID=3007 Rev=00.01
> C:  #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
> I:  If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> I:  If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
> 
> Signed-off-by: Oliver Neukum <oneukum@suse.de>
> ---
> drivers/bluetooth/ath3k.c | 2 ++
> drivers/bluetooth/btusb.c | 1 +
> 2 files changed, 3 insertions(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply

* Re: Questions on BlueZ 5.13: device creation API + persistent hid/input pipeline
From: Marcel Holtmann @ 2014-01-16 22:30 UTC (permalink / raw)
  To: Petri Gynther; +Cc: linux-bluetooth@vger.kernel.org development
In-Reply-To: <CAGXr9JHw-S5XdXEcp3APN9OKadt7LuoPQmJ2RZkAsRZ8dDJB-w@mail.gmail.com>

Hi Petri,

> I'm running BlueZ 5.13 userland + backported BlueZ kernel modules on
> an embedded system that I'm working on. The kernel on the system is
> 2.6.37-based. I ported uhid driver manually from 3.12.
> 
> I'm successfully using Bluetooth classic HID remote control and
> Bluetooth LE HoG remote control on this system. However, I have two
> questions:
> 
> 1) The Bluetooth classic remote that I'm using is not discoverable. It
> is only connectable. When the remote is not paired, it sends its
> Bluetooth MAC address to the host via IR, and the host needs to add
> this device to BlueZ's discovered devices database. But, how can I do
> that via D-Bus API? BlueZ 5 porting guide specifically mentions that "
> ... we decided to simply get rid of explicit CreateDevice /
> CreatePairedDevice methods and instead dynamically create device
> objects as they are discovered during device discovery."
> 
> So, is there no API available to add non-discoverable devices in BlueZ 5?
> 
> I have worked around this issue by manually adding this remote to
> <storage path>, so that bluetoothd creates the device on reboot via
> device_create_from_storage(). But, I would prefer not to restart
> bluetoothd every time a non-discoverable device needs to be added.

I have never heard of a remote that uses IR to setup the pairing. A creative way of doing out-of-band pairing.

What I think you are looking for is what the PS3 controllers do when the share their details over USB and then after that connect over Bluetooth HID. Have a look at plugins/sixaxis.c to see how they do it. BlueZ has a plugin API for doing exactly these kind of automated setup/pairing type of cases.

So you want to write a plugin for this remote.

The other plugin you might want to look at is plugins/autopair.c if it actually requires to also create an encrypted link.

> 2) There is a difference in HID vs HoG hid/input pipeline persistence.
> When the Bluetooth classic HID remote disconnects, the corresponding
> hid and input kernel devices are destroyed. And when it reconnects,
> hid and input devices are created again. This adds a lot of
> unnecessary delay at reconnect. And, the first keypress is always lost
> on reconnect.
> 
> In contrast, for the Bluetooth LE HoG remote, the hid/input pipeline
> is persistent. When HoG remote disconnects, hid and input devices
> remain in the system and are reused when the HoG remote reconnects.
> 
> Is there a way to make Bluetooth classic HID behave the same as HoG,
> i.e. retain the hid and input kernel devices on disconnect and reuse
> them on reconnect?

HID and HoG work a little bit different. HID uses a kernel transport driver while HoG uses /dev/uhid to do the work. Porting HID over to use /dev/uhid is certainly a possibility. We have considered that, but nobody has done that work yet.

Please remember that HID (with HIDP) is finding its right place in /sys device tree. While all HoG using /dev/uhid are considered virtual devices. There is a semi proposal that we agreed on New Orleans during the PlumbersConf, but I have no idea if David actually implemented it.

Another option is to make the HIDP transport smarter and persistent by integrating it into BlueZ 5’s kernel mgmt support. That however means you will need a much more recent Bluetooth subsystem. So 2.6.37 is not getting you anywhere near that even if we change HIDP support.

Regards

Marcel


^ permalink raw reply

* Questions on BlueZ 5.13: device creation API + persistent hid/input pipeline
From: Petri Gynther @ 2014-01-16 22:17 UTC (permalink / raw)
  To: linux-bluetooth

linux-bluetooth:

I'm running BlueZ 5.13 userland + backported BlueZ kernel modules on
an embedded system that I'm working on. The kernel on the system is
2.6.37-based. I ported uhid driver manually from 3.12.

I'm successfully using Bluetooth classic HID remote control and
Bluetooth LE HoG remote control on this system. However, I have two
questions:

1) The Bluetooth classic remote that I'm using is not discoverable. It
is only connectable. When the remote is not paired, it sends its
Bluetooth MAC address to the host via IR, and the host needs to add
this device to BlueZ's discovered devices database. But, how can I do
that via D-Bus API? BlueZ 5 porting guide specifically mentions that "
... we decided to simply get rid of explicit CreateDevice /
CreatePairedDevice methods and instead dynamically create device
objects as they are discovered during device discovery."

So, is there no API available to add non-discoverable devices in BlueZ 5?

I have worked around this issue by manually adding this remote to
<storage path>, so that bluetoothd creates the device on reboot via
device_create_from_storage(). But, I would prefer not to restart
bluetoothd every time a non-discoverable device needs to be added.


2) There is a difference in HID vs HoG hid/input pipeline persistence.
When the Bluetooth classic HID remote disconnects, the corresponding
hid and input kernel devices are destroyed. And when it reconnects,
hid and input devices are created again. This adds a lot of
unnecessary delay at reconnect. And, the first keypress is always lost
on reconnect.

In contrast, for the Bluetooth LE HoG remote, the hid/input pipeline
is persistent. When HoG remote disconnects, hid and input devices
remain in the system and are reused when the HoG remote reconnects.

Is there a way to make Bluetooth classic HID behave the same as HoG,
i.e. retain the hid and input kernel devices on disconnect and reuse
them on reconnect?

^ permalink raw reply

* Re: [PATCH 1/2] android: Add btmgmt to debug builds
From: Marcel Holtmann @ 2014-01-16 22:08 UTC (permalink / raw)
  To: Andrzej Kaczmarek; +Cc: linux-bluetooth@vger.kernel.org development
In-Reply-To: <1389883945-10707-1-git-send-email-andrzej.kaczmarek@tieto.com>

Hi Andrzej,

> android/Android.mk | 36 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 36 insertions(+)
> 
> diff --git a/android/Android.mk b/android/Android.mk
> index 7e97ec8..b3e6a50 100644
> --- a/android/Android.mk
> +++ b/android/Android.mk
> @@ -282,3 +282,39 @@ LOCAL_MODULE_TAGS := optional
> LOCAL_MODULE := bluetoothd-snoop
> 
> include $(BUILD_EXECUTABLE)
> +
> +#
> +# btmgmt
> +#
> +
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := \
> +	../tools/btmgmt.c \
> +	../monitor/mainloop.c \
> +	../lib/bluetooth.c \
> +	../lib/sdp.c \
> +	../src/eir.c \
> +	../src/glib-helper.c \
> +	../src/shared/io-mainloop.c \
> +	../src/shared/mgmt.c \
> +	../src/shared/queue.c \
> +	../src/shared/util.c \
> +
> +LOCAL_C_INCLUDES := \
> +	$(call include-path-for, glib) \
> +	$(call include-path-for, glib)/glib \
> +	$(LOCAL_PATH)/.. \
> +	$(LOCAL_PATH)/../src \
> +	$(LOCAL_PATH)/../lib \
> +
> +LOCAL_SHARED_LIBRARIES := \
> +	libglib \

have Johan fix the dependency on GLib instead. It should not be needed anymore.

Regards

Marcel


^ permalink raw reply

* Re: [PATCH] android/a2dp: Fix typo in condition
From: Luiz Augusto von Dentz @ 2014-01-16 15:54 UTC (permalink / raw)
  To: Andrzej Kaczmarek; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1389886700-21480-1-git-send-email-andrzej.kaczmarek@tieto.com>

Hi Andrzej,

On Thu, Jan 16, 2014 at 5:38 PM, Andrzej Kaczmarek
<andrzej.kaczmarek@tieto.com> wrote:
> ---
>  android/a2dp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/android/a2dp.c b/android/a2dp.c
> index 9b168ed..2288912 100644
> --- a/android/a2dp.c
> +++ b/android/a2dp.c
> @@ -1262,7 +1262,7 @@ static void bt_stream_open(const void *buf, uint16_t len)
>                 return;
>         }
>
> -       if (avdtp_stream_get_transport(setup->stream, &fd, NULL, NULL, NULL)) {
> +       if (!avdtp_stream_get_transport(setup->stream, &fd, NULL, NULL, NULL)) {
>                 error("avdtp_stream_get_transport: failed");
>                 audio_ipc_send_rsp(AUDIO_OP_OPEN_STREAM, AUDIO_STATUS_FAILED);
>                 return;
> --
> 1.8.5.2

Applied, thanks.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* [PATCH] android/a2dp: Fix typo in condition
From: Andrzej Kaczmarek @ 2014-01-16 15:38 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek

---
 android/a2dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/a2dp.c b/android/a2dp.c
index 9b168ed..2288912 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -1262,7 +1262,7 @@ static void bt_stream_open(const void *buf, uint16_t len)
 		return;
 	}
 
-	if (avdtp_stream_get_transport(setup->stream, &fd, NULL, NULL, NULL)) {
+	if (!avdtp_stream_get_transport(setup->stream, &fd, NULL, NULL, NULL)) {
 		error("avdtp_stream_get_transport: failed");
 		audio_ipc_send_rsp(AUDIO_OP_OPEN_STREAM, AUDIO_STATUS_FAILED);
 		return;
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH] add firmware update for Atheros 0cf3:311f
From: oliver @ 2014-01-16 15:02 UTC (permalink / raw)
  To: acho, marcel, gustavo, johan.hedberg, linux-bluetooth
  Cc: Oliver Neukum, Oliver Neukum
In-Reply-To: <1389884578-18479-1-git-send-email-oliver@neukum.org>

From: Oliver Neukum <oliver@neukum.org>

The device is not functional without firmware.

The device without firmware:
T:  Bus=02 Lev=02 Prnt=02 Port=05 Cnt=01 Dev#=  3 Spd=12  MxCh= 0
D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0cf3 ProdID=311f Rev=00.01
C:  #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
I:  If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb

The device with firmware:
T:  Bus=02 Lev=02 Prnt=02 Port=05 Cnt=01 Dev#=  4 Spd=12  MxCh= 0
D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0cf3 ProdID=3007 Rev=00.01
C:  #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
I:  If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb

Signed-off-by: Oliver Neukum <oneukum@suse.de>
---
 drivers/bluetooth/ath3k.c | 2 ++
 drivers/bluetooth/btusb.c | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index b0a875b..3822621 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -78,6 +78,7 @@ static const struct usb_device_id ath3k_table[] = {
 	{ USB_DEVICE(0x0CF3, 0x3008) },
 	{ USB_DEVICE(0x0CF3, 0x311D) },
 	{ USB_DEVICE(0x0CF3, 0x311E) },
+	{ USB_DEVICE(0x0CF3, 0x311F) },
 	{ USB_DEVICE(0x0CF3, 0x817a) },
 	{ USB_DEVICE(0x13d3, 0x3375) },
 	{ USB_DEVICE(0x04CA, 0x3004) },
@@ -121,6 +122,7 @@ static const struct usb_device_id ath3k_blist_tbl[] = {
 	{ USB_DEVICE(0x0cf3, 0x3008), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0x311D), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0x311E), .driver_info = BTUSB_ATH3012 },
+	{ USB_DEVICE(0x0cf3, 0x311F), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0CF3, 0x817a), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 },
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index e15b580..9f61dde 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -145,6 +145,7 @@ static const struct usb_device_id blacklist_table[] = {
 	{ USB_DEVICE(0x0cf3, 0x3008), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0x311e), .driver_info = BTUSB_ATH3012 },
+	{ USB_DEVICE(0x0cf3, 0x311f), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0x817a), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 },
-- 
1.8.4

^ permalink raw reply related

* [PATCH] add firmware update for Atheros 0cf3:311f
From: oliver @ 2014-01-16 15:02 UTC (permalink / raw)
  To: acho, marcel, gustavo, johan.hedberg, linux-bluetooth
  Cc: Oliver Neukum, Oliver Neukum

From: Oliver Neukum <oliver@neukum.org>

The device is not functional without firmware.

The device without firmware:
T:  Bus=02 Lev=02 Prnt=02 Port=05 Cnt=01 Dev#=  3 Spd=12  MxCh= 0
D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0cf3 ProdID=311f Rev=00.01
C:  #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
I:  If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb

The device with firmware:
T:  Bus=02 Lev=02 Prnt=02 Port=05 Cnt=01 Dev#=  4 Spd=12  MxCh= 0
D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0cf3 ProdID=3007 Rev=00.01
C:  #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
I:  If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb

Signed-off-by: Oliver Neukum <oneukum@suse.de>
---
 drivers/bluetooth/ath3k.c | 2 ++
 drivers/bluetooth/btusb.c | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index b0a875b..3822621 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -78,6 +78,7 @@ static const struct usb_device_id ath3k_table[] = {
 	{ USB_DEVICE(0x0CF3, 0x3008) },
 	{ USB_DEVICE(0x0CF3, 0x311D) },
 	{ USB_DEVICE(0x0CF3, 0x311E) },
+	{ USB_DEVICE(0x0CF3, 0x311F) },
 	{ USB_DEVICE(0x0CF3, 0x817a) },
 	{ USB_DEVICE(0x13d3, 0x3375) },
 	{ USB_DEVICE(0x04CA, 0x3004) },
@@ -121,6 +122,7 @@ static const struct usb_device_id ath3k_blist_tbl[] = {
 	{ USB_DEVICE(0x0cf3, 0x3008), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0x311D), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0x311E), .driver_info = BTUSB_ATH3012 },
+	{ USB_DEVICE(0x0cf3, 0x311F), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0CF3, 0x817a), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 },
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index e15b580..9f61dde 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -145,6 +145,7 @@ static const struct usb_device_id blacklist_table[] = {
 	{ USB_DEVICE(0x0cf3, 0x3008), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0x311e), .driver_info = BTUSB_ATH3012 },
+	{ USB_DEVICE(0x0cf3, 0x311f), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0x817a), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 },
-- 
1.8.4

^ permalink raw reply related

* [PATCH 2/2] android: Add l2ping to debug builds
From: Andrzej Kaczmarek @ 2014-01-16 14:52 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1389883945-10707-1-git-send-email-andrzej.kaczmarek@tieto.com>

---
 android/Android.mk | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/android/Android.mk b/android/Android.mk
index b3e6a50..d2009d7 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -318,3 +318,25 @@ LOCAL_MODULE_TAGS := debug
 LOCAL_MODULE := btmgmt
 
 include $(BUILD_EXECUTABLE)
+
+#
+# l2ping
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	../tools/l2ping.c \
+	../lib/bluetooth.c \
+	../lib/hci.c \
+
+LOCAL_C_INCLUDES := \
+	$(LOCAL_PATH)/../lib \
+
+LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE := l2ping
+
+include $(BUILD_EXECUTABLE)
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 1/2] android: Add btmgmt to debug builds
From: Andrzej Kaczmarek @ 2014-01-16 14:52 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek

---
 android/Android.mk | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/android/Android.mk b/android/Android.mk
index 7e97ec8..b3e6a50 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -282,3 +282,39 @@ LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE := bluetoothd-snoop
 
 include $(BUILD_EXECUTABLE)
+
+#
+# btmgmt
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	../tools/btmgmt.c \
+	../monitor/mainloop.c \
+	../lib/bluetooth.c \
+	../lib/sdp.c \
+	../src/eir.c \
+	../src/glib-helper.c \
+	../src/shared/io-mainloop.c \
+	../src/shared/mgmt.c \
+	../src/shared/queue.c \
+	../src/shared/util.c \
+
+LOCAL_C_INCLUDES := \
+	$(call include-path-for, glib) \
+	$(call include-path-for, glib)/glib \
+	$(LOCAL_PATH)/.. \
+	$(LOCAL_PATH)/../src \
+	$(LOCAL_PATH)/../lib \
+
+LOCAL_SHARED_LIBRARIES := \
+	libglib \
+
+LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE := btmgmt
+
+include $(BUILD_EXECUTABLE)
-- 
1.8.5.2


^ permalink raw reply related

* Re: [PATCH v2] android/bluetooth: Fix discovering new devices
From: Szymon Janc @ 2014-01-16 14:50 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <20140116135032.GA1267@x220.p-661hnu-f1>

Hi,

On Thursday 16 of January 2014 15:50:32 Johan Hedberg wrote:
> Hi Szymon,
> 
> On Thu, Jan 16, 2014, Szymon Janc wrote:
> > @@ -983,12 +994,15 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
> >  	eir_parse(&eir, data, data_len);
> >  
> >  	dev = find_device(bdaddr);
> > -	if (!dev) {
> > +	if (!dev || !dev->found) {
> 
> I think this would still deserve a code comment here explaining why
> dev->found is important. Other than that the patch is fine, so feel free
> to push it yourself once you've added the comment.

Pushed.

-- 
Best regards, 
Szymon Janc

^ permalink raw reply

* [PATCH] enable Atheros 0cf3:311e for firmware upload
From: oliver @ 2014-01-16 14:37 UTC (permalink / raw)
  To: acho, marcel, gustavo, johan.hedberg, linux-bluetooth
  Cc: Oliver Neukum, Oliver Neukum
In-Reply-To: <1389883031-10752-1-git-send-email-oliver@neukum.org>

From: Oliver Neukum <oliver@neukum.org>

The device will bind to btusb without firmware, but with the original
buggy firmware device discovery does not work. No devices are detected.

Device descriptor without firmware:
T:  Bus=03 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#=  2 Spd=12   MxCh= 0
D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0cf3 ProdID=311e Rev= 0.01
C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms

with firmware:
T:  Bus=03 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#=  3 Spd=12   MxCh= 0
D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0cf3 ProdID=311e Rev= 0.02
C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms

Signed-off-by: Oliver Neukum <oneukum@suse.de>
---
 drivers/bluetooth/ath3k.c | 2 ++
 drivers/bluetooth/btusb.c | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index 6bfc1bb..b0a875b 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -77,6 +77,7 @@ static const struct usb_device_id ath3k_table[] = {
 	{ USB_DEVICE(0x0CF3, 0x3004) },
 	{ USB_DEVICE(0x0CF3, 0x3008) },
 	{ USB_DEVICE(0x0CF3, 0x311D) },
+	{ USB_DEVICE(0x0CF3, 0x311E) },
 	{ USB_DEVICE(0x0CF3, 0x817a) },
 	{ USB_DEVICE(0x13d3, 0x3375) },
 	{ USB_DEVICE(0x04CA, 0x3004) },
@@ -119,6 +120,7 @@ static const struct usb_device_id ath3k_blist_tbl[] = {
 	{ USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0x3008), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0x311D), .driver_info = BTUSB_ATH3012 },
+	{ USB_DEVICE(0x0cf3, 0x311E), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0CF3, 0x817a), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 },
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index c0ff34f..e15b580 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -144,6 +144,7 @@ static const struct usb_device_id blacklist_table[] = {
 	{ USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0x3008), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 },
+	{ USB_DEVICE(0x0cf3, 0x311e), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0x817a), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 },
-- 
1.8.4

^ permalink raw reply related

* [PATCH] enable Atheros 0cf3:311e for firmware upload
From: oliver @ 2014-01-16 14:37 UTC (permalink / raw)
  To: acho, marcel, gustavo, johan.hedberg, linux-bluetooth
  Cc: Oliver Neukum, Oliver Neukum

From: Oliver Neukum <oliver@neukum.org>

The device will bind to btusb without firmware, but with the original
buggy firmware device discovery does not work. No devices are detected.

Device descriptor without firmware:
T:  Bus=03 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#=  2 Spd=12   MxCh= 0
D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0cf3 ProdID=311e Rev= 0.01
C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms

with firmware:
T:  Bus=03 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#=  3 Spd=12   MxCh= 0
D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0cf3 ProdID=311e Rev= 0.02
C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms

Signed-off-by: Oliver Neukum <oneukum@suse.de>
---
 drivers/bluetooth/ath3k.c | 2 ++
 drivers/bluetooth/btusb.c | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index 6bfc1bb..b0a875b 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -77,6 +77,7 @@ static const struct usb_device_id ath3k_table[] = {
 	{ USB_DEVICE(0x0CF3, 0x3004) },
 	{ USB_DEVICE(0x0CF3, 0x3008) },
 	{ USB_DEVICE(0x0CF3, 0x311D) },
+	{ USB_DEVICE(0x0CF3, 0x311E) },
 	{ USB_DEVICE(0x0CF3, 0x817a) },
 	{ USB_DEVICE(0x13d3, 0x3375) },
 	{ USB_DEVICE(0x04CA, 0x3004) },
@@ -119,6 +120,7 @@ static const struct usb_device_id ath3k_blist_tbl[] = {
 	{ USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0x3008), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0x311D), .driver_info = BTUSB_ATH3012 },
+	{ USB_DEVICE(0x0cf3, 0x311E), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0CF3, 0x817a), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 },
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index c0ff34f..e15b580 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -144,6 +144,7 @@ static const struct usb_device_id blacklist_table[] = {
 	{ USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0x3008), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 },
+	{ USB_DEVICE(0x0cf3, 0x311e), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0x817a), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 },
-- 
1.8.4

^ permalink raw reply related

* Re: [PATCH v2 00/11] Audio HAL implementation
From: Luiz Augusto von Dentz @ 2014-01-16 14:13 UTC (permalink / raw)
  To: Andrzej Kaczmarek; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1389809037-11575-1-git-send-email-andrzej.kaczmarek@tieto.com>

Hi Andrzej,

On Wed, Jan 15, 2014 at 8:03 PM, Andrzej Kaczmarek
<andrzej.kaczmarek@tieto.com> wrote:
> Hi,
>
> changes v1 -> v2
> - fixed comments from Luiz
> - removed "codec_" prefix from function related to SBC codec
> - additional patch to implement set_parameters for audio device
>   (A2dpSuspend is initialized this way)
> - changes dummy buffer size to 20*512 which is inline with Bluedroid
>   (AudioFlinger does crash when closing output stream when set to 512)
>
>
> Andrzej Kaczmarek (10):
>   android/hal-audio: Add support to register audio endpoints
>   android/hal-audio: Add support to unregister audio endpoints
>   android/hal-audio: Add support to open output stream
>   android/hal-audio: Add support to close output stream
>   android/hal-audio: Add support to resume output stream
>   android/hal-audio: Add support to suspend output stream
>   android/hal-audio: Handle audio preset from stream
>   android/hal-audio: Fix module loading
>   android/hal-audio: Fix AudioFlinger crash
>   android/hal-audio: Implement set_parameters for device
>
> Lukasz Rymanowski (1):
>   android/hal-audio: Add audio_ipc_cmd
>
>  android/Makefile.am |   1 +
>  android/hal-audio.c | 729 +++++++++++++++++++++++++++++++++++++++++++++++++---
>  2 files changed, 696 insertions(+), 34 deletions(-)
>
> --
> 1.8.5.2

Pushed, thanks.

-- 
Luiz Augusto von Dentz

^ permalink raw reply

* Re: [PATCH v2] android/bluetooth: Fix discovering new devices
From: Johan Hedberg @ 2014-01-16 13:50 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1389879325-21217-1-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Thu, Jan 16, 2014, Szymon Janc wrote:
> @@ -983,12 +994,15 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
>  	eir_parse(&eir, data, data_len);
>  
>  	dev = find_device(bdaddr);
> -	if (!dev) {
> +	if (!dev || !dev->found) {

I think this would still deserve a code comment here explaining why
dev->found is important. Other than that the patch is fine, so feel free
to push it yourself once you've added the comment.

Johan

^ permalink raw reply

* [PATCH v2] android/bluetooth: Fix discovering new devices
From: Szymon Janc @ 2014-01-16 13:35 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

Device found events should be send also for known devices if this is
new discovery session. Otherwise Android will ignore those devices.
---
V2: report bonded devices in same way as non-bonded


 android/bluetooth.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/android/bluetooth.c b/android/bluetooth.c
index f1e5458..b235cbd 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -90,6 +90,8 @@ struct device {
 	uint32_t timestamp;
 
 	GSList *uuids;
+
+	bool found; /* if device is found in current discovery session */
 };
 
 struct browse_req {
@@ -903,6 +905,13 @@ static void user_passkey_notify_callback(uint16_t index, uint16_t length,
 	send_ssp_request(&ev->addr.bdaddr, HAL_SSP_VARIANT_NOTIF, ev->passkey);
 }
 
+static void clear_device_found(gpointer data, gpointer user_data)
+{
+	struct device *dev = data;
+
+	dev->found = false;
+}
+
 static void mgmt_discovering_event(uint16_t index, uint16_t length,
 					const void *param, void *user_data)
 {
@@ -924,10 +933,12 @@ static void mgmt_discovering_event(uint16_t index, uint16_t length,
 
 	DBG("new discovering state %u", ev->discovering);
 
-	if (adapter.discovering)
+	if (adapter.discovering) {
 		cp.state = HAL_DISCOVERY_STATE_STARTED;
-	else
+	} else {
+		g_slist_foreach(devices, clear_device_found, NULL);
 		cp.state = HAL_DISCOVERY_STATE_STOPPED;
+	}
 
 	ipc_send_notif(HAL_SERVICE_ID_BLUETOOTH,
 			HAL_EV_DISCOVERY_STATE_CHANGED, sizeof(cp), &cp);
@@ -983,12 +994,15 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
 	eir_parse(&eir, data, data_len);
 
 	dev = find_device(bdaddr);
-	if (!dev) {
+	if (!dev || !dev->found) {
 		struct hal_ev_device_found *ev = (void *) buf;
 		bdaddr_t android_bdaddr;
 		uint8_t android_type;
 
-		dev = create_device(bdaddr, bdaddr_type);
+		if (!dev)
+			dev = create_device(bdaddr, bdaddr_type);
+
+		dev->found = true;
 
 		size += sizeof(*ev);
 
-- 
1.8.3.2


^ permalink raw reply related

* Re: [PATCHv3 08/19] emulator/bthost: Add rfcomm_mcc_recv stub
From: Johan Hedberg @ 2014-01-16 12:04 UTC (permalink / raw)
  To: Marcin Kraglak; +Cc: linux-bluetooth
In-Reply-To: <1389345509-27206-9-git-send-email-marcin.kraglak@tieto.com>

Hi Marcin,

On Fri, Jan 10, 2014, Marcin Kraglak wrote:
> It will handle mcc frames in bthost.
> ---
>  emulator/bthost.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)

All patches are pushed with lots of cleanups on top.

This one I couldn't quite understand.

> diff --git a/emulator/bthost.c b/emulator/bthost.c
> index 242ce19..591aae9 100644
> --- a/emulator/bthost.c
> +++ b/emulator/bthost.c
> @@ -1387,10 +1387,29 @@ static void rfcomm_dm_recv(struct bthost *bthost, struct btconn *conn,
>  {
>  }
>  
> +static void rfcomm_mcc_recv(struct bthost *bthost, struct btconn *conn,
> +			struct l2conn *l2conn, const void *data, uint16_t len)
> +{
> +}
> +
>  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 void *p;
> +	uint8_t ea;
> +
> +	ea = RFCOMM_TEST_EA(hdr->length) ? true : false;
> +
> +	if (!RFCOMM_GET_DLCI(hdr->address)) {
> +		if (ea)
> +			p = data + sizeof(struct rfcomm_hdr);
> +		else
> +			p = data + sizeof(struct rfcomm_hdr) + sizeof(uint8_t);
> +
> +		rfcomm_mcc_recv(bthost, conn, l2conn, p, p - data);
> +	}

(first of all, the above got already cleaned up to a slightly simpler
form upstream)

This "p - data" seems to be the length of data that rfcomm mcc_recv
should consume starting at p, right? In that case "p - data" will become
sizeof(struct rfcomm_hdr) or sizeof(struct rfcomm_hdr) +
sizeof(uint8_t), i.e. not the amount of data after p but the amount of
data before p! I.e. shouldn't you be subtracting these amounts from len
instead to get what you need to pass to rfcomm_mcc_recv?

In general, I think you'd be better off with not doing this kind of
pointer arithmetic to begin with (as it already lead to this bug).
Instead just use clear "len" variables for tracking the amount of data
behind some pointer. Also, you seem to be missing lots of checks for
such length variables in the code before accessing the data behind the
pointer. Please fix that too (the only reason why your code was working
is that rfcomm_mcc_recv never checks the length variable).

Johan

^ permalink raw reply

* Re: [PATCH] android/bluetooth: Fix discovering new devices
From: Szymon Janc @ 2014-01-16 10:22 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <20140114113920.GD4709@x220.p-661hnu-f1>

Hi Johan,

On Tuesday 14 of January 2014 13:39:20 Johan Hedberg wrote:
> Hi Szymon,
> 
> On Tue, Jan 14, 2014, Szymon Janc wrote:
> > +	} else {
> > +		GSList *l;
> > +
> > +		for(l = devices; l; l = g_slist_next(l)) {
> 
> Coding style thing here (space after 'for'). You might wanna consider a
> helper function and g_slist_foreach here tough.
> 
> > +static bool device_found_needed(struct device *dev)
> > +{
> > +	if (!dev)
> > +		return true;
> > +
> > +	if (dev->bond_state == HAL_BOND_STATE_BONDED)
> > +		return false;
> > +
> > +	return !dev->found;
> > +}
> 
> I think you should provide lots more code comments here with proper
> explanations of each if-statement. E.g. your commit message doesn't
> mention anything about bonded devices and yet you have a check for this
> state here.

Now I think this check is not really needed, if paired remote is responding to
inquiry then just notify HAL as with any other device found.

I'll send V2 shortly.


-- 
Best regards, 
Szymon Janc

^ permalink raw reply

* [PATCHv3 5/5] android/unit: Add /android_ipc/send_cmd_3 test case
From: Marcin Kraglak @ 2014-01-16 10:05 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389866702-30697-1-git-send-email-marcin.kraglak@tieto.com>

This case will register service, next unregister it and send
command. Expected status is raise SIGTERM.
---
 android/test-ipc.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/android/test-ipc.c b/android/test-ipc.c
index 930f9f4..1fde61b 100644
--- a/android/test-ipc.c
+++ b/android/test-ipc.c
@@ -306,6 +306,16 @@ static gboolean register_service(gpointer user_data)
 	return FALSE;
 }
 
+static gboolean unregister_service(gpointer user_data)
+{
+	struct context *context = user_data;
+	const struct test_data *test_data = context->data;
+
+	ipc_unregister(test_data->service);
+
+	return FALSE;
+}
+
 static void test_cmd(gconstpointer data)
 {
 	struct context *context = create_context(data);
@@ -336,6 +346,21 @@ static void test_cmd_reg(gconstpointer data)
 	ipc_cleanup();
 }
 
+static void test_cmd_reg_1(gconstpointer data)
+{
+	struct context *context = create_context(data);
+
+	ipc_init();
+
+	g_idle_add(register_service, context);
+	g_idle_add(unregister_service, context);
+	g_idle_add(send_cmd, context);
+
+	execute_context(context);
+
+	ipc_cleanup();
+}
+
 static void test_cmd_handler(const void *buf, uint16_t len)
 {
 	ipc_send_rsp(0, 1, 0);
@@ -367,6 +392,15 @@ static const struct test_data test_cmd_2 = {
 	.handlers_size = 1
 };
 
+static const struct test_data test_cmd_3 = {
+	.cmd = &test_cmd_1_hdr,
+	.cmd_size = sizeof(test_cmd_1_hdr),
+	.service = 0,
+	.handlers = cmd_handlers,
+	.handlers_size = 1,
+	.expected_signal = SIGTERM
+};
+
 int main(int argc, char *argv[])
 {
 	g_test_init(&argc, &argv, NULL);
@@ -378,6 +412,8 @@ int main(int argc, char *argv[])
 	g_test_add_data_func("/android_ipc/send_cmd_1", &test_cmd_1, test_cmd);
 	g_test_add_data_func("/android_ipc/send_cmd_2", &test_cmd_2,
 							test_cmd_reg);
+	g_test_add_data_func("/android_ipc/send_cmd_3", &test_cmd_3,
+							test_cmd_reg_1);
 
 	return g_test_run();
 }
-- 
1.8.3.1


^ permalink raw reply related

* [PATCHv3 4/5] android/unit: Add /android_ipc/send_cmd_2 test case
From: Marcin Kraglak @ 2014-01-16 10:05 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389866702-30697-1-git-send-email-marcin.kraglak@tieto.com>

This will test sending command to previously registered service.
---
 android/test-ipc.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/android/test-ipc.c b/android/test-ipc.c
index 99f8559..930f9f4 100644
--- a/android/test-ipc.c
+++ b/android/test-ipc.c
@@ -46,6 +46,9 @@ struct test_data {
 	uint32_t expected_signal;
 	const struct hal_hdr *cmd;
 	uint16_t cmd_size;
+	uint8_t service;
+	const struct ipc_handler *handlers;
+	uint8_t handlers_size;
 };
 
 struct context {
@@ -74,11 +77,23 @@ static void context_quit(struct context *context)
 static gboolean cmd_watch(GIOChannel *io, GIOCondition cond,
 						gpointer user_data)
 {
+	struct context *context = user_data;
+	const struct test_data *test_data = context->data;
+	uint8_t buf[128];
+	int sk;
+
 	if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) {
 		g_assert(FALSE);
 		return FALSE;
 	}
 
+	sk = g_io_channel_unix_get_fd(io);
+
+	g_assert(read(sk, buf, sizeof(buf)) == test_data->cmd_size);
+	g_assert(!memcmp(test_data->cmd, buf, test_data->cmd_size));
+
+	context_quit(context);
+
 	return TRUE;
 }
 
@@ -280,6 +295,17 @@ static gboolean send_cmd(gpointer user_data)
 	return FALSE;
 }
 
+static gboolean register_service(gpointer user_data)
+{
+	struct context *context = user_data;
+	const struct test_data *test_data = context->data;
+
+	ipc_register(test_data->service, test_data->handlers,
+						test_data->handlers_size);
+
+	return FALSE;
+}
+
 static void test_cmd(gconstpointer data)
 {
 	struct context *context = create_context(data);
@@ -293,6 +319,28 @@ static void test_cmd(gconstpointer data)
 	ipc_cleanup();
 }
 
+static void test_cmd_reg(gconstpointer data)
+{
+	struct context *context = create_context(data);
+	const struct test_data *test_data = context->data;
+
+	ipc_init();
+
+	g_idle_add(register_service, context);
+	g_idle_add(send_cmd, context);
+
+	execute_context(context);
+
+	ipc_unregister(test_data->service);
+
+	ipc_cleanup();
+}
+
+static void test_cmd_handler(const void *buf, uint16_t len)
+{
+	ipc_send_rsp(0, 1, 0);
+}
+
 static const struct test_data test_init_1 = {};
 
 static const struct hal_hdr test_cmd_1_hdr = {
@@ -307,6 +355,18 @@ static const struct test_data test_cmd_1 = {
 	.expected_signal = SIGTERM
 };
 
+static const struct ipc_handler cmd_handlers[] = {
+	{ test_cmd_handler, false, 0 }
+};
+
+static const struct test_data test_cmd_2 = {
+	.cmd = &test_cmd_1_hdr,
+	.cmd_size = sizeof(test_cmd_1_hdr),
+	.service = 0,
+	.handlers = cmd_handlers,
+	.handlers_size = 1
+};
+
 int main(int argc, char *argv[])
 {
 	g_test_init(&argc, &argv, NULL);
@@ -316,6 +376,8 @@ int main(int argc, char *argv[])
 
 	g_test_add_data_func("/android_ipc/init", &test_init_1, test_init);
 	g_test_add_data_func("/android_ipc/send_cmd_1", &test_cmd_1, test_cmd);
+	g_test_add_data_func("/android_ipc/send_cmd_2", &test_cmd_2,
+							test_cmd_reg);
 
 	return g_test_run();
 }
-- 
1.8.3.1


^ permalink raw reply related

* [PATCHv3 3/5] android/unit: Add /android_ipc/send_cmd_1 test case
From: Marcin Kraglak @ 2014-01-16 10:05 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1389866702-30697-1-git-send-email-marcin.kraglak@tieto.com>

This test case will check if ipc lib will raise SIGTERM
after sending command to not registered service.
---
 android/test-ipc.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/android/test-ipc.c b/android/test-ipc.c
index 6ac1175..99f8559 100644
--- a/android/test-ipc.c
+++ b/android/test-ipc.c
@@ -44,6 +44,8 @@
 
 struct test_data {
 	uint32_t expected_signal;
+	const struct hal_hdr *cmd;
+	uint16_t cmd_size;
 };
 
 struct context {
@@ -95,6 +97,7 @@ static gboolean connect_handler(GIOChannel *io, GIOCondition cond,
 						gpointer user_data)
 {
 	struct context *context = user_data;
+	const struct test_data *test_data = context->data;
 	GIOChannel *new_io;
 	GIOCondition watch_cond;
 	int sk;
@@ -126,7 +129,7 @@ static gboolean connect_handler(GIOChannel *io, GIOCondition cond,
 		context->cmd_io = new_io;
 	}
 
-	if (context->cmd_source && context->notif_source)
+	if (context->cmd_source && context->notif_source && !test_data->cmd)
 		context_quit(context);
 
 	return TRUE;
@@ -262,8 +265,48 @@ static void test_init(gconstpointer data)
 	ipc_cleanup();
 }
 
+static gboolean send_cmd(gpointer user_data)
+{
+	struct context *context = user_data;
+	const struct test_data *test_data = context->data;
+	int sk;
+
+	sk = g_io_channel_unix_get_fd(context->cmd_io);
+	g_assert(sk >= 0);
+
+	g_assert(write(sk, test_data->cmd, test_data->cmd_size) ==
+						test_data->cmd_size);
+
+	return FALSE;
+}
+
+static void test_cmd(gconstpointer data)
+{
+	struct context *context = create_context(data);
+
+	ipc_init();
+
+	g_idle_add(send_cmd, context);
+
+	execute_context(context);
+
+	ipc_cleanup();
+}
+
 static const struct test_data test_init_1 = {};
 
+static const struct hal_hdr test_cmd_1_hdr = {
+	.service_id = 0,
+	.opcode = 1,
+	.len = 0
+};
+
+static const struct test_data test_cmd_1 = {
+	.cmd = &test_cmd_1_hdr,
+	.cmd_size = sizeof(test_cmd_1_hdr),
+	.expected_signal = SIGTERM
+};
+
 int main(int argc, char *argv[])
 {
 	g_test_init(&argc, &argv, NULL);
@@ -272,6 +315,7 @@ int main(int argc, char *argv[])
 		__btd_log_init("*", 0);
 
 	g_test_add_data_func("/android_ipc/init", &test_init_1, test_init);
+	g_test_add_data_func("/android_ipc/send_cmd_1", &test_cmd_1, test_cmd);
 
 	return g_test_run();
 }
-- 
1.8.3.1


^ 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