aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/brcm2708/patches-3.10/0051-Added-inverted-transmitter-support.patch
blob: 62826251b90b1b1c405ebf74aa0c8df3200006f0 (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
From 09eb4e8210da3acb95f874f3ed2292f13e1f6ad3 Mon Sep 17 00:00:00 2001
From: pjennings <pjennings-git@pjennings.net>
Date: Wed, 20 Feb 2013 17:51:43 -0600
Subject: [PATCH 051/196] Added inverted transmitter support

---
 drivers/staging/media/lirc/lirc_rpi.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_rpi.c b/drivers/staging/media/lirc/lirc_rpi.c
index 96acab0..5bb0dfe 100644
--- a/drivers/staging/media/lirc/lirc_rpi.c
+++ b/drivers/staging/media/lirc/lirc_rpi.c
@@ -68,6 +68,8 @@ static int debug;
 static int sense = -1;
 /* use softcarrier by default */
 static int softcarrier = 1;
+/* 0 = do not invert output, 1 = invert output */
+static int invert = 0;
 
 struct gpio_chip *gpiochip;
 struct irq_chip *irqchip;
@@ -135,10 +137,10 @@ static long send_pulse_softcarrier(unsigned long length)
 	actual = 0; target = 0; flag = 0;
 	while (actual < length) {
 		if (flag) {
-			gpiochip->set(gpiochip, gpio_out_pin, 0);
+			gpiochip->set(gpiochip, gpio_out_pin, invert);
 			target += space_width;
 		} else {
-			gpiochip->set(gpiochip, gpio_out_pin, 1);
+			gpiochip->set(gpiochip, gpio_out_pin, !invert);
 			target += pulse_width;
 		}
 		d = (target - actual -
@@ -162,7 +164,7 @@ static long send_pulse(unsigned long length)
 	if (softcarrier) {
 		return send_pulse_softcarrier(length);
 	} else {
-		gpiochip->set(gpiochip, gpio_out_pin, 1);
+		gpiochip->set(gpiochip, gpio_out_pin, !invert);
 		safe_udelay(length);
 		return 0;
 	}
@@ -170,7 +172,7 @@ static long send_pulse(unsigned long length)
 
 static void send_space(long length)
 {
-	gpiochip->set(gpiochip, gpio_out_pin, 0);
+	gpiochip->set(gpiochip, gpio_out_pin, invert);
 	if (length <= 0)
 		return;
 	safe_udelay(length);
@@ -318,7 +320,7 @@ static int init_port(void)
 
 	gpiochip->direction_input(gpiochip, gpio_in_pin);
 	gpiochip->direction_output(gpiochip, gpio_out_pin, 1);
-	gpiochip->set(gpiochip, gpio_out_pin, 0);
+	gpiochip->set(gpiochip, gpio_out_pin, invert);
 
 	irq = gpiochip->to_irq(gpiochip, gpio_in_pin);
 	dprintk("to_irq %d\n", irq);
@@ -457,7 +459,7 @@ static ssize_t lirc_write(struct file *file, const char *buf,
 		else
 			delta = send_pulse(wbuf[i]);
 	}
-	gpiochip->set(gpiochip, gpio_out_pin, 0);
+	gpiochip->set(gpiochip, gpio_out_pin, invert);
 
 	spin_unlock_irqrestore(&lock, flags);
 	kfree(wbuf);
@@ -683,5 +685,8 @@ MODULE_PARM_DESC(sense, "Override autodetection of IR receiver circuit"
 module_param(softcarrier, bool, S_IRUGO);
 MODULE_PARM_DESC(softcarrier, "Software carrier (0 = off, 1 = on, default on)");
 
+module_param(invert, bool, S_IRUGO);
+MODULE_PARM_DESC(invert, "Invert output (0 = off, 1 = on, default off");
+
 module_param(debug, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(debug, "Enable debugging messages");
-- 
1.9.1