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