usb/181425: USB keyboard with full N-key rollover not working

2013-08-20 Thread Andrey Zholos

Number: 181425
Category:   usb
Synopsis:   USB keyboard with full N-key rollover not working
Confidential:   no
Severity:   non-critical
Priority:   low
Responsible:freebsd-usb
State:  open
Quarter:
Keywords:   
Date-Required:
Class:  sw-bug
Submitter-Id:   current-users
Arrival-Date:   Tue Aug 20 11:10:00 UTC 2013
Closed-Date:
Last-Modified:
Originator: Andrey Zholos
Release:FreeBSD 10.0-CURRENT #0 r254515
Organization:
Environment:
FreeBSD ukbd-test 10.0-CURRENT FreeBSD 10.0-CURRENT #0 r254515: Mon Aug 19 
15:58:40 EEST 2013 root@ukbd-test:/usr/obj/usr/src/sys/GENERIC  amd64
Description:
The keyboard I am using is a Max Keyboard Nighthawk X9. It features
full N-key rollover, which is supposed to allow pressing all keys at
once, so it reports all keys as a bitmap, rather than the usual 6-byte
array of keycodes. This confuses the ukbd driver.

The relevant part of dmesg with hw.usb.ukbd.debug=1:

ugen0.4: EST at usbus0
ukbd0: EST Gaming keyboard, class 0/0, rev 2.00/0.97, addr 3 on usbus0
ukbd_attach: Parsing HID descriptor of 65 bytes
ukbd_parse_hid: Found left control
ukbd_parse_hid: Found right control
ukbd_parse_hid: Found left shift
ukbd_parse_hid: Found right shift
ukbd_parse_hid: Found left alt
ukbd_parse_hid: Found right alt
ukbd_parse_hid: Found left GUI
ukbd_parse_hid: Found right GUI
ukbd_parse_hid: Found keyboard events
ukbd_parse_hid: Found keyboard numlock
ukbd_parse_hid: Found keyboard capslock
ukbd_parse_hid: Found keyboard scrolllock
ukbd_set_leds: leds=0x00
ukbd_set_leds: leds=0x00
kbd2 at ukbd0
ukbd_set_leds_callback: len=1, id=0
ukbd1: EST Gaming keyboard, class 0/0, rev 2.00/0.97, addr 3 on usbus0
ukbd_intr_callback: actlen=8 bytes
ukbd_intr_callback: modifiers = 0x
ukbd_attach: Parsing HID descriptor of 37 bytes
ukbd_parse_hid: Found left control
ukbd_parse_hid: Found right control
ukbd_parse_hid: Found left shift
ukbd_parse_hid: Found right shift
ukbd_parse_hid: Found left alt
ukbd_parse_hid: Found right alt
ukbd_parse_hid: Found left GUI
ukbd_parse_hid: Found right GUI
ukbd_parse_hid: Found keyboard events
ukbd_set_leds: leds=0x00
ukbd_set_leds: leds=0x00
kbd3 at ukbd1

Most keys don't work and show this:

ukbd_intr_callback: actlen=15 bytes
ukbd_intr_callback: modifiers = 0x
ukbd_intr_callback: actlen=15 bytes
ukbd_intr_callback: modifiers = 0x

Modifier keys (e.g. Ctrl) appear to work:

ukbd_intr_callback: actlen=15 bytes
ukbd_intr_callback: modifiers = 0x0001
ukbd_put_key: 0xe0 (224) pressed
ukbd_intr_callback: actlen=15 bytes
ukbd_intr_callback: modifiers = 0x
ukbd_put_key: 0x4e0 (1248) released

Multimedia keys don't do anything at all.

Special profile keys (e.g. Fn+PF1) also appear to work:

ukbd_intr_callback: actlen=8 bytes
ukbd_intr_callback: modifiers = 0x
ukbd_intr_callback: [0] = 0xf1
ukbd_put_key: 0xf1 (241) pressed
ukbd_intr_callback: actlen=8 bytes
ukbd_intr_callback: modifiers = 0x
ukbd_put_key: 0x4f1 (1265) released
ukbd_intr_callback: actlen=8 bytes
ukbd_intr_callback: modifiers = 0x

There are three HID descriptors:

