Linux bluetooth development
 help / color / mirror / Atom feed
* Re: [PATCHv2 4/6] android: Add supported uuids when adapter is initialized
From: Marcel Holtmann @ 2013-11-06  8:41 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: Marcin Kraglak, linux-bluetooth@vger.kernel.org development
In-Reply-To: <20131106080254.GA15573@x220.p-661hnu-f1>

Hi Johan,

>> It will set class of device with proper service hints.
>> We set it statically because we want to keep code simple.
>> 
>> ---
>> android/adapter.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 59 insertions(+)
> 
> I've applied patches 1-3, but am a bit confused about this one.
> 
>> diff --git a/android/adapter.c b/android/adapter.c
>> index 0f24cac..70b9265 100644
>> --- a/android/adapter.c
>> +++ b/android/adapter.c
>> @@ -52,6 +52,29 @@ static GIOChannel *notification_io = NULL;
>> /* This list contains addresses which are asked for records */
>> static GSList *browse_reqs;
>> 
>> +/*
>> + * This is an array of supported uuids and service hints. We add them via mgmt
>> + * interface when adapter is initialized. Uuids are in reverse orded.
>> + */
>> +static const struct mgmt_cp_add_uuid supported_services[] = {
>> +	/* OBEX_OPP_UUID */
>> +	{ .uuid = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
>> +			0x00, 0x10, 0x00, 0x00, 0x05, 0x11, 0x00, 0x00 },
>> +	.svc_hint = 0x10 },
>> +	/* HFP_AG_UUID */
>> +	{ .uuid = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
>> +			0x00, 0x10, 0x00, 0x00, 0x1f, 0x11, 0x00, 0x00 },
>> +	.svc_hint = 0x40 },
>> +	/* ADVANCED_AUDIO_UUID */
>> +	{ .uuid = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
>> +			0x00, 0x10, 0x00, 0x00, 0x0d, 0x11, 0x00, 0x00 },
>> +	.svc_hint = 0x08 },
>> +	/* PANU_UUID */
>> +	{ .uuid = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
>> +			0x00, 0x10, 0x00, 0x00, 0x15, 0x11, 0x00, 0x00 },
>> +	.svc_hint = 0x02 }
>> +};
> 
> I seem to remember the discussion around this drifting back to doing the
> registration dynamically. Do I remember wrong? Wasn't it so that at
> least some UUIDs (such as PAN) with a bluedroid based system only appear
> when you actually enable support for the profile in the UI?

looking at a Nexus 4, the SDP database seems static. The PAN record is always present.

I think dynamic is on the level do we compile in support for the PAN HAL module or not. So the record and UUID list should come from the PAN module. So it is kinda dynamic in that sense, but ultimately static.

Regards

Marcel


^ permalink raw reply

* Re: [PATCH_v4 00/12] Implemented hid interfaces in daemon and HAL
From: Johan Hedberg @ 2013-11-06  8:37 UTC (permalink / raw)
  To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1383685758-3900-1-git-send-email-ravikumar.veeramally@linux.intel.com>

Hi Ravi,

On Tue, Nov 05, 2013, Ravi kumar Veeramally wrote:
> v4: Fixed Johan's comments (length issue and single byte array)
> 
> v3: Wrong order of patches
> 
> v2: Fixed Johan's comments (splitting of patches, proper function and
>     struct names, update hal-msg.h and ipc document, alignment issues
>     removed pointer from ipc struct)
> 
> v1: This patch set implements get/set protocol and get/set report
>     interfaces and supported functionality in daemon. Sending notifications
>     and notification handling in hal. Few naming fixes and error handling.
>     And last handling of few uHID events.
> 
> Ravi kumar Veeramally (12):
>   android/hid: Implement hid get protocol in daemon
>   android/hid: Implement hid set protocol in daemon
>   android/hid: Handle protocol mode notification in HAL
>   android/hid: Add hid event get report structure to HAL msg headers
>   android/hid: Implement hid get report in daemon
>   android/hid: Add missing set report parameters to ipc document
>   android/hid: Implement hid set report in daemon
>   android/hid: Handle get report notification in HAL
>   android/hid: Replace header checking magic number with defines
>   android/hid: Handle invalid parameters in HAL
>   android/hid: Handle uhid events
>   android/hid: Align hal hid struct variables properly
> 
>  android/hal-hidhost.c   |  41 +++++-
>  android/hal-ipc-api.txt |   4 +-
>  android/hal-msg.h       |  32 +++--
>  android/hid.c           | 325 ++++++++++++++++++++++++++++++++++++++++++++++--
>  4 files changed, 372 insertions(+), 30 deletions(-)

I've applied all patches, but I also did some minor cleanups while
applying (e.g. to the documentation patch) and some bigger ones as
separate patches on top of this set.

Johan

^ permalink raw reply

* Re: [PATCH 1/2] android/debug: Export print uuid function
From: Andrei Emeltchenko @ 2013-11-06  8:32 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth@vger.kernel.org development
In-Reply-To: <C04753B6-1BA7-459F-830F-981D46C10AF3@holtmann.org>

Hi Marcel,

