ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / media / ir-common.h
1 /*
2  * some common structs and functions to handle infrared remotes via
3  * input layer ...
4  *
5  * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, write to the Free Software
19  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include <linux/version.h>
23 #include <linux/input.h>
24
25
26 #define IR_TYPE_RC5     1
27 #define IR_TYPE_OTHER  99
28
29 #define IR_KEYTAB_TYPE  u32
30 #define IR_KEYTAB_SIZE  64  // enougth for rc5, probably need more some day ...
31
32 #define IR_KEYCODE(tab,code)    (((unsigned)code < IR_KEYTAB_SIZE) \
33                                  ? tab[code] : KEY_RESERVED)
34
35 struct ir_input_state {
36         /* configuration */
37         int                ir_type;
38         IR_KEYTAB_TYPE     ir_codes[IR_KEYTAB_SIZE];
39
40         /* key info */
41         u32                ir_raw;      /* raw data */
42         u32                ir_key;      /* ir key code */
43         u32                keycode;     /* linux key code */
44         int                keypressed;  /* current state */
45 };
46
47 extern IR_KEYTAB_TYPE ir_codes_rc5_tv[IR_KEYTAB_SIZE];
48 extern IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE];
49
50 void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
51                    int ir_type, IR_KEYTAB_TYPE *ir_codes);
52 void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir);
53 void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
54                       u32 ir_key, u32 ir_raw);
55 u32  ir_extract_bits(u32 data, u32 mask);
56
57 /*
58  * Local variables:
59  * c-basic-offset: 8
60  * End:
61  */