From 5226d6103a000fb1a0b6a3fb35c13433d9ac8e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Wed, 1 May 2019 15:55:13 +0200 Subject: [PATCH] IOS/USB: Add debug logging for all transfers This makes debugging USB issues easier. --- Source/Core/Core/IOS/USB/LibusbDevice.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Source/Core/Core/IOS/USB/LibusbDevice.cpp b/Source/Core/Core/IOS/USB/LibusbDevice.cpp index 0821cfacbe..736695cab7 100644 --- a/Source/Core/Core/IOS/USB/LibusbDevice.cpp +++ b/Source/Core/Core/IOS/USB/LibusbDevice.cpp @@ -18,6 +18,7 @@ #include "Common/Assert.h" #include "Common/Logging/Log.h" +#include "Common/StringUtil.h" #include "Core/HW/Memmap.h" #include "Core/IOS/Device.h" #include "Core/IOS/IOS.h" @@ -184,11 +185,19 @@ int LibusbDevice::SubmitTransfer(std::unique_ptr cmd) if (!m_device_attached) return LIBUSB_ERROR_NOT_FOUND; + DEBUG_LOG(IOS_USB, + "[%04x:%04x %d] Control: bRequestType=%02x bRequest=%02x wValue=%04x" + " wIndex=%04x wLength=%04x", + m_vid, m_pid, m_active_interface, cmd->request_type, cmd->request, cmd->value, + cmd->index, cmd->length); + switch ((cmd->request_type << 8) | cmd->request) { // The following requests have to go through libusb and cannot be directly sent to the device. case USBHDR(DIR_HOST2DEVICE, TYPE_STANDARD, REC_INTERFACE, REQUEST_SET_INTERFACE): { + INFO_LOG(IOS_USB, "[%04x:%04x %d] REQUEST_SET_INTERFACE index=%04x value=%04x", m_vid, m_pid, + m_active_interface, cmd->index, cmd->value); if (static_cast(cmd->index) != m_active_interface) { const int ret = ChangeInterface(static_cast(cmd->index)); @@ -206,6 +215,8 @@ int LibusbDevice::SubmitTransfer(std::unique_ptr cmd) } case USBHDR(DIR_HOST2DEVICE, TYPE_STANDARD, REC_DEVICE, REQUEST_SET_CONFIGURATION): { + INFO_LOG(IOS_USB, "[%04x:%04x %d] REQUEST_SET_CONFIGURATION index=%04x value=%04x", m_vid, + m_pid, m_active_interface, cmd->index, cmd->value); const int ret = libusb_set_configuration(m_handle, cmd->value); if (ret == 0) m_ios.EnqueueIPCReply(cmd->ios_request, cmd->length); @@ -230,6 +241,9 @@ int LibusbDevice::SubmitTransfer(std::unique_ptr cmd) if (!m_device_attached) return LIBUSB_ERROR_NOT_FOUND; + DEBUG_LOG(IOS_USB, "[%04x:%04x %d] Bulk: length=%04x endpoint=%02x", m_vid, m_pid, + m_active_interface, cmd->length, cmd->endpoint); + libusb_transfer* transfer = libusb_alloc_transfer(0); libusb_fill_bulk_transfer(transfer, m_handle, cmd->endpoint, cmd->MakeBuffer(cmd->length).release(), cmd->length, TransferCallback, @@ -244,6 +258,9 @@ int LibusbDevice::SubmitTransfer(std::unique_ptr cmd) if (!m_device_attached) return LIBUSB_ERROR_NOT_FOUND; + DEBUG_LOG(IOS_USB, "[%04x:%04x %d] Interrupt: length=%04x endpoint=%02x", m_vid, m_pid, + m_active_interface, cmd->length, cmd->endpoint); + libusb_transfer* transfer = libusb_alloc_transfer(0); libusb_fill_interrupt_transfer(transfer, m_handle, cmd->endpoint, cmd->MakeBuffer(cmd->length).release(), cmd->length, @@ -258,6 +275,9 @@ int LibusbDevice::SubmitTransfer(std::unique_ptr cmd) if (!m_device_attached) return LIBUSB_ERROR_NOT_FOUND; + DEBUG_LOG(IOS_USB, "[%04x:%04x %d] Isochronous: length=%04x endpoint=%02x num_packets=%02x", + m_vid, m_pid, m_active_interface, cmd->length, cmd->endpoint, cmd->num_packets); + libusb_transfer* transfer = libusb_alloc_transfer(cmd->num_packets); transfer->buffer = cmd->MakeBuffer(cmd->length).release(); transfer->callback = TransferCallback;