On Tue, Nov 05, 2013 at 05:56:08PM +0100, Marcel Holtmann wrote:
> Hi Andrei,
> 
> > The function will be reused in socket HAL.
> > ---
> > android/client/textconv.c |    2 +-
> > android/client/textconv.h |    1 +
> > 2 files changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/android/client/textconv.c b/android/client/textconv.c
> > index 9a2f7e6..e6f327f 100644
> > --- a/android/client/textconv.c
> > +++ b/android/client/textconv.c
> > @@ -237,7 +237,7 @@ char *bdaddr2str(const bt_bdaddr_t *bd_addr)
> > 	return bt_bdaddr_t2str(bd_addr, bdaddr_tls_buffer);
> > }
> > 
> > -static char *btuuid2str(const bt_uuid_t *uuid)
> > +char *btuuid2str(const bt_uuid_t *uuid)
> > {
> > 	static char buf[MAX_UUID_STR_LEN];
> > 
> > diff --git a/android/client/textconv.h b/android/client/textconv.h
> > index 1c848ef..7520b04 100644
> > --- a/android/client/textconv.h
> > +++ b/android/client/textconv.h
> > @@ -109,6 +109,7 @@ void str2bt_uuid_t(const char *str, bt_uuid_t *uuid);
> > 
> > char *btproperty2str(const bt_property_t *property);
> > char *bdaddr2str(const bt_bdaddr_t *bd_addr);
> > +char *btuuid2str(const bt_uuid_t *uuid);
> 
> this is totally backwards then. The HAL should not depend on client code.
> 

So shall the function be moved to utils.c inside android or even better
src/shared?

Best regards 
Andrei Emeltchenko 

^ permalink raw reply

* Re: [PATCHv2 4/6] android: Add supported uuids when adapter is initialized
From: Marcin Kraglak @ 2013-11-06  8:27 UTC (permalink / raw)
  To: Marcin Kraglak, linux-bluetooth
In-Reply-To: <20131106080254.GA15573@x220.p-661hnu-f1>

As I remember we agreed to have dynamic sdp records and static list of
uuids (to have correct service hint in class of device). Bluedroid
sets service hint once, and send new adapter uuids when specific
services starts (for example when you init hidhost,
adapter_property_callback will return with new uuid). But it doesn't
matter if you add them at start of bluetooth interface or specific
profile init - it happens at the same time. I've also checked if uuids
are removed when profiles are cleaned - and bluedroid doesn't remove
uuids which were added at start.

On 6 November 2013 09:02, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Marcin,
>
> On Tue, Nov 05, 2013, Marcin Kraglak wrote:
>> It will set class of device with proper service hints.
>> We set it statically because we want to keep code simple.
>>
>> ---
>>  android/adapter.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 59 insertions(+)
>
> I've applied patches 1-3, but am a bit confused about this one.
>
>> diff --git a/android/adapter.c b/android/adapter.c
>> index 0f24cac..70b9265 100644
>> --- a/android/adapter.c
>> +++ b/android/adapter.c
>> @@ -52,6 +52,29 @@ static GIOChannel *notification_io = NULL;
>>  /* This list contains addresses which are asked for records */
>>  static GSList *browse_reqs;
>>
>> +/*
>> + * This is an array of supported uuids and service hints. We add them via mgmt
>> + * interface when adapter is initialized. Uuids are in reverse orded.
>> + */
>> +static const struct mgmt_cp_add_uuid supported_services[] = {
>> +     /* OBEX_OPP_UUID */
>> +     { .uuid = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
>> +                     0x00, 0x10, 0x00, 0x00, 0x05, 0x11, 0x00, 0x00 },
>> +     .svc_hint = 0x10 },
>> +     /* HFP_AG_UUID */
>> +     { .uuid = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
>> +                     0x00, 0x10, 0x00, 0x00, 0x1f, 0x11, 0x00, 0x00 },
>> +     .svc_hint = 0x40 },
>> +     /* ADVANCED_AUDIO_UUID */
>> +     { .uuid = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
>> +                     0x00, 0x10, 0x00, 0x00, 0x0d, 0x11, 0x00, 0x00 },
>> +     .svc_hint = 0x08 },
>> +     /* PANU_UUID */
>> +     { .uuid = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
>> +                     0x00, 0x10, 0x00, 0x00, 0x15, 0x11, 0x00, 0x00 },
>> +     .svc_hint = 0x02 }
>> +};
>
> I seem to remember the discussion around this drifting back to doing the
> registration dynamically. Do I remember wrong? Wasn't it so that at
> least some UUIDs (such as PAN) with a bluedroid based system only appear
> when you actually enable support for the profile in the UI?
>
> Johan

^ permalink raw reply

* Re: bluez-5.10/monitor/packet.c:4335: possible missing break ?
From: Johan Hedberg @ 2013-11-06  8:15 UTC (permalink / raw)
  To: David Binderman; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <DUB118-W372AC521B8229C59C076809CF10@phx.gbl>

Hi David,

On Tue, Nov 05, 2013, David Binderman wrote:
> Hello there,
> 
> I just ran the static analysis checker "cppcheck" over the source code of bluez-5.10
> 
> It said
> 
> [monitor/packet.c:4335] -> [monitor/packet.c:4338]: (warning) Variable 'str' is reassigned a value
>  before the old one has been used. 'break;' missing?
> 
> Source code is
> 
>     case 0x03:
>         str = "Allow Scan Request from White List Only, "
>             "Allow Connect Request from White List Only";
>     default:
>         str = "Reserved";
>         break;
> 
> Suggest add a break statement to the 0x03 case.

Yes, that looks like a bug. Do you want to send a proper patch for it?

Johan

^ permalink raw reply

* Re: [PATCH] android: Add option to specify controller index to use
From: Johan Hedberg @ 2013-11-06  8:14 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1383667658-31480-1-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Tue, Nov 05, 2013, Szymon Janc wrote:
> This will be usefull while testing on Linux where more controllers
> can be present.
> ---
> 
> This is on top of patchset starting with patch
> "adapter: Move MGMT_VERSION macro to mgmt.h"
> 
>  android/main.c | 39 +++++++++++++++++++++++++++++----------
>  1 file changed, 29 insertions(+), 10 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH v2 1/5] adapter: Move MGMT_VERSION macro to mgmt.h
From: Johan Hedberg @ 2013-11-06  8:13 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth, Szymon Janc
In-Reply-To: <1383675779-4757-1-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Tue, Nov 05, 2013, Szymon Janc wrote:
> This will be also used in Android daemon.
> ---
> 
> v2: fixed missing brackets around 'v' as suggested by Marcel
> 
>  src/adapter.c     | 1 -
>  src/shared/mgmt.h | 2 ++
>  2 files changed, 2 insertions(+), 1 deletion(-)

All five patches have been applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH] monitor: Fallback to 80 columns terminal if not able to get real size
From: Johan Hedberg @ 2013-11-06  8:03 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1383657773-13597-1-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Tue, Nov 05, 2013, Szymon Janc wrote:
> This makes num_columns always return valid number of columns, which is
> expected by print_packets function.
> 
> This also fix garbage prints while using btmon via adb shell.
> ---
>  monitor/display.c | 8 ++++----
>  monitor/display.h | 2 ++
>  2 files changed, 6 insertions(+), 4 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCHv2 4/6] android: Add supported uuids when adapter is initialized
From: Johan Hedberg @ 2013-11-06  8:02 UTC (permalink / raw)
  To: Marcin Kraglak; +Cc: linux-bluetooth
In-Reply-To: <1383657700-22313-5-git-send-email-marcin.kraglak@tieto.com>

Hi Marcin,

On Tue, Nov 05, 2013, Marcin Kraglak wrote:
> It will set class of device with proper service hints.
> We set it statically because we want to keep code simple.
> 
> ---
>  android/adapter.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 59 insertions(+)

I've applied patches 1-3, but am a bit confused about this one.

> diff --git a/android/adapter.c b/android/adapter.c
> index 0f24cac..70b9265 100644
> --- a/android/adapter.c
> +++ b/android/adapter.c
> @@ -52,6 +52,29 @@ static GIOChannel *notification_io = NULL;
>  /* This list contains addresses which are asked for records */
>  static GSList *browse_reqs;
>  
> +/*
> + * This is an array of supported uuids and service hints. We add them via mgmt
> + * interface when adapter is initialized. Uuids are in reverse orded.
> + */
> +static const struct mgmt_cp_add_uuid supported_services[] = {
> +	/* OBEX_OPP_UUID */
> +	{ .uuid = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
> +			0x00, 0x10, 0x00, 0x00, 0x05, 0x11, 0x00, 0x00 },
> +	.svc_hint = 0x10 },
> +	/* HFP_AG_UUID */
> +	{ .uuid = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
> +			0x00, 0x10, 0x00, 0x00, 0x1f, 0x11, 0x00, 0x00 },
> +	.svc_hint = 0x40 },
> +	/* ADVANCED_AUDIO_UUID */
> +	{ .uuid = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
> +			0x00, 0x10, 0x00, 0x00, 0x0d, 0x11, 0x00, 0x00 },
> +	.svc_hint = 0x08 },
> +	/* PANU_UUID */
> +	{ .uuid = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
> +			0x00, 0x10, 0x00, 0x00, 0x15, 0x11, 0x00, 0x00 },
> +	.svc_hint = 0x02 }
> +};

