summaryrefslogtreecommitdiff
path: root/include/media
diff options
context:
space:
mode:
Diffstat (limited to 'include/media')
-rw-r--r--include/media/ir-core.h47
1 files changed, 36 insertions, 11 deletions
diff --git a/include/media/ir-core.h b/include/media/ir-core.h
index e9fa94f..e9a0cbf 100644
--- a/include/media/ir-core.h
+++ b/include/media/ir-core.h
@@ -65,14 +65,12 @@ struct ir_dev_props {
void (*close)(void *priv);
};
-struct ir_raw_event {
- struct timespec delta; /* Time spent before event */
- enum raw_event_type type; /* event type */
-};
-
struct ir_raw_event_ctrl {
- struct kfifo kfifo; /* fifo for the pulse/space events */
- struct timespec last_event; /* when last event occurred */
+ struct work_struct rx_work; /* for the rx decoding workqueue */
+ struct kfifo kfifo; /* fifo for the pulse/space durations */
+ ktime_t last_event; /* when last event occurred */
+ enum raw_event_type last_type; /* last event type */
+ struct input_dev *input_dev; /* pointer to the parent input_dev */
};
struct ir_input_dev {
@@ -97,8 +95,7 @@ struct ir_input_dev {
struct ir_raw_handler {
struct list_head list;
- int (*decode)(struct input_dev *input_dev,
- struct ir_raw_event *ev);
+ int (*decode)(struct input_dev *input_dev, s64 duration);
int (*raw_register)(struct input_dev *input_dev);
int (*raw_unregister)(struct input_dev *input_dev);
};
@@ -154,8 +151,14 @@ void ir_unregister_class(struct input_dev *input_dev);
/* Routines from ir-raw-event.c */
int ir_raw_event_register(struct input_dev *input_dev);
void ir_raw_event_unregister(struct input_dev *input_dev);
-int ir_raw_event_store(struct input_dev *input_dev, enum raw_event_type type);
-int ir_raw_event_handle(struct input_dev *input_dev);
+void ir_raw_event_handle(struct input_dev *input_dev);
+int ir_raw_event_store(struct input_dev *input_dev, s64 duration);
+int ir_raw_event_store_edge(struct input_dev *input_dev, enum raw_event_type type);
+static inline void ir_raw_event_reset(struct input_dev *input_dev)
+{
+ ir_raw_event_store(input_dev, 0);
+ ir_raw_event_handle(input_dev);
+}
int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler);
void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler);
void ir_raw_init(void);
@@ -174,4 +177,26 @@ void ir_raw_init(void);
#define load_rc5_decode() 0
#endif
+/* macros for ir decoders */
+#define PULSE(units) ((units))
+#define SPACE(units) (-(units))
+#define IS_RESET(duration) ((duration) == 0)
+#define IS_PULSE(duration) ((duration) > 0)
+#define IS_SPACE(duration) ((duration) < 0)
+#define DURATION(duration) (abs((duration)))
+#define IS_TRANSITION(x, y) ((x) * (y) < 0)
+#define DECREASE_DURATION(duration, amount) \
+ do { \
+ if (IS_SPACE(duration)) \
+ duration += (amount); \
+ else if (IS_PULSE(duration)) \
+ duration -= (amount); \
+ } while (0)
+
+#define TO_UNITS(duration, unit_len) \
+ ((int)((duration) > 0 ? \
+ DIV_ROUND_CLOSEST(abs((duration)), (unit_len)) :\
+ -DIV_ROUND_CLOSEST(abs((duration)), (unit_len))))
+#define TO_US(duration) ((int)TO_UNITS(duration, 1000))
+
#endif /* _IR_CORE */