]> Pileus Git - ~andy/linux/blob - include/media/ir-common.h
V4L/DVB: ir-common: move IR tables from ir-keymaps.c to a separate file
[~andy/linux] / include / media / ir-common.h
1 /*
2  *
3  * some common structs and functions to handle infrared remotes via
4  * input layer ...
5  *
6  * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #ifndef _IR_COMMON
24 #define _IR_COMMON
25
26 #include <linux/input.h>
27 #include <linux/workqueue.h>
28 #include <linux/interrupt.h>
29 #include <media/ir-core.h>
30
31 #include <media/keycodes/adstech-dvb-t-pci.h>
32 #include <media/keycodes/apac-viewcomp.h>
33 #include <media/keycodes/asus-pc39.h>
34 #include <media/keycodes/ati-tv-wonder-hd-600.h>
35 #include <media/keycodes/avermedia-a16d.h>
36 #include <media/keycodes/avermedia-cardbus.h>
37 #include <media/keycodes/avermedia-dvbt.h>
38 #include <media/keycodes/avermedia.h>
39 #include <media/keycodes/avermedia-m135a-rm-jx.h>
40 #include <media/keycodes/avertv-303.h>
41 #include <media/keycodes/behold-columbus.h>
42 #include <media/keycodes/behold.h>
43 #include <media/keycodes/budget-ci-old.h>
44 #include <media/keycodes/cinergy-1400.h>
45 #include <media/keycodes/cinergy.h>
46 #include <media/keycodes/dm1105-nec.h>
47 #include <media/keycodes/dntv-live-dvb-t.h>
48 #include <media/keycodes/dntv-live-dvbt-pro.h>
49 #include <media/keycodes/empty.h>
50 #include <media/keycodes/em-terratec.h>
51 #include <media/keycodes/encore-enltv2.h>
52 #include <media/keycodes/encore-enltv-fm53.h>
53 #include <media/keycodes/encore-enltv.h>
54 #include <media/keycodes/evga-indtube.h>
55 #include <media/keycodes/eztv.h>
56 #include <media/keycodes/flydvb.h>
57 #include <media/keycodes/flyvideo.h>
58 #include <media/keycodes/fusionhdtv-mce.h>
59 #include <media/keycodes/gadmei-rm008z.h>
60 #include <media/keycodes/genius-tvgo-a11mce.h>
61 #include <media/keycodes/gotview7135.h>
62 #include <media/keycodes/hauppauge-new.h>
63 #include <media/keycodes/iodata-bctv7e.h>
64 #include <media/keycodes/kaiomy.h>
65 #include <media/keycodes/kworld-315u.h>
66 #include <media/keycodes/kworld-plus-tv-analog.h>
67 #include <media/keycodes/manli.h>
68 #include <media/keycodes/msi-tvanywhere.h>
69 #include <media/keycodes/msi-tvanywhere-plus.h>
70 #include <media/keycodes/nebula.h>
71 #include <media/keycodes/nec-terratec-cinergy-xs.h>
72 #include <media/keycodes/norwood.h>
73 #include <media/keycodes/npgtech.h>
74 #include <media/keycodes/pctv-sedna.h>
75 #include <media/keycodes/pinnacle-color.h>
76 #include <media/keycodes/pinnacle-grey.h>
77 #include <media/keycodes/pinnacle-pctv-hd.h>
78 #include <media/keycodes/pixelview.h>
79 #include <media/keycodes/pixelview-new.h>
80 #include <media/keycodes/powercolor-real-angel.h>
81 #include <media/keycodes/proteus-2309.h>
82 #include <media/keycodes/purpletv.h>
83 #include <media/keycodes/pv951.h>
84 #include <media/keycodes/rc5-hauppauge-new.h>
85 #include <media/keycodes/rc5-tv.h>
86 #include <media/keycodes/real-audio-220-32-keys.h>
87 #include <media/keycodes/tbs-nec.h>
88 #include <media/keycodes/terratec-cinergy-xs.h>
89 #include <media/keycodes/tevii-nec.h>
90 #include <media/keycodes/tt-1500.h>
91 #include <media/keycodes/videomate-s350.h>
92 #include <media/keycodes/videomate-tv-pvr.h>
93 #include <media/keycodes/winfast.h>
94 #include <media/keycodes/winfast-usbii-deluxe.h>
95
96 #define RC5_START(x)    (((x)>>12)&3)
97 #define RC5_TOGGLE(x)   (((x)>>11)&1)
98 #define RC5_ADDR(x)     (((x)>>6)&31)
99 #define RC5_INSTR(x)    ((x)&63)
100
101 struct ir_input_state {
102         /* configuration */
103         u64      ir_type;
104
105         /* key info */
106         u32                ir_key;      /* ir scancode */
107         u32                keycode;     /* linux key code */
108         int                keypressed;  /* current state */
109 };
110
111 /* this was saa7134_ir and bttv_ir, moved here for
112  * rc5 decoding. */
113 struct card_ir {
114         struct input_dev        *dev;
115         struct ir_input_state   ir;
116         char                    name[32];
117         char                    phys[32];
118         int                     users;
119
120         u32                     running:1;
121         struct ir_dev_props     props;
122
123         /* Usual gpio signalling */
124
125         u32                     mask_keycode;
126         u32                     mask_keydown;
127         u32                     mask_keyup;
128         u32                     polling;
129         u32                     last_gpio;
130         int                     shift_by;
131         int                     start; // What should RC5_START() be
132         int                     addr; // What RC5_ADDR() should be.
133         int                     rc5_key_timeout;
134         int                     rc5_remote_gap;
135         struct work_struct      work;
136         struct timer_list       timer;
137
138         /* RC5 gpio */
139         u32 rc5_gpio;
140         struct timer_list timer_end;    /* timer_end for code completion */
141         struct timer_list timer_keyup;  /* timer_end for key release */
142         u32 last_rc5;                   /* last good rc5 code */
143         u32 last_bit;                   /* last raw bit seen */
144         u32 code;                       /* raw code under construction */
145         struct timeval base_time;       /* time of last seen code */
146         int active;                     /* building raw code */
147
148         /* NEC decoding */
149         u32                     nec_gpio;
150         struct tasklet_struct   tlet;
151
152         /* IR core raw decoding */
153         u32                     raw_decode;
154 };
155
156 /* Routines from ir-functions.c */
157
158 int ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
159                    const u64 ir_type);
160 void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir);
161 void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
162                       u32 ir_key);
163 u32  ir_extract_bits(u32 data, u32 mask);
164 int  ir_dump_samples(u32 *samples, int count);
165 int  ir_decode_biphase(u32 *samples, int count, int low, int high);
166 int  ir_decode_pulsedistance(u32 *samples, int count, int low, int high);
167 u32  ir_rc5_decode(unsigned int code);
168
169 void ir_rc5_timer_end(unsigned long data);
170 void ir_rc5_timer_keyup(unsigned long data);
171
172 #endif