Lines Matching full:cis
69 static void cig_offset_get(struct ll_conn_iso_stream *cis);
71 static void cis_offset_get(struct ll_conn_iso_stream *cis);
157 struct ll_conn_iso_stream *cis; in ll_cig_parameters_commit() local
270 cis = ll_conn_iso_stream_get_by_id(ll_iso_setup.stream[i].cis_id); in ll_cig_parameters_commit()
271 if (cis) { in ll_cig_parameters_commit()
275 if ((cis->c_max_sdu && cis->hdr.datapath_in && in ll_cig_parameters_commit()
277 (cis->p_max_sdu && cis->hdr.datapath_out && in ll_cig_parameters_commit()
279 /* Reconfiguring CIS with datapath to wrong direction is in ll_cig_parameters_commit()
286 /* Acquire new CIS */ in ll_cig_parameters_commit()
287 cis = ll_conn_iso_stream_acquire(); in ll_cig_parameters_commit()
288 if (!cis) { in ll_cig_parameters_commit()
289 /* No space for new CIS */ in ll_cig_parameters_commit()
296 cis_created_handles[i] = ll_conn_iso_stream_handle_get(cis); in ll_cig_parameters_commit()
301 link_tx_free = cis->lll.link_tx_free; in ll_cig_parameters_commit()
302 link_tx = cis->lll.link_tx; in ll_cig_parameters_commit()
305 memcpy(cis, &ll_iso_setup.stream[i], sizeof(struct ll_conn_iso_stream)); in ll_cig_parameters_commit()
307 cis->group = cig; in ll_cig_parameters_commit()
308 cis->framed = cig->central.framing || force_framed; in ll_cig_parameters_commit()
310 cis->lll.link_tx_free = link_tx_free; in ll_cig_parameters_commit()
311 cis->lll.link_tx = link_tx; in ll_cig_parameters_commit()
312 cis->lll.handle = ll_conn_iso_stream_handle_get(cis); in ll_cig_parameters_commit()
313 handles[i] = cis->lll.handle; in ll_cig_parameters_commit()
321 /* 1) Acquire CIS instances and initialize instance data. in ll_cig_parameters_commit()
322 * 2) Calculate SE_Length for each CIS and store the largest in ll_cig_parameters_commit()
341 cis = ll_conn_iso_stream_get_by_group(cig, &handle_iter); in ll_cig_parameters_commit()
344 cis->lll.tx.ft = ll_iso_setup.c_ft; in ll_cig_parameters_commit()
345 cis->lll.rx.ft = ll_iso_setup.p_ft; in ll_cig_parameters_commit()
347 tx = cis->lll.tx.bn && cis->lll.tx.max_pdu; in ll_cig_parameters_commit()
348 rx = cis->lll.rx.bn && cis->lll.rx.max_pdu; in ll_cig_parameters_commit()
350 LL_ASSERT(cis->framed || iso_interval_us >= cig->c_sdu_interval); in ll_cig_parameters_commit()
352 tx = cig->c_sdu_interval && cis->c_max_sdu; in ll_cig_parameters_commit()
353 rx = cig->p_sdu_interval && cis->p_max_sdu; in ll_cig_parameters_commit()
358 cis->lll.tx.max_pdu = MIN(LL_CIS_OCTETS_TX_MAX, in ll_cig_parameters_commit()
359 cis->c_max_sdu); in ll_cig_parameters_commit()
360 cis->lll.rx.max_pdu = MIN(LL_CIS_OCTETS_RX_MAX, in ll_cig_parameters_commit()
361 cis->p_max_sdu); in ll_cig_parameters_commit()
371 bn = cis->lll.tx.bn; in ll_cig_parameters_commit()
372 max_pdu = cis->lll.tx.max_pdu; in ll_cig_parameters_commit()
374 iso_interval_adjusted_bn_max_pdu_get(cis->framed, in ll_cig_parameters_commit()
376 cig->c_sdu_interval, cis->c_max_sdu, &bn, &max_pdu); in ll_cig_parameters_commit()
382 cis->lll.tx.bn = bn; in ll_cig_parameters_commit()
383 cis->lll.tx.max_pdu = max_pdu; in ll_cig_parameters_commit()
385 cis->lll.tx.bn = 0U; in ll_cig_parameters_commit()
393 bn = cis->lll.rx.bn; in ll_cig_parameters_commit()
394 max_pdu = cis->lll.rx.max_pdu; in ll_cig_parameters_commit()
396 iso_interval_adjusted_bn_max_pdu_get(cis->framed, in ll_cig_parameters_commit()
398 cig->p_sdu_interval, cis->p_max_sdu, &bn, &max_pdu); in ll_cig_parameters_commit()
404 cis->lll.rx.bn = bn; in ll_cig_parameters_commit()
405 cis->lll.rx.max_pdu = max_pdu; in ll_cig_parameters_commit()
407 cis->lll.rx.bn = 0U; in ll_cig_parameters_commit()
412 mpt_c = PDU_CIS_MAX_US(cis->lll.tx.max_pdu, tx, cis->lll.tx.phy); in ll_cig_parameters_commit()
413 mpt_p = PDU_CIS_MAX_US(cis->lll.rx.max_pdu, rx, cis->lll.rx.phy); in ll_cig_parameters_commit()
419 se[i].total_count = MAX((cis->central.c_rtn + 1) * cis->lll.tx.bn, in ll_cig_parameters_commit()
420 (cis->central.p_rtn + 1) * cis->lll.rx.bn); in ll_cig_parameters_commit()
448 * 3) Calculate subinterval as either individual CIS subinterval (sequential), or the in ll_cig_parameters_commit()
453 cis = ll_conn_iso_stream_get_by_group(cig, &handle_iter); in ll_cig_parameters_commit()
461 cis->lll.tx.ft = DIV_ROUND_UP(total_time, iso_interval_us); in ll_cig_parameters_commit()
462 cis->lll.rx.ft = cis->lll.tx.ft; in ll_cig_parameters_commit()
470 * and spreads out payloads over multiple CIS events (if necessary). in ll_cig_parameters_commit()
474 cis->lll.tx.ft = ll_cis_calculate_ft(cig_sync_delay_us_max, iso_interval_us, in ll_cig_parameters_commit()
476 cis->framed); in ll_cig_parameters_commit()
478 cis->lll.rx.ft = ll_cis_calculate_ft(cig_sync_delay_us_max, iso_interval_us, in ll_cig_parameters_commit()
480 cis->framed); in ll_cig_parameters_commit()
482 if ((cis->lll.tx.ft == 0U) || (cis->lll.rx.ft == 0U)) { in ll_cig_parameters_commit()
491 cis->lll.nse = DIV_ROUND_UP(se[i].total_count, cis->lll.tx.ft); in ll_cig_parameters_commit()
496 cis->lll.sub_interval = MAX(SUB_INTERVAL_MIN, se[i].length); in ll_cig_parameters_commit()
497 cig_sync_delay += cis->lll.nse * cis->lll.sub_interval; in ll_cig_parameters_commit()
499 /* For interleaved CISes, offset each CIS by a fraction of a subinterval, in ll_cig_parameters_commit()
502 cis->lll.sub_interval = MAX(SUB_INTERVAL_MIN, num_cis * max_se_length); in ll_cig_parameters_commit()
504 (cis->lll.nse * cis->lll.sub_interval) + in ll_cig_parameters_commit()
505 (i * cis->lll.sub_interval / num_cis)); in ll_cig_parameters_commit()
515 /* 1) Calculate transport latencies for each CIS and validate against Max_Transport_Latency. in ll_cig_parameters_commit()
522 cis = ll_conn_iso_stream_get_by_group(cig, &handle_iter); in ll_cig_parameters_commit()
524 if (cis->framed) { in ll_cig_parameters_commit()
527 (cis->lll.tx.ft * iso_interval_us) + in ll_cig_parameters_commit()
530 (cis->lll.rx.ft * iso_interval_us) + in ll_cig_parameters_commit()
536 (cis->lll.tx.ft * iso_interval_us) - in ll_cig_parameters_commit()
539 (cis->lll.rx.ft * iso_interval_us) - in ll_cig_parameters_commit()
547 if (!cis->central.c_rtn && !cis->central.p_rtn) { in ll_cig_parameters_commit()
559 if (cis->central.c_rtn) { in ll_cig_parameters_commit()
560 cis->central.c_rtn--; in ll_cig_parameters_commit()
562 if (cis->central.p_rtn) { in ll_cig_parameters_commit()
563 cis->central.p_rtn--; in ll_cig_parameters_commit()
575 cis->sync_delay = cig_sync_delay; in ll_cig_parameters_commit()
576 cig_sync_delay -= cis->lll.nse * cis->lll.sub_interval; in ll_cig_parameters_commit()
579 cis->sync_delay = cig_sync_delay; in ll_cig_parameters_commit()
580 cig_sync_delay -= (cis->lll.sub_interval / num_cis); in ll_cig_parameters_commit()
583 if (cis->lll.nse <= 1) { in ll_cig_parameters_commit()
584 cis->lll.sub_interval = 0U; in ll_cig_parameters_commit()
620 /* Release CIS instance created in failing configuration */ in ll_cig_parameters_commit()
621 cis = ll_conn_iso_stream_get(cis_created_handles[i]); in ll_cig_parameters_commit()
622 ll_conn_iso_stream_release(cis); in ll_cig_parameters_commit()
700 struct ll_conn_iso_stream *cis; in ll_cis_create_check() local
708 cis = ll_conn_iso_stream_get(cis_handle); in ll_cis_create_check()
710 if (cis->group && (cis->lll.handle == cis_handle)) { in ll_cis_create_check()
711 if (cis->established) { in ll_cis_create_check()
712 /* CIS is already created */ in ll_cis_create_check()
725 struct ll_conn_iso_stream *cis; in ll_cis_create() local
731 cis = ll_conn_iso_stream_get(cis_handle); in ll_cis_create()
732 cis->lll.acl_handle = acl_handle; in ll_cis_create()
735 err = util_aa_le32(cis->lll.access_addr); in ll_cis_create()
739 cis->established = 0; in ll_cis_create()
740 cis->teardown = 0; in ll_cis_create()
742 (void)memset(&cis->hdr, 0U, sizeof(cis->hdr)); in ll_cis_create()
745 if (!cis->lll.link_tx_free) { in ll_cis_create()
746 cis->lll.link_tx_free = &cis->lll.link_tx; in ll_cis_create()
749 memq_init(cis->lll.link_tx_free, &cis->lll.memq_tx.head, &cis->lll.memq_tx.tail); in ll_cis_create()
750 cis->lll.link_tx_free = NULL; in ll_cis_create()
752 /* Initiate CIS Request Control Procedure */ in ll_cis_create()
753 if (ull_cp_cis_create(conn, cis) == BT_HCI_ERR_SUCCESS) { in ll_cis_create()
754 LL_ASSERT(cis->group); in ll_cis_create()
756 if (cis->group->state == CIG_STATE_CONFIGURABLE) { in ll_cis_create()
758 cis->group->state = CIG_STATE_INITIATING; in ll_cis_create()
767 * of the CIS configurations stored in the CIG.
769 * with the Connection_Handles of the CIS configurations.
773 struct ll_conn_iso_stream *cis; in ll_cig_remove() local
792 cis = ll_conn_iso_stream_get_by_group(cig, &handle_iter); in ll_cig_remove()
793 if (!cis) { in ll_cig_remove()
797 conn = ll_connected_get(cis->lll.acl_handle); in ll_cig_remove()
811 cis = ll_conn_iso_stream_get_by_group(cig, &handle_iter); in ll_cig_remove()
812 if (cis) { in ll_cig_remove()
813 /* Release CIS instance */ in ll_cig_remove()
814 ll_conn_iso_stream_release(cis); in ll_cig_remove()
842 struct ll_conn_iso_stream *cis; in ull_central_iso_setup() local
848 cis = ll_conn_iso_stream_get(cis_handle); in ull_central_iso_setup()
849 if (!cis) { in ull_central_iso_setup()
853 cig = cis->group; in ull_central_iso_setup()
858 /* ACL connection of the new CIS */ in ull_central_iso_setup()
859 conn = ll_conn_get(cis->lll.acl_handle); in ull_central_iso_setup()
868 /* Calculate offset for CIS */ in ull_central_iso_setup()
894 (cig->sync_delay - cis->sync_delay); in ull_central_iso_setup()
901 cis->offset = cis_offset; in ull_central_iso_setup()
914 cis_offset += cig->sync_delay - cis->sync_delay; in ull_central_iso_setup()
920 cis->offset = cis_offset; in ull_central_iso_setup()
924 cis->offset = *cis_offset_min; in ull_central_iso_setup()
928 cis->central.instant = instant; in ull_central_iso_setup()
930 cis->pkt_seq_num = 0U; in ull_central_iso_setup()
932 cis->lll.event_count = LLL_CONN_ISO_EVENT_COUNT_MAX; in ull_central_iso_setup()
933 cis->lll.next_subevent = 0U; in ull_central_iso_setup()
934 cis->lll.tifs_us = conn->lll.tifs_cis_us; in ull_central_iso_setup()
935 cis->lll.sn = 0U; in ull_central_iso_setup()
936 cis->lll.nesn = 0U; in ull_central_iso_setup()
937 cis->lll.cie = 0U; in ull_central_iso_setup()
938 cis->lll.npi = 0U; in ull_central_iso_setup()
939 cis->lll.flush = LLL_CIS_FLUSH_NONE; in ull_central_iso_setup()
940 cis->lll.active = 0U; in ull_central_iso_setup()
941 cis->lll.datapath_ready_rx = 0U; in ull_central_iso_setup()
942 cis->lll.tx.payload_count = 0U; in ull_central_iso_setup()
943 cis->lll.rx.payload_count = 0U; in ull_central_iso_setup()
945 cis->lll.tx.bn_curr = 1U; in ull_central_iso_setup()
946 cis->lll.rx.bn_curr = 1U; in ull_central_iso_setup()
950 *cis_sync_delay = cis->sync_delay; in ull_central_iso_setup()
951 *cis_offset_min = cis->offset; in ull_central_iso_setup()
952 memcpy(access_addr, cis->lll.access_addr, sizeof(cis->lll.access_addr)); in ull_central_iso_setup()
964 struct ll_conn_iso_stream *cis; in ull_central_iso_cis_offset_get() local
968 cis = ll_conn_iso_stream_get(cis_handle); in ull_central_iso_cis_offset_get()
969 LL_ASSERT(cis); in ull_central_iso_cis_offset_get()
971 conn = ll_conn_get(cis->lll.acl_handle); in ull_central_iso_cis_offset_get()
973 cis->central.instant = ull_conn_event_counter(conn) + 3U; in ull_central_iso_cis_offset_get()
974 *conn_event_count = cis->central.instant; in ull_central_iso_cis_offset_get()
976 /* Provide CIS offset range in ull_central_iso_cis_offset_get()
979 cig = cis->group; in ull_central_iso_cis_offset_get()
990 cis_offset_get(cis); in ull_central_iso_cis_offset_get()
992 cig_offset_get(cis); in ull_central_iso_cis_offset_get()
1001 *cis_offset_min += cig->sync_delay - cis->sync_delay; in ull_central_iso_cis_offset_get()
1008 static void cig_offset_get(struct ll_conn_iso_stream *cis) in cig_offset_get() argument
1014 mfy.param = cis; in cig_offset_get()
1022 struct ll_conn_iso_stream *cis; in mfy_cig_offset_get() local
1032 cis = param; in mfy_cig_offset_get()
1033 cig = cis->group; in mfy_cig_offset_get()
1042 /* Calculate the offset for the select CIS in the CIG */ in mfy_cig_offset_get()
1045 offset_min_us += cig->sync_delay - cis->sync_delay; in mfy_cig_offset_get()
1048 * the minimum CIS offset requirement. in mfy_cig_offset_get()
1050 conn = ll_conn_get(cis->lll.acl_handle); in mfy_cig_offset_get()
1062 static void cis_offset_get(struct ll_conn_iso_stream *cis) in cis_offset_get() argument
1068 mfy.param = cis; in cis_offset_get()
1078 struct ll_conn_iso_stream *cis; in mfy_cis_offset_get() local
1094 cis = param; in mfy_cis_offset_get()
1095 cig = cis->group; in mfy_cis_offset_get()
1160 conn = ll_conn_get(cis->lll.acl_handle); in mfy_cis_offset_get()
1165 /* Calculate the CIS offset in the CIG */ in mfy_cis_offset_get()
1168 acl_remainder_us - cis->sync_delay; in mfy_cis_offset_get()
1175 latency_acl = cis->central.instant - ull_conn_event_counter(conn); in mfy_cis_offset_get()
1187 * considering the select CIS in the CIG meets the minimum CIS offset in mfy_cis_offset_get()
1190 offset_limit_us = cig_interval_us + cig->sync_delay - cis->sync_delay; in mfy_cis_offset_get()
1199 cis->lll.event_count--; in mfy_cis_offset_get()