blob: b2d498c3183a186167b2af703eca7ce3d76404a8 [file] [log] [blame]
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -03001/* ir-register.c - handle IR scancode->keycode tables
2 *
3 * Copyright (C) 2009 by Mauro Carvalho Chehab <mchehab@redhat.com>
Mauro Carvalho Chehab446e4a62009-12-11 08:34:07 -03004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -030013 */
14
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -030015
Mauro Carvalho Chehab882ead32009-12-29 10:37:38 -030016#include <linux/input.h>
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -030017#include <media/ir-common.h>
18
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -030019#define IR_TAB_MIN_SIZE 32
Mauro Carvalho Chehabe97f4672009-12-04 17:17:47 -030020#define IR_TAB_MAX_SIZE 1024
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -030021
22/**
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -030023 * ir_seek_table() - returns the element order on the table
24 * @rc_tab: the ir_scancode_table with the keymap to be used
25 * @scancode: the scancode that we're seeking
26 *
27 * This routine is used by the input routines when a key is pressed at the
28 * IR. The scancode is received and needs to be converted into a keycode.
29 * If the key is not found, it returns KEY_UNKNOWN. Otherwise, returns the
30 * corresponding keycode from the table.
31 */
32static int ir_seek_table(struct ir_scancode_table *rc_tab, u32 scancode)
33{
34 int rc;
35 unsigned long flags;
36 struct ir_scancode *keymap = rc_tab->scan;
37
38 spin_lock_irqsave(&rc_tab->lock, flags);
39
40 /* FIXME: replace it by a binary search */
41
42 for (rc = 0; rc < rc_tab->size; rc++)
43 if (keymap[rc].scancode == scancode)
44 goto exit;
45
46 /* Not found */
47 rc = -EINVAL;
48
49exit:
50 spin_unlock_irqrestore(&rc_tab->lock, flags);
51 return rc;
52}
53
54/**
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -030055 * ir_roundup_tablesize() - gets an optimum value for the table size
56 * @n_elems: minimum number of entries to store keycodes
57 *
58 * This routine is used to choose the keycode table size.
59 *
60 * In order to have some empty space for new keycodes,
61 * and knowing in advance that kmalloc allocates only power of two
62 * segments, it optimizes the allocated space to have some spare space
63 * for those new keycodes by using the maximum number of entries that
64 * will be effectively be allocated by kmalloc.
65 * In order to reduce the quantity of table resizes, it has a minimum
66 * table size of IR_TAB_MIN_SIZE.
67 */
68int ir_roundup_tablesize(int n_elems)
69{
70 size_t size;
71
72 if (n_elems < IR_TAB_MIN_SIZE)
73 n_elems = IR_TAB_MIN_SIZE;
74
75 /*
76 * As kmalloc only allocates sizes of power of two, get as
77 * much entries as possible for the allocated memory segment
78 */
79 size = roundup_pow_of_two(n_elems * sizeof(struct ir_scancode));
80 n_elems = size / sizeof(struct ir_scancode);
81
82 return n_elems;
83}
Mauro Carvalho Chehab446e4a62009-12-11 08:34:07 -030084EXPORT_SYMBOL_GPL(ir_roundup_tablesize);
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -030085
86/**
87 * ir_copy_table() - copies a keytable, discarding the unused entries
88 * @destin: destin table
89 * @origin: origin table
90 *
91 * Copies all entries where the keycode is not KEY_UNKNOWN/KEY_RESERVED
Mauro Carvalho Chehabe93854d2009-12-14 00:16:55 -030092 * Also copies table size and table protocol.
93 * NOTE: It shouldn't copy the lock field
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -030094 */
95
96int ir_copy_table(struct ir_scancode_table *destin,
97 const struct ir_scancode_table *origin)
98{
99 int i, j = 0;
100
101 for (i = 0; i < origin->size; i++) {
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300102 if (origin->scan[i].keycode == KEY_UNKNOWN ||
103 origin->scan[i].keycode == KEY_RESERVED)
104 continue;
105
106 memcpy(&destin->scan[j], &origin->scan[i], sizeof(struct ir_scancode));
107 j++;
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300108 }
109 destin->size = j;
Mauro Carvalho Chehabe93854d2009-12-14 00:16:55 -0300110 destin->ir_type = origin->ir_type;
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300111
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300112 IR_dprintk(1, "Copied %d scancodes to the new keycode table\n", destin->size);
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300113
114 return 0;
115}
Mauro Carvalho Chehab446e4a62009-12-11 08:34:07 -0300116EXPORT_SYMBOL_GPL(ir_copy_table);
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300117
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300118/**
119 * ir_getkeycode() - get a keycode at the evdev scancode ->keycode table
120 * @dev: the struct input_dev device descriptor
121 * @scancode: the desired scancode
122 * @keycode: the keycode to be retorned.
123 *
124 * This routine is used to handle evdev EVIOCGKEY ioctl.
125 * If the key is not found, returns -EINVAL, otherwise, returns 0.
126 */
127static int ir_getkeycode(struct input_dev *dev,
128 int scancode, int *keycode)
129{
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300130 int elem;
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300131 struct ir_input_dev *ir_dev = input_get_drvdata(dev);
132 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300133
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300134 elem = ir_seek_table(rc_tab, scancode);
135 if (elem >= 0) {
136 *keycode = rc_tab->scan[elem].keycode;
137 return 0;
138 }
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300139
Mauro Carvalho Chehabe97f4672009-12-04 17:17:47 -0300140 /*
141 * Scancode not found and table can't be expanded
142 */
143 if (elem < 0 && rc_tab->size == IR_TAB_MAX_SIZE)
144 return -EINVAL;
145
146 /*
147 * If is there extra space, returns KEY_RESERVED,
148 * otherwise, input core won't let ir_setkeycode to work
149 */
150 *keycode = KEY_RESERVED;
151 return 0;
152}
153
Mauro Carvalho Chehabe97f4672009-12-04 17:17:47 -0300154/**
155 * ir_is_resize_needed() - Check if the table needs rezise
156 * @table: keycode table that may need to resize
157 * @n_elems: minimum number of entries to store keycodes
158 *
159 * Considering that kmalloc uses power of two storage areas, this
160 * routine detects if the real alloced size will change. If not, it
161 * just returns without doing nothing. Otherwise, it will extend or
162 * reduce the table size to meet the new needs.
163 *
164 * It returns 0 if no resize is needed, 1 otherwise.
165 */
166static int ir_is_resize_needed(struct ir_scancode_table *table, int n_elems)
167{
168 int cur_size = ir_roundup_tablesize(table->size);
169 int new_size = ir_roundup_tablesize(n_elems);
170
171 if (cur_size == new_size)
172 return 0;
173
174 /* Resize is needed */
175 return 1;
176}
177
178/**
179 * ir_delete_key() - remove a keycode from the table
180 * @rc_tab: keycode table
181 * @elem: element to be removed
182 *
183 */
184static void ir_delete_key(struct ir_scancode_table *rc_tab, int elem)
185{
186 unsigned long flags = 0;
187 int newsize = rc_tab->size - 1;
188 int resize = ir_is_resize_needed(rc_tab, newsize);
189 struct ir_scancode *oldkeymap = rc_tab->scan;
190 struct ir_scancode *newkeymap;
191
192 if (resize) {
193 newkeymap = kzalloc(ir_roundup_tablesize(newsize) *
194 sizeof(*newkeymap), GFP_ATOMIC);
195
196 /* There's no memory for resize. Keep the old table */
197 if (!newkeymap)
198 resize = 0;
199 }
200
201 if (!resize) {
202 newkeymap = oldkeymap;
203
204 /* We'll modify the live table. Lock it */
205 spin_lock_irqsave(&rc_tab->lock, flags);
206 }
207
208 /*
209 * Copy the elements before the one that will be deleted
210 * if (!resize), both oldkeymap and newkeymap points
211 * to the same place, so, there's no need to copy
212 */
213 if (resize && elem > 0)
214 memcpy(newkeymap, oldkeymap,
215 elem * sizeof(*newkeymap));
216
217 /*
218 * Copy the other elements overwriting the element to be removed
219 * This operation applies to both resize and non-resize case
220 */
221 if (elem < newsize)
222 memcpy(&newkeymap[elem], &oldkeymap[elem + 1],
223 (newsize - elem) * sizeof(*newkeymap));
224
225 if (resize) {
226 /*
227 * As the copy happened to a temporary table, only here
228 * it needs to lock while replacing the table pointers
229 * to use the new table
230 */
231 spin_lock_irqsave(&rc_tab->lock, flags);
232 rc_tab->size = newsize;
233 rc_tab->scan = newkeymap;
234 spin_unlock_irqrestore(&rc_tab->lock, flags);
235
236 /* Frees the old keytable */
237 kfree(oldkeymap);
238 } else {
239 rc_tab->size = newsize;
240 spin_unlock_irqrestore(&rc_tab->lock, flags);
241 }
242}
243
244/**
245 * ir_insert_key() - insert a keycode at the table
246 * @rc_tab: keycode table
247 * @scancode: the desired scancode
248 * @keycode: the keycode to be retorned.
249 *
250 */
251static int ir_insert_key(struct ir_scancode_table *rc_tab,
252 int scancode, int keycode)
253{
254 unsigned long flags;
255 int elem = rc_tab->size;
256 int newsize = rc_tab->size + 1;
257 int resize = ir_is_resize_needed(rc_tab, newsize);
258 struct ir_scancode *oldkeymap = rc_tab->scan;
259 struct ir_scancode *newkeymap;
260
261 if (resize) {
262 newkeymap = kzalloc(ir_roundup_tablesize(newsize) *
263 sizeof(*newkeymap), GFP_ATOMIC);
264 if (!newkeymap)
265 return -ENOMEM;
266
267 memcpy(newkeymap, oldkeymap,
268 rc_tab->size * sizeof(*newkeymap));
269 } else
270 newkeymap = oldkeymap;
271
272 /* Stores the new code at the table */
273 IR_dprintk(1, "#%d: New scan 0x%04x with key 0x%04x\n",
274 rc_tab->size, scancode, keycode);
275
276 spin_lock_irqsave(&rc_tab->lock, flags);
277 rc_tab->size = newsize;
278 if (resize) {
279 rc_tab->scan = newkeymap;
280 kfree(oldkeymap);
281 }
282 newkeymap[elem].scancode = scancode;
283 newkeymap[elem].keycode = keycode;
284 spin_unlock_irqrestore(&rc_tab->lock, flags);
285
286 return 0;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300287}
288
289/**
290 * ir_setkeycode() - set a keycode at the evdev scancode ->keycode table
291 * @dev: the struct input_dev device descriptor
292 * @scancode: the desired scancode
293 * @keycode: the keycode to be retorned.
294 *
295 * This routine is used to handle evdev EVIOCSKEY ioctl.
296 * There's one caveat here: how can we increase the size of the table?
297 * If the key is not found, returns -EINVAL, otherwise, returns 0.
298 */
299static int ir_setkeycode(struct input_dev *dev,
300 int scancode, int keycode)
301{
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300302 int rc = 0;
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300303 struct ir_input_dev *ir_dev = input_get_drvdata(dev);
304 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300305 struct ir_scancode *keymap = rc_tab->scan;
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300306 unsigned long flags;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300307
Mauro Carvalho Chehabe97f4672009-12-04 17:17:47 -0300308 /*
309 * Handle keycode table deletions
310 *
311 * If userspace is adding a KEY_UNKNOWN or KEY_RESERVED,
312 * deal as a trial to remove an existing scancode attribution
313 * if table become too big, reduce it to save space
314 */
315 if (keycode == KEY_UNKNOWN || keycode == KEY_RESERVED) {
316 rc = ir_seek_table(rc_tab, scancode);
317 if (rc < 0)
318 return 0;
319
320 IR_dprintk(1, "#%d: Deleting scan 0x%04x\n", rc, scancode);
321 clear_bit(keymap[rc].keycode, dev->keybit);
322 ir_delete_key(rc_tab, rc);
323
324 return 0;
325 }
326
327 /*
328 * Handle keycode replacements
329 *
330 * If the scancode exists, just replace by the new value
331 */
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300332 rc = ir_seek_table(rc_tab, scancode);
Mauro Carvalho Chehabe97f4672009-12-04 17:17:47 -0300333 if (rc >= 0) {
334 IR_dprintk(1, "#%d: Replacing scan 0x%04x with key 0x%04x\n",
335 rc, scancode, keycode);
336
337 clear_bit(keymap[rc].keycode, dev->keybit);
338
339 spin_lock_irqsave(&rc_tab->lock, flags);
340 keymap[rc].keycode = keycode;
341 spin_unlock_irqrestore(&rc_tab->lock, flags);
342
343 set_bit(keycode, dev->keybit);
344
345 return 0;
346 }
347
348 /*
349 * Handle new scancode inserts
350 *
351 * reallocate table if needed and insert a new keycode
352 */
353
354 /* Avoid growing the table indefinitely */
355 if (rc_tab->size + 1 > IR_TAB_MAX_SIZE)
356 return -EINVAL;
357
358 rc = ir_insert_key(rc_tab, scancode, keycode);
359 if (rc < 0)
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300360 return rc;
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300361 set_bit(keycode, dev->keybit);
362
363 return 0;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300364}
365
366/**
367 * ir_g_keycode_from_table() - gets the keycode that corresponds to a scancode
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300368 * @input_dev: the struct input_dev descriptor of the device
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300369 * @scancode: the scancode that we're seeking
370 *
371 * This routine is used by the input routines when a key is pressed at the
372 * IR. The scancode is received and needs to be converted into a keycode.
373 * If the key is not found, it returns KEY_UNKNOWN. Otherwise, returns the
374 * corresponding keycode from the table.
375 */
376u32 ir_g_keycode_from_table(struct input_dev *dev, u32 scancode)
377{
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300378 struct ir_input_dev *ir_dev = input_get_drvdata(dev);
379 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300380 struct ir_scancode *keymap = rc_tab->scan;
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300381 int elem;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300382
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300383 elem = ir_seek_table(rc_tab, scancode);
384 if (elem >= 0) {
385 IR_dprintk(1, "%s: scancode 0x%04x keycode 0x%02x\n",
386 dev->name, scancode, keymap[elem].keycode);
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300387
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300388 return rc_tab->scan[elem].keycode;
389 }
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300390
391 printk(KERN_INFO "%s: unknown key for scancode 0x%04x\n",
392 dev->name, scancode);
393
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300394 /* Reports userspace that an unknown keycode were got */
395 return KEY_RESERVED;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300396}
Mauro Carvalho Chehab446e4a62009-12-11 08:34:07 -0300397EXPORT_SYMBOL_GPL(ir_g_keycode_from_table);
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300398
399/**
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300400 * ir_input_register() - sets the IR keycode table and add the handlers
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300401 * for keymap table get/set
402 * @input_dev: the struct input_dev descriptor of the device
403 * @rc_tab: the struct ir_scancode_table table of scancode/keymap
404 *
405 * This routine is used to initialize the input infrastructure to work with
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300406 * an IR.
407 * It should be called before registering the IR device.
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300408 */
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300409int ir_input_register(struct input_dev *input_dev,
Mauro Carvalho Chehabe93854d2009-12-14 00:16:55 -0300410 const struct ir_scancode_table *rc_tab,
411 const struct ir_dev_props *props)
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300412{
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300413 struct ir_input_dev *ir_dev;
414 struct ir_scancode *keymap = rc_tab->scan;
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300415 int i, rc;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300416
417 if (rc_tab->scan == NULL || !rc_tab->size)
418 return -EINVAL;
419
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300420 ir_dev = kzalloc(sizeof(*ir_dev), GFP_KERNEL);
421 if (!ir_dev)
422 return -ENOMEM;
423
Mauro Carvalho Chehabe93854d2009-12-14 00:16:55 -0300424 spin_lock_init(&ir_dev->rc_tab.lock);
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300425
426 ir_dev->rc_tab.size = ir_roundup_tablesize(rc_tab->size);
427 ir_dev->rc_tab.scan = kzalloc(ir_dev->rc_tab.size *
428 sizeof(struct ir_scancode), GFP_KERNEL);
429 if (!ir_dev->rc_tab.scan)
430 return -ENOMEM;
431
432 IR_dprintk(1, "Allocated space for %d keycode entries (%zd bytes)\n",
433 ir_dev->rc_tab.size,
434 ir_dev->rc_tab.size * sizeof(ir_dev->rc_tab.scan));
435
436 ir_copy_table(&ir_dev->rc_tab, rc_tab);
Mauro Carvalho Chehabe93854d2009-12-14 00:16:55 -0300437 ir_dev->props = props;
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300438
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300439 /* set the bits for the keys */
440 IR_dprintk(1, "key map size: %d\n", rc_tab->size);
441 for (i = 0; i < rc_tab->size; i++) {
442 IR_dprintk(1, "#%d: setting bit for keycode 0x%04x\n",
443 i, keymap[i].keycode);
444 set_bit(keymap[i].keycode, input_dev->keybit);
445 }
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300446 clear_bit(0, input_dev->keybit);
447
448 set_bit(EV_KEY, input_dev->evbit);
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300449
450 input_dev->getkeycode = ir_getkeycode;
451 input_dev->setkeycode = ir_setkeycode;
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300452 input_set_drvdata(input_dev, ir_dev);
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300453
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300454 rc = input_register_device(input_dev);
Mauro Carvalho Chehab4714eda2009-12-13 16:00:08 -0300455 if (rc < 0)
456 goto err;
457
458 rc = ir_register_class(input_dev);
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300459 if (rc < 0) {
Mauro Carvalho Chehab4714eda2009-12-13 16:00:08 -0300460 input_unregister_device(input_dev);
461 goto err;
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300462 }
463
Mauro Carvalho Chehab4714eda2009-12-13 16:00:08 -0300464 return 0;
465
466err:
467 kfree(rc_tab->scan);
468 kfree(ir_dev);
469 input_set_drvdata(input_dev, NULL);
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300470 return rc;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300471}
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300472EXPORT_SYMBOL_GPL(ir_input_register);
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300473
Mauro Carvalho Chehab38ef6aa2009-12-11 09:47:42 -0300474void ir_input_unregister(struct input_dev *dev)
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300475{
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300476 struct ir_input_dev *ir_dev = input_get_drvdata(dev);
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300477 struct ir_scancode_table *rc_tab;
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300478
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300479 if (!ir_dev)
Mauro Carvalho Chehab05395a32009-12-06 08:32:49 -0300480 return;
481
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300482 IR_dprintk(1, "Freed keycode table\n");
483
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300484 rc_tab = &ir_dev->rc_tab;
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300485 rc_tab->size = 0;
486 kfree(rc_tab->scan);
487 rc_tab->scan = NULL;
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300488
Mauro Carvalho Chehab4714eda2009-12-13 16:00:08 -0300489 ir_unregister_class(dev);
490
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300491 kfree(ir_dev);
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300492 input_unregister_device(dev);
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300493}
Mauro Carvalho Chehab38ef6aa2009-12-11 09:47:42 -0300494EXPORT_SYMBOL_GPL(ir_input_unregister);
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300495
Mauro Carvalho Chehab446e4a62009-12-11 08:34:07 -0300496int ir_core_debug; /* ir_debug level (0,1,2) */
497EXPORT_SYMBOL_GPL(ir_core_debug);
498module_param_named(debug, ir_core_debug, int, 0644);
499
500MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");
501MODULE_LICENSE("GPL");