Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Mauro Carvalho Chehab | d5e5265 | 2005-11-08 21:37:32 -0800 | [diff] [blame] | 23 | #ifndef _IR_COMMON |
| 24 | #define _IR_COMMON |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
Mauro Carvalho Chehab | d5e5265 | 2005-11-08 21:37:32 -0800 | [diff] [blame] | 26 | #include <linux/input.h> |
Mauro Carvalho Chehab | 0b778a5 | 2006-12-27 14:04:09 -0200 | [diff] [blame] | 27 | #include <linux/workqueue.h> |
Mauro Carvalho Chehab | 622ecb3 | 2008-08-05 10:03:17 -0300 | [diff] [blame] | 28 | #include <linux/interrupt.h> |
Mauro Carvalho Chehab | 446e4a6 | 2009-12-11 08:34:07 -0300 | [diff] [blame] | 29 | #include <media/ir-core.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 31 | #define RC5_START(x) (((x)>>12)&3) |
| 32 | #define RC5_TOGGLE(x) (((x)>>11)&1) |
| 33 | #define RC5_ADDR(x) (((x)>>6)&31) |
| 34 | #define RC5_INSTR(x) ((x)&63) |
| 35 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | struct ir_input_state { |
| 37 | /* configuration */ |
Mauro Carvalho Chehab | 971e829 | 2009-12-14 13:53:37 -0300 | [diff] [blame] | 38 | u64 ir_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
| 40 | /* key info */ |
Mauro Carvalho Chehab | 8573b74 | 2009-11-27 22:40:22 -0300 | [diff] [blame] | 41 | u32 ir_key; /* ir scancode */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | u32 keycode; /* linux key code */ |
| 43 | int keypressed; /* current state */ |
| 44 | }; |
| 45 | |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 46 | /* this was saa7134_ir and bttv_ir, moved here for |
| 47 | * rc5 decoding. */ |
| 48 | struct card_ir { |
| 49 | struct input_dev *dev; |
| 50 | struct ir_input_state ir; |
| 51 | char name[32]; |
| 52 | char phys[32]; |
Mauro Carvalho Chehab | 716aab4 | 2010-03-31 14:40:35 -0300 | [diff] [blame^] | 53 | int users; |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 54 | |
Mauro Carvalho Chehab | 0210894 | 2010-03-20 00:25:37 -0300 | [diff] [blame] | 55 | u32 running:1; |
| 56 | struct ir_dev_props props; |
| 57 | |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 58 | /* Usual gpio signalling */ |
| 59 | |
| 60 | u32 mask_keycode; |
| 61 | u32 mask_keydown; |
| 62 | u32 mask_keyup; |
| 63 | u32 polling; |
| 64 | u32 last_gpio; |
| 65 | int shift_by; |
| 66 | int start; // What should RC5_START() be |
| 67 | int addr; // What RC5_ADDR() should be. |
| 68 | int rc5_key_timeout; |
| 69 | int rc5_remote_gap; |
| 70 | struct work_struct work; |
| 71 | struct timer_list timer; |
| 72 | |
| 73 | /* RC5 gpio */ |
| 74 | u32 rc5_gpio; |
| 75 | struct timer_list timer_end; /* timer_end for code completion */ |
| 76 | struct timer_list timer_keyup; /* timer_end for key release */ |
| 77 | u32 last_rc5; /* last good rc5 code */ |
| 78 | u32 last_bit; /* last raw bit seen */ |
| 79 | u32 code; /* raw code under construction */ |
| 80 | struct timeval base_time; /* time of last seen code */ |
| 81 | int active; /* building raw code */ |
Mauro Carvalho Chehab | 622ecb3 | 2008-08-05 10:03:17 -0300 | [diff] [blame] | 82 | |
| 83 | /* NEC decoding */ |
| 84 | u32 nec_gpio; |
| 85 | struct tasklet_struct tlet; |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 86 | |
| 87 | /* IR core raw decoding */ |
| 88 | u32 raw_decode; |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 89 | }; |
| 90 | |
Mauro Carvalho Chehab | ef53a11 | 2009-11-27 22:01:23 -0300 | [diff] [blame] | 91 | /* Routines from ir-functions.c */ |
| 92 | |
Mauro Carvalho Chehab | 055cd55 | 2009-11-29 08:19:59 -0300 | [diff] [blame] | 93 | int ir_input_init(struct input_dev *dev, struct ir_input_state *ir, |
Mauro Carvalho Chehab | 971e829 | 2009-12-14 13:53:37 -0300 | [diff] [blame] | 94 | const u64 ir_type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir); |
| 96 | void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir, |
Mauro Carvalho Chehab | 8573b74 | 2009-11-27 22:40:22 -0300 | [diff] [blame] | 97 | u32 ir_key); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | u32 ir_extract_bits(u32 data, u32 mask); |
| 99 | int ir_dump_samples(u32 *samples, int count); |
| 100 | int ir_decode_biphase(u32 *samples, int count, int low, int high); |
Mauro Carvalho Chehab | 793cf9e | 2005-09-09 13:03:37 -0700 | [diff] [blame] | 101 | int ir_decode_pulsedistance(u32 *samples, int count, int low, int high); |
Andy Walls | 1d23a00 | 2009-09-27 20:05:23 -0300 | [diff] [blame] | 102 | u32 ir_rc5_decode(unsigned int code); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 104 | void ir_rc5_timer_end(unsigned long data); |
| 105 | void ir_rc5_timer_keyup(unsigned long data); |
| 106 | |
Mauro Carvalho Chehab | ef53a11 | 2009-11-27 22:01:23 -0300 | [diff] [blame] | 107 | /* scancode->keycode map tables from ir-keymaps.c */ |
Ricardo Cerqueira | 4c0f631 | 2006-01-23 09:42:06 -0200 | [diff] [blame] | 108 | |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 109 | extern struct ir_scancode_table ir_codes_empty_table; |
| 110 | extern struct ir_scancode_table ir_codes_avermedia_table; |
| 111 | extern struct ir_scancode_table ir_codes_avermedia_dvbt_table; |
Mauro Carvalho Chehab | d152b8b | 2010-03-20 00:23:30 -0300 | [diff] [blame] | 112 | extern struct ir_scancode_table ir_codes_avermedia_m135a_rm_jx_table; |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 113 | extern struct ir_scancode_table ir_codes_avermedia_cardbus_table; |
| 114 | extern struct ir_scancode_table ir_codes_apac_viewcomp_table; |
| 115 | extern struct ir_scancode_table ir_codes_pixelview_table; |
| 116 | extern struct ir_scancode_table ir_codes_pixelview_new_table; |
| 117 | extern struct ir_scancode_table ir_codes_nebula_table; |
| 118 | extern struct ir_scancode_table ir_codes_dntv_live_dvb_t_table; |
| 119 | extern struct ir_scancode_table ir_codes_iodata_bctv7e_table; |
| 120 | extern struct ir_scancode_table ir_codes_adstech_dvb_t_pci_table; |
| 121 | extern struct ir_scancode_table ir_codes_msi_tvanywhere_table; |
| 122 | extern struct ir_scancode_table ir_codes_cinergy_1400_table; |
| 123 | extern struct ir_scancode_table ir_codes_avertv_303_table; |
| 124 | extern struct ir_scancode_table ir_codes_dntv_live_dvbt_pro_table; |
| 125 | extern struct ir_scancode_table ir_codes_em_terratec_table; |
| 126 | extern struct ir_scancode_table ir_codes_pinnacle_grey_table; |
| 127 | extern struct ir_scancode_table ir_codes_flyvideo_table; |
| 128 | extern struct ir_scancode_table ir_codes_flydvb_table; |
| 129 | extern struct ir_scancode_table ir_codes_cinergy_table; |
| 130 | extern struct ir_scancode_table ir_codes_eztv_table; |
| 131 | extern struct ir_scancode_table ir_codes_avermedia_table; |
| 132 | extern struct ir_scancode_table ir_codes_videomate_tv_pvr_table; |
| 133 | extern struct ir_scancode_table ir_codes_manli_table; |
| 134 | extern struct ir_scancode_table ir_codes_gotview7135_table; |
| 135 | extern struct ir_scancode_table ir_codes_purpletv_table; |
| 136 | extern struct ir_scancode_table ir_codes_pctv_sedna_table; |
| 137 | extern struct ir_scancode_table ir_codes_pv951_table; |
| 138 | extern struct ir_scancode_table ir_codes_rc5_tv_table; |
| 139 | extern struct ir_scancode_table ir_codes_winfast_table; |
| 140 | extern struct ir_scancode_table ir_codes_pinnacle_color_table; |
| 141 | extern struct ir_scancode_table ir_codes_hauppauge_new_table; |
Mauro Carvalho Chehab | 35d1988 | 2009-11-27 23:25:13 -0300 | [diff] [blame] | 142 | extern struct ir_scancode_table ir_codes_rc5_hauppauge_new_table; |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 143 | extern struct ir_scancode_table ir_codes_npgtech_table; |
| 144 | extern struct ir_scancode_table ir_codes_norwood_table; |
| 145 | extern struct ir_scancode_table ir_codes_proteus_2309_table; |
| 146 | extern struct ir_scancode_table ir_codes_budget_ci_old_table; |
| 147 | extern struct ir_scancode_table ir_codes_asus_pc39_table; |
| 148 | extern struct ir_scancode_table ir_codes_encore_enltv_table; |
| 149 | extern struct ir_scancode_table ir_codes_encore_enltv2_table; |
| 150 | extern struct ir_scancode_table ir_codes_tt_1500_table; |
| 151 | extern struct ir_scancode_table ir_codes_fusionhdtv_mce_table; |
| 152 | extern struct ir_scancode_table ir_codes_behold_table; |
| 153 | extern struct ir_scancode_table ir_codes_behold_columbus_table; |
| 154 | extern struct ir_scancode_table ir_codes_pinnacle_pctv_hd_table; |
| 155 | extern struct ir_scancode_table ir_codes_genius_tvgo_a11mce_table; |
| 156 | extern struct ir_scancode_table ir_codes_powercolor_real_angel_table; |
| 157 | extern struct ir_scancode_table ir_codes_avermedia_a16d_table; |
| 158 | extern struct ir_scancode_table ir_codes_encore_enltv_fm53_table; |
| 159 | extern struct ir_scancode_table ir_codes_real_audio_220_32_keys_table; |
| 160 | extern struct ir_scancode_table ir_codes_msi_tvanywhere_plus_table; |
| 161 | extern struct ir_scancode_table ir_codes_ati_tv_wonder_hd_600_table; |
| 162 | extern struct ir_scancode_table ir_codes_kworld_plus_tv_analog_table; |
| 163 | extern struct ir_scancode_table ir_codes_kaiomy_table; |
| 164 | extern struct ir_scancode_table ir_codes_dm1105_nec_table; |
Igor M. Liplianin | 9d2ba7a | 2009-09-23 14:44:12 -0300 | [diff] [blame] | 165 | extern struct ir_scancode_table ir_codes_tevii_nec_table; |
Igor M. Liplianin | d8d8622 | 2009-09-19 09:51:12 -0300 | [diff] [blame] | 166 | extern struct ir_scancode_table ir_codes_tbs_nec_table; |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 167 | extern struct ir_scancode_table ir_codes_evga_indtube_table; |
| 168 | extern struct ir_scancode_table ir_codes_terratec_cinergy_xs_table; |
| 169 | extern struct ir_scancode_table ir_codes_videomate_s350_table; |
| 170 | extern struct ir_scancode_table ir_codes_gadmei_rm008z_table; |
Mauro Carvalho Chehab | cda4303 | 2009-12-05 09:34:21 -0300 | [diff] [blame] | 171 | extern struct ir_scancode_table ir_codes_nec_terratec_cinergy_xs_table; |
Magnus Alm | ca39d84 | 2009-11-13 05:48:24 -0300 | [diff] [blame] | 172 | extern struct ir_scancode_table ir_codes_winfast_usbii_deluxe_table; |
Franklin Meng | 9a0a75a | 2010-02-13 02:37:15 -0300 | [diff] [blame] | 173 | extern struct ir_scancode_table ir_codes_kworld_315u_table; |
Mauro Carvalho Chehab | d5e5265 | 2005-11-08 21:37:32 -0800 | [diff] [blame] | 174 | #endif |