Lines Matching +full:source +full:- +full:dir

7  * Copyright (c) 2022-2023 Nordic Semiconductor ASA
9 * SPDX-License-Identifier: Apache-2.0
89 /* Source Available Contexts override value */
142 const struct bt_audio_codec_cap *codec_cap = cap->codec_cap; in build_pac_records()
143 struct net_buf_simple *buf = data->buf; in build_pac_records()
154 pac_codec->id = codec_cap->id; in build_pac_records()
155 pac_codec->cid = sys_cpu_to_le16(codec_cap->cid); in build_pac_records()
156 pac_codec->vid = sys_cpu_to_le16(codec_cap->vid); in build_pac_records()
158 if (net_buf_simple_tailroom(buf) < (sizeof(struct bt_pac_ltv_data) + codec_cap->data_len)) { in build_pac_records()
162 net_buf_simple_add_u8(buf, codec_cap->data_len); in build_pac_records()
163 net_buf_simple_add_mem(buf, codec_cap->data, codec_cap->data_len); in build_pac_records()
165 if (net_buf_simple_tailroom(buf) < (sizeof(struct bt_pac_ltv_data) + codec_cap->meta_len)) { in build_pac_records()
169 net_buf_simple_add_u8(buf, codec_cap->meta_len); in build_pac_records()
170 net_buf_simple_add_mem(buf, codec_cap->meta, codec_cap->meta_len); in build_pac_records()
172 data->rsp->num_pac++; in build_pac_records()
204 data.rsp->num_pac = 0; in get_pac_records()
216 enum bt_audio_dir dir) in pacs_get_available_contexts_for_conn() argument
223 return bt_pacs_get_available_contexts(dir); in pacs_get_available_contexts_for_conn()
226 switch (dir) { in pacs_get_available_contexts_for_conn()
229 if (client->snk_available_contexts != NULL) { in pacs_get_available_contexts_for_conn()
230 return POINTER_TO_UINT(client->snk_available_contexts); in pacs_get_available_contexts_for_conn()
236 if (client->src_available_contexts != NULL) { in pacs_get_available_contexts_for_conn()
237 return POINTER_TO_UINT(client->src_available_contexts); in pacs_get_available_contexts_for_conn()
243 return bt_pacs_get_available_contexts(dir); in pacs_get_available_contexts_for_conn()
271 static uint16_t supported_context_get(enum bt_audio_dir dir) in supported_context_get() argument
273 switch (dir) { in supported_context_get()
308 return -ENOTSUP; in set_available_contexts()
569 static sys_slist_t *pacs_get(enum bt_audio_dir dir) in pacs_get() argument
571 switch (dir) { in pacs_get()
679 static int pac_notify_loc(struct bt_conn *conn, enum bt_audio_dir dir) in pac_notify_loc() argument
685 switch (dir) { in pac_notify_loc()
699 return -EINVAL; in pac_notify_loc()
703 if (err != 0 && err != -ENOTCONN) { in pac_notify_loc()
713 static int pac_notify(struct bt_conn *conn, enum bt_audio_dir dir) in pac_notify() argument
719 switch (dir) { in pac_notify()
731 return -EINVAL; in pac_notify()
741 pacs = pacs_get(dir); in pac_notify()
747 if (err != 0 && err != -ENOTCONN) { in pac_notify()
753 if (err == -ENOTCONN) { in pac_notify()
773 if (err != 0 && err != -ENOTCONN) { in available_contexts_notify()
791 if (err != 0 && err != -ENOTCONN) { in supported_contexts_notify()
830 if (err && err != -ENOTCONN) { in pacs_gatt_notify()
867 if (atomic_test_bit(client->flags, FLAG_SINK_PAC_CHANGED)) { in notify_cb()
871 atomic_clear_bit(client->flags, FLAG_SINK_PAC_CHANGED); in notify_cb()
877 if (atomic_test_bit(client->flags, FLAG_SINK_AUDIO_LOCATIONS_CHANGED)) { in notify_cb()
881 atomic_clear_bit(client->flags, FLAG_SINK_AUDIO_LOCATIONS_CHANGED); in notify_cb()
887 if (atomic_test_bit(client->flags, FLAG_SOURCE_PAC_CHANGED)) { in notify_cb()
888 LOG_DBG("Notifying Source PAC"); in notify_cb()
891 atomic_clear_bit(client->flags, FLAG_SOURCE_PAC_CHANGED); in notify_cb()
897 if (atomic_test_and_clear_bit(client->flags, FLAG_SOURCE_AUDIO_LOCATIONS_CHANGED)) { in notify_cb()
898 LOG_DBG("Notifying Source Audio Location"); in notify_cb()
901 atomic_clear_bit(client->flags, FLAG_SOURCE_AUDIO_LOCATIONS_CHANGED); in notify_cb()
906 if (atomic_test_bit(client->flags, FLAG_AVAILABLE_AUDIO_CONTEXT_CHANGED)) { in notify_cb()
910 atomic_clear_bit(client->flags, FLAG_AVAILABLE_AUDIO_CONTEXT_CHANGED); in notify_cb()
915 atomic_test_bit(client->flags, FLAG_SUPPORTED_AUDIO_CONTEXT_CHANGED)) { in notify_cb()
919 atomic_clear_bit(client->flags, FLAG_SUPPORTED_AUDIO_CONTEXT_CHANGED); in notify_cb()
980 if (err != 0 || conn->encrypt == 0) { in pacs_security_changed()
984 if (!bt_addr_le_is_bonded(conn->id, &conn->le.dst)) { in pacs_security_changed()
1013 if (client->snk_available_contexts != NULL) { in pacs_disconnected()
1014 uint16_t old = POINTER_TO_UINT(client->snk_available_contexts); in pacs_disconnected()
1017 client->snk_available_contexts = NULL; in pacs_disconnected()
1020 atomic_set_bit_to(client->flags, FLAG_AVAILABLE_AUDIO_CONTEXT_CHANGED, old != new); in pacs_disconnected()
1025 if (client->src_available_contexts != NULL) { in pacs_disconnected()
1026 uint16_t old = POINTER_TO_UINT(client->src_available_contexts); in pacs_disconnected()
1029 client->src_available_contexts = NULL; in pacs_disconnected()
1032 atomic_set_bit_to(client->flags, FLAG_AVAILABLE_AUDIO_CONTEXT_CHANGED, old != new); in pacs_disconnected()
1047 void bt_pacs_cap_foreach(enum bt_audio_dir dir, bt_pacs_cap_foreach_func_t func, void *user_data) in bt_pacs_cap_foreach() argument
1056 pac = pacs_get(dir); in bt_pacs_cap_foreach()
1072 memcpy(&clients[i].addr, &info->addr, sizeof(bt_addr_le_t)); in add_bonded_addr_to_client_list()
1081 int bt_pacs_cap_register(enum bt_audio_dir dir, struct bt_pacs_cap *cap) in bt_pacs_cap_register() argument
1087 if (!cap || !cap->codec_cap) { in bt_pacs_cap_register()
1088 return -EINVAL; in bt_pacs_cap_register()
1091 codec_cap = cap->codec_cap; in bt_pacs_cap_register()
1093 pac = pacs_get(dir); in bt_pacs_cap_register()
1095 return -EINVAL; in bt_pacs_cap_register()
1101 LOG_DBG("cap %p dir %s codec_cap id 0x%02x codec_cap cid 0x%04x codec_cap vid 0x%04x", cap, in bt_pacs_cap_register()
1102 bt_audio_dir_str(dir), codec_cap->id, codec_cap->cid, codec_cap->vid); in bt_pacs_cap_register()
1104 sys_slist_append(pac, &cap->_node); in bt_pacs_cap_register()
1113 if (IS_ENABLED(CONFIG_BT_PAC_SNK_NOTIFIABLE) && dir == BT_AUDIO_DIR_SINK) { in bt_pacs_cap_register()
1118 if (IS_ENABLED(CONFIG_BT_PAC_SRC_NOTIFIABLE) && dir == BT_AUDIO_DIR_SOURCE) { in bt_pacs_cap_register()
1127 int bt_pacs_cap_unregister(enum bt_audio_dir dir, struct bt_pacs_cap *cap) in bt_pacs_cap_unregister() argument
1132 return -EINVAL; in bt_pacs_cap_unregister()
1135 pac = pacs_get(dir); in bt_pacs_cap_unregister()
1137 return -EINVAL; in bt_pacs_cap_unregister()
1140 LOG_DBG("cap %p dir %s", cap, bt_audio_dir_str(dir)); in bt_pacs_cap_unregister()
1142 if (!sys_slist_find_and_remove(pac, &cap->_node)) { in bt_pacs_cap_unregister()
1143 return -ENOENT; in bt_pacs_cap_unregister()
1146 switch (dir) { in bt_pacs_cap_unregister()
1160 return -EINVAL; in bt_pacs_cap_unregister()
1166 int bt_pacs_set_location(enum bt_audio_dir dir, enum bt_audio_location location) in bt_pacs_set_location() argument
1168 switch (dir) { in bt_pacs_set_location()
1176 return -EINVAL; in bt_pacs_set_location()
1182 int bt_pacs_set_available_contexts(enum bt_audio_dir dir, enum bt_audio_context contexts) in bt_pacs_set_available_contexts() argument
1184 switch (dir) { in bt_pacs_set_available_contexts()
1187 supported_context_get(dir)); in bt_pacs_set_available_contexts()
1190 supported_context_get(dir)); in bt_pacs_set_available_contexts()
1193 return -EINVAL; in bt_pacs_set_available_contexts()
1196 int bt_pacs_conn_set_available_contexts_for_conn(struct bt_conn *conn, enum bt_audio_dir dir, in bt_pacs_conn_set_available_contexts_for_conn() argument
1199 enum bt_audio_context old = pacs_get_available_contexts_for_conn(conn, dir); in bt_pacs_conn_set_available_contexts_for_conn()
1206 return -ENOENT; in bt_pacs_conn_set_available_contexts_for_conn()
1215 switch (dir) { in bt_pacs_conn_set_available_contexts_for_conn()
1219 client->snk_available_contexts = UINT_TO_POINTER(*contexts); in bt_pacs_conn_set_available_contexts_for_conn()
1221 client->snk_available_contexts = NULL; in bt_pacs_conn_set_available_contexts_for_conn()
1229 client->src_available_contexts = UINT_TO_POINTER(*contexts); in bt_pacs_conn_set_available_contexts_for_conn()
1231 client->src_available_contexts = NULL; in bt_pacs_conn_set_available_contexts_for_conn()
1237 return -EINVAL; in bt_pacs_conn_set_available_contexts_for_conn()
1240 if (pacs_get_available_contexts_for_conn(conn, dir) == old) { in bt_pacs_conn_set_available_contexts_for_conn()
1245 atomic_set_bit(client->flags, FLAG_AVAILABLE_AUDIO_CONTEXT_CHANGED); in bt_pacs_conn_set_available_contexts_for_conn()
1255 int bt_pacs_set_supported_contexts(enum bt_audio_dir dir, enum bt_audio_context contexts) in bt_pacs_set_supported_contexts() argument
1260 switch (dir) { in bt_pacs_set_supported_contexts()
1267 return -ENOTSUP; in bt_pacs_set_supported_contexts()
1274 return -ENOTSUP; in bt_pacs_set_supported_contexts()
1276 return -EINVAL; in bt_pacs_set_supported_contexts()
1283 return -EALREADY; in bt_pacs_set_supported_contexts()
1286 enum bt_audio_context bt_pacs_get_available_contexts(enum bt_audio_dir dir) in bt_pacs_get_available_contexts() argument
1288 switch (dir) { in bt_pacs_get_available_contexts()
1299 enum bt_audio_dir dir) in bt_pacs_get_available_contexts_for_conn() argument
1306 return pacs_get_available_contexts_for_conn(conn, dir); in bt_pacs_get_available_contexts_for_conn()