Lines Matching refs:client_obj
84 client_t *client_obj; member
160 static inline void _record_client_opened_device(client_t *client_obj, uint8_t dev_addr) in _record_client_opened_device() argument
163 client_obj->dynamic.opened_dev_addr_map |= (1 << (dev_addr - 1)); in _record_client_opened_device()
166 static inline void _clear_client_opened_device(client_t *client_obj, uint8_t dev_addr) in _clear_client_opened_device() argument
169 client_obj->dynamic.opened_dev_addr_map &= ~(1 << (dev_addr - 1)); in _clear_client_opened_device()
172 static inline bool _check_client_opened_device(client_t *client_obj, uint8_t dev_addr) in _check_client_opened_device() argument
175 return (client_obj->dynamic.opened_dev_addr_map & (1 << (dev_addr - 1))); in _check_client_opened_device()
178 static bool _unblock_client(client_t *client_obj, bool in_isr) in _unblock_client() argument
181 if (!client_obj->dynamic.flags.events_pending && !client_obj->dynamic.flags.handling_events) { in _unblock_client()
182 client_obj->dynamic.flags.events_pending = 1; in _unblock_client()
193 xSemaphoreGiveFromISR(client_obj->constant.event_sem, &xTaskWoken); in _unblock_client()
196 xSemaphoreGive(client_obj->constant.event_sem); in _unblock_client()
235 client_t *client_obj; in send_event_msg_to_clients() local
236 TAILQ_FOREACH(client_obj, &p_host_lib_obj->mux_protected.client_tailq, dynamic.tailq_entry) { in send_event_msg_to_clients()
240 bool send = _check_client_opened_device(client_obj, opened_dev_addr); in send_event_msg_to_clients()
247 if (xQueueSend(client_obj->constant.event_msg_queue, event_msg, 0) == pdTRUE) { in send_event_msg_to_clients()
249 _unblock_client(client_obj, false); in send_event_msg_to_clients()
285 client_t *client_obj = (client_t *)urb->usb_host_client; in ctrl_xfer_callback() local
288 TAILQ_INSERT_TAIL(&client_obj->dynamic.done_ctrl_xfer_tailq, urb, tailq_entry); in ctrl_xfer_callback()
289 client_obj->dynamic.num_done_ctrl_xfer++; in ctrl_xfer_callback()
290 _unblock_client(client_obj, false); in ctrl_xfer_callback()
339 client_t *client_obj = (client_t *)ep_obj->constant.intf_obj->constant.client_obj; in pipe_callback() local
347 TAILQ_REMOVE(&client_obj->dynamic.idle_ep_tailq, ep_obj, dynamic.tailq_entry); in pipe_callback()
348 TAILQ_INSERT_TAIL(&client_obj->dynamic.pending_ep_tailq, ep_obj, dynamic.tailq_entry); in pipe_callback()
350 bool yield = _unblock_client(client_obj, in_isr); in pipe_callback()
566 static void _handle_pending_ep(client_t *client_obj) in _handle_pending_ep() argument
569 while (!TAILQ_EMPTY(&client_obj->dynamic.pending_ep_tailq)) { in _handle_pending_ep()
571 endpoint_t *ep_obj = TAILQ_FIRST(&client_obj->dynamic.pending_ep_tailq); in _handle_pending_ep()
572 TAILQ_REMOVE(&client_obj->dynamic.pending_ep_tailq, ep_obj, dynamic.tailq_entry); in _handle_pending_ep()
573 TAILQ_INSERT_TAIL(&client_obj->dynamic.idle_ep_tailq, ep_obj, dynamic.tailq_entry); in _handle_pending_ep()
625 client_t *client_obj = heap_caps_calloc(1, sizeof(client_t), MALLOC_CAP_DEFAULT); in usb_host_client_register() local
628 if (client_obj == NULL || event_sem == NULL || event_msg_queue == NULL) { in usb_host_client_register()
633 TAILQ_INIT(&client_obj->dynamic.pending_ep_tailq); in usb_host_client_register()
634 TAILQ_INIT(&client_obj->dynamic.idle_ep_tailq); in usb_host_client_register()
635 TAILQ_INIT(&client_obj->mux_protected.interface_tailq); in usb_host_client_register()
636 TAILQ_INIT(&client_obj->dynamic.done_ctrl_xfer_tailq); in usb_host_client_register()
637 client_obj->constant.event_sem = event_sem; in usb_host_client_register()
638 client_obj->constant.event_callback = client_config->async.client_event_callback; in usb_host_client_register()
639 client_obj->constant.callback_arg = client_config->async.callback_arg; in usb_host_client_register()
640 client_obj->constant.event_msg_queue = event_msg_queue; in usb_host_client_register()
647 TAILQ_INSERT_TAIL(&p_host_lib_obj->mux_protected.client_tailq, client_obj, dynamic.tailq_entry); in usb_host_client_register()
651 *client_hdl_ret = (usb_host_client_handle_t)client_obj; in usb_host_client_register()
662 heap_caps_free(client_obj); in usb_host_client_register()
669 client_t *client_obj = (client_t *)client_hdl; in usb_host_client_deregister() local
677 if (!TAILQ_EMPTY(&client_obj->dynamic.pending_ep_tailq) || in usb_host_client_deregister()
678 !TAILQ_EMPTY(&client_obj->dynamic.idle_ep_tailq) || in usb_host_client_deregister()
679 !TAILQ_EMPTY(&client_obj->dynamic.done_ctrl_xfer_tailq) || in usb_host_client_deregister()
680 client_obj->dynamic.flags.handling_events || in usb_host_client_deregister()
681 client_obj->dynamic.flags.blocked || in usb_host_client_deregister()
682 client_obj->dynamic.flags.taking_mux || in usb_host_client_deregister()
683 client_obj->dynamic.flags.num_intf_claimed != 0 || in usb_host_client_deregister()
684 client_obj->dynamic.num_done_ctrl_xfer != 0 || in usb_host_client_deregister()
685 client_obj->dynamic.opened_dev_addr_map != 0) { in usb_host_client_deregister()
697 TAILQ_REMOVE(&p_host_lib_obj->mux_protected.client_tailq, client_obj, dynamic.tailq_entry); in usb_host_client_deregister()
707 vQueueDelete(client_obj->constant.event_msg_queue); in usb_host_client_deregister()
708 vSemaphoreDelete(client_obj->constant.event_sem); in usb_host_client_deregister()
709 heap_caps_free(client_obj); in usb_host_client_deregister()
720 client_t *client_obj = (client_t *)client_hdl; in usb_host_client_handle_events() local
723 if (!client_obj->dynamic.flags.events_pending) { in usb_host_client_handle_events()
725 client_obj->dynamic.flags.blocked = 1; in usb_host_client_handle_events()
727 BaseType_t sem_ret = xSemaphoreTake(client_obj->constant.event_sem, timeout_ticks); in usb_host_client_handle_events()
729 client_obj->dynamic.flags.blocked = 0; in usb_host_client_handle_events()
738 client_obj->dynamic.flags.handling_events = 1; in usb_host_client_handle_events()
739 while (client_obj->dynamic.flags.handling_events) { in usb_host_client_handle_events()
741 if (!TAILQ_EMPTY(&client_obj->dynamic.pending_ep_tailq)) { in usb_host_client_handle_events()
742 _handle_pending_ep(client_obj); in usb_host_client_handle_events()
745 while (client_obj->dynamic.num_done_ctrl_xfer > 0) { in usb_host_client_handle_events()
746 urb_t *urb = TAILQ_FIRST(&client_obj->dynamic.done_ctrl_xfer_tailq); in usb_host_client_handle_events()
747 TAILQ_REMOVE(&client_obj->dynamic.done_ctrl_xfer_tailq, urb, tailq_entry); in usb_host_client_handle_events()
748 client_obj->dynamic.num_done_ctrl_xfer--; in usb_host_client_handle_events()
755 while (uxQueueMessagesWaiting(client_obj->constant.event_msg_queue) > 0) { in usb_host_client_handle_events()
759 … BaseType_t queue_ret = xQueueReceive(client_obj->constant.event_msg_queue, &event_msg, 0); in usb_host_client_handle_events()
761 client_obj->constant.event_callback(&event_msg, client_obj->constant.callback_arg); in usb_host_client_handle_events()
765 if (TAILQ_EMPTY(&client_obj->dynamic.pending_ep_tailq) && in usb_host_client_handle_events()
766 client_obj->dynamic.num_done_ctrl_xfer == 0 && in usb_host_client_handle_events()
767 uxQueueMessagesWaiting(client_obj->constant.event_msg_queue) == 0) { in usb_host_client_handle_events()
769 client_obj->dynamic.flags.events_pending = 0; in usb_host_client_handle_events()
770 client_obj->dynamic.flags.handling_events = 0; in usb_host_client_handle_events()
783 client_t *client_obj = (client_t *)client_hdl; in usb_host_client_unblock() local
786 _unblock_client(client_obj, false); in usb_host_client_unblock()
797 client_t *client_obj = (client_t *)client_hdl; in usb_host_device_open() local
807 if (_check_client_opened_device(client_obj, dev_addr)) { in usb_host_device_open()
814 _record_client_opened_device(client_obj, dev_addr); in usb_host_device_open()
830 client_t *client_obj = (client_t *)client_hdl; in usb_host_device_close() local
838 TAILQ_FOREACH(intf_obj, &client_obj->mux_protected.interface_tailq, mux_protected.tailq_entry) { in usb_host_device_close()
853 HOST_CHECK_FROM_CRIT(_check_client_opened_device(client_obj, dev_addr), ESP_ERR_NOT_FOUND); in usb_host_device_close()
854 if (!_check_client_opened_device(client_obj, dev_addr)) { in usb_host_device_close()
861 _clear_client_opened_device(client_obj, dev_addr); in usb_host_device_close()
961 static interface_t *interface_alloc(client_t *client_obj, usb_device_handle_t dev_hdl, const usb_in… in interface_alloc() argument
968 intf_obj->constant.client_obj = client_obj; in interface_alloc()
984 static esp_err_t interface_claim(client_t *client_obj, usb_device_handle_t dev_hdl, const usb_confi… in interface_claim() argument
996 interface_t *intf_obj = interface_alloc(client_obj, dev_hdl, intf_desc); in interface_claim()
1019 …TAILQ_INSERT_TAIL(&client_obj->mux_protected.interface_tailq, intf_obj, mux_protected.tailq_entry); in interface_claim()
1023 …TAILQ_INSERT_TAIL(&client_obj->dynamic.idle_ep_tailq, intf_obj->constant.endpoints[i], dynamic.tai… in interface_claim()
1041 static esp_err_t interface_release(client_t *client_obj, usb_device_handle_t dev_hdl, uint8_t bInte… in interface_release() argument
1047 …TAILQ_FOREACH(intf_obj_iter, &client_obj->mux_protected.interface_tailq, mux_protected.tailq_entry… in interface_release()
1076 …TAILQ_REMOVE(&client_obj->dynamic.idle_ep_tailq, intf_obj->constant.endpoints[i], dynamic.tailq_en… in interface_release()
1081 TAILQ_REMOVE(&client_obj->mux_protected.interface_tailq, intf_obj, mux_protected.tailq_entry); in interface_release()
1100 client_t *client_obj = (client_t *)client_hdl; in usb_host_interface_claim() local
1106 HOST_CHECK_FROM_CRIT(_check_client_opened_device(client_obj, dev_addr), ESP_ERR_INVALID_STATE); in usb_host_interface_claim()
1107 client_obj->dynamic.flags.taking_mux = 1; in usb_host_interface_claim()
1117 …ret = interface_claim(client_obj, dev_hdl, config_desc, bInterfaceNumber, bAlternateSetting, &intf… in usb_host_interface_claim()
1127 client_obj->dynamic.flags.num_intf_claimed++; in usb_host_interface_claim()
1129 client_obj->dynamic.flags.taking_mux = 0; in usb_host_interface_claim()
1137 client_t *client_obj = (client_t *)client_hdl; in usb_host_interface_release() local
1143 HOST_CHECK_FROM_CRIT(_check_client_opened_device(client_obj, dev_addr), ESP_ERR_INVALID_STATE); in usb_host_interface_release()
1144 client_obj->dynamic.flags.taking_mux = 1; in usb_host_interface_release()
1149 esp_err_t ret = interface_release(client_obj, dev_hdl, bInterfaceNumber); in usb_host_interface_release()
1154 client_obj->dynamic.flags.num_intf_claimed--; in usb_host_interface_release()
1156 client_obj->dynamic.flags.taking_mux = 0; in usb_host_interface_release()