|
5 | 5 |
|
6 | 6 | /* |
7 | 7 | * Copyright (c) 2020 Intel Corporation |
8 | | - * Copyright (c) 2021-2024 Nordic Semiconductor ASA |
| 8 | + * Copyright (c) 2021-2025 Nordic Semiconductor ASA |
9 | 9 | * |
10 | 10 | * SPDX-License-Identifier: Apache-2.0 |
11 | 11 | */ |
@@ -70,6 +70,14 @@ extern "C" { |
70 | 70 |
|
71 | 71 | /** Unknown SDU interval */ |
72 | 72 | #define BT_ISO_SDU_INTERVAL_UNKNOWN 0x000000U |
| 73 | +/** The minimum value for vendor specific data path ID */ |
| 74 | +#define BT_ISO_DATA_PATH_VS_ID_MIN 0x01 |
| 75 | +/** The maximum value for vendor specific data path ID */ |
| 76 | +#define BT_ISO_DATA_PATH_VS_ID_MAX 0xFE |
| 77 | +/** Minimum controller delay in microseconds (0 s) */ |
| 78 | +#define BT_ISO_CONTROLLER_DELAY_MIN 0x000000 |
| 79 | +/** Maximum controller delay in microseconds (4 s) */ |
| 80 | +#define BT_ISO_CONTROLLER_DELAY_MAX 0x3D0900 |
73 | 81 | /** Minimum interval value in microseconds */ |
74 | 82 | #define BT_ISO_SDU_INTERVAL_MIN 0x0000FFU |
75 | 83 | /** Maximum interval value in microseconds */ |
@@ -178,7 +186,8 @@ enum bt_iso_state { |
178 | 186 | */ |
179 | 187 | enum bt_iso_chan_type { |
180 | 188 | BT_ISO_CHAN_TYPE_NONE, /**< No channel type */ |
181 | | - BT_ISO_CHAN_TYPE_CONNECTED, /**< Connected */ |
| 189 | + BT_ISO_CHAN_TYPE_CENTRAL, /**< Connected as central */ |
| 190 | + BT_ISO_CHAN_TYPE_PERIPHERAL, /**< Connected as peripheral */ |
182 | 191 | BT_ISO_CHAN_TYPE_BROADCASTER, /**< Isochronous broadcaster */ |
183 | 192 | BT_ISO_CHAN_TYPE_SYNC_RECEIVER /**< Synchronized receiver */ |
184 | 193 | }; |
@@ -230,13 +239,6 @@ struct bt_iso_chan_io_qos { |
230 | 239 | * This value is ignored if any advanced ISO parameters are set. |
231 | 240 | */ |
232 | 241 | uint8_t rtn; |
233 | | - /** |
234 | | - * @brief Channel data path reference |
235 | | - * |
236 | | - * Setting to NULL default to HCI data path (same as setting path.pid |
237 | | - * to @ref BT_ISO_DATA_PATH_HCI). |
238 | | - */ |
239 | | - struct bt_iso_chan_path *path; |
240 | 242 |
|
241 | 243 | #if defined(CONFIG_BT_ISO_TEST_PARAMS) || defined(__DOXYGEN__) |
242 | 244 | /** |
@@ -293,20 +295,37 @@ struct bt_iso_chan_qos { |
293 | 295 |
|
294 | 296 | /** @brief ISO Channel Data Path structure. */ |
295 | 297 | struct bt_iso_chan_path { |
296 | | - /** Default path ID */ |
297 | | - uint8_t pid; |
298 | | - /** Coding Format */ |
299 | | - uint8_t format; |
| 298 | + /** |
| 299 | + * @brief Default path ID |
| 300 | + * |
| 301 | + * @ref BT_ISO_DATA_PATH_HCI to use ISO over HCI or between @ref BT_ISO_DATA_PATH_VS_ID_MIN |
| 302 | + * and @ref BT_ISO_DATA_PATH_VS_ID_MAX for vendor specific data paths. |
| 303 | + */ |
| 304 | + uint8_t pid; |
| 305 | + /** |
| 306 | + * @brief Coding Format |
| 307 | + * |
| 308 | + * See the BT_HCI_CODING_FORMAT_* values for valid values. |
| 309 | + */ |
| 310 | + uint8_t format; |
300 | 311 | /** Company ID */ |
301 | | - uint16_t cid; |
| 312 | + uint16_t cid; |
302 | 313 | /** Vendor-defined Codec ID */ |
303 | | - uint16_t vid; |
304 | | - /** Controller Delay */ |
305 | | - uint32_t delay; |
306 | | - /** Codec Configuration length*/ |
307 | | - uint8_t cc_len; |
308 | | - /** Pointer to an array containing the Codec Configuration */ |
309 | | - uint8_t *cc; |
| 314 | + uint16_t vid; |
| 315 | + /** |
| 316 | + * @brief Controller Delay in microseconds |
| 317 | + * |
| 318 | + * Value range from @ref BT_ISO_CONTROLLER_DELAY_MIN to @ref BT_ISO_CONTROLLER_DELAY_MAX. |
| 319 | + */ |
| 320 | + uint32_t delay; |
| 321 | + /** Codec Configuration length */ |
| 322 | + uint8_t cc_len; |
| 323 | + /** |
| 324 | + * @brief Pointer to an array containing the Codec Configuration |
| 325 | + * |
| 326 | + * Shall not be NULL if bt_iso_chan_path.cc_len is non-zero. |
| 327 | + */ |
| 328 | + uint8_t *cc; |
310 | 329 | }; |
311 | 330 |
|
312 | 331 | /** ISO packet status flag bits */ |
@@ -691,6 +710,14 @@ struct bt_iso_chan_ops { |
691 | 710 | * channel is disconnected, including when a connection gets |
692 | 711 | * rejected or when setting security fails. |
693 | 712 | * |
| 713 | + * If the channel was established (i.e. @ref bt_iso_chan_ops.connected has been called |
| 714 | + * for this channel), then the channel object is still valid and the memory of the channel |
| 715 | + * shall not be memset to 0 or otherwise free'd. |
| 716 | + * To avoid any issues it is recommended to use a @ref k_work_submit or similar to not |
| 717 | + * overwrite any data while in the callback. |
| 718 | + * |
| 719 | + * For the above reason it is still possible to use bt_iso_chan_get_info() on the @p chan. |
| 720 | + * |
694 | 721 | * @param chan The channel that has been Disconnected |
695 | 722 | * @param reason BT_HCI_ERR_* reason for the disconnection. |
696 | 723 | */ |
@@ -957,6 +984,70 @@ int bt_iso_chan_send(struct bt_iso_chan *chan, struct net_buf *buf, uint16_t seq |
957 | 984 | int bt_iso_chan_send_ts(struct bt_iso_chan *chan, struct net_buf *buf, uint16_t seq_num, |
958 | 985 | uint32_t ts); |
959 | 986 |
|
| 987 | +/** |
| 988 | + * @brief Sets up the ISO data path for a ISO channel |
| 989 | + * |
| 990 | + * The channel must be associated with a BIS or CIS handle first which it is when the |
| 991 | + * bt_iso_chan_ops.connected() callback is called. |
| 992 | + * |
| 993 | + * @param chan The channel to setup the ISO data path for |
| 994 | + * @param dir The direction to setup, either @ref BT_HCI_DATAPATH_DIR_CTLR_TO_HOST or |
| 995 | + * @ref BT_HCI_DATAPATH_DIR_HOST_TO_CTLR. For ISO broadcast channels this can only be |
| 996 | + * @ref BT_HCI_DATAPATH_DIR_HOST_TO_CTLR, and for ISO sync receiver channels this can |
| 997 | + * only be @ref BT_HCI_DATAPATH_DIR_CTLR_TO_HOST. |
| 998 | + * @param path The data path |
| 999 | + * |
| 1000 | + * @retval 0 Success |
| 1001 | + * @retval -EINVAL Invalid parameters |
| 1002 | + * @retval -ENOBUFS No HCI command buffer could be allocated |
| 1003 | + * @retval -EIO The controller rejected the request or response contains invalid data |
| 1004 | + * @retval -ENODEV @p chan is not associated with a CIS or BIS handle |
| 1005 | + * @retval -EACCES The controller rejected the request as disallowed |
| 1006 | + * @retval -ENOEXEC Unexpected error occurred |
| 1007 | + */ |
| 1008 | +int bt_iso_setup_data_path(const struct bt_iso_chan *chan, uint8_t dir, |
| 1009 | + const struct bt_iso_chan_path *path); |
| 1010 | + |
| 1011 | +/** |
| 1012 | + * @brief Removes the ISO data path for a ISO channel |
| 1013 | + * |
| 1014 | + * Removes the ISO data path configured by bt_iso_setup_data_path() for the provided @p dir. |
| 1015 | + * |
| 1016 | + * The data paths of CIS for Peripherals are deleted by the controller, |
| 1017 | + * and thus it is not necessary (or possible) to remove |
| 1018 | + * data paths of CIS after they have disconnected for a Peripheral, |
| 1019 | + * as per Bluetooth Core specification 6.0, Vol 4, Part E, Section 7.7.5. |
| 1020 | + * The data paths for CIS for a Central remain valid, even after a disconnection, and thus a Central |
| 1021 | + * device should call bt_iso_remove_data_path() on disconnect if it no longer wants to use that CIS. |
| 1022 | + * All data paths created by a Central are removed when the CIG is removed with |
| 1023 | + * bt_iso_cig_terminate(). |
| 1024 | + * |
| 1025 | + * Any data paths associated with an ISO Sync Receiver BIG are removed by the controller |
| 1026 | + * when the BIG sync is lost or terminated, and thus it is not necessary (or possible) to remove |
| 1027 | + * data paths of ISO channels associated with a BIG for a Sync Receiver, |
| 1028 | + * as per Bluetooth Core specification 6.0, Vol 4, Part E, Section 7.7.65.30 |
| 1029 | + * |
| 1030 | + * All data paths associated with an ISO Broadcaster BIG are removed when the BIG is terminated by |
| 1031 | + * bt_iso_big_terminate(), and thus it is not necessary (or possible) to remove data paths of ISO |
| 1032 | + * channels associated with a BIG for a Broadcaster, |
| 1033 | + * as per Bluetooth Core specification 6.0, Vol 4, Part E, Section 7.8.105 |
| 1034 | + * |
| 1035 | + * @param chan The channel to setup the ISO data path for |
| 1036 | + * @param dir The direction to setup, either @ref BT_HCI_DATAPATH_DIR_CTLR_TO_HOST or |
| 1037 | + * @ref BT_HCI_DATAPATH_DIR_HOST_TO_CTLR. For ISO broadcast channels this can only be |
| 1038 | + * @ref BT_HCI_DATAPATH_DIR_HOST_TO_CTLR, and for ISO sync receiver channels this can |
| 1039 | + * only be @ref BT_HCI_DATAPATH_DIR_CTLR_TO_HOST. |
| 1040 | +
|
| 1041 | + * @retval 0 Success |
| 1042 | + * @retval -EINVAL Invalid parameters |
| 1043 | + * @retval -ENOBUFS No HCI command buffer could be allocated |
| 1044 | + * @retval -EIO The controller rejected the request or response contains invalid data |
| 1045 | + * @retval -ENODEV @p chan is not associated with a CIS or BIS handle |
| 1046 | + * @retval -EACCES The controller rejected the request as disallowed |
| 1047 | + * @retval -ENOEXEC Unexpected error occurred |
| 1048 | + */ |
| 1049 | +int bt_iso_remove_data_path(const struct bt_iso_chan *chan, uint8_t dir); |
| 1050 | + |
960 | 1051 | /** @brief ISO Unicast TX Info Structure */ |
961 | 1052 | struct bt_iso_unicast_tx_info { |
962 | 1053 | /** The transport latency in us */ |
@@ -1082,20 +1173,30 @@ struct bt_iso_info { |
1082 | 1173 | /** Connection Type specific Info.*/ |
1083 | 1174 | union { |
1084 | 1175 | #if defined(CONFIG_BT_ISO_UNICAST) || defined(__DOXYGEN__) |
1085 | | - /** Unicast specific Info. |
| 1176 | + /** |
| 1177 | + * @brief Unicast specific Info. |
| 1178 | + * |
1086 | 1179 | * Only available when @kconfig{CONFIG_BT_ISO_UNICAST} is enabled. |
| 1180 | + * Use this when the @ref bt_iso_info.type is @ref BT_ISO_CHAN_TYPE_CENTRAL or |
| 1181 | + * @ref BT_ISO_CHAN_TYPE_PERIPHERAL. |
1087 | 1182 | */ |
1088 | 1183 | struct bt_iso_unicast_info unicast; |
1089 | 1184 | #endif /* CONFIG_BT_ISO_UNICAST */ |
1090 | 1185 | #if defined(CONFIG_BT_ISO_BROADCASTER) || defined(__DOXYGEN__) |
1091 | | - /** Broadcaster specific Info. |
| 1186 | + /** |
| 1187 | + * @brief Broadcaster specific Info. |
| 1188 | + * |
1092 | 1189 | * Only available when @kconfig{CONFIG_BT_ISO_BROADCASTER} is enabled. |
| 1190 | + * Use this when the @ref bt_iso_info.type is @ref BT_ISO_CHAN_TYPE_BROADCASTER. |
1093 | 1191 | */ |
1094 | 1192 | struct bt_iso_broadcaster_info broadcaster; |
1095 | 1193 | #endif /* CONFIG_BT_ISO_BROADCASTER */ |
1096 | 1194 | #if defined(CONFIG_BT_ISO_SYNC_RECEIVER) || defined(__DOXYGEN__) |
1097 | | - /** Sync receiver specific Info. |
| 1195 | + /** |
| 1196 | + * @brief Sync receiver specific Info. |
| 1197 | + * |
1098 | 1198 | * Only available when @kconfig{CONFIG_BT_ISO_SYNC_RECEIVER} is enabled. |
| 1199 | + * Use this when the @ref bt_iso_info.type is @ref BT_ISO_CHAN_TYPE_SYNC_RECEIVER. |
1099 | 1200 | */ |
1100 | 1201 | struct bt_iso_sync_receiver_info sync_receiver; |
1101 | 1202 | #endif /* CONFIG_BT_ISO_SYNC_RECEIVER */ |
|
0 commit comments