Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 1/5] android/tester: Add SCAN_MODE get prop success test case
From: Grzegorz Kolodziejczyk @ 2013-12-31 14:46 UTC (permalink / raw)
  To: linux-bluetooth

This adds SCAN_MODE get property success test case.
---
 android/android-tester.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/android/android-tester.c b/android/android-tester.c
index c89b97a..d831f74 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -855,6 +855,17 @@ static const struct generic_data bluetooth_getprop_tod_success_test = {
 	.expected_property.len = sizeof(getprop_tod),
 };
 
+static bt_scan_mode_t getprop_scanmode = BT_SCAN_MODE_NONE;
+
+static const struct generic_data bluetooth_getprop_scanmode_success_test = {
+	.expected_hal_cb.adapter_properties_cb = getprop_success_cb,
+	.expected_cb_count = 1,
+	.expected_adapter_status = BT_STATUS_SUCCESS,
+	.expected_property.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
+	.expected_property.val = &getprop_scanmode,
+	.expected_property.len = sizeof(getprop_scanmode),
+};
+
 static const struct generic_data bluetooth_discovery_start_success_test = {
 	.expected_hal_cb.discovery_state_changed_cb =
 						discovery_start_success_cb,
@@ -1256,6 +1267,19 @@ static void test_getprop_tod_success(const void *test_data)
 	check_expected_status(adapter_status);
 }
 
+static void test_getprop_scanmode_success(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	const struct generic_data *test = data->test_data;
+	const bt_property_t prop = test->expected_property;
+	bt_status_t adapter_status;
+
+	init_test_conditions(data);
+
+	adapter_status = data->if_bluetooth->get_adapter_property(prop.type);
+	check_expected_status(adapter_status);
+}
+
 static void test_discovery_start_success(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
@@ -1840,6 +1864,11 @@ int main(int argc, char *argv[])
 					setup_enabled_adapter,
 					test_getprop_tod_success, teardown);
 
+	test_bredrle("Bluetooth Get SCAN_MODE - Success",
+				&bluetooth_getprop_scanmode_success_test,
+				setup_enabled_adapter,
+				test_getprop_scanmode_success, teardown);
+
 	test_bredrle("Bluetooth BREDR Discovery Start - Success",
 				&bluetooth_discovery_start_success_test,
 				setup_enabled_adapter,
-- 
1.8.5.2


^ permalink raw reply related

* Re: [PATCH_v3] android/pan: Add pan sdp record for NAP role
From: Johan Hedberg @ 2013-12-31 13:44 UTC (permalink / raw)
  To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1388494627-1449-1-git-send-email-ravikumar.veeramally@linux.intel.com>

Hi Ravi,

On Tue, Dec 31, 2013, Ravi kumar Veeramally wrote:
> ---
>  android/pan.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 95 insertions(+)

Applied. Thanks.

Johan

^ permalink raw reply

* [PATCH_v3] android/pan: Add pan sdp record for NAP role
From: Ravi kumar Veeramally @ 2013-12-31 12:57 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally

---
 android/pan.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)

diff --git a/android/pan.c b/android/pan.c
index 689c7ef..38e353d 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -44,9 +44,12 @@
 #include "utils.h"
 #include "bluetooth.h"
 
+#define SVC_HINT_NETWORKING 0x02
+
 static bdaddr_t adapter_addr;
 GSList *devices = NULL;
 uint8_t local_role = HAL_PAN_ROLE_NONE;
+static uint32_t record_id = 0;
 
 struct pan_device {
 	char		iface[16];
@@ -335,20 +338,110 @@ static const struct ipc_handler cmd_handlers[] = {
 	{ bt_pan_disconnect, false, sizeof(struct hal_cmd_pan_disconnect) },
 };
 
+static sdp_record_t *pan_record(void)
+{
+	sdp_list_t *svclass, *pfseq, *apseq, *root, *aproto;
+	uuid_t root_uuid, pan, l2cap, bnep;
+	sdp_profile_desc_t profile[1];
+	sdp_list_t *proto[2];
+	sdp_data_t *v, *p;
+	uint16_t psm = BNEP_PSM, version = 0x0100;
+	uint16_t security = 0x0001, type = 0xfffe;
+	uint32_t rate = 0;
+	const char *desc = "Network Access Point", *name = "Network Service";
+	sdp_record_t *record;
+	uint16_t ptype[] = { 0x0800, /* IPv4 */ 0x0806,  /* ARP */ };
+	sdp_data_t *head, *pseq, *data;
+
+	record = sdp_record_alloc();
+	if (!record)
+		return NULL;
+
+	record->attrlist = NULL;
+	record->pattern = NULL;
+
+	sdp_uuid16_create(&pan, NAP_SVCLASS_ID);
+	svclass = sdp_list_append(NULL, &pan);
+	sdp_set_service_classes(record, svclass);
+
+	sdp_uuid16_create(&profile[0].uuid, NAP_PROFILE_ID);
+	profile[0].version = 0x0100;
+	pfseq = sdp_list_append(NULL, &profile[0]);
+	sdp_set_profile_descs(record, pfseq);
+	sdp_set_info_attr(record, name, NULL, desc);
+	sdp_attr_add_new(record, SDP_ATTR_NET_ACCESS_TYPE, SDP_UINT16, &type);
+	sdp_attr_add_new(record, SDP_ATTR_MAX_NET_ACCESSRATE,
+							SDP_UINT32, &rate);
+
+	sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
+	root = sdp_list_append(NULL, &root_uuid);
+	sdp_set_browse_groups(record, root);
+
+	sdp_uuid16_create(&l2cap, L2CAP_UUID);
+	proto[0] = sdp_list_append(NULL, &l2cap);
+	p = sdp_data_alloc(SDP_UINT16, &psm);
+	proto[0] = sdp_list_append(proto[0], p);
+	apseq = sdp_list_append(NULL, proto[0]);
+
+	sdp_uuid16_create(&bnep, BNEP_UUID);
+	proto[1] = sdp_list_append(NULL, &bnep);
+	v = sdp_data_alloc(SDP_UINT16, &version);
+	proto[1] = sdp_list_append(proto[1], v);
+
+	head = sdp_data_alloc(SDP_UINT16, &ptype[0]);
+	data = sdp_data_alloc(SDP_UINT16, &ptype[1]);
+	sdp_seq_append(head, data);
+
+	pseq = sdp_data_alloc(SDP_SEQ16, head);
+	proto[1] = sdp_list_append(proto[1], pseq);
+	apseq = sdp_list_append(apseq, proto[1]);
+	aproto = sdp_list_append(NULL, apseq);
+	sdp_set_access_protos(record, aproto);
+	sdp_add_lang_attr(record);
+	sdp_attr_add_new(record, SDP_ATTR_SECURITY_DESC, SDP_UINT16, &security);
+
+	sdp_data_free(p);
+	sdp_data_free(v);
+	sdp_list_free(apseq, NULL);
+	sdp_list_free(root, NULL);
+	sdp_list_free(aproto, NULL);
+	sdp_list_free(proto[0], NULL);
+	sdp_list_free(proto[1], NULL);
+	sdp_list_free(svclass, NULL);
+	sdp_list_free(pfseq, NULL);
+
+	return record;
+}
+
 bool bt_pan_register(const bdaddr_t *addr)
 {
+	sdp_record_t *rec;
 	int err;
 
 	DBG("");
 
 	bacpy(&adapter_addr, addr);
 
+	rec = pan_record();
+	if (!rec) {
+		error("Failed to allocate PAN record");
+		return false;
+	}
+
+	if (bt_adapter_add_record(rec, SVC_HINT_NETWORKING) < 0) {
+		error("Failed to register PAN record");
+		sdp_record_free(rec);
+		return false;
+	}
+
 	err = bnep_init();
 	if (err) {
 		error("bnep init failed");
+		sdp_record_free(rec);
 		return false;
 	}
 
+	record_id = rec->handle;
 	ipc_register(HAL_SERVICE_ID_PAN, cmd_handlers,
 						G_N_ELEMENTS(cmd_handlers));
 
@@ -362,4 +455,6 @@ void bt_pan_unregister(void)
 	bnep_cleanup();
 
 	ipc_unregister(HAL_SERVICE_ID_PAN);
+	bt_adapter_remove_record(record_id);
+	record_id = 0;
 }
-- 
1.8.3.2


^ permalink raw reply related

* Re: BLE for Android
From: Luiz Augusto von Dentz @ 2013-12-31 12:02 UTC (permalink / raw)
  To: bill dr; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CAHTi60GvSMT54WbHC_aw=qja8ApFKZ4ouUYMDVi7RPuFZf-Urw@mail.gmail.com>

Hi,

On Tue, Dec 31, 2013 at 1:47 PM, bill dr <bilel.dr@gmail.com> wrote:
> Hi,
>
> I am trying to port BLE into a 4.1.1 android device.
> I found that bluez git repository contains an android directory.
> Could you explain me or point me to any link or document that explain
> how to use this directory. Is there any HAL implementation already
> done. Or this directory contains only "bluedroid" code ?
>
> Thank you !

Checkout the README:
https://git.kernel.org/cgit/bluetooth/bluez.git/tree/android/README

It is a clean implementation of bluetooth HAL, so no bluedroid code
bellow the HAL interface, above HAL is considered Android itself even
though it may actually contain bluetooth specific bits here and there.
Btw, we are almost ready to start looking at the BLE HAL.



-- 
Luiz Augusto von Dentz

^ permalink raw reply

* Re: [PATCH] tools/bluetooth-player: Formatting commands
From: Luiz Augusto von Dentz @ 2013-12-31 11:55 UTC (permalink / raw)
  To: Sebastian Chlad; +Cc: linux-bluetooth@vger.kernel.org, Sebastian Chlad
In-Reply-To: <1388413892-10018-1-git-send-email-sebastianx.chlad@intel.com>

Hi Sebastian,

On Mon, Dec 30, 2013 at 4:31 PM, Sebastian Chlad
<sebastianchlad@gmail.com> wrote:
> Formatting commands passed to bluetooth player.
> Whitespace character trimmed.
> ---
>  tools/bluetooth-player.c |    1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/tools/bluetooth-player.c b/tools/bluetooth-player.c
> index 622d391..2afdd17 100644
> --- a/tools/bluetooth-player.c
> +++ b/tools/bluetooth-player.c
> @@ -1080,6 +1080,7 @@ static void rl_handler(char *input)
>         if (!strlen(input))
>                 goto done;
>
> +       g_strstrip(input);
>         add_history(input);
>
>         argv = g_strsplit(input, " ", -1);
> --
> 1.7.9.5

Pushed, I went ahead and pushed a similar fix to obexctl and it seems
bluetoothctl could use the same logic but it doesn't use g_strsplit
and it does in fact check trailing whitespaces:

if (arg) {
    int len = strlen(arg);
    if (len > 0 && arg[len - 1] == ' ')
        arg[len - 1] = '\0';
}

We might be better off with g_strstrip + g_strsplit since we depend on
glib anyway.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* BLE for Android
From: bill dr @ 2013-12-31 11:47 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

I am trying to port BLE into a 4.1.1 android device.
I found that bluez git repository contains an android directory.
Could you explain me or point me to any link or document that explain
how to use this directory. Is there any HAL implementation already
done. Or this directory contains only "bluedroid" code ?

Thank you !

^ permalink raw reply

* [PATCH BlueZ 10/10] android/A2DP: Add stream suspend command/response struct
From: Luiz Augusto von Dentz @ 2013-12-31 11:30 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388489402-8919-1-git-send-email-luiz.dentz@gmail.com>

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

This adds the definitions to stream suspend command and response.
---
 android/a2dp.c    | 10 ++++++++++
 android/hal-msg.h |  5 +++++
 2 files changed, 15 insertions(+)

diff --git a/android/a2dp.c b/android/a2dp.c
index d3c02d6..dc2890c 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -392,6 +392,14 @@ static void bt_stream_resume(const void *buf, uint16_t len)
 							HAL_STATUS_FAILED);
 }
 
