Skip to content

Commit 674f634

Browse files
Thalleykoffes
authored andcommitted
[nrf noup] Bluetooth: BAP: Add target latency and phy to codec_cfg
The codec configuration operation for unicast (ASCS) contain both a target PHY and a target latency value that was previously just hardcoded by the client and unavailable by the server. This commit adds them to the bt_audio_codec_cfg struct so that applications can both set and get these values. The default values used by BT_AUDIO_CODEC_CFG use the same values as the client would previously set. Signed-off-by: Emil Gydesen <[email protected]> (cherry picked from commit 8788f8b)
1 parent 37151d3 commit 674f634

File tree

4 files changed

+202
-8
lines changed

4 files changed

+202
-8
lines changed

doc/releases/release-notes-4.3.rst

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
:orphan:
2+
3+
..
4+
What goes here: removed/deprecated apis, new boards, new drivers, notable
5+
features. If you feel like something new can be useful to a user, put it
6+
under "Other Enhancements" in the first paragraph, if you feel like something
7+
is worth mentioning in the project media (release blog post, release
8+
livestream) put it under "Major enhancement".
9+
..
10+
If you are describing a feature or functionality, consider adding it to the
11+
actual project documentation rather than the release notes, so that the
12+
information does not get lost in time.
13+
..
14+
No list of bugfixes, minor changes, those are already in the git log, this is
15+
not a changelog.
16+
..
17+
Does the entry have a link that contains the details? Just add the link, if
18+
you think it needs more details, put them in the content that shows up on the
19+
link.
20+
..
21+
Are you thinking about generating this? Don't put anything at all.
22+
..
23+
Does the thing require the user to change their application? Put it on the
24+
migration guide instead. (TODO: move the removed APIs section in the
25+
migration guide)
26+
27+
.. _zephyr_4.3:
28+
29+
Zephyr 4.3.0 (Working Draft)
30+
############################
31+
32+
We are pleased to announce the release of Zephyr version 4.3.0.
33+
34+
Major enhancements with this release include:
35+
36+
An overview of the changes required or recommended when migrating your application from Zephyr
37+
v4.2.0 to Zephyr v4.3.0 can be found in the separate :ref:`migration guide<migration_4.3>`.
38+
39+
The following sections provide detailed lists of changes by component.
40+
41+
Security Vulnerability Related
42+
******************************
43+
The following CVEs are addressed by this release:
44+
45+
More detailed information can be found in:
46+
https://docs.zephyrproject.org/latest/security/vulnerabilities.html
47+
48+
API Changes
49+
***********
50+
51+
* RTIO
52+
53+
* :c:func:`rtio_is_spi`
54+
* :c:func:`rtio_is_cspi`
55+
* :c:func:`rtio_is_i3c`
56+
* :c:func:`rtio_read_regs_async`
57+
58+
Removed APIs and options
59+
========================
60+
61+
* The TinyCrypt library was removed as the upstream version is no longer maintained.
62+
PSA Crypto API is now the recommended cryptographic library for Zephyr.
63+
64+
Deprecated APIs and options
65+
===========================
66+
67+
New APIs and options
68+
====================
69+
70+
..
71+
Link to new APIs here, in a group if you think it's necessary, no need to get
72+
fancy just list the link, that should contain the documentation. If you feel
73+
like you need to add more details, add them in the API documentation code
74+
instead.
75+
76+
.. zephyr-keep-sorted-start re(^\* \w)
77+
78+
* Architectures
79+
80+
* :kconfig:option:`CONFIG_SRAM_SW_ISR_TABLE`
81+
82+
* Bluetooth
83+
84+
* Audio
85+
86+
* :c:struct:`bt_audio_codec_cfg` now contains a target_latency and a target_phy option
87+
88+
* Power management
89+
90+
* :c:func:`pm_device_driver_deinit`
91+
92+
* Settings
93+
94+
* :kconfig:option:`CONFIG_SETTINGS_TFM_ITS`
95+
96+
.. zephyr-keep-sorted-stop
97+
98+
New Boards
99+
**********
100+
101+
..
102+
You may update this list as you contribute a new board during the release cycle, in order to make
103+
it visible to people who might be looking at the working draft of the release notes. However, note
104+
that this list will be recomputed at the time of the release, so you don't *have* to update it.
105+
In any case, just link the board, further details go in the board description.
106+
107+
New Drivers
108+
***********
109+
110+
..
111+
Same as above for boards, this will also be recomputed at the time of the release.
112+
Just link the driver, further details go in the binding description
113+
114+
* Input
115+
116+
* :dtcompatible:`chipsemi,chsc5x`
117+
118+
* Interrupt controller
119+
120+
* STM32 EXTI interrupt/event controller (:dtcompatible:`st,stm32-exti`) has a dedicated driver and API now, separate from STM32 GPIO Interrupt Control driver.
121+
122+
* RTC
123+
124+
* STM32 RTC driver has been updated to use the new STM32 EXTI interrupt controller API
125+
126+
127+
New Samples
128+
***********
129+
130+
..
131+
Same as above for boards and drivers, this will also be recomputed at the time of the release.
132+
Just link the sample, further details go in the sample documentation itself.
133+
134+
Other notable changes
135+
*********************
136+
137+
..
138+
Any more descriptive subsystem or driver changes. Do you really want to write
139+
a paragraph or is it enough to link to the api/driver/Kconfig/board page above?
140+
141+
* Removed support for Nordic Semiconductor nRF54L20 PDK (``nrf54l20pdk``) since it is
142+
replaced with :zephyr:board:`nrf54lm20dk` (``nrf54lm20dk``).

