Skip to content

Commit 1f8330e

Browse files
nsathish41Johan Hedberg
authored andcommitted
Bluetooth: add support to notify using SCO air mode
notifying using HCI_NOTIFY_CONN_ADD for SCO connection is generic in case of mSBC audio. To differntiate SCO air mode introducing HCI_NOTIFY_ENABLE_SCO_CVSD and HCI_NOTIFY_ENABLE_SCO_TRANSP. Signed-off-by: Sathish Narsimman <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
1 parent 1e5479b commit 1f8330e

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

include/net/bluetooth/hci.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
#define HCI_NOTIFY_CONN_ADD 1
5454
#define HCI_NOTIFY_CONN_DEL 2
5555
#define HCI_NOTIFY_VOICE_SETTING 3
56+
#define HCI_NOTIFY_ENABLE_SCO_CVSD 4
57+
#define HCI_NOTIFY_ENABLE_SCO_TRANSP 5
58+
#define HCI_NOTIFY_DISABLE_SCO 6
5659

5760
/* HCI bus types */
5861
#define HCI_VIRTUAL 0

net/bluetooth/hci_conn.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,18 @@ static void hci_conn_cleanup(struct hci_conn *conn)
122122

123123
hci_conn_hash_del(hdev, conn);
124124

125-
if (hdev->notify)
126-
hdev->notify(hdev, HCI_NOTIFY_CONN_DEL);
125+
if (conn->type == SCO_LINK || conn->type == ESCO_LINK) {
126+
switch (conn->setting & SCO_AIRMODE_MASK) {
127+
case SCO_AIRMODE_CVSD:
128+
case SCO_AIRMODE_TRANSP:
129+
if (hdev->notify)
130+
hdev->notify(hdev, HCI_NOTIFY_DISABLE_SCO);
131+
break;
132+
}
133+
} else {
134+
if (hdev->notify)
135+
hdev->notify(hdev, HCI_NOTIFY_CONN_DEL);
136+
}
127137

128138
hci_conn_del_sysfs(conn);
129139

@@ -577,8 +587,15 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst,
577587
hci_dev_hold(hdev);
578588

579589
hci_conn_hash_add(hdev, conn);
580-
if (hdev->notify)
581-
hdev->notify(hdev, HCI_NOTIFY_CONN_ADD);
590+
591+
/* The SCO and eSCO connections will only be notified when their
592+
* setup has been completed. This is different to ACL links which
593+
* can be notified right away.
594+
*/
595+
if (conn->type != SCO_LINK && conn->type != ESCO_LINK) {
596+
if (hdev->notify)
597+
hdev->notify(hdev, HCI_NOTIFY_CONN_ADD);
598+
}
582599

583600
hci_conn_init_sysfs(conn);
584601

net/bluetooth/hci_event.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2607,8 +2607,16 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
26072607
if (ev->status) {
26082608
hci_connect_cfm(conn, ev->status);
26092609
hci_conn_del(conn);
2610-
} else if (ev->link_type != ACL_LINK)
2610+
} else if (ev->link_type == SCO_LINK) {
2611+
switch (conn->setting & SCO_AIRMODE_MASK) {
2612+
case SCO_AIRMODE_CVSD:
2613+
if (hdev->notify)
2614+
hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD);
2615+
break;
2616+
}
2617+
26112618
hci_connect_cfm(conn, ev->status);
2619+
}
26122620

26132621
unlock:
26142622
hci_dev_unlock(hdev);
@@ -4307,6 +4315,19 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev,
43074315
break;
43084316
}
43094317

4318+
bt_dev_dbg(hdev, "SCO connected with air mode: %02x", ev->air_mode);
4319+
4320+
switch (conn->setting & SCO_AIRMODE_MASK) {
4321+
case SCO_AIRMODE_CVSD:
4322+
if (hdev->notify)
4323+
hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_CVSD);
4324+
break;
4325+
case SCO_AIRMODE_TRANSP:
4326+
if (hdev->notify)
4327+
hdev->notify(hdev, HCI_NOTIFY_ENABLE_SCO_TRANSP);
4328+
break;
4329+
}
4330+
43104331
hci_connect_cfm(conn, ev->status);
43114332
if (ev->status)
43124333
hci_conn_del(conn);

0 commit comments

Comments
 (0)