Bluetooth: audio: pacs: Replace capabilities API with pacs

This changes the API to use proper naming convention, as the code has
been moved out of capabilities.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This commit is contained in:
Mariusz Skamra 2022-10-20 11:25:38 +02:00 committed by Carles Cufí
commit 2627063ab2
13 changed files with 135 additions and 135 deletions

View file

@ -7,8 +7,8 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_CAPABILITIES_H_ #ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PACS_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_CAPABILITIES_H_ #define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PACS_H_
#include <zephyr/bluetooth/audio/audio.h> #include <zephyr/bluetooth/audio/audio.h>
@ -16,8 +16,8 @@
extern "C" { extern "C" {
#endif #endif
/** @brief Audio Capability structure. */ /** @brief Published Audio Capability structure. */
struct bt_audio_capability { struct bt_pacs_cap {
/** Capability codec reference */ /** Capability codec reference */
struct bt_codec *codec; struct bt_codec *codec;
@ -25,19 +25,19 @@ struct bt_audio_capability {
sys_snode_t _node; sys_snode_t _node;
}; };
/** @typedef bt_audio_foreach_capability_func_t /** @typedef bt_pacs_cap_foreach_func_t
* @brief Capability iterator callback. * @brief Published Audio Capability iterator callback.
* *
* @param capability Capability found. * @param cap Capability found.
* @param user_data Data given. * @param user_data Data given.
* *
* @return true to continue to the next capability * @return true to continue to the next capability
* @return false to stop the iteration * @return false to stop the iteration
*/ */
typedef bool (*bt_audio_foreach_capability_func_t)(const struct bt_audio_capability *capability, typedef bool (*bt_pacs_cap_foreach_func_t)(const struct bt_pacs_cap *cap,
void *user_data); void *user_data);
/** @brief Capability iterator. /** @brief Published Audio Capability iterator.
* *
* Iterate capabilities with endpoint direction specified. * Iterate capabilities with endpoint direction specified.
* *
@ -45,10 +45,11 @@ typedef bool (*bt_audio_foreach_capability_func_t)(const struct bt_audio_capabil
* @param func Callback function. * @param func Callback function.
* @param user_data Data to pass to the callback. * @param user_data Data to pass to the callback.
*/ */
void bt_audio_foreach_capability(enum bt_audio_dir dir, bt_audio_foreach_capability_func_t func, void bt_pacs_cap_foreach(enum bt_audio_dir dir,
void *user_data); bt_pacs_cap_foreach_func_t func,
void *user_data);
/** @brief Register Audio Capability. /** @brief Register Published Audio Capability.
* *
* Register Audio Local Capability. * Register Audio Local Capability.
* *
@ -57,9 +58,9 @@ void bt_audio_foreach_capability(enum bt_audio_dir dir, bt_audio_foreach_capabil
* *
* @return 0 in case of success or negative value in case of error. * @return 0 in case of success or negative value in case of error.
*/ */
int bt_audio_capability_register(enum bt_audio_dir dir, struct bt_audio_capability *cap); int bt_pacs_cap_register(enum bt_audio_dir dir, struct bt_pacs_cap *cap);
/** @brief Unregister Audio Capability. /** @brief Unregister Published Audio Capability.
* *
* Unregister Audio Local Capability. * Unregister Audio Local Capability.
* *
@ -68,7 +69,7 @@ int bt_audio_capability_register(enum bt_audio_dir dir, struct bt_audio_capabili
* *
* @return 0 in case of success or negative value in case of error. * @return 0 in case of success or negative value in case of error.
*/ */
int bt_audio_capability_unregister(enum bt_audio_dir dir, struct bt_audio_capability *cap); int bt_pacs_cap_unregister(enum bt_audio_dir dir, struct bt_pacs_cap *cap);
/** @brief Set the location for an endpoint type /** @brief Set the location for an endpoint type
* *
@ -76,16 +77,16 @@ int bt_audio_capability_unregister(enum bt_audio_dir dir, struct bt_audio_capabi
* @param location The location to be set. * @param location The location to be set.
* *
*/ */
int bt_audio_capability_set_location(enum bt_audio_dir dir, int bt_pacs_set_location(enum bt_audio_dir dir,
enum bt_audio_location location); enum bt_audio_location location);
/** @brief Set the available contexts for an endpoint type /** @brief Set the available contexts for an endpoint type
* *
* @param dir Direction of the endpoints to change available contexts for. * @param dir Direction of the endpoints to change available contexts for.
* @param contexts The contexts to be set. * @param contexts The contexts to be set.
*/ */
int bt_audio_capability_set_available_contexts(enum bt_audio_dir dir, int bt_pacs_set_available_contexts(enum bt_audio_dir dir,
enum bt_audio_context contexts); enum bt_audio_context contexts);
/** @brief Get the available contexts for an endpoint type /** @brief Get the available contexts for an endpoint type
* *
@ -93,10 +94,10 @@ int bt_audio_capability_set_available_contexts(enum bt_audio_dir dir,
* *
* @return Bitmask of available contexts. * @return Bitmask of available contexts.
*/ */
enum bt_audio_context bt_audio_capability_get_available_contexts(enum bt_audio_dir dir); enum bt_audio_context bt_pacs_get_available_contexts(enum bt_audio_dir dir);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_CAPABILITIES_H_ */ #endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PACS_H_ */

View file

@ -6,7 +6,7 @@
#include <zephyr/bluetooth/bluetooth.h> #include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/audio/audio.h> #include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/capabilities.h> #include <zephyr/bluetooth/audio/pacs.h>
#define SEM_TIMEOUT K_SECONDS(10) #define SEM_TIMEOUT K_SECONDS(10)
@ -148,7 +148,7 @@ static struct bt_audio_broadcast_sink_cb broadcast_sink_cbs = {
.pa_sync_lost = pa_sync_lost_cb .pa_sync_lost = pa_sync_lost_cb
}; };
static struct bt_audio_capability capabilities = { static struct bt_pacs_cap cap = {
.codec = &codec, .codec = &codec,
}; };
@ -164,7 +164,7 @@ static int init(void)
printk("Bluetooth initialized\n"); printk("Bluetooth initialized\n");
err = bt_audio_capability_register(BT_AUDIO_DIR_SINK, &capabilities); err = bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap);
if (err) { if (err) {
printk("Capability register failed (err %d)\n", err); printk("Capability register failed (err %d)\n", err);
return err; return err;

View file

@ -14,7 +14,7 @@
#include <zephyr/bluetooth/bluetooth.h> #include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/conn.h> #include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/audio/audio.h> #include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/capabilities.h> #include <zephyr/bluetooth/audio/pacs.h>
NET_BUF_POOL_FIXED_DEFINE(tx_pool, CONFIG_BT_ASCS_ASE_SRC_COUNT, NET_BUF_POOL_FIXED_DEFINE(tx_pool, CONFIG_BT_ASCS_ASE_SRC_COUNT,
BT_ISO_SDU_BUF_SIZE(CONFIG_BT_ISO_TX_MTU), BT_ISO_SDU_BUF_SIZE(CONFIG_BT_ISO_TX_MTU),
@ -411,11 +411,11 @@ BT_CONN_CB_DEFINE(conn_callbacks) = {
.disconnected = disconnected, .disconnected = disconnected,
}; };
static struct bt_audio_capability caps_sink = { static struct bt_pacs_cap cap_sink = {
.codec = &lc3_codec, .codec = &lc3_codec,
}; };
static struct bt_audio_capability caps_source = { static struct bt_pacs_cap cap_source = {
.codec = &lc3_codec, .codec = &lc3_codec,
}; };
@ -423,10 +423,10 @@ int bap_unicast_sr_init(void)
{ {
bt_audio_unicast_server_register_cb(&unicast_server_cb); bt_audio_unicast_server_register_cb(&unicast_server_cb);
bt_audio_capability_register(BT_AUDIO_DIR_SINK, &caps_sink); bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink);
if (IS_ENABLED(CONFIG_BT_ASCS_ASE_SRC)) { if (IS_ENABLED(CONFIG_BT_ASCS_ASE_SRC)) {
bt_audio_capability_register(BT_AUDIO_DIR_SOURCE, &caps_source); bt_pacs_cap_register(BT_AUDIO_DIR_SOURCE, &cap_source);
} }
for (size_t i = 0; i < ARRAY_SIZE(streams); i++) { for (size_t i = 0; i < ARRAY_SIZE(streams); i++) {

View file

@ -11,7 +11,7 @@
#include <zephyr/bluetooth/bluetooth.h> #include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/conn.h> #include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/audio/audio.h> #include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/capabilities.h> #include <zephyr/bluetooth/audio/pacs.h>
#include <zephyr/bluetooth/audio/csis.h> #include <zephyr/bluetooth/audio/csis.h>
#include <zephyr/bluetooth/services/ias.h> #include <zephyr/bluetooth/services/ias.h>
@ -213,22 +213,22 @@ void main(void)
* Front Left and the Front Right bits to a value of 0b1 * Front Left and the Front Right bits to a value of 0b1
* in the Sink Audio Locations characteristic value. * in the Sink Audio Locations characteristic value.
*/ */
bt_audio_capability_set_location(BT_AUDIO_DIR_SINK, bt_pacs_set_location(BT_AUDIO_DIR_SINK,
(BT_AUDIO_LOCATION_FRONT_LEFT | (BT_AUDIO_LOCATION_FRONT_LEFT |
BT_AUDIO_LOCATION_FRONT_RIGHT)); BT_AUDIO_LOCATION_FRONT_RIGHT));
} else { } else {
bt_audio_capability_set_location(BT_AUDIO_DIR_SINK, bt_pacs_set_location(BT_AUDIO_DIR_SINK,
BT_AUDIO_LOCATION_FRONT_LEFT); BT_AUDIO_LOCATION_FRONT_LEFT);
} }
bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SINK, bt_pacs_set_available_contexts(BT_AUDIO_DIR_SINK,
AVAILABLE_SINK_CONTEXT); AVAILABLE_SINK_CONTEXT);
if (IS_ENABLED(CONFIG_BT_ASCS_ASE_SRC)) { if (IS_ENABLED(CONFIG_BT_ASCS_ASE_SRC)) {
bt_audio_capability_set_location(BT_AUDIO_DIR_SOURCE, bt_pacs_set_location(BT_AUDIO_DIR_SOURCE,
BT_AUDIO_LOCATION_FRONT_LEFT); BT_AUDIO_LOCATION_FRONT_LEFT);
bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SOURCE, bt_pacs_set_available_contexts(BT_AUDIO_DIR_SOURCE,
AVAILABLE_SOURCE_CONTEXT); AVAILABLE_SOURCE_CONTEXT);
} }
k_work_init_delayable(&adv_work, adv_work_handler); k_work_init_delayable(&adv_work, adv_work_handler);

View file

@ -13,7 +13,7 @@
#include <zephyr/bluetooth/bluetooth.h> #include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/conn.h> #include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/audio/audio.h> #include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/capabilities.h> #include <zephyr/bluetooth/audio/pacs.h>
#include <zephyr/sys/byteorder.h> #include <zephyr/sys/byteorder.h>
#define AVAILABLE_SINK_CONTEXT (BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED | \ #define AVAILABLE_SINK_CONTEXT (BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED | \
@ -563,11 +563,11 @@ BT_CONN_CB_DEFINE(conn_callbacks) = {
.disconnected = disconnected, .disconnected = disconnected,
}; };
static struct bt_audio_capability caps_sink = { static struct bt_pacs_cap cap_sink = {
.codec = &lc3_codec, .codec = &lc3_codec,
}; };
static struct bt_audio_capability caps_source = { static struct bt_pacs_cap cap_source = {
.codec = &lc3_codec, .codec = &lc3_codec,
}; };
@ -576,8 +576,8 @@ static int set_location(void)
int err; int err;
if (IS_ENABLED(CONFIG_BT_PAC_SNK_LOC)) { if (IS_ENABLED(CONFIG_BT_PAC_SNK_LOC)) {
err = bt_audio_capability_set_location(BT_AUDIO_DIR_SINK, err = bt_pacs_set_location(BT_AUDIO_DIR_SINK,
BT_AUDIO_LOCATION_FRONT_CENTER); BT_AUDIO_LOCATION_FRONT_CENTER);
if (err != 0) { if (err != 0) {
printk("Failed to set sink location (err %d)\n", err); printk("Failed to set sink location (err %d)\n", err);
return err; return err;
@ -585,9 +585,9 @@ static int set_location(void)
} }
if (IS_ENABLED(CONFIG_BT_PAC_SRC_LOC)) { if (IS_ENABLED(CONFIG_BT_PAC_SRC_LOC)) {
err = bt_audio_capability_set_location(BT_AUDIO_DIR_SOURCE, err = bt_pacs_set_location(BT_AUDIO_DIR_SOURCE,
(BT_AUDIO_LOCATION_FRONT_LEFT | (BT_AUDIO_LOCATION_FRONT_LEFT |
BT_AUDIO_LOCATION_FRONT_RIGHT)); BT_AUDIO_LOCATION_FRONT_RIGHT));
if (err != 0) { if (err != 0) {
printk("Failed to set source location (err %d)\n", err); printk("Failed to set source location (err %d)\n", err);
return err; return err;
@ -604,8 +604,8 @@ static int set_available_contexts(void)
int err; int err;
if (IS_ENABLED(CONFIG_BT_PAC_SNK)) { if (IS_ENABLED(CONFIG_BT_PAC_SNK)) {
err = bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SINK, err = bt_pacs_set_available_contexts(BT_AUDIO_DIR_SINK,
AVAILABLE_SINK_CONTEXT); AVAILABLE_SINK_CONTEXT);
if (err != 0) { if (err != 0) {
printk("Failed to set sink available contexts (err %d)\n", err); printk("Failed to set sink available contexts (err %d)\n", err);
return err; return err;
@ -613,8 +613,8 @@ static int set_available_contexts(void)
} }
if (IS_ENABLED(CONFIG_BT_PAC_SRC)) { if (IS_ENABLED(CONFIG_BT_PAC_SRC)) {
err = bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SOURCE, err = bt_pacs_set_available_contexts(BT_AUDIO_DIR_SOURCE,
AVAILABLE_SOURCE_CONTEXT); AVAILABLE_SOURCE_CONTEXT);
if (err != 0) { if (err != 0) {
printk("Failed to set source available contexts (err %d)\n", err); printk("Failed to set source available contexts (err %d)\n", err);
return err; return err;
@ -640,8 +640,8 @@ void main(void)
bt_audio_unicast_server_register_cb(&unicast_server_cb); bt_audio_unicast_server_register_cb(&unicast_server_cb);
bt_audio_capability_register(BT_AUDIO_DIR_SINK, &caps_sink); bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink);
bt_audio_capability_register(BT_AUDIO_DIR_SOURCE, &caps_source); bt_pacs_cap_register(BT_AUDIO_DIR_SOURCE, &cap_source);
for (size_t i = 0; i < ARRAY_SIZE(streams); i++) { for (size_t i = 0; i < ARRAY_SIZE(streams); i++) {
bt_audio_stream_cb_register(&streams[i], &stream_ops); bt_audio_stream_cb_register(&streams[i], &stream_ops);

View file

@ -20,7 +20,7 @@
#include <zephyr/bluetooth/gatt.h> #include <zephyr/bluetooth/gatt.h>
#include "zephyr/bluetooth/iso.h" #include "zephyr/bluetooth/iso.h"
#include <zephyr/bluetooth/audio/audio.h> #include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/capabilities.h> #include <zephyr/bluetooth/audio/pacs.h>
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_ASCS) #define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_ASCS)
#define LOG_MODULE_NAME bt_ascs #define LOG_MODULE_NAME bt_ascs
@ -1187,12 +1187,12 @@ struct codec_lookup_id_data {
struct bt_codec *codec; struct bt_codec *codec;
}; };
static bool codec_lookup_id(const struct bt_audio_capability *capability, void *user_data) static bool codec_lookup_id(const struct bt_pacs_cap *cap, void *user_data)
{ {
struct codec_lookup_id_data *data = user_data; struct codec_lookup_id_data *data = user_data;
if (capability->codec->id == data->id) { if (cap->codec->id == data->id) {
data->codec = capability->codec; data->codec = cap->codec;
return false; return false;
} }
@ -1216,7 +1216,7 @@ static int ascs_ep_set_codec(struct bt_audio_ep *ep, uint8_t id, uint16_t cid,
BT_DBG("ep %p dir %u codec id 0x%02x cid 0x%04x vid 0x%04x len %u", BT_DBG("ep %p dir %u codec id 0x%02x cid 0x%04x vid 0x%04x len %u",
ep, ep->dir, id, cid, vid, len); ep, ep->dir, id, cid, vid, len);
bt_audio_foreach_capability(ep->dir, codec_lookup_id, &lookup_data); bt_pacs_cap_foreach(ep->dir, codec_lookup_id, &lookup_data);
if (lookup_data.codec == NULL) { if (lookup_data.codec == NULL) {
return -ENOENT; return -ENOENT;

View file

@ -12,7 +12,7 @@
#include <zephyr/bluetooth/bluetooth.h> #include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/gatt.h> #include <zephyr/bluetooth/gatt.h>
#include <zephyr/bluetooth/audio/audio.h> #include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/capabilities.h> #include <zephyr/bluetooth/audio/pacs.h>
#include <zephyr/bluetooth/audio/has.h> #include <zephyr/bluetooth/audio/has.h>
#include <zephyr/sys/check.h> #include <zephyr/sys/check.h>
@ -1151,15 +1151,15 @@ static int has_init(const struct device *dev)
* Front Left and the Front Right bits to a value of 0b1 * Front Left and the Front Right bits to a value of 0b1
* in the Sink Audio Locations characteristic value. * in the Sink Audio Locations characteristic value.
*/ */
bt_audio_capability_set_location(BT_AUDIO_DIR_SINK, bt_pacs_set_location(BT_AUDIO_DIR_SINK,
(BT_AUDIO_LOCATION_FRONT_LEFT | (BT_AUDIO_LOCATION_FRONT_LEFT |
BT_AUDIO_LOCATION_FRONT_RIGHT)); BT_AUDIO_LOCATION_FRONT_RIGHT));
} else if (IS_ENABLED(CONFIG_BT_HAS_HEARING_AID_LEFT)) { } else if (IS_ENABLED(CONFIG_BT_HAS_HEARING_AID_LEFT)) {
bt_audio_capability_set_location(BT_AUDIO_DIR_SINK, bt_pacs_set_location(BT_AUDIO_DIR_SINK,
BT_AUDIO_LOCATION_FRONT_LEFT); BT_AUDIO_LOCATION_FRONT_LEFT);
} else { } else {
bt_audio_capability_set_location(BT_AUDIO_DIR_SINK, bt_pacs_set_location(BT_AUDIO_DIR_SINK,
BT_AUDIO_LOCATION_FRONT_RIGHT); BT_AUDIO_LOCATION_FRONT_RIGHT);
} }
} }

View file

@ -20,7 +20,7 @@
#include <zephyr/bluetooth/conn.h> #include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/gatt.h> #include <zephyr/bluetooth/gatt.h>
#include <zephyr/bluetooth/audio/audio.h> #include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/capabilities.h> #include <zephyr/bluetooth/audio/pacs.h>
#include "../host/conn_internal.h" #include "../host/conn_internal.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_PACS) #define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_PACS)
@ -101,10 +101,10 @@ struct pac_records_build_data {
struct net_buf_simple *buf; struct net_buf_simple *buf;
}; };
static bool build_pac_records(const struct bt_audio_capability *capability, void *user_data) static bool build_pac_records(const struct bt_pacs_cap *cap, void *user_data)
{ {
struct pac_records_build_data *data = user_data; struct pac_records_build_data *data = user_data;
struct bt_codec *codec = capability->codec; struct bt_codec *codec = cap->codec;
struct net_buf_simple *buf = data->buf; struct net_buf_simple *buf = data->buf;
struct net_buf_simple_state state; struct net_buf_simple_state state;
struct bt_pac_ltv_data *cc, *meta; struct bt_pac_ltv_data *cc, *meta;
@ -153,17 +153,17 @@ static bool build_pac_records(const struct bt_audio_capability *capability, void
return true; return true;
fail: fail:
__ASSERT(true, "No space for %p", capability); __ASSERT(true, "No space for %p", cap);
net_buf_simple_restore(buf, &state); net_buf_simple_restore(buf, &state);
return false; return false;
} }
static void foreach_capability(sys_slist_t *list, bt_audio_foreach_capability_func_t func, static void foreach_cap(sys_slist_t *list, bt_pacs_cap_foreach_func_t func,
void *user_data) void *user_data)
{ {
struct bt_audio_capability *cap; struct bt_pacs_cap *cap;
SYS_SLIST_FOR_EACH_CONTAINER(list, cap, _node) { SYS_SLIST_FOR_EACH_CONTAINER(list, cap, _node) {
if (!func(cap, user_data)) { if (!func(cap, user_data)) {
@ -184,7 +184,7 @@ static void get_pac_records(struct bt_conn *conn, sys_slist_t *list,
data.rsp->num_pac = 0; data.rsp->num_pac = 0;
data.buf = buf; data.buf = buf;
foreach_capability(list, build_pac_records, &data); foreach_cap(list, build_pac_records, &data);
} }
static void available_context_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) static void available_context_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value)
@ -192,7 +192,6 @@ static void available_context_cfg_changed(const struct bt_gatt_attr *attr, uint1
BT_DBG("attr %p value 0x%04x", attr, value); BT_DBG("attr %p value 0x%04x", attr, value);
} }
static ssize_t available_contexts_read(struct bt_conn *conn, static ssize_t available_contexts_read(struct bt_conn *conn,
const struct bt_gatt_attr *attr, void *buf, const struct bt_gatt_attr *attr, void *buf,
uint16_t len, uint16_t offset) uint16_t len, uint16_t offset)
@ -558,10 +557,10 @@ static void pac_notify_src_loc(struct k_work *work)
#if defined(CONFIG_BT_PAC_SNK) #if defined(CONFIG_BT_PAC_SNK)
static void pac_notify_snk(struct k_work *work) static void pac_notify_snk(struct k_work *work)
{ {
struct pacs *caps = CONTAINER_OF(work, struct pacs, work); struct pacs *pac = CONTAINER_OF(work, struct pacs, work);
int err; int err;
get_pac_records(NULL, &caps->list, &read_buf); get_pac_records(NULL, &pac->list, &read_buf);
err = bt_gatt_notify_uuid(NULL, BT_UUID_PACS_SNK, pacs_svc.attrs, err = bt_gatt_notify_uuid(NULL, BT_UUID_PACS_SNK, pacs_svc.attrs,
read_buf.data, read_buf.len); read_buf.data, read_buf.len);
@ -574,10 +573,10 @@ static void pac_notify_snk(struct k_work *work)
#if defined(CONFIG_BT_PAC_SRC) #if defined(CONFIG_BT_PAC_SRC)
static void pac_notify_src(struct k_work *work) static void pac_notify_src(struct k_work *work)
{ {
struct pacs *caps = CONTAINER_OF(work, struct pacs, work); struct pacs *pac = CONTAINER_OF(work, struct pacs, work);
int err = 0; int err = 0;
get_pac_records(NULL, &caps->list, &read_buf); get_pac_records(NULL, &pac->list, &read_buf);
err = bt_gatt_notify_uuid(NULL, BT_UUID_PACS_SRC, pacs_svc.attrs, err = bt_gatt_notify_uuid(NULL, BT_UUID_PACS_SRC, pacs_svc.attrs,
read_buf.data, read_buf.len); read_buf.data, read_buf.len);
@ -636,35 +635,34 @@ static struct pacs *pacs_get(enum bt_audio_dir dir)
} }
} }
void bt_audio_foreach_capability(enum bt_audio_dir dir, bt_audio_foreach_capability_func_t func, void bt_pacs_cap_foreach(enum bt_audio_dir dir, bt_pacs_cap_foreach_func_t func, void *user_data)
void *user_data)
{ {
struct pacs *caps; struct pacs *pac;
CHECKIF(func == NULL) { CHECKIF(func == NULL) {
BT_ERR("func is NULL"); BT_ERR("func is NULL");
return; return;
} }
caps = pacs_get(dir); pac = pacs_get(dir);
if (!caps) { if (!pac) {
return; return;
} }
foreach_capability(&caps->list, func, user_data); foreach_cap(&pac->list, func, user_data);
} }
/* Register Audio Capability */ /* Register Audio Capability */
int bt_audio_capability_register(enum bt_audio_dir dir, struct bt_audio_capability *cap) int bt_pacs_cap_register(enum bt_audio_dir dir, struct bt_pacs_cap *cap)
{ {
struct pacs *caps; struct pacs *pac;
if (!cap || !cap->codec) { if (!cap || !cap->codec) {
return -EINVAL; return -EINVAL;
} }
caps = pacs_get(dir); pac = pacs_get(dir);
if (!caps) { if (!pac) {
return -EINVAL; return -EINVAL;
} }
@ -672,39 +670,39 @@ int bt_audio_capability_register(enum bt_audio_dir dir, struct bt_audio_capabili
"codec vid 0x%04x", cap, dir, cap->codec->id, "codec vid 0x%04x", cap, dir, cap->codec->id,
cap->codec->cid, cap->codec->vid); cap->codec->cid, cap->codec->vid);
sys_slist_append(&caps->list, &cap->_node); sys_slist_append(&pac->list, &cap->_node);
pacs_changed(caps); pacs_changed(pac);
return 0; return 0;
} }
/* Unregister Audio Capability */ /* Unregister Audio Capability */
int bt_audio_capability_unregister(enum bt_audio_dir dir, struct bt_audio_capability *cap) int bt_pacs_cap_unregister(enum bt_audio_dir dir, struct bt_pacs_cap *cap)
{ {
struct pacs *caps; struct pacs *pac;
if (!cap) { if (!cap) {
return -EINVAL; return -EINVAL;
} }
caps = pacs_get(dir); pac = pacs_get(dir);
if (!caps) { if (!pac) {
return -EINVAL; return -EINVAL;
} }
BT_DBG("cap %p dir 0x%02x", cap, dir); BT_DBG("cap %p dir 0x%02x", cap, dir);
if (!sys_slist_find_and_remove(&caps->list, &cap->_node)) { if (!sys_slist_find_and_remove(&pac->list, &cap->_node)) {
return -ENOENT; return -ENOENT;
} }
pacs_changed(caps); pacs_changed(pac);
return 0; return 0;
} }
int bt_audio_capability_set_location(enum bt_audio_dir dir, enum bt_audio_location location) int bt_pacs_set_location(enum bt_audio_dir dir, enum bt_audio_location location)
{ {
switch (dir) { switch (dir) {
case BT_AUDIO_DIR_SINK: case BT_AUDIO_DIR_SINK:
@ -716,8 +714,7 @@ int bt_audio_capability_set_location(enum bt_audio_dir dir, enum bt_audio_locati
return -EINVAL; return -EINVAL;
} }
int bt_audio_capability_set_available_contexts(enum bt_audio_dir dir, int bt_pacs_set_available_contexts(enum bt_audio_dir dir, enum bt_audio_context contexts)
enum bt_audio_context contexts)
{ {
switch (dir) { switch (dir) {
case BT_AUDIO_DIR_SINK: case BT_AUDIO_DIR_SINK:
@ -729,7 +726,7 @@ int bt_audio_capability_set_available_contexts(enum bt_audio_dir dir,
return -EINVAL; return -EINVAL;
} }
enum bt_audio_context bt_audio_capability_get_available_contexts(enum bt_audio_dir dir) enum bt_audio_context bt_pacs_get_available_contexts(enum bt_audio_dir dir)
{ {
switch (dir) { switch (dir) {
case BT_AUDIO_DIR_SINK: case BT_AUDIO_DIR_SINK:

View file

@ -21,7 +21,7 @@
#include <zephyr/bluetooth/gatt.h> #include <zephyr/bluetooth/gatt.h>
#include <zephyr/bluetooth/audio/audio.h> #include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/capabilities.h> #include <zephyr/bluetooth/audio/pacs.h>
#include "bt.h" #include "bt.h"
@ -684,11 +684,11 @@ static const struct bt_audio_unicast_server_cb unicast_server_cb = {
.release = lc3_release, .release = lc3_release,
}; };
static struct bt_audio_capability caps_sink = { static struct bt_pacs_cap cap_sink = {
.codec = &lc3_codec, .codec = &lc3_codec,
}; };
static struct bt_audio_capability caps_source = { static struct bt_pacs_cap cap_source = {
.codec = &lc3_codec, .codec = &lc3_codec,
}; };
@ -1697,7 +1697,7 @@ static int cmd_set_loc(const struct shell *sh, size_t argc, char *argv[])
} }
loc = shell_strtoul(argv[2], 16, &err); loc = shell_strtoul(argv[2], 16, &err);
err = bt_audio_capability_set_location(dir, loc); err = bt_pacs_set_location(dir, loc);
if (err) { if (err) {
shell_error(ctx_shell, "Set available contexts err %d", err); shell_error(ctx_shell, "Set available contexts err %d", err);
return -ENOEXEC; return -ENOEXEC;
@ -1727,7 +1727,7 @@ static int cmd_context(const struct shell *sh, size_t argc, char *argv[])
return err; return err;
} }
err = bt_audio_capability_set_available_contexts(dir, ctx); err = bt_pacs_set_available_contexts(dir, ctx);
if (err) { if (err) {
shell_error(ctx_shell, "Set available contexts err %d", err); shell_error(ctx_shell, "Set available contexts err %d", err);
return err; return err;
@ -1753,26 +1753,28 @@ static int cmd_init(const struct shell *sh, size_t argc, char *argv[])
if (IS_ENABLED(CONFIG_BT_AUDIO_UNICAST_SERVER) || if (IS_ENABLED(CONFIG_BT_AUDIO_UNICAST_SERVER) ||
IS_ENABLED(CONFIG_BT_AUDIO_BROADCAST_SINK)) { IS_ENABLED(CONFIG_BT_AUDIO_BROADCAST_SINK)) {
bt_audio_capability_register(BT_AUDIO_DIR_SINK, &caps_sink); bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink);
} }
if (IS_ENABLED(CONFIG_BT_AUDIO_UNICAST_SERVER)) { if (IS_ENABLED(CONFIG_BT_AUDIO_UNICAST_SERVER)) {
bt_audio_capability_register(BT_AUDIO_DIR_SOURCE, &caps_source); bt_pacs_cap_register(BT_AUDIO_DIR_SOURCE, &cap_source);
} }
if (IS_ENABLED(CONFIG_BT_PAC_SNK_LOC)) { if (IS_ENABLED(CONFIG_BT_PAC_SNK_LOC)) {
err = bt_audio_capability_set_location(BT_AUDIO_DIR_SINK, LOCATION); err = bt_pacs_set_location(BT_AUDIO_DIR_SINK, LOCATION);
__ASSERT(err == 0, "Failed to set sink location"); __ASSERT(err == 0, "Failed to set sink location");
err = bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SINK, CONTEXT); err = bt_pacs_set_available_contexts(BT_AUDIO_DIR_SINK,
CONTEXT);
__ASSERT(err == 0, "Failed to set sink available contexts"); __ASSERT(err == 0, "Failed to set sink available contexts");
} }
if (IS_ENABLED(CONFIG_BT_PAC_SRC_LOC)) { if (IS_ENABLED(CONFIG_BT_PAC_SRC_LOC)) {
err = bt_audio_capability_set_location(BT_AUDIO_DIR_SOURCE, LOCATION); err = bt_pacs_set_location(BT_AUDIO_DIR_SOURCE, LOCATION);
__ASSERT(err == 0, "Failed to set source location"); __ASSERT(err == 0, "Failed to set source location");
err = bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SOURCE, CONTEXT); err = bt_pacs_set_available_contexts(BT_AUDIO_DIR_SOURCE,
CONTEXT);
__ASSERT(err == 0, "Failed to set source available contexts"); __ASSERT(err == 0, "Failed to set source available contexts");
} }
@ -1971,10 +1973,10 @@ ssize_t audio_ad_data_add(struct bt_data *data_array, const size_t data_array_si
}; };
enum bt_audio_context snk_context, src_context; enum bt_audio_context snk_context, src_context;
snk_context = bt_audio_capability_get_available_contexts(BT_AUDIO_DIR_SINK); snk_context = bt_pacs_get_available_contexts(BT_AUDIO_DIR_SINK);
sys_put_le16(snk_context, &ad_bap_announcement[3]); sys_put_le16(snk_context, &ad_bap_announcement[3]);
src_context = bt_audio_capability_get_available_contexts(BT_AUDIO_DIR_SOURCE); src_context = bt_pacs_get_available_contexts(BT_AUDIO_DIR_SOURCE);
sys_put_le16(snk_context, &ad_bap_announcement[5]); sys_put_le16(snk_context, &ad_bap_announcement[5]);
/* Metadata length */ /* Metadata length */

View file

@ -32,7 +32,7 @@
#include <zephyr/bluetooth/sdp.h> #include <zephyr/bluetooth/sdp.h>
#include <zephyr/bluetooth/iso.h> #include <zephyr/bluetooth/iso.h>
#include <zephyr/bluetooth/audio/audio.h> #include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/capabilities.h> #include <zephyr/bluetooth/audio/pacs.h>
#include <zephyr/bluetooth/audio/csis.h> #include <zephyr/bluetooth/audio/csis.h>
#include <zephyr/shell/shell.h> #include <zephyr/shell/shell.h>

View file

@ -8,7 +8,7 @@
#include <zephyr/bluetooth/bluetooth.h> #include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/audio/audio.h> #include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/capabilities.h> #include <zephyr/bluetooth/audio/pacs.h>
#include "common.h" #include "common.h"
extern enum bst_result_t bst_result; extern enum bst_result_t bst_result;
@ -130,7 +130,7 @@ static struct bt_audio_broadcast_sink_cb broadcast_sink_cbs = {
.pa_sync_lost = pa_sync_lost_cb .pa_sync_lost = pa_sync_lost_cb
}; };
static struct bt_audio_capability capabilities = { static struct bt_pacs_cap cap = {
.codec = &preset_16_2_1.codec, .codec = &preset_16_2_1.codec,
}; };
@ -171,7 +171,7 @@ static int init(void)
printk("Bluetooth initialized\n"); printk("Bluetooth initialized\n");
err = bt_audio_capability_register(BT_AUDIO_DIR_SINK, &capabilities); err = bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap);
if (err) { if (err) {
FAIL("Capability register failed (err %d)\n", err); FAIL("Capability register failed (err %d)\n", err);
return err; return err;

View file

@ -8,7 +8,7 @@
#include <zephyr/bluetooth/bluetooth.h> #include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/audio/audio.h> #include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/capabilities.h> #include <zephyr/bluetooth/audio/pacs.h>
#include "common.h" #include "common.h"
#include "unicast_common.h" #include "unicast_common.h"

View file

@ -8,7 +8,7 @@
#include <zephyr/bluetooth/bluetooth.h> #include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/audio/audio.h> #include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/capabilities.h> #include <zephyr/bluetooth/audio/pacs.h>
#include "common.h" #include "common.h"
#include "unicast_common.h" #include "unicast_common.h"
@ -232,7 +232,7 @@ BT_CONN_CB_DEFINE(conn_callbacks) = {
static void init(void) static void init(void)
{ {
static struct bt_audio_capability caps = { static struct bt_pacs_cap cap = {
.codec = &lc3_codec, .codec = &lc3_codec,
}; };
int err; int err;
@ -247,7 +247,7 @@ static void init(void)
bt_audio_unicast_server_register_cb(&unicast_server_cb); bt_audio_unicast_server_register_cb(&unicast_server_cb);
err = bt_audio_capability_register(BT_AUDIO_DIR_SINK, &caps); err = bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap);
if (err != 0) { if (err != 0) {
FAIL("Failed to register capabilities: %d", err); FAIL("Failed to register capabilities: %d", err);
return; return;
@ -271,8 +271,8 @@ static void set_location(void)
int err; int err;
if (IS_ENABLED(CONFIG_BT_PAC_SNK_LOC)) { if (IS_ENABLED(CONFIG_BT_PAC_SNK_LOC)) {
err = bt_audio_capability_set_location(BT_AUDIO_DIR_SINK, err = bt_pacs_set_location(BT_AUDIO_DIR_SINK,
BT_AUDIO_LOCATION_FRONT_CENTER); BT_AUDIO_LOCATION_FRONT_CENTER);
if (err != 0) { if (err != 0) {
FAIL("Failed to set sink location (err %d)\n", err); FAIL("Failed to set sink location (err %d)\n", err);
return; return;
@ -280,9 +280,9 @@ static void set_location(void)
} }
if (IS_ENABLED(CONFIG_BT_PAC_SRC_LOC)) { if (IS_ENABLED(CONFIG_BT_PAC_SRC_LOC)) {
err = bt_audio_capability_set_location(BT_AUDIO_DIR_SOURCE, err = bt_pacs_set_location(BT_AUDIO_DIR_SOURCE,
(BT_AUDIO_LOCATION_FRONT_LEFT | (BT_AUDIO_LOCATION_FRONT_LEFT |
BT_AUDIO_LOCATION_FRONT_RIGHT)); BT_AUDIO_LOCATION_FRONT_RIGHT));
if (err != 0) { if (err != 0) {
FAIL("Failed to set source location (err %d)\n", err); FAIL("Failed to set source location (err %d)\n", err);
return; return;
@ -296,16 +296,16 @@ static void set_available_contexts(void)
{ {
int err; int err;
err = bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SINK, err = bt_pacs_set_available_contexts(BT_AUDIO_DIR_SINK,
BT_AUDIO_CONTEXT_TYPE_MEDIA | BT_AUDIO_CONTEXT_TYPE_MEDIA |
BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL); BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL);
if (IS_ENABLED(CONFIG_BT_PAC_SNK) && err != 0) { if (IS_ENABLED(CONFIG_BT_PAC_SNK) && err != 0) {
FAIL("Failed to set sink available contexts (err %d)\n", err); FAIL("Failed to set sink available contexts (err %d)\n", err);
return; return;
} }
err = bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SOURCE, err = bt_pacs_set_available_contexts(BT_AUDIO_DIR_SOURCE,
BT_AUDIO_CONTEXT_TYPE_NOTIFICATIONS); BT_AUDIO_CONTEXT_TYPE_NOTIFICATIONS);
if (IS_ENABLED(CONFIG_BT_PAC_SRC) && err != 0) { if (IS_ENABLED(CONFIG_BT_PAC_SRC) && err != 0) {
FAIL("Failed to set source available contexts (err %d)\n", err); FAIL("Failed to set source available contexts (err %d)\n", err);
return; return;