3 * BlueZ - Bluetooth protocol stack for Linux
5 * Copyright (C) 2006-2010 Nokia Corporation
6 * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #define A2DP_CODEC_SBC 0x00
26 #define A2DP_CODEC_MPEG12 0x01
27 #define A2DP_CODEC_MPEG24 0x02
28 #define A2DP_CODEC_ATRAC 0x03
29 #define A2DP_CODEC_VENDOR 0xFF
31 #define SBC_SAMPLING_FREQ_16000 (1 << 3)
32 #define SBC_SAMPLING_FREQ_32000 (1 << 2)
33 #define SBC_SAMPLING_FREQ_44100 (1 << 1)
34 #define SBC_SAMPLING_FREQ_48000 1
36 #define SBC_CHANNEL_MODE_MONO (1 << 3)
37 #define SBC_CHANNEL_MODE_DUAL_CHANNEL (1 << 2)
38 #define SBC_CHANNEL_MODE_STEREO (1 << 1)
39 #define SBC_CHANNEL_MODE_JOINT_STEREO 1
41 #define SBC_BLOCK_LENGTH_4 (1 << 3)
42 #define SBC_BLOCK_LENGTH_8 (1 << 2)
43 #define SBC_BLOCK_LENGTH_12 (1 << 1)
44 #define SBC_BLOCK_LENGTH_16 1
46 #define SBC_SUBBANDS_4 (1 << 1)
47 #define SBC_SUBBANDS_8 1
49 #define SBC_ALLOCATION_SNR (1 << 1)
50 #define SBC_ALLOCATION_LOUDNESS 1
52 #define MAX_BITPOOL 64
55 #define MPEG_CHANNEL_MODE_MONO (1 << 3)
56 #define MPEG_CHANNEL_MODE_DUAL_CHANNEL (1 << 2)
57 #define MPEG_CHANNEL_MODE_STEREO (1 << 1)
58 #define MPEG_CHANNEL_MODE_JOINT_STEREO 1
60 #define MPEG_LAYER_MP1 (1 << 2)
61 #define MPEG_LAYER_MP2 (1 << 1)
62 #define MPEG_LAYER_MP3 1
64 #define MPEG_SAMPLING_FREQ_16000 (1 << 5)
65 #define MPEG_SAMPLING_FREQ_22050 (1 << 4)
66 #define MPEG_SAMPLING_FREQ_24000 (1 << 3)
67 #define MPEG_SAMPLING_FREQ_32000 (1 << 2)
68 #define MPEG_SAMPLING_FREQ_44100 (1 << 1)
69 #define MPEG_SAMPLING_FREQ_48000 1
71 #define MPEG_BIT_RATE_VBR 0x8000
72 #define MPEG_BIT_RATE_320000 0x4000
73 #define MPEG_BIT_RATE_256000 0x2000
74 #define MPEG_BIT_RATE_224000 0x1000
75 #define MPEG_BIT_RATE_192000 0x0800
76 #define MPEG_BIT_RATE_160000 0x0400
77 #define MPEG_BIT_RATE_128000 0x0200
78 #define MPEG_BIT_RATE_112000 0x0100
79 #define MPEG_BIT_RATE_96000 0x0080
80 #define MPEG_BIT_RATE_80000 0x0040
81 #define MPEG_BIT_RATE_64000 0x0020
82 #define MPEG_BIT_RATE_56000 0x0010
83 #define MPEG_BIT_RATE_48000 0x0008
84 #define MPEG_BIT_RATE_40000 0x0004
85 #define MPEG_BIT_RATE_32000 0x0002
86 #define MPEG_BIT_RATE_FREE 0x0001
88 #define AAC_OBJECT_TYPE_MPEG2_AAC_LC 0x80
89 #define AAC_OBJECT_TYPE_MPEG4_AAC_LC 0x40
90 #define AAC_OBJECT_TYPE_MPEG4_AAC_LTP 0x20
91 #define AAC_OBJECT_TYPE_MPEG4_AAC_SCA 0x10
93 #define AAC_SAMPLING_FREQ_8000 0x0800
94 #define AAC_SAMPLING_FREQ_11025 0x0400
95 #define AAC_SAMPLING_FREQ_12000 0x0200
96 #define AAC_SAMPLING_FREQ_16000 0x0100
97 #define AAC_SAMPLING_FREQ_22050 0x0080
98 #define AAC_SAMPLING_FREQ_24000 0x0040
99 #define AAC_SAMPLING_FREQ_32000 0x0020
100 #define AAC_SAMPLING_FREQ_44100 0x0010
101 #define AAC_SAMPLING_FREQ_48000 0x0008
102 #define AAC_SAMPLING_FREQ_64000 0x0004
103 #define AAC_SAMPLING_FREQ_88200 0x0002
104 #define AAC_SAMPLING_FREQ_96000 0x0001
106 #define AAC_CHANNELS_1 0x02
107 #define AAC_CHANNELS_2 0x01
109 #define AAC_GET_BITRATE(a) ((a).bitrate1 << 16 | \
110 (a).bitrate2 << 8 | (a).bitrate3)
111 #define AAC_GET_FREQUENCY(a) ((a).frequency1 << 4 | (a).frequency2)
113 #define AAC_SET_BITRATE(a, b) \
115 (a).bitrate1 = (b >> 16) & 0x7f; \
116 (a).bitrate2 = (b >> 8) & 0xff; \
117 (a).bitrate3 = b & 0xff; \
119 #define AAC_SET_FREQUENCY(a, f) \
121 (a).frequency1 = (f >> 4) & 0xff; \
122 (a).frequency2 = f & 0x0f; \
125 #define AAC_INIT_BITRATE(b) \
126 .bitrate1 = (b >> 16) & 0x7f, \
127 .bitrate2 = (b >> 8) & 0xff, \
128 .bitrate3 = b & 0xff,
129 #define AAC_INIT_FREQUENCY(f) \
130 .frequency1 = (f >> 4) & 0xff, \
131 .frequency2 = f & 0x0f,
133 #define APTX_VENDOR_ID 0x0000004f
134 #define APTX_CODEC_ID 0x0001
136 #define APTX_CHANNEL_MODE_MONO 0x01
137 #define APTX_CHANNEL_MODE_STEREO 0x02
139 #define APTX_SAMPLING_FREQ_16000 0x08
140 #define APTX_SAMPLING_FREQ_32000 0x04
141 #define APTX_SAMPLING_FREQ_44100 0x02
142 #define APTX_SAMPLING_FREQ_48000 0x01
144 #define LDAC_VENDOR_ID 0x0000012d
145 #define LDAC_CODEC_ID 0x00aa
150 } __attribute__ ((packed)) a2dp_vendor_codec_t;
152 #if __BYTE_ORDER == __LITTLE_ENDIAN
155 uint8_t channel_mode:4;
157 uint8_t allocation_method:2;
159 uint8_t block_length:4;
162 } __attribute__ ((packed)) a2dp_sbc_t;
165 uint8_t channel_mode:4;
172 } __attribute__ ((packed)) a2dp_mpeg_t;
179 uint8_t frequency2:4;
184 } __attribute__ ((packed)) a2dp_aac_t;
187 a2dp_vendor_codec_t info;
188 uint8_t channel_mode:4;
190 } __attribute__ ((packed)) a2dp_aptx_t;
193 a2dp_vendor_codec_t info;
195 } __attribute__ ((packed)) a2dp_ldac_t;
197 #elif __BYTE_ORDER == __BIG_ENDIAN
201 uint8_t channel_mode:4;
202 uint8_t block_length:4;
204 uint8_t allocation_method:2;
207 } __attribute__ ((packed)) a2dp_sbc_t;
212 uint8_t channel_mode:4;
217 } __attribute__ ((packed)) a2dp_mpeg_t;
222 uint8_t frequency2:4;
229 } __attribute__ ((packed)) a2dp_aac_t;
232 a2dp_vendor_codec_t info;
234 uint8_t channel_mode:4;
235 } __attribute__ ((packed)) a2dp_aptx_t;
238 #error "Unknown byte order"