From patchwork Tue Apr 6 18:18:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 90842 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o36IJT67008357 for ; Tue, 6 Apr 2010 18:19:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757501Ab0DFSTF (ORCPT ); Tue, 6 Apr 2010 14:19:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49093 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757483Ab0DFSSy (ORCPT ); Tue, 6 Apr 2010 14:18:54 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o36IIsXC019249 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 6 Apr 2010 14:18:54 -0400 Received: from pedra (vpn-8-182.rdu.redhat.com [10.11.8.182]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o36IIAEv021397 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 6 Apr 2010 14:18:52 -0400 Date: Tue, 6 Apr 2010 15:18:03 -0300 From: Mauro Carvalho Chehab To: linux-media@vger.kernel.org, Linux Media Mailing List Subject: [PATCH 07/26] V4L/DVB: ir-core: Add support for RC map code register Message-ID: <20100406151803.593c8b4c@pedra> In-Reply-To: References: Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 06 Apr 2010 18:19:36 +0000 (UTC) diff --git a/drivers/media/IR/Makefile b/drivers/media/IR/Makefile index 6140b27..3a4f590 100644 --- a/drivers/media/IR/Makefile +++ b/drivers/media/IR/Makefile @@ -1,5 +1,5 @@ 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_VIDEO_IR) += ir-common.o diff --git a/drivers/media/IR/rc-map.c b/drivers/media/IR/rc-map.c new file mode 100644 index 0000000..aa269f5 --- /dev/null +++ b/drivers/media/IR/rc-map.c @@ -0,0 +1,75 @@ +/* ir-raw-event.c - handle IR Pulse/Space event + * + * Copyright (C) 2010 by Mauro Carvalho Chehab + * + * 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 +#include + +/* 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); diff --git a/include/media/ir-core.h b/include/media/ir-core.h index 643ff25..39df3cf 100644 --- a/include/media/ir-core.h +++ b/include/media/ir-core.h @@ -52,6 +52,11 @@ struct ir_scancode_table { spinlock_t lock; }; +struct rc_keymap { + struct list_head list; + struct ir_scancode_table map; +}; + struct ir_dev_props { unsigned long allowed_protos; void *priv; @@ -126,6 +131,12 @@ int ir_input_register(struct input_dev *dev, const char *driver_name); 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 */ int ir_register_class(struct input_dev *input_dev);