Zephyr API Documentation 4.0.0-rc3
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
a2dp_codec_sbc.h
Go to the documentation of this file.
1
4/*
5 * SPDX-License-Identifier: Apache-2.0
6 * Copyright (c) 2015-2016 Intel Corporation
7 * Copyright (c) 2021 NXP
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21#ifndef ZEPHYR_INCLUDE_BLUETOOTH_A2DP_CODEC_H_
22#define ZEPHYR_INCLUDE_BLUETOOTH_A2DP_CODEC_H_
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/* Sampling Frequency */
29#define A2DP_SBC_SAMP_FREQ_16000 BIT(7)
30#define A2DP_SBC_SAMP_FREQ_32000 BIT(6)
31#define A2DP_SBC_SAMP_FREQ_44100 BIT(5)
32#define A2DP_SBC_SAMP_FREQ_48000 BIT(4)
33
34/* Channel Mode */
35#define A2DP_SBC_CH_MODE_MONO BIT(3)
36#define A2DP_SBC_CH_MODE_DUAL BIT(2)
37#define A2DP_SBC_CH_MODE_STREO BIT(1)
38#define A2DP_SBC_CH_MODE_JOINT BIT(0)
39
40/* Block Length */
41#define A2DP_SBC_BLK_LEN_4 BIT(7)
42#define A2DP_SBC_BLK_LEN_8 BIT(6)
43#define A2DP_SBC_BLK_LEN_12 BIT(5)
44#define A2DP_SBC_BLK_LEN_16 BIT(4)
45
46/* Subbands */
47#define A2DP_SBC_SUBBAND_4 BIT(3)
48#define A2DP_SBC_SUBBAND_8 BIT(2)
49
50/* Allocation Method */
51#define A2DP_SBC_ALLOC_MTHD_SNR BIT(1)
52#define A2DP_SBC_ALLOC_MTHD_LOUDNESS BIT(0)
53
54#define BT_A2DP_SBC_SAMP_FREQ(cap) ((cap->config[0] >> 4) & 0x0f)
55#define BT_A2DP_SBC_CHAN_MODE(cap) ((cap->config[0]) & 0x0f)
56#define BT_A2DP_SBC_BLK_LEN(cap) ((cap->config[1] >> 4) & 0x0f)
57#define BT_A2DP_SBC_SUB_BAND(cap) ((cap->config[1] >> 2) & 0x03)
58#define BT_A2DP_SBC_ALLOC_MTHD(cap) ((cap->config[1]) & 0x03)
59
69
75#define BT_A2DP_SBC_MEDIA_HDR_NUM_FRAMES_GET(hdr) FIELD_GET(GENMASK(3, 0), (hdr))
77#define BT_A2DP_SBC_MEDIA_HDR_L_GET(hdr) FIELD_GET(BIT(5), (hdr))
79#define BT_A2DP_SBC_MEDIA_HDR_S_GET(hdr) FIELD_GET(BIT(6), (hdr))
81#define BT_A2DP_SBC_MEDIA_HDR_F_GET(hdr) FIELD_GET(BIT(7), (hdr))
82
88#define BT_A2DP_SBC_MEDIA_HDR_NUM_FRAMES_SET(hdr, val)\
89 hdr = ((hdr) & ~GENMASK(3, 0)) | FIELD_PREP(GENMASK(3, 0), (val))
91#define BT_A2DP_SBC_MEDIA_HDR_L_SET(hdr, val)\
92 hdr = ((hdr) & ~BIT(5)) | FIELD_PREP(BIT(5), (val))
94#define BT_A2DP_SBC_MEDIA_HDR_S_SET(hdr, val)\
95 hdr = ((hdr) & ~BIT(6)) | FIELD_PREP(BIT(6), (val))
97#define BT_A2DP_SBC_MEDIA_HDR_F_SET(hdr, val)\
98 hdr = ((hdr) & ~BIT(7)) | FIELD_PREP(BIT(7), (val))
99
100#define BT_A2DP_SBC_MEDIA_HDR_ENCODE(num_frames, l, s, f)\
101 FIELD_PREP(GENMASK(3, 0), num_frames) | FIELD_PREP(BIT(5), l) |\
102 FIELD_PREP(BIT(6), s) | FIELD_PREP(BIT(7), f)
103
111
119
120#ifdef __cplusplus
121}
122#endif
123
124#endif /* ZEPHYR_INCLUDE_BLUETOOTH_A2DP_CODEC_H_ */
uint32_t bt_a2dp_sbc_get_sampling_frequency(struct bt_a2dp_codec_sbc_params *sbc_codec)
get sample rate of a2dp sbc config.
uint8_t bt_a2dp_sbc_get_channel_num(struct bt_a2dp_codec_sbc_params *sbc_codec)
get channel num of a2dp sbc config.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
SBC Codec.
Definition a2dp_codec_sbc.h:61
uint8_t min_bitpool
Minimum Bitpool Value.
Definition a2dp_codec_sbc.h:65
uint8_t max_bitpool
Maximum Bitpool Value.
Definition a2dp_codec_sbc.h:67
uint8_t config[2]
First two octets of configuration.
Definition a2dp_codec_sbc.h:63