+static void bt_stream_suspend(const void *buf, uint16_t len)
+{
+	DBG("Not Implemented");
+
+	audio_ipc_send_rsp(AUDIO_SERVICE_ID_CORE, AUDIO_OP_SUSPEND_STREAM,
+							HAL_STATUS_FAILED);
+}
+
 static const struct ipc_handler audio_handlers[] = {
 	/* AUDIO_OP_OPEN */
 	{ bt_audio_open, true, sizeof(struct audio_cmd_open) },
@@ -403,6 +411,8 @@ static const struct ipc_handler audio_handlers[] = {
 	{ bt_stream_close, false, sizeof(struct audio_cmd_close_stream) },
 	/* AUDIO_OP_RESUME_STREAM */
 	{ bt_stream_resume, false, sizeof(struct audio_cmd_resume_stream) },
+	/* AUDIO_OP_SUSPEND_STREAM */
+	{ bt_stream_suspend, false, sizeof(struct audio_cmd_suspend_stream) },
 };
 
 bool bt_a2dp_register(const bdaddr_t *addr)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 259b687..6b2ec88 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -613,3 +613,8 @@ struct audio_cmd_close_stream {
 struct audio_cmd_resume_stream {
 	uint8_t id;
 } __attribute__((packed));
+
+#define AUDIO_OP_SUSPEND_STREAM			0x06
+struct audio_cmd_suspend_stream {
+	uint8_t id;
+} __attribute__((packed));
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH BlueZ 09/10] android/A2DP: Add stream resume command/response struct
From: Luiz Augusto von Dentz @ 2013-12-31 11:30 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388489402-8919-1-git-send-email-luiz.dentz@gmail.com>

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

This adds the definitions to stream resume command and response.
---
 android/a2dp.c    | 10 ++++++++++
 android/hal-msg.h |  5 +++++
 2 files changed, 15 insertions(+)

diff --git a/android/a2dp.c b/android/a2dp.c
index eac427d..d3c02d6 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -384,6 +384,14 @@ static void bt_stream_close(const void *buf, uint16_t len)
 							HAL_STATUS_FAILED);
 }
 
+static void bt_stream_resume(const void *buf, uint16_t len)
+{
+	DBG("Not Implemented");
+
+	audio_ipc_send_rsp(AUDIO_SERVICE_ID_CORE, AUDIO_OP_RESUME_STREAM,
+							HAL_STATUS_FAILED);
+}
+
 static const struct ipc_handler audio_handlers[] = {
 	/* AUDIO_OP_OPEN */
 	{ bt_audio_open, true, sizeof(struct audio_cmd_open) },
@@ -393,6 +401,8 @@ static const struct ipc_handler audio_handlers[] = {
 	{ bt_stream_open, false, sizeof(struct audio_cmd_open_stream) },
 	/* AUDIO_OP_CLOSE_STREAM */
 	{ bt_stream_close, false, sizeof(struct audio_cmd_close_stream) },
+	/* AUDIO_OP_RESUME_STREAM */
+	{ bt_stream_resume, false, sizeof(struct audio_cmd_resume_stream) },
 };
 
 bool bt_a2dp_register(const bdaddr_t *addr)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index a708157..259b687 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -608,3 +608,8 @@ struct audio_rsp_open_stream {
 struct audio_cmd_close_stream {
 	uint8_t id;
 } __attribute__((packed));
+
+#define AUDIO_OP_RESUME_STREAM			0x05
+struct audio_cmd_resume_stream {
+	uint8_t id;
+} __attribute__((packed));
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH BlueZ 08/10] android/A2DP: Add stream close command/response struct
From: Luiz Augusto von Dentz @ 2013-12-31 11:30 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388489402-8919-1-git-send-email-luiz.dentz@gmail.com>

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

This adds the definitions to stream close command and response.
---
 android/a2dp.c    | 10 ++++++++++
 android/hal-msg.h |  5 +++++
 2 files changed, 15 insertions(+)

diff --git a/android/a2dp.c b/android/a2dp.c
index 7709b15..eac427d 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -376,6 +376,14 @@ static void bt_stream_open(const void *buf, uint16_t len)
 							HAL_STATUS_FAILED);
 }
 
+static void bt_stream_close(const void *buf, uint16_t len)
+{
+	DBG("Not Implemented");
+
+	audio_ipc_send_rsp(AUDIO_SERVICE_ID_CORE, AUDIO_OP_CLOSE_STREAM,
+							HAL_STATUS_FAILED);
+}
+
 static const struct ipc_handler audio_handlers[] = {
 	/* AUDIO_OP_OPEN */
 	{ bt_audio_open, true, sizeof(struct audio_cmd_open) },
@@ -383,6 +391,8 @@ static const struct ipc_handler audio_handlers[] = {
 	{ bt_audio_close, false, sizeof(struct audio_cmd_close) },
 	/* AUDIO_OP_OPEN_STREAM */
 	{ bt_stream_open, false, sizeof(struct audio_cmd_open_stream) },
+	/* AUDIO_OP_CLOSE_STREAM */
+	{ bt_stream_close, false, sizeof(struct audio_cmd_close_stream) },
 };
 
 bool bt_a2dp_register(const bdaddr_t *addr)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index ff62de0..a708157 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -603,3 +603,8 @@ struct audio_rsp_open_stream {
 	uint8_t len;
 	uint8_t data[0];
 } __attribute__((packed));
+
+#define AUDIO_OP_CLOSE_STREAM			0x04
+struct audio_cmd_close_stream {
+	uint8_t id;
+} __attribute__((packed));
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH BlueZ 07/10] android/A2DP: Add stream open command/response struct
From: Luiz Augusto von Dentz @ 2013-12-31 11:29 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388489402-8919-1-git-send-email-luiz.dentz@gmail.com>

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

This adds the definitions to stream open command and response.
---
 android/a2dp.c    | 10 ++++++++++
 android/hal-msg.h | 10 ++++++++++
 2 files changed, 20 insertions(+)

diff --git a/android/a2dp.c b/android/a2dp.c
index e3d58ca..7709b15 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -368,11 +368,21 @@ static void bt_audio_close(const void *buf, uint16_t len)
 							HAL_STATUS_FAILED);
 }
 
+static void bt_stream_open(const void *buf, uint16_t len)
+{
+	DBG("Not Implemented");
+
+	audio_ipc_send_rsp(AUDIO_SERVICE_ID_CORE, AUDIO_OP_OPEN_STREAM,
+							HAL_STATUS_FAILED);
+}
+
 static const struct ipc_handler audio_handlers[] = {
 	/* AUDIO_OP_OPEN */
 	{ bt_audio_open, true, sizeof(struct audio_cmd_open) },
 	/* AUDIO_OP_CLOSE */
 	{ bt_audio_close, false, sizeof(struct audio_cmd_close) },
+	/* AUDIO_OP_OPEN_STREAM */
+	{ bt_stream_open, false, sizeof(struct audio_cmd_open_stream) },
 };
 
 bool bt_a2dp_register(const bdaddr_t *addr)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index d1135df..ff62de0 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -593,3 +593,13 @@ struct audio_rsp_open {
 struct audio_cmd_close {
 	uint8_t id;
 } __attribute__((packed));
+
+#define AUDIO_OP_OPEN_STREAM			0x03
+struct audio_cmd_open_stream {
+	uint8_t id;
+} __attribute__((packed));
+
+struct audio_rsp_open_stream {
+	uint8_t len;
+	uint8_t data[0];
+} __attribute__((packed));
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH BlueZ 06/10] android/A2DP: Add audio close command/response struct
From: Luiz Augusto von Dentz @ 2013-12-31 11:29 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388489402-8919-1-git-send-email-luiz.dentz@gmail.com>

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

