1/*
2 * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef __HI_COMM_AIO_H__
17#define __HI_COMM_AIO_H__
18
19#include "hi_common.h"
20#include "hi_errno.h"
21
22#ifdef __cplusplus
23#if __cplusplus
24extern "C" {
25#endif
26#endif /* End of #ifdef __cplusplus */
27
28
29#define MAX_AUDIO_FRAME_NUM    300      /* max count of audio frame in Buffer */
30#define MAX_AUDIO_POINT_BYTES  4        /* max bytes of one sample point(now 32bit max) */
31
32#define MAX_VOICE_POINT_NUM    480      /* max sample per frame for voice encode */
33
34#define MAX_AUDIO_POINT_NUM    2048     /* max sample per frame for all encoder(aacplus:2048) */
35#define MAX_AO_POINT_NUM       4096     /* from h3;support 4096 framelen */
36#define MIN_AUDIO_POINT_NUM    80       /* min sample per frame */
37#define MAX_AI_POINT_NUM       2048     /* max sample per frame for all encoder(aacplus:2048) */
38
39/* max length of audio frame by bytes, one frame contain many sample point */
40#define MAX_AUDIO_FRAME_LEN    (MAX_AUDIO_POINT_BYTES*MAX_AO_POINT_NUM)
41
42/* max length of audio stream by bytes */
43#define MAX_AUDIO_STREAM_LEN   MAX_AUDIO_FRAME_LEN
44
45#define MAX_AI_USRFRM_DEPTH     30      /* max depth of user frame buf */
46
47#define MAX_AUDIO_FILE_PATH_LEN 256
48#define MAX_AUDIO_FILE_NAME_LEN 256
49
50/* The VQE EQ Band num. */
51#define VQE_EQ_BAND_NUM  10
52#define VQE_DRC_SECNUM 5
53
54/* The VQE AEC Band num. */
55#define AEC_ERL_BAND_NUM       6
56#define AEC_ERL_BAND_VALUE_NUM 7
57
58/* The TalkVQEV2 EQ Band num. */
59#define TALKVQEV2_EQ_BAND_NUM   30
60
61#define AI_TALKVQEV2_MASK_PNR       0x1
62#define AI_TALKVQEV2_MASK_NR        0x2
63#define AI_TALKVQEV2_MASK_EQ        0x4
64#define AI_TALKVQEV2_MASK_AGC       0x8
65#define AI_TALKVQEV2_MASK_DRC       0x10
66#define AI_TALKVQEV2_MASK_LIMITER   0x20
67#define AI_TALKVQEV2_MASK_DEREVERB  0x40
68#define AI_TALKVQEV2_MASK_FMP       0x80
69#define AI_TALKVQEV2_MASK_WNR       0x100
70
71#define AI_RECORDVQE_MASK_HPF       0x1
72#define AI_RECORDVQE_MASK_RNR       0x2
73#define AI_RECORDVQE_MASK_HDR       0x4
74#define AI_RECORDVQE_MASK_DRC       0x8
75#define AI_RECORDVQE_MASK_EQ        0x10
76#define AI_RECORDVQE_MASK_AGC       0x20
77
78#define AI_TALKVQE_MASK_HPF     0x1
79#define AI_TALKVQE_MASK_AEC     0x2
80#define AI_TALKVQE_MASK_AGC     0x8
81#define AI_TALKVQE_MASK_EQ      0x10
82#define AI_TALKVQE_MASK_ANR     0x20
83
84#define AO_VQE_MASK_HPF         0x1
85#define AO_VQE_MASK_ANR         0x2
86#define AO_VQE_MASK_AGC         0x4
87#define AO_VQE_MASK_EQ          0x8
88
89
90typedef enum hiAUDIO_SAMPLE_RATE_E {
91    AUDIO_SAMPLE_RATE_8000   = 8000,    /* 8K samplerate */
92    AUDIO_SAMPLE_RATE_12000  = 12000,   /* 12K samplerate */
93    AUDIO_SAMPLE_RATE_11025  = 11025,   /* 11.025K samplerate */
94    AUDIO_SAMPLE_RATE_16000  = 16000,   /* 16K samplerate */
95    AUDIO_SAMPLE_RATE_22050  = 22050,   /* 22.050K samplerate */
96    AUDIO_SAMPLE_RATE_24000  = 24000,   /* 24K samplerate */
97    AUDIO_SAMPLE_RATE_32000  = 32000,   /* 32K samplerate */
98    AUDIO_SAMPLE_RATE_44100  = 44100,   /* 44.1K samplerate */
99    AUDIO_SAMPLE_RATE_48000  = 48000,   /* 48K samplerate */
100    AUDIO_SAMPLE_RATE_64000  = 64000,   /* 64K samplerate */
101    AUDIO_SAMPLE_RATE_96000  = 96000,   /* 96K samplerate */
102    AUDIO_SAMPLE_RATE_BUTT,
103} AUDIO_SAMPLE_RATE_E;
104
105typedef enum hiAUDIO_BIT_WIDTH_E {
106    AUDIO_BIT_WIDTH_8   = 0,   /* 8bit width */
107    AUDIO_BIT_WIDTH_16  = 1,   /* 16bit width */
108    AUDIO_BIT_WIDTH_24  = 2,   /* 24bit width */
109    AUDIO_BIT_WIDTH_BUTT,
110} AUDIO_BIT_WIDTH_E;
111
112typedef enum hiAIO_MODE_E {
113    AIO_MODE_I2S_MASTER  = 0,   /* AIO I2S master mode */
114    AIO_MODE_I2S_SLAVE,         /* AIO I2S slave mode */
115    AIO_MODE_PCM_SLAVE_STD,     /* AIO PCM slave standard mode */
116    AIO_MODE_PCM_SLAVE_NSTD,    /* AIO PCM slave non-standard mode */
117    AIO_MODE_PCM_MASTER_STD,    /* AIO PCM master standard mode */
118    AIO_MODE_PCM_MASTER_NSTD,   /* AIO PCM master non-standard mode */
119    AIO_MODE_BUTT
120} AIO_MODE_E;
121
122typedef enum {
123    AIO_I2STYPE_INNERCODEC = 0, /* AIO I2S connect inner audio CODEC */
124    AIO_I2STYPE_INNERHDMI,      /* AIO I2S connect Inner HDMI */
125    AIO_I2STYPE_EXTERN,         /* AIO I2S connect extern hardware */
126} AIO_I2STYPE_E;
127
128typedef enum hiAIO_SOUND_MODE_E {
129    AUDIO_SOUND_MODE_MONO   = 0, /* mono */
130    AUDIO_SOUND_MODE_STEREO = 1, /* stereo */
131    AUDIO_SOUND_MODE_BUTT
132} AUDIO_SOUND_MODE_E;
133
134/*
135An example of the packing scheme for G726-32 codewords is as shown,
136and bit A3 is the least significant bit of the first codeword:
137RTP G726-32:
1380                   1
1390 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
140+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
141|B B B B|A A A A|D D D D|C C C C| ...
142|0 1 2 3|0 1 2 3|0 1 2 3|0 1 2 3|
143+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
144
145MEDIA G726-32:
1460 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
147+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
148|A A A A|B B B B|C C C C|D D D D| ...
149|3 2 1 0|3 2 1 0|3 2 1 0|3 2 1 0|
150+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
151*/
152typedef enum hiG726_BPS_E {
153    G726_16K = 0,       /* G726 16kbps, see RFC3551.txt  4.5.4 G726-16 */
154    G726_24K,           /* G726 24kbps, see RFC3551.txt  4.5.4 G726-24 */
155    G726_32K,           /* G726 32kbps, see RFC3551.txt  4.5.4 G726-32 */
156    G726_40K,           /* G726 40kbps, see RFC3551.txt  4.5.4 G726-40 */
157    MEDIA_G726_16K,     /* G726 16kbps for ASF ... */
158    MEDIA_G726_24K,     /* G726 24kbps for ASF ... */
159    MEDIA_G726_32K,     /* G726 32kbps for ASF ... */
160    MEDIA_G726_40K,     /* G726 40kbps for ASF ... */
161    G726_BUTT,
162} G726_BPS_E;
163
164typedef enum hiADPCM_TYPE_E {
165    /* see DVI4 diiffers in three respects from the IMA ADPCM at RFC3551.txt 4.5.1 DVI4 */
166    ADPCM_TYPE_DVI4 = 0,    /* 32kbps ADPCM(DVI4) for RTP */
167    ADPCM_TYPE_IMA,         /* 32kbps ADPCM(IMA),NOTICE:point num must be 161/241/321/481 */
168    ADPCM_TYPE_ORG_DVI4,
169    ADPCM_TYPE_BUTT,
170} ADPCM_TYPE_E;
171
172#define AI_EXPAND  0x01
173#define AI_CUT     0x02
174
175typedef struct hiAIO_ATTR_S {
176    AUDIO_SAMPLE_RATE_E enSamplerate;   /* sample rate */
177    AUDIO_BIT_WIDTH_E   enBitwidth;     /* bitwidth */
178    AIO_MODE_E          enWorkmode;     /* master or slave mode */
179    AUDIO_SOUND_MODE_E  enSoundmode;    /* momo or steror */
180    HI_U32              u32EXFlag;      /* expand 8bit to 16bit, use AI_EXPAND(only valid for AI 8bit),
181                                           use AI_CUT(only valid for extern Codec for 24bit) */
182    HI_U32              u32FrmNum;      /* frame num in buf[2,MAX_AUDIO_FRAME_NUM] */
183    HI_U32              u32PtNumPerFrm; /* point num per frame (80/160/240/320/480/1024/2048)
184                                           (ADPCM IMA should add 1 point, AMR only support 160) */
185    HI_U32              u32ChnCnt;      /* channle number on FS, valid value:1/2/4/8 */
186    HI_U32              u32ClkSel;      /* 0: AI and AO clock is separate
187                                           1: AI and AO clock is inseparate, AI use AO's clock */
188    AIO_I2STYPE_E       enI2sType;      /* i2s type */
189} AIO_ATTR_S;
190
191typedef struct hiAI_CHN_PARAM_S {
192    HI_U32 u32UsrFrmDepth;
193} AI_CHN_PARAM_S;
194
195typedef enum hiAI_CHN_MODE_E {
196    AI_CHN_MODE_NORMAL = 0,     /* normal mode for AI chn */
197    AI_CHN_MODE_FAST,           /* fast mode for AI chn */
198    AI_CHN_MODE_BUTT,
199} AI_CHN_MODE_E;
200
201typedef struct hiAI_CHN_ATTR_S {
202    AI_CHN_MODE_E enMode;       /* operating mode */
203} AI_CHN_ATTR_S;
204
205typedef struct hiAUDIO_FRAME_S {
206    AUDIO_BIT_WIDTH_E   enBitwidth;     /* audio frame bitwidth */
207    AUDIO_SOUND_MODE_E  enSoundmode;    /* audio frame momo or stereo mode */
208    HI_U8  *u64VirAddr[2];              /* 2: 2chn */
209    HI_U64  u64PhyAddr[2];              /* 2: 2chn */
210    HI_U64  u64TimeStamp;               /* audio frame timestamp */
211    HI_U32  u32Seq;                     /* audio frame seq */
212    HI_U32  u32Len;                     /* data length per channel in frame */
213    HI_U32  u32PoolId[2];               /* 2: 2chn */
214} AUDIO_FRAME_S;
215
216typedef struct hiAEC_FRAME_S {
217    AUDIO_FRAME_S   stRefFrame;    /* AEC reference audio frame */
218    HI_BOOL         bValid;        /* whether frame is valid */
219    HI_BOOL         bSysBind;      /* whether is sysbind */
220} AEC_FRAME_S;
221
222
223typedef struct hiAUDIO_FRAME_INFO_S {
224    AUDIO_FRAME_S *pstFrame; /* frame ptr */
225    HI_U32         u32Id;   /* frame id */
226} AUDIO_FRAME_INFO_S;
227
228typedef struct hiAUDIO_STREAM_S {
229    HI_U8 ATTRIBUTE *pStream;         /* the virtual address of stream */
230    HI_U64 ATTRIBUTE u64PhyAddr;      /* the physics address of stream */
231    HI_U32 u32Len;          /* stream length, by bytes */
232    HI_U64 u64TimeStamp;    /* frame time stamp */
233    HI_U32 u32Seq;          /* frame seq, if stream is not a valid frame,u32Seq is 0 */
234} AUDIO_STREAM_S;
235
236
237typedef struct hiAO_CHN_STATE_S {
238    HI_U32                  u32ChnTotalNum;    /* total number of channel buffer */
239    HI_U32                  u32ChnFreeNum;     /* free number of channel buffer */
240    HI_U32                  u32ChnBusyNum;     /* busy number of channel buffer */
241} AO_CHN_STATE_S;
242
243typedef enum hiAUDIO_TRACK_MODE_E {
244    AUDIO_TRACK_NORMAL      = 0,
245    AUDIO_TRACK_BOTH_LEFT   = 1,
246    AUDIO_TRACK_BOTH_RIGHT  = 2,
247    AUDIO_TRACK_EXCHANGE    = 3,
248    AUDIO_TRACK_MIX         = 4,
249    AUDIO_TRACK_LEFT_MUTE   = 5,
250    AUDIO_TRACK_RIGHT_MUTE  = 6,
251    AUDIO_TRACK_BOTH_MUTE   = 7,
252
253    AUDIO_TRACK_BUTT
254} AUDIO_TRACK_MODE_E;
255
256
257typedef enum hiAUDIO_FADE_RATE_E {
258    AUDIO_FADE_RATE_1   = 0,
259    AUDIO_FADE_RATE_2   = 1,
260    AUDIO_FADE_RATE_4   = 2,
261    AUDIO_FADE_RATE_8   = 3,
262    AUDIO_FADE_RATE_16  = 4,
263    AUDIO_FADE_RATE_32  = 5,
264    AUDIO_FADE_RATE_64  = 6,
265    AUDIO_FADE_RATE_128 = 7,
266
267    AUDIO_FADE_RATE_BUTT
268} AUDIO_FADE_RATE_E;
269
270typedef struct hiAUDIO_FADE_S {
271    HI_BOOL         bFade;
272    AUDIO_FADE_RATE_E enFadeInRate;
273    AUDIO_FADE_RATE_E enFadeOutRate;
274} AUDIO_FADE_S;
275
276/* Defines the configure parameters of AEC. */
277typedef struct hiAI_AEC_CONFIG_S {
278    HI_BOOL bUsrMode;               /* mode 0: auto mode 1: mannual. */
279    HI_S8 s8CngMode;                /* cozy noisy mode: 0 close, 1 open, recommend 1 */
280    HI_S8 s8NearAllPassEnergy;      /* the far-end energy threshold for judging whether unvarnished transmission:
281                                       0 -59dBm0, 1 -49dBm0, 2 -39dBm0, recommend 1 */
282    HI_S8 s8NearCleanSupEnergy;     /* the energy threshold for compelling reset of near-end signal:
283                                       0 12dB, 1 15dB, 2 18dB, recommend 2 */
284
285    HI_S16 s16DTHnlSortQTh;         /* the threshold of judging single or double talk, recommend 16384, [0, 32767] */
286
287    HI_S16 s16EchoBandLow;          /* voice processing band1, low frequency parameter,
288                                       [1, 63) for 8k, [1, 127) for 16k, recommend 10 */
289    HI_S16 s16EchoBandHigh;         /* voice processing band1, high frequency parameter, (s16EchoBandLow, 63] for 8k,
290                                       (s16EchoBandLow, 127] for 16k, recommend 41,
291                                       s16EchoBandHigh must be greater than s16EchoBandLow */
292    HI_S16 s16EchoBandLow2;         /* voice processing band2, low frequency parameter,
293                                       [1, 63) for 8k, [1, 127) for 16k, recommend 47 */
294    HI_S16 s16EchoBandHigh2;        /* voice processing band2, high frequency parameter,
295                                       (s16EchoBandLow2, 63] for 8k, (s16EchoBandLow2, 127] for 16k,
296                                       recommend 72, s16EchoBandHigh2 must be greater than s16EchoBandLow2 */
297
298    HI_S16 s16ERLBand[AEC_ERL_BAND_NUM];    /* ERL protect area, [1, 63] for 8k, [1, 127] for 16k,
299                                               frequency band calculated by s16ERLBand * 62.5,
300                                               besides, s16ERLBand[n+1] should be greater than s16ERLBand[n] */
301    HI_S16 s16ERL[AEC_ERL_BAND_VALUE_NUM];  /* ERL protect value of ERL protect area,
302                                               the smaller its value, the more strength its protect ability,[0, 18] */
303    HI_S16 s16VioceProtectFreqL;    /* protect area of near-end low frequency,
304                                       [1, 63) for 8k, [1, 127) for 16k, recommend 3 */
305    HI_S16 s16VioceProtectFreqL1;   /* protect area of near-end low frequency1, (s16VioceProtectFreqL, 63] for 8k,
306                                       (s16VioceProtectFreqL, 127] for 16k, recommend 6 */
307    HI_S32 s32Reserved;             /* s16VioceProtectFreqL1 must be greater than s16VioceProtectFreqL */
308} AI_AEC_CONFIG_S;
309
310/* Defines the configure parameters of ANR. */
311typedef struct hiAUDIO_ANR_CONFIG_S {
312    HI_BOOL bUsrMode;   /* mode 0: auto, mode 1: manual. */
313
314    HI_S16 s16NrIntensity;       /* noise reduce intensity, range: [0, 25] */
315    HI_S16 s16NoiseDbThr;        /* noise threshold, range: [30, 60] */
316    HI_S8  s8SpProSwitch;        /* switch for music probe, range: [0:close, 1:open] */
317
318    HI_S32 s32Reserved;
319} AUDIO_ANR_CONFIG_S;
320
321/* Defines the configure parameters of AGC. */
322typedef struct hiAUDIO_AGC_CONFIG_S {
323    HI_BOOL bUsrMode;          /* mode 0: auto, mode 1: manual. */
324
325    HI_S8 s8TargetLevel;       /* target voltage level, range: [-40, -1]dB */
326    HI_S8 s8NoiseFloor;        /* noise floor, range: TalkVqe/AoVqe[-65, -20]dB, RecordVqe[-50, -20]dB */
327    HI_S8 s8MaxGain;           /* max gain, range: [0, 30]dB */
328    HI_S8 s8AdjustSpeed;       /* adjustable speed, range: [0, 10]dB/s */
329
330    HI_S8 s8ImproveSNR;        /* switch for improving SNR, range: [0:close, 1:upper limit 3dB, 2:upper limit 6dB] */
331    HI_S8 s8UseHighPassFilt;   /* switch for using high pass filt,
332    range: [0:close, 1:80Hz, 2:120Hz, 3:150:Hz, 4:300Hz: 5:500Hz] */
333    HI_S8 s8OutputMode;        /* output mode, mute when lower than noise floor, range: [0:close, 1:open] */
334    HI_S16 s16NoiseSupSwitch;  /* switch for noise suppression, range: [0:close, 1:open] */
335
336    HI_S32 s32Reserved;
337} AUDIO_AGC_CONFIG_S;
338
339/* Defines the configure parameters of HPF. */
340typedef enum hiAUDIO_HPF_FREQ_E {
341    AUDIO_HPF_FREQ_80   = 80,    /* 80Hz */
342    AUDIO_HPF_FREQ_120  = 120,   /* 120Hz */
343    AUDIO_HPF_FREQ_150  = 150,   /* 150Hz */
344    AUDIO_HPF_FREQ_BUTT,
345} AUDIO_HPF_FREQ_E;
346
347typedef struct hiAUDIO_HPF_CONFIG_S {
348    HI_BOOL bUsrMode;   /* mode 0: auto mode 1: mannual. */
349    AUDIO_HPF_FREQ_E enHpfFreq; /* freq to be processed, value:HiFiVqe/TalkVqe/AoVqe(80Hz, 120Hz, 150Hz),
350                                   RecordVqe(80Hz) */
351} AUDIO_HPF_CONFIG_S;
352
353typedef struct hiAI_RNR_CONFIG_S {
354    HI_BOOL bUsrMode;                /* mode 0: auto, mode 1: mannual. */
355
356    HI_S32  s32NrMode;               /* mode 0: floor noise; 1:ambient noise */
357
358    HI_S32 s32MaxNrLevel;            /* max NR level range:[2,20]dB */
359
360    HI_S32  s32NoiseThresh;          /* noise threshold, range:[-80, -20] */
361} AI_RNR_CONFIG_S;
362
363typedef struct hiAUDIO_EQ_CONFIG_S {
364    HI_S8  s8GaindB[VQE_EQ_BAND_NUM];   /* EQ band, include 100, 200, 250, 350, 500, 800, 1.2k, 2.5k, 4k, 8k in turn,
365                                        range:TalkVqe/AoVqe[-100, 20], RecordVqe[-50, 20] */
366    HI_S32 s32Reserved;
367} AUDIO_EQ_CONFIG_S;
368
369
370/* Defines the configure parameters of UPVQE work state. */
371typedef enum hiVQE_WORKSTATE_E {
372    VQE_WORKSTATE_COMMON  = 0,   /* common environment, Applicable to the family of voice calls. */
373    VQE_WORKSTATE_MUSIC   = 1,   /* music environment , Applicable to the family of music environment. */
374    VQE_WORKSTATE_NOISY   = 2,   /* noisy environment , Applicable to the noisy voice calls.  */
375} VQE_WORKSTATE_E;
376
377/* Defines record type */
378typedef enum hiVQE_RECORD_TYPE {
379    VQE_RECORD_NORMAL        = 0,  /* <double micphone recording. */
380    VQE_RECORD_BUTT,
381} VQE_RECORD_TYPE;
382
383
384/* HDR Set CODEC GAIN Function Handle type */
385typedef HI_S32 (*pFuncGainCallBack)(HI_S32 s32SetGain);
386
387typedef struct hiAI_HDR_CONFIG_S {
388    HI_BOOL bUsrMode;               /* mode 0: auto mode 1: mannual. */
389
390    HI_S32 s32MinGaindB;            /* the minimum of MIC(AI) CODEC gain, [0, 120] */
391    HI_S32 s32MaxGaindB;            /* the maximum of MIC(AI) CODEC gain, [0, 120] */
392
393    HI_S32 s32MicGaindB;            /* the current gain of MIC(AI) CODEC,[s32MinGaindB, s32MaxGaindB] */
394    HI_S32 s32MicGainStepdB;        /* the step size of gain adjustment, [1, 3], recommemd 2 */
395    pFuncGainCallBack pcallback;    /* the callback function pointer of CODEC gain adjustment */
396} AI_HDR_CONFIG_S;
397
398typedef struct hiAI_DRC_CONFIG_S {
399    HI_BOOL bUsrMode;   /* enable user mode or not,default 0: disable user mode,1: user mode. */
400
401    HI_S16  s16AttackTime;   /* time of signal change from large to small (ms),
402                                range:HiFiVqe[10, 250]ms, RecordVqe[10, 126]ms */
403    HI_S16  s16ReleaseTime;  /* time of signal change from small to large (ms),
404                                range:HiFiVqe[10, 250]ms, RecordVqe[10, 126]ms */
405
406    HI_S16 s16OldLevDb[VQE_DRC_SECNUM];  /* old curve level(dB), default[0, -472, -792, -960, -1280],
407                                            range:[-1440, 0]ms,store from big to small,scale:Q4 */
408    HI_S16 s16NewLevDb[VQE_DRC_SECNUM];  /* new curve level(dB), default[0, -174, -410, -608, -1021],
409                                            range:[-1440, 0]ms, store from big to small,scale:Q4 */
410} AI_DRC_CONFIG_S;
411
412typedef struct hiAI_TALKV2_EQ_CONFIG_S {
413    HI_BOOL bUsrMode;                       /* mode 0: auto, mode 1: mannual. */
414
415    HI_S8  s8GaindB[TALKVQEV2_EQ_BAND_NUM]; /* EQ band, range:[-50, 20]dB */
416} AI_TALKV2_EQ_CONFIG_S;
417
418typedef struct hiAI_TALKV2_PNR_CONFIG_S {
419    HI_BOOL bUsrMode;           /* mode 0: auto, mode 1: mannual. */
420
421    HI_S16 s16MinGainLimit;     /* maximum allowable noise rejection, default:5827, range:[0, 32767] */
422    HI_S16 s16SnrPriorLimit;    /* minimum prior signal-to-noise ratio, default:3276, range:[0, 32767] */
423    HI_S16 s16HtThreshold;      /* voice decision threshold, default:10, range:[0, 80] */
424    HI_S16 s16HsThreshold;      /* harmonic detection threshold, default:100, range:[100, 1100] */
425    HI_S16 s16AlphaPh;          /* speech probability smoothing coefficient, default:90, range:[0, 100] */
426    HI_S16 s16AlphaPsd;         /* noise estimation smoothing factor, default:65, range:[0, 100] */
427    HI_S16 s16PriorSnrFixed;    /* fixed prior signal-to-noise ratio, default:30, range:[1, 499] */
428    HI_S16 s16CepThreshold;     /* cepstrum smooth speech threshold, default:16, range:[0, 100] */
429    HI_S16 s16SpeechProtectThreshold;   /* speech protect threshold, default:90, range:[0, 100] */
430    HI_S16 s16HemEnable;        /* harmonic enhancement enable, default:1, range:[0, 1] */
431    HI_S16 s16TcsEnable;        /* cepstral smoothing switch, default:0, range:[0, 1] */
432
433    HI_S16 s16Reserved[3];      /* 3: reserved */
434} AI_TALKV2_PNR_CONFIG_S;
435
436typedef struct hiAI_TALKV2_NR_CONFIG_S {
437    HI_BOOL bUsrMode;           /* mode 0: auto, mode 1: mannual. */
438
439    HI_S16 s16MinGainLimit;     /* maximum allowable noise rejection, default:3276, range:[0, 32767] */
440    HI_S16 s16SnrPriorLimit;    /* minimum prior signal-to-noise ratio, default:327, range:[0, 32767] */
441    HI_S16 s16HtThreshold;      /* voice decision threshold, default:10, range:[0, 80] */
442    HI_S16 s16HsThreshold;      /* harmonic detection threshold, default:100, range:[100, 1100] */
443    HI_S16 s16PriNoiseEstiMode; /* single mic noise estimation algorithm mode, default:0, range:[0, 2] */
444    HI_S16 s16PriorSnrFixed;    /* fixed prior signal-to-noise ratio, default:20, range:[1, 499] */
445    HI_S16 s16PrioSnrThreshold; /* instantaneous prior snr, default:7, range:[5, 20] */
446    HI_S16 s16SmPrioSnrThreshold; /* smooth prior snr, default:10, range:[8, 30] */
447
448    HI_S16 s16Reserved[16];     /* 16: reserved */
449} AI_TALKV2_NR_CONFIG_S;
450
451typedef struct hiAI_TALKV2_AGC_CONFIG_S {
452    HI_BOOL bUsrMode;           /* mode 0: auto, mode 1: mannual. */
453
454    HI_S8 s8TargetLevel;        /* target level, default:-16, range:[-120, 120] */
455    HI_U8 u8MaxGain;            /* maximum gain, default:80, range:[0, 240] */
456    HI_S8 s8MinGain;            /* minimum gain, default:-60, range:[-120, 0] */
457    HI_S8 s8AdjustSpeed;        /* adjustable speed, default:5, range: [1, 10] */
458
459    HI_S16 s16Reserved[3];      /* 3: reserved */
460} AI_TALKV2_AGC_CONFIG_S;
461
462typedef struct hiAI_TALKV2_WNR_CONFIG_S {
463    HI_S8 s8Reserved[6];        /* 6: reserved */
464} AI_TALKV2_WNR_CONFIG_S;
465
466/* Defines the configure parameters of TalkV2 VQE. */
467typedef struct hiAI_TALKVQEV2_CONFIG_S {
468    HI_U32            u32OpenMask;
469
470    HI_S32            s32WorkSampleRate;    /* sample rate:16kHz */
471    HI_S32            s32FrameSample;       /* VQE frame length:80-4096 */
472    VQE_WORKSTATE_E   enWorkstate;
473
474    HI_S32            s32InChNum;
475    HI_S32            s32OutChNum;
476
477    AI_TALKV2_PNR_CONFIG_S  stPnrCfg;
478    AI_TALKV2_NR_CONFIG_S   stNrCfg;
479    AI_TALKV2_EQ_CONFIG_S   stEqCfg;
480    AI_TALKV2_AGC_CONFIG_S  stAgcCfg;
481
482    HI_BOOL bReserved0;
483    HI_S16  s16Reserved1[19];   /* 19: reserved */
484    HI_U8   u8Reserved2[8];     /* 8: reserved */
485
486    AI_TALKV2_WNR_CONFIG_S  stWnrCfg;
487} AI_TALKVQEV2_CONFIG_S;
488
489/* Defines the configure parameters of Record VQE. */
490typedef struct hiAI_RECORDVQE_CONFIG_S {
491    HI_U32              u32OpenMask;
492
493    HI_S32              s32WorkSampleRate;  /* Sample Rate:16KHz/48KHz */
494    HI_S32              s32FrameSample; /* VQE frame length:80-4096 */
495    VQE_WORKSTATE_E     enWorkstate;
496
497    HI_S32                s32InChNum;
498    HI_S32                s32OutChNum;
499    VQE_RECORD_TYPE       enRecordType;
500
501    AUDIO_HPF_CONFIG_S  stHpfCfg;
502    AI_RNR_CONFIG_S     stRnrCfg;
503    AI_HDR_CONFIG_S     stHdrCfg;
504    AI_DRC_CONFIG_S     stDrcCfg;
505    AUDIO_EQ_CONFIG_S   stEqCfg;
506    AUDIO_AGC_CONFIG_S  stAgcCfg;
507} AI_RECORDVQE_CONFIG_S;
508
509/* Defines the configure parameters of Talk VQE. */
510typedef struct hiAI_TALKVQE_CONFIG_S {
511    HI_U32              u32OpenMask;
512
513    HI_S32              s32WorkSampleRate;  /* Sample Rate: 8KHz/16KHz. default: 8KHz */
514    HI_S32              s32FrameSample; /* VQE frame length: 80-4096 */
515    VQE_WORKSTATE_E     enWorkstate;
516
517    AUDIO_HPF_CONFIG_S  stHpfCfg;
518    AI_AEC_CONFIG_S     stAecCfg;
519    AUDIO_ANR_CONFIG_S  stAnrCfg;
520    AUDIO_AGC_CONFIG_S  stAgcCfg;
521    AUDIO_EQ_CONFIG_S   stEqCfg;
522} AI_TALKVQE_CONFIG_S;
523
524typedef struct hiAO_VQE_CONFIG_S {
525    HI_U32              u32OpenMask;
526
527    HI_S32              s32WorkSampleRate;  /* Sample Rate: 8KHz/16KHz/48KHz. default: 8KHz */
528    HI_S32              s32FrameSample; /* VQE frame length: 80-4096 */
529    VQE_WORKSTATE_E     enWorkstate;
530
531    AUDIO_HPF_CONFIG_S stHpfCfg;
532    AUDIO_ANR_CONFIG_S stAnrCfg;
533    AUDIO_AGC_CONFIG_S stAgcCfg;
534    AUDIO_EQ_CONFIG_S  stEqCfg;
535} AO_VQE_CONFIG_S;
536
537/* Defines the module register configure of VQE. */
538typedef struct hiVQE_MODULE_CONFIG_S {
539    HI_VOID *pHandle;
540} VQE_MODULE_CONFIG_S;
541
542typedef struct hiAUDIO_VQE_REGISTER_S {
543    VQE_MODULE_CONFIG_S stResModCfg;
544    VQE_MODULE_CONFIG_S stHpfModCfg;
545    VQE_MODULE_CONFIG_S stHdrModCfg;
546    VQE_MODULE_CONFIG_S stGainModCfg;
547
548    // Record VQE
549    VQE_MODULE_CONFIG_S stRecordModCfg;
550
551    // Talk VQE
552    VQE_MODULE_CONFIG_S stAecModCfg;
553    VQE_MODULE_CONFIG_S stAnrModCfg;
554    VQE_MODULE_CONFIG_S stAgcModCfg;
555    VQE_MODULE_CONFIG_S stEqModCfg;
556
557    // HiFi VQE
558    VQE_MODULE_CONFIG_S stRnrModCfg;
559    VQE_MODULE_CONFIG_S stDrcModCfg;
560    VQE_MODULE_CONFIG_S stPeqModCfg;
561
562    /* TalkV2 VQE */
563    VQE_MODULE_CONFIG_S stTalkV2ModCfg;
564    VQE_MODULE_CONFIG_S stWnrModCfg;
565} AUDIO_VQE_REGISTER_S;
566
567/* Defines the configure parameters of AI saving file. */
568typedef struct hiAUDIO_SAVE_FILE_INFO_S {
569    HI_BOOL     bCfg;
570    HI_CHAR     aFilePath[MAX_AUDIO_FILE_PATH_LEN];
571    HI_CHAR     aFileName[MAX_AUDIO_FILE_NAME_LEN];
572    HI_U32      u32FileSize;  /* in KB */
573} AUDIO_SAVE_FILE_INFO_S;
574
575/* Defines whether the file is saving or not . */
576typedef struct hiAUDIO_FILE_STATUS_S {
577    HI_BOOL     bSaving;
578} AUDIO_FILE_STATUS_S;
579
580/* Defines audio clksel type */
581typedef enum hiAUDIO_CLKSEL_E {
582    AUDIO_CLKSEL_BASE       = 0,  /* <Audio base clk. */
583    AUDIO_CLKSEL_SPARE,           /* <Audio spare clk. */
584
585    AUDIO_CLKSEL_BUTT,
586} AUDIO_CLKSEL_E;
587
588/* Defines audio mode parameter. */
589typedef struct hiAUDIO_MOD_PARAM_S {
590    AUDIO_CLKSEL_E enClkSel;
591} AUDIO_MOD_PARAM_S;
592
593
594typedef enum hiEN_AIO_ERR_CODE_E {
595    AIO_ERR_VQE_ERR        = 65, /* vqe error */
596} EN_AIO_ERR_CODE_E;
597
598/* at lease one parameter is illagal ,eg, an illegal enumeration value  */
599#define HI_ERR_AIO_ILLEGAL_PARAM     HI_DEF_ERR(HI_ID_AIO, EN_ERR_LEVEL_ERROR, EN_ERR_ILLEGAL_PARAM)
600/* using a NULL point */
601#define HI_ERR_AIO_NULL_PTR          HI_DEF_ERR(HI_ID_AIO, EN_ERR_LEVEL_ERROR, EN_ERR_NULL_PTR)
602/* operation is not supported by NOW */
603#define HI_ERR_AIO_NOT_PERM          HI_DEF_ERR(HI_ID_AIO, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_PERM)
604/* system is not ready, had not initialed or loaded */
605#define HI_ERR_AIO_SYS_NOTREADY      HI_DEF_ERR(HI_ID_AIO, EN_ERR_LEVEL_ERROR, EN_ERR_SYS_NOTREADY)
606/* aio is working */
607#define HI_ERR_AIO_BUSY              HI_DEF_ERR(HI_ID_AIO, EN_ERR_LEVEL_ERROR, EN_ERR_BUSY)
608/* vqe err */
609#define HI_ERR_AIO_REGISTER_ERR      HI_DEF_ERR(HI_ID_AIO, EN_ERR_LEVEL_ERROR, AIO_ERR_VQE_ERR)
610
611/* invalid device ID */
612#define HI_ERR_AI_INVALID_DEVID     HI_DEF_ERR(HI_ID_AI, EN_ERR_LEVEL_ERROR, EN_ERR_INVALID_DEVID)
613/* invalid channel ID */
614#define HI_ERR_AI_INVALID_CHNID     HI_DEF_ERR(HI_ID_AI, EN_ERR_LEVEL_ERROR, EN_ERR_INVALID_CHNID)
615/* at lease one parameter is illagal ,eg, an illegal enumeration value  */
616#define HI_ERR_AI_ILLEGAL_PARAM     HI_DEF_ERR(HI_ID_AI, EN_ERR_LEVEL_ERROR, EN_ERR_ILLEGAL_PARAM)
617/* using a NULL point */
618#define HI_ERR_AI_NULL_PTR          HI_DEF_ERR(HI_ID_AI, EN_ERR_LEVEL_ERROR, EN_ERR_NULL_PTR)
619/* try to enable or initialize system,device or channel, before configing attribute */
620#define HI_ERR_AI_NOT_CONFIG        HI_DEF_ERR(HI_ID_AI, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_CONFIG)
621/* operation is not supported by NOW */
622#define HI_ERR_AI_NOT_SUPPORT       HI_DEF_ERR(HI_ID_AI, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_SUPPORT)
623/* operation is not permitted ,eg, try to change static attribute */
624#define HI_ERR_AI_NOT_PERM          HI_DEF_ERR(HI_ID_AI, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_PERM)
625/* the device is not enabled  */
626#define HI_ERR_AI_NOT_ENABLED       HI_DEF_ERR(HI_ID_AI, EN_ERR_LEVEL_ERROR, EN_ERR_UNEXIST)
627/* failure caused by malloc memory */
628#define HI_ERR_AI_NOMEM             HI_DEF_ERR(HI_ID_AI, EN_ERR_LEVEL_ERROR, EN_ERR_NOMEM)
629/* failure caused by malloc buffer */
630#define HI_ERR_AI_NOBUF             HI_DEF_ERR(HI_ID_AI, EN_ERR_LEVEL_ERROR, EN_ERR_NOBUF)
631/* no data in buffer */
632#define HI_ERR_AI_BUF_EMPTY         HI_DEF_ERR(HI_ID_AI, EN_ERR_LEVEL_ERROR, EN_ERR_BUF_EMPTY)
633/* no buffer for new data */
634#define HI_ERR_AI_BUF_FULL          HI_DEF_ERR(HI_ID_AI, EN_ERR_LEVEL_ERROR, EN_ERR_BUF_FULL)
635/* system is not ready,had not initialed or loaded */
636#define HI_ERR_AI_SYS_NOTREADY      HI_DEF_ERR(HI_ID_AI, EN_ERR_LEVEL_ERROR, EN_ERR_SYS_NOTREADY)
637
638#define HI_ERR_AI_BUSY              HI_DEF_ERR(HI_ID_AI, EN_ERR_LEVEL_ERROR, EN_ERR_BUSY)
639/* vqe  err */
640#define HI_ERR_AI_VQE_ERR       HI_DEF_ERR(HI_ID_AI, EN_ERR_LEVEL_ERROR, AIO_ERR_VQE_ERR)
641
642/* invalid device ID */
643#define HI_ERR_AO_INVALID_DEVID     HI_DEF_ERR(HI_ID_AO, EN_ERR_LEVEL_ERROR, EN_ERR_INVALID_DEVID)
644/* invalid channel ID */
645#define HI_ERR_AO_INVALID_CHNID     HI_DEF_ERR(HI_ID_AO, EN_ERR_LEVEL_ERROR, EN_ERR_INVALID_CHNID)
646/* at lease one parameter is illagal ,eg, an illegal enumeration value  */
647#define HI_ERR_AO_ILLEGAL_PARAM     HI_DEF_ERR(HI_ID_AO, EN_ERR_LEVEL_ERROR, EN_ERR_ILLEGAL_PARAM)
648/* using a NULL point */
649#define HI_ERR_AO_NULL_PTR          HI_DEF_ERR(HI_ID_AO, EN_ERR_LEVEL_ERROR, EN_ERR_NULL_PTR)
650/* try to enable or initialize system,device or channel, before configing attribute */
651#define HI_ERR_AO_NOT_CONFIG        HI_DEF_ERR(HI_ID_AO, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_CONFIG)
652/* operation is not supported by NOW */
653#define HI_ERR_AO_NOT_SUPPORT       HI_DEF_ERR(HI_ID_AO, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_SUPPORT)
654/* operation is not permitted ,eg, try to change static attribute */
655#define HI_ERR_AO_NOT_PERM          HI_DEF_ERR(HI_ID_AO, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_PERM)
656/* the device is not enabled  */
657#define HI_ERR_AO_NOT_ENABLED       HI_DEF_ERR(HI_ID_AO, EN_ERR_LEVEL_ERROR, EN_ERR_UNEXIST)
658/* failure caused by malloc memory */
659#define HI_ERR_AO_NOMEM             HI_DEF_ERR(HI_ID_AO, EN_ERR_LEVEL_ERROR, EN_ERR_NOMEM)
660/* failure caused by malloc buffer */
661#define HI_ERR_AO_NOBUF             HI_DEF_ERR(HI_ID_AO, EN_ERR_LEVEL_ERROR, EN_ERR_NOBUF)
662/* no data in buffer */
663#define HI_ERR_AO_BUF_EMPTY         HI_DEF_ERR(HI_ID_AO, EN_ERR_LEVEL_ERROR, EN_ERR_BUF_EMPTY)
664/* no buffer for new data */
665#define HI_ERR_AO_BUF_FULL          HI_DEF_ERR(HI_ID_AO, EN_ERR_LEVEL_ERROR, EN_ERR_BUF_FULL)
666/* system is not ready,had not initialed or loaded */
667#define HI_ERR_AO_SYS_NOTREADY      HI_DEF_ERR(HI_ID_AO, EN_ERR_LEVEL_ERROR, EN_ERR_SYS_NOTREADY)
668
669#define HI_ERR_AO_BUSY              HI_DEF_ERR(HI_ID_AO, EN_ERR_LEVEL_ERROR, EN_ERR_BUSY)
670/* vqe err */
671#define HI_ERR_AO_VQE_ERR       HI_DEF_ERR(HI_ID_AO, EN_ERR_LEVEL_ERROR, AIO_ERR_VQE_ERR)
672
673
674#ifdef __cplusplus
675#if __cplusplus
676}
677#endif
678#endif /* End of #ifdef __cplusplus */
679
680#endif /* End of #ifndef __HI_COMM_AI_H__ */
681
682