Commit graph

183 commits

Author SHA1 Message Date
akw@oneirism.org 6dbfe8c356 nusb/ptp: increase payload
A silly little patch, but some ptp devices (like the camera I own) use USB3 endpoints and subsequently require the data size of the payload to be 1024(-12 for metadata). This is reflected in libgphoto2's current ptp driver.
2022-06-30 01:58:01 +00:00
cinap_lenrek 990ceeef3b nusb/usbd: retry opendevtata() a few times on attach (work around mnt-reform trackball)
this is a known and already fixed issue with version the following version
of the mnt-reform trackball firmware:

55ca5bf848
2022-06-18 23:37:12 +00:00
Michael Forney 5c96a51f3a nusb/serial: fix pl2303 usbcmd error checks
Since e0087b2a, usbcmd with Rh2d returns the size of the data stage
(excluding the setup packet), so adjust the expected return values
accordingly.
2022-01-01 22:51:18 +00:00
cinap_lenrek be0a80faf3 nusb/disk: use setalt(), print argv0 in prints instead of "disk:" 2022-02-23 18:38:28 +00:00
cinap_lenrek 045936a778 nusb/cam: fix mistake (nil vs -1) 2022-02-23 18:13:00 +00:00
cinap_lenrek 8bf71adc94 nusb/audio: use setalt(), make sure endpoint has right direction. 2022-02-23 18:03:53 +00:00
cinap_lenrek 11e12ea0c0 nusb/cam: use setalt() 2022-02-23 18:02:02 +00:00
cinap_lenrek 67750a093f nusb/ether: use setalt() 2022-02-23 18:01:15 +00:00
cinap_lenrek bea20cd152 nusb/lib: provide a setalt() function to set the interface to its altsetting 2022-02-23 18:00:34 +00:00
cinap_lenrek 9cd55a085d nusb/ether: remove csp check for rndis, already done in nusbrc 2022-02-23 17:59:13 +00:00
cinap_lenrek 065d601916 nusb: Fix handling of interface altsetting.
The altsetting was handled only for a single endpoint
(per interface number), but has to be handled for each
endpoint (per interface *AND* altsetting number).

A multi function device (like a disk) can have
multiple interfaces, all with the same interface number
but varying altsetting numbers and each of these
interfaces would list distict endpoint configurations.

Multiple interfaces can even share some endpoints (they
use the same endpoint addresses), but
we still have to duplicate them for each
interface+altsetting number (as they'r part of
actually distict interfaces with distict endpoint
configurations).

It is also important to *NOT* make endpoints bi-directional
(dir == Eboth) when only one direction is used in a
interface/altsetting and the other direction in another.
This was the case for nusb/disk with some seagate drive
where endpoints where shared between the UAS and
usb storage class interface (but with distict altsettings).

The duplicate endpoints (as in using the same endpoint address)
are chained together by a next pointer and the head
is stored in Usbdev.ep[addr], where addr is the endpoint
address. These Ep structures will have distinct endpoint
numbers Ep.id (when they have conflicting types), but all
will share the endpoint address (lower 4 bits of the
endpoint number).

The consequence is that all of the endpoints configuration
(attributes, interval) is now stored in the Ep struct and
no more Altc struct is present.

A pointer to the Ep struct has to be passed to openep()
for it to configure the endpoint.

For the Iface struct, we will now create multiple of them:
one for each interface *AND* altsetting nunber,
chained together on a next pointer and the head being
stored in conf->iface[ifaceid].

--
cinap
2022-02-21 19:50:16 +00:00
cinap_lenrek 4ab2d149d4 nusb/usbd: use per hname collision counter instead of device address to resolve collisions
The device address is highly variable and depends on
all prior enumerated devices.

This can happen with some devices that do not have
a serial number and all devices of the same type
having the same hname.

