mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 02:03:06 -05:00
Kernel/USB: Add all USB 2.0 bmRequestType fields
This commit is contained in:
parent
5578a5a32d
commit
3b4f71e4df
Notes:
sideshowbarker
2024-07-18 06:53:07 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/3b4f71e4df9 Pull-request: https://github.com/SerenityOS/serenity/pull/9394 Reviewed-by: https://github.com/supercomputer7
3 changed files with 18 additions and 15 deletions
|
@ -579,7 +579,7 @@ void UHCIController::free_descriptor_chain(TransferDescriptor* first_descriptor)
|
|||
KResultOr<size_t> UHCIController::submit_control_transfer(Transfer& transfer)
|
||||
{
|
||||
Pipe& pipe = transfer.pipe(); // Short circuit the pipe related to this transfer
|
||||
bool direction_in = (transfer.request().request_type & USB_DEVICE_REQUEST_DEVICE_TO_HOST) == USB_DEVICE_REQUEST_DEVICE_TO_HOST;
|
||||
bool direction_in = (transfer.request().request_type & USB_REQUEST_TRANSFER_DIRECTION_DEVICE_TO_HOST) == USB_REQUEST_TRANSFER_DIRECTION_DEVICE_TO_HOST;
|
||||
|
||||
TransferDescriptor* setup_td = create_transfer_descriptor(pipe, PacketID::SETUP, sizeof(USBRequestData));
|
||||
if (!setup_td)
|
||||
|
|
|
@ -46,9 +46,8 @@ KResult Device::enumerate()
|
|||
{
|
||||
USBDeviceDescriptor dev_descriptor {};
|
||||
|
||||
// FIXME: 0x100 is a magic number for now, as I'm not quite sure how these are constructed....
|
||||
// Send 8-bytes to get at least the `max_packet_size` from the device
|
||||
auto transfer_length_or_error = m_default_pipe->control_transfer(USB_DEVICE_REQUEST_DEVICE_TO_HOST, USB_REQUEST_GET_DESCRIPTOR, 0x100, 0, 8, &dev_descriptor);
|
||||
auto transfer_length_or_error = m_default_pipe->control_transfer(USB_REQUEST_TRANSFER_DIRECTION_DEVICE_TO_HOST, USB_REQUEST_GET_DESCRIPTOR, (DESCRIPTOR_TYPE_DEVICE << 8), 0, 8, &dev_descriptor);
|
||||
|
||||
if (transfer_length_or_error.is_error())
|
||||
return transfer_length_or_error.error();
|
||||
|
@ -62,7 +61,7 @@ KResult Device::enumerate()
|
|||
VERIFY(dev_descriptor.descriptor_header.descriptor_type == DESCRIPTOR_TYPE_DEVICE);
|
||||
m_default_pipe->set_max_packet_size(dev_descriptor.max_packet_size);
|
||||
|
||||
transfer_length_or_error = m_default_pipe->control_transfer(USB_DEVICE_REQUEST_DEVICE_TO_HOST, USB_REQUEST_GET_DESCRIPTOR, 0x100, 0, sizeof(USBDeviceDescriptor), &dev_descriptor);
|
||||
transfer_length_or_error = m_default_pipe->control_transfer(USB_REQUEST_TRANSFER_DIRECTION_DEVICE_TO_HOST, USB_REQUEST_GET_DESCRIPTOR, (DESCRIPTOR_TYPE_DEVICE << 8), 0, sizeof(USBDeviceDescriptor), &dev_descriptor);
|
||||
|
||||
if (transfer_length_or_error.is_error())
|
||||
return transfer_length_or_error.error();
|
||||
|
@ -87,7 +86,7 @@ KResult Device::enumerate()
|
|||
m_address = m_controller->allocate_address();
|
||||
|
||||
// Attempt to set devices address on the bus
|
||||
transfer_length_or_error = m_default_pipe->control_transfer(USB_DEVICE_REQUEST_HOST_TO_DEVICE, USB_REQUEST_SET_ADDRESS, m_address, 0, 0, nullptr);
|
||||
transfer_length_or_error = m_default_pipe->control_transfer(USB_REQUEST_TRANSFER_DIRECTION_HOST_TO_DEVICE, USB_REQUEST_SET_ADDRESS, m_address, 0, 0, nullptr);
|
||||
|
||||
if (transfer_length_or_error.is_error())
|
||||
return transfer_length_or_error.error();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
|
||||
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -9,18 +10,21 @@
|
|||
#include <AK/Types.h>
|
||||
|
||||
//
|
||||
// USB Request directions
|
||||
// bmRequestType fields
|
||||
//
|
||||
// As per Section 9.4 of the USB Specification, it is noted that Requeset Types that
|
||||
// Device to Host have bit 7 of `bmRequestType` set. These are here as a convenience,
|
||||
// as we construct the request at the call-site to make reading transfers easier.
|
||||
// As per Section 9.3 of the USB 2.0 Specification.
|
||||
// Note that while some of these values are zero, there are here for convenience.
|
||||
// This is because it makes reading the request type easier to read when constructing a USB request.
|
||||
//
|
||||
static constexpr u8 USB_DEVICE_REQUEST_DEVICE_TO_HOST = 0x80;
|
||||
static constexpr u8 USB_DEVICE_REQUEST_HOST_TO_DEVICE = 0x00;
|
||||
static constexpr u8 USB_INTERFACE_REQUEST_DEVICE_TO_HOST = 0x81;
|
||||
static constexpr u8 USB_INTERFACE_REQUEST_HOST_TO_DEVICE = 0x01;
|
||||
static constexpr u8 USB_ENDPOINT_REQUEST_DEVICE_TO_HOST = 0x82;
|
||||
static constexpr u8 USB_ENDPOINT_REQUEST_HOST_TO_DEVICE = 0x02;
|
||||
static constexpr u8 USB_REQUEST_TRANSFER_DIRECTION_DEVICE_TO_HOST = 0x80;
|
||||
static constexpr u8 USB_REQUEST_TRANSFER_DIRECTION_HOST_TO_DEVICE = 0x00;
|
||||
static constexpr u8 USB_REQUEST_TYPE_STANDARD = 0x00;
|
||||
static constexpr u8 USB_REQUEST_TYPE_CLASS = 0x20;
|
||||
static constexpr u8 USB_REQUEST_TYPE_VENDOR = 0x40;
|
||||
static constexpr u8 USB_REQUEST_RECIPIENT_DEVICE = 0x00;
|
||||
static constexpr u8 USB_REQUEST_RECIPIENT_INTERFACE = 0x01;
|
||||
static constexpr u8 USB_REQUEST_RECIPIENT_ENDPOINT = 0x02;
|
||||
static constexpr u8 USB_REQUEST_RECIPIENT_OTHER = 0x03;
|
||||
|
||||
//
|
||||
// Standard USB request types
|
||||
|
|
Loading…
Add table
Reference in a new issue