lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /*****************************************************************************
|
| 2 | ** °æÈ¨ËùÓÐ (C)2015, ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
|
| 3 | **
|
| 4 | ** ÎļþÃû³Æ: voice.c
|
| 5 | ** Îļþ±êʶ:
|
| 6 | ** ÄÚÈÝÕªÒª:
|
| 7 | ** ʹÓ÷½·¨:
|
| 8 | **
|
| 9 | ** ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ Ð޸ıê¼Ç ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
|
| 10 | ** -----------------------------------------------------------------------------
|
| 11 | ** 2019/09/25 V1.0 Create xxq ´´½¨
|
| 12 | **
|
| 13 | * ******************************************************************************/
|
| 14 |
|
| 15 | #include <stdio.h>
|
| 16 | #include <unistd.h>
|
| 17 | #include <string.h>
|
| 18 | #include <stdlib.h>
|
| 19 |
|
| 20 | #include <stdint.h>
|
| 21 | #include <linux/volte_drv.h>
|
| 22 | #include <sys/ioctl.h>
|
| 23 | #include <fcntl.h>
|
| 24 | #include <tinyalsa/audio_mixer_ctrl.h>
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 25 | #include "voice_lib.h"
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 26 | #include "voice_ipc.h"
|
| 27 |
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 28 |
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 29 |
|
xf.li | 7ccf837 | 2024-03-07 00:08:02 -0800 | [diff] [blame] | 30 | //#define VOICE_DEV_NAME "/dev/voice_device"
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 31 |
|
| 32 |
|
| 33 |
|
| 34 | typedef struct {
|
| 35 | int fd;
|
| 36 | unsigned int state; // 0 close;1 open
|
| 37 | T_Voice_Para vpara;
|
| 38 | } T_voiceInfo;
|
| 39 |
|
| 40 | T_voiceInfo *voiceinfo = NULL;
|
| 41 |
|
| 42 | static int slic_flag = 0;
|
| 43 | static int slic_flag_already = 0;// 0 not get ,1 already get
|
| 44 |
|
| 45 | struct pcm *volte_pcm_voice_out = NULL;
|
| 46 | struct pcm *volte_pcm_voice_in = NULL;
|
| 47 |
|
| 48 | #if 0
|
| 49 |
|
| 50 |
|
| 51 | T_Voice_Para gsmhwpara = {
|
| 52 | 8000, //8000;16000
|
| 53 | 0, //// 0 gsm;1 td;2 wcdma;3 lte
|
| 54 | 0//0 hardware dsp;1 soft amr lib
|
| 55 | };
|
| 56 |
|
| 57 | T_Voice_Para tdnbhwpara = {
|
| 58 | 8000, //8000;16000
|
| 59 | 1, //// 0 gsm;1 td;2 wcdma;3 lte
|
| 60 | 0,//0 amr-nb;1 amr-wb
|
| 61 | 0//0 hardware dsp;1 soft amr lib
|
| 62 | };
|
| 63 |
|
| 64 | T_Voice_Para tdnbsfpara = {
|
| 65 | 8000, //8000;16000
|
| 66 | 1, //// 0 gsm;1 td;2 wcdma;3 lte
|
| 67 | 0,//0 amr-nb;1 amr-wb
|
| 68 | 1//0 hardware dsp;1 soft amr lib
|
| 69 | };
|
| 70 |
|
| 71 | T_Voice_Para tdwbsfpara = {
|
| 72 | 8000, //8000;16000
|
| 73 | 1, //// 0 gsm;1 td;2 wcdma;3 lte
|
| 74 | 1,//0 amr-nb;1 amr-wb
|
| 75 | 1//0 hardware dsp;1 soft amr lib
|
| 76 | };
|
| 77 |
|
| 78 |
|
| 79 | #endif
|
| 80 | //static volatile int voiceinfo.fd = 0;
|
| 81 |
|
| 82 |
|
| 83 | int voice_open(T_Voice_Para *para)
|
| 84 | {
|
| 85 | int ret = 0;
|
| 86 | if (!para) {
|
| 87 |
|
| 88 | printf("voice: open para is NULL.\n");
|
| 89 |
|
| 90 | return -1;
|
| 91 | }
|
| 92 |
|
| 93 | voiceinfo = calloc(1, sizeof(T_voiceInfo));
|
| 94 | if (!voiceinfo) {
|
| 95 |
|
| 96 | printf("voice: open calloc fail!\n");
|
| 97 | return -1;
|
| 98 | }
|
| 99 |
|
| 100 | voiceinfo->vpara = *para;
|
| 101 |
|
| 102 | voiceinfo->fd = open(VOICE_DEV_NAME, O_RDONLY);
|
| 103 | if (voiceinfo->fd < 0) {
|
| 104 | printf("voice lib: open voice device error.\n");
|
| 105 | free(voiceinfo);
|
| 106 | return -1;
|
| 107 |
|
| 108 | }
|
| 109 |
|
| 110 |
|
| 111 | ret = ioctl(voiceinfo->fd, VOICE_IOCTL_START, para);
|
| 112 | if (ret) {
|
| 113 | printf("voice lib: voice start fd=%d,ret=%d.\n", voiceinfo->fd, ret);
|
| 114 | goto err;
|
| 115 | }
|
| 116 | printf("voice open end !\n");
|
| 117 |
|
| 118 | return 0;
|
| 119 |
|
| 120 | err:
|
| 121 | close(voiceinfo->fd);
|
| 122 | free(voiceinfo);
|
| 123 | printf("voice open err end !\n");
|
| 124 | return -1;
|
| 125 |
|
| 126 |
|
| 127 | }
|
| 128 |
|
| 129 |
|
| 130 | int voice_close(T_Voice_Para *para)
|
| 131 | {
|
| 132 | int ret = 0;
|
| 133 |
|
| 134 | if (!voiceinfo) {
|
| 135 |
|
| 136 | printf("voice: close voiceinfo is NUll!\n");
|
| 137 | return 0;
|
| 138 | }
|
| 139 |
|
| 140 | ret = ioctl(voiceinfo->fd, VOICE_IOCTL_STOP, para);
|
| 141 |
|
| 142 | if (ret) {
|
| 143 | printf("voice lib: voice stop fd=%d,ret=%d.\n", voiceinfo->fd, ret);
|
| 144 | }
|
| 145 |
|
| 146 | if (voiceinfo->fd >= 0) {
|
| 147 | close(voiceinfo->fd);
|
| 148 | }
|
| 149 | voiceinfo->fd = -1;
|
| 150 |
|
| 151 | free(voiceinfo);
|
| 152 | voiceinfo = NULL;
|
| 153 |
|
| 154 | printf("voice close end !\n");
|
| 155 |
|
| 156 | return 0;
|
| 157 | }
|
| 158 | int voice_Vploop(int *path)
|
| 159 | {
|
| 160 | int ret = 0;
|
| 161 | int fd = -1;
|
| 162 | printf("voice_Vploop: start path=%d!\n",*path);
|
| 163 | fd = open(VOICE_DEV_NAME, O_RDONLY);
|
| 164 | if (fd < 0) {
|
| 165 | printf("voice_Vploop: open voice device error.\n");
|
| 166 | return -1;
|
| 167 | }
|
| 168 | ret = ioctl(fd, VOICE_IOCTL_VPLOOP, path);
|
| 169 | if (ret) {
|
q.huang | 16c52a1 | 2024-08-06 17:50:47 +0800 | [diff] [blame^] | 170 | printf("voice_Vploop: ret=%d,path=%d.\n", ret, *path);
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 171 | close(fd);
|
| 172 | return -1;
|
| 173 | }
|
| 174 | close(fd);
|
| 175 | return 0;
|
| 176 |
|
| 177 | }
|
| 178 |
|
| 179 | int voice_GetSlicFlag(void)
|
| 180 | {
|
| 181 | int ret = 0;
|
| 182 | int fd = -1;
|
| 183 | int flag = 0;
|
| 184 | printf("voice_GetSlicFlag: start!\n");
|
| 185 | fd = open(VOICE_DEV_NAME, O_RDONLY);
|
| 186 | if (fd < 0) {
|
| 187 | printf("voice_GetSlicFlag: open voice device error.\n");
|
| 188 | return -1;
|
| 189 | }
|
| 190 | ret = ioctl(fd, VOICE_IOCTL_GET_SLIC_USE_FLAG, &flag);
|
| 191 | if (ret) {
|
| 192 | printf("voice_GetSlicFlag: ret=%d,flag=%d.\n", ret, flag);
|
| 193 | close(fd);
|
| 194 | return -1;
|
| 195 | }
|
| 196 | close(fd);
|
| 197 | slic_flag_already = 1;
|
| 198 | return flag;
|
| 199 |
|
| 200 | }
|
| 201 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 202 | static T_ZDrvVoice_Cfg s_cfgParam = {0};
|
| 203 | static int cur_vmode = MAX_AVOICE_MODE;
|
| 204 |
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 205 | int zDrvVolte_PreOpen(T_ZDrvVolte_Cfg *cfgParam)
|
| 206 | {
|
| 207 |
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 208 | struct mixer *voice_mixer = NULL;
|
| 209 | struct pcm_config config_voice = {0};
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 210 | int ret = 0;
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 211 | printf(" voice lib zDrvVolte_PreOpen!\n");
|
| 212 |
|
| 213 | if (slic_flag_already == 1) {
|
| 214 | printf(" voice slic flag already get, slic_flag=%d!\n", slic_flag);
|
| 215 | if (slic_flag == 1) {
|
| 216 | return 0;
|
| 217 | }
|
| 218 |
|
| 219 | } else {
|
| 220 | slic_flag = voice_GetSlicFlag();
|
| 221 | printf(" voice slic flag get, slic_flag=%d!\n", slic_flag);
|
| 222 | if (slic_flag == 1) {
|
| 223 | return 0;
|
| 224 | }
|
| 225 | }
|
xf.li | e31de8b | 2023-12-26 23:38:58 -0800 | [diff] [blame] | 226 | #if defined(_VBUFF_IN_SINGLE_CORE) || defined(_VBUFF_IN_MULTI_CORE)
|
q.huang | 16c52a1 | 2024-08-06 17:50:47 +0800 | [diff] [blame^] | 227 | printf("%s: ap use voice buffer,return!\n",__func__);
|
xf.li | e31de8b | 2023-12-26 23:38:58 -0800 | [diff] [blame] | 228 | return 0;
|
| 229 |
|
| 230 | #endif
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 231 | #if defined(_ALSA_CODEC_IN_CAP) && defined(_USE_ALSA_AT_INTF)
|
q.huang | 16c52a1 | 2024-08-06 17:50:47 +0800 | [diff] [blame^] | 232 | printf("%s:_ALSA_CODEC_IN_CAP and at intf!\n",__func__);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 233 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 234 |
|
q.huang | 16c52a1 | 2024-08-06 17:50:47 +0800 | [diff] [blame^] | 235 | printf("%s:ap i2s and codec not need config,return!\n",__func__);
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 236 | return 0;
|
| 237 |
|
| 238 | #elif defined(_ALSA_CODEC_IN_CAP)
|
| 239 |
|
q.huang | 16c52a1 | 2024-08-06 17:50:47 +0800 | [diff] [blame^] | 240 | printf("%s:_ALSA_CODEC_IN_CAP!\n",__func__);
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 241 |
|
| 242 | if(cfgParam->clock_rate == 8000){
|
| 243 |
|
| 244 | ret = cap_alsa_voice_open(AVOICE_4G_NB);
|
| 245 | printf("%s:cap_alsa_voice_open clock_rate(%d) ret=%d!\n",__func__,cfgParam->clock_rate,ret);
|
| 246 | cur_vmode = AVOICE_4G_NB;
|
| 247 |
|
| 248 | }
|
| 249 | else if(cfgParam->clock_rate == 16000){
|
| 250 |
|
| 251 | ret = cap_alsa_voice_open(AVOICE_4G_WB);
|
| 252 | printf("%s:cap_alsa_voice_open clock_rate(%d) ret=%d!\n",__func__,cfgParam->clock_rate,ret);
|
| 253 | cur_vmode = AVOICE_4G_WB;
|
| 254 | }
|
| 255 | else{
|
| 256 |
|
| 257 | printf("%s:cap_alsa_voice_open clock_rate(%d) not support!\n",__func__,cfgParam->clock_rate);
|
| 258 | return -2;
|
| 259 |
|
| 260 | }
|
| 261 | s_cfgParam = *cfgParam;
|
| 262 | return ret;
|
| 263 |
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 264 | #endif
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 265 |
|
q.huang | 16c52a1 | 2024-08-06 17:50:47 +0800 | [diff] [blame^] | 266 | printf("%s:ap do mixer and pcm opt!\n",__func__);
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 267 |
|
| 268 | //open mixer dev for codec control
|
| 269 | voice_mixer = mixer_open(0);
|
| 270 | if (!voice_mixer) {
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 271 | printf("voice_mixer open failed!\n");
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 272 | return -1;
|
| 273 | }
|
| 274 |
|
| 275 | //config mixer dev
|
| 276 | mix_set_voice_path(voice_mixer, T_OUTPUT_SPEAKER);
|
| 277 | mix_set_voice_vol(voice_mixer, T_VOICE_VOL_3_LEVEL);
|
| 278 |
|
| 279 | //close mixer
|
| 280 | mixer_close(voice_mixer);
|
| 281 | voice_mixer = NULL;
|
| 282 |
|
| 283 | //open pcm dev for data tranf
|
| 284 | config_voice.channels = cfgParam->channel_count;
|
| 285 | config_voice.rate = cfgParam->clock_rate;
|
| 286 | //buffer num
|
| 287 | config_voice.period_count = 3;
|
| 288 | //buffer size
|
| 289 | config_voice.period_size = cfgParam->samples_per_frame * cfgParam->bits_per_sample / 8;
|
| 290 | //16-bit signed
|
| 291 | config_voice.format = PCM_FORMAT_S16_LE;
|
| 292 |
|
| 293 | //card 0 dev 1
|
| 294 | //23G card 0 dev 2
|
| 295 | volte_pcm_voice_out = pcm_open(0, 1, PCM_OUT, &config_voice);
|
| 296 | if (!pcm_is_ready(volte_pcm_voice_out)) {
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 297 | printf("volte_pcm_voice_out open failed!\n");
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 298 | goto err_ret;
|
| 299 | }
|
| 300 |
|
| 301 | volte_pcm_voice_in = pcm_open(0, 1, PCM_IN, &config_voice);
|
| 302 | if (!pcm_is_ready(volte_pcm_voice_in)) {
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 303 | printf("volte_pcm_voice_in open failed!\n");
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 304 | goto err_ret;
|
| 305 | }
|
| 306 |
|
| 307 | if (0 != pcm_prepare(volte_pcm_voice_out)) {
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 308 | printf("volte_pcm_voice_out pcm_prepare failed!\n");
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 309 | goto err_ret;
|
| 310 | }
|
| 311 |
|
| 312 | if (0 != pcm_prepare(volte_pcm_voice_in)) {
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 313 | printf("volte_pcm_voice_in pcm_prepare failed!\n");
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 314 | goto err_ret;
|
| 315 | }
|
| 316 | return 0;
|
| 317 | err_ret:
|
| 318 |
|
| 319 | pcm_close(volte_pcm_voice_out);
|
| 320 | volte_pcm_voice_out = NULL;
|
| 321 |
|
| 322 | if (volte_pcm_voice_in) {
|
| 323 | pcm_close(volte_pcm_voice_in);
|
| 324 | volte_pcm_voice_in = NULL;
|
| 325 | }
|
| 326 | return -1;
|
| 327 |
|
| 328 | }
|
| 329 |
|
| 330 | void zDrvVolte_PreClose(void)
|
| 331 | {
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 332 | int ret = 0;
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 333 |
|
| 334 | printf(" voice lib zDrvVolte_PreClose!\n");
|
| 335 |
|
| 336 | if (slic_flag_already == 1) {
|
| 337 | printf(" voice slic flag already get, slic_flag=%d!\n", slic_flag);
|
| 338 | if (slic_flag == 1) {
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 339 | return;
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 340 | }
|
| 341 |
|
| 342 | } else {
|
| 343 | slic_flag = voice_GetSlicFlag();
|
| 344 | printf(" voice slic flag get, slic_flag=%d!\n", slic_flag);
|
| 345 | if (slic_flag == 1) {
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 346 | return;
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 347 | }
|
| 348 | }
|
xf.li | e31de8b | 2023-12-26 23:38:58 -0800 | [diff] [blame] | 349 | #if defined(_VBUFF_IN_SINGLE_CORE) || defined(_VBUFF_IN_MULTI_CORE)
|
| 350 | printf("%s: use voice buffer,return!\n",__func__);
|
| 351 | return 0;
|
| 352 |
|
| 353 | #endif
|
| 354 |
|
| 355 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 356 | #if defined(_ALSA_CODEC_IN_CAP) && defined(_USE_ALSA_AT_INTF)
|
| 357 |
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 358 | printf("%s: i2s and codec not need config,return!\n",__func__);
|
| 359 | return ;
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 360 | #elif defined(_ALSA_CODEC_IN_CAP)
|
| 361 | if(s_cfgParam.clock_rate == 8000){
|
| 362 |
|
| 363 | ret = cap_alsa_voice_close(AVOICE_4G_NB);
|
| 364 | printf("%s:cap_alsa_voice_close clock_rate(%d) ret=%d!\n",__func__,s_cfgParam.clock_rate,ret);
|
| 365 |
|
| 366 | }
|
| 367 | else if(s_cfgParam.clock_rate == 16000){
|
| 368 |
|
| 369 | ret = cap_alsa_voice_close(AVOICE_4G_WB);
|
| 370 | printf("%s:cap_alsa_voice_close clock_rate(%d) ret=%d!\n",__func__,s_cfgParam.clock_rate,ret);
|
| 371 |
|
| 372 | }
|
| 373 | else{
|
| 374 |
|
| 375 | printf("%s:cap_alsa_voice_close clock_rate(%d) not support!\n",__func__,s_cfgParam.clock_rate);
|
| 376 |
|
| 377 | }
|
| 378 | return;
|
| 379 |
|
| 380 |
|
| 381 |
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 382 | #endif
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 383 |
|
| 384 |
|
| 385 | if (volte_pcm_voice_out) {
|
| 386 | pcm_close(volte_pcm_voice_out);
|
| 387 | volte_pcm_voice_out = NULL;
|
| 388 | }
|
| 389 | if (volte_pcm_voice_in) {
|
| 390 | pcm_close(volte_pcm_voice_in);
|
| 391 | volte_pcm_voice_in = NULL;
|
| 392 | }
|
| 393 | }
|
| 394 |
|
| 395 |
|
q.huang | 16c52a1 | 2024-08-06 17:50:47 +0800 | [diff] [blame^] | 396 | int voice_SetVoiceProcess(int *vp)
|
| 397 | {
|
| 398 | int ret = 0;
|
| 399 | int fd = -1;
|
| 400 | printf("%s: start vp=%d!\n",__func__,*vp);
|
| 401 | fd = open(VOICE_DEV_NAME, O_RDONLY);
|
| 402 | if (fd < 0) {
|
| 403 | printf("%s: open voice device error.\n",__func__);
|
| 404 | return -1;
|
| 405 | }
|
| 406 | ret = ioctl(fd, VOICE_IOCTL_SET_VP, vp);
|
| 407 | if (ret) {
|
| 408 | printf("%s: ret=%d,vp=%d.\n",__func__, ret, *vp);
|
| 409 | close(fd);
|
| 410 | return -1;
|
| 411 | }
|
| 412 | close(fd);
|
| 413 | return 0;
|
| 414 |
|
| 415 | }
|
| 416 | int voice_GetVoiceProcess(void)
|
| 417 | {
|
| 418 | int ret = 0;
|
| 419 | int fd = -1;
|
| 420 | int vp = 0;
|
| 421 | fd = open(VOICE_DEV_NAME, O_RDONLY);
|
| 422 | if (fd < 0) {
|
| 423 | printf("%s: open voice device error.\n",__func__);
|
| 424 | return -1;
|
| 425 | }
|
| 426 | ret = ioctl(fd, VOICE_IOCTL_GET_VP, &vp);
|
| 427 | if (ret) {
|
| 428 | printf("%s: ret=%d,vp=%d.\n",__func__, ret, vp);
|
| 429 | close(fd);
|
| 430 | return -1;
|
| 431 | }
|
| 432 | close(fd);
|
| 433 | printf("%s: vp=%d!\n",__func__,vp);
|
| 434 |
|
| 435 | return vp;
|
| 436 |
|
| 437 | }
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 438 |
|
| 439 |
|
| 440 |
|
q.huang | 16c52a1 | 2024-08-06 17:50:47 +0800 | [diff] [blame^] | 441 |
|
| 442 | int voice_SetVoiceBuffer(T_VoiceBuf_Para *vb)
|
| 443 | {
|
| 444 | int ret = 0;
|
| 445 | int fd = -1;
|
| 446 | printf("%s: start enable=%d,type=%d!\n",__func__,vb->enable,vb->type);
|
| 447 | fd = open(VOICE_DEV_NAME, O_RDONLY);
|
| 448 | if (fd < 0) {
|
| 449 | printf("%s: open voice device error.\n",__func__);
|
| 450 | return -1;
|
| 451 | }
|
| 452 | ret = ioctl(fd, VOICE_IOCTL_SET_VBUF, vb);
|
| 453 | if (ret) {
|
| 454 | printf("%s: ret=%d.\n",__func__, ret);
|
| 455 | close(fd);
|
| 456 | return -1;
|
| 457 | }
|
| 458 | close(fd);
|
| 459 | return 0;
|
| 460 |
|
| 461 | }
|
| 462 |
|
| 463 | int voice_GetVoiceBuffer(T_VoiceBuf_Para *vb)
|
| 464 | {
|
| 465 | int ret = 0;
|
| 466 | int fd = -1;
|
| 467 | fd = open(VOICE_DEV_NAME, O_RDONLY);
|
| 468 | if (fd < 0) {
|
| 469 | printf("%s: open voice device error.\n",__func__);
|
| 470 | return -1;
|
| 471 | }
|
| 472 | ret = ioctl(fd, VOICE_IOCTL_GET_VBUF, vb);
|
| 473 | if (ret) {
|
| 474 | printf("%s: ret=%d.\n",__func__, ret);
|
| 475 | close(fd);
|
| 476 | return -1;
|
| 477 | }
|
| 478 | close(fd);
|
| 479 | printf("%s: start fs=%d enable=%d,type=%d!\n",__func__,vb->fs,vb->enable,vb->type);
|
| 480 |
|
| 481 |
|
| 482 | return ret;
|
| 483 |
|
| 484 | }
|
| 485 |
|