Skip to contentSkip to conversation

Route kbd LEDs through the generic LEDs layer (4th version)

PATCH New Samuel Thibault 2 participants 6 messages Mar 7, 2010 – Mar 22, 2010

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

PATCH 1/1 Route kbd LEDs through the generic LEDs layer (4th version)

Route keyboard LEDs through the generic LEDs layer.

This permits to reassign keyboard LEDs to something else than keyboard "leds" state, by adding keyboard led and modifier triggers connected to a series of global input LEDs, themselves connected to global input triggers, which per-input device LEDs use by default. Userland can thus easily change the LED behavior of (a priori) all input devices, or of particular input devices.

This also permits to fix #7063 from userland by using a modifier to implement proper CapsLock behavior and have the keyboard caps lock led show that modifier state.

---

Hello,

Quoted 3 lines · Samuel Thibault, le Sun 07 Mar 2010 13:06:04 +0100, a écrit :

Thinking more about it, what about the following:

keyboard numlock trigger -> input numlock led -> input numlock trigger -> input keyboard led

Here is a fourth version of the patch that implements this.

Difference from the third version:
- creates LEDs for each input device.
- creates a global LED trigger connected to the global LED, that per-device LEDs use by default.
- properly initializes LED state on trigger and input device connection.

Difference between third and second:
- only input LEDs actually available on devices are registered.

Difference between second and first:
- rebase on 2.6.33, fix locking issues.

Samuel

Documentation/leds-class.txt +0 -3
diff -ur linux-2.6.33-orig/Documentation/leds-class.txt linux-2.6.33-perso/Documentation/leds-class.txt
@@ -2,9 +2,6 @@
 LED handling under Linux
 ========================
 
-If you're reading this and thinking about keyboard leds, these are
-handled by the input subsystem and the led class is *not* needed.
-
 In its simplest form, the LED class just allows control of LEDs from
 userspace. LEDs appear in /sys/class/leds/. The maximum brightness of the
 LED is defined in max_brightness file. The brightness file will set the brightness
drivers/char/keyboard.c +93 -3

164 lines not on this page · raw message

drivers/leds/Kconfig +8 -3
diff -ur linux-2.6.33-orig/drivers/leds/Kconfig linux-2.6.33-perso/drivers/leds/Kconfig
@@ -4,9 +4,6 @@
 	  Say Y to enable Linux LED support.  This allows control of supported
 	  LEDs from both userspace and optionally, by kernel events (triggers).
 
-	  This is not related to standard keyboard LEDs which are controlled
-	  via the input system.
-
 if NEW_LEDS
 
 config LEDS_CLASS
@@ -17,6 +14,14 @@
 
 comment "LED drivers"
 
+config LEDS_INPUT
+	tristate "LED Support using input keyboards"
+	depends on LEDS_CLASS
+	select LEDS_TRIGGERS
+	help
+	  This option enables support for the LEDs on keyboard managed
+	  by the input layer.
+
 config LEDS_ATMEL_PWM
 	tristate "LED Support using Atmel PWM outputs"
 	depends on LEDS_CLASS && ATMEL_PWM
drivers/leds/leds-input.c +295 -0

295 lines not on this page · raw message

drivers/leds/Makefile +1 -0
diff -ur linux-2.6.33-orig/drivers/leds/Makefile linux-2.6.33-perso/drivers/leds/Makefile
@@ -5,6 +5,7 @@
 obj-$(CONFIG_LEDS_TRIGGERS)		+= led-triggers.o
 
 # LED Platform Drivers
+obj-$(CONFIG_LEDS_INPUT)		+= leds-input.o
 obj-$(CONFIG_LEDS_ATMEL_PWM)		+= leds-atmel-pwm.o
 obj-$(CONFIG_LEDS_BD2802)		+= leds-bd2802.o
 obj-$(CONFIG_LEDS_LOCOMO)		+= leds-locomo.o
include/linux/leds.h +1 -0
diff -ur linux-2.6.33-orig/include/linux/leds.h linux-2.6.33-perso/include/linux/leds.h
@@ -65,6 +65,7 @@
 	struct list_head	 trig_list;
 	void			*trigger_data;
 #endif
