From: "Frédéric Dalleau" <frederic.dalleau@linux.intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: "Frédéric Dalleau" <frederic.dalleau@linux.intel.com>
Subject: [PATCH v8 7/8] Bluetooth: SCO connection fallback
Date: Fri, 5 Jul 2013 17:01:41 +0200 [thread overview]
Message-ID: <1373036503-1349-8-git-send-email-frederic.dalleau@linux.intel.com> (raw)
In-Reply-To: <1373036503-1349-1-git-send-email-frederic.dalleau@linux.intel.com>
When initiating a transparent eSCO connection, make use of T2 settings at
first try. T2 is the recommended settings from HFP 1.6 WideBand Speech. Upon
connection failure, try T1 settings.
When CVSD is requested and eSCO is supported, try to establish eSCO connection
using S3 settings. If it fails, fallback in sequence to S2, S1, D1, D0 settings.
Failure is detected if Synchronous Connection Complete event fails with
error 0x0d. This error code has been found experimentally by sending a T2
request to a T1 only SCO listener. It means "Connection Rejected due to
Limited resource".
To know which setting should be used, conn->fallback is used. Bluez only
attempt to reconnect twice. Since, more than 2 fallback are required,
conn->fallback is tested as an alternative measure. We want to fallback only if
conn->fallback is positive. Calling hci_setup_sync with conn->fallback == 0
triggers initial connection attempt.
These setting and the fallback order are described in Bluetooth HFP 1.6
specification p. 101.
Signed-off-by: Frédéric Dalleau <frederic.dalleau@linux.intel.com>
---
include/net/bluetooth/hci_core.h | 1 +
net/bluetooth/hci_conn.c | 37 +++++++++++++++++++++++++++++++------
net/bluetooth/hci_event.c | 3 ++-
3 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 61ca2ce..c4509e2 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -321,6 +321,7 @@ struct hci_conn {
__u8 passkey_entered;
__u16 disc_timeout;
__u16 setting;
+ __u8 fallback;
unsigned long flags;
__u8 remote_cap;
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 6282c26..3c684c9 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -31,6 +31,25 @@
#include <net/bluetooth/a2mp.h>
#include <net/bluetooth/smp.h>
+struct sco_param {
+ u16 pkt_type;
+ u16 max_latency;
+ u8 next;
+};
+
+static const struct sco_param sco_param_cvsd[] = {
+ { EDR_ESCO_MASK & ~ESCO_2EV3, 0x000a, 1 }, /* S3 */
+ { EDR_ESCO_MASK & ~ESCO_2EV3, 0x0007, 2 }, /* S2 */
+ { EDR_ESCO_MASK | ESCO_EV3, 0x0007, 3 }, /* S1 */
+ { EDR_ESCO_MASK | ESCO_HV3, 0xffff, 4 }, /* D1 */
+ { EDR_ESCO_MASK | ESCO_HV1, 0xffff, 0 }, /* D0 */
+};
+
+static const struct sco_param sco_param_wideband[] = {
+ { EDR_ESCO_MASK & ~ESCO_2EV3, 0x000d, 1 }, /* T2 */
+ { EDR_ESCO_MASK | ESCO_EV3, 0x0008, 0 }, /* T1 */
+};
+
static void hci_le_create_connection(struct hci_conn *conn)
{
struct hci_dev *hdev = conn->hdev;
@@ -176,6 +195,7 @@ void hci_setup_sync(struct hci_conn *conn, __u16 handle)
{
struct hci_dev *hdev = conn->hdev;
struct hci_cp_setup_sync_conn cp;
+ const struct sco_param *param;
BT_DBG("hcon %p", conn);
@@ -191,17 +211,22 @@ void hci_setup_sync(struct hci_conn *conn, __u16 handle)
switch (conn->setting & SCO_AIRMODE_MASK) {
case SCO_AIRMODE_TRANSP:
- cp.pkt_type = __constant_cpu_to_le16(EDR_ESCO_MASK &
- ~ESCO_2EV3);
- cp.max_latency = __constant_cpu_to_le16(0x000d);
+ param = &sco_param_wideband[conn->fallback];
+ cp.pkt_type = __constant_cpu_to_le16(param->pkt_type);
+ cp.max_latency = __constant_cpu_to_le16(param->max_latency);
cp.voice_setting = __constant_cpu_to_le16(SCO_AIRMODE_TRANSP);
cp.retrans_effort = 0x02;
+
+ conn->fallback = param->next;
break;
case SCO_AIRMODE_CVSD:
- cp.pkt_type = cpu_to_le16(conn->pkt_type);
- cp.max_latency = __constant_cpu_to_le16(0xffff);
+ param = &sco_param_cvsd[conn->fallback];
+ cp.pkt_type = __constant_cpu_to_le16(param->pkt_type);
+ cp.max_latency = __constant_cpu_to_le16(param->max_latency);
cp.voice_setting = cpu_to_le16(conn->setting);
- cp.retrans_effort = 0xff;
+ cp.retrans_effort = 0x01;
+
+ conn->fallback = param->next;
break;
}
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 0437200..6659af8 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2904,11 +2904,12 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev,
hci_conn_add_sysfs(conn);
break;
+ case 0x0d: /* No resource available */
case 0x11: /* Unsupported Feature or Parameter Value */
case 0x1c: /* SCO interval rejected */
case 0x1a: /* Unsupported Remote Feature */
case 0x1f: /* Unspecified error */
- if (conn->out && conn->attempt < 2) {
+ if (conn->out && (conn->attempt < 2 || conn->fallback > 0)) {
conn->pkt_type = (hdev->esco_type & SCO_ESCO_MASK) |
(hdev->esco_type & EDR_ESCO_MASK);
hci_setup_sync(conn, conn->link->handle);
--
1.7.9.5
next prev parent reply other threads:[~2013-07-05 15:01 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-05 15:01 [PATCH v8 0/8] sco: SCO socket option for voice_setting Frédéric Dalleau
2013-07-05 15:01 ` [PATCH v8 1/8] Bluetooth: Use hci_connect_sco directly Frédéric Dalleau
2013-07-05 15:01 ` [PATCH v8 2/8] Bluetooth: Remove unused mask parameter in sco_conn_defer_accept Frédéric Dalleau
2013-07-08 19:10 ` Marcel Holtmann
2013-07-09 7:00 ` Frédéric DALLEAU
2013-07-09 7:37 ` Marcel Holtmann
2013-07-05 15:01 ` [PATCH v8 3/8] Bluetooth: Add bluetooth socket voice option Frédéric Dalleau
2013-07-08 19:17 ` Marcel Holtmann
2013-07-05 15:01 ` [PATCH v8 4/8] Bluetooth: Constants declaration for SCO airmode Frédéric Dalleau
2013-07-08 19:04 ` Marcel Holtmann
2013-07-05 15:01 ` [PATCH v8 5/8] Bluetooth: Use voice setting in defered SCO connection request Frédéric Dalleau
2013-07-08 19:12 ` Marcel Holtmann
2013-07-09 9:36 ` Frédéric DALLEAU
2013-07-05 15:01 ` [PATCH v8 6/8] Bluetooth: Parameters for outgoing SCO connections Frédéric Dalleau
2013-07-08 19:20 ` Marcel Holtmann
2013-07-05 15:01 ` Frédéric Dalleau [this message]
2013-07-08 19:23 ` [PATCH v8 7/8] Bluetooth: SCO connection fallback Marcel Holtmann
2013-07-09 9:57 ` Frédéric DALLEAU
2013-07-09 14:25 ` Marcel Holtmann
2013-07-05 15:01 ` [PATCH v8 8/8] Bluetooth: Prevent transparent SCO on older devices Frédéric Dalleau
2013-07-08 2:33 ` Vinicius Costa Gomes
2013-07-08 9:31 ` Frédéric DALLEAU
2013-07-08 19:25 ` Marcel Holtmann
2013-07-12 13:48 ` Frédéric DALLEAU
2013-07-12 16:35 ` Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1373036503-1349-8-git-send-email-frederic.dalleau@linux.intel.com \
--to=frederic.dalleau@linux.intel.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).