* [PATCH v2] input: amikbd: fix scancode to key code conversion
@ 2026-12-01 16:40 Steffen A. Mork
2026-12-01 22:10 ` Dmitry Torokhov
2026-12-01 22:10 ` Daniel Palmer
0 siblings, 2 replies; 3+ messages in thread
From: Steffen A. Mork @ 2026-12-01 16:40 UTC (permalink / raw)
To: Dmitry Torokhov, linux-input
Cc: Geert Uytterhoeven, linux-m68k, linux-kernel, stable,
Steffen A. Mork
Previously the amikbd.c driver passed raw Amiga keyboard scancodes via
input_report_key(). As a result incorrect key codes were transmitted to
libinput and the input event framework, while a remapping was
simultaneously being performed for the VT console via
amikbd_init_console_keymaps().
This patch corrects the transmission of these scancodes by ensuring that
the proper Linux key codes are passed to input_report_key() instead.
Consequently, the remapping for the console is no longer necessary.
The Atari keyboard driver atakbd.c served as a reference for implementing
this fix.
Tested-by: Steffen A. Mork <linux-dev@morknet.de> # native Amiga 2000
Tested-by: Steffen A. Mork <linux-dev@morknet.de> # FS-UAE virtual Amiga 3000
Fixes: 5fa28ea42f28 ("[PATCH] m68k: restore amikbd compatibility with 2.4")
Signed-off-by: Steffen A. Mork <linux-dev@morknet.de>
---
Changes in v2:
- Fix conditional compile issues.
---
drivers/input/keyboard/amikbd.c | 47 +++++++++------------------------
1 file changed, 12 insertions(+), 35 deletions(-)
diff --git a/drivers/input/keyboard/amikbd.c b/drivers/input/keyboard/amikbd.c
index ecfae0b0b6aa..02efa9ddd719 100644
--- a/drivers/input/keyboard/amikbd.c
+++ b/drivers/input/keyboard/amikbd.c
@@ -26,8 +26,7 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
MODULE_DESCRIPTION("Amiga keyboard driver");
MODULE_LICENSE("GPL");
-#ifdef CONFIG_VT
-static unsigned char amikbd_keycode[0x78] __initdata = {
+static unsigned short amikbd_keycode[0x78] = {
[0] = KEY_GRAVE,
[1] = KEY_1,
[2] = KEY_2,
@@ -126,32 +125,6 @@ static unsigned char amikbd_keycode[0x78] __initdata = {
[103] = KEY_RIGHTMETA
};
-static void __init amikbd_init_console_keymaps(void)
-{
- /* We can spare 512 bytes on stack for temp_map in init path. */
- unsigned short temp_map[NR_KEYS];
- int i, j;
-
- for (i = 0; i < MAX_NR_KEYMAPS; i++) {
- if (!key_maps[i])
- continue;
- memset(temp_map, 0, sizeof(temp_map));
- for (j = 0; j < 0x78; j++) {
- if (!amikbd_keycode[j])
- continue;
- temp_map[j] = key_maps[i][amikbd_keycode[j]];
- }
- for (j = 0; j < NR_KEYS; j++) {
- if (!temp_map[j])
- temp_map[j] = 0xf200;
- }
- memcpy(key_maps[i], temp_map, sizeof(temp_map));
- }
-}
-#else /* !CONFIG_VT */
-static inline void amikbd_init_console_keymaps(void) {}
-#endif /* !CONFIG_VT */
-
static const char *amikbd_messages[8] = {
[0] = KERN_ALERT "amikbd: Ctrl-Amiga-Amiga reset warning!!\n",
[1] = KERN_WARNING "amikbd: keyboard lost sync\n",
@@ -177,11 +150,13 @@ static irqreturn_t amikbd_interrupt(int irq, void *data)
scancode >>= 1;
if (scancode < 0x78) { /* scancodes < 0x78 are keys */
+ const unsigned short keycode = amikbd_keycode[scancode];
+
if (scancode == 98) { /* CapsLock is a toggle switch key on Amiga */
- input_report_key(dev, scancode, 1);
- input_report_key(dev, scancode, 0);
+ input_report_key(dev, keycode, 1);
+ input_report_key(dev, keycode, 0);
} else {
- input_report_key(dev, scancode, down);
+ input_report_key(dev, keycode, down);
}
input_sync(dev);
@@ -210,11 +185,13 @@ static int __init amikbd_probe(struct platform_device *pdev)
dev->id.version = 0x0100;
dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
+ dev->keycode = amikbd_keycode;
+ dev->keycodesize = sizeof(amikbd_keycode[0]);
+ dev->keycodemax = ARRAY_SIZE(amikbd_keycode);
- for (i = 0; i < 0x78; i++)
- set_bit(i, dev->keybit);
-
- amikbd_init_console_keymaps();
+ for (i = 0; i < dev->keycodemax; i++)
+ if (amikbd_keycode[i])
+ set_bit(amikbd_keycode[i], dev->keybit);
ciaa.cra &= ~0x41; /* serial data in, turn off TA */
err = devm_request_irq(&pdev->dev, IRQ_AMIGA_CIAA_SP, amikbd_interrupt,
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] input: amikbd: fix scancode to key code conversion
2026-12-01 16:40 [PATCH v2] input: amikbd: fix scancode to key code conversion Steffen A. Mork
@ 2026-12-01 22:10 ` Dmitry Torokhov
2026-12-01 22:10 ` Daniel Palmer
1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2026-12-01 22:10 UTC (permalink / raw)
To: Steffen A. Mork
Cc: linux-input, Geert Uytterhoeven, linux-m68k, linux-kernel, stable
Hi Steffen,
On Tue, Dec 01, 2026 at 05:40:21PM +0100, Steffen A. Mork wrote:
> Previously the amikbd.c driver passed raw Amiga keyboard scancodes via
> input_report_key(). As a result incorrect key codes were transmitted to
> libinput and the input event framework, while a remapping was
> simultaneously being performed for the VT console via
> amikbd_init_console_keymaps().
>
> This patch corrects the transmission of these scancodes by ensuring that
> the proper Linux key codes are passed to input_report_key() instead.
> Consequently, the remapping for the console is no longer necessary.
>
> The Atari keyboard driver atakbd.c served as a reference for implementing
> this fix.
>
> Tested-by: Steffen A. Mork <linux-dev@morknet.de> # native Amiga 2000
> Tested-by: Steffen A. Mork <linux-dev@morknet.de> # FS-UAE virtual Amiga 3000
> Fixes: 5fa28ea42f28 ("[PATCH] m68k: restore amikbd compatibility with 2.4")
> Signed-off-by: Steffen A. Mork <linux-dev@morknet.de>
Commit 5fa28ea42f28 was an intentional change in 2006 to keep 2.4 Amiga
console keymaps working, and Roman Zippel pushed back against switching
to standard Linux keycodes when this came up again in 2007:
https://lore.kernel.org/r/d120d5000705031217h64db0644qb1e8bc8d8af6e78c@mail.gmail.com
It has been the driver's behavior for 20 years now and changing it will
break setups still using existing Amiga keymaps. Unless Geert wants this
change, we should leave the driver alone.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] input: amikbd: fix scancode to key code conversion
2026-12-01 16:40 [PATCH v2] input: amikbd: fix scancode to key code conversion Steffen A. Mork
2026-12-01 22:10 ` Dmitry Torokhov
@ 2026-12-01 22:10 ` Daniel Palmer
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Palmer @ 2026-12-01 22:10 UTC (permalink / raw)
To: Steffen A. Mork
Cc: Dmitry Torokhov, linux-input, Geert Uytterhoeven, linux-m68k,
linux-kernel, stable
Hi Steffen,
On Wed, 2 Dec 2026 at 01:40, Steffen A. Mork <linux-dev@morknet.de> wrote:
>
> Previously the amikbd.c driver passed raw Amiga keyboard scancodes via
> input_report_key(). As a result incorrect key codes were transmitted to
> libinput and the input event framework, while a remapping was
> simultaneously being performed for the VT console via
> amikbd_init_console_keymaps().
I had he same-ish patch in my tree. For me the keyboard mostly worked
but pressing ESC sent F10 or something instead which made it
impossible to get into the menu for Quake and play the game :).
I pulled your patch and tested Quake still works so:
Tested-by: Daniel Palmer <daniel@thingy.jp> # Amiga 4000
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-01 22:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 16:40 [PATCH v2] input: amikbd: fix scancode to key code conversion Steffen A. Mork
2026-12-01 22:10 ` Dmitry Torokhov
2026-12-01 22:10 ` Daniel Palmer
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.