blob: 67cc84d416b52c4f8a94a1853dcd5a18497b616b [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*******************************************************************************
2 * Copyright (C) 2007, ZTE Corporation.
3 *
4 * File Name: Drvs_voiceprocess.h
5 * File Mark:
6 * Description: Provide the interface of using vp
7 * Others:
8 * Version: V0.5
9 * Author: lvwenhua
10 * Date: 2012-06-13
11 * History 1:
12 * Date:
13 * Version:
14 * Author:
15 * Modification:
16 * History 2:
17 ********************************************************************************/
18#ifndef _DRVS_VP_H
19#define _DRVS_VP_H
20
21#include "drvs_i2s.h"
22#include "drvs_tdm.h"
23#include "drvs_volte.h"
24#include "drvs_rpmsg.h"
25#include "NvParam_drv.h"
26
27#define VOICE_TONE_MIXER_FUNCTION
28//#define TEST_WHITE_NOISE
29typedef enum
30{
31 VP_I2S_IDLE = 0,
32 VP_I2S_OPEN,
33 VP_I2S_INUSE,
34 VP_LOOP_ON
35} T_Vp_I2sStatus;
36
37/* Voice process channel selection. */
38typedef enum
39{
40 VP_PATH_HANDSET = 0,
41 VP_PATH_SPEAKER,
42 VP_PATH_HEADSET,
43 VP_PATH_BLUETOOTH,
44 VP_PATH_BLUETOOTH_NO_NR,
45 VP_PATH_HSANDSPK,
46
47 VP_PATH_OFF = 255,
48
49 MAX_VP_PATH = VP_PATH_OFF
50} T_ZDrv_VpPath;
51
52typedef enum
53{
54 VP_VOL_0 = 0,
55 VP_VOL_1,
56 VP_VOL_2,
57 VP_VOL_3,
58 VP_VOL_4,
59 VP_VOL_5,
60 VP_VOL_6,
61 VP_VOL_7,
62 VP_VOL_8,
63 VP_VOL_9,
64 VP_VOL_10,
65 VP_VOL_11,
66
67 MAX_VP_VOL
68} T_ZDrv_VpVol;
69
70typedef enum
71{
72 VP_FS_8000 = 0, ///< 8k sampling rate
73 VP_FS_11025 = 1, ///< 11.025k sampling rate
74 VP_FS_12000 = 2, ///< 12k sampling rate
75 VP_FS_16000 = 3, ///< 16k sampling rate
76 VP_FS_22050 = 4, ///< 22.050k sampling rate
77 VP_FS_24000 = 5, ///< 24k sampling rate
78 VP_FS_32000 = 6, ///< 32k sampling rate
79 VP_FS_44100 = 7, ///< 44.1k sampling rate
80 VP_FS_48000 = 8, ///< 48k sampling rate
81 MAX_VP_FS = 9 ///< Max sampling rate count
82
83} T_ZDrv_VpFs;
84
85typedef enum
86{
87 VP_DTMF_KEY_0 = 0,
88 VP_DTMF_KEY_1,
89 VP_DTMF_KEY_2,
90 VP_DTMF_KEY_3,
91 VP_DTMF_KEY_4,
92 VP_DTMF_KEY_5,
93 VP_DTMF_KEY_6,
94 VP_DTMF_KEY_7,
95 VP_DTMF_KEY_8,
96 VP_DTMF_KEY_9,
97 VP_DTMF_KEY_10, /* * */
98 VP_DTMF_KEY_11, /* # */
99
100 MAX_VP_DTMF_KEY
101} T_ZDrv_VpDtmfKey;
102
103
104//typedef T_ZDrvVolte_Cfg T_ZDrvVp_Cfg
105typedef struct
106{
107 char* pPresetRx;
108 unsigned long PresetLengthRx;
109 char* pPresetTx;
110 unsigned long PresetLengthTx;
111} zDrvVp_NxpParamsTool;
112
113typedef struct
114{
115 char* pPresetRx;
116 unsigned long PresetLengthRx;
117 char* pPresetTx;
118 unsigned long PresetLengthTx;
119} zDrvVp_ParamsTool;
120
121typedef enum
122{
123 VP_VOICE_SOURCE ,
124 VP_AUDIO_SOURCE ,
125 VP_FM_SOURCE ,
126 VP_EXTERN_AUDIO,
127 VP_SOURCE_MAX
128} T_ZDrvVp_SourceType;
129
130/* 0 lowpower;1 sms;2 call standard;3 alarm beep;*/
131typedef enum
132{
133 VP_LOWPOWER_TONE ,
134 VP_SMS_TONE ,
135 VP_CALLSTD_TONE ,
136 VP_ALARM_TONE,
137 VP_CALL_TIME_TONE,
138 VP_0_KEY_TONE,
139 VP_1_KEY_TONE,
140 VP_2_KEY_TONE,
141 VP_3_KEY_TONE,
142 VP_4_KEY_TONE,
143 VP_5_KEY_TONE,
144 VP_6_KEY_TONE,
145 VP_7_KEY_TONE,
146 VP_8_KEY_TONE,
147 VP_9_KEY_TONE,
148 VP_HASH_KEY_TONE, //#
149 VP_ASTERRIX_KEY_TONE, //*
150 VP_RESERVED1_TONE,
151 VP_RESERVED2_TONE,
152 VP_RESERVED3_TONE,
153 VP_RESERVED4_TONE,
154 VP_RESERVED5_TONE,
155 VP_RESERVED6_TONE,
156 VP_TONE_MAX
157} T_ZDrvVp_ToneNum;
158typedef struct _T_HalMixerToneInfo
159{
160 BOOL StartMixer;/*mixer flag TRUE start, FALSE stop;*/
161 BOOL dataIsWb;/* TRUE wb, FALSE nb, for voice mixer;*/
162 UINT32 cur_tone_fcount;/*tone data already processed count*/
163 UINT32 tone_total_size;/*tone data total size,unit 2byte*/
164 UINT32 inter_mixer_fcount;/*inter ,tone_size/data_mixer_oncesize*/
165 UINT32 rem_mixer_count;/*remainder , tone_size%data_mixer_oncesize*/
166 UINT16 *ptdata_mixer;/* tone data array pointer */
167 UINT32 data_mixer_oncesize;/*the size of a data processing, unit 2byte*/
168} T_HalMixerToneInfo;
169
170typedef struct _T_HalAudioLoopTestInfo
171{
172 BOOL startLoopTest;/*audo loop test flag TRUE start, FALSE stop;*/
173 UINT32 fs;/*tone data real frequence*/
174 UINT32 sampFs;/*tone data sample frequence*/
175 UINT8 *ptdata;/* audo loop test data array pointer */
176 UINT32 totalSize;/*tone data total size,unit 2byte*/
177 T_ZDrv_VpVol outpathvol[4];
178
179} T_HalAudioLoopTestInfo;
180typedef struct _T_HalAudioLoopTestPra
181{
182 UINT8 *src;/*tone data frequence*/
183 UINT8 *dest;/*tone data sample frequence*/
184 UINT32 sampfs;
185
186} T_HalAudioLoopTestPra;
xf.lice873192023-11-08 17:10:35 -0800187
xf.lice873192023-11-08 17:10:35 -0800188typedef enum
189{
190 ECALL_ST_INIT = 0,
xf.lif1aed282024-02-06 00:31:51 -0800191 ECALL_ST_OPEN,//1
192 ECALL_ST_START,//2
193 ECALL_ST_IDLE,//3
194 ECALL_ST_RX_IDLE,//4
195 ECALL_ST_TX_IDLE,//5
196 ECALL_ST_INUSE,//6
197 ECALL_ST_RX_INUSE,//7
198 ECALL_ST_TX_INUSE,//8
199 ECALL_ST_STOP,//9
200 ECALL_ST_CLOSE,//10
xf.lice873192023-11-08 17:10:35 -0800201 ECALL_ST_MAX
202} T_Ecall_State;
203
204
205typedef struct
206{
207 T_DrvEcall_Opt opt;
208 ZOSS_TIMER_ID timerId ;
209 ZOSS_SEMAPHORE_ID wrSemaphore;
210 ZOSS_SEMAPHORE_ID rdSemaphore;
211 T_Ecall_State ecallSta;
xf.lif1aed282024-02-06 00:31:51 -0800212 T_Ecall_State ecallRxSta;//two state,idle/inuse
213 T_Ecall_State ecallTxSta;//two state,idle/inuse
xf.lice873192023-11-08 17:10:35 -0800214 unsigned char* rxDataBuf;
215 unsigned char* txDataBuf;
216 int dataBufSize;
217
218} T_Hal_EcallData;
xf.lice873192023-11-08 17:10:35 -0800219
lh9ed821d2023-04-07 01:36:19 -0700220typedef struct
221{
222 //use for vp data process
223 UINT8* pVpTempRxInBuffer; //pVpRxInBuffer
224 UINT8* pVpTempTxInBuffer; //pVpTxInBuffer
225 UINT8* pVpTempRxOutPutBuffer;//pVpRxOutPutBuffer
226 UINT8* pVpTempTxOutPutBuffer;//pVpTxOutPutBuffer
227
228 T_ZDrvI2S_Cfg *pVpI2sCfg; //i2s cfg
229
230 T_ZDrvVp_Cfg vpCfgParam; //s_cfgParam
231
232 T_ZDrvI2s_Params i2sWriteParam; //s_VpI2sWriteParam
233 T_ZDrvI2s_Params i2sReadParam; //s_vpI2sReadParam
234
235 UINT32 frameCount; //s_vpFrameCount
236 UINT32 totalFrameBufSize; //s_vpTotalFrameBufSize
237 UINT32 inOutBufUseSize; //s_inOutBufUseSize
238 UINT32 rxSaveLen; //s_rxSaveLen
239 UINT32 txSaveLen; //s_txSaveLen
240 UINT32 saveLen; //save_len
241
242 UINT8 pcmSlotNum; //s_vpPcmSlotNum
243 UINT8 pcmWbSecDataPosition; //s_vpPcmWbSecDataPosition
244
245 UINT8 volteVpWriteStopFlag;//s_volteVpWriteStopFlag
246 UINT8 volteVpReadStopFlag;//s_volteVpReadStopFlag
247 UINT8 volteVpCfgEnFlag; // s_volteVpCfgEnFlag
248 BOOL firstWriteDataFlag;//s_firstWriteDataFlag
249 BOOL firstReadDataFlag;//s_firstReadDataFlag
250 BOOL i2sIsRstFlag;//s_i2sIsRstFlag
251} T_zDrvVp_SpeechState; // T_zDrvVp_SpeechState
252
253typedef struct
254{
xf.libdd93d52023-05-12 07:10:14 -0700255 UINT8 volteIsWb; //1 g_volteIsWb
256 UINT8 isUseSlicCodec; //2 g_isUseSlicCodec
257 UINT8 g_isUseTdm; //3
lh9ed821d2023-04-07 01:36:19 -0700258//for voice data process
xf.libdd93d52023-05-12 07:10:14 -0700259 UINT8 voiceInGsmTdMode; //4 g_voiceInGsmTdMode
260 UINT8 voiceInVolteMode; //5 g_voiceInVolteMode
lh9ed821d2023-04-07 01:36:19 -0700261
xf.libdd93d52023-05-12 07:10:14 -0700262 BOOL innerI2sIsMaster;//6 arm i2s2 g_innerI2sIsMaster
263 BOOL innerI2sIsI2sMode; //7 g_innerI2sIsI2sMode
264 BOOL vpLoopRuning; //8 g_vpLoopRuning
265 BOOL muteEn; //9 g_vpMuteEn
266 //BOOL nxpIsNormal; //10 g_vpNxpIsNormal
267 BOOL vProcIsNormal; //11 voice processing is normal flag
268 T_Vp_I2sStatus vpI2sStatus; //12 VpI2sStatus
lh9ed821d2023-04-07 01:36:19 -0700269
xf.libdd93d52023-05-12 07:10:14 -0700270 T_ZDrv_VpPath vpPath;//13 VP_PATH_HEADSET;//VP_PATH_SPEAKER; //VP_PATH_HANDSET; g_vpPath
271 T_ZDrv_VpPath vpLoopPath; //14 g_vpLoopPath
272 T_ZDrv_VpVol vpVol; //15 g_vpVol
273 T_ZDrvVoice_MODE voiceMode; //16 g_vpVoiceMode
274 SINT8 vpInitGain; //17 s_vpInitGain
275 T_Audio_NvFlag audio_ctrlFlag;//18 USE 32byte
lh9ed821d2023-04-07 01:36:19 -0700276
xf.libdd93d52023-05-12 07:10:14 -0700277 UINT8 dtmfDirSel;//19
278 UINT32 sample_rate;//20
279 UINT8 useDtmfLoop;//21
280 SINT32 muteCount;//22 mute_count
lh758261d2023-07-13 05:52:04 -0700281 BOOL vpLoopBkRunning;//23
282 BOOL rxMuteEn; //24
xf.liaa4d92f2023-09-13 00:18:58 -0700283 BOOL firstRegZCATFlag; //25
xf.lice873192023-11-08 17:10:35 -0800284 T_Hal_EcallData ecallData;//26
xf.li7ccf8372024-03-07 00:08:02 -0800285 UINT8 voice_nv_update;//27
lh9ed821d2023-04-07 01:36:19 -0700286} T_zDrvVoice_GbVar; //T_zDrvVoice_GbVar
287
288typedef struct
289{
290 //use for store memory address
291 UINT8* pVpRxInBuffer; //s_pVpRxInBuffer
292 UINT8* pVpTxInBuffer; //s_pVpTxInBuffer
293 UINT8* pVpRxOutPutBuffer; //s_pVpRxOutPutBuffer
294 UINT8* pVpTxOutPutBuffer; //s_pVpTxOutPutBuffer
295
296 UINT32 inOutBufSize; //s_inOutBufSize
297
298 T_ZDrvI2S_Cfg *pVpInnerI2sCfg; //s_pVpInnerI2sCfg
299 T_ZDrvI2S_Cfg *pVpExtI2sCfg; //s_pVpExtI2sCfg
300 T_ZDrvI2S_Cfg *pVpExtI2sWbCfg; //s_pVpExtI2sWbCfg
301 T_ZDrvTdm_Cfg *s_pVpTdmCfg;
302 T_ZDrvTdm_Cfg *s_pVpTdmWbCfg;
303 T_ZDrvTdm_Cfg *pVpTdmCfg;
304
305 T_ZDrvRpMsg_Msg pMsg;
306 SINT32 pMsgBuf[2];
307 //SINT32 muteCount;//mute_count
308
309 ZOSS_THREAD_ID vpThread ; //s_VpThread
310 ZOSS_THREAD_ID rcvDtmfThread ; //s_rcvDtmfThread
311 ZOSS_SEMAPHORE_ID vpSemaphore; //s_VpSemaphore
312 ZOSS_SEMAPHORE_ID vpThreadQuitSema;
313
314 ZOSS_THREAD_ID vpLoopThread; //s_VpLoopThread
315 ZOSS_SEMAPHORE_ID vpLoopSemaphore; //s_VpLoopSemaphore
316
317 T_zDrvVp_SpeechState *vpState;
318// T_zDrvVoice_GbVar wrapVpGbVar;
319} T_zDrvVp_State; //T_zDrvVp_State
320
321SINT32 zDrvVp_SetPath(T_ZDrv_VpPath path);
322SINT32 zDrvVp_SetVol(T_ZDrv_VpVol volume);
323SINT32 zDrvVp_SetGain(SINT32 vgain, UINT32 channel);
324/* 0 lowpower;1 sms;2 call standard;3 alarm beep;*/
325SINT32 zDrvVp_ToneMixerStart(T_ZDrvVp_ToneNum toneNum);
326SINT32 zDrvVp_SetMute(UINT32 enable, UINT32 channel);
327SINT32 zDrvVp_RcdOnOff(UINT32 on);
328SINT32 zDrvVp_DtmfTone(UINT32 Num);
329SINT32 zDrvVp_Loop(T_ZDrv_VpPath path);
330SINT32 zDrvVp_RingStart(VOID);
331SINT32 zDrvVp_RingStop(VOID);
332VOID zDrvVp_SetUseSlicFlag(BOOL useSlic);
333SINT32 zDrvVp_NxpSetParam(zDrvVp_NxpParamsTool *NxpParamsTool);
334SINT32 zDrvVp_NxpGetParam(zDrvVp_NxpParamsTool *NxpParamsTool);
335SINT32 zDrvVp_SetFmPath(T_ZDrv_VpPath path, BOOL enable);
336SINT32 zDrvVp_SetParam(zDrvVp_ParamsTool *paramsTool);
337SINT32 zDrvVp_GetParam(zDrvVp_ParamsTool *paramsTool);
338SINT32 zDrvVp_SetNvParam(zDrvVp_ParamsTool *paramsTool);
339SINT32 zDrvVp_GetNvParam(zDrvVp_ParamsTool *paramsTool);
340
341
342#endif