Linux USB learning and recording

Linux USB has
four different data transfer methods:
    1. Control Transfers
    2. Interrupt Data Transfers
    3. Bulk data Transfers
    4. Isochronous Data Transfers
    
    
device can have many Each interface represents a function, and each interface corresponds to a driver.
kernel/include/linux/usb.h
#define USB_MAJOR 180
View /proc/devices and you can see the devices with the major device numbers of 180 and 189


If the USB device is not associated with any other subsystem, you need to use the usb_register_dev function in the probe function of the corresponding driver to register and obtain the main device number USB_MAJOR.
If the USB device is associated with other subsystems, you need to use the corresponding registration function in the probe function of the corresponding driver, and USB_MAJOR will not be used.
For example, the USB keyboard is associated with the input subsystem, and the driver corresponds to the /kernel/drivers/hid/usbhid/usbkbd.c file. In its probe function, you can see that input_register_device is used to register an input device.

There are four main types of USB descriptors: device descriptors, configuration descriptors, interface descriptors, and endpoint descriptors.
include/linux/usb/ch9.h
Interface descriptor: struct usb_host_interface
Endpoint descriptor: struct usb_endpoint_descriptor
                    .bmAttributes [1..0] = 00 Control transmission
                                            01 Isochronous transmission
                                            10 Batch transmission
                                            11 Interrupt transmission
Device descriptor: struct usb_device_descriptor
                    . idVendor Vendor ID (VID that people often say)
                    .idProduct Product ID (PID that people often say)
Configuration descriptor: usb_config_descriptor

Guess you like

Origin blog.csdn.net/qq543716996/article/details/103913486