Bluetooth: ISO: Modify and add more debug for setup iso data path

Modify the function slightly to take a different
argument, and add more debugging to the function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2022-01-21 11:37:50 +01:00 committed by Carles Cufí
parent f67e12ae8e
commit bcfb4df390

View file

@ -230,21 +230,18 @@ static void bt_iso_chan_add(struct bt_conn *iso, struct bt_iso_chan *chan)
BT_DBG("iso %p chan %p", iso, chan);
}
static int bt_iso_setup_data_path(struct bt_conn *iso)
static int bt_iso_setup_data_path(struct bt_iso_chan *chan)
{
int err;
struct bt_iso_chan *chan;
struct bt_iso_chan_path default_hci_path = { .pid = BT_ISO_DATA_PATH_HCI };
struct bt_iso_chan_path *out_path = NULL;
struct bt_iso_chan_path *in_path = NULL;
struct bt_iso_chan_io_qos *tx_qos;
struct bt_iso_chan_io_qos *rx_qos;
struct bt_conn *iso;
uint8_t dir;
chan = iso_chan(iso);
if (chan == NULL) {
return -EINVAL;
}
iso = chan->iso;
tx_qos = chan->qos->tx;
rx_qos = chan->qos->rx;
@ -258,7 +255,7 @@ static int bt_iso_setup_data_path(struct bt_conn *iso)
* in the controller.
*/
if (tx_qos != NULL && chan->iso->iso.can_send) {
if (tx_qos != NULL && iso->iso.info.can_send) {
if (tx_qos->path != NULL) { /* Use application path */
in_path = tx_qos->path;
} else { /* else fallback to HCI path */
@ -266,7 +263,7 @@ static int bt_iso_setup_data_path(struct bt_conn *iso)
}
}
if (rx_qos != NULL && chan->iso->iso.can_recv) {
if (rx_qos != NULL && iso->iso.info.can_recv) {
if (rx_qos->path != NULL) { /* Use application path */
out_path = rx_qos->path;
} else { /* else fallback to HCI path */
@ -274,17 +271,33 @@ static int bt_iso_setup_data_path(struct bt_conn *iso)
}
}
__ASSERT(in_path || out_path,
"At least one path shall be shell: in %p out %p",
in_path, out_path);
if (IS_ENABLED(CONFIG_BT_ISO_BROADCASTER) &&
iso->iso.info.type == BT_ISO_CHAN_TYPE_BROADCASTER && in_path) {
dir = BT_HCI_DATAPATH_DIR_HOST_TO_CTLR;
return hci_le_setup_iso_data_path(iso, dir, in_path);
err = hci_le_setup_iso_data_path(iso, dir, in_path);
if (err != 0) {
BT_DBG("Failed to set broadcaster data path: %d", err);
}
return err;
} else if (IS_ENABLED(CONFIG_BT_ISO_SYNC_RECEIVER) &&
iso->iso.info.type == BT_ISO_CHAN_TYPE_SYNC_RECEIVER && out_path) {
iso->iso.info.type == BT_ISO_CHAN_TYPE_SYNC_RECEIVER &&
out_path) {
dir = BT_HCI_DATAPATH_DIR_CTLR_TO_HOST;
return hci_le_setup_iso_data_path(iso, dir, out_path);
err = hci_le_setup_iso_data_path(iso, dir, out_path);
if (err != 0) {
BT_DBG("Failed to set sync receiver data path: %d",
err);
}
return err;
} else if (IS_ENABLED(CONFIG_BT_ISO_UNICAST) &&
iso->iso.info.type == BT_ISO_CHAN_TYPE_CONNECTED) {
if (in_path != NULL && tx_qos->sdu > 0) {
if (in_path != NULL) {
/* Enable TX */
dir = BT_HCI_DATAPATH_DIR_HOST_TO_CTLR;
err = hci_le_setup_iso_data_path(iso, dir, in_path);
@ -293,7 +306,7 @@ static int bt_iso_setup_data_path(struct bt_conn *iso)
}
}
if (out_path != NULL && rx_qos->sdu > 0) {
if (out_path != NULL) {
/* Enable RX */
dir = BT_HCI_DATAPATH_DIR_CTLR_TO_HOST;
err = hci_le_setup_iso_data_path(iso, dir, out_path);
@ -313,6 +326,7 @@ static int bt_iso_setup_data_path(struct bt_conn *iso)
void bt_iso_connected(struct bt_conn *iso)
{
struct bt_iso_chan *chan;
int err;
if (iso == NULL || iso->type != BT_CONN_TYPE_ISO) {
BT_DBG("Invalid parameters: iso %p iso->type %u", iso,
@ -322,8 +336,15 @@ void bt_iso_connected(struct bt_conn *iso)
BT_DBG("%p", iso);
if (bt_iso_setup_data_path(iso)) {
BT_ERR("Unable to setup data path");
chan = iso_chan(iso);
if (chan == NULL) {
BT_ERR("Could not lookup chan from connected ISO");
return;
}
err = bt_iso_setup_data_path(chan);
if (err != 0) {
BT_ERR("Unable to setup data path: %d", err);
#if defined(CONFIG_BT_ISO_BROADCAST)
if (iso->iso.info.type == BT_ISO_CHAN_TYPE_BROADCASTER ||
iso->iso.info.type == BT_ISO_CHAN_TYPE_SYNC_RECEIVER) {
@ -349,12 +370,6 @@ void bt_iso_connected(struct bt_conn *iso)
return;
}
chan = iso_chan(iso);
if (chan == NULL) {
BT_ERR("Could not lookup chan from connected ISO");
return;
}
bt_iso_chan_set_state(chan, BT_ISO_STATE_CONNECTED);
if (chan->ops->connected) {
@ -696,7 +711,7 @@ int bt_iso_chan_send(struct bt_iso_chan *chan, struct net_buf *buf)
}
iso_conn = chan->iso;
if (!iso_conn->iso.can_send) {
if (!iso_conn->iso.info.can_send) {
BT_DBG("Channel not able to send");
return -EINVAL;
}