Linux bluetooth development
 help / color / mirror / Atom feed
* how to troubleshoot bluetooth audio issues?
From: Oleksij Rempel @ 2012-10-14 15:29 UTC (permalink / raw)
  To: pulseaudio-discuss, linux-bluetooth

Hallo all, (Pulseaudio and Bluetooth devs)

i have Samsung HS3000 bluetooth headset. Mostly it works but there are 
different issue with it:

- volume level seems to be set to max (at really uncomfortable level)
- at the moment i trying to change volume with pavucontrol or after it i 
get bad sound. Some times sort of cracky or trashy sound, some times 
just white noise.
- play/stop key do not works with linux (not pulse issue)

how to troubleshoot this issues? what tools should i use and where 
should it start?
-- 
Regards,
Oleksij

^ permalink raw reply

* Re: [PATCH] heartrate: Convert to DBus.Properties
From: Johan Hedberg @ 2012-10-13 19:31 UTC (permalink / raw)
  To: Andrzej Kaczmarek; +Cc: linux-bluetooth
In-Reply-To: <1350147379-10912-1-git-send-email-andrzej.kaczmarek@tieto.com>

H Andrzej,

On Sat, Oct 13, 2012, Andrzej Kaczmarek wrote:
> ---
>  doc/heartrate-api.txt          |  7 +---
>  profiles/heartrate/heartrate.c | 73 ++++++++++++++++++++++++------------------
>  test/test-heartrate            |  5 ++-
>  3 files changed, 46 insertions(+), 39 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply

* [PATCH] heartrate: Convert to DBus.Properties
From: Andrzej Kaczmarek @ 2012-10-13 16:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek

---
 doc/heartrate-api.txt          |  7 +---
 profiles/heartrate/heartrate.c | 73 ++++++++++++++++++++++++------------------
 test/test-heartrate            |  5 ++-
 3 files changed, 46 insertions(+), 39 deletions(-)

diff --git a/doc/heartrate-api.txt b/doc/heartrate-api.txt
index 39a0cbd..d1d5191 100644
--- a/doc/heartrate-api.txt
+++ b/doc/heartrate-api.txt
@@ -28,12 +28,7 @@ Service		org.bluez
 Interface	org.bluez.HeartRate
 Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
 
-Methods		dict GetProperties()
-
-			Returns all properties for the interface. See the
-			Properties section for the available properties.
-
-		Reset()
+Methods		Reset()
 
 			Restart the accumulation of energy expended from zero.
 
diff --git a/profiles/heartrate/heartrate.c b/profiles/heartrate/heartrate.c
index 28c1932..9a92960 100644
--- a/profiles/heartrate/heartrate.c
+++ b/profiles/heartrate/heartrate.c
@@ -641,43 +641,47 @@ static const GDBusMethodTable heartrate_manager_methods[] = {
 	{ }
 };
 
-static DBusMessage *get_properties(DBusConnection *conn, DBusMessage *msg,
-								void *data)
+static gboolean property_get_location(const GDBusPropertyTable *property,
+					DBusMessageIter *iter, void *data)
 {
 	struct heartrate *hr = data;
-	DBusMessageIter iter;
-	DBusMessageIter dict;
-	DBusMessage *reply;
-	gboolean has_reset;
+	char *loc;
 
-	reply = dbus_message_new_method_return(msg);
-	if (reply == NULL)
-		return NULL;
+	if (!hr->has_location)
+		return FALSE;
 
-	dbus_message_iter_init_append(reply, &iter);
+	loc = g_strdup(location2str(hr->location));
 
-	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);
+	if (loc == NULL)
+		return FALSE;
 
-	if (hr->has_location) {
-		char *loc = g_strdup(location2str(hr->location));
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &loc);
 
-		if (loc) {
-			dict_append_entry(&dict, "Location",
-						DBUS_TYPE_STRING, &loc);
-			g_free(loc);
-		}
-	}
+	g_free(loc);
 
-	has_reset = !!hr->hrcp_val_handle;
-	dict_append_entry(&dict, "ResetSupported", DBUS_TYPE_BOOLEAN,
-								&has_reset);
+	return TRUE;
+}
 
