* [PATCH] android/bluetooth: Make sure proper controller mode is set on start
@ 2014-05-08 9:07 Szymon Janc
2014-05-13 16:21 ` Szymon Janc
0 siblings, 1 reply; 2+ messages in thread
From: Szymon Janc @ 2014-05-08 9:07 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
BR/EDR and LE features can be toggled before daemon is started and
we should not assume their state.
---
android/bluetooth.c | 31 ++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 2bc79e2..dbd6102 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -3966,12 +3966,19 @@ static const struct ipc_handler cmd_handlers[] = {
bool bt_bluetooth_register(struct ipc *ipc, uint8_t mode)
{
+ uint32_t missing_settings;
+
DBG("mode 0x%x", mode);
+ missing_settings = adapter.current_settings ^
+ adapter.supported_settings;
+
switch (mode) {
case HAL_MODE_DEFAULT:
- if (!(adapter.current_settings & MGMT_SETTING_LE) &&
- (adapter.supported_settings & MGMT_SETTING_LE))
+ if (missing_settings & MGMT_SETTING_BREDR)
+ set_mode(MGMT_OP_SET_BREDR, 0x01);
+
+ if (missing_settings & MGMT_SETTING_LE)
set_mode(MGMT_OP_SET_LE, 0x01);
break;
case HAL_MODE_LE:
@@ -3990,14 +3997,24 @@ bool bt_bluetooth_register(struct ipc *ipc, uint8_t mode)
set_mode(MGMT_OP_SET_BREDR, 0x00);
break;
case HAL_MODE_BREDR:
- /*
- * BR/EDR Should be enabled on start, if it is not that means
- * there is LE controller only and we should fail
- */
- if (!(adapter.current_settings & MGMT_SETTING_BREDR)) {
+ /* Fail if controller does not support BR/EDR */
+ if (!(adapter.supported_settings & MGMT_SETTING_BREDR)) {
error("BR/EDR Mode not supported");
return false;
}
+
+ /* Enable BR/EDR if it is not enabled */
+ if (missing_settings & MGMT_SETTING_BREDR)
+ set_mode(MGMT_OP_SET_BREDR, 0x01);
+
+ /*
+ * According to Core Spec 4.0 host should not disable LE in
+ * controller if it was enabled (Vol 2. Part E. 7.3.79).
+ * Core Spec 4.1 removed this limitation and chips seem to be
+ * handling this just fine anyway.
+ */
+ if (adapter.current_settings & MGMT_SETTING_LE)
+ set_mode(MGMT_OP_SET_LE, 0x00);
break;
default:
error("Unknown mode 0x%x", mode);
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] android/bluetooth: Make sure proper controller mode is set on start
2014-05-08 9:07 [PATCH] android/bluetooth: Make sure proper controller mode is set on start Szymon Janc
@ 2014-05-13 16:21 ` Szymon Janc
0 siblings, 0 replies; 2+ messages in thread
From: Szymon Janc @ 2014-05-13 16:21 UTC (permalink / raw)
To: linux-bluetooth
On Thursday 08 of May 2014 11:07:13 Szymon Janc wrote:
> BR/EDR and LE features can be toggled before daemon is started and
> we should not assume their state.
> ---
> android/bluetooth.c | 31 ++++++++++++++++++++++++-------
> 1 file changed, 24 insertions(+), 7 deletions(-)
>
> diff --git a/android/bluetooth.c b/android/bluetooth.c
> index 2bc79e2..dbd6102 100644
> --- a/android/bluetooth.c
> +++ b/android/bluetooth.c
Applied.
--
Best regards,
Szymon Janc
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-13 16:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-08 9:07 [PATCH] android/bluetooth: Make sure proper controller mode is set on start Szymon Janc
2014-05-13 16:21 ` Szymon Janc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox