History log of /netbsd-current/sys/dev/usb/ukbd.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.164 02-Sep-2023 riastradh

ukbd(4): Sort includes.

No functional change intended.


# 1.163 02-Sep-2023 riastradh

ukbd(4): Fix ordering in ukbd_cnpollc exit.

This is probably an MP-safety issue waiting to happen, but let's at
least make the wind and unwind sequences mirror images.


# 1.162 10-Jan-2023 mrg

ukbd(4): remember how much of attach worked so detach works.

if ukbd_attach() fails it means it has only really done the pmf
setup, nothing else, so avoid trying to remove callouts, child
devices, or console setup, usb task and uhidev operations.

fixes the crash (but not the underlying ukbd doesn't work issue)
seen in PR#57149.


Revision tags: netbsd-10-base bouyer-sunxi-drm-base
# 1.161 06-Apr-2022 mlelstv

branches: 1.161.4;
remove debug printf


# 1.160 02-Apr-2022 mlelstv

Don't attach Yubikeys as console keyboard.


# 1.159 28-Mar-2022 riastradh

uhidev(9): Make uhidev state opaque.

This makes the API simpler and clearer and gives us more latitude to
fix bugs in the state management without breaking the ABI.

XXX kernel ABI change to signature of uhidev_get_report_desc and
uhidev_open, and to struct uhidev_attach_arg, requires bump for
uhidev driver modules


# 1.158 28-Mar-2022 riastradh

uhidev(9): Get the device and interface through attach args.

This way uhidev drivers don't need access to uhidev_softc itself for
it.


# 1.157 08-Jan-2022 riastradh

ukbd(4): Fix previous change to initial LED flashing.

Without this change the LEDs would get stuck on until the first
keypress. (This also seemed to trigger a crash in heavy load on
bringing aue(4) up and down over and over again while unplugging, but
I'm not sure why and I hope it's not actually related...)


# 1.156 31-Dec-2021 riastradh

ukbd(4): Avoid races in LED setting on attach.

- Don't reuse sc_delay for LED task -- a keyboard interrupt shortly
after attach might reset sc_delay so that the LEDs never get turned
back off.

- Don't turn the LEDs back off after attach if something else has
already changed them by the time the callout fires.

(And make sure to callout_halt before done this time!)


# 1.155 26-Dec-2021 andvar

fix various typos, mainly in comments.


# 1.154 25-Dec-2021 riastradh

ukbd(4): Wait for callouts and blinking to complete in detach.

This detach routine (and whole driver) has got a lotta other
problems, but let's fix 'em one at a time...


# 1.153 11-Oct-2021 jmcneill

ukbd: blink LEDs asynchronously at boot

Instead of holding up boot by 400ms for each attached ukbd to blink the
keyboard LEDs, turn them on and set a callout to turn them off later.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.152 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.151 27-Jun-2021 pgoyette

branches: 1.151.2;
Since there's a bit of code that is conditionally compiled based on
USBVERBOSE, we need to include the opt_usbverbose.h header to get any
possible definition of this macro.

XXX Note that this code will NOT get included in the loadable module
XXX for USBVERBOSE.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.150 24-Apr-2021 thorpej

branches: 1.150.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.149 02-Mar-2021 gdt

branches: 1.149.2;
ukbd: GC some 20 year old code (NFC)

Long ago, code was improved to allow detaching keyboards that were the
console, but the old commen and panic() were #if 0'd instead of
removed.


# 1.148 02-Mar-2021 gdt

ukbd: Condition probe-time verbosity on USBVERBOSE

Previously, this driver switched on more verbose messages based on
DIAGNOSTIC. But, the messages weren't about an impossible-to-reach
condition, just extra keys. Change the condition to USBVERBOSE,
documented as serving this purpose.


# 1.147 12-Sep-2020 macallan

branches: 1.147.2;
send PMF events for keyboard brightness hotkeys on apple laptops


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.146 29-Mar-2020 tih

Summary: Introduce a keyboard event ring buffer for USB console keyboards

For the console keyboard, events must be handled separately from the
interrupt handler, because of the possibility that the user chooses to
drop into DDB by use of the designated key combination. This delayed
handling is tied to the HZ clock through the callout(9) mechanism,
meaning that another keyboard event arriving within 10ms of the
previous one might overwrite its predecessor before it's handled.
This causes dropped events for fast typists - and the situation gets
worse with modern, programmable, keyboards.

This patch introduces a ring buffer in the ukbd_softc data structure,
so that multiple pending events may be safely stored.


# 1.145 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.144 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.143 08-Jan-2020 macallan

send PMF events for volume and brightness control keys on Apple keyboards


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.142 05-May-2019 mrg

branches: 1.142.2; 1.142.4;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.141 09-Jan-2018 christos

branches: 1.141.4;
tidy up debugging (make it compile with the 'ALL' kernel)


# 1.140 18-Dec-2017 jmcneill

ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)


# 1.139 10-Dec-2017 bouyer

Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825
# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

branches: 1.136.6;
don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.162 10-Jan-2023 mrg

ukbd(4): remember how much of attach worked so detach works.

if ukbd_attach() fails it means it has only really done the pmf
setup, nothing else, so avoid trying to remove callouts, child
devices, or console setup, usb task and uhidev operations.

fixes the crash (but not the underlying ukbd doesn't work issue)
seen in PR#57149.


Revision tags: netbsd-10-base bouyer-sunxi-drm-base
# 1.161 06-Apr-2022 mlelstv

remove debug printf


# 1.160 02-Apr-2022 mlelstv

Don't attach Yubikeys as console keyboard.


# 1.159 28-Mar-2022 riastradh

uhidev(9): Make uhidev state opaque.

This makes the API simpler and clearer and gives us more latitude to
fix bugs in the state management without breaking the ABI.

XXX kernel ABI change to signature of uhidev_get_report_desc and
uhidev_open, and to struct uhidev_attach_arg, requires bump for
uhidev driver modules


# 1.158 28-Mar-2022 riastradh

uhidev(9): Get the device and interface through attach args.

This way uhidev drivers don't need access to uhidev_softc itself for
it.


# 1.157 08-Jan-2022 riastradh

ukbd(4): Fix previous change to initial LED flashing.

Without this change the LEDs would get stuck on until the first
keypress. (This also seemed to trigger a crash in heavy load on
bringing aue(4) up and down over and over again while unplugging, but
I'm not sure why and I hope it's not actually related...)


# 1.156 31-Dec-2021 riastradh

ukbd(4): Avoid races in LED setting on attach.

- Don't reuse sc_delay for LED task -- a keyboard interrupt shortly
after attach might reset sc_delay so that the LEDs never get turned
back off.

- Don't turn the LEDs back off after attach if something else has
already changed them by the time the callout fires.

(And make sure to callout_halt before done this time!)


# 1.155 26-Dec-2021 andvar

fix various typos, mainly in comments.


# 1.154 25-Dec-2021 riastradh

ukbd(4): Wait for callouts and blinking to complete in detach.

This detach routine (and whole driver) has got a lotta other
problems, but let's fix 'em one at a time...


# 1.153 11-Oct-2021 jmcneill

ukbd: blink LEDs asynchronously at boot

Instead of holding up boot by 400ms for each attached ukbd to blink the
keyboard LEDs, turn them on and set a callout to turn them off later.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.152 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.151 27-Jun-2021 pgoyette

branches: 1.151.2;
Since there's a bit of code that is conditionally compiled based on
USBVERBOSE, we need to include the opt_usbverbose.h header to get any
possible definition of this macro.

XXX Note that this code will NOT get included in the loadable module
XXX for USBVERBOSE.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.150 24-Apr-2021 thorpej

branches: 1.150.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.149 02-Mar-2021 gdt

branches: 1.149.2;
ukbd: GC some 20 year old code (NFC)

Long ago, code was improved to allow detaching keyboards that were the
console, but the old commen and panic() were #if 0'd instead of
removed.


# 1.148 02-Mar-2021 gdt

ukbd: Condition probe-time verbosity on USBVERBOSE

Previously, this driver switched on more verbose messages based on
DIAGNOSTIC. But, the messages weren't about an impossible-to-reach
condition, just extra keys. Change the condition to USBVERBOSE,
documented as serving this purpose.


# 1.147 12-Sep-2020 macallan

branches: 1.147.2;
send PMF events for keyboard brightness hotkeys on apple laptops


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.146 29-Mar-2020 tih

Summary: Introduce a keyboard event ring buffer for USB console keyboards

For the console keyboard, events must be handled separately from the
interrupt handler, because of the possibility that the user chooses to
drop into DDB by use of the designated key combination. This delayed
handling is tied to the HZ clock through the callout(9) mechanism,
meaning that another keyboard event arriving within 10ms of the
previous one might overwrite its predecessor before it's handled.
This causes dropped events for fast typists - and the situation gets
worse with modern, programmable, keyboards.

This patch introduces a ring buffer in the ukbd_softc data structure,
so that multiple pending events may be safely stored.


# 1.145 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.144 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.143 08-Jan-2020 macallan

send PMF events for volume and brightness control keys on Apple keyboards


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.142 05-May-2019 mrg

branches: 1.142.2; 1.142.4;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.141 09-Jan-2018 christos

branches: 1.141.4;
tidy up debugging (make it compile with the 'ALL' kernel)


# 1.140 18-Dec-2017 jmcneill

ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)