I seem to remember the discussion around this drifting back to doing the
registration dynamically. Do I remember wrong? Wasn't it so that at
least some UUIDs (such as PAN) with a bluedroid based system only appear
when you actually enable support for the profile in the UI?

Johan

^ permalink raw reply

* Re: [PATCH] net: bluetooth: fix crash in l2cap_chan_send after l2cap_chan_del
From: Johan Hedberg @ 2013-11-06  7:43 UTC (permalink / raw)
  To: Seung-Woo Kim; +Cc: linux-bluetooth, marcel, gustavo, s.syam
In-Reply-To: <1383644793-30553-1-git-send-email-sw0312.kim@samsung.com>

Hi Seung-Woo Kim,

On Tue, Nov 05, 2013, Seung-Woo Kim wrote:
> Removing a bond and disconnecting from a specific remote device
> can cause l2cap_chan_send() is called after l2cap_chan_del() is
> called. This causes following crash.
> 
> [ 1384.972086] Unable to handle kernel NULL pointer dereference at virtual address 00000008
> [ 1384.972090] pgd = c0004000
> [ 1384.972125] [00000008] *pgd=00000000
> [ 1384.972137] Internal error: Oops: 17 [#1] PREEMPT SMP ARM
> [ 1384.972144] Modules linked in:
> [ 1384.972156] CPU: 0 PID: 841 Comm: krfcommd Not tainted 3.10.14-gdf22a71-dirty #435
> [ 1384.972162] task: df29a100 ti: df178000 task.ti: df178000
> [ 1384.972182] PC is at l2cap_create_basic_pdu+0x30/0x1ac
> [ 1384.972191] LR is at l2cap_chan_send+0x100/0x1d4
> [ 1384.972198] pc : [<c051d250>]    lr : [<c0521c78>]    psr: 40000113
> [ 1384.972198] sp : df179d40  ip : c083a010  fp : 00000008
> [ 1384.972202] r10: 00000004  r9 : 0000065a  r8 : 000003f5
> [ 1384.972206] r7 : 00000000  r6 : 00000000  r5 : df179e84  r4 : da557000
> [ 1384.972210] r3 : 00000000  r2 : 00000004  r1 : df179e84  r0 : 00000000
> [ 1384.972215] Flags: nZcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
> [ 1384.972220] Control: 10c53c7d  Table: 5c8b004a  DAC: 00000015
> [ 1384.972224] Process krfcommd (pid: 841, stack limit = 0xdf178238)
> [ 1384.972229] Stack: (0xdf179d40 to 0xdf17a000)
> [ 1384.972238] 9d40: 00000000 da557000 00000004 df179e84 00000004 000003f5 0000065a 00000000
> [ 1384.972245] 9d60: 00000008 c0521c78 df179e84 da557000 00000004 da557204 de0c6800 df179e84
> [ 1384.972253] 9d80: da557000 00000004 da557204 c0526b7c 00000004 df724000 df179e84 00000004
> [ 1384.972260] 9da0: df179db0 df29a100 c083bc48 c045481c 00000001 00000000 00000000 00000000
> [ 1384.972267] 9dc0: 00000000 df29a100 00000000 00000000 00000000 00000000 df179e10 00000000
> [ 1384.972274] 9de0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
> [ 1384.972281] 9e00: 00000000 00000000 00000000 00000000 df179e4c c000ec80 c0b538c0 00000004
> [ 1384.972288] 9e20: df724000 df178000 00000000 df179e84 c0b538c0 00000000 df178000 c07f4570
> [ 1384.972295] 9e40: dcad9c00 df179e74 c07f4394 df179e60 df178000 00000000 df179e84 de247010
> [ 1384.972303] 9e60: 00000043 c0454dec 00000001 00000004 df315c00 c0530598 00000004 df315c0c
> [ 1384.972310] 9e80: ffffc32c 00000000 00000000 df179ea0 00000001 00000000 00000000 00000000
> [ 1384.972317] 9ea0: df179ebc 00000004 df315c00 c05df838 00000000 c0530810 c07d08c0 d7017303
> [ 1384.972325] 9ec0: 6ec245b9 00000000 df315c00 c0531b04 c07f3fe0 c07f4018 da67a300 df315c00
> [ 1384.972332] 9ee0: 00000000 c05334e0 df315c00 df315b80 df315c00 de0c6800 da67a300 00000000
> [ 1384.972339] 9f00: de0c684c c0533674 df204100 df315c00 df315c00 df204100 df315c00 c082b138
> [ 1384.972347] 9f20: c053385c c0533754 a0000113 df178000 00000001 c083bc48 00000000 c053385c
> [ 1384.972354] 9f40: 00000000 00000000 00000000 c05338c4 00000000 df9f0000 df9f5ee4 df179f6c
> [ 1384.972360] 9f60: df178000 c0049db4 00000000 00000000 c07f3ff8 00000000 00000000 00000000
> [ 1384.972368] 9f80: df179f80 df179f80 00000000 00000000 df179f90 df179f90 df9f5ee4 c0049cfc
> [ 1384.972374] 9fa0: 00000000 00000000 00000000 c000f168 00000000 00000000 00000000 00000000
> [ 1384.972381] 9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
> [ 1384.972388] 9fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00010000 00000600
> [ 1384.972411] [<c051d250>] (l2cap_create_basic_pdu+0x30/0x1ac) from [<c0521c78>] (l2cap_chan_send+0x100/0x1d4)
> [ 1384.972425] [<c0521c78>] (l2cap_chan_send+0x100/0x1d4) from [<c0526b7c>] (l2cap_sock_sendmsg+0xa8/0x104)
> [ 1384.972440] [<c0526b7c>] (l2cap_sock_sendmsg+0xa8/0x104) from [<c045481c>] (sock_sendmsg+0xac/0xcc)
> [ 1384.972453] [<c045481c>] (sock_sendmsg+0xac/0xcc) from [<c0454dec>] (kernel_sendmsg+0x2c/0x34)
> [ 1384.972469] [<c0454dec>] (kernel_sendmsg+0x2c/0x34) from [<c0530598>] (rfcomm_send_frame+0x58/0x7c)
> [ 1384.972481] [<c0530598>] (rfcomm_send_frame+0x58/0x7c) from [<c0530810>] (rfcomm_send_ua+0x98/0xbc)
> [ 1384.972494] [<c0530810>] (rfcomm_send_ua+0x98/0xbc) from [<c0531b04>] (rfcomm_recv_disc+0xac/0x100)
> [ 1384.972506] [<c0531b04>] (rfcomm_recv_disc+0xac/0x100) from [<c05334e0>] (rfcomm_recv_frame+0x144/0x264)
> [ 1384.972519] [<c05334e0>] (rfcomm_recv_frame+0x144/0x264) from [<c0533674>] (rfcomm_process_rx+0x74/0xfc)
> [ 1384.972531] [<c0533674>] (rfcomm_process_rx+0x74/0xfc) from [<c0533754>] (rfcomm_process_sessions+0x58/0x160)
> [ 1384.972543] [<c0533754>] (rfcomm_process_sessions+0x58/0x160) from [<c05338c4>] (rfcomm_run+0x68/0x110)
> [ 1384.972558] [<c05338c4>] (rfcomm_run+0x68/0x110) from [<c0049db4>] (kthread+0xb8/0xbc)
> [ 1384.972576] [<c0049db4>] (kthread+0xb8/0xbc) from [<c000f168>] (ret_from_fork+0x14/0x2c)
> [ 1384.972586] Code: e3100004 e1a07003 e5946000 1a000057 (e5969008)
> [ 1384.972614] ---[ end trace 6170b7ce00144e8c ]---
> 
> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
> ---
> I can reproduce this crash with bluetooth-next kernel merged onto my v3.10
> system. It is usually happens when the device is at sleep state and remote
> device disconnects and removes bonding.
> 
> This patch is based on bluetooth-next tree.
> ---
>  net/bluetooth/l2cap_core.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)

