1 /** @file
2  * @brief Advance Audio Distribution Profile - SBC Codec header.
3  */
4 /*
5  * SPDX-License-Identifier: Apache-2.0
6  * Copyright (c) 2015-2016 Intel Corporation
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 #ifndef ZEPHYR_INCLUDE_BLUETOOTH_A2DP_CODEC_H_
21 #define ZEPHYR_INCLUDE_BLUETOOTH_A2DP_CODEC_H_
22 
23 #include <stdint.h>
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 /* Sampling Frequency */
30 #define A2DP_SBC_SAMP_FREQ_16000 BIT(7)
31 #define A2DP_SBC_SAMP_FREQ_32000 BIT(6)
32 #define A2DP_SBC_SAMP_FREQ_44100 BIT(5)
33 #define A2DP_SBC_SAMP_FREQ_48000 BIT(4)
34 
35 /* Channel Mode */
36 #define A2DP_SBC_CH_MODE_MONO  BIT(3)
37 #define A2DP_SBC_CH_MODE_DUAL  BIT(2)
38 #define A2DP_SBC_CH_MODE_STREO BIT(1)
39 #define A2DP_SBC_CH_MODE_JOINT BIT(0)
40 
41 /* Block Length */
42 #define A2DP_SBC_BLK_LEN_4  BIT(7)
43 #define A2DP_SBC_BLK_LEN_8  BIT(6)
44 #define A2DP_SBC_BLK_LEN_12 BIT(5)
45 #define A2DP_SBC_BLK_LEN_16 BIT(4)
46 
47 /* Subbands */
48 #define A2DP_SBC_SUBBAND_4 BIT(3)
49 #define A2DP_SBC_SUBBAND_8 BIT(2)
50 
51 /* Allocation Method */
52 #define A2DP_SBC_ALLOC_MTHD_SNR      BIT(1)
53 #define A2DP_SBC_ALLOC_MTHD_LOUDNESS BIT(0)
54 
55 #define BT_A2DP_SBC_SAMP_FREQ(preset)    ((preset->config[0] >> 4) & 0x0f)
56 #define BT_A2DP_SBC_CHAN_MODE(preset)    ((preset->config[0]) & 0x0f)
57 #define BT_A2DP_SBC_BLK_LEN(preset)      ((preset->config[1] >> 4) & 0x0f)
58 #define BT_A2DP_SBC_SUB_BAND(preset)     ((preset->config[1] >> 2) & 0x03)
59 #define BT_A2DP_SBC_ALLOC_MTHD(preset)   ((preset->config[1]) & 0x03)
60 
61 /** @brief SBC Codec */
62 struct bt_a2dp_codec_sbc_params {
63 	/** First two octets of configuration */
64 	uint8_t config[2];
65 	/** Minimum Bitpool Value */
66 	uint8_t min_bitpool;
67 	/** Maximum Bitpool Value */
68 	uint8_t max_bitpool;
69 } __packed;
70 
71 #ifdef __cplusplus
72 }
73 #endif
74 
75 #endif /* ZEPHYR_INCLUDE_BLUETOOTH_A2DP_CODEC_H_ */
76