-	dbus_message_iter_close_container(&iter, &dict);
+static gboolean property_exists_location(const GDBusPropertyTable *property,
+								void *data)
+{
+	struct heartrate *hr = data;
+
+	if (!hr->has_location || location2str(hr->location) == NULL)
+		return FALSE;
+
+	return TRUE;
+}
+
+static gboolean property_get_reset_supported(const GDBusPropertyTable *property,
+					DBusMessageIter *iter, void *data)
+{
+	struct heartrate *hr = data;
+	dbus_bool_t has_reset = !!hr->hrcp_val_handle;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &has_reset);
 
-	return reply;
+	return TRUE;
 }
 
 static DBusMessage *hrcp_reset(DBusConnection *conn, DBusMessage *msg,
@@ -704,13 +708,17 @@ static DBusMessage *hrcp_reset(DBusConnection *conn, DBusMessage *msg,
 }
 
 static const GDBusMethodTable heartrate_device_methods[] = {
-	{ GDBUS_METHOD("GetProperties",
-			NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
-			get_properties) },
 	{ GDBUS_METHOD("Reset", NULL, NULL, hrcp_reset) },
 	{ }
 };
 
+static const GDBusPropertyTable heartrate_device_properties[] = {
+	{ "Location", "s", property_get_location, NULL,
+						property_exists_location },
+	{ "ResetSupported", "b", property_get_reset_supported },
+	{ }
+};
+
 int heartrate_adapter_register(struct btd_adapter *adapter)
 {
 	struct heartrate_adapter *hradapter;
@@ -772,8 +780,9 @@ int heartrate_device_register(struct btd_device *device,
 						device_get_path(device),
 						HEART_RATE_INTERFACE,
 						heartrate_device_methods,
-						NULL, NULL, hr,
-						destroy_heartrate)) {
+						NULL,
+						heartrate_device_properties,
+						hr, destroy_heartrate)) {
 		error("D-Bus failed to register %s interface",
 						HEART_RATE_INTERFACE);
 		destroy_heartrate(hr);
diff --git a/test/test-heartrate b/test/test-heartrate
index 316375d..a7d05b4 100755
--- a/test/test-heartrate
+++ b/test/test-heartrate
@@ -80,7 +80,10 @@ if __name__ == "__main__":
 
 	watcher = Watcher(bus, path)
 
-	properties = heartrate.GetProperties()
+	dev_prop = dbus.Interface(bus.get_object("org.bluez", device_path),
+					"org.freedesktop.DBus.Properties")
+
+	properties = dev_prop.GetAll("org.bluez.HeartRate")
 
 	if "Location" in properties:
 		print("Sensor location: %s" % properties["Location"])
-- 
1.7.11.3


^ permalink raw reply related

* Re: [PATCH 1/2] heartrate: Fix registration of notification handler
From: Johan Hedberg @ 2012-10-13 16:49 UTC (permalink / raw)
  To: Andrzej Kaczmarek; +Cc: linux-bluetooth
In-Reply-To: <1350141502-4385-1-git-send-email-andrzej.kaczmarek@tieto.com>

Hi Andrzej,

On Sat, Oct 13, 2012, Andrzej Kaczmarek wrote:
> Notification handler is registered only when CCC is written during
> descriptors discovery, i.e. at least one watcher is registered before
> device is connected. This means there will be no handler registered in
> case watcher is registered after device already connected.
> This is side-effect of 74a9fc7.
> 
> This patch registers handler immediately when measurement characteristic
> is discovered so it does not matter when watcher is registered.
> 
> ccc_write_cb() is reduntant in this case so it's removed.
> ---
>  profiles/heartrate/heartrate.c | 24 ++++++++----------------
>  1 file changed, 8 insertions(+), 16 deletions(-)

Both patches have been applied. Thanks.

Johan

^ permalink raw reply

* [PATCH 2/2] heartrate: Remove unused measurement characteristic value handle
From: Andrzej Kaczmarek @ 2012-10-13 15:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1350141502-4385-1-git-send-email-andrzej.kaczmarek@tieto.com>

Since notification handler is now registered only for measurement
characteristic value handle it's no longer needed to keep this handle.
---
 profiles/heartrate/heartrate.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/profiles/heartrate/heartrate.c b/profiles/heartrate/heartrate.c
index 81ff310..28c1932 100644
--- a/profiles/heartrate/heartrate.c
+++ b/profiles/heartrate/heartrate.c
@@ -66,7 +66,6 @@ struct heartrate {
 
 	struct att_range		*svc_range;	/* primary svc range */
 
-	uint16_t			measurement_val_handle;
 	uint16_t			measurement_ccc_handle;
 	uint16_t			hrcp_val_handle;
 
@@ -478,8 +477,6 @@ static void discover_char_cb(GSList *chars, guint8 status, gpointer user_data)
 			struct gatt_char *c_next =
 				(chars->next ? chars->next->data : NULL);
 
-			hr->measurement_val_handle = c->value_handle;
-
 			hr->attionotid = g_attrib_register(hr->attrib,
 						ATT_OP_HANDLE_NOTIFY,
 						c->value_handle,
-- 
1.7.11.3


^ permalink raw reply related

* [PATCH 1/2] heartrate: Fix registration of notification handler
From: Andrzej Kaczmarek @ 2012-10-13 15:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek

Notification handler is registered only when CCC is written during
descriptors discovery, i.e. at least one watcher is registered before
device is connected. This means there will be no handler registered in
case watcher is registered after device already connected.
This is side-effect of 74a9fc7.

This patch registers handler immediately when measurement characteristic
is discovered so it does not matter when watcher is registered.

ccc_write_cb() is reduntant in this case so it's removed.
---
 profiles/heartrate/heartrate.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/profiles/heartrate/heartrate.c b/profiles/heartrate/heartrate.c
index 871b74e..81ff310 100644
--- a/profiles/heartrate/heartrate.c
+++ b/profiles/heartrate/heartrate.c
@@ -389,21 +389,6 @@ static void notify_handler(const uint8_t *pdu, uint16_t len, gpointer user_data)
 	process_measurement(hr, pdu + 3, len - 3);
 }
 
-static void ccc_write_cb(guint8 status, const guint8 *pdu, guint16 len,
-							gpointer user_data)
-{
-	struct heartrate *hr = user_data;
-
-	if (status != 0) {
-		error("Enable measurement failed");
-		return;
-	}
-
-	hr->attionotid = g_attrib_register(hr->attrib, ATT_OP_HANDLE_NOTIFY,
-						hr->measurement_val_handle,
-						notify_handler, hr, NULL);
-}
-
 static void discover_ccc_cb(guint8 status, const guint8 *pdu,
 						guint16 len, gpointer user_data)
 {
@@ -434,6 +419,7 @@ static void discover_ccc_cb(guint8 status, const guint8 *pdu,
 		uuid = att_get_u16(value + 2);
 
 		if (uuid == GATT_CLIENT_CHARAC_CFG_UUID) {
+			char *msg;
 			uint8_t value[2];
 
 			hr->measurement_ccc_handle = handle;
@@ -442,9 +428,10 @@ static void discover_ccc_cb(guint8 status, const guint8 *pdu,
 				break;
 
 			att_put_u16(GATT_CLIENT_CHARAC_CFG_NOTIF_BIT, value);
+			msg = g_strdup("Enable measurement");
 
 			gatt_write_char(hr->attrib, handle, value,
-					sizeof(value), ccc_write_cb, hr);
+					sizeof(value), char_write_cb, msg);
 
 			break;
 		}
@@ -493,6 +480,11 @@ static void discover_char_cb(GSList *chars, guint8 status, gpointer user_data)
 
 			hr->measurement_val_handle = c->value_handle;
 
+			hr->attionotid = g_attrib_register(hr->attrib,
+						ATT_OP_HANDLE_NOTIFY,
+						c->value_handle,
+						notify_handler, hr, NULL);
+
 			discover_measurement_ccc(hr, c, c_next);
 		} else if (g_strcmp0(c->uuid, BODY_SENSOR_LOCATION_UUID) == 0) {
 			DBG("Body Sensor Location supported");
-- 
1.7.11.3


^ permalink raw reply related

* Re: [PATCH BlueZ] input: Convert to DBus.Properties
From: Johan Hedberg @ 2012-10-13  9:20 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: linux-bluetooth
In-Reply-To: <1349981868-1263-1-git-send-email-lucas.demarchi@profusion.mobi>

Hi Lucas,

On Thu, Oct 11, 2012, Lucas De Marchi wrote:
> ---
>  profiles/input/device.c | 44 +++++++++++++-------------------------------
>  1 file changed, 13 insertions(+), 31 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply

* Re: [RFCv1 7/7] Bluetooth: Zero bredr pointer when chan is deleted
From: Marcel Holtmann @ 2012-10-12 23:54 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1350051005-6015-7-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
>  net/bluetooth/l2cap_core.c |    4 ++++
>  1 file changed, 4 insertions(+)

same here. Please write a commit message.

Regards

Marcel



^ permalink raw reply

* Re: [RFCv1 6/7] Bluetooth: AMP: Zero amp_mgr pointer if removed
From: Marcel Holtmann @ 2012-10-12 23:54 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1350051005-6015-6-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

> 
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
>  net/bluetooth/hci_conn.c |    6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

I want a commit messages that is more than just a subject.

Regards

Marcel



^ permalink raw reply

* Re: [RFCv1 5/7] Bluetooth: AMP: Get amp_mgr reference in HS hci_conn
From: Marcel Holtmann @ 2012-10-12 23:53 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1350051005-6015-5-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

> When assigning amp_mgr in hci_conn (type AMP_LINK) get also reference.
> In hci_conn_del those references would be put for both types.
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
>  net/bluetooth/amp.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Acked-by: Marcel Holtmann <marcel@holtmann.org>

> diff --git a/net/bluetooth/amp.c b/net/bluetooth/amp.c
> index 59da0f1..e525e23 100644
> --- a/net/bluetooth/amp.c
> +++ b/net/bluetooth/amp.c
> @@ -123,9 +123,11 @@ struct hci_conn *phylink_add(struct hci_dev *hdev, struct amp_mgr *mgr,
>  	hcon->attempt++;
>  	hcon->handle = __next_handle(mgr);
>  	hcon->remote_id = remote_id;
> -	hcon->amp_mgr = mgr;
>  	hcon->out = out;
>  
> +	hcon->amp_mgr = mgr;
> +	amp_mgr_get(mgr);
> +

We could discuss that amp_mgt_get(mgr) should just return mgr and you
can write this like this:

	hcon->amp_mgr = amp_mgr_get(mgr);

Regards

Marcel



^ permalink raw reply

* Re: [RFCv1 4/7] Bluetooth: Send EFS Conf Rsp only for BR/EDR chan
From: Marcel Holtmann @ 2012-10-12 23:51 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1350051005-6015-4-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

> Do not send EFS Configuration Response for High Speed channel yet.
> It will be sent after receiving Logical Link Complete event.
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
>  net/bluetooth/l2cap_core.c |   12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel



^ permalink raw reply

* Re: [RFCv1 3/7] Bluetooth: AMP: Drop packets when no l2cap conn exist
From: Marcel Holtmann @ 2012-10-12 23:50 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1350051005-6015-3-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

> HS hci conn should always have l2cap_conn associated with it.
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
>  net/bluetooth/l2cap_core.c |    4 ++++
>  1 file changed, 4 insertions(+)

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel



^ permalink raw reply

* Re: [RFCv1 2/7] Bluetooth: AMP: Handle complete frames in l2cap
From: Marcel Holtmann @ 2012-10-12 23:50 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1350051005-6015-2-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

> Check flags type in switch statement and handle new frame
> type ACL_COMPLETE used for High Speed data over AMP.
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
>  include/net/bluetooth/hci.h |    1 +
>  net/bluetooth/l2cap_core.c  |   15 ++++++++++-----
>  2 files changed, 11 insertions(+), 5 deletions(-)

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel



^ permalink raw reply

* Re: [RFCv1 1/7] Bluetooth: AMP: Use Loglink handle in ACL Handle field
From: Marcel Holtmann @ 2012-10-12 23:49 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1350051005-6015-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

> For AMP HCI controller use Logical Link handle in HCI ACL
> Handle field.
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
>  net/bluetooth/hci_core.c |   15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)

Acked-by: Marcel Holtmann <marcel@holtmann.org>

> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 2e72c41..32c4dbe 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -2162,7 +2162,20 @@ static void hci_queue_acl(struct hci_chan *chan, struct sk_buff_head *queue,
>  	skb->data_len = 0;
>  
>  	bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
> -	hci_add_acl_hdr(skb, conn->handle, flags);
> +
> +	switch (hdev->dev_type) {
> +	case HCI_BREDR:
> +		hci_add_acl_hdr(skb, conn->handle, flags);
> +		break;
> +

However, remove the empty lines here. It is fine to condense this
statement since they are single statements.

> +	case HCI_AMP:
> +		hci_add_acl_hdr(skb, chan->handle, flags);
> +		break;
> +
> +	default:
> +		BT_ERR("%s unknown dev_type %d", hdev->name, hdev->dev_type);
> +		return;
> +	}
>  
>  	list = skb_shinfo(skb)->frag_list;
>  	if (!list) {

regards

Marcel



^ permalink raw reply

* Re: [PATCH] Bluetooth: Rename __l2cap_connect() to l2cap_connect()
From: Marcel Holtmann @ 2012-10-12 23:48 UTC (permalink / raw)
  To: Gustavo Padovan; +Cc: linux-bluetooth, Gustavo Padovan
In-Reply-To: <1350042040-1908-1-git-send-email-gustavo@padovan.org>

Hi Gustavo,

> Use of "__" usually means we need to call the function with a lock held,
> which is not the case here.
> 
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> ---
>  net/bluetooth/l2cap_core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Acked-by: Marcel Holtmann <marcel@holtmann.org>

> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index 1d773b9..9060eec 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -3389,7 +3389,7 @@ static inline int l2cap_command_rej(struct l2cap_conn *conn,
>  	return 0;
>  }
>  
> -static void __l2cap_connect(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd,
> +static void l2cap_connect(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd,
>  			    u8 *data, u8 rsp_code, u8 amp_id)

Don't you need to fix the coding style for the indentation of the second
line.

Regards

Marcel



^ permalink raw reply

* Re: [PATCH -v3 2/2] Bluetooth: Add chan->ops->defer()
From: Marcel Holtmann @ 2012-10-12 23:46 UTC (permalink / raw)
  To: Gustavo Padovan; +Cc: linux-bluetooth, Gustavo Padovan
In-Reply-To: <1350041724-29948-2-git-send-email-gustavo@padovan.org>

Hi Gustavo,

> When DEFER_SETUP is set defer() will trigger an authorization
> request to the userspace.
> 
> l2cap_chan_no_defer() is meant to be used when one does not want to
> support DEFER_SETUP (A2MP for example).
> 
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> ---
>  include/net/bluetooth/l2cap.h |  5 +++++
>  net/bluetooth/a2mp.c          |  1 +
>  net/bluetooth/l2cap_core.c    | 10 +++-------
>  net/bluetooth/l2cap_sock.c    | 10 ++++++++++
>  4 files changed, 19 insertions(+), 7 deletions(-)

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel



^ permalink raw reply

* Re: [PATCH -v3 1/2] Bluetooth: Move bt_accept_enqueue() to l2cap_sock.c
From: Marcel Holtmann @ 2012-10-12 23:46 UTC (permalink / raw)
  To: Gustavo Padovan; +Cc: linux-bluetooth, Gustavo Padovan
In-Reply-To: <1350041724-29948-1-git-send-email-gustavo@padovan.org>

Hi Gustavo,

> This is part of the move the parent socket usage to l2cap_sock.c
> 
> The change is safe when it cames to locking, bt_accept_enqueue() is still

it is "comes".

> protected by the parent socket lock inside the
> l2cap_sock_new_connection_cb() code.
> 
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> ---
>  net/bluetooth/l2cap_core.c | 4 ----
>  net/bluetooth/l2cap_sock.c | 2 ++
>  2 files changed, 2 insertions(+), 4 deletions(-)

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel



^ permalink raw reply

* Re: [PATCH -v4 1/2] rctest: add automated test
From: Johan Hedberg @ 2012-10-12 14:58 UTC (permalink / raw)
  To: Gustavo Padovan; +Cc: linux-bluetooth, Gustavo Padovan
In-Reply-To: <1349668203-10782-1-git-send-email-gustavo@padovan.org>

Hi Gustavo,

On Mon, Oct 08, 2012, Gustavo Padovan wrote:
> adds -a option to enable automated tests. We use the -i option to define
> the receiving side and the -a define the sending side:
> 
> ./rctest -i hci0 -a hci1
> ---
>  test/rctest.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 42 insertions(+), 4 deletions(-)

Both patches have been applied. Thanks.

Johan

^ permalink raw reply

* [RFCv1 7/7] Bluetooth: Zero bredr pointer when chan is deleted
From: Andrei Emeltchenko @ 2012-10-12 14:10 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1350051005-6015-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>


Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 net/bluetooth/l2cap_core.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 1e717fd..eb286ca 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -531,6 +531,7 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err)
 	BT_DBG("chan %p, conn %p, err %d", chan, conn, err);
 
 	if (conn) {
+		struct amp_mgr *mgr = conn->hcon->amp_mgr;
 		/* Delete from channel list */
 		list_del(&chan->list);
 
@@ -540,6 +541,9 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err)
 
 		if (chan->chan_type != L2CAP_CHAN_CONN_FIX_A2MP)
 			hci_conn_put(conn->hcon);
+
+		if (mgr && mgr->bredr_chan == chan)
+			mgr->bredr_chan = NULL;
 	}
 
 	if (chan->ops->teardown)
-- 
1.7.9.5


^ permalink raw reply related

* [RFCv1 6/7] Bluetooth: AMP: Zero amp_mgr pointer if removed
From: Andrei Emeltchenko @ 2012-10-12 14:10 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1350051005-6015-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>


Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 net/bluetooth/hci_conn.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index fe64621..eed9c8e 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -439,8 +439,10 @@ int hci_conn_del(struct hci_conn *conn)
 
 	hci_chan_list_flush(conn);
 
-	if (conn->amp_mgr)
-		amp_mgr_put(conn->amp_mgr);
+	if (conn->amp_mgr) {
+		if (amp_mgr_put(conn->amp_mgr))
+			conn->amp_mgr = NULL;
+	}
 
 	hci_conn_hash_del(hdev, conn);
 	if (hdev->notify)
-- 
1.7.9.5


^ permalink raw reply related

* [RFCv1 5/7] Bluetooth: AMP: Get amp_mgr reference in HS hci_conn
From: Andrei Emeltchenko @ 2012-10-12 14:10 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1350051005-6015-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

When assigning amp_mgr in hci_conn (type AMP_LINK) get also reference.
In hci_conn_del those references would be put for both types.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 net/bluetooth/amp.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/amp.c b/net/bluetooth/amp.c
index 59da0f1..e525e23 100644
--- a/net/bluetooth/amp.c
+++ b/net/bluetooth/amp.c
@@ -123,9 +123,11 @@ struct hci_conn *phylink_add(struct hci_dev *hdev, struct amp_mgr *mgr,
 	hcon->attempt++;
 	hcon->handle = __next_handle(mgr);
 	hcon->remote_id = remote_id;
-	hcon->amp_mgr = mgr;
 	hcon->out = out;
 
+	hcon->amp_mgr = mgr;
+	amp_mgr_get(mgr);
+
 	return hcon;
 }
 
-- 
1.7.9.5


^ permalink raw reply related

* [RFCv1 4/7] Bluetooth: Send EFS Conf Rsp only for BR/EDR chan
From: Andrei Emeltchenko @ 2012-10-12 14:10 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1350051005-6015-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Do not send EFS Configuration Response for High Speed channel yet.
It will be sent after receiving Logical Link Complete event.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 net/bluetooth/l2cap_core.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 38b058d..1e717fd 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3718,7 +3718,11 @@ static inline int l2cap_config_req(struct l2cap_conn *conn,
 
 		/* check compatibility */
 
-		l2cap_send_efs_conf_rsp(chan, rsp, cmd->ident, flags);
+		/* Send rsp for BR/EDR channel */
+		if (!chan->ctrl_id)
+			l2cap_send_efs_conf_rsp(chan, rsp, cmd->ident, flags);
+		else
+			chan->ident = cmd->ident;
 	}
 
 unlock:
@@ -3767,7 +3771,11 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn,
 
 			/* check compatibility */
 
-			l2cap_send_efs_conf_rsp(chan, buf, cmd->ident, 0);
+			if (!chan->ctrl_id)
+				l2cap_send_efs_conf_rsp(chan, buf, cmd->ident,
+							0);
+			else
+				chan->ident = cmd->ident;
 		}
 		goto done;
 
-- 
1.7.9.5


^ permalink raw reply related

* [RFCv1 3/7] Bluetooth: AMP: Drop packets when no l2cap conn exist
From: Andrei Emeltchenko @ 2012-10-12 14:10 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1350051005-6015-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

HS hci conn should always have l2cap_conn associated with it.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 net/bluetooth/l2cap_core.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 38f311e..38b058d 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -5582,6 +5582,10 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
 	struct l2cap_hdr *hdr;
 	int len;
 
+	/* For AMP controller do not create l2cap conn */
+	if (!conn && hcon->hdev->dev_type != HCI_BREDR)
+		goto drop;
+
 	if (!conn)
 		conn = l2cap_conn_add(hcon, 0);
 
-- 
1.7.9.5


^ permalink raw reply related

* [RFCv1 2/7] Bluetooth: AMP: Handle complete frames in l2cap
From: Andrei Emeltchenko @ 2012-10-12 14:10 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1350051005-6015-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Check flags type in switch statement and handle new frame
type ACL_COMPLETE used for High Speed data over AMP.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 include/net/bluetooth/hci.h |    1 +
 net/bluetooth/l2cap_core.c  |   15 ++++++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 77b6a19..88cbbda 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -198,6 +198,7 @@ enum {
 #define ACL_START_NO_FLUSH	0x00
 #define ACL_CONT		0x01
 #define ACL_START		0x02
+#define ACL_COMPLETE		0x03
 #define ACL_ACTIVE_BCAST	0x04
 #define ACL_PICO_BCAST		0x08
 
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 207b4a8..38f311e 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -5579,6 +5579,8 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
 int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
 {
 	struct l2cap_conn *conn = hcon->l2cap_data;
+	struct l2cap_hdr *hdr;
+	int len;
 
 	if (!conn)
 		conn = l2cap_conn_add(hcon, 0);
@@ -5588,10 +5590,10 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
 
 	BT_DBG("conn %p len %d flags 0x%x", conn, skb->len, flags);
 
-	if (!(flags & ACL_CONT)) {
-		struct l2cap_hdr *hdr;
-		int len;
-
+	switch (flags) {
+	case ACL_START:
+	case ACL_START_NO_FLUSH:
+	case ACL_COMPLETE:
 		if (conn->rx_len) {
 			BT_ERR("Unexpected start frame (len %d)", skb->len);
 			kfree_skb(conn->rx_skb);
@@ -5633,7 +5635,9 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
 		skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, skb->len),
 					  skb->len);
 		conn->rx_len = len - skb->len;
-	} else {
+		break;
+
+	case ACL_CONT:
 		BT_DBG("Cont: frag len %d (expecting %d)", skb->len, conn->rx_len);
 
 		if (!conn->rx_len) {
@@ -5661,6 +5665,7 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
 			l2cap_recv_frame(conn, conn->rx_skb);
 			conn->rx_skb = NULL;
 		}
+		break;
 	}
 
 drop:
-- 
1.7.9.5


^ permalink raw reply related

* [RFCv1 1/7] Bluetooth: AMP: Use Loglink handle in ACL Handle field
From: Andrei Emeltchenko @ 2012-10-12 14:09 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

For AMP HCI controller use Logical Link handle in HCI ACL
Handle field.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 net/bluetooth/hci_core.c |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 2e72c41..32c4dbe 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2162,7 +2162,20 @@ static void hci_queue_acl(struct hci_chan *chan, struct sk_buff_head *queue,
 	skb->data_len = 0;
 
 	bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
-	hci_add_acl_hdr(skb, conn->handle, flags);
+
+	switch (hdev->dev_type) {
+	case HCI_BREDR:
+		hci_add_acl_hdr(skb, conn->handle, flags);
+		break;
+
+	case HCI_AMP:
+		hci_add_acl_hdr(skb, chan->handle, flags);
+		break;
+
+	default:
+		BT_ERR("%s unknown dev_type %d", hdev->name, hdev->dev_type);
+		return;
+	}
 
 	list = skb_shinfo(skb)->frag_list;
 	if (!list) {
-- 
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