OSDN Git Service

Merge commit '07772caf5ca22365dd62bc042de179a4da55f665' into remote
[android-x86/system-bt.git] / audio_a2dp_hw / bthost_ipc.h
1 /******************************************************************************
2  *  Copyright (C) 2016, The Linux Foundation. All rights reserved.
3  *
4  *  Not a Contribution
5  *****************************************************************************/
6 /*****************************************************************************
7  *  Copyright (C) 2009-2012 Broadcom Corporation
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  ******************************************************************************/
22
23 /*****************************************************************************
24  *
25  *  Filename:      audio_a2dp_hw.h
26  *
27  *  Description:
28  *
29  *****************************************************************************/
30 #ifndef BT_HOST_IPC_H
31 #define BT_HOST_IPC_H
32 #include "audio_a2dp_hw.h"
33 #include <system/audio.h>
34 /*****************************************************************************
35 **  Constants & Macros
36 ******************************************************************************/
37
38 #define BT_AUDIO_HARDWARE_INTERFACE "libbthost"
39 #define A2DP_CTRL_PATH "/data/misc/bluedroid/.a2dp_ctrl"
40 #define A2DP_DATA_PATH "/data/misc/bluedroid/.a2dp_data"
41
42 typedef enum {
43     A2DP_CTRL_GET_CODEC_CONFIG = 15,
44     A2DP_CTRL_GET_MULTICAST_STATUS,
45     A2DP_CTRL_GET_CONNECTION_STATUS,
46 } tA2DP_CTRL_EXT_CMD;
47
48 /*
49 codec specific definitions
50 */
51 #define CODEC_TYPE_SBC 0x00
52 #define CODEC_TYPE_AAC 0x02
53 #define NON_A2DP_CODEC_TYPE 0xFF
54 #define CODEC_OFFSET 3
55 #define VENDOR_ID_OFFSET 4
56 #define CODEC_ID_OFFSET (VENDOR_ID_OFFSET + 4)
57 #define CODEC_TYPE_PCM 0x05
58
59 #ifndef VENDOR_APTX
60 #define VENDOR_APTX 0x4F
61 #endif
62 #ifndef VENDOR_APTX_HD
63 #define VENDOR_APTX_HD 0xD7
64 #endif
65 #ifndef VENDOR_APTX_LL
66 #define VENDOR_APTX_LL 0x0A
67 #endif
68 #ifndef APTX_CODEC_ID
69 #define APTX_CODEC_ID 0x01
70 #endif
71 #ifndef APTX_HD_CODEC_ID
72 #define APTX_HD_CODEC_ID 0x24
73 #endif
74
75 #define A2D_SBC_FREQ_MASK 0xF0
76 #define A2D_SBC_CHN_MASK  0x0F
77 #define A2D_SBC_BLK_MASK  0xF0
78 #define A2D_SBC_SUBBAND_MASK 0x0C
79 #define A2D_SBC_ALLOC_MASK 0x03
80 #define A2D_SBC_SAMP_FREQ_16     0x80    /* b7:16  kHz */
81 #define A2D_SBC_SAMP_FREQ_32     0x40    /* b6:32  kHz */
82 #define A2D_SBC_SAMP_FREQ_44     0x20    /* b5:44.1kHz */
83 #define A2D_SBC_SAMP_FREQ_48     0x10    /* b4:48  kHz */
84 #define A2D_SBC_CH_MD_MONO       0x08    /* b3: mono */
85 #define A2D_SBC_CH_MD_DUAL       0x04    /* b2: dual */
86 #define A2D_SBC_CH_MD_STEREO     0x02    /* b1: stereo */
87 #define A2D_SBC_CH_MD_JOINT      0x01    /* b0: joint stereo */
88 #define A2D_SBC_BLOCKS_4         0x80    /* 4 blocks */
89 #define A2D_SBC_BLOCKS_8         0x40    /* 8 blocks */
90 #define A2D_SBC_BLOCKS_12        0x20    /* 12blocks */
91 #define A2D_SBC_BLOCKS_16        0x10    /* 16blocks */
92 #define A2D_SBC_SUBBAND_4        0x08    /* b3: 4 */
93 #define A2D_SBC_SUBBAND_8        0x04    /* b2: 8 */
94 #define A2D_SBC_ALLOC_MD_S       0x02    /* b1: SNR */
95 #define A2D_SBC_ALLOC_MD_L       0x01    /* b0: loundess */
96
97 /* APTX bitmask helper */
98 #define A2D_APTX_SAMP_FREQ_MASK  0xF0
99 #define A2D_APTX_SAMP_FREQ_48    0x10
100 #define A2D_APTX_SAMP_FREQ_44    0x20
101 #define A2D_APTX_CHAN_MASK       0x0F
102 #define A2D_APTX_CHAN_STEREO     0x02
103 #define A2D_APTX_CHAN_MONO       0x01
104
105
106 #define A2D_AAC_IE_OBJ_TYPE_MSK                0xF0    /* b7-b4 Object Type */
107 #define A2D_AAC_IE_OBJ_TYPE_MPEG_2_AAC_LC      0x80    /* b7:MPEG-2 AAC LC */
108 #define A2D_AAC_IE_OBJ_TYPE_MPEG_4_AAC_LC      0x40    /* b7:MPEG-4 AAC LC */
109 #define A2D_AAC_IE_OBJ_TYPE_MPEG_4_AAC_LTP     0x20    /* b7:MPEG-4 AAC LTP */
110 #define A2D_AAC_IE_OBJ_TYPE_MPEG_4_AAC_SCA     0x10    /* b7:MPEG-4 AAC SCALABLE */
111
112 #define A2D_AAC_IE_CHANNELS_MSK                0x0C
113 #define A2D_AAC_IE_CHANNELS_1                  0x08    /* Channel 1 */
114 #define A2D_AAC_IE_CHANNELS_2                  0x04    /* Channel 2 */
115
116 #define A2D_AAC_IE_VBR_MSK                     0x80
117 #define A2D_AAC_IE_VBR                         0x80    /* supported */
118
119 typedef struct {
120     uint8_t  codec_type;
121     uint8_t  dev_idx;
122     uint16_t sampling_rate; /*44.1khz,48khz*/
123     uint8_t  chn;           /*0(Mono),1(Dual),2(Stereo),3(JS)*/
124     uint8_t  blk_len;       /*4,8,12,16 */
125     uint8_t  subband;       /*4,8*/
126     uint8_t  alloc;         /*0(Loudness),1(SNR)*/
127     uint8_t  min_bitpool;   /* 2 */
128     uint8_t  max_bitpool;   /*53(44.1khz),51 (48khz) */
129     uint16_t mtu;
130     uint32_t bitrate;
131 }tA2DP_SBC_CODEC;
132
133 typedef struct {
134     uint8_t  codec_type;
135     uint8_t  dev_idx;
136     uint32_t vendor_id;
137     uint16_t codec_id;
138     uint16_t sampling_rate;
139     uint8_t  chnl;
140     uint8_t  cp;
141     uint16_t mtu;
142     uint32_t bitrate;
143 }tA2DP_APTX_CODEC;
144
145 typedef struct {
146     /** Set to sizeof(bt_host_ipc_interface_t) */
147     size_t          size;
148     void (*a2dp_open_ctrl_path)(struct a2dp_stream_common *common);
149     void (*a2dp_stream_common_init)(struct a2dp_stream_common *common);
150     int (*start_audio_datapath)(struct a2dp_stream_common *common);
151     int (*suspend_audio_datapath)(struct a2dp_stream_common *common, bool standby);
152     int (*stop_audio_datapath)(struct a2dp_stream_common *common);
153     int (*check_a2dp_stream_started)(struct a2dp_stream_common *common);
154     int (*check_a2dp_ready)(struct a2dp_stream_common *common);
155     int (*a2dp_read_audio_config)(struct a2dp_stream_common *common);
156     int (*skt_read)(int fd,void *buf, size_t bytes);
157     int (*skt_write)(int fd,const void *buf, size_t bytes);
158     int (*skt_disconnect)(int fd);
159     int (*a2dp_command)(struct a2dp_stream_common *common,char cmd);
160     int (*audio_stream_open)(void);
161     int (*audio_stream_close)(void);
162     int (*audio_start_stream)(void);
163     int (*audio_stop_stream)(void);
164     int (*audio_suspend_stream)(void);
165     void* (*audio_get_codec_config)(uint8_t *mcast, uint8_t *num_dev, audio_format_t *codec_type);
166     void (*audio_handoff_triggered)(void);
167     void (*clear_a2dpsuspend_flag)(void);
168     void*(*audio_get_next_codec_config)(uint8_t idx, audio_format_t *codec_type);
169
170 } bt_host_ipc_interface_t;
171 #endif