summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/uhidev.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Back-out USB data toggle fix for HID devices, since we received multiplemglocker2021-02-151-43/+1
| | | | | | reports about broken devices, e.g. for ukbd(4) and fido(4). ok mpi@
* Add uhidev_unset_report_dev(), doing the opposite ofanton2021-02-111-1/+11
| | | | | | uhidev_set_report_dev(). Needed by some upcoming changes to uhidpp. ok mglocker@
* If uhidev_set_report_dev() already have been invoked for the givenanton2021-02-111-4/+6
| | | | | | report id, there's no point in trying to find a matching sub device. ok mglocker@
* Add uhidev_set_report_dev() allowing usb drivers to early on install aanton2021-02-041-4/+23
| | | | | | | handler for a specific report id. Needed by an upcoming driver in order to communicate with the device already in the attach routine. ok mglocker@ as part of a larger diff
* update some usb.org URLs following reorganisation, add a new one for updsthen2021-01-291-2/+2
| | | | partly from Alessandro Ricci
* Resolve data toggle out of sync problem for ugen(4) and uhidev(4) devicesmglocker2021-01-251-1/+43
| | | | | | | | | | on xhci(4) controllers by clearing the interface endpoints before opening the pipes. Tested by Mikolaj Kucharski for ugen(4) and gnezdo@ for uhidev(4), plus myself for both. ok mpi@
* Backout clear endpoint stall on open(2). It seems to break an illuminatedpatrick2020-08-311-3/+1
| | | | | | | Logitech keyboard for unknown reasons. Reported by denis@ ok djm@
* Clear endpoint stall on open(2) of /dev/uhidX to synchronize toggle bitpatrick2020-08-271-2/+4
| | | | | | | | | | | | | as needed on xhci(4) machines. On non-xhci(4) we save and restore the toggle bit on close/open of a pipe. With xhci(4) this does not seem to be possible, at least I haven't yet found it. This means that on those machines with xhci(4), after a pipe close/open, the device will use the previous state, while xhci(4)'s state is reset to default. By issuing a clear endpoint stall we reset the device's toggle bit. Now every time a /dev/uhid is (re-)opened the state should be synchronized. Discussed with damien@, mpi@ and Pedro Marteletto ok markus@
* uhidev(4) does apply the SET_IDLE request to all its child driversmglocker2020-08-231-3/+1
| | | | | | | | | | | | | | today. This doesn't seem to be right, since SET_IDLE limits the reporting frequency for interrupt IN endpoints, normally only required on keyboard and mouse-like input devices. We noticed recently that other device types, like e.g. the Cyrus soundKey uaudio(4), will stall after the SET_IDLE request has been issued. Therefore we move the SET_IDLE request only to the uhidev(4) child drivers which seem to require this request. Those we have identified to be; ukbd(4), ums(4), umstc(4), umt(4), utpms(4), and uwacom(4). Suggested and ok mpi@
* Nuke all occurrences of usbd_abort_pipe() if it gets called rightmglocker2020-07-311-5/+1
| | | | | | | | | | before usbd_close_pipe(), since usbd_close_pipe() already takes care about aborting non-empty pipes. As investigated by gerhard@ usbdi.c rev. 1.57 did add usbd_abort_pipe() to usbd_close_pipe(), but the drivers didn't get cleaned up afterwards. ok gerhard@
* use the UE_GET_XFERTYPE macro where applicablejasper2020-02-221-4/+4
| | | | ok mpi@
* Prevent use-after-free in uhidev_close().mpi2020-01-041-14/+14
| | | | | | | Close pipes before freeing transfers, otherwise accessing elements in pipe->queue, like in usbd_abort_pipe(), will result in a crash. Problem reported by reyk@, ok visa@
* Send uhid(4) reports via the optional interrupt out pipe. Somepatrick2019-11-131-16/+45
| | | | | | | | tiny devices don't accept reports using control transfers since they think that offering the interrupt pipe is enough. Discussed with djm@ ok mpi@
* Move HID->bus constant conversion for HID report types out of ihidevjcs2018-08-251-1/+16
| | | | | | | | | | | | | | | | | | | | | into hidmt. The HID code uses hid_feature, hid_input, and hid_output constants to refer to report types internally that then need to be converted to their bus-level counterparts before actually getting sent out (so hid_feature becomes UHID_FEATURE_REPORT for USB, I2C_HID_REPORT_TYPE_FEATURE for i2c). This conversion was hard-coded in ihidev but ihidev_[gs]et_report should assume the type passed is already an i2c-level define, not a hid one. This is how uhidev does it. Add a conversion routine callback that any hidmt callers need to set so that hidmt can convert hid constants to the bus-level versions. Also add a similar conversion function to uhidev. ok deraadt
* A pile of sizes to free(9). In test for a few days in snapshots.deraadt2017-04-081-5/+5
| | | | | Errors will result in nice clean panic messages so we know what's wrong. Reviewed by dhill visa natano jsg.
* Do not execute the callback if the device is beeing detached.mpi2016-06-131-12/+13
| | | | | Should prevent a race triggering a use-after-free reported by martijn@ on bugs@
* revert manual additions of hid.h now that usbhid.h brings it injcs2016-01-091-3/+1
|
* Move HID support files out of dev/usb into new dev/hid directoryjcs2016-01-081-2/+3
| | | | | | | | | These files aren't USB-specific and were used by the previous Bluetooth implementation, and will be used by the upcoming HID-over-i2C implementation ok deraadt previous version ok kettenis and mpi
* Match 3rd party Xbox 360 controllers, from Christian Heckendorf.mpi2015-12-081-11/+15
| | | | Tested by jeremy@
* Fix uhidev_get_report_async() from David Higgs.mpi2015-02-281-4/+7
|
* Reduce the number of intermediate buffers by pre-allocating DMA buffersmpi2015-01-221-32/+41
| | | | | | | in the report functions instead of letting the stack do it magically for us. Reviewed and tested by David Higgs, thanks!
* Correctly report memory allocation failure in uhidev_set_report_async().mpi2015-01-091-2/+2
|
* Add an asynchronous version of uhidev_get_report(), from David Higgsmpi2015-01-091-2/+78
| | | | | | | with some tweaks. Nothing use it for the moment, but upcoming upd(4) improvements need it.
* yet more mallocarray() changes.doug2014-12-131-2/+2
| | | | ok tedu@ deraadt@
* Change uhidev(4) set/get report functions in various way.mpi2014-12-111-34/+43
| | | | | | | | | | | | | | Always pass the parent uhidev(4) descriptor corresponding to the single USB device with multiple reportIDs instead of a child. Make uhidev_get_report() aware of non NUL reportID by prepending a byte to the given buffer, just like uhidev_set_report{,async}() already do. Return the number of bytes written or read upon success and -1 otherwise. This allow callers to deal with short reads without having do mess with xfer error codes madness. Reviewed and tested by David Higgs.
* Deprecate usb_*_report(). USB HID devices are always attached belowmpi2014-12-081-35/+58
| | | | | | | | | | an uhidev(4) on OpenBSD and there is not point in rerolling your own reportID handling. Simply use uhidev_*_report(). This is a first step towards better error handling required to deal with broken upd(4) firmwares. Tested by David Higgs.
* sizeof() a pointer of the right struct to appease clang.mpi2014-08-101-2/+2
|
* add a size argument to free. will be used soon, but for now default to 0.tedu2014-07-121-7/+7
| | | | after discussions with beck deraadt kettenis.
* Print an understandable error message when we fail to read the reportmpi2014-07-101-3/+3
| | | | | | descriptor. Pointed out by benno@
* Plug an xfer leak.mpi2014-04-291-3/+16
|
* Change the usbd_*_report() family of functions to take a usbd_devicempi2014-04-241-16/+32
| | | | | | | | | | | and a infaceno argument instead of an iface pointer. While here, remove some unused functions and inlined usbd_read_report_desc since it is used only once. This is part of plumbing required to convert the various USB HID devices to handle multiples report IDs. ok andre@
* Modify the uhidev_*_report() methods to always take a report ID argumentmpi2014-04-151-17/+18
| | | | | | | | instead of using the default, per-driver, one. This is a step to move away from the 1 report ID <-> 1 driver design which is no longer true since the addition of upd(4). ok andre@
* Fix uhidev_detach() when detaching a device which did not claimed for allandre2014-03-231-2/+3
| | | | | | | report IDs, on those cases some positions on sc_subdevs[] can be null. Initial analysis by guenther@. ok mpi@
* Add a temporary hack to let a subdriver claim all the reportIDs ofmpi2014-03-191-11/+25
| | | | | | | a device. This should be removed once all the drivers attaching to uhidev(4) are converted. ok andre@, sthen@
* Move the logic to deal with devices with broken descriptors into itsmpi2014-03-161-69/+69
| | | | | | | own function and don't leave the driver half-configured if a children doesn't set the interrupt function. tested by jeremy@, ok andre@
* Starting the spring cleanup.mpi2014-03-151-25/+23
|
* Remove debug leftover.mpi2014-03-151-7/+2
|
* Abort and close all the interrupt pipes when detaching HID devices sincempi2014-02-251-2/+11
| | | | | | | | drivers attaching to uhidev(4) do not always do it. Seems to fix one of the transfer aborting races triggering a lot of "ehci_idone: ..." vomit upon resume. Reported by and fix tested by Ville Valkonen, ok deraadt@
* Kill matchlvl usage throughout the usb stack.pirofti2013-11-191-7/+1
| | | | | | Allows us to move forward on cleaning. Okay mpi@
* Clean-up the activate routines from the uoak*(4) drivers.pirofti2013-11-111-1/+5
| | | | | | | | Leave the deactivate bits to the parent. Simplify by making a single dying check in uhidev(4) interrupt routine instead of having each child doing it. Okay mpi@
* Spacing.mpi2013-11-011-20/+17
|
* Do not abuse the stack of the current process to prepend a report IDmpi2013-11-011-19/+25
| | | | | | | to the report request, use malloc(9) with the appropriate size like it is done in the synchronous version. ok miod@
* Add support for Microsoft XBox 360 controller as a uhid. It doesn't usejeremy2013-10-251-4/+21
| | | | | | | | | | | | | | | | | | | | | the standard interface class and doesn't have a report descriptor, so use a manually created one. The controller shows up as multiple devices with different interface numbers, so only match the first one as a uhid. The controller shows up as both a uhid and a ugen. Rename ugraphire_rdesc.h to uhid_rdesc.h and add the manually created Xbox 360 report descriptor to the file. Add ifndef SMALL_KERNEL around the related blocks for the XBox 360 controller and Wacom Graphire, so this should actually shrink the ramdisks. Manual report descriptor taken from a 2005 FreeBSD commit. Much help from mpi@ for getting this suitable for commit to OpenBSD. OK mpi@
* Unify and document usbd_transfer(9).mpi2013-09-201-3/+9
| | | | | | | | | | | Get rid of the badly named usbd_bulk_transfer() and usbd_intr_transfer() they were two identical wrappers to submit a synchronous transfer. Now all synchronous transfers are submited using usbd_setup_xfer(9) and usbd_transfer(9) explicitly using the USBD_CATCH flag when signals must be checked. Previous version ok'd by mglocker@, with subtle inputs from miod@
* Do no try to clear the endpoint, as it if has stalled, if thempi2013-09-191-2/+2
| | | | | | | | | | | | | | USB transfer reported an I/O error. This is more likely to have no effect apart generating more errors because when this happens, the device is generally already physically detached but the *detach() task has not run yet. So simply return and wait for the device to be removed like ucom(4) does. Partially fix an issue reported by RD Thrush rt at thrush.com. ok miod@
* When deactivating child devices do not panic if their driver doesmpi2013-05-071-7/+2
| | | | | | | | | | not implement an *activate() function. This could receive more love but is good enough for the moment to start cleaning useless *activate() functions. While here remove unused sc_dying argument. Tested by and ok mglocker@
* Get rid of various 'typedef struct' definitions and use plain structuremglocker2013-04-151-4/+4
| | | | | | | | | definitions instead. We don't change usb.h for now to stay compatible with userland. Tested by mpi@ on macppc and myself on i386. ok mpi@
* Remove config_activate() and DVACT_ACTIVATE. PCMCIA's the only thingmatthew2011-07-031-3/+1
| | | | | | | | that's ever used it, and it's long since been changed to use DVACT_{QUIESCE,SUSPEND,RESUME} instead. ok deraadt@, dlg@; miod@ also agreed with this idea when I brought it up a few weeks ago
* garbage collect "usb events". without /dev/usb there is no way to accessjakemsr2011-01-251-7/+1
| | | | | | them from userland, and nothing in the kernel uses them. ok krw@, miod@
* remove dying flag in detach() function.yuo2010-09-241-2/+1
| | | | | | The dying flag will be set in activate()/DEACTIVATE. ok deraadt@