hci_sync.c (bb87672562f871edd7a220222dd2480a87294580) hci_sync.c (26afbd826ee326e63a334c37fd45e82e50a615ec)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * BlueZ - Bluetooth protocol stack for Linux
4 *
5 * Copyright (C) 2021 Intel Corporation
6 */
7
8#include <linux/property.h>

--- 2786 unchanged lines hidden (view full) ---

2795static const struct hci_init_stage amp_init2[] = {
2796 /* HCI_OP_READ_LOCAL_FEATURES */
2797 HCI_INIT(hci_read_local_features_sync),
2798};
2799
2800/* Read Buffer Size (ACL mtu, max pkt, etc.) */
2801static int hci_read_buffer_size_sync(struct hci_dev *hdev)
2802{
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * BlueZ - Bluetooth protocol stack for Linux
4 *
5 * Copyright (C) 2021 Intel Corporation
6 */
7
8#include <linux/property.h>

--- 2786 unchanged lines hidden (view full) ---

2795static const struct hci_init_stage amp_init2[] = {
2796 /* HCI_OP_READ_LOCAL_FEATURES */
2797 HCI_INIT(hci_read_local_features_sync),
2798};
2799
2800/* Read Buffer Size (ACL mtu, max pkt, etc.) */
2801static int hci_read_buffer_size_sync(struct hci_dev *hdev)
2802{
2803 /* Use Read LE Buffer Size V2 if supported */
2804 if (hdev->commands[41] & 0x20)
2805 return __hci_cmd_sync_status(hdev,
2806 HCI_OP_LE_READ_BUFFER_SIZE_V2,
2807 0, NULL, HCI_CMD_TIMEOUT);
2808
2803 return __hci_cmd_sync_status(hdev, HCI_OP_READ_BUFFER_SIZE,
2804 0, NULL, HCI_CMD_TIMEOUT);
2805}
2806
2807/* Read Class of Device */
2808static int hci_read_dev_class_sync(struct hci_dev *hdev)
2809{
2810 return __hci_cmd_sync_status(hdev, HCI_OP_READ_CLASS_OF_DEV,

--- 235 unchanged lines hidden (view full) ---

3046{
3047 int err;
3048
3049 bt_dev_dbg(hdev, "");
3050
3051 if (hdev->dev_type == HCI_AMP)
3052 return hci_init_stage_sync(hdev, amp_init2);
3053
2809 return __hci_cmd_sync_status(hdev, HCI_OP_READ_BUFFER_SIZE,
2810 0, NULL, HCI_CMD_TIMEOUT);
2811}
2812
2813/* Read Class of Device */
2814static int hci_read_dev_class_sync(struct hci_dev *hdev)
2815{
2816 return __hci_cmd_sync_status(hdev, HCI_OP_READ_CLASS_OF_DEV,

--- 235 unchanged lines hidden (view full) ---

3052{
3053 int err;
3054
3055 bt_dev_dbg(hdev, "");
3056
3057 if (hdev->dev_type == HCI_AMP)
3058 return hci_init_stage_sync(hdev, amp_init2);
3059
3060 err = hci_init_stage_sync(hdev, hci_init2);
3061 if (err)
3062 return err;
3063
3054 if (lmp_bredr_capable(hdev)) {
3055 err = hci_init_stage_sync(hdev, br_init2);
3056 if (err)
3057 return err;
3058 } else {
3059 hci_dev_clear_flag(hdev, HCI_BREDR_ENABLED);
3060 }
3061
3062 if (lmp_le_capable(hdev)) {
3063 err = hci_init_stage_sync(hdev, le_init2);
3064 if (err)
3065 return err;
3066 /* LE-only controllers have LE implicitly enabled */
3067 if (!lmp_bredr_capable(hdev))
3068 hci_dev_set_flag(hdev, HCI_LE_ENABLED);
3069 }
3070
3064 if (lmp_bredr_capable(hdev)) {
3065 err = hci_init_stage_sync(hdev, br_init2);
3066 if (err)
3067 return err;
3068 } else {
3069 hci_dev_clear_flag(hdev, HCI_BREDR_ENABLED);
3070 }
3071
3072 if (lmp_le_capable(hdev)) {
3073 err = hci_init_stage_sync(hdev, le_init2);
3074 if (err)
3075 return err;
3076 /* LE-only controllers have LE implicitly enabled */
3077 if (!lmp_bredr_capable(hdev))
3078 hci_dev_set_flag(hdev, HCI_LE_ENABLED);
3079 }
3080
3071 return hci_init_stage_sync(hdev, hci_init2);
3081 return 0;
3072}
3073
3074static int hci_set_event_mask_sync(struct hci_dev *hdev)
3075{
3076 /* The second byte is 0xff instead of 0x9f (two reserved bits
3077 * disabled) since a Broadcom 1.2 dongle doesn't respond to the
3078 * command otherwise.
3079 */

--- 304 unchanged lines hidden (view full) ---

3384 events[1] |= 0x10; /* LE Extended Advertising Report */
3385
3386 /* If the controller supports the LE Extended Advertising
3387 * command, enable the corresponding event.
3388 */
3389 if (ext_adv_capable(hdev))
3390 events[2] |= 0x02; /* LE Advertising Set Terminated */
3391
3082}
3083
3084static int hci_set_event_mask_sync(struct hci_dev *hdev)
3085{
3086 /* The second byte is 0xff instead of 0x9f (two reserved bits
3087 * disabled) since a Broadcom 1.2 dongle doesn't respond to the
3088 * command otherwise.
3089 */

--- 304 unchanged lines hidden (view full) ---

3394 events[1] |= 0x10; /* LE Extended Advertising Report */
3395
3396 /* If the controller supports the LE Extended Advertising
3397 * command, enable the corresponding event.
3398 */
3399 if (ext_adv_capable(hdev))
3400 events[2] |= 0x02; /* LE Advertising Set Terminated */
3401
3402 if (cis_capable(hdev)) {
3403 events[3] |= 0x01; /* LE CIS Established */
3404 if (cis_peripheral_capable(hdev))
3405 events[3] |= 0x02; /* LE CIS Request */
3406 }
3407
3392 return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_EVENT_MASK,
3393 sizeof(events), events, HCI_CMD_TIMEOUT);
3394}
3395
3396/* Read LE Advertising Channel TX Power */
3397static int hci_le_read_adv_tx_power_sync(struct hci_dev *hdev)
3398{
3399 if ((hdev->commands[25] & 0x40) && !ext_adv_capable(hdev)) {

--- 124 unchanged lines hidden (view full) ---

3524
3525 if (cp.le == lmp_host_le_capable(hdev))
3526 return 0;
3527
3528 return __hci_cmd_sync_status(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED,
3529 sizeof(cp), &cp, HCI_CMD_TIMEOUT);
3530}
3531
3408 return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_EVENT_MASK,
3409 sizeof(events), events, HCI_CMD_TIMEOUT);
3410}
3411
3412/* Read LE Advertising Channel TX Power */
3413static int hci_le_read_adv_tx_power_sync(struct hci_dev *hdev)
3414{
3415 if ((hdev->commands[25] & 0x40) && !ext_adv_capable(hdev)) {

--- 124 unchanged lines hidden (view full) ---

3540
3541 if (cp.le == lmp_host_le_capable(hdev))
3542 return 0;
3543
3544 return __hci_cmd_sync_status(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED,
3545 sizeof(cp), &cp, HCI_CMD_TIMEOUT);
3546}
3547
3548/* LE Set Host Feature */
3549static int hci_le_set_host_feature_sync(struct hci_dev *hdev)
3550{
3551 struct hci_cp_le_set_host_feature cp;
3552
3553 if (!iso_capable(hdev))
3554 return 0;
3555
3556 memset(&cp, 0, sizeof(cp));
3557
3558 /* Isochronous Channels (Host Support) */
3559 cp.bit_number = 32;
3560 cp.bit_value = 1;
3561
3562 return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_HOST_FEATURE,
3563 sizeof(cp), &cp, HCI_CMD_TIMEOUT);
3564}
3565
3532/* LE Controller init stage 3 command sequence */
3533static const struct hci_init_stage le_init3[] = {
3534 /* HCI_OP_LE_SET_EVENT_MASK */
3535 HCI_INIT(hci_le_set_event_mask_sync),
3536 /* HCI_OP_LE_READ_ADV_TX_POWER */
3537 HCI_INIT(hci_le_read_adv_tx_power_sync),
3538 /* HCI_OP_LE_READ_TRANSMIT_POWER */
3539 HCI_INIT(hci_le_read_tx_power_sync),

--- 10 unchanged lines hidden (view full) ---

3550 /* HCI_OP_LE_READ_MAX_DATA_LEN */
3551 HCI_INIT(hci_le_read_max_data_len_sync),
3552 /* HCI_OP_LE_READ_DEF_DATA_LEN */
3553 HCI_INIT(hci_le_read_def_data_len_sync),
3554 /* HCI_OP_LE_READ_NUM_SUPPORTED_ADV_SETS */
3555 HCI_INIT(hci_le_read_num_support_adv_sets_sync),
3556 /* HCI_OP_WRITE_LE_HOST_SUPPORTED */
3557 HCI_INIT(hci_set_le_support_sync),
3566/* LE Controller init stage 3 command sequence */
3567static const struct hci_init_stage le_init3[] = {
3568 /* HCI_OP_LE_SET_EVENT_MASK */
3569 HCI_INIT(hci_le_set_event_mask_sync),
3570 /* HCI_OP_LE_READ_ADV_TX_POWER */
3571 HCI_INIT(hci_le_read_adv_tx_power_sync),
3572 /* HCI_OP_LE_READ_TRANSMIT_POWER */
3573 HCI_INIT(hci_le_read_tx_power_sync),

--- 10 unchanged lines hidden (view full) ---

3584 /* HCI_OP_LE_READ_MAX_DATA_LEN */
3585 HCI_INIT(hci_le_read_max_data_len_sync),
3586 /* HCI_OP_LE_READ_DEF_DATA_LEN */
3587 HCI_INIT(hci_le_read_def_data_len_sync),
3588 /* HCI_OP_LE_READ_NUM_SUPPORTED_ADV_SETS */
3589 HCI_INIT(hci_le_read_num_support_adv_sets_sync),
3590 /* HCI_OP_WRITE_LE_HOST_SUPPORTED */
3591 HCI_INIT(hci_set_le_support_sync),
3592 /* HCI_OP_LE_SET_HOST_FEATURE */
3593 HCI_INIT(hci_le_set_host_feature_sync),
3558 {}
3559};
3560
3561static int hci_init3_sync(struct hci_dev *hdev)
3562{
3563 int err;
3564
3565 bt_dev_dbg(hdev, "");

--- 1866 unchanged lines hidden (view full) ---

5432 HCI_EV_LE_CONN_COMPLETE,
5433 conn->conn_timeout, NULL);
5434
5435done:
5436 /* Re-enable advertising after the connection attempt is finished. */
5437 hci_resume_advertising_sync(hdev);
5438 return err;
5439}
3594 {}
3595};
3596
3597static int hci_init3_sync(struct hci_dev *hdev)
3598{
3599 int err;
3600
3601 bt_dev_dbg(hdev, "");

--- 1866 unchanged lines hidden (view full) ---

5468 HCI_EV_LE_CONN_COMPLETE,
5469 conn->conn_timeout, NULL);
5470
5471done:
5472 /* Re-enable advertising after the connection attempt is finished. */
5473 hci_resume_advertising_sync(hdev);
5474 return err;
5475}
5476
5477int hci_le_remove_cig_sync(struct hci_dev *hdev, u8 handle)
5478{
5479 struct hci_cp_le_remove_cig cp;
5480
5481 memset(&cp, 0, sizeof(cp));
5482 cp.cig_id = handle;
5483
5484 return __hci_cmd_sync_status(hdev, HCI_OP_LE_REMOVE_CIG, sizeof(cp),
5485 &cp, HCI_CMD_TIMEOUT);
5486}