[PATCH v2 16/30] staging: nvec: Enable the capslock LED in the keyboard driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When the caps lock key is pressed, toggle the associated
LED. According to Nvidia code, we should send 0x01 where
we sent 0x07, but this does not appear to work correctly
on the AC100.

Signed-off-by: Julian Andres Klode <jak@xxxxxxxxxxxxx>
Acked-by: Marc Dietrich <marvin24@xxxxxx>
---
 drivers/staging/nvec/nvec_kbd.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/nvec/nvec_kbd.c b/drivers/staging/nvec/nvec_kbd.c
index 167eac0..a4ce5a7 100644
--- a/drivers/staging/nvec/nvec_kbd.c
+++ b/drivers/staging/nvec/nvec_kbd.c
@@ -23,6 +23,8 @@
 
 #define ACK_KBD_EVENT {'\x05', '\xed', '\x01'}
 
+static const char led_on[3] = "\x05\xed\x07";
+static const char led_off[3] = "\x05\xed\x00";
 static unsigned char keycodes[ARRAY_SIZE(code_tab_102us)
 			      + ARRAY_SIZE(extcode_tab_us102)];
 
@@ -30,10 +32,21 @@ struct nvec_keys {
 	struct input_dev *input;
 	struct notifier_block notifier;
 	struct nvec_chip *nvec;
+	bool caps_lock;
 };
 
 static struct nvec_keys keys_dev;
 
+static void nvec_kbd_toggle_led(void)
+{
+	keys_dev.caps_lock = !keys_dev.caps_lock;
+
+	if (keys_dev.caps_lock)
+		nvec_write_async(keys_dev.nvec, led_on, sizeof(led_on));
+	else
+		nvec_write_async(keys_dev.nvec, led_off, sizeof(led_off));
+}
+
 static int nvec_keys_notifier(struct notifier_block *nb,
 			      unsigned long event_type, void *data)
 {
@@ -53,6 +66,9 @@ static int nvec_keys_notifier(struct notifier_block *nb,
 		code = msg[1] & 0x7f;
 		state = msg[1] & 0x80;
 
+		if (code_tabs[_size][code] == KEY_CAPSLOCK && state)
+			nvec_kbd_toggle_led();
+
 		input_report_key(keys_dev.input, code_tabs[_size][code],
 				 !state);
 		input_sync(keys_dev.input);
@@ -133,6 +149,9 @@ static int __devinit nvec_kbd_probe(struct platform_device *pdev)
 	or until we have a sync write */
 	mdelay(1000);
 
+	/* Disable caps lock LED */
+	nvec_write_async(nvec, led_off, sizeof(led_off));
+
 	return 0;
 
 fail:
-- 
1.7.5.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux