diff options
-rw-r--r-- | drivers/media/IR/Makefile | 2 | ||||
-rw-r--r-- | drivers/media/IR/rc-map.c | 75 | ||||
-rw-r--r-- | include/media/ir-core.h | 11 |
3 files changed, 87 insertions, 1 deletions
diff --git a/drivers/media/IR/Makefile b/drivers/media/IR/Makefile index 6140b2712c8a..3a4f590d0bbb 100644 --- a/drivers/media/IR/Makefile +++ b/drivers/media/IR/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | ir-common-objs := ir-functions.o ir-keymaps.o | 1 | ir-common-objs := ir-functions.o ir-keymaps.o |
2 | ir-core-objs := ir-keytable.o ir-sysfs.o ir-raw-event.o | 2 | ir-core-objs := ir-keytable.o ir-sysfs.o ir-raw-event.o rc-map.o |
3 | 3 | ||
4 | obj-$(CONFIG_IR_CORE) += ir-core.o | 4 | obj-$(CONFIG_IR_CORE) += ir-core.o |
5 | obj-$(CONFIG_VIDEO_IR) += ir-common.o | 5 | obj-$(CONFIG_VIDEO_IR) += ir-common.o |
diff --git a/drivers/media/IR/rc-map.c b/drivers/media/IR/rc-map.c new file mode 100644 index 000000000000..aa269f5ef3fe --- /dev/null +++ b/drivers/media/IR/rc-map.c | |||
@@ -0,0 +1,75 @@ | |||
1 | /* ir-raw-event.c - handle IR Pulse/Space event | ||
2 | * | ||
3 | * Copyright (C) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> | ||
4 | * | ||
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. | ||
13 | */ | ||
14 | |||
15 | #include <media/ir-core.h> | ||
16 | #include <linux/spinlock.h> | ||
17 | |||
18 | /* Used to handle IR raw handler extensions */ | ||
19 | static LIST_HEAD(rc_map_list); | ||
20 | static spinlock_t rc_map_lock; | ||
21 | |||
22 | |||
23 | static struct rc_keymap *seek_rc_map(const char *name) | ||
24 | { | ||
25 | struct rc_keymap *map = NULL; | ||
26 | |||
27 | spin_lock(&rc_map_lock); | ||
28 | list_for_each_entry(map, &rc_map_list, list) { | ||
29 | if (!strcmp(name, map->map.name)) | ||
30 | break; | ||
31 | } | ||
32 | spin_unlock(&rc_map_lock); | ||
33 | |||
34 | return map; | ||
35 | } | ||
36 | |||
37 | struct ir_scancode_table *get_rc_map(const char *name) | ||
38 | { | ||
39 | int rc = 0; | ||
40 | |||
41 | struct rc_keymap *map; | ||
42 | |||
43 | map = seek_rc_map(name); | ||
44 | #ifdef MODULE | ||
45 | if (!map) { | ||
46 | rc = request_module("name"); | ||
47 | if (rc < 0) | ||
48 | return NULL; | ||
49 | |||
50 | map = seek_rc_map(name); | ||
51 | } | ||
52 | #endif | ||
53 | if (!map) | ||
54 | return NULL; | ||
55 | |||
56 | return &map->map; | ||
57 | } | ||
58 | EXPORT_SYMBOL_GPL(get_rc_map); | ||
59 | |||
60 | int ir_register_map(struct rc_keymap *map) | ||
61 | { | ||
62 | spin_lock(&rc_map_lock); | ||
63 | list_add_tail(&map->list, &rc_map_list); | ||
64 | spin_unlock(&rc_map_lock); | ||
65 | return 0; | ||
66 | } | ||
67 | EXPORT_SYMBOL_GPL(ir_raw_handler_register); | ||
68 | |||
69 | void ir_unregister_map(struct rc_keymap *map) | ||
70 | { | ||
71 | spin_lock(&rc_map_lock); | ||
72 | list_del(&map->list); | ||
73 | spin_unlock(&rc_map_lock); | ||
74 | } | ||
75 | EXPORT_SYMBOL_GPL(ir_raw_handler_unregister); | ||
diff --git a/include/media/ir-core.h b/include/media/ir-core.h index 643ff25daa89..39df3cf9e845 100644 --- a/include/media/ir-core.h +++ b/include/media/ir-core.h | |||
@@ -52,6 +52,11 @@ struct ir_scancode_table { | |||
52 | spinlock_t lock; | 52 | spinlock_t lock; |
53 | }; | 53 | }; |
54 | 54 | ||
55 | struct rc_keymap { | ||
56 | struct list_head list; | ||
57 | struct ir_scancode_table map; | ||
58 | }; | ||
59 | |||
55 | struct ir_dev_props { | 60 | struct ir_dev_props { |
56 | unsigned long allowed_protos; | 61 | unsigned long allowed_protos; |
57 | void *priv; | 62 | void *priv; |
@@ -126,6 +131,12 @@ int ir_input_register(struct input_dev *dev, | |||
126 | const char *driver_name); | 131 | const char *driver_name); |
127 | void ir_input_unregister(struct input_dev *input_dev); | 132 | void ir_input_unregister(struct input_dev *input_dev); |
128 | 133 | ||
134 | /* Routines from rc-map.c */ | ||
135 | |||
136 | int ir_register_map(struct rc_keymap *map); | ||
137 | void ir_unregister_map(struct rc_keymap *map); | ||
138 | struct ir_scancode_table *get_rc_map(const char *name); | ||
139 | |||
129 | /* Routines from ir-sysfs.c */ | 140 | /* Routines from ir-sysfs.c */ |
130 | 141 | ||
131 | int ir_register_class(struct input_dev *input_dev); | 142 | int ir_register_class(struct input_dev *input_dev); |