blob: 6178fdc8a1ac31c03afdaf495b9394074fcbdb14 [file] [log] [blame]
The Android Open Source Projecte9df6ba2012-12-13 14:55:37 -08001/******************************************************************************
2 *
3 * Copyright (C) 2001-2012 Broadcom Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18
19/******************************************************************************
20 *
21 * This file contains codec definitions from Widcomm's Universal Embedded
22 * Drivers API.
23 *
24 ******************************************************************************/
25
26#ifndef UCODEC_H
27#define UCODEC_H
28
29#include "bt_target.h"
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34
35/*******************************************************************************
36** Codec APIs
37*******************************************************************************/
38
39/**** Codec IDs ****/
40#define UCODEC_ID_1 0
41#define UCODEC_ID_2 1
42#define UCODEC_ID_3 2
43#define UCODEC_ID_4 3
44#define UCODEC_NUMBER 4
45
46typedef UINT8 tUCODEC_ID;
47
48/**** Status ****/
49#define UCODEC_SUCCESS 0x00
50#define UCODEC_TX_DONE 0x01
51#define UCODEC_RX_READY 0x02
52#define UCODEC_FLOW_CTRL_ON 0x03
53#define UCODEC_FLOW_CTRL_OFF 0x04
54#define UCODEC_OVERFLOW 0x05
55#define UCODEC_UNSUPORTED_CNF 0x06
56#define UCODEC_WRONG_PARAM 0x07
57#define UCODEC_NOT_CONFIGURED 0x08
58#define UCODEC_OUT_OF_MEMORY 0x09
59#define UCODEC_GENERIC_ERROR 0x0a
60#define UCODEC_RECOVERABLE_ERROR 0x0b
61#define UCODEC_UNRECOVERABLE_ERROR 0x0c
62#define UCODEC_LOW_LEVEL_DRIVER_ERROR (0x0d)
63
64typedef UINT8 tUCODEC_STATUS;
65
66/**** Media type ****/
67#define UCODEC_MEDIA_TYPE_AUDIO 0
68#define UCODEC_MEDIA_TYPE_VIDEO 1
69#define UCODEC_MEDIA_TYPE_MULTI 2
70
71typedef UINT8 tUCODEC_MEDIA_TYPE;
72
73/**** Audio Codec type ****/
74#define UCODEC_AUDIO_SBC 0
75#define UCODEC_AUDIO_M12_LAYER1 1 /* layer1 (mp1) */
76#define UCODEC_AUDIO_M12_LAYER2 2 /* layer2 (mp2) */
77#define UCODEC_AUDIO_M12_LAYER3 3 /* layer3 (mp3) */
78#define UCODEC_AUDIO_M24_2LC 4 /* MPEG-2 AAC LC */
79#define UCODEC_AUDIO_M24_4LC 5 /* MPEG-4 AAC LC */
80#define UCODEC_AUDIO_M24_4LTP 6 /* MPEG-4 AAC LTP */
81#define UCODEC_AUDIO_M24_4S 7 /* MPEG-4 AAC scalable */
82#define UCODEC_AUDIO_VOLUME 8 /* Volume settings */
83#define UCODEC_AUDIO_BALANCE 9 /* Balance settings */
84
85typedef UINT8 tUCODEC_AUDIO_FEAT_TYPE;
86
87/**** Video Codec type -> TODO ****/
88/*TBD*/
89
90typedef UINT8 tUCODEC_VIDEO_FEAT_TYPE;
91
92/**** SBC sample frequency ****/
93#define UCODEC_SBC_SMP_FREQ_16 0 /* 16 */
94#define UCODEC_SBC_SMP_FREQ_32 1 /* 23 */
95#define UCODEC_SBC_SMP_FREQ_44 2 /* 44.1 */
96#define UCODEC_SBC_SMP_FREQ_48 3 /* 48 */
97
98typedef UINT8 tUCODEC_SBC_SMP_FREQ;
99
100/**** SBC sample frequency ****/
101#define UCODEC_SBC_SUBBAND_4 4
102#define UCODEC_SBC_SUBBAND_8 8
103
104typedef UINT8 tUCODEC_SBC_SUBBAND;
105/**** Allocation method ****/
106#define UCODEC_SBC_ALLOC_MD_S 0 /* SNR */
107#define UCODEC_SBC_ALLOC_MD_L 1 /* loundess */
108
109typedef UINT8 tUCODEC_SBC_ALLOC_MD;
110
111/**** MPEG sample frequency ****/
112#define UCODEC_M12_SMP_FREQ_16 0 /* 16 */
113#define UCODEC_M12_SMP_FREQ_22 1 /* 22 */
114#define UCODEC_M12_SMP_FREQ_24 2 /* 24 */
115#define UCODEC_M12_SMP_FREQ_32 3 /* 32 */
116#define UCODEC_M12_SMP_FREQ_44 4 /* 44 */
117#define UCODEC_M12_SMP_FREQ_48 5 /* 48 */
118
119typedef UINT8 tUCODEC_M12_SMP_FREQ;
120
121/**** Channel mode ****/
122#define UCODEC_CHN_MONO 0
123#define UCODEC_CHN_DUAL 1
124#define UCODEC_CHN_STEREO 2
125#define UCODEC_CHN_JOINT_STEREO 3
126
127typedef UINT8 tUCODEC_CH_MODE;
128/**** Audio Codec type ****/
129#define UCODEC_M24_SMP_FREQ_8 0 /* 8 */
130#define UCODEC_M24_SMP_FREQ_11 1 /* 11 */
131#define UCODEC_M24_SMP_FREQ_12 2 /* 12 */
132#define UCODEC_M24_SMP_FREQ_16 3 /* 16 */
133#define UCODEC_M24_SMP_FREQ_22 4 /* 22.05 */
134#define UCODEC_M24_SMP_FREQ_24 5 /* 24 */
135#define UCODEC_M24_SMP_FREQ_32 6 /* 32 */
136#define UCODEC_M24_SMP_FREQ_44 7 /* 44.1 */
137#define UCODEC_M24_SMP_FREQ_48 8 /* 48 */
138#define UCODEC_M24_SMP_FREQ_64 9 /* 64 */
139#define UCODEC_M24_SMP_FREQ_88 10 /* 88 */
140#define UCODEC_M24_SMP_FREQ_96 11 /* 96 */
141
142typedef UINT8 tUCODEC_M24_SMP_FREQ;
143
144/**** Codec configuration structure ****/
145typedef struct tUCODEC_CNF_SBC_TAG
146{
147 tUCODEC_SBC_SMP_FREQ SampleFreq;
148 tUCODEC_CH_MODE ChannelMode;
149 UINT16 Offset; /* GKI buffer based offset for UCODEC_ReadBuf */
150 UINT16 MtuSize; /* Max buffer len for UCODEC_ReadBuf*/
151 UINT8 PoolId; /* GKI pool ID for UCODEC_ReadBuf */
152 UINT8 NumBlock; /* Number of block in block unit : 4 blocks 8 blocks 12 blocks 16 blocks are the possible value */
153 UINT8 Subband;
154 tUCODEC_SBC_ALLOC_MD AllocMthd;
155 UINT8 MinBitPool;
156 UINT8 MaxBitPool;
157} tUCODEC_CNF_SBC;
158
159typedef struct tUCODEC_CNF_M12_TAG
160{
161 tUCODEC_CH_MODE ChannelMode; /* Mono, Dual, stereo, joint stereo */
162 tUCODEC_M12_SMP_FREQ SampleFreq; /* Sample freq: 16, 22, 24, 32, 44, 48 */
163 UINT16 BitRate; /* Bit rate in bit per sec */
164 UINT16 Offset; /* GKI buffer based offset for UCODEC_ReadBuf */
165 UINT16 MtuSize; /* Max buffer len for UCODEC_ReadBuf*/
166 UINT8 PoolId; /* GKI pool ID for UCODEC_ReadBuf */
167 BOOLEAN VBR; /* Variable Bit Rate */
168 BOOLEAN CRC_On; /* CRC error detection */
169 BOOLEAN MPF; /* Media payload format */
170} tUCODEC_CNF_M12;
171
172typedef struct tUCODEC_CNF_M24_TAG
173{
174 tUCODEC_M24_SMP_FREQ SampleFreq; /* Sample freq: 8, 11, 12, 16, 22.05, 24, 32, 44.1, 48, 64, 88, 96 */
175 UINT32 BitRate; /* Bit rate */
176 UINT16 Offset; /* GKI buffer based offset for UCODEC_ReadBuf */
177 UINT16 MtuSize; /* Max buffer len for UCODEC_ReadBuf*/
178 UINT8 PoolId; /* GKI pool ID for UCODEC_ReadBuf */
179 UINT8 Chanels; /* 1 or 2 chanels */
180} tUCODEC_CNF_M24;
181
182
183typedef union tUCODEC_CODEC_TYPE_TAG
184{
185 tUCODEC_AUDIO_FEAT_TYPE AudioType;
186 tUCODEC_VIDEO_FEAT_TYPE VideoType;
187} tUCODEC_CODEC_TYPE;
188
189typedef union tUCODEC_FEATURE_TAG
190{
191 /* Add here the audio feature structure */
192 tUCODEC_CNF_SBC SBCConfig;
193 tUCODEC_CNF_M12 M12Config;
194 tUCODEC_CNF_M24 M24Config;
195 UINT8 Volume; /* 0 to mute. 0xFF for the max volume */
196 UINT8 Balance; /* 0->100% right, 255->100% left */
197 /* Add here the video feature structure */
198 /* TBD */
199} tUCODEC_FEATURE;
200
201typedef struct tUCODEC_CNF_TAG
202{
203 tUCODEC_MEDIA_TYPE MediaType;
204 tUCODEC_CODEC_TYPE Type;
205 tUCODEC_FEATURE Feature;
206} tUCODEC_CNF;
207
208typedef struct tUCODEC_BUF_INFO_TAG
209{
210 UINT8 NumOfFrames;
211 UINT32 TimesStamp;
212} tUCODEC_BUF_INFO;
213
214
215/******************************************************************************
216**
217** Function tUCODEC_CBACK_PTR
218**
219** Description This call back report CODEC indication.
220** It report codec error as well as flow onfrol indication.
221**
222** Input : CodecId: Id of the codec that calls this call back.
223** Status: ->UCODEC_FLOW_CTRL_OFF if the Tx Q just
224** went below the low watermark
225** ->UCODEC_RX_READY if data are ready to be
226** read. This olny hapens when the Rx Q was
227** empty before receiving data.
228** ->UCODEC_INTERNAL_ERROR if something went
229** wrong with the driver
230**
231** Output Parameters : None
232**
233** Returns None.
234**
235******************************************************************************/
236typedef void (* tUCODEC_CBACK_PTR)(tUCODEC_ID, tUCODEC_STATUS);
237
238/*******************************************************************************
239** Function Prototypes
240*******************************************************************************/
241
242/******************************************************************************
243**
244** Function UCODEC_Init
245**
246** Description Startup initialisation function. This function is called
247** before any orther function of UCODEC it initialize UCODEC
248** internal structure an the external codec.
249**
250** Input : CodecId: Id of the codec to perform the operation on.
251**
252** Output Parameters : None
253**
254** Returns UCODEC_SUCCESS if The action was performed with sucess.
255** Error code else.
256**
257******************************************************************************/
258BT_API extern tUCODEC_STATUS UCODEC_Init (void *);
259
260/******************************************************************************
261**
262** Function UCODEC_Configure
263**
264** Description Initialise the CODEC for a particular stream.
265**
266**
267** Input : CodecId: Id of the codec to perform the operation on.
268** CbackPrt: Call back pointer for codec feedback.
269** pConfig: Pointer on a codec configuration structure.
270**
271** Output Parameters : None
272**
273** Returns UCODEC_SUCCESS if The action was performed with sucess.
274**
275******************************************************************************/
276BT_API extern tUCODEC_STATUS UCODEC_Configure (tUCODEC_ID, tUCODEC_CBACK_PTR, tUCODEC_CNF *);
277
278/******************************************************************************
279**
280** Function UCODEC_FlushTx
281**
282** Description Fluch Tx buffer Q.
283**
284** Input : CodecId: Id of the codec to perform the operation on.
285**
286** Output Parameters : None
287**
288** Returns UCODEC_SUCCESS if The action was performed with sucess.
289** Error code else.
290**
291******************************************************************************/
292BT_API extern tUCODEC_STATUS UCODEC_FlushTx (tUCODEC_ID);
293
294/******************************************************************************
295**
296** Function UCODEC_FlushRx
297**
298** Description Fluch Rx buffer Q.
299**
300** Input : CodecId: Id of the codec to perform the operation on.
301**
302** Output Parameters : None
303**
304** Returns UCODEC_SUCCESS if The action was performed with sucess.
305** Error code else.
306**
307******************************************************************************/
308BT_API extern tUCODEC_STATUS UCODEC_FlushRx (tUCODEC_ID);
309
310/******************************************************************************
311**
312** Function UCODEC_WriteBuf
313**
314** Description Send a buffer to the codec.
315**
316** Input : CodecId: Id of the codec to perform the operation on.
317** pBuf: Pointer onto the GKI buffer to be send to the CODEC.
318**
319** Output Parameters : None
320**
321** Returns UCODEC_SUCCESS if The action was performed with sucess.
322** UCODEC_FLOW_CTRL_ON if The codec buffer Q had reach a UCODEC_HIGH_WM
323** watermark. The buffer is queued
324** UCODEC_OVERFLOW if The codec buffer Q had reach a critical
325** watermark. The buffer is dropped.
326**
327******************************************************************************/
328BT_API extern tUCODEC_STATUS UCODEC_WriteBuf (tUCODEC_ID, BT_HDR *);
329
330/******************************************************************************
331**
332** Function UCODEC_ReadBuf
333**
334** Description Get a buffer from the codec.
335**
336** Input : CodecId: Id of the codec to perform the operation on.
337**
338** Output Parameters : None
339**
340** Returns Pointer on the GKI buffer. NULL if the Rx Q is empty
341**
342******************************************************************************/
343BT_API extern tUCODEC_STATUS UCODEC_ReadBuf (tUCODEC_ID, BT_HDR **, tUCODEC_BUF_INFO *);
344
345/******************************************************************************
346**
347** Function UCODEC_Close
348**
349** Description This function is called to put the codec in low power mode
350**
351**
352** Input : CodecId: Id of the codec to perform the operation on.
353**
354** Output Parameters : None
355**
356** Returns UCODEC_SUCCESS : The action was performed with sucess.
357** Error code else.
358**
359******************************************************************************/
360BT_API extern tUCODEC_STATUS UCODEC_Close (tUCODEC_ID);
361
362/******************************************************************************
363**
364** Function UCODEC_Open
365**
366** Description This function is called to resume the codec from low power
367** mode after UCODEC_Close had been called. It will put the
368** codec in the state it was before UCODEC_Close being called.
369**
370** Input : CodecId: Id of the codec to perform the operation on.
371**
372** Output Parameters : None
373**
374** Returns UCODEC_SUCCESS : The action was performed with sucess.
375** Error code else.
376**
377******************************************************************************/
378BT_API extern tUCODEC_STATUS UCODEC_Open (tUCODEC_ID);
379
380#ifdef __cplusplus
381};
382#endif
383
384
385#endif /* UCODEC_H */