# uhidd -D /dev/ugen0.4
ugen0.4[0]- Report descriptor dump:
USAGE PAGE Generic Desktop(0x1)
USAGE Keyboard(0x6)[Generic Desktop(0x1)]
COLLECTION Application(1)
  USAGE PAGE Keyboard(0x7)
  USAGE MINIMUM Keyboard LeftControl(224)
  USAGE MAXIMUM Keyboard Right GUI(231)
  LOGICAL MINIMUM 0
  LOGICAL MAXIMUM 1
  REPORT SIZE 1
  REPORT COUNT 8
  INPUT ( Data Variable Absolute ) (2)
  REPORT SIZE 8
  REPORT COUNT 1
  INPUT ( Const Array Absolute ) (1)
  USAGE PAGE Keyboard(0x7)
  USAGE MINIMUM Reserved (no event indicated)(0)
  USAGE MAXIMUM Unknown Usage(255)
  LOGICAL MINIMUM 0
  LOGICAL MAXIMUM 255
  REPORT SIZE 8
  REPORT COUNT 6
  INPUT ( Data Array Absolute ) (0)
  USAGE PAGE LEDs(0x8)
  USAGE MINIMUM Num Lock(1)
  USAGE MAXIMUM Scroll Lock(3)
  LOGICAL MAXIMUM 1
  REPORT SIZE 1
  REPORT COUNT 3
  OUTPUT ( Data Variable Absolute ) (2)
  REPORT COUNT 5
  OUTPUT ( Const Array Absolute ) (1)
END COLLECTION
ugen0.4[0]- Kernel driver is active
ugen0.4[0]- Abort attach since kernel driver is active
ugen0.4[0]- Please try running uhidd with option '-u' to detach the kernel 
drivers
ugen0.4[1]- Report descriptor dump:
USAGE PAGE Consumer(0xc)
USAGE Consumer Control(0x1)[Consumer(0xc)]
COLLECTION Application(1)

Re: usb/181425: USB keyboard with full N-key rollover not working

2013-08-20 Thread Hans Petter Selasky
The following reply was made to PR usb/181425; it has been noted by GNATS.

From: Hans Petter Selasky h...@bitfrost.no
To: Andrey Zholos a...@q-fu.com
Cc: freebsd-gnats-sub...@freebsd.org
Subject: Re: usb/181425: USB keyboard with full N-key rollover not working
Date: Tue, 20 Aug 2013 13:56:13 +0200

 Hi,
 
 Have you looked into the USB HID specification from USB.org regarding 
 this? I think USB keyboard stuff is explicitly defined. You are right 
 that we don't support more than a few simultaneously pressed keys, and 
 that would reguire a bit more changes in ukbd driver.
 
 Instead of applying a quirk, maybe ukbd.c could switch to boot-proto 
 automatically when HIO_VARIABLE is set? It is simply a so-called USB 
 control request.
 
 I'm not sure if it is better to use uhidd or ukbd for the purpose you 
 want to use the keyboard.
 
 Thank you for your investigation!
 
 --HPS
 
 
  Ideally I would like to get this keyboard to work in normal protocol
  with full rollover for perfectionist reasons, but I guess that would
  require too many changes to ukbd.c and introduce overhead for the
  majority of keyboards.
 
 
  Patch attached with submission follows:
 
  --- sys/dev/usb/input/ukbd.c (revision 254515)
  +++ sys/dev/usb/input/ukbd.c (working copy)
  @@ -1130,8 +1130,12 @@
   HID_USAGE2(HUP_KEYBOARD, 0x00),
   hid_input, 0, sc-sc_loc_events, flags,
   sc-sc_id_events)) {
  -sc-sc_flags |= UKBD_FLAG_EVENTS;
  -DPRINTFN(1, Found keyboard events\n);
  +if (flags  HIO_VARIABLE)
  +DPRINTFN(1, Ignoring key bitmap\n);
  +else {
  +sc-sc_flags |= UKBD_FLAG_EVENTS;
  +DPRINTFN(1, Found keyboard events\n);
  +}
   }
 
   /* figure out leds on keyboard */
 
 
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org


Re: usb/181425: USB keyboard with full N-key rollover not working

2013-08-20 Thread Mark Felder
I have an opposite problem on my Dell workstation: my keyboard with
N-key rollover doesn't work in BIOS or FreeBSD boot menu, but does work
after the kernel is loaded...

