Add new event types for timeout & carrier report
Move timeout handling from ir_raw_event_store_with_filter to
ir-lirc-codec, where it is really needed.
Now lirc bridge ensures proper gap handling.
Extend lirc bridge for carrier & timeout reports
Note: all new ir_raw_event variables now should be initialized
like that:
struct ir_raw_event ev = ir_new_event;
Signed-off-by: Maxim Levitsky
---
drivers/media/IR/ene_ir.c |2 +-
drivers/media/IR/ene_ir.h |2 +-
drivers/media/IR/ir-core-priv.h| 11 +-
drivers/media/IR/ir-jvc-decoder.c |5 ++-
drivers/media/IR/ir-lirc-codec.c | 66
drivers/media/IR/ir-nec-decoder.c |5 ++-
drivers/media/IR/ir-raw-event.c| 41 +-
drivers/media/IR/ir-rc5-decoder.c |5 ++-
drivers/media/IR/ir-rc6-decoder.c |5 ++-
drivers/media/IR/ir-sony-decoder.c |5 ++-
drivers/media/IR/mceusb.c |2 +-
drivers/media/IR/streamzap.c |6 ++--
include/media/ir-core.h| 26 --
13 files changed, 121 insertions(+), 60 deletions(-)
diff --git a/drivers/media/IR/ene_ir.c b/drivers/media/IR/ene_ir.c
index 8e3e0c8..c7bbbca 100644
--- a/drivers/media/IR/ene_ir.c
+++ b/drivers/media/IR/ene_ir.c
@@ -699,7 +699,7 @@ static irqreturn_t ene_isr(int irq, void *data)
unsigned long flags;
irqreturn_t retval = IRQ_NONE;
struct ene_device *dev = (struct ene_device *)data;
- struct ir_raw_event ev;
+ struct ir_raw_event ev = ir_new_event;
spin_lock_irqsave(&dev->hw_lock, flags);
diff --git a/drivers/media/IR/ene_ir.h b/drivers/media/IR/ene_ir.h
index 69a0ae0..27b2eb0 100644
--- a/drivers/media/IR/ene_ir.h
+++ b/drivers/media/IR/ene_ir.h
@@ -188,7 +188,7 @@
* And there is nothing to change this setting
*/
-#define ENE_MAXGAP (0xFFF * 0x61)
+#define ENE_MAXGAP 2
#define ENE_MINGAP (127 * sample_period)
/**/
diff --git a/drivers/media/IR/ir-core-priv.h b/drivers/media/IR/ir-core-priv.h
index 5d7e08f..a287373 100644
--- a/drivers/media/IR/ir-core-priv.h
+++ b/drivers/media/IR/ir-core-priv.h
@@ -82,6 +82,10 @@ struct ir_raw_event_ctrl {
struct ir_input_dev *ir_dev;
struct lirc_driver *drv;
int carrier_low;
+ ktime_t timeout_start;
+ bool timeout;
+ bool send_timeout_reports;
+
} lirc;
};
@@ -109,9 +113,14 @@ static inline void decrease_duration(struct ir_raw_event
*ev, unsigned duration)
ev->duration -= duration;
}
+/* Returns true if event is normal pulse/space event */
+static inline bool is_timing_event(struct ir_raw_event ev)
+{
+ return !ev.carrier_report && !ev.reset;
+}
+
#define TO_US(duration)DIV_ROUND_CLOSEST((duration),
1000)
#define TO_STR(is_pulse) ((is_pulse) ? "pulse" : "space")
-#define IS_RESET(ev) (ev.duration == 0)
/*
* Routines from ir-sysfs.c - Meant to be called only internally inside
* ir-core
diff --git a/drivers/media/IR/ir-jvc-decoder.c
b/drivers/media/IR/ir-jvc-decoder.c
index 77a89c4..63dca6e 100644
--- a/drivers/media/IR/ir-jvc-decoder.c
+++ b/drivers/media/IR/ir-jvc-decoder.c
@@ -50,8 +50,9 @@ static int ir_jvc_decode(struct input_dev *input_dev, struct
ir_raw_event ev)
if (!(ir_dev->raw->enabled_protocols & IR_TYPE_JVC))
return 0;
- if (IS_RESET(ev)) {
- data->state = STATE_INACTIVE;
+ if (!is_timing_event(ev)) {
+ if (ev.reset)
+ data->state = STATE_INACTIVE;
return 0;
}
diff --git a/drivers/media/IR/ir-lirc-codec.c b/drivers/media/IR/ir-lirc-codec.c
index e63f757..e6ca7a3 100644
--- a/drivers/media/IR/ir-lirc-codec.c
+++ b/drivers/media/IR/ir-lirc-codec.c
@@ -32,7 +32,9 @@
static int ir_lirc_decode(struct input_dev *input_dev, struct ir_raw_event ev)
{
struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
+ struct lirc_codec *lirc = &ir_dev->raw->lirc;
int sample;
+ int duration_msec;
if (!(ir_dev->raw->enabled_protocols & IR_TYPE_LIRC))
return 0;
@@ -40,21 +42,56 @@ static int ir_lirc_decode(struct input_dev *input_dev,
struct ir_raw_event ev)
if (!ir_dev->raw->lirc.drv || !ir_dev->raw->lirc.drv->rbuf)
return -EINVAL;
- if (IS_RESET(ev))
+ duration_msec = DIV_ROUND_CLOSEST(ev.duration, 1000);
+
+ if (ev.reset)
return 0;
- IR_dprintk(2, "LIRC data transfer started (%uus %s)\n",
- TO_US(ev.duration), TO_STR(ev.pulse));
+ if (ev.carrier_report) {
+ /* TODO: send RX duty cycle */
+ sample = LIRC_FREQUENCY(ev.carrier);
+
+ } else if (ev.timeout) {
+