Lines Matching refs:sep

79 static void avdtp_sep_lock(struct bt_avdtp_sep *sep)  in avdtp_sep_lock()  argument
81 if (sep != NULL) { in avdtp_sep_lock()
82 k_sem_take(&sep->sem_lock, K_FOREVER); in avdtp_sep_lock()
86 static void avdtp_sep_unlock(struct bt_avdtp_sep *sep) in avdtp_sep_unlock() argument
88 if (sep != NULL) { in avdtp_sep_unlock()
89 k_sem_give(&sep->sem_lock); in avdtp_sep_unlock()
93 static void bt_avdtp_set_state(struct bt_avdtp_sep *sep, uint8_t state) in bt_avdtp_set_state() argument
95 sep->state = state; in bt_avdtp_set_state()
97 sep->sep_info.inuse = 1U; in bt_avdtp_set_state()
99 sep->sep_info.inuse = 0U; in bt_avdtp_set_state()
103 static void bt_avdtp_set_state_lock(struct bt_avdtp_sep *sep, uint8_t state) in bt_avdtp_set_state_lock() argument
105 avdtp_sep_lock(sep); in bt_avdtp_set_state_lock()
106 bt_avdtp_set_state(sep, state); in bt_avdtp_set_state_lock()
107 avdtp_sep_unlock(sep); in bt_avdtp_set_state_lock()
121 struct bt_avdtp_sep *sep = CONTAINER_OF(chan, struct bt_avdtp_sep, chan.chan); in bt_avdtp_media_l2cap_connected() local
128 session = sep->session; in bt_avdtp_media_l2cap_connected()
134 bt_avdtp_set_state_lock(sep, AVDTP_OPEN); in bt_avdtp_media_l2cap_connected()
149 struct bt_avdtp_sep *sep = CONTAINER_OF(chan, struct bt_avdtp_sep, chan.chan); in bt_avdtp_media_l2cap_disconnected() local
151 session = sep->session; in bt_avdtp_media_l2cap_disconnected()
158 avdtp_sep_lock(sep); in bt_avdtp_media_l2cap_disconnected()
159 if ((sep->state == AVDTP_CLOSING) && (session->req != NULL) && in bt_avdtp_media_l2cap_disconnected()
164 bt_avdtp_set_state(sep, AVDTP_IDLE); in bt_avdtp_media_l2cap_disconnected()
165 avdtp_sep_unlock(sep); in bt_avdtp_media_l2cap_disconnected()
171 } else if (sep->state > AVDTP_OPENING) { in bt_avdtp_media_l2cap_disconnected()
172 bt_avdtp_set_state(sep, AVDTP_IDLE); in bt_avdtp_media_l2cap_disconnected()
173 avdtp_sep_unlock(sep); in bt_avdtp_media_l2cap_disconnected()
175 session->ops->stream_l2cap_disconnected(session, sep); in bt_avdtp_media_l2cap_disconnected()
177 avdtp_sep_unlock(sep); in bt_avdtp_media_l2cap_disconnected()
184 struct bt_avdtp_sep *sep = CONTAINER_OF(chan, struct bt_avdtp_sep, chan.chan); in bt_avdtp_media_l2cap_recv() local
186 if (sep->media_data_cb != NULL) { in bt_avdtp_media_l2cap_recv()
187 sep->media_data_cb(sep, buf); in bt_avdtp_media_l2cap_recv()
198 static int avdtp_media_connect(struct bt_avdtp *session, struct bt_avdtp_sep *sep) in avdtp_media_connect() argument
204 sep->session = session; in avdtp_media_connect()
205 sep->chan.rx.mtu = BT_L2CAP_RX_MTU; in avdtp_media_connect()
206 sep->chan.chan.ops = &stream_chan_ops; in avdtp_media_connect()
207 sep->chan.required_sec_level = BT_SECURITY_L2; in avdtp_media_connect()
209 return bt_l2cap_chan_connect(session->br_chan.chan.conn, &sep->chan.chan, in avdtp_media_connect()
213 static int avdtp_media_disconnect(struct bt_avdtp_sep *sep) in avdtp_media_disconnect() argument
215 if (sep == NULL || sep->chan.chan.conn == NULL || sep->chan.chan.ops == NULL) { in avdtp_media_disconnect()
219 return bt_l2cap_chan_disconnect(&sep->chan.chan); in avdtp_media_disconnect()
268 struct bt_avdtp_sep *sep; in avdtp_discover_handler() local
294 SYS_SLIST_FOR_EACH_CONTAINER(&seps, sep, _node) { in avdtp_discover_handler()
296 sep_data.inuse = sep->sep_info.inuse; in avdtp_discover_handler()
297 sep_data.id = sep->sep_info.id; in avdtp_discover_handler()
298 sep_data.tsep = sep->sep_info.tsep; in avdtp_discover_handler()
299 sep_data.media_type = sep->sep_info.media_type; in avdtp_discover_handler()
332 struct bt_avdtp_sep *sep = NULL; in avdtp_get_sep() local
334 SYS_SLIST_FOR_EACH_CONTAINER(&seps, sep, _node) { in avdtp_get_sep()
335 if (sep->sep_info.id == stream_endpoint_id) { in avdtp_get_sep()
340 return sep; in avdtp_get_sep()
345 struct bt_avdtp_sep *sep; in avdtp_get_cmd_sep() local
351 sep = avdtp_get_sep(net_buf_pull_u8(buf) >> 2); in avdtp_get_cmd_sep()
352 return sep; in avdtp_get_cmd_sep()
361 struct bt_avdtp_sep *sep; in avdtp_get_capabilities_handler() local
364 sep = avdtp_get_cmd_sep(buf); in avdtp_get_capabilities_handler()
365 if ((sep == NULL) || (session->ops->get_capabilities_ind == NULL)) { in avdtp_get_capabilities_handler()
374 err = session->ops->get_capabilities_ind(session, sep, rsp_buf, in avdtp_get_capabilities_handler()
428 struct bt_avdtp_sep *sep; in avdtp_process_configuration() local
432 sep = avdtp_get_cmd_sep(buf); in avdtp_process_configuration()
433 avdtp_sep_lock(sep); in avdtp_process_configuration()
434 if (sep == NULL) { in avdtp_process_configuration()
449 if (!(sep->state & expected_state)) { in avdtp_process_configuration()
457 avdtp_sep_unlock(sep); in avdtp_process_configuration()
464 session, sep, int_seid, buf, &error_code); in avdtp_process_configuration()
467 session, sep, int_seid, buf, &error_code); in avdtp_process_configuration()
476 avdtp_sep_unlock(sep); in avdtp_process_configuration()
499 bt_avdtp_set_state(sep, AVDTP_CONFIGURED); in avdtp_process_configuration()
501 avdtp_sep_unlock(sep); in avdtp_process_configuration()
511 bt_avdtp_set_state_lock(SET_CONF_REQ(req)->sep, AVDTP_CONFIGURED); in avdtp_process_configuration()
569 struct bt_avdtp_sep *sep; in avdtp_open_handler() local
573 sep = avdtp_get_cmd_sep(buf); in avdtp_open_handler()
574 avdtp_sep_lock(sep); in avdtp_open_handler()
575 if ((sep == NULL) || (session->ops->open_ind == NULL)) { in avdtp_open_handler()
578 if (sep->state != AVDTP_CONFIGURED) { in avdtp_open_handler()
582 err = session->ops->open_ind(session, sep, &error_code); in avdtp_open_handler()
589 avdtp_sep_unlock(sep); in avdtp_open_handler()
600 session->current_sep = sep; in avdtp_open_handler()
610 bt_avdtp_set_state(sep, AVDTP_OPENING); in avdtp_open_handler()
612 avdtp_sep_unlock(sep); in avdtp_open_handler()
622 bt_avdtp_set_state_lock(CTRL_REQ(req)->sep, AVDTP_OPENING); in avdtp_open_handler()
624 if (!avdtp_media_connect(session, CTRL_REQ(req)->sep)) { in avdtp_open_handler()
643 struct bt_avdtp_sep *sep; in avdtp_start_handler() local
647 sep = avdtp_get_cmd_sep(buf); in avdtp_start_handler()
648 avdtp_sep_lock(sep); in avdtp_start_handler()
649 if ((sep == NULL) || (session->ops->start_ind == NULL)) { in avdtp_start_handler()
652 if (sep->state != AVDTP_OPEN) { in avdtp_start_handler()
656 err = session->ops->start_ind(session, sep, &error_code); in avdtp_start_handler()
663 avdtp_sep_unlock(sep); in avdtp_start_handler()
681 bt_avdtp_set_state(sep, AVDTP_STREAMING); in avdtp_start_handler()
683 avdtp_sep_unlock(sep); in avdtp_start_handler()
692 bt_avdtp_set_state_lock(CTRL_REQ(req)->sep, AVDTP_STREAMING); in avdtp_start_handler()
717 struct bt_avdtp_sep *sep; in avdtp_close_handler() local
721 sep = avdtp_get_cmd_sep(buf); in avdtp_close_handler()
722 avdtp_sep_lock(sep); in avdtp_close_handler()
723 if ((sep == NULL) || (session->ops->close_ind == NULL)) { in avdtp_close_handler()
726 if (!(sep->state & (AVDTP_OPEN | AVDTP_STREAMING))) { in avdtp_close_handler()
730 err = session->ops->close_ind(session, sep, &error_code); in avdtp_close_handler()
737 avdtp_sep_unlock(sep); in avdtp_close_handler()
748 bt_avdtp_set_state(sep, AVDTP_CLOSING); in avdtp_close_handler()
757 bt_avdtp_set_state(sep, AVDTP_IDLE); in avdtp_close_handler()
759 avdtp_sep_unlock(sep); in avdtp_close_handler()
769 bt_avdtp_set_state_lock(CTRL_REQ(req)->sep, AVDTP_CLOSING); in avdtp_close_handler()
770 if (!avdtp_media_disconnect(CTRL_REQ(req)->sep)) { in avdtp_close_handler()
787 struct bt_avdtp_sep *sep; in avdtp_suspend_handler() local
791 sep = avdtp_get_cmd_sep(buf); in avdtp_suspend_handler()
792 avdtp_sep_lock(sep); in avdtp_suspend_handler()
793 if ((sep == NULL) || (session->ops->suspend_ind == NULL)) { in avdtp_suspend_handler()
796 if (sep->state != AVDTP_STREAMING) { in avdtp_suspend_handler()
800 err = session->ops->suspend_ind(session, sep, &error_code); in avdtp_suspend_handler()
808 avdtp_sep_unlock(sep); in avdtp_suspend_handler()
826 bt_avdtp_set_state(sep, AVDTP_OPEN); in avdtp_suspend_handler()
828 avdtp_sep_unlock(sep); in avdtp_suspend_handler()
837 bt_avdtp_set_state_lock(CTRL_REQ(req)->sep, AVDTP_OPEN); in avdtp_suspend_handler()
862 struct bt_avdtp_sep *sep; in avdtp_abort_handler() local
866 sep = avdtp_get_cmd_sep(buf); in avdtp_abort_handler()
867 avdtp_sep_lock(sep); in avdtp_abort_handler()
868 if ((sep == NULL) || (session->ops->abort_ind == NULL)) { in avdtp_abort_handler()
872 err = session->ops->abort_ind(session, sep, &error_code); in avdtp_abort_handler()
878 avdtp_sep_unlock(sep); in avdtp_abort_handler()
896 if ((sep->state & (AVDTP_OPEN | AVDTP_STREAMING)) && in avdtp_abort_handler()
897 (sep->chan.state == BT_L2CAP_CONNECTED)) { in avdtp_abort_handler()
898 bt_avdtp_set_state(sep, AVDTP_ABORTING); in avdtp_abort_handler()
900 bt_avdtp_set_state(sep, AVDTP_IDLE); in avdtp_abort_handler()
903 avdtp_sep_unlock(sep); in avdtp_abort_handler()
912 uint8_t pre_state = CTRL_REQ(req)->sep->state; in avdtp_abort_handler()
914 bt_avdtp_set_state_lock(CTRL_REQ(req)->sep, AVDTP_ABORTING); in avdtp_abort_handler()
917 avdtp_media_disconnect(CTRL_REQ(req)->sep); in avdtp_abort_handler()
923 bt_avdtp_set_state_lock(CTRL_REQ(req)->sep, AVDTP_IDLE); in avdtp_abort_handler()
1254 int bt_avdtp_register_sep(uint8_t media_type, uint8_t sep_type, struct bt_avdtp_sep *sep) in bt_avdtp_register_sep() argument
1260 if (!sep) { in bt_avdtp_register_sep()
1270 sep->sep_info.id = bt_avdtp_sep++; in bt_avdtp_register_sep()
1271 sep->sep_info.inuse = 0U; in bt_avdtp_register_sep()
1272 sep->sep_info.media_type = media_type; in bt_avdtp_register_sep()
1273 sep->sep_info.tsep = sep_type; in bt_avdtp_register_sep()
1275 k_sem_init(&sep->sem_lock, 1, 1); in bt_avdtp_register_sep()
1276 bt_avdtp_set_state_lock(sep, AVDTP_IDLE); in bt_avdtp_register_sep()
1278 sys_slist_append(&seps, &sep->_node); in bt_avdtp_register_sep()
1475 if (!param || !session || !param->sep) { in bt_avdtp_set_configuration()
1480 if (param->sep->state != AVDTP_IDLE) { in bt_avdtp_set_configuration()
1489 if (!param || !session || !param->sep) { in bt_avdtp_reconfigure()
1494 if (param->sep->state != AVDTP_OPEN) { in bt_avdtp_reconfigure()
1507 if (!param || !session || !param->sep) { in bt_avdtp_ctrl()
1512 if (!(param->sep->state & check_state)) { in bt_avdtp_ctrl()
1544 if (!err && param->sep->sep_info.tsep == BT_AVDTP_SINK) { in bt_avdtp_start()
1545 bt_avdtp_set_state_lock(param->sep, AVDTP_STREAMING); in bt_avdtp_start()
1563 int bt_avdtp_send_media_data(struct bt_avdtp_sep *sep, struct net_buf *buf) in bt_avdtp_send_media_data() argument
1567 if (sep->state != AVDTP_STREAMING || sep->sep_info.tsep != BT_AVDTP_SOURCE) { in bt_avdtp_send_media_data()
1571 err = bt_l2cap_chan_send(&sep->chan.chan, buf); in bt_avdtp_send_media_data()
1580 uint32_t bt_avdtp_get_media_mtu(struct bt_avdtp_sep *sep) in bt_avdtp_get_media_mtu() argument
1582 return sep->chan.tx.mtu; in bt_avdtp_get_media_mtu()