Skip to content

Commit 8b1c324

Browse files
yliu98holtmann
authored andcommitted
Bluetooth: Skip eSCO 2M params when not supported
If a peer device doesn't support eSCO 2M we should skip the params that use it when setting up sync connection since they will always fail. Signed-off-by: Yu Liu <[email protected]> Reviewed-by: Abhishek Pandit-Subedi <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent b8ddc3b commit 8b1c324

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

include/net/bluetooth/hci_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
13651365
#define lmp_le_capable(dev) ((dev)->features[0][4] & LMP_LE)
13661366
#define lmp_sniffsubr_capable(dev) ((dev)->features[0][5] & LMP_SNIFF_SUBR)
13671367
#define lmp_pause_enc_capable(dev) ((dev)->features[0][5] & LMP_PAUSE_ENC)
1368+
#define lmp_esco_2m_capable(dev) ((dev)->features[0][5] & LMP_EDR_ESCO_2M)
13681369
#define lmp_ext_inq_capable(dev) ((dev)->features[0][6] & LMP_EXT_INQ)
13691370
#define lmp_le_br_capable(dev) (!!((dev)->features[0][6] & LMP_SIMUL_LE_BR))
13701371
#define lmp_ssp_capable(dev) ((dev)->features[0][6] & LMP_SIMPLE_PAIR)

net/bluetooth/hci_conn.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,20 @@ static void hci_add_sco(struct hci_conn *conn, __u16 handle)
293293
hci_send_cmd(hdev, HCI_OP_ADD_SCO, sizeof(cp), &cp);
294294
}
295295

296+
static bool find_next_esco_param(struct hci_conn *conn,
297+
const struct sco_param *esco_param, int size)
298+
{
299+
for (; conn->attempt <= size; conn->attempt++) {
300+
if (lmp_esco_2m_capable(conn->link) ||
301+
(esco_param[conn->attempt - 1].pkt_type & ESCO_2EV3))
302+
break;
303+
BT_DBG("hcon %p skipped attempt %d, eSCO 2M not supported",
304+
conn, conn->attempt);
305+
}
306+
307+
return conn->attempt <= size;
308+
}
309+
296310
bool hci_setup_sync(struct hci_conn *conn, __u16 handle)
297311
{
298312
struct hci_dev *hdev = conn->hdev;
@@ -314,13 +328,15 @@ bool hci_setup_sync(struct hci_conn *conn, __u16 handle)
314328

315329
switch (conn->setting & SCO_AIRMODE_MASK) {
316330
case SCO_AIRMODE_TRANSP:
317-
if (conn->attempt > ARRAY_SIZE(esco_param_msbc))
331+
if (!find_next_esco_param(conn, esco_param_msbc,
332+
ARRAY_SIZE(esco_param_msbc)))
318333
return false;
319334
param = &esco_param_msbc[conn->attempt - 1];
320335
break;
321336
case SCO_AIRMODE_CVSD:
322337
if (lmp_esco_capable(conn->link)) {
323-
if (conn->attempt > ARRAY_SIZE(esco_param_cvsd))
338+
if (!find_next_esco_param(conn, esco_param_cvsd,
339+
ARRAY_SIZE(esco_param_cvsd)))
324340
return false;
325341
param = &esco_param_cvsd[conn->attempt - 1];
326342
} else {

0 commit comments

Comments
 (0)