Bluetooth: Introduce HCI_QUIRK_SIMULTANEOUS_DISCOVERY
Subsystems (2)
PATCH v3 1/5 Bluetooth: Introduce HCI_QUIRK_SIMULTANEOUS_DISCOVERY
Some controllers allow both LE scan and BR/EDR inquiry to run at the same time, while others allow only one, LE SCAN or BR/EDR inquiry at given time.
Since this is specific to each controller, add a new quirk setting that allows drivers to tell the core wether given controller can do both LE scan and BR/EDR inquiry at same time.
--- include/net/bluetooth/hci.h | 9 +++++++++ 1 file changed, 9 insertions(+)
include/net/bluetooth/hci.h +9 -0
@@ -160,6 +160,15 @@ enum {* during the hdev->setup vendor callback. */ HCI_QUIRK_STRICT_DUPLICATE_FILTER , + +/* When this quirk is set, LE scan and BR/EDR inquiry is done +* simultaneously, otherwise it's interleaved. +* . +* +* This quirk can be set before hci_register_dev is called or +* during the hdev->setup vendor callback. +*/ + HCI_QUIRK_SIMULTANEOUS_DISCOVERY, };/* HCI device flags */
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH v3 2/5 Bluetooth: Add simultaneous dual mode scan
When doing scan through mgmt api, some controllers can do both le and classic scan at same time. They can be distinguished by HCI_QUIRK_SIMULTANEOUS_DISCOVERY set.
This patch enables them to use this feature when doing dual mode scan. Instead of doing le, then classic scan, both scans are run at once.
--- net/bluetooth/hci_core.c | 24 +++++-- net/bluetooth/hci_event.c | 18 ++++- net/bluetooth/mgmt.c | 172 ++++++++++++++++++++++++++++------------------ 3 files changed, 142 insertions(+), 72 deletions(-)
net/bluetooth/hci_core.c +19 -5
@@ -2902,12 +2902,26 @@ static void le_scan_disable_work_complete(struct hci_dev *hdev, u8 status,hci_dev_lock (hdev); -hci_inquiry_cache_flush (hdev); +if (test_bit (HCI_QUIRK_SIMULTANEOUS_DISCOVERY , + &hdev->quirks)) { +/* If we were running le only scan, change discovery +* state. If we were running both le and classic scans +* simultaneously, and classic is already finished, +* stop discovery, otherwise classic scan will stop +* discovery when finished. +*/ +if (!test_bit (HCI_INQUIRY , &hdev->flags)) +hci_discovery_set_state (hdev, +DISCOVERY_STOPPED ); + }else { +hci_inquiry_cache_flush (hdev); - err =hci_req_run (&req, inquiry_complete); -if (err) { -BT_ERR ("Inquiry request failed: err %d" , err); -hci_discovery_set_state (hdev,DISCOVERY_STOPPED ); + err =hci_req_run (&req, inquiry_complete); +if (err) { +BT_ERR ("Inquiry request failed: err %d" , err); +hci_discovery_set_state (hdev, +DISCOVERY_STOPPED ); + } }hci_dev_unlock (hdev);
net/bluetooth/hci_event.c +16 -2
@@ -2126,7 +2126,14 @@ static void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) goto unlock;if (list_empty (&discov->resolve)) { -hci_discovery_set_state (hdev,DISCOVERY_STOPPED ); +/* if we were running BR/EDR inquiry change discovery state. +* If we were running both BR/EDR inquiry and LE scan +* simultaneously, and LE is already finished, change state, +* otherwise LE scan will stop discovery when finished. +*/ +if (!hci_dev_test_flag (hdev,HCI_LE_SCAN ) || + !test_bit (HCI_QUIRK_SIMULTANEOUS_DISCOVERY , &hdev->quirks)) +hci_discovery_set_state (hdev,DISCOVERY_STOPPED ); goto unlock; }
@@ -2135,7 +2142,14 @@ static void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) e->name_state =NAME_PENDING ;hci_discovery_set_state (hdev,DISCOVERY_RESOLVING ); }else { -hci_discovery_set_state (hdev,DISCOVERY_STOPPED ); +/* if we were running classic discovery change discovery state. +* If we were running both le and classic scans simultaneously, +* and le is already finished, change state, otherwise le +* scan will stop discovery when finished. +*/ +if (!hci_dev_test_flag (hdev,HCI_LE_SCAN ) || + !test_bit (HCI_QUIRK_SIMULTANEOUS_DISCOVERY , &hdev->quirks)) +hci_discovery_set_state (hdev,DISCOVERY_STOPPED ); } unlock:
net/bluetooth/mgmt.c +107 -65
214 lines not on this page · raw message
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH v3 3/5 Bluetooth: Set HCI_QUIRK_SIMULTANEOUS_DISCOVERY for BTUSB_ATH3012
In reply to Jakub PawlowskiAtheros controllers can do both LE and classic scan at once.
--- drivers/bluetooth/btusb.c | 1 + 1 file changed, 1 insertion(+)
drivers/bluetooth/btusb.c +1 -0
@@ -3042,6 +3042,7 @@ static int btusb_probe(struct usb_interface *intf,if (id->driver_info &BTUSB_ATH3012 ) { hdev->set_bdaddr = btusb_set_bdaddr_ath3012; +set_bit (HCI_QUIRK_SIMULTANEOUS_DISCOVERY , &hdev->quirks);set_bit (HCI_QUIRK_STRICT_DUPLICATE_FILTER , &hdev->quirks); }
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH v3 4/5 Bluetooth: Set HCI_QUIRK_SIMULTANEOUS_DISCOVERY for BTUSB_INTEL
In reply to Jakub PawlowskiIntel controllers can do both LE and classic scan at once.
--- drivers/bluetooth/btusb.c | 1 + 1 file changed, 1 insertion(+)
drivers/bluetooth/btusb.c +1 -0
@@ -3019,6 +3019,7 @@ static int btusb_probe(struct usb_interface *intf, hdev->shutdown = btusb_shutdown_intel; hdev->set_bdaddr = btusb_set_bdaddr_intel;set_bit (HCI_QUIRK_STRICT_DUPLICATE_FILTER , &hdev->quirks); +set_bit (HCI_QUIRK_SIMULTANEOUS_DISCOVERY , &hdev->quirks); }if (id->driver_info &BTUSB_INTEL_NEW ) {
Signature · 1 line
2.2.0.rc0.207.ga3a616c
PATCH v3 5/5 Bluetooth: Set HCI_QUIRK_SIMULTANEOUS_DISCOVERY for BTUSB_CSR
In reply to Jakub PawlowskiCSR controllers can do both LE and classic scan at once.
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -3087,6 +3087,8 @@ static int btusb_probe(struct usb_interface *intf,/* Fake CSR devices with broken commands */ if (bcdDevice <=0x100 ) hdev->setup = btusb_setup_csr; + +set_bit (HCI_QUIRK_SIMULTANEOUS_DISCOVERY , &hdev->quirks); }if (id->driver_info &BTUSB_SNIFFER ) {
Signature · 1 line
2.2.0.rc0.207.ga3a616c