Lines Matching refs:chan
51 #define iso_chan(_iso) ((_iso)->iso.chan);
100 struct bt_iso_chan *chan = iso->iso.chan; in bt_iso_sent_cb() local
103 __ASSERT(chan != NULL, "NULL chan for iso %p", iso); in bt_iso_sent_cb()
105 ops = chan->ops; in bt_iso_sent_cb()
108 ops->sent(chan); in bt_iso_sent_cb()
242 static void bt_iso_chan_add(struct bt_conn *iso, struct bt_iso_chan *chan) in bt_iso_chan_add() argument
245 chan->iso = iso; in bt_iso_chan_add()
246 iso->iso.chan = chan; in bt_iso_chan_add()
249 LOG_DBG("iso %p chan %p", iso, chan); in bt_iso_chan_add()
252 static int bt_iso_setup_data_path(struct bt_iso_chan *chan) in bt_iso_setup_data_path() argument
265 iso = chan->iso; in bt_iso_setup_data_path()
267 tx_qos = chan->qos->tx; in bt_iso_setup_data_path()
268 rx_qos = chan->qos->rx; in bt_iso_setup_data_path()
347 struct bt_iso_chan *chan; in bt_iso_connected() local
357 chan = iso_chan(iso); in bt_iso_connected()
358 if (chan == NULL) { in bt_iso_connected()
363 err = bt_iso_setup_data_path(chan); in bt_iso_connected()
389 bt_iso_chan_set_state(chan, BT_ISO_STATE_CONNECTED); in bt_iso_connected()
391 if (chan->ops->connected) { in bt_iso_connected()
392 chan->ops->connected(chan); in bt_iso_connected()
396 static void bt_iso_chan_disconnected(struct bt_iso_chan *chan, uint8_t reason) in bt_iso_chan_disconnected() argument
398 LOG_DBG("%p, reason 0x%02x", chan, reason); in bt_iso_chan_disconnected()
400 __ASSERT(chan->iso != NULL, "NULL conn for iso chan %p", chan); in bt_iso_chan_disconnected()
402 bt_iso_chan_set_state(chan, BT_ISO_STATE_DISCONNECTED); in bt_iso_chan_disconnected()
403 bt_conn_set_state(chan->iso, BT_CONN_DISCONNECT_COMPLETE); in bt_iso_chan_disconnected()
409 chan->iso->iso.info.type == BT_ISO_CHAN_TYPE_CONNECTED) { in bt_iso_chan_disconnected()
410 bt_iso_cleanup_acl(chan->iso); in bt_iso_chan_disconnected()
412 if (chan->iso->role == BT_HCI_ROLE_PERIPHERAL) { in bt_iso_chan_disconnected()
413 bt_conn_unref(chan->iso); in bt_iso_chan_disconnected()
414 chan->iso = NULL; in bt_iso_chan_disconnected()
421 bt_iso_remove_data_path(chan->iso); in bt_iso_chan_disconnected()
427 cig = get_cig(chan); in bt_iso_chan_disconnected()
446 if (chan->ops->disconnected) { in bt_iso_chan_disconnected()
447 chan->ops->disconnected(chan, reason); in bt_iso_chan_disconnected()
453 struct bt_iso_chan *chan; in bt_iso_disconnected() local
462 chan = iso_chan(iso); in bt_iso_disconnected()
463 if (chan == NULL) { in bt_iso_disconnected()
468 bt_iso_chan_disconnected(chan, iso->err); in bt_iso_disconnected()
490 void bt_iso_chan_set_state_debug(struct bt_iso_chan *chan, enum bt_iso_state state, in bt_iso_chan_set_state_debug() argument
493 LOG_DBG("chan %p iso %p %s -> %s", chan, chan->iso, bt_iso_chan_state_str(chan->state), in bt_iso_chan_set_state_debug()
504 if (chan->state != BT_ISO_STATE_DISCONNECTED) { in bt_iso_chan_set_state_debug()
509 if (chan->state != BT_ISO_STATE_CONNECTING) { in bt_iso_chan_set_state_debug()
514 if (chan->state != BT_ISO_STATE_CONNECTING && in bt_iso_chan_set_state_debug()
515 chan->state != BT_ISO_STATE_CONNECTED) { in bt_iso_chan_set_state_debug()
524 chan->state = state; in bt_iso_chan_set_state_debug()
527 void bt_iso_chan_set_state(struct bt_iso_chan *chan, enum bt_iso_state state) in bt_iso_chan_set_state() argument
529 chan->state = state; in bt_iso_chan_set_state()
533 int bt_iso_chan_get_info(const struct bt_iso_chan *chan, struct bt_iso_info *info) in bt_iso_chan_get_info() argument
535 CHECKIF(chan == NULL) { in bt_iso_chan_get_info()
540 CHECKIF(chan->iso == NULL) { in bt_iso_chan_get_info()
550 (void)memcpy(info, &chan->iso->iso.info, sizeof(*info)); in bt_iso_chan_get_info()
576 struct bt_iso_chan *chan; in bt_iso_recv() local
707 chan = iso_chan(iso); in bt_iso_recv()
708 if (chan == NULL) { in bt_iso_recv()
710 } else if (chan->ops->recv != NULL) { in bt_iso_recv()
711 chan->ops->recv(chan, iso_info(iso->rx), iso->rx); in bt_iso_recv()
745 if (conn->iso.chan->state != BT_ISO_STATE_CONNECTED) { in iso_data_pull()
785 static uint16_t iso_chan_max_data_len(const struct bt_iso_chan *chan) in iso_chan_max_data_len() argument
790 if (chan->qos->tx == NULL) { in iso_chan_max_data_len()
794 max_data_len = chan->qos->tx->sdu; in iso_chan_max_data_len()
822 static int validate_send(const struct bt_iso_chan *chan, const struct net_buf *buf, in validate_send() argument
828 CHECKIF(!chan || !buf) { in validate_send()
829 LOG_DBG("Invalid parameters: chan %p buf %p", chan, buf); in validate_send()
833 BT_ISO_DATA_DBG("chan %p len %zu", chan, net_buf_frags_len(buf)); in validate_send()
835 if (chan->state != BT_ISO_STATE_CONNECTED) { in validate_send()
836 LOG_DBG("Channel %p not connected", chan); in validate_send()
840 iso_conn = chan->iso; in validate_send()
842 LOG_DBG("Channel %p not able to send", chan); in validate_send()
859 LOG_DBG("Channel %p cannot send ISO packet with buffer size %u", chan, buf->size); in validate_send()
864 max_data_len = iso_chan_max_data_len(chan); in validate_send()
866 LOG_DBG("Channel %p cannot send %u octets, maximum %u", chan, buf->len, in validate_send()
874 int bt_iso_chan_send(struct bt_iso_chan *chan, struct net_buf *buf, uint16_t seq_num) in bt_iso_chan_send() argument
880 err = validate_send(chan, buf, BT_HCI_ISO_SDU_HDR_SIZE); in bt_iso_chan_send()
885 BT_ISO_DATA_DBG("chan %p len %zu", chan, net_buf_frags_len(buf)); in bt_iso_chan_send()
892 iso_conn = chan->iso; in bt_iso_chan_send()
898 int bt_iso_chan_send_ts(struct bt_iso_chan *chan, struct net_buf *buf, uint16_t seq_num, in bt_iso_chan_send_ts() argument
905 err = validate_send(chan, buf, BT_HCI_ISO_SDU_TS_HDR_SIZE); in bt_iso_chan_send_ts()
910 BT_ISO_DATA_DBG("chan %p len %zu", chan, net_buf_frags_len(buf)); in bt_iso_chan_send_ts()
918 iso_conn = chan->iso; in bt_iso_chan_send_ts()
980 int bt_iso_chan_get_tx_sync(const struct bt_iso_chan *chan, struct bt_iso_tx_info *info) in bt_iso_chan_get_tx_sync() argument
988 CHECKIF(chan == NULL) { in bt_iso_chan_get_tx_sync()
993 CHECKIF(chan->iso == NULL) { in bt_iso_chan_get_tx_sync()
1003 CHECKIF(chan->state != BT_ISO_STATE_CONNECTED) { in bt_iso_chan_get_tx_sync()
1013 cp->handle = sys_cpu_to_le16(chan->iso->handle); in bt_iso_chan_get_tx_sync()
1037 int bt_iso_chan_disconnect(struct bt_iso_chan *chan) in bt_iso_chan_disconnect() argument
1041 CHECKIF(!chan) { in bt_iso_chan_disconnect()
1042 LOG_DBG("Invalid parameter: chan %p", chan); in bt_iso_chan_disconnect()
1046 CHECKIF(chan->iso == NULL) { in bt_iso_chan_disconnect()
1051 if (chan->iso->iso.acl == NULL || chan->state == BT_ISO_STATE_DISCONNECTED) { in bt_iso_chan_disconnect()
1056 if (chan->state == BT_ISO_STATE_ENCRYPT_PENDING) { in bt_iso_chan_disconnect()
1058 bt_iso_chan_set_state(chan, BT_ISO_STATE_DISCONNECTED); in bt_iso_chan_disconnect()
1060 if (chan->ops->disconnected) { in bt_iso_chan_disconnect()
1061 chan->ops->disconnected(chan, BT_HCI_ERR_LOCALHOST_TERM_CONN); in bt_iso_chan_disconnect()
1067 if (chan->state == BT_ISO_STATE_DISCONNECTING) { in bt_iso_chan_disconnect()
1073 if (IS_ENABLED(CONFIG_BT_ISO_PERIPHERAL) && chan->iso->role == BT_HCI_ROLE_PERIPHERAL && in bt_iso_chan_disconnect()
1074 chan->state == BT_ISO_STATE_CONNECTING) { in bt_iso_chan_disconnect()
1081 err = bt_conn_disconnect(chan->iso, BT_HCI_ERR_REMOTE_USER_TERM_CONN); in bt_iso_chan_disconnect()
1083 bt_iso_chan_set_state(chan, BT_ISO_STATE_DISCONNECTING); in bt_iso_chan_disconnect()
1110 struct bt_iso_chan *chan; in store_cis_info() local
1113 chan = iso_conn->chan; in store_cis_info()
1114 rx = chan->qos->rx; in store_cis_info()
1115 tx = chan->qos->tx; in store_cis_info()
1117 LOG_DBG("iso_chan %p tx %p rx %p", chan, tx, rx); in store_cis_info()
1229 struct bt_iso_chan *chan; in store_cis_info_v2() local
1236 chan = iso_conn->chan; in store_cis_info_v2()
1237 rx = chan->qos->rx; in store_cis_info_v2()
1238 tx = chan->qos->tx; in store_cis_info_v2()
1401 struct bt_iso_chan *chan; in iso_accept() local
1415 err = iso_server->accept(&accept_info, &chan); in iso_accept()
1422 chan->required_sec_level = iso_server->sec_level; in iso_accept()
1425 bt_iso_chan_add(iso, chan); in iso_accept()
1426 bt_iso_chan_set_state(chan, BT_ISO_STATE_CONNECTING); in iso_accept()
1636 struct bt_iso_chan *chan; in bt_iso_remove_data_path() local
1640 chan = iso_chan(iso); in bt_iso_remove_data_path()
1641 if (chan == NULL) { in bt_iso_remove_data_path()
1645 tx_qos = chan->qos->tx; in bt_iso_remove_data_path()