This adds the definitions to audio close command and response.
---
 android/a2dp.c    | 10 ++++++++++
 android/hal-msg.h |  5 +++++
 2 files changed, 15 insertions(+)

diff --git a/android/a2dp.c b/android/a2dp.c
index 325c282..e3d58ca 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -360,9 +360,19 @@ static void bt_audio_open(const void *buf, uint16_t len)
 							HAL_STATUS_FAILED);
 }
 
+static void bt_audio_close(const void *buf, uint16_t len)
+{
+	DBG("Not Implemented");
+
+	audio_ipc_send_rsp(AUDIO_SERVICE_ID_CORE, AUDIO_OP_CLOSE,
+							HAL_STATUS_FAILED);
+}
+
 static const struct ipc_handler audio_handlers[] = {
 	/* AUDIO_OP_OPEN */
 	{ bt_audio_open, true, sizeof(struct audio_cmd_open) },
+	/* AUDIO_OP_CLOSE */
+	{ bt_audio_close, false, sizeof(struct audio_cmd_close) },
 };
 
 bool bt_a2dp_register(const bdaddr_t *addr)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 1036988..d1135df 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -588,3 +588,8 @@ struct audio_cmd_open {
 struct audio_rsp_open {
 	uint8_t id;
 } __attribute__((packed));
+
+#define AUDIO_OP_CLOSE				0x02
+struct audio_cmd_close {
+	uint8_t id;
+} __attribute__((packed));
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH BlueZ 05/10] android/A2DP: Add audio open command/response struct
From: Luiz Augusto von Dentz @ 2013-12-31 11:29 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388489402-8919-1-git-send-email-luiz.dentz@gmail.com>

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

This adds the definitions to audio open command and response.
---
 android/a2dp.c            | 10 ++++++++++
 android/audio-ipc-api.txt |  2 +-
 android/hal-msg.h         | 18 ++++++++++++++++++
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/android/a2dp.c b/android/a2dp.c
index 7550644..325c282 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -352,7 +352,17 @@ static sdp_record_t *a2dp_record(void)
 	return record;
 }
 
+static void bt_audio_open(const void *buf, uint16_t len)
+{
+	DBG("Not Implemented");
+
+	audio_ipc_send_rsp(AUDIO_SERVICE_ID_CORE, AUDIO_OP_OPEN,
+							HAL_STATUS_FAILED);
+}
+
 static const struct ipc_handler audio_handlers[] = {
+	/* AUDIO_OP_OPEN */
+	{ bt_audio_open, true, sizeof(struct audio_cmd_open) },
 };
 
 bool bt_a2dp_register(const bdaddr_t *addr)
diff --git a/android/audio-ipc-api.txt b/android/audio-ipc-api.txt
index 1c42800..37a1569 100644
--- a/android/audio-ipc-api.txt
+++ b/android/audio-ipc-api.txt
@@ -49,9 +49,9 @@ Identifier: "audio" (BT_AUDIO_ID)
 
 		Command parameters: Service UUID (16 octets)
 				    Codec ID (1 octet)
+				    Number of codec presets (1 octet)
 				    Codec capabilities length (1 octet)
 				    Codec capabilities (variable)
-				    Number of codec presets (1 octet)
 				    Codec preset # length (1 octet)
 				    Codec preset # configuration (variable)
 				    ...
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 267f9b2..1036988 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -570,3 +570,21 @@ struct hal_ev_a2dp_audio_state {
 	uint8_t state;
 	uint8_t bdaddr[6];
 } __attribute__((packed));
+
+#define AUDIO_OP_OPEN				0x01
+struct audio_preset {
+	uint8_t len;
+	uint8_t data[0];
+} __attribute__((packed));
+
+struct audio_cmd_open {
+	uint16_t uuid;
+	uint8_t codec;
+	uint8_t presets;
+	uint8_t len;
+	struct audio_preset preset[0];
+} __attribute__((packed));
+
+struct audio_rsp_open {
+	uint8_t id;
+} __attribute__((packed));
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH BlueZ 04/10] android/A2DP: Add initial code to handle audio IPC commands
From: Luiz Augusto von Dentz @ 2013-12-31 11:29 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388489402-8919-1-git-send-email-luiz.dentz@gmail.com>

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

This adds initial code to handle audio IPC commands.
---
 android/a2dp.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/android/a2dp.c b/android/a2dp.c
index 581d094..7550644 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -352,6 +352,9 @@ static sdp_record_t *a2dp_record(void)
 	return record;
 }
 
+static const struct ipc_handler audio_handlers[] = {
+};
+
 bool bt_a2dp_register(const bdaddr_t *addr)
 {
 	GError *err = NULL;
@@ -359,6 +362,8 @@ bool bt_a2dp_register(const bdaddr_t *addr)
 
 	DBG("");
 
+	audio_ipc_init();
+
 	bacpy(&adapter_addr, addr);
 
 	server = bt_io_listen(connect_cb, NULL, NULL, NULL, &err,
@@ -388,6 +393,9 @@ bool bt_a2dp_register(const bdaddr_t *addr)
 	ipc_register(HAL_SERVICE_ID_A2DP, cmd_handlers,
 						G_N_ELEMENTS(cmd_handlers));
 
+	audio_ipc_register(AUDIO_SERVICE_ID_CORE, audio_handlers,
+						G_N_ELEMENTS(audio_handlers));
+
 	return true;
 
 fail:
@@ -411,8 +419,9 @@ void bt_a2dp_unregister(void)
 	g_slist_foreach(devices, a2dp_device_disconnected, NULL);
 	devices = NULL;
 
-
 	ipc_unregister(HAL_SERVICE_ID_A2DP);
+	audio_ipc_unregister(AUDIO_SERVICE_ID_CORE);
+
 	bt_adapter_remove_record(record_id);
 	record_id = 0;
 
@@ -421,4 +430,6 @@ void bt_a2dp_unregister(void)
 		g_io_channel_unref(server);
 		server = NULL;
 	}
+
+	audio_ipc_cleanup();
 }
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH BlueZ 03/10] android/ipc: Add audio_ipc_send_rsp and audio_ipc_send_rsp_full
From: Luiz Augusto von Dentz @ 2013-12-31 11:29 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388489402-8919-1-git-send-email-luiz.dentz@gmail.com>

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

These functions can be used to respond to commands recieved over audio
IPC.
---
 android/ipc.c | 24 ++++++++++++++++++++++++
 android/ipc.h |  4 ++++
 2 files changed, 28 insertions(+)

diff --git a/android/ipc.c b/android/ipc.c
index 751284f..d6cb126 100644
--- a/android/ipc.c
+++ b/android/ipc.c
@@ -381,6 +381,30 @@ void audio_ipc_cleanup(void)
 	}
 }
 
+void audio_ipc_send_rsp(uint8_t service_id, uint8_t opcode, uint8_t status)
+{
+	struct hal_status s;
+	int sk;
+
+	sk = g_io_channel_unix_get_fd(audio_io);
+
+	if (status == HAL_STATUS_SUCCESS) {
+		ipc_send(sk, service_id, opcode, 0, NULL, -1);
+		return;
+	}
+
+	s.code = status;
+
+	ipc_send(sk, service_id, HAL_OP_STATUS, sizeof(s), &s, -1);
+}
+
+void audio_ipc_send_rsp_full(uint8_t service_id, uint8_t opcode, uint16_t len,
+							void *param, int fd)
+{
+	ipc_send(g_io_channel_unix_get_fd(audio_io), service_id, opcode, len,
+								param, fd);
+}
+
 void audio_ipc_register(uint8_t service, const struct ipc_handler *handlers,
 								uint8_t size)
 {
diff --git a/android/ipc.h b/android/ipc.h
index 44d5a5d..f224367 100644
--- a/android/ipc.h
+++ b/android/ipc.h
@@ -41,6 +41,10 @@ void ipc_unregister(uint8_t service);
 void audio_ipc_init(void);
 void audio_ipc_cleanup(void);
 
+void audio_ipc_send_rsp(uint8_t service_id, uint8_t opcode, uint8_t status);
+void audio_ipc_send_rsp_full(uint8_t service_id, uint8_t opcode, uint16_t len,
+							void *param, int fd);
+
 void audio_ipc_register(uint8_t service, const struct ipc_handler *handlers,
 								uint8_t size);
 void audio_ipc_unregister(uint8_t service);
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH BlueZ 02/10] android/ipc: Add audio_ipc_register and audio_ipc_unregister
From: Luiz Augusto von Dentz @ 2013-12-31 11:29 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1388489402-8919-1-git-send-email-luiz.dentz@gmail.com>

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

These function can be used to register command handlers for audio IPC.
---
 android/hal-msg.h |  4 ++++
 android/ipc.c     | 14 ++++++++++++++
 android/ipc.h     |  4 ++++
 3 files changed, 22 insertions(+)

diff --git a/android/hal-msg.h b/android/hal-msg.h
index b14eced..267f9b2 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -48,6 +48,10 @@ struct hal_hdr {
 
 #define HAL_SERVICE_ID_MAX HAL_SERVICE_ID_GATT
 
+#define AUDIO_SERVICE_ID_CORE		0
+
+#define AUDIO_SERVICE_ID_MAX AUDIO_SERVICE_ID_CORE
+
 /* Core Service */
 
 #define HAL_STATUS_SUCCESS		0x00
diff --git a/android/ipc.c b/android/ipc.c
index d062d95..751284f 100644
--- a/android/ipc.c
+++ b/android/ipc.c
@@ -46,6 +46,7 @@ struct service_handler {
 };
 
 static struct service_handler services[HAL_SERVICE_ID_MAX + 1];
+static struct service_handler audio_services[AUDIO_SERVICE_ID_MAX + 1];
 
 static GIOChannel *cmd_io = NULL;
 static GIOChannel *notif_io = NULL;
@@ -379,3 +380,16 @@ void audio_ipc_cleanup(void)
 		audio_io = NULL;
 	}
 }
