All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Input: atkbd - add LED triggers for keyboard state
@ 2014-03-02 21:05 Jason A. Donenfeld
  2014-03-07 14:04 ` Pavel Machek
  0 siblings, 1 reply; 4+ messages in thread
From: Jason A. Donenfeld @ 2014-03-02 21:05 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jason A. Donenfeld

Many new laptop keyboards aren't shipping with LEDs in the keys for
caps lock, num lock, and scroll lock. They do, however, ship with many LEDs
for specialized functions that mostly go non-utilized by any current
Linux drivers. Having a caps lock LED is very helpful in early boot full
disk encryption, where a fancy GUI is not available to show that caps
lock is activated.

This patch wires in the caps, num, and scroll lock states of the
keyboard into the generic LED trigger subsystem, so that integrators can
have different LEDs activated on caps/num/scroll lock state changes.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 drivers/input/keyboard/atkbd.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 2626773..15061bf 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -28,6 +28,7 @@
 #include <linux/libps2.h>
 #include <linux/mutex.h>
 #include <linux/dmi.h>
+#include <linux/leds.h>
 
 #define DRIVER_DESC	"AT and PS/2 keyboard driver"
 
@@ -302,6 +303,12 @@ static const unsigned int xl_table[] = {
 	ATKBD_RET_NAK, ATKBD_RET_HANJA, ATKBD_RET_HANGEUL,
 };
 
+#ifdef CONFIG_LEDS_TRIGGERS
+struct led_trigger *capsl_led_trigger = 0;
+struct led_trigger *numl_led_trigger = 0;
+struct led_trigger *scrolll_led_trigger = 0;
+#endif
+
 /*
  * Checks if we should mangle the scancode to extract 'release' bit
  * in translated mode.
@@ -559,6 +566,12 @@ static int atkbd_set_leds(struct atkbd *atkbd)
 	if (ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_SETLEDS))
 		return -1;
 
+#ifdef CONFIG_LEDS_TRIGGERS
+	led_trigger_event(capsl_led_trigger, test_bit(LED_CAPSL, dev->led) ? LED_FULL : LED_OFF);
+	led_trigger_event(numl_led_trigger, test_bit(LED_NUML, dev->led) ? LED_FULL : LED_OFF);
+	led_trigger_event(scrolll_led_trigger, test_bit(LED_SCROLLL, dev->led) ? LED_FULL : LED_OFF);
+#endif
+
 	if (atkbd->extra) {
 		param[0] = 0;
 		param[1] = (test_bit(LED_COMPOSE, dev->led) ? 0x01 : 0)
@@ -1781,12 +1794,25 @@ static const struct dmi_system_id atkbd_dmi_quirk_table[] __initconst = {
 static int __init atkbd_init(void)
 {
 	dmi_check_system(atkbd_dmi_quirk_table);
+#ifdef CONFIG_LEDS_TRIGGERS
+	led_trigger_register_simple("caps-lock", &capsl_led_trigger);
+	led_trigger_register_simple("num-lock", &numl_led_trigger);
+	led_trigger_register_simple("scroll-lock", &scrolll_led_trigger);
+#endif
 
 	return serio_register_driver(&atkbd_drv);
 }
 
 static void __exit atkbd_exit(void)
 {
+#ifdef CONFIG_LEDS_TRIGGERS
+	led_trigger_unregister_simple(capsl_led_trigger);
+	capsl_led_trigger = 0;
+	led_trigger_unregister_simple(numl_led_trigger);
+	numl_led_trigger = 0;
+	led_trigger_unregister_simple(scrolll_led_trigger);
+	scrolll_led_trigger = 0;
+#endif
 	serio_unregister_driver(&atkbd_drv);
 }
 
-- 
1.8.5.4


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

* Re: [PATCH] Input: atkbd - add LED triggers for keyboard state
  2014-03-02 21:05 [PATCH] Input: atkbd - add LED triggers for keyboard state Jason A. Donenfeld
@ 2014-03-07 14:04 ` Pavel Machek
  0 siblings, 0 replies; 4+ messages in thread
From: Pavel Machek @ 2014-03-07 14:04 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: linux-kernel

On Sun 2014-03-02 22:05:56, Jason A. Donenfeld wrote:
> Many new laptop keyboards aren't shipping with LEDs in the keys for
> caps lock, num lock, and scroll lock. They do, however, ship with many LEDs
> for specialized functions that mostly go non-utilized by any current
> Linux drivers. Having a caps lock LED is very helpful in early boot full
> disk encryption, where a fancy GUI is not available to show that caps
> lock is activated.

There's already patch in akpm tree that does this... and more.

Please help improving it.

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

* Re: [PATCH] Input: atkbd - add LED triggers for keyboard state
  2015-07-13 22:45 Jason A. Donenfeld
