mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
Bluetooth: hci_core: Introduce HCI_CONN_FLAG_PAST
This introduces a new device flag so userspace can indicate if it wants to enable PAST Receiver for a specific device. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
@@ -166,6 +166,7 @@ enum hci_conn_flags {
|
||||
HCI_CONN_FLAG_REMOTE_WAKEUP = BIT(0),
|
||||
HCI_CONN_FLAG_DEVICE_PRIVACY = BIT(1),
|
||||
HCI_CONN_FLAG_ADDRESS_RESOLUTION = BIT(2),
|
||||
HCI_CONN_FLAG_PAST = BIT(3),
|
||||
};
|
||||
typedef u8 hci_conn_flags_t;
|
||||
|
||||
|
||||
@@ -4324,6 +4324,10 @@ static int hci_le_set_event_mask_sync(struct hci_dev *hdev)
|
||||
if (ll_privacy_capable(hdev))
|
||||
hdev->conn_flags |= HCI_CONN_FLAG_ADDRESS_RESOLUTION;
|
||||
|
||||
/* Mark PAST if supported */
|
||||
if (past_capable(hdev))
|
||||
hdev->conn_flags |= HCI_CONN_FLAG_PAST;
|
||||
|
||||
/* If the controller supports Extended Scanner Filter
|
||||
* Policies, enable the corresponding event.
|
||||
*/
|
||||
@@ -7024,10 +7028,41 @@ unlock:
|
||||
hci_dev_unlock(hdev);
|
||||
}
|
||||
|
||||
static int hci_le_past_params_sync(struct hci_dev *hdev, struct hci_conn *conn,
|
||||
struct hci_conn *acl, struct bt_iso_qos *qos)
|
||||
{
|
||||
struct hci_cp_le_past_params cp;
|
||||
int err;
|
||||
|
||||
memset(&cp, 0, sizeof(cp));
|
||||
cp.handle = cpu_to_le16(acl->handle);
|
||||
/* An HCI_LE_Periodic_Advertising_Sync_Transfer_Received event is sent
|
||||
* to the Host. HCI_LE_Periodic_Advertising_Report events will be
|
||||
* enabled with duplicate filtering enabled.
|
||||
*/
|
||||
cp.mode = 0x03;
|
||||
cp.skip = cpu_to_le16(qos->bcast.skip);
|
||||
cp.sync_timeout = cpu_to_le16(qos->bcast.sync_timeout);
|
||||
cp.cte_type = qos->bcast.sync_cte_type;
|
||||
|
||||
/* HCI_LE_PAST_PARAMS command returns a command complete event so it
|
||||
* cannot wait for HCI_EV_LE_PAST_RECEIVED.
|
||||
*/
|
||||
err = __hci_cmd_sync_status(hdev, HCI_OP_LE_PAST_PARAMS,
|
||||
sizeof(cp), &cp, HCI_CMD_TIMEOUT);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* Wait for HCI_EV_LE_PAST_RECEIVED event */
|
||||
return __hci_cmd_sync_status_sk(hdev, HCI_OP_NOP, 0, NULL,
|
||||
HCI_EV_LE_PAST_RECEIVED,
|
||||
conn->conn_timeout, NULL);
|
||||
}
|
||||
|
||||
static int hci_le_pa_create_sync(struct hci_dev *hdev, void *data)
|
||||
{
|
||||
struct hci_cp_le_pa_create_sync cp;
|
||||
struct hci_conn *conn = data;
|
||||
struct hci_conn *conn = data, *le;
|
||||
struct bt_iso_qos *qos = &conn->iso_qos;
|
||||
int err;
|
||||
|
||||
@@ -7059,6 +7094,24 @@ static int hci_le_pa_create_sync(struct hci_dev *hdev, void *data)
|
||||
|
||||
hci_update_passive_scan_sync(hdev);
|
||||
|
||||
/* Check if PAST is possible:
|
||||
*
|
||||
* 1. Check if an ACL connection with the destination address exists
|
||||
* 2. Check if that HCI_CONN_FLAG_PAST has been set which indicates that
|
||||
* user really intended to use PAST.
|
||||
*/
|
||||
le = hci_conn_hash_lookup_le(hdev, &conn->dst, conn->dst_type);
|
||||
if (le) {
|
||||
struct hci_conn_params *params;
|
||||
|
||||
params = hci_conn_params_lookup(hdev, &le->dst, le->dst_type);
|
||||
if (params && params->flags & HCI_CONN_FLAG_PAST) {
|
||||
err = hci_le_past_params_sync(hdev, conn, le, qos);
|
||||
if (!err)
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
/* SID has not been set listen for HCI_EV_LE_EXT_ADV_REPORT to update
|
||||
* it.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user