mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] HID: ayaneo-flip-kb: Add driver for keyboard backlight
@ 2026-11-08 11:07 Hijae Song
  2026-11-08 12:19 ` Antheas Kapenekakis
  0 siblings, 1 reply; 6+ messages in thread
From: Hijae Song @ 2026-11-08 11:07 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires
  Cc: linux-input, linux-kernel, Antheas Kapenekakis, Hijae Song

The AYANEO Flip KB has a built-in SiGma Micro USB keyboard (1c4f:007c)
with two HID interfaces: a boot keyboard and a vendor-defined one that
carries an 8-byte Feature Report (ID 0x41) controlling the RGB
backlight. hid-generic binds both, and the backlight is not exposed to
the OS.

Add a driver that exposes the backlight as a multicolor LED class
device, ayaneo:rgb:kbd_backlight. The report layout was determined by
experiments on real hardware:

  byte 1-3: blue, red, green
  byte 4:   firmware effect select (1 = static; 2 and 3 select
            rainbow and breathing, which are not used here)
  byte 5:   0 = off, 1 = on
  byte 6-7: constants 0x41, 0x5a

There is no separate brightness field, so brightness is applied by
scaling the color bytes. GetFeature does not reflect the current state
and is not used.

Turning the backlight off keeps sending the configured color with
mode=off rather than all zeroes, so that the keyboard's own Fn+Space
toggle keeps working afterwards. The LED is marked
LED_RETAIN_AT_SHUTDOWN so unbinding the driver does not blank it.

Both interfaces are bound to this driver so hid-generic stays away; the
boot keyboard interface is started unchanged.

Tested on an AYANEO Flip KB: color and brightness changes through sysfs
and UPower, Fn+Space toggling, behavior after reboot, and a third-party
LED client (HueSync).

Signed-off-by: Hijae Song <hijae99@gmail.com>
---
 drivers/hid/Kconfig              |  12 +++
 drivers/hid/Makefile             |   1 +
 drivers/hid/hid-ayaneo-flip-kb.c | 171 +++++++++++++++++++++++++++++++
 drivers/hid/hid-ids.h            |   1 +
 4 files changed, 185 insertions(+)
 create mode 100644 drivers/hid/hid-ayaneo-flip-kb.c

diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index aa7fa11a..bba11e4b 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -205,6 +205,18 @@ config HID_AUREAL
 	help
 	Support for Aureal Cy se W-01RN Remote Controller and other Aureal derived remotes.
 
+config HID_AYANEO_FLIP_KB
+	tristate "AYANEO Flip KB keyboard backlight"
+	depends on USB_HID
+	depends on LEDS_CLASS_MULTICOLOR
+	help
+	  Support for the RGB backlight of the AYANEO Flip KB's built-in
+	  keyboard. The backlight is exposed as a multicolor LED class
+	  device.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called hid-ayaneo-flip-kb.
+
 config HID_BELKIN
 	tristate "Belkin Flip KVM and Wireless keyboard"
 	help
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 48a863b2..4bac905c 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -35,6 +35,7 @@ obj-$(CONFIG_HID_APPLETB_KBD)	+= hid-appletb-kbd.o
 obj-$(CONFIG_HID_CREATIVE_SB0540)	+= hid-creative-sb0540.o
 obj-$(CONFIG_HID_ASUS)		+= hid-asus.o
 obj-$(CONFIG_HID_AUREAL)	+= hid-aureal.o
+obj-$(CONFIG_HID_AYANEO_FLIP_KB)	+= hid-ayaneo-flip-kb.o
 obj-$(CONFIG_HID_BELKIN)	+= hid-belkin.o
 obj-$(CONFIG_HID_BETOP_FF)	+= hid-betopff.o
 obj-$(CONFIG_HID_BIGBEN_FF)	+= hid-bigbenff.o
diff --git a/drivers/hid/hid-ayaneo-flip-kb.c b/drivers/hid/hid-ayaneo-flip-kb.c
new file mode 100644
index 00000000..8068b7d4
--- /dev/null
+++ b/drivers/hid/hid-ayaneo-flip-kb.c
@@ -0,0 +1,171 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * HID driver for the AYANEO Flip KB's built-in keyboard backlight
+ *
+ * The keyboard enumerates as a SiGma Micro USB HID device with two
+ * interfaces: a plain boot keyboard and a vendor-defined one carrying a
+ * Feature Report (ID 0x41) that controls the RGB backlight. The layout
+ * of that report was determined by testing on real hardware:
+ *
+ *   byte 0: report ID (0x41)
+ *   byte 1: blue
+ *   byte 2: red
+ *   byte 3: green
+ *   byte 4: firmware effect select (0 = keep previous report, 1 = static
+ *           color, 2 = rainbow cycle, 3 = breathing, other tested values
+ *           behave like 1); this driver only ever asks for static color
+ *   byte 5: mode, 0 = off, 1 = on (other tested values behave like 1)
+ *   byte 6: fixed 0x41
+ *   byte 7: fixed 0x5a
+ *
+ * Copyright (c) 2026 Hijae Song
+ */
+
+#include <linux/cleanup.h>
+#include <linux/hid.h>
+#include <linux/led-class-multicolor.h>
+#include <linux/leds.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+
+#include "hid-ids.h"
+
+#define FLIP_KB_REPORT_ID	0x41
+#define FLIP_KB_REPORT_SIZE	8
+#define FLIP_KB_MODE_OFF	0
+#define FLIP_KB_MODE_STATIC	1
+#define FLIP_KB_EFFECT_STATIC	1
+
+struct flip_kb {
+	struct hid_device *hdev;
+	struct led_classdev_mc mc_led;
+	struct mc_subled subled[3];
+};
+
+static int flip_kb_send(struct hid_device *hdev, u8 r, u8 g, u8 b, u8 mode)
+{
+	u8 *buf __free(kfree) = kzalloc(FLIP_KB_REPORT_SIZE, GFP_KERNEL);
+	int ret;
+
+	if (!buf)
+		return -ENOMEM;
+
+	buf[0] = FLIP_KB_REPORT_ID;
+	buf[1] = b;
+	buf[2] = r;
+	buf[3] = g;
+	buf[4] = FLIP_KB_EFFECT_STATIC;
+	buf[5] = mode;
+	buf[6] = 0x41;
+	buf[7] = 0x5a;
+
+	ret = hid_hw_raw_request(hdev, FLIP_KB_REPORT_ID, buf,
+				 FLIP_KB_REPORT_SIZE, HID_FEATURE_REPORT,
+				 HID_REQ_SET_REPORT);
+	return ret < 0 ? ret : 0;
+}
+
+static int flip_kb_brightness_set(struct led_classdev *led_cdev,
+				  enum led_brightness brightness)
+{
+	struct led_classdev_mc *mc_led = lcdev_to_mccdev(led_cdev);
+	struct flip_kb *kb = container_of(mc_led, struct flip_kb, mc_led);
+
+	if (brightness) {
+		led_mc_calc_color_components(mc_led, brightness);
+		return flip_kb_send(kb->hdev, kb->subled[0].brightness,
+				    kb->subled[1].brightness, kb->subled[2].brightness,
+				    FLIP_KB_MODE_STATIC);
+	}
+
+	/*
+	 * An all-zero color combined with mode=off makes the keyboard's
+	 * own Fn+Space toggle stop responding until a non-zero report is
+	 * sent again. mode=off already blanks the backlight regardless of
+	 * the color bytes, so send the configured intensities unscaled
+	 * instead of collapsing them to zero.
+	 */
+	return flip_kb_send(kb->hdev, kb->subled[0].intensity,
+			    kb->subled[1].intensity, kb->subled[2].intensity,
+			    FLIP_KB_MODE_OFF);
+}
+
+static int flip_kb_probe(struct hid_device *hdev, const struct hid_device_id *id)
+{
+	struct flip_kb *kb;
+	int ret, i;
+
+	ret = hid_parse(hdev);
+	if (ret)
+		return ret;
+
+	/*
+	 * Both interfaces match this driver, which keeps hid-generic from
+	 * binding to them, so the boot keyboard interface must be started
+	 * normally and left alone.
+	 */
+	if (!hid_validate_values(hdev, HID_FEATURE_REPORT, FLIP_KB_REPORT_ID,
+				 0, 1))
+		return hid_hw_start(hdev, HID_CONNECT_DEFAULT);
+
+	kb = devm_kzalloc(&hdev->dev, sizeof(*kb), GFP_KERNEL);
+	if (!kb)
+		return -ENOMEM;
+
+	kb->hdev = hdev;
+	hid_set_drvdata(hdev, kb);
+
+	kb->subled[0].color_index = LED_COLOR_ID_RED;
+	kb->subled[1].color_index = LED_COLOR_ID_GREEN;
+	kb->subled[2].color_index = LED_COLOR_ID_BLUE;
+	for (i = 0; i < 3; i++)
+		kb->subled[i].intensity = 255;
+
+	kb->mc_led.subled_info = kb->subled;
+	kb->mc_led.num_colors = 3;
+	kb->mc_led.led_cdev.name = "ayaneo:rgb:" LED_FUNCTION_KBD_BACKLIGHT;
+	kb->mc_led.led_cdev.max_brightness = 255;
+	/* Keep the backlight lit across driver unbind instead of blanking it. */
+	kb->mc_led.led_cdev.flags = LED_RETAIN_AT_SHUTDOWN;
+	kb->mc_led.led_cdev.brightness_set_blocking = flip_kb_brightness_set;
+
+	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
+	if (ret)
+		return ret;
+
+	ret = led_classdev_multicolor_register(&hdev->dev, &kb->mc_led);
+	if (ret)
+		hid_hw_stop(hdev);
+
+	return ret;
+}
+
+static void flip_kb_remove(struct hid_device *hdev)
+{
+	struct flip_kb *kb = hid_get_drvdata(hdev);
+
+	/* Unregister the LED before the transport goes away. */
+	if (kb)
+		led_classdev_multicolor_unregister(&kb->mc_led);
+
+	hid_hw_stop(hdev);
+}
+
+static const struct hid_device_id flip_kb_devices[] = {
+	{ HID_USB_DEVICE(USB_VENDOR_ID_SIGMA_MICRO,
+			 USB_DEVICE_ID_SIGMA_MICRO_AYANEO_FLIP_KB) },
+	{ }
+};
+MODULE_DEVICE_TABLE(hid, flip_kb_devices);
+
+static struct hid_driver flip_kb_driver = {
+	.name = "ayaneo-flip-kb",
+	.id_table = flip_kb_devices,
+	.probe = flip_kb_probe,
+	.remove = flip_kb_remove,
+};
+module_hid_driver(flip_kb_driver);
+
+MODULE_AUTHOR("Hijae Song <hijae99@gmail.com>");
+MODULE_DESCRIPTION("HID driver for the AYANEO Flip KB keyboard backlight");
+MODULE_LICENSE("GPL");
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 341bf587..88302307 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -1309,6 +1309,7 @@
 #define USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD	0x0002
 #define USB_DEVICE_ID_SIGMA_MICRO_USB_MOUSE	0x0034
 #define USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD2	0x0059
+#define USB_DEVICE_ID_SIGMA_MICRO_AYANEO_FLIP_KB	0x007c
 
 #define USB_VENDOR_ID_SIGMATEL		0x066F
 #define USB_DEVICE_ID_SIGMATEL_STMP3780	0x3780
-- 
2.54.0 (Apple Git-157)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] HID: ayaneo-flip-kb: Add driver for keyboard backlight
  2026-11-08 11:07 [PATCH] HID: ayaneo-flip-kb: Add driver for keyboard backlight Hijae Song
@ 2026-11-08 12:19 ` Antheas Kapenekakis
  2026-11-08 13:55   ` Hijae Song
  0 siblings, 1 reply; 6+ messages in thread
From: Antheas Kapenekakis @ 2026-11-08 12:19 UTC (permalink / raw)
  To: Hijae Song; +Cc: Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel

On Sun, 8 Nov 2026 at 12:08, Hijae Song <hijae99@gmail.com> wrote:
>
> The AYANEO Flip KB has a built-in SiGma Micro USB keyboard (1c4f:007c)
> with two HID interfaces: a boot keyboard and a vendor-defined one that
> carries an 8-byte Feature Report (ID 0x41) controlling the RGB
> backlight. hid-generic binds both, and the backlight is not exposed to
> the OS.
>
> Add a driver that exposes the backlight as a multicolor LED class
> device, ayaneo:rgb:kbd_backlight. The report layout was determined by
> experiments on real hardware:
>
>   byte 1-3: blue, red, green
>   byte 4:   firmware effect select (1 = static; 2 and 3 select
>             rainbow and breathing, which are not used here)
>   byte 5:   0 = off, 1 = on
>   byte 6-7: constants 0x41, 0x5a
>
> There is no separate brightness field, so brightness is applied by
> scaling the color bytes. GetFeature does not reflect the current state
> and is not used.
>
> Turning the backlight off keeps sending the configured color with
> mode=off rather than all zeroes, so that the keyboard's own Fn+Space
> toggle keeps working afterwards. The LED is marked
> LED_RETAIN_AT_SHUTDOWN so unbinding the driver does not blank it.
>
> Both interfaces are bound to this driver so hid-generic stays away; the
> boot keyboard interface is started unchanged.
>
> Tested on an AYANEO Flip KB: color and brightness changes through sysfs
> and UPower, Fn+Space toggling, behavior after reboot, and a third-party
> LED client (HueSync).

Hi,
I do not have the bandwidth to review this driver, but I will leave
some broad strokes feedback.

The name of the driver cannot be -flip-kb. You need to make sure it is
generic enough to match most Ayaneo devices. There are 4 flip devices
if I recall. Adding a driver for a single one is a tough sell. Also
this does not control the joysticks LEDs, so naming it ayaneo flip kb
is not appropriate. It is a niche device line, they do not sell a lot
of units and the form factor is not what most users prefer.

If this is an actual keyboard product on the market and Ayaneo is
sourcing the part for their device (it seems so, SiGma Micro appears
to make keyboard ICs), look-up similar devices and kernel drivers. One
might exist already. If not, and provided that Ayaneo did not modify
the backlight protocol, rename the driver appropriately to sigma
something, move it to the appropriate location if there is one, such
as the led subsystem, and match other backlight driver conventions.

Provided the latter is the case and we can make a Sigma micro driver,
I will also try to review the driver, as it is more valuable than just
Ayaneo Flip devices

Best,
Antheas

> Signed-off-by: Hijae Song <hijae99@gmail.com>
> ---
>  drivers/hid/Kconfig              |  12 +++
>  drivers/hid/Makefile             |   1 +
>  drivers/hid/hid-ayaneo-flip-kb.c | 171 +++++++++++++++++++++++++++++++
>  drivers/hid/hid-ids.h            |   1 +
>  4 files changed, 185 insertions(+)
>  create mode 100644 drivers/hid/hid-ayaneo-flip-kb.c
>
> diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
> index aa7fa11a..bba11e4b 100644
> --- a/drivers/hid/Kconfig
> +++ b/drivers/hid/Kconfig
> @@ -205,6 +205,18 @@ config HID_AUREAL
>         help
>         Support for Aureal Cy se W-01RN Remote Controller and other Aureal derived remotes.
>
> +config HID_AYANEO_FLIP_KB
> +       tristate "AYANEO Flip KB keyboard backlight"
> +       depends on USB_HID
> +       depends on LEDS_CLASS_MULTICOLOR
> +       help
> +         Support for the RGB backlight of the AYANEO Flip KB's built-in
> +         keyboard. The backlight is exposed as a multicolor LED class
> +         device.
> +
> +         To compile this driver as a module, choose M here: the
> +         module will be called hid-ayaneo-flip-kb.
> +
>  config HID_BELKIN
>         tristate "Belkin Flip KVM and Wireless keyboard"
>         help
> diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
> index 48a863b2..4bac905c 100644
> --- a/drivers/hid/Makefile
> +++ b/drivers/hid/Makefile
> @@ -35,6 +35,7 @@ obj-$(CONFIG_HID_APPLETB_KBD) += hid-appletb-kbd.o
>  obj-$(CONFIG_HID_CREATIVE_SB0540)      += hid-creative-sb0540.o
>  obj-$(CONFIG_HID_ASUS)         += hid-asus.o
>  obj-$(CONFIG_HID_AUREAL)       += hid-aureal.o
> +obj-$(CONFIG_HID_AYANEO_FLIP_KB)       += hid-ayaneo-flip-kb.o
>  obj-$(CONFIG_HID_BELKIN)       += hid-belkin.o
>  obj-$(CONFIG_HID_BETOP_FF)     += hid-betopff.o
>  obj-$(CONFIG_HID_BIGBEN_FF)    += hid-bigbenff.o
> diff --git a/drivers/hid/hid-ayaneo-flip-kb.c b/drivers/hid/hid-ayaneo-flip-kb.c
> new file mode 100644
> index 00000000..8068b7d4
> --- /dev/null
> +++ b/drivers/hid/hid-ayaneo-flip-kb.c
> @@ -0,0 +1,171 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * HID driver for the AYANEO Flip KB's built-in keyboard backlight
> + *
> + * The keyboard enumerates as a SiGma Micro USB HID device with two
> + * interfaces: a plain boot keyboard and a vendor-defined one carrying a
> + * Feature Report (ID 0x41) that controls the RGB backlight. The layout
> + * of that report was determined by testing on real hardware:
> + *
> + *   byte 0: report ID (0x41)
> + *   byte 1: blue
> + *   byte 2: red
> + *   byte 3: green
> + *   byte 4: firmware effect select (0 = keep previous report, 1 = static
> + *           color, 2 = rainbow cycle, 3 = breathing, other tested values
> + *           behave like 1); this driver only ever asks for static color
> + *   byte 5: mode, 0 = off, 1 = on (other tested values behave like 1)
> + *   byte 6: fixed 0x41
> + *   byte 7: fixed 0x5a
> + *
> + * Copyright (c) 2026 Hijae Song
> + */
> +
> +#include <linux/cleanup.h>
> +#include <linux/hid.h>
> +#include <linux/led-class-multicolor.h>
> +#include <linux/leds.h>
> +#include <linux/module.h>
> +#include <linux/slab.h>
> +
> +#include "hid-ids.h"
> +
> +#define FLIP_KB_REPORT_ID      0x41
> +#define FLIP_KB_REPORT_SIZE    8
> +#define FLIP_KB_MODE_OFF       0
> +#define FLIP_KB_MODE_STATIC    1
> +#define FLIP_KB_EFFECT_STATIC  1
> +
> +struct flip_kb {
> +       struct hid_device *hdev;
> +       struct led_classdev_mc mc_led;
> +       struct mc_subled subled[3];
> +};
> +
> +static int flip_kb_send(struct hid_device *hdev, u8 r, u8 g, u8 b, u8 mode)
> +{
> +       u8 *buf __free(kfree) = kzalloc(FLIP_KB_REPORT_SIZE, GFP_KERNEL);
> +       int ret;
> +
> +       if (!buf)
> +               return -ENOMEM;
> +
> +       buf[0] = FLIP_KB_REPORT_ID;
> +       buf[1] = b;
> +       buf[2] = r;
> +       buf[3] = g;
> +       buf[4] = FLIP_KB_EFFECT_STATIC;
> +       buf[5] = mode;
> +       buf[6] = 0x41;
> +       buf[7] = 0x5a;
> +
> +       ret = hid_hw_raw_request(hdev, FLIP_KB_REPORT_ID, buf,
> +                                FLIP_KB_REPORT_SIZE, HID_FEATURE_REPORT,
> +                                HID_REQ_SET_REPORT);
> +       return ret < 0 ? ret : 0;
> +}
> +
> +static int flip_kb_brightness_set(struct led_classdev *led_cdev,
> +                                 enum led_brightness brightness)
> +{
> +       struct led_classdev_mc *mc_led = lcdev_to_mccdev(led_cdev);
> +       struct flip_kb *kb = container_of(mc_led, struct flip_kb, mc_led);
> +
> +       if (brightness) {
> +               led_mc_calc_color_components(mc_led, brightness);
> +               return flip_kb_send(kb->hdev, kb->subled[0].brightness,
> +                                   kb->subled[1].brightness, kb->subled[2].brightness,
> +                                   FLIP_KB_MODE_STATIC);
> +       }
> +
> +       /*
> +        * An all-zero color combined with mode=off makes the keyboard's
> +        * own Fn+Space toggle stop responding until a non-zero report is
> +        * sent again. mode=off already blanks the backlight regardless of
> +        * the color bytes, so send the configured intensities unscaled
> +        * instead of collapsing them to zero.
> +        */
> +       return flip_kb_send(kb->hdev, kb->subled[0].intensity,
> +                           kb->subled[1].intensity, kb->subled[2].intensity,
> +                           FLIP_KB_MODE_OFF);
> +}
> +
> +static int flip_kb_probe(struct hid_device *hdev, const struct hid_device_id *id)
> +{
> +       struct flip_kb *kb;
> +       int ret, i;
> +
> +       ret = hid_parse(hdev);
> +       if (ret)
> +               return ret;
> +
> +       /*
> +        * Both interfaces match this driver, which keeps hid-generic from
> +        * binding to them, so the boot keyboard interface must be started
> +        * normally and left alone.
> +        */
> +       if (!hid_validate_values(hdev, HID_FEATURE_REPORT, FLIP_KB_REPORT_ID,
> +                                0, 1))
> +               return hid_hw_start(hdev, HID_CONNECT_DEFAULT);
> +
> +       kb = devm_kzalloc(&hdev->dev, sizeof(*kb), GFP_KERNEL);
> +       if (!kb)
> +               return -ENOMEM;
> +
> +       kb->hdev = hdev;
> +       hid_set_drvdata(hdev, kb);
> +
> +       kb->subled[0].color_index = LED_COLOR_ID_RED;
> +       kb->subled[1].color_index = LED_COLOR_ID_GREEN;
> +       kb->subled[2].color_index = LED_COLOR_ID_BLUE;
> +       for (i = 0; i < 3; i++)
> +               kb->subled[i].intensity = 255;
> +
> +       kb->mc_led.subled_info = kb->subled;
> +       kb->mc_led.num_colors = 3;
> +       kb->mc_led.led_cdev.name = "ayaneo:rgb:" LED_FUNCTION_KBD_BACKLIGHT;
> +       kb->mc_led.led_cdev.max_brightness = 255;
> +       /* Keep the backlight lit across driver unbind instead of blanking it. */
> +       kb->mc_led.led_cdev.flags = LED_RETAIN_AT_SHUTDOWN;
> +       kb->mc_led.led_cdev.brightness_set_blocking = flip_kb_brightness_set;
> +
> +       ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
> +       if (ret)
> +               return ret;
> +
> +       ret = led_classdev_multicolor_register(&hdev->dev, &kb->mc_led);
> +       if (ret)
> +               hid_hw_stop(hdev);
> +
> +       return ret;
> +}
> +
> +static void flip_kb_remove(struct hid_device *hdev)
> +{
> +       struct flip_kb *kb = hid_get_drvdata(hdev);
> +
> +       /* Unregister the LED before the transport goes away. */
> +       if (kb)
> +               led_classdev_multicolor_unregister(&kb->mc_led);
> +
> +       hid_hw_stop(hdev);
> +}
> +
> +static const struct hid_device_id flip_kb_devices[] = {
> +       { HID_USB_DEVICE(USB_VENDOR_ID_SIGMA_MICRO,
> +                        USB_DEVICE_ID_SIGMA_MICRO_AYANEO_FLIP_KB) },
> +       { }
> +};
> +MODULE_DEVICE_TABLE(hid, flip_kb_devices);
> +
> +static struct hid_driver flip_kb_driver = {
> +       .name = "ayaneo-flip-kb",
> +       .id_table = flip_kb_devices,
> +       .probe = flip_kb_probe,
> +       .remove = flip_kb_remove,
> +};
> +module_hid_driver(flip_kb_driver);
> +
> +MODULE_AUTHOR("Hijae Song <hijae99@gmail.com>");
> +MODULE_DESCRIPTION("HID driver for the AYANEO Flip KB keyboard backlight");
> +MODULE_LICENSE("GPL");
> diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
> index 341bf587..88302307 100644
> --- a/drivers/hid/hid-ids.h
> +++ b/drivers/hid/hid-ids.h
> @@ -1309,6 +1309,7 @@
>  #define USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD     0x0002
>  #define USB_DEVICE_ID_SIGMA_MICRO_USB_MOUSE    0x0034
>  #define USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD2    0x0059
> +#define USB_DEVICE_ID_SIGMA_MICRO_AYANEO_FLIP_KB       0x007c
>
>  #define USB_VENDOR_ID_SIGMATEL         0x066F
>  #define USB_DEVICE_ID_SIGMATEL_STMP3780        0x3780
> --
> 2.54.0 (Apple Git-157)
>
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] HID: ayaneo-flip-kb: Add driver for keyboard backlight
  2026-11-08 12:19 ` Antheas Kapenekakis
