diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-11-09 21:44:27 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-12-29 05:16:37 -0500 |
commit | 631493ecacd81f1af74de459c1d16f7ffa6c82c0 (patch) | |
tree | 646a1fc62e8bb6e581d6583c94a5668a43d9a5f2 /drivers/media/rc | |
parent | bc2a6c5719efd74ce841ad0f0c9b6ea2590da6da (diff) |
[media] rc-core: merge rc-map.c into rc-main.c
With this change, all rc-core functions are into just one file, except
for the rc-raw specific functions.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/rc')
-rw-r--r-- | drivers/media/rc/Makefile | 2 | ||||
-rw-r--r-- | drivers/media/rc/rc-main.c | 94 | ||||
-rw-r--r-- | drivers/media/rc/rc-map.c | 107 |
3 files changed, 94 insertions, 109 deletions
diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile index 5a1112cfe8ec..1eb24e6bc55c 100644 --- a/drivers/media/rc/Makefile +++ b/drivers/media/rc/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | ir-common-objs := ir-functions.o | 1 | ir-common-objs := ir-functions.o |
2 | rc-core-objs := rc-main.o rc-raw.o rc-map.o | 2 | rc-core-objs := rc-main.o rc-raw.o |
3 | 3 | ||
4 | obj-y += keymaps/ | 4 | obj-y += keymaps/ |
5 | 5 | ||
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index d7726776f937..afcf0a88464d 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c | |||
@@ -12,7 +12,9 @@ | |||
12 | * GNU General Public License for more details. | 12 | * GNU General Public License for more details. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | 15 | #include <media/ir-core.h> | |
16 | #include <linux/spinlock.h> | ||
17 | #include <linux/delay.h> | ||
16 | #include <linux/input.h> | 18 | #include <linux/input.h> |
17 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
18 | #include <linux/device.h> | 20 | #include <linux/device.h> |
@@ -30,6 +32,96 @@ static unsigned long ir_core_dev_number; | |||
30 | /* FIXME: IR_KEYPRESS_TIMEOUT should be protocol specific */ | 32 | /* FIXME: IR_KEYPRESS_TIMEOUT should be protocol specific */ |
31 | #define IR_KEYPRESS_TIMEOUT 250 | 33 | #define IR_KEYPRESS_TIMEOUT 250 |
32 | 34 | ||
35 | /* Used to handle IR raw handler extensions */ | ||
36 | static LIST_HEAD(rc_map_list); | ||
37 | static DEFINE_SPINLOCK(rc_map_lock); | ||
38 | |||
39 | static struct rc_keymap *seek_rc_map(const char *name) | ||
40 | { | ||
41 | struct rc_keymap *map = NULL; | ||
42 | |||
43 | spin_lock(&rc_map_lock); | ||
44 | list_for_each_entry(map, &rc_map_list, list) { | ||
45 | if (!strcmp(name, map->map.name)) { | ||
46 | spin_unlock(&rc_map_lock); | ||
47 | return map; | ||
48 | } | ||
49 | } | ||
50 | spin_unlock(&rc_map_lock); | ||
51 | |||
52 | return NULL; | ||
53 | } | ||
54 | |||
55 | struct ir_scancode_table *get_rc_map(const char *name) | ||
56 | { | ||
57 | |||
58 | struct rc_keymap *map; | ||
59 | |||
60 | map = seek_rc_map(name); | ||
61 | #ifdef MODULE | ||
62 | if (!map) { | ||
63 | int rc = request_module(name); | ||
64 | if (rc < 0) { | ||
65 | printk(KERN_ERR "Couldn't load IR keymap %s\n", name); | ||
66 | return NULL; | ||
67 | } | ||
68 | msleep(20); /* Give some time for IR to register */ | ||
69 | |||
70 | map = seek_rc_map(name); | ||
71 | } | ||
72 | #endif | ||
73 | if (!map) { | ||
74 | printk(KERN_ERR "IR keymap %s not found\n", name); | ||
75 | return NULL; | ||
76 | } | ||
77 | |||
78 | printk(KERN_INFO "Registered IR keymap %s\n", map->map.name); | ||
79 | |||
80 | return &map->map; | ||
81 | } | ||
82 | EXPORT_SYMBOL_GPL(get_rc_map); | ||
83 | |||
84 | int ir_register_map(struct rc_keymap *map) | ||
85 | { | ||
86 | spin_lock(&rc_map_lock); | ||
87 | list_add_tail(&map->list, &rc_map_list); | ||
88 | spin_unlock(&rc_map_lock); | ||
89 | return 0; | ||
90 | } | ||
91 | EXPORT_SYMBOL_GPL(ir_register_map); | ||
92 | |||
93 | void ir_unregister_map(struct rc_keymap *map) | ||
94 | { | ||
95 | spin_lock(&rc_map_lock); | ||
96 | list_del(&map->list); | ||
97 | spin_unlock(&rc_map_lock); | ||
98 | } | ||
99 | EXPORT_SYMBOL_GPL(ir_unregister_map); | ||
100 | |||
101 | |||
102 | static struct ir_scancode empty[] = { | ||
103 | { 0x2a, KEY_COFFEE }, | ||
104 | }; | ||
105 | |||
106 | static struct rc_keymap empty_map = { | ||
107 | .map = { | ||
108 | .scan = empty, | ||
109 | .size = ARRAY_SIZE(empty), | ||
110 | .ir_type = IR_TYPE_UNKNOWN, /* Legacy IR type */ | ||
111 | .name = RC_MAP_EMPTY, | ||
112 | } | ||
113 | }; | ||
114 | |||
115 | int ir_rcmap_init(void) | ||
116 | { | ||
117 | return ir_register_map(&empty_map); | ||
118 | } | ||
119 | |||
120 | void ir_rcmap_cleanup(void) | ||
121 | { | ||
122 | ir_unregister_map(&empty_map); | ||
123 | } | ||
124 | |||
33 | /** | 125 | /** |
34 | * ir_create_table() - initializes a scancode table | 126 | * ir_create_table() - initializes a scancode table |
35 | * @rc_tab: the ir_scancode_table to initialize | 127 | * @rc_tab: the ir_scancode_table to initialize |
diff --git a/drivers/media/rc/rc-map.c b/drivers/media/rc/rc-map.c deleted file mode 100644 index 689143f2fff0..000000000000 --- a/drivers/media/rc/rc-map.c +++ /dev/null | |||
@@ -1,107 +0,0 @@ | |||
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 | #include <linux/delay.h> | ||
18 | |||
19 | /* Used to handle IR raw handler extensions */ | ||
20 | static LIST_HEAD(rc_map_list); | ||
21 | static DEFINE_SPINLOCK(rc_map_lock); | ||
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 | spin_unlock(&rc_map_lock); | ||
31 | return map; | ||
32 | } | ||
33 | } | ||
34 | spin_unlock(&rc_map_lock); | ||
35 | |||
36 | return NULL; | ||
37 | } | ||
38 | |||
39 | struct ir_scancode_table *get_rc_map(const char *name) | ||
40 | { | ||
41 | |||
42 | struct rc_keymap *map; | ||
43 | |||
44 | map = seek_rc_map(name); | ||
45 | #ifdef MODULE | ||
46 | if (!map) { | ||
47 | int rc = request_module(name); | ||
48 | if (rc < 0) { | ||
49 | printk(KERN_ERR "Couldn't load IR keymap %s\n", name); | ||
50 | return NULL; | ||
51 | } | ||
52 | msleep(20); /* Give some time for IR to register */ | ||
53 | |||
54 | map = seek_rc_map(name); | ||
55 | } | ||
56 | #endif | ||
57 | if (!map) { | ||
58 | printk(KERN_ERR "IR keymap %s not found\n", name); | ||
59 | return NULL; | ||
60 | } | ||
61 | |||
62 | printk(KERN_INFO "Registered IR keymap %s\n", map->map.name); | ||
63 | |||
64 | return &map->map; | ||
65 | } | ||
66 | EXPORT_SYMBOL_GPL(get_rc_map); | ||
67 | |||
68 | int ir_register_map(struct rc_keymap *map) | ||
69 | { | ||
70 | spin_lock(&rc_map_lock); | ||
71 | list_add_tail(&map->list, &rc_map_list); | ||
72 | spin_unlock(&rc_map_lock); | ||
73 | return 0; | ||
74 | } | ||
75 | EXPORT_SYMBOL_GPL(ir_register_map); | ||
76 | |||
77 | void ir_unregister_map(struct rc_keymap *map) | ||
78 | { | ||
79 | spin_lock(&rc_map_lock); | ||
80 | list_del(&map->list); | ||
81 | spin_unlock(&rc_map_lock); | ||
82 | } | ||
83 | EXPORT_SYMBOL_GPL(ir_unregister_map); | ||
84 | |||
85 | |||
86 | static struct ir_scancode empty[] = { | ||
87 | { 0x2a, KEY_COFFEE }, | ||
88 | }; | ||
89 | |||
90 | static struct rc_keymap empty_map = { | ||
91 | .map = { | ||
92 | .scan = empty, | ||
93 | .size = ARRAY_SIZE(empty), | ||
94 | .ir_type = IR_TYPE_UNKNOWN, /* Legacy IR type */ | ||
95 | .name = RC_MAP_EMPTY, | ||
96 | } | ||
97 | }; | ||
98 | |||
99 | int ir_rcmap_init(void) | ||
100 | { | ||
101 | return ir_register_map(&empty_map); | ||
102 | } | ||
103 | |||
104 | void ir_rcmap_cleanup(void) | ||
105 | { | ||
106 | ir_unregister_map(&empty_map); | ||
107 | } | ||