mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 22:51:42 +00:00
V4L/DVB: ir-core: Add support for RC map code register
Instead of having all RC tables hardcoded on one file with all tables there, add infrastructure for registering and dynamically load the table(s) when needed. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
77b7422d48
commit
9ce50c1a5f
@ -1,5 +1,5 @@
|
|||||||
ir-common-objs := ir-functions.o ir-keymaps.o
|
ir-common-objs := ir-functions.o ir-keymaps.o
|
||||||
ir-core-objs := ir-keytable.o ir-sysfs.o ir-raw-event.o
|
ir-core-objs := ir-keytable.o ir-sysfs.o ir-raw-event.o rc-map.o
|
||||||
|
|
||||||
obj-$(CONFIG_IR_CORE) += ir-core.o
|
obj-$(CONFIG_IR_CORE) += ir-core.o
|
||||||
obj-$(CONFIG_VIDEO_IR) += ir-common.o
|
obj-$(CONFIG_VIDEO_IR) += ir-common.o
|
||||||
|
75
drivers/media/IR/rc-map.c
Normal file
75
drivers/media/IR/rc-map.c
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/* ir-raw-event.c - handle IR Pulse/Space event
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <media/ir-core.h>
|
||||||
|
#include <linux/spinlock.h>
|
||||||
|
|
||||||
|
/* Used to handle IR raw handler extensions */
|
||||||
|
static LIST_HEAD(rc_map_list);
|
||||||
|
static spinlock_t rc_map_lock;
|
||||||
|
|
||||||
|
|
||||||
|
static struct rc_keymap *seek_rc_map(const char *name)
|
||||||
|
{
|
||||||
|
struct rc_keymap *map = NULL;
|
||||||
|
|
||||||
|
spin_lock(&rc_map_lock);
|
||||||
|
list_for_each_entry(map, &rc_map_list, list) {
|
||||||
|
if (!strcmp(name, map->map.name))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
spin_unlock(&rc_map_lock);
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ir_scancode_table *get_rc_map(const char *name)
|
||||||
|
{
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
struct rc_keymap *map;
|
||||||
|
|
||||||
|
map = seek_rc_map(name);
|
||||||
|
#ifdef MODULE
|
||||||
|
if (!map) {
|
||||||
|
rc = request_module("name");
|
||||||
|
if (rc < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
map = seek_rc_map(name);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (!map)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return &map->map;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(get_rc_map);
|
||||||
|
|
||||||
|
int ir_register_map(struct rc_keymap *map)
|
||||||
|
{
|
||||||
|
spin_lock(&rc_map_lock);
|
||||||
|
list_add_tail(&map->list, &rc_map_list);
|
||||||
|
spin_unlock(&rc_map_lock);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(ir_raw_handler_register);
|
||||||
|
|
||||||
|
void ir_unregister_map(struct rc_keymap *map)
|
||||||
|
{
|
||||||
|
spin_lock(&rc_map_lock);
|
||||||
|
list_del(&map->list);
|
||||||
|
spin_unlock(&rc_map_lock);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(ir_raw_handler_unregister);
|
@ -52,6 +52,11 @@ struct ir_scancode_table {
|
|||||||
spinlock_t lock;
|
spinlock_t lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct rc_keymap {
|
||||||
|
struct list_head list;
|
||||||
|
struct ir_scancode_table map;
|
||||||
|
};
|
||||||
|
|
||||||
struct ir_dev_props {
|
struct ir_dev_props {
|
||||||
unsigned long allowed_protos;
|
unsigned long allowed_protos;
|
||||||
void *priv;
|
void *priv;
|
||||||
@ -126,6 +131,12 @@ int ir_input_register(struct input_dev *dev,
|
|||||||
const char *driver_name);
|
const char *driver_name);
|
||||||
void ir_input_unregister(struct input_dev *input_dev);
|
void ir_input_unregister(struct input_dev *input_dev);
|
||||||
|
|
||||||
|
/* Routines from rc-map.c */
|
||||||
|
|
||||||
|
int ir_register_map(struct rc_keymap *map);
|
||||||
|
void ir_unregister_map(struct rc_keymap *map);
|
||||||
|
struct ir_scancode_table *get_rc_map(const char *name);
|
||||||
|
|
||||||
/* Routines from ir-sysfs.c */
|
/* Routines from ir-sysfs.c */
|
||||||
|
|
||||||
int ir_register_class(struct input_dev *input_dev);
|
int ir_register_class(struct input_dev *input_dev);
|
||||||
|
Loading…
Reference in New Issue
Block a user