lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <unistd.h> |
| 3 | #include <string.h> |
| 4 | #include <stdlib.h> |
| 5 | |
| 6 | #include <stdint.h> |
| 7 | #include "slic_type.h" |
| 8 | #include "slic_inf.h" |
| 9 | #include <linux/volte_drv.h> |
| 10 | #include <sys/ioctl.h> |
| 11 | #include <fcntl.h> |
| 12 | #include "voice_lib.h" |
| 13 | |
| 14 | typedef struct |
| 15 | { |
| 16 | WORD wToneId; |
| 17 | WORD wCadenceCount; |
| 18 | |
| 19 | WORD wCadence1_rptcnt; |
| 20 | WORD wCadence1_on; |
| 21 | WORD wCadence1_off; |
| 22 | WORD wCadence1_Freq; |
| 23 | WORD wCadence1_2ndFreq; |
| 24 | WORD wCadence1_Amp; |
| 25 | |
| 26 | WORD wCadence2_rptcnt; |
| 27 | WORD wCadence2_on; |
| 28 | WORD wCadence2_off; |
| 29 | WORD wCadence2_Freq; |
| 30 | WORD wCadence2_2ndFreq; |
| 31 | WORD wCadence2_Amp; |
| 32 | |
| 33 | WORD wCadence3_rptcnt; |
| 34 | WORD wCadence3_on; |
| 35 | WORD wCadence3_off; |
| 36 | WORD wCadence3_Freq; |
| 37 | WORD wCadence3_2ndFreq; |
| 38 | WORD wCadence3_Amp; |
| 39 | |
| 40 | WORD wCadence4_rptcnt; |
| 41 | WORD wCadence4_on; |
| 42 | WORD wCadence4_off; |
| 43 | WORD wCadence4_Freq; |
| 44 | WORD wCadence4_2ndFreq; |
| 45 | WORD wCadence4_Amp; |
| 46 | |
| 47 | WORD wDura; |
| 48 | BYTE bRowStatus; |
| 49 | BYTE bReserve; |
| 50 | }TONE_ATTR; |
| 51 | |
| 52 | /*TONE ID*/ |
| 53 | |
| 54 | #define SIGNAL_RING (WORD)0x8100 /* ÕñÁå */ |
| 55 | #define SIGNAL_RING_TWO (WORD)0x8101 /* 2¶ÎÕñÁå */ |
| 56 | #define SIGNAL_RING_THREE (WORD)0x8102 /* 3¶ÎÕñÁå */ |
| 57 | #define SIGNAL_RING_FOUR (WORD)0x8103 /* 4¶ÎÕñÁå */ |
| 58 | #define SIGNAL_RING_LONG (WORD)0x8104 /* ³¤Ê±¼äÕñÁå */ |
| 59 | |
| 60 | #define SIGNAL_TONE (WORD)0x8200 /* ·ÅÒô */ |
| 61 | #define SIGNAL_TONE_TWO (WORD)0x8201 /* 2¶Î·ÅÒô */ |
| 62 | #define SIGNAL_TONE_THREE (WORD)0x8202 /* 3¶Î·ÅÒô */ |
| 63 | #define SIGNAL_TONE_FOUR (WORD)0x8203 /* 4¶Î·ÅÒô */ |
| 64 | #define SIGNAL_TONE_LONG (WORD)0x8204 /* ³¤Ê±¼ä·ÅÒô */ |
| 65 | |
| 66 | TONE_ATTR ToneAttr[] = { |
| 67 | /* |
| 68 | ToneId Cadence Cadence1 Cadence2 Cadence3 Cadence4 Dura RowStatus Rese*/ |
| 69 | {SIGNAL_RING, 1, 1,200,800,25,0,100, 0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0, 12000, 1, 0}, |
| 70 | {SIGNAL_RING_TWO, 2, 1,100,800,25,0,100, 1,200,800,25,0,100, 0,0,0,0,0,0, 0,0,0,0,0,0, 12000, 1, 0}, |
| 71 | {SIGNAL_RING_THREE, 3, 1,100,800,25,0,100, 1,400,800,25,0,100, 1,200,800,25,0,100, 0,0,0,0,0,0, 12000, 1, 0}, |
| 72 | {SIGNAL_RING_FOUR, 4, 1,100,800,25,0,100, 1,400,800,25,0,100, 1,300,300,25,0,100, 1,200,800,25,0,100, 12000, 1, 0}, |
| 73 | {SIGNAL_RING_LONG, 1, 1,6000,0,25,0,100, 0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0, 12000, 1, 0}, |
| 74 | |
| 75 | {SIGNAL_TONE, 1, 1,40,400,450,0,100, 0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0, 12000, 1, 0}, |
| 76 | {SIGNAL_TONE_TWO, 2, 1,40,400,450,0,100, 1,100,800,450,0,100, 0,0,0,0,0,0, 0,0,0,0,0,0, 12000, 1, 0}, |
| 77 | {SIGNAL_TONE_THREE, 3, 1,40,400,450,0,100, 1,100,800,450,0,100, 1,200,800,450,0,100, 0,0,0,0,0,0, 12000, 1, 0}, |
| 78 | {SIGNAL_TONE_FOUR, 4, 1,40,400,450,0,100, 1,100,800,450,0,100, 1,300,300,450,0,100, 1,200,800,450,0,100, 12000, 1, 0}, |
| 79 | {SIGNAL_TONE_LONG, 1, 1,6000,0,450,0,100, 0,0,0,0,0,0, 0,0,0,0,0,0, 0,0,0,0,0,0, 12000, 1, 0}, |
| 80 | }; |
| 81 | #define VOICE_TEST_CALL_DRV |
| 82 | #ifdef VOICE_TEST_CALL_DRV |
| 83 | static int voice_fd = -1; |
| 84 | static int volte_fd = -1; |
| 85 | #else |
| 86 | T_Voice_Para gsmhwpara = { |
| 87 | 8000, //8000;16000 |
| 88 | 0, //// 0 gsm;1 td;2 wcdma;3 lte |
| 89 | 0//0 hardware dsp;1 soft amr lib |
| 90 | }; |
| 91 | |
| 92 | T_Voice_Para tdnbhwpara = { |
| 93 | 8000, //8000;16000 |
| 94 | 1, //// 0 gsm;1 td;2 wcdma;3 lte |
| 95 | 0,//0 amr-nb;1 amr-wb |
| 96 | 0//0 hardware dsp;1 soft amr lib |
| 97 | }; |
| 98 | |
| 99 | T_Voice_Para tdnbsfpara = { |
| 100 | 8000, //8000;16000 |
| 101 | 1, //// 0 gsm;1 td;2 wcdma;3 lte |
| 102 | 0,//0 amr-nb;1 amr-wb |
| 103 | 1//0 hardware dsp;1 soft amr lib |
| 104 | }; |
| 105 | |
| 106 | T_Voice_Para tdwbsfpara = { |
| 107 | 8000, //8000;16000 |
| 108 | 1, //// 0 gsm;1 td;2 wcdma;3 lte |
| 109 | 1,//0 amr-nb;1 amr-wb |
| 110 | 1//0 hardware dsp;1 soft amr lib |
| 111 | }; |
| 112 | #endif |
| 113 | |
| 114 | |
| 115 | static VOID DataFormat(SIGNAL_DATA *pSig, TONE_ATTR *pAttr) |
| 116 | { |
| 117 | #if 0 |
| 118 | pSig->wDura = pAttr->wDura; |
| 119 | pSig->bCadenceNum = pAttr->wCadenceCount; |
| 120 | pSig->wSignalID = pAttr->wToneId; |
| 121 | |
| 122 | pSig->Cadence[0].wCadenceRptCnt = pAttr->wCadence1_rptcnt; |
| 123 | pSig->Cadence[0].wCadenceOn = pAttr->wCadence1_on; |
| 124 | pSig->Cadence[0].wCadenceOff = pAttr->wCadence1_off; |
| 125 | pSig->Cadence[0].wFreq1 = pAttr->wCadence1_Freq; |
| 126 | pSig->Cadence[0].wFreq2 = pAttr->wCadence1_2ndFreq; |
| 127 | pSig->Cadence[0].wAmp = pAttr->wCadence1_Amp; |
| 128 | |
| 129 | pSig->Cadence[1].wCadenceRptCnt = pAttr->wCadence2_rptcnt; |
| 130 | pSig->Cadence[1].wCadenceOn = pAttr->wCadence2_on; |
| 131 | pSig->Cadence[1].wCadenceOff = pAttr->wCadence2_off; |
| 132 | pSig->Cadence[1].wFreq1 = pAttr->wCadence2_Freq; |
| 133 | pSig->Cadence[1].wFreq2 = pAttr->wCadence2_2ndFreq; |
| 134 | pSig->Cadence[1].wAmp = pAttr->wCadence2_Amp; |
| 135 | |
| 136 | pSig->Cadence[2].wCadenceRptCnt = pAttr->wCadence3_rptcnt; |
| 137 | pSig->Cadence[2].wCadenceOn = pAttr->wCadence3_on; |
| 138 | pSig->Cadence[2].wCadenceOff = pAttr->wCadence3_off; |
| 139 | pSig->Cadence[2].wFreq1 = pAttr->wCadence3_Freq; |
| 140 | pSig->Cadence[2].wFreq2 = pAttr->wCadence3_2ndFreq; |
| 141 | pSig->Cadence[2].wAmp = pAttr->wCadence3_Amp; |
| 142 | |
| 143 | pSig->Cadence[3].wCadenceRptCnt = pAttr->wCadence4_rptcnt; |
| 144 | pSig->Cadence[3].wCadenceOn = pAttr->wCadence4_on; |
| 145 | pSig->Cadence[3].wCadenceOff = pAttr->wCadence4_off; |
| 146 | pSig->Cadence[3].wFreq1 = pAttr->wCadence4_Freq; |
| 147 | pSig->Cadence[3].wFreq2 = pAttr->wCadence4_2ndFreq; |
| 148 | pSig->Cadence[3].wAmp = pAttr->wCadence4_Amp; |
| 149 | #endif |
| 150 | } |
| 151 | static TONE_ATTR* GetToneData(WORD wTid) |
| 152 | { |
| 153 | WORD i; |
| 154 | for (i = 0; i < sizeof(ToneAttr)/sizeof(TONE_ATTR); i++) |
| 155 | { |
| 156 | if (wTid == ToneAttr[i].wToneId) |
| 157 | { |
| 158 | return &ToneAttr[i]; |
| 159 | } |
| 160 | } |
| 161 | return NULL; |
| 162 | } |
| 163 | |
| 164 | static void SLIC_SelfTest(void) |
| 165 | { |
| 166 | BYTE bBuf[16] = {0,}; |
| 167 | WORD wSize = 0; |
| 168 | SIGNAL_DATA tSig; |
| 169 | DWORD dC = 0; |
| 170 | #if 0 |
| 171 | tSig.wDura = 6000; /*60s */ |
| 172 | tSig.bCadenceNum = 1; |
| 173 | tSig.wSignalType = USL_RING_SIGNAL; |
| 174 | tSig.wSignalID = 0x8100; |
| 175 | tSig.Cadence[0].wCadenceOn = 100; /* 1s */ |
| 176 | tSig.Cadence[0].wCadenceOff = 0; /* no off */ |
| 177 | tSig.Cadence[0].wFreq1 = 25; |
| 178 | tSig.Cadence[0].wFreq2 = 0; |
| 179 | tSig.Cadence[0].wAmp = 100; |
| 180 | #endif |
| 181 | /* chip test */ |
| 182 | printf("\n check legerity chip"); |
| 183 | bBuf[0] = 0x73; |
| 184 | wSize = 2; |
| 185 | SLIC_Read_Codec(bBuf); |
| 186 | if ((bBuf[0] != 0x2) && (bBuf[1] != 0xb2)) |
| 187 | { |
| 188 | printf("\n read legerity ID error"); |
| 189 | } else { |
| 190 | printf("\n read legerity ID success ID:0x%x 0x%x", bBuf[0], bBuf[1]); |
| 191 | } |
| 192 | |
| 193 | /* ring test -self test mode */ |
| 194 | printf("\n control port 1 ringing "); |
| 195 | SLIC_Play_Signal(0, 0, &tSig); |
| 196 | printf("\n press any key to stop port 1 ring"); |
| 197 | while(!(dC = getchar())) { ;} |
| 198 | SLIC_Stop_Signal(0, 0); |
| 199 | |
| 200 | printf("\n control port 2 ringing "); |
| 201 | SLIC_Play_Signal(1, 0, &tSig); |
| 202 | printf("\n press any key to stop port 2 ring"); |
| 203 | while(!(dC = getchar())) { ;} |
| 204 | SLIC_Stop_Signal(1, 0); |
| 205 | |
| 206 | SLIC_MsgClr(); |
| 207 | SLIC_DebugLevel(0); |
| 208 | return; |
| 209 | } |
| 210 | /*lint -restore*/ |
| 211 | /*lint -save -e14*/ |
| 212 | int main(int argc, char** argv) |
| 213 | { |
| 214 | SIGNAL_DATA tSig = {0}; |
| 215 | DWORD wRev = 0; |
| 216 | WORD wPort = 0; |
| 217 | WORD wPort_type = 0; |
| 218 | WORD wTimeSlot = 0; |
| 219 | DWORD wTid = 0; |
| 220 | WORD wTime = 0; |
| 221 | WORD wLevel = 0; |
| 222 | TONE_ATTR *pToneAttr = NULL; |
| 223 | |
| 224 | wRev = SLIC_Initial(); |
| 225 | if (wRev == SLIC_FAIL) |
| 226 | { |
| 227 | printf("\n SLIC initial failed!"); |
| 228 | exit(1); |
| 229 | } |
| 230 | |
| 231 | if (argc < 2) |
| 232 | { |
| 233 | printf("\n Usage:%s cmd parm...", argv[0]); |
| 234 | exit(1); |
| 235 | } |
| 236 | |
| 237 | if (0 == strcmp("reset", argv[1])) /* port reset */ |
| 238 | { |
| 239 | if (argc != 4) |
| 240 | { |
| 241 | printf("\n Usage:%s reset port type", argv[0]); |
| 242 | exit(1); |
| 243 | } |
| 244 | wPort = atoi(argv[2]); |
| 245 | wPort_type = atoi(argv[3]); |
| 246 | wRev = SLIC_ResetPort(wPort, wPort_type); |
| 247 | } else if (0 == strcmp("slotset", argv[1])) /*time slot set */ |
| 248 | { |
| 249 | if (argc != 5) |
| 250 | { |
| 251 | printf("\n Usage:%s slotset port type timeslot\n", argv[0]); |
| 252 | exit(1); |
| 253 | } |
| 254 | wPort = atoi(argv[2]); |
| 255 | wPort_type = atoi(argv[3]); |
| 256 | wTimeSlot = atoi(argv[4]); |
| 257 | wRev = SLIC_SelectTimeSlot(wPort, wPort_type, wTimeSlot, wTimeSlot); |
| 258 | |
| 259 | } else if (0 == strcmp("reverse", argv[1])) /* polarity reverse */ |
| 260 | { |
| 261 | if (argc != 3) |
| 262 | { |
| 263 | printf("\n Usage:%s reverse port\n", argv[0]); |
| 264 | exit(1); |
| 265 | } |
| 266 | wPort = atoi(argv[2]); |
| 267 | wRev = SLIC_FXS_PolarityReverse(wPort); |
| 268 | } else if (0 == strcmp("startring", argv[1])) /* start ring */ |
| 269 | { |
| 270 | tSig.signal_type= RING_SIGNAL; |
| 271 | memcpy(tSig.cid, argv[2], 11); |
| 272 | printf("slictool startring cid %s", tSig.cid); |
| 273 | wRev = SLIC_Play_Signal(wPort, SLIC_PORT_TYPE, &tSig); |
| 274 | } else if (0 == strcmp("stopring", argv[1])) /* stop ring */ |
| 275 | { |
| 276 | wRev = SLIC_Stop_Signal(0, SLIC_PORT_TYPE); |
| 277 | } else if (0 == strcmp("playtone", argv[1])) /* play tone */ |
| 278 | { |
| 279 | tSig.signal_type = TONE_SIGNAL; |
| 280 | if(NULL != argv[2]) |
| 281 | { |
| 282 | tSig.tone_type = atoi(argv[2]); |
| 283 | } |
| 284 | else |
| 285 | { |
| 286 | tSig.tone_type = TONE_DIAL; |
| 287 | } |
| 288 | printf("tone_type %d\n", tSig.tone_type); |
| 289 | wRev = SLIC_Play_Signal(0, wPort_type, &tSig); |
| 290 | } |
| 291 | else if (0 == strcmp("rcvmsg", argv[1])) /* rcvmsg */ |
| 292 | { |
| 293 | while(1) |
| 294 | { |
| 295 | BYTE bEvent = 0; |
| 296 | DWORD pPayLoad = 0; |
| 297 | if (SLIC_FAIL == SLIC_MsgRev(&bEvent, &pPayLoad)) |
| 298 | { |
| 299 | printf("SLIC: Error-->>SLIC_MsgRev Failed\n"); |
| 300 | continue; |
| 301 | } |
| 302 | printf("SLIC: SLIC_MsgRev Event %d, payload %x\n", bEvent, pPayLoad); |
| 303 | } |
| 304 | } |
| 305 | else if (0 == strcmp("stoptone", argv[1])) /* stop tone */ |
| 306 | { |
| 307 | wRev = SLIC_Stop_Signal(wPort, wPort_type); |
| 308 | }else if (0 == strcmp("startpcm", argv[1])) /* stop tone */ |
| 309 | { |
| 310 | wRev = SLIC_Start_PCM(); |
| 311 | } else if (0 == strcmp("stoppcm", argv[1])) /* stop tone */ |
| 312 | { |
| 313 | wRev = SLIC_Stop_PCM(); |
| 314 | } else if (0 == strcmp("pcmnb", argv[1])) /* stop tone */ |
| 315 | { |
| 316 | wRev = SLIC_PCM_Set_NB(); |
| 317 | } else if (0 == strcmp("pcmwb", argv[1])) /* stop tone */ |
| 318 | { |
| 319 | wRev = SLIC_PCM_Set_WB(); |
| 320 | } else if (0 == strcmp("lock", argv[1])) /* lock port */ |
| 321 | { |
| 322 | if (argc != 4) |
| 323 | { |
| 324 | printf("\n Usage:%s lock port type\n", argv[0]); |
| 325 | exit(1); |
| 326 | } |
| 327 | wPort = atoi(argv[2]); |
| 328 | wPort_type = atoi(argv[3]); |
| 329 | wRev = SLIC_Port_Lock(wPort, wPort_type); |
| 330 | } else if (0 == strcmp("unlock", argv[1])) /* unlock port */ |
| 331 | { |
| 332 | if (argc != 4) |
| 333 | { |
| 334 | printf("\n Usage:%s unlock port type\n", argv[0]); |
| 335 | exit(1); |
| 336 | } |
| 337 | wPort = atoi(argv[2]); |
| 338 | wPort_type = atoi(argv[3]); |
| 339 | wRev = SLIC_Port_UnLock(wPort, wPort_type); |
| 340 | } else if (0 == strcmp("codecset", argv[1])) /* codecset */ |
| 341 | { |
| 342 | BYTE bBuf[256]; |
| 343 | BYTE bTmp = 0; |
| 344 | BYTE bSize = 0; |
| 345 | DWORD bParm; |
| 346 | if (argc != 3) |
| 347 | { |
| 348 | printf("\n Usage:%s codecset parmstring\n", argv[0]); |
| 349 | exit(1); |
| 350 | } |
| 351 | sscanf(&(argv[2][bTmp]), "%x", &bParm); |
| 352 | |
| 353 | bBuf[bSize++] = bParm; |
| 354 | printf("\n codecset addr %x\n", bBuf[0]); |
| 355 | for (bTmp = 0; argv[2][bTmp]!= 0; bTmp++) |
| 356 | { |
| 357 | if (argv[2][bTmp] != ' ') |
| 358 | { |
| 359 | printf("\n codecset argv[2][%d] %x\n", bTmp, argv[2][bTmp]); |
| 360 | continue; |
| 361 | } |
| 362 | |
| 363 | sscanf(&(argv[2][bTmp]), "%x", &bParm); |
| 364 | bBuf[bSize++] = bParm; |
| 365 | } |
| 366 | printf("\n codecset value %x\n", bBuf[1]); |
| 367 | wRev = SLIC_Cfg_Codec(bBuf); |
| 368 | } else if (0 == strcmp("codecget", argv[1])) /* codecget */ |
| 369 | { |
| 370 | BYTE bBuf[256]; |
| 371 | BYTE bSize = 0; |
| 372 | DWORD bParm; |
| 373 | if (argc != 3) |
| 374 | { |
| 375 | printf("\n Usage:%s codecget address\n", argv[0]); |
| 376 | exit(1); |
| 377 | } |
| 378 | sscanf(&(argv[2][0]), "%x", &bParm); |
| 379 | bBuf[0] = bParm; |
| 380 | |
| 381 | wRev = SLIC_Read_Codec(bBuf); |
| 382 | } else if (0 == strcmp("ramset", argv[1])) //ramset |
| 383 | { |
| 384 | BYTE bBuf[256]; |
| 385 | BYTE bTmp = 0; |
| 386 | BYTE bSize = 0; |
| 387 | DWORD bParm; |
| 388 | if (argc != 3) |
| 389 | { |
| 390 | printf("\n Usage:%s ramset parmstring\n", argv[0]); |
| 391 | exit(1); |
| 392 | } |
| 393 | sscanf(&(argv[2][bTmp]), "%x", &bParm); |
| 394 | bBuf[bSize++] = (BYTE)bParm; |
| 395 | bBuf[bSize++] = (bParm>>8)&(0x07); |
| 396 | |
| 397 | for (bTmp = 0; argv[2][bTmp]!= 0; bTmp++) |
| 398 | { |
| 399 | if (argv[2][bTmp] != ' ') |
| 400 | { |
| 401 | continue; |
| 402 | } |
| 403 | |
| 404 | sscanf(&(argv[2][bTmp]), "%x", &bParm); |
| 405 | bBuf[bSize++] = (BYTE)bParm; |
| 406 | bBuf[bSize++] = (bParm>>8)&(0xff); |
| 407 | bBuf[bSize++] = (bParm>>16)&(0xff); |
| 408 | bBuf[bSize++] = (bParm>>24)&(0xff); |
| 409 | } |
| 410 | wRev = SLIC_Cfg_Ram(bBuf); |
| 411 | |
| 412 | }else if (0 == strcmp("ramget", argv[1])) //ramget |
| 413 | { |
| 414 | BYTE bBuf[256]; |
| 415 | BYTE bSize = 0; |
| 416 | DWORD dwParm; |
| 417 | WORD *pAddr = (WORD *)&bBuf[0]; |
| 418 | if (argc != 3) |
| 419 | { |
| 420 | printf("\n Usage:%s ramget address\n", argv[0]); |
| 421 | exit(1); |
| 422 | } |
| 423 | sscanf(&(argv[2][0]), "%x", &dwParm); |
| 424 | *pAddr = (WORD)dwParm; |
| 425 | printf("read ram %d \n", (int)bBuf); |
| 426 | wRev = SLIC_Read_Ram(bBuf); |
| 427 | |
| 428 | } else if (0 == strcmp("hooklow", argv[1])) /* config hook low time */ |
| 429 | { |
| 430 | if (argc != 4) |
| 431 | { |
| 432 | printf("\n Usage:%s hooklow port time\n", argv[0]); |
| 433 | exit(1); |
| 434 | } |
| 435 | wPort = atoi(argv[2]); |
| 436 | wTime = atoi(argv[3]); |
| 437 | wRev = SLIC_Cfg_HookLowTime(wPort, wTime); |
| 438 | } else if (0 == strcmp("hookhigh", argv[1])) /* config hook high time */ |
| 439 | { |
| 440 | if (argc != 4) |
| 441 | { |
| 442 | printf("\n Usage:%s hookhigh port time\n", argv[0]); |
| 443 | exit(1); |
| 444 | } |
| 445 | wPort = atoi(argv[2]); |
| 446 | wTime = atoi(argv[3]); |
| 447 | wRev = SLIC_Cfg_HookHighTime(wPort, wTime); |
| 448 | } else if (0 == strcmp("prehookhigh", argv[1])) /* config prehook time */ |
| 449 | { |
| 450 | if (argc != 4) |
| 451 | { |
| 452 | printf("\n Usage:%s prehookhigh port time\n", argv[0]); |
| 453 | exit(1); |
| 454 | } |
| 455 | wPort = atoi(argv[2]); |
| 456 | wTime = atoi(argv[3]); |
| 457 | wRev = SLIC_Cfg_PreHookHighTime(wPort, wTime); |
| 458 | } else if (0 == strcmp("flashlowmin", argv[1])) /* config flash low min */ |
| 459 | { |
| 460 | if (argc != 4) |
| 461 | { |
| 462 | printf("\n Usage:%s flashlowmin port time\n", argv[0]); |
| 463 | exit(1); |
| 464 | } |
| 465 | wPort = atoi(argv[2]); |
| 466 | wTime = atoi(argv[3]); |
| 467 | wRev = SLIC_Cfg_FlashLowMinTime(wPort, wTime); |
| 468 | } else if (0 == strcmp("flashlowmax", argv[1])) /* config flash low max */ |
| 469 | { |
| 470 | if (argc != 4) |
| 471 | { |
| 472 | printf("\n Usage:%s flashlowmax port time\n", argv[0]); |
| 473 | exit(1); |
| 474 | } |
| 475 | wPort = atoi(argv[2]); |
| 476 | wTime = atoi(argv[3]); |
| 477 | wRev = SLIC_Cfg_FlashLowMaxTime(wPort, wTime); |
| 478 | } else if (0 == strcmp("flashfix", argv[1])) /* config flash high fix */ |
| 479 | { |
| 480 | if (argc != 4) |
| 481 | { |
| 482 | printf("\n Usage:%s flashfix port time\n", argv[0]); |
| 483 | exit(1); |
| 484 | } |
| 485 | wPort = atoi(argv[2]); |
| 486 | wTime = atoi(argv[3]); |
| 487 | wRev = SLIC_Cfg_FlashHighFixTime(wPort, wTime); |
| 488 | } else if (0 == strcmp("diallowmin", argv[1])) /* config pulse low min */ |
| 489 | { |
| 490 | if (argc != 4) |
| 491 | { |
| 492 | printf("\n Usage:%s diallowmin port time\n", argv[0]); |
| 493 | exit(1); |
| 494 | } |
| 495 | wPort = atoi(argv[2]); |
| 496 | wTime = atoi(argv[3]); |
| 497 | wRev = SLIC_Cfg_DialLowMinTime(wPort, wTime); |
| 498 | } else if (0 == strcmp("diallowmax", argv[1])) /* config pulse low max */ |
| 499 | { |
| 500 | if (argc != 4) |
| 501 | { |
| 502 | printf("\n Usage:%s diallowmax port time\n", argv[0]); |
| 503 | exit(1); |
| 504 | } |
| 505 | wPort = atoi(argv[2]); |
| 506 | wTime = atoi(argv[3]); |
| 507 | wRev = SLIC_Cfg_DialLowMaxTime(wPort, wTime); |
| 508 | } else if (0 == strcmp("dialhighmin", argv[1])) /* config pulse high min */ |
| 509 | { |
| 510 | if (argc != 4) |
| 511 | { |
| 512 | printf("\n Usage:%s dialhighmin port time\n", argv[0]); |
| 513 | exit(1); |
| 514 | } |
| 515 | wPort = atoi(argv[2]); |
| 516 | wTime = atoi(argv[3]); |
| 517 | wRev = SLIC_Cfg_DialHighMinTime(wPort, wTime); |
| 518 | } else if (0 == strcmp("dialhighfix", argv[1])) /* config pulse high fix */ |
| 519 | { |
| 520 | if (argc != 4) |
| 521 | { |
| 522 | printf("\n Usage:%s dialhighfix port time\n", argv[0]); |
| 523 | exit(1); |
| 524 | } |
| 525 | wPort = atoi(argv[2]); |
| 526 | wTime = atoi(argv[3]); |
| 527 | wRev = SLIC_Cfg_DialHighFixTime(wPort, wTime); |
| 528 | } else if (0 == strcmp("debuglvl", argv[1])) /* config debug level */ |
| 529 | { |
| 530 | if (argc != 3) |
| 531 | { |
| 532 | printf("\n Usage:%s debuglvl level\n", argv[0]); |
| 533 | exit(1); |
| 534 | } |
| 535 | wLevel = atoi(argv[2]); |
| 536 | SLIC_DebugLevel(wLevel); |
| 537 | } else if (0 == strcmp("selftest", argv[1])) /* self test */ |
| 538 | { |
| 539 | if (argc != 2) |
| 540 | { |
| 541 | printf("\n Usage:%s selftest\n", argv[0]); |
| 542 | exit(1); |
| 543 | } |
| 544 | SLIC_SelfTest(); |
| 545 | } |
| 546 | else if (0 == strcmp("leg", argv[1])) /* chip initial */ |
| 547 | { |
| 548 | |
| 549 | if (argc != 3) |
| 550 | { |
| 551 | printf("\n Usage:%s leg num(1:init,other num :no init)\n", argv[0]); |
| 552 | exit(1); |
| 553 | } |
| 554 | wPort=atoi(argv[2]); |
| 555 | if(wPort==1) |
| 556 | { |
| 557 | wRev = SLIC_Dev_Init(); |
| 558 | if(wRev==SLIC_FAIL) |
| 559 | printf("leg init fail!!\n"); |
| 560 | else |
| 561 | printf("leg init success!\n"); |
| 562 | } |
| 563 | else |
| 564 | exit(1); |
| 565 | |
| 566 | } |
| 567 | else if (0 == strcmp("test", argv[1])) /* 112 test start */ |
| 568 | { |
| 569 | WriteCmd_t Cmd = {0}; |
| 570 | if (argc != 6) |
| 571 | { |
| 572 | printf("\n Usage:%s test port type item\n", argv[0]); |
| 573 | exit(1); |
| 574 | } |
| 575 | |
| 576 | Cmd.port = atoi(argv[2]); |
| 577 | Cmd.port_type = atoi(argv[3]); |
| 578 | Cmd.item = atoi(argv[4]); |
| 579 | Cmd.obligate = atoi(argv[5]); |
| 580 | wRev = SLIC_112TestStart((WriteCmd_t *)&Cmd); |
| 581 | } |
| 582 | else if (0 == strcmp("readreg", argv[1])) /* codecget */ |
| 583 | { |
| 584 | BYTE bBuf[256]; |
| 585 | BYTE bSize = 1; |
| 586 | BYTE loopi; |
| 587 | if (argc != 4) |
| 588 | { |
| 589 | printf("\n Usage:%s codecget port type address size\n", argv[0]); |
| 590 | exit(1); |
| 591 | } |
| 592 | wPort = atoi(argv[2]); |
| 593 | wPort_type = atoi(argv[3]); |
| 594 | |
| 595 | for(loopi=0; loopi<=126; loopi++) |
| 596 | { |
| 597 | bBuf[0] = loopi; |
| 598 | wRev = SLIC_Read_Codec(bBuf); |
| 599 | if (wRev != SLIC_SUCCESS) |
| 600 | break; |
| 601 | } |
| 602 | } |
| 603 | else if (0 == strcmp("readram", argv[1])) |
| 604 | { |
| 605 | BYTE bSize = 4; //siliconlab 32176 readram 28bit once |
| 606 | WORD loopi; |
| 607 | union |
| 608 | { |
| 609 | DWORD wReturnvalue; |
| 610 | WORD wAddress_on10; |
| 611 | } xchange; |
| 612 | |
| 613 | if (argc != 4) |
| 614 | { |
| 615 | printf("\n Usage:%s readram port port_type reg_10\n", argv[0]); |
| 616 | exit(1); |
| 617 | } |
| 618 | |
| 619 | wPort = atoi(argv[2]); |
| 620 | wPort_type = atoi(argv[3]); |
| 621 | |
| 622 | printf("____show all rams_____ \n"); |
| 623 | for(loopi=0; loopi<=1565; loopi++) |
| 624 | { |
| 625 | xchange.wAddress_on10 = loopi; |
| 626 | wRev = SLIC_Read_Ram((BYTE *) &xchange.wAddress_on10); |
| 627 | if (wRev != SLIC_SUCCESS) |
| 628 | break; |
| 629 | } |
| 630 | } |
| 631 | else if (0 == strcmp("voice_test", argv[1])) /* rcvmsg */ |
| 632 | { |
| 633 | #ifdef VOICE_TEST_CALL_DRV |
| 634 | int ret = 0; |
| 635 | // WORD codecpath = 0; |
| 636 | // WORD onoff = 0; |
| 637 | T_Voice_Para para = {0}; |
| 638 | int slicflag = 0; |
| 639 | T_ZDrvVoice_Cfg cfg = {8000,1,160,16,0}; |
| 640 | T_ZDrvVoice_Cfg cfgwb = {16000,1,320,16,0}; |
| 641 | |
| 642 | para.codec_path = atoi(argv[2]);//0 dsp ;1 soft |
| 643 | para.mode = atoi(argv[3]); // 0gsm,1 td;2 wcdma |
| 644 | para.codec_type = atoi(argv[3]); // 0 amr-nb;1 amr-wb |
| 645 | // onoff = atoi(argv[4]); // 0 off;1 on |
| 646 | printf("slctool: voice_test codec_path=%d,mode=%d!\n",para.codec_path,para.mode); |
| 647 | |
| 648 | |
| 649 | |
| 650 | voice_fd = open("/dev/voice_device", O_RDONLY); |
| 651 | if(voice_fd < 0) |
| 652 | { |
| 653 | printf("slctool: open voice device error.\n"); |
| 654 | exit(1); //cov m |
| 655 | } |
| 656 | //open volte |
| 657 | |
| 658 | volte_fd = open("/dev/volte_device", O_RDONLY); |
| 659 | if(volte_fd < 0) |
| 660 | { |
| 661 | printf("slctool: open volte device error.\n"); |
| 662 | exit(1); //cov m |
| 663 | } |
| 664 | |
| 665 | //ret = ioctl(volte_fd,VOLTE_IOCTL_SET_CFG,&cfg); |
| 666 | // printf("slctool: volte set cfg fd=%d,ret=%d.\n",volte_fd,ret); |
| 667 | |
| 668 | |
| 669 | |
| 670 | ret = ioctl(volte_fd,VOLTE_IOCTL_GET_SLIC_USE_FLAG,&slicflag); |
| 671 | printf("slctool: volte get slic flag=%d fd=%d,ret=%d.\n",slicflag,volte_fd,ret); |
| 672 | |
| 673 | ret = ioctl(volte_fd,VOLTE_IOCTL_SET_CFG,&cfg); |
| 674 | |
| 675 | close(volte_fd); |
| 676 | |
| 677 | volte_fd = open("/dev/volte_device", O_RDONLY); |
| 678 | if(volte_fd < 0) |
| 679 | { |
| 680 | printf("slctool: open volte device error.\n"); |
| 681 | exit(1); //cov m |
| 682 | } |
| 683 | |
| 684 | //ret = ioctl(volte_fd,VOLTE_IOCTL_SET_CFG,&cfg); |
| 685 | // printf("slctool: volte set cfg fd=%d,ret=%d.\n",volte_fd,ret); |
| 686 | ret = ioctl(volte_fd,VOLTE_IOCTL_GET_SLIC_USE_FLAG,&slicflag); |
| 687 | printf("slctool: volte get slic flag=%d fd=%d,ret=%d.\n",slicflag,volte_fd,ret); |
| 688 | |
| 689 | ret = ioctl(volte_fd,VOLTE_IOCTL_SET_CFG,&cfgwb); |
| 690 | |
| 691 | close(volte_fd); |
| 692 | |
| 693 | ret = ioctl(voice_fd,VOICE_IOCTL_START,¶); |
| 694 | printf("slctool: voice start fd=%d,ret=%d.\n",voice_fd,ret); |
| 695 | |
| 696 | usleep(1000000); |
| 697 | |
| 698 | printf("slctool: bef voice stop fd=%d,ret=%d.\n",voice_fd,ret); |
| 699 | |
| 700 | ret = ioctl(voice_fd,VOICE_IOCTL_STOP,¶); |
| 701 | printf("slctool: voice stop fd=%d,ret=%d.\n",voice_fd,ret); |
| 702 | |
| 703 | close(voice_fd); |
| 704 | |
| 705 | |
| 706 | printf("voice test !\n"); |
| 707 | #else |
| 708 | |
| 709 | int ret = 0; |
| 710 | int sel; |
| 711 | T_Voice_Para *para; |
| 712 | sel = atoi(argv[2]);//0 gsm ;1 tdnbhw;2tdnbsf ;3tdwbsf |
| 713 | if (sel == 0){ |
| 714 | para = &gsmhwpara; |
| 715 | } |
| 716 | else if(sel == 1){ |
| 717 | para = &tdnbhwpara; |
| 718 | } |
| 719 | else if(sel == 2){ |
| 720 | para = &tdnbsfpara; |
| 721 | |
| 722 | } |
| 723 | else if(sel == 3){ |
| 724 | para = &tdwbsfpara; |
| 725 | } |
| 726 | else{ |
| 727 | printf("voice lib test invalid para\n"); |
| 728 | exit(1); |
| 729 | } |
| 730 | ret = voice_open(para); |
| 731 | printf("slctool: voice_open,ret=%d.\n",ret); |
| 732 | usleep(1000000); |
| 733 | |
| 734 | |
| 735 | ret = voice_close(para); |
| 736 | #endif |
| 737 | |
| 738 | |
| 739 | } |
| 740 | else if (0 == strcmp("vploop", argv[1])) |
| 741 | { |
| 742 | int ret = 0; |
| 743 | |
| 744 | int path = 0; |
| 745 | path = atoi(argv[2]);//0 hanset ;1 sp;2 headset;255 off |
| 746 | printf("slictool vploop path=%d \n",path); |
| 747 | if((path >=0)&&(path <=2)){ |
| 748 | ret = SLIC_PCM_Set_NB(); |
| 749 | if (ret != 0) |
| 750 | { |
| 751 | printf("SLIC_PCM_Set_NB Error ret=%d!\n",ret); |
| 752 | exit(1); |
| 753 | } |
| 754 | ret = SLIC_Start_PCM(); |
| 755 | if (ret != 0) |
| 756 | { |
| 757 | printf("SLIC_Start_PCM Error ret=%d!\n",ret); |
| 758 | exit(1); |
| 759 | } |
| 760 | } |
| 761 | else if(path == 255){ |
| 762 | ret = SLIC_Stop_PCM(); |
| 763 | if (ret != 0) |
| 764 | { |
| 765 | printf("SLIC_Stop_PCM Error ret=%d!\n",ret); |
| 766 | exit(1); |
| 767 | } |
| 768 | SLIC_Release(); |
| 769 | |
| 770 | } |
| 771 | |
| 772 | ret = voice_Vploop(&path); |
| 773 | if (ret != 0) |
| 774 | { |
| 775 | printf("vploop Error ret=%d!\n",ret); |
| 776 | exit(1); |
| 777 | } |
| 778 | |
| 779 | } |
| 780 | |
| 781 | else |
| 782 | { |
| 783 | printf("not support!\n"); |
| 784 | } |
| 785 | |
| 786 | if (wRev != SLIC_SUCCESS) |
| 787 | { |
| 788 | printf("\n Run Error!\n"); |
| 789 | exit(1); |
| 790 | } |
| 791 | |
| 792 | SLIC_Release(); |
| 793 | return 0; |
| 794 | } |
| 795 | /*lint -restore*/ |
| 796 | |