libusb / libusb

A cross-platform library to access USB devices
https://libusb.info
GNU Lesser General Public License v2.1
5.22k stars 1.9k forks source link

Support for reporting USB 3.2 Gen2x2 speeds over libusb #1477

Closed hjmallon closed 4 months ago

hjmallon commented 6 months ago

This is a much simpler stab at https://github.com/libusb/libusb/pull/680

It reports the correct information on Linux (tested on kernel 5.15), and on macOS (tested with a USB 3.2 gen2x2 card in a Mac Pro on the latest macOS)

hjmallon commented 6 months ago

Thanks for the review, I have applied changes and rebased on master

tormodvolden commented 5 months ago

BTW, it seems this is not possible to detect on WIndows yet: https://techcommunity.microsoft.com/t5/windows-11/how-to-distinguish-usb-3-2-gen-2-10gb-s-and-gen-2-2-20gb-s-by-c/m-p/3053969

mcuee commented 5 months ago

Tested under Linux Ubuntu 24.04 (just installed today) on an Intel N100 Mini PC. It seems to work fine.

mcuee@HeroBoxUbuntu:~/build/libusb/libusb_pr1477$ ./examples/testlibusb 
Dev (bus 4, device 11): 05E3 - 0749 speed: 5G
Dev (bus 4, device 10): 0BDA - 0411 speed: 5G
Dev (bus 4, device 9): 0BDA - 0411 speed: 5G
Dev (bus 4, device 1): 1D6B - 0003 speed: 10G
Dev (bus 3, device 21): 1A40 - 0201 speed: 480M
Dev (bus 3, device 20): 1915 - 1025 speed: 12M
Dev (bus 3, device 18): 1A40 - 0201 speed: 480M
Dev (bus 3, device 19): 0AC8 - 3420 speed: 480M
Dev (bus 3, device 17): 0BDA - 5411 speed: 480M
Dev (bus 3, device 16): 0BDA - 5411 speed: 480M
Dev (bus 3, device 2): 046D - C52B speed: 12M
Dev (bus 3, device 3): 8087 - 0026 speed: 12M
Dev (bus 3, device 1): 1D6B - 0002 speed: 480M
Dev (bus 2, device 1): 1D6B - 0003 speed: 20G
Dev (bus 1, device 1): 1D6B - 0002 speed: 480M

lsusb -t output

mcuee@HeroBoxUbuntu:~/build/libusb/libusb_pr1477$ lsusb -t
/:  Bus 001.Port 001: Dev 001, Class=root_hub, Driver=xhci_hcd/1p, 480M
/:  Bus 002.Port 001: Dev 001, Class=root_hub, Driver=xhci_hcd/1p, 20000M/x2
/:  Bus 003.Port 001: Dev 001, Class=root_hub, Driver=xhci_hcd/12p, 480M
    |__ Port 002: Dev 002, If 0, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 002: Dev 002, If 1, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 002: Dev 002, If 2, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 006: Dev 016, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 001: Dev 017, If 0, Class=Hub, Driver=hub/4p, 480M
            |__ Port 001: Dev 019, If 0, Class=Video, Driver=uvcvideo, 480M
            |__ Port 001: Dev 019, If 1, Class=Video, Driver=uvcvideo, 480M
            |__ Port 001: Dev 019, If 2, Class=Audio, Driver=snd-usb-audio, 480M
            |__ Port 001: Dev 019, If 3, Class=Audio, Driver=snd-usb-audio, 480M
        |__ Port 004: Dev 018, If 0, Class=Hub, Driver=hub/7p, 480M
            |__ Port 004: Dev 020, If 0, Class=Audio, Driver=snd-usb-audio, 12M
            |__ Port 004: Dev 020, If 1, Class=Audio, Driver=snd-usb-audio, 12M
            |__ Port 004: Dev 020, If 2, Class=Human Interface Device, Driver=usbhid, 12M
            |__ Port 004: Dev 020, If 3, Class=Human Interface Device, Driver=usbhid, 12M
            |__ Port 005: Dev 021, If 0, Class=Hub, Driver=hub/7p, 480M
    |__ Port 010: Dev 003, If 0, Class=Wireless, Driver=btusb, 12M
    |__ Port 010: Dev 003, If 1, Class=Wireless, Driver=btusb, 12M
/:  Bus 004.Port 001: Dev 001, Class=root_hub, Driver=xhci_hcd/4p, 10000M
    |__ Port 001: Dev 009, If 0, Class=Hub, Driver=hub/4p, 5000M
        |__ Port 001: Dev 010, If 0, Class=Hub, Driver=hub/4p, 5000M
            |__ Port 002: Dev 011, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
tormodvolden commented 4 months ago

Thanks for the patch, review and testing everyone!