@ 2026-11-08 13:55   ` Hijae Song
  2026-11-08 14:26     ` Antheas Kapenekakis
  0 siblings, 1 reply; 6+ messages in thread
From: Hijae Song @ 2026-11-08 13:55 UTC (permalink / raw)
  To: Antheas Kapenekakis
  Cc: Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel

Hi Antheas,

Thanks for the feedback.

> If this is an actual keyboard product on the market and Ayaneo is
> sourcing the part for their device, look-up similar devices and kernel
> drivers.

I checked. hid-sigmamicro only fixes the 0x0059 report descriptor, and
I found no SiGma Micro backlight driver on lore.

> The name of the driver cannot be -flip-kb. You need to make sure it is
> generic enough to match most Ayaneo devices.

1c4f:007c also appears on the AYANEO Slide in hhd-dev/hwinfo, with the
same vendor interface (report ID 0x41, 7-byte feature report). I only
have a Flip KB, so I can only test the byte layout there.

Matias's hid-ayaneo already claims 1c4f:0002 behind a DMI check for
AYANEO 3. Would you prefer that I add 007c backlight support to
hid-ayaneo once it is merged, or keep a separate driver named after
the chip? I lean towards hid-ayaneo, since the Slide may work the same
way, but I would like your view first.

I will also fix the two sashiko comments in v2.

Thanks,
Hijae

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] HID: ayaneo-flip-kb: Add driver for keyboard backlight
  2026-11-08 13:55   ` Hijae Song
@ 2026-11-08 14:26     ` Antheas Kapenekakis
  2026-11-08 14:28       ` Antheas Kapenekakis
  0 siblings, 1 reply; 6+ messages in thread
From: Antheas Kapenekakis @ 2026-11-08 14:26 UTC (permalink / raw)
  To: Hijae Song; +Cc: Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel

On Sun, 8 Nov 2026 at 14:55, Hijae Song <hijae99@gmail.com> wrote:
>
> Hi Antheas,
>
> Thanks for the feedback.
>
> > If this is an actual keyboard product on the market and Ayaneo is
> > sourcing the part for their device, look-up similar devices and kernel
> > drivers.
>
> I checked. hid-sigmamicro only fixes the 0x0059 report descriptor, and
> I found no SiGma Micro backlight driver on lore.
>
> > The name of the driver cannot be -flip-kb. You need to make sure it is
> > generic enough to match most Ayaneo devices.
>
> 1c4f:007c also appears on the AYANEO Slide in hhd-dev/hwinfo, with the
> same vendor interface (report ID 0x41, 7-byte feature report). I only
> have a Flip KB, so I can only test the byte layout there.
>
> Matias's hid-ayaneo already claims 1c4f:0002 behind a DMI check for
> AYANEO 3. Would you prefer that I add 007c backlight support to
> hid-ayaneo once it is merged, or keep a separate driver named after
> the chip? I lean towards hid-ayaneo, since the Slide may work the same
> way, but I would like your view first.

Mmmm so Ayaneo does not have a vid and may trample the pid of another
device. That is not good. There is no guarantee this led profile is
used by a different vendor.

There are two options:
 - Adding the keyboard to the hid-ayaneo driver
     - This would happen after it merges
     - There is 0 common logic between the rgb device and the keyboard device
     - Driver registers a different led sysfs ABI and has convoluted
dmi handling
     - The driver would devolve
 - Adding a scoped driver for the keyboard
     - You can start now
     - Can tightly scope to keyboard device
     - name can be hid-ayaneo-kbd unless other vendor is found

I would tend towards the latter. hid-ayaneo has plenty of work to
merge. The controller firmware is quite unstable. Even my
implementation in userspace is buggy. But that's fine... Windows is
buggy too.

I have two comments for your current version:
  - remove all flip kbd references, name AYANEO_KBD
  - use brightness values of 0 and 1, no scaling. DEs know how to
handle these values by toggling.
     - another option is 0-3, which looks nicer, but let's not get too
deep into this
  - use devm to register the led structure, drop remove entry point.
Use devm prior to starting the device so that register code stays with
initialization
  - check if led subsystem is appropriate. I am not sure of the
correct place. If not, current location is fine
  - initialize host values to ff ff ff so on first write we get a nice
white color
  - if there is only one effect, brightness 0 is off. Do not add an
effect handler

With 2-3 revisions this should be good to go. While at it, try to find
a Slide user

Best,
Antheas

> I will also fix the two sashiko comments in v2.
>
> Thanks,
> Hijae
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] HID: ayaneo-flip-kb: Add driver for keyboard backlight
  2026-11-08 14:26     ` Antheas Kapenekakis