# 1.139 10-Dec-2017 bouyer

Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825
# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

branches: 1.136.6;
don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.161 06-Apr-2022 mlelstv

remove debug printf


# 1.160 02-Apr-2022 mlelstv

Don't attach Yubikeys as console keyboard.


# 1.159 28-Mar-2022 riastradh

uhidev(9): Make uhidev state opaque.

This makes the API simpler and clearer and gives us more latitude to
fix bugs in the state management without breaking the ABI.

XXX kernel ABI change to signature of uhidev_get_report_desc and
uhidev_open, and to struct uhidev_attach_arg, requires bump for
uhidev driver modules


# 1.158 28-Mar-2022 riastradh

uhidev(9): Get the device and interface through attach args.

This way uhidev drivers don't need access to uhidev_softc itself for
it.


# 1.157 08-Jan-2022 riastradh

ukbd(4): Fix previous change to initial LED flashing.

Without this change the LEDs would get stuck on until the first
keypress. (This also seemed to trigger a crash in heavy load on
bringing aue(4) up and down over and over again while unplugging, but
I'm not sure why and I hope it's not actually related...)


# 1.156 31-Dec-2021 riastradh

ukbd(4): Avoid races in LED setting on attach.

- Don't reuse sc_delay for LED task -- a keyboard interrupt shortly
after attach might reset sc_delay so that the LEDs never get turned
back off.

- Don't turn the LEDs back off after attach if something else has
already changed them by the time the callout fires.

(And make sure to callout_halt before done this time!)


# 1.155 26-Dec-2021 andvar

fix various typos, mainly in comments.


# 1.154 25-Dec-2021 riastradh

ukbd(4): Wait for callouts and blinking to complete in detach.

This detach routine (and whole driver) has got a lotta other
problems, but let's fix 'em one at a time...


# 1.153 11-Oct-2021 jmcneill

ukbd: blink LEDs asynchronously at boot

Instead of holding up boot by 400ms for each attached ukbd to blink the
keyboard LEDs, turn them on and set a callout to turn them off later.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.152 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.151 27-Jun-2021 pgoyette

branches: 1.151.2;
Since there's a bit of code that is conditionally compiled based on
USBVERBOSE, we need to include the opt_usbverbose.h header to get any
possible definition of this macro.

XXX Note that this code will NOT get included in the loadable module
XXX for USBVERBOSE.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.150 24-Apr-2021 thorpej

branches: 1.150.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.149 02-Mar-2021 gdt

branches: 1.149.2;
ukbd: GC some 20 year old code (NFC)

Long ago, code was improved to allow detaching keyboards that were the
console, but the old commen and panic() were #if 0'd instead of
removed.


# 1.148 02-Mar-2021 gdt

ukbd: Condition probe-time verbosity on USBVERBOSE

Previously, this driver switched on more verbose messages based on
DIAGNOSTIC. But, the messages weren't about an impossible-to-reach
condition, just extra keys. Change the condition to USBVERBOSE,
documented as serving this purpose.


# 1.147 12-Sep-2020 macallan

branches: 1.147.2;
send PMF events for keyboard brightness hotkeys on apple laptops


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.146 29-Mar-2020 tih

Summary: Introduce a keyboard event ring buffer for USB console keyboards

For the console keyboard, events must be handled separately from the
interrupt handler, because of the possibility that the user chooses to
drop into DDB by use of the designated key combination. This delayed
handling is tied to the HZ clock through the callout(9) mechanism,
meaning that another keyboard event arriving within 10ms of the
previous one might overwrite its predecessor before it's handled.
This causes dropped events for fast typists - and the situation gets
worse with modern, programmable, keyboards.

This patch introduces a ring buffer in the ukbd_softc data structure,
so that multiple pending events may be safely stored.


# 1.145 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.144 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.143 08-Jan-2020 macallan

send PMF events for volume and brightness control keys on Apple keyboards


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.142 05-May-2019 mrg

branches: 1.142.4;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.141 09-Jan-2018 christos

branches: 1.141.4;
tidy up debugging (make it compile with the 'ALL' kernel)


# 1.140 18-Dec-2017 jmcneill

ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)


# 1.139 10-Dec-2017 bouyer

Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825
# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

branches: 1.136.6;
don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.160 02-Apr-2022 mlelstv

Don't attach Yubikeys as console keyboard.


# 1.159 28-Mar-2022 riastradh

uhidev(9): Make uhidev state opaque.

This makes the API simpler and clearer and gives us more latitude to
fix bugs in the state management without breaking the ABI.

XXX kernel ABI change to signature of uhidev_get_report_desc and
uhidev_open, and to struct uhidev_attach_arg, requires bump for
uhidev driver modules


# 1.158 28-Mar-2022 riastradh

uhidev(9): Get the device and interface through attach args.

This way uhidev drivers don't need access to uhidev_softc itself for
it.


# 1.157 08-Jan-2022 riastradh

ukbd(4): Fix previous change to initial LED flashing.

Without this change the LEDs would get stuck on until the first
keypress. (This also seemed to trigger a crash in heavy load on
bringing aue(4) up and down over and over again while unplugging, but
I'm not sure why and I hope it's not actually related...)


# 1.156 31-Dec-2021 riastradh

ukbd(4): Avoid races in LED setting on attach.

- Don't reuse sc_delay for LED task -- a keyboard interrupt shortly
after attach might reset sc_delay so that the LEDs never get turned
back off.

- Don't turn the LEDs back off after attach if something else has
already changed them by the time the callout fires.

(And make sure to callout_halt before done this time!)


# 1.155 26-Dec-2021 andvar

fix various typos, mainly in comments.


# 1.154 25-Dec-2021 riastradh

ukbd(4): Wait for callouts and blinking to complete in detach.

This detach routine (and whole driver) has got a lotta other
problems, but let's fix 'em one at a time...


# 1.153 11-Oct-2021 jmcneill

ukbd: blink LEDs asynchronously at boot

Instead of holding up boot by 400ms for each attached ukbd to blink the
keyboard LEDs, turn them on and set a callout to turn them off later.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.152 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.151 27-Jun-2021 pgoyette

branches: 1.151.2;
Since there's a bit of code that is conditionally compiled based on
USBVERBOSE, we need to include the opt_usbverbose.h header to get any
possible definition of this macro.

XXX Note that this code will NOT get included in the loadable module
XXX for USBVERBOSE.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.150 24-Apr-2021 thorpej

branches: 1.150.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.149 02-Mar-2021 gdt

branches: 1.149.2;
ukbd: GC some 20 year old code (NFC)

Long ago, code was improved to allow detaching keyboards that were the
console, but the old commen and panic() were #if 0'd instead of
removed.


# 1.148 02-Mar-2021 gdt

ukbd: Condition probe-time verbosity on USBVERBOSE

Previously, this driver switched on more verbose messages based on
DIAGNOSTIC. But, the messages weren't about an impossible-to-reach
condition, just extra keys. Change the condition to USBVERBOSE,
documented as serving this purpose.


# 1.147 12-Sep-2020 macallan

branches: 1.147.2;
send PMF events for keyboard brightness hotkeys on apple laptops


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.146 29-Mar-2020 tih

Summary: Introduce a keyboard event ring buffer for USB console keyboards

For the console keyboard, events must be handled separately from the
interrupt handler, because of the possibility that the user chooses to
drop into DDB by use of the designated key combination. This delayed
handling is tied to the HZ clock through the callout(9) mechanism,
meaning that another keyboard event arriving within 10ms of the
previous one might overwrite its predecessor before it's handled.
This causes dropped events for fast typists - and the situation gets
worse with modern, programmable, keyboards.

This patch introduces a ring buffer in the ukbd_softc data structure,
so that multiple pending events may be safely stored.


# 1.145 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.144 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.143 08-Jan-2020 macallan

send PMF events for volume and brightness control keys on Apple keyboards


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.142 05-May-2019 mrg

branches: 1.142.4;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.141 09-Jan-2018 christos

branches: 1.141.4;
tidy up debugging (make it compile with the 'ALL' kernel)


# 1.140 18-Dec-2017 jmcneill

ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)


# 1.139 10-Dec-2017 bouyer

Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825
# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

branches: 1.136.6;
don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.159 28-Mar-2022 riastradh

uhidev(9): Make uhidev state opaque.

This makes the API simpler and clearer and gives us more latitude to
fix bugs in the state management without breaking the ABI.