Using a counter of collisions per hname makes more sense
and is more stable (given that the order devices are
enumerated is deterministic).
2022-02-06 01:19:01 +00:00
Sigrid f5db3bf0e0 nusb/ether: rndis: add standard class code (tested by jmi2k with OnePlus 8) 2021-04-20 18:08:58 +02:00
Romano a398a09783 [9front] [patch] nusb/ether -t rndis 2021-04-01 12:54:08 +02:00
cinap_lenrek 2f28aaac65 nusb: don't create rw iso endpoints (by Michael Forney)
There may be two iso endpoints with the same ID if it is asynchronous
or adaptive (one for data, one for feedback), and rw iso endpoints are
unusable (error out with "iso i/o is half-duplex").
2021-02-10 20:08:13 +01:00
cinap_lenrek d7ade692c8 nusb: don't create rw iso endpoints (by Michael Forney)
There may be two iso endpoints with the same ID if it is asynchronous
or adaptive (one for data, one for feedback), and rw iso endpoints are
unusable (error out with "iso i/o is half-duplex").
2021-02-10 19:52:00 +01:00
Sigrid a9e70446a0 nusb/kb: correct Mod4 scancode (125 → 91, to match what kbdfs has) 2021-01-22 17:48:41 +01:00
Sigrid 07805ac892 nusb/kb: update button state if event was actually received, fix typos (thanks umbraticus) 2020-12-08 11:47:15 +01:00
mischief f8738fd757 nusb/kb, nusb/joy: dont try to set protocol on nonboot devices
the hid 1.11 specification says that for hid devices which arent in
the boot subclass (subclass 1), it is only optional to support the set
protocol command.  for my devices, trying to set protocol results in a
stall error and unusable devices.

fixes my Tex Shinobi keyboard and Playstation 4 controller.
2020-11-21 12:31:54 -08:00
cinap_lenrek e8111e517d nusb/cam: don't videoclose() when open failed
The fsdestroyfid() is called regardless if the open succeeded
or failed. This causes erroneous videoclose() when opening
the frame or video file while the camera is active.
2020-11-16 19:56:13 +01:00
Ori Bernstein 98c07541bb nusb/serial: add ids for FT230X (thanks mischief) 2020-10-17 19:27:21 -07:00
Sigrid 0505f8fb3a nusb/lib: use fmtprint for the entire dump to be printed out 2020-08-23 12:14:32 +02:00
kvik 758edf2b14 nusb/kb: add quirks for Elecom HUGE trackball
As said in the code comment:

	Elecom trackball report descriptor lies by
	omission, failing to mention all its buttons.
	We patch the descriptor with a correct count
	which lets us parse full reports. Tested with:
		Elecom HUGE (M-HT1DRBK, M-HT1URBK)

The descriptor fixup is adapted from Linux kernel:
	drivers/hid/hid-elecom.c
in which a more detailed account of why and how this
works may be found.

A followup change to nusb/kb will be needed to expose
these additional events for potential remapping.
2020-05-08 20:49:11 +02:00
cinap_lenrek ecba7822e3 nusb/usbd: fix portreset error handling
error handling in portreset() was wrong. we called closedev()
on the device without changing the reference.

just call portdetach() when the reset fails.
2020-04-05 03:05:06 +02:00
cinap_lenrek 315f20b9f4 nusb/audio: set frequency only when supported
before setting the sampling rate, check bit D0
"Sampling Frequency" in the audio class specific
endpoint descriptor.
2020-04-05 00:59:47 +02:00
cinap_lenrek fe39388250 nusb/usbd: cleanup processes on unmount
this makes sure that when postsharesrv() fails (for
example because the shr file already exists), the
worker process gets killed and all file descriptors
to devusb get closed.
2020-03-08 16:06:37 +01:00
cinap_lenrek efd64da989 nusb/usbd: fix /env/usbbusy bug
run the usb hub poll "work()" proc in the same filedescriptor
group as the fileserver by forking the process in Srv.start
callback.

this also prevents the usbbusy filedescriptor from being kept
open by the fileserver process.
2020-03-07 22:26:49 +01:00
cinap_lenrek 3a4a3faf29 nusb/usbd: work around devices that ignore the high byte of wLength in control transfer reads
there appear to be devices out there such as Realtek RTL2838UHIDIR
SDR that do not process control transfers correctly, ignoring the
high byte of the wLength field. to work around this, we specify an
odd number of bytes for read sizes >= 256 which keeps the low byte
0xFF.
2019-05-07 09:19:53 +02:00
mischief 83ab780783 nusb/usbd: stop sending port enable commands
from what i can tell, sending port enable is a spec violation.

this fixes a hang during hub enumeration in the ASMedia
xhci controller when i plug in my IBM UltraNav SK-8845.

also, send unsuspend when port is suspended instead of enable.

from the USB 2 specification:

11.24.2.7.1.2 PORT_ENABLE
...
This bit may be set only as a result of a SetPortFeature(PORT_ENABLE).
...
The hub response to a SetPortFeature(PORT_ENABLE) request is not specified.
2019-04-18 02:48:35 -07:00
mischief 07674f6e8d nusb/usbd: fix dump %U formatter 2019-04-13 22:37:52 -07:00
cinap_lenrek 58668339bc nusb/kb: fix continuous scrollwheel delta not being reported (thanks sam-d) 2019-03-21 01:27:28 +01:00
cinap_lenrek a37402be19 nusb/audio: fix %.*s format usage 2019-02-25 03:41:10 +01:00
cinap_lenrek 1b619dea42 nusb/disk: revert previous attempts and just not issue capacity command when theres no media present 2018-12-24 19:06:01 +01:00
Ori Bernstein ee9b29550f Make the check work.
Embarrassing.
2018-12-23 23:10:42 -08:00
cinap_lenrek c80f22f74a nusb/disk: implement 64 bit lba read/write commands (16 byte commands)
untested.
2018-12-24 05:10:43 +01:00
cinap_lenrek 2aec1f8a09 nusb/disk: fix typo "(" 2018-12-24 05:05:41 +01:00
Ori Bernstein bb151fa789 Don't unnecessarily unstall devices.
Some SD card readers are slow to unstall. We try to unstall them
in a loop if there's no SD card in there, but they're not stalled.
They're happily reporting that there's no SD card in them by giving
back the appropriate error code.

Skipping the unstall speeds up the retry loop, cutting the time spent
attaching the USB device at boot from multiple minutes to nearly instant.
2018-12-23 19:44:58 -08:00
cinap_lenrek 06783edd7a nusb/kb: multitouch support (touchscreens, stylus)
touchscreens signal multiple contact points (X/Y) in
the hid descriptor separated by being nested in separate
collections. the contact point is identified by a
optional contact id. if omited, we use the collection
index and report id.

so we collect all the items (X/Y, buttons, wheel) from
separate collections in Hidslot structures and in the
end combine all the slots together.

buttons are or'ed together while absolute X/Y is applied
when it changed. relative X/Y deltas get added together.

thanks to kivik and Glats for testing.
2018-11-14 09:12:34 +01:00
cinap_lenrek 8a7f897b30 nusb/kb: revert multitouch, breaks some mice... 2018-11-13 03:34:19 +01:00
cinap_lenrek 9de1403358 nusb/kb: lilu dallas multitouch 2018-11-12 08:52:01 +01:00
aiju 17f0b2ce38 nusb/serial: fix wrong guard statement (thanks deuteron) 2018-11-06 12:05:15 +00:00
cinap_lenrek 8dfff00e50 nusb/serial: add support for CH340 serial converter 2018-10-21 17:24:33 +02:00
cinap_lenrek 5bb7240ee9 nusb/kb: work arround broken split transaction on raspi's dwc otg usb controller 2018-10-20 19:57:37 +02:00
cinap_lenrek 86a9f92f47 nusb/ether: add support for lan78xx (raspi3) (thanks richard miller) 2018-10-20 19:30:16 +02:00
cinap_lenrek 29865005f9 nusb/ether: tune buffer size parameters for SMSC ethernet (raspi) (thanks richard miller) 2018-10-20 19:29:18 +02:00
mischief 2d221e61e3 nusb/disk: also drive usb attached scsi devices 2018-10-15 04:14:59 -07:00
aiju 22fc5467a4 nusb/joy: update misleading comment (thanks Tobias Heinecke) 2018-10-15 10:10:34 +01:00
mischief 7af5442d3b nusb/joy: send magic packet to enable playstation controller events 2018-10-10 13:56:28 -07:00
cinap_lenrek 45ce4de650 nusb/ether: fix ethertype filtering 2018-08-07 23:46:58 +02:00
aiju 0e5888a0cf add usb tablet support 2018-05-08 08:28:48 +00:00