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 | * handle saa7134 IR remotes via linux kernel input layer. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | * |
| 19 | */ |
| 20 | |
| 21 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include <linux/init.h> |
| 23 | #include <linux/delay.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #include <linux/interrupt.h> |
| 25 | #include <linux/input.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 26 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
| 28 | #include "saa7134-reg.h" |
| 29 | #include "saa7134.h" |
| 30 | |
Mauro Carvalho Chehab | 727e625 | 2010-03-12 21:18:14 -0300 | [diff] [blame] | 31 | #define MODULE_NAME "saa7134" |
| 32 | |
Douglas Schilling Landgraf | ff699e6 | 2008-04-22 14:41:48 -0300 | [diff] [blame] | 33 | static unsigned int disable_ir; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | module_param(disable_ir, int, 0444); |
| 35 | MODULE_PARM_DESC(disable_ir,"disable infrared remote support"); |
| 36 | |
Douglas Schilling Landgraf | ff699e6 | 2008-04-22 14:41:48 -0300 | [diff] [blame] | 37 | static unsigned int ir_debug; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | module_param(ir_debug, int, 0644); |
| 39 | MODULE_PARM_DESC(ir_debug,"enable debug messages [IR]"); |
| 40 | |
Douglas Schilling Landgraf | ff699e6 | 2008-04-22 14:41:48 -0300 | [diff] [blame] | 41 | static int pinnacle_remote; |
Sylvain Pasche | b93eedb | 2006-03-25 23:14:42 -0300 | [diff] [blame] | 42 | module_param(pinnacle_remote, int, 0644); /* Choose Pinnacle PCTV remote */ |
| 43 | MODULE_PARM_DESC(pinnacle_remote, "Specify Pinnacle PCTV remote: 0=coloured, 1=grey (defaults to 0)"); |
| 44 | |
Adrian Bunk | c408a6f | 2006-12-28 12:47:47 -0300 | [diff] [blame] | 45 | static int ir_rc5_remote_gap = 885; |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 46 | module_param(ir_rc5_remote_gap, int, 0644); |
Adrian Bunk | c408a6f | 2006-12-28 12:47:47 -0300 | [diff] [blame] | 47 | static int ir_rc5_key_timeout = 115; |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 48 | module_param(ir_rc5_key_timeout, int, 0644); |
| 49 | |
Pedro | 0938e31 | 2007-10-17 17:58:40 -0300 | [diff] [blame] | 50 | static int repeat_delay = 500; |
| 51 | module_param(repeat_delay, int, 0644); |
| 52 | MODULE_PARM_DESC(repeat_delay, "delay before key repeat started"); |
| 53 | static int repeat_period = 33; |
| 54 | module_param(repeat_period, int, 0644); |
Joe Perches | ac9bb7f | 2007-11-20 09:00:35 -0300 | [diff] [blame] | 55 | MODULE_PARM_DESC(repeat_period, "repeat period between " |
Pedro | 0938e31 | 2007-10-17 17:58:40 -0300 | [diff] [blame] | 56 | "keypresses when key is down"); |
| 57 | |
Andrey J. Melnikoff (TEMHOTA) | e8018c9 | 2008-01-07 05:17:39 -0300 | [diff] [blame] | 58 | static unsigned int disable_other_ir; |
| 59 | module_param(disable_other_ir, int, 0644); |
| 60 | MODULE_PARM_DESC(disable_other_ir, "disable full codes of " |
| 61 | "alternative remotes from other manufacturers"); |
| 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | #define dprintk(fmt, arg...) if (ir_debug) \ |
| 64 | printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg) |
Ricardo Cerqueira | ac9cd97 | 2005-11-08 21:37:56 -0800 | [diff] [blame] | 65 | #define i2cdprintk(fmt, arg...) if (ir_debug) \ |
Jean Delvare | 1df8e98 | 2009-05-13 16:48:07 -0300 | [diff] [blame] | 66 | printk(KERN_DEBUG "%s/ir: " fmt, ir->name , ## arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | |
Mauro Carvalho Chehab | 622ecb3 | 2008-08-05 10:03:17 -0300 | [diff] [blame] | 68 | /* Helper functions for RC5 and NEC decoding at GPIO16 or GPIO18 */ |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 69 | static int saa7134_rc5_irq(struct saa7134_dev *dev); |
Mauro Carvalho Chehab | 622ecb3 | 2008-08-05 10:03:17 -0300 | [diff] [blame] | 70 | static int saa7134_nec_irq(struct saa7134_dev *dev); |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 71 | static int saa7134_raw_decode_irq(struct saa7134_dev *dev); |
Mauro Carvalho Chehab | 622ecb3 | 2008-08-05 10:03:17 -0300 | [diff] [blame] | 72 | static void nec_task(unsigned long data); |
| 73 | static void saa7134_nec_timer(unsigned long data); |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 74 | |
Ricardo Cerqueira | ac9cd97 | 2005-11-08 21:37:56 -0800 | [diff] [blame] | 75 | /* -------------------- GPIO generic keycode builder -------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
| 77 | static int build_key(struct saa7134_dev *dev) |
| 78 | { |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 79 | struct card_ir *ir = dev->remote; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | u32 gpio, data; |
| 81 | |
Pedro | 0938e31 | 2007-10-17 17:58:40 -0300 | [diff] [blame] | 82 | /* here comes the additional handshake steps for some cards */ |
| 83 | switch (dev->board) { |
| 84 | case SAA7134_BOARD_GOTVIEW_7135: |
| 85 | saa_setb(SAA7134_GPIO_GPSTATUS1, 0x80); |
| 86 | saa_clearb(SAA7134_GPIO_GPSTATUS1, 0x80); |
| 87 | break; |
| 88 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | /* rising SAA7134_GPIO_GPRESCAN reads the status */ |
| 90 | saa_clearb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN); |
| 91 | saa_setb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN); |
| 92 | |
| 93 | gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2); |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 94 | if (ir->polling) { |
| 95 | if (ir->last_gpio == gpio) |
| 96 | return 0; |
| 97 | ir->last_gpio = gpio; |
| 98 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 100 | data = ir_extract_bits(gpio, ir->mask_keycode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | dprintk("build_key gpio=0x%x mask=0x%x data=%d\n", |
| 102 | gpio, ir->mask_keycode, data); |
| 103 | |
Mauro Carvalho Chehab | 26d5f3a | 2008-12-07 13:19:29 -0300 | [diff] [blame] | 104 | switch (dev->board) { |
| 105 | case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG: |
| 106 | if (data == ir->mask_keycode) |
| 107 | ir_input_nokey(ir->dev, &ir->ir); |
| 108 | else |
Mauro Carvalho Chehab | 8573b74 | 2009-11-27 22:40:22 -0300 | [diff] [blame] | 109 | ir_input_keydown(ir->dev, &ir->ir, data); |
Mauro Carvalho Chehab | 26d5f3a | 2008-12-07 13:19:29 -0300 | [diff] [blame] | 110 | return 0; |
| 111 | } |
| 112 | |
Peter Missel | 0602fbb | 2006-01-09 18:21:23 -0200 | [diff] [blame] | 113 | if (ir->polling) { |
| 114 | if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || |
| 115 | (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { |
Mauro Carvalho Chehab | 8573b74 | 2009-11-27 22:40:22 -0300 | [diff] [blame] | 116 | ir_input_keydown(ir->dev, &ir->ir, data); |
Peter Missel | 0602fbb | 2006-01-09 18:21:23 -0200 | [diff] [blame] | 117 | } else { |
| 118 | ir_input_nokey(ir->dev, &ir->ir); |
| 119 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | } |
Peter Missel | 0602fbb | 2006-01-09 18:21:23 -0200 | [diff] [blame] | 121 | else { /* IRQ driven mode - handle key press and release in one go */ |
| 122 | if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || |
| 123 | (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { |
Mauro Carvalho Chehab | 8573b74 | 2009-11-27 22:40:22 -0300 | [diff] [blame] | 124 | ir_input_keydown(ir->dev, &ir->ir, data); |
Peter Missel | 0602fbb | 2006-01-09 18:21:23 -0200 | [diff] [blame] | 125 | ir_input_nokey(ir->dev, &ir->ir); |
| 126 | } |
| 127 | } |
| 128 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | return 0; |
| 130 | } |
| 131 | |
Ricardo Cerqueira | ac9cd97 | 2005-11-08 21:37:56 -0800 | [diff] [blame] | 132 | /* --------------------- Chip specific I2C key builders ----------------- */ |
| 133 | |
Lukas Karas | d995a18 | 2009-11-24 12:06:52 -0300 | [diff] [blame] | 134 | static int get_key_flydvb_trio(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) |
| 135 | { |
| 136 | int gpio; |
| 137 | int attempt = 0; |
| 138 | unsigned char b; |
| 139 | |
| 140 | /* We need this to access GPI Used by the saa_readl macro. */ |
| 141 | struct saa7134_dev *dev = ir->c->adapter->algo_data; |
| 142 | |
| 143 | if (dev == NULL) { |
| 144 | dprintk("get_key_flydvb_trio: " |
| 145 | "gir->c->adapter->algo_data is NULL!\n"); |
| 146 | return -EIO; |
| 147 | } |
| 148 | |
| 149 | /* rising SAA7134_GPIGPRESCAN reads the status */ |
| 150 | saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); |
| 151 | saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); |
| 152 | |
| 153 | gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2); |
| 154 | |
| 155 | if (0x40000 & ~gpio) |
| 156 | return 0; /* No button press */ |
| 157 | |
| 158 | /* No button press - only before first key pressed */ |
| 159 | if (b == 0xFF) |
| 160 | return 0; |
| 161 | |
| 162 | /* poll IR chip */ |
| 163 | /* weak up the IR chip */ |
| 164 | b = 0; |
| 165 | |
| 166 | while (1 != i2c_master_send(ir->c, &b, 1)) { |
| 167 | if ((attempt++) < 10) { |
| 168 | /* |
| 169 | * wait a bit for next attempt - |
| 170 | * I don't know how make it better |
| 171 | */ |
| 172 | msleep(10); |
| 173 | continue; |
| 174 | } |
| 175 | i2cdprintk("send wake up byte to pic16C505 (IR chip)" |
| 176 | "failed %dx\n", attempt); |
| 177 | return -EIO; |
| 178 | } |
| 179 | if (1 != i2c_master_recv(ir->c, &b, 1)) { |
| 180 | i2cdprintk("read error\n"); |
| 181 | return -EIO; |
| 182 | } |
| 183 | |
| 184 | *ir_key = b; |
| 185 | *ir_raw = b; |
| 186 | return 1; |
| 187 | } |
| 188 | |
Brian Rogers | ba340b4 | 2008-10-13 08:37:06 -0300 | [diff] [blame] | 189 | static int get_key_msi_tvanywhere_plus(struct IR_i2c *ir, u32 *ir_key, |
| 190 | u32 *ir_raw) |
| 191 | { |
| 192 | unsigned char b; |
| 193 | int gpio; |
| 194 | |
| 195 | /* <dev> is needed to access GPIO. Used by the saa_readl macro. */ |
Jean Delvare | c668f32 | 2009-05-13 16:48:50 -0300 | [diff] [blame] | 196 | struct saa7134_dev *dev = ir->c->adapter->algo_data; |
Brian Rogers | ba340b4 | 2008-10-13 08:37:06 -0300 | [diff] [blame] | 197 | if (dev == NULL) { |
| 198 | dprintk("get_key_msi_tvanywhere_plus: " |
Jean Delvare | c668f32 | 2009-05-13 16:48:50 -0300 | [diff] [blame] | 199 | "gir->c->adapter->algo_data is NULL!\n"); |
Brian Rogers | ba340b4 | 2008-10-13 08:37:06 -0300 | [diff] [blame] | 200 | return -EIO; |
| 201 | } |
| 202 | |
| 203 | /* rising SAA7134_GPIO_GPRESCAN reads the status */ |
| 204 | |
| 205 | saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); |
| 206 | saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); |
| 207 | |
| 208 | gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2); |
| 209 | |
| 210 | /* GPIO&0x40 is pulsed low when a button is pressed. Don't do |
| 211 | I2C receive if gpio&0x40 is not low. */ |
| 212 | |
| 213 | if (gpio & 0x40) |
| 214 | return 0; /* No button press */ |
| 215 | |
| 216 | /* GPIO says there is a button press. Get it. */ |
| 217 | |
Jean Delvare | c668f32 | 2009-05-13 16:48:50 -0300 | [diff] [blame] | 218 | if (1 != i2c_master_recv(ir->c, &b, 1)) { |
Brian Rogers | ba340b4 | 2008-10-13 08:37:06 -0300 | [diff] [blame] | 219 | i2cdprintk("read error\n"); |
| 220 | return -EIO; |
| 221 | } |
| 222 | |
| 223 | /* No button press */ |
| 224 | |
| 225 | if (b == 0xff) |
| 226 | return 0; |
| 227 | |
| 228 | /* Button pressed */ |
| 229 | |
| 230 | dprintk("get_key_msi_tvanywhere_plus: Key = 0x%02X\n", b); |
| 231 | *ir_key = b; |
| 232 | *ir_raw = b; |
| 233 | return 1; |
| 234 | } |
| 235 | |
Ricardo Cerqueira | ac9cd97 | 2005-11-08 21:37:56 -0800 | [diff] [blame] | 236 | static int get_key_purpletv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) |
| 237 | { |
| 238 | unsigned char b; |
| 239 | |
| 240 | /* poll IR chip */ |
Jean Delvare | c668f32 | 2009-05-13 16:48:50 -0300 | [diff] [blame] | 241 | if (1 != i2c_master_recv(ir->c, &b, 1)) { |
Ricardo Cerqueira | ac9cd97 | 2005-11-08 21:37:56 -0800 | [diff] [blame] | 242 | i2cdprintk("read error\n"); |
| 243 | return -EIO; |
| 244 | } |
| 245 | |
| 246 | /* no button press */ |
| 247 | if (b==0) |
| 248 | return 0; |
| 249 | |
| 250 | /* repeating */ |
| 251 | if (b & 0x80) |
| 252 | return 1; |
| 253 | |
| 254 | *ir_key = b; |
| 255 | *ir_raw = b; |
| 256 | return 1; |
| 257 | } |
| 258 | |
Thomas Genty | 177aaaf | 2006-11-29 21:57:24 -0300 | [diff] [blame] | 259 | static int get_key_hvr1110(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) |
| 260 | { |
| 261 | unsigned char buf[5], cod4, code3, code4; |
| 262 | |
| 263 | /* poll IR chip */ |
Jean Delvare | c668f32 | 2009-05-13 16:48:50 -0300 | [diff] [blame] | 264 | if (5 != i2c_master_recv(ir->c, buf, 5)) |
Thomas Genty | 177aaaf | 2006-11-29 21:57:24 -0300 | [diff] [blame] | 265 | return -EIO; |
| 266 | |
| 267 | cod4 = buf[4]; |
| 268 | code4 = (cod4 >> 2); |
| 269 | code3 = buf[3]; |
| 270 | if (code3 == 0) |
| 271 | /* no key pressed */ |
| 272 | return 0; |
| 273 | |
| 274 | /* return key */ |
| 275 | *ir_key = code4; |
| 276 | *ir_raw = code4; |
| 277 | return 1; |
| 278 | } |
| 279 | |
Andrey J. Melnikoff (TEMHOTA) | e8018c9 | 2008-01-07 05:17:39 -0300 | [diff] [blame] | 280 | |
| 281 | static int get_key_beholdm6xx(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) |
| 282 | { |
| 283 | unsigned char data[12]; |
| 284 | u32 gpio; |
| 285 | |
Jean Delvare | c668f32 | 2009-05-13 16:48:50 -0300 | [diff] [blame] | 286 | struct saa7134_dev *dev = ir->c->adapter->algo_data; |
Andrey J. Melnikoff (TEMHOTA) | e8018c9 | 2008-01-07 05:17:39 -0300 | [diff] [blame] | 287 | |
| 288 | /* rising SAA7134_GPIO_GPRESCAN reads the status */ |
| 289 | saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); |
| 290 | saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); |
| 291 | |
| 292 | gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2); |
| 293 | |
Mauro Carvalho Chehab | 616f887 | 2008-01-07 05:18:36 -0300 | [diff] [blame] | 294 | if (0x400000 & ~gpio) |
Andrey J. Melnikoff (TEMHOTA) | e8018c9 | 2008-01-07 05:17:39 -0300 | [diff] [blame] | 295 | return 0; /* No button press */ |
| 296 | |
Jean Delvare | c668f32 | 2009-05-13 16:48:50 -0300 | [diff] [blame] | 297 | ir->c->addr = 0x5a >> 1; |
Andrey J. Melnikoff (TEMHOTA) | e8018c9 | 2008-01-07 05:17:39 -0300 | [diff] [blame] | 298 | |
Jean Delvare | c668f32 | 2009-05-13 16:48:50 -0300 | [diff] [blame] | 299 | if (12 != i2c_master_recv(ir->c, data, 12)) { |
Andrey J. Melnikoff (TEMHOTA) | e8018c9 | 2008-01-07 05:17:39 -0300 | [diff] [blame] | 300 | i2cdprintk("read error\n"); |
| 301 | return -EIO; |
| 302 | } |
| 303 | /* IR of this card normally decode signals NEC-standard from |
| 304 | * - Sven IHOO MT 5.1R remote. xxyye718 |
| 305 | * - Sven DVD HD-10xx remote. xxyyf708 |
| 306 | * - BBK ... |
| 307 | * - mayby others |
| 308 | * So, skip not our, if disable full codes mode. |
| 309 | */ |
| 310 | if (data[10] != 0x6b && data[11] != 0x86 && disable_other_ir) |
| 311 | return 0; |
| 312 | |
Dmitri Belimov | 2d21ffe | 2009-09-07 20:36:05 -0300 | [diff] [blame] | 313 | /* Wrong data decode fix */ |
| 314 | if (data[9] != (unsigned char)(~data[8])) |
| 315 | return 0; |
| 316 | |
Andrey J. Melnikoff (TEMHOTA) | e8018c9 | 2008-01-07 05:17:39 -0300 | [diff] [blame] | 317 | *ir_key = data[9]; |
| 318 | *ir_raw = data[9]; |
| 319 | |
| 320 | return 1; |
| 321 | } |
| 322 | |
Mauro Carvalho Chehab | 1c22dad | 2008-07-17 22:31:29 -0300 | [diff] [blame] | 323 | /* Common (grey or coloured) pinnacle PCTV remote handling |
| 324 | * |
| 325 | */ |
| 326 | static int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw, |
| 327 | int parity_offset, int marker, int code_modulo) |
| 328 | { |
| 329 | unsigned char b[4]; |
| 330 | unsigned int start = 0,parity = 0,code = 0; |
| 331 | |
| 332 | /* poll IR chip */ |
Jean Delvare | c668f32 | 2009-05-13 16:48:50 -0300 | [diff] [blame] | 333 | if (4 != i2c_master_recv(ir->c, b, 4)) { |
Mauro Carvalho Chehab | 1c22dad | 2008-07-17 22:31:29 -0300 | [diff] [blame] | 334 | i2cdprintk("read error\n"); |
| 335 | return -EIO; |
| 336 | } |
| 337 | |
| 338 | for (start = 0; start < ARRAY_SIZE(b); start++) { |
| 339 | if (b[start] == marker) { |
| 340 | code=b[(start+parity_offset + 1) % 4]; |
| 341 | parity=b[(start+parity_offset) % 4]; |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | /* Empty Request */ |
| 346 | if (parity == 0) |
| 347 | return 0; |
| 348 | |
| 349 | /* Repeating... */ |
| 350 | if (ir->old == parity) |
| 351 | return 0; |
| 352 | |
| 353 | ir->old = parity; |
| 354 | |
| 355 | /* drop special codes when a key is held down a long time for the grey controller |
| 356 | In this case, the second bit of the code is asserted */ |
| 357 | if (marker == 0xfe && (code & 0x40)) |
| 358 | return 0; |
| 359 | |
| 360 | code %= code_modulo; |
| 361 | |
| 362 | *ir_raw = code; |
| 363 | *ir_key = code; |
| 364 | |
| 365 | i2cdprintk("Pinnacle PCTV key %02x\n", code); |
| 366 | |
| 367 | return 1; |
| 368 | } |
| 369 | |
| 370 | /* The grey pinnacle PCTV remote |
| 371 | * |
| 372 | * There are one issue with this remote: |
| 373 | * - I2c packet does not change when the same key is pressed quickly. The workaround |
| 374 | * is to hold down each key for about half a second, so that another code is generated |
| 375 | * in the i2c packet, and the function can distinguish key presses. |
| 376 | * |
| 377 | * Sylvain Pasche <sylvain.pasche@gmail.com> |
| 378 | */ |
| 379 | static int get_key_pinnacle_grey(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) |
| 380 | { |
| 381 | |
| 382 | return get_key_pinnacle(ir, ir_key, ir_raw, 1, 0xfe, 0xff); |
| 383 | } |
| 384 | |
| 385 | |
| 386 | /* The new pinnacle PCTV remote (with the colored buttons) |
| 387 | * |
| 388 | * Ricardo Cerqueira <v4l@cerqueira.org> |
| 389 | */ |
| 390 | static int get_key_pinnacle_color(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) |
| 391 | { |
| 392 | /* code_modulo parameter (0x88) is used to reduce code value to fit inside IR_KEYTAB_SIZE |
| 393 | * |
| 394 | * this is the only value that results in 42 unique |
| 395 | * codes < 128 |
| 396 | */ |
| 397 | |
| 398 | return get_key_pinnacle(ir, ir_key, ir_raw, 2, 0x80, 0x88); |
| 399 | } |
| 400 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | void saa7134_input_irq(struct saa7134_dev *dev) |
| 402 | { |
Mauro Carvalho Chehab | 716aab4 | 2010-03-31 14:40:35 -0300 | [diff] [blame^] | 403 | struct card_ir *ir; |
| 404 | |
| 405 | if (!dev || !dev->remote) |
| 406 | return; |
| 407 | |
| 408 | ir = dev->remote; |
| 409 | if (!ir->running) |
| 410 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | |
Mauro Carvalho Chehab | 622ecb3 | 2008-08-05 10:03:17 -0300 | [diff] [blame] | 412 | if (ir->nec_gpio) { |
| 413 | saa7134_nec_irq(dev); |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 414 | } else if (!ir->polling && !ir->rc5_gpio && !ir->raw_decode) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | build_key(dev); |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 416 | } else if (ir->rc5_gpio) { |
| 417 | saa7134_rc5_irq(dev); |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 418 | } else if (ir->raw_decode) { |
| 419 | saa7134_raw_decode_irq(dev); |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 420 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | static void saa7134_input_timer(unsigned long data) |
| 424 | { |
Dmitry Torokhov | b4ba788 | 2007-05-21 11:41:02 -0300 | [diff] [blame] | 425 | struct saa7134_dev *dev = (struct saa7134_dev *)data; |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 426 | struct card_ir *ir = dev->remote; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | |
| 428 | build_key(dev); |
Dmitry Torokhov | b4ba788 | 2007-05-21 11:41:02 -0300 | [diff] [blame] | 429 | mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | } |
| 431 | |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 432 | void ir_raw_decode_timer_end(unsigned long data) |
| 433 | { |
| 434 | struct saa7134_dev *dev = (struct saa7134_dev *)data; |
Mauro Carvalho Chehab | 9f15478 | 2010-03-21 13:00:55 -0300 | [diff] [blame] | 435 | struct card_ir *ir = dev->remote; |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 436 | |
Mauro Carvalho Chehab | ada3963 | 2010-03-21 12:24:24 -0300 | [diff] [blame] | 437 | ir_raw_event_handle(dev->remote->dev); |
Mauro Carvalho Chehab | 9f15478 | 2010-03-21 13:00:55 -0300 | [diff] [blame] | 438 | |
| 439 | ir->active = 0; |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 440 | } |
| 441 | |
Mauro Carvalho Chehab | 716aab4 | 2010-03-31 14:40:35 -0300 | [diff] [blame^] | 442 | static int __saa7134_ir_start(void *priv) |
Dmitry Torokhov | b07b478 | 2006-11-20 10:23:04 -0300 | [diff] [blame] | 443 | { |
Mauro Carvalho Chehab | 716aab4 | 2010-03-31 14:40:35 -0300 | [diff] [blame^] | 444 | struct saa7134_dev *dev = priv; |
| 445 | struct card_ir *ir; |
| 446 | |
| 447 | if (!dev) |
| 448 | return -EINVAL; |
| 449 | |
| 450 | ir = dev->remote; |
| 451 | if (!ir) |
| 452 | return -EINVAL; |
| 453 | |
Mauro Carvalho Chehab | 0210894 | 2010-03-20 00:25:37 -0300 | [diff] [blame] | 454 | if (ir->running) |
Mauro Carvalho Chehab | 716aab4 | 2010-03-31 14:40:35 -0300 | [diff] [blame^] | 455 | return 0; |
Mauro Carvalho Chehab | 0210894 | 2010-03-20 00:25:37 -0300 | [diff] [blame] | 456 | |
| 457 | ir->running = 1; |
Dmitry Torokhov | b07b478 | 2006-11-20 10:23:04 -0300 | [diff] [blame] | 458 | if (ir->polling) { |
Dmitry Torokhov | b4ba788 | 2007-05-21 11:41:02 -0300 | [diff] [blame] | 459 | setup_timer(&ir->timer, saa7134_input_timer, |
| 460 | (unsigned long)dev); |
Dmitry Torokhov | b07b478 | 2006-11-20 10:23:04 -0300 | [diff] [blame] | 461 | ir->timer.expires = jiffies + HZ; |
| 462 | add_timer(&ir->timer); |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 463 | } else if (ir->rc5_gpio) { |
| 464 | /* set timer_end for code completion */ |
| 465 | init_timer(&ir->timer_end); |
| 466 | ir->timer_end.function = ir_rc5_timer_end; |
| 467 | ir->timer_end.data = (unsigned long)ir; |
| 468 | init_timer(&ir->timer_keyup); |
| 469 | ir->timer_keyup.function = ir_rc5_timer_keyup; |
| 470 | ir->timer_keyup.data = (unsigned long)ir; |
| 471 | ir->shift_by = 2; |
| 472 | ir->start = 0x2; |
| 473 | ir->addr = 0x17; |
| 474 | ir->rc5_key_timeout = ir_rc5_key_timeout; |
| 475 | ir->rc5_remote_gap = ir_rc5_remote_gap; |
Mauro Carvalho Chehab | 622ecb3 | 2008-08-05 10:03:17 -0300 | [diff] [blame] | 476 | } else if (ir->nec_gpio) { |
| 477 | setup_timer(&ir->timer_keyup, saa7134_nec_timer, |
| 478 | (unsigned long)dev); |
| 479 | tasklet_init(&ir->tlet, nec_task, (unsigned long)dev); |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 480 | } else if (ir->raw_decode) { |
| 481 | /* set timer_end for code completion */ |
| 482 | init_timer(&ir->timer_end); |
| 483 | ir->timer_end.function = ir_raw_decode_timer_end; |
| 484 | ir->timer_end.data = (unsigned long)dev; |
Mauro Carvalho Chehab | 9f15478 | 2010-03-21 13:00:55 -0300 | [diff] [blame] | 485 | ir->active = 0; |
Dmitry Torokhov | b07b478 | 2006-11-20 10:23:04 -0300 | [diff] [blame] | 486 | } |
Mauro Carvalho Chehab | 716aab4 | 2010-03-31 14:40:35 -0300 | [diff] [blame^] | 487 | |
| 488 | return 0; |
Dmitry Torokhov | b07b478 | 2006-11-20 10:23:04 -0300 | [diff] [blame] | 489 | } |
| 490 | |
Mauro Carvalho Chehab | 716aab4 | 2010-03-31 14:40:35 -0300 | [diff] [blame^] | 491 | static void __saa7134_ir_stop(void *priv) |
Dmitry Torokhov | b07b478 | 2006-11-20 10:23:04 -0300 | [diff] [blame] | 492 | { |
Mauro Carvalho Chehab | 716aab4 | 2010-03-31 14:40:35 -0300 | [diff] [blame^] | 493 | struct saa7134_dev *dev = priv; |
| 494 | struct card_ir *ir; |
| 495 | |
| 496 | if (!dev) |
| 497 | return; |
| 498 | |
| 499 | ir = dev->remote; |
| 500 | if (!ir) |
| 501 | return; |
Mauro Carvalho Chehab | 0210894 | 2010-03-20 00:25:37 -0300 | [diff] [blame] | 502 | |
| 503 | if (!ir->running) |
| 504 | return; |
Dmitry Torokhov | b07b478 | 2006-11-20 10:23:04 -0300 | [diff] [blame] | 505 | if (dev->remote->polling) |
| 506 | del_timer_sync(&dev->remote->timer); |
Mauro Carvalho Chehab | 0210894 | 2010-03-20 00:25:37 -0300 | [diff] [blame] | 507 | else if (ir->rc5_gpio) |
| 508 | del_timer_sync(&ir->timer_end); |
| 509 | else if (ir->nec_gpio) |
| 510 | tasklet_kill(&ir->tlet); |
Mauro Carvalho Chehab | 9f15478 | 2010-03-21 13:00:55 -0300 | [diff] [blame] | 511 | else if (ir->raw_decode) { |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 512 | del_timer_sync(&ir->timer_end); |
Mauro Carvalho Chehab | 9f15478 | 2010-03-21 13:00:55 -0300 | [diff] [blame] | 513 | ir->active = 0; |
| 514 | } |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 515 | |
Mauro Carvalho Chehab | 0210894 | 2010-03-20 00:25:37 -0300 | [diff] [blame] | 516 | ir->running = 0; |
Mauro Carvalho Chehab | 716aab4 | 2010-03-31 14:40:35 -0300 | [diff] [blame^] | 517 | |
| 518 | return; |
Mauro Carvalho Chehab | 0210894 | 2010-03-20 00:25:37 -0300 | [diff] [blame] | 519 | } |
| 520 | |
Mauro Carvalho Chehab | 716aab4 | 2010-03-31 14:40:35 -0300 | [diff] [blame^] | 521 | int saa7134_ir_start(struct saa7134_dev *dev) |
| 522 | { |
| 523 | if (dev->remote->users) |
| 524 | return __saa7134_ir_start(dev); |
| 525 | |
| 526 | return 0; |
| 527 | } |
| 528 | |
| 529 | void saa7134_ir_stop(struct saa7134_dev *dev) |
| 530 | { |
| 531 | if (dev->remote->users) |
| 532 | __saa7134_ir_stop(dev); |
| 533 | } |
| 534 | |
| 535 | static int saa7134_ir_open(void *priv) |
| 536 | { |
| 537 | struct saa7134_dev *dev = priv; |
| 538 | |
| 539 | dev->remote->users++; |
| 540 | return __saa7134_ir_start(dev); |
| 541 | } |
| 542 | |
| 543 | static void saa7134_ir_close(void *priv) |
| 544 | { |
| 545 | struct saa7134_dev *dev = priv; |
| 546 | |
| 547 | dev->remote->users--; |
| 548 | if (!dev->remote->users) |
| 549 | __saa7134_ir_stop(dev); |
| 550 | } |
| 551 | |
| 552 | |
Mauro Carvalho Chehab | 0210894 | 2010-03-20 00:25:37 -0300 | [diff] [blame] | 553 | int saa7134_ir_change_protocol(void *priv, u64 ir_type) |
| 554 | { |
| 555 | struct saa7134_dev *dev = priv; |
| 556 | struct card_ir *ir = dev->remote; |
| 557 | u32 nec_gpio, rc5_gpio; |
| 558 | |
| 559 | if (ir_type == IR_TYPE_RC5) { |
| 560 | dprintk("Changing protocol to RC5\n"); |
| 561 | nec_gpio = 0; |
| 562 | rc5_gpio = 1; |
| 563 | } else if (ir_type == IR_TYPE_NEC) { |
| 564 | dprintk("Changing protocol to NEC\n"); |
| 565 | nec_gpio = 1; |
| 566 | rc5_gpio = 0; |
| 567 | } else { |
| 568 | dprintk("IR protocol type %ud is not supported\n", |
| 569 | (unsigned)ir_type); |
| 570 | return -EINVAL; |
| 571 | } |
| 572 | |
| 573 | if (ir->running) { |
| 574 | saa7134_ir_stop(dev); |
| 575 | ir->nec_gpio = nec_gpio; |
| 576 | ir->rc5_gpio = rc5_gpio; |
Mauro Carvalho Chehab | 716aab4 | 2010-03-31 14:40:35 -0300 | [diff] [blame^] | 577 | saa7134_ir_start(dev); |
Mauro Carvalho Chehab | 0210894 | 2010-03-20 00:25:37 -0300 | [diff] [blame] | 578 | } else { |
| 579 | ir->nec_gpio = nec_gpio; |
| 580 | ir->rc5_gpio = rc5_gpio; |
| 581 | } |
| 582 | |
| 583 | return 0; |
Dmitry Torokhov | b07b478 | 2006-11-20 10:23:04 -0300 | [diff] [blame] | 584 | } |
| 585 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | int saa7134_input_init1(struct saa7134_dev *dev) |
| 587 | { |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 588 | struct card_ir *ir; |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 589 | struct input_dev *input_dev; |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 590 | struct ir_scancode_table *ir_codes = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | u32 mask_keycode = 0; |
| 592 | u32 mask_keydown = 0; |
| 593 | u32 mask_keyup = 0; |
| 594 | int polling = 0; |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 595 | int rc5_gpio = 0; |
Mauro Carvalho Chehab | 622ecb3 | 2008-08-05 10:03:17 -0300 | [diff] [blame] | 596 | int nec_gpio = 0; |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 597 | int raw_decode = 0; |
Mauro Carvalho Chehab | 971e829 | 2009-12-14 13:53:37 -0300 | [diff] [blame] | 598 | u64 ir_type = IR_TYPE_OTHER; |
Dmitry Torokhov | b07b478 | 2006-11-20 10:23:04 -0300 | [diff] [blame] | 599 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | |
Ricardo Cerqueira | cb2444d | 2005-11-08 21:38:47 -0800 | [diff] [blame] | 601 | if (dev->has_remote != SAA7134_REMOTE_GPIO) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | return -ENODEV; |
| 603 | if (disable_ir) |
| 604 | return -ENODEV; |
| 605 | |
| 606 | /* detect & configure */ |
| 607 | switch (dev->board) { |
| 608 | case SAA7134_BOARD_FLYVIDEO2000: |
| 609 | case SAA7134_BOARD_FLYVIDEO3000: |
Vladimir Ermakov | 8f27fd9 | 2010-03-10 12:44:57 -0300 | [diff] [blame] | 610 | case SAA7134_BOARD_HAWELL_HW_404M7: |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 611 | case SAA7134_BOARD_FLYTVPLATINUM_FM: |
Arnaud Patard | 6af90ab | 2005-11-08 21:36:55 -0800 | [diff] [blame] | 612 | case SAA7134_BOARD_FLYTVPLATINUM_MINI2: |
Eugene Yudin | 23389b8 | 2009-08-29 09:32:11 -0300 | [diff] [blame] | 613 | case SAA7134_BOARD_ROVERMEDIA_LINK_PRO_FM: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 614 | ir_codes = &ir_codes_flyvideo_table; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | mask_keycode = 0xEC00000; |
| 616 | mask_keydown = 0x0040000; |
| 617 | break; |
| 618 | case SAA7134_BOARD_CINERGY400: |
| 619 | case SAA7134_BOARD_CINERGY600: |
| 620 | case SAA7134_BOARD_CINERGY600_MK3: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 621 | ir_codes = &ir_codes_cinergy_table; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | mask_keycode = 0x00003f; |
| 623 | mask_keyup = 0x040000; |
| 624 | break; |
| 625 | case SAA7134_BOARD_ECS_TVP3XP: |
| 626 | case SAA7134_BOARD_ECS_TVP3XP_4CB5: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 627 | ir_codes = &ir_codes_eztv_table; |
Mauro Carvalho Chehab | 330a115 | 2005-07-12 13:59:01 -0700 | [diff] [blame] | 628 | mask_keycode = 0x00017c; |
| 629 | mask_keyup = 0x000002; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | polling = 50; // ms |
Mauro Carvalho Chehab | 330a115 | 2005-07-12 13:59:01 -0700 | [diff] [blame] | 631 | break; |
| 632 | case SAA7134_BOARD_KWORLD_XPERT: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | case SAA7134_BOARD_AVACSSMARTTV: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 634 | ir_codes = &ir_codes_pixelview_table; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | mask_keycode = 0x00001F; |
| 636 | mask_keyup = 0x000020; |
| 637 | polling = 50; // ms |
| 638 | break; |
| 639 | case SAA7134_BOARD_MD2819: |
Mauro Carvalho Chehab | ac19ecc | 2005-06-23 22:05:09 -0700 | [diff] [blame] | 640 | case SAA7134_BOARD_KWORLD_VSTREAM_XPERT: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | case SAA7134_BOARD_AVERMEDIA_305: |
| 642 | case SAA7134_BOARD_AVERMEDIA_307: |
Mauro Carvalho Chehab | ac19ecc | 2005-06-23 22:05:09 -0700 | [diff] [blame] | 643 | case SAA7134_BOARD_AVERMEDIA_STUDIO_305: |
Vasiliy Temnikov | 5a5e1da | 2009-08-26 22:10:55 -0300 | [diff] [blame] | 644 | case SAA7134_BOARD_AVERMEDIA_STUDIO_505: |
Mauro Carvalho Chehab | ac19ecc | 2005-06-23 22:05:09 -0700 | [diff] [blame] | 645 | case SAA7134_BOARD_AVERMEDIA_STUDIO_307: |
Mikhail Fedotov | 3ac706d | 2006-10-06 20:23:47 -0300 | [diff] [blame] | 646 | case SAA7134_BOARD_AVERMEDIA_STUDIO_507: |
Andy Shevchenko | df0dbbe | 2009-04-08 14:01:19 -0300 | [diff] [blame] | 647 | case SAA7134_BOARD_AVERMEDIA_STUDIO_507UA: |
Mauro Carvalho Chehab | ac19ecc | 2005-06-23 22:05:09 -0700 | [diff] [blame] | 648 | case SAA7134_BOARD_AVERMEDIA_GO_007_FM: |
Albert Graham | d2761f2 | 2007-12-09 09:44:38 -0300 | [diff] [blame] | 649 | case SAA7134_BOARD_AVERMEDIA_M102: |
Pham Thanh Nam | 6a2d802 | 2008-12-30 23:26:09 -0300 | [diff] [blame] | 650 | case SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 651 | ir_codes = &ir_codes_avermedia_table; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 652 | mask_keycode = 0x0007C8; |
| 653 | mask_keydown = 0x000010; |
| 654 | polling = 50; // ms |
| 655 | /* Set GPIO pin2 to high to enable the IR controller */ |
| 656 | saa_setb(SAA7134_GPIO_GPMODE0, 0x4); |
| 657 | saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4); |
| 658 | break; |
Mauro Carvalho Chehab | 36f6bb9 | 2008-06-26 17:03:00 -0300 | [diff] [blame] | 659 | case SAA7134_BOARD_AVERMEDIA_M135A: |
Mauro Carvalho Chehab | d152b8b | 2010-03-20 00:23:30 -0300 | [diff] [blame] | 660 | ir_codes = &ir_codes_avermedia_m135a_rm_jx_table; |
Mauro Carvalho Chehab | 36f6bb9 | 2008-06-26 17:03:00 -0300 | [diff] [blame] | 661 | mask_keydown = 0x0040000; |
Mauro Carvalho Chehab | d152b8b | 2010-03-20 00:23:30 -0300 | [diff] [blame] | 662 | mask_keycode = 0xffff; |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 663 | raw_decode = 1; |
Mauro Carvalho Chehab | 36f6bb9 | 2008-06-26 17:03:00 -0300 | [diff] [blame] | 664 | break; |
pasky@ucw.cz | 450efcf | 2006-11-12 14:22:32 -0300 | [diff] [blame] | 665 | case SAA7134_BOARD_AVERMEDIA_777: |
pasky@ucw.cz | 29e0f1a | 2006-11-12 14:23:32 -0300 | [diff] [blame] | 666 | case SAA7134_BOARD_AVERMEDIA_A16AR: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 667 | ir_codes = &ir_codes_avermedia_table; |
pasky@ucw.cz | 450efcf | 2006-11-12 14:22:32 -0300 | [diff] [blame] | 668 | mask_keycode = 0x02F200; |
| 669 | mask_keydown = 0x000400; |
| 670 | polling = 50; // ms |
| 671 | /* Without this we won't receive key up events */ |
| 672 | saa_setb(SAA7134_GPIO_GPMODE1, 0x1); |
| 673 | saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1); |
Linus Torvalds | 4dd7406 | 2006-11-13 09:50:11 -0800 | [diff] [blame] | 674 | break; |
Tim Farrington | 6e501a3 | 2008-06-15 13:33:42 -0300 | [diff] [blame] | 675 | case SAA7134_BOARD_AVERMEDIA_A16D: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 676 | ir_codes = &ir_codes_avermedia_a16d_table; |
Tim Farrington | 6e501a3 | 2008-06-15 13:33:42 -0300 | [diff] [blame] | 677 | mask_keycode = 0x02F200; |
| 678 | mask_keydown = 0x000400; |
| 679 | polling = 50; /* ms */ |
| 680 | /* Without this we won't receive key up events */ |
| 681 | saa_setb(SAA7134_GPIO_GPMODE1, 0x1); |
| 682 | saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1); |
| 683 | break; |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 684 | case SAA7134_BOARD_KWORLD_TERMINATOR: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 685 | ir_codes = &ir_codes_pixelview_table; |
James R. Webb | dc2286c | 2005-11-08 21:37:00 -0800 | [diff] [blame] | 686 | mask_keycode = 0x00001f; |
| 687 | mask_keyup = 0x000060; |
| 688 | polling = 50; // ms |
| 689 | break; |
Mauro Carvalho Chehab | ac19ecc | 2005-06-23 22:05:09 -0700 | [diff] [blame] | 690 | case SAA7134_BOARD_MANLI_MTV001: |
| 691 | case SAA7134_BOARD_MANLI_MTV002: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 692 | ir_codes = &ir_codes_manli_table; |
Dmitry Belimov | b34dddb | 2008-04-23 14:09:08 -0300 | [diff] [blame] | 693 | mask_keycode = 0x001f00; |
| 694 | mask_keyup = 0x004000; |
| 695 | polling = 50; /* ms */ |
| 696 | break; |
Nickolay V. Shmyrev | a8ff417 | 2005-11-08 21:36:16 -0800 | [diff] [blame] | 697 | case SAA7134_BOARD_BEHOLD_409FM: |
Andrey J. Melnikoff (TEMHOTA) | e8018c9 | 2008-01-07 05:17:39 -0300 | [diff] [blame] | 698 | case SAA7134_BOARD_BEHOLD_401: |
| 699 | case SAA7134_BOARD_BEHOLD_403: |
| 700 | case SAA7134_BOARD_BEHOLD_403FM: |
| 701 | case SAA7134_BOARD_BEHOLD_405: |
| 702 | case SAA7134_BOARD_BEHOLD_405FM: |
| 703 | case SAA7134_BOARD_BEHOLD_407: |
| 704 | case SAA7134_BOARD_BEHOLD_407FM: |
| 705 | case SAA7134_BOARD_BEHOLD_409: |
| 706 | case SAA7134_BOARD_BEHOLD_505FM: |
Dmitri Belimov | 9c6f97a | 2009-12-21 02:00:38 -0300 | [diff] [blame] | 707 | case SAA7134_BOARD_BEHOLD_505RDS_MK5: |
| 708 | case SAA7134_BOARD_BEHOLD_505RDS_MK3: |
Andrey J. Melnikoff (TEMHOTA) | e8018c9 | 2008-01-07 05:17:39 -0300 | [diff] [blame] | 709 | case SAA7134_BOARD_BEHOLD_507_9FM: |
Dmitri Belimov | 84d728c | 2009-04-23 02:32:49 -0300 | [diff] [blame] | 710 | case SAA7134_BOARD_BEHOLD_507RDS_MK3: |
| 711 | case SAA7134_BOARD_BEHOLD_507RDS_MK5: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 712 | ir_codes = &ir_codes_manli_table; |
Dmitry Belimov | b34dddb | 2008-04-23 14:09:08 -0300 | [diff] [blame] | 713 | mask_keycode = 0x003f00; |
| 714 | mask_keyup = 0x004000; |
| 715 | polling = 50; /* ms */ |
| 716 | break; |
| 717 | case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 718 | ir_codes = &ir_codes_behold_columbus_table; |
Dmitry Belimov | b34dddb | 2008-04-23 14:09:08 -0300 | [diff] [blame] | 719 | mask_keycode = 0x003f00; |
Mauro Carvalho Chehab | ac19ecc | 2005-06-23 22:05:09 -0700 | [diff] [blame] | 720 | mask_keyup = 0x004000; |
Mauro Carvalho Chehab | ac19ecc | 2005-06-23 22:05:09 -0700 | [diff] [blame] | 721 | polling = 50; // ms |
| 722 | break; |
Ricardo Cerqueira | 17ce1ff | 2005-11-08 21:38:47 -0800 | [diff] [blame] | 723 | case SAA7134_BOARD_SEDNA_PC_TV_CARDBUS: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 724 | ir_codes = &ir_codes_pctv_sedna_table; |
Pavel Mihaylov | c3d9319 | 2005-11-08 21:38:43 -0800 | [diff] [blame] | 725 | mask_keycode = 0x001f00; |
| 726 | mask_keyup = 0x004000; |
| 727 | polling = 50; // ms |
| 728 | break; |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 729 | case SAA7134_BOARD_GOTVIEW_7135: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 730 | ir_codes = &ir_codes_gotview7135_table; |
Pedro | 0938e31 | 2007-10-17 17:58:40 -0300 | [diff] [blame] | 731 | mask_keycode = 0x0003CC; |
Nickolay V. Shmyrev | 6b96144 | 2005-11-08 21:36:22 -0800 | [diff] [blame] | 732 | mask_keydown = 0x000010; |
Pedro | 0938e31 | 2007-10-17 17:58:40 -0300 | [diff] [blame] | 733 | polling = 5; /* ms */ |
| 734 | saa_setb(SAA7134_GPIO_GPMODE1, 0x80); |
Nickolay V. Shmyrev | 6b96144 | 2005-11-08 21:36:22 -0800 | [diff] [blame] | 735 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 736 | case SAA7134_BOARD_VIDEOMATE_TV_PVR: |
Nickolay V. Shmyrev | 2a9a9a8 | 2006-01-09 15:25:33 -0200 | [diff] [blame] | 737 | case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS: |
Mauro Carvalho Chehab | 330a115 | 2005-07-12 13:59:01 -0700 | [diff] [blame] | 738 | case SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 739 | ir_codes = &ir_codes_videomate_tv_pvr_table; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 740 | mask_keycode = 0x00003F; |
| 741 | mask_keyup = 0x400000; |
| 742 | polling = 50; // ms |
| 743 | break; |
Michal Majchrowicz | b04c1ba | 2006-09-13 16:42:42 -0300 | [diff] [blame] | 744 | case SAA7134_BOARD_PROTEUS_2309: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 745 | ir_codes = &ir_codes_proteus_2309_table; |
Michal Majchrowicz | b04c1ba | 2006-09-13 16:42:42 -0300 | [diff] [blame] | 746 | mask_keycode = 0x00007F; |
| 747 | mask_keyup = 0x000080; |
| 748 | polling = 50; // ms |
| 749 | break; |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 750 | case SAA7134_BOARD_VIDEOMATE_DVBT_300: |
| 751 | case SAA7134_BOARD_VIDEOMATE_DVBT_200: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 752 | ir_codes = &ir_codes_videomate_tv_pvr_table; |
Nickolay V. Shmyrev | fea095f | 2005-11-08 21:36:47 -0800 | [diff] [blame] | 753 | mask_keycode = 0x003F00; |
| 754 | mask_keyup = 0x040000; |
| 755 | break; |
James Le Cuirot | f5c965a | 2007-07-02 12:53:25 -0300 | [diff] [blame] | 756 | case SAA7134_BOARD_FLYDVBS_LR300: |
Giampiero Giancipoli | 3d8466e | 2006-02-07 06:49:09 -0200 | [diff] [blame] | 757 | case SAA7134_BOARD_FLYDVBT_LR301: |
Rudo Thomas | a802917 | 2006-02-27 00:08:46 -0300 | [diff] [blame] | 758 | case SAA7134_BOARD_FLYDVBTDUO: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 759 | ir_codes = &ir_codes_flydvb_table; |
Giampiero Giancipoli | 3d8466e | 2006-02-07 06:49:09 -0200 | [diff] [blame] | 760 | mask_keycode = 0x0001F00; |
| 761 | mask_keydown = 0x0040000; |
| 762 | break; |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 763 | case SAA7134_BOARD_ASUSTeK_P7131_DUAL: |
Ed Vipas | 904ab88 | 2007-03-29 18:32:49 -0300 | [diff] [blame] | 764 | case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: |
Mauro Carvalho Chehab | dfb4ba1 | 2009-08-20 10:13:40 -0300 | [diff] [blame] | 765 | case SAA7134_BOARD_ASUSTeK_P7131_ANALOG: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 766 | ir_codes = &ir_codes_asus_pc39_table; |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 767 | mask_keydown = 0x0040000; |
| 768 | rc5_gpio = 1; |
| 769 | break; |
Juan Pablo Sormani | c36c459 | 2006-12-27 12:46:36 -0300 | [diff] [blame] | 770 | case SAA7134_BOARD_ENCORE_ENLTV: |
| 771 | case SAA7134_BOARD_ENCORE_ENLTV_FM: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 772 | ir_codes = &ir_codes_encore_enltv_table; |
Juan Pablo Sormani | c36c459 | 2006-12-27 12:46:36 -0300 | [diff] [blame] | 773 | mask_keycode = 0x00007f; |
| 774 | mask_keyup = 0x040000; |
| 775 | polling = 50; // ms |
| 776 | break; |
Mauro Carvalho Chehab | bf1ece6 | 2008-06-26 17:03:00 -0300 | [diff] [blame] | 777 | case SAA7134_BOARD_ENCORE_ENLTV_FM53: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 778 | ir_codes = &ir_codes_encore_enltv_fm53_table; |
Mauro Carvalho Chehab | bf1ece6 | 2008-06-26 17:03:00 -0300 | [diff] [blame] | 779 | mask_keydown = 0x0040000; |
| 780 | mask_keycode = 0x00007f; |
| 781 | nec_gpio = 1; |
| 782 | break; |
Tony Wan | 480f75a | 2007-05-11 11:33:50 -0300 | [diff] [blame] | 783 | case SAA7134_BOARD_10MOONSTVMASTER3: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 784 | ir_codes = &ir_codes_encore_enltv_table; |
Tony Wan | 480f75a | 2007-05-11 11:33:50 -0300 | [diff] [blame] | 785 | mask_keycode = 0x5f80000; |
| 786 | mask_keyup = 0x8000000; |
| 787 | polling = 50; //ms |
| 788 | break; |
Adrian Pardini | f0ba356 | 2008-02-11 12:40:53 -0300 | [diff] [blame] | 789 | case SAA7134_BOARD_GENIUS_TVGO_A11MCE: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 790 | ir_codes = &ir_codes_genius_tvgo_a11mce_table; |
Adrian Pardini | f0ba356 | 2008-02-11 12:40:53 -0300 | [diff] [blame] | 791 | mask_keycode = 0xff; |
| 792 | mask_keydown = 0xf00000; |
| 793 | polling = 50; /* ms */ |
| 794 | break; |
Mauro Carvalho Chehab | 9b00019 | 2008-06-26 17:03:00 -0300 | [diff] [blame] | 795 | case SAA7134_BOARD_REAL_ANGEL_220: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 796 | ir_codes = &ir_codes_real_audio_220_32_keys_table; |
Mauro Carvalho Chehab | 9b00019 | 2008-06-26 17:03:00 -0300 | [diff] [blame] | 797 | mask_keycode = 0x3f00; |
| 798 | mask_keyup = 0x4000; |
| 799 | polling = 50; /* ms */ |
| 800 | break; |
Mauro Carvalho Chehab | 26d5f3a | 2008-12-07 13:19:29 -0300 | [diff] [blame] | 801 | case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 802 | ir_codes = &ir_codes_kworld_plus_tv_analog_table; |
Mauro Carvalho Chehab | 26d5f3a | 2008-12-07 13:19:29 -0300 | [diff] [blame] | 803 | mask_keycode = 0x7f; |
| 804 | polling = 40; /* ms */ |
| 805 | break; |
Igor M. Liplianin | ecfcfec | 2009-08-13 21:42:21 -0300 | [diff] [blame] | 806 | case SAA7134_BOARD_VIDEOMATE_S350: |
Mauro Carvalho Chehab | 715a223 | 2009-08-29 14:15:55 -0300 | [diff] [blame] | 807 | ir_codes = &ir_codes_videomate_s350_table; |
Igor M. Liplianin | ecfcfec | 2009-08-13 21:42:21 -0300 | [diff] [blame] | 808 | mask_keycode = 0x003f00; |
| 809 | mask_keydown = 0x040000; |
| 810 | break; |
Michael Obst | 0700ade | 2009-10-31 14:05:42 -0300 | [diff] [blame] | 811 | case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S: |
| 812 | ir_codes = &ir_codes_winfast_table; |
| 813 | mask_keycode = 0x5f00; |
| 814 | mask_keyup = 0x020000; |
Michael Krufky | 117e134 | 2009-11-01 11:16:10 -0300 | [diff] [blame] | 815 | polling = 50; /* ms */ |
Michael Obst | 0700ade | 2009-10-31 14:05:42 -0300 | [diff] [blame] | 816 | break; |
Lukas Karas | d995a18 | 2009-11-24 12:06:52 -0300 | [diff] [blame] | 817 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | } |
| 819 | if (NULL == ir_codes) { |
| 820 | printk("%s: Oops: IR config error [card=%d]\n", |
| 821 | dev->name, dev->board); |
| 822 | return -ENODEV; |
| 823 | } |
| 824 | |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 825 | ir = kzalloc(sizeof(*ir), GFP_KERNEL); |
| 826 | input_dev = input_allocate_device(); |
| 827 | if (!ir || !input_dev) { |
Dmitry Torokhov | b07b478 | 2006-11-20 10:23:04 -0300 | [diff] [blame] | 828 | err = -ENOMEM; |
| 829 | goto err_out_free; |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 830 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 831 | |
Dmitry Torokhov | d271d1c | 2005-11-20 00:56:54 -0500 | [diff] [blame] | 832 | ir->dev = input_dev; |
Mauro Carvalho Chehab | 0210894 | 2010-03-20 00:25:37 -0300 | [diff] [blame] | 833 | dev->remote = ir; |
| 834 | |
| 835 | ir->running = 0; |
Dmitry Torokhov | d271d1c | 2005-11-20 00:56:54 -0500 | [diff] [blame] | 836 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 837 | /* init hardware-specific stuff */ |
| 838 | ir->mask_keycode = mask_keycode; |
| 839 | ir->mask_keydown = mask_keydown; |
| 840 | ir->mask_keyup = mask_keyup; |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 841 | ir->polling = polling; |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 842 | ir->rc5_gpio = rc5_gpio; |
Mauro Carvalho Chehab | 622ecb3 | 2008-08-05 10:03:17 -0300 | [diff] [blame] | 843 | ir->nec_gpio = nec_gpio; |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 844 | ir->raw_decode = raw_decode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 845 | |
| 846 | /* init input device */ |
| 847 | snprintf(ir->name, sizeof(ir->name), "saa7134 IR (%s)", |
| 848 | saa7134_boards[dev->board].name); |
| 849 | snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", |
| 850 | pci_name(dev->pci)); |
| 851 | |
Mauro Carvalho Chehab | 716aab4 | 2010-03-31 14:40:35 -0300 | [diff] [blame^] | 852 | |
| 853 | ir->props.priv = dev; |
| 854 | ir->props.open = saa7134_ir_open; |
| 855 | ir->props.close = saa7134_ir_close; |
| 856 | |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 857 | if (ir_codes->ir_type != IR_TYPE_OTHER && !raw_decode) { |
Mauro Carvalho Chehab | 0210894 | 2010-03-20 00:25:37 -0300 | [diff] [blame] | 858 | ir->props.allowed_protos = IR_TYPE_RC5 | IR_TYPE_NEC; |
Mauro Carvalho Chehab | 0210894 | 2010-03-20 00:25:37 -0300 | [diff] [blame] | 859 | ir->props.change_protocol = saa7134_ir_change_protocol; |
| 860 | |
| 861 | /* Set IR protocol */ |
| 862 | saa7134_ir_change_protocol(ir->props.priv, ir_codes->ir_type); |
| 863 | } |
Mauro Carvalho Chehab | 579e7d6 | 2009-12-11 11:20:59 -0300 | [diff] [blame] | 864 | err = ir_input_init(input_dev, &ir->ir, ir_type); |
Mauro Carvalho Chehab | 055cd55 | 2009-11-29 08:19:59 -0300 | [diff] [blame] | 865 | if (err < 0) |
| 866 | goto err_out_free; |
| 867 | |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 868 | input_dev->name = ir->name; |
| 869 | input_dev->phys = ir->phys; |
| 870 | input_dev->id.bustype = BUS_PCI; |
| 871 | input_dev->id.version = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 872 | if (dev->pci->subsystem_vendor) { |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 873 | input_dev->id.vendor = dev->pci->subsystem_vendor; |
| 874 | input_dev->id.product = dev->pci->subsystem_device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 875 | } else { |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 876 | input_dev->id.vendor = dev->pci->vendor; |
| 877 | input_dev->id.product = dev->pci->device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 878 | } |
Dmitry Torokhov | 2c8a3a3 | 2007-07-16 09:28:15 -0300 | [diff] [blame] | 879 | input_dev->dev.parent = &dev->pci->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 880 | |
Mauro Carvalho Chehab | 0210894 | 2010-03-20 00:25:37 -0300 | [diff] [blame] | 881 | err = ir_input_register(ir->dev, ir_codes, &ir->props, MODULE_NAME); |
Dmitry Torokhov | b07b478 | 2006-11-20 10:23:04 -0300 | [diff] [blame] | 882 | if (err) |
Mauro Carvalho Chehab | 716aab4 | 2010-03-31 14:40:35 -0300 | [diff] [blame^] | 883 | goto err_out_free; |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 884 | if (ir_codes->ir_type != IR_TYPE_OTHER) { |
| 885 | err = ir_raw_event_register(ir->dev); |
| 886 | if (err) |
Mauro Carvalho Chehab | 716aab4 | 2010-03-31 14:40:35 -0300 | [diff] [blame^] | 887 | goto err_out_free; |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 888 | } |
Dmitry Torokhov | b07b478 | 2006-11-20 10:23:04 -0300 | [diff] [blame] | 889 | |
Pedro | 0938e31 | 2007-10-17 17:58:40 -0300 | [diff] [blame] | 890 | /* the remote isn't as bouncy as a keyboard */ |
| 891 | ir->dev->rep[REP_DELAY] = repeat_delay; |
| 892 | ir->dev->rep[REP_PERIOD] = repeat_period; |
| 893 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 894 | return 0; |
Dmitry Torokhov | b07b478 | 2006-11-20 10:23:04 -0300 | [diff] [blame] | 895 | |
Mauro Carvalho Chehab | 716aab4 | 2010-03-31 14:40:35 -0300 | [diff] [blame^] | 896 | err_out_free: |
Dmitry Torokhov | b07b478 | 2006-11-20 10:23:04 -0300 | [diff] [blame] | 897 | dev->remote = NULL; |
Dmitry Torokhov | b07b478 | 2006-11-20 10:23:04 -0300 | [diff] [blame] | 898 | kfree(ir); |
| 899 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 900 | } |
| 901 | |
| 902 | void saa7134_input_fini(struct saa7134_dev *dev) |
| 903 | { |
| 904 | if (NULL == dev->remote) |
| 905 | return; |
| 906 | |
Dmitry Torokhov | b07b478 | 2006-11-20 10:23:04 -0300 | [diff] [blame] | 907 | saa7134_ir_stop(dev); |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 908 | ir_raw_event_unregister(dev->remote->dev); |
Mauro Carvalho Chehab | 38ef6aa | 2009-12-11 09:47:42 -0300 | [diff] [blame] | 909 | ir_input_unregister(dev->remote->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 910 | kfree(dev->remote); |
| 911 | dev->remote = NULL; |
| 912 | } |
| 913 | |
Jean Delvare | c668f32 | 2009-05-13 16:48:50 -0300 | [diff] [blame] | 914 | void saa7134_probe_i2c_ir(struct saa7134_dev *dev) |
Ricardo Cerqueira | ac9cd97 | 2005-11-08 21:37:56 -0800 | [diff] [blame] | 915 | { |
Jean Delvare | 43e16ea | 2009-10-02 05:47:08 -0300 | [diff] [blame] | 916 | struct i2c_board_info info; |
Jean Delvare | c668f32 | 2009-05-13 16:48:50 -0300 | [diff] [blame] | 917 | |
Jean Delvare | c668f32 | 2009-05-13 16:48:50 -0300 | [diff] [blame] | 918 | struct i2c_msg msg_msi = { |
| 919 | .addr = 0x50, |
| 920 | .flags = I2C_M_RD, |
| 921 | .len = 0, |
| 922 | .buf = NULL, |
| 923 | }; |
| 924 | |
Jean Delvare | c668f32 | 2009-05-13 16:48:50 -0300 | [diff] [blame] | 925 | int rc; |
| 926 | |
Ricardo Cerqueira | ac9cd97 | 2005-11-08 21:37:56 -0800 | [diff] [blame] | 927 | if (disable_ir) { |
Jean Delvare | c668f32 | 2009-05-13 16:48:50 -0300 | [diff] [blame] | 928 | dprintk("IR has been disabled, not probing for i2c remote\n"); |
Ricardo Cerqueira | ac9cd97 | 2005-11-08 21:37:56 -0800 | [diff] [blame] | 929 | return; |
| 930 | } |
| 931 | |
Jean Delvare | 43e16ea | 2009-10-02 05:47:08 -0300 | [diff] [blame] | 932 | memset(&info, 0, sizeof(struct i2c_board_info)); |
Mauro Carvalho Chehab | 7aedd5ec | 2009-09-07 02:22:01 -0300 | [diff] [blame] | 933 | memset(&dev->init_data, 0, sizeof(dev->init_data)); |
Jean Delvare | 43e16ea | 2009-10-02 05:47:08 -0300 | [diff] [blame] | 934 | strlcpy(info.type, "ir_video", I2C_NAME_SIZE); |
Jean Delvare | 4d7a2d6 | 2009-05-13 16:49:32 -0300 | [diff] [blame] | 935 | |
| 936 | switch (dev->board) { |
| 937 | case SAA7134_BOARD_PINNACLE_PCTV_110i: |
| 938 | case SAA7134_BOARD_PINNACLE_PCTV_310i: |
Mauro Carvalho Chehab | 7aedd5ec | 2009-09-07 02:22:01 -0300 | [diff] [blame] | 939 | dev->init_data.name = "Pinnacle PCTV"; |
Jean Delvare | 4d7a2d6 | 2009-05-13 16:49:32 -0300 | [diff] [blame] | 940 | if (pinnacle_remote == 0) { |
Mauro Carvalho Chehab | 7aedd5ec | 2009-09-07 02:22:01 -0300 | [diff] [blame] | 941 | dev->init_data.get_key = get_key_pinnacle_color; |
| 942 | dev->init_data.ir_codes = &ir_codes_pinnacle_color_table; |
Jean Delvare | 43e16ea | 2009-10-02 05:47:08 -0300 | [diff] [blame] | 943 | info.addr = 0x47; |
Jean Delvare | 4d7a2d6 | 2009-05-13 16:49:32 -0300 | [diff] [blame] | 944 | } else { |
Mauro Carvalho Chehab | 7aedd5ec | 2009-09-07 02:22:01 -0300 | [diff] [blame] | 945 | dev->init_data.get_key = get_key_pinnacle_grey; |
| 946 | dev->init_data.ir_codes = &ir_codes_pinnacle_grey_table; |
Jean Delvare | 43e16ea | 2009-10-02 05:47:08 -0300 | [diff] [blame] | 947 | info.addr = 0x47; |
Jean Delvare | 4d7a2d6 | 2009-05-13 16:49:32 -0300 | [diff] [blame] | 948 | } |
| 949 | break; |
| 950 | case SAA7134_BOARD_UPMOST_PURPLE_TV: |
Mauro Carvalho Chehab | 7aedd5ec | 2009-09-07 02:22:01 -0300 | [diff] [blame] | 951 | dev->init_data.name = "Purple TV"; |
| 952 | dev->init_data.get_key = get_key_purpletv; |
| 953 | dev->init_data.ir_codes = &ir_codes_purpletv_table; |
Jean Delvare | aef02aa | 2009-10-02 08:47:22 -0300 | [diff] [blame] | 954 | info.addr = 0x7a; |
Jean Delvare | 4d7a2d6 | 2009-05-13 16:49:32 -0300 | [diff] [blame] | 955 | break; |
| 956 | case SAA7134_BOARD_MSI_TVATANYWHERE_PLUS: |
Mauro Carvalho Chehab | 7aedd5ec | 2009-09-07 02:22:01 -0300 | [diff] [blame] | 957 | dev->init_data.name = "MSI TV@nywhere Plus"; |
| 958 | dev->init_data.get_key = get_key_msi_tvanywhere_plus; |
| 959 | dev->init_data.ir_codes = &ir_codes_msi_tvanywhere_plus_table; |
Jean Delvare | 43e16ea | 2009-10-02 05:47:08 -0300 | [diff] [blame] | 960 | info.addr = 0x30; |
Jean Delvare | ec218a4 | 2009-05-13 16:51:46 -0300 | [diff] [blame] | 961 | /* MSI TV@nywhere Plus controller doesn't seem to |
| 962 | respond to probes unless we read something from |
| 963 | an existing device. Weird... |
| 964 | REVISIT: might no longer be needed */ |
| 965 | rc = i2c_transfer(&dev->i2c_adap, &msg_msi, 1); |
| 966 | dprintk(KERN_DEBUG "probe 0x%02x @ %s: %s\n", |
| 967 | msg_msi.addr, dev->i2c_adap.name, |
| 968 | (1 == rc) ? "yes" : "no"); |
Jean Delvare | 4d7a2d6 | 2009-05-13 16:49:32 -0300 | [diff] [blame] | 969 | break; |
| 970 | case SAA7134_BOARD_HAUPPAUGE_HVR1110: |
Mauro Carvalho Chehab | 7aedd5ec | 2009-09-07 02:22:01 -0300 | [diff] [blame] | 971 | dev->init_data.name = "HVR 1110"; |
| 972 | dev->init_data.get_key = get_key_hvr1110; |
| 973 | dev->init_data.ir_codes = &ir_codes_hauppauge_new_table; |
Jean Delvare | 30093e8 | 2009-10-02 09:48:04 -0300 | [diff] [blame] | 974 | info.addr = 0x71; |
Jean Delvare | 4d7a2d6 | 2009-05-13 16:49:32 -0300 | [diff] [blame] | 975 | break; |
| 976 | case SAA7134_BOARD_BEHOLD_607FM_MK3: |
| 977 | case SAA7134_BOARD_BEHOLD_607FM_MK5: |
| 978 | case SAA7134_BOARD_BEHOLD_609FM_MK3: |
| 979 | case SAA7134_BOARD_BEHOLD_609FM_MK5: |
| 980 | case SAA7134_BOARD_BEHOLD_607RDS_MK3: |
| 981 | case SAA7134_BOARD_BEHOLD_607RDS_MK5: |
| 982 | case SAA7134_BOARD_BEHOLD_609RDS_MK3: |
| 983 | case SAA7134_BOARD_BEHOLD_609RDS_MK5: |
| 984 | case SAA7134_BOARD_BEHOLD_M6: |
| 985 | case SAA7134_BOARD_BEHOLD_M63: |
| 986 | case SAA7134_BOARD_BEHOLD_M6_EXTRA: |
| 987 | case SAA7134_BOARD_BEHOLD_H6: |
Dmitri Belimov | 2012c87f | 2009-08-26 01:01:12 -0300 | [diff] [blame] | 988 | case SAA7134_BOARD_BEHOLD_X7: |
Mauro Carvalho Chehab | 7aedd5ec | 2009-09-07 02:22:01 -0300 | [diff] [blame] | 989 | dev->init_data.name = "BeholdTV"; |
| 990 | dev->init_data.get_key = get_key_beholdm6xx; |
| 991 | dev->init_data.ir_codes = &ir_codes_behold_table; |
Dmitri Belimov | 2ffbb64 | 2010-03-04 02:40:37 -0300 | [diff] [blame] | 992 | dev->init_data.type = IR_TYPE_NEC; |
Jean Delvare | 30093e8 | 2009-10-02 09:48:04 -0300 | [diff] [blame] | 993 | info.addr = 0x2d; |
Jean Delvare | 4d7a2d6 | 2009-05-13 16:49:32 -0300 | [diff] [blame] | 994 | break; |
Jean Delvare | d9a88e6 | 2009-05-13 16:52:44 -0300 | [diff] [blame] | 995 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_501: |
| 996 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: |
Jean Delvare | 43e16ea | 2009-10-02 05:47:08 -0300 | [diff] [blame] | 997 | info.addr = 0x40; |
Jean Delvare | d9a88e6 | 2009-05-13 16:52:44 -0300 | [diff] [blame] | 998 | break; |
Lukas Karas | d995a18 | 2009-11-24 12:06:52 -0300 | [diff] [blame] | 999 | case SAA7134_BOARD_FLYDVB_TRIO: |
| 1000 | dev->init_data.name = "FlyDVB Trio"; |
| 1001 | dev->init_data.get_key = get_key_flydvb_trio; |
| 1002 | dev->init_data.ir_codes = &ir_codes_flydvb_table; |
| 1003 | info.addr = 0x0b; |
| 1004 | break; |
Jean Delvare | 30093e8 | 2009-10-02 09:48:04 -0300 | [diff] [blame] | 1005 | default: |
| 1006 | dprintk("No I2C IR support for board %x\n", dev->board); |
| 1007 | return; |
Jean Delvare | 4d7a2d6 | 2009-05-13 16:49:32 -0300 | [diff] [blame] | 1008 | } |
| 1009 | |
Mauro Carvalho Chehab | 7aedd5ec | 2009-09-07 02:22:01 -0300 | [diff] [blame] | 1010 | if (dev->init_data.name) |
Jean Delvare | 43e16ea | 2009-10-02 05:47:08 -0300 | [diff] [blame] | 1011 | info.platform_data = &dev->init_data; |
Jean Delvare | 30093e8 | 2009-10-02 09:48:04 -0300 | [diff] [blame] | 1012 | i2c_new_device(&dev->i2c_adap, &info); |
Jean Delvare | c668f32 | 2009-05-13 16:48:50 -0300 | [diff] [blame] | 1013 | } |
| 1014 | |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 1015 | static int saa7134_raw_decode_irq(struct saa7134_dev *dev) |
| 1016 | { |
| 1017 | struct card_ir *ir = dev->remote; |
| 1018 | unsigned long timeout; |
Mauro Carvalho Chehab | d89b4bd | 2010-03-26 22:39:29 -0300 | [diff] [blame] | 1019 | int pulse; |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 1020 | |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 1021 | /* Generate initial event */ |
| 1022 | saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); |
| 1023 | saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); |
| 1024 | pulse = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2) & ir->mask_keydown; |
Mauro Carvalho Chehab | 93c312f | 2010-03-25 21:13:43 -0300 | [diff] [blame] | 1025 | ir_raw_event_store(dev->remote->dev, pulse ? IR_PULSE : IR_SPACE); |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 1026 | |
Mauro Carvalho Chehab | 9f15478 | 2010-03-21 13:00:55 -0300 | [diff] [blame] | 1027 | |
| 1028 | /* |
| 1029 | * Wait 15 ms from the start of the first IR event before processing |
| 1030 | * the event. This time is enough for NEC protocol. May need adjustments |
| 1031 | * to work with other protocols. |
| 1032 | */ |
| 1033 | if (!ir->active) { |
| 1034 | timeout = jiffies + jiffies_to_msecs(15); |
| 1035 | mod_timer(&ir->timer_end, timeout); |
| 1036 | ir->active = 1; |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 1037 | } |
| 1038 | |
Mauro Carvalho Chehab | a3572c3 | 2010-03-20 20:59:44 -0300 | [diff] [blame] | 1039 | return 1; |
| 1040 | } |
| 1041 | |
Hermann Pitton | 9160723 | 2006-12-07 21:45:28 -0300 | [diff] [blame] | 1042 | static int saa7134_rc5_irq(struct saa7134_dev *dev) |
| 1043 | { |
| 1044 | struct card_ir *ir = dev->remote; |
| 1045 | struct timeval tv; |
| 1046 | u32 gap; |
| 1047 | unsigned long current_jiffies, timeout; |
| 1048 | |
| 1049 | /* get time of bit */ |
| 1050 | current_jiffies = jiffies; |
| 1051 | do_gettimeofday(&tv); |
| 1052 | |
| 1053 | /* avoid overflow with gap >1s */ |
| 1054 | if (tv.tv_sec - ir->base_time.tv_sec > 1) { |
| 1055 | gap = 200000; |
| 1056 | } else { |
| 1057 | gap = 1000000 * (tv.tv_sec - ir->base_time.tv_sec) + |
| 1058 | tv.tv_usec - ir->base_time.tv_usec; |
| 1059 | } |
| 1060 | |
| 1061 | /* active code => add bit */ |
| 1062 | if (ir->active) { |
| 1063 | /* only if in the code (otherwise spurious IRQ or timer |
| 1064 | late) */ |
| 1065 | if (ir->last_bit < 28) { |
| 1066 | ir->last_bit = (gap - ir_rc5_remote_gap / 2) / |
| 1067 | ir_rc5_remote_gap; |
| 1068 | ir->code |= 1 << ir->last_bit; |
| 1069 | } |
| 1070 | /* starting new code */ |
| 1071 | } else { |
| 1072 | ir->active = 1; |
| 1073 | ir->code = 0; |
| 1074 | ir->base_time = tv; |
| 1075 | ir->last_bit = 0; |
| 1076 | |
| 1077 | timeout = current_jiffies + (500 + 30 * HZ) / 1000; |
| 1078 | mod_timer(&ir->timer_end, timeout); |
| 1079 | } |
| 1080 | |
| 1081 | return 1; |
| 1082 | } |
| 1083 | |
Mauro Carvalho Chehab | 622ecb3 | 2008-08-05 10:03:17 -0300 | [diff] [blame] | 1084 | /* On NEC protocol, One has 2.25 ms, and zero has 1.125 ms |
| 1085 | The first pulse (start) has 9 + 4.5 ms |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1086 | */ |
Mauro Carvalho Chehab | 622ecb3 | 2008-08-05 10:03:17 -0300 | [diff] [blame] | 1087 | |
| 1088 | static void saa7134_nec_timer(unsigned long data) |
| 1089 | { |
| 1090 | struct saa7134_dev *dev = (struct saa7134_dev *) data; |
| 1091 | struct card_ir *ir = dev->remote; |
| 1092 | |
| 1093 | dprintk("Cancel key repeat\n"); |
| 1094 | |
| 1095 | ir_input_nokey(ir->dev, &ir->ir); |
| 1096 | } |
| 1097 | |
| 1098 | static void nec_task(unsigned long data) |
| 1099 | { |
| 1100 | struct saa7134_dev *dev = (struct saa7134_dev *) data; |
| 1101 | struct card_ir *ir; |
| 1102 | struct timeval tv; |
| 1103 | int count, pulse, oldpulse, gap; |
| 1104 | u32 ircode = 0, not_code = 0; |
| 1105 | int ngap = 0; |
| 1106 | |
| 1107 | if (!data) { |
| 1108 | printk(KERN_ERR "saa713x/ir: Can't recover dev struct\n"); |
| 1109 | /* GPIO will be kept disabled */ |
| 1110 | return; |
| 1111 | } |
| 1112 | |
| 1113 | ir = dev->remote; |
| 1114 | |
| 1115 | /* rising SAA7134_GPIO_GPRESCAN reads the status */ |
| 1116 | saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); |
| 1117 | saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); |
| 1118 | |
| 1119 | oldpulse = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2) & ir->mask_keydown; |
| 1120 | pulse = oldpulse; |
| 1121 | |
| 1122 | do_gettimeofday(&tv); |
| 1123 | ir->base_time = tv; |
| 1124 | |
| 1125 | /* Decode NEC pulsecode. This code can take up to 76.5 ms to run. |
| 1126 | Unfortunately, using IRQ to decode pulse didn't work, since it uses |
| 1127 | a pulse train of 38KHz. This means one pulse on each 52 us |
| 1128 | */ |
| 1129 | do { |
| 1130 | /* Wait until the end of pulse/space or 5 ms */ |
| 1131 | for (count = 0; count < 500; count++) { |
| 1132 | udelay(10); |
| 1133 | /* rising SAA7134_GPIO_GPRESCAN reads the status */ |
| 1134 | saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); |
| 1135 | saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); |
| 1136 | pulse = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2) |
| 1137 | & ir->mask_keydown; |
| 1138 | if (pulse != oldpulse) |
| 1139 | break; |
| 1140 | } |
| 1141 | |
| 1142 | do_gettimeofday(&tv); |
| 1143 | gap = 1000000 * (tv.tv_sec - ir->base_time.tv_sec) + |
| 1144 | tv.tv_usec - ir->base_time.tv_usec; |
| 1145 | |
| 1146 | if (!pulse) { |
| 1147 | /* Bit 0 has 560 us, while bit 1 has 1120 us. |
| 1148 | Do something only if bit == 1 |
| 1149 | */ |
| 1150 | if (ngap && (gap > 560 + 280)) { |
| 1151 | unsigned int shift = ngap - 1; |
| 1152 | |
| 1153 | /* Address first, then command */ |
| 1154 | if (shift < 8) { |
| 1155 | shift += 8; |
| 1156 | ircode |= 1 << shift; |
| 1157 | } else if (shift < 16) { |
| 1158 | not_code |= 1 << shift; |
| 1159 | } else if (shift < 24) { |
| 1160 | shift -= 16; |
| 1161 | ircode |= 1 << shift; |
| 1162 | } else { |
| 1163 | shift -= 24; |
| 1164 | not_code |= 1 << shift; |
| 1165 | } |
| 1166 | } |
| 1167 | ngap++; |
| 1168 | } |
| 1169 | |
| 1170 | |
| 1171 | ir->base_time = tv; |
| 1172 | |
| 1173 | /* TIMEOUT - Long pulse */ |
| 1174 | if (gap >= 5000) |
| 1175 | break; |
| 1176 | oldpulse = pulse; |
| 1177 | } while (ngap < 32); |
| 1178 | |
| 1179 | if (ngap == 32) { |
| 1180 | /* FIXME: should check if not_code == ~ircode */ |
| 1181 | ir->code = ir_extract_bits(ircode, ir->mask_keycode); |
| 1182 | |
| 1183 | dprintk("scancode = 0x%02x (code = 0x%02x, notcode= 0x%02x)\n", |
| 1184 | ir->code, ircode, not_code); |
| 1185 | |
Mauro Carvalho Chehab | 8573b74 | 2009-11-27 22:40:22 -0300 | [diff] [blame] | 1186 | ir_input_keydown(ir->dev, &ir->ir, ir->code); |
Mauro Carvalho Chehab | 622ecb3 | 2008-08-05 10:03:17 -0300 | [diff] [blame] | 1187 | } else |
| 1188 | dprintk("Repeat last key\n"); |
| 1189 | |
| 1190 | /* Keep repeating the last key */ |
| 1191 | mod_timer(&ir->timer_keyup, jiffies + msecs_to_jiffies(150)); |
| 1192 | |
| 1193 | saa_setl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18); |
| 1194 | } |
| 1195 | |
| 1196 | static int saa7134_nec_irq(struct saa7134_dev *dev) |
| 1197 | { |
| 1198 | struct card_ir *ir = dev->remote; |
| 1199 | |
| 1200 | saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18); |
| 1201 | tasklet_schedule(&ir->tlet); |
| 1202 | |
| 1203 | return 1; |
| 1204 | } |