aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/bluetooth/hci.h4
-rw-r--r--include/net/bluetooth/hci_core.h9
-rw-r--r--net/bluetooth/hci_request.c37
3 files changed, 40 insertions, 10 deletions
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 89bf800f6eb1..04211457367a 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -1540,7 +1540,9 @@ struct hci_cp_le_set_ext_scan_params {
1540 __u8 data[0]; 1540 __u8 data[0];
1541} __packed; 1541} __packed;
1542 1542
1543#define LE_SCAN_PHY_1M 0x01 1543#define LE_SCAN_PHY_1M 0x01
1544#define LE_SCAN_PHY_2M 0x02
1545#define LE_SCAN_PHY_CODED 0x04
1544 1546
1545struct hci_cp_le_scan_phy_params { 1547struct hci_cp_le_scan_phy_params {
1546 __u8 type; 1548 __u8 type;
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index ab5d494a545a..113c9bb609c7 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1165,6 +1165,15 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
1165#define bredr_sc_enabled(dev) (lmp_sc_capable(dev) && \ 1165#define bredr_sc_enabled(dev) (lmp_sc_capable(dev) && \
1166 hci_dev_test_flag(dev, HCI_SC_ENABLED)) 1166 hci_dev_test_flag(dev, HCI_SC_ENABLED))
1167 1167
1168#define scan_1m(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_1M) || \
1169 ((dev)->le_rx_def_phys & HCI_LE_SET_PHY_1M))
1170
1171#define scan_2m(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_2M) || \
1172 ((dev)->le_rx_def_phys & HCI_LE_SET_PHY_2M))
1173
1174#define scan_coded(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_CODED) || \
1175 ((dev)->le_rx_def_phys & HCI_LE_SET_PHY_CODED))
1176
1168/* Use ext scanning if set ext scan param and ext scan enable is supported */ 1177/* Use ext scanning if set ext scan param and ext scan enable is supported */
1169#define use_ext_scan(dev) (((dev)->commands[37] & 0x20) && \ 1178#define use_ext_scan(dev) (((dev)->commands[37] & 0x20) && \
1170 ((dev)->commands[37] & 0x40)) 1179 ((dev)->commands[37] & 0x40))
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index faf7c711234c..215059a7646e 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -790,8 +790,8 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval,
790 struct hci_cp_le_set_ext_scan_params *ext_param_cp; 790 struct hci_cp_le_set_ext_scan_params *ext_param_cp;
791 struct hci_cp_le_set_ext_scan_enable ext_enable_cp; 791 struct hci_cp_le_set_ext_scan_enable ext_enable_cp;
792 struct hci_cp_le_scan_phy_params *phy_params; 792 struct hci_cp_le_scan_phy_params *phy_params;
793 /* Ony single PHY (1M) is supported as of now */ 793 u8 data[sizeof(*ext_param_cp) + sizeof(*phy_params) * 2];
794 u8 data[sizeof(*ext_param_cp) + sizeof(*phy_params) * 1]; 794 u32 plen;
795 795
796 ext_param_cp = (void *)data; 796 ext_param_cp = (void *)data;
797 phy_params = (void *)ext_param_cp->data; 797 phy_params = (void *)ext_param_cp->data;
@@ -799,16 +799,35 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval,
799 memset(ext_param_cp, 0, sizeof(*ext_param_cp)); 799 memset(ext_param_cp, 0, sizeof(*ext_param_cp));
800 ext_param_cp->own_addr_type = own_addr_type; 800 ext_param_cp->own_addr_type = own_addr_type;
801 ext_param_cp->filter_policy = filter_policy; 801 ext_param_cp->filter_policy = filter_policy;
802 ext_param_cp->scanning_phys = LE_SCAN_PHY_1M;
803 802
804 memset(phy_params, 0, sizeof(*phy_params)); 803 plen = sizeof(*ext_param_cp);
805 phy_params->type = type; 804
806 phy_params->interval = cpu_to_le16(interval); 805 if (scan_1m(hdev) || scan_2m(hdev)) {
807 phy_params->window = cpu_to_le16(window); 806 ext_param_cp->scanning_phys |= LE_SCAN_PHY_1M;
807
808 memset(phy_params, 0, sizeof(*phy_params));
809 phy_params->type = type;
810 phy_params->interval = cpu_to_le16(interval);
811 phy_params->window = cpu_to_le16(window);
812
813 plen += sizeof(*phy_params);
814 phy_params++;
815 }
816
817 if (scan_coded(hdev)) {
818 ext_param_cp->scanning_phys |= LE_SCAN_PHY_CODED;
819
820 memset(phy_params, 0, sizeof(*phy_params));
821 phy_params->type = type;
822 phy_params->interval = cpu_to_le16(interval);
823 phy_params->window = cpu_to_le16(window);
824
825 plen += sizeof(*phy_params);
826 phy_params++;
827 }
808 828
809 hci_req_add(req, HCI_OP_LE_SET_EXT_SCAN_PARAMS, 829 hci_req_add(req, HCI_OP_LE_SET_EXT_SCAN_PARAMS,
810 sizeof(*ext_param_cp) + sizeof(*phy_params), 830 plen, ext_param_cp);
811 ext_param_cp);
812 831
813 memset(&ext_enable_cp, 0, sizeof(ext_enable_cp)); 832 memset(&ext_enable_cp, 0, sizeof(ext_enable_cp));
814 ext_enable_cp.enable = LE_SCAN_ENABLE; 833 ext_enable_cp.enable = LE_SCAN_ENABLE;