From 06900485ecc85d2131459fc786ade1ecc288ad52 Mon Sep 17 00:00:00 2001 From: Morten Priess Date: Tue, 5 Oct 2021 15:33:39 +0200 Subject: [PATCH] Bluetooth: host: Add bt_configure_data_path for vendor data path Implemented host function for configuring vendor specific data path for use with ISO, and fixed passing of path ID in setup. Signed-off-by: Morten Priess --- include/bluetooth/bluetooth.h | 17 +++++++++++++++ subsys/bluetooth/host/hci_core.c | 37 ++++++++++++++++++++++++++++++++ subsys/bluetooth/host/iso.c | 11 +++------- 3 files changed, 57 insertions(+), 8 deletions(-) diff --git a/include/bluetooth/bluetooth.h b/include/bluetooth/bluetooth.h index c365ff15556..a1250c3e7ed 100644 --- a/include/bluetooth/bluetooth.h +++ b/include/bluetooth/bluetooth.h @@ -2169,6 +2169,23 @@ void bt_foreach_bond(uint8_t id, void (*func)(const struct bt_bond_info *info, void *user_data), void *user_data); +/** @brief Configure vendor data path + * + * Request the Controller to configure the data transport path in a given direction between + * the Controller and the Host. + * + * @param dir Direction to be configured, BT_HCI_DATAPATH_DIR_HOST_TO_CTLR or + * BT_HCI_DATAPATH_DIR_CTLR_TO_HOST + * @param id Vendor specific logical transport channel ID, range + * [BT_HCI_DATAPATH_ID_VS..BT_HCI_DATAPATH_ID_VS_END] + * @param vs_config_len Length of additional vendor specific configuration data + * @param vs_config Pointer to additional vendor specific configuration data + * + * @return 0 in case of success or negative value in case of error. + */ +int bt_configure_data_path(uint8_t dir, uint8_t id, uint8_t vs_config_len, + const uint8_t *vs_config); + /** * @} */ diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index 4d43a32e2ab..952660e51ca 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -3801,3 +3801,40 @@ void bt_data_parse(struct net_buf_simple *ad, net_buf_simple_pull(ad, len - 1); } } + +int bt_configure_data_path(uint8_t dir, uint8_t id, uint8_t vs_config_len, + const uint8_t *vs_config) +{ + struct bt_hci_rp_configure_data_path *rp; + struct bt_hci_cp_configure_data_path *cp; + struct net_buf *rsp; + struct net_buf *buf; + int err; + + buf = bt_hci_cmd_create(BT_HCI_OP_CONFIGURE_DATA_PATH, sizeof(*cp) + + vs_config_len); + if (!buf) { + return -ENOBUFS; + } + + cp = net_buf_add(buf, sizeof(*cp)); + cp->data_path_dir = dir; + cp->data_path_id = id; + cp->vs_config_len = vs_config_len; + if (vs_config_len) { + (void)memcpy(cp->vs_config, vs_config, vs_config_len); + } + + err = bt_hci_cmd_send_sync(BT_HCI_OP_CONFIGURE_DATA_PATH, buf, &rsp); + if (err) { + return err; + } + + rp = (void *)rsp->data; + if (rp->status) { + err = -EIO; + } + net_buf_unref(rsp); + + return err; +} diff --git a/subsys/bluetooth/host/iso.c b/subsys/bluetooth/host/iso.c index f44d5a373ae..00a4f6660d1 100644 --- a/subsys/bluetooth/host/iso.c +++ b/subsys/bluetooth/host/iso.c @@ -292,15 +292,10 @@ static int bt_iso_setup_data_path(struct bt_conn *iso) rx_qos = chan->qos->rx; in_path.path = tx_qos && tx_qos->path ? tx_qos->path : &default_path; + in_path.pid = tx_qos ? tx_qos->path->pid : BT_ISO_DATA_PATH_DISABLED; + out_path.path = rx_qos && rx_qos->path ? rx_qos->path : &default_path; - - if (!tx_qos) { - in_path.pid = BT_ISO_DATA_PATH_DISABLED; - } - - if (!rx_qos) { - out_path.pid = BT_ISO_DATA_PATH_DISABLED; - } + out_path.pid = rx_qos ? rx_qos->path->pid : BT_ISO_DATA_PATH_DISABLED; if (iso->iso.is_bis) { /* Only set one data path for BIS as per the spec */