2010-04-02 13:33:35 +08:00
|
|
|
/* 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>
|
2010-05-05 23:20:21 +08:00
|
|
|
#include <linux/delay.h>
|
2010-04-02 13:33:35 +08:00
|
|
|
|
|
|
|
/* Used to handle IR raw handler extensions */
|
|
|
|
static LIST_HEAD(rc_map_list);
|
2010-04-08 03:19:36 +08:00
|
|
|
static DEFINE_SPINLOCK(rc_map_lock);
|
2010-04-02 13:33:35 +08:00
|
|
|
|
|
|
|
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) {
|
2010-04-03 07:01:00 +08:00
|
|
|
if (!strcmp(name, map->map.name)) {
|
|
|
|
spin_unlock(&rc_map_lock);
|
|
|
|
return map;
|
|
|
|
}
|
2010-04-02 13:33:35 +08:00
|
|
|
}
|
|
|
|
spin_unlock(&rc_map_lock);
|
|
|
|
|
2010-04-03 07:01:00 +08:00
|
|
|
return NULL;
|
2010-04-02 13:33:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
struct ir_scancode_table *get_rc_map(const char *name)
|
|
|
|
{
|
|
|
|
|
|
|
|
struct rc_keymap *map;
|
|
|
|
|
|
|
|
map = seek_rc_map(name);
|
|
|
|
#ifdef MODULE
|
|
|
|
if (!map) {
|
2010-04-09 06:04:06 +08:00
|
|
|
int rc = request_module(name);
|
2010-04-03 07:01:00 +08:00
|
|
|
if (rc < 0) {
|
|
|
|
printk(KERN_ERR "Couldn't load IR keymap %s\n", name);
|
2010-04-02 13:33:35 +08:00
|
|
|
return NULL;
|
2010-04-03 07:01:00 +08:00
|
|
|
}
|
|
|
|
msleep(20); /* Give some time for IR to register */
|
2010-04-02 13:33:35 +08:00
|
|
|
|
|
|
|
map = seek_rc_map(name);
|
|
|
|
}
|
|
|
|
#endif
|
2010-04-03 07:01:00 +08:00
|
|
|
if (!map) {
|
|
|
|
printk(KERN_ERR "IR keymap %s not found\n", name);
|
2010-04-02 13:33:35 +08:00
|
|
|
return NULL;
|
2010-04-03 07:01:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
printk(KERN_INFO "Registered IR keymap %s\n", map->map.name);
|
2010-04-02 13:33:35 +08:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
V4L/DVB: Break Remote Controller keymaps into modules
The original Remote Controller approach were very messy: a big file,
that were part of ir-common kernel module, containing 64 different
RC keymap tables, used by the V4L/DVB drivers.
Better to break each RC keymap table into a separate module,
registering them into rc core on a process similar to the fs/nls tables.
As an userspace program is now in charge of loading those tables,
adds an option to allow the complete removal of those tables from
kernelspace.
Yet, on embedded devices like Set Top Boxes and TV sets, maybe the
only available input device is the IR. So, we should keep allowing
the usage of in-kernel tables, but a latter patch should change
the default to 'n', after giving some time for distros to add
the v4l-utils with the ir-keytable program, to allow the table
load via userspace.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-04-02 14:05:46 +08:00
|
|
|
EXPORT_SYMBOL_GPL(ir_register_map);
|
2010-04-02 13:33:35 +08:00
|
|
|
|
|
|
|
void ir_unregister_map(struct rc_keymap *map)
|
|
|
|
{
|
|
|
|
spin_lock(&rc_map_lock);
|
|
|
|
list_del(&map->list);
|
|
|
|
spin_unlock(&rc_map_lock);
|
|
|
|
}
|
V4L/DVB: Break Remote Controller keymaps into modules
The original Remote Controller approach were very messy: a big file,
that were part of ir-common kernel module, containing 64 different
RC keymap tables, used by the V4L/DVB drivers.
Better to break each RC keymap table into a separate module,
registering them into rc core on a process similar to the fs/nls tables.
As an userspace program is now in charge of loading those tables,
adds an option to allow the complete removal of those tables from
kernelspace.
Yet, on embedded devices like Set Top Boxes and TV sets, maybe the
only available input device is the IR. So, we should keep allowing
the usage of in-kernel tables, but a latter patch should change
the default to 'n', after giving some time for distros to add
the v4l-utils with the ir-keytable program, to allow the table
load via userspace.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-04-02 14:05:46 +08:00
|
|
|
EXPORT_SYMBOL_GPL(ir_unregister_map);
|
2010-04-03 07:01:00 +08:00
|
|
|
|