include/zephyr/bluetooth/audio/audio.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,10 @@ enum bt_audio_metadata_type {
550550
/* Use HCI data path as default, can be overwritten by application */ \
551551
.path_id = BT_ISO_DATA_PATH_HCI, \
552552
.ctlr_transcode = false, \
553+
COND_CODE_1(IS_ENABLED(CONFIG_BT_BAP_UNICAST), \
554+
(.target_latency = BT_AUDIO_CODEC_CFG_TARGET_LATENCY_BALANCED, \
555+
.target_phy = BT_AUDIO_CODEC_CFG_TARGET_PHY_2M,), \
556+
()) \
553557
.id = _id, \
554558
.cid = _cid, \
555559
.vid = _vid, \
@@ -714,6 +718,39 @@ struct bt_audio_codec_cap {
714718
#endif /* CONFIG_BT_AUDIO_CODEC_CAP_MAX_METADATA_SIZE */
715719
};
716720

721+
/**
722+
* @brief Codec configuration target latency
723+
*
724+
* Set by the BAP Unicast Client to provide context for the BAP Unicast Server for the server to
725+
* set its QoS preferences.
726+
*/
727+
enum bt_audio_codec_cfg_target_latency {
728+
/** Target low latency */
729+
BT_AUDIO_CODEC_CFG_TARGET_LATENCY_LOW = 0x01,
730+
731+
/** Target balanced latency */
732+
BT_AUDIO_CODEC_CFG_TARGET_LATENCY_BALANCED = 0x02,
733+
734+
/** Target high latency */
735+
BT_AUDIO_CODEC_CFG_TARGET_LATENCY_HIGH = 0x03,
736+
};
737+
738+
/**
739+
* @brief Codec configuration target PHY
740+
*
741+
* The target PHY to achieve the target latency (@ref bt_audio_codec_cfg_target_latency).
742+
*/
743+
enum bt_audio_codec_cfg_target_phy {
744+
/** LE 1M PHY */
745+
BT_AUDIO_CODEC_CFG_TARGET_PHY_1M = 0x01,
746+
747+
/** LE 2M PHY */
748+
BT_AUDIO_CODEC_CFG_TARGET_PHY_2M = 0x02,
749+
750+
/** LE Coded PHY */
751+
BT_AUDIO_CODEC_CFG_TARGET_PHY_CODED = 0x03,
752+
};
753+
717754
/** @brief Codec specific configuration structure. */
718755
struct bt_audio_codec_cfg {
719756
/** Data path ID
@@ -728,6 +765,18 @@ struct bt_audio_codec_cfg {
728765
* BT_HCI_CODING_FORMAT_TRANSPARENT if false, else uses the @ref bt_audio_codec_cfg.id.
729766
*/
730767
bool ctlr_transcode;
768+
#if defined(CONFIG_BT_BAP_UNICAST)
769+
/** Target latency
770+
*
771+
* Unused for broadcast streams.
772+
*/
773+
enum bt_audio_codec_cfg_target_latency target_latency;
774+
/** Target PHY
775+
*
776+
* Unused for broadcast streams.
777+
*/
778+
enum bt_audio_codec_cfg_target_phy target_phy;
779+
#endif /* CONFIG_BT_BAP_UNICAST */
731780
/** Codec ID */
732781
uint8_t id;
733782
/** Codec Company ID */

subsys/bluetooth/audio/ascs.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,8 +1487,9 @@ static void ascs_cp_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value)
14871487
LOG_DBG("attr %p value 0x%04x", attr, value);
14881488
}
14891489

