blob: 22a7d677221a9d927e29cf37e548405a1246d6ec [file] [log] [blame]
xf.libdd93d52023-05-12 07:10:14 -07001/************************************************************************
2*¹¦ÄܽéÉÜ£ºÆ½Ì¨ÄÚ²¿À©Õ¹at¿Í»§¶ËºÍ·þÎñ¶Ë×¢²á£¬ËùÓÐ×¢²á¾ùÔÚext_regist_init½Ó¿ÚÖÐÍê³É£¬ÓÉat_ctlÔÚÆô¶¯Ê±µ÷ÓÃ
3*¸ºÔðÈË£º
4*±¸·ÝÈË£º
5*ÐÞ¸ÄÈÕ£º
6*ÐÞ¸ÄÄÚÈÝ£º
7*°æ±¾ºÅ£º
8************************************************************************/
9#if (APP_OS_TYPE == APP_OS_LINUX)
10#include "at_msg.h"
11#include "at_com.h"
12#include "at_context.h"
13#include "ext_dev_func.h"
14#include "ext_cmux_func.h"
15#ifdef _USE_VOICE_ALSA
16#include "tinyalsa/audio_mixer_ctrl.h"
xf.lie31de8b2023-12-26 23:38:58 -080017//#include "voice_lib.h"
xf.li742dd022023-06-08 01:43:32 -070018#include "voice_ipc.h"
xf.libdd93d52023-05-12 07:10:14 -070019#endif
xf.lie31de8b2023-12-26 23:38:58 -080020#if (defined _USE_VOICE_ALSA) || (defined _VBUFF_IN_SINGLE_CORE)
21#include "voice_lib.h"
22#endif
23
xf.libdd93d52023-05-12 07:10:14 -070024//#include "ext_regist.h"
25//#include "softap_api.h"
26//#include "at_utils.h"
27//#include "pub/drvs_ret.h"
28//#include "earpiece_api.h"
29#define DRV_SUCCESS 0
30
31/*
32typedef enum
33{
34 VP_PATH_HANDSET =0,
35 VP_PATH_SPEAKER,
36 VP_PATH_HEADSET,
37 VP_PATH_BLUETOOTH,
38 VP_PATH_BLUETOOTH_NO_NR,
39 VP_PATH_HSANDSPK,
40
41 VP_PATH_OFF = 255,
42
43 MAX_VP_PATH = VP_PATH_OFF
44}T_ZDrv_VpPath;
45*/
46/* Voice input channel selection. */
47typedef enum
48{
49 CODEC_INPUT_MICPHONE =0, /*input path in earphone mic*/
50 CODEC_INPUT_HEADSET, /*input path in headset*/
51 CODEC_INPUT_BLUETOOTH, /*input path in bluetooth*/
52 CODEC_INPUT_HANDSFREE, /*input path in mic(handsfree)*/
53
54 MAX_CODEC_INPUT_PATH
55} T_ZDrv_CodecInputPath;
56
57/* Voice output channel selection. */
58typedef enum
59{
60 CODEC_OUTPUT_RECEIVER =0, /*output path in receiver*/
61 CODEC_OUTPUT_SPEAKER, /*output path in speaker*/
62 CODEC_OUTPUT_HEADSET, /*output path in headset*/
63 CODEC_OUTPUT_BLUETOOTH, /*output path in bluetooth*/
64 CODEC_OUTPUT_HSANDSPK, /*output path in both headset and speaker*/
65
66
67 MAX_CODEC_OUTPUT_PATH
68}T_ZDrv_CodecOutputPath;
xf.lidf7f8ba2024-09-12 23:53:34 -070069
70
71#ifdef _VBUFF_IN_SINGLE_CORE
72extern int vbuffer_stream_start(void);
73extern int vbuffer_stream_stop(void);
74#endif
75
76#ifdef _USE_VOICE_AT
77
78extern int voice_SetVoiceBuffer(T_VoiceBuf_Para *vb);
79extern int voice_GetVoiceBuffer(T_VoiceBuf_Para *vb);
80#endif
81
xf.libdd93d52023-05-12 07:10:14 -070082#ifdef _CONFIG_USE_CODEC_EARPIECE_DETECT
83extern SINT32 halEarp_Open(VOID);
84extern SINT32 halEarp_Close(VOID);
85extern SINT32 halEarp_GetPlugStatus(T_ZDrvEarp_State* plug_status);
86#endif
87
88#ifdef _CONFIG_USE_CODEC
89extern SINT32 halAudioConfig_ReadReg (UINT16 regPage, UINT16 regAddress, UINT16 *regValue);
90extern SINT32 halAudioConfig_WriteReg (UINT16 regPage, UINT16 regAddress, UINT16 regValue, UINT16 regMask);
91extern SINT32 halAudioConfig_DumpReg (VOID);
92
93
94int codecWrite_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
95{
96 char *at_str = NULL;
97 UINT32 ret = DRV_SUCCESS;
98 UINT8 pPtr[40] = {0};
99 int a[4] = {0};
100 //CHAR b[6] = {0};
101 //CHAR c[6] = {0};
102 //CHAR d[6] = {0};
103 UINT16 reg_page = 0;
104 UINT16 reg_index = 0;
105 UINT16 write_value = 0;
106 UINT16 write_mask = 0;
107 at_str = at_paras;
108 at_print(AT_DEBUG,"codecWrite_act_func, at_paras:%s \n", at_paras);
109
110 //ret = sscanf (at_str, "%[0-9],%[0-9],%[0-9],%[0-9]", a, b, c, d);
111 ret = sscanf (at_str, "%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3]);
112 reg_page = a[0];
113 reg_index = a[1];
114 write_value = a[2];
115 write_mask = a[3];
116 at_print(AT_DEBUG,"zCtrm_ExtAT_WRCODEC reg_page=0x%x, reg_index=0x%x, write_value=0x%x, write_mask=0x%x\n", reg_page, reg_index, write_value, write_mask);
117
118 if (ret == 4) {
119 ret = halAudioConfig_WriteReg (reg_page, reg_index, write_value, write_mask);
120 if (ret == DRV_SUCCESS) {
121 *res_msg = at_ok_build();
122 *res_msglen = strlen (*res_msg);
123 return AT_END;
124 }
125 }
126
127 *res_msg = at_err_build(ATERR_PROC_FAILED);
128 *res_msglen = strlen (*res_msg);
129 return AT_END;
130}
131
132int codecRead_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
133{
134 char *at_str = NULL;
135 at_str = at_paras;
136 UINT32 ret = DRV_SUCCESS;
137 int a[2] = {0};
138 //CHAR b[6] = {0};
139 CHAR re_str[30] = {'\0'};
140
141 UINT16 reg_page = 0;
142 UINT16 reg_index = 0;
143 UINT16 read_value = 0;
144 at_print(AT_DEBUG,"codecRead_act_func, at_paras:%s \n", at_paras);
145
146 //ret = sscanf (at_str, "%[0-9],%[0-9]", a, b);
147 ret = sscanf (at_str, "%d,%d", &a[0], &a[1]);
148 reg_page = a[0];
149 reg_index = a[1];
150 at_print(AT_DEBUG,"codecRead_act_func reg_page=0x%x, reg_index=0x%x \n", reg_page, reg_index);
151
152 if (ret == 2) {
153 ret = halAudioConfig_ReadReg (reg_page, reg_index, &read_value);
154 if (ret == DRV_SUCCESS) {
155
156 sprintf(re_str, "0x%x=0x%x\r\n" , reg_index,read_value);
157
158 *res_msg = at_query_result_build("reg",re_str);
159
160 //*res_msg = at_ok_build();
161 *res_msglen = strlen (*res_msg);
162 return AT_END;
163 }
164 }
165
166 *res_msg = at_err_build(ATERR_PROC_FAILED);
167 *res_msglen = strlen (*res_msg);
168 return AT_END;
169}
170
171int codecDump_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
172{
173 char *at_str = NULL;
174 at_str = at_paras;
175 UINT32 ret = DRV_SUCCESS;
176 at_print(AT_DEBUG,"codecDump_act_func, at_paras:%s \n", at_paras);
177
178 if (*at_str == '1') {
179 at_print(AT_DEBUG,"codecDump_act_func is ok. \n");
180 ret = halAudioConfig_DumpReg();
181 if (ret == DRV_SUCCESS) {
182 *res_msg = at_ok_build();
183 *res_msglen = strlen (*res_msg);
184 return AT_END;
185 }
186 }
187
188 *res_msg = at_err_build(ATERR_PROC_FAILED);
189 *res_msglen = strlen (*res_msg);
190 return AT_END;
191
192
193}
194//ƽ̨ÄÚ²¿À©Õ¹atÃüÁ·¢£¬ËùÓÐÀ©Õ¹µÄ¿Í»§¶ËºÍ·þÎñ¶ËatÃüÁ¾ùÐèÒªÔڸú¯ÊýÖУ¬¸Ãº¯Êý»áÔÚat_ctlÓ¦Óóõʼ»¯Ê±£¬Íê³ÉÉÏÊöatÃüÁîµÄ×¢²á
195
196
197int extAtSdev_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
198{
199 char *at_str = NULL;
200 UINT32 ret = DRV_SUCCESS;
201 T_ZDrv_VpPath path;
202
203 UINT8 pPtr[40] = {0};
204 int a = 0;
205 //CHAR b[6] = {0};
206 UINT16 dev_num = 0;
207 at_str = at_paras;
208 at_print(AT_DEBUG,"extAtSdev_act_func, at_paras:%s \n", at_paras);
209
210 ret = sscanf (at_str, "%d", &a);
211 dev_num = a;
212 at_print(AT_DEBUG,"extAtSdev_act_func dev_num=0x%d\n", dev_num);
213
214 if (ret == 1) {
215
216 if(dev_num == 0)
217 {
218 path = VP_PATH_HANDSET;
219 at_print(AT_DEBUG, "[MDL] extAtSdev_act_func output channel=%d\r",dev_num);
220 }
221 else if(dev_num == 1)
222 {
223 path = VP_PATH_SPEAKER;
224 at_print(AT_DEBUG, "[MDL] extAtSdev_act_func output channel=%d\r",dev_num);
225 }
226 else if(dev_num == 2)
227 {
228 path = VP_PATH_HEADSET;
229 at_print(AT_DEBUG, "[MDL] extAtSdev_act_func output channel=%d\r",dev_num);
230 }
231 else
232 {
233 sprintf ( (char *) pPtr, "\r\n%s\r\n", "+CME ERROR: 6004");
234 path = VP_PATH_HANDSET;
235 *res_msg = at_err_build ("pPtr");
236 *res_msglen = strlen (*res_msg);
237 return AT_END;
238 }
239
240 ret = zDrvVp_SetPath(path);
241 if (ret == DRV_SUCCESS) {
242 *res_msg = at_ok_build();
243 *res_msglen = strlen (*res_msg);
244 return AT_END;
245 }
246 *res_msg = at_err_build(ATERR_PROC_FAILED);
247 *res_msglen = strlen (*res_msg);
248
249 return AT_END;
250 }
251 return AT_END;
252}
253int extAtRxPath_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
254{
255 char *at_str = NULL;
256 UINT32 ret = DRV_SUCCESS;
257 T_ZDrv_CodecOutputPath path;
258
259 UINT8 pPtr[40] = {0};
260 int a[2] = {0};
261 //CHAR b[6] = {0};
262 UINT16 dev_num = 0;
263 UINT16 isenable = 0;
264 at_str = at_paras;
265 at_print(AT_DEBUG,"extAtSdev_act_func, at_paras:%s \n", at_paras);
266
267 ret = sscanf (at_str, "%d %d", &a[0], &a[1]);
268 dev_num = a[0];
269 isenable = a[1];
270 at_print(AT_DEBUG,"extAtSdev_act_func dev_num=0x%d\n", dev_num);
271
272 if (ret == 2) {
273
274 if(dev_num == 0)
275 {
276 path = CODEC_OUTPUT_RECEIVER;
277 at_print(AT_DEBUG, "[MDL] extAtSdev_act_func output channel=%d\r",dev_num);
278 }
279 else if(dev_num == 1)
280 {
281 path = CODEC_OUTPUT_SPEAKER;
282 at_print(AT_DEBUG, "[MDL] extAtSdev_act_func output channel=%d\r",dev_num);
283 }
284 else if(dev_num == 2)
285 {
286 path = CODEC_OUTPUT_HEADSET;
287 at_print(AT_DEBUG, "[MDL] extAtSdev_act_func output channel=%d\r",dev_num);
288 }
289 else
290 {
291 sprintf ( (char *) pPtr, "\r\n%s\r\n", "+CME ERROR: 6004");
292 path = CODEC_OUTPUT_RECEIVER;
293 *res_msg = at_err_build ("pPtr");
294 *res_msglen = strlen (*res_msg);
295 return AT_END;
296 }
297
298 //ret = zDrvVp_SetTxPath(CODEC_INPUT_MICPHONE, TRUE);
299 ret = zDrvVp_SetRxPath(path, isenable);
300 if (ret == DRV_SUCCESS) {
301 *res_msg = at_ok_build();
302 *res_msglen = strlen (*res_msg);
303 return AT_END;
304 }
305 *res_msg = at_err_build(ATERR_PROC_FAILED);
306 *res_msglen = strlen (*res_msg);
307
308 return AT_END;
309 }
310 return AT_END;
311}
312int extAtTxPath_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
313{
314 char *at_str = NULL;
315 UINT32 ret = DRV_SUCCESS;
316 T_ZDrv_VpPath path;
317
318 UINT8 pPtr[40] = {0};
319 int a[2] = {0};
320 //CHAR b[6] = {0};
321 UINT16 dev_num = 0;
322 UINT16 isenable = 0;
323 at_str = at_paras;
324 at_print(AT_DEBUG,"extAtSdev_act_func, at_paras:%s \n", at_paras);
325
326 ret = sscanf (at_str, "%d %d", &a[0], &a[1]);
327 dev_num = a[0];
328 isenable = a[1];
329 at_print(AT_DEBUG,"extAtSdev_act_func dev_num=0x%d\n", dev_num);
330
331 if (ret == 2) {
332
333 if(dev_num == 0)
334 {
335 path = CODEC_INPUT_MICPHONE; //IN2P
336 at_print(AT_DEBUG, "[MDL] extAtSdev_act_func output channel=%d\r",dev_num);
337 }
338 else if(dev_num == 1)
339 {
340 path = CODEC_INPUT_HANDSFREE; //CODEC_INPUT_HEADSET IN2P
341 at_print(AT_DEBUG, "[MDL] extAtSdev_act_func output channel=%d\r",dev_num);
342 }
343 else if(dev_num == 2)
344 {
345 path = CODEC_INPUT_HEADSET; //CODEC_INPUT_HANDSFREE IN1P
346 at_print(AT_DEBUG, "[MDL] extAtSdev_act_func output channel=%d\r",dev_num);
347 }
348 else
349 {
350 sprintf ( (char *) pPtr, "\r\n%s\r\n", "+CME ERROR: 6004");
351 path = VP_PATH_HANDSET;
352 *res_msg = at_err_build ("pPtr");
353 *res_msglen = strlen (*res_msg);
354 return AT_END;
355 }
356
357 ret = zDrvVp_SetTxPath(path, isenable);
358 if (ret == DRV_SUCCESS) {
359 *res_msg = at_ok_build();
360 *res_msglen = strlen (*res_msg);
361 return AT_END;
362 }
363
364 *res_msg = at_err_build(ATERR_PROC_FAILED);
365 *res_msglen = strlen (*res_msg);
366
367 return AT_END;
368 }
369 return AT_END;
370}
371#endif
372
373#ifdef _CONFIG_USE_CODEC_EARPIECE_DETECT
374int extAtEarp_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
375{
376 char *at_str = NULL;
377 UINT32 ret = DRV_SUCCESS;
378 T_ZDrv_VpPath path;
379
380 UINT8 pPtr[40] = {0};
381 int a = 0;
382 //CHAR b[6] = {0};
383 UINT16 onOff = 0;
384 at_str = at_paras;
385 at_print(AT_DEBUG,"extAtSdev_act_func, at_paras:%s \n", at_paras);
386
387 ret = sscanf (at_str, "%d", &a);
388 onOff = a;
389 at_print(AT_DEBUG,"extAtSdev_act_func dev_num=0x%d\n", onOff);
390
391 if (ret == 1) {
392 if(onOff == 1)
393 {
394 ret = halEarp_Open();
395 }
396 else
397 {
398 ret = halEarp_Close();
399 }
400
401 if (ret == DRV_SUCCESS) {
402 *res_msg = at_ok_build();
403 *res_msglen = strlen (*res_msg);
404 return AT_END;
405 }
406 }
407 *res_msg = at_err_build(ATERR_PROC_FAILED);
408 *res_msglen = strlen (*res_msg);
409
410 return AT_END;
411}
412#endif
413#ifdef _USE_VOICE_ALSA
414
415
416
417
418
419
420int extAt_VPATH_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
421{
422 char *at_str = NULL;
423 UINT32 ret = DRV_SUCCESS;
424 int path;
425 int a = 0;
426 //CHAR b[6] = {0};
427 UINT16 onOff = 0;
428 at_str = at_paras;
429 at_print(AT_DEBUG,"extAt_VPATH_act_func, at_paras:%s \n", at_paras);
430
431 ret = sscanf (at_str, "%d,%d",&path,&a);
432 onOff = a;
433 at_print(AT_DEBUG,"extAt_VPATH_act_func path =%d,onOff=0x%d\n",path, onOff);
434
435 if (ret == 2) {
436 if(onOff == 1)
437 {
438 ret = set_voice_device_mode(path);
439 printf("extAt_VPATH_act_func on vpath,ret=%d\n",ret);
440 }
441 else
442 {
443 //ret = set_voice_device_mode(path);
444 printf("extAt_VPATH_act_func off vpath not support\n");
445
446 }
447 if (ret == DRV_SUCCESS) {
448 *res_msg = at_ok_build();
449 *res_msglen = strlen (*res_msg);
450 return AT_END;
451 }
452 }
453
454 *res_msg = at_err_build(ATERR_PROC_FAILED);
455 *res_msglen = strlen (*res_msg);
456
457 return AT_END;
458}
459
460int extAt_VALSA_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
461{
462 char *at_str = NULL;
463 UINT32 ret = DRV_SUCCESS;
464
465 int mode = 0;
466 int enable = 0;
467
468 UINT16 onOff = 0;
469 at_str = at_paras;
470 printf("extAt_VALSA_act_func, at_paras:%s \n", at_paras);
471
472 ret = sscanf (at_str, "%d,%d", &mode,&enable);
473 onOff = enable;
474 printf("extAt_VALSA_act_func mode=%d,enable=%d,ret=%d\n",mode,enable,ret);
475
476 if (ret == 2) {
477 if(onOff == 1)
478 {
479 ret = alsa_voice_open(mode);
480 printf("extAt_voice_act_func alsa_voice_open,ret=%d\n",ret);
481 }
482 else
483 {
484 ret = alsa_voice_close(mode);
485 printf("extAt_voice_act_func alsa_voice_close,ret=%d\n",ret);
486
487 }
488 if (ret == DRV_SUCCESS) {
489 *res_msg = at_ok_build();
490 *res_msglen = strlen (*res_msg);
491 return AT_END;
492 }
493 }
494 *res_msg = at_err_build(ATERR_PROC_FAILED);
495 *res_msglen = strlen (*res_msg);
496
497 return AT_END;
498}
499
xf.li742dd022023-06-08 01:43:32 -0700500int extAt_CAP_VALSA_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
501{
502 char *at_str = NULL;
503 UINT32 ret = DRV_SUCCESS;
504
505 int mode = 0;
506 int enable = 0;
507
508 UINT16 onOff = 0;
509 at_str = at_paras;
510 printf("extAt_CAP_VALSA_act_func, at_paras:%s \n", at_paras);
511
512 ret = sscanf (at_str, "%d,%d", &mode,&enable);
513 onOff = enable;
514 printf("extAt_CAP_VALSA_act_func mode=%d,enable=%d,ret=%d\n",mode,enable,ret);
515
516 if (ret == 2) {
517 if(onOff == 1)
518 {
519 ret = cap_alsa_voice_open(mode);
520 printf("extAt_CAP_VALSA_act_func alsa_voice_open,ret=%d\n",ret);
521 }
522 else
523 {
524 ret = cap_alsa_voice_close(mode);
525 printf("extAt_CAP_VALSA_act_func alsa_voice_close,ret=%d\n",ret);
526
527 }
528 if (ret == DRV_SUCCESS) {
529 *res_msg = at_ok_build();
530 *res_msglen = strlen (*res_msg);
531 return AT_END;
532 }
533 }
534 *res_msg = at_err_build(ATERR_PROC_FAILED);
535 *res_msglen = strlen (*res_msg);
536
537 return AT_END;
538}
xf.lie31de8b2023-12-26 23:38:58 -0800539#endif
xf.li742dd022023-06-08 01:43:32 -0700540
xf.lidf7f8ba2024-09-12 23:53:34 -0700541#ifdef _USE_VOICE_AT
542
543int extAt_Voice_Process_set (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
544{
545 char *at_str = NULL;
546 UINT32 ret = DRV_SUCCESS;
547
548 int mode = 0;
549 int vp = 0;
550
551 UINT16 onOff = 0;
552 at_str = at_paras;
553 printf("%s, at_paras:%s \n",__func__, at_paras);
554
555 ret = sscanf (at_str, "%d", &vp);
556 printf("%s: vp=%d,ret=%d\n",__func__,vp,ret);
557
558 if (ret == 1) {
559
560 ret = voice_SetVoiceProcess(&vp);
561 printf("%s: alsa_voice_open,ret=%d\n",__func__,ret);
562
563 if (ret == DRV_SUCCESS) {
564 *res_msg = at_ok_build();
565 *res_msglen = strlen (*res_msg);
566 return AT_END;
567 }
568 }
569 *res_msg = at_err_build(ATERR_PROC_FAILED);
570 *res_msglen = strlen (*res_msg);
571
572 return AT_END;
573}
574
575
576
577int extAt_Voice_Process_get(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
578{
579
580
581
582 char vp_str[32] = {0};
583 printf("%s: %s\n",__func__,at_paras);
584 int vp = voice_GetVoiceProcess();
585 if( vp < 0)
586 {
587 *res_msg = at_err_build(ATERR_PROC_FAILED);
588 *res_msglen = strlen(*res_msg);
589 return AT_END;
590 }
591 printf("%s: vp=%d",__func__,vp);
592
593 snprintf(vp_str, 32,"%d\r\n",vp);
594
595 *res_msg = at_query_result_build("AT+VOICEPROCESS",vp_str);
596 *res_msglen = strlen(*res_msg);
597 return AT_END;
598
599}
600
601
602
603
604int extAt_VoiceBuffer_Set (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
605{
606 char *at_str = NULL;
607 UINT32 ret = DRV_SUCCESS;
608
609 int enable = 0;
610 int type = 0;
611 T_VoiceBuf_Para vb;
612 at_str = at_paras;
613 printf("%s, at_paras:%s \n",__func__, at_paras);
614
615 //ret = sscanf (at_str, "%d", &vp);
616
617 ret = sscanf (at_str, "%d,%d", &enable,&type);
618 printf("%s: enable=%d type=%d,ret=%d\n",__func__,enable,type,ret);
619
620 if (ret == 2) {
621 vb.enable = enable;
622 vb.type = type;
623
624 ret = voice_SetVoiceBuffer(&vb);
625 printf("%s: voice_SetVoiceBuffer,ret=%d\n",__func__,ret);
626
627 if (ret == DRV_SUCCESS) {
628 *res_msg = at_ok_build();
629 *res_msglen = strlen (*res_msg);
630 return AT_END;
631 }
632 }
633 *res_msg = at_err_build(ATERR_PROC_FAILED);
634 *res_msglen = strlen (*res_msg);
635
636 return AT_END;
637}
638
639
640int extAt_VoiceBuffer_Get(int at_fd,char * at_paras,void **res_msg,int * res_msglen)
641{
642 UINT32 ret = DRV_SUCCESS;
643
644 T_VoiceBuf_Para vb;
645
646
647 char vp_str[32] = {0};
648 printf("%s: %s\n",__func__,at_paras);
649 ret = voice_GetVoiceBuffer(&vb);
650 if( ret < 0)
651 {
652 *res_msg = at_err_build(ATERR_PROC_FAILED);
653 *res_msglen = strlen(*res_msg);
654 return AT_END;
655 }
656 printf("%s: fs=%d enable=%d type=%d",__func__,vb.fs,vb.enable,vb.type);
657
658 snprintf(vp_str, 32,"%d %d %d\r\n",vb.fs,vb.enable,vb.type);
659
660 *res_msg = at_query_result_build("AT+VOICE_BUFFER",vp_str);
661 *res_msglen = strlen(*res_msg);
662 return AT_END;
663
664}
665
666
667#endif
668
xf.lie31de8b2023-12-26 23:38:58 -0800669#ifdef _VBUFF_IN_SINGLE_CORE
670int extAt_VBUFFER_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
671{
672 char *at_str = NULL;
673 UINT32 ret = DRV_SUCCESS;
674
675 int mode = 0;
676 int enable = 0;
677
678 UINT16 onOff = 0;
679 at_str = at_paras;
680 printf("extAt_VBUFFER_act_func, at_paras:%s \n", at_paras);
681
682 ret = sscanf (at_str, "%d", &enable);
683 onOff = enable;
684 printf("extAt_VBUFFER_act_func enable=%d,ret=%d\n",enable,ret);
685
686 if (ret == 1) {
687 if(onOff == 1)
688 {
689 ret = vbuffer_stream_start();
690 printf("extAt_VBUFFER_act_func vbuffer_stream_start,ret=%d\n",ret);
691 }
692 else
693 {
694 ret = vbuffer_stream_stop();
695 printf("extAt_VBUFFER_act_func vbuffer_stream_stop,ret=%d\n",ret);
696 }
697 if (ret == DRV_SUCCESS) {
698 *res_msg = at_ok_build();
699 *res_msglen = strlen (*res_msg);
700 return AT_END;
701 }
702 }
703 *res_msg = at_err_build(ATERR_PROC_FAILED);
704 *res_msglen = strlen (*res_msg);
705
706 return AT_END;
707}
xf.libdd93d52023-05-12 07:10:14 -0700708#endif
709
710void ext_audio_regist_init(void)
711{
712 printf("ext_audio_regist_init! \n");
713
714#ifdef _CONFIG_USE_CODEC
715 register_serv_func2("WRCODEC=", 0, 0, 0, codecWrite_act_func, NULL);
716 register_serv_func2("RDCODEC=", 0, 0, 0, codecRead_act_func, NULL);
717 register_serv_func2("DUMPCODECREG=", 0, 0, 0, codecDump_act_func, NULL);
718 register_serv_func2("ExtAT_SDEV=", 0, 0, 0, extAtSdev_act_func, NULL);
719 register_serv_func2("ExtAT_RXPATH=", 0, 0, 0, extAtRxPath_act_func, NULL);
720 register_serv_func2("ExtAT_TXPATH=", 0, 0, 0, extAtTxPath_act_func, NULL);
721#endif
722#ifdef _CONFIG_USE_CODEC_EARPIECE_DETECT
723 register_serv_func2("ExtAT_EARP=", 0, 0, 0, extAtEarp_act_func, NULL);
724#endif
725
726#ifdef _USE_VOICE_ALSA
727
728 register_serv_func2("VALSA=", 0, 0, 0, extAt_VALSA_act_func, NULL);
729 register_serv_func2("VPATH=", 0, 0, 0, extAt_VPATH_act_func, NULL);
xf.li742dd022023-06-08 01:43:32 -0700730 register_serv_func2("CAP_VALSA=", 0, 0, 0, extAt_CAP_VALSA_act_func, NULL);
xf.libdd93d52023-05-12 07:10:14 -0700731#endif
xf.lie31de8b2023-12-26 23:38:58 -0800732
733#ifdef _VBUFF_IN_SINGLE_CORE
734 register_serv_func2("VBUFFER=", 0, 0, 0, extAt_VBUFFER_act_func, NULL);
735#endif
736
xf.lidf7f8ba2024-09-12 23:53:34 -0700737#ifdef _USE_VOICE_AT
738register_serv_func2("VOICE_PROCESS=",0,0,0,extAt_Voice_Process_set, NULL);
739register_serv_func2("VOICE_PROCESS?",0,0,0,extAt_Voice_Process_get, NULL);
740
741register_serv_func2("VOICE_BUFFER=",0,0,0,extAt_VoiceBuffer_Set, NULL);
742register_serv_func2("VOICE_BUFFER?",0,0,0,extAt_VoiceBuffer_Get, NULL);
743#endif
744
745
746
747
xf.libdd93d52023-05-12 07:10:14 -0700748}
749
750#endif