Linux bluetooth development
 help / color / mirror / Atom feed
* Re: [RFC 3/3] Bluetooth:  Provide mgmt API for reading list of supported codecs
From: Vinicius Costa Gomes @ 2013-01-03 22:16 UTC (permalink / raw)
  To: Gustavo Padovan, Michael Knudsen, linux-bluetooth,
	Michael Knudsen
In-Reply-To: <20130103190916.GA2114@joana>

Hi Gustavo,

> 
> We think it is better to read the list of codecs from the SCO socket, we need
> to allow both oFono and PulseAudio to read them without the need of talking to
> BlueZ. Also, bluetoothd has nothing intersting to do with this information.

Take a look at the thread "CSA2: User space aspect"[1]. I have to agree
with Marcel, the mgmt command makes more sense. As how that information
will get to oFono/PulseAudio we have NewConnection() in the Profile API
and SetConfiguration() on the Media API, that may be extended (if
needed).

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


Cheers,
-- 
Vinicius

[1] http://thread.gmane.org/gmane.linux.bluez.kernel/31746

^ permalink raw reply

* Re: [PATCH] Bluetooth: fix the oops due to conn->hcon == NULL in shutdown case
From: Gustavo Padovan @ 2013-01-03 22:02 UTC (permalink / raw)
  To: Chuansheng Liu; +Cc: marcel, johan.hedberg, linux-bluetooth, linux-kernel
In-Reply-To: <1356429857.25456.4.camel@cliu38-desktop-build>

Hi Chuansheng,

* Chuansheng Liu <chuansheng.liu@intel.com> [2012-12-25 18:04:17 +0800]:

