blob: 61c223bc39537b3b5da43c920da746b97c7ea18f [file] [log] [blame]
Mauro Carvalho Chehab446e4a62009-12-11 08:34:07 -03001/*
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
20extern 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
Mauro Carvalho Chehab971e8292009-12-14 13:53:37 -030024#define IR_TYPE_UNKNOWN 0
25#define IR_TYPE_RC5 (1 << 0) /* Philips RC5 protocol */
26#define IR_TYPE_PD (1 << 1) /* Pulse distance encoded IR */
27#define IR_TYPE_NEC (1 << 2)
28#define IR_TYPE_OTHER (((u64)1) << 63l)
Mauro Carvalho Chehab446e4a62009-12-11 08:34:07 -030029
30struct ir_scancode {
31 u16 scancode;
32 u32 keycode;
33};
34
35struct ir_scancode_table {
36 struct ir_scancode *scan;
37 int size;
Mauro Carvalho Chehab971e8292009-12-14 13:53:37 -030038 u64 ir_type;
Mauro Carvalho Chehab446e4a62009-12-11 08:34:07 -030039 spinlock_t lock;
40};
41
Mauro Carvalho Chehabe93854d2009-12-14 00:16:55 -030042struct ir_dev_props {
43 unsigned long allowed_protos;
44 void *priv;
Mauro Carvalho Chehab971e8292009-12-14 13:53:37 -030045 int (*change_protocol)(void *priv, u64 ir_type);
Mauro Carvalho Chehabe93854d2009-12-14 00:16:55 -030046};
47
Mauro Carvalho Chehab53f87022009-12-14 02:16:36 -030048
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -030049struct ir_input_dev {
Mauro Carvalho Chehab4714eda2009-12-13 16:00:08 -030050 struct input_dev *dev; /* Input device*/
51 struct ir_scancode_table rc_tab; /* scan/key table */
52 unsigned long devno; /* device number */
53 struct attribute_group attr; /* IR attributes */
54 struct device *class_dev; /* virtual class dev */
Mauro Carvalho Chehabe93854d2009-12-14 00:16:55 -030055 const struct ir_dev_props *props; /* Device properties */
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -030056};
Mauro Carvalho Chehab53f87022009-12-14 02:16:36 -030057#define to_ir_input_dev(_attr) container_of(_attr, struct ir_input_dev, attr)
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -030058
Mauro Carvalho Chehab446e4a62009-12-11 08:34:07 -030059/* Routines from ir-keytable.c */
60
61u32 ir_g_keycode_from_table(struct input_dev *input_dev,
62 u32 scancode);
63
Mauro Carvalho Chehab75543cc2009-12-11 09:44:23 -030064int ir_input_register(struct input_dev *dev,
Mauro Carvalho Chehabe93854d2009-12-14 00:16:55 -030065 const struct ir_scancode_table *ir_codes,
66 const struct ir_dev_props *props);
Mauro Carvalho Chehab38ef6aa2009-12-11 09:47:42 -030067void ir_input_unregister(struct input_dev *input_dev);
Mauro Carvalho Chehab446e4a62009-12-11 08:34:07 -030068
Mauro Carvalho Chehab4714eda2009-12-13 16:00:08 -030069/* Routines from ir-sysfs.c */
70
71int ir_register_class(struct input_dev *input_dev);
72void ir_unregister_class(struct input_dev *input_dev);
73
Mauro Carvalho Chehab446e4a62009-12-11 08:34:07 -030074#endif