Re: ucc(4): consumer control keyboard device driver

2021-08-24 Thread Anton Lindqvist
Hi,

On Fri, Aug 20, 2021 at 10:48:28PM -0700, David Rinehart wrote:
> I use usbhidaction, a little differently:
> 
> - OBSD media server in office, connected to speakers
> 
> - Custom microservice on media server, to control volume
> 
> - When I am docked at startup (detected in .xsession), configure:
> 
>   - Set AUDIODEVICE to office media server for sndio
> 
>   - Use usbhidaction to send volume and mute commands to media
> center microservice
> 
> This setup works incredibly well - and I would never have considered it
> with other OSs.  I would have tried to rig a headphone jack and
> splitter or something.  Current config just uses the network.
> 
> Since I have other OBSD media servers around the house, I can easily
> change the address and send audio & control to other rooms.
> 
> Wondering if my custom config will still be possible with ucc...

I'm afraid it won't work with your setup. As I understand things, you're
reacting to certain buttons and relaying the associated action to your
media server using usbhidaction? I see two alternatives:

1. Disable ucc completely keeping your old setup intact.

2. Wondering if one could write a small X11 utility that listens for
   keyboard input and reacts to certian keys like XF86AudioMute. This
   requires some trivial tweak to ucc as it currently does not emit any
   scan codes for the volume related usages in raw mode.



Re: ucc(4): consumer control keyboard device driver

2021-08-21 Thread Alessandro De Laurenzis

Hello Anton,

I applied your patch to a recent snapshot; my HID keyboard is an 
"oldish" Logitech K400 that I regularly use with the following 
usbhidaction config file:



Consumer:Bass 1
sndioctl -f $1 output.mute=!
Consumer:0x00eb 1
sndioctl -f $1 output.level=-0.05
Consumer:Volume_Decrement 1
sndioctl -f $1 output.level=+0.05


(yes, the buttons have very fancy labels...)

None of the multimedia keys work when the device is attached to ucc driver.

Please find enclosed the dmesg with (UCC_DEBUG enabled) and without the 
patch; I pressed all keys multiple times and disabled hotplugd (which 
launches usbhidaction), just to avoid any interference; I also detached 
and reattached the keyboard.


Cheers


On 17/08/2021 20:13, Anton Lindqvist wrote:

Hi,
Here's a new driver for USB HID Consumer Control keyboards. Such
keyboard is a pseudo device which is used to expose audio and
application launch keys. My prime motivation is to get the volume mute,
increment and decrement keys to just work on my keyboard without the
need to use usbhidaction(1).

ucc(4) attaches a wskbd(4) keyboard "on top" making it appear like an
ordinary keyboard, which also makes it possible to inject key
press/release input. It supports both translating and raw mode making it
compatible with the ordinary console and X11.

My keyboard for instance exposes 42 keys in its input report. I only
care about the volume and audio related ones and therefore only added
mappings for those. Additional mappings should be trivial to add if
desired.

Testing would be much appreciated.

Comments? OK?

diff --git share/man/man4/Makefile share/man/man4/Makefile
index 6a0ecb20653..63b33660159 100644
--- share/man/man4/Makefile
+++ share/man/man4/Makefile
@@ -84,7 +84,7 @@ MAN=  aac.4 abcrtc.4 abl.4 ac97.4 acphy.4 acrtc.4 \
tlphy.4 thmc.4 tpm.4 tpmr.4 tqphy.4 trm.4 trunk.4 tsl.4 tty.4 \
tun.4 tap.4 twe.4 \
txp.4 txphy.4 uaudio.4 uark.4 uath.4 ubcmtp.4 uberry.4 ubsa.4 \
-   ubsec.4 ucom.4 uchcom.4 ucrcom.4 ucycom.4 ukspan.4 uslhcom.4 \
+   ubsec.4 ucc.4 ucom.4 uchcom.4 ucrcom.4 ucycom.4 ukspan.4 uslhcom.4 \
udav.4 udcf.4 udl.4 udp.4 udsbr.4 \
uftdi.4 ugen.4 ugl.4 ugold.4 uguru.4 uhci.4 uhid.4 uhidev.4 uhidpp.4 \
uipaq.4 ujoy.4 uk.4 ukbd.4 \
diff --git share/man/man4/ucc.4 share/man/man4/ucc.4
new file mode 100644
index 000..413c88aa6af
--- /dev/null
+++ share/man/man4/ucc.4
@@ -0,0 +1,45 @@
+.\"   $OpenBSD$
+.\"
+.\" Copyright (c) 2021 Anton Lindqvist 
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.Dd $Mdocdate$
+.Dt UCC 4
+.Os
+.Sh NAME
+.Nm ucc
+.Nd Consumer Control keyboards
+.Sh SYNOPSIS
+.Cd "ucc* at uhidev?"
+.Cd "wsbkd* at ucc? mux 1"
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for Consumer Control pseudo keyboards, often used to
+expose audio and application launch keys.
+.Sh SEE ALSO
+.Xr intro 4 ,
+.Xr uhidev 4 ,
+.Xr usb 4 ,
+.Xr wskbd 4
+.Sh HISTORY
+The
+.Nm
+driver first appeared in
+.Ox 7.0 .
+.Sh AUTHORS
+The
+.Nm
+driver was written by
+.An Anton Lindqvist Aq Mt an...@openbsd.org .
diff --git share/man/man4/uhidev.4 share/man/man4/uhidev.4
index 02252789a3f..d398c564bd5 100644
--- share/man/man4/uhidev.4
+++ share/man/man4/uhidev.4
@@ -37,6 +37,7 @@
  .Sh SYNOPSIS
  .Cd "uhidev*  at uhub?"
  .Cd "fido*at uhidev?"
+.Cd "ucc* at uhidev?"
  .Cd "ucycom*  at uhidev?"
  .Cd "ugold*   at uhidev?"
  .Cd "uhid*at uhidev?"
@@ -72,6 +73,7 @@ only dispatches data to them based on the report id.
  .Sh SEE ALSO
  .Xr fido 4 ,
  .Xr intro 4 ,
+.Xr ucc 4 ,
  .Xr ucycom 4 ,
  .Xr ugold 4 ,
  .Xr uhid 4 ,
diff --git share/man/man4/usb.4 share/man/man4/usb.4
index dad3d3a97d9..d159d8b27f3 100644
--- share/man/man4/usb.4
+++ share/man/man4/usb.4
@@ -249,6 +249,8 @@ D-Link DSB-R100 USB radio device
  FIDO/U2F security keys
  .It Xr ubcmtp 4
  Broadcom trackpad mouse
+.It Xr ucc 4
+USB Consumer Control keyboards
  .It Xr ugold 4
  TEMPer gold HID thermometer and hygrometer
  .It Xr uhid 4
diff --git sys/arch/alpha/conf/GENERIC sys/arch/alpha/conf/GENERIC
index 8af652ce301..54d4a45cd4e 100644
--- sys/arch/alpha/conf/GENERIC
+++ sys/arch/alpha/conf/GENERIC
@@ -107,6 +107,8 @@ uslhcom* at uhidev? # Silicon Labs CP2110 
USB HID UART
  ucom* at uslhcom?