+
+void audio_ipc_register(uint8_t service, const struct ipc_handler *handlers,
+								uint8_t size)
+{
+	audio_services[service].handler = handlers;
+	audio_services[service].size = size;
+}
+
+void audio_ipc_unregister(uint8_t service)
+{
+	audio_services[service].handler = NULL;
+	audio_services[service].size = 0;
+}
diff --git a/android/ipc.h b/android/ipc.h
index 8e92811..44d5a5d 100644
--- a/android/ipc.h
+++ b/android/ipc.h
@@ -40,3 +40,7 @@ void ipc_unregister(uint8_t service);
 
 void audio_ipc_init(void);
 void audio_ipc_cleanup(void);
+
+void audio_ipc_register(uint8_t service, const struct ipc_handler *handlers,
+								uint8_t size);
+void audio_ipc_unregister(uint8_t service);
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH BlueZ 01/10] android/ipc: Add initial code for audio IPC
From: Luiz Augusto von Dentz @ 2013-12-31 11:29 UTC (permalink / raw)
  To: linux-bluetooth

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

This add initial code for listen and accept connections on the abstract
socket defined for the audio IPC.
---
 android/hal-msg.h |  1 +
 android/ipc.c     | 65 +++++++++++++++++++++++++++++++++++++++++++++----------
 android/ipc.h     |  3 +++
 3 files changed, 57 insertions(+), 12 deletions(-)

diff --git a/android/hal-msg.h b/android/hal-msg.h
index c351501..b14eced 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -24,6 +24,7 @@
 #define BLUEZ_HAL_MTU 1024
 
 static const char BLUEZ_HAL_SK_PATH[] = "\0bluez_hal_socket";
+static const char BLUEZ_AUDIO_SK_PATH[] = "\0bluez_audio_socket";
 
 struct hal_hdr {
 	uint8_t  service_id;
diff --git a/android/ipc.c b/android/ipc.c
index 9e8ccc3..d062d95 100644
--- a/android/ipc.c
+++ b/android/ipc.c
@@ -49,8 +49,10 @@ static struct service_handler services[HAL_SERVICE_ID_MAX + 1];
 
 static GIOChannel *cmd_io = NULL;
 static GIOChannel *notif_io = NULL;
+static GIOChannel *audio_io = NULL;
 
-static void ipc_handle_msg(const void *buf, ssize_t len)
+static void ipc_handle_msg(struct service_handler *handlers, const void *buf,
+								ssize_t len)
 {
 	const struct hal_hdr *msg = buf;
 	const struct ipc_handler *handler;
@@ -76,7 +78,7 @@ static void ipc_handle_msg(const void *buf, ssize_t len)
 	}
 
 	/* if service is registered */
-	if (!services[msg->service_id].handler) {
+	if (!handlers[msg->service_id].handler) {
 		error("IPC: unregistered service (0x%x), terminating",
 							msg->service_id);
 		raise(SIGTERM);
@@ -85,7 +87,7 @@ static void ipc_handle_msg(const void *buf, ssize_t len)
 
 	/* if opcode is valid */
 	if (msg->opcode == HAL_OP_STATUS ||
-			msg->opcode > services[msg->service_id].size) {
+			msg->opcode > handlers[msg->service_id].size) {
 		error("IPC: invalid opcode 0x%x for service 0x%x, terminating",
 						msg->opcode, msg->service_id);
 		raise(SIGTERM);
@@ -93,7 +95,7 @@ static void ipc_handle_msg(const void *buf, ssize_t len)
 	}
 
 	/* opcode is table offset + 1 */
-	handler = &services[msg->service_id].handler[msg->opcode - 1];
+	handler = &handlers[msg->service_id].handler[msg->opcode - 1];
 
 	/* if payload size is valid */
 	if ((handler->var_len && handler->data_len > msg->len) ||
@@ -110,6 +112,7 @@ static void ipc_handle_msg(const void *buf, ssize_t len)
 static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond,
 							gpointer user_data)
 {
+	struct service_handler *handlers = user_data;
 	char buf[BLUEZ_HAL_MTU];
 	ssize_t ret;
 	int fd;
@@ -128,7 +131,7 @@ static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond,
 		goto fail;
 	}
 
-	ipc_handle_msg(buf, ret);
+	ipc_handle_msg(handlers, buf, ret);
 	return TRUE;
 
 fail:
@@ -145,7 +148,8 @@ static gboolean notif_watch_cb(GIOChannel *io, GIOCondition cond,
 	return FALSE;
 }
 
-static GIOChannel *connect_hal(GIOFunc connect_cb)
+static GIOChannel *connect_hal(const char *path, size_t size,
+							GIOFunc connect_cb)
 {
 	struct sockaddr_un addr;
 	GIOCondition cond;
@@ -167,11 +171,11 @@ static GIOChannel *connect_hal(GIOFunc connect_cb)
 	memset(&addr, 0, sizeof(addr));
 	addr.sun_family = AF_UNIX;
 
-	memcpy(addr.sun_path, BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH));
+	memcpy(addr.sun_path, path, size);
 
 	if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
-		error("IPC: failed to connect HAL socket: %d (%s)", errno,
-							strerror(errno));
+		error("IPC: failed to connect HAL socket %s: %d (%s)", &path[1],
+							errno, strerror(errno));
 		g_io_channel_unref(io);
 		return NULL;
 	}
@@ -200,7 +204,7 @@ static gboolean notif_connect_cb(GIOChannel *io, GIOCondition cond,
 
 	cond = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
 
-	g_io_add_watch(cmd_io, cond, cmd_watch_cb, NULL);
+	g_io_add_watch(cmd_io, cond, cmd_watch_cb, services);
 
 	info("IPC: successfully connected");
 
@@ -218,7 +222,8 @@ static gboolean cmd_connect_cb(GIOChannel *io, GIOCondition cond,
 		return FALSE;
 	}
 
-	notif_io = connect_hal(notif_connect_cb);
+	notif_io = connect_hal(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH),
+							notif_connect_cb);
 	if (!notif_io)
 		raise(SIGTERM);
 
@@ -227,7 +232,8 @@ static gboolean cmd_connect_cb(GIOChannel *io, GIOCondition cond,
 
 void ipc_init(void)
 {
-	cmd_io = connect_hal(cmd_connect_cb);
+	cmd_io = connect_hal(BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH),
+							cmd_connect_cb);
 	if (!cmd_io)
 		raise(SIGTERM);
 }
@@ -338,3 +344,38 @@ void ipc_unregister(uint8_t service)
 	services[service].handler = NULL;
 	services[service].size = 0;
 }
+
+static gboolean audio_connect_cb(GIOChannel *io, GIOCondition cond,
+							gpointer user_data)
+{
+	DBG("");
+
+	if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
+		error("Audio IPC: socket connect failed");
+		audio_ipc_cleanup();
+		return FALSE;
+	}
+
+	cond = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
+
+	g_io_add_watch(audio_io, cond, cmd_watch_cb, NULL);
+
+	info("Audio IPC: successfully connected");
+
+	return FALSE;
+}
+
+void audio_ipc_init(void)
+{
+	audio_io = connect_hal(BLUEZ_AUDIO_SK_PATH, sizeof(BLUEZ_AUDIO_SK_PATH),
+							audio_connect_cb);
+}
+
+void audio_ipc_cleanup(void)
+{
+	if (audio_io) {
+		g_io_channel_shutdown(audio_io, TRUE, NULL);
+		g_io_channel_unref(audio_io);
+		audio_io = NULL;
+	}
+}
diff --git a/android/ipc.h b/android/ipc.h
index 6cd102b..8e92811 100644
--- a/android/ipc.h
+++ b/android/ipc.h
@@ -37,3 +37,6 @@ void ipc_send_notif(uint8_t service_id, uint8_t opcode,  uint16_t len,
 void ipc_register(uint8_t service, const struct ipc_handler *handlers,
 								uint8_t size);
 void ipc_unregister(uint8_t service);
+
+void audio_ipc_init(void);
+void audio_ipc_cleanup(void);
-- 
1.8.4.2


^ permalink raw reply related

* [PATCH_v2] android/pan: Add pan sdp record for NAP role
From: Ravi kumar Veeramally @ 2013-12-31  9:59 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally

---
 android/pan.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)

diff --git a/android/pan.c b/android/pan.c
index 689c7ef..a4d8977 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -44,9 +44,12 @@
 #include "utils.h"
 #include "bluetooth.h"
 
+#define SVC_HINT_NETWORKING 0x02
+
 static bdaddr_t adapter_addr;
 GSList *devices = NULL;
 uint8_t local_role = HAL_PAN_ROLE_NONE;
