diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-03-24 19:47:53 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-05-17 23:52:59 -0400 |
commit | 995187bed30c0545e8da88372e9807da0a85911e (patch) | |
tree | e3e28eff10f8f01f1bfd7ff865a29076bf6700dc /drivers/media/IR/ir-raw-event.c | |
parent | 9f1547829a6f39fe6b2da22653dff40502f3d568 (diff) |
V4L/DVB: ir-core: dynamically load the compiled IR protocols
Instead of hardcoding the protocols into ir-core, add a register interface
for the IR protocol decoders, and convert ir-nec-decoder into a client of
ir-core.
With this approach, it is possible to dynamically load the needed IR protocols,
and to add a RAW IR interface module, registered as one IR raw protocol decoder.
This patch opens a way to register a lirc_dev interface to work as an userspace
IR protocol decoder.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/IR/ir-raw-event.c')
-rw-r--r-- | drivers/media/IR/ir-raw-event.c | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/drivers/media/IR/ir-raw-event.c b/drivers/media/IR/ir-raw-event.c index 0ae55433cef9..3eae128400ea 100644 --- a/drivers/media/IR/ir-raw-event.c +++ b/drivers/media/IR/ir-raw-event.c | |||
@@ -13,10 +13,18 @@ | |||
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <media/ir-core.h> | 15 | #include <media/ir-core.h> |
16 | #include <linux/workqueue.h> | ||
16 | 17 | ||
17 | /* Define the max number of bit transitions per IR keycode */ | 18 | /* Define the max number of bit transitions per IR keycode */ |
18 | #define MAX_IR_EVENT_SIZE 256 | 19 | #define MAX_IR_EVENT_SIZE 256 |
19 | 20 | ||
21 | /* Used to handle IR raw handler extensions */ | ||
22 | static LIST_HEAD(ir_raw_handler_list); | ||
23 | static DEFINE_MUTEX(ir_raw_handler_lock); | ||
24 | |||
25 | /* Used to load the decoders */ | ||
26 | static struct work_struct wq_load; | ||
27 | |||
20 | static void ir_keyup_timer(unsigned long data) | 28 | static void ir_keyup_timer(unsigned long data) |
21 | { | 29 | { |
22 | struct input_dev *input_dev = (struct input_dev *)data; | 30 | struct input_dev *input_dev = (struct input_dev *)data; |
@@ -101,6 +109,7 @@ int ir_raw_event_handle(struct input_dev *input_dev) | |||
101 | int rc; | 109 | int rc; |
102 | struct ir_raw_event *evs; | 110 | struct ir_raw_event *evs; |
103 | int len, i; | 111 | int len, i; |
112 | struct ir_raw_handler *ir_raw_handler; | ||
104 | 113 | ||
105 | /* | 114 | /* |
106 | * Store the events into a temporary buffer. This allows calling more than | 115 | * Store the events into a temporary buffer. This allows calling more than |
@@ -122,10 +131,56 @@ int ir_raw_event_handle(struct input_dev *input_dev) | |||
122 | evs[i].type, (evs[i].delta.tv_nsec + 500) / 1000); | 131 | evs[i].type, (evs[i].delta.tv_nsec + 500) / 1000); |
123 | } | 132 | } |
124 | 133 | ||
125 | rc = ir_nec_decode(input_dev, evs, len); | 134 | /* |
135 | * Call all ir decoders. This allows decoding the same event with | ||
136 | * more than one protocol handler. | ||
137 | * FIXME: better handle the returned code: does it make sense to use | ||
138 | * other decoders, if the first one already handled the IR? | ||
139 | */ | ||
140 | list_for_each_entry(ir_raw_handler, &ir_raw_handler_list, list) { | ||
141 | rc = ir_raw_handler->decode(input_dev, evs, len); | ||
142 | } | ||
126 | 143 | ||
127 | kfree(evs); | 144 | kfree(evs); |
128 | 145 | ||
129 | return rc; | 146 | return rc; |
130 | } | 147 | } |
131 | EXPORT_SYMBOL_GPL(ir_raw_event_handle); | 148 | EXPORT_SYMBOL_GPL(ir_raw_event_handle); |
149 | |||
150 | /* | ||
151 | * Extension interface - used to register the IR decoders | ||
152 | */ | ||
153 | |||
154 | int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler) | ||
155 | { | ||
156 | mutex_lock(&ir_raw_handler_lock); | ||
157 | list_add_tail(&ir_raw_handler->list, &ir_raw_handler_list); | ||
158 | mutex_unlock(&ir_raw_handler_lock); | ||
159 | return 0; | ||
160 | } | ||
161 | EXPORT_SYMBOL(ir_raw_handler_register); | ||
162 | |||
163 | void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler) | ||
164 | { | ||
165 | mutex_lock(&ir_raw_handler_lock); | ||
166 | list_del(&ir_raw_handler->list); | ||
167 | mutex_unlock(&ir_raw_handler_lock); | ||
168 | } | ||
169 | EXPORT_SYMBOL(ir_raw_handler_unregister); | ||
170 | |||
171 | static void init_decoders(struct work_struct *work) | ||
172 | { | ||
173 | /* Load the decoder modules */ | ||
174 | |||
175 | load_nec_decode(); | ||
176 | |||
177 | /* If needed, we may later add some init code. In this case, | ||
178 | it is needed to change the CONFIG_MODULE test at ir-core.h | ||
179 | */ | ||
180 | } | ||
181 | |||
182 | void ir_raw_init(void) | ||
183 | { | ||
184 | INIT_WORK(&wq_load, init_decoders); | ||
185 | schedule_work(&wq_load); | ||
186 | } \ No newline at end of file | ||