Re: ucc(4): consumer control keyboard device driver

2021-08-21 Thread David Rinehart
I use usbhidaction, a little differently:

- OBSD media server in office, connected to speakers

- Custom microservice on media server, to control volume

- When I am docked at startup (detected in .xsession), configure:

- Set AUDIODEVICE to office media server for sndio

- Use usbhidaction to send volume and mute commands to media
  center microservice

This setup works incredibly well - and I would never have considered it
with other OSs.  I would have tried to rig a headphone jack and
splitter or something.  Current config just uses the network.

Since I have other OBSD media servers around the house, I can easily
change the address and send audio & control to other rooms.

Wondering if my custom config will still be possible with ucc...


On 8/18/21 10:24 AM, Florian Obser wrote:
> My microsoft sculpt has a bunch of media keys. I tried mute and
> increment / decrement. They don't seem to have an effect.
>
> --- dmesg.bootWed Aug 18 19:19:07 2021
> +++ dmesg.boot.uccWed Aug 18 19:19:16 2021
> @@ -1,7 +1,7 @@
> -OpenBSD 7.0-beta (GENERIC.MP) #131: Wed Aug 18 10:18:06 CEST 2021
> +OpenBSD 7.0-beta (GENERIC.MP) #132: Wed Aug 18 13:41:45 CEST 2021
>  florian@x1:/usr/src/sys/arch/amd64/compile/GENERIC.MP
>  real mem = 8266944512 (7883MB)
> -avail mem = 8000442368 (7629MB)
> +avail mem = 8000446464 (7629MB)
>  random: good seed from bootblocks
>  mpath0 at root
>  scsibus0 at mpath0: 256 targets
> @@ -122,21 +122,21 @@
>  uhidev1 at uhub0 port 2 configuration 1 interface 1 "Microsoft Microsoft\M-. 
> 2.4GHz Transceiver v9.0" rev 2.00/7.97 addr 2
>  uhidev1: iclass 3/1, 26 report ids
>  uhid0 at uhidev1 reportid 18: input=0, output=0, feature=1
> -uhid1 at uhidev1 reportid 23: input=0, output=0, feature=1
> +ucc0 at uhidev1 reportid 23 hid error 6
>  ums0 at uhidev1 reportid 26: 5 buttons, Z and W dir
>  wsmouse2 at ums0 mux 0
>  uhidev2 at uhub0 port 2 configuration 1 interface 2 "Microsoft Microsoft\M-. 
> 2.4GHz Transceiver v9.0" rev 2.00/7.97 addr 2
>  uhidev2: iclass 3/0, 39 report ids
> -uhid2 at uhidev2 reportid 3: input=1, output=0, feature=0
> -uhid3 at uhidev2 reportid 7: input=7, output=0, feature=0
> -uhid4 at uhidev2 reportid 32: input=0, output=0, feature=18
> -uhid5 at uhidev2 reportid 33: input=2, output=0, feature=0
> -uhid6 at uhidev2 reportid 34: input=0, output=0, feature=26
> -uhid7 at uhidev2 reportid 35: input=0, output=0, feature=26
> -uhid8 at uhidev2 reportid 36: input=0, output=0, feature=31
> -uhid9 at uhidev2 reportid 37: input=0, output=0, feature=31
> -uhid10 at uhidev2 reportid 38: input=0, output=0, feature=31
> -uhid11 at uhidev2 reportid 39: input=31, output=0, feature=0
> +uhid1 at uhidev2 reportid 3: input=1, output=0, feature=0
> +ucc1 at uhidev2 reportid 7 keys 1, mappings 0
> +uhid2 at uhidev2 reportid 32: input=0, output=0, feature=18
> +uhid3 at uhidev2 reportid 33: input=2, output=0, feature=0
> +uhid4 at uhidev2 reportid 34: input=0, output=0, feature=26
> +uhid5 at uhidev2 reportid 35: input=0, output=0, feature=26
> +uhid6 at uhidev2 reportid 36: input=0, output=0, feature=31
> +uhid7 at uhidev2 reportid 37: input=0, output=0, feature=31
> +uhid8 at uhidev2 reportid 38: input=0, output=0, feature=31
> +ucc2 at uhidev2 reportid 39 keys 1, mappings 0
>  umb0 at uhub0 port 4 configuration 1 interface 0 "Sierra Wireless Inc. 
> Sierra Wireless EM7345 4G LTE" rev 2.00/17.29 addr 3
>  umodem0 at uhub0 port 4 configuration 1 interface 2 "Sierra Wireless Inc. 
> Sierra Wireless EM7345 4G LTE" rev 2.00/17.29 addr 3
>  umodem0: data interface 3, has no CM over data, has break
> @@ -145,12 +145,12 @@
>  uhub2 at uhub1 port 1 configuration 1 interface 0 "Intel Rate Matching Hub" 
> rev 2.00/0.04 addr 2
>  uhidev3 at uhub2 port 5 configuration 1 interface 0 "ELAN Touchscreen" rev 
> 2.00/0.12 addr 3
>  uhidev3: iclass 3/0, 68 report ids
> -uhid12 at uhidev3 reportid 1: input=115, output=0, feature=0
> -uhid13 at uhidev3 reportid 2: input=64, output=0, feature=0
> -uhid14 at uhidev3 reportid 3: input=0, output=31, feature=0
> -uhid15 at uhidev3 reportid 4: input=19, output=0, feature=0
> -uhid16 at uhidev3 reportid 10: input=0, output=0, feature=1
> -uhid17 at uhidev3 reportid 68: input=0, output=0, feature=255
> +uhid9 at uhidev3 reportid 1: input=115, output=0, feature=0
> +uhid10 at uhidev3 reportid 2: input=64, output=0, feature=0
> +uhid11 at uhidev3 reportid 3: input=0, output=31, feature=0
> +uhid12 at uhidev3 reportid 4: input=19, output=0, feature=0
> +uhid13 at uhidev3 reportid 10: input=0, output=0, feature=1
> +uhid14 at uhidev3 reportid 68: input=0, output=0, feature=255
>  uvideo0 at uhub2 port 8 configuration 1 interface 0 "Chicony Electronics 
> Co.,Ltd. Integrated Camera" rev 2.00/25.09 addr 4
>  video0 at uvideo0
>  vscsi0 at root
>
>
> dmesg.boot.ucc:
> OpenBSD 7.0-beta (GENERIC.MP) #132: Wed Aug 18 13:41:45 CEST 2021
> florian@x1:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> real mem = 8266944512 (7883MB)
> avail me

Re: ucc(4): consumer control keyboard device driver