@ 2026-11-08 14:28       ` Antheas Kapenekakis
  2026-11-08 14:30         ` Antheas Kapenekakis
  0 siblings, 1 reply; 6+ messages in thread
From: Antheas Kapenekakis @ 2026-11-08 14:28 UTC (permalink / raw)
  To: Hijae Song; +Cc: Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel

On Sun, 8 Nov 2026 at 15:26, Antheas Kapenekakis <lkml@antheas.dev> wrote:
>
> On Sun, 8 Nov 2026 at 14:55, Hijae Song <hijae99@gmail.com> wrote:
> >
> > Hi Antheas,
> >
> > Thanks for the feedback.
> >
> > > If this is an actual keyboard product on the market and Ayaneo is
> > > sourcing the part for their device, look-up similar devices and kernel
> > > drivers.
> >
> > I checked. hid-sigmamicro only fixes the 0x0059 report descriptor, and
> > I found no SiGma Micro backlight driver on lore.
> >
> > > The name of the driver cannot be -flip-kb. You need to make sure it is
> > > generic enough to match most Ayaneo devices.
> >
> > 1c4f:007c also appears on the AYANEO Slide in hhd-dev/hwinfo, with the
> > same vendor interface (report ID 0x41, 7-byte feature report). I only
> > have a Flip KB, so I can only test the byte layout there.
> >
> > Matias's hid-ayaneo already claims 1c4f:0002 behind a DMI check for
> > AYANEO 3. Would you prefer that I add 007c backlight support to
> > hid-ayaneo once it is merged, or keep a separate driver named after
> > the chip? I lean towards hid-ayaneo, since the Slide may work the same
> > way, but I would like your view first.
>
> Mmmm so Ayaneo does not have a vid and may trample the pid of another
> device. That is not good. There is no guarantee this led profile is
> used by a different vendor.
>
> There are two options:
>  - Adding the keyboard to the hid-ayaneo driver
>      - This would happen after it merges
>      - There is 0 common logic between the rgb device and the keyboard device
>      - Driver registers a different led sysfs ABI and has convoluted
> dmi handling
>      - The driver would devolve
>  - Adding a scoped driver for the keyboard
>      - You can start now
>      - Can tightly scope to keyboard device
>      - name can be hid-ayaneo-kbd unless other vendor is found
>
> I would tend towards the latter. hid-ayaneo has plenty of work to
> merge. The controller firmware is quite unstable. Even my
> implementation in userspace is buggy. But that's fine... Windows is
> buggy too.
>
> I have two comments for your current version:
>   - remove all flip kbd references, name AYANEO_KBD
>   - use brightness values of 0 and 1, no scaling. DEs know how to
> handle these values by toggling.
>      - another option is 0-3, which looks nicer, but let's not get too
> deep into this
>   - use devm to register the led structure, drop remove entry point.
> Use devm prior to starting the device so that register code stays with
> initialization
>   - check if led subsystem is appropriate. I am not sure of the
> correct place. If not, current location is fine
>   - initialize host values to ff ff ff so on first write we get a nice
> white color
>   - if there is only one effect, brightness 0 is off. Do not add an
> effect handler

