From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: "Hervé Poussineau" <hpoussin@reactos.org>, qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
qemu-ppc@nongnu.org, programmingkidx@gmail.com
Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH] adb: change handler only when recognized
Date: Tue, 09 Aug 2016 09:17:17 +1000 [thread overview]
Message-ID: <1470698237.3015.15.camel@kernel.crashing.org> (raw)
In-Reply-To: <1457789937-30923-1-git-send-email-hpoussin@reactos.org>
On Sat, 2016-03-12 at 14:38 +0100, Hervé Poussineau wrote:
> ADB devices must take new handler into account only when they
> recognize it.
> This lets operating systems probe for valid/invalid handles, to know
> device capabilities.
>
> Add a FIXME in keyboard handler, which should use a different
> translation
> table depending of the selected handler.
Ah interesting ! I was just debugging why my new via-pmu model in Qemu
makes the ADB mouse emulation not work, while I tracked it down to
problems in that area and started re-inventing ... your patch :-)
The other issue is we shouldn't let the device change address unless
it's one of the "special" handler IDs. MacOS 9 with a PMU tries to
send an oddball 3-bytes write to register 3 during boot to the mouse
(probably some Trackpad related magic) with "2" in the address field,
if we accept the address change, things go very wrong.
We should add support for handler 4 for the mouse at some point too
while we are at it (different protocol though reg 0 though).
I'll send a fixup patch to correctly ignore the address change for
now but I'll wait for you to rebase your patch for the rest.
Cheers,
Ben.
> Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
> ---
>
> This conflicts with some in-list patches, but may explain why
> translation tables are not
> correct, or don't work in all situations.
> I have another patch to add 3-button mouse support, but I'll wait for
> 2.7 merge window.
>
> hw/input/adb.c | 26 +++++++++++++++++++++++---
> 1 file changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/hw/input/adb.c b/hw/input/adb.c
> index f0ad0d4..82bfb05 100644
> --- a/hw/input/adb.c
> +++ b/hw/input/adb.c
> @@ -237,6 +237,7 @@ static int adb_kbd_poll(ADBDevice *d, uint8_t
> *obuf)
> if (keycode == 0xe0) {
> ext_keycode = 1;
> } else {
> + /* FIXME: take handler into account when translating
> keycode */
> if (ext_keycode)
> adb_keycode = pc_to_adb_keycode[keycode | 0x80];
> else
> @@ -283,9 +284,15 @@ static int adb_kbd_request(ADBDevice *d, uint8_t
> *obuf,
> d->devaddr = buf[1] & 0xf;
> break;
> default:
> - /* XXX: check this */
> d->devaddr = buf[1] & 0xf;
> - d->handler = buf[2];
> + /* we support handlers:
> + * 1: Apple Standard Keyboard
> + * 2: Apple Extended Keyboard (LShift = RShift)
> + * 3: Apple Extended Keyboard (LShift != RShift)
> + */
> + if (buf[2] == 1 || buf[2] == 2 || buf[2] == 3) {
> + d->handler = buf[2];
> + }
> break;
> }
> }
> @@ -492,8 +499,21 @@ static int adb_mouse_request(ADBDevice *d,
> uint8_t *obuf,
> d->devaddr = buf[1] & 0xf;
> break;
> default:
> - /* XXX: check this */
> d->devaddr = buf[1] & 0xf;
> + /* we support handlers:
> + * 0x01: Classic Apple Mouse Protocol / 100 cpi
> operations
> + * 0x02: Classic Apple Mouse Protocol / 200 cpi
> operations
> + * we don't support handlers (at least):
> + * 0x03: Mouse systems A3 trackball
> + * 0x04: Extended Apple Mouse Protocol
> + * 0x2f: Microspeed mouse
> + * 0x42: Macally
> + * 0x5f: Microspeed mouse
> + * 0x66: Microspeed mouse
> + */
> + if (buf[2] == 1 || buf[2] == 2) {
> + d->handler = buf[2];
> + }
> break;
> }
> }
next prev parent reply other threads:[~2016-08-08 23:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-12 13:38 [Qemu-devel] [PATCH] adb: change handler only when recognized Hervé Poussineau
2016-03-12 14:31 ` Programmingkid
2016-03-12 15:24 ` Mark Cave-Ayland
2016-03-12 17:44 ` Hervé Poussineau
2016-03-12 18:13 ` Programmingkid
2016-03-12 20:31 ` Hervé Poussineau
2016-03-13 16:06 ` Peter Maydell
2016-08-08 23:17 ` Benjamin Herrenschmidt [this message]
2016-08-09 0:11 ` [Qemu-devel] [Qemu-ppc] " BALATON Zoltan
2016-08-09 0:29 ` Benjamin Herrenschmidt
2016-08-09 1:31 ` BALATON Zoltan
2016-08-09 4:06 ` Benjamin Herrenschmidt
2016-08-09 9:35 ` Howard Spoelstra
2016-08-09 10:26 ` BALATON Zoltan
2016-08-09 11:49 ` Benjamin Herrenschmidt
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=1470698237.3015.15.camel@kernel.crashing.org \
--to=benh@kernel.crashing.org \
--cc=hpoussin@reactos.org \
--cc=peter.maydell@linaro.org \
--cc=programmingkidx@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.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;
as well as URLs for NNTP newsgroup(s).