Lines Matching refs:handle
90 static void usb_kick_locked(usb_handle* handle);
103 static void AddDevice(std::unique_ptr<usb_handle> handle) { in AddDevice() argument
104 handle->mark = true; in AddDevice()
106 g_usb_handles.push_back(std::move(handle)); in AddDevice()
314 std::unique_ptr<usb_handle> handle = in AndroidInterfaceAdded() local
316 if (handle == nullptr) { in AndroidInterfaceAdded()
321 handle->devpath = devpath; in AndroidInterfaceAdded()
322 usb_handle* handle_p = handle.get(); in AndroidInterfaceAdded()
324 LOG(INFO) << "reported max packet size for " << serial << " is " << handle->max_packet_size; in AndroidInterfaceAdded()
325 AddDevice(std::move(handle)); in AndroidInterfaceAdded()
357 std::unique_ptr<usb_handle> handle; in CheckInterface() local
391 handle.reset(new usb_handle); in CheckInterface()
392 if (handle == nullptr) { in CheckInterface()
436 handle->bulkIn = endpoint; in CheckInterface()
438 if (!ClearPipeStallBothEnds(interface, handle->bulkIn)) { in CheckInterface()
444 handle->bulkOut = endpoint; in CheckInterface()
446 if (!ClearPipeStallBothEnds(interface, handle->bulkOut)) { in CheckInterface()
460 handle->zero_mask = endPointMaxPacketSize - 1; in CheckInterface()
461 handle->max_packet_size = endPointMaxPacketSize; in CheckInterface()
464 handle->interface = interface; in CheckInterface()
465 return handle; in CheckInterface()
518 int usb_write(usb_handle *handle, const void *buf, int len) in usb_write() argument
525 if (!handle || handle->dead) in usb_write()
528 if (NULL == handle->interface) { in usb_write()
533 if (0 == handle->bulkOut) { in usb_write()
539 (*handle->interface)->WritePipe(handle->interface, handle->bulkOut, (void *)buf, len); in usb_write()
541 if ((result == 0) && (handle->zero_mask)) { in usb_write()
543 if(!(len & handle->zero_mask)) { in usb_write()
545 (*handle->interface)->WritePipe( in usb_write()
546 handle->interface, handle->bulkOut, (void *)buf, 0); in usb_write()
557 int usb_read(usb_handle *handle, void *buf, int len) in usb_read() argument
566 if (!handle || handle->dead) { in usb_read()
570 if (NULL == handle->interface) { in usb_read()
575 if (0 == handle->bulkIn) { in usb_read()
580 result = (*handle->interface)->ReadPipe(handle->interface, handle->bulkIn, buf, &numBytes); in usb_read()
584 (*handle->interface)->ClearPipeStall(handle->interface, handle->bulkIn); in usb_read()
585 result = (*handle->interface)->ReadPipe(handle->interface, handle->bulkIn, buf, &numBytes); in usb_read()
597 int usb_close(usb_handle *handle) in usb_close() argument
601 if ((*it).get() == handle) { in usb_close()
609 void usb_reset(usb_handle* handle) { in usb_reset() argument
611 usb_kick(handle); in usb_reset()
614 static void usb_kick_locked(usb_handle *handle) in usb_kick_locked() argument
618 if (!handle) in usb_kick_locked()
621 if (!handle->dead) in usb_kick_locked()
623 handle->dead = true; in usb_kick_locked()
624 (*handle->interface)->USBInterfaceClose(handle->interface); in usb_kick_locked()
625 (*handle->interface)->Release(handle->interface); in usb_kick_locked()
629 void usb_kick(usb_handle *handle) { in usb_kick() argument
632 usb_kick_locked(handle); in usb_kick()
635 size_t usb_get_max_packet_size(usb_handle* handle) { in usb_get_max_packet_size() argument
636 return handle->max_packet_size; in usb_get_max_packet_size()