1 /*
2  * Copyright (c) 2021 Demant
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #define IS_PERIPHERAL(cig) \
8 	(IS_ENABLED(CONFIG_BT_CTLR_PERIPHERAL_ISO) && \
9 	 (cig->lll.role == BT_HCI_ROLE_PERIPHERAL))
10 
11 #define IS_CENTRAL(cig) \
12 	(IS_ENABLED(CONFIG_BT_CTLR_CENTRAL_ISO) && \
13 	 (cig->lll.role == BT_HCI_ROLE_CENTRAL))
14 
15 /* BT Core 5.4, Vol 6, Part B, section 2.4.2.29 */
16 #define CIS_MIN_OFFSET_MIN 500U
17 
18 /* Helper functions to initialize and reset ull_conn_iso module */
19 int ull_conn_iso_init(void);
20 int ull_conn_iso_reset(void);
21 
22 struct ll_conn_iso_group *ll_conn_iso_group_acquire(void);
23 void ll_conn_iso_group_release(struct ll_conn_iso_group *cig);
24 uint16_t ll_conn_iso_group_handle_get(struct ll_conn_iso_group *cig);
25 struct ll_conn_iso_group *ll_conn_iso_group_get(uint16_t handle);
26 struct ll_conn_iso_group *ll_conn_iso_group_get_by_id(uint8_t id);
27 
28 struct ll_conn_iso_stream *ll_conn_iso_stream_acquire(void);
29 void ll_conn_iso_stream_release(struct ll_conn_iso_stream *cis);
30 uint16_t ll_conn_iso_stream_handle_get(struct ll_conn_iso_stream *cis);
31 struct ll_conn_iso_stream *ll_conn_iso_stream_get(uint16_t handle);
32 struct ll_conn_iso_stream *ll_iso_stream_connected_get(uint16_t handle);
33 struct ll_conn_iso_stream *ll_conn_iso_stream_get_by_acl(struct ll_conn *conn,
34 							 uint16_t *cis_iter);
35 struct ll_conn_iso_stream *ll_conn_iso_stream_get_by_group(struct ll_conn_iso_group *cig,
36 							   uint16_t *handle_iter);
37 struct ll_conn_iso_stream *ll_conn_iso_stream_get_by_id(uint8_t cis_id);
38 
39 void ull_conn_iso_start(struct ll_conn *acl, uint16_t cis_handle,
40 			uint32_t ticks_at_expire, uint32_t remainder,
41 			uint16_t instant_latency);
42 void ull_conn_iso_done(struct node_rx_event_done *done);
43 void ull_conn_iso_cis_stop(struct ll_conn_iso_stream *cis,
44 			   ll_iso_stream_released_cb_t cis_released_cb,
45 			   uint8_t reason);
46 
47 void ull_conn_iso_resume_ticker_start(struct lll_event *resume_event,
48 				      uint16_t cis_handle,
49 				      uint32_t ticks_anchor,
50 				      uint32_t resume_timeout);
51 void ull_conn_iso_transmit_test_cig_interval(uint16_t handle,
52 					     uint32_t ticks_at_expire);
53 
54 void ull_conn_iso_ticker_cb(uint32_t ticks_at_expire, uint32_t ticks_drift,
55 			    uint32_t remainder, uint16_t lazy, uint8_t force,
56 			    void *param);
57