> 
> Meet one panic issue as below stack:
> <1>[11340.226404] BUG: unable to handle kernel NULL pointer dereference at 00000008
> <4>[11340.226619] EIP is at __sco_sock_close+0xe8/0x1a0
> <4>[11340.226629] EAX: f063a740 EBX: 00000000 ECX: f58f4544 EDX: 00000000
> <4>[11340.226640] ESI: dec83e00 EDI: 5f9a081f EBP: e0fdff38 ESP: e0fdff1c
> <0>[11340.226674] Stack:
> <4>[11340.226682]  c184db87 c1251028 dec83e00 e0fdff38 c1754aef dec83e00 00000000 e0fdff5c
> <4>[11340.226718]  c184f587 e0fdff64 e0fdff68 5f9a081f e0fdff5c c1751852 d7813800 62262f10
> <4>[11340.226752]  e0fdff70 c1753c00 00000000 00000001 0000000d e0fdffac c175425c 00000041
> <0>[11340.226793] Call Trace:
> <4>[11340.226813]  [<c184db87>] ? sco_sock_clear_timer+0x27/0x60
> <4>[11340.226831]  [<c1251028>] ? local_bh_enable+0x68/0xd0
> <4>[11340.226846]  [<c1754aef>] ? lock_sock_nested+0x4f/0x60
> <4>[11340.226862]  [<c184f587>] sco_sock_shutdown+0x67/0xb0
> <4>[11340.226879]  [<c1751852>] ? sockfd_lookup_light+0x22/0x80
> <4>[11340.226897]  [<c1753c00>] sys_shutdown+0x30/0x60
> <4>[11340.226912]  [<c175425c>] sys_socketcall+0x1dc/0x2a0
> <4>[11340.226929]  [<c149ba78>] ? trace_hardirqs_on_thunk+0xc/0x10
> <4>[11340.226944]  [<c18860f1>] syscall_call+0x7/0xb
> <4>[11340.226960]  [<c1880000>] ? restore_cur+0x5e/0xd7
> <0>[11340.226969] Code: <f0> ff 4b 08 0f 94 c0 84 c0 74 20 80 7b 19 01 74 2f b8 0a 00 00
> 
> Disassemble the code:
> base address of __sco_sock_close is 0xc184f410
> 0xc184f4f8 <+232>:   lock decl 0x8(%ebx) < == crash here, ebx is 0x0,
> 
> the related source code is:
> (gdb) l *0xc184f4f8
> 0xc184f4f8 is in __sco_sock_close (arch/x86/include/asm/atomic.h:123)
> 119     static inline int atomic_dec_and_test(atomic_t *v)
> 123             asm volatile(LOCK_PREFIX "decl %0; sete %1"
> 
> The whole call stack is:
> sys_shutdown()
>   sco_sock_shutdown()
>     __sco_sock_close()
>       hci_conn_put()
>         atomic_dec_and_test()
> 
> Due to the conn->hcon is NULL, and the member hcon->refcnt is at offset 0x8,
> so "BUG: unable to handle kernel NULL pointer dereference at 00000008"
> appears.
> 
> Here fix it that adding the condition if conn->hcon is NULL, just like
> in sco_chan_del().
> 
> Signed-off-by: liu chuansheng <chuansheng.liu@intel.com>
> ---
>  net/bluetooth/sco.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
> index 531a93d..190f70c 100644
> --- a/net/bluetooth/sco.c
> +++ b/net/bluetooth/sco.c
> @@ -355,8 +355,10 @@ static void __sco_sock_close(struct sock *sk)
>  		if (sco_pi(sk)->conn) {
>  			sk->sk_state = BT_DISCONN;
>  			sco_sock_set_timer(sk, SCO_DISCONN_TIMEOUT);
> -			hci_conn_put(sco_pi(sk)->conn->hcon);
> -			sco_pi(sk)->conn->hcon = NULL;
> +			if (sco_pi(sk)->conn->hcon) {
> +				hci_conn_put(sco_pi(sk)->conn->hcon);
> +				sco_pi(sk)->conn->hcon = NULL;
> +			}
>  		} else
>  			sco_chan_del(sk, ECONNRESET);
>  		break;

Please check if the following patch fixes the issue for you:

commit ae5668c1fc155d3034d0eedcdb52798390975a39 (HEAD, master)
Author: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Date:   Thu Jan 3 19:59:28 2013 -0200

    Bluetooth: Check if the hci connection exists in SCO shutdown
    
    Checking only for sco_conn seems to not be enough and lead to NULL
    dereferences in the code, check for hcon instead.
    
    <1>[11340.226404] BUG: unable to handle kernel NULL pointer dereference at
    0000000
    8
    <4>[11340.226619] EIP is at __sco_sock_close+0xe8/0x1a0
    <4>[11340.226629] EAX: f063a740 EBX: 00000000 ECX: f58f4544 EDX: 00000000
    <4>[11340.226640] ESI: dec83e00 EDI: 5f9a081f EBP: e0fdff38 ESP: e0fdff1c
    <0>[11340.226674] Stack:
    <4>[11340.226682]  c184db87 c1251028 dec83e00 e0fdff38 c1754aef dec83e00
    00000000
    e0fdff5c
    <4>[11340.226718]  c184f587 e0fdff64 e0fdff68 5f9a081f e0fdff5c c1751852
    d7813800
    62262f10
    <4>[11340.226752]  e0fdff70 c1753c00 00000000 00000001 0000000d e0fdffac
    c175425c
    00000041
    <0>[11340.226793] Call Trace:
    <4>[11340.226813]  [<c184db87>] ? sco_sock_clear_timer+0x27/0x60
    <4>[11340.226831]  [<c1251028>] ? local_bh_enable+0x68/0xd0
    <4>[11340.226846]  [<c1754aef>] ? lock_sock_nested+0x4f/0x60
    <4>[11340.226862]  [<c184f587>] sco_sock_shutdown+0x67/0xb0
    <4>[11340.226879]  [<c1751852>] ? sockfd_lookup_light+0x22/0x80
    <4>[11340.226897]  [<c1753c00>] sys_shutdown+0x30/0x60
    <4>[11340.226912]  [<c175425c>] sys_socketcall+0x1dc/0x2a0
    <4>[11340.226929]  [<c149ba78>] ? trace_hardirqs_on_thunk+0xc/0x10
    <4>[11340.226944]  [<c18860f1>] syscall_call+0x7/0xb
    <4>[11340.226960]  [<c1880000>] ? restore_cur+0x5e/0xd7
    <0>[11340.226969] Code: <f0> ff 4b 08 0f 94 c0 84 c0 74 20 80 7b 19 01 74
    2f b8 0a 00 00
    
    Reported-by: Chuansheng Liu <chuansheng.liu@intel.com>
    Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 531a93d..57f250c 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -352,7 +352,7 @@ static void __sco_sock_close(struct sock *sk)
 
 	case BT_CONNECTED:
 	case BT_CONFIG:
-		if (sco_pi(sk)->conn) {
+		if (sco_pi(sk)->conn->hcon) {
 			sk->sk_state = BT_DISCONN;
 			sco_sock_set_timer(sk, SCO_DISCONN_TIMEOUT);
 			hci_conn_put(sco_pi(sk)->conn->hcon);

^ permalink raw reply related

* Re: [PATCH 2/2] AVCTP: Replace calls to g_queue_free_full function
From: Marcel Holtmann @ 2013-01-03 21:00 UTC (permalink / raw)
  To: Giovanni Gherdovich; +Cc: linux-bluetooth
In-Reply-To: <1357241835-4861-1-git-send-email-g.gherdovich@gmail.com>

Hi Giovanni,

> The function g_queue_free_full is available only from GLib 2.32.
> If BlueZ has to build against GLib 2.28, as stated in the configure.ac,
> this patch replaces the calls to g_queue_free_full in the AVTCP module
> with its body, taken from the sources of GLib 2.32.
> ---
>  profiles/audio/avctp.c |   14 ++++++++------
>  1 files changed, 8 insertions(+), 6 deletions(-)

patch has been applied.

Regards

Marcel



^ permalink raw reply

* Re: [PATCH 1/2] core: Replace calls to g_queue_free_full function
From: Marcel Holtmann @ 2013-01-03 21:00 UTC (permalink / raw)
  To: Giovanni Gherdovich; +Cc: linux-bluetooth
In-Reply-To: <1357241822-4825-1-git-send-email-g.gherdovich@gmail.com>

Hi Giovanni,

> The function g_queue_free_full is available only from GLib 2.32.
> If BlueZ has to build against GLib 2.28, as stated in the configure.ac,
> this patch replaces the calls to g_queue_free_full in the "core" BlueZ module
> with its body, taken from the sources of GLib 2.32.
> ---
>  src/adapter.c |   10 +++++++++-
>  1 files changed, 9 insertions(+), 1 deletions(-)

patch has been applied.

Regards

Marcel



^ permalink raw reply

* Re: [PATCH 2/2] Bluetooth: Add support for Foxconn / Hon Hai [0489:e056]
From: Gustavo Padovan @ 2013-01-03 20:59 UTC (permalink / raw)
  To: AceLan Kao; +Cc: linux-bluetooth, Marcel Holtmann, Johan Hedberg
In-Reply-To: <1357187100-9658-2-git-send-email-acelan.kao@canonical.com>

Hi AceLan,

* AceLan Kao <acelan.kao@canonical.com> [2013-01-03 12:25:00 +0800]:

> Add support for the AR9462 chip
> 
> T: Bus=01 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=0489 ProdID=e056 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: AceLan Kao <acelan.kao@canonical.com>
> ---
>  drivers/bluetooth/ath3k.c |    2 ++
>  drivers/bluetooth/btusb.c |    1 +
>  2 files changed, 3 insertions(+)

Both patches have been applied to bluetooth.git. Thanks.

	Gustavo

^ permalink raw reply

* Re: [PATCH] attrib-server: Fix invalid device access
From: Johan Hedberg @ 2013-01-03 20:56 UTC (permalink / raw)
  To: Paulo Borges; +Cc: linux-bluetooth
In-Reply-To: <1357239438-10309-1-git-send-email-paulo.borges@openbossa.org>

Hi Paulo,

On Thu, Jan 03, 2013, Paulo Borges wrote:
> When the device is not found, the channel attach must fail.
> ---
>  src/attrib-server.c |   11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)

Applied though I did make one change first:

> diff --git a/src/attrib-server.c b/src/attrib-server.c
> index 15622e4..4a25743 100644
> --- a/src/attrib-server.c
> +++ b/src/attrib-server.c
> @@ -1131,10 +1131,17 @@ guint attrib_channel_attach(GAttrib *attrib)
>  	ba2str(&channel->dst, addr);
>  
>  	device = adapter_find_device(server->adapter, addr);
> -	if (device == NULL || device_is_bonded(device) == FALSE) {
> +	if (device == NULL) {
> +		error("Device not found");

Never do error() logs with a very generic message like this. Always
provide enough context to figure out what part of the the (big) bluez
code base the error is coming from. Unlike DBG() error() doesn't provide
any automatic context.

Johan

^ permalink raw reply

* Re: [PATCH] Bluetooth device 04ca:3008 should use ath3k
From: Gustavo Padovan @ 2013-01-03 20:39 UTC (permalink / raw)
  To: Sergio Cambra; +Cc: linux-bluetooth
In-Reply-To: <2070457.EiHL78Yky8@tablet>

Hi Sergio,

* Sergio Cambra <sergio@enpijama.es> [2013-01-02 21:52:12 +0100]:

> I'm using kernel 3.6.6 from Chakra, and 04ca:3008 device was using btusb driver. Adapter was found but scan didn't work. Loading ath3k with modprobe didn't fix it.
> 
> After adding 04ca:3008 to ath3k.c and btusb.c, ath3k was loaded on boot and it finds bluetooth devices on scanning. This patch is working in 3.6.6 but it's simple so I did against latest version (3.8-rc1)
> 
> This patch it's for bug https://bugzilla.kernel.org/show_bug.cgi?id=51891
> 
> diff -uprN -X linux-3.8-rc1-vanilla/Documentation/dontdiff linux-3.8-rc1-vanilla/drivers/bluetooth/ath3k.c linux-3.8-rc1/drivers/bluetooth/ath3k.c
> --- linux-3.8-rc1-vanilla/drivers/bluetooth/ath3k.c     2013-01-02 21:41:46.778002039 +0100
> +++ linux-3.8-rc1/drivers/bluetooth/ath3k.c     2013-01-02 21:41:55.501028313 +0100
> @@ -77,6 +77,7 @@ static struct usb_device_id ath3k_table[
>         { USB_DEVICE(0x0CF3, 0x311D) },
>         { USB_DEVICE(0x13d3, 0x3375) },
>         { USB_DEVICE(0x04CA, 0x3005) },
> +       { USB_DEVICE(0x04CA, 0x3008) },
>         { USB_DEVICE(0x13d3, 0x3362) },
>         { USB_DEVICE(0x0CF3, 0xE004) },
>         { USB_DEVICE(0x0930, 0x0219) },
> @@ -104,6 +105,7 @@ static struct usb_device_id ath3k_blist_
>         { USB_DEVICE(0x0cf3, 0x311D), .driver_info = BTUSB_ATH3012 },
>         { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
>         { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
> +       { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
>         { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
>         { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
>         { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
> diff -uprN -X linux-3.8-rc1-vanilla/Documentation/dontdiff linux-3.8-rc1-vanilla/drivers/bluetooth/btusb.c linux-3.8-rc1/drivers/bluetooth/btusb.c
> --- linux-3.8-rc1-vanilla/drivers/bluetooth/btusb.c     2013-01-02 21:41:46.781335256 +0100
> +++ linux-3.8-rc1/drivers/bluetooth/btusb.c     2013-01-02 21:41:55.504361528 +0100
> @@ -135,6 +135,7 @@ static struct usb_device_id blacklist_ta
>         { USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 },
>         { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
>         { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
> +       { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
>         { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
>         { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
>         { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },

Please provide a patch rebased against bluetooth.git[0] and with your
Signed-off-by: line.
Also, we require the output of /sys/kernel/debug/usb/devices for this device
in the commit message.

[0] http://git.kernel.org/?p=linux/kernel/git/bluetooth/bluetooth.git

	Gustavo

^ permalink raw reply

* Re: [PATCH] Bluetooth: Add support for GC-WB300D PCIe [04ca:3006] to ath3k.
From: Gustavo Padovan @ 2013-01-03 20:07 UTC (permalink / raw)
  To: Daniel Schaal
  Cc: Marcel Holtmann, Johan Hedberg, linux-bluetooth, linux-kernel
In-Reply-To: <1356776074-1703-2-git-send-email-farbing@web.de>

Hi Daniel, 

* Daniel Schaal <farbing@web.de> [2012-12-29 11:14:34 +0100]:

> T:  Bus=02 Lev=02 Prnt=02 Port=06 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=04ca ProdID=3006 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: Daniel Schaal <farbing@web.de>
> ---
>  drivers/bluetooth/ath3k.c |    2 ++
>  drivers/bluetooth/btusb.c |    1 +
>  2 files changed, 3 insertions(+)

Patch has been applied to bluetooth.git. Thanks.

	Gustavo

^ permalink raw reply

* [PATCH BlueZ 8/8] gdbus: Fix introspection data for deprecated properties
From: Luiz Augusto von Dentz @ 2013-01-03 19:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1357242371-6752-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Fix missing </property> when generating introspection xml of deprecated
properties.
---
 gdbus/object.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gdbus/object.c b/gdbus/object.c
index b9cb284..729557b 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -210,9 +210,12 @@ static void generate_interface_xml(GString *gstr, struct interface_data *iface)
 
 		if (!deprecated)
 			g_string_append_printf(gstr, "/>\n");
-		else
+		else {
 			g_string_append_printf(gstr,
 				G_DBUS_ANNOTATE_DEPRECATED(">\n\t\t\t"));
+
+			g_string_append_printf(gstr, "\t\t</property>\n");
+		}
 	}
 }
 
-- 
1.8.0.1


^ permalink raw reply related

* [PATCH BlueZ 7/8] player: Remove experimental flag from MediaPlayer1
From: Luiz Augusto von Dentz @ 2013-01-03 19:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1357242371-6752-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 doc/media-api.txt       |  2 +-
 profiles/audio/player.c | 21 +++++++--------------
 2 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/doc/media-api.txt b/doc/media-api.txt
index 5a6b68c..12a2d7a 100644
--- a/doc/media-api.txt
+++ b/doc/media-api.txt
@@ -179,7 +179,7 @@ MediaPlayer1 hierarchy
 ======================
 
 Service		org.bluez (Controller role)
-Interface	org.bluez.MediaPlayer1 [Experimental]
+Interface	org.bluez.MediaPlayer1
 Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/playerX
 
 Methods		void Play()
diff --git a/profiles/audio/player.c b/profiles/audio/player.c
index 62c08c9..5a6d69f 100644
--- a/profiles/audio/player.c
+++ b/profiles/audio/player.c
@@ -410,20 +410,13 @@ static const GDBusSignalTable media_player_signals[] = {
 };
 
 static const GDBusPropertyTable media_player_properties[] = {
-	{ "Position", "u", get_position, NULL, NULL,
-					G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
-	{ "Status", "s", get_status, NULL, status_exists,
-					G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
-	{ "Equalizer", "s", get_setting, set_setting, setting_exists,
-					G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
-	{ "Repeat", "s", get_setting, set_setting, setting_exists,
-					G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
-	{ "Shuffle", "s", get_setting, set_setting, setting_exists,
-					G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
-	{ "Scan", "s", get_setting, set_setting, setting_exists,
-					G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
-	{ "Track", "a{sv}", get_track, NULL, NULL,
-					G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
+	{ "Position", "u", get_position, NULL, NULL },
+	{ "Status", "s", get_status, NULL, status_exists },
+	{ "Equalizer", "s", get_setting, set_setting, setting_exists },
+	{ "Repeat", "s", get_setting, set_setting, setting_exists },
+	{ "Shuffle", "s", get_setting, set_setting, setting_exists },
+	{ "Scan", "s", get_setting, set_setting, setting_exists },
+	{ "Track", "a{sv}", get_track, NULL, NULL },
 	{ }
 };
 
-- 
1.8.0.1


^ permalink raw reply related

* [PATCH BlueZ 6/8] control: Mark all members of MediaControl1 as deprecated
From: Luiz Augusto von Dentz @ 2013-01-03 19:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1357242371-6752-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 profiles/audio/control.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/profiles/audio/control.c b/profiles/audio/control.c
index 642fdd5..70faab8 100644
--- a/profiles/audio/control.c
+++ b/profiles/audio/control.c
@@ -222,20 +222,23 @@ static gboolean control_property_get_connected(
 }
 
 static const GDBusMethodTable control_methods[] = {
-	{ GDBUS_METHOD("Play", NULL, NULL, control_play) },
-	{ GDBUS_METHOD("Pause", NULL, NULL, control_pause) },
-	{ GDBUS_METHOD("Stop", NULL, NULL, control_stop) },
-	{ GDBUS_METHOD("Next", NULL, NULL, control_next) },
-	{ GDBUS_METHOD("Previous", NULL, NULL, control_previous) },
-	{ GDBUS_METHOD("VolumeUp", NULL, NULL, control_volume_up) },
-	{ GDBUS_METHOD("VolumeDown", NULL, NULL, control_volume_down) },
-	{ GDBUS_METHOD("FastForward", NULL, NULL, control_fast_forward) },
-	{ GDBUS_METHOD("Rewind", NULL, NULL, control_rewind) },
+	{ GDBUS_DEPRECATED_METHOD("Play", NULL, NULL, control_play) },
+	{ GDBUS_DEPRECATED_METHOD("Pause", NULL, NULL, control_pause) },
+	{ GDBUS_DEPRECATED_METHOD("Stop", NULL, NULL, control_stop) },
+	{ GDBUS_DEPRECATED_METHOD("Next", NULL, NULL, control_next) },
+	{ GDBUS_DEPRECATED_METHOD("Previous", NULL, NULL, control_previous) },
+	{ GDBUS_DEPRECATED_METHOD("VolumeUp", NULL, NULL, control_volume_up) },
+	{ GDBUS_DEPRECATED_METHOD("VolumeDown", NULL, NULL,
+							control_volume_down) },
+	{ GDBUS_DEPRECATED_METHOD("FastForward", NULL, NULL,
+							control_fast_forward) },
+	{ GDBUS_DEPRECATED_METHOD("Rewind", NULL, NULL, control_rewind) },
 	{ }
 };
 
 static const GDBusPropertyTable control_properties[] = {
-	{ "Connected", "b", control_property_get_connected },
+	{ "Connected", "b", control_property_get_connected, NULL, NULL,
+					G_DBUS_PROPERTY_FLAG_DEPRECATED },
 	{ }
 };
 
-- 
1.8.0.1


^ permalink raw reply related

* [PATCH BlueZ 5/8] AVRCP: Always create a controller player even for version 1.0
From: Luiz Augusto von Dentz @ 2013-01-03 19:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1357242371-6752-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Since the buttons controls are now part of the MediaPlayer1 it can be used
even with AVRCP version 1.0.
---
 profiles/audio/avrcp.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 99741e8..74ef3ea 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -1952,6 +1952,9 @@ static bool ct_set_setting(struct media_player *mp, const char *key,
 	if (session == NULL)
 		return false;
 
+	if (session->version < 0x0103)
+		return false;
+
 	attr = attr_to_val(key);
 	if (attr < 0)
 		return false;
@@ -2063,24 +2066,15 @@ static gboolean avrcp_get_capabilities_resp(struct avctp *conn,
 					void *user_data)
 {
 	struct avrcp *session = user_data;
-	struct avrcp_player *player = session->player;
-	struct media_player *mp;
 	struct avrcp_header *pdu = (void *) operands;
 	uint16_t events = 0;
 	uint8_t count;
-	const char *path;
 
 	if (pdu->params[0] != CAP_EVENTS_SUPPORTED)
 		return FALSE;
 
 	count = pdu->params[1];
 
-	path = device_get_path(session->dev->btd_dev);
-
-	mp = media_player_controller_create(path);
-	if (mp == NULL)
-		return FALSE;
-
 	for (; count > 0; count--) {
 		uint8_t event = pdu->params[1 + count];
 
@@ -2095,10 +2089,6 @@ static gboolean avrcp_get_capabilities_resp(struct avctp *conn,
 		}
 	}
 
-	media_player_set_callbacks(mp, &ct_cbs, player);
-	player->user_data = mp;
-	player->destroy = (GDestroyNotify) media_player_destroy;
-
 	if (!(events & (1 << AVRCP_EVENT_SETTINGS_CHANGED)))
 		avrcp_list_player_attributes(session);
 
@@ -2185,6 +2175,8 @@ static void session_tg_init(struct avrcp *session)
 static void session_ct_init(struct avrcp *session)
 {
 	struct avrcp_player *player;
+	struct media_player *mp;
+	const char *path;
 
 	session->control_handlers = ct_control_handlers;
 
@@ -2195,13 +2187,22 @@ static void session_ct_init(struct avrcp *session)
 							handle_vendordep_pdu,
 							session);
 
-	if (session->version < 0x0103)
-		return;
-
 	player = g_new0(struct avrcp_player, 1);
 	player->sessions = g_slist_prepend(player->sessions, session);
 	session->player = player;
 
+	path = device_get_path(session->dev->btd_dev);
+
+	mp = media_player_controller_create(path);
+	if (mp != NULL) {
+		media_player_set_callbacks(mp, &ct_cbs, player);
+		player->user_data = mp;
+		player->destroy = (GDestroyNotify) media_player_destroy;
+	}
+
+	if (session->version < 0x0103)
+		return;
+
 	avrcp_get_capabilities(session);
 }
 
-- 
1.8.0.1


^ permalink raw reply related

* [PATCH BlueZ 4/8] player: Fix documentation to use TrackNumber in track metadata
From: Luiz Augusto von Dentz @ 2013-01-03 19:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1357242371-6752-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Using Track key inside a Track property would be pointless, despite the
documentation and code where also inconsistent.
---
 doc/media-api.txt       | 2 +-
 profiles/audio/avrcp.c  | 2 +-
 profiles/audio/player.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/doc/media-api.txt b/doc/media-api.txt
index eb1f74f..5a6b68c 100644
--- a/doc/media-api.txt
+++ b/doc/media-api.txt
@@ -280,7 +280,7 @@ Properties	string Equalizer [readwrite]
 
 					Number of tracks in total
 
-				uint32 Number:
+				uint32 TrackNumber:
 
 					Track number
 
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 7b7c2ef..99741e8 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -649,7 +649,7 @@ static const char *metadata_to_str(uint32_t id)
 	case AVRCP_MEDIA_ATTRIBUTE_GENRE:
 		return "Genre";
 	case AVRCP_MEDIA_ATTRIBUTE_TRACK:
-		return "Track";
+		return "TrackNumber";
 	case AVRCP_MEDIA_ATTRIBUTE_N_TRACKS:
 		return "NumberOfTracks";
 	case AVRCP_MEDIA_ATTRIBUTE_DURATION:
diff --git a/profiles/audio/player.c b/profiles/audio/player.c
index 01086d0..62c08c9 100644
--- a/profiles/audio/player.c
+++ b/profiles/audio/player.c
@@ -72,7 +72,7 @@ static void append_metadata(void *key, void *value, void *user_data)
 	DBusMessageIter *dict = user_data;
 
 	if (strcasecmp((char *) key, "Duration") == 0 ||
-			strcasecmp((char *) key, "Track") == 0 ||
+			strcasecmp((char *) key, "TrackNumber") == 0 ||
 			strcasecmp((char *) key, "NumberOfTracks") == 0)  {
 		uint32_t num = atoi(value);
 		dict_append_entry(dict, key, DBUS_TYPE_UINT32, &num);
-- 
1.8.0.1


^ permalink raw reply related

* [PATCH BlueZ 3/8] player: Add support for button controls
From: Luiz Augusto von Dentz @ 2013-01-03 19:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1357242371-6752-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds support for buttons controls in MediaPlayer1
---
 profiles/audio/avrcp.c  |  91 ++++++++++++++++++++++++++-
 profiles/audio/player.c | 162 ++++++++++++++++++++++++++++++++++++++++++++++++
 profiles/audio/player.h |   9 +++
 3 files changed, 261 insertions(+), 1 deletion(-)

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index ce070cd..7b7c2ef 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -1965,8 +1965,96 @@ static bool ct_set_setting(struct media_player *mp, const char *key,
 	return true;
 }
 
+static int ct_press(struct avrcp_player *player, uint8_t op)
+{
+	int err;
+	struct avrcp *session;
+
+	session = player->sessions->data;
+	if (session == NULL)
+		return -ENOTCONN;
+
+	err = avctp_send_passthrough(session->conn, op);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+static int ct_play(struct media_player *mp, void *user_data)
+{
+	struct avrcp_player *player = user_data;
+
+	return ct_press(player, AVC_PLAY);
+}
+
+static int ct_pause(struct media_player *mp, void *user_data)
+{
+	struct avrcp_player *player = user_data;
+
+	return ct_press(player, AVC_PAUSE);
+}
+
+static int ct_stop(struct media_player *mp, void *user_data)
+{
+	struct avrcp_player *player = user_data;
+
+	return ct_press(player, AVC_STOP);
+}
+
+static int ct_next(struct media_player *mp, void *user_data)
+{
+	struct avrcp_player *player = user_data;
+
+	return ct_press(player, AVC_FORWARD);
+}
+
+static int ct_previous(struct media_player *mp, void *user_data)
+{
+	struct avrcp_player *player = user_data;
+
+	return ct_press(player, AVC_BACKWARD);
+}
+
+static int ct_fast_forward(struct media_player *mp, void *user_data)
+{
+	struct avrcp_player *player = user_data;
+
+	return ct_press(player, AVC_FAST_FORWARD);
+}
+
+static int ct_rewind(struct media_player *mp, void *user_data)
+{
+	struct avrcp_player *player = user_data;
+
+	return ct_press(player, AVC_REWIND);
+}
+
+static int ct_volume_up(struct media_player *mp, void *user_data)
+{
+	struct avrcp_player *player = user_data;
+
+	return ct_press(player, AVC_VOLUME_UP);
+}
+
+static int ct_volume_down(struct media_player *mp, void *user_data)
+{
+	struct avrcp_player *player = user_data;
+
+	return ct_press(player, AVC_VOLUME_DOWN);
+}
+
 static const struct media_player_callback ct_cbs = {
-	.set_setting = ct_set_setting,
+	.set_setting	= ct_set_setting,
+	.play		= ct_play,
+	.pause		= ct_pause,
+	.stop		= ct_stop,
+	.next		= ct_next,
+	.previous	= ct_previous,
+	.fast_forward	= ct_fast_forward,
+	.rewind		= ct_rewind,
+	.volume_up	= ct_volume_up,
+	.volume_down	= ct_volume_down,
 };
 
 static gboolean avrcp_get_capabilities_resp(struct avctp *conn,
@@ -1988,6 +2076,7 @@ static gboolean avrcp_get_capabilities_resp(struct avctp *conn,
 	count = pdu->params[1];
 
 	path = device_get_path(session->dev->btd_dev);
+
 	mp = media_player_controller_create(path);
 	if (mp == NULL)
 		return FALSE;
diff --git a/profiles/audio/player.c b/profiles/audio/player.c
index ae6b19b..01086d0 100644
--- a/profiles/audio/player.c
+++ b/profiles/audio/player.c
@@ -239,7 +239,169 @@ static gboolean get_track(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
+static DBusMessage *media_player_play(DBusConnection *conn, DBusMessage *msg,
+								void *data)
+{
+	struct media_player *mp = data;
+	struct player_callback *cb = mp->cb;
+	int err;
+
+	if (cb->cbs->play == NULL)
+		return btd_error_not_supported(msg);
+
+	err = cb->cbs->play(mp, cb->user_data);
+	if (err < 0)
+		return btd_error_failed(msg, strerror(-err));
+
+	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+}
+
+static DBusMessage *media_player_pause(DBusConnection *conn, DBusMessage *msg,
+								void *data)
+{
+	struct media_player *mp = data;
+	struct player_callback *cb = mp->cb;
+	int err;
+
+	if (cb->cbs->pause == NULL)
+		return btd_error_not_supported(msg);
+
+	err = cb->cbs->pause(mp, cb->user_data);
+	if (err < 0)
+		return btd_error_failed(msg, strerror(-err));
+
+	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+}
+
+static DBusMessage *media_player_stop(DBusConnection *conn, DBusMessage *msg,
+								void *data)
+{
+	struct media_player *mp = data;
+	struct player_callback *cb = mp->cb;
+	int err;
+
+	if (cb->cbs->stop == NULL)
+		return btd_error_not_supported(msg);
+
+	err = cb->cbs->stop(mp, cb->user_data);
+	if (err < 0)
+		return btd_error_failed(msg, strerror(-err));
+
+	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+}
+
+static DBusMessage *media_player_next(DBusConnection *conn, DBusMessage *msg,
+								void *data)
+{
+	struct media_player *mp = data;
+	struct player_callback *cb = mp->cb;
+	int err;
+
+	if (cb->cbs->next == NULL)
+		return btd_error_not_supported(msg);
+
+	err = cb->cbs->next(mp, cb->user_data);
+	if (err < 0)
+		return btd_error_failed(msg, strerror(-err));
+
+	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+}
+
+static DBusMessage *media_player_previous(DBusConnection *conn,
+						DBusMessage *msg, void *data)
+{
+	struct media_player *mp = data;
+	struct player_callback *cb = mp->cb;
+	int err;
+
+	if (cb->cbs->previous == NULL)
+		return btd_error_not_supported(msg);
+
+	err = cb->cbs->previous(mp, cb->user_data);
+	if (err < 0)
+		return btd_error_failed(msg, strerror(-err));
+
+	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+}
+
+static DBusMessage *media_player_fast_forward(DBusConnection *conn,
+						DBusMessage *msg, void *data)
+{
+	struct media_player *mp = data;
+	struct player_callback *cb = mp->cb;
+	int err;
+
+	if (cb->cbs->fast_forward == NULL)
+		return btd_error_not_supported(msg);
+
+	err = cb->cbs->fast_forward(mp, cb->user_data);
+	if (err < 0)
+		return btd_error_failed(msg, strerror(-err));
+
+	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+}
+
+static DBusMessage *media_player_rewind(DBusConnection *conn, DBusMessage *msg,
+								void *data)
+{
+	struct media_player *mp = data;
+	struct player_callback *cb = mp->cb;
+	int err;
+
+	if (cb->cbs->rewind == NULL)
+		return btd_error_not_supported(msg);
+
+	err = cb->cbs->rewind(mp, cb->user_data);
+	if (err < 0)
+		return btd_error_failed(msg, strerror(-err));
+
+	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+}
+
+static DBusMessage *media_player_volume_up(DBusConnection *conn,
+						DBusMessage *msg, void *data)
+{
+	struct media_player *mp = data;
+	struct player_callback *cb = mp->cb;
+	int err;
+
+	if (cb->cbs->volume_up == NULL)
+		return btd_error_not_supported(msg);
+
+	err = cb->cbs->volume_up(mp, cb->user_data);
+	if (err < 0)
+		return btd_error_failed(msg, strerror(-err));
+
+	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+}
+
+static DBusMessage *media_player_volume_down(DBusConnection *conn,
+						DBusMessage *msg, void *data)
+{
+	struct media_player *mp = data;
+	struct player_callback *cb = mp->cb;
+	int err;
+
+	if (cb->cbs->volume_down == NULL)
+		return btd_error_not_supported(msg);
+
+	err = cb->cbs->volume_down(mp, cb->user_data);
+	if (err < 0)
+		return btd_error_failed(msg, strerror(-err));
+
+	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+}
+
 static const GDBusMethodTable media_player_methods[] = {
+	{ GDBUS_METHOD("Play", NULL, NULL, media_player_play) },
+	{ GDBUS_METHOD("Pause", NULL, NULL, media_player_pause) },
+	{ GDBUS_METHOD("Stop", NULL, NULL, media_player_stop) },
+	{ GDBUS_METHOD("Next", NULL, NULL, media_player_next) },
+	{ GDBUS_METHOD("Previous", NULL, NULL, media_player_previous) },
+	{ GDBUS_METHOD("FastForward", NULL, NULL, media_player_fast_forward) },
+	{ GDBUS_METHOD("Rewind", NULL, NULL, media_player_rewind) },
+	{ GDBUS_METHOD("VolumeUp", NULL, NULL, media_player_volume_up) },
+	{ GDBUS_METHOD("VolumeDown", NULL, NULL, media_player_volume_down) },
 	{ }
 };
 
diff --git a/profiles/audio/player.h b/profiles/audio/player.h
index 87dfb66..4b92b30 100644
--- a/profiles/audio/player.h
+++ b/profiles/audio/player.h
@@ -28,6 +28,15 @@ struct media_player;
 struct media_player_callback {
 	bool (*set_setting) (struct media_player *mp, const char *key,
 				const char *value, void *user_data);
+	int (*play) (struct media_player *mp, void *user_data);
+	int (*pause) (struct media_player *mp, void *user_data);
+	int (*stop) (struct media_player *mp, void *user_data);
+	int (*next) (struct media_player *mp, void *user_data);
+	int (*previous) (struct media_player *mp, void *user_data);
+	int (*fast_forward) (struct media_player *mp, void *user_data);
+	int (*rewind) (struct media_player *mp, void *user_data);
+	int (*volume_up) (struct media_player *mp, void *user_data);
+	int (*volume_down) (struct media_player *mp, void *user_data);
 };
 
 struct media_player *media_player_controller_create(const char *path);
-- 
1.8.0.1


^ permalink raw reply related

* [PATCH BlueZ 2/8] player: Remove GetTrack and TrackChanged
From: Luiz Augusto von Dentz @ 2013-01-03 19:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1357242371-6752-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This turn track metadata into a property called "Track" of MediaPlayer1
---
 profiles/audio/player.c | 83 +++++++++++++++----------------------------------
 1 file changed, 25 insertions(+), 58 deletions(-)

diff --git a/profiles/audio/player.c b/profiles/audio/player.c
index 8748893..ae6b19b 100644
--- a/profiles/audio/player.c
+++ b/profiles/audio/player.c
@@ -82,33 +82,6 @@ static void append_metadata(void *key, void *value, void *user_data)
 	dict_append_entry(dict, key, DBUS_TYPE_STRING, &value);
 }
 
-static DBusMessage *media_player_get_track(DBusConnection *conn,
-						DBusMessage *msg, void *data)
-{
-	struct media_player *mp = data;
-	DBusMessage *reply;
-	DBusMessageIter iter, dict;
-
-	reply = dbus_message_new_method_return(msg);
-	if (!reply)
-		return NULL;
-
-	dbus_message_iter_init_append(reply, &iter);
-
-	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
-					DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
-					DBUS_TYPE_STRING_AS_STRING
-					DBUS_TYPE_VARIANT_AS_STRING
-					DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
-					&dict);
-
-	g_hash_table_foreach(mp->track, append_metadata, &dict);
-
-	dbus_message_iter_close_container(&iter, &dict);
-
-	return reply;
-}
-
 static struct pending_req *find_pending(struct media_player *mp,
 							const char *key)
 {
@@ -246,16 +219,31 @@ static void set_setting(const GDBusPropertyTable *property,
 	player_set_setting(mp, id, property->name, value);
 }
 
+static gboolean get_track(const GDBusPropertyTable *property,
+					DBusMessageIter *iter, void *data)
+{
+	struct media_player *mp = data;
+	DBusMessageIter dict;
+
+	dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+					DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+					DBUS_TYPE_STRING_AS_STRING
+					DBUS_TYPE_VARIANT_AS_STRING
+					DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
+					&dict);
+
+	g_hash_table_foreach(mp->track, append_metadata, &dict);
+
+	dbus_message_iter_close_container(iter, &dict);
+
+	return TRUE;
+}
+
 static const GDBusMethodTable media_player_methods[] = {
-	{ GDBUS_EXPERIMENTAL_METHOD("GetTrack",
-			NULL, GDBUS_ARGS({ "metadata", "a{sv}" }),
-			media_player_get_track) },
 	{ }
 };
 
 static const GDBusSignalTable media_player_signals[] = {
-	{ GDBUS_EXPERIMENTAL_SIGNAL("TrackChanged",
-			GDBUS_ARGS({ "metadata", "a{sv}" })) },
 	{ }
 };
 
@@ -272,6 +260,8 @@ static const GDBusPropertyTable media_player_properties[] = {
 					G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
 	{ "Scan", "s", get_setting, set_setting, setting_exists,
 					G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
+	{ "Track", "a{sv}", get_track, NULL, NULL,
+					G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
 	{ }
 };
 
@@ -424,33 +414,10 @@ void media_player_set_status(struct media_player *mp, const char *status)
 static gboolean process_metadata_changed(void *user_data)
 {
 	struct media_player *mp = user_data;
-	DBusMessage *signal;
-	DBusMessageIter iter, dict;
-
-	mp->process_id = 0;
-
-	signal = dbus_message_new_signal(mp->path, MEDIA_PLAYER_INTERFACE,
-							"TrackChanged");
-	if (signal == NULL) {
-		error("Unable to allocate TrackChanged signal");
-		return FALSE;
-	}
 
-	dbus_message_iter_init_append(signal, &iter);
-
-	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
-					DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
-					DBUS_TYPE_STRING_AS_STRING
-					DBUS_TYPE_VARIANT_AS_STRING
-					DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
-					&dict);
-
-
-	g_hash_table_foreach(mp->track, append_metadata, &dict);
-
-	dbus_message_iter_close_container(&iter, &dict);
-
-	g_dbus_send_message(btd_get_dbus_connection(), signal);
+	g_dbus_emit_property_changed(btd_get_dbus_connection(),
+					mp->path, MEDIA_PLAYER_INTERFACE,
+					"Track");
 
 	return FALSE;
 }
-- 
1.8.0.1


^ permalink raw reply related

* [PATCH BlueZ 1/8] media-api: Add playback control methods to MediaPlayer1
From: Luiz Augusto von Dentz @ 2013-01-03 19:46 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds methods such as Play, Pause directly in MediaPlayer1, in
addition to that Track is now turn into a property to take advantage of
ObjectManager and document the interface as experimental.
---
 doc/media-api.txt | 99 ++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 57 insertions(+), 42 deletions(-)

diff --git a/doc/media-api.txt b/doc/media-api.txt
index e2a72dc..eb1f74f 100644
--- a/doc/media-api.txt
+++ b/doc/media-api.txt
@@ -129,7 +129,7 @@ Media Control hierarchy
 =======================
 
 Service		org.bluez
-Interface	org.bluez.MediaControl1
+Interface	org.bluez.MediaControl1 [Deprecated]
 Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
 
 Methods		void Play()
@@ -178,65 +178,47 @@ Properties
 MediaPlayer1 hierarchy
 ======================
 
-Service		unique name (Target role)
-Interface	org.bluez.MediaPlayer1
-Object path	freely definable
-
 Service		org.bluez (Controller role)
-Interface	org.bluez.MediaPlayer1
+Interface	org.bluez.MediaPlayer1 [Experimental]
 Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/playerX
 
-Methods		dict GetTrack()
-
-			Returns known metadata of the current track.
-
-			See TrackChanged for possible values.
-
-		void Release()
-
-			This method gets called when the service daemon
-			unregisters the player which can then perform
-			cleanup tasks. There is no need to unregister the
-			player, because when this method gets called it has
-			already been unregistered.
+Methods		void Play()
 
-Signals		TrackChanged(dict metadata)
+			Resume playback.
 
-			This signal indicates that current track has changed.
-			All available metadata for the new track shall be set
-			at once in the metadata argument. Metadata cannot be
-			updated in parts, otherwise it will be interpreted as
-			multiple track changes.
+		void Pause()
 
-			Possible values:
+			Pause playback.
 
-				string Title:
+		void Stop()
 
-					Track title name
+			Stop playback.
 
-				string Artist:
+		void Next()
 
-					Track artist name
+			Next item.
 
-				string Album:
+		void Previous()
 
-					Track album name
+			Previous item.
 
-				string Genre:
+		void VolumeUp()
 
-					Track genre name
+			Adjust remote volume one step up
 
-				uint32 NumberOfTracks:
+		void VolumeDown()
 
-					Number of tracks in total
+			Adjust remote volume one step down
 
-				uint32 Number:
+		void FastForward()
 
-					Track number
+			Fast forward playback, this action is only stopped
+			when another method in this interface is called.
 
-				uint32 Duration:
+		void Rewind()
 
-					Track duration in milliseconds
+			Rewind playback, this action is only stopped
+			when another method in this interface is called.
 
 Properties	string Equalizer [readwrite]
 
@@ -258,8 +240,8 @@ Properties	string Equalizer [readwrite]
 		string Status [readonly]
 
 			Possible status: "playing", "stopped", "paused",
-					"forward-seek", "reverse-seek" or
-					"error"
+					"forward-seek", "reverse-seek"
+					or "error"
 
 		uint32 Position [readonly]
 
@@ -272,6 +254,39 @@ Properties	string Equalizer [readwrite]
 			possible to signal its end by setting position to the
 			maximum uint32 value.
 
+		dict Track [readonly]
+
+			Track metadata.
+
+			Possible values:
+
+				string Title:
+
+					Track title name
+
+				string Artist:
+
+					Track artist name
+
+				string Album:
+
+					Track album name
+
+				string Genre:
+
+					Track genre name
+
+				uint32 NumberOfTracks:
+
+					Number of tracks in total
+
+				uint32 Number:
+
+					Track number
+
+				uint32 Duration:
+
+					Track duration in milliseconds
 
 MediaEndpoint1 hierarchy
 ========================
-- 
1.8.0.1


^ permalink raw reply related

* Re: [PATCH v2 2/2] Bluetooth: Fix stop discovery while in STARTING state
From: Gustavo Padovan @ 2013-01-03 19:38 UTC (permalink / raw)
  To: Jaganath Kanakkassery; +Cc: linux-bluetooth
In-Reply-To: <1356094225-12706-3-git-send-email-jaganath.k@samsung.com>

Hi Jaganath,

* Jaganath Kanakkassery <jaganath.k@samsung.com> [2012-12-21 18:20:25 +0530]:

> If stop_discovery() is called when discovery state is STARTING, it
> will be failed currently. This patch fixes this.
> 
> Signed-off-by: Jaganath Kanakkassery <jaganath.k@samsung.com>
> ---
>  include/net/bluetooth/hci_core.h |    2 ++
>  net/bluetooth/hci_event.c        |   14 ++++++++++++--
>  net/bluetooth/mgmt.c             |   31 ++++++++++++++++++++++++++++++-
>  3 files changed, 44 insertions(+), 3 deletions(-)
> 
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index 119fcb6..c2886b7 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -64,6 +64,7 @@ struct discovery_state {
>  		DISCOVERY_RESOLVING,
>  		DISCOVERY_STOPPING,
>  	} state;
> +	u8  discovering;
>  	struct list_head	all;	/* All devices found during inquiry */
>  	struct list_head	unknown;	/* Name state not known */
>  	struct list_head	resolve;	/* Name needs to be resolved */
> @@ -1066,6 +1067,7 @@ int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
>  int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
>  		     u8 addr_type, s8 rssi, u8 *name, u8 name_len);
>  int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status);
> +int mgmt_start_discovery_complete(struct hci_dev *hdev, u8 status);
>  int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status);
>  int mgmt_discovering(struct hci_dev *hdev, u8 discovering);
>  int mgmt_interleaved_discovery(struct hci_dev *hdev);
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index e248e7c..b486458 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -1092,7 +1092,12 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
>  		set_bit(HCI_LE_SCAN, &hdev->dev_flags);
>  
>  		hci_dev_lock(hdev);
> -		hci_discovery_set_state(hdev, DISCOVERY_FINDING);
> +		if (hdev->discovery.state == DISCOVERY_STOPPING) {
> +			hci_cancel_le_scan(hdev);
> +			mgmt_start_discovery_complete(hdev, 0);

Reply to mgmt with an error here might be better.

> +		} else {
> +			hci_discovery_set_state(hdev, DISCOVERY_FINDING);
> +		}
>  		hci_dev_unlock(hdev);
>  		break;
>  
> @@ -1189,7 +1194,12 @@ static void hci_cs_inquiry(struct hci_dev *hdev, __u8 status)
>  	set_bit(HCI_INQUIRY, &hdev->flags);
>  
>  	hci_dev_lock(hdev);
> -	hci_discovery_set_state(hdev, DISCOVERY_FINDING);
> +	if (hdev->discovery.state == DISCOVERY_STOPPING) {
> +		hci_cancel_inquiry(hdev);
> +		mgmt_start_discovery_complete(hdev, 0);
> +	} else {
> +		hci_discovery_set_state(hdev, DISCOVERY_FINDING);
> +	}
>  	hci_dev_unlock(hdev);
>  }
>  
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index d6c0d78..ba4171f 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -2385,7 +2385,8 @@ static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data,
>  
>  	hci_dev_lock(hdev);
>  
> -	if (!hci_discovery_active(hdev)) {
> +	if (hdev->discovery.state != DISCOVERY_STARTING &&
> +	    !hci_discovery_active(hdev)) {
>  		err = cmd_complete(sk, hdev->id, MGMT_OP_STOP_DISCOVERY,
>  				   MGMT_STATUS_REJECTED, &mgmt_cp->type,
>  				   sizeof(mgmt_cp->type));
> @@ -2433,6 +2434,10 @@ static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data,
>  
>  		break;
>  
> +	case DISCOVERY_STARTING:
> +		err = 0;
> +		break;
> +
>  	default:
>  		BT_DBG("unknown discovery state %u", hdev->discovery.state);
>  		err = -EFAULT;
> @@ -3624,6 +3629,25 @@ int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status)
>  	return err;
>  }
>  
> +int mgmt_start_discovery_complete(struct hci_dev *hdev, u8 status)
> +{
> +	struct pending_cmd *cmd;
> +	u8 type;
> +	int err;
> +
> +	cmd = mgmt_pending_find(MGMT_OP_START_DISCOVERY, hdev);
> +	if (!cmd)
> +		return -ENOENT;
> +
> +	type = hdev->discovery.type;
> +
> +	err = cmd_complete(cmd->sk, hdev->id, cmd->opcode, mgmt_status(status),
> +			   &type, sizeof(type));
> +	mgmt_pending_remove(cmd);
> +
> +	return err;
> +}

This is exactly the same thing as mgmt_start_discovery_failed(), just rename it
to _complete() as you did with mgmt_stop_discovery_failed(). Do it as a
separate patch.

	Gustavo

^ permalink raw reply

* [PATCH 2/2] AVCTP: Replace calls to g_queue_free_full function
From: Giovanni Gherdovich @ 2013-01-03 19:37 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Giovanni Gherdovich

The function g_queue_free_full is available only from GLib 2.32.
If BlueZ has to build against GLib 2.28, as stated in the configure.ac,
this patch replaces the calls to g_queue_free_full in the AVTCP module
with its body, taken from the sources of GLib 2.32.
---
 profiles/audio/avctp.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index 013c587..b26abe5 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -370,7 +370,7 @@ static struct avctp_pdu_handler *find_handler(GSList *list, uint8_t opcode)
 	return NULL;
 }
 
-static void pending_destroy(void *data)
+static void pending_destroy(gpointer data, gpointer user_data)
 {
 	struct avctp_pending_req *req = data;
 
@@ -395,8 +395,10 @@ static void avctp_channel_destroy(struct avctp_channel *chan)
 		g_source_remove(chan->process_id);
 
 	g_free(chan->buffer);
-	g_queue_free_full(chan->queue, pending_destroy);
-	g_slist_free_full(chan->processed, pending_destroy);
+	g_queue_foreach(chan->queue, pending_destroy, NULL);
+	g_queue_free(chan->queue);
+	g_slist_foreach(chan->processed, pending_destroy, NULL);
+	g_slist_free(chan->processed);
 	g_slist_free_full(chan->handlers, g_free);
 	g_free(chan);
 }
@@ -540,7 +542,7 @@ static gboolean req_timeout(gpointer user_data)
 
 	p->timeout = 0;
 
-	pending_destroy(p);
+	pending_destroy(p, NULL);
 	chan->p = NULL;
 
 	if (chan->process_id == 0)
@@ -574,7 +576,7 @@ static gboolean process_queue(void *user_data)
 		if (p->process(p->data) == 0)
 			break;
 
-		pending_destroy(p);
+		pending_destroy(p, NULL);
 	}
 
 	if (p == NULL)
@@ -626,7 +628,7 @@ static void control_response(struct avctp_channel *control,
 			return;
 
 		control->processed = g_slist_remove(control->processed, p);
-		pending_destroy(p);
+		pending_destroy(p, NULL);
 
 		return;
 	}
-- 
1.7.4.1


^ permalink raw reply related

* [PATCH 1/2] core: Replace calls to g_queue_free_full function
From: Giovanni Gherdovich @ 2013-01-03 19:37 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Giovanni Gherdovich

The function g_queue_free_full is available only from GLib 2.32.
If BlueZ has to build against GLib 2.28, as stated in the configure.ac,
this patch replaces the calls to g_queue_free_full in the "core" BlueZ module
with its body, taken from the sources of GLib 2.32.
---
 src/adapter.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index e71cea8..ca94fa9 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1688,6 +1688,13 @@ int btd_adapter_stop(struct btd_adapter *adapter)
 	return 0;
 }
 
+static void free_service_auth(gpointer data, gpointer user_data)
+{
+	struct service_auth *auth = data;
+
+	g_free(auth);
+}
+
 static void adapter_free(gpointer user_data)
 {
 	struct btd_adapter *adapter = user_data;
@@ -1697,7 +1704,8 @@ static void adapter_free(gpointer user_data)
 	if (adapter->auth_idle_id)
 		g_source_remove(adapter->auth_idle_id);
 
-	g_queue_free_full(adapter->auths, g_free);
+	g_queue_foreach(adapter->auths, free_service_auth, NULL);
+	g_queue_free(adapter->auths);
 
 	sdp_list_free(adapter->services, NULL);
 
-- 
1.7.4.1


^ permalink raw reply related

* Re: [PATCH 1/2] core: Replace calls to g_queue_free_full function
From: Giovanni Gherdovich @ 2013-01-03 19:36 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz, Vinicius Costa Gomes,
	Anderson Lizardo
  Cc: linux-bluetooth
In-Reply-To: <1357164488.19248.92.camel@aeonflux>

Hi Marcel, Luiz, Vinicius, Anderson,

2013/1/2 Marcel Holtmann <marcel@holtmann.org>:
> [...]
>
> I would have done this:
>
>         static void free_service_auth(gpointer data, gpointer user_data)
>         {
>                 struct service_auth *auth = data;
>
>                 g_free(auth);
>         }


> change pending_destroy() to this:
>
>         static void pending_destroy(gpointer data, gpointer user_data)
>         {
>                 ...
>         }
>
> And then fix the callers to add an extra NULL.

I am about to send the modified patch.

I also had to revert another GLib function, g_slist_free_full,
to g_slist_foreach + g_slist_free, since having changed the signature
of pending_destroy, i didn't suit any more the second argument of
g_slist_free_full.
I hope that's not a big deal.


2013/1/2 Luiz Augusto von Dentz <luiz.dentz@gmail.com>:
> [...]
>
> There is something off here, in the past we did have an implementation
> of g_slist_free_full to overcome this dependency problem but it was
> removed in this commit:
>
> commit 84156dadb25ec0973752d34d84fc9ffb3c720988
> Author: Marcel Holtmann <marcel@holtmann.org>
> Date:   Mon Apr 16 18:22:24 2012 +0200
>
>     build: Remove glib-compat.h support
>

yes, here a link to the gitweb
http://git.kernel.org/?p=bluetooth/bluez.git;a=commitdiff;h=84156dadb25ec0973752d34d84fc9ffb3c720988;hp=1a79248e6be548696715f3bb2ddcf01630cf2c69

2013/1/2 Luiz Augusto von Dentz <luiz.dentz@gmail.com>:
> Hi Vinicius,
>
> On Wed, Jan 2, 2013 at 10:23 PM, Vinicius Gomes
>> [...]
>> The problem now is g_queue_free_full() not the g_slist_free_full().
>
> Right, but it is quite the same situation  [...]

It is exactly the same situation.
In the commit where the GLib team added g_queue_free_full,
they mentioned that they wanted to align the API for GQueue
to what they had for GSList and GList.

2013/1/3 Luiz Augusto von Dentz <luiz.dentz@gmail.com>:
> [...]
>
> Anyway regardless if we do update or not, I don't see why
> g_queue_free_full is different than g_slist_free_full, so instead of
> converting everything to g_queue_foreach + g_queue_free why we don't
> bring back glib-compat and do this in one place as we did for
> g_slist_free_full?

If you bring back that code, you bring back the evil cast of

void (*) (void *)

to

void (*) (void *, void *)

which I am trying to avoid.

Regards,
Giovanni

^ permalink raw reply

* Re: [RFC 3/3] Bluetooth:  Provide mgmt API for reading list of supported codecs
From: Gustavo Padovan @ 2013-01-03 19:09 UTC (permalink / raw)
  To: Michael Knudsen; +Cc: linux-bluetooth, Michael Knudsen
In-Reply-To: <1353585909-28400-4-git-send-email-m.knudsen@samsung.com>

Hi Michael,

* Michael Knudsen <michaelknudsendk@gmail.com> [2012-11-22 13:05:08 +0100]:

> Provide an API for allowing user space to read the list of codecs
> supported by a given controller.  For now, hardwire PCM support,
> but construct initial list of supported codecs by inspecting the
> relevant bits of the local supported features bit mask.  Later,
> devices that support the appropriate HCI command will read out the
> actual list during controller initialisation.
> ---
>  include/net/bluetooth/hci_core.h |    2 ++
>  include/net/bluetooth/mgmt.h     |    7 +++++++
>  net/bluetooth/hci_core.c         |    3 +++
>  net/bluetooth/hci_event.c        |   21 +++++++++++++++++++++
>  net/bluetooth/mgmt.c             |   36 ++++++++++++++++++++++++++++++++++++
>  5 files changed, 69 insertions(+)
> 
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index ef5b85d..79fe128 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -153,6 +153,8 @@ struct hci_dev {
>  	__u8		features[8];
>  	__u8		host_features[8];
>  	__u8		commands[64];
> +	__u8		codecs;
> +	__u8		codec[255];
>  	__u8		hci_ver;
>  	__u16		hci_rev;
>  	__u8		lmp_ver;
> diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
> index 22980a7..523dc58 100644
> --- a/include/net/bluetooth/mgmt.h
> +++ b/include/net/bluetooth/mgmt.h
> @@ -350,6 +350,13 @@ struct mgmt_cp_set_device_id {
>  } __packed;
>  #define MGMT_SET_DEVICE_ID_SIZE		8
>  
> +#define MGMT_OP_READ_CODECS		0x0029
> +#define MGMT_READ_CODECS_SIZE		0
> +struct mgmt_rp_read_codecs {
> +	__u8	count;
> +	__u8	codec[0];
> +} __packed;
> +

We think it is better to read the list of codecs from the SCO socket, we need
to allow both oFono and PulseAudio to read them without the need of talking to
BlueZ. Also, bluetoothd has nothing intersting to do with this information.

	Gustavo

^ permalink raw reply

* [PATCH] attrib-server: Fix invalid device access
From: Paulo Borges @ 2013-01-03 18:57 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Paulo Borges

When the device is not found, the channel attach must fail.
---
 src/attrib-server.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/attrib-server.c b/src/attrib-server.c
index 15622e4..4a25743 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -1131,10 +1131,17 @@ guint attrib_channel_attach(GAttrib *attrib)
 	ba2str(&channel->dst, addr);
 
 	device = adapter_find_device(server->adapter, addr);
-	if (device == NULL || device_is_bonded(device) == FALSE) {
+	if (device == NULL) {
+		error("Device not found");
+		g_free(channel);
+
+		return 0;
+	}
+
+	if (device_is_bonded(device) == FALSE) {
 		char *filename;
 
-		filename = btd_device_get_storage_path(channel->device, "ccc");
+		filename = btd_device_get_storage_path(device, "ccc");
 		unlink(filename);
 		g_free(filename);
 	}
-- 
1.7.9.5


^ permalink raw reply related

* Re: [PATCH v2 BlueZ 1/6] input: Remove dead code from encrypt_completed()
From: Johan Hedberg @ 2013-01-03 16:12 UTC (permalink / raw)
  To: Anderson Lizardo; +Cc: linux-bluetooth
In-Reply-To: <1357222503-31554-1-git-send-email-anderson.lizardo@openbossa.org>

Hi Lizardo,

On Thu, Jan 03, 2013, Anderson Lizardo wrote:
> "status" is always zero, so this code will never be reached.
> ---
>  profiles/input/device.c |    7 -------
>  1 file changed, 7 deletions(-)

All patches in this set have been applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH 00/12] Add LE broadcaster and observer functionality
From: Aloisio Almeida @ 2013-01-03 15:02 UTC (permalink / raw)
  To: Jefferson Delfes; +Cc: linux-bluetooth
In-Reply-To: <1355511098-10190-1-git-send-email-jefferson.delfes@openbossa.org>

bump

On Fri, Dec 14, 2012 at 3:51 PM, Jefferson Delfes
<jefferson.delfes@openbossa.org> wrote:
> This patch series adds broadcaster and observer functionality.
>
> For the userspace, we are updating our branch and we will send it in s few
> days.
>
> Aloisio Almeida Jr (10):
>   Bluetooth: Set advertising parameters on LE setup
>   Bluetooth: Add set controller data MGMT command
>   Bluetooth: Add set broadcaster MGMT command
>   Bluetooth: Advertise controller data in broadcaster mode
>   Bluetooth: Stop to acquire hdev lock inside hci_update_ad
>   Bluetooth: Enable on-the-fly update of broadcast data
>   Bluetooth: Enable support for broadcaster mode when powered off.
>   Bluetooth: Refactor le scan helpers to enable observer support
>   Bluetooth: Add set observer MGMT command
>   Bluetooth: Enable support for observer mode when powered off.
>
> Jefferson Delfes (2):
>   Bluetooth: Add HCI command to set advertising parameters
>   Bluetooth: Add unset controller data MGMT command
>
>  include/net/bluetooth/hci.h      |  19 +++
>  include/net/bluetooth/hci_core.h |  42 ++++-
>  include/net/bluetooth/mgmt.h     |  21 +++
>  net/bluetooth/hci_core.c         | 183 ++++++++++++++++-----
>  net/bluetooth/hci_event.c        | 121 +++++++++-----
>  net/bluetooth/mgmt.c             | 335 +++++++++++++++++++++++++++++++++++++--
>  6 files changed, 628 insertions(+), 93 deletions(-)
>
> --
> 1.8.0.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH v2 BlueZ 6/6] input: Fix closing sockets when ioctl_connadd() fails
From: Anderson Lizardo @ 2013-01-03 14:15 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1357222503-31554-1-git-send-email-anderson.lizardo@openbossa.org>

Instead of calling close() directly, properly shutdown the channel and
set GIOChannel pointers to NULL.

Fixes this error detected when HIDP support is disabled on kernel and we
attempt to connect to a BT keyboard:

bluetoothd[5168]: profiles/input/device.c:encrypt_notify()
bluetoothd[5168]: ioctl_connadd(): Protocol not supported(93)
bluetoothd[5168]: profiles/input/device.c:ctrl_watch_cb() Device
CA:FE:CA:FE:CA:FE disconnected

(bluetoothd:5168): GLib-WARNING **: Invalid file descriptor.

bluetoothd[5168]: profiles/input/device.c:intr_watch_cb() Device
CA:FE:CA:FE:CA:FE disconnected

(bluetoothd:5168): GLib-WARNING **: Invalid file descriptor.
---
 profiles/input/device.c |   26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/profiles/input/device.c b/profiles/input/device.c
index 3d5ee20..9ab7509 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -136,8 +136,10 @@ static gboolean intr_watch_cb(GIOChannel *chan, GIOCondition cond, gpointer data
 
 	idev->intr_watch = 0;
 
-	g_io_channel_unref(idev->intr_io);
-	idev->intr_io = NULL;
+	if (idev->intr_io) {
+		g_io_channel_unref(idev->intr_io);
+		idev->intr_io = NULL;
+	}
 
 	/* Close control channel */
 	if (idev->ctrl_io && !(cond & G_IO_NVAL))
@@ -163,8 +165,10 @@ static gboolean ctrl_watch_cb(GIOChannel *chan, GIOCondition cond, gpointer data
 
 	idev->ctrl_watch = 0;
 
-	g_io_channel_unref(idev->ctrl_io);
-	idev->ctrl_io = NULL;
+	if (idev->ctrl_io) {
+		g_io_channel_unref(idev->ctrl_io);
+		idev->ctrl_io = NULL;
+	}
 
 	/* Close interrupt channel */
 	if (idev->intr_io && !(cond & G_IO_NVAL))
@@ -282,8 +286,18 @@ static gboolean encrypt_notify(GIOChannel *io, GIOCondition condition,
 	err = ioctl_connadd(idev->req);
 	if (err < 0) {
 		error("ioctl_connadd(): %s (%d)", strerror(-err), -err);
-		close(idev->req->intr_sock);
-		close(idev->req->ctrl_sock);
+
+		if (idev->ctrl_io) {
+			g_io_channel_shutdown(idev->ctrl_io, FALSE, NULL);
+			g_io_channel_unref(idev->ctrl_io);
+			idev->ctrl_io = NULL;
+		}
+
+		if (idev->intr_io) {
+			g_io_channel_shutdown(idev->intr_io, FALSE, NULL);
+			g_io_channel_unref(idev->intr_io);
+			idev->intr_io = NULL;
+		}
 	}
 
 	idev->sec_watch = 0;
-- 
1.7.9.5


^ permalink raw reply related


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