XXX kernel ABI change to signature of uhidev_get_report_desc and
uhidev_open, and to struct uhidev_attach_arg, requires bump for
uhidev driver modules


# 1.158 28-Mar-2022 riastradh

uhidev(9): Get the device and interface through attach args.

This way uhidev drivers don't need access to uhidev_softc itself for
it.


# 1.157 08-Jan-2022 riastradh

ukbd(4): Fix previous change to initial LED flashing.

Without this change the LEDs would get stuck on until the first
keypress. (This also seemed to trigger a crash in heavy load on
bringing aue(4) up and down over and over again while unplugging, but
I'm not sure why and I hope it's not actually related...)


# 1.156 31-Dec-2021 riastradh

ukbd(4): Avoid races in LED setting on attach.

- Don't reuse sc_delay for LED task -- a keyboard interrupt shortly
after attach might reset sc_delay so that the LEDs never get turned
back off.

- Don't turn the LEDs back off after attach if something else has
already changed them by the time the callout fires.

(And make sure to callout_halt before done this time!)


# 1.155 26-Dec-2021 andvar

fix various typos, mainly in comments.


# 1.154 25-Dec-2021 riastradh

ukbd(4): Wait for callouts and blinking to complete in detach.

This detach routine (and whole driver) has got a lotta other
problems, but let's fix 'em one at a time...


# 1.153 11-Oct-2021 jmcneill

ukbd: blink LEDs asynchronously at boot

Instead of holding up boot by 400ms for each attached ukbd to blink the
keyboard LEDs, turn them on and set a callout to turn them off later.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.152 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.151 27-Jun-2021 pgoyette

branches: 1.151.2;
Since there's a bit of code that is conditionally compiled based on
USBVERBOSE, we need to include the opt_usbverbose.h header to get any
possible definition of this macro.

XXX Note that this code will NOT get included in the loadable module
XXX for USBVERBOSE.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.150 24-Apr-2021 thorpej

branches: 1.150.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.149 02-Mar-2021 gdt

branches: 1.149.2;
ukbd: GC some 20 year old code (NFC)

Long ago, code was improved to allow detaching keyboards that were the
console, but the old commen and panic() were #if 0'd instead of
removed.


# 1.148 02-Mar-2021 gdt

ukbd: Condition probe-time verbosity on USBVERBOSE

Previously, this driver switched on more verbose messages based on
DIAGNOSTIC. But, the messages weren't about an impossible-to-reach
condition, just extra keys. Change the condition to USBVERBOSE,
documented as serving this purpose.


# 1.147 12-Sep-2020 macallan

branches: 1.147.2;
send PMF events for keyboard brightness hotkeys on apple laptops


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.146 29-Mar-2020 tih

Summary: Introduce a keyboard event ring buffer for USB console keyboards

For the console keyboard, events must be handled separately from the
interrupt handler, because of the possibility that the user chooses to
drop into DDB by use of the designated key combination. This delayed
handling is tied to the HZ clock through the callout(9) mechanism,
meaning that another keyboard event arriving within 10ms of the
previous one might overwrite its predecessor before it's handled.
This causes dropped events for fast typists - and the situation gets
worse with modern, programmable, keyboards.

This patch introduces a ring buffer in the ukbd_softc data structure,
so that multiple pending events may be safely stored.


# 1.145 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.144 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.143 08-Jan-2020 macallan

send PMF events for volume and brightness control keys on Apple keyboards


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.142 05-May-2019 mrg

branches: 1.142.4;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.141 09-Jan-2018 christos

branches: 1.141.4;
tidy up debugging (make it compile with the 'ALL' kernel)


# 1.140 18-Dec-2017 jmcneill

ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)


# 1.139 10-Dec-2017 bouyer

Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825
# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

branches: 1.136.6;
don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.157 08-Jan-2022 riastradh

ukbd(4): Fix previous change to initial LED flashing.

Without this change the LEDs would get stuck on until the first
keypress. (This also seemed to trigger a crash in heavy load on
bringing aue(4) up and down over and over again while unplugging, but
I'm not sure why and I hope it's not actually related...)


# 1.156 31-Dec-2021 riastradh

ukbd(4): Avoid races in LED setting on attach.

- Don't reuse sc_delay for LED task -- a keyboard interrupt shortly
after attach might reset sc_delay so that the LEDs never get turned
back off.

- Don't turn the LEDs back off after attach if something else has
already changed them by the time the callout fires.

(And make sure to callout_halt before done this time!)


# 1.155 26-Dec-2021 andvar

fix various typos, mainly in comments.


# 1.154 25-Dec-2021 riastradh

ukbd(4): Wait for callouts and blinking to complete in detach.

This detach routine (and whole driver) has got a lotta other
problems, but let's fix 'em one at a time...


# 1.153 11-Oct-2021 jmcneill

ukbd: blink LEDs asynchronously at boot

Instead of holding up boot by 400ms for each attached ukbd to blink the
keyboard LEDs, turn them on and set a callout to turn them off later.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.152 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.151 27-Jun-2021 pgoyette

branches: 1.151.2;
Since there's a bit of code that is conditionally compiled based on
USBVERBOSE, we need to include the opt_usbverbose.h header to get any
possible definition of this macro.

XXX Note that this code will NOT get included in the loadable module
XXX for USBVERBOSE.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.150 24-Apr-2021 thorpej

branches: 1.150.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.149 02-Mar-2021 gdt

branches: 1.149.2;
ukbd: GC some 20 year old code (NFC)

Long ago, code was improved to allow detaching keyboards that were the
console, but the old commen and panic() were #if 0'd instead of
removed.


# 1.148 02-Mar-2021 gdt

ukbd: Condition probe-time verbosity on USBVERBOSE

Previously, this driver switched on more verbose messages based on
DIAGNOSTIC. But, the messages weren't about an impossible-to-reach
condition, just extra keys. Change the condition to USBVERBOSE,
documented as serving this purpose.


# 1.147 12-Sep-2020 macallan

branches: 1.147.2;
send PMF events for keyboard brightness hotkeys on apple laptops


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.146 29-Mar-2020 tih

Summary: Introduce a keyboard event ring buffer for USB console keyboards

For the console keyboard, events must be handled separately from the
interrupt handler, because of the possibility that the user chooses to
drop into DDB by use of the designated key combination. This delayed
handling is tied to the HZ clock through the callout(9) mechanism,
meaning that another keyboard event arriving within 10ms of the
previous one might overwrite its predecessor before it's handled.
This causes dropped events for fast typists - and the situation gets
worse with modern, programmable, keyboards.

This patch introduces a ring buffer in the ukbd_softc data structure,
so that multiple pending events may be safely stored.


# 1.145 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.144 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.143 08-Jan-2020 macallan

send PMF events for volume and brightness control keys on Apple keyboards


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.142 05-May-2019 mrg

branches: 1.142.4;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.141 09-Jan-2018 christos

branches: 1.141.4;
tidy up debugging (make it compile with the 'ALL' kernel)


# 1.140 18-Dec-2017 jmcneill

ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)


# 1.139 10-Dec-2017 bouyer

Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825
# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

branches: 1.136.6;
don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.156 31-Dec-2021 riastradh

ukbd(4): Avoid races in LED setting on attach.

- Don't reuse sc_delay for LED task -- a keyboard interrupt shortly
after attach might reset sc_delay so that the LEDs never get turned
back off.

- Don't turn the LEDs back off after attach if something else has
already changed them by the time the callout fires.

(And make sure to callout_halt before done this time!)


# 1.155 26-Dec-2021 andvar

fix various typos, mainly in comments.


# 1.154 25-Dec-2021 riastradh

ukbd(4): Wait for callouts and blinking to complete in detach.

This detach routine (and whole driver) has got a lotta other
problems, but let's fix 'em one at a time...


# 1.153 11-Oct-2021 jmcneill

ukbd: blink LEDs asynchronously at boot

Instead of holding up boot by 400ms for each attached ukbd to blink the
keyboard LEDs, turn them on and set a callout to turn them off later.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.152 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.151 27-Jun-2021 pgoyette

branches: 1.151.2;
Since there's a bit of code that is conditionally compiled based on
USBVERBOSE, we need to include the opt_usbverbose.h header to get any
possible definition of this macro.

XXX Note that this code will NOT get included in the loadable module
XXX for USBVERBOSE.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.150 24-Apr-2021 thorpej

branches: 1.150.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.149 02-Mar-2021 gdt

branches: 1.149.2;
ukbd: GC some 20 year old code (NFC)

Long ago, code was improved to allow detaching keyboards that were the
console, but the old commen and panic() were #if 0'd instead of
removed.


# 1.148 02-Mar-2021 gdt

ukbd: Condition probe-time verbosity on USBVERBOSE

Previously, this driver switched on more verbose messages based on
DIAGNOSTIC. But, the messages weren't about an impossible-to-reach
condition, just extra keys. Change the condition to USBVERBOSE,
documented as serving this purpose.


