brcm2708: update 3.10 patches with raspberrypi/rpi-3.10.y of 27 Apr. 2014
[14.07/openwrt.git] / target / linux / brcm2708 / patches-3.10 / 0051-Added-inverted-transmitter-support.patch
1 From 09eb4e8210da3acb95f874f3ed2292f13e1f6ad3 Mon Sep 17 00:00:00 2001
2 From: pjennings <pjennings-git@pjennings.net>
3 Date: Wed, 20 Feb 2013 17:51:43 -0600
4 Subject: [PATCH 051/196] Added inverted transmitter support
5
6 ---
7  drivers/staging/media/lirc/lirc_rpi.c | 17 +++++++++++------
8  1 file changed, 11 insertions(+), 6 deletions(-)
9
10 diff --git a/drivers/staging/media/lirc/lirc_rpi.c b/drivers/staging/media/lirc/lirc_rpi.c
11 index 96acab0..5bb0dfe 100644
12 --- a/drivers/staging/media/lirc/lirc_rpi.c
13 +++ b/drivers/staging/media/lirc/lirc_rpi.c
14 @@ -68,6 +68,8 @@ static int debug;
15  static int sense = -1;
16  /* use softcarrier by default */
17  static int softcarrier = 1;
18 +/* 0 = do not invert output, 1 = invert output */
19 +static int invert = 0;
20  
21  struct gpio_chip *gpiochip;
22  struct irq_chip *irqchip;
23 @@ -135,10 +137,10 @@ static long send_pulse_softcarrier(unsigned long length)
24         actual = 0; target = 0; flag = 0;
25         while (actual < length) {
26                 if (flag) {
27 -                       gpiochip->set(gpiochip, gpio_out_pin, 0);
28 +                       gpiochip->set(gpiochip, gpio_out_pin, invert);
29                         target += space_width;
30                 } else {
31 -                       gpiochip->set(gpiochip, gpio_out_pin, 1);
32 +                       gpiochip->set(gpiochip, gpio_out_pin, !invert);
33                         target += pulse_width;
34                 }
35                 d = (target - actual -
36 @@ -162,7 +164,7 @@ static long send_pulse(unsigned long length)
37         if (softcarrier) {
38                 return send_pulse_softcarrier(length);
39         } else {
40 -               gpiochip->set(gpiochip, gpio_out_pin, 1);
41 +               gpiochip->set(gpiochip, gpio_out_pin, !invert);
42                 safe_udelay(length);
43                 return 0;
44         }
45 @@ -170,7 +172,7 @@ static long send_pulse(unsigned long length)
46  
47  static void send_space(long length)
48  {
49 -       gpiochip->set(gpiochip, gpio_out_pin, 0);
50 +       gpiochip->set(gpiochip, gpio_out_pin, invert);
51         if (length <= 0)
52                 return;
53         safe_udelay(length);
54 @@ -318,7 +320,7 @@ static int init_port(void)
55  
56         gpiochip->direction_input(gpiochip, gpio_in_pin);
57         gpiochip->direction_output(gpiochip, gpio_out_pin, 1);
58 -       gpiochip->set(gpiochip, gpio_out_pin, 0);
59 +       gpiochip->set(gpiochip, gpio_out_pin, invert);
60  
61         irq = gpiochip->to_irq(gpiochip, gpio_in_pin);
62         dprintk("to_irq %d\n", irq);
63 @@ -457,7 +459,7 @@ static ssize_t lirc_write(struct file *file, const char *buf,
64                 else
65                         delta = send_pulse(wbuf[i]);
66         }
67 -       gpiochip->set(gpiochip, gpio_out_pin, 0);
68 +       gpiochip->set(gpiochip, gpio_out_pin, invert);
69  
70         spin_unlock_irqrestore(&lock, flags);
71         kfree(wbuf);
72 @@ -683,5 +685,8 @@ MODULE_PARM_DESC(sense, "Override autodetection of IR receiver circuit"
73  module_param(softcarrier, bool, S_IRUGO);
74  MODULE_PARM_DESC(softcarrier, "Software carrier (0 = off, 1 = on, default on)");
75  
76 +module_param(invert, bool, S_IRUGO);
77 +MODULE_PARM_DESC(invert, "Invert output (0 = off, 1 = on, default off");
78 +
79  module_param(debug, bool, S_IRUGO | S_IWUSR);
80  MODULE_PARM_DESC(debug, "Enable debugging messages");
81 -- 
82 1.9.1
83