+static uint32_t record_id = 0;
 
 struct pan_device {
 	char		iface[16];
@@ -335,20 +338,110 @@ static const struct ipc_handler cmd_handlers[] = {
 	{ bt_pan_disconnect, false, sizeof(struct hal_cmd_pan_disconnect) },
 };
 
+static sdp_record_t *pan_record(void)
+{
+	sdp_list_t *svclass, *pfseq, *apseq, *root, *aproto;
+	uuid_t root_uuid, pan, l2cap, bnep;
+	sdp_profile_desc_t profile[1];
+	sdp_list_t *proto[2];
+	sdp_data_t *v, *p;
+	uint16_t psm = BNEP_PSM, version = 0x0100;
+	uint16_t security = 0x0001, type = 0xfffe;
+	uint32_t rate = 0;
+	const char *desc = "Network service", *name = "bnep";
+	sdp_record_t *record;
+	uint16_t ptype[] = { 0x0800, /* IPv4 */ 0x0806,  /* ARP */ };
+	sdp_data_t *head, *pseq, *data;
+
+	record = sdp_record_alloc();
+	if (!record)
+		return NULL;
+
+	record->attrlist = NULL;
+	record->pattern = NULL;
+
+	sdp_uuid16_create(&pan, NAP_SVCLASS_ID);
+	svclass = sdp_list_append(NULL, &pan);
+	sdp_set_service_classes(record, svclass);
+
+	sdp_uuid16_create(&profile[0].uuid, NAP_PROFILE_ID);
+	profile[0].version = 0x0100;
+	pfseq = sdp_list_append(NULL, &profile[0]);
+	sdp_set_profile_descs(record, pfseq);
+	sdp_set_info_attr(record, name, NULL, desc);
+	sdp_attr_add_new(record, SDP_ATTR_NET_ACCESS_TYPE, SDP_UINT16, &type);
+	sdp_attr_add_new(record, SDP_ATTR_MAX_NET_ACCESSRATE,
+							SDP_UINT32, &rate);
+
+	sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
+	root = sdp_list_append(NULL, &root_uuid);
+	sdp_set_browse_groups(record, root);
+
+	sdp_uuid16_create(&l2cap, L2CAP_UUID);
+	proto[0] = sdp_list_append(NULL, &l2cap);
+	p = sdp_data_alloc(SDP_UINT16, &psm);
+	proto[0] = sdp_list_append(proto[0], p);
+	apseq = sdp_list_append(NULL, proto[0]);
+
+	sdp_uuid16_create(&bnep, BNEP_UUID);
+	proto[1] = sdp_list_append(NULL, &bnep);
+	v = sdp_data_alloc(SDP_UINT16, &version);
+	proto[1] = sdp_list_append(proto[1], v);
+
+	head = sdp_data_alloc(SDP_UINT16, &ptype[0]);
+	data = sdp_data_alloc(SDP_UINT16, &ptype[1]);
+	sdp_seq_append(head, data);
+
+	pseq = sdp_data_alloc(SDP_SEQ16, head);
+	proto[1] = sdp_list_append(proto[1], pseq);
+	apseq = sdp_list_append(apseq, proto[1]);
+	aproto = sdp_list_append(NULL, apseq);
+	sdp_set_access_protos(record, aproto);
+	sdp_add_lang_attr(record);
+	sdp_attr_add_new(record, SDP_ATTR_SECURITY_DESC, SDP_UINT16, &security);
+
+	sdp_data_free(p);
+	sdp_data_free(v);
+	sdp_list_free(apseq, NULL);
+	sdp_list_free(root, NULL);
+	sdp_list_free(aproto, NULL);
+	sdp_list_free(proto[0], NULL);
+	sdp_list_free(proto[1], NULL);
+	sdp_list_free(svclass, NULL);
+	sdp_list_free(pfseq, NULL);
+
+	return record;
+}
+
 bool bt_pan_register(const bdaddr_t *addr)
 {
+	sdp_record_t *rec;
 	int err;
 
 	DBG("");
 
 	bacpy(&adapter_addr, addr);
 
+	rec = pan_record();
+	if (!rec) {
+		error("Failed to allocate PAN record");
+		return false;
+	}
+
+	if (bt_adapter_add_record(rec, SVC_HINT_NETWORKING) < 0) {
+		error("Failed to register PAN record");
+		sdp_record_free(rec);
+		return false;
+	}
+
 	err = bnep_init();
 	if (err) {
 		error("bnep init failed");
+		sdp_record_free(rec);
 		return false;
 	}
 
+	record_id = rec->handle;
 	ipc_register(HAL_SERVICE_ID_PAN, cmd_handlers,
 						G_N_ELEMENTS(cmd_handlers));
 
@@ -362,4 +455,6 @@ void bt_pan_unregister(void)
 	bnep_cleanup();
 
 	ipc_unregister(HAL_SERVICE_ID_PAN);
+	bt_adapter_remove_record(record_id);
+	record_id = 0;
 }
-- 
1.8.3.2


^ permalink raw reply related

* Re: [PATCH 1/4] android/hidhost: Move get_protocol parameter check to daemon
From: Johan Hedberg @ 2013-12-31  9:35 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1388444180-13683-1-git-send-email-szymon.janc@gmail.com>

Hi Szymon,

On Mon, Dec 30, 2013, Szymon Janc wrote:
> HAL library is to be as simple as possible and parameters values should
> be verified by daemon for robustness anyway. Move this check to daemon.
> ---
>  android/hal-hidhost.c | 12 ++----------
>  android/hidhost.c     |  9 +++++++++
>  2 files changed, 11 insertions(+), 10 deletions(-)

All patches in this set have been applied. Thanks.

Johan

^ permalink raw reply

* Re: [RFC 6/6] android/audio: Add listener thread on the Audio HAL socket
From: Luiz Augusto von Dentz @ 2013-12-31  9:08 UTC (permalink / raw)
  To: Lukasz Rymanowski
  Cc: Lukasz Rymanowski, linux-bluetooth@vger.kernel.org, Johan Hedberg
In-Reply-To: <CAN_7+YZs8y-+xcYtJu39MToF5oMu9XGvFfCGCGgacA4doOVM2g@mail.gmail.com>

Hi Lukazs,

On Mon, Dec 30, 2013 at 10:57 PM, Lukasz Rymanowski
<lukasz.rymanowski@gmail.com> wrote:
> Hi Luiz,
>
> On Mon, Dec 30, 2013 at 2:07 PM, Luiz Augusto von Dentz
> <luiz.dentz@gmail.com> wrote:
>> Hi Lukasz,
>>
>> On Mon, Dec 30, 2013 at 1:40 PM, Lukasz Rymanowski
>> <lukasz.rymanowski@tieto.com> wrote:
>>> Hi Luiz,
>>>
>>> On 30 December 2013 12:31, Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote:
>>>> Hi Lukasz,
>>>>
>>>> On Mon, Dec 30, 2013 at 12:17 PM, Lukasz Rymanowski
>>>> <lukasz.rymanowski@tieto.com> wrote:
>>>>> This patch add thread which is reponsible for listen on audio HAL
>>>>> socket, register a2dp endpoint(s) and maintain socket.
>>>>> When bluetooth daemon goes down, HAL audio plugin starts to listen on Audio HAL
>>>>> socket again.
>>>>>
>>>>> ---
>>>>>  android/Makefile.am |   2 +
>>>>>  android/hal-audio.c | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>>>  android/hal-audio.h |  18 +++++++
>>>>>  3 files changed, 165 insertions(+)
>>>>>  create mode 100644 android/hal-audio.h
>>>>>
>>>>> diff --git a/android/Makefile.am b/android/Makefile.am
>>>>> index eaf39bd..bd90c13 100644
>>>>> --- a/android/Makefile.am
>>>>> +++ b/android/Makefile.am
>>>>> @@ -112,6 +112,8 @@ android_libaudio_internal_la_SOURCES = android/hal-audio.c \
>>>>>
>>>>>  android_libaudio_internal_la_CFLAGS = -I$(srcdir)/android
>>>>>
>>>>> +android_libaudio_internal_la_LDFLAGS = -pthread
>>>>> +
>>>>>  endif
>>>>>
>>>>>  EXTRA_DIST += android/Android.mk android/hal-ipc-api.txt android/README \
>>>>> diff --git a/android/hal-audio.c b/android/hal-audio.c
>>>>> index 011a699..0e3bc70 100644
>>>>> --- a/android/hal-audio.c
>>>>> +++ b/android/hal-audio.c
>>>>> @@ -16,18 +16,30 @@
>>>>>   */
>>>>>
>>>>>  #include <errno.h>
>>>>> +#include <pthread.h>
>>>>> +#include <poll.h>
>>>>>  #include <stdio.h>
>>>>>  #include <stdlib.h>
>>>>>  #include <string.h>
>>>>> +#include <sys/socket.h>
>>>>> +#include <sys/un.h>
>>>>> +#include <unistd.h>
>>>>>
>>>>>  #include <hardware/audio.h>
>>>>>  #include <hardware/hardware.h>
>>>>>
>>>>> +#include "hal-audio.h"
>>>>>  #include "hal-log.h"
>>>>>
>>>>>  struct a2dp_audio_dev {
>>>>>         struct audio_hw_device dev;
>>>>>         struct a2dp_stream_out *stream_out;
>>>>> +
>>>>> +       pthread_t bt_watcher;
>>>>> +       pthread_mutex_t hal_sk_mutex;
>>>>> +       pthread_cond_t bt_watcher_cond;
>>>>> +
>>>>> +       int hal_sk;
>>>>>  };
>>>>>
>>>>>  struct a2dp_stream_out {
>>>>> @@ -384,15 +396,135 @@ static int audio_dump(const audio_hw_device_t *device, int fd)
>>>>>
>>>>>  static int audio_close(hw_device_t *device)
>>>>>  {
>>>>> +       struct audio_hw_device *dev = (struct audio_hw_device *)device;
>>>>> +       struct a2dp_audio_dev *a2dp_dev = (struct a2dp_audio_dev *)dev;
>>>>> +
>>
>> Hmm, Im afraid these are not the same pointers as you do  *device =
>> &a2dp_dev->dev.common; so this will probably cause invalid accesses.
>>
> Actually this is same pointer and even I could do here direct cast
> from hw_device_t to a2dp_audio_dev with some comment why I can do it.
> Is that fine?
> Also in audio_open(), to make code less confusing, will do *device =
> (hw_device_t *)a2dp_dev
> Is that fine for you? Not sure how discussion ends or IRC about that
> as I had to go.

It seems the biggest problem with this type of usage of casts is
binary compatibility, but this is a general problem in Android we
can't do anything about and for BlueZ it shouldn't matter that much
since the code should always be available it is just a matter of
recompiling.

-- 
Luiz Augusto von Dentz

^ permalink raw reply

* Re: [PATCH v2] Bluetooth: Add hci_h4p driver
From: Sebastian Reichel @ 2013-12-30 23:42 UTC (permalink / raw)
  To: Pali Rohár, Marcel Holtmann,
	Ивайло Димитров,
	Gustavo F. Padovan, Johan Hedberg, Pavel Machek, linux-kernel,
	linux-bluetooth@vger.kernel.org development
In-Reply-To: <20131230145250.GA16904@earth.universe>

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

Hi again,

On Mon, Dec 30, 2013 at 03:52:51PM +0100, Sebastian Reichel wrote:
> On Mon, Dec 30, 2013 at 03:31:25PM +0100, Pali Rohár wrote:
> > [...] I think that correct commit message is not needed now.

> Wolfram Sang gave a talk about that at 30C3 yesterday. Official
> recordings of his talk are not yet ready, but the live stream
> has been recorded and uploaded to youtube: [...]

The official recording is now available from here:

http://media.ccc.de/browse/congress/2013/30C3_-_5446_-_en_-_saal_g_-_201312282200_-_the_good_the_bad_and_the_ugly_-_linux_kernel_patches_-_wsa.html

-- Sebastian

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* [PATCH 4/4] android/hidhost: Move set_report parameter check to daemon
From: Szymon Janc @ 2013-12-30 22:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1388444180-13683-1-git-send-email-szymon.janc@gmail.com>

HAL library is to be as simple as possible and parameters values should
be verified by daemon for robustness anyway. Move this check to daemon.
---
 android/hal-hidhost.c | 15 ++-------------
 android/hidhost.c     | 10 ++++++++++
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index 371250a..fd3ad2d 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -294,19 +294,8 @@ static bt_status_t set_report(bt_bdaddr_t *bd_addr,
 	cmd->len = strlen(report);
 	memcpy(cmd->data, report, cmd->len);
 
-	switch (report_type) {
-	case BTHH_INPUT_REPORT:
-		cmd->type = HAL_HIDHOST_INPUT_REPORT;
-		break;
-	case BTHH_OUTPUT_REPORT:
-		cmd->type = HAL_HIDHOST_OUTPUT_REPORT;
-		break;
-	case BTHH_FEATURE_REPORT:
-		cmd->type = HAL_HIDHOST_FEATURE_REPORT;
-		break;
-	default:
-		return BT_STATUS_PARM_INVALID;
-	}
+	/* type match IPC type */
+	cmd->type = report_type;
 
 	return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HIDHOST_SET_REPORT,
 				sizeof(*cmd) + cmd->len, buf, 0, NULL, NULL);
diff --git a/android/hidhost.c b/android/hidhost.c
index 1cf85b1..aed9899 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -1064,6 +1064,16 @@ static void bt_hid_set_report(const void *buf, uint16_t len)
 		return;
 	}
 
+	switch (cmd->type) {
+	case HAL_HIDHOST_INPUT_REPORT:
+	case HAL_HIDHOST_OUTPUT_REPORT:
+	case HAL_HIDHOST_FEATURE_REPORT:
+		break;
+	default:
+		status = HAL_STATUS_INVALID;
+		goto failed;
+	}
+
 	android2bdaddr(&cmd->bdaddr, &dst);
 
 	l = g_slist_find_custom(devices, &dst, device_cmp);
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 3/4] android/hidhost: Move get_report parameter check to daemon
From: Szymon Janc @ 2013-12-30 22:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1388444180-13683-1-git-send-email-szymon.janc@gmail.com>

HAL library is to be as simple as possible and parameters values should
be verified by daemon for robustness anyway. Move this check to daemon.
---
 android/hal-hidhost.c | 15 ++-------------
 android/hidhost.c     | 10 ++++++++++
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index b331145..371250a 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -268,19 +268,8 @@ static bt_status_t get_report(bt_bdaddr_t *bd_addr,
 	cmd.id = report_id;
 	cmd.buf_size = buffer_size;
 
-	switch (report_type) {
-	case BTHH_INPUT_REPORT:
-		cmd.type = HAL_HIDHOST_INPUT_REPORT;
-		break;
-	case BTHH_OUTPUT_REPORT:
-		cmd.type = HAL_HIDHOST_OUTPUT_REPORT;
-		break;
-	case BTHH_FEATURE_REPORT:
-		cmd.type = HAL_HIDHOST_FEATURE_REPORT;
-		break;
-	default:
-		return BT_STATUS_PARM_INVALID;
-	}
+	/* type match IPC type */
+	cmd.type = report_type;
 
 	return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HIDHOST_GET_REPORT,
 			sizeof(cmd), &cmd, 0, NULL, NULL);
diff --git a/android/hidhost.c b/android/hidhost.c
index 76e65b8..1cf85b1 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -991,6 +991,16 @@ static void bt_hid_get_report(const void *buf, uint16_t len)
 
 	DBG("");
 
+	switch (cmd->type) {
+	case HAL_HIDHOST_INPUT_REPORT:
+	case HAL_HIDHOST_OUTPUT_REPORT:
+	case HAL_HIDHOST_FEATURE_REPORT:
+		break;
+	default:
+		status = HAL_STATUS_INVALID;
+		goto failed;
+	}
+
 	android2bdaddr(&cmd->bdaddr, &dst);
 
 	l = g_slist_find_custom(devices, &dst, device_cmp);
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 2/4] android/hidhost: Move set_protocol parameter check to daemon
From: Szymon Janc @ 2013-12-30 22:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1388444180-13683-1-git-send-email-szymon.janc@gmail.com>

