summaryrefslogtreecommitdiff
path: root/recipes-kernel/vizzini/vizzini-1.1/vizzini-1.1-ledrtig.patch
blob: 7d8e03ae60cc3a7b6735f9eac68d50afa0d2fc66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
diff -ur orig/vizzini.c new/vizzini.c
--- orig/vizzini.c	2017-07-21 13:55:37.000000000 +0300
+++ new/vizzini.c	2017-07-20 15:37:52.000000000 +0300
@@ -54,6 +54,8 @@
 #include <linux/fcntl.h>
 #include <asm/uaccess.h>
 
+#include <linux/leds.h>
+
 
 #include "vizzini.h"
 #include "vzioctl.h"
@@ -71,6 +73,38 @@
 static DEFINE_MUTEX(xr21v141x_table_lock);
 
 /*
+ * LED triggers
+ */
+
+static void xr21v141x_register_led_triggers(struct xr21v141x *xr21v141x)
+{
+#ifdef CONFIG_LEDS_TRIGGERS
+	xr21v141x->led_trigger_rx_delay_on = 50;
+	xr21v141x->led_trigger_rx_delay_off = 1;
+	sprintf(xr21v141x->led_trigger_rx_name, "vizzini%d-rx", xr21v141x->minor);
+	led_trigger_register_simple(xr21v141x->led_trigger_rx_name, &xr21v141x->led_trigger_rx);
+
+	xr21v141x->led_trigger_tx_delay_on = 50;
+	xr21v141x->led_trigger_tx_delay_off = 1;
+	sprintf(xr21v141x->led_trigger_tx_name, "vizzini%d-tx", xr21v141x->minor);
+	led_trigger_register_simple(xr21v141x->led_trigger_tx_name, &xr21v141x->led_trigger_tx);
+
+	dev_info(&xr21v141x->control->dev, "%s and %s led triggers registered\n",
+		xr21v141x->led_trigger_rx_name, xr21v141x->led_trigger_tx_name);
+#endif
+}
+
+static void xr21v141x_unregister_led_triggers(struct xr21v141x *xr21v141x)
+{
+#ifdef CONFIG_LEDS_TRIGGERS
+	led_trigger_unregister_simple(xr21v141x->led_trigger_rx);
+	led_trigger_unregister_simple(xr21v141x->led_trigger_tx);
+	dev_info(&xr21v141x->control->dev, "led triggers unregistered\n");
+#endif
+}
+
+
+/*
  * Functions for ACM control messages.
  */
 
@@ -330,6 +364,11 @@
 	if (!urb->actual_length)
 		return;
 
+#ifdef CONFIG_LEDS_TRIGGERS
+	led_trigger_blink_oneshot(xr21v141x->led_trigger_rx,
+		&xr21v141x->led_trigger_rx_delay_on,
+		&xr21v141x->led_trigger_rx_delay_off, 0);
+#endif
 
 	tty_insert_flip_string(&xr21v141x->port, urb->transfer_buffer, urb->actual_length);
 	tty_flip_buffer_push(&xr21v141x->port);
@@ -653,6 +692,12 @@
 	
 	spin_unlock_irqrestore(&xr21v141x->write_lock, flags);
 
+#ifdef CONFIG_LEDS_TRIGGERS
+	led_trigger_blink_oneshot(xr21v141x->led_trigger_tx,
+		&xr21v141x->led_trigger_tx_delay_on,
+		&xr21v141x->led_trigger_tx_delay_off, 0);
+#endif
+
 	
 	if (stat < 0)
 		return stat;
@@ -1723,6 +1768,9 @@
 	}
 #endif		
      
+
+	xr21v141x_register_led_triggers(xr21v141x);
+
 	return 0;
 alloc_fail8:
 		if (xr21v141x->country_codes) {
@@ -1817,6 +1865,8 @@
 					xr21v141x->data : xr21v141x->control);
 
 	tty_port_put(&xr21v141x->port);
+
+	xr21v141x_unregister_led_triggers(xr21v141x);
 }
 
 #ifdef CONFIG_PM
diff -ur orig/vizzini.h new/vizzini.h
--- orig/vizzini.h	2017-07-21 13:55:37.000000000 +0300
+++ new/vizzini.h	2017-07-20 15:36:57.000000000 +0300
@@ -282,6 +282,18 @@
 #ifdef VIZZINI_IWA
         int           iwa;
 #endif
+
+#ifdef CONFIG_LEDS_TRIGGERS
+	char led_trigger_rx_name[32];
+	unsigned long led_trigger_rx_delay_on;
+	unsigned long led_trigger_rx_delay_off;
+	struct led_trigger *led_trigger_rx;
+	char led_trigger_tx_name[32];
+	unsigned long led_trigger_tx_delay_on;
+	unsigned long led_trigger_tx_delay_off;
+	struct led_trigger *led_trigger_tx;
+#endif
+
 	struct serial_rs485 rs485;
 };