aboutsummaryrefslogtreecommitdiffstats
path: root/include/media
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2010-03-20 19:59:44 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-17 23:52:56 -0400
commita3572c34da8dacc78a629211a91cf34e9b408701 (patch)
tree281efd4d69b68bd4720668fd91cfcf16d1ed3089 /include/media
parent0210894956cf57d525d56341cc3e0f3d5d2db659 (diff)
V4L/DVB: ir-core: Add logic to decode IR protocols at the IR core
Adds a method to pass IR raw pulse/code events into ir-core. This is needed in order to support LIRC. It also helps to move common code from the drivers into the core. In order to allow testing, it implements a simple NEC protocol decoder at ir-nec-decoder.c file. The logic is about the same used at saa7134 driver that handles Avermedia M135A and Encore FM53 boards. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include/media')
-rw-r--r--include/media/ir-common.h3
-rw-r--r--include/media/ir-core.h32
2 files changed, 35 insertions, 0 deletions
diff --git a/include/media/ir-common.h b/include/media/ir-common.h
index 41469b79ad1..87f2ec78deb 100644
--- a/include/media/ir-common.h
+++ b/include/media/ir-common.h
@@ -82,6 +82,9 @@ struct card_ir {
82 /* NEC decoding */ 82 /* NEC decoding */
83 u32 nec_gpio; 83 u32 nec_gpio;
84 struct tasklet_struct tlet; 84 struct tasklet_struct tlet;
85
86 /* IR core raw decoding */
87 u32 raw_decode;
85}; 88};
86 89
87/* Routines from ir-functions.c */ 90/* Routines from ir-functions.c */
diff --git a/include/media/ir-core.h b/include/media/ir-core.h
index 1eae72d518e..369969d9077 100644
--- a/include/media/ir-core.h
+++ b/include/media/ir-core.h
@@ -16,6 +16,8 @@
16 16
17#include <linux/input.h> 17#include <linux/input.h>
18#include <linux/spinlock.h> 18#include <linux/spinlock.h>
19#include <linux/kfifo.h>
20#include <linux/time.h>
19 21
20extern int ir_core_debug; 22extern int ir_core_debug;
21#define IR_dprintk(level, fmt, arg...) if (ir_core_debug >= level) \ 23#define IR_dprintk(level, fmt, arg...) if (ir_core_debug >= level) \
@@ -27,6 +29,13 @@ extern int ir_core_debug;
27#define IR_TYPE_NEC (1 << 2) 29#define IR_TYPE_NEC (1 << 2)
28#define IR_TYPE_OTHER (((u64)1) << 63l) 30#define IR_TYPE_OTHER (((u64)1) << 63l)
29 31
32enum raw_event_type {
33 IR_SPACE = (1 << 0),
34 IR_PULSE = (1 << 1),
35 IR_START_EVENT = (1 << 2),
36 IR_STOP_EVENT = (1 << 3),
37};
38
30struct ir_scancode { 39struct ir_scancode {
31 u16 scancode; 40 u16 scancode;
32 u32 keycode; 41 u32 keycode;
@@ -46,6 +55,15 @@ struct ir_dev_props {
46 int (*change_protocol)(void *priv, u64 ir_type); 55 int (*change_protocol)(void *priv, u64 ir_type);
47}; 56};
48 57
58struct ir_raw_event {
59 struct timespec delta; /* Time spent before event */
60 enum raw_event_type type; /* event type */
61};
62
63struct ir_raw_event_ctrl {
64 struct kfifo kfifo; /* fifo for the pulse/space events */
65 struct timespec last_event; /* when last event occurred */
66};
49 67
50struct ir_input_dev { 68struct ir_input_dev {
51 struct device dev; /* device */ 69 struct device dev; /* device */
@@ -53,7 +71,9 @@ struct ir_input_dev {
53 struct ir_scancode_table rc_tab; /* scan/key table */ 71 struct ir_scancode_table rc_tab; /* scan/key table */
54 unsigned long devno; /* device number */ 72 unsigned long devno; /* device number */
55 const struct ir_dev_props *props; /* Device properties */ 73 const struct ir_dev_props *props; /* Device properties */
74 struct ir_raw_event_ctrl *raw; /* for raw pulse/space events */
56}; 75};
76
57#define to_ir_input_dev(_attr) container_of(_attr, struct ir_input_dev, attr) 77#define to_ir_input_dev(_attr) container_of(_attr, struct ir_input_dev, attr)
58 78
59/* Routines from ir-keytable.c */ 79/* Routines from ir-keytable.c */
@@ -72,4 +92,16 @@ void ir_input_unregister(struct input_dev *input_dev);
72int ir_register_class(struct input_dev *input_dev); 92int ir_register_class(struct input_dev *input_dev);
73void ir_unregister_class(struct input_dev *input_dev); 93void ir_unregister_class(struct input_dev *input_dev);
74 94
95/* Routines from ir-raw-event.c */
96int ir_raw_event_register(struct input_dev *input_dev);
97void ir_raw_event_unregister(struct input_dev *input_dev);
98int ir_raw_event_store(struct input_dev *input_dev, enum raw_event_type type);
99int ir_raw_event_handle(struct input_dev *input_dev);
100
101/* from ir-nec-decoder.c */
102int ir_nec_decode(struct input_dev *input_dev,
103 struct ir_raw_event *evs,
104 int len);
105
106
75#endif 107#endif