HAL library is to be as simple as possible and parameters values should
be verified by daemon for robustness anyway. Move this check to daemon.
---
 android/hal-hidhost.c | 12 ++----------
 android/hidhost.c     |  9 +++++++++
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index 5d05f9b..b331145 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -241,16 +241,8 @@ static bt_status_t set_protocol(bt_bdaddr_t *bd_addr,
 
 	memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
 
-	switch (protocol_mode) {
-	case BTHH_REPORT_MODE:
-		cmd.mode = HAL_HIDHOST_REPORT_PROTOCOL;
-		break;
-	case BTHH_BOOT_MODE:
-		cmd.mode = HAL_HIDHOST_BOOT_PROTOCOL;
-		break;
-	default:
-		return BT_STATUS_PARM_INVALID;
-	}
+	/* type match IPC type */
+	cmd.mode = protocol_mode;
 
 	return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST,
 				HAL_OP_HIDHOST_SET_PROTOCOL,
diff --git a/android/hidhost.c b/android/hidhost.c
index 4635e53..76e65b8 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -935,6 +935,15 @@ static void bt_hid_set_protocol(const void *buf, uint16_t len)
 
 	DBG("");
 
+	switch (cmd->mode) {
+	case HAL_HIDHOST_REPORT_PROTOCOL:
+	case HAL_HIDHOST_BOOT_PROTOCOL:
+		break;
+	default:
+		status = HAL_STATUS_INVALID;
+		goto failed;
+	}
+
 	android2bdaddr(&cmd->bdaddr, &dst);
 
 	l = g_slist_find_custom(devices, &dst, device_cmp);
-- 
1.8.5.2


^ permalink raw reply related

* [PATCH 1/4] android/hidhost: Move get_protocol parameter check to daemon
From: Szymon Janc @ 2013-12-30 22:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

HAL library is to be as simple as possible and parameters values should
be verified by daemon for robustness anyway. Move this check to daemon.
---
 android/hal-hidhost.c | 12 ++----------
 android/hidhost.c     |  9 +++++++++
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index 6a6b682..5d05f9b 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -218,16 +218,8 @@ static bt_status_t get_protocol(bt_bdaddr_t *bd_addr,
 
 	memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
 
-	switch (protocol_mode) {
-	case BTHH_REPORT_MODE:
-		cmd.mode = HAL_HIDHOST_REPORT_PROTOCOL;
-		break;
-	case BTHH_BOOT_MODE:
-		cmd.mode = HAL_HIDHOST_BOOT_PROTOCOL;
-		break;
-	default:
-		return BT_STATUS_PARM_INVALID;
-	}
+	/* type match IPC type */
+	cmd.mode = protocol_mode;
 
 	return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST,
 				HAL_OP_HIDHOST_GET_PROTOCOL,
diff --git a/android/hidhost.c b/android/hidhost.c
index 0e0391a..4635e53 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -880,6 +880,15 @@ static void bt_hid_get_protocol(const void *buf, uint16_t len)
 
 	DBG("");
 
+	switch (cmd->mode) {
+	case HAL_HIDHOST_REPORT_PROTOCOL:
+	case HAL_HIDHOST_BOOT_PROTOCOL:
+		break;
+	default:
+		status = HAL_STATUS_INVALID;
+		goto failed;
+	}
+
 	android2bdaddr(&cmd->bdaddr, &dst);
 
 	l = g_slist_find_custom(devices, &dst, device_cmp);
-- 
1.8.5.2


^ permalink raw reply related

* Re: [PATCH v2] Bluetooth: Add hci_h4p driver
From: Pavel Machek @ 2013-12-30 22:48 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Pali Rohár,
	Ивайло Димитров,
	Gustavo F. Padovan, Johan Hedberg, linux-kernel,
	linux-bluetooth@vger.kernel.org development, Ville Tervo,
	Sebastian Reichel
In-Reply-To: <C8D1F470-7964-4EAC-82E0-D53CF54DE086@holtmann.org>

Hi!

> > +#define NBT_DBG(fmt, arg...) \
> > +		pr_debug("%s: " fmt "" , __func__ , ## arg)
> > +
> > +#define NBT_DBG_FW(fmt, arg...) \
> > +		pr_debug("%s: " fmt "" , __func__ , ## arg)
> > +
> > +#define NBT_DBG_POWER(fmt, arg...) \
> > +		pr_debug("%s: " fmt "" , __func__ , ## arg)
> > +
> > +#define NBT_DBG_TRANSFER(fmt, arg...) \
> > +		pr_debug("%s: " fmt "" , __func__ , ## arg)
> > +
> > +#define NBT_DBG_TRANSFER_NF(fmt, arg...) \
> > +		pr_debug(fmt "" , ## arg)
> > +
> > +#define NBT_DBG_DMA(fmt, arg...) \
> > +		pr_debug("%s: " fmt "" , __func__ , ## arg)
> 
> 
> I rather not introduce another ton of new debug helpers. Either use the BT_ ones or just spell this out if you need something that is not common.
> 

It looks like idea here is that separate macros may be defined out
separately.

That debugging level should not be neccessary these days, so:

Regards,
							Pavel

commit 1978475804807d6e17015c8aa53ad5606a82a71c
Author: Pavel <pavel@ucw.cz>
Date:   Mon Dec 30 23:47:00 2013 +0100

    Remove custom debugging helpers.
    
    Signed-off-by: Pavel Machek <pavel@ucw.cz>

diff --git a/drivers/bluetooth/hci_h4p.h b/drivers/bluetooth/hci_h4p.h
index d1d313b..a2174ea 100644
--- a/drivers/bluetooth/hci_h4p.h
+++ b/drivers/bluetooth/hci_h4p.h
@@ -1,10 +1,8 @@
 /*
- * This file is part of hci_h4p bluetooth driver
+ * This file is part of Nokia H4P bluetooth driver
  *
  * Copyright (C) 2005-2008 Nokia Corporation.
  *
- * Contact: Ville Tervo <ville.tervo@nokia.com>
- *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * version 2 as published by the Free Software Foundation.
@@ -48,24 +46,6 @@
 #define UART_OMAP_SYSC_NO_IDLE		(1 << UART_OMAP_SYSC_IDLEMODE)
 #define UART_OMAP_SYSC_SMART_IDLE	(2 << UART_OMAP_SYSC_IDLEMODE)
 
-#define NBT_DBG(fmt, arg...) \
-		pr_debug("%s: " fmt "" , __func__ , ## arg)
-
-#define NBT_DBG_FW(fmt, arg...) \
-		pr_debug("%s: " fmt "" , __func__ , ## arg)
-
-#define NBT_DBG_POWER(fmt, arg...) \
-		pr_debug("%s: " fmt "" , __func__ , ## arg)
-
-#define NBT_DBG_TRANSFER(fmt, arg...) \
-		pr_debug("%s: " fmt "" , __func__ , ## arg)
-
-#define NBT_DBG_TRANSFER_NF(fmt, arg...) \
-		pr_debug(fmt "" , ## arg)
-
-#define NBT_DBG_DMA(fmt, arg...) \
-		pr_debug("%s: " fmt "" , __func__ , ## arg)
-
 #define H4P_TRANSFER_MODE		1
 #define H4P_SCHED_TRANSFER_MODE		2
 #define H4P_ACTIVE_MODE			3
diff --git a/drivers/bluetooth/nokia_core.c b/drivers/bluetooth/nokia_core.c
index 6dbd3b7..85dd106 100644
--- a/drivers/bluetooth/nokia_core.c
+++ b/drivers/bluetooth/nokia_core.c
@@ -54,7 +54,7 @@ static void hci_h4p_set_clk(struct hci_h4p_info *info, int *clock, int enable)
 
 	spin_lock_irqsave(&info->clocks_lock, flags);
 	if (enable && !*clock) {
-		NBT_DBG_POWER("Enabling %p\n", clock);
+		BT_DBG("Enabling %p\n", clock);
 		clk_prepare_enable(info->uart_fclk);
 		clk_prepare_enable(info->uart_iclk);
 		if (atomic_read(&info->clk_users) == 0)
@@ -63,7 +63,7 @@ static void hci_h4p_set_clk(struct hci_h4p_info *info, int *clock, int enable)
 	}
 
 	if (!enable && *clock) {
-		NBT_DBG_POWER("Disabling %p\n", clock);
+		BT_DBG("Disabling %p\n", clock);
 		if (atomic_dec_and_test(&info->clk_users))
 			hci_h4p_store_regs(info);
 		clk_disable_unprepare(info->uart_fclk);
@@ -114,7 +114,7 @@ static inline void h4p_schedule_pm(struct hci_h4p_info *info)
 
 static void hci_h4p_disable_tx(struct hci_h4p_info *info)
 {
-	NBT_DBG_POWER("\n");
+	BT_DBG("\n");
 
 	if (!info->pm_enabled)
 		return;
@@ -130,7 +130,7 @@ static void hci_h4p_disable_tx(struct hci_h4p_info *info)
 void hci_h4p_enable_tx(struct hci_h4p_info *info)
 {
 	unsigned long flags;
-	NBT_DBG_POWER("\n");
+	BT_DBG("\n");
 
 	if (!info->pm_enabled)
 		return;
@@ -197,7 +197,7 @@ int hci_h4p_send_alive_packet(struct hci_h4p_info *info)
 	unsigned long flags;
 	int len;
 
-	NBT_DBG("Sending alive packet\n");
+	BT_DBG("Sending alive packet\n");
 
 	len = H4_TYPE_SIZE + sizeof(*hdr) + sizeof(*pkt);
 	skb = bt_skb_alloc(len, GFP_KERNEL);
@@ -217,7 +217,7 @@ int hci_h4p_send_alive_packet(struct hci_h4p_info *info)
 		     UART_IER_THRI);
 	spin_unlock_irqrestore(&info->lock, flags);
 
-	NBT_DBG("Alive packet sent\n");
+	BT_DBG("Alive packet sent\n");
 
 	return 0;
 }
@@ -228,7 +228,7 @@ static void hci_h4p_alive_packet(struct hci_h4p_info *info,
 	struct hci_h4p_alive_hdr *hdr;
 	struct hci_h4p_alive_pkt *pkt;
 
-	NBT_DBG("Received alive packet\n");
+	BT_DBG("Received alive packet\n");
 	hdr = (struct hci_h4p_alive_hdr *)skb->data;
 	if (hdr->dlen != sizeof(*pkt)) {
 		dev_err(info->dev, "Corrupted alive message\n");
@@ -256,7 +256,7 @@ static int hci_h4p_send_negotiation(struct hci_h4p_info *info)
 	int err, len;
 	u16 sysclk;
 
-	NBT_DBG("Sending negotiation..\n");
+	BT_DBG("Sending negotiation..\n");
 
 	switch (info->bt_sysclk) {
 	case 1:
@@ -326,7 +326,7 @@ static int hci_h4p_send_negotiation(struct hci_h4p_info *info)
 	if (info->init_error < 0)
 		return info->init_error;
 
-	NBT_DBG("Negotiation succesful\n");
+	BT_DBG("Negotiation succesful\n");
 	return 0;
 }
 
@@ -448,14 +448,14 @@ static inline void hci_h4p_recv_frame(struct hci_h4p_info *info,
 		}
 
 		if (!test_bit(HCI_UP, &info->hdev->flags)) {
-			NBT_DBG("fw_event\n");
+			BT_DBG("fw_event\n");
 			hci_h4p_parse_fw_event(info, skb);
 			return;
 		}
 	}
 
 	hci_recv_frame(skb);
-	NBT_DBG("Frame sent to upper layer\n");
+	BT_DBG("Frame sent to upper layer\n");
 }
 
 static inline void hci_h4p_handle_byte(struct hci_h4p_info *info, u8 byte)
@@ -514,8 +514,8 @@ static void hci_h4p_rx_tasklet(unsigned long data)
 	u8 byte;
 	struct hci_h4p_info *info = (struct hci_h4p_info *)data;
 
-	NBT_DBG("tasklet woke up\n");
-	NBT_DBG_TRANSFER("rx_tasklet woke up\ndata ");
+	BT_DBG("tasklet woke up\n");
+	BT_DBG("rx_tasklet woke up\ndata ");
 
 	while (hci_h4p_inb(info, UART_LSR) & UART_LSR_DR) {
 		byte = hci_h4p_inb(info, UART_RX);
@@ -535,7 +535,7 @@ static void hci_h4p_rx_tasklet(unsigned long data)
 			info->rx_skb->dev = (void *)info->hdev;
 		}
 		info->hdev->stat.byte_rx++;
-		NBT_DBG_TRANSFER_NF("0x%.2x  ", byte);
+		pr_debug("0x%.2x  ", byte);
 		hci_h4p_handle_byte(info, byte);
 	}
 
@@ -551,8 +551,8 @@ static void hci_h4p_rx_tasklet(unsigned long data)
 	}
 
 finish_rx:
-	NBT_DBG_TRANSFER_NF("\n");
-	NBT_DBG("rx_ended\n");
+	pr_debug("\n");
+	BT_DBG("rx_ended\n");
 }
 
 static void hci_h4p_tx_tasklet(unsigned long data)
@@ -561,8 +561,8 @@ static void hci_h4p_tx_tasklet(unsigned long data)
 	struct sk_buff *skb;
 	struct hci_h4p_info *info = (struct hci_h4p_info *)data;
 
-	NBT_DBG("tasklet woke up\n");
-	NBT_DBG_TRANSFER("tx_tasklet woke up\n data ");
+	BT_DBG("tasklet woke up\n");
+	BT_DBG("tx_tasklet woke up\n data ");
 
 	if (info->autorts != info->rx_enabled) {
 		if (hci_h4p_inb(info, UART_LSR) & UART_LSR_TEMT) {
@@ -587,7 +587,7 @@ static void hci_h4p_tx_tasklet(unsigned long data)
 	skb = skb_dequeue(&info->txq);
 	if (!skb) {
 		/* No data in buffer */
-		NBT_DBG("skb ready\n");
+		BT_DBG("skb ready\n");
 		if (hci_h4p_inb(info, UART_LSR) & UART_LSR_TEMT) {
 			hci_h4p_outb(info, UART_IER,
 				     hci_h4p_inb(info, UART_IER) &
@@ -605,13 +605,13 @@ static void hci_h4p_tx_tasklet(unsigned long data)
 	/* Copy data to tx fifo */
 	while (!(hci_h4p_inb(info, UART_OMAP_SSR) & UART_OMAP_SSR_TXFULL) &&
 	       (sent < skb->len)) {
-		NBT_DBG_TRANSFER_NF("0x%.2x ", skb->data[sent]);
+		pr_debug("0x%.2x ", skb->data[sent]);
 		hci_h4p_outb(info, UART_TX, skb->data[sent]);
 		sent++;
 	}
 
 	info->hdev->stat.byte_tx += sent;
-	NBT_DBG_TRANSFER_NF("\n");
+	pr_debug("\n");
 	if (skb->len == sent) {
 		kfree_skb(skb);
 	} else {
@@ -642,7 +642,7 @@ static irqreturn_t hci_h4p_interrupt(int irq, void *data)
 	if (iir & UART_IIR_NO_INT)
 		return IRQ_HANDLED;
 
-	NBT_DBG("In interrupt handler iir 0x%.2x\n", iir);
+	BT_DBG("In interrupt handler iir 0x%.2x\n", iir);
 
 	iir &= UART_IIR_ID;
 
@@ -688,7 +688,7 @@ static irqreturn_t hci_h4p_wakeup_interrupt(int irq, void *dev_inst)
 		return IRQ_HANDLED;
 	}
 
-	NBT_DBG_POWER("gpio interrupt %d\n", should_wakeup);
+	BT_DBG("gpio interrupt %d\n", should_wakeup);
 
 	/* Check if wee have missed some interrupts */
 	if (info->rx_enabled == should_wakeup)
@@ -970,7 +970,7 @@ again:
 	info->alive_cmd_skb = NULL;
 	set_bit(HCI_RUNNING, &hdev->flags);
 
-	NBT_DBG("hci up and running\n");
+	BT_DBG("hci up and running\n");
 	return 0;
 
 err_clean:
@@ -1030,7 +1030,7 @@ static int hci_h4p_hci_send_frame(struct sk_buff *skb)
 		return -ENODEV;
 	}
 
-	NBT_DBG("dev %p, skb %p\n", hdev, skb);
+	BT_DBG("dev %p, skb %p\n", hdev, skb);
 
 	info = hci_get_drvdata(hdev);
 
@@ -1188,10 +1188,10 @@ static int hci_h4p_probe(struct platform_device *pdev)
 	info->reset_gpio_shared = bt_plat_data->reset_gpio_shared;
 	info->bt_sysclk = bt_plat_data->bt_sysclk;
 
-	NBT_DBG("RESET gpio: %d\n", info->reset_gpio);
-	NBT_DBG("BTWU gpio: %d\n", info->bt_wakeup_gpio);
-	NBT_DBG("HOSTWU gpio: %d\n", info->host_wakeup_gpio);
-	NBT_DBG("sysclk: %d\n", info->bt_sysclk);
+	BT_DBG("RESET gpio: %d\n", info->reset_gpio);
+	BT_DBG("BTWU gpio: %d\n", info->bt_wakeup_gpio);
+	BT_DBG("HOSTWU gpio: %d\n", info->host_wakeup_gpio);
+	BT_DBG("sysclk: %d\n", info->bt_sysclk);
 
 	init_completion(&info->test_completion);
 	complete_all(&info->test_completion);
diff --git a/drivers/bluetooth/nokia_fw-bcm.c b/drivers/bluetooth/nokia_fw-bcm.c
index 9c01a6a..0cf8535 100644
--- a/drivers/bluetooth/nokia_fw-bcm.c
+++ b/drivers/bluetooth/nokia_fw-bcm.c
@@ -73,7 +73,7 @@ void hci_h4p_bcm_parse_fw_event(struct hci_h4p_info *info, struct sk_buff *skb)
 	}
 
 	if (fw_skb->data[1] == 0x01 && fw_skb->data[2] == 0xfc && fw_skb->len >= 10) {
-		NBT_DBG_FW("Setting bluetooth address\n");
+		BT_DBG("Setting bluetooth address\n");
 		err = hci_h4p_bcm_set_bdaddr(info, fw_skb);
 		if (err < 0) {
 			kfree_skb(fw_skb);
@@ -99,7 +99,7 @@ int hci_h4p_bcm_send_fw(struct hci_h4p_info *info,
 
 	info->fw_error = 0;
 
-	NBT_DBG_FW("Sending firmware\n");
+	BT_DBG("Sending firmware\n");
 
 	time = jiffies;
 
@@ -108,7 +108,7 @@ int hci_h4p_bcm_send_fw(struct hci_h4p_info *info,
 	if (!skb)
 		return -ENODATA;
 
-	NBT_DBG_FW("Sending commands\n");
+	BT_DBG("Sending commands\n");
 
 	/*
 	 * Disable smart-idle as UART TX interrupts
@@ -135,7 +135,7 @@ int hci_h4p_bcm_send_fw(struct hci_h4p_info *info,
 		return -EPROTO;
 	}
 
-	NBT_DBG_FW("Firmware sent in %d msecs\n",
+	BT_DBG("Firmware sent in %d msecs\n",
 		   jiffies_to_msecs(jiffies-time));
 
 	hci_h4p_set_auto_ctsrts(info, 0, UART_EFR_RTS);
diff --git a/drivers/bluetooth/nokia_fw-csr.c b/drivers/bluetooth/nokia_fw-csr.c
index 23c5fc5..886b721 100644
--- a/drivers/bluetooth/nokia_fw-csr.c
+++ b/drivers/bluetooth/nokia_fw-csr.c
@@ -53,7 +53,7 @@ int hci_h4p_bc4_send_fw(struct hci_h4p_info *info,
 
 	info->fw_error = 0;
 
-	NBT_DBG_FW("Sending firmware\n");
+	BT_DBG("Sending firmware\n");
 	skb = skb_dequeue(fw_queue);
 
 	if (!skb)
@@ -90,7 +90,7 @@ int hci_h4p_bc4_send_fw(struct hci_h4p_info *info,
 	}
 
 	for (count = 1; ; count++) {
-		NBT_DBG_FW("Sending firmware command %d\n", count);
+		BT_DBG("Sending firmware command %d\n", count);
 		init_completion(&info->fw_completion);
 		skb_queue_tail(&info->txq, skb);
 		spin_lock_irqsave(&info->lock, flags);
diff --git a/drivers/bluetooth/nokia_fw-ti1273.c b/drivers/bluetooth/nokia_fw-ti1273.c
index 2825504..fd82494 100644
--- a/drivers/bluetooth/nokia_fw-ti1273.c
+++ b/drivers/bluetooth/nokia_fw-ti1273.c
@@ -63,7 +63,7 @@ int hci_h4p_ti1273_send_fw(struct hci_h4p_info *info,
 
 	info->fw_error = 0;
 
-	NBT_DBG_FW("Sending firmware\n");
+	BT_DBG("Sending firmware\n");
 
 	time = jiffies;
 
@@ -72,7 +72,7 @@ int hci_h4p_ti1273_send_fw(struct hci_h4p_info *info,
 	if (!skb)
 		return -ENODATA;
 
-	NBT_DBG_FW("Sending commands\n");
+	BT_DBG("Sending commands\n");
 	/* Check if this is bd_address packet */
 	init_completion(&info->fw_completion);
 	hci_h4p_smart_idle(info, 0);
@@ -93,7 +93,7 @@ int hci_h4p_ti1273_send_fw(struct hci_h4p_info *info,
 		return -EPROTO;
 	}
 
-	NBT_DBG_FW("Firmware sent in %d msecs\n",
+	BT_DBG("Firmware sent in %d msecs\n",
 		   jiffies_to_msecs(jiffies-time));
 
 	hci_h4p_set_auto_ctsrts(info, 0, UART_EFR_RTS);
diff --git a/drivers/bluetooth/nokia_fw.c b/drivers/bluetooth/nokia_fw.c
index b3d39f9..f69efd8 100644
--- a/drivers/bluetooth/nokia_fw.c
+++ b/drivers/bluetooth/nokia_fw.c
@@ -38,7 +38,7 @@ static int hci_h4p_open_firmware(struct hci_h4p_info *info,
 	int err;
 
 	fw_pos = 0;
-	NBT_DBG_FW("Opening firmware man_id 0x%.2x ver_id 0x%.2x\n",
+	BT_DBG("Opening firmware man_id 0x%.2x ver_id 0x%.2x\n",
 			info->man_id, info->ver_id);
 	switch (info->man_id) {
 	case H4P_ID_TI1271:
diff --git a/drivers/bluetooth/nokia_uart.c b/drivers/bluetooth/nokia_uart.c
index fd94a98..c19b8d2 100644
--- a/drivers/bluetooth/nokia_uart.c
+++ b/drivers/bluetooth/nokia_uart.c
@@ -100,7 +100,7 @@ void hci_h4p_change_speed(struct hci_h4p_info *info, unsigned long speed)
 	unsigned int divisor;
 	u8 lcr, mdr1;
 
-	NBT_DBG("Setting speed %lu\n", speed);
+	BT_DBG("Setting speed %lu\n", speed);
 
 	if (speed >= 460800) {
 		divisor = UART_CLOCK / 13 / speed;


									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ 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