Ah yes, if the device supports Fn+Space, for this driver to merge you
need to send the correct hw notify and have at least KDE report the
cycling correctly. You will also need to read the values currently in
the device instead of hardcoding them. If it is a feature report, a
get_report should return current values

I am not sure what your current comment means about sending 0 breaking
the toggle.

Best,
Antheas

> With 2-3 revisions this should be good to go. While at it, try to find
> a Slide user
>
> Best,
> Antheas
>
> > I will also fix the two sashiko comments in v2.
> >
> > Thanks,
> > Hijae
> >


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] HID: ayaneo-flip-kb: Add driver for keyboard backlight
  2026-11-08 14:28       ` Antheas Kapenekakis
@ 2026-11-08 14:30         ` Antheas Kapenekakis
  0 siblings, 0 replies; 6+ messages in thread
From: Antheas Kapenekakis @ 2026-11-08 14:30 UTC (permalink / raw)
  To: Hijae Song; +Cc: Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel

On Sun, 8 Nov 2026 at 15:28, Antheas Kapenekakis <lkml@antheas.dev> wrote:
>
> On Sun, 8 Nov 2026 at 15:26, Antheas Kapenekakis <lkml@antheas.dev> wrote:
> >
> > On Sun, 8 Nov 2026 at 14:55, Hijae Song <hijae99@gmail.com> wrote:
> > >
> > > Hi Antheas,
> > >
> > > Thanks for the feedback.
> > >
> > > > If this is an actual keyboard product on the market and Ayaneo is
> > > > sourcing the part for their device, look-up similar devices and kernel
> > > > drivers.
> > >
> > > I checked. hid-sigmamicro only fixes the 0x0059 report descriptor, and
> > > I found no SiGma Micro backlight driver on lore.
> > >
> > > > The name of the driver cannot be -flip-kb. You need to make sure it is
> > > > generic enough to match most Ayaneo devices.
> > >
> > > 1c4f:007c also appears on the AYANEO Slide in hhd-dev/hwinfo, with the
> > > same vendor interface (report ID 0x41, 7-byte feature report). I only
> > > have a Flip KB, so I can only test the byte layout there.
> > >
> > > Matias's hid-ayaneo already claims 1c4f:0002 behind a DMI check for
> > > AYANEO 3. Would you prefer that I add 007c backlight support to
> > > hid-ayaneo once it is merged, or keep a separate driver named after
> > > the chip? I lean towards hid-ayaneo, since the Slide may work the same
> > > way, but I would like your view first.
> >
> > Mmmm so Ayaneo does not have a vid and may trample the pid of another
> > device. That is not good. There is no guarantee this led profile is
> > used by a different vendor.
> >
> > There are two options:
> >  - Adding the keyboard to the hid-ayaneo driver
> >      - This would happen after it merges
> >      - There is 0 common logic between the rgb device and the keyboard device
> >      - Driver registers a different led sysfs ABI and has convoluted
> > dmi handling
> >      - The driver would devolve
> >  - Adding a scoped driver for the keyboard
> >      - You can start now
> >      - Can tightly scope to keyboard device
> >      - name can be hid-ayaneo-kbd unless other vendor is found
> >
> > I would tend towards the latter. hid-ayaneo has plenty of work to
> > merge. The controller firmware is quite unstable. Even my
> > implementation in userspace is buggy. But that's fine... Windows is
> > buggy too.
> >
> > I have two comments for your current version:
> >   - remove all flip kbd references, name AYANEO_KBD
> >   - use brightness values of 0 and 1, no scaling. DEs know how to
> > handle these values by toggling.
> >      - another option is 0-3, which looks nicer, but let's not get too
> > deep into this
> >   - use devm to register the led structure, drop remove entry point.
> > Use devm prior to starting the device so that register code stays with
> > initialization
> >   - check if led subsystem is appropriate. I am not sure of the
> > correct place. If not, current location is fine
> >   - initialize host values to ff ff ff so on first write we get a nice
> > white color
> >   - if there is only one effect, brightness 0 is off. Do not add an
> > effect handler
>
> Ah yes, if the device supports Fn+Space, for this driver to merge you
> need to send the correct hw notify and have at least KDE report the
> cycling correctly. You will also need to read the values currently in
> the device instead of hardcoding them. If it is a feature report, a
> get_report should return current values
>
> I am not sure what your current comment means about sending 0 breaking
> the toggle.

Ok got it. Make intensity take values of 0 and 1, and use those for
the mode byte. Do not scale intensities. Always send what is
programmed currently. Implement the readback correctly and see if the
device notifies you when brightness changes. If it does, use hw notify
(as other drivers do) to notify userspace and have them read the new
value.

Antheas

> Best,
> Antheas
>
> > With 2-3 revisions this should be good to go. While at it, try to find
> > a Slide user
> >
> > Best,
> > Antheas
> >
> > > I will also fix the two sashiko comments in v2.
> > >
> > > Thanks,
> > > Hijae
> > >


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-08 14:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-08 11:07 [PATCH] HID: ayaneo-flip-kb: Add driver for keyboard backlight Hijae Song
2026-11-08 12:19 ` Antheas Kapenekakis
2026-11-08 13:55   ` Hijae Song
2026-11-08 14:26     ` Antheas Kapenekakis
2026-11-08 14:28       ` Antheas Kapenekakis
2026-11-08 14:30         ` Antheas Kapenekakis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®