Commit graph

183 commits

Author SHA1 Message Date
cinap_lenrek dc8432d459 nusb/usbd: increase buffer size to capture port information
due to the addition of uframes property, the buffer got truncated
resulting in usbd not recognizing the number of roothub ports.
2018-04-08 20:51:48 +02:00
mischief c3c7429dc2 nusb/ptp: set storage name to their human readable description string 2018-03-17 15:06:13 -07:00
aiju 657f0ed99a nusb/cam: ctl message fixes 2018-03-07 20:44:55 +00:00
aiju 2da5e135dc add nusb/cam 2018-03-07 10:06:18 +00:00
aiju a2d8dcfd82 usb lib: add maxpkt and ntds to Altc struct 2018-03-07 10:04:27 +00:00
cinap_lenrek 986278e04d nusb/ether: mux bridges, bring in line with devether 2018-02-18 19:56:58 +01:00
cinap_lenrek a2e8246ffc nusb: add missing header dependencies to mkfiles 2018-02-18 02:06:55 +01:00
cinap_lenrek 3e22f7ef1d nusb/ether: dont forward loopback packets on bridges, remove read nonblocking hack 2017-12-18 20:50:25 +01:00
cinap_lenrek 9fd8894fec ether: allow spoofing of source mac address for bridges; used by vmx
to implement layer 2 bridges in userspace, we disable to auto filling
of the source mac address when bridge mode is enabled on the
connection.
2017-12-15 22:22:29 +01:00
cinap_lenrek 153793714e nusb/disk: add a 100ms sleep after ums reset, remove unused note handler, cleanup
my pretec usb stick sometimes hangs on the first inquiry request,
waiting for the inquiry response forever. adding a 100ms delay after
the reset command seems to fix it.