+	void			*private;
 };
 
 extern int led_classdev_register(struct device *parent,
#1 lore raw

PATCH 1/1 Route kbd LEDs through the generic LEDs layer (5th version)

Route keyboard LEDs through the generic LEDs layer.

This permits to reassign keyboard LEDs to something else than keyboard "leds" state, by adding keyboard led and modifier triggers connected to a series of global input LEDs, themselves connected to global input triggers, which per-input device LEDs use by default. Userland can thus easily change the LED behavior of (a priori) all input devices, or of particular input devices.

This also permits to fix #7063 from userland by using a modifier to implement proper CapsLock behavior and have the keyboard caps lock led show that modifier state.

---

Hello,

Here is a fifth version

Differences from the fourth version:
- use the platform_data field of the device struct instead of adding a private field to struct led_classdev.
- fix using input led triggers for non-input leds.

Difference from the third version:
- creates LEDs for each input device.
- creates a global LED trigger connected to the global LED, that per-device LEDs use by default.
- properly initializes LED state on trigger and input device connection.

Difference between third and second:
- only input LEDs actually available on devices are registered.

Difference between second and first:
- rebase on 2.6.33, fix locking issues.

Samuel

Documentation/leds-class.txt +0 -3
diff -ur linux-2.6.33-orig/Documentation/leds-class.txt linux-2.6.33-perso/Documentation/leds-class.txt
@@ -2,9 +2,6 @@
 LED handling under Linux
 ========================
 
-If you're reading this and thinking about keyboard leds, these are
-handled by the input subsystem and the led class is *not* needed.
-
 In its simplest form, the LED class just allows control of LEDs from
 userspace. LEDs appear in /sys/class/leds/. The maximum brightness of the
 LED is defined in max_brightness file. The brightness file will set the brightness
drivers/char/keyboard.c +93 -3

164 lines not on this page · raw message

drivers/leds/Kconfig +8 -3
diff -ur linux-2.6.33-orig/drivers/leds/Kconfig linux-2.6.33-perso/drivers/leds/Kconfig
@@ -4,9 +4,6 @@
 	  Say Y to enable Linux LED support.  This allows control of supported
 	  LEDs from both userspace and optionally, by kernel events (triggers).
 
-	  This is not related to standard keyboard LEDs which are controlled
-	  via the input system.
-
 if NEW_LEDS
 
 config LEDS_CLASS
@@ -17,6 +14,14 @@
 
 comment "LED drivers"
 
+config LEDS_INPUT
+	tristate "LED Support using input keyboards"
+	depends on LEDS_CLASS
+	select LEDS_TRIGGERS
+	help
+	  This option enables support for the LEDs on keyboard managed
+	  by the input layer.
+
 config LEDS_ATMEL_PWM
 	tristate "LED Support using Atmel PWM outputs"
 	depends on LEDS_CLASS && ATMEL_PWM
drivers/leds/leds-input.c +307 -0

307 lines not on this page · raw message

drivers/leds/Makefile +1 -0
diff -ur linux-2.6.33-orig/drivers/leds/Makefile linux-2.6.33-perso/drivers/leds/Makefile
@@ -5,6 +5,7 @@
 obj-$(CONFIG_LEDS_TRIGGERS)		+= led-triggers.o
 
 # LED Platform Drivers
+obj-$(CONFIG_LEDS_INPUT)		+= leds-input.o
 obj-$(CONFIG_LEDS_ATMEL_PWM)		+= leds-atmel-pwm.o
 obj-$(CONFIG_LEDS_BD2802)		+= leds-bd2802.o
 obj-$(CONFIG_LEDS_LOCOMO)		+= leds-locomo.o
Tested-by on v1 1/1
#2 lore raw

Re: [PATCH] Route kbd LEDs through the generic LEDs layer (5th version)

Hi!

Quoted 8 lines

Route keyboard LEDs through the generic LEDs layer.

This permits to reassign keyboard LEDs to something else than keyboard "leds" state, by adding keyboard led and modifier triggers connected to a series of global input LEDs, themselves connected to global input triggers, which per-input device LEDs use by default. Userland can thus easily change the LED behavior of (a priori) all input devices, or of particular input devices.

Quoted 5 lines

This also permits to fix #7063 from userland by using a modifier to implement proper CapsLock behavior and have the keyboard caps lock led show that modifier state.

I like it.

Now, minor comments:

sometimes it uses "numl" (led name), sometimes it uses "numlock" trigger name.

root@amd:/sys/class/leds/input5::numl# echo heartbeat > trigger

did not do the trick on my thinkpad. It still acts as numlock led. Is it driven by hw? input5::capsl works as expected.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#3 lore raw

Re: [PATCH] Route kbd LEDs through the generic LEDs layer (5th version)

Quoted 4 lines · Pavel Machek, le Sun 21 Mar 2010 22:09:38 +0100, a écrit :

Now, minor comments:

sometimes it uses "numl" (led name), sometimes it uses "numlock" trigger name.

Yes, I preferred to stick to the existing names: numl like LED_NUML, and numlock like VC_NUMLOCK. I don't have any opinion on this however.

Quoted 4 lines
root@amd:/sys/class/leds/input5::numl# echo heartbeat > trigger

did not do the trick on my thinkpad. It still acts as numlock led. Is it driven by hw? input5::capsl works as expected.

If it is a laptop, it is likely, depending on the BIOS & such. On my laptop, doing this works fine.

Samuel
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

Re: [PATCH] Route kbd LEDs through the generic LEDs layer (5th version)

Quoted 8 lines
Quoted 5 lines
root@amd:/sys/class/leds/input5::numl# echo heartbeat > trigger

did not do the trick on my thinkpad. It still acts as numlock led. Is it driven by hw? input5::capsl works as expected.

If it is a laptop, it is likely, depending on the BIOS & such. On my laptop, doing this works fine.

Thinkpad x60. And yes, since it also changes behaviour of "jkl" keys, it seems to be something strange with the hardware.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#5 lore raw

PATCH 1/1 Route kbd LEDs through the generic LEDs layer (5th version)

In reply to Samuel Thibault

Route keyboard LEDs through the generic LEDs layer.

This permits to reassign keyboard LEDs to something else than keyboard "leds" state, by adding keyboard led and modifier triggers connected to a series of global input LEDs, themselves connected to global input triggers, which per-input device LEDs use by default. Userland can thus easily change the LED behavior of (a priori) all input devices, or of particular input devices.

This also permits to fix #7063 from userland by using a modifier to implement proper CapsLock behavior and have the keyboard caps lock led show that modifier state.

---

Hello,

Here is a fifth version

Differences from the fourth version:
- use the platform_data field of the device struct instead of adding a private field to struct led_classdev.
- fix using input led triggers for non-input leds.

Difference from the third version:
- creates LEDs for each input device.
- creates a global LED trigger connected to the global LED, that per-device LEDs use by default.
- properly initializes LED state on trigger and input device connection.

Difference between third and second:
- only input LEDs actually available on devices are registered.

Difference between second and first:
- rebase on 2.6.33, fix locking issues.

Samuel

Documentation/leds-class.txt +0 -3
diff -ur linux-2.6.33-orig/Documentation/leds-class.txt linux-2.6.33-perso/Documentation/leds-class.txt
@@ -2,9 +2,6 @@
 LED handling under Linux
 ========================
 
-If you're reading this and thinking about keyboard leds, these are
-handled by the input subsystem and the led class is *not* needed.
-
 In its simplest form, the LED class just allows control of LEDs from
 userspace. LEDs appear in /sys/class/leds/. The maximum brightness of the
 LED is defined in max_brightness file. The brightness file will set the brightness
drivers/char/keyboard.c +93 -3

164 lines not on this page · raw message

drivers/leds/Kconfig +8 -3
diff -ur linux-2.6.33-orig/drivers/leds/Kconfig linux-2.6.33-perso/drivers/leds/Kconfig
@@ -4,9 +4,6 @@
 	  Say Y to enable Linux LED support.  This allows control of supported
 	  LEDs from both userspace and optionally, by kernel events (triggers).
 
-	  This is not related to standard keyboard LEDs which are controlled
-	  via the input system.
-
 if NEW_LEDS
 
 config LEDS_CLASS
@@ -17,6 +14,14 @@
 
 comment "LED drivers"
 
+config LEDS_INPUT
+	tristate "LED Support using input keyboards"
+	depends on LEDS_CLASS
+	select LEDS_TRIGGERS
+	help
+	  This option enables support for the LEDs on keyboard managed
+	  by the input layer.
+
 config LEDS_ATMEL_PWM
 	tristate "LED Support using Atmel PWM outputs"
 	depends on LEDS_CLASS && ATMEL_PWM
drivers/leds/leds-input.c +307 -0

307 lines not on this page · raw message

drivers/leds/Makefile +1 -0
diff -ur linux-2.6.33-orig/drivers/leds/Makefile linux-2.6.33-perso/drivers/leds/Makefile
@@ -5,6 +5,7 @@
 obj-$(CONFIG_LEDS_TRIGGERS)		+= led-triggers.o
 
 # LED Platform Drivers
+obj-$(CONFIG_LEDS_INPUT)		+= leds-input.o
 obj-$(CONFIG_LEDS_ATMEL_PWM)		+= leds-atmel-pwm.o
 obj-$(CONFIG_LEDS_BD2802)		+= leds-bd2802.o
 obj-$(CONFIG_LEDS_LOCOMO)		+= leds-locomo.o