Lines Matching refs:ch_id

81 static int uipc_close_ch_locked(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id);
239 static int uipc_check_fd_locked(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id) { in uipc_check_fd_locked() argument
240 if (ch_id >= UIPC_CH_NUM) return -1; in uipc_check_fd_locked()
245 if (SAFE_FD_ISSET(uipc.ch[ch_id].srvfd, &uipc.read_set)) { in uipc_check_fd_locked()
246 BTIF_TRACE_EVENT("INCOMING CONNECTION ON CH %d", ch_id); in uipc_check_fd_locked()
249 if (uipc.ch[ch_id].fd != UIPC_DISCONNECTED) { in uipc_check_fd_locked()
250 BTIF_TRACE_EVENT("CLOSE CONNECTION (FD %d)", uipc.ch[ch_id].fd); in uipc_check_fd_locked()
251 close(uipc.ch[ch_id].fd); in uipc_check_fd_locked()
252 FD_CLR(uipc.ch[ch_id].fd, &uipc.active_set); in uipc_check_fd_locked()
253 uipc.ch[ch_id].fd = UIPC_DISCONNECTED; in uipc_check_fd_locked()
256 uipc.ch[ch_id].fd = accept_server_socket(uipc.ch[ch_id].srvfd); in uipc_check_fd_locked()
258 BTIF_TRACE_EVENT("NEW FD %d", uipc.ch[ch_id].fd); in uipc_check_fd_locked()
260 if ((uipc.ch[ch_id].fd >= 0) && uipc.ch[ch_id].cback) { in uipc_check_fd_locked()
263 BTIF_TRACE_EVENT("ADD FD %d TO ACTIVE SET", uipc.ch[ch_id].fd); in uipc_check_fd_locked()
264 FD_SET(uipc.ch[ch_id].fd, &uipc.active_set); in uipc_check_fd_locked()
265 uipc.max_fd = MAX(uipc.max_fd, uipc.ch[ch_id].fd); in uipc_check_fd_locked()
268 if (uipc.ch[ch_id].fd < 0) { in uipc_check_fd_locked()
269 BTIF_TRACE_ERROR("FAILED TO ACCEPT CH %d", ch_id); in uipc_check_fd_locked()
273 if (uipc.ch[ch_id].cback) uipc.ch[ch_id].cback(ch_id, UIPC_OPEN_EVT); in uipc_check_fd_locked()
278 if (SAFE_FD_ISSET(uipc.ch[ch_id].fd, &uipc.read_set)) { in uipc_check_fd_locked()
281 if (uipc.ch[ch_id].cback) in uipc_check_fd_locked()
282 uipc.ch[ch_id].cback(ch_id, UIPC_RX_DATA_READY_EVT); in uipc_check_fd_locked()
302 static int uipc_setup_server_locked(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id, in uipc_setup_server_locked() argument
306 BTIF_TRACE_EVENT("SETUP CHANNEL SERVER %d", ch_id); in uipc_setup_server_locked()
308 if (ch_id >= UIPC_CH_NUM) return -1; in uipc_setup_server_locked()
323 uipc.ch[ch_id].srvfd = fd; in uipc_setup_server_locked()
324 uipc.ch[ch_id].cback = cback; in uipc_setup_server_locked()
325 uipc.ch[ch_id].read_poll_tmo_ms = DEFAULT_READ_POLL_TMO_MS; in uipc_setup_server_locked()
333 static void uipc_flush_ch_locked(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id) { in uipc_flush_ch_locked() argument
338 pfd.fd = uipc.ch[ch_id].fd; in uipc_flush_ch_locked()
340 if (uipc.ch[ch_id].fd == UIPC_DISCONNECTED) { in uipc_flush_ch_locked()
372 static void uipc_flush_locked(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id) { in uipc_flush_locked() argument
373 if (ch_id >= UIPC_CH_NUM) return; in uipc_flush_locked()
375 switch (ch_id) { in uipc_flush_locked()
386 static int uipc_close_ch_locked(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id) { in uipc_close_ch_locked() argument
389 BTIF_TRACE_EVENT("CLOSE CHANNEL %d", ch_id); in uipc_close_ch_locked()
391 if (ch_id >= UIPC_CH_NUM) return -1; in uipc_close_ch_locked()
393 if (uipc.ch[ch_id].srvfd != UIPC_DISCONNECTED) { in uipc_close_ch_locked()
394 BTIF_TRACE_EVENT("CLOSE SERVER (FD %d)", uipc.ch[ch_id].srvfd); in uipc_close_ch_locked()
395 close(uipc.ch[ch_id].srvfd); in uipc_close_ch_locked()
396 FD_CLR(uipc.ch[ch_id].srvfd, &uipc.active_set); in uipc_close_ch_locked()
397 uipc.ch[ch_id].srvfd = UIPC_DISCONNECTED; in uipc_close_ch_locked()
401 if (uipc.ch[ch_id].fd != UIPC_DISCONNECTED) { in uipc_close_ch_locked()
402 BTIF_TRACE_EVENT("CLOSE CONNECTION (FD %d)", uipc.ch[ch_id].fd); in uipc_close_ch_locked()
403 close(uipc.ch[ch_id].fd); in uipc_close_ch_locked()
404 FD_CLR(uipc.ch[ch_id].fd, &uipc.active_set); in uipc_close_ch_locked()
405 uipc.ch[ch_id].fd = UIPC_DISCONNECTED; in uipc_close_ch_locked()
410 if (uipc.ch[ch_id].cback) uipc.ch[ch_id].cback(ch_id, UIPC_CLOSE_EVT); in uipc_close_ch_locked()
418 void uipc_close_locked(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id) { in uipc_close_locked() argument
419 if (uipc.ch[ch_id].srvfd == UIPC_DISCONNECTED) { in uipc_close_locked()
420 BTIF_TRACE_EVENT("CHANNEL %d ALREADY CLOSED", ch_id); in uipc_close_locked()
425 uipc.ch[ch_id].task_evt_flags |= UIPC_TASK_FLAG_DISCONNECT_CHAN; in uipc_close_locked()
431 int ch_id; in uipc_read_task() local
467 for (ch_id = 0; ch_id < UIPC_CH_NUM; ch_id++) { in uipc_read_task()
468 if (ch_id != UIPC_CH_ID_AV_AUDIO) uipc_check_fd_locked(uipc, ch_id); in uipc_read_task()
542 bool UIPC_Open(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id, tUIPC_RCV_CBACK* p_cback, in UIPC_Open() argument
544 BTIF_TRACE_DEBUG("UIPC_Open : ch_id %d, p_cback %x", ch_id, p_cback); in UIPC_Open()
548 if (ch_id >= UIPC_CH_NUM) { in UIPC_Open()
552 if (uipc.ch[ch_id].srvfd != UIPC_DISCONNECTED) { in UIPC_Open()
553 BTIF_TRACE_EVENT("CHANNEL %d ALREADY OPEN", ch_id); in UIPC_Open()
557 uipc_setup_server_locked(uipc, ch_id, socket_path, p_cback); in UIPC_Open()
571 void UIPC_Close(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id) { in UIPC_Close() argument
572 BTIF_TRACE_DEBUG("UIPC_Close : ch_id %d", ch_id); in UIPC_Close()
575 if (ch_id != UIPC_CH_ID_ALL) { in UIPC_Close()
577 uipc_close_locked(uipc, ch_id); in UIPC_Close()
595 bool UIPC_Send(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id, in UIPC_Send() argument
598 BTIF_TRACE_DEBUG("UIPC_Send : ch_id:%d %d bytes", ch_id, msglen); in UIPC_Send()
603 OSI_NO_INTR(ret = write(uipc.ch[ch_id].fd, p_buf, msglen)); in UIPC_Send()
621 uint32_t UIPC_Read(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id, in UIPC_Read() argument
624 if (ch_id >= UIPC_CH_NUM) { in UIPC_Read()
625 BTIF_TRACE_ERROR("UIPC_Read : invalid ch id %d", ch_id); in UIPC_Read()
630 int fd = uipc.ch[ch_id].fd; in UIPC_Read()
634 BTIF_TRACE_ERROR("UIPC_Read : channel %d closed", ch_id); in UIPC_Read()
646 OSI_NO_INTR(poll_ret = poll(&pfd, 1, uipc.ch[ch_id].read_poll_tmo_ms)); in UIPC_Read()
649 uipc.ch[ch_id].read_poll_tmo_ms); in UIPC_Read()
663 uipc_close_locked(uipc, ch_id); in UIPC_Read()
675 uipc_close_locked(uipc, ch_id); in UIPC_Read()
700 extern bool UIPC_Ioctl(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id, uint32_t request, in UIPC_Ioctl() argument
702 BTIF_TRACE_DEBUG("#### UIPC_Ioctl : ch_id %d, request %d ####", ch_id, in UIPC_Ioctl()
708 uipc_flush_locked(uipc, ch_id); in UIPC_Ioctl()
714 uipc.ch[ch_id].cback = (tUIPC_RCV_CBACK*)param; in UIPC_Ioctl()
719 if (uipc.ch[ch_id].fd != UIPC_DISCONNECTED) { in UIPC_Ioctl()
721 FD_CLR(uipc.ch[ch_id].fd, &uipc.active_set); in UIPC_Ioctl()
729 uipc.ch[ch_id].read_poll_tmo_ms = (intptr_t)param; in UIPC_Ioctl()
730 BTIF_TRACE_EVENT("UIPC_SET_READ_POLL_TMO : CH %d, TMO %d ms", ch_id, in UIPC_Ioctl()
731 uipc.ch[ch_id].read_poll_tmo_ms); in UIPC_Ioctl()