mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-29 05:36:47 +00:00
[kernel/WeTek_Play] - add a network link led trigger which allows to bind leds to the link status of either eth (ethlink) or wifi (wifilink) via /sys/class/leds/<ledname>/trigger
This commit is contained in:
parent
4f2f6d26d0
commit
5f11db6557
@ -3063,6 +3063,7 @@ CONFIG_LEDS_TRIGGERS=y
|
||||
CONFIG_LEDS_TRIGGER_TIMER=y
|
||||
CONFIG_LEDS_TRIGGER_ONESHOT=y
|
||||
CONFIG_LEDS_TRIGGER_REMOTE_CONTROL=y
|
||||
CONFIG_LEDS_TRIGGER_NETWORK=y
|
||||
CONFIG_LEDS_TRIGGER_HEARTBEAT=y
|
||||
# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set
|
||||
CONFIG_LEDS_TRIGGER_CPU=y
|
||||
|
@ -0,0 +1,127 @@
|
||||
From 9d998299c324d107cfb663f5e1e1bdf435f1cc66 Mon Sep 17 00:00:00 2001
|
||||
From: Memphiz <memphis@machzwo.de>
|
||||
Date: Sun, 8 Mar 2015 22:11:34 +0100
|
||||
Subject: [PATCH 3/6] [WeTek_Play] - add network link status ledtrigger -
|
||||
allows to assign leds to weteks network link status (either eth or wifi)
|
||||
|
||||
---
|
||||
drivers/leds/trigger/Kconfig | 7 +++
|
||||
drivers/leds/trigger/Makefile | 1 +
|
||||
drivers/leds/trigger/ledtrig-network.c | 79 ++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 87 insertions(+)
|
||||
create mode 100644 drivers/leds/trigger/ledtrig-network.c
|
||||
|
||||
diff --git a/drivers/leds/trigger/Kconfig b/drivers/leds/trigger/Kconfig
|
||||
index e911914..4d889bb 100644
|
||||
--- a/drivers/leds/trigger/Kconfig
|
||||
+++ b/drivers/leds/trigger/Kconfig
|
||||
@@ -48,6 +48,13 @@ config LEDS_TRIGGER_REMOTE_CONTROL
|
||||
This allows LEDs to be controlled by Remote Control activity.
|
||||
If unsure, say Y.
|
||||
|
||||
+config LEDS_TRIGGER_NETWORK
|
||||
+ bool "LED network link trigger"
|
||||
+ depends on LEDS_TRIGGERS
|
||||
+ help
|
||||
+ This allows LEDs to be controlled by network link status.
|
||||
+ If unsure, say Y.
|
||||
+
|
||||
config LEDS_TRIGGER_HEARTBEAT
|
||||
tristate "LED Heartbeat Trigger"
|
||||
depends on LEDS_TRIGGERS
|
||||
diff --git a/drivers/leds/trigger/Makefile b/drivers/leds/trigger/Makefile
|
||||
index 868976b..4bbe38f 100644
|
||||
--- a/drivers/leds/trigger/Makefile
|
||||
+++ b/drivers/leds/trigger/Makefile
|
||||
@@ -9,3 +9,4 @@ obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o
|
||||
obj-$(CONFIG_LEDS_TRIGGER_TRANSIENT) += ledtrig-transient.o
|
||||
obj-$(CONFIG_LEDS_TRIGGER_CAMERA) += ledtrig-camera.o
|
||||
obj-$(CONFIG_LEDS_TRIGGER_REMOTE_CONTROL) += ledtrig-remote-control.o
|
||||
+obj-$(CONFIG_LEDS_TRIGGER_NETWORK) += ledtrig-network.o
|
||||
diff --git a/drivers/leds/trigger/ledtrig-network.c b/drivers/leds/trigger/ledtrig-network.c
|
||||
new file mode 100644
|
||||
index 0000000..790aa10
|
||||
--- /dev/null
|
||||
+++ b/drivers/leds/trigger/ledtrig-network.c
|
||||
@@ -0,0 +1,79 @@
|
||||
+/*
|
||||
+ * LED Network Trigger
|
||||
+ *
|
||||
+ * Copyright 2015 Memphiz (memphiz@kodi.tv)
|
||||
+ *
|
||||
+ * 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/jiffies.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/init.h>
|
||||
+#include <linux/timer.h>
|
||||
+#include <linux/leds.h>
|
||||
+
|
||||
+void ledtrig_eth_linkup(struct led_classdev *led_cdev);
|
||||
+void ledtrig_eth_linkdown(struct led_classdev *led_cdev);
|
||||
+void ledtrig_wifi_linkup(struct led_classdev *led_cdev);
|
||||
+void ledtrig_wifi_linkdown(struct led_classdev *led_cdev);
|
||||
+
|
||||
+static struct led_trigger ledtrig_eth = {
|
||||
+ .name = "ethlink",
|
||||
+ .activate = ledtrig_eth_linkup,
|
||||
+ .deactivate = ledtrig_eth_linkdown,
|
||||
+};
|
||||
+
|
||||
+static struct led_trigger ledtrig_wifi = {
|
||||
+ .name = "wifilink",
|
||||
+ .activate = ledtrig_wifi_linkup,
|
||||
+ .deactivate = ledtrig_wifi_linkdown,
|
||||
+};
|
||||
+
|
||||
+void ledtrig_eth_linkup(struct led_classdev *led_cdev)
|
||||
+{
|
||||
+ led_trigger_event(&ledtrig_eth, INT_MAX);
|
||||
+}
|
||||
+EXPORT_SYMBOL(ledtrig_eth_linkup);
|
||||
+
|
||||
+void ledtrig_eth_linkdown(struct led_classdev *led_cdev)
|
||||
+{
|
||||
+ led_trigger_event(&ledtrig_eth, LED_OFF);
|
||||
+}
|
||||
+EXPORT_SYMBOL(ledtrig_eth_linkdown);
|
||||
+
|
||||
+void ledtrig_wifi_linkup(struct led_classdev *led_cdev)
|
||||
+{
|
||||
+ led_trigger_event(&ledtrig_wifi, INT_MAX);
|
||||
+}
|
||||
+EXPORT_SYMBOL(ledtrig_wifi_linkup);
|
||||
+
|
||||
+void ledtrig_wifi_linkdown(struct led_classdev *led_cdev)
|
||||
+{
|
||||
+ led_trigger_event(&ledtrig_wifi, LED_OFF);
|
||||
+}
|
||||
+EXPORT_SYMBOL(ledtrig_wifi_linkdown);
|
||||
+
|
||||
+static int __init ledtrig_network_init(void)
|
||||
+{
|
||||
+ led_trigger_register(&ledtrig_eth);
|
||||
+ led_trigger_register(&ledtrig_wifi);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void __exit ledtrig_network_exit(void)
|
||||
+{
|
||||
+ led_trigger_unregister(&ledtrig_eth);
|
||||
+ led_trigger_unregister(&ledtrig_wifi);
|
||||
+}
|
||||
+
|
||||
+module_init(ledtrig_network_init);
|
||||
+module_exit(ledtrig_network_exit);
|
||||
+
|
||||
+MODULE_AUTHOR("Memphiz <memphiz@kodi.tv>");
|
||||
+MODULE_DESCRIPTION("LED Network link trigger");
|
||||
+MODULE_LICENSE("GPL");
|
||||
+
|
||||
--
|
||||
1.9.3 (Apple Git-50)
|
Loading…
x
Reference in New Issue
Block a user