From 4b7d90f9393203fe90be01e1cffaa816aec83568 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Fri, 21 Aug 2026 16:22:14 +0300 Subject: [PATCH] Kernel: Ignore SET_PROTOCOL(1) errors on HID devices One of my USB mice is a boot protocol device but stalls on SET_PROTOCOL request. USB HID is supposed to be in report protocol on initialization so an error *should* not be an issue --- kernel/kernel/USB/HID/HIDDriver.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/kernel/kernel/USB/HID/HIDDriver.cpp b/kernel/kernel/USB/HID/HIDDriver.cpp index 833d9838..c378319d 100644 --- a/kernel/kernel/USB/HID/HIDDriver.cpp +++ b/kernel/kernel/USB/HID/HIDDriver.cpp @@ -14,6 +14,7 @@ namespace Kernel enum HIDRequest : uint8_t { + GET_PROTOCOL = 0x03, SET_PROTOCOL = 0x0B, }; @@ -84,7 +85,7 @@ namespace Kernel BAN::ErrorOr USBHIDDriver::initialize() { - auto dma_buffer = TRY(DMARegion::create(1024)); + auto dma_buffer = TRY(DMARegion::create(1024, PageTable::MemoryType::Normal)); ASSERT(static_cast(m_interface.descriptor.bInterfaceClass) == USB::InterfaceBaseClass::HID); @@ -119,13 +120,14 @@ namespace Kernel // If this device supports boot protocol, make sure it is not used if (m_interface.descriptor.bInterfaceSubClass == 0x01) { - USBDeviceRequest request; - request.bmRequestType = USB::RequestType::HostToDevice | USB::RequestType::Class | USB::RequestType::Interface; - request.bRequest = HIDRequest::SET_PROTOCOL; - request.wValue = 1; // report protocol - request.wIndex = m_interface.descriptor.bInterfaceNumber; - request.wLength = 0; - TRY(m_device.send_request(request, 0)); + const auto request = USBDeviceRequest { + .bmRequestType = USB::RequestType::HostToDevice | USB::RequestType::Class | USB::RequestType::Interface, + .bRequest = HIDRequest::SET_PROTOCOL, + .wValue = 1, // report protocol + .wIndex = m_interface.descriptor.bInterfaceNumber, + .wLength = 0, + }; + (void)m_device.send_request(request, 0); } const auto& hid_descriptor = *reinterpret_cast(m_interface.misc_descriptors[hid_descriptor_index].data());