Lines Matching +full:volume +full:- +full:min
6 * Copyright (c) 2022-2023 Nordic Semiconductor ASA
9 * SPDX-License-Identifier: Apache-2.0
69 #define ASE_ID(_ase) ase->ep.status.id
104 MIN(BT_ATT_MAX_ATTRIBUTE_LEN, \
112 (BT_ATT_BUF_SIZE - NTF_HEADER_SIZE) >= ASE_BUF_SIZE ||
113 DIV_ROUND_UP(ASE_BUF_SIZE, (BT_ATT_BUF_SIZE - NTF_HEADER_SIZE)) <=
133 switch (rsp->code) { in ascs_app_rsp_warn_valid()
144 LOG_WRN("Invalid application error code: %u", rsp->code); in ascs_app_rsp_warn_valid()
149 switch (rsp->code) { in ascs_app_rsp_warn_valid()
154 if (rsp->reason != BT_BAP_ASCS_REASON_NONE) { in ascs_app_rsp_warn_valid()
155 LOG_WRN("Invalid reason %u for code %u", rsp->reason, rsp->code); in ascs_app_rsp_warn_valid()
160 if (!IN_RANGE(rsp->reason, BT_BAP_ASCS_REASON_NONE, BT_BAP_ASCS_REASON_CIS)) { in ascs_app_rsp_warn_valid()
161 LOG_WRN("Invalid reason %u for code %u", rsp->reason, rsp->code); in ascs_app_rsp_warn_valid()
166 if (!BT_AUDIO_METADATA_TYPE_IS_KNOWN(rsp->metadata_type)) { in ascs_app_rsp_warn_valid()
167 LOG_WRN("Invalid metadata type %u for code %u", rsp->metadata_type, in ascs_app_rsp_warn_valid()
168 rsp->code); in ascs_app_rsp_warn_valid()
183 return ep->status.state; in ascs_ep_get_state()
188 __ASSERT(ase && ase->conn, "Non-existing ASE"); in ase_free()
190 LOG_DBG("conn %p ase %p id 0x%02x", (void *)ase->conn, ase, ase->ep.status.id); in ase_free()
192 if (ase->ep.iso != NULL) { in ase_free()
193 bt_bap_iso_unbind_ep(ase->ep.iso, &ase->ep); in ase_free()
196 bt_conn_unref(ase->conn); in ase_free()
197 ase->conn = NULL; in ase_free()
199 (void)k_work_cancel_delayable(&ase->disconnect_work); in ase_free()
200 (void)k_work_cancel_delayable(&ase->state_transition_work); in ase_free()
208 return mtu - NTF_HEADER_SIZE; in get_max_ntf_size()
216 struct bt_conn *conn = ase->conn; in ase_state_notify()
228 !bt_gatt_is_subscribed(conn, ase->attr, BT_GATT_CCC_NOTIFY)) { in ase_state_notify()
239 ascs_ep_get_status(&ase->ep, &ase_buf); in ase_state_notify()
243 ntf_size = MIN(max_ntf_size, ase_buf.len); in ase_state_notify()
249 err = bt_gatt_notify(conn, ase->attr, ase_buf.data, ntf_size); in ase_state_notify()
261 struct bt_bap_ep *ep = &ase->ep; in ascs_disconnect_stream_work_handler()
262 struct bt_bap_stream *stream = ep->stream; in ascs_disconnect_stream_work_handler()
265 __ASSERT(ep != NULL && ep->iso && stream != NULL, in ascs_disconnect_stream_work_handler()
267 ep, ep == NULL ? NULL : ep->iso, stream); in ascs_disconnect_stream_work_handler()
269 if (ep->dir == BT_AUDIO_DIR_SINK) { in ascs_disconnect_stream_work_handler()
270 pair_stream = ep->iso->tx.stream; in ascs_disconnect_stream_work_handler()
272 pair_stream = ep->iso->rx.stream; in ascs_disconnect_stream_work_handler()
281 __ASSERT(pair_stream->ep != NULL, "Invalid pair_stream %p", in ascs_disconnect_stream_work_handler()
284 if (pair_stream->ep->status.state == BT_BAP_EP_STATE_STREAMING) { in ascs_disconnect_stream_work_handler()
292 pair_ase = CONTAINER_OF(pair_stream->ep, struct bt_ascs_ase, in ascs_disconnect_stream_work_handler()
296 (void)k_work_cancel_delayable(&pair_ase->disconnect_work); in ascs_disconnect_stream_work_handler()
300 ep->iso != NULL && in ascs_disconnect_stream_work_handler()
301 (ep->iso->chan.state == BT_ISO_STATE_CONNECTED || in ascs_disconnect_stream_work_handler()
302 ep->iso->chan.state == BT_ISO_STATE_CONNECTING)) { in ascs_disconnect_stream_work_handler()
314 struct bt_ascs_ase *ase = CONTAINER_OF(stream->ep, struct bt_ascs_ase, in ascs_disconnect_stream()
319 return k_work_reschedule(&ase->disconnect_work, in ascs_disconnect_stream()
325 struct bt_bap_stream *stream = ase->ep.stream; in ase_enter_state_idle()
330 ase->ep.receiver_ready = false; in ase_enter_state_idle()
332 if (stream->conn != NULL) { in ase_enter_state_idle()
333 bt_conn_unref(stream->conn); in ase_enter_state_idle()
334 stream->conn = NULL; in ase_enter_state_idle()
337 ops = stream->ops; in ase_enter_state_idle()
338 if (ops != NULL && ops->released != NULL) { in ase_enter_state_idle()
339 ops->released(stream); in ase_enter_state_idle()
347 struct bt_bap_stream *stream = ase->ep.stream; in ase_enter_state_codec_configured()
352 ase->ep.receiver_ready = false; in ase_enter_state_codec_configured()
354 ops = stream->ops; in ase_enter_state_codec_configured()
355 if (ops != NULL && ops->configured != NULL) { in ase_enter_state_codec_configured()
356 ops->configured(stream, &ase->ep.qos_pref); in ase_enter_state_codec_configured()
362 struct bt_bap_stream *stream = ase->ep.stream; in ase_enter_state_qos_configured()
367 ase->ep.receiver_ready = false; in ase_enter_state_qos_configured()
369 ops = stream->ops; in ase_enter_state_qos_configured()
370 if (ops != NULL && ops->qos_set != NULL) { in ase_enter_state_qos_configured()
371 ops->qos_set(stream); in ase_enter_state_qos_configured()
377 struct bt_bap_stream *stream = ase->ep.stream; in ase_enter_state_enabling()
382 ops = stream->ops; in ase_enter_state_enabling()
383 if (ops != NULL && ops->enabled != NULL) { in ase_enter_state_enabling()
384 ops->enabled(stream); in ase_enter_state_enabling()
388 if (ase->ep.dir == BT_AUDIO_DIR_SINK && ase->ep.receiver_ready && ase->ep.iso != NULL && in ase_enter_state_enabling()
389 ase->ep.iso->chan.state == BT_ISO_STATE_CONNECTED) { in ase_enter_state_enabling()
390 ascs_ep_set_state(&ase->ep, BT_BAP_EP_STATE_STREAMING); in ase_enter_state_enabling()
396 struct bt_bap_stream *stream = ase->ep.stream; in ase_enter_state_streaming()
401 ops = stream->ops; in ase_enter_state_streaming()
402 if (ops != NULL && ops->started != NULL) { in ase_enter_state_streaming()
403 ops->started(stream); in ase_enter_state_streaming()
409 struct bt_bap_stream *stream = ase->ep.stream; in ase_metadata_updated()
414 ops = stream->ops; in ase_metadata_updated()
415 if (ops != NULL && ops->metadata_updated != NULL) { in ase_metadata_updated()
416 ops->metadata_updated(stream); in ase_metadata_updated()
422 struct bt_bap_stream *stream = ase->ep.stream; in ase_exit_state_streaming()
424 const enum bt_bap_ep_state next_state = ascs_ep_get_state(&ase->ep); in ase_exit_state_streaming()
425 uint8_t reason = ase->ep.reason; in ase_exit_state_streaming()
434 ops = stream->ops; in ase_exit_state_streaming()
437 * On link-loss we go from streaming state to QOS configured state, in ase_exit_state_streaming()
442 if (ops != NULL && ops->disabled != NULL) { in ase_exit_state_streaming()
443 ops->disabled(stream); in ase_exit_state_streaming()
449 if (ops != NULL && ops->stopped != NULL) { in ase_exit_state_streaming()
450 ops->stopped(stream, reason); in ase_exit_state_streaming()
458 struct bt_bap_stream *stream = ase->ep.stream; in ase_exit_state_enabling()
460 const enum bt_bap_ep_state next_state = ascs_ep_get_state(&ase->ep); in ase_exit_state_enabling()
462 ops = stream->ops; in ase_exit_state_enabling()
470 if (next_state == BT_BAP_EP_STATE_QOS_CONFIGURED && ase->ep.dir == BT_AUDIO_DIR_SINK) { in ase_exit_state_enabling()
471 if (ops != NULL && ops->disabled != NULL) { in ase_exit_state_enabling()
472 ops->disabled(stream); in ase_exit_state_enabling()
481 struct bt_bap_stream *stream = ase->ep.stream; in ase_enter_state_disabling()
486 ase->ep.receiver_ready = false; in ase_enter_state_disabling()
488 ops = stream->ops; in ase_enter_state_disabling()
489 if (ops != NULL && ops->disabled != NULL) { in ase_enter_state_disabling()
490 ops->disabled(stream); in ase_enter_state_disabling()
496 struct bt_bap_stream *stream = ase->ep.stream; in ase_enter_state_releasing()
500 ase->ep.receiver_ready = false; in ase_enter_state_releasing()
513 ascs_ep_set_state(&ase->ep, BT_BAP_EP_STATE_IDLE); in ase_enter_state_releasing()
521 const enum bt_bap_ep_state old_state = ascs_ep_get_state(&ase->ep); in state_transition_work_handler()
522 const enum bt_bap_ep_state new_state = ase->state_pending; in state_transition_work_handler()
525 ase->ep.status.state = new_state; in state_transition_work_handler()
528 if (ase->conn != NULL) { in state_transition_work_handler()
530 if (err == -ENOMEM) { in state_transition_work_handler()
535 ase->ep.status.state = old_state; in state_transition_work_handler()
537 err = bt_conn_get_info(ase->conn, &info); in state_transition_work_handler()
556 LOG_DBG("ase %p ep %p id 0x%02x %s -> %s", ase, &ase->ep, ase->ep.status.id, in state_transition_work_handler()
613 const enum bt_bap_ep_state old_state = ascs_ep_get_state(&ase->ep); in ascs_ep_set_state()
639 valid_state_transition = ase->ep.dir == BT_AUDIO_DIR_SOURCE; in ascs_ep_set_state()
643 /* Source ASE transition Streaming->QoS configured is valid on case of CIS in ascs_ep_set_state()
644 * link-loss. in ascs_ep_set_state()
646 valid_state_transition = ase->ep.dir == BT_AUDIO_DIR_SINK || in ascs_ep_set_state()
647 ase->unexpected_iso_link_loss; in ascs_ep_set_state()
674 valid_state_transition = ase->ep.dir == BT_AUDIO_DIR_SOURCE; in ascs_ep_set_state()
688 valid_state_transition = ase->ep.dir == BT_AUDIO_DIR_SOURCE; in ascs_ep_set_state()
696 BT_ASSERT_MSG(false, "Invalid state transition: %s -> %s", in ascs_ep_set_state()
699 return -EBADMSG; in ascs_ep_set_state()
702 ase->state_pending = state; in ascs_ep_set_state()
704 err = k_work_schedule(&ase->state_transition_work, K_NO_WAIT); in ascs_ep_set_state()
716 struct bt_bap_qos_cfg_pref *pref = &ep->qos_pref; in ascs_ep_get_status_config()
719 cfg->framing = pref->unframed_supported ? BT_ASCS_QOS_FRAMING_UNFRAMED in ascs_ep_get_status_config()
721 cfg->phy = pref->phy; in ascs_ep_get_status_config()
722 cfg->rtn = pref->rtn; in ascs_ep_get_status_config()
723 cfg->latency = sys_cpu_to_le16(pref->latency); in ascs_ep_get_status_config()
724 sys_put_le24(pref->pd_min, cfg->pd_min); in ascs_ep_get_status_config()
725 sys_put_le24(pref->pd_max, cfg->pd_max); in ascs_ep_get_status_config()
726 sys_put_le24(pref->pref_pd_min, cfg->prefer_pd_min); in ascs_ep_get_status_config()
727 sys_put_le24(pref->pref_pd_max, cfg->prefer_pd_max); in ascs_ep_get_status_config()
728 cfg->codec.id = ep->codec_cfg.id; in ascs_ep_get_status_config()
729 cfg->codec.cid = sys_cpu_to_le16(ep->codec_cfg.cid); in ascs_ep_get_status_config()
730 cfg->codec.vid = sys_cpu_to_le16(ep->codec_cfg.vid); in ascs_ep_get_status_config()
734 bt_audio_dir_str(ep->dir), pref->unframed_supported, pref->phy, pref->rtn, in ascs_ep_get_status_config()
735 pref->latency, pref->pd_min, pref->pd_max, pref->pref_pd_min, pref->pref_pd_max, in ascs_ep_get_status_config()
736 ep->stream->codec_cfg->id); in ascs_ep_get_status_config()
738 cfg->cc_len = ep->codec_cfg.data_len; in ascs_ep_get_status_config()
739 net_buf_simple_add_mem(buf, ep->codec_cfg.data, ep->codec_cfg.data_len); in ascs_ep_get_status_config()
747 qos->cig_id = ep->cig_id; in ascs_ep_get_status_qos()
748 qos->cis_id = ep->cis_id; in ascs_ep_get_status_qos()
749 sys_put_le24(ep->stream->qos->interval, qos->interval); in ascs_ep_get_status_qos()
750 qos->framing = ep->stream->qos->framing; in ascs_ep_get_status_qos()
751 qos->phy = ep->stream->qos->phy; in ascs_ep_get_status_qos()
752 qos->sdu = sys_cpu_to_le16(ep->stream->qos->sdu); in ascs_ep_get_status_qos()
753 qos->rtn = ep->stream->qos->rtn; in ascs_ep_get_status_qos()
754 qos->latency = sys_cpu_to_le16(ep->stream->qos->latency); in ascs_ep_get_status_qos()
755 sys_put_le24(ep->stream->qos->pd, qos->pd); in ascs_ep_get_status_qos()
759 bt_audio_dir_str(ep->dir), ep->stream->codec_cfg->id, ep->stream->qos->interval, in ascs_ep_get_status_qos()
760 ep->stream->qos->framing, ep->stream->qos->phy, ep->stream->qos->rtn, in ascs_ep_get_status_qos()
761 ep->stream->qos->latency, ep->stream->qos->pd); in ascs_ep_get_status_qos()
769 enable->cig_id = ep->cig_id; in ascs_ep_get_status_enable()
770 enable->cis_id = ep->cis_id; in ascs_ep_get_status_enable()
772 enable->metadata_len = ep->codec_cfg.meta_len; in ascs_ep_get_status_enable()
773 net_buf_simple_add_mem(buf, ep->codec_cfg.meta, ep->codec_cfg.meta_len); in ascs_ep_get_status_enable()
776 bt_audio_dir_str(ep->dir), ep->cig_id, ep->cis_id); in ascs_ep_get_status_enable()
795 return -EINVAL; in ascs_ep_get_status()
798 LOG_DBG("ep %p id 0x%02x state %s", ep, ep->status.id, in ascs_ep_get_status()
799 bt_bap_ep_state_str(ep->status.state)); in ascs_ep_get_status()
804 (void)net_buf_simple_add_mem(buf, &ep->status, sizeof(ep->status)); in ascs_ep_get_status()
806 switch (ep->status.state) { in ascs_ep_get_status()
834 LOG_DBG("conn %p", (void *)info->acl); in ascs_iso_accept()
841 if (ase->conn != info->acl || in ascs_iso_accept()
842 ase->ep.cig_id != info->cig_id || in ascs_iso_accept()
843 ase->ep.cis_id != info->cis_id) { in ascs_iso_accept()
847 state = ascs_ep_get_state(&ase->ep); in ascs_iso_accept()
853 __ASSERT(ase->ep.iso != NULL, "ep %p not bound with ISO", &ase->ep); in ascs_iso_accept()
855 chan = &ase->ep.iso->chan; in ascs_iso_accept()
856 if (chan->iso != NULL) { in ascs_iso_accept()
858 return -EALREADY; in ascs_iso_accept()
868 return -EACCES; in ascs_iso_accept()
881 ep = iso->rx.ep; in ascs_iso_recv()
891 if ((info->flags & BT_ISO_FLAGS_VALID) != 0) { in ascs_iso_recv()
899 if (ep->status.state != BT_BAP_EP_STATE_STREAMING) { in ascs_iso_recv()
902 bt_bap_ep_state_str(ep->status.state)); in ascs_iso_recv()
908 stream = ep->stream; in ascs_iso_recv()
914 ops = stream->ops; in ascs_iso_recv()
917 LOG_DBG("stream %p ep %p len %zu", stream, stream->ep, net_buf_frags_len(buf)); in ascs_iso_recv()
920 if (ops != NULL && ops->recv != NULL) { in ascs_iso_recv()
921 ops->recv(stream, info, buf); in ascs_iso_recv()
936 ep = iso->tx.ep; in ascs_iso_sent()
942 stream = ep->stream; in ascs_iso_sent()
948 ops = stream->ops; in ascs_iso_sent()
951 LOG_DBG("stream %p ep %p", stream, stream->ep); in ascs_iso_sent()
954 if (ops != NULL && ops->sent != NULL) { in ascs_iso_sent()
955 ops->sent(stream); in ascs_iso_sent()
963 struct bt_bap_qos_cfg *qos_cfg = &ep->qos; in ascs_update_sdu_size()
965 if (ep->dir == BT_AUDIO_DIR_SINK) { in ascs_update_sdu_size()
966 io_qos = ep->iso->chan.qos->rx; in ascs_update_sdu_size()
967 } else if (ep->dir == BT_AUDIO_DIR_SOURCE) { in ascs_update_sdu_size()
968 io_qos = ep->iso->chan.qos->tx; in ascs_update_sdu_size()
973 io_qos->sdu = qos_cfg->sdu; in ascs_update_sdu_size()
974 io_qos->rtn = qos_cfg->rtn; in ascs_update_sdu_size()
983 if (ep->status.state != BT_BAP_EP_STATE_ENABLING) { in ascs_ep_iso_connected()
985 bt_bap_ep_state_str(ep->status.state)); in ascs_ep_iso_connected()
989 stream = ep->stream; in ascs_ep_iso_connected()
996 ep->reason = BT_HCI_ERR_SUCCESS; in ascs_ep_iso_connected()
997 ase->unexpected_iso_link_loss = false; in ascs_ep_iso_connected()
1005 LOG_DBG("stream %p ep %p dir %s", stream, ep, bt_audio_dir_str(ep->dir)); in ascs_ep_iso_connected()
1009 stream->_prev_seq_num = 0U; in ascs_ep_iso_connected()
1012 stream_ops = stream->ops; in ascs_ep_iso_connected()
1013 if (stream_ops != NULL && stream_ops->connected != NULL) { in ascs_ep_iso_connected()
1014 stream_ops->connected(stream); in ascs_ep_iso_connected()
1017 if (ep->dir == BT_AUDIO_DIR_SINK && ep->receiver_ready) { in ascs_ep_iso_connected()
1030 if (iso->rx.ep == NULL && iso->tx.ep == NULL) { in ascs_iso_connected()
1035 if (iso->rx.ep != NULL) { in ascs_iso_connected()
1036 ascs_ep_iso_connected(iso->rx.ep); in ascs_iso_connected()
1039 if (iso->tx.ep != NULL) { in ascs_iso_connected()
1040 ascs_ep_iso_connected(iso->tx.ep); in ascs_iso_connected()
1050 stream = ep->stream; in ascs_ep_iso_disconnected()
1056 LOG_DBG("stream %p ep %p state %s reason 0x%02x", stream, stream->ep, in ascs_ep_iso_disconnected()
1057 bt_bap_ep_state_str(ep->status.state), reason); in ascs_ep_iso_disconnected()
1059 stream_ops = stream->ops; in ascs_ep_iso_disconnected()
1060 if (stream_ops != NULL && stream_ops->disconnected != NULL) { in ascs_ep_iso_disconnected()
1061 stream_ops->disconnected(stream, reason); in ascs_ep_iso_disconnected()
1065 (void)k_work_cancel_delayable(&ase->disconnect_work); in ascs_ep_iso_disconnected()
1066 ep->reason = reason; in ascs_ep_iso_disconnected()
1068 if (ep->status.state == BT_BAP_EP_STATE_RELEASING) { in ascs_ep_iso_disconnected()
1070 } else if (ep->status.state == BT_BAP_EP_STATE_STREAMING || in ascs_ep_iso_disconnected()
1071 ep->status.state == BT_BAP_EP_STATE_DISABLING) { in ascs_ep_iso_disconnected()
1078 ase->unexpected_iso_link_loss = true; in ascs_ep_iso_disconnected()
1088 if (iso->rx.ep == NULL && iso->tx.ep == NULL) { in ascs_iso_disconnected()
1092 if (iso->rx.ep != NULL) { in ascs_iso_disconnected()
1093 ascs_ep_iso_disconnected(iso->rx.ep, reason); in ascs_iso_disconnected()
1096 if (iso->tx.ep != NULL) { in ascs_iso_disconnected()
1097 ascs_ep_iso_disconnected(iso->tx.ep, reason); in ascs_iso_disconnected()
1122 * (sizeof buffer - header for notification)
1124 BUILD_ASSERT(BT_ATT_BUF_SIZE - NTF_HEADER_SIZE >= CP_RSP_BUF_SIZE,
1135 rsp->op = op; in ascs_cp_rsp_init()
1136 rsp->num_ase = 0; in ascs_cp_rsp_init()
1148 if (rsp->num_ase == BT_ASCS_UNSUPP_OR_LENGTH_ERR_NUM_ASE) { in ascs_cp_rsp_add()
1158 rsp->num_ase = BT_ASCS_UNSUPP_OR_LENGTH_ERR_NUM_ASE; in ascs_cp_rsp_add()
1161 rsp->num_ase++; in ascs_cp_rsp_add()
1166 ase_rsp->id = id; in ascs_cp_rsp_add()
1167 ase_rsp->code = code; in ascs_cp_rsp_add()
1168 ase_rsp->reason = reason; in ascs_cp_rsp_add()
1178 enum bt_bap_ep_state state = ascs_ep_get_state(&ase->ep); in ase_release()
1185 return -EBADMSG; in ase_release()
1188 if (unicast_server_cb == NULL || unicast_server_cb->release == NULL) { in ase_release()
1191 return -ENOTSUP; in ase_release()
1194 err = unicast_server_cb->release(ase->ep.stream, rsp); in ase_release()
1196 if (rsp->code == BT_BAP_ASCS_RSP_CODE_SUCCESS) { in ase_release()
1201 LOG_ERR("Release failed: err %d, code %u, reason %u", err, rsp->code, rsp->reason); in ase_release()
1206 ase->ep.reason = reason; in ase_release()
1208 ascs_ep_set_state(&ase->ep, BT_BAP_EP_STATE_RELEASING); in ase_release()
1217 const enum bt_bap_ep_state state = ascs_ep_get_state(&ase->ep); in bt_ascs_release_ase()
1235 ep = &ase->ep; in ase_disable()
1237 switch (ep->status.state) { in ase_disable()
1244 LOG_WRN("Invalid operation in state: %s", bt_bap_ep_state_str(ep->status.state)); in ase_disable()
1247 return -EBADMSG; in ase_disable()
1250 stream = ep->stream; in ase_disable()
1252 if (unicast_server_cb == NULL || unicast_server_cb->disable == NULL) { in ase_disable()
1254 return -ENOTSUP; in ase_disable()
1257 err = unicast_server_cb->disable(stream, rsp); in ase_disable()
1259 if (rsp->code == BT_BAP_ASCS_RSP_CODE_SUCCESS) { in ase_disable()
1264 LOG_ERR("Disable failed: err %d, code %u, reason %u", err, rsp->code, rsp->reason); in ase_disable()
1269 ep->reason = reason; in ase_disable()
1274 if (ep->dir == BT_AUDIO_DIR_SOURCE) { in ase_disable()
1296 if (ase->conn != conn) { in disconnected()
1300 if (ase->ep.status.state != BT_BAP_EP_STATE_IDLE) { in disconnected()
1307 * calling stream->stopped when leaving the streaming state. in disconnected()
1309 ase->ep.reason = reason; in disconnected()
1310 ase->state_pending = BT_BAP_EP_STATE_IDLE; in disconnected()
1311 state_transition_work_handler(&ase->state_transition_work.work); in disconnected()
1332 if (iso->rx.ep != NULL) { in bap_iso_find_func()
1333 ep = iso->rx.ep; in bap_iso_find_func()
1334 } else if (iso->tx.ep != NULL) { in bap_iso_find_func()
1335 ep = iso->tx.ep; in bap_iso_find_func()
1340 return ep->stream->conn == params->acl && in bap_iso_find_func()
1341 ep->cig_id == params->cig_id && in bap_iso_find_func()
1342 ep->cis_id == params->cis_id; in bap_iso_find_func()
1376 if (ase->ep.status.id == POINTER_TO_UINT(BT_AUDIO_CHRC_USER_DATA(attr))) { in ase_attr_cb()
1377 ase->attr = attr; in ase_attr_cb()
1390 ep->status.id = id; in ascs_ep_init()
1391 ep->dir = ASE_DIR(id); in ascs_ep_init()
1392 ep->reason = BT_HCI_ERR_SUCCESS; in ascs_ep_init()
1399 ascs_ep_init(&ase->ep, id); in ase_init()
1401 ase->conn = bt_conn_ref(conn); in ase_init()
1406 __ASSERT(ase->attr, "ASE characteristic not found\n"); in ase_init()
1408 k_work_init_delayable(&ase->disconnect_work, ascs_disconnect_stream_work_handler); in ase_init()
1409 k_work_init_delayable(&ase->state_transition_work, state_transition_work_handler); in ase_init()
1441 if (ase->conn == conn && ase->ep.status.id == id) { in ase_find()
1477 ascs_ep_get_status(&ase->ep, &ase_buf); in ascs_ase_read()
1502 if (cap->codec_cap->id == data->id && cap->codec_cap->cid == data->cid && in codec_lookup_id()
1503 cap->codec_cap->vid == data->vid) { in codec_lookup_id()
1504 data->codec_cap = cap->codec_cap; in codec_lookup_id()
1525 return -EINVAL; in ascs_ep_set_codec()
1528 codec_cfg = &ep->codec_cfg; in ascs_ep_set_codec()
1531 ep, bt_audio_dir_str(ep->dir), id, cid, vid, len); in ascs_ep_set_codec()
1533 bt_pacs_cap_foreach(ep->dir, codec_lookup_id, &lookup_data); in ascs_ep_set_codec()
1537 id, bt_audio_dir_str(ep->dir)); in ascs_ep_set_codec()
1541 return -ENOENT; in ascs_ep_set_codec()
1544 codec_cfg->id = id; in ascs_ep_set_codec()
1545 codec_cfg->cid = cid; in ascs_ep_set_codec()
1546 codec_cfg->vid = vid; in ascs_ep_set_codec()
1547 codec_cfg->data_len = len; in ascs_ep_set_codec()
1548 memcpy(codec_cfg->data, cc, len); in ascs_ep_set_codec()
1549 codec_cfg->path_id = lookup_data.codec_cap->path_id; in ascs_ep_set_codec()
1566 ase, cfg->latency, cfg->phy, cfg->codec.id, cfg->codec.cid, cfg->codec.vid, in ase_config()
1567 cfg->cc_len); in ase_config()
1569 if (cfg->latency < BT_ASCS_CONFIG_LATENCY_LOW || in ase_config()
1570 cfg->latency > BT_ASCS_CONFIG_LATENCY_HIGH) { in ase_config()
1571 LOG_WRN("Invalid latency: 0x%02x", cfg->latency); in ase_config()
1574 return -EINVAL; in ase_config()
1577 if (cfg->phy < BT_ASCS_CONFIG_PHY_LE_1M || in ase_config()
1578 cfg->phy > BT_ASCS_CONFIG_PHY_LE_CODED) { in ase_config()
1579 LOG_WRN("Invalid PHY: 0x%02x", cfg->phy); in ase_config()
1582 return -EINVAL; in ase_config()
1585 if (cfg->cc_len > CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE) { in ase_config()
1586 LOG_DBG("Can not store %u codec configuration data", cfg->cc_len); in ase_config()
1588 return -ENOMEM; in ase_config()
1591 switch (ase->ep.status.state) { in ase_config()
1601 bt_bap_ep_state_str(ase->ep.status.state)); in ase_config()
1604 return -EINVAL; in ase_config()
1610 (void)memcpy(&codec_cfg, &ase->ep.codec_cfg, sizeof(codec_cfg)); in ase_config()
1612 err = ascs_ep_set_codec(&ase->ep, cfg->codec.id, sys_le16_to_cpu(cfg->codec.cid), in ase_config()
1613 sys_le16_to_cpu(cfg->codec.vid), (uint8_t *)cfg->cc, cfg->cc_len, in ase_config()
1617 (void)memcpy(&ase->ep.codec_cfg, &codec_cfg, sizeof(codec_cfg)); in ase_config()
1622 if (ase->ep.stream != NULL) { in ase_config()
1624 unicast_server_cb->reconfig != NULL) { in ase_config()
1625 err = unicast_server_cb->reconfig(ase->ep.stream, ase->ep.dir, in ase_config()
1626 &ase->ep.codec_cfg, &ase->ep.qos_pref, in ase_config()
1629 err = -ENOTSUP; in ase_config()
1634 if (err == 0 && !bt_bap_valid_qos_pref(&ase->ep.qos_pref)) { in ase_config()
1641 err = -EINVAL; in ase_config()
1655 (void)memcpy(&ase->ep.codec_cfg, &codec_cfg, sizeof(codec_cfg)); in ase_config()
1661 stream = ase->ep.stream; in ase_config()
1665 unicast_server_cb->config != NULL) { in ase_config()
1666 err = unicast_server_cb->config(ase->conn, &ase->ep, ase->ep.dir, in ase_config()
1667 &ase->ep.codec_cfg, &stream, in ase_config()
1668 &ase->ep.qos_pref, &rsp); in ase_config()
1670 err = -ENOTSUP; in ase_config()
1675 if (err == 0 && !bt_bap_valid_qos_pref(&ase->ep.qos_pref)) { in ase_config()
1682 err = -EINVAL; in ase_config()
1696 (void)memcpy(&ase->ep.codec_cfg, &codec_cfg, sizeof(codec_cfg)); in ase_config()
1699 return err ? err : -ENOMEM; in ase_config()
1707 bt_bap_stream_attach(ase->conn, stream, &ase->ep, &ase->ep.codec_cfg); in ase_config()
1709 ascs_ep_set_state(&ase->ep, BT_BAP_EP_STATE_CODEC_CONFIGURED); in ase_config()
1719 if (ase->conn == conn && ase->ep.stream == stream) { in ep_lookup_stream()
1720 return &ase->ep; in ep_lookup_stream()
1738 return -EINVAL; in bt_ascs_config_ase()
1743 LOG_DBG("Stream already configured for conn %p", (void *)stream->conn); in bt_ascs_config_ase()
1744 return -EALREADY; in bt_ascs_config_ase()
1757 return -ENOTSUP; in bt_ascs_config_ase()
1760 ep = &ase->ep; in bt_ascs_config_ase()
1763 return -EINVAL; in bt_ascs_config_ase()
1766 lookup_data.id = codec_cfg->id; in bt_ascs_config_ase()
1767 lookup_data.cid = codec_cfg->cid; in bt_ascs_config_ase()
1768 lookup_data.vid = codec_cfg->vid; in bt_ascs_config_ase()
1770 bt_pacs_cap_foreach(ep->dir, codec_lookup_id, &lookup_data); in bt_ascs_config_ase()
1774 codec_cfg->id, bt_audio_dir_str(ep->dir)); in bt_ascs_config_ase()
1775 return -ENOENT; in bt_ascs_config_ase()
1778 (void)memcpy(&ep->codec_cfg, codec_cfg, sizeof(ep->codec_cfg)); in bt_ascs_config_ase()
1780 ep->qos_pref = *qos_pref; in bt_ascs_config_ase()
1782 bt_bap_stream_attach(conn, stream, ep, &ep->codec_cfg); in bt_ascs_config_ase()
1800 return (max_ntf_size - rsp_hdr_size) / sizeof(struct bt_ascs_cp_ase_rsp); in get_max_ase_rsp_for_conn()
1836 if (buf->len < sizeof(*op)) { in is_valid_config_len()
1837 LOG_WRN("Invalid length %u < %zu", buf->len, sizeof(*op)); in is_valid_config_len()
1842 if (!is_valid_num_ases(conn, op->num_ases)) { in is_valid_config_len()
1846 for (uint8_t i = 0U; i < op->num_ases; i++) { in is_valid_config_len()
1849 if (buf->len < sizeof(*config)) { in is_valid_config_len()
1855 if (buf->len < config->cc_len) { in is_valid_config_len()
1860 (void)net_buf_simple_pull_mem(buf, config->cc_len); in is_valid_config_len()
1863 if (buf->len > 0) { in is_valid_config_len()
1884 LOG_DBG("num_ases %u", req->num_ases); in ascs_config()
1886 for (uint8_t i = 0; i < req->num_ases; i++) { in ascs_config()
1891 (void)net_buf_simple_pull(buf, cfg->cc_len); in ascs_config()
1893 LOG_DBG("ase 0x%02x cc_len %u", cfg->ase, cfg->cc_len); in ascs_config()
1895 if (!cfg->ase || cfg->ase > ASE_COUNT) { in ascs_config()
1896 LOG_WRN("Invalid ASE ID: %u", cfg->ase); in ascs_config()
1897 ascs_cp_rsp_add(cfg->ase, BT_BAP_ASCS_RSP_CODE_INVALID_ASE, in ascs_config()
1902 ase = ase_find(conn, cfg->ase); in ascs_config()
1908 ase = ase_new(conn, cfg->ase); in ascs_config()
1910 ascs_cp_rsp_add(cfg->ase, BT_BAP_ASCS_RSP_CODE_NO_MEM, in ascs_config()
1912 LOG_WRN("No free ASE found for config ASE ID 0x%02x", cfg->ase); in ascs_config()
1922 return buf->size; in ascs_config()
1930 if (ase->conn == conn) { in bt_ascs_foreach_ep()
1931 func(&ase->ep, user_data); in bt_ascs_foreach_ep()
1939 struct bt_bap_ep *ep = &ase->ep; in ase_qos()
1943 "latency %u pd %u", ase, cig_id, cis_id, qos->interval, qos->framing, qos->phy, in ase_qos()
1944 qos->sdu, qos->rtn, qos->latency, qos->pd); in ase_qos()
1946 switch (ep->status.state) { in ase_qos()
1953 LOG_WRN("Invalid operation in state: %s", bt_bap_ep_state_str(ep->status.state)); in ase_qos()
1959 stream = ep->stream; in ase_qos()
1966 if (stream->ep == NULL) { in ase_qos()
1967 LOG_ERR("NULL stream->ep"); in ase_qos()
1972 rsp->reason = bt_audio_verify_qos(qos); in ase_qos()
1973 if (rsp->reason != BT_BAP_ASCS_REASON_NONE) { in ase_qos()
1974 rsp->code = BT_BAP_ASCS_RSP_CODE_CONF_INVALID; in ase_qos()
1978 rsp->reason = bt_bap_stream_verify_qos(stream, qos); in ase_qos()
1979 if (rsp->reason != BT_BAP_ASCS_REASON_NONE) { in ase_qos()
1980 rsp->code = BT_BAP_ASCS_RSP_CODE_CONF_INVALID; in ase_qos()
1984 if (unicast_server_cb != NULL && unicast_server_cb->qos != NULL) { in ase_qos()
1985 int err = unicast_server_cb->qos(stream, qos, rsp); in ase_qos()
1988 if (rsp->code == BT_BAP_ASCS_RSP_CODE_SUCCESS) { in ase_qos()
1994 err, rsp->code, rsp->reason); in ase_qos()
1999 /* QoS->QoS transition. Unbind ISO if CIG/CIS changed. */ in ase_qos()
2000 if (ep->iso != NULL && (ep->cig_id != cig_id || ep->cis_id != cis_id)) { in ase_qos()
2001 bt_bap_iso_unbind_ep(ep->iso, ep); in ase_qos()
2004 if (ep->iso == NULL) { in ase_qos()
2007 iso = bap_iso_get_or_new(ase->conn, cig_id, cis_id); in ase_qos()
2015 if (bt_bap_iso_get_ep(false, iso, ep->dir) != NULL) { in ase_qos()
2017 &iso->chan, bt_audio_dir_str(ep->dir)); in ase_qos()
2029 ep->qos = *qos; in ase_qos()
2030 stream->qos = &ep->qos; in ase_qos()
2033 * we have the ISO <-> EP coupling completed (due to setting in ase_qos()
2036 bt_bap_iso_configure_data_path(ep, stream->codec_cfg); in ase_qos()
2038 ep->cig_id = cig_id; in ase_qos()
2039 ep->cis_id = cis_id; in ase_qos()
2054 if (buf->len < sizeof(*op)) { in is_valid_qos_len()
2055 LOG_WRN("Invalid length %u < %zu", buf->len, sizeof(*op)); in is_valid_qos_len()
2060 if (!is_valid_num_ases(conn, op->num_ases)) { in is_valid_qos_len()
2064 params_size = sizeof(struct bt_ascs_qos) * op->num_ases; in is_valid_qos_len()
2065 if (buf->len < params_size) { in is_valid_qos_len()
2072 if (buf->len > 0) { in is_valid_qos_len()
2092 LOG_DBG("num_ases %u", req->num_ases); in ascs_qos()
2094 for (uint8_t i = 0; i < req->num_ases; i++) { in ascs_qos()
2103 LOG_DBG("ase 0x%02x", qos->ase); in ascs_qos()
2105 if (!is_valid_ase_id(qos->ase)) { in ascs_qos()
2106 ascs_cp_rsp_add(qos->ase, BT_BAP_ASCS_RSP_CODE_INVALID_ASE, in ascs_qos()
2108 LOG_WRN("Unknown ase 0x%02x", qos->ase); in ascs_qos()
2112 ase = ase_find(conn, qos->ase); in ascs_qos()
2115 ascs_cp_rsp_add(qos->ase, BT_BAP_ASCS_RSP_CODE_INVALID_ASE_STATE, in ascs_qos()
2120 cqos.interval = sys_get_le24(qos->interval); in ascs_qos()
2121 cqos.framing = qos->framing; in ascs_qos()
2122 cqos.phy = qos->phy; in ascs_qos()
2123 cqos.sdu = sys_le16_to_cpu(qos->sdu); in ascs_qos()
2124 cqos.rtn = qos->rtn; in ascs_qos()
2125 cqos.latency = sys_le16_to_cpu(qos->latency); in ascs_qos()
2126 cqos.pd = sys_get_le24(qos->pd); in ascs_qos()
2128 ase_qos(ase, qos->cig, qos->cis, &cqos, &rsp); in ascs_qos()
2129 ascs_cp_rsp_add(qos->ase, rsp.code, rsp.reason); in ascs_qos()
2132 return buf->size; in ascs_qos()
2150 const struct bt_bap_ep *ep = result->ep; in ascs_parse_metadata()
2151 const uint8_t data_len = data->data_len; in ascs_parse_metadata()
2152 const uint8_t data_type = data->type; in ascs_parse_metadata()
2153 const uint8_t *data_value = data->data; in ascs_parse_metadata()
2169 *result->rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_METADATA_INVALID, in ascs_parse_metadata()
2171 result->err = -EBADMSG; in ascs_parse_metadata()
2177 *result->rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_METADATA_INVALID, in ascs_parse_metadata()
2179 result->err = -EINVAL; in ascs_parse_metadata()
2186 if (!is_context_available(result->conn, ep->dir, context)) { in ascs_parse_metadata()
2188 *result->rsp = BT_BAP_ASCS_RSP( in ascs_parse_metadata()
2190 result->err = -EACCES; in ascs_parse_metadata()
2199 *result->rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_METADATA_INVALID, in ascs_parse_metadata()
2201 result->err = -EBADMSG; in ascs_parse_metadata()
2212 if (!bt_cap_acceptor_ccid_exist(ep->stream->conn, ccid)) { in ascs_parse_metadata()
2232 *result->rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_METADATA_INVALID, in ascs_parse_metadata()
2234 result->err = -EBADMSG; in ascs_parse_metadata()
2243 *result->rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_METADATA_INVALID, in ascs_parse_metadata()
2245 result->err = -EBADMSG; in ascs_parse_metadata()
2254 *result->rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_METADATA_INVALID, in ascs_parse_metadata()
2256 result->err = -EBADMSG; in ascs_parse_metadata()
2273 .conn = ase->conn, in ascs_verify_metadata()
2280 if (meta->len > CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE) { in ascs_verify_metadata()
2281 LOG_WRN("Not enough space for Codec Config Metadata: %u > %d", meta->len, in ascs_verify_metadata()
2285 return -ENOMEM; in ascs_verify_metadata()
2289 err = bt_audio_data_parse(meta->data, meta->len, ascs_parse_metadata, &result); in ascs_verify_metadata()
2290 if (err != 0 && err != -ECANCELED) { in ascs_verify_metadata()
2313 LOG_DBG("ase %p meta->len %u", ase, meta->len); in ase_metadata()
2315 ep = &ase->ep; in ase_metadata()
2316 state = ep->status.state; in ase_metadata()
2331 stream = ep->stream; in ase_metadata()
2338 } else if (unicast_server_cb != NULL && unicast_server_cb->metadata != NULL) { in ase_metadata()
2339 err = unicast_server_cb->metadata(stream, meta->data, meta->len, &rsp); in ase_metadata()
2341 err = -ENOTSUP; in ase_metadata()
2359 ep->codec_cfg.meta_len = meta->len; in ase_metadata()
2360 (void)memcpy(ep->codec_cfg.meta, meta->data, meta->len); in ase_metadata()
2363 ascs_ep_set_state(ep, ep->status.state); in ase_metadata()
2375 LOG_DBG("ase %p meta->len %u", ase, meta->len); in ase_enable()
2377 ep = &ase->ep; in ase_enable()
2380 if (ep->status.state != BT_BAP_EP_STATE_QOS_CONFIGURED) { in ase_enable()
2381 err = -EBADMSG; in ase_enable()
2382 LOG_WRN("Invalid operation in state: %s", bt_bap_ep_state_str(ep->status.state)); in ase_enable()
2388 stream = ep->stream; in ase_enable()
2395 } else if (unicast_server_cb != NULL && unicast_server_cb->enable != NULL) { in ase_enable()
2396 err = unicast_server_cb->enable(stream, meta->data, meta->len, &rsp); in ase_enable()
2398 err = -ENOTSUP; in ase_enable()
2414 return -EFAULT; in ase_enable()
2417 ep->codec_cfg.meta_len = meta->len; in ase_enable()
2418 (void)memcpy(ep->codec_cfg.meta, meta->data, meta->len); in ase_enable()
2434 if (buf->len < sizeof(*op)) { in is_valid_enable_len()
2435 LOG_WRN("Invalid length %u < %zu", buf->len, sizeof(*op)); in is_valid_enable_len()
2440 if (!is_valid_num_ases(conn, op->num_ases)) { in is_valid_enable_len()
2444 for (uint8_t i = 0U; i < op->num_ases; i++) { in is_valid_enable_len()
2447 if (buf->len < sizeof(*metadata)) { in is_valid_enable_len()
2453 if (buf->len < metadata->len) { in is_valid_enable_len()
2458 (void)net_buf_simple_pull_mem(buf, metadata->len); in is_valid_enable_len()
2461 if (buf->len > 0) { in is_valid_enable_len()
2483 LOG_DBG("num_ases %u", req->num_ases); in ascs_enable()
2485 for (i = 0; i < req->num_ases; i++) { in ascs_enable()
2489 (void)net_buf_simple_pull(buf, meta->len); in ascs_enable()
2491 if (!is_valid_ase_id(meta->ase)) { in ascs_enable()
2492 ascs_cp_rsp_add(meta->ase, BT_BAP_ASCS_RSP_CODE_INVALID_ASE, in ascs_enable()
2494 LOG_WRN("Unknown ase 0x%02x", meta->ase); in ascs_enable()
2498 ase = ase_find(conn, meta->ase); in ascs_enable()
2500 LOG_DBG("Invalid operation for idle ase 0x%02x", meta->ase); in ascs_enable()
2501 ascs_cp_rsp_add(meta->ase, BT_BAP_ASCS_RSP_CODE_INVALID_ASE_STATE, in ascs_enable()
2509 return buf->size; in ascs_enable()
2521 ep = &ase->ep; in ase_start()
2524 if (ep->status.state != BT_BAP_EP_STATE_ENABLING) { in ase_start()
2525 LOG_WRN("Invalid operation in state: %s", bt_bap_ep_state_str(ep->status.state)); in ase_start()
2531 if (ep->iso->chan.state != BT_ISO_STATE_CONNECTED) { in ase_start()
2536 ep->iso->chan.state); in ase_start()
2542 if (unicast_server_cb != NULL && unicast_server_cb->start != NULL) { in ase_start()
2543 err = unicast_server_cb->start(ep->stream, &rsp); in ase_start()
2545 err = -ENOTSUP; in ase_start()
2564 ep->receiver_ready = true; in ase_start()
2578 if (buf->len < sizeof(*op)) { in is_valid_start_len()
2579 LOG_WRN("Invalid length %u < %zu", buf->len, sizeof(*op)); in is_valid_start_len()
2584 if (!is_valid_num_ases(conn, op->num_ases)) { in is_valid_start_len()
2588 if (buf->len != op->num_ases) { in is_valid_start_len()
2609 LOG_DBG("num_ases %u", req->num_ases); in ascs_start()
2611 for (i = 0; i < req->num_ases; i++) { in ascs_start()
2650 return buf->size; in ascs_start()
2660 if (buf->len < sizeof(*op)) { in is_valid_disable_len()
2661 LOG_WRN("Invalid length %u < %zu", buf->len, sizeof(*op)); in is_valid_disable_len()
2666 if (!is_valid_num_ases(conn, op->num_ases)) { in is_valid_disable_len()
2670 if (buf->len != op->num_ases) { in is_valid_disable_len()
2690 LOG_DBG("num_ases %u", req->num_ases); in ascs_disable()
2692 for (uint8_t i = 0; i < req->num_ases; i++) { in ascs_disable()
2721 return buf->size; in ascs_disable()
2734 ep = &ase->ep; in ase_stop()
2736 if (ep->status.state != BT_BAP_EP_STATE_DISABLING) { in ase_stop()
2737 LOG_WRN("Invalid operation in state: %s", bt_bap_ep_state_str(ep->status.state)); in ase_stop()
2743 stream = ep->stream; in ase_stop()
2744 if (unicast_server_cb != NULL && unicast_server_cb->stop != NULL) { in ase_stop()
2745 err = unicast_server_cb->stop(stream, &rsp); in ase_stop()
2747 err = -ENOTSUP; in ase_stop()
2768 * procedure defined in Volume 3, Part C, Section 9.3.15. in ase_stop()
2789 if (buf->len < sizeof(*op)) { in is_valid_stop_len()
2790 LOG_WRN("Invalid length %u < %zu", buf->len, sizeof(*op)); in is_valid_stop_len()
2795 if (op->num_ases < 1U) { in is_valid_stop_len()
2800 if (buf->len != op->num_ases) { in is_valid_stop_len()
2821 LOG_DBG("num_ases %u", req->num_ases); in ascs_stop()
2823 for (i = 0; i < req->num_ases; i++) { in ascs_stop()
2862 return buf->size; in ascs_stop()
2872 if (buf->len < sizeof(*op)) { in is_valid_metadata_len()
2873 LOG_WRN("Invalid length %u < %zu", buf->len, sizeof(*op)); in is_valid_metadata_len()
2878 if (!is_valid_num_ases(conn, op->num_ases)) { in is_valid_metadata_len()
2882 for (uint8_t i = 0U; i < op->num_ases; i++) { in is_valid_metadata_len()
2885 if (buf->len < sizeof(*metadata)) { in is_valid_metadata_len()
2891 if (buf->len < metadata->len) { in is_valid_metadata_len()
2896 (void)net_buf_simple_pull_mem(buf, metadata->len); in is_valid_metadata_len()
2899 if (buf->len > 0) { in is_valid_metadata_len()
2921 LOG_DBG("num_ases %u", req->num_ases); in ascs_metadata()
2923 for (i = 0; i < req->num_ases; i++) { in ascs_metadata()
2927 (void)net_buf_simple_pull(buf, meta->len); in ascs_metadata()
2929 if (meta->len > CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE) { in ascs_metadata()
2930 LOG_DBG("Cannot store %u octets of metadata", meta->len); in ascs_metadata()
2932 ascs_cp_rsp_add(meta->ase, BT_BAP_ASCS_RSP_CODE_NO_MEM, in ascs_metadata()
2937 if (!is_valid_ase_id(meta->ase)) { in ascs_metadata()
2938 ascs_cp_rsp_add(meta->ase, BT_BAP_ASCS_RSP_CODE_INVALID_ASE, in ascs_metadata()
2940 LOG_WRN("Unknown ase 0x%02x", meta->ase); in ascs_metadata()
2944 ase = ase_find(conn, meta->ase); in ascs_metadata()
2946 LOG_DBG("Invalid operation for idle ase 0x%02x", meta->ase); in ascs_metadata()
2947 ascs_cp_rsp_add(meta->ase, BT_BAP_ASCS_RSP_CODE_INVALID_ASE_STATE, in ascs_metadata()
2955 return buf->size; in ascs_metadata()
2965 if (buf->len < sizeof(*op)) { in is_valid_release_len()
2966 LOG_WRN("Invalid length %u < %zu", buf->len, sizeof(*op)); in is_valid_release_len()
2971 if (!is_valid_num_ases(conn, op->num_ases)) { in is_valid_release_len()
2975 if (buf->len != op->num_ases) { in is_valid_release_len()
2996 LOG_DBG("num_ases %u", req->num_ases); in ascs_release()
2998 for (i = 0; i < req->num_ases; i++) { in ascs_release()
3027 return buf->size; in ascs_release()
3056 (void *)conn, attr, data, len, bt_ascs_op_str(req->op), req->op); in ascs_cp_write()
3058 ascs_cp_rsp_init(req->op); in ascs_cp_write()
3060 switch (req->op) { in ascs_cp_write()
3152 uint8_t snk_ases_to_rem = CONFIG_BT_ASCS_MAX_ASE_SNK_COUNT - snk_cnt; in configure_ase_char()
3153 uint8_t src_ases_to_rem = CONFIG_BT_ASCS_MAX_ASE_SRC_COUNT - src_cnt; in configure_ase_char()
3160 ascs_svc.attr_count -= attrs_to_rem; in configure_ase_char()
3170 ascs_svc.attr_count -= attrs_to_rem; in configure_ase_char()
3176 size_t src_start_idx = ascs_svc.attr_count - (src_cnt * ASCS_ASE_CHAR_ATTR_COUNT); in configure_ase_char()
3177 size_t new_src_start_idx = src_start_idx - (snk_ases_to_rem * in configure_ase_char()
3184 ascs_svc.attr_count -= attrs_to_rem; in configure_ase_char()
3195 return -EALREADY; in bt_ascs_register()
3202 return -EINVAL; in bt_ascs_register()
3209 return -EINVAL; in bt_ascs_register()
3241 return -ENOTSUP; in bt_ascs_init()
3245 return -EALREADY; in bt_ascs_init()
3264 if (ase->conn != NULL) { in bt_ascs_cleanup()
3265 bt_ascs_release_ase(&ase->ep); in bt_ascs_cleanup()
3281 return -EALREADY; in bt_ascs_unregister()
3288 return -EBUSY; in bt_ascs_unregister()