The patch has been applied to bluetooth-next. Thanks.

I also fixed up the subject a bit to be consistent with the rest of the
commits for the Bluetooth subsystem.

Johan

^ permalink raw reply

* [PATCH] Bluetooth: ath3k: Add support for another AR3012 card
From: Sujith Manoharan @ 2013-11-06  5:26 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: gustavo

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=04ca ProdID=300b Rev= 0.01
C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
A:  FirstIf#= 0 IfCount= 2 Cls=e0(wlcon) Sub=01 Prot=01
I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb

Reported-by:Face <falazemi@gmail.com>
Signed-off-by: Sujith Manoharan <sujith@msujith.org>
---
 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 32582ec..d3fdc32 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -83,6 +83,7 @@ static const struct usb_device_id ath3k_table[] = {
 	{ USB_DEVICE(0x04CA, 0x3005) },
 	{ USB_DEVICE(0x04CA, 0x3006) },
 	{ USB_DEVICE(0x04CA, 0x3008) },
+	{ USB_DEVICE(0x04CA, 0x300b) },
 	{ USB_DEVICE(0x13d3, 0x3362) },
 	{ USB_DEVICE(0x0CF3, 0xE004) },
 	{ USB_DEVICE(0x0CF3, 0xE005) },
@@ -126,6 +127,7 @@ static const struct usb_device_id ath3k_blist_tbl[] = {
 	{ USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x04ca, 0x3006), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
+	{ USB_DEVICE(0x04ca, 0x300b), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0xe005), .driver_info = BTUSB_ATH3012 },
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 711ca6f..3d04bce 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -150,6 +150,7 @@ static const struct usb_device_id blacklist_table[] = {
 	{ USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x04ca, 0x3006), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
+	{ USB_DEVICE(0x04ca, 0x300b), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
 	{ USB_DEVICE(0x0cf3, 0xe005), .driver_info = BTUSB_ATH3012 },
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH_v4 12/12] android/hid: Align hal hid struct variables properly
From: Ravi kumar Veeramally @ 2013-11-05 21:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383685758-3900-1-git-send-email-ravikumar.veeramally@linux.intel.com>

---
 android/hal-msg.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 2c3067f..41ba649 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -282,9 +282,9 @@ struct hal_cmd_hid_set_protocol {
 
 #define HAL_OP_HID_GET_REPORT		0x07
 struct hal_cmd_hid_get_report {
-	uint8_t bdaddr[6];
-	uint8_t type;
-	uint8_t id;
+	uint8_t  bdaddr[6];
+	uint8_t  type;
+	uint8_t  id;
 	uint16_t buf;
 } __attribute__((packed));
 
@@ -448,16 +448,16 @@ struct hal_ev_hid_conn_state {
 
 #define HAL_EV_HID_INFO			0x82
 struct hal_ev_hid_info {
-	uint8_t bdaddr[6];
-	uint8_t attr;
-	uint8_t subclass;
-	uint8_t app_id;
+	uint8_t  bdaddr[6];
+	uint8_t  attr;
+	uint8_t  subclass;
+	uint8_t  app_id;
 	uint16_t vendor;
 	uint16_t product;
 	uint16_t version;
-	uint8_t country;
+	uint8_t  country;
 	uint16_t descr_len;
-	uint8_t descr[884];
+	uint8_t  descr[884];
 } __attribute__((packed));
 
 #define HAL_EV_HID_PROTO_MODE		0x83
-- 
1.8.1.2


^ permalink raw reply related

* [PATCH_v4 11/12] android/hid: Handle uhid events
From: Ravi kumar Veeramally @ 2013-11-05 21:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383685758-3900-1-git-send-email-ravikumar.veeramally@linux.intel.com>

Handling few uhid events and described scenarios. OUTPUT and
FEATURE events are not yet handled.
---
 android/hid.c | 40 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/android/hid.c b/android/hid.c
index 999f5d6..172a945 100644
--- a/android/hid.c
+++ b/android/hid.c
@@ -149,6 +149,11 @@ static void hid_device_free(struct hid_device *dev)
 	g_free(dev);
 }
 
+static void handle_uhid_event(struct hid_device *dev, struct uhid_event *ev)
+{
+	DBG("UHID_OUTPUT UHID_FEATURE unsupported");
+}
+
 static gboolean uhid_event_cb(GIOChannel *io, GIOCondition cond,
 							gpointer user_data)
 {
@@ -172,7 +177,40 @@ static gboolean uhid_event_cb(GIOChannel *io, GIOCondition cond,
 	}
 
 	DBG("uHID event type %d received", ev.type);
-	/* TODO Handle events */
+
+	switch (ev.type) {
+	case UHID_START:
+	case UHID_STOP:
+		/* These are called to start and stop the underlying hardware.
+		 * We open the channels before creating the device so the
+		 * hardware is always ready. No need to handle these.
+		 * The kernel never destroys a device itself! Only an explicit
+		 * UHID_DESTROY request can remove a device. */
+
+		break;
+	case UHID_OPEN:
+	case UHID_CLOSE:
+		/* OPEN/CLOSE are sent whenever user-space opens any interface
+		 * provided by the kernel HID device. Whenever the open-count
+		 * is non-zero we must be ready for I/O. As long as it is zero,
+		 * we can decide to drop all I/O and put the device
+		 * asleep This is optional, though. */
+		break;
+	case UHID_OUTPUT:
+	case UHID_FEATURE:
+		handle_uhid_event(dev, &ev);
+		break;
+	case UHID_OUTPUT_EV:
+		/* This is only sent by kernels prior to linux-3.11. It
+		 * requires us to parse HID-descriptors in user-space to
+		 * properly handle it. This is redundant as the kernel
+		 * does it already. That's why newer kernels assemble
+		 * the output-reports and send it to us via UHID_OUTPUT. */
+		DBG("UHID_OUTPUT_EV unsupported");
+		break;
+	default:
+		warn("unexpected uHID event");
+	}
 
 	return TRUE;
 
-- 
1.8.1.2


^ permalink raw reply related

* [PATCH_v4 10/12] android/hid: Handle invalid parameters in HAL
From: Ravi kumar Veeramally @ 2013-11-05 21:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383685758-3900-1-git-send-email-ravikumar.veeramally@linux.intel.com>

---
 android/hal-hidhost.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index fe68fe7..815902b 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -204,9 +204,8 @@ static bt_status_t hh_get_protocol(bt_bdaddr_t *bd_addr,
 	case BTHH_BOOT_MODE:
 		cmd.mode = HAL_HID_BOOT_PROTOCOL;
 		break;
-	case BTHH_UNSUPPORTED_MODE:
-		cmd.mode = HAL_HID_UNSUPPORTED_PROTOCOL;
-		break;
+	default:
+		return BT_STATUS_PARM_INVALID;
 	}
 
 	return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST,
@@ -236,9 +235,8 @@ static bt_status_t hh_set_protocol(bt_bdaddr_t *bd_addr,
 	case BTHH_BOOT_MODE:
 		cmd.mode = HAL_HID_BOOT_PROTOCOL;
 		break;
-	case BTHH_UNSUPPORTED_MODE:
-		cmd.mode = HAL_HID_UNSUPPORTED_PROTOCOL;
-		break;
+	default:
+		return BT_STATUS_PARM_INVALID;
 	}
 
 	return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST,
@@ -275,6 +273,8 @@ static bt_status_t hh_get_report(bt_bdaddr_t *bd_addr,
 	case BTHH_FEATURE_REPORT:
 		cmd.type = HAL_HID_FEATURE_REPORT;
 		break;
+	default:
+		return BT_STATUS_PARM_INVALID;
 	}
 
 	return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HID_GET_REPORT,
@@ -309,6 +309,8 @@ static bt_status_t hh_set_report(bt_bdaddr_t *bd_addr,
 	case BTHH_FEATURE_REPORT:
 		cmd.type = HAL_HID_FEATURE_REPORT;
 		break;
+	default:
+		return BT_STATUS_PARM_INVALID;
 	}
 
 	return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HID_SET_REPORT,
-- 
1.8.1.2


^ permalink raw reply related

* [PATCH_v4 09/12] android/hid: Replace header checking magic number with defines
From: Ravi kumar Veeramally @ 2013-11-05 21:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383685758-3900-1-git-send-email-ravikumar.veeramally@linux.intel.com>

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

diff --git a/android/hid.c b/android/hid.c
index 5411922..999f5d6 100644
--- a/android/hid.c
+++ b/android/hid.c
@@ -200,7 +200,7 @@ static gboolean intr_io_watch_cb(GIOChannel *chan, gpointer data)
 	}
 
 	/* Discard non-data packets */
-	if (bread == 0 || buf[0] != 0xA1)
+	if (bread == 0 || buf[0] != (HID_MSG_DATA | HID_DATA_TYPE_INPUT))
 		return TRUE;
 
 	/* send data to uHID device skipping HIDP header byte */
-- 
1.8.1.2


^ permalink raw reply related

* [PATCH_v4 08/12] android/hid: Handle get report notification in HAL
From: Ravi kumar Veeramally @ 2013-11-05 21:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383685758-3900-1-git-send-email-ravikumar.veeramally@linux.intel.com>

---
 android/hal-hidhost.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index 29e3ee0..fe68fe7 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -68,6 +68,15 @@ static void handle_proto_mode(void *buf)
 							ev->status, ev->mode);
 }
 
+static void handle_get_report(void *buf)
+{
+	struct hal_ev_hid_get_report *ev = buf;
+
+	if (bt_hh_cbacks->get_report_cb)
+		bt_hh_cbacks->get_report_cb((bt_bdaddr_t *) ev->bdaddr,
+						ev->status, ev->data, ev->len);
+}
+
 /* will be called from notification thread context */
 void bt_notify_hh(uint16_t opcode, void *buf, uint16_t len)
 {
@@ -84,6 +93,9 @@ void bt_notify_hh(uint16_t opcode, void *buf, uint16_t len)
 	case HAL_EV_HID_PROTO_MODE:
 		handle_proto_mode(buf);
 		break;
+	case HAL_EV_HID_GET_REPORT:
+		handle_get_report(buf);
+		break;
 	default:
 		DBG("Unhandled callback opcode=0x%x", opcode);
 		break;
-- 
1.8.1.2


^ permalink raw reply related

* [PATCH_v4 07/12] android/hid: Implement hid set report in daemon
From: Ravi kumar Veeramally @ 2013-11-05 21:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383685758-3900-1-git-send-email-ravikumar.veeramally@linux.intel.com>

This patch requests hid device to set report.
---
 android/hal-hidhost.c |  2 ++
 android/hal-msg.h     |  6 ++++--
 android/hid.c         | 40 ++++++++++++++++++++++++++++++++++++++--
 3 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index f554cb2..29e3ee0 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -284,6 +284,8 @@ static bt_status_t hh_set_report(bt_bdaddr_t *bd_addr,
 		return BT_STATUS_PARM_INVALID;
 
 	memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+	cmd.len = strlen(report);
+	memcpy(cmd.data, report, cmd.len);
 
 	switch (reportType) {
 	case BTHH_INPUT_REPORT:
diff --git a/android/hal-msg.h b/android/hal-msg.h
index bc7df6b..2c3067f 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -290,8 +290,10 @@ struct hal_cmd_hid_get_report {
 
 #define HAL_OP_HID_SET_REPORT		0x08
 struct hal_cmd_hid_set_report {
-	uint8_t bdaddr[6];
-	uint8_t type;
+	uint8_t  bdaddr[6];
+	uint8_t  type;
+	uint16_t len;
+	uint8_t  data[670];
 } __attribute__((packed));
 
 #define HAL_OP_HID_SEND_DATA		0x09
diff --git a/android/hid.c b/android/hid.c
index fd58e6f..5411922 100644
--- a/android/hid.c
+++ b/android/hid.c
@@ -56,6 +56,7 @@
 
 /* HID message types */
 #define HID_MSG_GET_REPORT	0x40
+#define HID_MSG_SET_REPORT	0x50
 #define HID_MSG_GET_PROTOCOL	0x60
 #define HID_MSG_SET_PROTOCOL	0x70
 #define HID_MSG_DATA		0xa0
@@ -842,9 +843,44 @@ static uint8_t bt_hid_get_report(struct hal_cmd_hid_get_report *cmd,
 static uint8_t bt_hid_set_report(struct hal_cmd_hid_set_report *cmd,
 								uint16_t len)
 {
-	DBG("Not Implemented");
+	struct hid_device *dev;
+	GSList *l;
+	bdaddr_t dst;
+	int fd;
+	uint8_t *req;
+	uint8_t req_size;
 
-	return HAL_STATUS_FAILED;
+	DBG("");
+
+	if (len < sizeof(*cmd))
+		return HAL_STATUS_INVALID;
+
+	android2bdaddr(&cmd->bdaddr, &dst);
+
+	l = g_slist_find_custom(devices, &dst, device_cmp);
+	if (!l)
+		return HAL_STATUS_FAILED;
+
+	dev = l->data;
+	req_size = 1 + cmd->len;
+	req = g_try_malloc0(req_size);
+	if (!req)
+		return HAL_STATUS_NOMEM;
+
+	req[0] = HID_MSG_SET_REPORT | cmd->type;
+	memcpy(req + 1, cmd->data, req_size - 1);
+
+	fd = g_io_channel_unix_get_fd(dev->ctrl_io);
+
+	if (write(fd, req, req_size) < 0) {
+		error("error while querying device protocol");
+		g_free(req);
+		return HAL_STATUS_FAILED;
+	}
+
+	dev->last_hid_msg = HID_MSG_SET_REPORT;
+	g_free(req);
+	return HAL_STATUS_SUCCESS;
 }
 
 static uint8_t bt_hid_send_data(struct hal_cmd_hid_send_data *cmd,
-- 
1.8.1.2


^ permalink raw reply related

* [PATCH_v4 06/12] android/hid: Add missing set report parameters to ipc document
From: Ravi kumar Veeramally @ 2013-11-05 21:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383685758-3900-1-git-send-email-ravikumar.veeramally@linux.intel.com>

---
 android/hal-ipc-api.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 6b11684..48bcc45 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -552,7 +552,9 @@ Commands and responses:
 
 		Command parameters: Remote address (6 octets)
 		                    Report type (1 octet)
-		                    ...
+		                    Report length (2 octet)
+		                    Report data (670 octet) L2CAP default MTU
+
 		Response parameters: <none>
 
 		Valid report types: 0x01 = Input
-- 
1.8.1.2


^ permalink raw reply related

* [PATCH_v4 05/12] android/hid: Implement hid get report in daemon
From: Ravi kumar Veeramally @ 2013-11-05 21:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383685758-3900-1-git-send-email-ravikumar.veeramally@linux.intel.com>

This patch requests hid device report and reads reply
message and sends notification to HAL.
---
 android/hal-hidhost.c |   1 +
 android/hid.c         | 102 +++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 101 insertions(+), 2 deletions(-)

diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index 13928e6..f554cb2 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -251,6 +251,7 @@ static bt_status_t hh_get_report(bt_bdaddr_t *bd_addr,
 
 	memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
 	cmd.id = reportId;
+	cmd.buf = bufferSize;
 
 	switch (reportType) {
 	case BTHH_INPUT_REPORT:
diff --git a/android/hid.c b/android/hid.c
index dc44159..fd58e6f 100644
--- a/android/hid.c
+++ b/android/hid.c
@@ -55,14 +55,23 @@
 #define UHID_DEVICE_FILE	"/dev/uhid"
 
 /* HID message types */
+#define HID_MSG_GET_REPORT	0x40
 #define HID_MSG_GET_PROTOCOL	0x60
 #define HID_MSG_SET_PROTOCOL	0x70
 #define HID_MSG_DATA		0xa0
 
+/* HID data types */
+#define HID_DATA_TYPE_INPUT	0x01
+#define HID_DATA_TYPE_OUTPUT	0x02
+#define HID_DATA_TYPE_FEATURE	0x03
+
 /* HID protocol header parameters */
 #define HID_PROTO_BOOT		0x00
 #define HID_PROTO_REPORT	0x01
 
+/* HID GET REPORT Size Field */
+#define HID_GET_REPORT_SIZE_FIELD	0x08
+
 static GIOChannel *notification_io = NULL;
 static GIOChannel *ctrl_io = NULL;
 static GIOChannel *intr_io = NULL;
@@ -283,6 +292,50 @@ static void bt_hid_notify_proto_mode(struct hid_device *dev, uint8_t *buf,
 				HAL_EV_HID_PROTO_MODE, sizeof(ev), &ev, -1);
 }
 
+static void bt_hid_notify_get_report(struct hid_device *dev, uint8_t *buf,
+									int len)
+{
+	struct hal_ev_hid_get_report *ev;
+	int ev_len;
+	char address[18];
+
+	ba2str(&dev->dst, address);
+	DBG("device %s", address);
+
+	ev_len = sizeof(*ev) + sizeof(struct hal_ev_hid_get_report) + 1;
+
+	if (!((buf[0] == (HID_MSG_DATA | HID_DATA_TYPE_INPUT)) ||
+			(buf[0] == (HID_MSG_DATA | HID_DATA_TYPE_OUTPUT)) ||
+			(buf[0]	== (HID_MSG_DATA | HID_DATA_TYPE_FEATURE)))) {
+		ev = g_malloc0(ev_len);
+		ev->status = buf[0];
+		bdaddr2android(&dev->dst, ev->bdaddr);
+		goto send;
+	}
+
+	/* Report porotocol mode reply contains id after hdr, in boot
+	 * protocol mode id doesn't exist */
+	ev_len += (dev->boot_dev) ? (len - 1) : (len - 2);
+	ev = g_malloc0(ev_len);
+	ev->status = HAL_HID_STATUS_OK;
+	bdaddr2android(&dev->dst, ev->bdaddr);
+
+	/* Report porotocol mode reply contains id after hdr, in boot
+	 * protocol mode id doesn't exist */
+	if (dev->boot_dev) {
+		ev->len = len - 1;
+		memcpy(ev->data, buf + 1, ev->len);
+	} else {
+		ev->len = len - 2;
+		memcpy(ev->data, buf + 2, ev->len);
+	}
+
+send:
+	ipc_send(notification_io, HAL_SERVICE_ID_HIDHOST, HAL_EV_HID_GET_REPORT,
+						ev_len, ev, -1);
+	g_free(ev);
+}
+
 static gboolean ctrl_io_watch_cb(GIOChannel *chan, gpointer data)
 {
 	struct hid_device *dev = data;
@@ -303,6 +356,9 @@ static gboolean ctrl_io_watch_cb(GIOChannel *chan, gpointer data)
 	case HID_MSG_SET_PROTOCOL:
 		bt_hid_notify_proto_mode(dev, buf, bread);
 		break;
+	case HID_MSG_GET_REPORT:
+		bt_hid_notify_get_report(dev, buf, bread);
+		break;
 	}
 
 	/* reset msg type request */
@@ -736,9 +792,51 @@ static uint8_t bt_hid_set_protocol(struct hal_cmd_hid_set_protocol *cmd,
 static uint8_t bt_hid_get_report(struct hal_cmd_hid_get_report *cmd,
 								uint16_t len)
 {
-	DBG("Not Implemented");
+	struct hid_device *dev;
+	GSList *l;
+	bdaddr_t dst;
+	int fd;
+	uint8_t *req;
+	uint8_t req_size;
 
-	return HAL_STATUS_FAILED;
+	DBG("");
+
+	if (len < sizeof(*cmd))
+		return HAL_STATUS_INVALID;
+
+	android2bdaddr(&cmd->bdaddr, &dst);
+
+	l = g_slist_find_custom(devices, &dst, device_cmp);
+	if (!l)
+		return HAL_STATUS_FAILED;
+
+	dev = l->data;
+	req_size = (cmd->buf > 0) ? 4 : 2;
+	req = g_try_malloc0(req_size);
+	if (!req)
+		return HAL_STATUS_NOMEM;
+
+	req[0] = HID_MSG_GET_REPORT | cmd->type;
+
+	if (cmd->buf > 0)
+		req[0] = req[0] | HID_GET_REPORT_SIZE_FIELD;
+
+	req[1] = cmd->id;
+
+	if (cmd->buf > 0)
+		bt_put_le16(cmd->buf, (req + 2));
+
+	fd = g_io_channel_unix_get_fd(dev->ctrl_io);
+
+	if (write(fd, req, req_size) < 0) {
+		error("error while querying device protocol");
+		g_free(req);
+		return HAL_STATUS_FAILED;
+	}
+
+	dev->last_hid_msg = HID_MSG_GET_REPORT;
+	g_free(req);
+	return HAL_STATUS_SUCCESS;
 }
 
 static uint8_t bt_hid_set_report(struct hal_cmd_hid_set_report *cmd,
-- 
1.8.1.2


^ permalink raw reply related

* [PATCH_v4 04/12] android/hid: Add hid event get report structure to HAL msg headers
From: Ravi kumar Veeramally @ 2013-11-05 21:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383685758-3900-1-git-send-email-ravikumar.veeramally@linux.intel.com>

---
 android/hal-msg.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 5faf852..bc7df6b 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -465,6 +465,14 @@ struct hal_ev_hid_proto_mode {
 	uint8_t mode;
 } __attribute__((packed));
 
+#define HAL_EV_HID_GET_REPORT		0x85
+struct hal_ev_hid_get_report {
+	uint8_t  bdaddr[6];
+	uint8_t  status;
+	uint16_t len;
+	uint8_t  data[0];
+} __attribute__((packed));
+
 #define HAL_EV_AV_CONNECTION_STATE	0x81
 struct hal_ev_av_connection_state {
 	uint8_t state;
-- 
1.8.1.2


^ permalink raw reply related

* [PATCH_v4 03/12] android/hid: Handle protocol mode notification in HAL
From: Ravi kumar Veeramally @ 2013-11-05 21:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383685758-3900-1-git-send-email-ravikumar.veeramally@linux.intel.com>

---
 android/hal-hidhost.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index c20c785..13928e6 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -59,6 +59,15 @@ static void handle_info(void *buf)
 		bt_hh_cbacks->hid_info_cb((bt_bdaddr_t *) ev->bdaddr, info);
 }
 
+static void handle_proto_mode(void *buf)
+{
+	struct hal_ev_hid_proto_mode *ev = buf;
+
+	if (bt_hh_cbacks->protocol_mode_cb)
+		bt_hh_cbacks->protocol_mode_cb((bt_bdaddr_t *) ev->bdaddr,
+							ev->status, ev->mode);
+}
+
 /* will be called from notification thread context */
 void bt_notify_hh(uint16_t opcode, void *buf, uint16_t len)
 {
@@ -72,6 +81,9 @@ void bt_notify_hh(uint16_t opcode, void *buf, uint16_t len)
 	case HAL_EV_HID_INFO:
 		handle_info(buf);
 		break;
+	case HAL_EV_HID_PROTO_MODE:
+		handle_proto_mode(buf);
+		break;
 	default:
 		DBG("Unhandled callback opcode=0x%x", opcode);
 		break;
-- 
1.8.1.2


^ permalink raw reply related

* [PATCH_v4 02/12] android/hid: Implement hid set protocol in daemon
From: Ravi kumar Veeramally @ 2013-11-05 21:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383685758-3900-1-git-send-email-ravikumar.veeramally@linux.intel.com>

This patch requests hid device to set protocol mode and reads
reply message and sends notification to HAL.
---
 android/hid.c | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/android/hid.c b/android/hid.c
index 9bfa018..dc44159 100644
--- a/android/hid.c
+++ b/android/hid.c
@@ -56,6 +56,7 @@
 
 /* HID message types */
 #define HID_MSG_GET_PROTOCOL	0x60
+#define HID_MSG_SET_PROTOCOL	0x70
 #define HID_MSG_DATA		0xa0
 
 /* HID protocol header parameters */
@@ -299,6 +300,7 @@ static gboolean ctrl_io_watch_cb(GIOChannel *chan, gpointer data)
 
 	switch (dev->last_hid_msg) {
 	case HID_MSG_GET_PROTOCOL:
+	case HID_MSG_SET_PROTOCOL:
 		bt_hid_notify_proto_mode(dev, buf, bread);
 		break;
 	}
@@ -697,9 +699,38 @@ static uint8_t bt_hid_get_protocol(struct hal_cmd_hid_get_protocol *cmd,
 static uint8_t bt_hid_set_protocol(struct hal_cmd_hid_set_protocol *cmd,
 								uint16_t len)
 {
-	DBG("Not Implemented");
+	struct hid_device *dev;
+	GSList *l;
+	bdaddr_t dst;
+	int fd;
+	uint8_t hdr;
 
-	return HAL_STATUS_FAILED;
+	DBG("");
+
+	if (len < sizeof(*cmd))
+		return HAL_STATUS_INVALID;
+
+	android2bdaddr(&cmd->bdaddr, &dst);
+
+	l = g_slist_find_custom(devices, &dst, device_cmp);
+	if (!l)
+		return HAL_STATUS_FAILED;
+
+	dev = l->data;
+
+	if (dev->boot_dev)
+		return HAL_STATUS_UNSUPPORTED;
+
+	hdr = HID_MSG_SET_PROTOCOL | cmd->mode;
+	fd = g_io_channel_unix_get_fd(dev->ctrl_io);
+
+	if (write(fd, &hdr, sizeof(hdr)) < 0) {
+		error("error while setting device protocol");
+		return HAL_STATUS_FAILED;
+	}
+
+	dev->last_hid_msg = HID_MSG_SET_PROTOCOL;
+	return HAL_STATUS_SUCCESS;
 }
 
 static uint8_t bt_hid_get_report(struct hal_cmd_hid_get_report *cmd,
-- 
1.8.1.2


^ permalink raw reply related

* [PATCH_v4 01/12] android/hid: Implement hid get protocol in daemon
From: Ravi kumar Veeramally @ 2013-11-05 21:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1383685758-3900-1-git-send-email-ravikumar.veeramally@linux.intel.com>

This patch requests hid device protocol mode and reads reply
message and sends notification to HAL.
---
 android/hid.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 102 insertions(+), 4 deletions(-)

diff --git a/android/hid.c b/android/hid.c
index 8f5ba88..9bfa018 100644
--- a/android/hid.c
+++ b/android/hid.c
@@ -54,6 +54,14 @@
 #define L2CAP_PSM_HIDP_INTR	0x13
 #define UHID_DEVICE_FILE	"/dev/uhid"
 
+/* HID message types */
+#define HID_MSG_GET_PROTOCOL	0x60
+#define HID_MSG_DATA		0xa0
+
+/* HID protocol header parameters */
+#define HID_PROTO_BOOT		0x00
+#define HID_PROTO_REPORT	0x01
+
 static GIOChannel *notification_io = NULL;
 static GIOChannel *ctrl_io = NULL;
 static GIOChannel *intr_io = NULL;
@@ -76,6 +84,7 @@ struct hid_device {
 	guint		intr_watch;
 	int		uhid_fd;
 	guint		uhid_watch_id;
+	uint8_t		last_hid_msg;
 };
 
 static int device_cmp(gconstpointer s, gconstpointer user_data)
@@ -243,12 +252,72 @@ static gboolean intr_watch_cb(GIOChannel *chan, GIOCondition cond,
 	return FALSE;
 }
 
+static void bt_hid_notify_proto_mode(struct hid_device *dev, uint8_t *buf,
+									int len)
+{
+	struct hal_ev_hid_proto_mode ev;
+	char address[18];
+
+	ba2str(&dev->dst, address);
+	DBG("device %s", address);
+
+	memset(&ev, 0, sizeof(ev));
+	bdaddr2android(&dev->dst, ev.bdaddr);
+
+	if (buf[0] == HID_MSG_DATA) {
+		ev.status = HAL_HID_STATUS_OK;
+		if (buf[1] == HID_PROTO_REPORT)
+			ev.mode = HAL_HID_REPORT_PROTOCOL;
+		else if (buf[1] == HID_PROTO_BOOT)
+			ev.mode = HAL_HID_BOOT_PROTOCOL;
+		else
+			ev.mode = HAL_HID_UNSUPPORTED_PROTOCOL;
+
+	} else {
+		ev.status = buf[0];
+		ev.mode = HAL_HID_UNSUPPORTED_PROTOCOL;
+	}
+
+	ipc_send(notification_io, HAL_SERVICE_ID_HIDHOST,
+				HAL_EV_HID_PROTO_MODE, sizeof(ev), &ev, -1);
+}
+
+static gboolean ctrl_io_watch_cb(GIOChannel *chan, gpointer data)
+{
+	struct hid_device *dev = data;
+	int fd, bread;
+	uint8_t buf[UHID_DATA_MAX];
+
+	DBG("");
+
+	fd = g_io_channel_unix_get_fd(chan);
+	bread = read(fd, buf, sizeof(buf));
+	if (bread < 0) {
+		error("read: %s(%d)", strerror(errno), -errno);
+		return TRUE;
+	}
+
+	switch (dev->last_hid_msg) {
+	case HID_MSG_GET_PROTOCOL:
+		bt_hid_notify_proto_mode(dev, buf, bread);
+		break;
+	}
+
+	/* reset msg type request */
+	dev->last_hid_msg = 0;
+
+	return TRUE;
+}
+
 static gboolean ctrl_watch_cb(GIOChannel *chan, GIOCondition cond,
 								gpointer data)
 {
 	struct hid_device *dev = data;
 	char address[18];
 
+	if (cond & G_IO_IN)
+		return ctrl_io_watch_cb(chan, data);
+
 	ba2str(&dev->dst, address);
 	bt_hid_notify_state(dev, HAL_HID_STATE_DISCONNECTED);
 
@@ -395,8 +464,8 @@ static void control_connect_cb(GIOChannel *chan, GError *conn_err,
 	}
 
 	dev->ctrl_watch = g_io_add_watch(dev->ctrl_io,
-					G_IO_HUP | G_IO_ERR | G_IO_NVAL,
-					ctrl_watch_cb, dev);
+				G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+				ctrl_watch_cb, dev);
 
 	return;
 
@@ -591,9 +660,38 @@ static uint8_t bt_hid_info(struct hal_cmd_hid_set_info *cmd, uint16_t len)
 static uint8_t bt_hid_get_protocol(struct hal_cmd_hid_get_protocol *cmd,
 								uint16_t len)
 {
-	DBG("Not Implemented");
+	struct hid_device *dev;
+	GSList *l;
+	bdaddr_t dst;
+	int fd;
+	uint8_t hdr;
 
-	return HAL_STATUS_FAILED;
+	DBG("");
+
+	if (len < sizeof(*cmd))
+		return HAL_STATUS_INVALID;
+
+	android2bdaddr(&cmd->bdaddr, &dst);
+
+	l = g_slist_find_custom(devices, &dst, device_cmp);
+	if (!l)
+		return HAL_STATUS_FAILED;
+
+	dev = l->data;
+
+	if (dev->boot_dev)
+		return HAL_STATUS_UNSUPPORTED;
+
+	hdr = HID_MSG_GET_PROTOCOL | cmd->mode;
+	fd = g_io_channel_unix_get_fd(dev->ctrl_io);
+
+	if (write(fd, &hdr, sizeof(hdr)) < 0) {
+		error("error while querying device protocol");
+		return HAL_STATUS_FAILED;
+	}
+
+	dev->last_hid_msg = HID_MSG_GET_PROTOCOL;
+	return HAL_STATUS_SUCCESS;
 }
 
 static uint8_t bt_hid_set_protocol(struct hal_cmd_hid_set_protocol *cmd,
-- 
1.8.1.2


^ permalink raw reply related

* [PATCH_v4 00/12] Implemented hid interfaces in daemon and HAL
From: Ravi kumar Veeramally @ 2013-11-05 21:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally

v4: Fixed Johan's comments (length issue and single byte array)

v3: Wrong order of patches

v2: Fixed Johan's comments (splitting of patches, proper function and
    struct names, update hal-msg.h and ipc document, alignment issues
    removed pointer from ipc struct)

v1: This patch set implements get/set protocol and get/set report
    interfaces and supported functionality in daemon. Sending notifications
    and notification handling in hal. Few naming fixes and error handling.
    And last handling of few uHID events.

Ravi kumar Veeramally (12):
  android/hid: Implement hid get protocol in daemon
  android/hid: Implement hid set protocol in daemon
  android/hid: Handle protocol mode notification in HAL
  android/hid: Add hid event get report structure to HAL msg headers
  android/hid: Implement hid get report in daemon
  android/hid: Add missing set report parameters to ipc document
  android/hid: Implement hid set report in daemon
  android/hid: Handle get report notification in HAL
  android/hid: Replace header checking magic number with defines
  android/hid: Handle invalid parameters in HAL
  android/hid: Handle uhid events
  android/hid: Align hal hid struct variables properly

 android/hal-hidhost.c   |  41 +++++-
 android/hal-ipc-api.txt |   4 +-
 android/hal-msg.h       |  32 +++--
 android/hid.c           | 325 ++++++++++++++++++++++++++++++++++++++++++++++--
 4 files changed, 372 insertions(+), 30 deletions(-)

-- 
1.8.1.2


^ permalink raw reply

* Re: pull request: bluetooth 2013-10-30
From: John W. Linville @ 2013-11-05 20:58 UTC (permalink / raw)
  To: Gustavo Padovan, linux-wireless, linux-bluetooth, linux-kernel
In-Reply-To: <20131030193842.GA2271@joana>

On Wed, Oct 30, 2013 at 05:38:42PM -0200, Gustavo Padovan wrote:
> Hi John,
> 
> A last fix to the 3.12. I ended forgetting to send it before, I hope we can
> still make the way to 3.12. It is a revert and it fixes an issue with bluetooth
> suspend/hibernate that had many bug reports. Please pull or let me know of any
> problems. Thanks!
> 
> 	Gustavo
> --
> The following changes since commit c7515d2365a6b8a018950198ebe1f5be793cd4bb:
> 
>   brcmsmac: call bcma_core_pci_power_save() from non-atomic context (2013-09-26 14:02:34 -0400)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth master
> 
> for you to fetch changes up to b1a8014471b01dd862de9f91bbbff1296afac42d:
> 
>   Bluetooth: revert: "Bluetooth: Add missing reset_resume dev_pm_ops" (2013-10-02 16:01:49 -0300)

Pulling now...

-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply


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