Skip to content

Commit 288c902

Browse files
committed
Bluetooth: Enable all supported LE PHY by default
This enables 2M and Coded PHY by default if they are marked as supported in the LE features bits. Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 0fe8c8d commit 288c902

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

include/net/bluetooth/hci_core.h

+4
Original file line numberDiff line numberDiff line change
@@ -1683,9 +1683,13 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
16831683
#define scan_1m(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_1M) || \
16841684
((dev)->le_rx_def_phys & HCI_LE_SET_PHY_1M))
16851685

1686+
#define le_2m_capable(dev) (((dev)->le_features[1] & HCI_LE_PHY_2M))
1687+
16861688
#define scan_2m(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_2M) || \
16871689
((dev)->le_rx_def_phys & HCI_LE_SET_PHY_2M))
16881690

1691+
#define le_coded_capable(dev) (((dev)->le_features[1] & HCI_LE_PHY_CODED))
1692+
16891693
#define scan_coded(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_CODED) || \
16901694
((dev)->le_rx_def_phys & HCI_LE_SET_PHY_CODED))
16911695

net/bluetooth/hci_sync.c

+24-4
Original file line numberDiff line numberDiff line change
@@ -4414,18 +4414,38 @@ static int hci_le_set_write_def_data_len_sync(struct hci_dev *hdev)
44144414
sizeof(cp), &cp, HCI_CMD_TIMEOUT);
44154415
}
44164416

4417-
/* Set Default PHY parameters if command is supported */
4417+
/* Set Default PHY parameters if command is supported, enables all supported
4418+
* PHYs according to the LE Features bits.
4419+
*/
44184420
static int hci_le_set_default_phy_sync(struct hci_dev *hdev)
44194421
{
44204422
struct hci_cp_le_set_default_phy cp;
44214423

4422-
if (!(hdev->commands[35] & 0x20))
4424+
if (!(hdev->commands[35] & 0x20)) {
4425+
/* If the command is not supported it means only 1M PHY is
4426+
* supported.
4427+
*/
4428+
hdev->le_tx_def_phys = HCI_LE_SET_PHY_1M;
4429+
hdev->le_rx_def_phys = HCI_LE_SET_PHY_1M;
44234430
return 0;
4431+
}
44244432

44254433
memset(&cp, 0, sizeof(cp));
44264434
cp.all_phys = 0x00;
4427-
cp.tx_phys = hdev->le_tx_def_phys;
4428-
cp.rx_phys = hdev->le_rx_def_phys;
4435+
cp.tx_phys = HCI_LE_SET_PHY_1M;
4436+
cp.rx_phys = HCI_LE_SET_PHY_1M;
4437+
4438+
/* Enables 2M PHY if supported */
4439+
if (le_2m_capable(hdev)) {
4440+
cp.tx_phys |= HCI_LE_SET_PHY_2M;
4441+
cp.rx_phys |= HCI_LE_SET_PHY_2M;
4442+
}
4443+
4444+
/* Enables Coded PHY if supported */
4445+
if (le_coded_capable(hdev)) {
4446+
cp.tx_phys |= HCI_LE_SET_PHY_CODED;
4447+
cp.rx_phys |= HCI_LE_SET_PHY_CODED;
4448+
}
44294449

44304450
return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_DEFAULT_PHY,
44314451
sizeof(cp), &cp, HCI_CMD_TIMEOUT);

net/bluetooth/mgmt.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -8393,10 +8393,10 @@ static u32 get_supported_adv_flags(struct hci_dev *hdev)
83938393
flags |= MGMT_ADV_FLAG_HW_OFFLOAD;
83948394
flags |= MGMT_ADV_FLAG_CAN_SET_TX_POWER;
83958395

8396-
if (hdev->le_features[1] & HCI_LE_PHY_2M)
8396+
if (le_2m_capable(hdev))
83978397
flags |= MGMT_ADV_FLAG_SEC_2M;
83988398

8399-
if (hdev->le_features[1] & HCI_LE_PHY_CODED)
8399+
if (le_coded_capable(hdev))
84008400
flags |= MGMT_ADV_FLAG_SEC_CODED;
84018401
}
84028402

0 commit comments

Comments
 (0)