diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-03-20 19:59:44 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-05-17 23:52:56 -0400 |
commit | a3572c34da8dacc78a629211a91cf34e9b408701 (patch) | |
tree | 281efd4d69b68bd4720668fd91cfcf16d1ed3089 /include/media/ir-core.h | |
parent | 0210894956cf57d525d56341cc3e0f3d5d2db659 (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/ir-core.h')
-rw-r--r-- | include/media/ir-core.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/media/ir-core.h b/include/media/ir-core.h index 1eae72d518e0..369969d90779 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 | ||
20 | extern int ir_core_debug; | 22 | extern 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 | ||
32 | enum 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 | |||
30 | struct ir_scancode { | 39 | struct 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 | ||
58 | struct ir_raw_event { | ||
59 | struct timespec delta; /* Time spent before event */ | ||
60 | enum raw_event_type type; /* event type */ | ||
61 | }; | ||
62 | |||
63 | struct 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 | ||
50 | struct ir_input_dev { | 68 | struct 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); | |||
72 | int ir_register_class(struct input_dev *input_dev); | 92 | int ir_register_class(struct input_dev *input_dev); |
73 | void ir_unregister_class(struct input_dev *input_dev); | 93 | void ir_unregister_class(struct input_dev *input_dev); |
74 | 94 | ||
95 | /* Routines from ir-raw-event.c */ | ||
96 | int ir_raw_event_register(struct input_dev *input_dev); | ||
97 | void ir_raw_event_unregister(struct input_dev *input_dev); | ||
98 | int ir_raw_event_store(struct input_dev *input_dev, enum raw_event_type type); | ||
99 | int ir_raw_event_handle(struct input_dev *input_dev); | ||
100 | |||
101 | /* from ir-nec-decoder.c */ | ||
102 | int ir_nec_decode(struct input_dev *input_dev, | ||
103 | struct ir_raw_event *evs, | ||
104 | int len); | ||
105 | |||
106 | |||
75 | #endif | 107 | #endif |