From patchwork Mon Jul 13 22:45:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 6782571 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 29EFAC05AC for ; Mon, 13 Jul 2015 22:52:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 45AF52061B for ; Mon, 13 Jul 2015 22:52:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3EA3A20558 for ; Mon, 13 Jul 2015 22:52:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751117AbbGMWwv (ORCPT ); Mon, 13 Jul 2015 18:52:51 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:44066 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751093AbbGMWwu (ORCPT ); Mon, 13 Jul 2015 18:52:50 -0400 X-Greylist: delayed 401 seconds by postgrey-1.27 at vger.kernel.org; Mon, 13 Jul 2015 18:52:50 EDT Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 74fe1c6f; Mon, 13 Jul 2015 22:45:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id; s=mail; bh=ZkwM3CEUa2z3m6ny+vwJOZ2E5vM =; b=0bqmqNHGuZEOOYO3fGBuSTXMMYsRap/zOThnz7S0OBuaRQYIMq15Co0Gyj5 1xzkZyot0c4/pfuLNVajI1+jhPXD3idwrxl8vmpIgOaP4lmVdxLFo5RDTT3JsnKz Y3MqM/v4PI0pwnrUs6esL0m/D6j+kzZRDXC4akSxVgmyOxtz0bRWPNQsv3E/qn1C 37XHgy9OlV16RCtZJvjRgCnhjYgoAD2UfqXrjI8hX8msbgajguk8akniDVtIFnwX 8BJlzy3UqhDL8PfbZCKb/HYXwjxtwx9WtgnE/6ndq2AJUAlx4ytn6KVAgIIFa0PG oeitOTjzNAGrC/umQCECHWGlzYg== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 224761ba TLS version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO; Mon, 13 Jul 2015 22:45:41 +0000 (UTC) From: "Jason A. Donenfeld" To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Jason A. Donenfeld" Subject: [PATCH] Input: atkbd - add LED triggers for keyboard state Date: Tue, 14 Jul 2015 00:45:54 +0200 Message-Id: <1436827554-2186-1-git-send-email-Jason@zx2c4.com> X-Mailer: git-send-email 2.4.5 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 #include #include +#include #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); }