LCOV - code coverage report
Current view: top level - zephyr/bluetooth/classic - a2dp_codec_sbc.h Coverage Total Hit
Test: new.info Lines: 38.5 % 39 15
Test Date: 2025-09-05 16:43:28

            Line data    Source code
       1            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              :  * 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
      25              : extern "C" {
      26              : #endif
      27              : 
      28              : /* Sampling Frequency */
      29            0 : #define A2DP_SBC_SAMP_FREQ_16000 BIT(7)
      30            0 : #define A2DP_SBC_SAMP_FREQ_32000 BIT(6)
      31            0 : #define A2DP_SBC_SAMP_FREQ_44100 BIT(5)
      32            0 : #define A2DP_SBC_SAMP_FREQ_48000 BIT(4)
      33              : 
      34              : /* Channel Mode */
      35            0 : #define A2DP_SBC_CH_MODE_MONO  BIT(3)
      36            0 : #define A2DP_SBC_CH_MODE_DUAL  BIT(2)
      37            0 : #define A2DP_SBC_CH_MODE_STREO BIT(1)
      38            0 : #define A2DP_SBC_CH_MODE_JOINT BIT(0)
      39              : 
      40              : /* Block Length */
      41            0 : #define A2DP_SBC_BLK_LEN_4  BIT(7)
      42            0 : #define A2DP_SBC_BLK_LEN_8  BIT(6)
      43            0 : #define A2DP_SBC_BLK_LEN_12 BIT(5)
      44            0 : #define A2DP_SBC_BLK_LEN_16 BIT(4)
      45              : 
      46              : /* Subbands */
      47            0 : #define A2DP_SBC_SUBBAND_4 BIT(3)
      48            0 : #define A2DP_SBC_SUBBAND_8 BIT(2)
      49              : 
      50              : /* Allocation Method */
      51            0 : #define A2DP_SBC_ALLOC_MTHD_SNR      BIT(1)
      52            0 : #define A2DP_SBC_ALLOC_MTHD_LOUDNESS BIT(0)
      53              : 
      54            0 : #define BT_A2DP_SBC_SAMP_FREQ(cap)    ((cap->config[0] >> 4) & 0x0f)
      55            0 : #define BT_A2DP_SBC_CHAN_MODE(cap)    ((cap->config[0]) & 0x0f)
      56            0 : #define BT_A2DP_SBC_BLK_LEN(cap)      ((cap->config[1] >> 4) & 0x0f)
      57            0 : #define BT_A2DP_SBC_SUB_BAND(cap)     ((cap->config[1] >> 2) & 0x03)
      58            0 : #define BT_A2DP_SBC_ALLOC_MTHD(cap)   ((cap->config[1]) & 0x03)
      59            0 : #define BT_A2DP_SBC_MIN_BITPOOL_VALUE  2
      60            0 : #define BT_A2DP_SBC_MAX_BITPOOL_VALUE  250
      61              : 
      62              : /** @brief SBC Codec */
      63            1 : struct bt_a2dp_codec_sbc_params {
      64              :         /** First two octets of configuration */
      65            1 :         uint8_t config[2];
      66              :         /** Minimum Bitpool Value */
      67            1 :         uint8_t min_bitpool;
      68              :         /** Maximum Bitpool Value */
      69            1 :         uint8_t max_bitpool;
      70              : } __packed;
      71              : 
      72              : /** If the F bit is set to 0, this field indicates the number of frames contained
      73              :  *  in this packet. If the F bit is set to 1, this field indicates the number
      74              :  *  of remaining fragments, including the current fragment.
      75              :  *  Therefore, the last counter value shall be one.
      76              :  */
      77            1 : #define BT_A2DP_SBC_MEDIA_HDR_NUM_FRAMES_GET(hdr) FIELD_GET(GENMASK(3, 0), (hdr))
      78              : /** Set to 1 for the last packet of a fragmented SBC frame, otherwise set to 0. */
      79            1 : #define BT_A2DP_SBC_MEDIA_HDR_L_GET(hdr)          FIELD_GET(BIT(5), (hdr))
      80              : /** Set to 1 for the starting packet of a fragmented SBC frame, otherwise set to 0. */
      81            1 : #define BT_A2DP_SBC_MEDIA_HDR_S_GET(hdr)          FIELD_GET(BIT(6), (hdr))
      82              : /** Set to 1 if the SBC frame is fragmented, otherwise set to 0. */
      83            1 : #define BT_A2DP_SBC_MEDIA_HDR_F_GET(hdr)          FIELD_GET(BIT(7), (hdr))
      84              : 
      85              : /** If the F bit is set to 0, this field indicates the number of frames contained
      86              :  *  in this packet. If the F bit is set to 1, this field indicates the number
      87              :  *  of remaining fragments, including the current fragment.
      88              :  *  Therefore, the last counter value shall be one.
      89              :  */
      90            1 : #define BT_A2DP_SBC_MEDIA_HDR_NUM_FRAMES_SET(hdr, val)\
      91              :         hdr = ((hdr) & ~GENMASK(3, 0)) | FIELD_PREP(GENMASK(3, 0), (val))
      92              : /** Set to 1 for the last packet of a fragmented SBC frame, otherwise set to 0. */
      93            1 : #define BT_A2DP_SBC_MEDIA_HDR_L_SET(hdr, val)\
      94              :         hdr = ((hdr) & ~BIT(5)) | FIELD_PREP(BIT(5), (val))
      95              : /** Set to 1 for the starting packet of a fragmented SBC frame, otherwise set to 0. */
      96            1 : #define BT_A2DP_SBC_MEDIA_HDR_S_SET(hdr, val)\
      97              :         hdr = ((hdr) & ~BIT(6)) | FIELD_PREP(BIT(6), (val))
      98              : /** Set to 1 if the SBC frame is fragmented, otherwise set to 0. */
      99            1 : #define BT_A2DP_SBC_MEDIA_HDR_F_SET(hdr, val)\
     100              :         hdr = ((hdr) & ~BIT(7)) | FIELD_PREP(BIT(7), (val))
     101              : 
     102            0 : #define BT_A2DP_SBC_MEDIA_HDR_ENCODE(num_frames, l, s, f)\
     103              :         FIELD_PREP(GENMASK(3, 0), num_frames) | FIELD_PREP(BIT(5), l) |\
     104              :         FIELD_PREP(BIT(6), s) | FIELD_PREP(BIT(7), f)
     105              : 
     106              : /** @brief get channel num of a2dp sbc config.
     107              :  *
     108              :  *  @param sbc_codec The a2dp sbc parameter.
     109              :  *
     110              :  *  @return the channel num.
     111              :  */
     112            1 : uint8_t bt_a2dp_sbc_get_channel_num(struct bt_a2dp_codec_sbc_params *sbc_codec);
     113              : 
     114              : /** @brief get sample rate of a2dp sbc config.
     115              :  *
     116              :  *  @param sbc_codec The a2dp sbc parameter.
     117              :  *
     118              :  *  @return the sample rate.
     119              :  */
     120            1 : uint32_t bt_a2dp_sbc_get_sampling_frequency(struct bt_a2dp_codec_sbc_params *sbc_codec);
     121              : 
     122              : #ifdef __cplusplus
     123              : }
     124              : #endif
     125              : 
     126              : #endif /* ZEPHYR_INCLUDE_BLUETOOTH_A2DP_CODEC_H_ */
        

Generated by: LCOV version 2.0-1