Skip to contentSkip to conversation

leds: add keyboard num/caps lock trigger

PATCH In review Arnaud Patard (Rtp) 2 participants 5 messages Jan 13, 2011 – Nov 14, 2011

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

PATCH 1/1 leds: add keyboard num/caps lock trigger

Implement a led trigger which enable/disable a led according to keyboard leds events.

drivers/leds/Kconfig +7 -0
Index: linux-2.6-submit/drivers/leds/Kconfig
===================================================================
@@ -400,6 +400,13 @@
 	  This allows LEDs to be initialised in the ON state.
 	  If unsure, say Y.
 
+config LEDS_TRIGGER_KEYBOARD
+	tristate "Keyboard LED Trigger"
+	depends on INPUT
+	help
+	  This allows LEDs to be controller by keyboard caps/num lock
+	  state.
+
 comment "iptables trigger is under Netfilter config (LED target)"
 	depends on LEDS_TRIGGERS
 
drivers/leds/ledtrig-keyleds.c new file +173 -0

173 lines not on this page · raw message

drivers/leds/Makefile +1 -0
Index: linux-2.6-submit/drivers/leds/Makefile
===================================================================
@@ -52,3 +52,4 @@
 obj-$(CONFIG_LEDS_TRIGGER_BACKLIGHT)	+= ledtrig-backlight.o
 obj-$(CONFIG_LEDS_TRIGGER_GPIO)		+= ledtrig-gpio.o
 obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON)	+= ledtrig-default-on.o
+obj-$(CONFIG_LEDS_TRIGGER_KEYBOARD)	+= ledtrig-keyleds.o
#1 lore raw

Hello,

Quoted 2 lines · Arnaud Patard, le Thu 13 Jan 2011 13:59:13 +0100, a écrit :

Implement a led trigger which enable/disable a led according to keyboard leds events.

This is already being implemented in a more generic and useful way, also permitting to use the keyboard leds for other triggers, see the leds-route-kbd-leds-through-the-generic-leds-layer.patch in the mm tree, and the “route kbd LEDs through the generic LEDs layer” thread here.

Samuel

#2 lore raw
Quoted 1 line · Samuel Thibault

Hello,

Hi,

Quoted 10 lines
Quoted 2 lines · Arnaud Patard, le Thu 13 Jan 2011 13:59:13 +0100, a écrit :

Implement a led trigger which enable/disable a led according to keyboard leds events.

This is already being implemented in a more generic and useful way, also permitting to use the keyboard leds for other triggers, see the leds-route-kbd-leds-through-the-generic-leds-layer.patch in the mm tree, and the “route kbd LEDs through the generic LEDs layer” thread here.

I've download the patch at [1] and after a quick runtime test, got no success. When booting with the LEDS_INPUT set to y, the machine is hanging. I didn't have a serial console at hand so no log for now. I've then tried it as module, and it didn't work too. No freeze, but led state did not change.
Moreover, I found a bug. The kbd_update_leds_helper() change is wrong. It should use !!(leds & (1<<VC_*)) and not !!(leds & VC_*).

btw, my use case/problem is different than yours. I've a arm system where the keyboard is usb hid one and the led I'm trying to control a led connected on a gpio.

Arnaud

[1] http://userweb.kernel.org/~akpm/mmotm/broken-out/leds-route-kbd-leds-through-the-generic-leds-layer.patch

#3 lore raw

Hello,

Quoted 10 lines · Arnaud Patard, le Mon 17 Jan 2011 00:54:05 +0100, a écrit :
Quoted 4 lines

This is already being implemented in a more generic and useful way, also permitting to use the keyboard leds for other triggers, see the leds-route-kbd-leds-through-the-generic-leds-layer.patch in the mm tree, and the “route kbd LEDs through the generic LEDs layer” thread here.

I've download the patch at [1] and after a quick runtime test, got no success. When booting with the LEDS_INPUT set to y, the machine is hanging. I didn't have a serial console at hand so no log for now. I've then tried it as module, and it didn't work too. No freeze, but led state did not change.

Odd, in my memory it was working for me.

Quoted 2 lines

Moreover, I found a bug. The kbd_update_leds_helper() change is wrong. It should use !!(leds & (1<<VC_*)) and not !!(leds & VC_*).

Indeed. This has actually disappeared in the version I'm working on from the feedback provided by Dmitry.

Quoted 1 line

btw, my use case/problem is different than yours.

Yes, but my implementation fills both needs.

Quoted 2 lines

I've a arm system where the keyboard is usb hid one and the led I'm trying to control a led connected on a gpio.

Then simply connect it to the new e.g. "input::numl" (or "vt::numl" as per new name according to Dmitry's feedback) trigger provided by my patch.

Samuel

#4 lore raw
In reply to Arnaud Patard (Rtp)
Quoted 3 lines · Arnaud Patard, le Mon 17 Jan 2011 00:54:05 +0100, a écrit :

I've download the patch at [1] and after a quick runtime test, got no success. When booting with the LEDS_INPUT set to y, the machine is hanging.

Could you try again with the attached patch?

Samuel

Documentation/leds/leds-class.txt +0 -3
index 79699c2..62261c0 100644
@@ -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/leds/Kconfig +8 -3
index ff203a4..1f31969 100644
@@ -11,9 +11,6 @@ menuconfig NEW_LEDS
 	  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
@@ -32,6 +29,14 @@ config LEDS_88PM860X
 	  This option enables support for on-chip LED drivers found on Marvell
 	  Semiconductor 88PM8606 PMIC.
 
+config LEDS_INPUT
+	tristate "LED Support using input keyboards"
+	depends on LEDS_CLASS && INPUT
+	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
drivers/leds/Makefile +1 -0
index e4f6bf5..90956c2 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_LEDS_TRIGGERS)		+= led-triggers.o
 obj-$(CONFIG_LEDS_88PM860X)		+= leds-88pm860x.o
 obj-$(CONFIG_LEDS_ATMEL_PWM)		+= leds-atmel-pwm.o
 obj-$(CONFIG_LEDS_BD2802)		+= leds-bd2802.o
+obj-$(CONFIG_LEDS_INPUT)		+= leds-input.o
 obj-$(CONFIG_LEDS_LOCOMO)		+= leds-locomo.o
 obj-$(CONFIG_LEDS_LM3530)		+= leds-lm3530.o
 obj-$(CONFIG_LEDS_MIKROTIK_RB532)	+= leds-rb532.o
drivers/leds/leds-input.c new file +306 -0

306 lines not on this page · raw message

drivers/tty/Kconfig +1 -0
index b3d1741..622eecd 100644
@@ -2,6 +2,7 @@ config VT
 	bool "Virtual terminal" if EXPERT
 	depends on !S390 && !UML
 	select INPUT
+	select LEDS_INPUT
 	default y
 	---help---
 	  If you say Y here, you will get support for terminal devices with
drivers/tty/vt/keyboard.c +65 -26

150 lines not on this page · raw message