2021-08-19 Thread Anton Lindqvist
On Wed, Aug 18, 2021 at 12:01:53PM -0500, joshua stein wrote:
> On Wed, 18 Aug 2021 at 18:48:45 +0200, Martin Pieuchot wrote:
> > Regarding the introduction of a separate wskbd(4) this can be seen as an
> > intermediate step.  Having this logic in ukbd(4) implies revisiting the
> > way reportID are mapped to USB drivers, which is still a bit of a hack
> > when it comes to supporting multiple of them.  Having a simpler driver
> > like ucc(4) can help us figure out out to support more "special" keys
> > without having to deal with the HID logic at the same time.
> > 
> > It would be great if users of usbhidaction(1) could tell us if this
> > introduce any regression and/or if other keys could be supported.
> 
> I used usbhidaction for a Bluetooth audio device that supported 
> passing button presses through.
> 
> https://jcs.org/2020/11/18/openbsd_btaudio#responding-to-headphone-buttons
> 
> $ cat .usbhidaction.conf
> Consumer:Play/Pause 1
> ~/bin/music playpause
> 
> Due to the lack of an XF86Audio* keysym that is both "play/pause", 
> ucc can only map it to just XF86AudioPlay.  It's no big deal for me 
> to adapt though, and I'm happy to see a driver do all of this 
> automatically.
> 
> Though it would be nice to find a way to pass any unsupported 
> buttons through, even if they are just no-named keysyms that would 
> at least allow a program to bind/react to them.

I'm currently looking into what hid-input in Linux does while
encountering unknown keys.



Re: ucc(4): consumer control keyboard device driver

2021-08-18 Thread Florian Obser
My microsoft sculpt has a bunch of media keys. I tried mute and
increment / decrement. They don't seem to have an effect.

--- dmesg.boot  Wed Aug 18 19:19:07 2021
+++ dmesg.boot.ucc  Wed Aug 18 19:19:16 2021
@@ -1,7 +1,7 @@
-OpenBSD 7.0-beta (GENERIC.MP) #131: Wed Aug 18 10:18:06 CEST 2021
+OpenBSD 7.0-beta (GENERIC.MP) #132: Wed Aug 18 13:41:45 CEST 2021
 florian@x1:/usr/src/sys/arch/amd64/compile/GENERIC.MP
 real mem = 8266944512 (7883MB)
-avail mem = 8000442368 (7629MB)
+avail mem = 8000446464 (7629MB)
 random: good seed from bootblocks
 mpath0 at root
 scsibus0 at mpath0: 256 targets
@@ -122,21 +122,21 @@
 uhidev1 at uhub0 port 2 configuration 1 interface 1 "Microsoft Microsoft\M-. 
2.4GHz Transceiver v9.0" rev 2.00/7.97 addr 2
 uhidev1: iclass 3/1, 26 report ids
 uhid0 at uhidev1 reportid 18: input=0, output=0, feature=1
-uhid1 at uhidev1 reportid 23: input=0, output=0, feature=1
+ucc0 at uhidev1 reportid 23 hid error 6
 ums0 at uhidev1 reportid 26: 5 buttons, Z and W dir
 wsmouse2 at ums0 mux 0
 uhidev2 at uhub0 port 2 configuration 1 interface 2 "Microsoft Microsoft\M-. 
2.4GHz Transceiver v9.0" rev 2.00/7.97 addr 2
 uhidev2: iclass 3/0, 39 report ids
-uhid2 at uhidev2 reportid 3: input=1, output=0, feature=0
-uhid3 at uhidev2 reportid 7: input=7, output=0, feature=0
-uhid4 at uhidev2 reportid 32: input=0, output=0, feature=18
-uhid5 at uhidev2 reportid 33: input=2, output=0, feature=0
-uhid6 at uhidev2 reportid 34: input=0, output=0, feature=26
-uhid7 at uhidev2 reportid 35: input=0, output=0, feature=26
-uhid8 at uhidev2 reportid 36: input=0, output=0, feature=31
-uhid9 at uhidev2 reportid 37: input=0, output=0, feature=31
-uhid10 at uhidev2 reportid 38: input=0, output=0, feature=31
-uhid11 at uhidev2 reportid 39: input=31, output=0, feature=0
+uhid1 at uhidev2 reportid 3: input=1, output=0, feature=0
+ucc1 at uhidev2 reportid 7 keys 1, mappings 0
+uhid2 at uhidev2 reportid 32: input=0, output=0, feature=18
+uhid3 at uhidev2 reportid 33: input=2, output=0, feature=0
+uhid4 at uhidev2 reportid 34: input=0, output=0, feature=26
+uhid5 at uhidev2 reportid 35: input=0, output=0, feature=26
+uhid6 at uhidev2 reportid 36: input=0, output=0, feature=31
+uhid7 at uhidev2 reportid 37: input=0, output=0, feature=31
+uhid8 at uhidev2 reportid 38: input=0, output=0, feature=31
+ucc2 at uhidev2 reportid 39 keys 1, mappings 0
 umb0 at uhub0 port 4 configuration 1 interface 0 "Sierra Wireless Inc. Sierra 
Wireless EM7345 4G LTE" rev 2.00/17.29 addr 3
 umodem0 at uhub0 port 4 configuration 1 interface 2 "Sierra Wireless Inc. 
Sierra Wireless EM7345 4G LTE" rev 2.00/17.29 addr 3
 umodem0: data interface 3, has no CM over data, has break
@@ -145,12 +145,12 @@
 uhub2 at uhub1 port 1 configuration 1 interface 0 "Intel Rate Matching Hub" 
rev 2.00/0.04 addr 2
 uhidev3 at uhub2 port 5 configuration 1 interface 0 "ELAN Touchscreen" rev 
2.00/0.12 addr 3
 uhidev3: iclass 3/0, 68 report ids
-uhid12 at uhidev3 reportid 1: input=115, output=0, feature=0
-uhid13 at uhidev3 reportid 2: input=64, output=0, feature=0
-uhid14 at uhidev3 reportid 3: input=0, output=31, feature=0
-uhid15 at uhidev3 reportid 4: input=19, output=0, feature=0
-uhid16 at uhidev3 reportid 10: input=0, output=0, feature=1
-uhid17 at uhidev3 reportid 68: input=0, output=0, feature=255
+uhid9 at uhidev3 reportid 1: input=115, output=0, feature=0
+uhid10 at uhidev3 reportid 2: input=64, output=0, feature=0
+uhid11 at uhidev3 reportid 3: input=0, output=31, feature=0
+uhid12 at uhidev3 reportid 4: input=19, output=0, feature=0
+uhid13 at uhidev3 reportid 10: input=0, output=0, feature=1
+uhid14 at uhidev3 reportid 68: input=0, output=0, feature=255
 uvideo0 at uhub2 port 8 configuration 1 interface 0 "Chicony Electronics 
Co.,Ltd. Integrated Camera" rev 2.00/25.09 addr 4
 video0 at uvideo0
 vscsi0 at root


