Mauro Carvalho Chehab | 446e4a6 | 2009-12-11 08:34:07 -0300 | [diff] [blame] | 1 | /* |
| 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 | |
| 20 | extern 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 | |
| 24 | enum ir_type { |
| 25 | IR_TYPE_UNKNOWN = 0, |
Mauro Carvalho Chehab | e93854d | 2009-12-14 00:16:55 -0300 | [diff] [blame^] | 26 | IR_TYPE_RC5 = 1L << 0, /* Philips RC5 protocol */ |
| 27 | IR_TYPE_PD = 1L << 1, /* Pulse distance encoded IR */ |
| 28 | IR_TYPE_NEC = 1L << 2, |
| 29 | IR_TYPE_OTHER = 1L << 63, |
Mauro Carvalho Chehab | 446e4a6 | 2009-12-11 08:34:07 -0300 | [diff] [blame] | 30 | }; |
| 31 | |
| 32 | struct ir_scancode { |
| 33 | u16 scancode; |
| 34 | u32 keycode; |
| 35 | }; |
| 36 | |
| 37 | struct ir_scancode_table { |
| 38 | struct ir_scancode *scan; |
| 39 | int size; |
| 40 | enum ir_type ir_type; |
| 41 | spinlock_t lock; |
| 42 | }; |
| 43 | |
Mauro Carvalho Chehab | e93854d | 2009-12-14 00:16:55 -0300 | [diff] [blame^] | 44 | struct ir_dev_props { |
| 45 | unsigned long allowed_protos; |
| 46 | void *priv; |
| 47 | int (*change_protocol)(void *priv, unsigned long protocol); |
| 48 | }; |
| 49 | |
Mauro Carvalho Chehab | 75543cc | 2009-12-11 09:44:23 -0300 | [diff] [blame] | 50 | struct ir_input_dev { |
Mauro Carvalho Chehab | 4714eda | 2009-12-13 16:00:08 -0300 | [diff] [blame] | 51 | struct input_dev *dev; /* Input device*/ |
| 52 | struct ir_scancode_table rc_tab; /* scan/key table */ |
| 53 | unsigned long devno; /* device number */ |
| 54 | struct attribute_group attr; /* IR attributes */ |
| 55 | struct device *class_dev; /* virtual class dev */ |
Mauro Carvalho Chehab | e93854d | 2009-12-14 00:16:55 -0300 | [diff] [blame^] | 56 | const struct ir_dev_props *props; /* Device properties */ |
Mauro Carvalho Chehab | 75543cc | 2009-12-11 09:44:23 -0300 | [diff] [blame] | 57 | }; |
| 58 | |
Mauro Carvalho Chehab | 446e4a6 | 2009-12-11 08:34:07 -0300 | [diff] [blame] | 59 | /* Routines from ir-keytable.c */ |
| 60 | |
| 61 | u32 ir_g_keycode_from_table(struct input_dev *input_dev, |
| 62 | u32 scancode); |
| 63 | |
| 64 | int ir_set_keycode_table(struct input_dev *input_dev, |
| 65 | struct ir_scancode_table *rc_tab); |
| 66 | |
| 67 | int ir_roundup_tablesize(int n_elems); |
Mauro Carvalho Chehab | 75543cc | 2009-12-11 09:44:23 -0300 | [diff] [blame] | 68 | int ir_input_register(struct input_dev *dev, |
Mauro Carvalho Chehab | e93854d | 2009-12-14 00:16:55 -0300 | [diff] [blame^] | 69 | const struct ir_scancode_table *ir_codes, |
| 70 | const struct ir_dev_props *props); |
Mauro Carvalho Chehab | 38ef6aa | 2009-12-11 09:47:42 -0300 | [diff] [blame] | 71 | void ir_input_unregister(struct input_dev *input_dev); |
Mauro Carvalho Chehab | 446e4a6 | 2009-12-11 08:34:07 -0300 | [diff] [blame] | 72 | |
Mauro Carvalho Chehab | 4714eda | 2009-12-13 16:00:08 -0300 | [diff] [blame] | 73 | /* Routines from ir-sysfs.c */ |
| 74 | |
| 75 | int ir_register_class(struct input_dev *input_dev); |
| 76 | void ir_unregister_class(struct input_dev *input_dev); |
| 77 | |
Mauro Carvalho Chehab | 446e4a6 | 2009-12-11 08:34:07 -0300 | [diff] [blame] | 78 | #endif |