xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 1 | #ifdef USE_CAP_SUPPORT
|
| 2 | #include <stdio.h>
|
| 3 | #include <unistd.h>
|
| 4 | #include <string.h>
|
| 5 | #include <stdlib.h>
|
| 6 | #include <stdint.h>
|
| 7 | #include <sys/ioctl.h>
|
| 8 | #include <fcntl.h>
|
| 9 | #include "voice_ipc.h"
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 10 | #include "voice_lib.h"
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 11 | #include "linux/rpmsg_zx29.h"
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 12 | #include "softap_api.h"
|
| 13 | #include "pthread.h"
|
xf.li | 7ccf837 | 2024-03-07 00:08:02 -0800 | [diff] [blame] | 14 | #include <linux/volte_drv.h>
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 15 |
|
| 16 | extern int sc_audio_set_voice_device_mode(int dev_mode);
|
| 17 | extern int sc_audio_get_voice_device_mode(int *p_dev_mode);
|
| 18 | extern int sc_audio_set_rx_voice_vol(int vol);
|
| 19 | extern int sc_audio_get_rx_voice_vol(int * p_vol);
|
| 20 | extern int sc_audio_set_tx_voice_vol(int vol);
|
| 21 | extern int sc_audio_get_tx_voice_vol(int *p_vol);
|
| 22 | extern int sc_audio_set_tx_voice_mute_state(int mute );
|
| 23 | extern int sc_audio_get_tx_voice_mute_state(int *p_mute);
|
| 24 | extern int sc_audio_set_rx_voice_mute_state(int mute);
|
| 25 | extern int sc_audio_get_rx_voice_mute_state(int *p_mute);
|
lh | 758261d | 2023-07-13 05:52:04 -0700 | [diff] [blame] | 26 | //extern int sc_audio_set_loopback_enable_state(int enable);
|
| 27 | //extern int sc_audio_get_loopback_enable_state(int *p_enable);
|
| 28 | int ap_audio_set_loopback_enable(int dev_mode,int enable);
|
| 29 | int ap_audio_get_loopback_enable(int *p_enable);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 30 |
|
xf.li | 7ccf837 | 2024-03-07 00:08:02 -0800 | [diff] [blame] | 31 | static unsigned char *recv_voice_nvrw_buf = NULL;
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 32 | static int voice_ipc_fd = -1;
|
| 33 | static voice_ipc_control_msg voice_ctrl_recvmsg[IPC_VOICE_FUNC_MAX] = {0};
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 34 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 35 | int cap_alsa_voice_open(int vmode)
|
| 36 | {
|
| 37 | int ret = 0;
|
| 38 | int msg_handle = 0;
|
| 39 | MSG_BUF msg;
|
| 40 | LONG msg_size = sizeof(MSG_BUF)-sizeof(LONG);
|
| 41 | int module_id = MODULE_ID_VOICE_CLIENT;
|
| 42 | int dst_id = MODULE_ID_VOICE_SERVER;
|
| 43 | int msg_cmd = MSG_CMD_CAP_VALSA_OPEN;
|
xf.li | 7ccf837 | 2024-03-07 00:08:02 -0800 | [diff] [blame] | 44 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 45 | //´´½¨ÏûÏ¢¶ÓÁÐ
|
| 46 | msg_handle = msgget(module_id, IPC_CREAT|0600);
|
| 47 |
|
| 48 | //·¢ËÍÏûÏ¢
|
| 49 | ret = ipc_send_message(module_id, dst_id, msg_cmd, sizeof(int), (unsigned char *)(&vmode), 0);
|
| 50 | if(0 != ret){
|
| 51 | printf("%s: send msg error(%d)!\n", __func__, ret);
|
| 52 | msgctl(msg_handle,IPC_RMID,0);
|
| 53 | return ret;
|
| 54 | }
|
| 55 | printf("%s: send msg success(%d)!\n", __func__, ret);
|
| 56 |
|
| 57 | //½ÓÊÕÏûÏ¢
|
| 58 | while(1)
|
| 59 | {
|
| 60 | memset(&msg, 0x00, sizeof(MSG_BUF));
|
| 61 |
|
| 62 | //»ñÈ¡ÏûÏ¢¶ÓÁÐÏûÏ¢²¢´¦Àí
|
| 63 | ret = msgrcv(msg_handle, &msg, msg_size, 0, 0);
|
| 64 | if(0 > ret){
|
| 65 | continue;
|
| 66 | }
|
| 67 |
|
| 68 | //Æ¥Åäµ½ÊÇMSG_CMD_CAP_VALSA_OPENʱ²Å´¦Àí
|
| 69 | if(msg_cmd == msg.usMsgCmd){
|
| 70 | ret = *((int *)msg.aucDataBuf);
|
| 71 | msgctl(msg_handle,IPC_RMID,0);
|
| 72 | printf("%s: receive msg success(%d)!\n", __func__, ret);
|
| 73 | break;
|
| 74 | }
|
| 75 | }
|
| 76 |
|
| 77 | return ret;
|
| 78 | }
|
| 79 |
|
| 80 | int cap_alsa_voice_close(int vmode)
|
| 81 | {
|
| 82 | int ret = 0;
|
| 83 | int msg_handle = 0;
|
| 84 | MSG_BUF msg;
|
| 85 | LONG msg_size = sizeof(MSG_BUF)-sizeof(LONG);
|
| 86 | int module_id = MODULE_ID_VOICE_CLIENT;
|
| 87 | int dst_id = MODULE_ID_VOICE_SERVER;
|
| 88 | int msg_cmd = MSG_CMD_CAP_VALSA_CLOSE;
|
| 89 |
|
| 90 | //´´½¨ÏûÏ¢¶ÓÁÐ
|
| 91 | msg_handle = msgget(module_id, IPC_CREAT|0600);
|
| 92 |
|
| 93 | //·¢ËÍÏûÏ¢
|
| 94 | ret = ipc_send_message(module_id, dst_id, msg_cmd, sizeof(int), (unsigned char *)(&vmode), 0);
|
| 95 | if(0 != ret){
|
| 96 | printf("%s: send msg error(%d)!\n", __func__, ret);
|
| 97 | msgctl(msg_handle,IPC_RMID,0);
|
| 98 | return ret;
|
| 99 | }
|
| 100 | printf("%s: send msg success(%d)!\n", __func__, ret);
|
| 101 |
|
| 102 | //½ÓÊÕÏûÏ¢
|
| 103 | while(1)
|
| 104 | {
|
| 105 | memset(&msg, 0x00, sizeof(MSG_BUF));
|
| 106 |
|
| 107 | //»ñÈ¡ÏûÏ¢¶ÓÁÐÏûÏ¢²¢´¦Àí
|
| 108 | ret = msgrcv(msg_handle, &msg, msg_size, 0, 0);
|
| 109 | if(0 > ret){
|
| 110 | continue;
|
| 111 | }
|
| 112 |
|
| 113 | //Æ¥Åäµ½ÊÇMSG_CMD_CAP_VALSA_CLOSEʱ²Å´¦Àí
|
| 114 | if(msg_cmd == msg.usMsgCmd){
|
| 115 | ret = *((int *)msg.aucDataBuf);
|
| 116 | msgctl(msg_handle,IPC_RMID,0);
|
| 117 | printf("%s: receive msg success(%d)!\n", __func__, ret);
|
| 118 | break;
|
| 119 | }
|
| 120 | }
|
| 121 |
|
| 122 | return ret;
|
| 123 | }
|
| 124 |
|
| 125 | int ipc_cap_alsa_voice_open(int vmode)
|
| 126 | {
|
| 127 | int ret = 0;
|
| 128 | int func_id = IPC_CAP_ALSA_VOICE_OPEN;
|
| 129 | voice_ctrl_recvmsg[func_id].func_id = VOICE_WAIT_MSG_FROM_CAP;
|
| 130 |
|
| 131 | ret = Voice_Ctrl_Rpmsg_Send(func_id, &vmode);
|
| 132 |
|
| 133 | if (0 >= ret){
|
| 134 | printf("%s: Voice_Ctrl_Rpmsg_Send error, return %d!\n", __func__, ret);
|
| 135 | return VOICEIPC_ERROR;
|
| 136 | }
|
| 137 | printf("%s: Voice_Ctrl_Rpmsg_Send success, write_len=%d!\n", __func__, ret);
|
| 138 |
|
| 139 | while(func_id != voice_ctrl_recvmsg[func_id].func_id){
|
| 140 | usleep(1);
|
| 141 | }
|
| 142 |
|
| 143 | memcpy(&ret, voice_ctrl_recvmsg[func_id].param, voice_ctrl_recvmsg[func_id].param_len);
|
| 144 | printf("%s: ipc receive success, ret=%d!\n", __func__, ret);
|
| 145 |
|
| 146 | return ret;
|
| 147 | }
|
| 148 |
|
| 149 | int ipc_cap_alsa_voice_close(int vmode)
|
| 150 | {
|
| 151 | int ret = 0;
|
| 152 | int func_id = IPC_CAP_ALSA_VOICE_CLOSE;
|
| 153 | voice_ctrl_recvmsg[func_id].func_id = VOICE_WAIT_MSG_FROM_CAP;
|
| 154 |
|
| 155 | ret = Voice_Ctrl_Rpmsg_Send(func_id, &vmode);
|
| 156 |
|
| 157 | if (0 >= ret){
|
| 158 | printf("%s: Voice_Ctrl_Rpmsg_Send error, return %d!\n", __func__, ret);
|
| 159 | return VOICEIPC_ERROR;
|
| 160 | }
|
| 161 | printf("%s: Voice_Ctrl_Rpmsg_Send success, write_len=%d!\n", __func__, ret);
|
| 162 |
|
| 163 | while(func_id != voice_ctrl_recvmsg[func_id].func_id){
|
| 164 | usleep(1);
|
| 165 | }
|
| 166 |
|
| 167 | memcpy(&ret, voice_ctrl_recvmsg[func_id].param, voice_ctrl_recvmsg[func_id].param_len);
|
| 168 | printf("%s: ipc receive success, ret=%d!\n", __func__, ret);
|
| 169 |
|
| 170 | return ret;
|
| 171 | }
|
| 172 |
|
| 173 | void ipc_set_voice_device_mode_rcv(voice_ipc_control_msg msg)
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 174 | {
|
| 175 | int ret = VOICEIPC_OK;
|
| 176 | int msg_len = 0;
|
| 177 | int dev_mode = 0;
|
| 178 |
|
| 179 | //memcpy(&dev_mode, msg.param, msg.param_len);
|
| 180 | dev_mode = *((int *)msg.param);
|
| 181 | ret = sc_audio_set_voice_device_mode(dev_mode);
|
| 182 |
|
| 183 | //msg.func_idä¸å
|
| 184 | msg.param_len = sizeof(int);
|
| 185 | memcpy(msg.param, &ret, msg.param_len);
|
| 186 | msg_len = VOICE_HEAD_LEN + msg.param_len;
|
| 187 |
|
| 188 | ret = write(voice_ipc_fd, &msg, msg_len);
|
| 189 |
|
| 190 | if (0 >= ret){
|
| 191 | printf("%s: write error(%d)!\n", __func__, ret);
|
| 192 | }
|
| 193 | }
|
| 194 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 195 | void ipc_get_voice_device_mode_rcv(voice_ipc_control_msg msg)
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 196 | {
|
| 197 | int ret = VOICEIPC_OK;
|
| 198 | int msg_len = 0;
|
| 199 | int *p_dev_mode = NULL;
|
| 200 |
|
| 201 | p_dev_mode = (int *)msg.param;
|
| 202 | ret = sc_audio_get_voice_device_mode(p_dev_mode);
|
| 203 |
|
| 204 | //msg.func_idä¸å
|
| 205 | msg.param_len = sizeof(int);
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 206 | if(0 == ret)
|
| 207 | memcpy(msg.param, p_dev_mode, msg.param_len);
|
| 208 | else
|
| 209 | memcpy(msg.param, &ret, msg.param_len);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 210 | msg_len = VOICE_HEAD_LEN + msg.param_len;
|
| 211 |
|
| 212 | ret = write(voice_ipc_fd, &msg, msg_len);
|
| 213 |
|
| 214 | if (0 >= ret){
|
| 215 | printf("%s: write error(%d)!\n", __func__, ret);
|
| 216 | }
|
| 217 | }
|
| 218 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 219 | void ipc_set_rx_voice_vol_rcv(voice_ipc_control_msg msg)
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 220 | {
|
| 221 | int ret = VOICEIPC_OK;
|
| 222 | int msg_len = 0;
|
| 223 | int vol = 0;
|
| 224 |
|
| 225 | //memcpy(&dev_mode, msg.param, msg.param_len);
|
| 226 | vol = *((int *)msg.param);
|
| 227 | ret = sc_audio_set_rx_voice_vol(vol);
|
| 228 |
|
| 229 | //msg.func_idä¸å
|
| 230 | msg.param_len = sizeof(int);
|
| 231 | memcpy(msg.param, &ret, msg.param_len);
|
| 232 | msg_len = VOICE_HEAD_LEN + msg.param_len;
|
| 233 |
|
| 234 | ret = write(voice_ipc_fd, &msg, msg_len);
|
| 235 |
|
| 236 | if (0 >= ret){
|
| 237 | printf("%s: write error(%d)!\n", __func__, ret);
|
| 238 | }
|
| 239 | }
|
| 240 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 241 | void ipc_get_rx_voice_vol_rcv(voice_ipc_control_msg msg)
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 242 | {
|
| 243 | int ret = VOICEIPC_OK;
|
| 244 | int msg_len = 0;
|
| 245 | int *p_vol = NULL;
|
| 246 |
|
| 247 | p_vol = (int *)msg.param;
|
| 248 | ret = sc_audio_get_rx_voice_vol(p_vol);
|
| 249 |
|
| 250 | //msg.func_idä¸å
|
| 251 | msg.param_len = sizeof(int);
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 252 | if(0 == ret)
|
| 253 | memcpy(msg.param, p_vol, msg.param_len);
|
| 254 | else
|
| 255 | memcpy(msg.param, &ret, msg.param_len);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 256 | msg_len = VOICE_HEAD_LEN + msg.param_len;
|
| 257 |
|
| 258 | ret = write(voice_ipc_fd, &msg, msg_len);
|
| 259 |
|
| 260 | if (0 >= ret){
|
| 261 | printf("%s: write error(%d)!\n", __func__, ret);
|
| 262 | }
|
| 263 | }
|
| 264 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 265 | void ipc_set_tx_voice_vol_rcv(voice_ipc_control_msg msg)
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 266 | {
|
| 267 | int ret = VOICEIPC_OK;
|
| 268 | int msg_len = 0;
|
| 269 | int vol = 0;
|
| 270 |
|
| 271 | //memcpy(&dev_mode, msg.param, msg.param_len);
|
| 272 | vol = *((int *)msg.param);
|
| 273 | ret = sc_audio_set_tx_voice_vol(vol);
|
| 274 |
|
| 275 | //msg.func_idä¸å
|
| 276 | msg.param_len = sizeof(int);
|
| 277 | memcpy(msg.param, &ret, msg.param_len);
|
| 278 | msg_len = VOICE_HEAD_LEN + msg.param_len;
|
| 279 |
|
| 280 | ret = write(voice_ipc_fd, &msg, msg_len);
|
| 281 |
|
| 282 | if (0 >= ret){
|
| 283 | printf("%s: write error(%d)!\n", __func__, ret);
|
| 284 | }
|
| 285 | }
|
| 286 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 287 | void ipc_get_tx_voice_vol_rcv(voice_ipc_control_msg msg)
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 288 | {
|
| 289 | int ret = VOICEIPC_OK;
|
| 290 | int msg_len = 0;
|
| 291 | int *p_vol = NULL;
|
| 292 |
|
| 293 | p_vol = (int *)msg.param;
|
| 294 | ret = sc_audio_get_tx_voice_vol(p_vol);
|
| 295 |
|
| 296 | //msg.func_idä¸å
|
| 297 | msg.param_len = sizeof(int);
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 298 | if(0 == ret)
|
| 299 | memcpy(msg.param, p_vol, msg.param_len);
|
| 300 | else
|
| 301 | memcpy(msg.param, &ret, msg.param_len);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 302 | msg_len = VOICE_HEAD_LEN + msg.param_len;
|
| 303 |
|
| 304 | ret = write(voice_ipc_fd, &msg, msg_len);
|
| 305 |
|
| 306 | if (0 >= ret){
|
| 307 | printf("%s: write error(%d)!\n", __func__, ret);
|
| 308 | }
|
| 309 | }
|
| 310 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 311 | void ipc_set_tx_voice_mute_state_rcv(voice_ipc_control_msg msg)
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 312 | {
|
| 313 | int ret = VOICEIPC_OK;
|
| 314 | int msg_len = 0;
|
| 315 | int mute = 0;
|
| 316 |
|
| 317 | //memcpy(&dev_mode, msg.param, msg.param_len);
|
| 318 | mute = *((int *)msg.param);
|
| 319 | ret = sc_audio_set_tx_voice_mute_state(mute);
|
| 320 |
|
| 321 | //msg.func_idä¸å
|
| 322 | msg.param_len = sizeof(int);
|
| 323 | memcpy(msg.param, &ret, msg.param_len);
|
| 324 | msg_len = VOICE_HEAD_LEN + msg.param_len;
|
| 325 |
|
| 326 | ret = write(voice_ipc_fd, &msg, msg_len);
|
| 327 |
|
| 328 | if (0 >= ret){
|
| 329 | printf("%s: write error(%d)!\n", __func__, ret);
|
| 330 | }
|
| 331 | }
|
| 332 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 333 | void ipc_get_tx_voice_mute_state_rcv(voice_ipc_control_msg msg)
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 334 | {
|
| 335 | int ret = VOICEIPC_OK;
|
| 336 | int msg_len = 0;
|
| 337 | int *p_mute = NULL;
|
| 338 |
|
| 339 | p_mute = (int *)msg.param;
|
| 340 | ret = sc_audio_get_tx_voice_mute_state(p_mute);
|
| 341 |
|
| 342 | //msg.func_idä¸å
|
| 343 | msg.param_len = sizeof(int);
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 344 | if(0 == ret)
|
| 345 | memcpy(msg.param, p_mute, msg.param_len);
|
| 346 | else
|
| 347 | memcpy(msg.param, &ret, msg.param_len);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 348 | msg_len = VOICE_HEAD_LEN + msg.param_len;
|
| 349 |
|
| 350 | ret = write(voice_ipc_fd, &msg, msg_len);
|
| 351 |
|
| 352 | if (0 >= ret){
|
| 353 | printf("%s: write error(%d)!\n", __func__, ret);
|
| 354 | }
|
| 355 | }
|
| 356 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 357 | void ipc_set_rx_voice_mute_state_rcv(voice_ipc_control_msg msg)
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 358 | {
|
| 359 | int ret = VOICEIPC_OK;
|
| 360 | int msg_len = 0;
|
| 361 | int mute = 0;
|
| 362 |
|
| 363 | //memcpy(&dev_mode, msg.param, msg.param_len);
|
| 364 | mute = *((int *)msg.param);
|
| 365 | ret = sc_audio_set_rx_voice_mute_state(mute);
|
| 366 |
|
| 367 | //msg.func_idä¸å
|
| 368 | msg.param_len = sizeof(int);
|
| 369 | memcpy(msg.param, &ret, msg.param_len);
|
| 370 | msg_len = VOICE_HEAD_LEN + msg.param_len;
|
| 371 |
|
| 372 | ret = write(voice_ipc_fd, &msg, msg_len);
|
| 373 |
|
| 374 | if (0 >= ret){
|
| 375 | printf("%s: write error(%d)!\n", __func__, ret);
|
| 376 | }
|
| 377 | }
|
| 378 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 379 | void ipc_get_rx_voice_mute_state_rcv(voice_ipc_control_msg msg)
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 380 | {
|
| 381 | int ret = VOICEIPC_OK;
|
| 382 | int msg_len = 0;
|
| 383 | int *p_mute = NULL;
|
| 384 |
|
| 385 | p_mute = (int *)msg.param;
|
| 386 | ret = sc_audio_get_rx_voice_mute_state(p_mute);
|
| 387 |
|
| 388 | //msg.func_idä¸å
|
| 389 | msg.param_len = sizeof(int);
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 390 | if(0 == ret)
|
| 391 | memcpy(msg.param, p_mute, msg.param_len);
|
| 392 | else
|
| 393 | memcpy(msg.param, &ret, msg.param_len);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 394 | msg_len = VOICE_HEAD_LEN + msg.param_len;
|
| 395 |
|
| 396 | ret = write(voice_ipc_fd, &msg, msg_len);
|
| 397 |
|
| 398 | if (0 >= ret){
|
| 399 | printf("%s: write error(%d)!\n", __func__, ret);
|
| 400 | }
|
| 401 | }
|
| 402 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 403 | void ipc_set_loopback_enable_state_rcv(voice_ipc_control_msg msg)
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 404 | {
|
| 405 | int ret = VOICEIPC_OK;
|
| 406 | int msg_len = 0;
|
lh | 758261d | 2023-07-13 05:52:04 -0700 | [diff] [blame] | 407 | int dev_mode = 0,enable = 0;
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 408 |
|
| 409 | //memcpy(&dev_mode, msg.param, msg.param_len);
|
lh | 758261d | 2023-07-13 05:52:04 -0700 | [diff] [blame] | 410 | //enable = *((int *)msg.param);
|
| 411 | memcpy(&dev_mode, msg.param, sizeof(int));
|
| 412 | memcpy(&enable, msg.param+sizeof(int), sizeof(int));
|
| 413 |
|
| 414 | //ret = sc_audio_set_loopback_enable_state(enable);
|
| 415 | ret = ap_audio_set_loopback_enable(dev_mode,enable);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 416 |
|
| 417 | //msg.func_idä¸å
|
| 418 | msg.param_len = sizeof(int);
|
| 419 | memcpy(msg.param, &ret, msg.param_len);
|
| 420 | msg_len = VOICE_HEAD_LEN + msg.param_len;
|
| 421 |
|
| 422 | ret = write(voice_ipc_fd, &msg, msg_len);
|
| 423 |
|
| 424 | if (0 >= ret){
|
| 425 | printf("%s: write error(%d)!\n", __func__, ret);
|
| 426 | }
|
| 427 | }
|
| 428 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 429 | void ipc_get_loopback_enable_state_rcv(voice_ipc_control_msg msg)
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 430 | {
|
| 431 | int ret = VOICEIPC_OK;
|
| 432 | int msg_len = 0;
|
| 433 | int *p_enable = NULL;
|
| 434 |
|
| 435 | p_enable = (int *)msg.param;
|
lh | 758261d | 2023-07-13 05:52:04 -0700 | [diff] [blame] | 436 | //ret = sc_audio_get_loopback_enable_state(p_enable);
|
| 437 | ret = ap_audio_get_loopback_enable(p_enable);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 438 | //msg.func_idä¸å
|
| 439 | msg.param_len = sizeof(int);
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 440 | if(0 == ret)
|
| 441 | memcpy(msg.param, p_enable, msg.param_len);
|
| 442 | else
|
| 443 | memcpy(msg.param, &ret, msg.param_len);
|
| 444 | msg_len = VOICE_HEAD_LEN + msg.param_len;
|
| 445 |
|
| 446 | ret = write(voice_ipc_fd, &msg, msg_len);
|
| 447 |
|
| 448 | if (0 >= ret){
|
| 449 | printf("%s: write error(%d)!\n", __func__, ret);
|
| 450 | }
|
| 451 | }
|
| 452 |
|
| 453 | #ifdef _USE_VOICE_ALSA
|
| 454 | void ipc_ap_alsa_voice_open_rcv(voice_ipc_control_msg msg)
|
| 455 | {
|
| 456 | int ret = VOICEIPC_OK;
|
| 457 | int msg_len = 0;
|
| 458 | int vmode = 0;
|
| 459 |
|
| 460 | vmode = *((int *)msg.param);
|
| 461 | ret = alsa_voice_open(vmode);
|
| 462 |
|
| 463 | //msg.func_idä¸å
|
| 464 | msg.param_len = sizeof(int);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 465 | memcpy(msg.param, &ret, msg.param_len);
|
| 466 | msg_len = VOICE_HEAD_LEN + msg.param_len;
|
| 467 |
|
| 468 | ret = write(voice_ipc_fd, &msg, msg_len);
|
| 469 |
|
| 470 | if (0 >= ret){
|
| 471 | printf("%s: write error(%d)!\n", __func__, ret);
|
| 472 | }
|
| 473 | }
|
| 474 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 475 | void ipc_ap_alsa_voice_close_rcv(voice_ipc_control_msg msg)
|
| 476 | {
|
| 477 | int ret = VOICEIPC_OK;
|
| 478 | int msg_len = 0;
|
| 479 | int vmode = 0;
|
| 480 |
|
| 481 | vmode = *((int *)msg.param);
|
| 482 | ret = alsa_voice_close(vmode);
|
| 483 |
|
| 484 | //msg.func_idä¸å
|
| 485 | msg.param_len = sizeof(int);
|
| 486 | memcpy(msg.param, &ret, msg.param_len);
|
| 487 | msg_len = VOICE_HEAD_LEN + msg.param_len;
|
| 488 |
|
| 489 | ret = write(voice_ipc_fd, &msg, msg_len);
|
| 490 |
|
| 491 | if (0 >= ret){
|
| 492 | printf("%s: write error(%d)!\n", __func__, ret);
|
| 493 | }
|
| 494 | }
|
| 495 | #endif
|
| 496 |
|
| 497 | void voice_ipc_recv_proc(voice_ipc_control_msg msg)
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 498 | {
|
| 499 | switch(msg.func_id){
|
| 500 | case IPC_SET_VOICE_DEVICE_MODE:
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 501 | ipc_set_voice_device_mode_rcv(voice_ctrl_recvmsg[msg.func_id]);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 502 | break;
|
| 503 | case IPC_GET_VOICE_DEVICE_MODE:
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 504 | ipc_get_voice_device_mode_rcv(voice_ctrl_recvmsg[msg.func_id]);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 505 | break;
|
| 506 | case IPC_SET_RX_VOICE_VOL:
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 507 | ipc_set_rx_voice_vol_rcv(voice_ctrl_recvmsg[msg.func_id]);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 508 | break;
|
| 509 | case IPC_GET_RX_VOICE_VOL:
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 510 | ipc_get_rx_voice_vol_rcv(voice_ctrl_recvmsg[msg.func_id]);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 511 | break;
|
| 512 | case IPC_SET_TX_VOICE_VOL:
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 513 | ipc_set_tx_voice_vol_rcv(voice_ctrl_recvmsg[msg.func_id]);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 514 | break;
|
| 515 | case IPC_GET_TX_VOICE_VOL:
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 516 | ipc_get_tx_voice_vol_rcv(voice_ctrl_recvmsg[msg.func_id]);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 517 | break;
|
| 518 | case IPC_SET_TX_VOICE_MUTE_STATE:
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 519 | ipc_set_tx_voice_mute_state_rcv(voice_ctrl_recvmsg[msg.func_id]);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 520 | break;
|
| 521 | case IPC_GET_TX_VOICE_MUTE_STATE:
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 522 | ipc_get_tx_voice_mute_state_rcv(voice_ctrl_recvmsg[msg.func_id]);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 523 | break;
|
| 524 | case IPC_SET_RX_VOICE_MUTE_STATE:
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 525 | ipc_set_rx_voice_mute_state_rcv(voice_ctrl_recvmsg[msg.func_id]);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 526 | break;
|
| 527 | case IPC_GET_RX_VOICE_MUTE_STATE:
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 528 | ipc_get_rx_voice_mute_state_rcv(voice_ctrl_recvmsg[msg.func_id]);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 529 | break;
|
| 530 | case IPC_SET_LOOPBACK_ENABLE_STATE:
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 531 | ipc_set_loopback_enable_state_rcv(voice_ctrl_recvmsg[msg.func_id]);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 532 | break;
|
| 533 | case IPC_GET_LOOPBACK_ENABLE_STATE:
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 534 | ipc_get_loopback_enable_state_rcv(voice_ctrl_recvmsg[msg.func_id]);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 535 | break;
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 536 | #ifdef _USE_VOICE_ALSA
|
| 537 | case IPC_AP_ALSA_VOICE_OPEN:
|
| 538 | ipc_ap_alsa_voice_open_rcv(voice_ctrl_recvmsg[msg.func_id]);
|
| 539 | break;
|
| 540 | case IPC_AP_ALSA_VOICE_CLOSE:
|
| 541 | ipc_ap_alsa_voice_close_rcv(voice_ctrl_recvmsg[msg.func_id]);
|
| 542 | break;
|
| 543 | #endif
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 544 | default:
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 545 | break;
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 546 | }
|
| 547 | }
|
| 548 |
|
| 549 | void Voice_Ctrl_Rpmsg_Recv(void)
|
| 550 | {
|
| 551 | int read_len = 0;
|
| 552 | voice_ipc_control_msg tmpbuf = {0};
|
| 553 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 554 | while(1){
|
xf.li | 7ccf837 | 2024-03-07 00:08:02 -0800 | [diff] [blame] | 555 | read_len = read(voice_ipc_fd, &tmpbuf, (VOICE_HEAD_LEN + VOICE_CONTROL_MAX_LEN));
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 556 |
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 557 | if (0 >= read_len){
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 558 | sleep(1);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 559 | continue;
|
| 560 | }
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 561 | printf("%s: voice_ipc_fd=%d, read_len=%d\n", __func__, voice_ipc_fd, read_len);
|
| 562 |
|
| 563 | //Êý¾Ý¶ÁÈ¡ÍêºóÔٸıäfuc_id
|
| 564 | if(0 != tmpbuf.param_len){
|
| 565 | memcpy(voice_ctrl_recvmsg[tmpbuf.func_id].param, tmpbuf.param, tmpbuf.param_len);
|
| 566 | }
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 567 | voice_ctrl_recvmsg[tmpbuf.func_id].param_len = tmpbuf.param_len;
|
| 568 | voice_ctrl_recvmsg[tmpbuf.func_id].func_id = tmpbuf.func_id;
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 569 | printf("%s: tmpbuf.param_len=%d, tmpbuf.func_id=%d\n", __func__, tmpbuf.param_len, tmpbuf.func_id);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 570 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 571 | voice_ipc_recv_proc(voice_ctrl_recvmsg[tmpbuf.func_id]);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 572 | }
|
| 573 | }
|
| 574 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 575 | int Voice_Ctrl_Rpmsg_Send(int func_id, int *msg)
|
| 576 | {
|
| 577 | voice_ipc_control_msg tmpbuf = {0};
|
| 578 | int tmpbuf_len = 0;
|
| 579 | int write_len = 0;
|
| 580 |
|
| 581 | tmpbuf.func_id = func_id;
|
| 582 |
|
| 583 | if(NULL == msg){
|
| 584 | tmpbuf.param_len = 0;
|
| 585 | }else{
|
| 586 | tmpbuf.param_len = sizeof(int);
|
| 587 | memcpy(tmpbuf.param, msg, tmpbuf.param_len);
|
| 588 | }
|
| 589 |
|
| 590 | tmpbuf_len = VOICE_HEAD_LEN + tmpbuf.param_len;
|
| 591 |
|
| 592 | //printf("Voice_Ctrl_Rpmsg_Send, voice_ipc_fd = %d\n", voice_ipc_fd);
|
| 593 | write_len = write(voice_ipc_fd, &tmpbuf, tmpbuf_len);
|
| 594 |
|
| 595 | return write_len;
|
| 596 | }
|
| 597 |
|
| 598 | int voice_ipc_init(void) //ééåå§å?
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 599 | {
|
| 600 | voice_ipc_fd = open(VOICE_IPC_CONTROL_CHANNEL, O_RDWR);
|
| 601 |
|
| 602 | if(0 > voice_ipc_fd){
|
| 603 | printf("%s: open the channel(%s) error!\n", __func__, VOICE_IPC_CONTROL_CHANNEL);
|
| 604 | return VOICEIPC_ERROR;
|
| 605 | }
|
| 606 |
|
| 607 | if(0 > ioctl(voice_ipc_fd, RPMSG_CREATE_CHANNEL, VOICE_IPC_CONTROL_CHANNEL_SIZE)){
|
| 608 | printf("%s: ioctl RPMSG_CREATE_CHANNEL fail!\n", __func__);
|
| 609 | close(voice_ipc_fd);
|
| 610 | voice_ipc_fd = -1;
|
| 611 | return VOICEIPC_ERROR;
|
| 612 | }
|
| 613 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 614 | if(0 > ioctl(voice_ipc_fd, RPMSG_SET_INT_FLAG, NULL)){ //å䏿?
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 615 | printf("%s: ioctl RPMSG_SET_INT_FLAG fail!\n", __func__);
|
| 616 | close(voice_ipc_fd);
|
| 617 | voice_ipc_fd = -1;
|
| 618 | return VOICEIPC_ERROR;
|
| 619 | }
|
| 620 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 621 | if(0 > ioctl(voice_ipc_fd, RPMSG_CLEAR_POLL_FLAG, NULL)){ //é»å¡æ¹å¼è¯»æ°æ?
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 622 | printf("%s: ioctl RPMSG_CLEAR_POLL_FLAG fail!\n", __func__);
|
| 623 | close(voice_ipc_fd);
|
| 624 | voice_ipc_fd = -1;
|
| 625 | return VOICEIPC_ERROR;
|
| 626 | }
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 627 |
|
| 628 | printf("voice_ipc_init %s create success! voice_ipc_fd = %d\n", VOICE_IPC_CONTROL_CHANNEL, voice_ipc_fd);
|
| 629 |
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 630 | return VOICEIPC_OK;
|
| 631 | }
|
| 632 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 633 | int recv_msg_proc(MSG_BUF msg)
|
| 634 | {
|
| 635 | int ret = 0;
|
| 636 | int vmode = 0;
|
| 637 | int module_id = MODULE_ID_VOICE_SERVER;
|
| 638 | int dst_id = MODULE_ID_VOICE_CLIENT;
|
| 639 |
|
| 640 | switch(msg.usMsgCmd){
|
| 641 | case MSG_CMD_CAP_VALSA_OPEN:
|
| 642 | vmode = *((int *)msg.aucDataBuf);
|
| 643 | ret = ipc_cap_alsa_voice_open(vmode);
|
| 644 | //dst_id = MODULE_ID_CAP_VALSA_OPEN;
|
| 645 | ret = ipc_send_message(module_id, dst_id, msg.usMsgCmd, sizeof(int), (unsigned char *)(&ret), 0);
|
| 646 | if(0 != ret){
|
| 647 | printf("%s: ipc_send_message error, return %d!\n", __func__, ret);
|
| 648 | }
|
| 649 | break;
|
| 650 | case MSG_CMD_CAP_VALSA_CLOSE:
|
| 651 | vmode = *((int *)msg.aucDataBuf);
|
| 652 | ret = ipc_cap_alsa_voice_close(vmode);
|
| 653 | //dst_id = MODULE_ID_CAP_VALSA_CLOSE;
|
| 654 | ret = ipc_send_message(module_id, dst_id, msg.usMsgCmd, sizeof(int), (unsigned char *)(&ret), 0);
|
| 655 | if(0 != ret){
|
| 656 | printf("%s: ipc_send_message error, return %d!\n", __func__, ret);
|
| 657 | }
|
| 658 | break;
|
| 659 | default:
|
| 660 | printf("%s: msg.usMsgCmd=%d, not support!\n", __func__, msg.usMsgCmd);
|
| 661 | break;
|
| 662 | }
|
| 663 |
|
| 664 | return ret;
|
| 665 | }
|
| 666 |
|
| 667 | void recv_cap_voice_alsa(void)
|
| 668 | {
|
| 669 | int ret = 0;
|
| 670 | int msg_handle = 0;
|
| 671 | MSG_BUF msg;
|
| 672 | LONG msg_size = sizeof(MSG_BUF)-sizeof(LONG);
|
| 673 | int module_id = MODULE_ID_VOICE_SERVER;
|
| 674 |
|
| 675 | //´´½¨ÏûÏ¢¶ÓÁÐ
|
| 676 | msg_handle = msgget(module_id, IPC_CREAT|0600);
|
| 677 |
|
| 678 | //½ÓÊÕÏûÏ¢
|
| 679 | while(1)
|
| 680 | {
|
| 681 | memset(&msg, 0x00, sizeof(MSG_BUF));
|
| 682 |
|
| 683 | //»ñÈ¡ÏûÏ¢¶ÓÁÐÏûÏ¢²¢´¦Àí
|
| 684 | ret = msgrcv(msg_handle, &msg, msg_size, 0, 0);
|
| 685 |
|
| 686 | if(0 > ret){
|
| 687 | continue;
|
| 688 | }
|
| 689 |
|
| 690 | recv_msg_proc(msg);
|
| 691 | }
|
| 692 | }
|
| 693 |
|
xf.li | 7ccf837 | 2024-03-07 00:08:02 -0800 | [diff] [blame] | 694 | void recv_update_voice_nvrw_ipc(void)
|
| 695 | {
|
| 696 | int read_len = 0;
|
| 697 | int ret = -1;
|
| 698 | int fd = -1;
|
| 699 |
|
| 700 | recv_voice_nvrw_buf = (unsigned char*)malloc(VOICE_HEAD_LEN + VOICE_NVRW_MAX_LEN);
|
| 701 | if(!recv_voice_nvrw_buf){
|
| 702 | printf("%s: recv_voice_nvrw_buf malloc fail!\n", __func__);
|
| 703 | return;
|
| 704 | }
|
| 705 |
|
| 706 | while(1){
|
| 707 | read_len = read(voice_ipc_fd, recv_voice_nvrw_buf, VOICE_HEAD_LEN + VOICE_NVRW_MAX_LEN);
|
| 708 | if (0 >= read_len){
|
| 709 | sleep(1);
|
| 710 | continue;
|
| 711 | }
|
| 712 |
|
| 713 | printf("%s: read_len = %d, func_id = %d, param_len = %d!\n", __func__, read_len, \
|
| 714 | *((int*)recv_voice_nvrw_buf), *((int*)recv_voice_nvrw_buf + 1));
|
| 715 |
|
| 716 | #if 0
|
| 717 | printf("%s: param[0]=%02x,param[1]=%02x,param[2]=%02x,param[3]=%02x,param[4]=%02x,param[5]=%02x,param[6]=%02x!\n", \
|
| 718 | __func__, recv_voice_nvrw_buf.param[0], recv_voice_nvrw_buf.param[1], recv_voice_nvrw_buf.param[2], \
|
| 719 | recv_voice_nvrw_buf.param[3], recv_voice_nvrw_buf.param[4], recv_voice_nvrw_buf.param[5], recv_voice_nvrw_buf.param[6]);
|
| 720 |
|
| 721 | int writesize = 0;
|
| 722 | FILE *ptest = fopen("/mnt/userdata/voice_nv_test_ap.bin", "wb");
|
| 723 | if(!ptest){
|
| 724 | printf("%s: Unable to create file '/mnt/userdata/voice_nv_test_ap.bin'!\n", __func__);
|
| 725 | }
|
| 726 |
|
| 727 | writesize = fwrite(recv_voice_nvrw_buf.param, 1, recv_voice_nvrw_buf.param_len, ptest);
|
| 728 | printf("%s: writesize = %d!\n", __func__, writesize);
|
| 729 |
|
| 730 | if(NULL != ptest){
|
| 731 | fclose(ptest);
|
| 732 | }
|
| 733 | #endif
|
| 734 |
|
| 735 | fd = open(VOICE_DEV_NAME, O_RDWR);
|
| 736 |
|
| 737 | if(0 > fd){
|
| 738 | printf("%s: open voice device error!\n", __func__);
|
| 739 | }
|
| 740 | else{
|
| 741 | ret = ioctl(fd, VOICE_IOCTL_SET_VOICE_NVRW, recv_voice_nvrw_buf);
|
| 742 | printf("%s: ioctl /dev/voice_device end, ret=%d!\n", __func__, ret);
|
| 743 | close(fd);
|
| 744 | }
|
| 745 |
|
| 746 | break;
|
| 747 | }
|
| 748 |
|
| 749 | if(recv_voice_nvrw_buf){
|
| 750 | free(recv_voice_nvrw_buf);
|
| 751 | recv_voice_nvrw_buf = NULL;
|
| 752 | }
|
| 753 |
|
| 754 | return;
|
| 755 | }
|
| 756 |
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 757 | int main(int argc, char **argv)
|
| 758 | {
|
| 759 | int ret = 0;
|
| 760 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 761 | //ipcͨµÀ³õʼ»¯
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 762 | ret = voice_ipc_init();
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 763 | if(0 > ret){
|
| 764 | printf("voice_ipc_init %s error!\n", VOICE_IPC_CONTROL_CHANNEL);
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 765 | return -1;
|
| 766 | }
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 767 |
|
xf.li | 742dd02 | 2023-06-08 01:43:32 -0700 | [diff] [blame] | 768 | //ipc³õʼ»¯ºó£¬´´½¨msgÏûÏ¢½ÓÊÕÏß³Ì
|
| 769 | pthread_t recv_thread_tid;
|
| 770 | if(0 != pthread_create(&recv_thread_tid, NULL, (void *)recv_cap_voice_alsa, NULL)){
|
| 771 | printf("recv_cap_voice_alsa create error!\n");
|
| 772 | }
|
| 773 |
|
xf.li | 7ccf837 | 2024-03-07 00:08:02 -0800 | [diff] [blame] | 774 | sleep(4); //µÈ´ýcap²àÒôƵºË¼äͨµÀ½¨Á¢Íê³É
|
| 775 |
|
| 776 | //ipc³õʼ»¯ºó£¬Ö±½Ó»ñÈ¡cap²àvoice nv
|
| 777 | recv_update_voice_nvrw_ipc();
|
| 778 |
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 779 | Voice_Ctrl_Rpmsg_Recv();
|
| 780 |
|
| 781 | return 0;
|
| 782 | }
|
| 783 |
|
| 784 | #endif
|