# 1.147 12-Sep-2020 macallan

branches: 1.147.2;
send PMF events for keyboard brightness hotkeys on apple laptops


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.146 29-Mar-2020 tih

Summary: Introduce a keyboard event ring buffer for USB console keyboards

For the console keyboard, events must be handled separately from the
interrupt handler, because of the possibility that the user chooses to
drop into DDB by use of the designated key combination. This delayed
handling is tied to the HZ clock through the callout(9) mechanism,
meaning that another keyboard event arriving within 10ms of the
previous one might overwrite its predecessor before it's handled.
This causes dropped events for fast typists - and the situation gets
worse with modern, programmable, keyboards.

This patch introduces a ring buffer in the ukbd_softc data structure,
so that multiple pending events may be safely stored.


# 1.145 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.144 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.143 08-Jan-2020 macallan

send PMF events for volume and brightness control keys on Apple keyboards


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.142 05-May-2019 mrg

branches: 1.142.4;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.141 09-Jan-2018 christos

branches: 1.141.4;
tidy up debugging (make it compile with the 'ALL' kernel)


# 1.140 18-Dec-2017 jmcneill

ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)


# 1.139 10-Dec-2017 bouyer

Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825
# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

branches: 1.136.6;
don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.155 26-Dec-2021 andvar

fix various typos, mainly in comments.


# 1.154 25-Dec-2021 riastradh

ukbd(4): Wait for callouts and blinking to complete in detach.

This detach routine (and whole driver) has got a lotta other
problems, but let's fix 'em one at a time...


# 1.153 11-Oct-2021 jmcneill

ukbd: blink LEDs asynchronously at boot

Instead of holding up boot by 400ms for each attached ukbd to blink the
keyboard LEDs, turn them on and set a callout to turn them off later.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.152 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.151 27-Jun-2021 pgoyette

branches: 1.151.2;
Since there's a bit of code that is conditionally compiled based on
USBVERBOSE, we need to include the opt_usbverbose.h header to get any
possible definition of this macro.

XXX Note that this code will NOT get included in the loadable module
XXX for USBVERBOSE.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.150 24-Apr-2021 thorpej

branches: 1.150.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.149 02-Mar-2021 gdt

branches: 1.149.2;
ukbd: GC some 20 year old code (NFC)

Long ago, code was improved to allow detaching keyboards that were the
console, but the old commen and panic() were #if 0'd instead of
removed.


# 1.148 02-Mar-2021 gdt

ukbd: Condition probe-time verbosity on USBVERBOSE

Previously, this driver switched on more verbose messages based on
DIAGNOSTIC. But, the messages weren't about an impossible-to-reach
condition, just extra keys. Change the condition to USBVERBOSE,
documented as serving this purpose.


# 1.147 12-Sep-2020 macallan

branches: 1.147.2;
send PMF events for keyboard brightness hotkeys on apple laptops


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.146 29-Mar-2020 tih

Summary: Introduce a keyboard event ring buffer for USB console keyboards

For the console keyboard, events must be handled separately from the
interrupt handler, because of the possibility that the user chooses to
drop into DDB by use of the designated key combination. This delayed
handling is tied to the HZ clock through the callout(9) mechanism,
meaning that another keyboard event arriving within 10ms of the
previous one might overwrite its predecessor before it's handled.
This causes dropped events for fast typists - and the situation gets
worse with modern, programmable, keyboards.

This patch introduces a ring buffer in the ukbd_softc data structure,
so that multiple pending events may be safely stored.


# 1.145 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.144 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.143 08-Jan-2020 macallan

send PMF events for volume and brightness control keys on Apple keyboards


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.142 05-May-2019 mrg

branches: 1.142.4;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.141 09-Jan-2018 christos

branches: 1.141.4;
tidy up debugging (make it compile with the 'ALL' kernel)


# 1.140 18-Dec-2017 jmcneill

ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)


# 1.139 10-Dec-2017 bouyer

Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825
# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

branches: 1.136.6;
don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.154 25-Dec-2021 riastradh

ukbd(4): Wait for callouts and blinking to complete in detach.

This detach routine (and whole driver) has got a lotta other
problems, but let's fix 'em one at a time...


# 1.153 11-Oct-2021 jmcneill

ukbd: blink LEDs asynchronously at boot

Instead of holding up boot by 400ms for each attached ukbd to blink the
keyboard LEDs, turn them on and set a callout to turn them off later.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.152 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.151 27-Jun-2021 pgoyette

branches: 1.151.2;
Since there's a bit of code that is conditionally compiled based on
USBVERBOSE, we need to include the opt_usbverbose.h header to get any
possible definition of this macro.

XXX Note that this code will NOT get included in the loadable module
XXX for USBVERBOSE.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.150 24-Apr-2021 thorpej

branches: 1.150.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.149 02-Mar-2021 gdt

branches: 1.149.2;
ukbd: GC some 20 year old code (NFC)

Long ago, code was improved to allow detaching keyboards that were the
console, but the old commen and panic() were #if 0'd instead of
removed.


# 1.148 02-Mar-2021 gdt

ukbd: Condition probe-time verbosity on USBVERBOSE

Previously, this driver switched on more verbose messages based on
DIAGNOSTIC. But, the messages weren't about an impossible-to-reach
condition, just extra keys. Change the condition to USBVERBOSE,
documented as serving this purpose.


# 1.147 12-Sep-2020 macallan

branches: 1.147.2;
send PMF events for keyboard brightness hotkeys on apple laptops


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.146 29-Mar-2020 tih

Summary: Introduce a keyboard event ring buffer for USB console keyboards

For the console keyboard, events must be handled separately from the
interrupt handler, because of the possibility that the user chooses to
drop into DDB by use of the designated key combination. This delayed
handling is tied to the HZ clock through the callout(9) mechanism,
meaning that another keyboard event arriving within 10ms of the
previous one might overwrite its predecessor before it's handled.
This causes dropped events for fast typists - and the situation gets
worse with modern, programmable, keyboards.

This patch introduces a ring buffer in the ukbd_softc data structure,
so that multiple pending events may be safely stored.


# 1.145 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.144 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.143 08-Jan-2020 macallan

send PMF events for volume and brightness control keys on Apple keyboards


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.142 05-May-2019 mrg

branches: 1.142.4;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.141 09-Jan-2018 christos

branches: 1.141.4;
tidy up debugging (make it compile with the 'ALL' kernel)


# 1.140 18-Dec-2017 jmcneill

ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)


# 1.139 10-Dec-2017 bouyer

Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825
# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

branches: 1.136.6;
don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.153 11-Oct-2021 jmcneill

ukbd: blink LEDs asynchronously at boot

Instead of holding up boot by 400ms for each attached ukbd to blink the
keyboard LEDs, turn them on and set a callout to turn them off later.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.152 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.151 27-Jun-2021 pgoyette

branches: 1.151.2;
Since there's a bit of code that is conditionally compiled based on
USBVERBOSE, we need to include the opt_usbverbose.h header to get any
possible definition of this macro.

XXX Note that this code will NOT get included in the loadable module
XXX for USBVERBOSE.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.150 24-Apr-2021 thorpej

branches: 1.150.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.149 02-Mar-2021 gdt

branches: 1.149.2;
ukbd: GC some 20 year old code (NFC)

Long ago, code was improved to allow detaching keyboards that were the
console, but the old commen and panic() were #if 0'd instead of
removed.


# 1.148 02-Mar-2021 gdt

ukbd: Condition probe-time verbosity on USBVERBOSE

Previously, this driver switched on more verbose messages based on
DIAGNOSTIC. But, the messages weren't about an impossible-to-reach
condition, just extra keys. Change the condition to USBVERBOSE,
documented as serving this purpose.


# 1.147 12-Sep-2020 macallan

branches: 1.147.2;
send PMF events for keyboard brightness hotkeys on apple laptops


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.146 29-Mar-2020 tih

Summary: Introduce a keyboard event ring buffer for USB console keyboards

For the console keyboard, events must be handled separately from the
interrupt handler, because of the possibility that the user chooses to
drop into DDB by use of the designated key combination. This delayed
handling is tied to the HZ clock through the callout(9) mechanism,
meaning that another keyboard event arriving within 10ms of the
previous one might overwrite its predecessor before it's handled.
This causes dropped events for fast typists - and the situation gets
worse with modern, programmable, keyboards.

This patch introduces a ring buffer in the ukbd_softc data structure,
so that multiple pending events may be safely stored.


# 1.145 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.144 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.143 08-Jan-2020 macallan

send PMF events for volume and brightness control keys on Apple keyboards


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.142 05-May-2019 mrg

branches: 1.142.4;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.141 09-Jan-2018 christos

branches: 1.141.4;
tidy up debugging (make it compile with the 'ALL' kernel)


# 1.140 18-Dec-2017 jmcneill

ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)


# 1.139 10-Dec-2017 bouyer

Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825
# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

