From: Jan-Benedict Glaw <jbglaw@lug-owl.de>
To: Congjun Yang <congjuny@yahoo.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: keyboard raw mode
Date: Sat, 1 Jul 2006 11:55:41 +0200 [thread overview]
Message-ID: <20060701095541.GO26883@lug-owl.de> (raw)
In-Reply-To: <20060701050023.31696.qmail@web32009.mail.mud.yahoo.com>
[-- Attachment #1: Type: text/plain, Size: 3774 bytes --]
On Fri, 2006-06-30 22:00:23 -0700, Congjun Yang <congjuny@yahoo.com> wrote:
> The keyboard worked fine with kernel 2.4.7. If I put
> the keyboard in raw mode, I can receive the sequence
> "1d 9d 9d". A simple test can be done with "showkey
> -s". However, newer kernels seem to treat the second
> break code as a hardware error, which in my case it's
> not, and simply discard it.
This is because the whole user input handling was reworked in the mean
time.
For keyboards, things are like this:
* A low-level port driver implements a serial endpoint. For PCs,
this are the keyboard and aux channel of the keyboard controller
i8240. These are called serio ports.
* Protocol drivers can be hooked up to these serio ports and
communicate with the actual hardware. This is eg. a driver for AT
keyboards or a PS2 mouse.
* All protocol drivers (eg. the atkbd driver) will *never* ever
stuff the raw I/O anywhere. They interpret the stream and push
commonly used values into Linux's Input API. That is, if you press
the "A" button on *any* keyboard, all drivers will issue a KEY_A
event and never ever tell about the specific raw keycodes
received.
* If you talk to the old /dev/psaux interface, of if you use the raw
mode for keyboard reading, then the formerly issued KEY_A event is
translated back to the raw sequence. Of course, non-recognized
events (like two break codes) cannot be emulated, so this doesn't
work at all.
> While it's necessary to have a work around for certain
> hardwares that tender to produce such errors, but why
> would the fix be done at "raw" level? In raw mode, I
> would expect to receive whatever is generated from the
> keyboard, including possibly errors. If I decide to
> put the keyboard in raw mode, I assume the
> responsibility of handling raw data.
There's no direct raw level anymore; it's the result of emulation
these days.
There are two solutions:
* Throw away the atkbd driver. That means there's no more a
"keyboard" from the system point of view. Write a small daemon
that uses the serio_raw driver to get the raw I/O coming from the
keyboard and make it interpret it. Don't forget to also do atkbd's
work and parse the "normal" keyboard I/O, too, and issue the KEY_A
(and all the other) events to the kernel using the uinput driver.
* Write a filter driver for your keyboard. (Actually, write two.)
I've done that some time ago, with some luck you'll find it. If
not, that's probably lost (was just a test:-)
Such a driver is both, a protocol driver and a serio driver. As a
protocol driver, it accesses a serio port and relays the read data
to a second driver (which should in your case parse the MSR data
and relay it to some userland applications). Anything that's not
specific to the POS functions (non-standard beeps, MSC, barcode
scanner, background light, LCD display, ...) should be given back
to the first driver, which (serio half) also registers a new serio
port to be useable by atkbd.
I'm not sure what the best variant is. The first one is a bit easier
to implement, but if you fsck up your daemon, you no longer have a
keyboard:-) The second one is a bit harder to implement, but you can
reuse the atkbd driver. As I said, that was already written once and
proved to work.
MfG, JBG
--
Jan-Benedict Glaw jbglaw@lug-owl.de . +49-172-7608481 _ O _
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg _ _ O
für einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2006-07-01 9:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-01 5:00 keyboard raw mode Congjun Yang
2006-07-01 9:55 ` Jan-Benedict Glaw [this message]
2006-07-01 14:04 ` Dmitry Torokhov
2006-07-02 8:21 ` Congjun Yang
2006-07-02 15:11 ` Dmitry Torokhov
2006-07-03 20:07 ` Congjun Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060701095541.GO26883@lug-owl.de \
--to=jbglaw@lug-owl.de \
--cc=congjuny@yahoo.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox