aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxim Levitsky <maximlevitsky@gmail.com>2010-07-31 10:59:21 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-08-08 22:43:00 -0400
commitb378f43fe9466e7712a8b16be64795ffca3a937e (patch)
tree72b73594094549d049f0dcdd653135f42e3f2b29
parent86ff071cad3e7e4c7469b3941bfced6fe9b04b5f (diff)
V4L/DVB: IR: Allow not to compile keymaps in
Currently, ir device registration fails if keymap requested by driver is not found. Fix that by always compiling in the empty keymap, and using it as a failback. Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com> Acked-by: Jarod Wilson <jarod@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/IR/ir-core-priv.h3
-rw-r--r--drivers/media/IR/ir-sysfs.c2
-rw-r--r--drivers/media/IR/keymaps/Makefile1
-rw-r--r--drivers/media/IR/keymaps/rc-empty.c44
-rw-r--r--drivers/media/IR/rc-map.c23
-rw-r--r--include/media/ir-core.h8
6 files changed, 33 insertions, 48 deletions
diff --git a/drivers/media/IR/ir-core-priv.h b/drivers/media/IR/ir-core-priv.h
index 502d477b391c..be6817261c8f 100644
--- a/drivers/media/IR/ir-core-priv.h
+++ b/drivers/media/IR/ir-core-priv.h
@@ -126,7 +126,8 @@ int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler);
126void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler); 126void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler);
127void ir_raw_init(void); 127void ir_raw_init(void);
128 128
129 129int ir_rcmap_init(void);
130void ir_rcmap_cleanup(void);
130/* 131/*
131 * Decoder initialization code 132 * Decoder initialization code
132 * 133 *
diff --git a/drivers/media/IR/ir-sysfs.c b/drivers/media/IR/ir-sysfs.c
index 6273047e915b..96dafc425c8e 100644
--- a/drivers/media/IR/ir-sysfs.c
+++ b/drivers/media/IR/ir-sysfs.c
@@ -325,6 +325,7 @@ static int __init ir_core_init(void)
325 325
326 /* Initialize/load the decoders/keymap code that will be used */ 326 /* Initialize/load the decoders/keymap code that will be used */
327 ir_raw_init(); 327 ir_raw_init();
328 ir_rcmap_init();
328 329
329 return 0; 330 return 0;
330} 331}
@@ -332,6 +333,7 @@ static int __init ir_core_init(void)
332static void __exit ir_core_exit(void) 333static void __exit ir_core_exit(void)
333{ 334{
334 class_unregister(&ir_input_class); 335 class_unregister(&ir_input_class);
336 ir_rcmap_cleanup();
335} 337}
336 338
337module_init(ir_core_init); 339module_init(ir_core_init);
diff --git a/drivers/media/IR/keymaps/Makefile b/drivers/media/IR/keymaps/Makefile
index c9fcc41944e9..950e5d953c6f 100644
--- a/drivers/media/IR/keymaps/Makefile
+++ b/drivers/media/IR/keymaps/Makefile
@@ -19,7 +19,6 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
19 rc-dm1105-nec.o \ 19 rc-dm1105-nec.o \
20 rc-dntv-live-dvb-t.o \ 20 rc-dntv-live-dvb-t.o \
21 rc-dntv-live-dvbt-pro.o \ 21 rc-dntv-live-dvbt-pro.o \
22 rc-empty.o \
23 rc-em-terratec.o \ 22 rc-em-terratec.o \
24 rc-encore-enltv2.o \ 23 rc-encore-enltv2.o \
25 rc-encore-enltv.o \ 24 rc-encore-enltv.o \
diff --git a/drivers/media/IR/keymaps/rc-empty.c b/drivers/media/IR/keymaps/rc-empty.c
deleted file mode 100644
index 3b338d84b476..000000000000
--- a/drivers/media/IR/keymaps/rc-empty.c
+++ /dev/null
@@ -1,44 +0,0 @@
1/* empty.h - Keytable for empty Remote Controller
2 *
3 * keymap imported from ir-keymaps.c
4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13#include <media/rc-map.h>
14
15/* empty keytable, can be used as placeholder for not-yet created keytables */
16
17static struct ir_scancode empty[] = {
18 { 0x2a, KEY_COFFEE },
19};
20
21static struct rc_keymap empty_map = {
22 .map = {
23 .scan = empty,
24 .size = ARRAY_SIZE(empty),
25 .ir_type = IR_TYPE_UNKNOWN, /* Legacy IR type */
26 .name = RC_MAP_EMPTY,
27 }
28};
29
30static int __init init_rc_map_empty(void)
31{
32 return ir_register_map(&empty_map);
33}
34
35static void __exit exit_rc_map_empty(void)
36{
37 ir_unregister_map(&empty_map);
38}
39
40module_init(init_rc_map_empty)
41module_exit(exit_rc_map_empty)
42
43MODULE_LICENSE("GPL");
44MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");
diff --git a/drivers/media/IR/rc-map.c b/drivers/media/IR/rc-map.c
index 46a8f1524b5b..689143f2fff0 100644
--- a/drivers/media/IR/rc-map.c
+++ b/drivers/media/IR/rc-map.c
@@ -82,3 +82,26 @@ void ir_unregister_map(struct rc_keymap *map)
82} 82}
83EXPORT_SYMBOL_GPL(ir_unregister_map); 83EXPORT_SYMBOL_GPL(ir_unregister_map);
84 84
85
86static struct ir_scancode empty[] = {
87 { 0x2a, KEY_COFFEE },
88};
89
90static 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
99int ir_rcmap_init(void)
100{
101 return ir_register_map(&empty_map);
102}
103
104void ir_rcmap_cleanup(void)
105{
106 ir_unregister_map(&empty_map);
107}
diff --git a/include/media/ir-core.h b/include/media/ir-core.h
index 513e60dd1010..197d05aa83dc 100644
--- a/include/media/ir-core.h
+++ b/include/media/ir-core.h
@@ -110,8 +110,12 @@ static inline int ir_input_register(struct input_dev *dev,
110 return -EINVAL; 110 return -EINVAL;
111 111
112 ir_codes = get_rc_map(map_name); 112 ir_codes = get_rc_map(map_name);
113 if (!ir_codes) 113 if (!ir_codes) {
114 return -EINVAL; 114 ir_codes = get_rc_map(RC_MAP_EMPTY);
115
116 if (!ir_codes)
117 return -EINVAL;
118 }
115 119
116 rc = __ir_input_register(dev, ir_codes, props, driver_name); 120 rc = __ir_input_register(dev, ir_codes, props, driver_name);
117 if (rc < 0) 121 if (rc < 0)