dmesg.boot.ucc:
OpenBSD 7.0-beta (GENERIC.MP) #132: Wed Aug 18 13:41:45 CEST 2021
florian@x1:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 8266944512 (7883MB)
avail mem = 8000446464 (7629MB)
random: good seed from bootblocks
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xdcd3c000 (57 entries)
bios0: vendor LENOVO version "GRET40WW (1.17 )" date 09/02/2014
bios0: LENOVO 20A7006VUS
acpi0 at bios0: ACPI 5.0
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP SLIC ASF! DBGP ECDT HPET APIC MCFG SSDT SSDT SSDT SSDT 
SSDT SSDT UEFI MSDM BATB FPDT UEFI DMAR
acpi0: wakeup devices LID_(S4) SLPB(S3) IGBE(S4) EXP2(S4) XHCI(S3) EHC1(S3)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpiec0 at acpi0
acpihpet0 at acpi0: 14318179 Hz
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i7-4600U CPU @ 2.10GHz, 1995.71 MHz, 06-45-01
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PC

Re: ucc(4): consumer control keyboard device driver

2021-08-18 Thread Paco Esteban
On Wed, 18 Aug 2021, Stuart Henderson wrote:

> On 2021/08/18 18:48, Martin Pieuchot wrote:
> > Regarding the introduction of a separate wskbd(4) this can be seen as an
> > intermediate step.  Having this logic in ukbd(4) implies revisiting the
> > way reportID are mapped to USB drivers, which is still a bit of a hack
> > when it comes to supporting multiple of them.
> 
> Talking of this, paco@ (cc'd) should send the lsusb from his USB-C dock...

This is the output of lsusb with the USB-C that sthen is talking about
attached.  Dmesg also for convenience.

https://e1e0.net/paste/lsusb.txt
https://e1e0.net/paste/dmesg_p14s.txt

For the record, the HDMI output works if an actual monitor is attached
and is shown on xrandr as "DisplayPort-1".  Display Port is not
recognized, nor is the network interface or the audio interface.  The
USB hub(s) work ok.

I can do some tests if you want.  Just send patches my way and I can
provide the output you need.

Cheers,

-- 
Paco Esteban.
0x5818130B8A6DBC03



Re: ucc(4): consumer control keyboard device driver

2021-08-18 Thread joshua stein
On Wed, 18 Aug 2021 at 18:48:45 +0200, Martin Pieuchot wrote:
> Regarding the introduction of a separate wskbd(4) this can be seen as an
> intermediate step.  Having this logic in ukbd(4) implies revisiting the
> way reportID are mapped to USB drivers, which is still a bit of a hack
> when it comes to supporting multiple of them.  Having a simpler driver
> like ucc(4) can help us figure out out to support more "special" keys
> without having to deal with the HID logic at the same time.
> 
> It would be great if users of usbhidaction(1) could tell us if this
> introduce any regression and/or if other keys could be supported.

I used usbhidaction for a Bluetooth audio device that supported 
passing button presses through.

https://jcs.org/2020/11/18/openbsd_btaudio#responding-to-headphone-buttons

$ cat .usbhidaction.conf
Consumer:Play/Pause 1
~/bin/music playpause

Due to the lack of an XF86Audio* keysym that is both "play/pause", 
ucc can only map it to just XF86AudioPlay.  It's no big deal for me 
to adapt though, and I'm happy to see a driver do all of this 
automatically.

Though it would be nice to find a way to pass any unsupported 
buttons through, even if they are just no-named keysyms that would 
at least allow a program to bind/react to them.



Re: ucc(4): consumer control keyboard device driver

2021-08-18 Thread Stuart Henderson
On 2021/08/18 18:48, Martin Pieuchot wrote:
> Regarding the introduction of a separate wskbd(4) this can be seen as an
> intermediate step.  Having this logic in ukbd(4) implies revisiting the
> way reportID are mapped to USB drivers, which is still a bit of a hack
> when it comes to supporting multiple of them.

Talking of this, paco@ (cc'd) should send the lsusb from his USB-C dock...



Re: ucc(4): consumer control keyboard device driver

2021-08-18 Thread Martin Pieuchot
On 18/08/21(Wed) 17:50, Mark Kettenis wrote:
> > Date: Tue, 17 Aug 2021 20:13:41 +0200
> > From: Anton Lindqvist 
> > 
> > Hi,
> > 
> > Here's a new driver for USB HID Consumer Control keyboards. Such
> > keyboard is a pseudo device which is used to expose audio and
> > application launch keys. My prime motivation is to get the volume mute,
> > increment and decrement keys to just work on my keyboard without the
> > need to use usbhidaction(1).
> > 
> > ucc(4) attaches a wskbd(4) keyboard "on top" making it appear like an
> > ordinary keyboard, which also makes it possible to inject key
> > press/release input. It supports both translating and raw mode making it
> > compatible with the ordinary console and X11.
> > 
> > My keyboard for instance exposes 42 keys in its input report. I only
> > care about the volume and audio related ones and therefore only added
> > mappings for those. Additional mappings should be trivial to add if
> > desired.
> > 
> > Testing would be much appreciated.
> > 
> > Comments? OK?
> 
> So the downside of this is that you get a separate wskbd(4) device for
> these.  This will be transparent for most users thanks to wsmux(4),
> but it does mean that doing a multi-seat wscons setup becomes a little
> bit more involved.  That's fine with me as I don't think that's an
> important use case for OpenBSD.
>
> This looks reasonable to me.

I agree.  I am also very happy to see a kernel driver that makes things
work out-of-the-box.

Regarding the introduction of a separate wskbd(4) this can be seen as an
intermediate step.  Having this logic in ukbd(4) implies revisiting the
way reportID are mapped to USB drivers, which is still a bit of a hack
when it comes to supporting multiple of them.  Having a simpler driver
like ucc(4) can help us figure out out to support more "special" keys
without having to deal with the HID logic at the same time.

It would be great if users of usbhidaction(1) could tell us if this
introduce any regression and/or if other keys could be supported.

I'm definitively ok with this direction.

> > diff --git share/man/man4/Makefile share/man/man4/Makefile
> > index 6a0ecb20653..63b33660159 100644
> > --- share/man/man4/Makefile
> > +++ share/man/man4/Makefile
> > @@ -84,7 +84,7 @@ MAN=  aac.4 abcrtc.4 abl.4 ac97.4 acphy.4 acrtc.4 \
> > tlphy.4 thmc.4 tpm.4 tpmr.4 tqphy.4 trm.4 trunk.4 tsl.4 tty.4 \
> > tun.4 tap.4 twe.4 \
> > txp.4 txphy.4 uaudio.4 uark.4 uath.4 ubcmtp.4 uberry.4 ubsa.4 \
> > -   ubsec.4 ucom.4 uchcom.4 ucrcom.4 ucycom.4 ukspan.4 uslhcom.4 \
> > +   ubsec.4 ucc.4 ucom.4 uchcom.4 ucrcom.4 ucycom.4 ukspan.4 uslhcom.4 \
> > udav.4 udcf.4 udl.4 udp.4 udsbr.4 \
> > uftdi.4 ugen.4 ugl.4 ugold.4 uguru.4 uhci.4 uhid.4 uhidev.4 uhidpp.4 \
> > uipaq.4 ujoy.4 uk.4 ukbd.4 \
> > diff --git share/man/man4/ucc.4 share/man/man4/ucc.4
> > new file mode 100644
> > index 000..413c88aa6af
> > --- /dev/null
> > +++ share/man/man4/ucc.4
> > @@ -0,0 +1,45 @@
> > +.\"$OpenBSD$
> > +.\"
> > +.\" Copyright (c) 2021 Anton Lindqvist 
> > +.\"
> > +.\" Permission to use, copy, modify, and distribute this software for any
> > +.\" purpose with or without fee is hereby granted, provided that the above
> > +.\" copyright notice and this permission notice appear in all copies.
> > +.\"
> > +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 
> > WARRANTIES
> > +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
> > +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
> > +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
> > +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
> > +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
> > +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> > +.\"
> > +.Dd $Mdocdate$
> > +.Dt UCC 4
> > +.Os
> > +.Sh NAME
> > +.Nm ucc
> > +.Nd Consumer Control keyboards
> > +.Sh SYNOPSIS
> > +.Cd "ucc* at uhidev?"
> > +.Cd "wsbkd* at ucc? mux 1"
> > +.Sh DESCRIPTION
> > +The
> > +.Nm
> > +driver provides support for Consumer Control pseudo keyboards, often used 
> > to
> > +expose audio and application launch keys.
> > +.Sh SEE ALSO
> > +.Xr intro 4 ,
> > +.Xr uhidev 4 ,
> > +.Xr usb 4 ,
> > +.Xr wskbd 4
> > +.Sh HISTORY
> > +The
> > +.Nm
> > +driver first appeared in
> > +.Ox 7.0 .
> > +.Sh AUTHORS
> > +The
> > +.Nm
> > +driver was written by
> > +.An Anton Lindqvist Aq Mt an...@openbsd.org .
> > diff --git share/man/man4/uhidev.4 share/man/man4/uhidev.4
> > index 02252789a3f..d398c564bd5 100644
> > --- share/man/man4/uhidev.4
> > +++ share/man/man4/uhidev.4
> > @@ -37,6 +37,7 @@
> >  .Sh SYNOPSIS
> >  .Cd "uhidev*  at uhub?"
> >  .Cd "fido*at uhidev?"
> > +.Cd "ucc* at uhidev?"
> >  .Cd "ucycom*  at uhidev?"
> >  .Cd "ugold*   at uhidev?"
> >  .Cd "uhid*at uhidev?"
> > @@ -72,6 +73,7 @@ only dispatches data to them based on the report id.
> >  .Sh SEE 

Re: ucc(4): consumer control keyboard device driver

2021-08-18 Thread Mark Kettenis
> Date: Tue, 17 Aug 2021 20:13:41 +0200
> From: Anton Lindqvist 
> 
> Hi,
> 
> Here's a new driver for USB HID Consumer Control keyboards. Such
> keyboard is a pseudo device which is used to expose audio and
> application launch keys. My prime motivation is to get the volume mute,
> increment and decrement keys to just work on my keyboard without the
> need to use usbhidaction(1).
> 
> ucc(4) attaches a wskbd(4) keyboard "on top" making it appear like an
> ordinary keyboard, which also makes it possible to inject key
> press/release input. It supports both translating and raw mode making it
> compatible with the ordinary console and X11.
> 
> My keyboard for instance exposes 42 keys in its input report. I only
> care about the volume and audio related ones and therefore only added
> mappings for those. Additional mappings should be trivial to add if
> desired.
> 
> Testing would be much appreciated.
> 
> Comments? OK?

So the downside of this is that you get a separate wskbd(4) device for
these.  This will be transparent for most users thanks to wsmux(4),
but it does mean that doing a multi-seat wscons setup becomes a little
bit more involved.  That's fine with me as I don't think that's an
important use case for OpenBSD.

This looks reasonable to me.


> diff --git share/man/man4/Makefile share/man/man4/Makefile
> index 6a0ecb20653..63b33660159 100644
> --- share/man/man4/Makefile
> +++ share/man/man4/Makefile
> @@ -84,7 +84,7 @@ MAN=aac.4 abcrtc.4 abl.4 ac97.4 acphy.4 acrtc.4 \
>   tlphy.4 thmc.4 tpm.4 tpmr.4 tqphy.4 trm.4 trunk.4 tsl.4 tty.4 \
>   tun.4 tap.4 twe.4 \
>   txp.4 txphy.4 uaudio.4 uark.4 uath.4 ubcmtp.4 uberry.4 ubsa.4 \
> - ubsec.4 ucom.4 uchcom.4 ucrcom.4 ucycom.4 ukspan.4 uslhcom.4 \
> + ubsec.4 ucc.4 ucom.4 uchcom.4 ucrcom.4 ucycom.4 ukspan.4 uslhcom.4 \
>   udav.4 udcf.4 udl.4 udp.4 udsbr.4 \
>   uftdi.4 ugen.4 ugl.4 ugold.4 uguru.4 uhci.4 uhid.4 uhidev.4 uhidpp.4 \
>   uipaq.4 ujoy.4 uk.4 ukbd.4 \
> diff --git share/man/man4/ucc.4 share/man/man4/ucc.4
> new file mode 100644
> index 000..413c88aa6af
> --- /dev/null
> +++ share/man/man4/ucc.4
> @@ -0,0 +1,45 @@
> +.\"  $OpenBSD$
> +.\"
> +.\" Copyright (c) 2021 Anton Lindqvist 
> +.\"
> +.\" Permission to use, copy, modify, and distribute this software for any
> +.\" purpose with or without fee is hereby granted, provided that the above
> +.\" copyright notice and this permission notice appear in all copies.
> +.\"
> +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
> +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
> +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
> +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
> +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
> +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
> +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> +.\"
> +.Dd $Mdocdate$
> +.Dt UCC 4
> +.Os
> +.Sh NAME
> +.Nm ucc
> +.Nd Consumer Control keyboards
> +.Sh SYNOPSIS
> +.Cd "ucc* at uhidev?"
> +.Cd "wsbkd* at ucc? mux 1"
> +.Sh DESCRIPTION
> +The
> +.Nm
> +driver provides support for Consumer Control pseudo keyboards, often used to
> +expose audio and application launch keys.
> +.Sh SEE ALSO
> +.Xr intro 4 ,
> +.Xr uhidev 4 ,
> +.Xr usb 4 ,
> +.Xr wskbd 4
> +.Sh HISTORY
> +The
> +.Nm
> +driver first appeared in
> +.Ox 7.0 .
> +.Sh AUTHORS
> +The
> +.Nm
> +driver was written by
> +.An Anton Lindqvist Aq Mt an...@openbsd.org .
> diff --git share/man/man4/uhidev.4 share/man/man4/uhidev.4
> index 02252789a3f..d398c564bd5 100644
> --- share/man/man4/uhidev.4
> +++ share/man/man4/uhidev.4
> @@ -37,6 +37,7 @@
>  .Sh SYNOPSIS
>  .Cd "uhidev*  at uhub?"
>  .Cd "fido*at uhidev?"
> +.Cd "ucc* at uhidev?"
>  .Cd "ucycom*  at uhidev?"
>  .Cd "ugold*   at uhidev?"
>  .Cd "uhid*at uhidev?"
> @@ -72,6 +73,7 @@ only dispatches data to them based on the report id.
>  .Sh SEE ALSO
>  .Xr fido 4 ,
>  .Xr intro 4 ,
> +.Xr ucc 4 ,
>  .Xr ucycom 4 ,
>  .Xr ugold 4 ,
>  .Xr uhid 4 ,
> diff --git share/man/man4/usb.4 share/man/man4/usb.4
> index dad3d3a97d9..d159d8b27f3 100644
> --- share/man/man4/usb.4
> +++ share/man/man4/usb.4
> @@ -249,6 +249,8 @@ D-Link DSB-R100 USB radio device
>  FIDO/U2F security keys
>  .It Xr ubcmtp 4
>  Broadcom trackpad mouse
> +.It Xr ucc 4
> +USB Consumer Control keyboards
>  .It Xr ugold 4
>  TEMPer gold HID thermometer and hygrometer
>  .It Xr uhid 4
> diff --git sys/arch/alpha/conf/GENERIC sys/arch/alpha/conf/GENERIC
> index 8af652ce301..54d4a45cd4e 100644
> --- sys/arch/alpha/conf/GENERIC
> +++ sys/arch/alpha/conf/GENERIC
> @@ -107,6 +107,8 @@ uslhcom* at uhidev?   # Silicon Labs 
> CP2110 USB HID UART
>  ucom*at uslhcom?
>  uhid*at uhidev?  # USB generic HID support
>  fido*at uhidev?  # FIDO/U2F

Re: ucc(4): consumer control keyboard device driver

2021-08-17 Thread Anton Lindqvist
On Tue, Aug 17, 2021 at 10:08:35PM +0200, Paul de Weerd wrote:
> Hi Anton,
> 
> Thanks - I've applied your diff and built a kernel with it.  Full
> dmesg (both before and after) at the end of this mail, diff is:
> 
> -uhid2 at uhidev3 reportid 3: input=3, output=0, feature=0
> +ucc0 at uhidev3 reportid 3 keys 24, mappings 7
> +wskbd3 at ucc0 mux 1
> 
> -wskbd3 at ukbd2 mux 1
> -uhid3 at uhidev5 reportid 3: input=4, output=0, feature=0
> -uhid4 at uhidev5 reportid 4: input=1, output=0, feature=0
> -uhidpp0 at uhidev5 reportid 16
> +wskbd4 at ukbd2 mux 1
> +ucc1 at uhidev5 reportid 3 keys 0, mappings 0
> +uhid2 at uhidev5 reportid 4: input=1, output=0, feature=0
> +uhidpp0 at uhidev5 reportid 16
> 
> That is with this keyboard:
> 
> [weerd@pom] $ dmesg | grep Metadot
> uhidev2 at uhub3 port 4 configuration 1 interface 0 "Metadot - Das Keyboard 
> Das Keyboard" rev 2.00/1.00 addr 4
> uhidev3 at uhub3 port 4 configuration 1 interface 1 "Metadot - Das Keyboard 
> Das Keyboard" rev 2.00/1.00 addr 4
> [weerd@pom] $ usbdevs -v -a 04
> addr 04: 24f0:0140 Metadot - Das Keyboard, Das Keyboard
>  full speed, power 100 mA, config 1, rev 1.00
>  driver: uhidev2
>  driver: uhidev3
> 
> (there's a few more deltas that I'm leaving out due to an external
> AHCI controller not being detected).
> 
> Anyway, I see two ucc(4) devices - not sure why that is; assuming it's
> because the keyboard itself also shows up twice.  But at least the
> volume control works.  Playing an audio file with mpd and turning the
> big volume knob on my keyboard changes the volume (also indicated by
> sndioctl(1).  The 'mute' button doesn't do anything, but I may have to
> dig a bit more into how this works first.
> 
> I'll play around with this a bit more, but initial results look very
> promising - thanks for this new driver!

The second one is from your Logitech MX518 mouse. What would be helpful
is a raw dump of the USB HID report descriptor from both the mouse and
your keyboard. In order get the reports, one must boot a kernel without
ucc making the two devices attach as uhid as opposed of being matched by
ucc. Then run the following command once per device, the uhid numbers
are taken from your dmesg before applying the ucc diff:

# usbhidctl -f /dev/uhid2 -R >keyboard
# usbhidctl -f /dev/uhid3 -R >mouse

As for the mute button, could you enable UCC_DEBUG in dev/usb/ucc.c,
compile and install the new kernel, make sure to press the mute button
and then send me the dmesg output please.



Re: ucc(4): consumer control keyboard device driver

2021-08-17 Thread Paul de Weerd
Hi Anton,

Thanks - I've applied your diff and built a kernel with it.  Full
dmesg (both before and after) at the end of this mail, diff is:

-uhid2 at uhidev3 reportid 3: input=3, output=0, feature=0
+ucc0 at uhidev3 reportid 3 keys 24, mappings 7
+wskbd3 at ucc0 mux 1

-wskbd3 at ukbd2 mux 1
-uhid3 at uhidev5 reportid 3: input=4, output=0, feature=0
-uhid4 at uhidev5 reportid 4: input=1, output=0, feature=0
-uhidpp0 at uhidev5 reportid 16
+wskbd4 at ukbd2 mux 1
+ucc1 at uhidev5 reportid 3 keys 0, mappings 0
+uhid2 at uhidev5 reportid 4: input=1, output=0, feature=0
+uhidpp0 at uhidev5 reportid 16

That is with this keyboard:

[weerd@pom] $ dmesg | grep Metadot
uhidev2 at uhub3 port 4 configuration 1 interface 0 "Metadot - Das Keyboard Das 
Keyboard" rev 2.00/1.00 addr 4
uhidev3 at uhub3 port 4 configuration 1 interface 1 "Metadot - Das Keyboard Das 
Keyboard" rev 2.00/1.00 addr 4
[weerd@pom] $ usbdevs -v -a 04
addr 04: 24f0:0140 Metadot - Das Keyboard, Das Keyboard
 full speed, power 100 mA, config 1, rev 1.00
 driver: uhidev2
 driver: uhidev3

(there's a few more deltas that I'm leaving out due to an external
AHCI controller not being detected).

Anyway, I see two ucc(4) devices - not sure why that is; assuming it's
because the keyboard itself also shows up twice.  But at least the
volume control works.  Playing an audio file with mpd and turning the
big volume knob on my keyboard changes the volume (also indicated by
sndioctl(1).  The 'mute' button doesn't do anything, but I may have to
dig a bit more into how this works first.

I'll play around with this a bit more, but initial results look very
promising - thanks for this new driver!

Paul

--- dmesg before applying diff ---
OpenBSD 6.9-current (GENERIC.MP) #179: Wed Aug 11 22:49:10 MDT 2021
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 34243899392 (32657MB)
avail mem = 33190125568 (31652MB)
random: good seed from bootblocks
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xec410 (88 entries)
bios0: vendor Dell Inc. version "A25" date 05/30/2019
bios0: Dell Inc. OptiPlex 9020
acpi0 at bios0: ACPI 5.0
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP APIC FPDT SLIC LPIT SSDT SSDT SSDT HPET SSDT MCFG SSDT 
ASF! DMAR
acpi0: wakeup devices UAR1(S3) RP01(S4) PXSX(S4) PXSX(S4) PXSX(S4) RP05(S4) 
PXSX(S4) PXSX(S4) PXSX(S4) PXSX(S4) GLAN(S4) EHC1(S3) EHC2(S3) XHC_(S4) 
HDEF(S4) PEG0(S4) [...]
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 3691.99 MHz, 06-3c-03
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,TSC_ADJUST,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,SRBDS_CTRL,MD_CLEAR,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,MELTDOWN
cpu0: 256KB 64b/line 8-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges
cpu0: apic clock running at 99MHz
cpu0: mwait min=64, max=64, C-substates=0.2.1.2.4, IBE
cpu1 at mainbus0: apid 2 (application processor)
cpu1: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 3691.49 MHz, 06-3c-03
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,TSC_ADJUST,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,SRBDS_CTRL,MD_CLEAR,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,MELTDOWN
cpu1: 256KB 64b/line 8-way L2 cache
cpu1: smt 0, core 1, package 0
cpu2 at mainbus0: apid 4 (application processor)
cpu2: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 3691.48 MHz, 06-3c-03
cpu2: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,TSC_ADJUST,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,SRBDS_CTRL,MD_CLEAR,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,MELTDOWN
cpu2: 256KB 64b/line 8-way L2 cache
cpu2: smt 0, core 2, package 0
cpu3 at mainbus0: apid 6 (application processor)
cpu3: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 3691.48 MHz, 06-3c-03
cpu3: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTP

Re: ucc(4): consumer control keyboard device driver

2021-08-17 Thread Jason McIntyre
On Tue, Aug 17, 2021 at 08:13:41PM +0200, Anton Lindqvist wrote:
> Hi,
> Here's a new driver for USB HID Consumer Control keyboards. Such
> keyboard is a pseudo device which is used to expose audio and
> application launch keys. My prime motivation is to get the volume mute,
> increment and decrement keys to just work on my keyboard without the
> need to use usbhidaction(1).
> 
> ucc(4) attaches a wskbd(4) keyboard "on top" making it appear like an
> ordinary keyboard, which also makes it possible to inject key
> press/release input. It supports both translating and raw mode making it
> compatible with the ordinary console and X11.
> 
> My keyboard for instance exposes 42 keys in its input report. I only
> care about the volume and audio related ones and therefore only added
> mappings for those. Additional mappings should be trivial to add if
> desired.
> 
> Testing would be much appreciated.
> 
> Comments? OK?
> 

hi.

the doc parts look good.
jmc

> diff --git share/man/man4/Makefile share/man/man4/Makefile
> index 6a0ecb20653..63b33660159 100644
> --- share/man/man4/Makefile
> +++ share/man/man4/Makefile
> @@ -84,7 +84,7 @@ MAN=aac.4 abcrtc.4 abl.4 ac97.4 acphy.4 acrtc.4 \
>   tlphy.4 thmc.4 tpm.4 tpmr.4 tqphy.4 trm.4 trunk.4 tsl.4 tty.4 \
>   tun.4 tap.4 twe.4 \
>   txp.4 txphy.4 uaudio.4 uark.4 uath.4 ubcmtp.4 uberry.4 ubsa.4 \
> - ubsec.4 ucom.4 uchcom.4 ucrcom.4 ucycom.4 ukspan.4 uslhcom.4 \
> + ubsec.4 ucc.4 ucom.4 uchcom.4 ucrcom.4 ucycom.4 ukspan.4 uslhcom.4 \
>   udav.4 udcf.4 udl.4 udp.4 udsbr.4 \
>   uftdi.4 ugen.4 ugl.4 ugold.4 uguru.4 uhci.4 uhid.4 uhidev.4 uhidpp.4 \
>   uipaq.4 ujoy.4 uk.4 ukbd.4 \
> diff --git share/man/man4/ucc.4 share/man/man4/ucc.4
> new file mode 100644
> index 000..413c88aa6af
> --- /dev/null
> +++ share/man/man4/ucc.4
> @@ -0,0 +1,45 @@
> +.\"  $OpenBSD$
> +.\"
> +.\" Copyright (c) 2021 Anton Lindqvist 
> +.\"
> +.\" Permission to use, copy, modify, and distribute this software for any
> +.\" purpose with or without fee is hereby granted, provided that the above
> +.\" copyright notice and this permission notice appear in all copies.
> +.\"
> +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
> +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
> +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
> +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
> +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
> +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
> +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> +.\"
> +.Dd $Mdocdate$
> +.Dt UCC 4
> +.Os
> +.Sh NAME
> +.Nm ucc
> +.Nd Consumer Control keyboards
> +.Sh SYNOPSIS
> +.Cd "ucc* at uhidev?"
> +.Cd "wsbkd* at ucc? mux 1"
> +.Sh DESCRIPTION
> +The
> +.Nm
> +driver provides support for Consumer Control pseudo keyboards, often used to
> +expose audio and application launch keys.
> +.Sh SEE ALSO
> +.Xr intro 4 ,
> +.Xr uhidev 4 ,
> +.Xr usb 4 ,
> +.Xr wskbd 4
> +.Sh HISTORY
> +The
> +.Nm
> +driver first appeared in
> +.Ox 7.0 .
> +.Sh AUTHORS
> +The
> +.Nm
> +driver was written by
> +.An Anton Lindqvist Aq Mt an...@openbsd.org .
> diff --git share/man/man4/uhidev.4 share/man/man4/uhidev.4
> index 02252789a3f..d398c564bd5 100644
> --- share/man/man4/uhidev.4
> +++ share/man/man4/uhidev.4
> @@ -37,6 +37,7 @@
>  .Sh SYNOPSIS
>  .Cd "uhidev*  at uhub?"
>  .Cd "fido*at uhidev?"
> +.Cd "ucc* at uhidev?"
>  .Cd "ucycom*  at uhidev?"
>  .Cd "ugold*   at uhidev?"
>  .Cd "uhid*at uhidev?"
> @@ -72,6 +73,7 @@ only dispatches data to them based on the report id.
>  .Sh SEE ALSO
>  .Xr fido 4 ,
>  .Xr intro 4 ,
> +.Xr ucc 4 ,
>  .Xr ucycom 4 ,
>  .Xr ugold 4 ,
>  .Xr uhid 4 ,
> diff --git share/man/man4/usb.4 share/man/man4/usb.4
> index dad3d3a97d9..d159d8b27f3 100644
> --- share/man/man4/usb.4
> +++ share/man/man4/usb.4
> @@ -249,6 +249,8 @@ D-Link DSB-R100 USB radio device
>  FIDO/U2F security keys
>  .It Xr ubcmtp 4
>  Broadcom trackpad mouse
> +.It Xr ucc 4
> +USB Consumer Control keyboards
>  .It Xr ugold 4
>  TEMPer gold HID thermometer and hygrometer
>  .It Xr uhid 4
> diff --git sys/arch/alpha/conf/GENERIC sys/arch/alpha/conf/GENERIC
> index 8af652ce301..54d4a45cd4e 100644
> --- sys/arch/alpha/conf/GENERIC
> +++ sys/arch/alpha/conf/GENERIC
> @@ -107,6 +107,8 @@ uslhcom* at uhidev?   # Silicon Labs 
> CP2110 USB HID UART
>  ucom*at uslhcom?
>  uhid*at uhidev?  # USB generic HID support
>  fido*at uhidev?  # FIDO/U2F security key support
> +ucc* at uhidev?  # Consumer Control keyboards
> +wskbd*   at ucc? mux 1
>  ujoy*at uhidev?  # USB joystick/gamecontroller 
> support
>  uhidpp*  at uhidev?  # Logitech HID++ Devices
>  upd* at uhidev?

ucc(4): consumer control keyboard device driver

2021-08-17 Thread Anton Lindqvist
Hi,
Here's a new driver for USB HID Consumer Control keyboards. Such
keyboard is a pseudo device which is used to expose audio and
application launch keys. My prime motivation is to get the volume mute,
increment and decrement keys to just work on my keyboard without the
need to use usbhidaction(1).

ucc(4) attaches a wskbd(4) keyboard "on top" making it appear like an
ordinary keyboard, which also makes it possible to inject key
press/release input. It supports both translating and raw mode making it
compatible with the ordinary console and X11.

My keyboard for instance exposes 42 keys in its input report. I only
care about the volume and audio related ones and therefore only added
mappings for those. Additional mappings should be trivial to add if
desired.

Testing would be much appreciated.

Comments? OK?

diff --git share/man/man4/Makefile share/man/man4/Makefile
index 6a0ecb20653..63b33660159 100644
--- share/man/man4/Makefile
+++ share/man/man4/Makefile
@@ -84,7 +84,7 @@ MAN=  aac.4 abcrtc.4 abl.4 ac97.4 acphy.4 acrtc.4 \
tlphy.4 thmc.4 tpm.4 tpmr.4 tqphy.4 trm.4 trunk.4 tsl.4 tty.4 \
tun.4 tap.4 twe.4 \
txp.4 txphy.4 uaudio.4 uark.4 uath.4 ubcmtp.4 uberry.4 ubsa.4 \
-   ubsec.4 ucom.4 uchcom.4 ucrcom.4 ucycom.4 ukspan.4 uslhcom.4 \
+   ubsec.4 ucc.4 ucom.4 uchcom.4 ucrcom.4 ucycom.4 ukspan.4 uslhcom.4 \
udav.4 udcf.4 udl.4 udp.4 udsbr.4 \
uftdi.4 ugen.4 ugl.4 ugold.4 uguru.4 uhci.4 uhid.4 uhidev.4 uhidpp.4 \
uipaq.4 ujoy.4 uk.4 ukbd.4 \
diff --git share/man/man4/ucc.4 share/man/man4/ucc.4
new file mode 100644
index 000..413c88aa6af
--- /dev/null
+++ share/man/man4/ucc.4
@@ -0,0 +1,45 @@
+.\"$OpenBSD$
+.\"
+.\" Copyright (c) 2021 Anton Lindqvist 
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.Dd $Mdocdate$
+.Dt UCC 4
+.Os
+.Sh NAME
+.Nm ucc
+.Nd Consumer Control keyboards
+.Sh SYNOPSIS
+.Cd "ucc* at uhidev?"
+.Cd "wsbkd* at ucc? mux 1"
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for Consumer Control pseudo keyboards, often used to
+expose audio and application launch keys.
+.Sh SEE ALSO
+.Xr intro 4 ,
+.Xr uhidev 4 ,
+.Xr usb 4 ,
+.Xr wskbd 4
+.Sh HISTORY
+The
+.Nm
+driver first appeared in
+.Ox 7.0 .
+.Sh AUTHORS
+The
+.Nm
+driver was written by
+.An Anton Lindqvist Aq Mt an...@openbsd.org .
diff --git share/man/man4/uhidev.4 share/man/man4/uhidev.4
index 02252789a3f..d398c564bd5 100644
--- share/man/man4/uhidev.4
+++ share/man/man4/uhidev.4
@@ -37,6 +37,7 @@
 .Sh SYNOPSIS
 .Cd "uhidev*  at uhub?"
 .Cd "fido*at uhidev?"
+.Cd "ucc* at uhidev?"
 .Cd "ucycom*  at uhidev?"
 .Cd "ugold*   at uhidev?"
 .Cd "uhid*at uhidev?"
@@ -72,6 +73,7 @@ only dispatches data to them based on the report id.
 .Sh SEE ALSO
 .Xr fido 4 ,
 .Xr intro 4 ,
+.Xr ucc 4 ,
 .Xr ucycom 4 ,
 .Xr ugold 4 ,
 .Xr uhid 4 ,
diff --git share/man/man4/usb.4 share/man/man4/usb.4
index dad3d3a97d9..d159d8b27f3 100644
--- share/man/man4/usb.4
+++ share/man/man4/usb.4
@@ -249,6 +249,8 @@ D-Link DSB-R100 USB radio device
 FIDO/U2F security keys
 .It Xr ubcmtp 4
 Broadcom trackpad mouse
+.It Xr ucc 4
+USB Consumer Control keyboards
 .It Xr ugold 4
 TEMPer gold HID thermometer and hygrometer
 .It Xr uhid 4
diff --git sys/arch/alpha/conf/GENERIC sys/arch/alpha/conf/GENERIC
index 8af652ce301..54d4a45cd4e 100644
--- sys/arch/alpha/conf/GENERIC
+++ sys/arch/alpha/conf/GENERIC
@@ -107,6 +107,8 @@ uslhcom* at uhidev? # Silicon Labs CP2110 
USB HID UART
 ucom*  at uslhcom?
 uhid*  at uhidev?  # USB generic HID support
 fido*  at uhidev?  # FIDO/U2F security key support
+ucc*   at uhidev?  # Consumer Control keyboards
+wskbd* at ucc? mux 1
 ujoy*  at uhidev?  # USB joystick/gamecontroller support
 uhidpp*at uhidev?  # Logitech HID++ Devices
 upd*   at uhidev?  # USB Power Devices sensors
diff --git sys/arch/amd64/conf/GENERIC sys/arch/amd64/conf/GENERIC
index c0c16f7c986..0d278739ccf 100644
--- sys/arch/amd64/conf/GENERIC
+++ sys/arch/amd64/conf/GENERIC
@@ -286,6 +286,8 @@ uslhcom* at uhidev? # Silicon Labs CP2110 USB HID 
UART
 ucom*  at uslhcom?
 uhid*  at uhidev?  # USB generic HID support
 fido*  at uhidev?