branches: 1.136.6;
don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.152 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base thorpej-i2c-spi-conf-base
# 1.151 27-Jun-2021 pgoyette

branches: 1.151.2;
Since there's a bit of code that is conditionally compiled based on
USBVERBOSE, we need to include the opt_usbverbose.h header to get any
possible definition of this macro.

XXX Note that this code will NOT get included in the loadable module
XXX for USBVERBOSE.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.150 24-Apr-2021 thorpej

branches: 1.150.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.149 02-Mar-2021 gdt

branches: 1.149.2;
ukbd: GC some 20 year old code (NFC)

Long ago, code was improved to allow detaching keyboards that were the
console, but the old commen and panic() were #if 0'd instead of
removed.


# 1.148 02-Mar-2021 gdt

ukbd: Condition probe-time verbosity on USBVERBOSE

Previously, this driver switched on more verbose messages based on
DIAGNOSTIC. But, the messages weren't about an impossible-to-reach
condition, just extra keys. Change the condition to USBVERBOSE,
documented as serving this purpose.


# 1.147 12-Sep-2020 macallan

branches: 1.147.2;
send PMF events for keyboard brightness hotkeys on apple laptops


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.146 29-Mar-2020 tih

Summary: Introduce a keyboard event ring buffer for USB console keyboards

For the console keyboard, events must be handled separately from the
interrupt handler, because of the possibility that the user chooses to
drop into DDB by use of the designated key combination. This delayed
handling is tied to the HZ clock through the callout(9) mechanism,
meaning that another keyboard event arriving within 10ms of the
previous one might overwrite its predecessor before it's handled.
This causes dropped events for fast typists - and the situation gets
worse with modern, programmable, keyboards.

This patch introduces a ring buffer in the ukbd_softc data structure,
so that multiple pending events may be safely stored.


# 1.145 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.144 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.143 08-Jan-2020 macallan

send PMF events for volume and brightness control keys on Apple keyboards


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.142 05-May-2019 mrg

branches: 1.142.4;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.141 09-Jan-2018 christos

branches: 1.141.4;
tidy up debugging (make it compile with the 'ALL' kernel)


# 1.140 18-Dec-2017 jmcneill

ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)


# 1.139 10-Dec-2017 bouyer

Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825
# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

branches: 1.136.6;
don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.151 27-Jun-2021 pgoyette

Since there's a bit of code that is conditionally compiled based on
USBVERBOSE, we need to include the opt_usbverbose.h header to get any
possible definition of this macro.

XXX Note that this code will NOT get included in the loadable module
XXX for USBVERBOSE.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.150 24-Apr-2021 thorpej

Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.149 02-Mar-2021 gdt

branches: 1.149.2;
ukbd: GC some 20 year old code (NFC)

Long ago, code was improved to allow detaching keyboards that were the
console, but the old commen and panic() were #if 0'd instead of
removed.


# 1.148 02-Mar-2021 gdt

ukbd: Condition probe-time verbosity on USBVERBOSE

Previously, this driver switched on more verbose messages based on
DIAGNOSTIC. But, the messages weren't about an impossible-to-reach
condition, just extra keys. Change the condition to USBVERBOSE,
documented as serving this purpose.


# 1.147 12-Sep-2020 macallan

branches: 1.147.2;
send PMF events for keyboard brightness hotkeys on apple laptops


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.146 29-Mar-2020 tih

Summary: Introduce a keyboard event ring buffer for USB console keyboards

For the console keyboard, events must be handled separately from the
interrupt handler, because of the possibility that the user chooses to
drop into DDB by use of the designated key combination. This delayed
handling is tied to the HZ clock through the callout(9) mechanism,
meaning that another keyboard event arriving within 10ms of the
previous one might overwrite its predecessor before it's handled.
This causes dropped events for fast typists - and the situation gets
worse with modern, programmable, keyboards.

This patch introduces a ring buffer in the ukbd_softc data structure,
so that multiple pending events may be safely stored.


# 1.145 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.144 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.143 08-Jan-2020 macallan

send PMF events for volume and brightness control keys on Apple keyboards


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.142 05-May-2019 mrg

branches: 1.142.4;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.141 09-Jan-2018 christos

branches: 1.141.4;
tidy up debugging (make it compile with the 'ALL' kernel)


# 1.140 18-Dec-2017 jmcneill

ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)


# 1.139 10-Dec-2017 bouyer

Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825
# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

branches: 1.136.6;
don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.150 24-Apr-2021 thorpej

Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.149 02-Mar-2021 gdt

branches: 1.149.2;
ukbd: GC some 20 year old code (NFC)

Long ago, code was improved to allow detaching keyboards that were the
console, but the old commen and panic() were #if 0'd instead of
removed.


# 1.148 02-Mar-2021 gdt

ukbd: Condition probe-time verbosity on USBVERBOSE

Previously, this driver switched on more verbose messages based on
DIAGNOSTIC. But, the messages weren't about an impossible-to-reach
condition, just extra keys. Change the condition to USBVERBOSE,
documented as serving this purpose.


# 1.147 12-Sep-2020 macallan

branches: 1.147.2;
send PMF events for keyboard brightness hotkeys on apple laptops


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.146 29-Mar-2020 tih

Summary: Introduce a keyboard event ring buffer for USB console keyboards

For the console keyboard, events must be handled separately from the
interrupt handler, because of the possibility that the user chooses to
drop into DDB by use of the designated key combination. This delayed
handling is tied to the HZ clock through the callout(9) mechanism,
meaning that another keyboard event arriving within 10ms of the
previous one might overwrite its predecessor before it's handled.
This causes dropped events for fast typists - and the situation gets
worse with modern, programmable, keyboards.

This patch introduces a ring buffer in the ukbd_softc data structure,
so that multiple pending events may be safely stored.


# 1.145 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.144 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.143 08-Jan-2020 macallan

send PMF events for volume and brightness control keys on Apple keyboards


Revision tags: netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.142 05-May-2019 mrg

branches: 1.142.4;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.141 09-Jan-2018 christos

branches: 1.141.4;
tidy up debugging (make it compile with the 'ALL' kernel)


# 1.140 18-Dec-2017 jmcneill

ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)


# 1.139 10-Dec-2017 bouyer

Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825
# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

branches: 1.136.6;
don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.149 02-Mar-2021 gdt

ukbd: GC some 20 year old code (NFC)

Long ago, code was improved to allow detaching keyboards that were the
console, but the old commen and panic() were #if 0'd instead of
removed.


# 1.148 02-Mar-2021 gdt

ukbd: Condition probe-time verbosity on USBVERBOSE

Previously, this driver switched on more verbose messages based on
DIAGNOSTIC. But, the messages weren't about an impossible-to-reach
condition, just extra keys. Change the condition to USBVERBOSE,
documented as serving this purpose.


Revision tags: thorpej-futex-base
# 1.147 12-Sep-2020 macallan

send PMF events for keyboard brightness hotkeys on apple laptops


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.146 29-Mar-2020 tih

Summary: Introduce a keyboard event ring buffer for USB console keyboards

For the console keyboard, events must be handled separately from the
interrupt handler, because of the possibility that the user chooses to
drop into DDB by use of the designated key combination. This delayed
handling is tied to the HZ clock through the callout(9) mechanism,
meaning that another keyboard event arriving within 10ms of the
previous one might overwrite its predecessor before it's handled.
This causes dropped events for fast typists - and the situation gets
worse with modern, programmable, keyboards.

This patch introduces a ring buffer in the ukbd_softc data structure,
so that multiple pending events may be safely stored.


# 1.145 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.144 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.143 08-Jan-2020 macallan

send PMF events for volume and brightness control keys on Apple keyboards


Revision tags: netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.142 05-May-2019 mrg

branches: 1.142.4;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.141 09-Jan-2018 christos

branches: 1.141.4;
tidy up debugging (make it compile with the 'ALL' kernel)


# 1.140 18-Dec-2017 jmcneill

ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)


# 1.139 10-Dec-2017 bouyer

Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825
# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

branches: 1.136.6;
don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.147 12-Sep-2020 macallan

send PMF events for keyboard brightness hotkeys on apple laptops


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.146 29-Mar-2020 tih

Summary: Introduce a keyboard event ring buffer for USB console keyboards

For the console keyboard, events must be handled separately from the
interrupt handler, because of the possibility that the user chooses to
drop into DDB by use of the designated key combination. This delayed
handling is tied to the HZ clock through the callout(9) mechanism,
meaning that another keyboard event arriving within 10ms of the
previous one might overwrite its predecessor before it's handled.
This causes dropped events for fast typists - and the situation gets
worse with modern, programmable, keyboards.

This patch introduces a ring buffer in the ukbd_softc data structure,
so that multiple pending events may be safely stored.


# 1.145 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.144 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.143 08-Jan-2020 macallan

send PMF events for volume and brightness control keys on Apple keyboards


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.142 05-May-2019 mrg

branches: 1.142.4;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.141 09-Jan-2018 christos

