1 /** @file
2  *  @brief Bluetooth LC3 codec handling
3  */
4 
5 /*
6  * Copyright (c) 2020 Intel Corporation
7  * Copyright (c) 2022 Nordic Semiconductor ASA
8  *
9  * SPDX-License-Identifier: Apache-2.0
10  */
11 #ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_LC3_H_
12 #define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_LC3_H_
13 
14 /**
15  * @brief LC3
16  * @defgroup BT_AUDIO_CODEC_LC3 AUDIO
17  * @ingroup bluetooth
18  * @{
19  */
20 
21 #include <zephyr/sys/util_macro.h>
22 #include <zephyr/bluetooth/byteorder.h>
23 #include <zephyr/bluetooth/hci_types.h>
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 /**
30  *  @brief LC3 codec ID
31  */
32 #define BT_HCI_CODING_FORMAT_LC3 0x06
33 
34 /**
35  * @brief Codec capability type id's
36  *
37  * Used to build and parse codec capabilities as specified in the PAC specification.
38  * Source is assigned numbers for Generic Audio, bluetooth.com.
39  *
40  * Even though they are in-fixed with LC3 they can be used for other codec types as well.
41  */
42 enum bt_audio_codec_capability_type {
43 
44 	/**
45 	 *  @brief LC3 sample frequency capability type
46 	 */
47 	BT_AUDIO_CODEC_LC3_FREQ = 0x01,
48 
49 	/**
50 	 *  @brief LC3 frame duration capability type
51 	 */
52 	BT_AUDIO_CODEC_LC3_DURATION = 0x02,
53 
54 	/**
55 	 *  @brief LC3 channel count capability type
56 	 */
57 	BT_AUDIO_CODEC_LC3_CHAN_COUNT = 0x03,
58 
59 	/**
60 	 *  @brief LC3 frame length capability type
61 	 */
62 	BT_AUDIO_CODEC_LC3_FRAME_LEN = 0x04,
63 
64 	/**
65 	 *  @brief Max codec frame count per SDU capability type
66 	 */
67 	BT_AUDIO_CODEC_LC3_FRAME_COUNT = 0x05,
68 };
69 
70 /**
71  *  @brief LC3 8 Khz frequency capability
72  */
73 #define BT_AUDIO_CODEC_LC3_FREQ_8KHZ           BIT(0)
74 /**
75  *  @brief LC3 11.025 Khz frequency capability
76  */
77 #define BT_AUDIO_CODEC_LC3_FREQ_11KHZ          BIT(1)
78 /**
79  *  @brief LC3 16 Khz frequency capability
80  */
81 #define BT_AUDIO_CODEC_LC3_FREQ_16KHZ          BIT(2)
82 /**
83  *  @brief LC3 22.05 Khz frequency capability
84  */
85 #define BT_AUDIO_CODEC_LC3_FREQ_22KHZ          BIT(3)
86 /**
87  *  @brief LC3 24 Khz frequency capability
88  */
89 #define BT_AUDIO_CODEC_LC3_FREQ_24KHZ          BIT(4)
90 /**
91  *  @brief LC3 32 Khz frequency capability
92  */
93 #define BT_AUDIO_CODEC_LC3_FREQ_32KHZ          BIT(5)
94 /**
95  *  @brief LC3 44.1 Khz frequency capability
96  */
97 #define BT_AUDIO_CODEC_LC3_FREQ_44KHZ          BIT(6)
98 /**
99  *  @brief LC3 48 Khz frequency capability
100  */
101 #define BT_AUDIO_CODEC_LC3_FREQ_48KHZ          BIT(7)
102 /**
103  *  @brief LC3 any frequency capability
104  */
105 #define BT_AUDIO_CODEC_LC3_FREQ_ANY                                                                \
106 	(BT_AUDIO_CODEC_LC3_FREQ_8KHZ | BT_AUDIO_CODEC_LC3_FREQ_16KHZ |                            \
107 	 BT_AUDIO_CODEC_LC3_FREQ_24KHZ | BT_AUDIO_CODEC_LC3_FREQ_32KHZ |                           \
108 	 BT_AUDIO_CODEC_LC3_FREQ_44KHZ | BT_AUDIO_CODEC_LC3_FREQ_48KHZ)
109 
110 /**
111  *  @brief LC3 7.5 msec frame duration capability
112  */
113 #define BT_AUDIO_CODEC_LC3_DURATION_7_5        BIT(0)
114 /**
115  *  @brief LC3 10 msec frame duration capability
116  */
117 #define BT_AUDIO_CODEC_LC3_DURATION_10         BIT(1)
118 /**
119  *  @brief LC3 any frame duration capability
120  */
121 #define BT_AUDIO_CODEC_LC3_DURATION_ANY                                                            \
122 	(BT_AUDIO_CODEC_LC3_DURATION_7_5 | BT_AUDIO_CODEC_LC3_DURATION_10)
123 /**
124  *  @brief LC3 7.5 msec preferred frame duration capability
125  */
126 #define BT_AUDIO_CODEC_LC3_DURATION_PREFER_7_5 BIT(4)
127 /**
128  *  @brief LC3 10 msec preferred frame duration capability
129  */
130 #define BT_AUDIO_CODEC_LC3_DURATION_PREFER_10  BIT(5)
131 
132 /**
133  *  @brief LC3 minimum supported channel counts
134  */
135 #define BT_AUDIO_CODEC_LC3_CHAN_COUNT_MIN 1
136 /**
137  *  @brief LC3 maximum supported channel counts
138  */
139 #define BT_AUDIO_CODEC_LC3_CHAN_COUNT_MAX 8
140 /**
141  *  @brief LC3 channel count support capability
142  *
143  *  Macro accepts variable number of channel counts.
144  *  The allowed channel counts are defined by specification and have to be in range from
145  *  @ref BT_AUDIO_CODEC_LC3_CHAN_COUNT_MIN to @ref BT_AUDIO_CODEC_LC3_CHAN_COUNT_MAX inclusive.
146  *
147  *  Example to support 1 and 3 channels:
148  *    BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT(1, 3)
149  */
150 #define BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT(...)                                                 \
151 	((uint8_t)((FOR_EACH(BIT, (|), __VA_ARGS__)) >> 1))
152 
153 struct BT_AUDIO_CODEC_LC3_frame_len {
154 	uint16_t min;
155 	uint16_t max;
156 };
157 
158 struct bt_audio_codec_octets_per_codec_frame {
159 	/** Minimum number of octets supported per codec frame */
160 	uint16_t min;
161 	/** Maximum number of octets supported per codec frame */
162 	uint16_t max;
163 };
164 
165 /**
166  * @brief Codec configuration type IDs
167  *
168  * Used to build and parse codec configurations as specified in the ASCS and BAP specifications.
169  * Source is assigned numbers for Generic Audio, bluetooth.com.
170  *
171  * Even though they are in-fixed with LC3 they can be used for other codec types as well.
172  */
173 enum bt_audio_codec_config_type {
174 
175 	/** @brief LC3 Sample Frequency configuration type. */
176 	BT_AUDIO_CODEC_CONFIG_LC3_FREQ = 0x01,
177 
178 	/** @brief LC3 Frame Duration configuration type. */
179 	BT_AUDIO_CODEC_CONFIG_LC3_DURATION = 0x02,
180 
181 	/** @brief LC3 channel Allocation configuration type. */
182 	BT_AUDIO_CODEC_CONFIG_LC3_CHAN_ALLOC = 0x03,
183 
184 	/** @brief LC3 Frame Length configuration type. */
185 	BT_AUDIO_CODEC_CONFIG_LC3_FRAME_LEN = 0x04,
186 
187 	/** @brief Codec frame blocks, per SDU configuration type. */
188 	BT_AUDIO_CODEC_CONFIG_LC3_FRAME_BLKS_PER_SDU = 0x05,
189 };
190 
191 enum bt_audio_codec_config_freq {
192 	/**
193 	 *  @brief 8 Khz codec Sample Frequency configuration
194 	 */
195 	BT_AUDIO_CODEC_CONFIG_LC3_FREQ_8KHZ = 0x01,
196 	/**
197 	 *  @brief 11.025 Khz codec Sample Frequency configuration
198 	 */
199 	BT_AUDIO_CODEC_CONFIG_LC3_FREQ_11KHZ = 0x02,
200 	/**
201 	 *  @brief 16 Khz codec Sample Frequency configuration
202 	 */
203 	BT_AUDIO_CODEC_CONFIG_LC3_FREQ_16KHZ = 0x03,
204 	/**
205 	 *  @brief 22.05 Khz codec Sample Frequency configuration
206 	 */
207 	BT_AUDIO_CODEC_CONFIG_LC3_FREQ_22KHZ = 0x04,
208 	/**
209 	 *  @brief 24 Khz codec Sample Frequency configuration
210 	 */
211 	BT_AUDIO_CODEC_CONFIG_LC3_FREQ_24KHZ = 0x05,
212 	/**
213 	 *  @brief 32 Khz codec Sample Frequency configuration
214 	 */
215 	BT_AUDIO_CODEC_CONFIG_LC3_FREQ_32KHZ = 0x06,
216 	/**
217 	 *  @brief 44.1 Khz codec Sample Frequency configuration
218 	 */
219 	BT_AUDIO_CODEC_CONFIG_LC3_FREQ_44KHZ = 0x07,
220 	/**
221 	 *  @brief 48 Khz codec Sample Frequency configuration
222 	 */
223 	BT_AUDIO_CODEC_CONFIG_LC3_FREQ_48KHZ = 0x08,
224 	/**
225 	 *  @brief 88.2 Khz codec Sample Frequency configuration
226 	 */
227 	BT_AUDIO_CODEC_CONFIG_LC3_FREQ_88KHZ = 0x09,
228 	/**
229 	 *  @brief 96 Khz codec Sample Frequency configuration
230 	 */
231 	BT_AUDIO_CODEC_CONFIG_LC3_FREQ_96KHZ = 0x0a,
232 	/**
233 	 *  @brief 176.4 Khz codec Sample Frequency configuration
234 	 */
235 	BT_AUDIO_CODEC_CONFIG_LC3_FREQ_176KHZ = 0x0b,
236 	/**
237 	 *  @brief 192 Khz codec Sample Frequency configuration
238 	 */
239 	BT_AUDIO_CODEC_CONFIG_LC3_FREQ_192KHZ = 0x0c,
240 	/**
241 	 *  @brief 384 Khz codec Sample Frequency configuration
242 	 */
243 	BT_AUDIO_CODEC_CONFIG_LC3_FREQ_384KHZ = 0x0d,
244 };
245 
246 /**
247  *  @brief LC3 7.5 msec Frame Duration configuration
248  */
249 #define BT_AUDIO_CODEC_CONFIG_LC3_DURATION_7_5 0x00
250 /**
251  *  @brief LC3 10 msec Frame Duration configuration
252  */
253 #define BT_AUDIO_CODEC_CONFIG_LC3_DURATION_10  0x01
254 
255 /**
256  *  @brief Helper to declare LC3 codec capability
257  *
258  *  _max_frames_per_sdu value is optional and will be included only if != 1
259  */
260 /* COND_CODE_1 is used to omit an LTV entry in case the _frames_per_sdu is 1.
261  * COND_CODE_1 will evaluate to second argument if the flag parameter(first argument) is 1
262  * - removing one layer of paranteses.
263  * If the flags argument is != 1 it will evaluate to the third argument which inserts a LTV
264  * entry for the max_frames_per_sdu value.
265  */
266 
267 #define BT_AUDIO_CODEC_CAP_LC3_DATA(_freq, _duration, _chan_count, _len_min, _len_max,             \
268 				    _max_frames_per_sdu)                                           \
269 	{                                                                                          \
270 		BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_LC3_FREQ, BT_BYTES_LIST_LE16(_freq)),           \
271 		BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_LC3_DURATION, (_duration)),                     \
272 		BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_LC3_CHAN_COUNT, (_chan_count)),                 \
273 		BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_LC3_FRAME_LEN,                                  \
274 				    BT_BYTES_LIST_LE16(_len_min),                                  \
275 				    BT_BYTES_LIST_LE16(_len_max)),                                 \
276 		COND_CODE_1(_max_frames_per_sdu, (),                                               \
277 			    (BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_LC3_FRAME_COUNT,                   \
278 						 (_max_frames_per_sdu))))                          \
279 	}
280 
281 /**
282  *  @brief Helper to declare LC3 codec metadata
283  */
284 #define BT_AUDIO_CODEC_CAP_LC3_META(_prefer_context)                                               \
285 	{                                                                                          \
286 		BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_PREF_CONTEXT,                           \
287 				    BT_BYTES_LIST_LE16(_prefer_context))                           \
288 	}
289 
290 /**
291  * @brief Helper to declare LC3 codec
292  *
293  * @param _freq Supported Sampling Frequencies bitfield (see BT_AUDIO_CODEC_LC3_FREQ_*)
294  * @param _duration Supported Frame Durations bitfield (see BT_AUDIO_CODEC_LC3_DURATION_*)
295  * @param _chan_count Supported channels (see @ref BT_AUDIO_CODEC_LC3_CHAN_COUNT_SUPPORT)
296  * @param _len_min Minimum number of octets supported per codec frame
297  * @param _len_max Maximum number of octets supported per codec frame
298  * @param _max_frames_per_sdu Supported maximum codec frames per SDU
299  * @param _prefer_context Preferred contexts (@ref bt_audio_context)
300  *
301  */
302 #define BT_AUDIO_CODEC_CAP_LC3(_freq, _duration, _chan_count, _len_min, _len_max,                  \
303 			       _max_frames_per_sdu, _prefer_context)                               \
304 	BT_AUDIO_CODEC_CAP(BT_HCI_CODING_FORMAT_LC3, 0x0000, 0x0000,                               \
305 			   BT_AUDIO_CODEC_CAP_LC3_DATA(_freq, _duration, _chan_count, _len_min,    \
306 						       _len_max, _max_frames_per_sdu),             \
307 			   BT_AUDIO_CODEC_CAP_LC3_META(_prefer_context))
308 
309 /**
310  *  @brief Helper to declare LC3 codec data configuration
311  *
312  *  @param _freq            Sampling frequency (BT_AUDIO_CODEC_CONFIG_LC3_FREQ_*)
313  *  @param _duration        Frame duration (BT_AUDIO_CODEC_CONFIG_LC3_DURATION_*)
314  *  @param _loc             Audio channel location bitfield (@ref bt_audio_location)
315  *  @param _len             Octets per frame (16-bit integer)
316  *  @param _frames_per_sdu  Frames per SDU (8-bit integer). This value is optional and will be
317  *                          included only if != 1
318  */
319 #define BT_AUDIO_CODEC_CFG_LC3_DATA(_freq, _duration, _loc, _len, _frames_per_sdu)                 \
320 	{                                                                                          \
321 		BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CONFIG_LC3_FREQ, (_freq)),                      \
322 		BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CONFIG_LC3_DURATION, (_duration)),              \
323 		BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CONFIG_LC3_CHAN_ALLOC,                          \
324 				    BT_BYTES_LIST_LE32(_loc)),                                     \
325 		BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CONFIG_LC3_FRAME_LEN,                           \
326 				    BT_BYTES_LIST_LE16(_len)),                                     \
327 		COND_CODE_1(_frames_per_sdu, (),                                                   \
328 			    (BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CONFIG_LC3_FRAME_BLKS_PER_SDU,     \
329 						 (_frames_per_sdu))))                              \
330 	}
331 
332 /**
333  *  @brief Helper to declare LC3 codec metadata configuration
334  */
335 #define BT_AUDIO_CODEC_CFG_LC3_META(_stream_context)                                               \
336 	{                                                                                          \
337 		BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT,                         \
338 				    BT_BYTES_LIST_LE16(_stream_context))                           \
339 	}
340 
341 /**
342  *  @brief Helper to declare LC3 codec configuration.
343  *
344  *  @param _freq            Sampling frequency (BT_AUDIO_CODEC_CONFIG_LC3_FREQ_*)
345  *  @param _duration        Frame duration (BT_AUDIO_CODEC_CONFIG_LC3_DURATION_*)
346  *  @param _loc             Audio channel location bitfield (@ref bt_audio_location)
347  *  @param _len             Octets per frame (16-bit integer)
348  *  @param _frames_per_sdu  Frames per SDU (8-bit integer)
349  *  @param _stream_context  Stream context (BT_AUDIO_CONTEXT_*)
350  */
351 #define BT_AUDIO_CODEC_LC3_CONFIG(_freq, _duration, _loc, _len, _frames_per_sdu, _stream_context)  \
352 	BT_AUDIO_CODEC_CFG(                                                                        \
353 		BT_HCI_CODING_FORMAT_LC3, 0x0000, 0x0000,                                          \
354 		BT_AUDIO_CODEC_CFG_LC3_DATA(_freq, _duration, _loc, _len, _frames_per_sdu),        \
355 		BT_AUDIO_CODEC_CFG_LC3_META(_stream_context))
356 
357 /**
358  *  @brief Helper to declare LC3 8.1 codec configuration
359  *
360  *  @param _loc             Audio channel location bitfield (@ref bt_audio_location)
361  *  @param _stream_context  Stream context (BT_AUDIO_CONTEXT_*)
362  */
363 #define BT_AUDIO_CODEC_LC3_CONFIG_8_1(_loc, _stream_context)                                       \
364 	BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_8KHZ,                             \
365 				  BT_AUDIO_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 26u, 1,            \
366 				  _stream_context)
367 /**
368  *  @brief Helper to declare LC3 8.2 codec configuration
369  *
370  *  @param _loc             Audio channel location bitfield (@ref bt_audio_location)
371  *  @param _stream_context  Stream context (BT_AUDIO_CONTEXT_*)
372  */
373 #define BT_AUDIO_CODEC_LC3_CONFIG_8_2(_loc, _stream_context)                                       \
374 	BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_8KHZ,                             \
375 				  BT_AUDIO_CODEC_CONFIG_LC3_DURATION_10, _loc, 30u, 1,             \
376 				  _stream_context)
377 /**
378  *  @brief Helper to declare LC3 16.1 codec configuration
379  *
380  *  @param _loc             Audio channel location bitfield (@ref bt_audio_location)
381  *  @param _stream_context  Stream context (BT_AUDIO_CONTEXT_*)
382  */
383 #define BT_AUDIO_CODEC_LC3_CONFIG_16_1(_loc, _stream_context)                                      \
384 	BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_16KHZ,                            \
385 				  BT_AUDIO_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 30u, 1,            \
386 				  _stream_context)
387 /**
388  *  @brief Helper to declare LC3 16.2 codec configuration
389  *
390  *  @param _loc             Audio channel location bitfield (@ref bt_audio_location)
391  *  @param _stream_context  Stream context (BT_AUDIO_CONTEXT_*)
392  */
393 #define BT_AUDIO_CODEC_LC3_CONFIG_16_2(_loc, _stream_context)                                      \
394 	BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_16KHZ,                            \
395 				  BT_AUDIO_CODEC_CONFIG_LC3_DURATION_10, _loc, 40u, 1,             \
396 				  _stream_context)
397 
398 /**
399  *  @brief Helper to declare LC3 24.1 codec configuration
400  *
401  *  @param _loc             Audio channel location bitfield (@ref bt_audio_location)
402  *  @param _stream_context  Stream context (BT_AUDIO_CONTEXT_*)
403  */
404 #define BT_AUDIO_CODEC_LC3_CONFIG_24_1(_loc, _stream_context)                                      \
405 	BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_24KHZ,                            \
406 				  BT_AUDIO_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 45u, 1,            \
407 				  _stream_context)
408 /**
409  *  @brief Helper to declare LC3 24.2 codec configuration
410  *
411  *  @param _loc             Audio channel location bitfield (@ref bt_audio_location)
412  *  @param _stream_context  Stream context (BT_AUDIO_CONTEXT_*)
413  */
414 #define BT_AUDIO_CODEC_LC3_CONFIG_24_2(_loc, _stream_context)                                      \
415 	BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_24KHZ,                            \
416 				  BT_AUDIO_CODEC_CONFIG_LC3_DURATION_10, _loc, 60u, 1,             \
417 				  _stream_context)
418 /**
419  *  @brief Helper to declare LC3 32.1 codec configuration
420  *
421  *  @param _loc             Audio channel location bitfield (@ref bt_audio_location)
422  *  @param _stream_context  Stream context (BT_AUDIO_CONTEXT_*)
423  */
424 #define BT_AUDIO_CODEC_LC3_CONFIG_32_1(_loc, _stream_context)                                      \
425 	BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_32KHZ,                            \
426 				  BT_AUDIO_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 60u, 1,            \
427 				  _stream_context)
428 /**
429  *  @brief Helper to declare LC3 32.2 codec configuration
430  *
431  *  @param _loc             Audio channel location bitfield (@ref bt_audio_location)
432  *  @param _stream_context  Stream context (BT_AUDIO_CONTEXT_*)
433  */
434 #define BT_AUDIO_CODEC_LC3_CONFIG_32_2(_loc, _stream_context)                                      \
435 	BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_32KHZ,                            \
436 				  BT_AUDIO_CODEC_CONFIG_LC3_DURATION_10, _loc, 80u, 1,             \
437 				  _stream_context)
438 /**
439  *  @brief Helper to declare LC3 441.1 codec configuration
440  *
441  *  @param _loc             Audio channel location bitfield (@ref bt_audio_location)
442  *  @param _stream_context  Stream context (BT_AUDIO_CONTEXT_*)
443  */
444 #define BT_AUDIO_CODEC_LC3_CONFIG_441_1(_loc, _stream_context)                                     \
445 	BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_44KHZ,                            \
446 				  BT_AUDIO_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 98u, 1,            \
447 				  _stream_context)
448 /**
449  *  @brief Helper to declare LC3 441.2 codec configuration
450  *
451  *  @param _loc             Audio channel location bitfield (@ref bt_audio_location)
452  *  @param _stream_context  Stream context (BT_AUDIO_CONTEXT_*)
453  */
454 #define BT_AUDIO_CODEC_LC3_CONFIG_441_2(_loc, _stream_context)                                     \
455 	BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_44KHZ,                            \
456 				  BT_AUDIO_CODEC_CONFIG_LC3_DURATION_10, _loc, 130u, 1,            \
457 				  _stream_context)
458 /**
459  *  @brief Helper to declare LC3 48.1 codec configuration
460  *
461  *  @param _loc             Audio channel location bitfield (@ref bt_audio_location)
462  *  @param _stream_context  Stream context (BT_AUDIO_CONTEXT_*)
463  */
464 #define BT_AUDIO_CODEC_LC3_CONFIG_48_1(_loc, _stream_context)                                      \
465 	BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_48KHZ,                            \
466 				  BT_AUDIO_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 75u, 1,            \
467 				  _stream_context)
468 /**
469  *  @brief Helper to declare LC3 48.2 codec configuration
470  *
471  *  @param _loc             Audio channel location bitfield (@ref bt_audio_location)
472  *  @param _stream_context  Stream context (BT_AUDIO_CONTEXT_*)
473  */
474 #define BT_AUDIO_CODEC_LC3_CONFIG_48_2(_loc, _stream_context)                                      \
475 	BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_48KHZ,                            \
476 				  BT_AUDIO_CODEC_CONFIG_LC3_DURATION_10, _loc, 100u, 1,            \
477 				  _stream_context)
478 /**
479  *  @brief Helper to declare LC3 48.3 codec configuration
480  *
481  *  @param _loc             Audio channel location bitfield (@ref bt_audio_location)
482  *  @param _stream_context  Stream context (BT_AUDIO_CONTEXT_*)
483  */
484 #define BT_AUDIO_CODEC_LC3_CONFIG_48_3(_loc, _stream_context)                                      \
485 	BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_48KHZ,                            \
486 				  BT_AUDIO_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 90u, 1,            \
487 				  _stream_context)
488 /**
489  *  @brief Helper to declare LC3 48.4 codec configuration
490  *
491  *  @param _loc             Audio channel location bitfield (@ref bt_audio_location)
492  *  @param _stream_context  Stream context (BT_AUDIO_CONTEXT_*)
493  */
494 #define BT_AUDIO_CODEC_LC3_CONFIG_48_4(_loc, _stream_context)                                      \
495 	BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_48KHZ,                            \
496 				  BT_AUDIO_CODEC_CONFIG_LC3_DURATION_10, _loc, 120u, 1,            \
497 				  _stream_context)
498 /**
499  *  @brief Helper to declare LC3 48.5 codec configuration
500  *
501  *  @param _loc             Audio channel location bitfield (@ref bt_audio_location)
502  *  @param _stream_context  Stream context (BT_AUDIO_CONTEXT_*)
503  */
504 #define BT_AUDIO_CODEC_LC3_CONFIG_48_5(_loc, _stream_context)                                      \
505 	BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_48KHZ,                            \
506 				  BT_AUDIO_CODEC_CONFIG_LC3_DURATION_7_5, _loc, 117u, 1,           \
507 				  _stream_context)
508 /**
509  *  @brief Helper to declare LC3 48.6 codec configuration
510  *
511  *  @param _loc             Audio channel location bitfield (@ref bt_audio_location)
512  *  @param _stream_context  Stream context (BT_AUDIO_CONTEXT_*)
513  */
514 #define BT_AUDIO_CODEC_LC3_CONFIG_48_6(_loc, _stream_context)                                      \
515 	BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_48KHZ,                            \
516 				  BT_AUDIO_CODEC_CONFIG_LC3_DURATION_10, _loc, 155u, 1,            \
517 				  _stream_context)
518 /**
519  *  @brief Helper to declare LC3 codec QoS for 7.5ms interval
520  */
521 #define BT_AUDIO_CODEC_LC3_QOS_7_5(_framing, _sdu, _rtn, _latency, _pd)                            \
522 	BT_AUDIO_CODEC_QOS(7500u, _framing, BT_AUDIO_CODEC_QOS_2M, _sdu, _rtn, _latency, _pd)
523 /**
524  *  @brief Helper to declare LC3 codec QoS for 7.5ms interval unframed input
525  */
526 #define BT_AUDIO_CODEC_LC3_QOS_7_5_UNFRAMED(_sdu, _rtn, _latency, _pd)                             \
527 	BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, _sdu, _rtn, _latency, _pd)
528 /**
529  *  @brief Helper to declare LC3 codec QoS for 10ms frame internal
530  */
531 #define BT_AUDIO_CODEC_LC3_QOS_10(_framing, _sdu, _rtn, _latency, _pd)                             \
532 	BT_AUDIO_CODEC_QOS(10000u, _framing, BT_AUDIO_CODEC_QOS_2M, _sdu, _rtn, _latency, _pd)
533 /**
534  *  @brief Helper to declare LC3 codec QoS for 10ms interval unframed input
535  */
536 #define BT_AUDIO_CODEC_LC3_QOS_10_UNFRAMED(_sdu, _rtn, _latency, _pd)                              \
537 	BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, _sdu, _rtn, _latency, _pd)
538 
539 #ifdef __cplusplus
540 }
541 #endif
542 
543 /**
544  * @}
545  */
546 
547 #endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_LC3_H_ */
548