Lines Matching refs:ch_id
114 static int uipc_close_ch_locked(tUIPC_CH_ID ch_id);
286 static int uipc_check_fd_locked(tUIPC_CH_ID ch_id) in uipc_check_fd_locked() argument
288 if (ch_id >= UIPC_CH_NUM) in uipc_check_fd_locked()
293 if (SAFE_FD_ISSET(uipc_main.ch[ch_id].srvfd, &uipc_main.read_set)) in uipc_check_fd_locked()
295 BTIF_TRACE_EVENT("INCOMING CONNECTION ON CH %d", ch_id); in uipc_check_fd_locked()
297 uipc_main.ch[ch_id].fd = accept_server_socket(uipc_main.ch[ch_id].srvfd); in uipc_check_fd_locked()
299 BTIF_TRACE_EVENT("NEW FD %d", uipc_main.ch[ch_id].fd); in uipc_check_fd_locked()
301 if ((uipc_main.ch[ch_id].fd > 0) && uipc_main.ch[ch_id].cback) in uipc_check_fd_locked()
305 BTIF_TRACE_EVENT("ADD FD %d TO ACTIVE SET", uipc_main.ch[ch_id].fd); in uipc_check_fd_locked()
306 FD_SET(uipc_main.ch[ch_id].fd, &uipc_main.active_set); in uipc_check_fd_locked()
307 uipc_main.max_fd = MAX(uipc_main.max_fd, uipc_main.ch[ch_id].fd); in uipc_check_fd_locked()
310 if (uipc_main.ch[ch_id].fd < 0) in uipc_check_fd_locked()
312 BTIF_TRACE_ERROR("FAILED TO ACCEPT CH %d (%s)", ch_id, strerror(errno)); in uipc_check_fd_locked()
316 if (uipc_main.ch[ch_id].cback) in uipc_check_fd_locked()
317 uipc_main.ch[ch_id].cback(ch_id, UIPC_OPEN_EVT); in uipc_check_fd_locked()
322 if (SAFE_FD_ISSET(uipc_main.ch[ch_id].fd, &uipc_main.read_set)) in uipc_check_fd_locked()
326 if (uipc_main.ch[ch_id].cback) in uipc_check_fd_locked()
327 uipc_main.ch[ch_id].cback(ch_id, UIPC_RX_DATA_READY_EVT); in uipc_check_fd_locked()
350 static int uipc_setup_server_locked(tUIPC_CH_ID ch_id, char *name, tUIPC_RCV_CBACK *cback) in uipc_setup_server_locked() argument
354 BTIF_TRACE_EVENT("SETUP CHANNEL SERVER %d", ch_id); in uipc_setup_server_locked()
356 if (ch_id >= UIPC_CH_NUM) in uipc_setup_server_locked()
374 uipc_main.ch[ch_id].srvfd = fd; in uipc_setup_server_locked()
375 uipc_main.ch[ch_id].cback = cback; in uipc_setup_server_locked()
376 uipc_main.ch[ch_id].read_poll_tmo_ms = DEFAULT_READ_POLL_TMO_MS; in uipc_setup_server_locked()
386 static void uipc_flush_ch_locked(tUIPC_CH_ID ch_id) in uipc_flush_ch_locked() argument
392 pfd.fd = uipc_main.ch[ch_id].fd; in uipc_flush_ch_locked()
394 if (uipc_main.ch[ch_id].fd == UIPC_DISCONNECTED) in uipc_flush_ch_locked()
429 static void uipc_flush_locked(tUIPC_CH_ID ch_id) in uipc_flush_locked() argument
431 if (ch_id >= UIPC_CH_NUM) in uipc_flush_locked()
434 switch(ch_id) in uipc_flush_locked()
447 static int uipc_close_ch_locked(tUIPC_CH_ID ch_id) in uipc_close_ch_locked() argument
451 BTIF_TRACE_EVENT("CLOSE CHANNEL %d", ch_id); in uipc_close_ch_locked()
453 if (ch_id >= UIPC_CH_NUM) in uipc_close_ch_locked()
456 if (uipc_main.ch[ch_id].srvfd != UIPC_DISCONNECTED) in uipc_close_ch_locked()
458 BTIF_TRACE_EVENT("CLOSE SERVER (FD %d)", uipc_main.ch[ch_id].srvfd); in uipc_close_ch_locked()
459 close(uipc_main.ch[ch_id].srvfd); in uipc_close_ch_locked()
460 FD_CLR(uipc_main.ch[ch_id].srvfd, &uipc_main.active_set); in uipc_close_ch_locked()
461 uipc_main.ch[ch_id].srvfd = UIPC_DISCONNECTED; in uipc_close_ch_locked()
465 if (uipc_main.ch[ch_id].fd != UIPC_DISCONNECTED) in uipc_close_ch_locked()
467 BTIF_TRACE_EVENT("CLOSE CONNECTION (FD %d)", uipc_main.ch[ch_id].fd); in uipc_close_ch_locked()
468 close(uipc_main.ch[ch_id].fd); in uipc_close_ch_locked()
469 FD_CLR(uipc_main.ch[ch_id].fd, &uipc_main.active_set); in uipc_close_ch_locked()
470 uipc_main.ch[ch_id].fd = UIPC_DISCONNECTED; in uipc_close_ch_locked()
475 if (uipc_main.ch[ch_id].cback) in uipc_close_ch_locked()
476 uipc_main.ch[ch_id].cback(ch_id, UIPC_CLOSE_EVT); in uipc_close_ch_locked()
486 void uipc_close_locked(tUIPC_CH_ID ch_id) in uipc_close_locked() argument
488 if (uipc_main.ch[ch_id].srvfd == UIPC_DISCONNECTED) in uipc_close_locked()
490 BTIF_TRACE_EVENT("CHANNEL %d ALREADY CLOSED", ch_id); in uipc_close_locked()
495 uipc_main.ch[ch_id].task_evt_flags |= UIPC_TASK_FLAG_DISCONNECT_CHAN; in uipc_close_locked()
502 int ch_id; in uipc_read_task() local
538 for (ch_id = 0; ch_id < UIPC_CH_NUM; ch_id++) in uipc_read_task()
540 if (ch_id != UIPC_CH_ID_AV_AUDIO) in uipc_read_task()
541 uipc_check_fd_locked(ch_id); in uipc_read_task()
619 BOOLEAN UIPC_Open(tUIPC_CH_ID ch_id, tUIPC_RCV_CBACK *p_cback) in UIPC_Open() argument
621 BTIF_TRACE_DEBUG("UIPC_Open : ch_id %d, p_cback %x", ch_id, p_cback); in UIPC_Open()
625 if (ch_id >= UIPC_CH_NUM) in UIPC_Open()
631 if (uipc_main.ch[ch_id].srvfd != UIPC_DISCONNECTED) in UIPC_Open()
633 BTIF_TRACE_EVENT("CHANNEL %d ALREADY OPEN", ch_id); in UIPC_Open()
638 switch(ch_id) in UIPC_Open()
641 uipc_setup_server_locked(ch_id, A2DP_CTRL_PATH, p_cback); in UIPC_Open()
645 uipc_setup_server_locked(ch_id, A2DP_DATA_PATH, p_cback); in UIPC_Open()
664 void UIPC_Close(tUIPC_CH_ID ch_id) in UIPC_Close() argument
666 BTIF_TRACE_DEBUG("UIPC_Close : ch_id %d", ch_id); in UIPC_Close()
669 if (ch_id != UIPC_CH_ID_ALL) in UIPC_Close()
672 uipc_close_locked(ch_id); in UIPC_Close()
692 BOOLEAN UIPC_Send(tUIPC_CH_ID ch_id, UINT16 msg_evt, UINT8 *p_buf, in UIPC_Send() argument
697 BTIF_TRACE_DEBUG("UIPC_Send : ch_id:%d %d bytes", ch_id, msglen); in UIPC_Send()
702 OSI_NO_INTR(ret = write(uipc_main.ch[ch_id].fd, p_buf, msglen)); in UIPC_Send()
722 UINT32 UIPC_Read(tUIPC_CH_ID ch_id, UINT16 *p_msg_evt, UINT8 *p_buf, UINT32 len) in UIPC_Read() argument
725 int fd = uipc_main.ch[ch_id].fd; in UIPC_Read()
729 if (ch_id >= UIPC_CH_NUM) in UIPC_Read()
731 BTIF_TRACE_ERROR("UIPC_Read : invalid ch id %d", ch_id); in UIPC_Read()
737 BTIF_TRACE_ERROR("UIPC_Read : channel %d closed", ch_id); in UIPC_Read()
754 uipc_main.ch[ch_id].read_poll_tmo_ms)); in UIPC_Read()
757 BTIF_TRACE_WARNING("poll timeout (%d ms)", uipc_main.ch[ch_id].read_poll_tmo_ms); in UIPC_Read()
772 uipc_close_locked(ch_id); in UIPC_Read()
786 uipc_close_locked(ch_id); in UIPC_Read()
814 extern BOOLEAN UIPC_Ioctl(tUIPC_CH_ID ch_id, UINT32 request, void *param) in UIPC_Ioctl() argument
816 BTIF_TRACE_DEBUG("#### UIPC_Ioctl : ch_id %d, request %d ####", ch_id, request); in UIPC_Ioctl()
823 uipc_flush_locked(ch_id); in UIPC_Ioctl()
828 uipc_main.ch[ch_id].cback = (tUIPC_RCV_CBACK*)param; in UIPC_Ioctl()
834 if (uipc_main.ch[ch_id].fd != UIPC_DISCONNECTED) in UIPC_Ioctl()
837 FD_CLR(uipc_main.ch[ch_id].fd, &uipc_main.active_set); in UIPC_Ioctl()
845 uipc_main.ch[ch_id].read_poll_tmo_ms = (intptr_t)param; in UIPC_Ioctl()
846 …BTIF_TRACE_EVENT("UIPC_SET_READ_POLL_TMO : CH %d, TMO %d ms", ch_id, uipc_main.ch[ch_id].read_poll… in UIPC_Ioctl()