Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
1da177e4 LT |
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 | ||
d5e52653 MCC |
23 | #ifndef _IR_COMMON |
24 | #define _IR_COMMON | |
1da177e4 | 25 | |
d5e52653 | 26 | #include <linux/input.h> |
0b778a56 | 27 | #include <linux/workqueue.h> |
622ecb30 | 28 | #include <linux/interrupt.h> |
7fee03e4 | 29 | #include <linux/spinlock.h> |
1da177e4 | 30 | |
4e89217b MCC |
31 | extern int media_ir_debug; /* media_ir_debug level (0,1,2) */ |
32 | #define IR_dprintk(level, fmt, arg...) if (media_ir_debug >= level) \ | |
a53e2125 | 33 | printk(KERN_DEBUG "%s: " fmt , __func__, ## arg) |
4e89217b | 34 | |
1da177e4 | 35 | #define IR_TYPE_RC5 1 |
793cf9e6 | 36 | #define IR_TYPE_PD 2 /* Pulse distance encoded IR */ |
1da177e4 LT |
37 | #define IR_TYPE_OTHER 99 |
38 | ||
715a2233 MCC |
39 | struct ir_scancode { |
40 | u16 scancode; | |
41 | u32 keycode; | |
42 | }; | |
43 | ||
44 | struct ir_scancode_table { | |
45 | struct ir_scancode *scan; | |
46 | int size; | |
7fee03e4 | 47 | spinlock_t lock; |
715a2233 | 48 | }; |
1da177e4 | 49 | |
9160723e HP |
50 | #define RC5_START(x) (((x)>>12)&3) |
51 | #define RC5_TOGGLE(x) (((x)>>11)&1) | |
52 | #define RC5_ADDR(x) (((x)>>6)&31) | |
53 | #define RC5_INSTR(x) ((x)&63) | |
54 | ||
1da177e4 LT |
55 | struct ir_input_state { |
56 | /* configuration */ | |
57 | int ir_type; | |
1da177e4 | 58 | |
f6fc5049 MCC |
59 | struct ir_scancode_table keytable; |
60 | ||
1da177e4 | 61 | /* key info */ |
8573b74a | 62 | u32 ir_key; /* ir scancode */ |
1da177e4 LT |
63 | u32 keycode; /* linux key code */ |
64 | int keypressed; /* current state */ | |
65 | }; | |
66 | ||
9160723e HP |
67 | /* this was saa7134_ir and bttv_ir, moved here for |
68 | * rc5 decoding. */ | |
69 | struct card_ir { | |
70 | struct input_dev *dev; | |
71 | struct ir_input_state ir; | |
72 | char name[32]; | |
73 | char phys[32]; | |
74 | ||
75 | /* Usual gpio signalling */ | |
76 | ||
77 | u32 mask_keycode; | |
78 | u32 mask_keydown; | |
79 | u32 mask_keyup; | |
80 | u32 polling; | |
81 | u32 last_gpio; | |
82 | int shift_by; | |
83 | int start; // What should RC5_START() be | |
84 | int addr; // What RC5_ADDR() should be. | |
85 | int rc5_key_timeout; | |
86 | int rc5_remote_gap; | |
87 | struct work_struct work; | |
88 | struct timer_list timer; | |
89 | ||
90 | /* RC5 gpio */ | |
91 | u32 rc5_gpio; | |
92 | struct timer_list timer_end; /* timer_end for code completion */ | |
93 | struct timer_list timer_keyup; /* timer_end for key release */ | |
94 | u32 last_rc5; /* last good rc5 code */ | |
95 | u32 last_bit; /* last raw bit seen */ | |
96 | u32 code; /* raw code under construction */ | |
97 | struct timeval base_time; /* time of last seen code */ | |
98 | int active; /* building raw code */ | |
622ecb30 MCC |
99 | |
100 | /* NEC decoding */ | |
101 | u32 nec_gpio; | |
102 | struct tasklet_struct tlet; | |
9160723e HP |
103 | }; |
104 | ||
ef53a115 MCC |
105 | /* Routines from ir-functions.c */ |
106 | ||
055cd556 | 107 | int ir_input_init(struct input_dev *dev, struct ir_input_state *ir, |
715a2233 | 108 | int ir_type, struct ir_scancode_table *ir_codes); |
1da177e4 LT |
109 | void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir); |
110 | void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir, | |
8573b74a | 111 | u32 ir_key); |
1da177e4 LT |
112 | u32 ir_extract_bits(u32 data, u32 mask); |
113 | int ir_dump_samples(u32 *samples, int count); | |
114 | int ir_decode_biphase(u32 *samples, int count, int low, int high); | |
793cf9e6 | 115 | int ir_decode_pulsedistance(u32 *samples, int count, int low, int high); |
1d23a002 | 116 | u32 ir_rc5_decode(unsigned int code); |
1da177e4 | 117 | |
9160723e HP |
118 | void ir_rc5_timer_end(unsigned long data); |
119 | void ir_rc5_timer_keyup(unsigned long data); | |
120 | ||
ef53a115 MCC |
121 | /* Routines from ir-keytable.c */ |
122 | ||
123 | u32 ir_g_keycode_from_table(struct input_dev *input_dev, | |
124 | u32 scancode); | |
125 | ||
126 | int ir_set_keycode_table(struct input_dev *input_dev, | |
127 | struct ir_scancode_table *rc_tab); | |
f6fc5049 MCC |
128 | |
129 | int ir_roundup_tablesize(int n_elems); | |
130 | int ir_copy_table(struct ir_scancode_table *destin, | |
131 | const struct ir_scancode_table *origin); | |
055cd556 | 132 | void ir_input_free(struct input_dev *input_dev); |
ef53a115 MCC |
133 | |
134 | /* scancode->keycode map tables from ir-keymaps.c */ | |
4c0f631e | 135 | |
715a2233 MCC |
136 | extern struct ir_scancode_table ir_codes_empty_table; |
137 | extern struct ir_scancode_table ir_codes_avermedia_table; | |
138 | extern struct ir_scancode_table ir_codes_avermedia_dvbt_table; | |
139 | extern struct ir_scancode_table ir_codes_avermedia_m135a_table; | |
140 | extern struct ir_scancode_table ir_codes_avermedia_cardbus_table; | |
141 | extern struct ir_scancode_table ir_codes_apac_viewcomp_table; | |
142 | extern struct ir_scancode_table ir_codes_pixelview_table; | |
143 | extern struct ir_scancode_table ir_codes_pixelview_new_table; | |
144 | extern struct ir_scancode_table ir_codes_nebula_table; | |
145 | extern struct ir_scancode_table ir_codes_dntv_live_dvb_t_table; | |
146 | extern struct ir_scancode_table ir_codes_iodata_bctv7e_table; | |
147 | extern struct ir_scancode_table ir_codes_adstech_dvb_t_pci_table; | |
148 | extern struct ir_scancode_table ir_codes_msi_tvanywhere_table; | |
149 | extern struct ir_scancode_table ir_codes_cinergy_1400_table; | |
150 | extern struct ir_scancode_table ir_codes_avertv_303_table; | |
151 | extern struct ir_scancode_table ir_codes_dntv_live_dvbt_pro_table; | |
152 | extern struct ir_scancode_table ir_codes_em_terratec_table; | |
153 | extern struct ir_scancode_table ir_codes_pinnacle_grey_table; | |
154 | extern struct ir_scancode_table ir_codes_flyvideo_table; | |
155 | extern struct ir_scancode_table ir_codes_flydvb_table; | |
156 | extern struct ir_scancode_table ir_codes_cinergy_table; | |
157 | extern struct ir_scancode_table ir_codes_eztv_table; | |
158 | extern struct ir_scancode_table ir_codes_avermedia_table; | |
159 | extern struct ir_scancode_table ir_codes_videomate_tv_pvr_table; | |
160 | extern struct ir_scancode_table ir_codes_manli_table; | |
161 | extern struct ir_scancode_table ir_codes_gotview7135_table; | |
162 | extern struct ir_scancode_table ir_codes_purpletv_table; | |
163 | extern struct ir_scancode_table ir_codes_pctv_sedna_table; | |
164 | extern struct ir_scancode_table ir_codes_pv951_table; | |
165 | extern struct ir_scancode_table ir_codes_rc5_tv_table; | |
166 | extern struct ir_scancode_table ir_codes_winfast_table; | |
167 | extern struct ir_scancode_table ir_codes_pinnacle_color_table; | |
168 | extern struct ir_scancode_table ir_codes_hauppauge_new_table; | |
35d1988c | 169 | extern struct ir_scancode_table ir_codes_rc5_hauppauge_new_table; |
715a2233 MCC |
170 | extern struct ir_scancode_table ir_codes_npgtech_table; |
171 | extern struct ir_scancode_table ir_codes_norwood_table; | |
172 | extern struct ir_scancode_table ir_codes_proteus_2309_table; | |
173 | extern struct ir_scancode_table ir_codes_budget_ci_old_table; | |
174 | extern struct ir_scancode_table ir_codes_asus_pc39_table; | |
175 | extern struct ir_scancode_table ir_codes_encore_enltv_table; | |
176 | extern struct ir_scancode_table ir_codes_encore_enltv2_table; | |
177 | extern struct ir_scancode_table ir_codes_tt_1500_table; | |
178 | extern struct ir_scancode_table ir_codes_fusionhdtv_mce_table; | |
179 | extern struct ir_scancode_table ir_codes_behold_table; | |
180 | extern struct ir_scancode_table ir_codes_behold_columbus_table; | |
181 | extern struct ir_scancode_table ir_codes_pinnacle_pctv_hd_table; | |
182 | extern struct ir_scancode_table ir_codes_genius_tvgo_a11mce_table; | |
183 | extern struct ir_scancode_table ir_codes_powercolor_real_angel_table; | |
184 | extern struct ir_scancode_table ir_codes_avermedia_a16d_table; | |
185 | extern struct ir_scancode_table ir_codes_encore_enltv_fm53_table; | |
186 | extern struct ir_scancode_table ir_codes_real_audio_220_32_keys_table; | |
187 | extern struct ir_scancode_table ir_codes_msi_tvanywhere_plus_table; | |
188 | extern struct ir_scancode_table ir_codes_ati_tv_wonder_hd_600_table; | |
189 | extern struct ir_scancode_table ir_codes_kworld_plus_tv_analog_table; | |
190 | extern struct ir_scancode_table ir_codes_kaiomy_table; | |
191 | extern struct ir_scancode_table ir_codes_dm1105_nec_table; | |
9d2ba7ad | 192 | extern struct ir_scancode_table ir_codes_tevii_nec_table; |
d8d86225 | 193 | extern struct ir_scancode_table ir_codes_tbs_nec_table; |
715a2233 MCC |
194 | extern struct ir_scancode_table ir_codes_evga_indtube_table; |
195 | extern struct ir_scancode_table ir_codes_terratec_cinergy_xs_table; | |
196 | extern struct ir_scancode_table ir_codes_videomate_s350_table; | |
197 | extern struct ir_scancode_table ir_codes_gadmei_rm008z_table; | |
d5e52653 | 198 | #endif |