Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ v2 03/18] gatt: Register Manager D-Bus Interface
From: Claudio Takahasi @ 2014-01-21 13:26 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: claudio.takahasi, Alvaro Silva
In-Reply-To: <1390310814-19880-1-git-send-email-claudio.takahasi@openbossa.org>

From: Alvaro Silva <alvaro.silva@openbossa.org>

This patch registers the Service Manager D-Bus Interface. This
interface implements the methods to allow external application register
and unregister GATT Services.
---
 Makefile.am     |  1 +
 src/gatt-dbus.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/gatt-dbus.h | 25 +++++++++++++++++++
 src/gatt.c      |  9 +++++++
 4 files changed, 110 insertions(+)
 create mode 100644 src/gatt-dbus.c
 create mode 100644 src/gatt-dbus.h

diff --git a/Makefile.am b/Makefile.am
index 45c9f16..ed9083e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -146,6 +146,7 @@ src_bluetoothd_SOURCES = $(builtin_sources) \
 			src/adapter.h src/adapter.c \
 			src/profile.h src/profile.c \
 			src/service.h src/service.c \
+			src/gatt-dbus.h src/gatt-dbus.c \
 			src/gatt.h src/gatt.c \
 			src/device.h src/device.c src/attio.h \
 			src/dbus-common.c src/dbus-common.h \
diff --git a/src/gatt-dbus.c b/src/gatt-dbus.c
new file mode 100644
index 0000000..95c47de
--- /dev/null
+++ b/src/gatt-dbus.c
@@ -0,0 +1,75 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2014  Instituto Nokia de Tecnologia - INdT
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdint.h>
+
+#include <glib.h>
+#include <dbus/dbus.h>
+#include <gdbus/gdbus.h>
+
+#include "dbus-common.h"
+#include "log.h"
+
+#include "gatt-dbus.h"
+
+#define SERVICE_MGR_IFACE		"org.bluez.GattServiceManager1"
+
+static DBusMessage *register_service(DBusConnection *conn,
+					DBusMessage *msg, void *user_data)
+{
+	return dbus_message_new_method_return(msg);
+}
+
+static DBusMessage *unregister_service(DBusConnection *conn,
+					DBusMessage *msg, void *user_data)
+{
+	return dbus_message_new_method_return(msg);
+}
+
+static const GDBusMethodTable methods[] = {
+	{ GDBUS_EXPERIMENTAL_METHOD("RegisterService",
+				GDBUS_ARGS({ "service", "o"},
+						{ "options", "a{sv}"}),
+				NULL, register_service) },
+	{ GDBUS_EXPERIMENTAL_METHOD("UnregisterService",
+				GDBUS_ARGS({"service", "o"}),
+				NULL, unregister_service) },
+	{ }
+};
+
+gboolean gatt_dbus_manager_register(void)
+{
+	return g_dbus_register_interface(btd_get_dbus_connection(),
+					"/org/bluez", SERVICE_MGR_IFACE,
+					methods, NULL, NULL, NULL, NULL);
+}
+
+void gatt_dbus_manager_unregister(void)
+{
+	g_dbus_unregister_interface(btd_get_dbus_connection(), "/org/bluez",
+							SERVICE_MGR_IFACE);
+}
diff --git a/src/gatt-dbus.h b/src/gatt-dbus.h
new file mode 100644
index 0000000..310cfa9
--- /dev/null
+++ b/src/gatt-dbus.h
@@ -0,0 +1,25 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2014  Instituto Nokia de Tecnologia - INdT
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+gboolean gatt_dbus_manager_register(void);
+void gatt_dbus_manager_unregister(void);
diff --git a/src/gatt.c b/src/gatt.c
index 06619f0..e8b691a 100644
--- a/src/gatt.c
+++ b/src/gatt.c
@@ -25,14 +25,23 @@
 #include <config.h>
 #endif
 
+#include <glib.h>
+
+#include "log.h"
+
+#include "gatt-dbus.h"
 #include "gatt.h"
 
 void gatt_init(void)
 {
+	DBG("Starting GATT server");
 
+	gatt_dbus_manager_register();
 }
 
 void gatt_cleanup(void)
 {
+	DBG("Stopping GATT server");
 
+	gatt_dbus_manager_unregister();
 }
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH BlueZ v2 02/18] gatt: Add stub for gatt.{c, h} files
From: Claudio Takahasi @ 2014-01-21 13:26 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: claudio.takahasi, Alvaro Silva
In-Reply-To: <1390310814-19880-1-git-send-email-claudio.takahasi@openbossa.org>

From: Alvaro Silva <alvaro.silva@openbossa.org>

These files implement functions to manipulate ATT transactions, and expose
functions to allow other entities to manage GATT based services.
---
 Makefile.am |  1 +
 src/gatt.c  | 38 ++++++++++++++++++++++++++++++++++++++
 src/gatt.h  | 26 ++++++++++++++++++++++++++
 src/main.c  |  4 ++++
 4 files changed, 69 insertions(+)
 create mode 100644 src/gatt.c
 create mode 100644 src/gatt.h

diff --git a/Makefile.am b/Makefile.am
index f68e1ec..45c9f16 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -146,6 +146,7 @@ src_bluetoothd_SOURCES = $(builtin_sources) \
 			src/adapter.h src/adapter.c \
 			src/profile.h src/profile.c \
 			src/service.h src/service.c \
+			src/gatt.h src/gatt.c \
 			src/device.h src/device.c src/attio.h \
 			src/dbus-common.c src/dbus-common.h \
 			src/eir.h src/eir.c \
diff --git a/src/gatt.c b/src/gatt.c
new file mode 100644
index 0000000..06619f0
--- /dev/null
+++ b/src/gatt.c
@@ -0,0 +1,38 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2014  Instituto Nokia de Tecnologia - INdT
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "gatt.h"
+
+void gatt_init(void)
+{
+
+}
+
+void gatt_cleanup(void)
+{
+
+}
diff --git a/src/gatt.h b/src/gatt.h
new file mode 100644
index 0000000..3a320b4
--- /dev/null
+++ b/src/gatt.h
@@ -0,0 +1,26 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2014  Instituto Nokia de Tecnologia - INdT
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+void gatt_init(void);
+
+void gatt_cleanup(void);
diff --git a/src/main.c b/src/main.c
index 91d90b4..fccc838 100644
--- a/src/main.c
+++ b/src/main.c
@@ -55,6 +55,7 @@
 #include "dbus-common.h"
 #include "agent.h"
 #include "profile.h"
+#include "gatt.h"
 #include "systemd.h"
 
 #define BLUEZ_NAME "org.bluez"
@@ -545,6 +546,8 @@ int main(int argc, char *argv[])
 
 	g_dbus_set_flags(gdbus_flags);
 
+	gatt_init();
+
 	if (option_compat == TRUE)
 		sdp_flags |= SDP_SERVER_COMPAT;
 
@@ -595,6 +598,7 @@ int main(int argc, char *argv[])
 	btd_profile_cleanup();
 	btd_agent_cleanup();
 	btd_device_cleanup();
+	gatt_cleanup();
 
 	adapter_cleanup();
 
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH BlueZ v2 01/18] doc: Add GATT API
From: Claudio Takahasi @ 2014-01-21 13:26 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: claudio.takahasi
In-Reply-To: <1390310814-19880-1-git-send-email-claudio.takahasi@openbossa.org>

This patch proposes an unified GATT API for local and remote services.
---
 doc/gatt-api.txt | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 145 insertions(+)
 create mode 100644 doc/gatt-api.txt

