Skip to contentSkip to conversation

Bluetooth: Introduce HCI_QUIRK_SIMULTAENOUS_DISCOVERY

PATCH New Jakub Pawlowski 1 participant 3 messages Feb 26, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Bluetooth: Introduce HCI_QUIRK_SIMULTAENOUS_DISCOVERY

Some controllers allow both le and classic scan to run at the same time, while others allow only one, le or classic 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 and classic discovery at same time.

---
 include/net/bluetooth/hci.h | 9 +++++++++
 1 file changed, 9 insertions(+)
include/net/bluetooth/hci.h +9 -0
index 8e54f82..d64851a 100644
@@ -160,6 +160,15 @@ enum {
 	 * during the hdev->setup vendor callback.
 	 */
 	HCI_QUIRK_STRICT_DUPLICATE_FILTER,
+
+	/* When this quirk is set, scanning for both le and classic devices
+	 * is done simoultaenously. If it's not set, the scan is
+	 * interleaved.
+	 *
+	 * This quirk can be set before hci_register_dev is called or
+	 * during the hdev->setup vendor callback.
+	 */
+	HCI_QUIRK_SIMULTAENOUS_DISCOVERY,
 };
 
 /* HCI device flags */
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#1 lore raw

PATCH 2/3 Bluetooth: Add simultaenous 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_SIMULTAENOUS_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  | 26 +++++++++++++++++------
 net/bluetooth/hci_event.c | 18 ++++++++++++++--
 net/bluetooth/mgmt.c      | 54 +++++++++++++++++++++++++++++++----------------
 3 files changed, 72 insertions(+), 26 deletions(-)
net/bluetooth/hci_core.c +20 -6
index dbd26bc..c4f2316 100644
@@ -2866,12 +2866,26 @@ static void le_scan_disable_work_complete(struct hci_dev *hdev, u8 status,
 
 		hci_dev_lock(hdev);
 
-		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);
+		if (!test_bit(HCI_QUIRK_SIMULTAENOUS_DISCOVERY,
+			      &hdev->quirks)) {
+			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);
+			}
+		} else {
+			/* If we were running le only scan, change discovery
+			 * state. If we were running both le and classic scans
+			 * simultaenously, 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);
 		}
 
 		hci_dev_unlock(hdev);
net/bluetooth/hci_event.c +16 -2
index e9b17b5..d69de31 100644
@@ -2127,7 +2127,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 classic discovery change discovery state.
+		 * If we were running both le and classic scans simultaenously,
+		 * and le is already finished, change state, otherwise le
+		 * scan will stop discovery when finished.
+		 */
+		if (!test_bit(HCI_LE_SCAN, &hdev->flags) ||
+		    !test_bit(HCI_QUIRK_SIMULTAENOUS_DISCOVERY, &hdev->quirks))
+			hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
 		goto unlock;
 	}
 
@@ -2136,7 +2143,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 simultaenously,
+		 * and le is already finished, change state, otherwise le
+		 * scan will stop discovery when finished.
+		 */
+		if (!test_bit(HCI_LE_SCAN, &hdev->flags) ||
+		    !test_bit(HCI_QUIRK_SIMULTAENOUS_DISCOVERY, &hdev->quirks))
+			hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
 	}
 
 unlock:
net/bluetooth/mgmt.c +36 -18

83 lines not on this page · raw message

Signature · 1 line
2.2.0.rc0.207.ga3a616c
#2 lore raw

PATCH 3/3 Bluetooth: Set HCI_QUIRK_SIMULTAENOUS_DISCOVERY for BTUSB_ATH3012

In reply to Jakub Pawlowski

Atheros 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
index 3ca2e1b..119c77c 100644
@@ -2777,6 +2777,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_SIMULTAENOUS_DISCOVERY, &hdev->quirks);
 		set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks);
 	}
 
Signature · 1 line
2.2.0.rc0.207.ga3a616c