diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-11 06:34:07 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-15 21:18:42 -0500 |
commit | 446e4a64d2f6efddc63a47169ba3c8037b620307 (patch) | |
tree | 3b14d76f7e93d5b35de50edf85a9179f759adb3d | |
parent | e27d38112eb727df189a9ebf560aa104cb102253 (diff) |
V4L/DVB (13613): IR: create ir-core module
Split the ir-common into two separate modules:
- ir-core: it is the IR-independent functions;
- ir-common: has the common part used by V4L drivers.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/IR/Kconfig | 7 | ||||
-rw-r--r-- | drivers/media/IR/Makefile | 4 | ||||
-rw-r--r-- | drivers/media/IR/ir-functions.c | 3 | ||||
-rw-r--r-- | drivers/media/IR/ir-keytable.c | 21 | ||||
-rw-r--r-- | include/media/ir-common.h | 39 | ||||
-rw-r--r-- | include/media/ir-core.h | 57 |
6 files changed, 86 insertions, 45 deletions
diff --git a/drivers/media/IR/Kconfig b/drivers/media/IR/Kconfig index 5b4ac969a586..4dde7d180a32 100644 --- a/drivers/media/IR/Kconfig +++ b/drivers/media/IR/Kconfig | |||
@@ -1,4 +1,9 @@ | |||
1 | config VIDEO_IR | 1 | config IR_CORE |
2 | tristate | 2 | tristate |
3 | depends on INPUT | 3 | depends on INPUT |
4 | default INPUT | 4 | default INPUT |
5 | |||
6 | config VIDEO_IR | ||
7 | tristate | ||
8 | depends on IR_CORE | ||
9 | default IR_CORE | ||
diff --git a/drivers/media/IR/Makefile b/drivers/media/IR/Makefile index 2781f430c6e1..df5ddb4bbbf7 100644 --- a/drivers/media/IR/Makefile +++ b/drivers/media/IR/Makefile | |||
@@ -1,3 +1,5 @@ | |||
1 | ir-common-objs := ir-functions.o ir-keymaps.o ir-keytable.o | 1 | ir-common-objs := ir-functions.o ir-keymaps.o |
2 | ir-core-objs := ir-keytable.o | ||
2 | 3 | ||
4 | obj-$(CONFIG_IR_CORE) += ir-core.o | ||
3 | obj-$(CONFIG_VIDEO_IR) += ir-common.o | 5 | obj-$(CONFIG_VIDEO_IR) += ir-common.o |
diff --git a/drivers/media/IR/ir-functions.c b/drivers/media/IR/ir-functions.c index e616f624ceaa..2db22948a310 100644 --- a/drivers/media/IR/ir-functions.c +++ b/drivers/media/IR/ir-functions.c | |||
@@ -34,9 +34,6 @@ static int repeat = 1; | |||
34 | module_param(repeat, int, 0444); | 34 | module_param(repeat, int, 0444); |
35 | MODULE_PARM_DESC(repeat,"auto-repeat for IR keys (default: on)"); | 35 | MODULE_PARM_DESC(repeat,"auto-repeat for IR keys (default: on)"); |
36 | 36 | ||
37 | int media_ir_debug; /* media_ir_debug level (0,1,2) */ | ||
38 | module_param_named(debug, media_ir_debug, int, 0644); | ||
39 | |||
40 | /* -------------------------------------------------------------------------- */ | 37 | /* -------------------------------------------------------------------------- */ |
41 | 38 | ||
42 | static void ir_input_key_event(struct input_dev *dev, struct ir_input_state *ir) | 39 | static void ir_input_key_event(struct input_dev *dev, struct ir_input_state *ir) |
diff --git a/drivers/media/IR/ir-keytable.c b/drivers/media/IR/ir-keytable.c index 99ed2deceef3..20d642dbab49 100644 --- a/drivers/media/IR/ir-keytable.c +++ b/drivers/media/IR/ir-keytable.c | |||
@@ -1,6 +1,15 @@ | |||
1 | /* ir-register.c - handle IR scancode->keycode tables | 1 | /* ir-register.c - handle IR scancode->keycode tables |
2 | * | 2 | * |
3 | * Copyright (C) 2009 by Mauro Carvalho Chehab <mchehab@redhat.com> | 3 | * Copyright (C) 2009 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. | ||
4 | */ | 13 | */ |
5 | 14 | ||
6 | #include <linux/usb/input.h> | 15 | #include <linux/usb/input.h> |
@@ -10,7 +19,6 @@ | |||
10 | #define IR_TAB_MIN_SIZE 32 | 19 | #define IR_TAB_MIN_SIZE 32 |
11 | #define IR_TAB_MAX_SIZE 1024 | 20 | #define IR_TAB_MAX_SIZE 1024 |
12 | 21 | ||
13 | |||
14 | /** | 22 | /** |
15 | * ir_seek_table() - returns the element order on the table | 23 | * ir_seek_table() - returns the element order on the table |
16 | * @rc_tab: the ir_scancode_table with the keymap to be used | 24 | * @rc_tab: the ir_scancode_table with the keymap to be used |
@@ -73,6 +81,7 @@ int ir_roundup_tablesize(int n_elems) | |||
73 | 81 | ||
74 | return n_elems; | 82 | return n_elems; |
75 | } | 83 | } |
84 | EXPORT_SYMBOL_GPL(ir_roundup_tablesize); | ||
76 | 85 | ||
77 | /** | 86 | /** |
78 | * ir_copy_table() - copies a keytable, discarding the unused entries | 87 | * ir_copy_table() - copies a keytable, discarding the unused entries |
@@ -101,6 +110,7 @@ int ir_copy_table(struct ir_scancode_table *destin, | |||
101 | 110 | ||
102 | return 0; | 111 | return 0; |
103 | } | 112 | } |
113 | EXPORT_SYMBOL_GPL(ir_copy_table); | ||
104 | 114 | ||
105 | /** | 115 | /** |
106 | * ir_getkeycode() - get a keycode at the evdev scancode ->keycode table | 116 | * ir_getkeycode() - get a keycode at the evdev scancode ->keycode table |
@@ -137,7 +147,6 @@ static int ir_getkeycode(struct input_dev *dev, | |||
137 | return 0; | 147 | return 0; |
138 | } | 148 | } |
139 | 149 | ||
140 | |||
141 | /** | 150 | /** |
142 | * ir_is_resize_needed() - Check if the table needs rezise | 151 | * ir_is_resize_needed() - Check if the table needs rezise |
143 | * @table: keycode table that may need to resize | 152 | * @table: keycode table that may need to resize |
@@ -379,6 +388,7 @@ u32 ir_g_keycode_from_table(struct input_dev *dev, u32 scancode) | |||
379 | /* Reports userspace that an unknown keycode were got */ | 388 | /* Reports userspace that an unknown keycode were got */ |
380 | return KEY_RESERVED; | 389 | return KEY_RESERVED; |
381 | } | 390 | } |
391 | EXPORT_SYMBOL_GPL(ir_g_keycode_from_table); | ||
382 | 392 | ||
383 | /** | 393 | /** |
384 | * ir_set_keycode_table() - sets the IR keycode table and add the handlers | 394 | * ir_set_keycode_table() - sets the IR keycode table and add the handlers |
@@ -415,6 +425,7 @@ int ir_set_keycode_table(struct input_dev *input_dev, | |||
415 | 425 | ||
416 | return 0; | 426 | return 0; |
417 | } | 427 | } |
428 | EXPORT_SYMBOL_GPL(ir_set_keycode_table); | ||
418 | 429 | ||
419 | void ir_input_free(struct input_dev *dev) | 430 | void ir_input_free(struct input_dev *dev) |
420 | { | 431 | { |
@@ -431,3 +442,9 @@ void ir_input_free(struct input_dev *dev) | |||
431 | } | 442 | } |
432 | EXPORT_SYMBOL_GPL(ir_input_free); | 443 | EXPORT_SYMBOL_GPL(ir_input_free); |
433 | 444 | ||
445 | int ir_core_debug; /* ir_debug level (0,1,2) */ | ||
446 | EXPORT_SYMBOL_GPL(ir_core_debug); | ||
447 | module_param_named(debug, ir_core_debug, int, 0644); | ||
448 | |||
449 | MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); | ||
450 | MODULE_LICENSE("GPL"); | ||
diff --git a/include/media/ir-common.h b/include/media/ir-common.h index 45bf5cf59458..18d300414fa2 100644 --- a/include/media/ir-common.h +++ b/include/media/ir-common.h | |||
@@ -26,31 +26,7 @@ | |||
26 | #include <linux/input.h> | 26 | #include <linux/input.h> |
27 | #include <linux/workqueue.h> | 27 | #include <linux/workqueue.h> |
28 | #include <linux/interrupt.h> | 28 | #include <linux/interrupt.h> |
29 | #include <linux/spinlock.h> | 29 | #include <media/ir-core.h> |
30 | |||
31 | extern int media_ir_debug; /* media_ir_debug level (0,1,2) */ | ||
32 | #define IR_dprintk(level, fmt, arg...) if (media_ir_debug >= level) \ | ||
33 | printk(KERN_DEBUG "%s: " fmt , __func__, ## arg) | ||
34 | |||
35 | enum ir_type { | ||
36 | IR_TYPE_UNKNOWN = 0, | ||
37 | IR_TYPE_RC5 = 1, | ||
38 | IR_TYPE_PD = 2, /* Pulse distance encoded IR */ | ||
39 | IR_TYPE_NEC = 3, | ||
40 | IR_TYPE_OTHER = 99, | ||
41 | }; | ||
42 | |||
43 | struct ir_scancode { | ||
44 | u16 scancode; | ||
45 | u32 keycode; | ||
46 | }; | ||
47 | |||
48 | struct ir_scancode_table { | ||
49 | struct ir_scancode *scan; | ||
50 | int size; | ||
51 | enum ir_type ir_type; | ||
52 | spinlock_t lock; | ||
53 | }; | ||
54 | 30 | ||
55 | #define RC5_START(x) (((x)>>12)&3) | 31 | #define RC5_START(x) (((x)>>12)&3) |
56 | #define RC5_TOGGLE(x) (((x)>>11)&1) | 32 | #define RC5_TOGGLE(x) (((x)>>11)&1) |
@@ -123,19 +99,6 @@ u32 ir_rc5_decode(unsigned int code); | |||
123 | void ir_rc5_timer_end(unsigned long data); | 99 | void ir_rc5_timer_end(unsigned long data); |
124 | void ir_rc5_timer_keyup(unsigned long data); | 100 | void ir_rc5_timer_keyup(unsigned long data); |
125 | 101 | ||
126 | /* Routines from ir-keytable.c */ | ||
127 | |||
128 | u32 ir_g_keycode_from_table(struct input_dev *input_dev, | ||
129 | u32 scancode); | ||
130 | |||
131 | int ir_set_keycode_table(struct input_dev *input_dev, | ||
132 | struct ir_scancode_table *rc_tab); | ||
133 | |||
134 | int ir_roundup_tablesize(int n_elems); | ||
135 | int ir_copy_table(struct ir_scancode_table *destin, | ||
136 | const struct ir_scancode_table *origin); | ||
137 | void ir_input_free(struct input_dev *input_dev); | ||
138 | |||
139 | /* scancode->keycode map tables from ir-keymaps.c */ | 102 | /* scancode->keycode map tables from ir-keymaps.c */ |
140 | 103 | ||
141 | extern struct ir_scancode_table ir_codes_empty_table; | 104 | extern struct ir_scancode_table ir_codes_empty_table; |
diff --git a/include/media/ir-core.h b/include/media/ir-core.h new file mode 100644 index 000000000000..825d04a4e77b --- /dev/null +++ b/include/media/ir-core.h | |||
@@ -0,0 +1,57 @@ | |||
1 | /* | ||
2 | * Remote Controller core header | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation version 2 of the License. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | */ | ||
13 | |||
14 | #ifndef _IR_CORE | ||
15 | #define _IR_CORE | ||
16 | |||
17 | #include <linux/input.h> | ||
18 | #include <linux/spinlock.h> | ||
19 | |||
20 | extern int ir_core_debug; | ||
21 | #define IR_dprintk(level, fmt, arg...) if (ir_core_debug >= level) \ | ||
22 | printk(KERN_DEBUG "%s: " fmt , __func__, ## arg) | ||
23 | |||
24 | enum ir_type { | ||
25 | IR_TYPE_UNKNOWN = 0, | ||
26 | IR_TYPE_RC5 = 1, | ||
27 | IR_TYPE_PD = 2, /* Pulse distance encoded IR */ | ||
28 | IR_TYPE_NEC = 3, | ||
29 | IR_TYPE_OTHER = 99, | ||
30 | }; | ||
31 | |||
32 | struct ir_scancode { | ||
33 | u16 scancode; | ||
34 | u32 keycode; | ||
35 | }; | ||
36 | |||
37 | struct ir_scancode_table { | ||
38 | struct ir_scancode *scan; | ||
39 | int size; | ||
40 | enum ir_type ir_type; | ||
41 | spinlock_t lock; | ||
42 | }; | ||
43 | |||
44 | /* Routines from ir-keytable.c */ | ||
45 | |||
46 | u32 ir_g_keycode_from_table(struct input_dev *input_dev, | ||
47 | u32 scancode); | ||
48 | |||
49 | int ir_set_keycode_table(struct input_dev *input_dev, | ||
50 | struct ir_scancode_table *rc_tab); | ||
51 | |||
52 | int ir_roundup_tablesize(int n_elems); | ||
53 | int ir_copy_table(struct ir_scancode_table *destin, | ||
54 | const struct ir_scancode_table *origin); | ||
55 | void ir_input_free(struct input_dev *input_dev); | ||
56 | |||
57 | #endif | ||