diff --git a/doc/gatt-api.txt b/doc/gatt-api.txt
new file mode 100644
index 0000000..df60fb8
--- /dev/null
+++ b/doc/gatt-api.txt
@@ -0,0 +1,145 @@
+BlueZ D-Bus GATT API description
+********************************
+
+GATT local and remote services share the same high-level D-Bus API. Local
+refers to GATT based service exported by a BlueZ plugin or an external
+application. Remote refers to GATT services exported by the peer.
+
+BlueZ acts as a proxy, translating ATT operations to D-Bus method calls and
+Properties (or the opposite). Support for D-Bus Object Manager is mandatory for
+external services to allow seamless GATT declarations (Service, Characteristic
+and Descriptors) discovery.
+
+Service hierarchy
+=================
+
+GATT remote and local service representation. Object path for local services
+is freely definable.
+
+External applications implementing local services must register the services
+using GattServiceManager1 registration method and must implement the methods
+and properties defined in GattService1 interface.
+
+Service		org.bluez
+Interface	org.bluez.GattService1 [Experimental]
+Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/serviceXX
+
+Methods		void Release()
+
+			Release this service. At this point, it will not be
+			used by BlueZ anymore and can be destroyed by the
+			owner. Method applicable to external GATT services
+			implementations only (GATT servers).
+
+Properties	string UUID [read-only]
+
+			128-bit service UUID.
+
+		array{object} Includes [read-only]: Not implemented
+
+			Array of object paths representing the included
+			services of this service.
+
+
+Characteristic hierarchy
+========================
+
+For local GATT defined services, the object paths need to follow the service
+path hierarchy and are freely definable.
+
+Service		org.bluez
+Interface	org.bluez.Characteristic1 [Experimental]
+Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/serviceXX/charYYYY
+
+Properties	string UUID [read-only]
+
+			128-bit characteristic UUID.
+
+		object Service [read-only]
+
+			Object path of the GATT service the characteristc
+			belongs to.
+
+		array{byte} Value [read-write]
+
+			Value read from the remote Bluetooth device or from
+			the external application implementing GATT services.
+
+		array{string} Flags [read-only, optional]
+
+			Defines how the characteristic value can be used. See
+			Core spec page 1898, "Table 3.5: Characteristic
+			Properties bit field" and page 1900, "Table 3.8:
+			Characteristic Extended Properties bit field". Allowed
+			values: "broadcast", "read", "write-without-response",
+			"write", "notify", "indicate",
+			"authenticated-signed-writes", "reliable-write", and
+			"writable-auxiliaries".
+
+
+Characteristic Descriptors hierarchy
+====================================
+
+Local or remote GATT characteristic descriptors hierarchy.
+
+Service		org.bluez
+Interface	org.bluez.Descriptor1 [Experimental]
+Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/serviceXX/charYYYY/descriptorZZZ
+
+Properties	string UUID [read-only]
+
+			128-bit descriptor UUID.
+
+		object Characteristic [read-only]
+
+			Object path of the GATT characteristc the descriptor
+			belongs to.
+
+		array{byte} Value [read-write]
+
+			Raw characteristic descriptor value read from the
+			remote Bluetooth device or from the external
+			application implementing GATT services.
+
+		string Permissions [read-only]: To be defined
+
+			Defines read/write authentication and authorization
+			requirements.
+
+Service Manager hierarchy
+=============================
+
+Service Manager allows external applications to register GATT based
+services. Services must follow the API for Service and Characteristic
+described above.
+
+Local GATT services, characteristics and characteristic descriptors are
+discovered automatically using the D-Bus Object Manager interface.
+
+Service		org.bluez
+Interface	org.bluez.GattServiceManager1 [Experimental]
+Object path	/org/bluez
+
+Methods		RegisterService(object service, dict options)
+
+			Registers remote application service exported under
+			interface GattService1. Characteristic objects must
+			be hierarchical to their service and must use the
+			interface Characteristic1. D-Bus Object Manager is
+			used to fetch the exported objects.
+
+			"service" object path together with the D-Bus system
+			bus connection ID define the identification of the
+			application registering a GATT based service.
+
+			Possible errors: org.bluez.Error.InvalidArguments
+					 org.bluez.Error.AlreadyExists
+
+		UnregisterService(object service)
+
+			This unregisters the service that has been
+			previously registered. The object path parameter
+			must match the same value that has been used
+			on registration.
+
+			Possible errors: org.bluez.Error.DoesNotExist
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH BlueZ v2 00/18] GATT API: External Services
From: Claudio Takahasi @ 2014-01-21 13:26 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: claudio.takahasi

This patchset implements the minimal support for adding local services
declarations.

Limitation: Remove services and multiple services exported by the same
remote will be implemented the next series.

Changes from PATCH v1 to PATCH v2:
* Rebase
* Included patch "doc: Add GATT API"
* Interfaces renamed: s/Service1/GattService1, and
  s/ServiceManager1/GattServiceManager1
* Removed patch "gatt: Implement UnregisterService" from this patchset

Changes from PATCH v0 to PATCH v1:
* Rebase

Changes from RFC v0 to PATCH v0:
* Changed copyright year : s/2013/2014
* Fixed coding style
* Added gatt-service binary to gitignore
* Added extra comment in the source code

Features:
* API for internal and external services declaration
* Unix socket for testing purpose: services are exported
through unix sockets to avoid breaking the current attribute
server.

How to test:
Run bluetoothd with EXPERIMENTAL flag (-E)
Replace /etc/dbus-1/system.d/bluetooth.conf and reload DBus settings
$gatttool -L --primary (or interactive mode)

Roughly upstreaming plan (steps):
* GATT Server: External Services
* GATT Server: External Characteristics (Server)
* GATT Server: External Descriptors (Server)
* Replace attribute server

Alvaro Silva (6):
  gatt: Add stub for gatt.{c, h} files
  gatt: Register Manager D-Bus Interface
  gatt: Add registering external service
  gatt: Add external services tracking
  gatt: Register ATT command/event handler
  gatt: Add Discover All Primary Services

Andre Guedes (1):
  gatt: Add helper for creating GATT services

Claudio Takahasi (11):
  doc: Add GATT API
  lib: Move GATT UUID to uuid.h
  gatt: Add server unix socket
  gattrib: Use default ATT LE MTU for non-standard sockets
  test: Add external service GATT skeleton
  gitignore: Add test/gatt-service
  test: Add signal handling for gatt-service
  test: Add registering external service
  gatttool: Add unix socket connect
  gatttool: Add unix socket support for interactive mode
  bluetooth.conf: Add ObjectManager interface

 .gitignore           |   1 +
 Makefile.am          |   2 +
 Makefile.tools       |   5 +
 attrib/gatt.h        |  25 ----
 attrib/gattrib.c     |  16 +--
 attrib/gatttool.c    |  27 +++-
 attrib/gatttool.h    |   1 +
 attrib/interactive.c |  19 +--
 attrib/utils.c       |  54 ++++++++
 doc/gatt-api.txt     | 145 +++++++++++++++++++
 lib/uuid.h           |  30 ++++
 src/bluetooth.conf   |   1 +
 src/gatt-dbus.c      | 271 ++++++++++++++++++++++++++++++++++++
 src/gatt-dbus.h      |  25 ++++
 src/gatt.c           | 383 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/gatt.h           |  36 +++++
 src/main.c           |   4 +
 test/gatt-service.c  | 254 ++++++++++++++++++++++++++++++++++
 18 files changed, 1251 insertions(+), 48 deletions(-)
 create mode 100644 doc/gatt-api.txt
 create mode 100644 src/gatt-dbus.c
 create mode 100644 src/gatt-dbus.h
 create mode 100644 src/gatt.c
 create mode 100644 src/gatt.h
 create mode 100644 test/gatt-service.c

-- 
1.8.3.1


^ permalink raw reply

* Re: [PATCH 1/2] android: Add btmgmt to debug builds
From: Johan Hedberg @ 2014-01-21 12:56 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Andrzej Kaczmarek, linux-bluetooth@vger.kernel.org development
In-Reply-To: <BE345789-E478-4C6C-B192-4DAB782CE135@holtmann.org>

Hi Marcel,

On Thu, Jan 16, 2014, Marcel Holtmann wrote:
> > android/Android.mk | 36 ++++++++++++++++++++++++++++++++++++
> > 1 file changed, 36 insertions(+)
> > 
> > diff --git a/android/Android.mk b/android/Android.mk
> > index 7e97ec8..b3e6a50 100644
> > --- a/android/Android.mk
> > +++ b/android/Android.mk
> > @@ -282,3 +282,39 @@ LOCAL_MODULE_TAGS := optional
> > LOCAL_MODULE := bluetoothd-snoop
> > 
> > include $(BUILD_EXECUTABLE)
> > +
> > +#
> > +# btmgmt
> > +#
> > +
> > +include $(CLEAR_VARS)
> > +
> > +LOCAL_SRC_FILES := \
> > +	../tools/btmgmt.c \
> > +	../monitor/mainloop.c \
> > +	../lib/bluetooth.c \
> > +	../lib/sdp.c \
> > +	../src/eir.c \
> > +	../src/glib-helper.c \
> > +	../src/shared/io-mainloop.c \
> > +	../src/shared/mgmt.c \
> > +	../src/shared/queue.c \
> > +	../src/shared/util.c \
> > +
> > +LOCAL_C_INCLUDES := \
> > +	$(call include-path-for, glib) \
> > +	$(call include-path-for, glib)/glib \
> > +	$(LOCAL_PATH)/.. \
> > +	$(LOCAL_PATH)/../src \
> > +	$(LOCAL_PATH)/../lib \
> > +
> > +LOCAL_SHARED_LIBRARIES := \
> > +	libglib \
> 
> have Johan fix the dependency on GLib instead. It should not be needed anymore.

btmgmt is now free of GLib so Andrzej is free to send a new patch for
the Android build.

Johan

^ permalink raw reply

* [PATCH_v2 2/2] android/tester: Add HIDhost GetReport test
From: Ravi kumar Veeramally @ 2014-01-21 12:24 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1390307059-7772-1-git-send-email-ravikumar.veeramally@linux.intel.com>

---
 android/android-tester.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index 9a17612..e0b4579 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -3206,6 +3206,10 @@ static void setup_hidhost_interface(const void *test_data)
 
 #define HID_SEND_DATA			0xa2
 
+#define HID_GET_INPUT_REPORT		0x49
+#define HID_GET_OUTPUT_REPORT		0x4a
+#define HID_GET_FEATURE_REPORT		0x4b
+
 static void hid_prepare_reply_protocol_mode(const void *data, uint16_t len)
 {
 	struct test_data *t_data = tester_get_data();
@@ -3221,6 +3225,22 @@ static void hid_prepare_reply_protocol_mode(const void *data, uint16_t len)
 						(void *)pdu, pdu_len);
 }
 
+static void hid_prepare_reply_report(const void *data, uint16_t len)
+{
+	struct test_data *t_data = tester_get_data();
+	struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
+	uint8_t pdu[3] = { 0, 0, 0 };
+	uint16_t pdu_len = 0;
+
+	pdu_len = 3;
+	pdu[0] = 0xa2;
+	pdu[1] = 0x01;
+	pdu[2] = 0x00;
+
+	bthost_send_cid(bthost, t_data->ctrl_handle, t_data->ctrl_cid,
+						(void *)pdu, pdu_len);
+}
+
 static void hid_intr_cid_hook_cb(const void *data, uint16_t len,
 							void *user_data)
 {
@@ -3255,6 +3275,11 @@ static void hid_ctrl_cid_hook_cb(const void *data, uint16_t len,
 	case HID_SET_BOOT_PROTOCOL:
 		hid_prepare_reply_protocol_mode(data, len);
 		break;
+	case HID_GET_INPUT_REPORT:
+	case HID_GET_OUTPUT_REPORT:
+	case HID_GET_FEATURE_REPORT:
+		hid_prepare_reply_report(data, len);
+		break;
 	/* HID device doesnot reply for this commads, so reaching pdu's
 	 * to hid device means assuming test passed */
 	case HID_SET_INPUT_REPORT:
@@ -3514,6 +3539,41 @@ static void test_hidhost_send_data(const void *test_data)
 		tester_test_failed();
 }
 
+static void hid_get_report_cb(bt_bdaddr_t *bd_addr, bthh_status_t status,
+						uint8_t *report, int size)
+{
+	struct test_data *data = tester_get_data();
+	const struct hidhost_generic_data *test = data->test_data;
+
+	if (data->cb_count == test->expected_cb_count &&
+					status == test->expected_status &&
+					size == test->expected_report_size)
+		tester_test_passed();
+	else
+		tester_test_failed();
+}
+
+static const struct hidhost_generic_data hidhost_test_get_report = {
+	.expected_hal_cb.get_report_cb = hid_get_report_cb,
+	.expected_cb_count = 1,
+	.expected_status = BTHH_OK,
+	.expected_report_size = 2,
+};
+
+static void test_hidhost_get_report(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	const uint8_t *hid_addr = hciemu_get_client_bdaddr(data->hciemu);
+	bt_bdaddr_t bdaddr;
+	bt_status_t bt_status;
+
+	data->cb_count = 0;
+	bdaddr2android((const bdaddr_t *) hid_addr, &bdaddr);
+	bt_status = data->if_hid->get_report(&bdaddr, BTHH_INPUT_REPORT, 1, 20);
+	if (bt_status != BT_STATUS_SUCCESS)
+		tester_test_failed();
+}
+
 #define test_bredrle(name, data, test_setup, test, test_teardown) \
 	do { \
 		struct test_data *user; \
@@ -3879,6 +3939,10 @@ int main(int argc, char *argv[])
 			&hidhost_test_get_protocol, setup_hidhost_connect,
 				test_hidhost_set_protocol, teardown);
 
+	test_bredrle("HIDHost GetReport Success",
+			&hidhost_test_get_report, setup_hidhost_connect,
+				test_hidhost_get_report, teardown);
+
 	test_bredrle("HIDHost SetReport Success",
 				NULL, setup_hidhost_connect,
 				test_hidhost_set_report, teardown);
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH_v2 1/2] android/hidhost: Fix miscalculation of get report event notification length
From: Ravi kumar Veeramally @ 2014-01-21 12:24 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally

Event length is size of struct + data len (if any). It is miscalulated.
---
 android/hidhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/hidhost.c b/android/hidhost.c