I didn't know keyboards could be problematic.
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org


Re: usb/181425: USB keyboard with full N-key rollover not working

2013-08-20 Thread Andrey Zholos
The following reply was made to PR usb/181425; it has been noted by GNATS.

From: Andrey Zholos a...@q-fu.com
To: Hans Petter Selasky h...@bitfrost.no
Cc: freebsd-gnats-sub...@freebsd.org
Subject: Re: usb/181425: USB keyboard with full N-key rollover not working
Date: Tue, 20 Aug 2013 16:12:25 +0300

  Have you looked into the USB HID specification from USB.org regarding 
  this? I think USB keyboard stuff is explicitly defined. You are right 
  that we don't support more than a few simultaneously pressed keys, and 
  that would reguire a bit more changes in ukbd driver.
 
 Yes, I looked, it was interesting. I was kind of disappointed
 afterwards when I realized that the drivers (not just the kernel but
 uhidd and Linux) supported just a specific subset of the possible
 descriptors.
 
  Instead of applying a quirk, maybe ukbd.c could switch to boot-proto 
  automatically when HIO_VARIABLE is set? It is simply a so-called USB 
  control request.
 
 Exactly! That's the point of the patch.
 
 The descriptor parser currently assumes that if a keyboard usage range
 starts at 0, then it must be an array of bytes. It should also make
 sure that flags doesn't have HIO_VARIABLE (check added by this patch),
 and maybe that sc_loc_events.size == 8.
 
 The actual switch to boot protocol happens at ukbd.c:1241 - not because
 of a quirk, but be because now, with this additional check,
 !(sc-sc_flags  UKBD_FLAG_EVENTS).
 
  I'm not sure if it is better to use uhidd or ukbd for the purpose you 
  want to use the keyboard.
 
 Probably uhidd is the best place for full rollover support. It's needed
 anyway to support the multimedia keys. But currently it makes the same
 assumptions as ukbd about the events buffer and so doesn't work.
 
 Of course, ukbd has to work with the keyboard at least in boot protocol,
 otherwise you need to use a different keyboard to install uhidd.
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org


Re: usb/181425: commit references a PR

2013-08-20 Thread dfilter service
The following reply was made to PR usb/181425; it has been noted by GNATS.

From: dfil...@freebsd.org (dfilter service)
To: bug-follo...@freebsd.org
Cc:  
Subject: Re: usb/181425: commit references a PR
Date: Tue, 20 Aug 2013 16:21:17 + (UTC)

 Author: hselasky
 Date: Tue Aug 20 16:21:05 2013
 New Revision: 254572
 URL: http://svnweb.freebsd.org/changeset/base/254572
 
 Log:
   Force keyboards which don't have the required
   HID fields to use the USB BOOT protocol for now.
   
   PR:  usb/181425
   Submitted by:Andrey Zholos a...@q-fu.com
   MFC after:   4 weeks
 
 Modified:
   head/sys/dev/usb/input/ukbd.c
 
 Modified: head/sys/dev/usb/input/ukbd.c
 ==
 --- head/sys/dev/usb/input/ukbd.c  Tue Aug 20 14:59:31 2013
(r254571)
 +++ head/sys/dev/usb/input/ukbd.c  Tue Aug 20 16:21:05 2013
(r254572)
 @@ -1130,8 +1130,12 @@ ukbd_parse_hid(struct ukbd_softc *sc, co
HID_USAGE2(HUP_KEYBOARD, 0x00),
hid_input, 0, sc-sc_loc_events, flags,
sc-sc_id_events)) {
 -  sc-sc_flags |= UKBD_FLAG_EVENTS;
 -  DPRINTFN(1, Found keyboard events\n);
 +  if (flags  HIO_VARIABLE) {
 +  DPRINTFN(1, Ignoring keyboard event control\n);
 +  } else {
 +  sc-sc_flags |= UKBD_FLAG_EVENTS;
 +  DPRINTFN(1, Found keyboard event array\n);
 +  }
}
  
/* figure out leds on keyboard */
 ___
 svn-src-...@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
 
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org


Alerts

2013-08-20 Thread Ruby Moss
Please  alerts  me  any   activityon  myaccounts.
thanks.
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to freebsd-usb-unsubscr...@freebsd.org