lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210304120449.10441-1-qiuxiaojin@cvte.com>
Date:   Thu,  4 Mar 2021 20:04:49 +0800
From:   qiuxiaojin <qxj511mail@...il.com>
To:     pavel@....cz, dmurphy@...com, qiuxiaojin@...e.com
Cc:     linux-kernel@...r.kernel.org, linux-leds@...r.kernel.org
Subject: [PATCH] leds: add touch screen LED triggers

Some LED devices support touch screen.
This patch enables direct LED trigger controls by the driver.
touch screen or pressure can be done simply by other driver space.
Two trigger APIs are added, ledtrig_touch_panel_ctrl()
and ledtrig_touch_pressure_ctrl().

Signed-off-by: qiuxiaojin <qiuxiaojin@...e.com>
---
 drivers/leds/trigger/Kconfig                |  6 +++
 drivers/leds/trigger/Makefile               |  1 +
 drivers/leds/trigger/ledtrig-touch-screen.c | 56 +++++++++++++++++++++
 include/linux/leds.h                        |  8 +++
 4 files changed, 71 insertions(+)
 create mode 100644 drivers/leds/trigger/ledtrig-touch-screen.c

diff --git a/drivers/leds/trigger/Kconfig b/drivers/leds/trigger/Kconfig
index ce9429ca6dde..e0802a71c4c2 100644
--- a/drivers/leds/trigger/Kconfig
+++ b/drivers/leds/trigger/Kconfig
@@ -144,4 +144,10 @@ config LEDS_TRIGGER_AUDIO
 	  the audio mute and mic-mute changes.
 	  If unsure, say N
 
+config LEDS_TRIGGER_TOUCH_SCREEN
+	tristate "LED Touch Screen Trigger"
+	help
+	  This allows LEDs to be controlled as a touch screen device.
+	  This enables direct touch on/off by the driver, kernel space.
+	  If unsure, say Y
 endif # LEDS_TRIGGERS
diff --git a/drivers/leds/trigger/Makefile b/drivers/leds/trigger/Makefile
index 733a83e2a718..ff659f56f9ad 100644
--- a/drivers/leds/trigger/Makefile
+++ b/drivers/leds/trigger/Makefile
@@ -15,3 +15,4 @@ obj-$(CONFIG_LEDS_TRIGGER_PANIC)	+= ledtrig-panic.o
 obj-$(CONFIG_LEDS_TRIGGER_NETDEV)	+= ledtrig-netdev.o
 obj-$(CONFIG_LEDS_TRIGGER_PATTERN)	+= ledtrig-pattern.o
 obj-$(CONFIG_LEDS_TRIGGER_AUDIO)	+= ledtrig-audio.o
+obj-$(CONFIG_LEDS_TRIGGER_TOUCH_SCREEN)	+= ledtrig-touch-screen.o
diff --git a/drivers/leds/trigger/ledtrig-touch-screen.c b/drivers/leds/trigger/ledtrig-touch-screen.c
new file mode 100644
index 000000000000..9a80e9991f45
--- /dev/null
+++ b/drivers/leds/trigger/ledtrig-touch-screen.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Touch Screen Control Trigger
+ *
+ * based on ledtrig-camera.c
+ *
+ * Copyright 2013 Texas Instruments
+ *
+ * Author: Milo(Woogyom) Kim <milo.kim@...com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/leds.h>
+
+DEFINE_LED_TRIGGER(ledtrig_touch_panel);
+DEFINE_LED_TRIGGER(ledtrig_touch_pressure);
+
+void ledtrig_touch_panel_ctrl(bool on)
+{
+	enum led_brightness brt = on ? LED_FULL : LED_OFF;
+
+	led_trigger_event(ledtrig_touch_panel, brt);
+}
+EXPORT_SYMBOL_GPL(ledtrig_touch_panel_ctrl);
+
+void ledtrig_touch_pressure_ctrl(enum led_brightness brt)
+{
+	led_trigger_event(ledtrig_touch_pressure, brt);
+}
+EXPORT_SYMBOL_GPL(ledtrig_touch_pressure_ctrl);
+
+static int __init ledtrig_touch_screen_init(void)
+{
+	led_trigger_register_simple("ts_touch", &ledtrig_touch_panel);
+	led_trigger_register_simple("ts_pressure", &ledtrig_touch_pressure);
+	return 0;
+}
+module_init(ledtrig_touch_screen_init);
+
+static void __exit ledtrig_touch_screen_exit(void)
+{
+	led_trigger_unregister_simple(ledtrig_touch_pressure);
+	led_trigger_unregister_simple(ledtrig_touch_panel);
+}
+module_exit(ledtrig_touch_screen_exit);
+
+MODULE_DESCRIPTION("LED Trigger for Touch Screen Control");
+MODULE_AUTHOR("qiuxiaojin");
+MODULE_LICENSE("GPL v2");
diff --git a/include/linux/leds.h b/include/linux/leds.h
index 6a8d6409c993..cd1a4bd73185 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -481,6 +481,14 @@ static inline void ledtrig_flash_ctrl(bool on) {}
 static inline void ledtrig_torch_ctrl(bool on) {}
 #endif
 
+#if defined(CONFIG_LEDS_TRIGGER_TOUCH_SCREEN)
+extern void ledtrig_touch_panel_ctrl(bool on);
+extern void ledtrig_touch_pressure_ctrl(enum led_brightness brt);
+#else
+static inline void ledtrig_touch_panel_ctrl(bool on) {}
+static inline void ledtrig_touch_pressure_ctrl(enum led_brightness brt)
+#endif
+
 /*
  * Generic LED platform data for describing LED names and default triggers.
  */
-- 
2.21.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