Skip to contentSkip to conversation

platform/x86: fujitsu-laptop: Report Windows Ink button on LIFEBOOK U9311X

PATCH In review Florian Schmidt 2 participants 2 messages Nov 20 – Nov 23

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: fujitsu-laptop: Report Windows Ink button on LIFEBOOK U9311X

The LIFEBOOK U9311X has a hardware button for Microsoft Windows Ink. Pressing it does not queue an entry in the FUNC_BUTTONS ring buffer. Instead, bit 20 of the FUNC_FLAGS status (op 0x4) is set while the button is held down and cleared on release, and an ACPI notify is raised on both edges. The FUNC_FLAGS event value (op 0x1) reports bit 20 on both edges, so it cannot be used to tell press from release.

FUNC_FLAGS op 0x0 returns 0x66120120 on this machine, so bit 20 is advertised as supported. Bit 30 follows the Fn lock state and is not touched by this change.

Track the level of bit 20 and report press and release as KEY_PROG1 so the button can be bound in userspace.

Tested on a LIFEBOOK U9311X (BIOS 2.42) with this change backported to v7.0: libinput shows KEY_PROG1 pressed/released for each button press, independent of the Fn lock state.

The analysis of the dynamic debug output, the code change and this changelog were produced with the help of an AI coding assistant (Claude Code by Anthropic) on my request to make this button usable under Linux. I reviewed the change and tested it on the hardware.

---
 drivers/platform/x86/fujitsu-laptop.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/platform/x86/fujitsu-laptop.c +19 -0
index 8e909cb..0bcb92e 100644
@@ -81,6 +81,7 @@
 #define FLAG_TOUCHPAD_TOGGLE		BIT(26)
 #define FLAG_MICMUTE			BIT(29)
 #define FLAG_SOFTKEYS			(FLAG_RFKILL | FLAG_TOUCHPAD_TOGGLE | FLAG_MICMUTE)
+#define FLAG_INK_BUTTON			BIT(20)
 
 /* FUNC interface - LED control */
 #define FUNC_LED_OFF			BIT(0)
@@ -140,6 +141,7 @@ struct fujitsu_laptop {
 	spinlock_t fifo_lock;
 	int flags_supported;
 	int flags_state;
+	bool ink_button_pressed;
 	bool charge_control_supported;
 };
 
@@ -585,6 +587,7 @@ static const struct key_entry keymap_default[] = {
 	{ KE_KEY, FLAG_RFKILL,          { KEY_RFKILL } },
 	{ KE_KEY, FLAG_TOUCHPAD_TOGGLE, { KEY_TOUCHPAD_TOGGLE } },
 	{ KE_KEY, FLAG_MICMUTE,         { KEY_MICMUTE } },
+	{ KE_KEY, FLAG_INK_BUTTON,      { KEY_PROG1 } },
 	{ KE_END, 0 }
 };
 
@@ -957,6 +960,7 @@ static void acpi_fujitsu_laptop_notify(acpi_handle handle, u32 event, void *data
 	unsigned long flags;
 	int scancode, i = 0;
 	unsigned int irb;
+	bool pressed;
 
 	if (event != ACPI_FUJITSU_NOTIFY_CODE) {
 		acpi_handle_info(handle, "Unsupported event [0x%x]\n", event);
@@ -990,6 +994,20 @@ static void acpi_fujitsu_laptop_notify(acpi_handle handle, u32 event, void *data
 		for_each_set_bit(i, &flags, BITS_PER_LONG)
 			sparse_keymap_report_event(priv->input, BIT(i), 1, true);
 	}
+
+	/*
+	 * On some models (e.g. LIFEBOOK U9311X) the Windows Ink button is
+	 * only reported as a level in the status flags: the bit is set while
+	 * the button is held down. Report press and release on each change.
+	 */
+	if (priv->flags_supported & FLAG_INK_BUTTON) {
+		pressed = priv->flags_state & FLAG_INK_BUTTON;
+		if (pressed != priv->ink_button_pressed) {
+			sparse_keymap_report_event(priv->input, FLAG_INK_BUTTON,
+						   pressed, false);
+			priv->ink_button_pressed = pressed;
+		}
+	}
 }
 
 static int acpi_fujitsu_laptop_probe(struct platform_device *pdev)
@@ -1037,6 +1055,7 @@ static int acpi_fujitsu_laptop_probe(struct platform_device *pdev)
 	if (priv->flags_supported)
 		priv->flags_state = call_fext_func(fext, FUNC_FLAGS, 0x4, 0x0,
 						   0x0);
+	priv->ink_button_pressed = priv->flags_state & FLAG_INK_BUTTON;
 
 	/* Suspect this is a keymap of the application panel, print it */
 	acpi_handle_info(device->handle, "BTNI: [0x%x]\n",
Signature · 1 line
2.53.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 18 lines · Florian Schmidt

The LIFEBOOK U9311X has a hardware button for Microsoft Windows Ink. Pressing it does not queue an entry in the FUNC_BUTTONS ring buffer. Instead, bit 20 of the FUNC_FLAGS status (op 0x4) is set while the button is held down and cleared on release, and an ACPI notify is raised on both edges. The FUNC_FLAGS event value (op 0x1) reports bit 20 on both edges, so it cannot be used to tell press from release.

FUNC_FLAGS op 0x0 returns 0x66120120 on this machine, so bit 20 is advertised as supported. Bit 30 follows the Fn lock state and is not touched by this change.

Track the level of bit 20 and report press and release as KEY_PROG1 so the button can be bound in userspace.

Tested on a LIFEBOOK U9311X (BIOS 2.42) with this change backported to v7.0: libinput shows KEY_PROG1 pressed/released for each button press, independent of the Fn lock state.

Quoted 6 lines

The analysis of the dynamic debug output, the code change and this changelog were produced with the help of an AI coding assistant (Claude Code by Anthropic) on my request to make this button usable under Linux. I reviewed the change and tested it on the hardware.

I don't have suitable hardware to test this myself. However, the proposed changes look reasonable and they are reported to work.

Quoted 71 lines
---
 drivers/platform/x86/fujitsu-laptop.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/platform/x86/fujitsu-laptop.c +19 -0
index 8e909cb..0bcb92e 100644
@@ -81,6 +81,7 @@
 #define FLAG_TOUCHPAD_TOGGLE		BIT(26)
 #define FLAG_MICMUTE			BIT(29)
 #define FLAG_SOFTKEYS			(FLAG_RFKILL | FLAG_TOUCHPAD_TOGGLE | FLAG_MICMUTE)
+#define FLAG_INK_BUTTON			BIT(20)
 
 /* FUNC interface - LED control */
 #define FUNC_LED_OFF			BIT(0)
@@ -140,6 +141,7 @@ struct fujitsu_laptop {
 	spinlock_t fifo_lock;
 	int flags_supported;
 	int flags_state;
+	bool ink_button_pressed;
 	bool charge_control_supported;
 };
 
@@ -585,6 +587,7 @@ static const struct key_entry keymap_default[] = {
 	{ KE_KEY, FLAG_RFKILL,          { KEY_RFKILL } },
 	{ KE_KEY, FLAG_TOUCHPAD_TOGGLE, { KEY_TOUCHPAD_TOGGLE } },
 	{ KE_KEY, FLAG_MICMUTE,         { KEY_MICMUTE } },
+	{ KE_KEY, FLAG_INK_BUTTON,      { KEY_PROG1 } },
 	{ KE_END, 0 }
 };
 
@@ -957,6 +960,7 @@ static void acpi_fujitsu_laptop_notify(acpi_handle handle, u32 event, void *data
 	unsigned long flags;
 	int scancode, i = 0;
 	unsigned int irb;
+	bool pressed;
 
 	if (event != ACPI_FUJITSU_NOTIFY_CODE) {
 		acpi_handle_info(handle, "Unsupported event [0x%x]\n", event);
@@ -990,6 +994,20 @@ static void acpi_fujitsu_laptop_notify(acpi_handle handle, u32 event, void *data
 		for_each_set_bit(i, &flags, BITS_PER_LONG)
 			sparse_keymap_report_event(priv->input, BIT(i), 1, true);
 	}
+
+	/*
+	 * On some models (e.g. LIFEBOOK U9311X) the Windows Ink button is
+	 * only reported as a level in the status flags: the bit is set while
+	 * the button is held down. Report press and release on each change.
+	 */
+	if (priv->flags_supported & FLAG_INK_BUTTON) {
+		pressed = priv->flags_state & FLAG_INK_BUTTON;
+		if (pressed != priv->ink_button_pressed) {
+			sparse_keymap_report_event(priv->input, FLAG_INK_BUTTON,
+						   pressed, false);
+			priv->ink_button_pressed = pressed;
+		}
+	}
 }
 
 static int acpi_fujitsu_laptop_probe(struct platform_device *pdev)
@@ -1037,6 +1055,7 @@ static int acpi_fujitsu_laptop_probe(struct platform_device *pdev)
 	if (priv->flags_supported)
 		priv->flags_state = call_fext_func(fext, FUNC_FLAGS, 0x4, 0x0,
 						   0x0);
+	priv->ink_button_pressed = priv->flags_state & FLAG_INK_BUTTON;
 
 	/* Suspect this is a keymap of the application panel, print it */
 	acpi_handle_info(device->handle, "BTNI: [0x%x]\n",
Signature · 1 line
2.53.0