getting rid of unused "ding()" note handler and simplify umsrequest()
incomplete read handling.
2017-08-11 01:00:09 +02:00
cinap_lenrek 56ac6ea29e nusb/*: cleanup 2017-07-31 15:29:08 +02:00
cinap_lenrek b1d4e86064 nusb/usbd: support for usb3 hubs 2017-07-31 14:38:39 +02:00
cinap_lenrek 215b67ff3d nusb/usbd: create endpoint files for conf #1, usb3 preparation 2017-07-31 03:19:24 +02:00
cinap_lenrek a397bfd48c usb: fix wrong pollival calculation in setmaxpkt() 2017-07-24 23:47:55 +02:00
mischief 5ef9330b6f nusb/ptp: treat any assocation as a directory
previously nusb/ptp showed only 'generic folder' association type as directories, but all associations work as directories. tested with LG G5/android 7.0
2017-04-21 15:09:50 -07:00
cinap_lenrek e0087b2a78 nusb/lib: make usbcmd() return value symmetic; returning size of data phase (if any) (thanks aiju)
usbcmd() with Rh2d used to return the command size (8+ndata) wile returning
only ndata for Rd2h. this changes it to always return ndata for Rh2d. it
mostly doesnt matter as Rh2d callers only check r < 0 for error, but this
makes the interface symmetic.
2017-04-01 22:19:58 +02:00
aiju 9cb67a523f nusb/serial: pl2303: better error handling 2017-03-31 20:20:25 +00:00
cinap_lenrek fdc8187038 nusb/ether: support for "bridge" ctl message 2016-11-12 23:11:03 +01:00
cinap_lenrek 062a46607e nusb/kb: set usage to 0 (undefined) for items exceeding usage list 2016-09-28 19:25:23 +02:00
cinap_lenrek 9cb3e5900e nusb/lib: fix wrong endpoint id when openep() finds already existing endpoint file 2016-09-28 19:15:10 +02:00
cinap_lenrek cb9a5a19b0 nusb/ether: promisc and multicast support for admtek pegasus (aue) 2016-09-17 14:18:40 +02:00
cinap_lenrek 382abccf27 nusb/ether: multicast and promisc support for rtl8150 (url) 2016-09-17 14:06:03 +02:00
cinap_lenrek c937aac59b nusb/ether: experimental pomisc mode and multicast support for smsc and asix 2016-09-16 23:21:54 +02:00
cinap_lenrek 772afbe98c format pointer subtraction results with %zd instead of %ld (for long -> intptr on amd64) 2016-01-07 04:44:13 +01:00
cinap_lenrek 7e3b2cdb55 usbd: intoruce /env/usbbusy
to solve the usb device enumeration race on boot, usbd creates /env/usbbusy
on startup and once all devices have been enumerated and readers have consumed
all the events, we remove the file so nusbrc/bootrc can continue. this makes
sure all the usb devices that where plugged in on boot are made available.
2015-11-22 03:17:15 +01:00
cinap_lenrek 562f1b51ee nusb/audio: dont sysfatal on bad endpoint (no altc) 2015-06-29 22:28:23 +02:00
cinap_lenrek 5adf0606f1 nusb/serial: remove unused channel 2015-06-15 00:30:19 +02:00
cinap_lenrek 3ceedfd1e1 nusb/disk: adding identical partition is a no-op 2015-05-30 22:24:55 +02:00
cinap_lenrek 76ee4c3988 usbd: set device info for control file (see usb(3), thanks qeed) 2015-05-18 01:26:29 +02:00
cinap_lenrek 4bfd4122d9 nusb/serial: recognize aijuboard jtag interface 2015-05-11 02:34:54 +02:00
cinap_lenrek adfb8dff26 nusb/kb: always try to recover on error, fix recover for multi-function devices
when we get an i/o error, always call hdrecover() which
will reset the port and reinitialize the interface of
the calling processes endpoint.

handle the case when we have multi-function device with
multiple reader procs in hdrecover(). the sequence is
as follows:

1) any of the reader procs encounters i/o error and calls hdrecover(),
acquires qlock and initiates port reset.
2) any other readerprocs will now encounter i/o error (due to reset) and also call
hdrecover() but will be waiting on the qlock for reset to complete.
3) first process completes reset and reinitializes its interface with setproto()
and then releases the qlock for the other readers todo the same.
2015-04-08 18:07:16 +02:00
cinap_lenrek eec5799f4c nusb/usbd: fix typo in debug prints, dont use %U format as its not installed 2015-02-17 22:17:30 +01:00
ftrvxmtrx c5da8810ee nusb/kb: fix alt/altgr being swapped for some reason 2015-01-01 22:53:17 +01:00
cinap_lenrek d1799f65ca nusb/serial: fix nusb/serial hang with ftdi
have to create process, not a thread in ftdi code so main
process can exit after posting fs service.
2014-12-24 11:04:18 +01:00
cinap_lenrek bb33ba6b9a nusb/kb: dont set boot protocol on HidCSP interface when we failed to read report descriptor (thanks aap_)
this fixes wireless keyboard/mouse on raspi.
2014-10-31 20:40:13 +01:00
cinap_lenrek a5bce84600 nusb/kb: delete code for keyboard boot protocol handling, just use hid parser
unify the keyboard and mouse readers into one using the hid
report parser for both. remove the keyboard protocol handling,
as it is now handled by hid parser and all we get is a sequence
of keycodes in Hiddev.k[] which we diff for up/down and translate
to pc scancodes.
2014-08-16 23:34:28 +02:00
cinap_lenrek d8d26c7001 nusb/ptp: do maxpkt reads to avoid babble error with usb 2.0 devices (thanks mischief!)
mischief got babble error with his mobile phone as we used to
read at max 64 bytes for the data response phase. his device
has 512 byte packet size.

thans to mischief for the patience.
2014-08-13 01:10:59 +02:00
cinap_lenrek 8677db333a nusb/serial: implement flushes
handle reads and writes with 9pqueue(2) so they can
be flushed and wont hang the filesystem. this also
lets us get rid of the timeouts.

ftdi is still full of braindamage that should be
rewritten, but i dont have a device to test.
2014-07-05 08:17:37 +02:00
cinap_lenrek 502247bf92 nusb/serial: more cleanup 2014-07-05 06:01:03 +02:00
cinap_lenrek 336e605a11 support for huawei e220 g3 modem, cleanup nusb/serial 2014-07-05 23:19:13 +02:00
cinap_lenrek 4ad63a4c56 nusb: fix spelling, sorry 2014-06-28 19:55:14 +02:00
cinap_lenrek 4275c49e72 nusb: implement aijus stable uniqueue device names
instead of naming devices by ther dynamically assigned device address,
we hash device uniqueue fields from the device descriptor and produce
a 5 digit hex string that will identify the device across machines.

when there is a collision (less than 1% chance with 100 devices),
usbd will append the device address to the name to make it uniqueue
for this machine.

the hname is passed to drivers in the devid argument, which now has
the form addr:hname, where the colon and hname can be omited (for backwards
compatibility).

when the new behaviour isnt desired, nousbhname= environment variable
can be defined giving the old behaviour.
2014-06-28 18:09:43 +02:00
cinap_lenrek ec572a53a9 ptp: fix alignment assumptions for amd64 2014-06-28 01:36:37 +02:00
cinap_lenrek 93d0474f77 nusb/usbd: cleanup 2014-06-03 21:40:30 +02:00
cinap_lenrek 5ab9f9c621 nusb/usbd: serialize /dev/usbevent processing
when there are multiple readers of /dev/usbevent, we have to
serialize the processing to make sure that only one driver
is opening the devices control endpoint at a time.

to do this, we assume the device is busy after reading the
event file until the next read or clunk on the same fid.

to mark a device busy, we set the dev->aux pointer to the
fid processing a event. And the Event structure takes a
reference to the device producing the event.

the problem arised from cdc ethernet and nusb/serial sharing
the same device class, and we need to run the particular driver
to figure out if the device can be used. doing this concurrently
fails because devusb allows only one open per endpoint.
2014-06-03 07:21:48 +02:00
ftrvxmtrx d2c3185bfa fix threadsetname usage in few places 2014-05-03 13:07:52 +02:00
cinap_lenrek 0753d7852d revert previous change, i was confused. 2014-04-24 22:02:47 +02:00
cinap_lenrek 634b40fe27 nusb: use ep->addr instead of ep->id in unstall() library function
this is not a bug, but using ep->addr makes the intend more clear.
2014-04-24 22:00:31 +02:00
ftrvxmtrx 70d7f4c32a nusb/rndis: avoid allocation on each transmission
The slack space for outgoing packets set to 44+16 bytes.
2014-04-23 21:20:11 +02:00
cinap_lenrek 41908149de nusb: resolve endpoint id conflict with different input and output types
ftrvxmtrx repots devices that use the endpoint number for
input and output of different types like:

 nusb/ether:             parsedesc endpoint 5[7]  07 05 81 03 08 00 09	# ep1 in intr
 nusb/ether:             parsedesc endpoint 5[7]  07 05 82 02 00 02 00
 nusb/ether:             parsedesc endpoint 5[7]  07 05 01 02 00 02 00	# ep1 out bulk

the previous change tried to work arround this but had the
concequence that only the lastly defined endpoint was
usable.

this change addresses the issue by allowing up to 32 endpoints
per device (16 output + 16 input endpoints) in devusb. the
hci driver will ignore the 4th bit and will only use the
lower 4 bits as endpoint address when talking to the usb
device.

when we encounter a conflict, we map the input endpoint
to the upper id range 16..31 and the output endpoint
to id 0..15 so two distinct endpoints are created.
2014-04-23 20:03:01 +02:00
ftrvxmtrx 2ef8c9ed41 nusb: workaround for endpoints with same index but different types
nusb code assumes endpoint numbers are unique.  It's true in general
case, but it becomes false once the direction bit is ignored.  The
commit adds a check so that two endpoints of different types are not
merged into one with Eboth direction.  It does overwrite endpoint
though, so it shouldn't be considered as a full fix.
2014-04-23 23:45:00 +02:00
ftrvxmtrx 99c0abc76d nusb/ether: add RNDIS support (tested on Nexus 5) 2014-04-22 23:34:52 +02:00
cinap_lenrek b94c766fef nusb: dont include <bio.h>, we'r not using it (thanks erik) 2014-04-19 16:18:39 +02:00
ftrvxmtrx 9204ed8910 nusb/kb: fix trackpoint on thinkpad usb keyboard
The trackpoint has no subclass, but it's still a pointer device.
Also close the device while we are here.
2014-04-18 16:43:43 +02:00
aiju 26a8accad2 nusb: added joy 2014-03-09 18:03:07 +01:00
cinap_lenrek f88d0c372d nusb: fix loaddevstr() (thanks erik quanstro and richard miller)
loaddevstr() should request 256 bytes, as per standard and
respect the length embedded in the string.
2014-03-06 22:53:20 +01:00
cinap_lenrek fc78640118 nusb/ether: fix pointer truncation 2014-02-14 14:18:09 +01:00
cinap_lenrek 4a9f900726 mkfiles: do not rely on path containing the . element
when executing generated binaries and helper scripts,
always execute them as ./name instead of relying that
path contsins the dot.
2013-10-26 20:22:01 +02:00
cinap_lenrek 8ceb100fa4 nusb/ether: new driver interface with kernel inspired Block buffers
introduce kernel inspured Block structure with
read/write pointers to pass packets arround.

the intend is to avoid copying when adding/removing
frame headers and simplifying the drivers.

the driver now calls etheriq() directly allowing it to
queue multiple packets in one pass without having
to keep state.

transmit gets a buffer passed that has room for
frame headers and trailers so no copying is needed.

blocks are refcounted avoiding another copy when
passed to only one receive queue (common case).

receive queues are now limited to 100KB avoiding
buffer bloat.

Dq* a memory leak in destroyfid has been fixed.

lots of minor cleanups.
2013-10-18 18:41:27 +02:00
cinap_lenrek 52fc6d50d4 nusb/ether: fix wrong size check causing odd sized packets to be discarded (thanks mischief!)
ethernet packets with sizes that where not multiples of 4 where
discarded because the check uses the smsc frame size instead of
the payload size. when a usb read returns just one packet, theres
no next frame header and the calculated frame size is bigger than
the usb read which caused the whole packet to be discarded as invalid.

thanks to mischief for testing and debugging!
2013-10-16 16:42:40 +02:00
cinap_lenrek 965bb2d248 nusb/disk: handle blocking usb access with srv released
usb is bound after /dev, so a hanging usb device will hang
access to /dev. we avoid this by releasing the srv, which
allows the fs to still handle reads and walks of the
directories.

ios are serialized by a qlock in the Umsc structure.
2013-10-16 12:26:56 +02:00
ppatience0 225cc4af5c nusb/ether: add rtl8150 driver, remove unused includes 2013-10-02 02:25:43 -04:00
cinap_lenrek f8cbd5d12f nusb/serial: set exit status 2013-09-15 16:21:43 +02:00
ppatience0 334054e0e7 nusb/ether: add aue driver for admtek pegasus usb ethernet adapter 2013-08-24 19:18:15 -04:00
cinap_lenrek bfe852b3a2 nusb/kb: *really* only send to mousein when mouse state actually changes (zero detlas, same buttons) 2013-08-10 08:47:43 +02:00
cinap_lenrek 2012ba4d03 revert previous commit... stupid idea 2013-08-10 08:37:13 +02:00
cinap_lenrek f887f71320 nusb/kb: only send to mousein when mouse state actually changes 2013-08-10 07:59:54 +02:00
ppatience0 473d12c94f nusb: only read 18 bytes for device descriptor 2013-07-05 18:42:15 -04:00
ppatience0 d1b6c02ac9 nusb/ether: fix asixread() invert/shift in wrong order 2013-06-19 21:25:08 -04:00
cinap_lenrek 1a6d523d26 nusb/ether: fix asixwrite()
invert/shift in wrong order causing low 16 bits to be all ffff...
2013-06-18 02:00:05 +02:00
ppatience0 89ed97aaa2 nusb/ether: call sysfatal if dev is nil 2013-06-16 20:37:51 -04:00
cinap_lenrek 97c4381dc4 nusb/kb: map button 4 to middle button 2 (for logitech 5 button mouse) 2013-06-02 23:45:38 +02:00
cinap_lenrek 4c6c7be688 nusb/kb: simplify repeat logic as scancode now contains the info about esc1 extension 2013-05-18 01:46:25 +02:00
ftrvxmtrx 506cae05df nusb/kb: oops, fixup 2013-05-18 01:03:13 +02:00
ftrvxmtrx 811c3e8d78 nusb/kb: use a flag to indicate extended code; fix the most unix-friendly key on se/fi kbd layout 2013-05-18 01:01:34 +02:00
cinap_lenrek e83d5a84f2 nusb/serial: Add support for Amontec JTAGkey devices (from sources) 2013-04-26 15:25:25 +02:00
cinap_lenrek 9f25f9504a nusb/disk: add small delay after unit start command (for thinkpad sdcard reader)
diskparts fails on thinkpad x200 sdcard reader if we dont
give the unit some time to startup. the device took about
100ms to become ready so status poll loop with a long
timeout would be overkill.
2013-03-10 04:06:42 +01:00
cinap_lenrek 6bd2c26a85 nusb/kb: fix "Home" key producing "7" with some usb keyboards (import from sources patch/usb-khome)
Fixes the problem with certain keyboards generating "7" on "Home" key press.

http://9fans.net/archive/2013/03/8
http://9fans.net/archive/2013/03/10
2013-03-01 19:53:11 +01:00
cinap_lenrek af3dad5490 nusb/disk: allow 12 and 16 byte raw scsi commands (from erik quanstro) 2013-02-13 10:03:53 +01:00
cinap_lenrek d41f67c2b9 audio: fix delay control, increase default buffer delay to 40ms
just doing a single sleep isnt enougth, as we get woken
up for every block!
2013-02-01 15:23:38 +01:00
cinap_lenrek a2b83a5aea nusb/kb: increase maximum report descriptor size, non-continuous endpoints (from richard millars usbmouse-endpoint patch)
Another band-aid fix to the usb mouse driver, to cope with a mouse which has
an interrupt endpoint number 3 but no number 1 or 2, and a report descriptor
more than 128 bytes long.
2013-01-30 20:33:28 +01:00
cinap_lenrek 68c5dc8014 nusb/serial: add silabs driver (from sources) 2013-01-25 17:12:15 +01:00
cinap_lenrek 8c81499659 scsi: do only 36 byte inquiry
some devices freeze up with inqiry allocation length
other than 36 bytes. as we do not really care about
the vendor specific part of the inquiry, lets only do
36 byte inquiry for now.
2013-01-03 20:46:25 +01:00
cinap_lenrek 8f3595e058 nusb/kb: remove mouse acceleration -a flag
mouse acceleration can be done by software in the kernels
devmouse device like:

echo hwaccel off >/dev/mousectl
echo accelerated 5 >/dev/mousectl

it is hard to pass nusb/kb parameters anyway as it is started
from nusbrc in bootfs.paq, so i remove the option.
2012-12-26 22:48:12 +01:00
cinap_lenrek 7b34e8e759 nusb/kb: use report protocol for mouse
instead of forcing mouse to boot protocol, which often
doesnt work, we set it to report protocol and parse
the hid report descriptor. if thers no such descriptor
we revert to boot protocol.

all mouse packet parsing is done by report parser,
even for boot protocol. also all the work arrounds
for the leadbyte hack (report id?) are removed.

keyboards should not be affected by this change.
2012-12-19 12:09:35 +01:00
cinap_lenrek 3971337d13 nusb: provide language id when reading string descriptors (thanks ftrvxmtrx)
there are devices which do not return a string if used
with invalid language id, so at least try to use the first
one and choose english if failed.

this fixes CDC ethernet for N900
2012-12-10 10:36:53 +01:00
cinap_lenrek 6e630a2d1f nusb/ether: remove debug prints, cleanup 2012-12-06 00:31:25 +01:00
cinap_lenrek 29ca49ca38 nusb/ether: remove vid check in smsc driver, cleanup cdc driver 2012-12-06 23:24:42 +01:00
cinap_lenrek 23239adf54 nusb/ether: port drivers for asix and smsc ethernet 2012-12-06 23:05:24 +01:00
cinap_lenrek 86eaffdcaa nusb/kb: fix 5ms sleep polling in repeatproc, notegroup, cleanup
fix repeatproc timeout handling, add constants for Kbdelay
and Kbrepeat.

set procname so one knows which is keyboard and which is mouse
and on what endpoints they work.

9front's /dev/mousein and /dev/kbdin allow multiple opens,
so theres no need for the refcounted Kin structures.

spawn the worker procs in ther own note group, so they wont
get killed on interrupt in the original notegroup.
2012-11-30 19:01:59 +01:00
cinap_lenrek 3f25f69718 nusb/kb: add support for evoluent vertical mouse 2012-11-30 04:02:03 +01:00
cinap_lenrek 4260392749 nusb/kb: skip 0x01 lead byte hack, you dont wanna know
apparently, some mouse send constant 0x01 byte
before normal 4 byte mouse packet. this is known in
openbsd/freebsd as UQ_MS_LEADING_BYTE quirk.
2012-11-25 22:37:53 +01:00
cinap_lenrek aadc581040 nusb/kb: zero reads, error handling, priority, cleanup
handle short reads as errors and retry. this can happen
on ohci and some ps2 to usb converter. it might'v deen caused
by a recent change on sources handling td overrun differently.

fix error handling. have to check f->ep == nil after recovery
and check packet size. also, use f->ep->dfd instead of ptrfd
and kbdfd as it might be different after recovery. make a
setleds() error non fatal.

boost process priority for keyboard and mouse worker processes.

cleanup: use single write() in putmod(), improve error reporting.
2012-11-24 16:37:39 +01:00
cinap_lenrek a064a48e6d nusb: handle 0 csp value on iface, remove unneeded configdev() calls after getdev() 2012-09-06 05:25:23 +02:00
cinap_lenrek 3cdaf6ea5f usbd: add missing quotefmtinstall 2012-09-06 04:07:51 +02:00
cinap_lenrek 93063b3db0 nusbd: properly handle port detach on hub disconnect 2012-09-05 00:06:20 +02:00
cinap_lenrek 142a77c9dc nusb/kb: increase mouse packet buffer from 32 to 64 bytes for Microsoft Sidewinder X5 Mouse (thanks Rexford Gibbs for reporting and testing) 2012-08-13 10:41:02 +02:00
cinap_lenrek 5377a19447 nusb/audio: setup audioin 2012-05-03 22:30:32 +02:00
cinap_lenrek 9b0fc40aee nusbd: properly terminate worker proc if no hubs can be found 2012-03-09 07:55:01 +01:00
cinap_lenrek 424f8a9520 nusb: debug flags 2012-03-01 18:56:54 +01:00