1490-
static int ascs_ep_set_codec(struct bt_bap_ep *ep, uint8_t id, uint16_t cid, uint16_t vid,
1491-
uint8_t *cc, uint8_t len, struct bt_bap_ascs_rsp *rsp)
1490+
static int ascs_ep_set_codec(struct bt_bap_ep *ep, uint8_t target_latency, uint8_t target_phy,
1491+
uint8_t id, uint16_t cid, uint16_t vid, const uint8_t *cc, uint8_t len,
1492+
struct bt_bap_ascs_rsp *rsp)
14921493
{
14931494
const struct bt_audio_codec_cap *codec_cap;
14941495
struct bt_audio_codec_cfg *codec_cfg;
@@ -1520,6 +1521,8 @@ static int ascs_ep_set_codec(struct bt_bap_ep *ep, uint8_t id, uint16_t cid, uin
15201521
return -ENOENT;
15211522
}
15221523

1524+
codec_cfg->target_latency = target_latency;
1525+
codec_cfg->target_phy = target_phy;
15231526
codec_cfg->id = id;
15241527
codec_cfg->cid = cid;
15251528
codec_cfg->vid = vid;
@@ -1588,10 +1591,10 @@ static int ase_config(struct bt_ascs_ase *ase, const struct bt_ascs_config *cfg)
15881591
*/
15891592
(void)memcpy(&codec_cfg, &ase->ep.codec_cfg, sizeof(codec_cfg));
15901593

1591-
err = ascs_ep_set_codec(&ase->ep, cfg->codec.id, sys_le16_to_cpu(cfg->codec.cid),
1592-
sys_le16_to_cpu(cfg->codec.vid), (uint8_t *)cfg->cc, cfg->cc_len,
1593-
&rsp);
1594-
if (err) {
1594+
err = ascs_ep_set_codec(&ase->ep, cfg->latency, cfg->phy, cfg->codec.id,
1595+
sys_le16_to_cpu(cfg->codec.cid), sys_le16_to_cpu(cfg->codec.vid),
1596+
(const uint8_t *)cfg->cc, cfg->cc_len, &rsp);
1597+
if (err != 0) {
15951598
ascs_app_rsp_warn_valid(&rsp);
15961599
(void)memcpy(&ase->ep.codec_cfg, &codec_cfg, sizeof(codec_cfg));
15971600
ascs_cp_rsp_add(ASE_ID(ase), rsp.code, rsp.reason);

subsys/bluetooth/audio/bap_unicast_client.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,8 +1936,8 @@ static int unicast_client_ep_config(struct bt_bap_ep *ep, struct net_buf_simple
19361936

19371937
req = net_buf_simple_add(buf, sizeof(*req));
19381938
req->ase = ep->status.id;
1939-
req->latency = 0x02; /* TODO: Select target latency based on additional input? */
1940-
req->phy = 0x02; /* TODO: Select target PHY based on additional input? */
1939+
req->latency = codec_cfg->target_latency;
1940+
req->phy = codec_cfg->target_phy;
19411941
req->codec.id = codec_cfg->id;
19421942
req->codec.cid = codec_cfg->cid;
19431943
req->codec.vid = codec_cfg->vid;

0 commit comments

Comments
 (0)