All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] leds: add touch screen LED triggers
@ 2021-03-04 12:04 qiuxiaojin
  2021-03-04 12:08 ` Pavel Machek
  0 siblings, 1 reply; 3+ messages in thread
From: qiuxiaojin @ 2021-03-04 12:04 UTC (permalink / raw)
  To: pavel, dmurphy, qiuxiaojin; +Cc: linux-kernel, linux-leds

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@cvte.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@ti.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


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

* Re: [PATCH] leds: add touch screen LED triggers
  2021-03-04 12:04 [PATCH] leds: add touch screen LED triggers qiuxiaojin
@ 2021-03-04 12:08 ` Pavel Machek
       [not found]   ` <2021030420435331766817@cvte.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Machek @ 2021-03-04 12:08 UTC (permalink / raw)
  To: qiuxiaojin; +Cc: dmurphy, qiuxiaojin, linux-kernel, linux-leds

[-- Attachment #1: Type: text/plain, Size: 497 bytes --]

On Thu 2021-03-04 20:04:49, qiuxiaojin wrote:
> 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().

Why?

> Signed-off-by: qiuxiaojin <qiuxiaojin@cvte.com>

Need real name and matching from: and signed-off.

								Pavel
-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: Re: [PATCH] leds: add touch screen LED triggers
       [not found]   ` <2021030420435331766817@cvte.com>
@ 2021-03-04 17:49     ` Pavel Machek
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Machek @ 2021-03-04 17:49 UTC (permalink / raw)
  To: qiuxiaojin; +Cc: qiuxiaojin, dmurphy, linux-kernel, linux-leds

[-- Attachment #1: Type: text/plain, Size: 520 bytes --]

On Thu 2021-03-04 20:43:53, qiuxiaojin@cvte.com wrote:
> > qiuxiaojin
> is my real name, maybe I should have my own english name

Sorry about that. I assumed it would start with capital letter.

> > why
> There is such a scene, when touching the screen, different LED actions can be triggered according to whether touch or not or different pressure values
>

Yes, I understand so far. I don't understand why you'd want such LED.

Best regards,
								Pavel

-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

end of thread, other threads:[~2021-03-04 17:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-04 12:04 [PATCH] leds: add touch screen LED triggers qiuxiaojin
2021-03-04 12:08 ` Pavel Machek
     [not found]   ` <2021030420435331766817@cvte.com>
2021-03-04 17:49     ` Pavel Machek

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.