Sync GTK4/libadwaita/Qt/Tk gtkTtk themes, add Tcl/Tk, and fix lid-close input leak
- Extend geminux-sync-gtk-theme and geminux-apply-theme to synchronize GTK4/libadwaita (dconf + ADW_DISABLE_PORTAL=1), qt6ct (QT_QPA_PLATFORMTHEME=qt6ct:gtk3), Kvantum, and live classic/ttk Tk apps - Preinstall dconf, gtk+2.0, tcl, tcl-lib, tcl-tls, tk, and custom zero-glycin geminux-gtkttk (GtkTtk 0.9 with XImage blitting, RESOURCE_MANAGER live reload, and *TkTheme: gtkTtk) - Add kernel patch 0011 to open gemini-lid keyboard/touchscreen handles for synchronous raw Hall GPIO66 input filtering, inhibit SSD2092 touch while closed, and set 1 ms hall-switch / 10 ms keyboard-matrix debounce in DT
This commit is contained in:
1 parent
16fcaaaba6
commit
983d529ec3
87 files changed
+10943
-45
No files matched your search
@@ -0,0 +1,304 @@
|
||||
From: Geminux <geminux@localhost>
|
||||
Subject: [PATCH 11/11] Input: gemini-lid - synchronous Hall GPIO filter, touch inhibit, and debounce tuning
|
||||
|
||||
When closing the Gemini PDA clamshell lid, the outer edge of the display
|
||||
bezel physically depresses exposed home-row/outer keycaps (Left Shift, A,
|
||||
Space, Right Shift, L, backslash/apostrophe) against the glass.
|
||||
|
||||
Three timing and filtering gaps allowed those spurious keypresses (such as
|
||||
"A L \") and touches to reach the active X11 terminal before SW_LID
|
||||
inhibited the keypad and before geminux-lock grabbed the keyboard:
|
||||
|
||||
1. In DT, hall-switch used a 64 ms debounce-interval while keyboard-matrix
|
||||
had no debounce-delay-ms (0 ms), letting AW9523 row interrupts report
|
||||
key presses 64 ms ahead of SW_LID = 1. Reduce hall-switch hardware EINT
|
||||
debounce to 1 ms (<1>, preserving EINT debounce entries for S3 wakeup
|
||||
clearing) and add standard 10 ms switch debounce to /keyboard-matrix.
|
||||
2. gemini-lid never called input_open_device() on the keyboard handle, so
|
||||
input_pass_values() skipped gemini_lid_filter() on keyboard events
|
||||
(because handle->open == 0) and relied solely on asynchronous workqueue
|
||||
inhibition (~19 ms later).
|
||||
3. gemini-lid did not track or inhibit the SSD2092/NT36772 touchscreen.
|
||||
|
||||
Fix gemini-lid to open its matched keyboard and touchscreen handles for
|
||||
synchronous filtering in event_lock, sample raw Hall GPIO66 (active-low)
|
||||
directly inside gemini_lid_filter() whenever lid_armed is set so key
|
||||
presses/repeats, MSC_SCAN, and touch events are dropped immediately on lid
|
||||
closure (while letting key releases and EV_SYN pass), and inhibit both
|
||||
the matrix keypad and touchscreen while closed.
|
||||
|
||||
---
|
||||
diff --git a/arch/arm64/boot/dts/mediatek/mt6797-gemini-pda-geminux.dts b/arch/arm64/boot/dts/mediatek/mt6797-gemini-pda-geminux.dts
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt6797-gemini-pda-geminux.dts 2026-11-25 19:06:56.532365631 +0200
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt6797-gemini-pda-geminux.dts 2026-11-25 19:06:56.532414713 +0200
|
||||
@@ -210,6 +210,14 @@
|
||||
|
||||
&hall_gpio_keys {
|
||||
status = "okay";
|
||||
+
|
||||
+ hall-switch {
|
||||
+ debounce-interval = <1>;
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&{/keyboard-matrix} {
|
||||
+ debounce-delay-ms = <10>;
|
||||
};
|
||||
|
||||
&{/i2c@11007000/charger@6b} {
|
||||
diff --git a/drivers/input/misc/gemini-lid.c b/drivers/input/misc/gemini-lid.c
|
||||
--- a/drivers/input/misc/gemini-lid.c 2026-11-25 19:06:56.532586357 +0200
|
||||
+++ b/drivers/input/misc/gemini-lid.c 2026-11-25 19:06:56.532627083 +0200
|
||||
@@ -2,13 +2,17 @@
|
||||
/*
|
||||
* Gemini PDA lid policy. The lid closes the keyboard against the screen, so
|
||||
* while it is closed, power the backlight down, blank the console, which turns
|
||||
- * the display off under a DRM driver, and inhibit the built-in keyboard: the input core closes it, the matrix scan stops and its row
|
||||
- * interrupts are masked. Nothing happens until the lid has been seen open
|
||||
- * once, so a lid that reads closed at boot cannot lock the keyboard out.
|
||||
+ * the display off under a DRM driver, filter lid-close presses synchronously
|
||||
+ * via the Hall GPIO, and inhibit the built-in keyboard and touchscreen.
|
||||
+ * Nothing happens until the lid has been seen open once, so a lid that reads
|
||||
+ * closed at boot cannot lock input out.
|
||||
*/
|
||||
|
||||
#include <linux/backlight.h>
|
||||
#include <linux/console.h>
|
||||
+#include <linux/fwnode.h>
|
||||
+#include <linux/gpio/consumer.h>
|
||||
+#include <linux/gpio/driver.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mutex.h>
|
||||
@@ -17,26 +21,38 @@
|
||||
#include <linux/vt_kern.h>
|
||||
#include <linux/workqueue.h>
|
||||
|
||||
+#define GEMINI_HALL_GPIO 66
|
||||
+
|
||||
+#define GEMINI_LID_KEYBOARD ((void *)1)
|
||||
+#define GEMINI_LID_TOUCHSCREEN ((void *)2)
|
||||
+
|
||||
static bool lid_armed;
|
||||
static bool lid_closed;
|
||||
|
||||
-/* The built-in keyboard, and no further changes once the module exits. */
|
||||
+/* Built-in input devices, Hall GPIO handle, and module exit guard. */
|
||||
static DEFINE_MUTEX(lid_lock);
|
||||
static struct input_dev *lid_keyboard;
|
||||
+static struct input_dev *lid_touchscreen;
|
||||
+static struct gpio_device *hall_gdev;
|
||||
+static struct gpio_desc *hall_gpiod;
|
||||
static bool lid_exiting;
|
||||
static bool lid_applied_closed;
|
||||
|
||||
static void gemini_lid_apply(bool closed)
|
||||
{
|
||||
struct backlight_device *bd = backlight_device_get_by_type(BACKLIGHT_RAW);
|
||||
- int err = 0;
|
||||
+ int kbd_err = 0, ts_err = 0;
|
||||
|
||||
if (lid_keyboard)
|
||||
- err = closed ? input_inhibit_device(lid_keyboard) :
|
||||
- input_uninhibit_device(lid_keyboard);
|
||||
- pr_info("gemini-lid: lid %s, keyboard %s %d\n",
|
||||
+ kbd_err = closed ? input_inhibit_device(lid_keyboard) :
|
||||
+ input_uninhibit_device(lid_keyboard);
|
||||
+ if (lid_touchscreen)
|
||||
+ ts_err = closed ? input_inhibit_device(lid_touchscreen) :
|
||||
+ input_uninhibit_device(lid_touchscreen);
|
||||
+ pr_info("gemini-lid: lid %s, keyboard %s %d, touch %s %d\n",
|
||||
closed ? "closed" : "open",
|
||||
- lid_keyboard ? (closed ? "inhibited" : "restored") : "absent", err);
|
||||
+ lid_keyboard ? (closed ? "inhibited" : "restored") : "absent", kbd_err,
|
||||
+ lid_touchscreen ? (closed ? "inhibited" : "restored") : "absent", ts_err);
|
||||
/* Open: the display first, so the backlight doesn't light a sleeping panel. */
|
||||
if (!closed) {
|
||||
console_lock();
|
||||
@@ -92,15 +108,45 @@
|
||||
"gpio-matrix-keypad");
|
||||
}
|
||||
|
||||
+static bool gemini_lid_is_touchscreen(struct input_dev *dev)
|
||||
+{
|
||||
+ return dev->dev.parent &&
|
||||
+ of_device_is_compatible(dev->dev.parent->of_node,
|
||||
+ "novatek,nt36772-ts");
|
||||
+}
|
||||
+
|
||||
+static bool gemini_lid_raw_closed(void)
|
||||
+{
|
||||
+ /* Hall GPIO66 is GPIO_ACTIVE_LOW: raw 0 means lid magnet is closed. */
|
||||
+ return hall_gpiod && gpiod_get_raw_value(hall_gpiod) == 0;
|
||||
+}
|
||||
+
|
||||
static bool gemini_lid_filter(struct input_handle *handle, unsigned int type,
|
||||
unsigned int code, int value)
|
||||
{
|
||||
- if (handle->private || type != EV_SW || code != SW_LID)
|
||||
+ if (handle->private) {
|
||||
+ if (!READ_ONCE(lid_armed))
|
||||
+ return false;
|
||||
+ if (!READ_ONCE(lid_closed)) {
|
||||
+ if (!gemini_lid_raw_closed())
|
||||
+ return false;
|
||||
+ WRITE_ONCE(lid_closed, true);
|
||||
+ queue_work(system_freezable_wq, &gemini_lid_work);
|
||||
+ }
|
||||
+ /* Allow key releases and EV_SYN through so no held key sticks. */
|
||||
+ if (type == EV_KEY)
|
||||
+ return value != 0;
|
||||
+ if (type == EV_MSC || type == EV_ABS || type == EV_REL)
|
||||
+ return true;
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (type != EV_SW || code != SW_LID)
|
||||
return false;
|
||||
|
||||
if (!value)
|
||||
- lid_armed = true;
|
||||
- if (lid_armed && lid_closed != !!value) {
|
||||
+ WRITE_ONCE(lid_armed, true);
|
||||
+ if (READ_ONCE(lid_armed) && READ_ONCE(lid_closed) != !!value) {
|
||||
WRITE_ONCE(lid_closed, !!value);
|
||||
queue_work(system_freezable_wq, &gemini_lid_work);
|
||||
}
|
||||
@@ -113,10 +159,11 @@
|
||||
const struct input_device_id *id)
|
||||
{
|
||||
bool keyboard = gemini_lid_is_keyboard(dev);
|
||||
+ bool touchscreen = !keyboard && gemini_lid_is_touchscreen(dev);
|
||||
struct input_handle *handle;
|
||||
int err;
|
||||
|
||||
- if (!keyboard && !test_bit(SW_LID, dev->swbit))
|
||||
+ if (!keyboard && !touchscreen && !test_bit(SW_LID, dev->swbit))
|
||||
return -ENODEV;
|
||||
|
||||
handle = kzalloc(sizeof(*handle), GFP_KERNEL);
|
||||
@@ -126,27 +173,35 @@
|
||||
handle->dev = dev;
|
||||
handle->handler = handler;
|
||||
handle->name = "gemini-lid";
|
||||
- handle->private = keyboard ? handle : NULL;
|
||||
+ handle->private = keyboard ? GEMINI_LID_KEYBOARD :
|
||||
+ (touchscreen ? GEMINI_LID_TOUCHSCREEN : NULL);
|
||||
|
||||
err = input_register_handle(handle);
|
||||
if (err)
|
||||
goto err_free;
|
||||
|
||||
- if (keyboard) {
|
||||
- /* Nothing to read: keep the device, and inhibit it if closed. */
|
||||
- scoped_guard(mutex, &lid_lock)
|
||||
- lid_keyboard = dev;
|
||||
+ /*
|
||||
+ * input_pass_values() only invokes filters when handle->open > 0,
|
||||
+ * so open matched keyboard and touchscreen handles as well.
|
||||
+ */
|
||||
+ err = input_open_device(handle);
|
||||
+ if (err)
|
||||
+ goto err_unregister;
|
||||
+
|
||||
+ if (keyboard || touchscreen) {
|
||||
+ scoped_guard(mutex, &lid_lock) {
|
||||
+ if (keyboard)
|
||||
+ lid_keyboard = dev;
|
||||
+ else
|
||||
+ lid_touchscreen = dev;
|
||||
+ }
|
||||
if (READ_ONCE(lid_closed))
|
||||
queue_work(system_freezable_wq, &gemini_lid_work);
|
||||
return 0;
|
||||
}
|
||||
|
||||
- err = input_open_device(handle);
|
||||
- if (err)
|
||||
- goto err_unregister;
|
||||
-
|
||||
if (!test_bit(SW_LID, dev->sw))
|
||||
- lid_armed = true;
|
||||
+ WRITE_ONCE(lid_armed, true);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -160,11 +215,14 @@
|
||||
static void gemini_lid_disconnect(struct input_handle *handle)
|
||||
{
|
||||
if (handle->private) {
|
||||
- scoped_guard(mutex, &lid_lock)
|
||||
- lid_keyboard = NULL;
|
||||
- } else {
|
||||
- input_close_device(handle);
|
||||
+ scoped_guard(mutex, &lid_lock) {
|
||||
+ if (handle->private == GEMINI_LID_KEYBOARD)
|
||||
+ lid_keyboard = NULL;
|
||||
+ else if (handle->private == GEMINI_LID_TOUCHSCREEN)
|
||||
+ lid_touchscreen = NULL;
|
||||
+ }
|
||||
}
|
||||
+ input_close_device(handle);
|
||||
input_unregister_handle(handle);
|
||||
kfree(handle);
|
||||
}
|
||||
@@ -179,6 +237,10 @@
|
||||
.flags = INPUT_DEVICE_ID_MATCH_EVBIT,
|
||||
.evbit = { BIT_MASK(EV_KEY) },
|
||||
},
|
||||
+ {
|
||||
+ .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
|
||||
+ .evbit = { BIT_MASK(EV_ABS) },
|
||||
+ },
|
||||
{ }
|
||||
};
|
||||
|
||||
@@ -192,7 +254,32 @@
|
||||
|
||||
static int __init gemini_lid_init(void)
|
||||
{
|
||||
- return input_register_handler(&gemini_lid_handler);
|
||||
+ struct device_node *pio_np;
|
||||
+ struct gpio_desc *desc;
|
||||
+ int err;
|
||||
+
|
||||
+ pio_np = of_find_node_by_path("/pinctrl@10005000");
|
||||
+ if (pio_np) {
|
||||
+ hall_gdev = gpio_device_find_by_fwnode(of_fwnode_handle(pio_np));
|
||||
+ of_node_put(pio_np);
|
||||
+ }
|
||||
+ if (!hall_gdev)
|
||||
+ hall_gdev = gpio_device_find_by_label("10005000.pinctrl");
|
||||
+ if (hall_gdev) {
|
||||
+ desc = gpio_device_get_desc(hall_gdev, GEMINI_HALL_GPIO);
|
||||
+ if (!IS_ERR_OR_NULL(desc))
|
||||
+ hall_gpiod = desc;
|
||||
+ } else {
|
||||
+ pr_warn("gemini-lid: Hall pinctrl GPIO unavailable; using SW_LID only\n");
|
||||
+ }
|
||||
+
|
||||
+ err = input_register_handler(&gemini_lid_handler);
|
||||
+ if (err && hall_gdev) {
|
||||
+ gpio_device_put(hall_gdev);
|
||||
+ hall_gdev = NULL;
|
||||
+ hall_gpiod = NULL;
|
||||
+ }
|
||||
+ return err;
|
||||
}
|
||||
module_init(gemini_lid_init);
|
||||
|
||||
@@ -206,8 +293,13 @@
|
||||
}
|
||||
input_unregister_handler(&gemini_lid_handler);
|
||||
cancel_work_sync(&gemini_lid_work);
|
||||
+ if (hall_gdev) {
|
||||
+ gpio_device_put(hall_gdev);
|
||||
+ hall_gdev = NULL;
|
||||
+ hall_gpiod = NULL;
|
||||
+ }
|
||||
}
|
||||
module_exit(gemini_lid_exit);
|
||||
|
||||
-MODULE_DESCRIPTION("Gemini PDA lid policy: backlight off and keyboard inhibited while closed");
|
||||
+MODULE_DESCRIPTION("Gemini PDA lid policy: synchronous filter and input inhibit while closed");
|
||||
MODULE_LICENSE("GPL");
|
||||
@@ -8,3 +8,4 @@
|
||||
0008-gemini-resume-wake-and-spm-standby.patch
|
||||
0009-mt6797-wlan-drop-free-stability.patch
|
||||
0010-mt6797-ccci-md1-boot-hs-v2-and-rpc.patch
|
||||
0011-gemini-lid-sync-filter-and-debounce.patch
|
||||
Reference in new issue
Block a user