branches: 1.141.4;
tidy up debugging (make it compile with the 'ALL' kernel)


# 1.140 18-Dec-2017 jmcneill

ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)


# 1.139 10-Dec-2017 bouyer

Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825
# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

branches: 1.136.6;
don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.146 29-Mar-2020 tih

Summary: Introduce a keyboard event ring buffer for USB console keyboards

For the console keyboard, events must be handled separately from the
interrupt handler, because of the possibility that the user chooses to
drop into DDB by use of the designated key combination. This delayed
handling is tied to the HZ clock through the callout(9) mechanism,
meaning that another keyboard event arriving within 10ms of the
previous one might overwrite its predecessor before it's handled.
This causes dropped events for fast typists - and the situation gets
worse with modern, programmable, keyboards.

This patch introduces a ring buffer in the ukbd_softc data structure,
so that multiple pending events may be safely stored.


# 1.145 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.144 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.143 08-Jan-2020 macallan

send PMF events for volume and brightness control keys on Apple keyboards


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.142 05-May-2019 mrg

branches: 1.142.4;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.141 09-Jan-2018 christos

branches: 1.141.4;
tidy up debugging (make it compile with the 'ALL' kernel)


# 1.140 18-Dec-2017 jmcneill

ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)


# 1.139 10-Dec-2017 bouyer

Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825
# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

branches: 1.136.6;
don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.145 14-Mar-2020 christos

revert the 0x% -> %# change for fixed width formats pointed out by uwe.


# 1.144 13-Mar-2020 christos

PR/55068: sc.dying: Fix printf formats:
- no %s/%p for kernel log
- 0x% -> %#
- always %j for kernel log


Revision tags: ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.143 08-Jan-2020 macallan

send PMF events for volume and brightness control keys on Apple keyboards


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.142 05-May-2019 mrg

branches: 1.142.4;
remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.141 09-Jan-2018 christos

branches: 1.141.4;
tidy up debugging (make it compile with the 'ALL' kernel)


# 1.140 18-Dec-2017 jmcneill

ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)


# 1.139 10-Dec-2017 bouyer

Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825
# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

branches: 1.136.6;
don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.143 08-Jan-2020 macallan

send PMF events for volume and brightness control keys on Apple keyboards


Revision tags: ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.142 05-May-2019 mrg

remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.141 09-Jan-2018 christos

branches: 1.141.4;
tidy up debugging (make it compile with the 'ALL' kernel)


# 1.140 18-Dec-2017 jmcneill

ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)


# 1.139 10-Dec-2017 bouyer

Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825
# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

branches: 1.136.6;
don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.142 05-May-2019 mrg

remove explicit 'extern struct cfdriver <my>_cd;' and use ioconf.h


Revision tags: isaki-audio2-base pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.141 09-Jan-2018 christos

tidy up debugging (make it compile with the 'ALL' kernel)


# 1.140 18-Dec-2017 jmcneill

ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)


# 1.139 10-Dec-2017 bouyer

Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825
# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

branches: 1.136.6;
don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.141 09-Jan-2018 christos

tidy up debugging (make it compile with the 'ALL' kernel)


# 1.140 18-Dec-2017 jmcneill

ukbd_cngetc: poll once for data in the buffer, otherwise return type 0 (no data)


# 1.139 10-Dec-2017 bouyer

Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825
# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

branches: 1.136.6;
don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.138 13-Aug-2017 jakllsch

Support more varieties of USB keyboard reports.

The previous code asssumed reports would closely match the Bootstrap
Keyboard Protocol. This is no longer always the case, particularly
with higher-end keyboards.


# 1.137 13-Aug-2017 jakllsch

Fix memory leak in report parsing error paths.


Revision tags: perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204
# 1.136 20-Jan-2017 maya

don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

branches: 1.134.2;
Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


# 1.136 20-Jan-2017 maya

don't memcpy overlapping buffers, use memmove.
this is undefined behaviour.
CID 1299069


# 1.135 20-Jan-2017 maya

kassert that we aren't overflowing the array.

this assert isn't expected to trigger due to current parameters used, but
to be sure, check.


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

branches: 1.133.2;
Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers


Revision tags: nick-nhusb-base-20161204
# 1.134 25-Nov-2016 skrll

Sort opt_* #includes


Revision tags: pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.133 30-Apr-2016 skrll

Make GDIUM_KEYBOARD_HACK compile


# 1.132 27-Apr-2016 jakllsch

Pull in opt_usb.h in _KERNEL_OPT case for various *_DEBUG options.
Makes various driver-specific debugging options work again.

XXX more to fix in dev/usb


# 1.131 23-Apr-2016 skrll

Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.130 07-Mar-2015 mrg

properly protect uhid's sc_q member with sc_lock. should fix PR#49728.
while here, remove D_MPSAFE from uhid* and all uhid users, as it really
needs all the callers to be safe and they're not.

XXX: pullup-7


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.129 26-Sep-2013 skrll

branches: 1.129.4; 1.129.6;
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

- usbd_clear_endpoint_stall_async is already triggered via a
usb_task, so simply call usbd_do_request.

- uhidev_set_report_async had one caller in ukbd_set_leds.
Convert this usage to use usb_task as well.

Discussed with mrg@


# 1.128 15-Sep-2013 martin

ifdef variable like their use


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1
# 1.127 22-Jul-2013 soren

Missing AB_QUIET newlines.


Revision tags: riastradh-drm2-base
# 1.126 04-Apr-2013 skrll

branches: 1.126.4; 1.126.6;
Whitespace


Revision tags: agc-symver-base yamt-pagecache-base8
# 1.125 05-Jan-2013 christos

- need opt_usb.h if depending on USB_DEBUG
- remove trailing whitespace
- add missing KERNEL_RCSID


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.124 10-Jun-2012 mrg

branches: 1.124.2;
merge the jmcneill-usbmp branch. many thanks to jared for the
initial work, and every one else who has tested things for me.
this is largely my fault at this point :-)

the main changes are something like:

- usbd_bus_methods{} gains a get_lock() to enable the
host controller to provide a lock for the USB code.
if the lock isn't provided, old-style protection is
(partially) applied.

- ehci/ohci/uhci have been converted to the new
interfaces, including mutex/cv/etc conversion.

- usbdivar.h contains a discussion about locking and
what locks are held for which method calls. more
to come for usbdi(9) here.

- audio drivers (uaudio, umidi, auvitek) have been
properly SMPified now that USB is ready.

- scsi drivers have been modified to take the kernel
lock explicitly before calling into scsi code.

- usb pipes are associated with a lock, that is the
same as the controller lock. (this could be split
up further in the future.)

- several usbfoo_locked() or usbfoo_unlocked()
functions have been added to the usbdi(9) to
enable functionality with or without the USB
lock (per controller) already being held.

the TODO.usbmp file has specific details on what is left to
do, including what device-specific changes should be done now
that the whole framework is ready.


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9
# 1.123 24-Apr-2012 khorben

Revert previous commit, as it really is wrong to grow ukbd_trtab to an array
of 16-bit values. While at it, set the correct value for the Sleep button.

Likewise, keep forwarding the keys specific to the Sun Type 7 USB keyboard as
raw input (currently required for X), but making sure to use unassigned and
valid values this time.

Tested with modular-xorg-server 1.6.5nb11 and xf86-input-keyboard 1.3.2nb3.


# 1.122 22-Apr-2012 khorben

Implemented extra keys as found on Sun Type 7 USB keyboards, and
according to the documentation mentioned above in this file.

"works here" macallan@, myself


# 1.121 22-Apr-2012 khorben

Also lookup and be able to lit the LED for the Compose key. Seems to
require additional modifications to function properly in X though.

No objection on current-users@


# 1.120 22-Apr-2012 khorben

Convert keycodes 0x7f, 0x80 and 0x81 to PMF events VOLUME_TOGGLE,
VOLUME_UP and VOLUME_DOWN as observed on my Sun Type 7 USB keyboard, and
according to the documentation mentioned above.

"works here" macallan@ and myself


# 1.119 22-Apr-2012 khorben

Indent the trtab_gdium_fn array like surrounding variables.

No objection on current-users@


# 1.118 22-Apr-2012 khorben

Fixed a potential out-of-bounds array access when translating keycodes
for the gdium keyboard.

Reviewed by macallan@


Revision tags: yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7
# 1.117 11-Mar-2012 mrg

minor cleanups from usbmp:
- move usbd_delay_ms() into usbdivar.h in the usb_subr.c section
- minor rcsid fixes
- copyright maintenence


Revision tags: jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.116 24-Feb-2012 mrg

remove any remnants of freebsd/openbsd code.


Revision tags: jmcneill-usbmp-base2 netbsd-6-base
# 1.115 23-Dec-2011 jakllsch

branches: 1.115.2;
Revert previous due to active usbmp branch(es).


# 1.114 22-Dec-2011 jakllsch

Adjust-away inconsistent and trailing whitespace.


