[PATCH 1/3] platform/x86: panasonic-laptop: Handle CF-33 rotation-lock button
From: Hilgad Montelo
Date: Wed Aug 12 2026 - 22:57:45 EST
On the Panasonic Toughbook CF-33 the bezel "Rotation Lock" button does
not signal via ACPI notify like the other hotkeys. Instead the
embedded controller injects raw i8042/PS2 scancodes that alias the
real Left-GUI/Meta key:
press: e0 5b 65
release: e5 e0 db
e0 5b / e0 db are the standard AT scancode for the physical Left-GUI
key. The bare 65 / e5 bytes interleaved with them are not valid codes
for any real key and only ever appear as part of this vendor signal
(confirmed by tracing raw bytes crossing the i8042 port on the actual
hardware). Left unfiltered, this shows up as a spurious KEY_LEFTMETA +
KEY_F14 combo, which does nothing useful and can trigger desktop
environment Meta-key bindings on every press.
This driver already installs an i8042 filter (panasonic_i8042_filter)
to de-duplicate volume key events. Extend it with a small state
machine that recognizes and swallows the exact e0 5b 65 ... e5 e0 db
sequence, and emits a single debounced KEY_ROTATE_LOCK_TOGGLE event
instead. The 600ms debounce is needed because the EC repeats the
make/break unit every ~280-400ms for as long as the button is
physically held, which would otherwise fire multiple toggles for one
tap. If a byte sequence starts the same way but doesn't complete the
pattern, the buffered e0 5b bytes are replayed unfiltered, so a
genuine Left-GUI keypress is unaffected.
Verified on a CF-33 Mk1: each button press now produces exactly one
KEY_ROTATE_LOCK_TOGGLE pair, the plain keyboard device stays silent
during presses (no more stray LEFTMETA/F14), and GNOME's auto-rotate
lock correctly engages/disengages. Brightness and volume hotkeys are
unaffected.
Signed-off-by: Hilgad Montelo <hilgad.montelo@xxxxxxxxx>
---
drivers/platform/x86/panasonic-laptop.c | 75 ++++++++++++++++++++++++-
1 file changed, 74 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
index 719add7..730d7cb 100644
--- a/drivers/platform/x86/panasonic-laptop.c
+++ b/drivers/platform/x86/panasonic-laptop.c
@@ -127,6 +127,7 @@
#include <linux/init.h>
#include <linux/input.h>
#include <linux/input/sparse-keymap.h>
+#include <linux/jiffies.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
@@ -256,15 +257,81 @@ struct pcc_acpi {
/*
* On some Panasonic models the volume up / down / mute keys send duplicate
* keypress events over the PS/2 kbd interface, filter these out.
+ *
+ * On the CF-33 the bezel "Rotation Lock" button also signals over this same
+ * interface, instead of via an ACPI notify like the other hotkeys. It does
+ * so by injecting scancodes that alias the real Left-GUI/Meta key
+ * (e0 5b make / e0 db break), interleaved with a bare byte (0x65 / 0xe5)
+ * that no physical key on this keyboard uses. Left unfiltered this shows up
+ * as a bogus LEFTMETA+F14 combo. We recognize and swallow the whole
+ * sequence and emit a single debounced KEY_ROTATE_LOCK_TOGGLE instead; any
+ * byte that breaks the expected pattern is treated as a genuine key and
+ * replayed unfiltered.
*/
+enum rot_lock_state {
+ ROT_IDLE,
+ ROT_WAIT_65,
+ ROT_WAIT_E5,
+ ROT_WAIT_E0B,
+ ROT_WAIT_DB,
+};
+
static bool panasonic_i8042_filter(unsigned char data, unsigned char str,
struct serio *port, void *context)
{
+ struct pcc_acpi *pcc = context;
static bool extended;
+ static enum rot_lock_state rstate = ROT_IDLE;
+ static unsigned long last_toggle;
+ const unsigned long debounce = msecs_to_jiffies(600);
if (str & I8042_STR_AUXDATA)
return false;
+ switch (rstate) {
+ case ROT_WAIT_65:
+ if (data == 0x65) {
+ rstate = ROT_WAIT_E5;
+ if (pcc && pcc->input_dev &&
+ time_after(jiffies, last_toggle + debounce)) {
+ input_report_key(pcc->input_dev,
+ KEY_ROTATE_LOCK_TOGGLE, 1);
+ input_sync(pcc->input_dev);
+ input_report_key(pcc->input_dev,
+ KEY_ROTATE_LOCK_TOGGLE, 0);
+ input_sync(pcc->input_dev);
+ last_toggle = jiffies;
+ }
+ return true;
+ }
+ /* Not our sequence: replay the buffered genuine Left-GUI make. */
+ rstate = ROT_IDLE;
+ serio_interrupt(port, 0xe0, 0);
+ serio_interrupt(port, 0x5b, 0);
+ break;
+ case ROT_WAIT_E5:
+ if (data == 0xe5) {
+ rstate = ROT_WAIT_E0B;
+ return true;
+ }
+ rstate = ROT_IDLE;
+ break;
+ case ROT_WAIT_E0B:
+ if (data == 0xe0) {
+ rstate = ROT_WAIT_DB;
+ return true;
+ }
+ rstate = ROT_IDLE;
+ break;
+ case ROT_WAIT_DB:
+ rstate = ROT_IDLE;
+ if (data == 0xdb)
+ return true;
+ break;
+ case ROT_IDLE:
+ break;
+ }
+
if (data == 0xe0) {
extended = true;
return true;
@@ -276,6 +343,9 @@ static bool panasonic_i8042_filter(unsigned char data, unsigned char str,
case 0x2e: /* e0 2e / e0 ae, Volume Down press / release */
case 0x30: /* e0 30 / e0 b0, Volume Up press / release */
return true;
+ case 0x5b: /* e0 5b, possible start of rotate-lock sequence */
+ rstate = ROT_WAIT_65;
+ return true;
default:
/*
* Report the previously filtered e0 before continuing
@@ -944,6 +1014,9 @@ static int acpi_pcc_init_input(struct pcc_acpi *pcc)
goto err_free_dev;
}
+ /* Synthesized by panasonic_i8042_filter(), not part of the ACPI keymap. */
+ input_set_capability(input_dev, EV_KEY, KEY_ROTATE_LOCK_TOGGLE);
+
error = input_register_device(input_dev);
if (error) {
pr_err("Unable to register input device\n");
@@ -1090,7 +1163,7 @@ static int acpi_pcc_hotkey_probe(struct platform_device *pdev)
pcc->platform = NULL;
}
- i8042_install_filter(panasonic_i8042_filter, NULL);
+ i8042_install_filter(panasonic_i8042_filter, pcc);
return 0;
out_platform:
--
2.53.0