@ 2015-07-14  0:19 ` Dmitry Torokhov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2015-07-14  0:19 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: linux-input, linux-kernel, Samuel Thibault

Hi Jason,

On Tue, Jul 14, 2015 at 12:45:54AM +0200, Jason A. Donenfeld wrote:
> Many new laptop keyboards aren't shipping with LEDs in the keys for
> caps lock, num lock, and scroll lock. They do, however, ship with many LEDs
> for specialized functions that mostly go non-utilized by any current
> Linux drivers. Having a caps lock LED is very helpful in early boot full
> disk encryption, where a fancy GUI is not available to show that caps
> lock is activated.
> 
> This patch wires in the caps, num, and scroll lock states of the
> keyboard into the generic LED trigger subsystem, so that integrators can
> have different LEDs activated on caps/num/scroll lock state changes.

atkbd is the wrong level to introduce this functionality, as you want
the same for all other kinds of keyboards. Moreover needed changes from
Samuel Thibault have been merged into 4.2.

Thanks.

-- 
Dmitry

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

* [PATCH] Input: atkbd - add LED triggers for keyboard state
@ 2015-07-13 22:45 Jason A. Donenfeld
  2015-07-14  0:19 ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Jason A. Donenfeld @ 2015-07-13 22:45 UTC (permalink / raw)
  To: dmitry.torokhov, linux-input, linux-kernel; +Cc: Jason A. Donenfeld

Many new laptop keyboards aren't shipping with LEDs in the keys for
caps lock, num lock, and scroll lock. They do, however, ship with many LEDs
for specialized functions that mostly go non-utilized by any current
Linux drivers. Having a caps lock LED is very helpful in early boot full
disk encryption, where a fancy GUI is not available to show that caps
lock is activated.

This patch wires in the caps, num, and scroll lock states of the
keyboard into the generic LED trigger subsystem, so that integrators can
have different LEDs activated on caps/num/scroll lock state changes.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 drivers/input/keyboard/atkbd.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index ec876b5..d01f83c 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -28,6 +28,7 @@
 #include <linux/libps2.h>
 #include <linux/mutex.h>
 #include <linux/dmi.h>
+#include <linux/leds.h>
 
 #define DRIVER_DESC	"AT and PS/2 keyboard driver"
 
@@ -308,6 +309,12 @@ static const unsigned int xl_table[] = {
 	ATKBD_RET_NAK, ATKBD_RET_HANJA, ATKBD_RET_HANGEUL,
 };
 
+#ifdef CONFIG_LEDS_TRIGGERS
+struct led_trigger *capsl_led_trigger = 0;
+struct led_trigger *numl_led_trigger = 0;
+struct led_trigger *scrolll_led_trigger = 0;
+#endif
+
 /*
  * Checks if we should mangle the scancode to extract 'release' bit
  * in translated mode.
@@ -567,6 +574,12 @@ static int atkbd_set_leds(struct atkbd *atkbd)
 	if (ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_SETLEDS))
 		return -1;
 
+#ifdef CONFIG_LEDS_TRIGGERS
+	led_trigger_event(capsl_led_trigger, test_bit(LED_CAPSL, dev->led) ? LED_FULL : LED_OFF);
+	led_trigger_event(numl_led_trigger, test_bit(LED_NUML, dev->led) ? LED_FULL : LED_OFF);
+	led_trigger_event(scrolll_led_trigger, test_bit(LED_SCROLLL, dev->led) ? LED_FULL : LED_OFF);
+#endif
+
 	if (atkbd->extra) {
 		param[0] = 0;
 		param[1] = (test_bit(LED_COMPOSE, dev->led) ? 0x01 : 0)
@@ -1808,12 +1821,25 @@ static const struct dmi_system_id atkbd_dmi_quirk_table[] __initconst = {
 static int __init atkbd_init(void)
 {
 	dmi_check_system(atkbd_dmi_quirk_table);
+#ifdef CONFIG_LEDS_TRIGGERS
+	led_trigger_register_simple("caps-lock", &capsl_led_trigger);
+	led_trigger_register_simple("num-lock", &numl_led_trigger);
+	led_trigger_register_simple("scroll-lock", &scrolll_led_trigger);
+#endif
 
 	return serio_register_driver(&atkbd_drv);
 }
 
 static void __exit atkbd_exit(void)
 {
+#ifdef CONFIG_LEDS_TRIGGERS
+	led_trigger_unregister_simple(capsl_led_trigger);
+	capsl_led_trigger = 0;
+	led_trigger_unregister_simple(numl_led_trigger);
+	numl_led_trigger = 0;
+	led_trigger_unregister_simple(scrolll_led_trigger);
+	scrolll_led_trigger = 0;
+#endif
 	serio_unregister_driver(&atkbd_drv);
 }
 
-- 
2.4.5


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

end of thread, other threads:[~2015-07-14  0:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-02 21:05 [PATCH] Input: atkbd - add LED triggers for keyboard state Jason A. Donenfeld
2014-03-07 14:04 ` Pavel Machek
2015-07-13 22:45 Jason A. Donenfeld
2015-07-14  0:19 ` Dmitry Torokhov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.