Revision tags: jmcneill-usbmp-pre-base2 mrg-ohci-jmcneill-usbmp-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.113 03-Nov-2011 macallan

branches: 1.113.4;
only build gdium Fn support with options GDIUM_KEYBOARD_HACK


Revision tags: yamt-pagecache-base
# 1.112 02-Nov-2011 macallan

branches: 1.112.2;
support PMF events as target type in scancode translation tables


# 1.111 02-Nov-2011 macallan

support Gdium's Fn key
translation table from OpenBSD


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.110 02-Jan-2011 mbalmer

Cap h.loc.count at MAXKEYCODE instead of bailing out. This lets some obscure/
roque keyboards attach.

From loganaden@devio.us (Loganaden Velvindron), thanks!


# 1.109 30-Nov-2010 phx

Support for Apple notebook keyboards, which have a few quirks.
1. On ISO-keyboard the keycodes for the key left of '1' and right of Shift
are swapped.
2. Find the Apple FN key in the report descriptor and do the translations
needed, before passing the keycodes to wscons.
3. Those keyboards only have the left Alt key. AltGr is missing. So it is
emulated when holding down FN together with Alt.


Revision tags: uebayasi-xip-base4
# 1.108 03-Nov-2010 dyoung

Stop using the compatibility macros USB_ATTACH(), USB_DETACH(),
USB_MATCH(), et cetera. These files produce the same assembly
(according to objdump -d) before and after the change


Revision tags: uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9
# 1.107 09-Feb-2010 sborrill

branches: 1.107.2;
Tweak comment about keyboard mapping.


Revision tags: uebayasi-xip-base
# 1.106 11-Jan-2010 pooka

branches: 1.106.2;
_KERNEL_POT


Revision tags: matt-premerge-20091211
# 1.105 12-Nov-2009 dyoung

Simplify activation hooks. (sc_dying must die!)


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 jym-xensuspend-nbase
# 1.104 11-Jul-2009 jakllsch

Fix WSKBD_RAW mode ukbd -> pckbd translation for Pause/Break and
Print Screen/Sys Req keys so xf86-input-keyboard can figure out
what we want.

Additionally, fix dead URL, and add a note that this emulation
is not completely identical to a real pckbd.


Revision tags: yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.103 09-Mar-2009 uebayasi

These don't need <sys/tty.h>.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.102 11-Jan-2009 cegger

branches: 1.102.2;
make this compile


Revision tags: netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 haad-dm-base
# 1.101 09-Sep-2008 jmcneill

branches: 1.101.2; 1.101.4; 1.101.10;
register with pmf


Revision tags: wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.100 24-May-2008 cube

branches: 1.100.4;
Split device_t and softc for all USB device drivers, and related cosmetic
changes.

Matthias Drochner kindly reviewed this patch, and tested ums, ubt, uaudio
and ral. I tested umass myself.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.99 28-Apr-2008 martin

branches: 1.99.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.98 05-Apr-2008 cegger

branches: 1.98.2; 1.98.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.97 18-Feb-2008 dyoung

branches: 1.97.6;
Use device_t and its accessor functions.

Register _childdetached methods with drivers that attach children.
Wait to set child references to NULL there, instead of doing that
in the detach method.

Replace many uses of USB_DECLARE_DRIVER() with CFATTACH_DECL2().


# 1.96 29-Jan-2008 tron

Add support for function keys F16 to F19 as present on e.g. the new
Apple aluminum keyboard.

Patch contributed by Michael Piotrowski in PR kern/37788, reviewed
by Matthias Drochner.


Revision tags: nick-csl-alignment-base5 bouyer-xeni386-merge1 matt-armv6-prevmlocking vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base matt-mips64-base jmcneill-pm-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base reinoud-bufcleanup-base mjf-ufs-trans-base vmlocking-base
# 1.95 04-Mar-2007 christos

branches: 1.95.16; 1.95.22;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 itohy-usb1-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.94 16-Nov-2006 christos

branches: 1.94.2; 1.94.4; 1.94.8; 1.94.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.93 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.92 03-Sep-2006 christos

branches: 1.92.2; 1.92.4;
add missing initializer


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 elad-kernelauth-base simonb-timecounters-base
# 1.91 28-Mar-2006 thorpej

Use device_unit().


Revision tags: peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.90 11-Dec-2005 christos

branches: 1.90.4; 1.90.6; 1.90.8; 1.90.10; 1.90.12;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.89 13-Jun-2005 cube

branches: 1.89.2;
Provide a header for UKBD_LAYOUT. It makes more sense, and it avoids
quoting issues during the build process.

Reported and checked by spz@.


# 1.88 03-May-2005 jonathan

Fix ifdef botch in previous revision:

The `Static' forward declaration of ukbd_rawrepeat was inside #ifdef
UKBD_REPEAT but not #ifdef DISPLAY_COMPAT_RAWCKBD. The definition and
all other references are inside both #ifdefs. The `static' function
declaration with no definition failed GCC warnings.

Pass GCC warnings by wrapping the declaration with a check that both
CPP tokens are defined.


# 1.87 03-May-2005 augustss

Don't emulate auto repeat in the keyboard driver, the wskbd driver does that.
Auto repeat emulation can be turned on by defining UKBD_REPEAT, but this
should never be necessary.


# 1.86 29-Apr-2005 augustss

If UKBD_LAYOUT isn't defined, but PCKBD_LAYOUT is, use the latter as the
default layout. Fixes half of kern/28668.


Revision tags: netbsd-2-0-3-RELEASE yamt-km-base4 netbsd-2-0-2-RELEASE yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base netbsd-2-0-1-RELEASE kent-audio1-beforemerge netbsd-2-base kent-audio1-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.85 11-Mar-2003 augustss

branches: 1.85.2; 1.85.8; 1.85.16;
Update URLs for the HID spec.

(Committed at 36000 feet above the Atlantic on board LH418 using
a broadband satellite connection.)


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.84 09-Oct-2002 augustss

Make sure we are at splusb() while polling.


Revision tags: kqueue-base
# 1.83 23-Sep-2002 simonb

Remove breaks after returns, unreachable returns and returns after
returns(!).


Revision tags: gehenna-devsw-base
# 1.82 11-Jul-2002 augustss

Get rid of trailing white space.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base
# 1.81 17-Mar-2002 atatat

branches: 1.81.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.


Revision tags: newlock-base ifpoll-base
# 1.80 31-Dec-2001 augustss

Make a typedef for struct proc to make portingeasier.


# 1.79 30-Dec-2001 augustss

A little more debug.


# 1.78 30-Dec-2001 augustss

Fix typo.


# 1.77 29-Dec-2001 augustss

Remove garbage.


# 1.76 29-Dec-2001 augustss

Add some missing scan code translations. Docs from Microsoft via Perry Metzger.


# 1.75 28-Dec-2001 augustss

Introduce an extra driver level for HID devices, uhidev. This uhidev driver
attaches to the hub, and HID drivers (ums, ukbd, and uhid) attach to
uhidev. The reason for this change is that some HID devices report multiple
components (like a keyboard and a mouse) using the same interface, but with
different report identifiers. The report identifier can be specified with
a locator for the HID drivers.
Furthermore, change the ukbd driver to handle other formats than the boot
protocol.


# 1.74 28-Nov-2001 lukem

use #ifdef DDB (for consistency with the rest of the kernel)


# 1.73 15-Nov-2001 augustss

usbd_interface2device_handle() cannot fail.


# 1.72 13-Nov-2001 lukem

add RCSIDs


Revision tags: thorpej-mips-cache-base
# 1.71 07-Nov-2001 augustss

Add a workaround for broken ports (e.g. macppc) that do not call
cnpollc before cngetc in DDB. DDB now works with USB console on Macs.

Don't frob the LEDs if nothing changes.


# 1.70 28-Oct-2001 augustss

Use the usb callout macros.


# 1.69 24-Oct-2001 augustss

If we are the console and we have DDB then events must not be delivered
from the interrupt routine since this will enter the USB interrupt
processing recursively during polling.
Now ukbd can be used as console keyboard for DDB!


# 1.68 24-Oct-2001 augustss

Make sure interrupt pipe is closed when detaching console keyboard.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2
# 1.67 28-Sep-2001 augustss

branches: 1.67.2;
Only clear the endpoint on stall (from FreeBSD).


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.66 06-Apr-2001 augustss

branches: 1.66.2; 1.66.4;
Allow a UKBD_LAYOUT option to determine the default keyboard layout.
(From OpenBSD.)


# 1.65 21-Feb-2001 jdolecek

branches: 1.65.2;
make some more constant arrays 'const'


# 1.64 23-Jan-2001 augustss

Make sure driver attach/detach events are generated in a consistent manner.


# 1.63 29-Dec-2000 augustss

Update many URLs.


# 1.62 20-Aug-2000 augustss

