blob: 4c11a0167fc90bd9a0adf5488655aea6d417bca5 [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 */
Mauro Carvalho Chehab8719cfd2009-12-17 09:24:37 -030068static int ir_roundup_tablesize(int n_elems)
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -030069{
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}
84
85/**
86 * ir_copy_table() - copies a keytable, discarding the unused entries
87 * @destin: destin table
88 * @origin: origin table
89 *
90 * Copies all entries where the keycode is not KEY_UNKNOWN/KEY_RESERVED
Mauro Carvalho Chehabe93854d2009-12-14 00:16:55 -030091 * Also copies table size and table protocol.
92 * NOTE: It shouldn't copy the lock field
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -030093 */
94
Mauro Carvalho Chehab8719cfd2009-12-17 09:24:37 -030095static int ir_copy_table(struct ir_scancode_table *destin,
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -030096 const struct ir_scancode_table *origin)
97{
98 int i, j = 0;
99
100 for (i = 0; i < origin->size; i++) {
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300101 if (origin->scan[i].keycode == KEY_UNKNOWN ||
102 origin->scan[i].keycode == KEY_RESERVED)
103 continue;
104
105 memcpy(&destin->scan[j], &origin->scan[i], sizeof(struct ir_scancode));
106 j++;
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300107 }
108 destin->size = j;
Mauro Carvalho Chehabe93854d2009-12-14 00:16:55 -0300109 destin->ir_type = origin->ir_type;
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300110
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300111 IR_dprintk(1, "Copied %d scancodes to the new keycode table\n", destin->size);
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300112
113 return 0;
114}
115
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300116/**
117 * ir_getkeycode() - get a keycode at the evdev scancode ->keycode table
118 * @dev: the struct input_dev device descriptor
119 * @scancode: the desired scancode
120 * @keycode: the keycode to be retorned.
121 *
122 * This routine is used to handle evdev EVIOCGKEY ioctl.
123 * If the key is not found, returns -EINVAL, otherwise, returns 0.
124 */
125static int ir_getkeycode(struct input_dev *dev,
126 int scancode, int *keycode)
127{
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300128 int elem;
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300129 struct ir_input_dev *ir_dev = input_get_drvdata(dev);
130 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300131
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300132 elem = ir_seek_table(rc_tab, scancode);
133 if (elem >= 0) {
134 *keycode = rc_tab->scan[elem].keycode;
135 return 0;
136 }
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300137
Mauro Carvalho Chehabe97f4672009-12-04 17:17:47 -0300138 /*
139 * Scancode not found and table can't be expanded
140 */
141 if (elem < 0 && rc_tab->size == IR_TAB_MAX_SIZE)
142 return -EINVAL;
143
144 /*
145 * If is there extra space, returns KEY_RESERVED,
146 * otherwise, input core won't let ir_setkeycode to work
147 */
148 *keycode = KEY_RESERVED;
149 return 0;
150}
151
Mauro Carvalho Chehabe97f4672009-12-04 17:17:47 -0300152/**
153 * ir_is_resize_needed() - Check if the table needs rezise
154 * @table: keycode table that may need to resize
155 * @n_elems: minimum number of entries to store keycodes
156 *
157 * Considering that kmalloc uses power of two storage areas, this
158 * routine detects if the real alloced size will change. If not, it
159 * just returns without doing nothing. Otherwise, it will extend or
160 * reduce the table size to meet the new needs.
161 *
162 * It returns 0 if no resize is needed, 1 otherwise.
163 */
164static int ir_is_resize_needed(struct ir_scancode_table *table, int n_elems)
165{
166 int cur_size = ir_roundup_tablesize(table->size);
167 int new_size = ir_roundup_tablesize(n_elems);
168
169 if (cur_size == new_size)
170 return 0;
171
172 /* Resize is needed */
173 return 1;
174}
175
176/**
177 * ir_delete_key() - remove a keycode from the table
178 * @rc_tab: keycode table
179 * @elem: element to be removed
180 *
181 */
182static void ir_delete_key(struct ir_scancode_table *rc_tab, int elem)
183{
184 unsigned long flags = 0;
185 int newsize = rc_tab->size - 1;
186 int resize = ir_is_resize_needed(rc_tab, newsize);
187 struct ir_scancode *oldkeymap = rc_tab->scan;
188 struct ir_scancode *newkeymap;
189
190 if (resize) {
191 newkeymap = kzalloc(ir_roundup_tablesize(newsize) *
192 sizeof(*newkeymap), GFP_ATOMIC);
193
194 /* There's no memory for resize. Keep the old table */
195 if (!newkeymap)
196 resize = 0;
197 }
198
199 if (!resize) {
200 newkeymap = oldkeymap;
201
202 /* We'll modify the live table. Lock it */
203 spin_lock_irqsave(&rc_tab->lock, flags);
204 }
205
206 /*
207 * Copy the elements before the one that will be deleted
208 * if (!resize), both oldkeymap and newkeymap points
209 * to the same place, so, there's no need to copy
210 */
211 if (resize && elem > 0)
212 memcpy(newkeymap, oldkeymap,
213 elem * sizeof(*newkeymap));
214
215 /*
216 * Copy the other elements overwriting the element to be removed
217 * This operation applies to both resize and non-resize case
218 */
219 if (elem < newsize)
220 memcpy(&newkeymap[elem], &oldkeymap[elem + 1],
221 (newsize - elem) * sizeof(*newkeymap));
222
223 if (resize) {
224 /*
225 * As the copy happened to a temporary table, only here
226 * it needs to lock while replacing the table pointers
227 * to use the new table
228 */
229 spin_lock_irqsave(&rc_tab->lock, flags);
230 rc_tab->size = newsize;
231 rc_tab->scan = newkeymap;
232 spin_unlock_irqrestore(&rc_tab->lock, flags);
233
234 /* Frees the old keytable */
235 kfree(oldkeymap);
236 } else {
237 rc_tab->size = newsize;
238 spin_unlock_irqrestore(&rc_tab->lock, flags);
239 }
240}
241
242/**
243 * ir_insert_key() - insert a keycode at the table
244 * @rc_tab: keycode table
245 * @scancode: the desired scancode
246 * @keycode: the keycode to be retorned.
247 *
248 */
249static int ir_insert_key(struct ir_scancode_table *rc_tab,
250 int scancode, int keycode)
251{
252 unsigned long flags;
253 int elem = rc_tab->size;
254 int newsize = rc_tab->size + 1;
255 int resize = ir_is_resize_needed(rc_tab, newsize);
256 struct ir_scancode *oldkeymap = rc_tab->scan;
257 struct ir_scancode *newkeymap;
258
259 if (resize) {
260 newkeymap = kzalloc(ir_roundup_tablesize(newsize) *
261 sizeof(*newkeymap), GFP_ATOMIC);
262 if (!newkeymap)
263 return -ENOMEM;
264
265 memcpy(newkeymap, oldkeymap,
266 rc_tab->size * sizeof(*newkeymap));
267 } else
268 newkeymap = oldkeymap;
269
270 /* Stores the new code at the table */
271 IR_dprintk(1, "#%d: New scan 0x%04x with key 0x%04x\n",
272 rc_tab->size, scancode, keycode);
273
274 spin_lock_irqsave(&rc_tab->lock, flags);
275 rc_tab->size = newsize;
276 if (resize) {
277 rc_tab->scan = newkeymap;
278 kfree(oldkeymap);
279 }
280 newkeymap[elem].scancode = scancode;
281 newkeymap[elem].keycode = keycode;
282 spin_unlock_irqrestore(&rc_tab->lock, flags);
283
284 return 0;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300285}
286
287/**
288 * ir_setkeycode() - set a keycode at the evdev scancode ->keycode table
289 * @dev: the struct input_dev device descriptor
290 * @scancode: the desired scancode
291 * @keycode: the keycode to be retorned.
292 *
293 * This routine is used to handle evdev EVIOCSKEY ioctl.
294 * There's one caveat here: how can we increase the size of the table?
295 * If the key is not found, returns -EINVAL, otherwise, returns 0.
296 */
297static int ir_setkeycode(struct input_dev *dev,
298 int scancode, int keycode)
299{
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300300 int rc = 0;
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300301 struct ir_input_dev *ir_dev = input_get_drvdata(dev);
302 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300303 struct ir_scancode *keymap = rc_tab->scan;
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300304 unsigned long flags;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300305
Mauro Carvalho Chehabe97f4672009-12-04 17:17:47 -0300306 /*
307 * Handle keycode table deletions
308 *
309 * If userspace is adding a KEY_UNKNOWN or KEY_RESERVED,
310 * deal as a trial to remove an existing scancode attribution
311 * if table become too big, reduce it to save space
312 */
313 if (keycode == KEY_UNKNOWN || keycode == KEY_RESERVED) {
314 rc = ir_seek_table(rc_tab, scancode);
315 if (rc < 0)
316 return 0;
317
318 IR_dprintk(1, "#%d: Deleting scan 0x%04x\n", rc, scancode);
319 clear_bit(keymap[rc].keycode, dev->keybit);
320 ir_delete_key(rc_tab, rc);
321
322 return 0;
323 }
324
325 /*
326 * Handle keycode replacements
327 *
328 * If the scancode exists, just replace by the new value
329 */
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300330 rc = ir_seek_table(rc_tab, scancode);
Mauro Carvalho Chehabe97f4672009-12-04 17:17:47 -0300331 if (rc >= 0) {
332 IR_dprintk(1, "#%d: Replacing scan 0x%04x with key 0x%04x\n",
333 rc, scancode, keycode);
334
335 clear_bit(keymap[rc].keycode, dev->keybit);
336
337 spin_lock_irqsave(&rc_tab->lock, flags);
338 keymap[rc].keycode = keycode;
339 spin_unlock_irqrestore(&rc_tab->lock, flags);
340
341 set_bit(keycode, dev->keybit);
342
343 return 0;
344 }
345
346 /*
347 * Handle new scancode inserts
348 *
349 * reallocate table if needed and insert a new keycode
350 */
351
352 /* Avoid growing the table indefinitely */
353 if (rc_tab->size + 1 > IR_TAB_MAX_SIZE)
354 return -EINVAL;
355
356 rc = ir_insert_key(rc_tab, scancode, keycode);
357 if (rc < 0)
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300358 return rc;
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300359 set_bit(keycode, dev->keybit);
360
361 return 0;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300362}
363
364/**
365 * ir_g_keycode_from_table() - gets the keycode that corresponds to a scancode
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300366 * @input_dev: the struct input_dev descriptor of the device
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300367 * @scancode: the scancode that we're seeking
368 *
369 * This routine is used by the input routines when a key is pressed at the
370 * IR. The scancode is received and needs to be converted into a keycode.
371 * If the key is not found, it returns KEY_UNKNOWN. Otherwise, returns the
372 * corresponding keycode from the table.
373 */
374u32 ir_g_keycode_from_table(struct input_dev *dev, u32 scancode)
375{
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300376 struct ir_input_dev *ir_dev = input_get_drvdata(dev);
377 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300378 struct ir_scancode *keymap = rc_tab->scan;
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300379 int elem;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300380
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300381 elem = ir_seek_table(rc_tab, scancode);
382 if (elem >= 0) {
383 IR_dprintk(1, "%s: scancode 0x%04x keycode 0x%02x\n",
384 dev->name, scancode, keymap[elem].keycode);
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300385
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300386 return rc_tab->scan[elem].keycode;
387 }
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300388
389 printk(KERN_INFO "%s: unknown key for scancode 0x%04x\n",
390 dev->name, scancode);
391
Mauro Carvalho Chehab7fee03e2009-12-02 15:56:47 -0300392 /* Reports userspace that an unknown keycode were got */
393 return KEY_RESERVED;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300394}
Mauro Carvalho Chehab446e4a62009-12-11 08:34:07 -0300395EXPORT_SYMBOL_GPL(ir_g_keycode_from_table);
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300396
397/**
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300398 * ir_input_register() - sets the IR keycode table and add the handlers
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300399 * for keymap table get/set
400 * @input_dev: the struct input_dev descriptor of the device
401 * @rc_tab: the struct ir_scancode_table table of scancode/keymap
402 *
Mauro Carvalho Chehabd4b778d2009-12-14 02:55:03 -0300403 * This routine is used to initialize the input infrastructure
404 * to work with an IR.
405 * It will register the input/evdev interface for the device and
406 * register the syfs code for IR class
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300407 */
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300408int ir_input_register(struct input_dev *input_dev,
Mauro Carvalho Chehabe93854d2009-12-14 00:16:55 -0300409 const struct ir_scancode_table *rc_tab,
410 const struct ir_dev_props *props)
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300411{
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300412 struct ir_input_dev *ir_dev;
413 struct ir_scancode *keymap = rc_tab->scan;
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300414 int i, rc;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300415
416 if (rc_tab->scan == NULL || !rc_tab->size)
417 return -EINVAL;
418
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300419 ir_dev = kzalloc(sizeof(*ir_dev), GFP_KERNEL);
420 if (!ir_dev)
421 return -ENOMEM;
422
Mauro Carvalho Chehabe93854d2009-12-14 00:16:55 -0300423 spin_lock_init(&ir_dev->rc_tab.lock);
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300424
425 ir_dev->rc_tab.size = ir_roundup_tablesize(rc_tab->size);
426 ir_dev->rc_tab.scan = kzalloc(ir_dev->rc_tab.size *
427 sizeof(struct ir_scancode), GFP_KERNEL);
428 if (!ir_dev->rc_tab.scan)
429 return -ENOMEM;
430
431 IR_dprintk(1, "Allocated space for %d keycode entries (%zd bytes)\n",
432 ir_dev->rc_tab.size,
433 ir_dev->rc_tab.size * sizeof(ir_dev->rc_tab.scan));
434
435 ir_copy_table(&ir_dev->rc_tab, rc_tab);
Mauro Carvalho Chehabe93854d2009-12-14 00:16:55 -0300436 ir_dev->props = props;
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300437
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300438 /* set the bits for the keys */
439 IR_dprintk(1, "key map size: %d\n", rc_tab->size);
440 for (i = 0; i < rc_tab->size; i++) {
441 IR_dprintk(1, "#%d: setting bit for keycode 0x%04x\n",
442 i, keymap[i].keycode);
443 set_bit(keymap[i].keycode, input_dev->keybit);
444 }
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300445 clear_bit(0, input_dev->keybit);
446
447 set_bit(EV_KEY, input_dev->evbit);
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300448
449 input_dev->getkeycode = ir_getkeycode;
450 input_dev->setkeycode = ir_setkeycode;
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300451 input_set_drvdata(input_dev, ir_dev);
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300452
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300453 rc = input_register_device(input_dev);
Mauro Carvalho Chehab4714eda2009-12-13 16:00:08 -0300454 if (rc < 0)
455 goto err;
456
457 rc = ir_register_class(input_dev);
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300458 if (rc < 0) {
Mauro Carvalho Chehab4714eda2009-12-13 16:00:08 -0300459 input_unregister_device(input_dev);
460 goto err;
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300461 }
462
Mauro Carvalho Chehab4714eda2009-12-13 16:00:08 -0300463 return 0;
464
465err:
466 kfree(rc_tab->scan);
467 kfree(ir_dev);
468 input_set_drvdata(input_dev, NULL);
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300469 return rc;
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -0300470}
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300471EXPORT_SYMBOL_GPL(ir_input_register);
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300472
Mauro Carvalho Chehabd4b778d2009-12-14 02:55:03 -0300473/**
474 * ir_input_unregister() - unregisters IR and frees resources
475 * @input_dev: the struct input_dev descriptor of the device
476
477 * This routine is used to free memory and de-register interfaces.
478 */
Mauro Carvalho Chehab38ef6aa2009-12-11 09:47:42 -0300479void ir_input_unregister(struct input_dev *dev)
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300480{
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300481 struct ir_input_dev *ir_dev = input_get_drvdata(dev);
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300482 struct ir_scancode_table *rc_tab;
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300483
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300484 if (!ir_dev)
Mauro Carvalho Chehab05395a32009-12-06 08:32:49 -0300485 return;
486
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300487 IR_dprintk(1, "Freed keycode table\n");
488
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300489 rc_tab = &ir_dev->rc_tab;
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300490 rc_tab->size = 0;
491 kfree(rc_tab->scan);
492 rc_tab->scan = NULL;
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300493
Mauro Carvalho Chehab4714eda2009-12-13 16:00:08 -0300494 ir_unregister_class(dev);
495
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -0300496 kfree(ir_dev);
Mauro Carvalho Chehab579e7d62009-12-11 11:20:59 -0300497 input_unregister_device(dev);
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300498}
Mauro Carvalho Chehab38ef6aa2009-12-11 09:47:42 -0300499EXPORT_SYMBOL_GPL(ir_input_unregister);
Mauro Carvalho Chehabf6fc5042009-11-29 11:08:02 -0300500
Mauro Carvalho Chehab446e4a62009-12-11 08:34:07 -0300501int ir_core_debug; /* ir_debug level (0,1,2) */
502EXPORT_SYMBOL_GPL(ir_core_debug);
503module_param_named(debug, ir_core_debug, int, 0644);
504
505MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");
506MODULE_LICENSE("GPL");