Lines Matching refs:iso
51 #define iso_chan(_iso) ((_iso)->iso.chan);
80 static void bt_iso_remove_data_path(struct bt_conn *iso);
97 static void bt_iso_sent_cb(struct bt_conn *iso, void *user_data, int err) in bt_iso_sent_cb() argument
100 struct bt_iso_chan *chan = iso->iso.chan; in bt_iso_sent_cb()
103 __ASSERT(chan != NULL, "NULL chan for iso %p", iso); in bt_iso_sent_cb()
117 struct bt_conn *iso; in hci_iso() local
133 iso(buf)->handle = bt_iso_handle(handle); in hci_iso()
134 iso(buf)->index = BT_CONN_INDEX_INVALID; in hci_iso()
136 BT_ISO_DATA_DBG("handle %u len %u flags %u", iso(buf)->handle, len, flags); in hci_iso()
144 iso = bt_conn_lookup_handle(iso(buf)->handle, BT_CONN_TYPE_ISO); in hci_iso()
145 if (iso == NULL) { in hci_iso()
146 LOG_ERR("Unable to find conn for handle %u", iso(buf)->handle); in hci_iso()
151 iso(buf)->index = bt_conn_index(iso); in hci_iso()
153 bt_conn_recv(iso, buf, flags); in hci_iso()
154 bt_conn_unref(iso); in hci_iso()
177 struct bt_conn *iso = bt_conn_new(iso_conns, ARRAY_SIZE(iso_conns)); in iso_new() local
179 if (iso) { in iso_new()
180 iso->type = BT_CONN_TYPE_ISO; in iso_new()
181 iso->tx_data_pull = iso_data_pull; in iso_new()
182 iso->get_and_clear_cb = iso_get_and_clear_cb; in iso_new()
183 iso->has_data = iso_has_data; in iso_new()
188 return iso; in iso_new()
191 static int hci_le_setup_iso_data_path(const struct bt_conn *iso, uint8_t dir, in hci_le_setup_iso_data_path() argument
215 cp->handle = sys_cpu_to_le16(iso->handle); in hci_le_setup_iso_data_path()
233 if (rp->status || (sys_le16_to_cpu(rp->handle) != iso->handle)) { in hci_le_setup_iso_data_path()
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()
247 k_fifo_init(&iso->iso.txq); in bt_iso_chan_add()
249 LOG_DBG("iso %p chan %p", iso, chan); in bt_iso_chan_add()
262 struct bt_conn *iso; in bt_iso_setup_data_path() local
265 iso = chan->iso; in bt_iso_setup_data_path()
279 if (tx_qos != NULL && iso->iso.info.can_send) { in bt_iso_setup_data_path()
287 if (rx_qos != NULL && iso->iso.info.can_recv) { in bt_iso_setup_data_path()
299 iso->iso.info.type == BT_ISO_CHAN_TYPE_BROADCASTER && in_path) { in bt_iso_setup_data_path()
301 err = hci_le_setup_iso_data_path(iso, dir, in_path); in bt_iso_setup_data_path()
308 iso->iso.info.type == BT_ISO_CHAN_TYPE_SYNC_RECEIVER && out_path) { in bt_iso_setup_data_path()
310 err = hci_le_setup_iso_data_path(iso, dir, out_path); in bt_iso_setup_data_path()
317 iso->iso.info.type == BT_ISO_CHAN_TYPE_CONNECTED) { in bt_iso_setup_data_path()
321 err = hci_le_setup_iso_data_path(iso, dir, in_path); in bt_iso_setup_data_path()
331 err = hci_le_setup_iso_data_path(iso, dir, out_path); in bt_iso_setup_data_path()
340 __ASSERT(false, "Invalid iso.info.type: %u", iso->iso.info.type); in bt_iso_setup_data_path()
345 void bt_iso_connected(struct bt_conn *iso) in bt_iso_connected() argument
350 if (iso == NULL || iso->type != BT_CONN_TYPE_ISO) { in bt_iso_connected()
351 LOG_DBG("Invalid parameters: iso %p iso->type %u", iso, iso ? iso->type : 0); in bt_iso_connected()
355 LOG_DBG("%p", iso); in bt_iso_connected()
357 chan = iso_chan(iso); in bt_iso_connected()
368 } else if (iso->iso.info.type == BT_ISO_CHAN_TYPE_BROADCASTER || in bt_iso_connected()
369 iso->iso.info.type == BT_ISO_CHAN_TYPE_SYNC_RECEIVER) { in bt_iso_connected()
372 big = lookup_big_by_handle(iso->iso.big_handle); in bt_iso_connected()
381 iso->iso.info.type == BT_ISO_CHAN_TYPE_CONNECTED) { in bt_iso_connected()
382 bt_conn_disconnect(iso, BT_HCI_ERR_REMOTE_USER_TERM_CONN); in bt_iso_connected()
384 __ASSERT(false, "Invalid iso.info.type: %u", iso->iso.info.type); in bt_iso_connected()
400 __ASSERT(chan->iso != NULL, "NULL conn for iso chan %p", chan); 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()
451 void bt_iso_disconnected(struct bt_conn *iso) in bt_iso_disconnected() argument
455 if (iso == NULL || iso->type != BT_CONN_TYPE_ISO) { in bt_iso_disconnected()
456 LOG_DBG("Invalid parameters: iso %p iso->type %u", iso, iso ? iso->type : 0); in bt_iso_disconnected()
460 LOG_DBG("%p", iso); in bt_iso_disconnected()
462 chan = iso_chan(iso); in bt_iso_disconnected()
468 bt_iso_chan_disconnected(chan, iso->err); in bt_iso_disconnected()
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()
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()
573 void bt_iso_recv(struct bt_conn *iso, struct net_buf *buf, uint8_t flags) in bt_iso_recv() argument
583 BT_ISO_DATA_DBG("handle %u len %u flags 0x%02x pb 0x%02x ts 0x%02x", iso->handle, buf->len, in bt_iso_recv()
632 if (iso->rx) { in bt_iso_recv()
635 bt_conn_reset_rx_state(iso); in bt_iso_recv()
638 iso->rx = buf; in bt_iso_recv()
639 iso->rx_len = len - buf->len; in bt_iso_recv()
640 if (iso->rx_len) { in bt_iso_recv()
646 bt_conn_reset_rx_state(iso); in bt_iso_recv()
656 if (!iso->rx) { in bt_iso_recv()
662 BT_ISO_DATA_DBG("Cont, len %u rx_len %u", buf->len, iso->rx_len); in bt_iso_recv()
664 if (buf->len > net_buf_tailroom(iso->rx)) { in bt_iso_recv()
666 bt_conn_reset_rx_state(iso); in bt_iso_recv()
671 net_buf_add_mem(iso->rx, buf->data, buf->len); in bt_iso_recv()
672 iso->rx_len -= buf->len; in bt_iso_recv()
680 BT_ISO_DATA_DBG("End, len %u rx_len %u", buf->len, iso->rx_len); in bt_iso_recv()
682 if (iso->rx == NULL) { in bt_iso_recv()
688 if (buf->len > net_buf_tailroom(iso->rx)) { in bt_iso_recv()
690 bt_conn_reset_rx_state(iso); in bt_iso_recv()
695 (void)net_buf_add_mem(iso->rx, buf->data, buf->len); in bt_iso_recv()
696 iso->rx_len -= buf->len; in bt_iso_recv()
702 bt_conn_reset_rx_state(iso); in bt_iso_recv()
707 chan = iso_chan(iso); in bt_iso_recv()
711 chan->ops->recv(chan, iso_info(iso->rx), iso->rx); in bt_iso_recv()
714 bt_conn_reset_rx_state(iso); in bt_iso_recv()
721 return !k_fifo_is_empty(&conn->iso.txq); in iso_has_data()
735 struct net_buf *frag = k_fifo_peek_head(&conn->iso.txq); in iso_data_pull()
745 if (conn->iso.chan->state != BT_ISO_STATE_CONNECTED) { in iso_data_pull()
746 __maybe_unused struct net_buf *b = k_fifo_get(&conn->iso.txq, K_NO_WAIT); in iso_data_pull()
770 __maybe_unused struct net_buf *b = k_fifo_get(&conn->iso.txq, K_NO_WAIT); in iso_data_pull()
813 k_fifo_put(&conn->iso.txq, buf); in conn_iso_send()
840 iso_conn = chan->iso; in validate_send()
841 if (!iso_conn->iso.info.can_send) { in validate_send()
892 iso_conn = chan->iso; in bt_iso_chan_send()
918 iso_conn = chan->iso; in bt_iso_chan_send_ts()
993 CHECKIF(chan->iso == NULL) { in bt_iso_chan_get_tx_sync()
1013 cp->handle = sys_cpu_to_le16(chan->iso->handle); in bt_iso_chan_get_tx_sync()
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()
1073 if (IS_ENABLED(CONFIG_BT_ISO_PERIPHERAL) && chan->iso->role == BT_HCI_ROLE_PERIPHERAL && in bt_iso_chan_disconnect()
1081 err = bt_conn_disconnect(chan->iso, BT_HCI_ERR_REMOTE_USER_TERM_CONN); in bt_iso_chan_disconnect()
1089 void bt_iso_cleanup_acl(struct bt_conn *iso) in bt_iso_cleanup_acl() argument
1091 LOG_DBG("%p", iso); in bt_iso_cleanup_acl()
1093 if (iso->iso.acl) { in bt_iso_cleanup_acl()
1094 bt_conn_unref(iso->iso.acl); in bt_iso_cleanup_acl()
1095 iso->iso.acl = NULL; in bt_iso_cleanup_acl()
1099 static void store_cis_info(const struct bt_hci_evt_le_cis_established *evt, struct bt_conn *iso) in store_cis_info() argument
1101 struct bt_conn_iso *iso_conn = &iso->iso; in store_cis_info()
1112 iso_conn = &iso->iso; in store_cis_info()
1119 if (iso->role == BT_HCI_ROLE_PERIPHERAL) { in store_cis_info()
1157 if (iso->role == BT_HCI_ROLE_PERIPHERAL && evt->p_bn > 0) { in store_cis_info()
1159 } else if (iso->role == BT_HCI_ROLE_CENTRAL && evt->c_bn > 0) { in store_cis_info()
1167 if (iso->role == BT_HCI_ROLE_PERIPHERAL && evt->c_bn > 0) { in store_cis_info()
1169 } else if (iso->role == BT_HCI_ROLE_CENTRAL && evt->p_bn > 0) { in store_cis_info()
1199 if (iso->role == BT_HCI_ROLE_PERIPHERAL) { in store_cis_info()
1218 struct bt_conn *iso) in store_cis_info_v2() argument
1220 struct bt_conn_iso *iso_conn = &iso->iso; in store_cis_info_v2()
1234 store_cis_info((const struct bt_hci_evt_le_cis_established *)evt, iso); in store_cis_info_v2()
1240 if (iso->role == BT_HCI_ROLE_PERIPHERAL) { in store_cis_info_v2()
1281 struct bt_conn *iso; in hci_le_cis_established() local
1286 iso = bt_conn_lookup_handle(handle, BT_CONN_TYPE_ISO); in hci_le_cis_established()
1287 if (!iso) { in hci_le_cis_established()
1300 store_cis_info(evt, iso); in hci_le_cis_established()
1301 bt_conn_set_state(iso, BT_CONN_CONNECTED); in hci_le_cis_established()
1302 } else if (iso->role == BT_HCI_ROLE_PERIPHERAL || in hci_le_cis_established()
1304 iso->err = evt->status; in hci_le_cis_established()
1305 bt_iso_disconnected(iso); in hci_le_cis_established()
1308 bt_conn_unref(iso); in hci_le_cis_established()
1315 struct bt_conn *iso; in hci_le_cis_established_v2() local
1320 iso = bt_conn_lookup_handle(handle, BT_CONN_TYPE_ISO); in hci_le_cis_established_v2()
1321 if (!iso) { in hci_le_cis_established_v2()
1334 store_cis_info_v2(evt, iso); in hci_le_cis_established_v2()
1335 bt_conn_set_state(iso, BT_CONN_CONNECTED); in hci_le_cis_established_v2()
1336 } else if (iso->role == BT_HCI_ROLE_PERIPHERAL || in hci_le_cis_established_v2()
1338 iso->err = evt->status; in hci_le_cis_established_v2()
1339 bt_iso_disconnected(iso); in hci_le_cis_established_v2()
1342 bt_conn_unref(iso); in hci_le_cis_established_v2()
1398 static int iso_accept(struct bt_conn *acl, struct bt_conn *iso) in iso_accept() argument
1404 CHECKIF(!iso || iso->type != BT_CONN_TYPE_ISO) { in iso_accept()
1405 LOG_DBG("Invalid parameters: iso %p iso->type %u", iso, iso ? iso->type : 0); in iso_accept()
1409 LOG_DBG("%p", iso); in iso_accept()
1412 accept_info.cig_id = iso->iso.cig_id; in iso_accept()
1413 accept_info.cis_id = iso->iso.cis_id; in iso_accept()
1425 bt_iso_chan_add(iso, chan); in iso_accept()
1498 struct bt_conn *acl, *iso; in hci_le_cis_req() local
1512 iso = bt_conn_lookup_handle(cis_handle, BT_CONN_TYPE_ISO); in hci_le_cis_req()
1513 if (iso) { in hci_le_cis_req()
1516 bt_conn_unref(iso); in hci_le_cis_req()
1541 iso = bt_conn_add_iso(acl); in hci_le_cis_req()
1545 if (!iso) { in hci_le_cis_req()
1551 iso->iso.info.type = BT_ISO_CHAN_TYPE_CONNECTED; in hci_le_cis_req()
1552 iso->iso.cig_id = evt->cig_id; in hci_le_cis_req()
1553 iso->iso.cis_id = evt->cis_id; in hci_le_cis_req()
1556 err = iso_accept(acl, iso); in hci_le_cis_req()
1559 bt_iso_cleanup_acl(iso); in hci_le_cis_req()
1560 bt_conn_unref(iso); in hci_le_cis_req()
1565 iso->handle = cis_handle; in hci_le_cis_req()
1566 iso->role = BT_HCI_ROLE_PERIPHERAL; in hci_le_cis_req()
1567 bt_conn_set_state(iso, BT_CONN_INITIATING); in hci_le_cis_req()
1571 bt_iso_cleanup_acl(iso); in hci_le_cis_req()
1572 bt_conn_unref(iso); in hci_le_cis_req()
1580 struct bt_conn *iso = iso_new(); in bt_conn_add_iso() local
1582 if (iso == NULL) { in bt_conn_add_iso()
1587 iso->iso.acl = bt_conn_ref(acl); in bt_conn_add_iso()
1589 return iso; in bt_conn_add_iso()
1594 static int hci_le_remove_iso_data_path(struct bt_conn *iso, uint8_t dir) in hci_le_remove_iso_data_path() argument
1607 cp->handle = sys_cpu_to_le16(iso->handle); in hci_le_remove_iso_data_path()
1616 if (rp->status || (sys_le16_to_cpu(rp->handle) != iso->handle)) { in hci_le_remove_iso_data_path()
1625 static void bt_iso_remove_data_path(struct bt_conn *iso) in bt_iso_remove_data_path() argument
1627 enum bt_iso_chan_type type = iso->iso.info.type; in bt_iso_remove_data_path()
1629 LOG_DBG("%p", iso); in bt_iso_remove_data_path()
1640 chan = iso_chan(iso); in bt_iso_remove_data_path()
1654 (void)hci_le_remove_iso_data_path(iso, dir); in bt_iso_remove_data_path()
1661 (void)hci_le_remove_iso_data_path(iso, BIT(BT_HCI_DATAPATH_DIR_HOST_TO_CTLR)); in bt_iso_remove_data_path()
1662 (void)hci_le_remove_iso_data_path(iso, BIT(BT_HCI_DATAPATH_DIR_CTLR_TO_HOST)); in bt_iso_remove_data_path()
1762 cis_param->cis_id = cis->iso->iso.cis_id; in hci_le_set_cig_params()
1852 cis_param->cis_id = cis->iso->iso.cis_id; in hci_le_set_cig_test_params()
1934 if (iso_chan == NULL || iso_chan->iso == NULL) { in get_cig()
1938 __ASSERT(iso_chan->iso->iso.cig_id < ARRAY_SIZE(cigs), "Invalid cig_id %u", in get_cig()
1939 iso_chan->iso->iso.cig_id); in get_cig()
1941 return &cigs[iso_chan->iso->iso.cig_id]; in get_cig()
1964 if (cig == NULL || cis == NULL || cis->iso == NULL) { in cis_is_in_cig()
1968 return cig->id == cis->iso->iso.cig_id; in cis_is_in_cig()
1976 if (cis->iso == NULL) { in cig_init_cis()
1979 cis->iso = iso_new(); in cig_init_cis()
1980 if (cis->iso == NULL) { in cig_init_cis()
1984 iso_conn = &cis->iso->iso; in cig_init_cis()
1990 bt_iso_chan_add(cis->iso, cis); in cig_init_cis()
2004 if (cis->iso != NULL) { in cleanup_cig()
2005 bt_conn_unref(cis->iso); in cleanup_cig()
2006 cis->iso = NULL; in cleanup_cig()
2038 if (cis->iso != NULL && !cis_is_in_cig(cig, cis)) { in valid_cig_param()
2224 cis->iso->handle = sys_le16_to_cpu(handle); in bt_iso_cig_create()
2243 if (cis->iso != NULL && cis->iso->iso.cis_id >= existing_num_cis) { in restore_cig()
2244 bt_conn_unref(cis->iso); in restore_cig()
2245 cis->iso = NULL; in restore_cig()
2335 cis->iso->handle = sys_le16_to_cpu(handle); in bt_iso_cig_reconfigure()
2384 struct bt_conn *iso = &iso_conns[i]; in bt_iso_security_changed() local
2387 if (iso == NULL || iso->iso.acl != acl) { in bt_iso_security_changed()
2391 iso_chan = iso_chan(iso); in bt_iso_security_changed()
2408 LOG_DBG("Failed to encrypt ACL %p for ISO %p: %u %s", acl, iso, hci_status, in bt_iso_security_changed()
2453 bt_conn_set_state(iso_chan->iso, BT_CONN_INITIATING); in bt_iso_security_changed()
2485 cis->cis_handle = sys_cpu_to_le16(param[i].iso_chan->iso->handle); in hci_le_create_cis()
2530 bt_iso_cleanup_acl(iso_chan->iso); in iso_chan_connect_security()
2541 iso_chan->iso->iso.acl = bt_conn_ref(acl); in iso_chan_connect_security()
2553 const struct bt_conn *iso = &iso_conns[i]; in iso_chans_connecting() local
2556 if (iso == NULL || iso->iso.info.type != BT_ISO_CHAN_TYPE_CONNECTED) { in iso_chans_connecting()
2560 iso_chan = iso_chan(iso); in iso_chans_connecting()
2606 if (param[i].iso_chan->iso == NULL) { in bt_iso_chan_connect()
2654 iso_chan->iso->iso.acl = bt_conn_ref(param[i].acl); in bt_iso_chan_connect()
2655 bt_conn_set_state(iso_chan->iso, BT_CONN_INITIATING); in bt_iso_chan_connect()
2713 if (bis->iso != NULL) { in cleanup_big()
2714 bt_conn_unref(bis->iso); in cleanup_big()
2715 bis->iso = NULL; in cleanup_big()
2729 bis->iso->err = reason; in big_disconnect()
2752 bis->iso = iso_new(); in big_init_bis()
2754 if (!bis->iso) { in big_init_bis()
2758 iso_conn = &bis->iso->iso; in big_init_bis()
2763 iso_conn->bis_id = bt_conn_index(bis->iso); in big_init_bis()
2765 bt_iso_chan_add(bis->iso, bis); in big_init_bis()
2966 if (bis->iso) { in valid_big_param()
3175 struct bt_conn *iso_conn = bis->iso; in hci_le_big_complete()
3178 store_bis_broadcaster_info(evt, &iso_conn->iso.info); in hci_le_big_complete()
3278 bis->iso->iso.info.type == BT_ISO_CHAN_TYPE_BROADCASTER) { in bt_iso_big_terminate()
3290 bis->iso->iso.info.type == BT_ISO_CHAN_TYPE_SYNC_RECEIVER) { in bt_iso_big_terminate()
3365 struct bt_conn *iso_conn = bis->iso; in hci_le_big_sync_established()
3368 store_bis_sync_receiver_info(evt, &iso_conn->iso.info); in hci_le_big_sync_established()
3511 if (param_bis->iso) { in bt_iso_big_sync()
3574 bt_iso_cleanup_acl(cis->iso); in bt_iso_reset()