Implement handling of the UQ_SPUR_BUT_UP quirk. Some keyboards sometimes
generate a key up quickly followed by a key down for the same key, so we
take care of that.
(Finally I can type again without going nuts. :)


# 1.61 17-Aug-2000 augustss

Add two keys to the raw mapping for German keyboards.
From Matthias Kretschmer <McCratch@gmx.net>, fixes PR 10850.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.60 01-Jun-2000 augustss

Bring the coding style into the 80s, i.e., get rid of __P and use
ANSI prototypes and declarations.


Revision tags: minoura-xpg4dl-base
# 1.59 27-Apr-2000 augustss

branches: 1.59.2;
Change my email address.


# 1.58 27-Mar-2000 augustss

Change (almost) all static to Static. The symbol `Static' can then be defined
to `' or `static' depending on if you want to debug or not.


# 1.57 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.56 29-Feb-2000 augustss

Distinguish between device and interface classes.
(I finally found a document that said that they were different.)


Revision tags: chs-ubc2-newbase
# 1.55 02-Feb-2000 augustss

Generate usb events on attach and detach.


# 1.54 19-Jan-2000 augustss

Add an argument to usbd_open_pipe_intr() to specify the polling interval
for an interrupt pipe in case we don't what what the descriptor suggests.


# 1.53 16-Jan-2000 augustss

Add a DPRINTF on keyboard errors.


# 1.52 16-Jan-2000 augustss

Let usbd_set_polling() work on a usbd_device_handle instead of
a usbd_interface_handle.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.51 06-Dec-1999 augustss

Cosmetics and a couple of diagnostic messages.


# 1.50 01-Dec-1999 augustss

Done something half sensible if a USB console keyboard is unplugged instead
of panic()ing.
XXX Untested. I will test it the next time I can borrow an iMac.


# 1.49 26-Nov-1999 augustss

Cosmetic changes.


Revision tags: fvdl-softdep-base
# 1.48 12-Nov-1999 mjacob

Hide function definition within ifdef's is becomes active in.


# 1.47 12-Nov-1999 augustss

A number of stylistic changes to increase readability (many suggested
by Nick Hibma):
use NULL not 0
declare all local definitions static
rename s/usbd_request/usbd_xfer/ s/reqh/xfer/
rename s/r/err/
use implicit test for no err
KNF


Revision tags: comdex-fall-1999-base
# 1.46 13-Oct-1999 augustss

branches: 1.46.2; 1.46.4;
Merge in a large batch of changes from Nick Hibma <hibma@skylink.it> so
the USB stack compiles on FreeBSD again.


# 1.45 12-Oct-1999 augustss

Add an event mechanism so that a userland process can watch devices come
and go.


# 1.44 12-Sep-1999 augustss

branches: 1.44.2;
Dot't forget to deactivate subdevices.


# 1.43 05-Sep-1999 augustss

Change the way the `struct device' base part of all driver softc are
declared and accessed to make it more portable. Idea from Nick Hibma, FreeBSD.
No functional changes.


# 1.42 04-Sep-1999 augustss

Change the way the direction is extracted from the endpoint descriptor.
No functional changes to the drivers. From Nick Hibma, FreeBSD.


# 1.41 28-Aug-1999 augustss

Change some 'struct device' to 'bdevice'. From FreeBSD.


# 1.40 23-Aug-1999 augustss

Make sure to mark the device as dying already in the (de)activate routine.
This avoids access to it before the detach routine has blown it away.


# 1.39 14-Aug-1999 augustss

Some changes from FreeBSD (no functional differences).


Revision tags: chs-ubc2-base
# 1.38 24-Jul-1999 augustss

More DIAGNOSTIC messages.


# 1.37 30-Jun-1999 augustss

Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.


# 1.36 26-Jun-1999 augustss

Remove unneeded #include.


# 1.35 14-Jun-1999 augustss

Get rid of a bunch of code that was part of an old USBDI proposal, but that
is unused in our USB stack.

Once upon a time, when I started writing the USB stack for NetBSD, there
was an effort to make a standard for how USB device drivers should interact
with the rest of the USB stack. This effort had contributors from just
about all Un*x camps (but not Micro$oft :). I based my design on one of their
early proposals since I thought it would be a good idea if we could all
share device drivers with a minimum effort. Shortly after I started my work
all the free Un*x people were thrown out of the USBDI work since we did not
pay the USB membership fee. Well, some time has passed now and the work of
the standardization group is almost public again. But alas, the new standard
has grown to be a monster! I do not want to have this as the basis for the
*BSD USB stack; it is far too complicated.
So, since we are not even close to being compilant with the standard, I've
thrown out some old baggage.


# 1.34 11-Jun-1999 wrstuden

If we're the console keyboard, automatically enable the keyboard.

Should fix part of console keyboard problems on macppc. The usb keyboard will
now work on boot! Doesn't fix problems with keyboard freaking out when
changing LED state.

Thanks to Mattias & Lennart & Tsubai for input on resolving this problem.


# 1.33 10-Jun-1999 augustss

Add more debug.


# 1.32 14-May-1999 augustss

Fix debug printf.


# 1.31 13-May-1999 thorpej

Rework the way ukbd attaches itself as the console (again). We now allow
the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on. Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>


# 1.30 09-May-1999 augustss

Call ws routines at spltty() from interrupt routines.


# 1.29 06-May-1999 thorpej

Add a way for machine-dependent code to tell a USB controller that it
has the console input device. The USB keyboard driver uses this to
attach the first USB keyboard instance as the console keyboard.

Unfortunately, this must still be deferred to autoconfiguration time,
but there's not much we can do about that right now.


Revision tags: netbsd-1-4-base
# 1.28 13-Jan-1999 augustss

branches: 1.28.2;
Fix transpostion in translation table for XT scan codes.


# 1.27 10-Jan-1999 augustss

Make sure to check the modifier map for the windows keys.


# 1.26 10-Jan-1999 augustss

Fix buglets in translation to raw scancodes.


# 1.25 10-Jan-1999 augustss

Update/add URLs to relevant USB specs.


# 1.24 10-Jan-1999 augustss

Move a declaration.


# 1.23 10-Jan-1999 augustss

Use a special map for USB key code translation instead of first translating
to an XT scancode and then to the wscons code.
XXX The XT translation is still available in "raw" mode.


# 1.22 09-Jan-1999 drochner

there is no "cnattach" member in "struct wskbd_accessops" (yet?)


# 1.21 08-Jan-1999 augustss

Various little fixes from the FreeBSD version.


# 1.20 30-Dec-1998 augustss

Implement autorepeat in raw keyboard mode.


# 1.19 30-Dec-1998 augustss

Implement raw keyboard mode for X.


# 1.18 29-Dec-1998 augustss

Add some #if 0 code for keyboard console attachment.


# 1.17 28-Dec-1998 augustss

Cosmetics.


# 1.16 26-Dec-1998 augustss

Merge changes to make the USB stack work with FreeBSD. The original
diffs from Nick Hibma <n_hibma@freebsd.org>, but with substantial
changes from me.
XXX Not tested on FreeBSD yet.


# 1.15 10-Dec-1998 augustss

Take care of some lines > 80 chars.


Revision tags: kenh-if-detach-base
# 1.14 09-Dec-1998 augustss

Improvement to the ugen driver.
Better error checking.
Some code rearrengment.


# 1.13 02-Dec-1998 augustss

Even shorter printfs at attach.


# 1.12 02-Dec-1998 augustss

Avoid wrapping lines in attach printfs.


# 1.11 25-Nov-1998 augustss

Make the copyright header conform to the NetBSD template.


Revision tags: chs-ubc-base
# 1.10 17-Sep-1998 drochner

Adapt to keymap table format change.


# 1.9 02-Aug-1998 augustss

Use wskbd enable function.


# 1.8 02-Aug-1998 drochner

Adapt to wskbd interface changes; add dummy enable/disable function.


# 1.7 01-Aug-1998 augustss

Make sure to abort the interrupt pipe on disconnect of a mouse or keyboard.
Improve some error messages.


# 1.6 01-Aug-1998 augustss

Switch from a global flag to tell if the host controller should use
polling to a local one for each controller.


# 1.5 01-Aug-1998 augustss

Complete the scancode conversion table.
Tell the keyboard not to send idle reports.


Revision tags: eeh-paddr_t-base
# 1.4 29-Jul-1998 augustss

Add functions to execute asynchronous requests and use these from
interrupt context.
[I had some feline debugging help here. I noticed that every time Kem,
our kitty, jumped onto the USB keyboard the machine crashed.]


# 1.3 26-Jul-1998 augustss

A first stab att supporting console access with a USB keyboard.


# 1.2 25-Jul-1998 augustss

Add wscons attachments for USB keyboard.


# 1.1 12-Jul-1998 augustss

Add USB support. Supported so far:
* UHCI and OHCI host controllers on PCI
* Hubs
* HID devices withe special drivers for mouse and keyboard
* Printers