index 3da77c8..108493a 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -371,7 +371,7 @@ static void bt_hid_notify_get_report(struct hid_device *dev, uint8_t *buf,
 	ba2str(&dev->dst, address);
 	DBG("device %s", address);
 
-	ev_len = sizeof(*ev) + sizeof(struct hal_ev_hidhost_get_report) + 1;
+	ev_len = sizeof(*ev);
 
 	if (!((buf[0] == (HID_MSG_DATA | HID_DATA_TYPE_INPUT)) ||
 			(buf[0] == (HID_MSG_DATA | HID_DATA_TYPE_OUTPUT)) ||
-- 
1.8.3.2


^ permalink raw reply related

* Re: [PATCH BlueZ 2/2] android/A2DP: Fix sending notification on bt_a2dp_unregister
From: Luiz Augusto von Dentz @ 2014-01-21 11:41 UTC (permalink / raw)
  To: linux-bluetooth@vger.kernel.org
In-Reply-To: <1390220727-21494-2-git-send-email-luiz.dentz@gmail.com>

Hi,

On Mon, Jan 20, 2014 at 2:25 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> At this point IPC might have been closed already.
> ---
>  android/a2dp.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/android/a2dp.c b/android/a2dp.c
> index 8ec03c8..5569691 100644
> --- a/android/a2dp.c
> +++ b/android/a2dp.c
> @@ -119,8 +119,10 @@ static void unregister_endpoint(void *data)
>         g_free(endpoint);
>  }
>
> -static void a2dp_device_free(struct a2dp_device *dev)
> +static void a2dp_device_free(void *data)
>  {
> +       struct a2dp_device *dev = data;
> +
>         if (dev->idle_id > 0)
>                 g_source_remove(dev->idle_id);
>
> @@ -1471,13 +1473,6 @@ fail:
>         return false;
>  }
>
> -static void a2dp_device_disconnected(gpointer data, gpointer user_data)
> -{
> -       struct a2dp_device *dev = data;
> -
> -       bt_a2dp_notify_state(dev, HAL_A2DP_STATE_DISCONNECTED);
> -}
> -
>  void bt_a2dp_unregister(void)
>  {
>         DBG("");
> @@ -1488,7 +1483,7 @@ void bt_a2dp_unregister(void)
>         g_slist_free_full(endpoints, unregister_endpoint);
>         endpoints = NULL;
>
> -       g_slist_foreach(devices, a2dp_device_disconnected, NULL);
> +       g_slist_free_full(devices, a2dp_device_free);
>         devices = NULL;
>
>         ipc_unregister(HAL_SERVICE_ID_A2DP);
> --
> 1.8.4.2

Applied, patch 1/2 will need some changes so it is not applied yet.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* unknown main item tag 0x0
From: Alexander Holler @ 2014-01-21 11:32 UTC (permalink / raw)
  To: linux-bluetooth

Hello,

I can't remember since when I'm seeing the kernel message "unknown main 
item tag 0x0" for many Bluetooth input devices, but it is since quiet 
some time.

Has someone already tried to find out where that does come from?

My first guess would be that bluez misses one or more bytes a connection 
startup, which is based on the fact that, since ever, it misses the 
first keystroke of BT-keyboards too (the keystroke which wakes up the 
keyboard and initiates the connection). And I'm pretty sure my keyboard 
does transmit that initiating keystroke, because Windows receives it. ;)

Besides that, that guess isn't based on anything. I neither have tried 
to search through the source nor did I run some tests.

But because I'm curious I can't completely ignore that kernel message, 
even if I haven't experienced any obvious problems. So here is the 
question if someone else has a pointer or has already searched what the 
reason for that message is. I don't think it's a fault of the used 
device(s), as I see this message for multiple bt-input-devices.

Regards,

Alexander Holler

^ permalink raw reply

* Re: Unable to use Sony Dualshock 4 game controller
From: Szymon Janc @ 2014-01-21 11:06 UTC (permalink / raw)
  To: Christopher Rosell; +Cc: linux-bluetooth
In-Reply-To: <CAPk--xzV9n5-RnAhPhbM2hCnftvJxeCm9E0Wgkj+zzdqNqseVQ@mail.gmail.com>

Hi Christopher,

On Friday 20 of December 2013 16:43:17 Christopher Rosell wrote:
> Hello there,
> 
> I'm attempting to use a Sony Dualshock 4 game controller with bluez,
> but have run into some problems. I'm running Linux kernel 3.12.4 on
> Arch Linux with bluez 5.12.
> 
> The DS4 is a standard bluetooth device, unlike the DS3 and I was able
> to pair and use it without any problems in Windows 7, but in Linux I
> have not been able to get it working correctly. The controller can be
> started in two modes, a pairing mode by pressing the buttons Share and
> PS at the same time and a normal mode by pressing the PS button only.

Please check BlueZ 5.14.

-- 
Best regards, 
Szymon Janc

^ permalink raw reply

* [PATCH SBC v5 2/2] sbc: Add sbc_init_a2dp to sbc.sym
From: Luiz Augusto von Dentz @ 2014-01-21  9:08 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1390295313-5951-1-git-send-email-luiz.dentz@gmail.com>

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

---
 sbc/sbc.sym | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sbc/sbc.sym b/sbc/sbc.sym
index 3a0c6bf..0c23a05 100644
--- a/sbc/sbc.sym
+++ b/sbc/sbc.sym
@@ -19,3 +19,7 @@ SBC_1.1 {
 global:
 	sbc_init_msbc;
 } SBC_1.0;
+SBC_1.2 {
+global:
+	sbc_init_a2dp;
+} SBC_1.1;
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH SBC v5 1/2] sbc: Add sbc_init_a2dp
From: Luiz Augusto von Dentz @ 2014-01-21  9:08 UTC (permalink / raw)
  To: linux-bluetooth

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

This adds sbc_init_a2dp that can be used to convert A2DP configuration to
the internal representation since they are not binary compatible.
---
 sbc/sbc.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 sbc/sbc.h |   2 +
 2 files changed, 146 insertions(+)

diff --git a/sbc/sbc.c b/sbc/sbc.c
index c589217..ee6a2ab 100644
--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -57,6 +57,55 @@
 #define MSBC_SYNCWORD	0xAD
 #define MSBC_BLOCKS	15
 
+#define A2DP_SAMPLING_FREQ_16000		(1 << 3)
+#define A2DP_SAMPLING_FREQ_32000		(1 << 2)
+#define A2DP_SAMPLING_FREQ_44100		(1 << 1)
+#define A2DP_SAMPLING_FREQ_48000		(1 << 0)
+
+#define A2DP_CHANNEL_MODE_MONO			(1 << 3)
+#define A2DP_CHANNEL_MODE_DUAL_CHANNEL		(1 << 2)
+#define A2DP_CHANNEL_MODE_STEREO		(1 << 1)
+#define A2DP_CHANNEL_MODE_JOINT_STEREO		(1 << 0)
+
+#define A2DP_BLOCK_LENGTH_4			(1 << 3)
+#define A2DP_BLOCK_LENGTH_8			(1 << 2)
+#define A2DP_BLOCK_LENGTH_12			(1 << 1)
+#define A2DP_BLOCK_LENGTH_16			(1 << 0)
+
+#define A2DP_SUBBANDS_4				(1 << 1)
+#define A2DP_SUBBANDS_8				(1 << 0)
+
+#define A2DP_ALLOCATION_SNR			(1 << 1)
+#define A2DP_ALLOCATION_LOUDNESS		(1 << 0)
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+
+struct a2dp_sbc {
+	uint8_t channel_mode:4;
+	uint8_t frequency:4;
+	uint8_t allocation_method:2;
+	uint8_t subbands:2;
+	uint8_t block_length:4;
+	uint8_t min_bitpool;
+	uint8_t max_bitpool;
+} __attribute__ ((packed));
+
+#elif __BYTE_ORDER == __BIG_ENDIAN
+
+struct a2dp_sbc {
+	uint8_t frequency:4;
+	uint8_t channel_mode:4;
+	uint8_t block_length:4;
+	uint8_t subbands:2;
+	uint8_t allocation_method:2;
+	uint8_t min_bitpool;
+	uint8_t max_bitpool;
+} __attribute__ ((packed));
+
+#else
+#error "Unknown byte order"
+#endif
+
 /* This structure contains an unpacked SBC frame.
    Yes, there is probably quite some unused space herein */
 struct sbc_frame {
@@ -1046,6 +1095,101 @@ SBC_EXPORT int sbc_init_msbc(sbc_t *sbc, unsigned long flags)
 	return 0;
 }
 
+SBC_EXPORT int sbc_init_a2dp(sbc_t *sbc, unsigned long flags,
+					const void *conf, size_t conf_len)
+{
+	const struct a2dp_sbc *a2dp;
+	int err;
+
+	if (conf_len != sizeof(*a2dp))
+		return -EINVAL;
+
+	err = sbc_init(sbc, flags);
+	if (err < 0)
+		return err;
+
+	a2dp = conf;
+
+	switch (a2dp->frequency) {
+	case A2DP_SAMPLING_FREQ_16000:
+		sbc->frequency = SBC_FREQ_16000;
+		break;
+	case A2DP_SAMPLING_FREQ_32000:
+		sbc->frequency = SBC_FREQ_32000;
+		break;
+	case A2DP_SAMPLING_FREQ_44100:
+		sbc->frequency = SBC_FREQ_44100;
+		break;
+	case A2DP_SAMPLING_FREQ_48000:
+		sbc->frequency = SBC_FREQ_48000;
+		break;
+	default:
+		goto failed;
+	}
+
+	switch (a2dp->channel_mode) {
+	case A2DP_CHANNEL_MODE_MONO:
+		sbc->mode = SBC_MODE_MONO;
+		break;
+	case A2DP_CHANNEL_MODE_DUAL_CHANNEL:
+		sbc->mode = SBC_MODE_DUAL_CHANNEL;
+		break;
+	case A2DP_CHANNEL_MODE_STEREO:
+		sbc->mode = SBC_MODE_STEREO;
+		break;
+	case A2DP_CHANNEL_MODE_JOINT_STEREO:
+		sbc->mode = SBC_MODE_JOINT_STEREO;
+		break;
+	default:
+		goto failed;
+	}
+
+	switch (a2dp->allocation_method) {
+	case A2DP_ALLOCATION_SNR:
+		sbc->allocation = SBC_AM_SNR;
+		break;
+	case A2DP_ALLOCATION_LOUDNESS:
+		sbc->allocation = SBC_AM_LOUDNESS;
+		break;
+	default:
+		goto failed;
+	}
+
+	switch (a2dp->subbands) {
+	case A2DP_SUBBANDS_4:
+		sbc->subbands = SBC_SB_4;
+		break;
+	case A2DP_SUBBANDS_8:
+		sbc->subbands = SBC_SB_8;
+		break;
+	default:
+		goto failed;
+	}
+
+	switch (a2dp->block_length) {
+	case A2DP_BLOCK_LENGTH_4:
+		sbc->blocks = SBC_BLK_4;
+		break;
+	case A2DP_BLOCK_LENGTH_8:
+		sbc->blocks = SBC_BLK_8;
+		break;
+	case A2DP_BLOCK_LENGTH_12:
+		sbc->blocks = SBC_BLK_12;
+		break;
+	case A2DP_BLOCK_LENGTH_16:
+		sbc->blocks = SBC_BLK_16;
+		break;
+	default:
+		goto failed;
+	}
+
+	return 0;
+
+failed:
+	sbc_finish(sbc);
+	return -EINVAL;
+}
+
 SBC_EXPORT ssize_t sbc_parse(sbc_t *sbc, const void *input, size_t input_len)
 {
 	return sbc_decode(sbc, input, input_len, NULL, 0, NULL);
diff --git a/sbc/sbc.h b/sbc/sbc.h
index 5f8a1fc..32eb2e9 100644
--- a/sbc/sbc.h
+++ b/sbc/sbc.h
@@ -84,6 +84,8 @@ typedef struct sbc_struct sbc_t;
 int sbc_init(sbc_t *sbc, unsigned long flags);
 int sbc_reinit(sbc_t *sbc, unsigned long flags);
 int sbc_init_msbc(sbc_t *sbc, unsigned long flags);
+int sbc_init_a2dp(sbc_t *sbc, unsigned long flags,
+					const void *conf, size_t conf_len);
 
 ssize_t sbc_parse(sbc_t *sbc, const void *input, size_t input_len);
 
-- 
1.8.4.2


^ permalink raw reply related

* Re: [PATCH BlueZ] emulator: Fix unaligned memory access compilation errors
From: Johan Hedberg @ 2014-01-21  9:08 UTC (permalink / raw)
  To: Anderson Lizardo; +Cc: linux-bluetooth
In-Reply-To: <1390268769-30209-1-git-send-email-anderson.lizardo@openbossa.org>

Hi Lizardo,

On Mon, Jan 20, 2014, Anderson Lizardo wrote:
> The u128_xor() function does proper aligned access and accepts void *
> arguments, therefore the casts are unnecessary and trigger clang errors.
> ---
>  emulator/smp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH SBC v4 1/2] sbc: Add sbc_init_a2dp
From: Marcel Holtmann @ 2014-01-21  8:58 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org development
In-Reply-To: <1390293983-31667-1-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

> This adds sbc_init_a2dp that can be used to convert A2DP configuration to
> the internal representation since they are not binary compatible.
> ---
> sbc/sbc.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> sbc/sbc.h |   2 +
> 2 files changed, 146 insertions(+)
> 
> diff --git a/sbc/sbc.c b/sbc/sbc.c
> index c589217..12e8238 100644
> --- a/sbc/sbc.c
> +++ b/sbc/sbc.c
> @@ -57,6 +57,55 @@
> #define MSBC_SYNCWORD	0xAD
> #define MSBC_BLOCKS	15
> 
> +#define A2DP_SAMPLING_FREQ_16000		(1 << 3)
> +#define A2DP_SAMPLING_FREQ_32000		(1 << 2)
> +#define A2DP_SAMPLING_FREQ_44100		(1 << 1)
> +#define A2DP_SAMPLING_FREQ_48000		(1 << 0)
> +
> +#define A2DP_CHANNEL_MODE_MONO			(1 << 3)
> +#define A2DP_CHANNEL_MODE_DUAL_CHANNEL		(1 << 2)
> +#define A2DP_CHANNEL_MODE_STEREO		(1 << 1)
> +#define A2DP_CHANNEL_MODE_JOINT_STEREO		(1 << 0)
> +
> +#define A2DP_BLOCK_LENGTH_4			(1 << 3)
> +#define A2DP_BLOCK_LENGTH_8			(1 << 2)
> +#define A2DP_BLOCK_LENGTH_12			(1 << 1)
> +#define A2DP_BLOCK_LENGTH_16			(1 << 0)
> +
> +#define A2DP_SUBBANDS_4				(1 << 1)
> +#define A2DP_SUBBANDS_8				(1 << 0)
> +
> +#define A2DP_ALLOCATION_SNR			(1 << 1)
> +#define A2DP_ALLOCATION_LOUDNESS		(1 << 0)
> +
> +#if __BYTE_ORDER == __LITTLE_ENDIAN
> +
> +struct a2dp_sbc {
> +	uint8_t channel_mode:4;
> +	uint8_t frequency:4;
> +	uint8_t allocation_method:2;
> +	uint8_t subbands:2;
> +	uint8_t block_length:4;
> +	uint8_t min_bitpool;
> +	uint8_t max_bitpool;
> +} __attribute__ ((packed));
> +
> +#elif __BYTE_ORDER == __BIG_ENDIAN
> +
> +struct a2dp_sbc {
> +	uint8_t frequency:4;
> +	uint8_t channel_mode:4;
> +	uint8_t block_length:4;
> +	uint8_t subbands:2;
> +	uint8_t allocation_method:2;
> +	uint8_t min_bitpool;
> +	uint8_t max_bitpool;
> +} __attribute__ ((packed));
> +
> +#else
> +#error "Unknown byte order"
> +#endif
> +
> /* This structure contains an unpacked SBC frame.
>    Yes, there is probably quite some unused space herein */
> struct sbc_frame {
> @@ -1046,6 +1095,101 @@ SBC_EXPORT int sbc_init_msbc(sbc_t *sbc, unsigned long flags)
> 	return 0;
> }
> 
> +SBC_EXPORT int sbc_init_a2dp(sbc_t *sbc, unsigned long flags, const void *conf,
> +							size_t conf_len)

just to make it easier on the eyes:

			..a2dp(sbc_t *sbc, unsigned long flags,
						const void *conf, size_t conf_len)

> +{
> +	const struct a2dp_sbc *a2dp;
> +	int err;
> +
> +	if (conf_len != sizeof(*a2dp))
> +		return -EINVAL;
> +
> +	err = sbc_init(sbc, flags);
> +	if (err < 0)
> +		return err;
> +
> +	a2dp = conf;
> +
> +	switch (a2dp->frequency) {
> +	case A2DP_SAMPLING_FREQ_16000:
> +		sbc->frequency = SBC_FREQ_16000;
> +		break;
> +	case A2DP_SAMPLING_FREQ_32000:
> +		sbc->frequency = SBC_FREQ_32000;
> +		break;
> +	case A2DP_SAMPLING_FREQ_44100:
> +		sbc->frequency = SBC_FREQ_44100;
> +		break;
> +	case A2DP_SAMPLING_FREQ_48000:
> +		sbc->frequency = SBC_FREQ_48000;
> +		break;
> +	default:
> +		goto failed;
> +	}
> +
> +	switch (a2dp->channel_mode) {
> +	case A2DP_CHANNEL_MODE_MONO:
> +		sbc->mode = SBC_MODE_MONO;
> +		break;
> +	case A2DP_CHANNEL_MODE_DUAL_CHANNEL:
> +		sbc->mode = SBC_MODE_DUAL_CHANNEL;
> +		break;
> +	case A2DP_CHANNEL_MODE_STEREO:
> +		sbc->mode = SBC_MODE_STEREO;
> +		break;
> +	case A2DP_CHANNEL_MODE_JOINT_STEREO:
> +		sbc->mode = SBC_MODE_JOINT_STEREO;
> +		break;
> +	default:
> +		goto failed;
> +	}
> +
> +	switch (a2dp->allocation_method) {
> +	case A2DP_ALLOCATION_SNR:
> +		sbc->allocation = SBC_AM_SNR;
> +		break;
> +	case A2DP_ALLOCATION_LOUDNESS:
> +		sbc->allocation = SBC_AM_LOUDNESS;
> +		break;
> +	default:
> +		goto failed;
> +	}
> +
> +	switch (a2dp->subbands) {
> +	case A2DP_SUBBANDS_4:
> +		sbc->subbands = SBC_SB_4;
> +		break;
> +	case A2DP_SUBBANDS_8:
> +		sbc->subbands = SBC_SB_8;
> +		break;
> +	default:
> +		goto failed;
> +	}
> +
> +	switch (a2dp->block_length) {
> +	case A2DP_BLOCK_LENGTH_4:
> +		sbc->blocks = SBC_BLK_4;
> +		break;
> +	case A2DP_BLOCK_LENGTH_8:
> +		sbc->blocks = SBC_BLK_8;
> +		break;
> +	case A2DP_BLOCK_LENGTH_12:
> +		sbc->blocks = SBC_BLK_12;
> +		break;
> +	case A2DP_BLOCK_LENGTH_16:
> +		sbc->blocks = SBC_BLK_16;
> +		break;
> +	default:
> +		goto failed;
> +	}
> +
> +	return 0;
> +
> +failed:
> +	sbc_finish(sbc);
> +	return -EINVAL;
> +}
> +
> SBC_EXPORT ssize_t sbc_parse(sbc_t *sbc, const void *input, size_t input_len)
> {
> 	return sbc_decode(sbc, input, input_len, NULL, 0, NULL);
> diff --git a/sbc/sbc.h b/sbc/sbc.h
> index 5f8a1fc..02ad9fe 100644
> --- a/sbc/sbc.h
> +++ b/sbc/sbc.h
> @@ -84,6 +84,8 @@ typedef struct sbc_struct sbc_t;
> int sbc_init(sbc_t *sbc, unsigned long flags);
> int sbc_reinit(sbc_t *sbc, unsigned long flags);
> int sbc_init_msbc(sbc_t *sbc, unsigned long flags);
> +int sbc_init_a2dp(sbc_t *sbc, unsigned long flags, const void *conf,
> +							size_t conf_len);

Same here:

	int sbc_init_a2dp(sbc_t *sbc, unsigned long flags,
					const void *conf, size_t conf_len);

> 
> ssize_t sbc_parse(sbc_t *sbc, const void *input, size_t input_len);

Regards

Marcel


^ permalink raw reply

* [PATCH SBC v4 2/2] sbc: Add sbc_init_a2dp to sbc.sym
From: Luiz Augusto von Dentz @ 2014-01-21  8:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1390293983-31667-1-git-send-email-luiz.dentz@gmail.com>

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

---
 sbc/sbc.sym | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sbc/sbc.sym b/sbc/sbc.sym
index 3a0c6bf..0c23a05 100644
--- a/sbc/sbc.sym
+++ b/sbc/sbc.sym
@@ -19,3 +19,7 @@ SBC_1.1 {
 global:
 	sbc_init_msbc;
 } SBC_1.0;
+SBC_1.2 {
+global:
+	sbc_init_a2dp;
+} SBC_1.1;
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH SBC v4 1/2] sbc: Add sbc_init_a2dp
From: Luiz Augusto von Dentz @ 2014-01-21  8:46 UTC (permalink / raw)
  To: linux-bluetooth

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

This adds sbc_init_a2dp that can be used to convert A2DP configuration to
the internal representation since they are not binary compatible.
---
 sbc/sbc.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 sbc/sbc.h |   2 +
 2 files changed, 146 insertions(+)

diff --git a/sbc/sbc.c b/sbc/sbc.c
index c589217..12e8238 100644
--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -57,6 +57,55 @@
 #define MSBC_SYNCWORD	0xAD
 #define MSBC_BLOCKS	15
 
+#define A2DP_SAMPLING_FREQ_16000		(1 << 3)
+#define A2DP_SAMPLING_FREQ_32000		(1 << 2)
+#define A2DP_SAMPLING_FREQ_44100		(1 << 1)
+#define A2DP_SAMPLING_FREQ_48000		(1 << 0)
+
+#define A2DP_CHANNEL_MODE_MONO			(1 << 3)
+#define A2DP_CHANNEL_MODE_DUAL_CHANNEL		(1 << 2)
+#define A2DP_CHANNEL_MODE_STEREO		(1 << 1)
+#define A2DP_CHANNEL_MODE_JOINT_STEREO		(1 << 0)
+
+#define A2DP_BLOCK_LENGTH_4			(1 << 3)
+#define A2DP_BLOCK_LENGTH_8			(1 << 2)
+#define A2DP_BLOCK_LENGTH_12			(1 << 1)
+#define A2DP_BLOCK_LENGTH_16			(1 << 0)
+
+#define A2DP_SUBBANDS_4				(1 << 1)
+#define A2DP_SUBBANDS_8				(1 << 0)
+
+#define A2DP_ALLOCATION_SNR			(1 << 1)
+#define A2DP_ALLOCATION_LOUDNESS		(1 << 0)
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+
+struct a2dp_sbc {
+	uint8_t channel_mode:4;
+	uint8_t frequency:4;
+	uint8_t allocation_method:2;
+	uint8_t subbands:2;
+	uint8_t block_length:4;
+	uint8_t min_bitpool;
+	uint8_t max_bitpool;
+} __attribute__ ((packed));
+
+#elif __BYTE_ORDER == __BIG_ENDIAN
+
+struct a2dp_sbc {
+	uint8_t frequency:4;
+	uint8_t channel_mode:4;
+	uint8_t block_length:4;
+	uint8_t subbands:2;
+	uint8_t allocation_method:2;
+	uint8_t min_bitpool;
+	uint8_t max_bitpool;
+} __attribute__ ((packed));
+
+#else
+#error "Unknown byte order"
+#endif
+
 /* This structure contains an unpacked SBC frame.
    Yes, there is probably quite some unused space herein */
 struct sbc_frame {
@@ -1046,6 +1095,101 @@ SBC_EXPORT int sbc_init_msbc(sbc_t *sbc, unsigned long flags)
 	return 0;
 }
 
+SBC_EXPORT int sbc_init_a2dp(sbc_t *sbc, unsigned long flags, const void *conf,
+							size_t conf_len)
+{
+	const struct a2dp_sbc *a2dp;
+	int err;
+
+	if (conf_len != sizeof(*a2dp))
+		return -EINVAL;
+
+	err = sbc_init(sbc, flags);
+	if (err < 0)
+		return err;
+
+	a2dp = conf;
+
+	switch (a2dp->frequency) {
+	case A2DP_SAMPLING_FREQ_16000:
+		sbc->frequency = SBC_FREQ_16000;
+		break;
+	case A2DP_SAMPLING_FREQ_32000:
+		sbc->frequency = SBC_FREQ_32000;
+		break;
+	case A2DP_SAMPLING_FREQ_44100:
+		sbc->frequency = SBC_FREQ_44100;
+		break;
+	case A2DP_SAMPLING_FREQ_48000:
+		sbc->frequency = SBC_FREQ_48000;
+		break;
+	default:
+		goto failed;
+	}
+
+	switch (a2dp->channel_mode) {
+	case A2DP_CHANNEL_MODE_MONO:
+		sbc->mode = SBC_MODE_MONO;
+		break;
+	case A2DP_CHANNEL_MODE_DUAL_CHANNEL:
+		sbc->mode = SBC_MODE_DUAL_CHANNEL;
+		break;
+	case A2DP_CHANNEL_MODE_STEREO:
+		sbc->mode = SBC_MODE_STEREO;
+		break;
+	case A2DP_CHANNEL_MODE_JOINT_STEREO:
+		sbc->mode = SBC_MODE_JOINT_STEREO;
+		break;
+	default:
+		goto failed;
+	}
+
+	switch (a2dp->allocation_method) {
+	case A2DP_ALLOCATION_SNR:
+		sbc->allocation = SBC_AM_SNR;
+		break;
+	case A2DP_ALLOCATION_LOUDNESS:
+		sbc->allocation = SBC_AM_LOUDNESS;
+		break;
+	default:
+		goto failed;
+	}
+
+	switch (a2dp->subbands) {
+	case A2DP_SUBBANDS_4:
+		sbc->subbands = SBC_SB_4;
+		break;
+	case A2DP_SUBBANDS_8:
+		sbc->subbands = SBC_SB_8;
+		break;
+	default:
+		goto failed;
+	}
+
+	switch (a2dp->block_length) {
+	case A2DP_BLOCK_LENGTH_4:
+		sbc->blocks = SBC_BLK_4;
+		break;
+	case A2DP_BLOCK_LENGTH_8:
+		sbc->blocks = SBC_BLK_8;
+		break;
+	case A2DP_BLOCK_LENGTH_12:
+		sbc->blocks = SBC_BLK_12;
+		break;
+	case A2DP_BLOCK_LENGTH_16:
+		sbc->blocks = SBC_BLK_16;
+		break;
+	default:
+		goto failed;
+	}
+
+	return 0;
+
+failed:
+	sbc_finish(sbc);
+	return -EINVAL;
+}
+
 SBC_EXPORT ssize_t sbc_parse(sbc_t *sbc, const void *input, size_t input_len)
 {
 	return sbc_decode(sbc, input, input_len, NULL, 0, NULL);
diff --git a/sbc/sbc.h b/sbc/sbc.h
index 5f8a1fc..02ad9fe 100644
--- a/sbc/sbc.h
+++ b/sbc/sbc.h
@@ -84,6 +84,8 @@ typedef struct sbc_struct sbc_t;
 int sbc_init(sbc_t *sbc, unsigned long flags);
 int sbc_reinit(sbc_t *sbc, unsigned long flags);
 int sbc_init_msbc(sbc_t *sbc, unsigned long flags);
+int sbc_init_a2dp(sbc_t *sbc, unsigned long flags, const void *conf,
+							size_t conf_len);
 
 ssize_t sbc_parse(sbc_t *sbc, const void *input, size_t input_len);
 
-- 
1.8.4.2


^ permalink raw reply related

* Re: [PATCH 0/1] HIDP: Add a special case for the Dualshock 4
From: David Herrmann @ 2014-01-21  8:26 UTC (permalink / raw)
  To: Simon Wood; +Cc: Frank Praznik, linux-bluetooth@vger.kernel.org
In-Reply-To: <5ddfeed2ae259064d50f6b08eb15cf5f.squirrel@mungewell.org>

Hi

On Tue, Jan 21, 2014 at 3:00 AM,  <simon@mungewell.org> wrote:
>> This adds a special case in the HIDP core for the Dualshock 4
> controller.
>> The controller only recognizes output reports with the report type 0x52
> and only accepts reports sent via the ctrl channel.
>
> Which part of the system is 'at fault' here, is it simply the DS4 behaving
> incorrectly or that Bluez is not picking up some data or that 'we' are
> just the incorrect method to send the data (in the hid-sony kernel
> driver)?

No-one is at fault. Well, strictly speaking the DS4 is, as it has to
accept SET_REPORT and asynchronous OUTPUT_REPORTs, but it doesn't.
That's quite common. What we actually want is HIDP to provide to
functions, one to call SET_REPORT and one to do the async
OUTPUT_REPORT is currently does.

I implemented this some time ago here:
  http://cgit.freedesktop.org/~dvdhrm/linux/log/?h=hid

Maybe it's time to get that merged. But that hack here is ugly and not
the way to go.

Thanks
David

>
> I noticed that the BT HID spec notes a 'HID control' channel in the
> example descriptor in table 5.3.3 as 'Parameter 0'.
>
> The DS4 gives this in it's SDP report
> --
>         Attribute 0x0004 - ProtocolDescriptorList
>                 Sequence
>                         Sequence
>                                 UUID16 0x0100 - L2CAP
>                                 UINT16 0x0011 <---------- 'HDI Control' PSM 17
>                         Sequence
>                                 UUID16 0x0011 - HIDP
> --
>
> Shouldn't Bluez be remembering this and sending accesses to this PSM in
> the appropriate mode?
>
> Just looking to fix the problem where it really exists, without just
> working around specifically for the DS4.
>
> Simon
>
>

^ permalink raw reply

* Re: [PATCH 0/1] HIDP: Add a special case for the Dualshock 4
From: simon @ 2014-01-21  2:00 UTC (permalink / raw)
  To: Frank Praznik; +Cc: linux-bluetooth, dh.herrmann, simon

[-- Attachment #1: Type: text/plain, Size: 987 bytes --]

> This adds a special case in the HIDP core for the Dualshock 4
controller.
> The controller only recognizes output reports with the report type 0x52
and only accepts reports sent via the ctrl channel.

Which part of the system is 'at fault' here, is it simply the DS4 behaving
incorrectly or that Bluez is not picking up some data or that 'we' are
just the incorrect method to send the data (in the hid-sony kernel
driver)?


I noticed that the BT HID spec notes a 'HID control' channel in the
example descriptor in table 5.3.3 as 'Parameter 0'.

The DS4 gives this in it's SDP report
--
	Attribute 0x0004 - ProtocolDescriptorList
		Sequence
			Sequence
				UUID16 0x0100 - L2CAP
				UINT16 0x0011 <---------- 'HDI Control' PSM 17
			Sequence
				UUID16 0x0011 - HIDP
--

Shouldn't Bluez be remembering this and sending accesses to this PSM in
the appropriate mode?

Just looking to fix the problem where it really exists, without just
working around specifically for the DS4.

Simon



[-- Attachment #2: records_raw.txt --]
[-- Type: text/plain, Size: 3035 bytes --]

Sequence
	Attribute 0x0000 - ServiceRecordHandle
		UINT32 0x00010001
	Attribute 0x0001 - ServiceClassIDList
		Sequence
			UUID16 0x1124 - HumanInterfaceDeviceService (HID)
	Attribute 0x0004 - ProtocolDescriptorList
		Sequence
			Sequence
				UUID16 0x0100 - L2CAP
				UINT16 0x0011
			Sequence
				UUID16 0x0011 - HIDP
	Attribute 0x0006 - LanguageBaseAttributeIDList
		Sequence
			UINT16 0x656e
			UINT16 0x006a
			UINT16 0x0100
	Attribute 0x0009 - BluetoothProfileDescriptorList
		Sequence
			Sequence
				UUID16 0x1124 - HumanInterfaceDeviceService (HID)
				UINT16 0x0100
	Attribute 0x000d - AdditionalProtocolDescriptorLists
		Sequence
			Sequence
				Sequence
					UUID16 0x0100 - L2CAP
					UINT16 0x0013
				Sequence
					UUID16 0x0011 - HIDP
	Attribute 0x0100
		String Wireless Controller\0
	Attribute 0x0101
		String Game Controller\0
	Attribute 0x0102
		String Sony Computer Entertainment\0
	Attribute 0x0200				<===== ?????
		UINT16 0x0100
	Attribute 0x0201				<===== HIDParserVersion 
		UINT16 0x0111
	Attribute 0x0202				<===== HIDDeviceSubclass 
		UINT8 0x08
	Attribute 0x0203				<===== HIDCountryCode 
		UINT8 0x00
	Attribute 0x0204				<===== HIDVirtualCable
		Bool False
	Attribute 0x0205				<===== HIDReconnectInitiate
		Bool True
	Attribute 0x0206				<===== HIDDescriptorList
		Sequence
			Sequence
				UINT8 0x22
				Data 05 01 09 05 a1 01 85 01 09 30 09 31 09 32 09 35 15 00 26 ff 00 75 08 95 04 81 02 09 39 15 00 25 07 75 04 95 01 81 42 05 09 19 01 29 0e 15 00 25 01 75 01 95 0e 81 02 75 06 95 01 81 01 05 01 09 33 09 34 15 00 26 ff 00 75 08 95 02 81 02 06 04 ff 85 02 09 24 95 24 b1 02 85 a3 09 25 95 30 b1 02 85 05 09 26 95 28 b1 02 85 06 09 27 95 34 b1 02 85 07 09 28 95 30 b1 02 85 08 09 29 95 2f b1 02 06 03 ff 85 03 09 21 95 26 b1 02 85 04 09 22 95 2e b1 02 85 f0 09 47 95 3f b1 02 85 f1 09 48 95 3f b1 02 85 f2 09 49 95 0f b1 02 06 00 ff 85 11 09 20 15 00 26 ff 00 75 08 95 4d 81 02 09 21 91 02 85 12 09 22 95 8d 81 02 09 23 91 02 85 13 09 24 95 cd 81 02 09 25 91 02 85 14 09 26 96 0d 01 81 02 09 27 91 02 85 15 09 28 96 4d 01 81 02 09 29 91 02 85 16 09 2a 96 8d 01 81 02 09 2b 91 02 85 17 09 2c 96 cd 01 81 02 09 2d 91 02 85 18 09 2e 96 0d 02 81 02 09 2f 91 02 85 19 09 30 96 22 02 81 02 09 31 91 02 06 80 ff 85 82 09 22 95 3f b1 02 85 83 09 23 b1 02 85 84 09 24 b1 02 85 90 09 30 b1 02 85 91 09 31 b1 02 85 92 09 32 b1 02 85 93 09 33 b1 02 85 a0 09 40 b1 02 85 a4 09 44 b1 02 c0 00
Sequence
	Attribute 0x0000 - ServiceRecordHandle
		UINT32 0x00010002
	Attribute 0x0001 - ServiceClassIDList
		Sequence
			UUID16 0x1200 - PnPInformation
	Attribute 0x0004 - ProtocolDescriptorList
		Sequence
			Sequence
				UUID16 0x0100 - L2CAP
				UINT16 0x0001
			Sequence
				UUID16 0x0001 - SDP
	Attribute 0x0009 - BluetoothProfileDescriptorList
		Sequence
			Sequence
				UUID16 0x1200 - PnPInformation
				UINT16 0x0103
	Attribute 0x0200
		UINT16 0x0103
	Attribute 0x0201
		UINT16 0x054c
	Attribute 0x0202
		UINT16 0x05c4
	Attribute 0x0203
		UINT16 0x0100
	Attribute 0x0204
		Bool True
	Attribute 0x0205
		UINT16 0x0002

^ permalink raw reply

* [PATCH BlueZ] emulator: Fix unaligned memory access compilation errors
From: Anderson Lizardo @ 2014-01-21  1:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo

The u128_xor() function does proper aligned access and accepts void *
arguments, therefore the casts are unnecessary and trigger clang errors.
---
 emulator/smp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/emulator/smp.c b/emulator/smp.c
index 2b4f9a5..cb7cda0 100644
--- a/emulator/smp.c
+++ b/emulator/smp.c
@@ -248,7 +248,7 @@ static int smp_c1(struct smp_conn *conn, uint8_t rnd[16], uint8_t res[16])
 	baswap((bdaddr_t *) (p2 + 10), (bdaddr_t *) conn->ra);
 
 	/* res = r XOR p1 */
-	u128_xor((u128 *) res, (u128 *) rnd, (u128 *) p1);
+	u128_xor(res, rnd, p1);
 
 	/* res = e(k, res) */
 	err = smp_e(conn->smp->alg_sk, conn->tk, res, res);
@@ -256,7 +256,7 @@ static int smp_c1(struct smp_conn *conn, uint8_t rnd[16], uint8_t res[16])
 		return err;
 
 	/* res = res XOR p2 */
-	u128_xor((u128 *) res, (u128 *) res, (u128 *) p2);
+	u128_xor(res, res, p2);
 
 	/* res = e(k, res) */
 	return smp_e(conn->smp->alg_sk, conn->tk, res, res);
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 1/1] HIDP: Add a special case for the Dualshock 4
From: Frank Praznik @ 2014-01-20 23:37 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: dh.herrmann, simon, Frank Praznik
In-Reply-To: <1390261022-3113-1-git-send-email-frank.praznik@oh.rr.com>

The Dualshock 4 wants reports with type 0x52 sent on the ctrlchannel when
running over bluetooth. This adds a special case so that the reports can
be successfully sent.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>

---

 net/bluetooth/hidp/core.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index 292e619..e597e3f 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -360,9 +360,17 @@ static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, s
 	int ret;
 
 	if (report_type == HID_OUTPUT_REPORT) {
-		report_type = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT;
-		return hidp_send_intr_message(session, report_type,
+		/* The Dualshock 4 wants report type 0x52 sent via the ctrl channel */
+		if(hid->vendor == 0x54c && hid->product == 0x5c4) {
+			report_type = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_OUPUT;
+			return hidp_send_ctrl_message(session, report_type,
 					      data, count);
+		}
+		else {
+			report_type = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT;
+			return hidp_send_intr_message(session, report_type,
+					      data, count);
+		}
 	} else if (report_type != HID_FEATURE_REPORT) {
 		return -EINVAL;
 	}
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH 0/1] HIDP: Add a special case for the Dualshock 4
From: Frank Praznik @ 2014-01-20 23:37 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: dh.herrmann, simon

This adds a special case in the HIDP core for the Dualshock 4 controller.
The controller only recognizes output reports with the report type 0x52 and 
only accepts reports sent via the ctrl channel. 

Unfortunately, this was the only way I could send data to the controller. I
looked around for alternatives, but adding a special case to the HIDP system
seemed to be the only way. If there is a way to set a custom report type and 
specify the channel without polluting the core with a device specific quirk 
I'll gladly use it.

^ permalink raw reply

* Re: [PATCHv5 00/11] IPC negative tester
From: Szymon Janc @ 2014-01-20 22:26 UTC (permalink / raw)
  To: Jakub Tyszkowski; +Cc: linux-bluetooth
In-Reply-To: <1390210570-28260-1-git-send-email-jakub.tyszkowski@tieto.com>

Hi Jakub,

On Monday 20 January 2014 10:35:59 Jakub Tyszkowski wrote:
> Following patchset adds IPC negative tester framework along with test cases
> checking IPC's behaviour on daemon side. Expected daemon's behaviour is to
> shut down gracefully in case of receiving invalid IPC data.
> 
> v2 changes:
>   * fixed few indentation issues
>   * fixed missing __attribute__((packed))
>   * fixed amount of data written for 'malformed data' test case
>   * fixed opcode for 'invalid service' test case
>   * added patch(8) with more 'malformed data' cases
> 
> v3 changes:
>   * changed license to GPL
>   * changed 'ipc-negative-tester' name to 'ipc-tester'
> 
> v4 changes:
>   * fixed typo in first test case and last commit's message
>   * fixed daemon shutdown handler function
> 
> v5 changes:
>   * added clean up in case of setup failure
>   * added test execution macro enhancement for easy data creation
>   * added test cases for core BT interfaces (Patches: 9, 10, 11)
> 
> Jakub Tyszkowski (11):
>   android/ipc-tester: Skeleton for ipc negative tester
>   android/ipc-tester: Run daemon in separate process
>   android/ipc-tester: Add IPC initialization
>   android/ipc-tester: Add daemon shutdown handler
>   android/ipc-tester: Add sending test data with ipc
>   android/ipc-tester: Register services
>   android/ipc-tester: Add basic test cases for IPC's daemon site
>   android/ipc-tester: Add more cases for malformed data
>   android/ipc-tester: Add cases for service opcode boundaries
>   android/ipc-tester: Add cases for Core message data size
>   android/ipc-tester: Add cases for BT message data size
> 
>  .gitignore           |   1 +
>  android/Makefile.am  |  17 +
>  android/ipc-tester.c | 868
> +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 886
> insertions(+)
>  create mode 100644 android/ipc-tester.c
> 

All patches in this set have been applied, thanks.

-- 
Szymon K. Janc
szymon.janc@gmail.com

^ permalink raw reply

* Re: [PATCH SBC v3 1/2] sbc: Add sbc_init_a2dp
From: Marcel Holtmann @ 2014-01-20 22:07 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org development
In-Reply-To: <1390246452-29103-1-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

> This adds sbc_init_a2dp that can be used to convert A2DP configuration to
> the internal representation since they are not binary compatible.
> ---
> sbc/sbc.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> sbc/sbc.h |   2 +
> 2 files changed, 146 insertions(+)
> 
> diff --git a/sbc/sbc.c b/sbc/sbc.c
> index c589217..9fd2311 100644
> --- a/sbc/sbc.c
> +++ b/sbc/sbc.c
> @@ -57,6 +57,55 @@
> #define MSBC_SYNCWORD	0xAD
> #define MSBC_BLOCKS	15
> 
> +#define A2DP_SAMPLING_FREQ_16000		(1 << 3)
> +#define A2DP_SAMPLING_FREQ_32000		(1 << 2)
> +#define A2DP_SAMPLING_FREQ_44100		(1 << 1)
> +#define A2DP_SAMPLING_FREQ_48000		1

please use (1 << 0) here.

> +
> +#define A2DP_CHANNEL_MODE_MONO			(1 << 3)
> +#define A2DP_CHANNEL_MODE_DUAL_CHANNEL		(1 << 2)
> +#define A2DP_CHANNEL_MODE_STEREO		(1 << 1)
> +#define A2DP_CHANNEL_MODE_JOINT_STEREO		1
> +
> +#define A2DP_BLOCK_LENGTH_4			(1 << 3)
> +#define A2DP_BLOCK_LENGTH_8			(1 << 2)
> +#define A2DP_BLOCK_LENGTH_12			(1 << 1)
> +#define A2DP_BLOCK_LENGTH_16			1
> +
> +#define A2DP_SUBBANDS_4				(1 << 1)
> +#define A2DP_SUBBANDS_8				1
> +
> +#define A2DP_ALLOCATION_SNR			(1 << 1)
> +#define A2DP_ALLOCATION_LOUDNESS		1
> +
> +#if __BYTE_ORDER == __LITTLE_ENDIAN
> +
> +struct a2dp_sbc {
> +	uint8_t channel_mode:4;
> +	uint8_t frequency:4;
> +	uint8_t allocation_method:2;
> +	uint8_t subbands:2;
> +	uint8_t block_length:4;
> +	uint8_t min_bitpool;
> +	uint8_t max_bitpool;
> +} __attribute__ ((packed));
> +
> +#elif __BYTE_ORDER == __BIG_ENDIAN
> +
> +struct a2dp_sbc {
> +	uint8_t frequency:4;
> +	uint8_t channel_mode:4;
> +	uint8_t block_length:4;
> +	uint8_t subbands:2;
> +	uint8_t allocation_method:2;
> +	uint8_t min_bitpool;
> +	uint8_t max_bitpool;
> +} __attribute__ ((packed));
> +
> +#else
> +#error "Unknown byte order"
> +#endif
> +
> /* This structure contains an unpacked SBC frame.
>    Yes, there is probably quite some unused space herein */
> struct sbc_frame {
> @@ -1046,6 +1095,101 @@ SBC_EXPORT int sbc_init_msbc(sbc_t *sbc, unsigned long flags)
> 	return 0;
> }
> 
> +SBC_EXPORT int sbc_init_a2dp(sbc_t *sbc, unsigned long flags, const void *conf,
> +							size_t conf_len)
> +{
> +	const struct a2dp_sbc *a2dp;
> +	int err;
> +
> +	if (conf_len != sizeof(*a2dp))
> +		return -EINVAL;
> +
> +	err = sbc_init(sbc, flags);
> +	if (err < 0)
> +		return err;
> +
> +	a2dp = conf;
> +
> +	switch (a2dp->frequency) {
> +	case A2DP_SAMPLING_FREQ_16000:
> +		sbc->frequency = SBC_FREQ_16000;
> +		break;
> +	case A2DP_SAMPLING_FREQ_32000:
> +		sbc->frequency = SBC_FREQ_32000;
> +		break;
> +	case A2DP_SAMPLING_FREQ_44100:
> +		sbc->frequency = SBC_FREQ_44100;
> +		break;
> +	case A2DP_SAMPLING_FREQ_48000:
> +		sbc->frequency = SBC_FREQ_48000;
> +		break;
> +	default:
> +		goto failed;
> +	}
> +
> +	switch (a2dp->channel_mode) {
> +	case A2DP_CHANNEL_MODE_MONO:
> +		sbc->mode = SBC_MODE_MONO;
> +		break;
> +	case A2DP_CHANNEL_MODE_DUAL_CHANNEL:
> +		sbc->mode = SBC_MODE_DUAL_CHANNEL;
> +		break;
> +	case A2DP_CHANNEL_MODE_STEREO:
> +		sbc->mode = SBC_MODE_STEREO;
> +		break;
> +	case A2DP_CHANNEL_MODE_JOINT_STEREO:
> +		sbc->mode = SBC_MODE_JOINT_STEREO;
> +		break;
> +	default:
> +		goto failed;
> +	}
> +
> +	switch (a2dp->allocation_method) {
> +	case A2DP_ALLOCATION_SNR:
> +		sbc->allocation = SBC_AM_SNR;
> +		break;
> +	case A2DP_ALLOCATION_LOUDNESS:
> +		sbc->allocation = SBC_AM_LOUDNESS;
> +		break;
> +	default:
> +		goto failed;
> +	}
> +
> +	switch (a2dp->subbands) {
> +	case A2DP_SUBBANDS_4:
> +		sbc->subbands = SBC_SB_4;
> +		break;
> +	case A2DP_SUBBANDS_8:
> +		sbc->subbands = SBC_SB_8;
> +		break;
> +	default:
> +		goto failed;
> +	}
> +
> +	switch (a2dp->block_length) {
> +	case A2DP_BLOCK_LENGTH_4:
> +		sbc->blocks = SBC_BLK_4;
> +		break;
> +	case A2DP_BLOCK_LENGTH_8:
> +		sbc->blocks = SBC_BLK_8;
> +		break;
> +	case A2DP_BLOCK_LENGTH_12:
> +		sbc->blocks = SBC_BLK_12;
> +		break;
> +	case A2DP_BLOCK_LENGTH_16:
> +		sbc->blocks = SBC_BLK_16;
> +		break;
> +	default:
> +		goto failed;
> +	}
> +
> +	return 0;
> +
> +failed:
> +	sbc_finish(sbc);
> +	return -EINVAL;
> +}
> +
> SBC_EXPORT ssize_t sbc_parse(sbc_t *sbc, const void *input, size_t input_len)
> {
> 	return sbc_decode(sbc, input, input_len, NULL, 0, NULL);
> diff --git a/sbc/sbc.h b/sbc/sbc.h
> index 5f8a1fc..02ad9fe 100644
> --- a/sbc/sbc.h
> +++ b/sbc/sbc.h
> @@ -84,6 +84,8 @@ typedef struct sbc_struct sbc_t;
> int sbc_init(sbc_t *sbc, unsigned long flags);
> int sbc_reinit(sbc_t *sbc, unsigned long flags);
> int sbc_init_msbc(sbc_t *sbc, unsigned long flags);
> +int sbc_init_a2dp(sbc_t *sbc, unsigned long flags, const void *conf,
> +							size_t conf_len);

Lets get const void *conf and size_t conf_len both on the second line. It feels looks wise a little bit easier on eyes. 

And then the same for the actual implementation of course. Otherwise, this looks good.

Regards

Marcel


^ permalink raw reply

* Re: [PATCH] obexd/irmc: Fix folder for LUID requests
From: Harald Schmitt @ 2014-01-20 20:55 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CABBYNZLDtvMzbZN8Ju+VpAnFwQc2vVnqkgAeyM73XC8af3XeGw@mail.gmail.com>

Hi Luiz,

Am 20.01.2014 20:29, schrieb Luiz Augusto von Dentz:
> Hi Harald,
> 
> On Mon, Jan 20, 2014 at 7:39 PM, Harald Schmitt <linux@hschmitt.de> wrote:
>> The old macro PB_LUID_FOLDER had the folder luid on the second level:
>> /telecom/luid. But the luid folder occurs per IrMC spec on level three e.g.
>> /telecom/pb/luid. On the second level the object store e.g. pb is specified.
>> This bug was introduced with commit 62ebf8d0f345e7722334d852cf7a010b202647e7.
>> ---
>>  obexd/plugins/irmc.c      | 6 +++---
>>  obexd/plugins/phonebook.h | 2 +-
>>  2 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/obexd/plugins/irmc.c b/obexd/plugins/irmc.c
>> index d343977..d0e98b4 100644
>> --- a/obexd/plugins/irmc.c
>> +++ b/obexd/plugins/irmc.c
>> @@ -326,7 +326,7 @@ static int irmc_open_nt(struct irmc_session *irmc)
>>         return 0;
>>  }
>>
>> -static int irmc_open_luid(struct irmc_session *irmc)
>> +static int irmc_open_pb_luid(struct irmc_session *irmc)
>>  {
>>         if (irmc->buffer == NULL)
>>                 irmc->buffer = g_string_new("");
>> @@ -381,8 +381,8 @@ static void *irmc_open(const char *name, int oflag, mode_t mode, void *context,
>>                 ret = irmc_open_cal(irmc);
>>         else if (g_str_has_prefix(path, PB_NOTES_FOLDER))
>>                 ret = irmc_open_nt(irmc);
>> -       else if (g_str_has_prefix(path, PB_LUID_FOLDER))
>> -               ret = irmc_open_luid(irmc);
>> +       else if (g_str_has_prefix(path, PB_CONTACTS_LUID_FOLDER))
>> +               ret = irmc_open_pb_luid(irmc);
>>         else
>>                 ret = -EBADR;
>>
>> diff --git a/obexd/plugins/phonebook.h b/obexd/plugins/phonebook.h
>> index 441cff2..015c9a3 100644
>> --- a/obexd/plugins/phonebook.h
>> +++ b/obexd/plugins/phonebook.h
>> @@ -37,7 +37,7 @@
>>  #define PB_CALLS_INCOMING_FOLDER "/telecom/ich"
>>  #define PB_CALLS_MISSED_FOLDER "/telecom/mch"
>>  #define PB_CALLS_OUTGOING_FOLDER "/telecom/och"
>> -#define PB_LUID_FOLDER "/telecom/luid"
>> +#define PB_CONTACTS_LUID_FOLDER "/telecom/pb/luid"
>>
>>  #define PB_CONTACTS "/telecom/pb.vcf"
>>  #define PB_CALLS_COMBINED "/telecom/cch.vcf"
>> --
>> 1.8.3.2
> 
> I went ahead and pushed this one, but I preserve much of the define
> and function names used before since I did not see any reason to
> change those.
> 
That's fine with me. I just thought it would be more descriptive.


^ permalink raw reply

* Re: linux-firmware: pull-request Marvell mwifiex-firmware 2014-01-09
From: Ben Hutchings @ 2014-01-20 20:32 UTC (permalink / raw)
  To: Bing Zhao
  Cc: linux-wireless@vger.kernel.org, linux-bluetooth@vger.kernel.org,
	Frank Huang
In-Reply-To: <477F20668A386D41ADCC57781B1F70430F53691FC8@SC-VEXCH1.marvell.com>

On Mon, Jan 20, 2014 at 12:26:47PM -0800, Bing Zhao wrote:
> Hi Ben,
> 
> > > > >  File: mrvl/usb8797_uapsta.bin
> > > > > -Version: 14.69.11.p179
> > > > > +Version: 14.68.29.p26
> > > > [...]
> > > >
> > > > Why are these updates rolling the version number backward?  Did the
> > > > later versions cause regressions?
> > >
> > > These images are newer firmware versions actually.
> > >
> > > The 2nd (69 or 68) and 3rd (11 or 29) numbers in the version string do
> > > not necessarily mean the version increasing or decreasing. Only when
> > > first 3 numbers are fixed, a smaller 4th number will mean that the
> > > version is rolling backward. For examples,
> > 
> > So what do you they mean and why are they in the version number?
> 
> The first 3 numbers altogether identifies the firmware branch/features. The 4th number is the firmware revision.

This is a uniquely confusing way of generating version numbers.  If
only the current 4th part (what you call firmware revision) follows
the usual version ordering, then I think that should be used as the
(public) version number.

Ben.

-- 
Ben Hutchings
Gates has joked that everything goes on and off unexepectedly in the house,
which is run by a high-end PC network built on Windows NT. - Seattle Times

^ permalink raw reply


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