brcm2708-gpu-fw: update to latest version
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.4 / 0380-media-rc-gpio-ir-recv-add-timeout-on-idle.patch
1 From 87909c64d14dc0f907ebe95f77874075a75e7f66 Mon Sep 17 00:00:00 2001
2 From: Eric Nelson <eric@nelint.com>
3 Date: Wed, 23 Sep 2015 11:07:08 -0300
4 Subject: [PATCH 380/423] [media] rc: gpio-ir-recv: add timeout on idle
5
6 Many decoders require a trailing space (period without IR illumination)
7 to be delivered before completing a decode.
8
9 Since the gpio-ir-recv driver only delivers events on gpio transitions,
10 a single IR symbol (caused by a quick touch on an IR remote) will not
11 be properly decoded without the use of a timer to flush the tail end
12 state of the IR receiver.
13
14 This patch initializes and uses a timer and the timeout field of rcdev
15 to complete the stream and allow decode.
16
17 The timeout can be overridden through the use of the LIRC_SET_REC_TIMEOUT
18 ioctl.
19
20 Signed-off-by: Eric Nelson <eric@nelint.com>
21 Acked-by: Sean Young <sean@mess.org>
22 Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
23 ---
24 drivers/media/rc/gpio-ir-recv.c | 22 ++++++++++++++++++++++
25 1 file changed, 22 insertions(+)
26
27 --- a/drivers/media/rc/gpio-ir-recv.c
28 +++ b/drivers/media/rc/gpio-ir-recv.c
29 @@ -30,6 +30,7 @@ struct gpio_rc_dev {
30 struct rc_dev *rcdev;
31 int gpio_nr;
32 bool active_low;
33 + struct timer_list flush_timer;
34 };
35
36 #ifdef CONFIG_OF
37 @@ -93,12 +94,26 @@ static irqreturn_t gpio_ir_recv_irq(int
38 if (rc < 0)
39 goto err_get_value;
40
41 + mod_timer(&gpio_dev->flush_timer,
42 + jiffies + nsecs_to_jiffies(gpio_dev->rcdev->timeout));
43 +
44 ir_raw_event_handle(gpio_dev->rcdev);
45
46 err_get_value:
47 return IRQ_HANDLED;
48 }
49
50 +static void flush_timer(unsigned long arg)
51 +{
52 + struct gpio_rc_dev *gpio_dev = (struct gpio_rc_dev *)arg;
53 + DEFINE_IR_RAW_EVENT(ev);
54 +
55 + ev.timeout = true;
56 + ev.duration = gpio_dev->rcdev->timeout;
57 + ir_raw_event_store(gpio_dev->rcdev, &ev);
58 + ir_raw_event_handle(gpio_dev->rcdev);
59 +}
60 +
61 static int gpio_ir_recv_probe(struct platform_device *pdev)
62 {
63 struct gpio_rc_dev *gpio_dev;
64 @@ -144,6 +159,9 @@ static int gpio_ir_recv_probe(struct pla
65 rcdev->input_id.version = 0x0100;
66 rcdev->dev.parent = &pdev->dev;
67 rcdev->driver_name = GPIO_IR_DRIVER_NAME;
68 + rcdev->min_timeout = 0;
69 + rcdev->timeout = IR_DEFAULT_TIMEOUT;
70 + rcdev->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
71 if (pdata->allowed_protos)
72 rcdev->allowed_protocols = pdata->allowed_protos;
73 else
74 @@ -154,6 +172,9 @@ static int gpio_ir_recv_probe(struct pla
75 gpio_dev->gpio_nr = pdata->gpio_nr;
76 gpio_dev->active_low = pdata->active_low;
77
78 + setup_timer(&gpio_dev->flush_timer, flush_timer,
79 + (unsigned long)gpio_dev);
80 +
81 rc = gpio_request(pdata->gpio_nr, "gpio-ir-recv");
82 if (rc < 0)
83 goto err_gpio_request;
84 @@ -196,6 +217,7 @@ static int gpio_ir_recv_remove(struct pl
85 struct gpio_rc_dev *gpio_dev = platform_get_drvdata(pdev);
86
87 free_irq(gpio_to_irq(gpio_dev->gpio_nr), gpio_dev);
88 + del_timer_sync(&gpio_dev->flush_timer);
89 rc_unregister_device(gpio_dev->rcdev);
90 gpio_free(gpio_dev->gpio_nr);
91 kfree(gpio_dev);