summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Young <sean@mess.org>2018-03-08 09:42:44 -0500
committerTao Huang <huangtao@rock-chips.com>2018-12-10 20:36:34 +0800
commit6c8c59d8c7dce3b5fa07fb9f9d057c7c0b5abacd (patch)
tree2a311d76d62b23396b268bda4e04b8dd93c3b9a0
parent0d22cc0e86ea009f9fd7ae853e90aca54d60cd24 (diff)
UPSTREAM: media: rc: meson-ir: add timeout on idle
Meson doesn't seem to be able to generate timeout events in hardware. So install a software timer to generate the timeout events required by the decoders to prevent "ghost keypresses". Reported-by: Matthias Reichl <hias@horus.com> Tested-by: Matthias Reichl <hias@horus.com> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> (cherry picked from commit 8d7a77ce56cdb5f50b83ca0c59a31362e1a5eeb4) Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com> Conflicts: drivers/media/rc/meson-ir.c
-rw-r--r--drivers/media/rc/rc-ir-raw.c30
-rw-r--r--include/media/rc-core.h4
2 files changed, 30 insertions, 4 deletions
diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c
index 74b25e41d547..997bfb75716f 100644
--- a/drivers/media/rc/rc-ir-raw.c
+++ b/drivers/media/rc/rc-ir-raw.c
@@ -101,7 +101,6 @@ int ir_raw_event_store_edge(struct rc_dev *dev, bool pulse)
{
ktime_t now;
DEFINE_IR_RAW_EVENT(ev);
- int rc = 0;
if (!dev->raw)
return -EINVAL;
@@ -110,8 +109,33 @@ int ir_raw_event_store_edge(struct rc_dev *dev, bool pulse)
ev.duration = ktime_to_ns(ktime_sub(now, dev->raw->last_event));
ev.pulse = !pulse;
+ return ir_raw_event_store_with_timeout(dev, &ev);
+}
+EXPORT_SYMBOL_GPL(ir_raw_event_store_edge);
+
+/*
+ * ir_raw_event_store_with_timeout() - pass a pulse/space duration to the raw
+ * ir decoders, schedule decoding and
+ * timeout
+ * @dev: the struct rc_dev device descriptor
+ * @ev: the struct ir_raw_event descriptor of the pulse/space
+ *
+ * This routine (which may be called from an interrupt context) stores a
+ * pulse/space duration for the raw ir decoding state machines, schedules
+ * decoding and generates a timeout.
+ */
+int ir_raw_event_store_with_timeout(struct rc_dev *dev, struct ir_raw_event *ev)
+{
+ ktime_t now;
+ int rc = 0;
+
+ if (!dev->raw)
+ return -EINVAL;
+
+ now = ktime_get();
+
spin_lock(&dev->raw->edge_spinlock);
- rc = ir_raw_event_store(dev, &ev);
+ rc = ir_raw_event_store(dev, ev);
dev->raw->last_event = now;
@@ -126,7 +150,7 @@ int ir_raw_event_store_edge(struct rc_dev *dev, bool pulse)
return rc;
}
-EXPORT_SYMBOL_GPL(ir_raw_event_store_edge);
+EXPORT_SYMBOL_GPL(ir_raw_event_store_with_timeout);
/**
* ir_raw_event_store_with_filter() - pass next pulse/space to decoders with some processing
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index 63503460f7bb..c077c07318bf 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -348,7 +348,9 @@ void ir_raw_event_handle(struct rc_dev *dev);
int ir_raw_event_store(struct rc_dev *dev, struct ir_raw_event *ev);
int ir_raw_event_store_edge(struct rc_dev *dev, bool pulse);
int ir_raw_event_store_with_filter(struct rc_dev *dev,
- struct ir_raw_event *ev);
+ struct ir_raw_event *ev);
+int ir_raw_event_store_with_timeout(struct rc_dev *dev,
+ struct ir_raw_event *ev);
void ir_raw_event_set_idle(struct rc_dev *dev, bool idle);
int ir_raw_encode_scancode(enum rc_proto protocol, u32 scancode,
struct ir_raw_event *events, unsigned int max);