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> |
| 22 | #include <linux/moduleparam.h> |
| 23 | #include <linux/init.h> |
| 24 | #include <linux/delay.h> |
| 25 | #include <linux/sched.h> |
| 26 | #include <linux/interrupt.h> |
| 27 | #include <linux/input.h> |
| 28 | |
| 29 | #include "saa7134-reg.h" |
| 30 | #include "saa7134.h" |
| 31 | |
| 32 | static unsigned int disable_ir = 0; |
| 33 | module_param(disable_ir, int, 0444); |
| 34 | MODULE_PARM_DESC(disable_ir,"disable infrared remote support"); |
| 35 | |
| 36 | static unsigned int ir_debug = 0; |
| 37 | module_param(ir_debug, int, 0644); |
| 38 | MODULE_PARM_DESC(ir_debug,"enable debug messages [IR]"); |
| 39 | |
Sylvain Pasche | b93eedb | 2006-03-25 23:14:42 -0300 | [diff] [blame] | 40 | static int pinnacle_remote = 0; |
| 41 | module_param(pinnacle_remote, int, 0644); /* Choose Pinnacle PCTV remote */ |
| 42 | MODULE_PARM_DESC(pinnacle_remote, "Specify Pinnacle PCTV remote: 0=coloured, 1=grey (defaults to 0)"); |
| 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #define dprintk(fmt, arg...) if (ir_debug) \ |
| 45 | printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg) |
Ricardo Cerqueira | ac9cd97 | 2005-11-08 21:37:56 -0800 | [diff] [blame] | 46 | #define i2cdprintk(fmt, arg...) if (ir_debug) \ |
| 47 | printk(KERN_DEBUG "%s/ir: " fmt, ir->c.name , ## arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
Ricardo Cerqueira | ac9cd97 | 2005-11-08 21:37:56 -0800 | [diff] [blame] | 49 | /* -------------------- GPIO generic keycode builder -------------------- */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
| 51 | static int build_key(struct saa7134_dev *dev) |
| 52 | { |
| 53 | struct saa7134_ir *ir = dev->remote; |
| 54 | u32 gpio, data; |
| 55 | |
| 56 | /* rising SAA7134_GPIO_GPRESCAN reads the status */ |
| 57 | saa_clearb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN); |
| 58 | saa_setb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN); |
| 59 | |
| 60 | gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2); |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 61 | if (ir->polling) { |
| 62 | if (ir->last_gpio == gpio) |
| 63 | return 0; |
| 64 | ir->last_gpio = gpio; |
| 65 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 67 | data = ir_extract_bits(gpio, ir->mask_keycode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | dprintk("build_key gpio=0x%x mask=0x%x data=%d\n", |
| 69 | gpio, ir->mask_keycode, data); |
| 70 | |
Peter Missel | 0602fbb | 2006-01-09 18:21:23 -0200 | [diff] [blame] | 71 | if (ir->polling) { |
| 72 | if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || |
| 73 | (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { |
| 74 | ir_input_keydown(ir->dev, &ir->ir, data, data); |
| 75 | } else { |
| 76 | ir_input_nokey(ir->dev, &ir->ir); |
| 77 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | } |
Peter Missel | 0602fbb | 2006-01-09 18:21:23 -0200 | [diff] [blame] | 79 | else { /* IRQ driven mode - handle key press and release in one go */ |
| 80 | if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || |
| 81 | (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { |
| 82 | ir_input_keydown(ir->dev, &ir->ir, data, data); |
| 83 | ir_input_nokey(ir->dev, &ir->ir); |
| 84 | } |
| 85 | } |
| 86 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | return 0; |
| 88 | } |
| 89 | |
Ricardo Cerqueira | ac9cd97 | 2005-11-08 21:37:56 -0800 | [diff] [blame] | 90 | /* --------------------- Chip specific I2C key builders ----------------- */ |
| 91 | |
| 92 | static int get_key_purpletv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) |
| 93 | { |
| 94 | unsigned char b; |
| 95 | |
| 96 | /* poll IR chip */ |
| 97 | if (1 != i2c_master_recv(&ir->c,&b,1)) { |
| 98 | i2cdprintk("read error\n"); |
| 99 | return -EIO; |
| 100 | } |
| 101 | |
| 102 | /* no button press */ |
| 103 | if (b==0) |
| 104 | return 0; |
| 105 | |
| 106 | /* repeating */ |
| 107 | if (b & 0x80) |
| 108 | return 1; |
| 109 | |
| 110 | *ir_key = b; |
| 111 | *ir_raw = b; |
| 112 | return 1; |
| 113 | } |
| 114 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | void saa7134_input_irq(struct saa7134_dev *dev) |
| 116 | { |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 117 | struct saa7134_ir *ir = dev->remote; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 119 | if (!ir->polling) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | build_key(dev); |
| 121 | } |
| 122 | |
| 123 | static void saa7134_input_timer(unsigned long data) |
| 124 | { |
| 125 | struct saa7134_dev *dev = (struct saa7134_dev*)data; |
| 126 | struct saa7134_ir *ir = dev->remote; |
| 127 | unsigned long timeout; |
| 128 | |
| 129 | build_key(dev); |
| 130 | timeout = jiffies + (ir->polling * HZ / 1000); |
| 131 | mod_timer(&ir->timer, timeout); |
| 132 | } |
| 133 | |
| 134 | int saa7134_input_init1(struct saa7134_dev *dev) |
| 135 | { |
| 136 | struct saa7134_ir *ir; |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 137 | struct input_dev *input_dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | IR_KEYTAB_TYPE *ir_codes = NULL; |
| 139 | u32 mask_keycode = 0; |
| 140 | u32 mask_keydown = 0; |
| 141 | u32 mask_keyup = 0; |
| 142 | int polling = 0; |
| 143 | int ir_type = IR_TYPE_OTHER; |
| 144 | |
Ricardo Cerqueira | cb2444d | 2005-11-08 21:38:47 -0800 | [diff] [blame] | 145 | if (dev->has_remote != SAA7134_REMOTE_GPIO) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | return -ENODEV; |
| 147 | if (disable_ir) |
| 148 | return -ENODEV; |
| 149 | |
| 150 | /* detect & configure */ |
| 151 | switch (dev->board) { |
| 152 | case SAA7134_BOARD_FLYVIDEO2000: |
| 153 | case SAA7134_BOARD_FLYVIDEO3000: |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 154 | case SAA7134_BOARD_FLYTVPLATINUM_FM: |
Arnaud Patard | 6af90ab | 2005-11-08 21:36:55 -0800 | [diff] [blame] | 155 | case SAA7134_BOARD_FLYTVPLATINUM_MINI2: |
Ricardo Cerqueira | 4c0f631 | 2006-01-23 09:42:06 -0200 | [diff] [blame] | 156 | ir_codes = ir_codes_flyvideo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | mask_keycode = 0xEC00000; |
| 158 | mask_keydown = 0x0040000; |
| 159 | break; |
| 160 | case SAA7134_BOARD_CINERGY400: |
| 161 | case SAA7134_BOARD_CINERGY600: |
| 162 | case SAA7134_BOARD_CINERGY600_MK3: |
Ricardo Cerqueira | 4c0f631 | 2006-01-23 09:42:06 -0200 | [diff] [blame] | 163 | ir_codes = ir_codes_cinergy; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | mask_keycode = 0x00003f; |
| 165 | mask_keyup = 0x040000; |
| 166 | break; |
| 167 | case SAA7134_BOARD_ECS_TVP3XP: |
| 168 | case SAA7134_BOARD_ECS_TVP3XP_4CB5: |
Ricardo Cerqueira | 4c0f631 | 2006-01-23 09:42:06 -0200 | [diff] [blame] | 169 | ir_codes = ir_codes_eztv; |
Mauro Carvalho Chehab | 330a115 | 2005-07-12 13:59:01 -0700 | [diff] [blame] | 170 | mask_keycode = 0x00017c; |
| 171 | mask_keyup = 0x000002; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | polling = 50; // ms |
Mauro Carvalho Chehab | 330a115 | 2005-07-12 13:59:01 -0700 | [diff] [blame] | 173 | break; |
| 174 | case SAA7134_BOARD_KWORLD_XPERT: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | case SAA7134_BOARD_AVACSSMARTTV: |
Nickolay V. Shmyrev | b639f9d | 2006-01-23 09:44:10 -0200 | [diff] [blame] | 176 | ir_codes = ir_codes_pixelview; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | mask_keycode = 0x00001F; |
| 178 | mask_keyup = 0x000020; |
| 179 | polling = 50; // ms |
| 180 | break; |
| 181 | case SAA7134_BOARD_MD2819: |
Mauro Carvalho Chehab | ac19ecc | 2005-06-23 22:05:09 -0700 | [diff] [blame] | 182 | case SAA7134_BOARD_KWORLD_VSTREAM_XPERT: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | case SAA7134_BOARD_AVERMEDIA_305: |
| 184 | case SAA7134_BOARD_AVERMEDIA_307: |
Mauro Carvalho Chehab | ac19ecc | 2005-06-23 22:05:09 -0700 | [diff] [blame] | 185 | case SAA7134_BOARD_AVERMEDIA_STUDIO_305: |
| 186 | case SAA7134_BOARD_AVERMEDIA_STUDIO_307: |
| 187 | case SAA7134_BOARD_AVERMEDIA_GO_007_FM: |
Nickolay V. Shmyrev | b639f9d | 2006-01-23 09:44:10 -0200 | [diff] [blame] | 188 | ir_codes = ir_codes_avermedia; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | mask_keycode = 0x0007C8; |
| 190 | mask_keydown = 0x000010; |
| 191 | polling = 50; // ms |
| 192 | /* Set GPIO pin2 to high to enable the IR controller */ |
| 193 | saa_setb(SAA7134_GPIO_GPMODE0, 0x4); |
| 194 | saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4); |
| 195 | break; |
pasky@ucw.cz | 450efcf | 2006-11-12 14:22:32 -0300 | [diff] [blame] | 196 | case SAA7134_BOARD_AVERMEDIA_777: |
pasky@ucw.cz | 29e0f1a | 2006-11-12 14:23:32 -0300 | [diff] [blame] | 197 | case SAA7134_BOARD_AVERMEDIA_A16AR: |
pasky@ucw.cz | 450efcf | 2006-11-12 14:22:32 -0300 | [diff] [blame] | 198 | ir_codes = ir_codes_avermedia; |
| 199 | mask_keycode = 0x02F200; |
| 200 | mask_keydown = 0x000400; |
| 201 | polling = 50; // ms |
| 202 | /* Without this we won't receive key up events */ |
| 203 | saa_setb(SAA7134_GPIO_GPMODE1, 0x1); |
| 204 | saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1); |
Linus Torvalds | 4dd7406 | 2006-11-13 09:50:11 -0800 | [diff] [blame] | 205 | break; |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 206 | case SAA7134_BOARD_KWORLD_TERMINATOR: |
Nickolay V. Shmyrev | b639f9d | 2006-01-23 09:44:10 -0200 | [diff] [blame] | 207 | ir_codes = ir_codes_pixelview; |
James R. Webb | dc2286c | 2005-11-08 21:37:00 -0800 | [diff] [blame] | 208 | mask_keycode = 0x00001f; |
| 209 | mask_keyup = 0x000060; |
| 210 | polling = 50; // ms |
| 211 | break; |
Mauro Carvalho Chehab | ac19ecc | 2005-06-23 22:05:09 -0700 | [diff] [blame] | 212 | case SAA7134_BOARD_MANLI_MTV001: |
| 213 | case SAA7134_BOARD_MANLI_MTV002: |
Nickolay V. Shmyrev | a8ff417 | 2005-11-08 21:36:16 -0800 | [diff] [blame] | 214 | case SAA7134_BOARD_BEHOLD_409FM: |
Ricardo Cerqueira | 4c0f631 | 2006-01-23 09:42:06 -0200 | [diff] [blame] | 215 | ir_codes = ir_codes_manli; |
Mauro Carvalho Chehab | ac19ecc | 2005-06-23 22:05:09 -0700 | [diff] [blame] | 216 | mask_keycode = 0x001f00; |
| 217 | mask_keyup = 0x004000; |
Mauro Carvalho Chehab | ac19ecc | 2005-06-23 22:05:09 -0700 | [diff] [blame] | 218 | polling = 50; // ms |
| 219 | break; |
Ricardo Cerqueira | 17ce1ff | 2005-11-08 21:38:47 -0800 | [diff] [blame] | 220 | case SAA7134_BOARD_SEDNA_PC_TV_CARDBUS: |
Ricardo Cerqueira | 4c0f631 | 2006-01-23 09:42:06 -0200 | [diff] [blame] | 221 | ir_codes = ir_codes_pctv_sedna; |
Pavel Mihaylov | c3d9319 | 2005-11-08 21:38:43 -0800 | [diff] [blame] | 222 | mask_keycode = 0x001f00; |
| 223 | mask_keyup = 0x004000; |
| 224 | polling = 50; // ms |
| 225 | break; |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 226 | case SAA7134_BOARD_GOTVIEW_7135: |
Ricardo Cerqueira | 4c0f631 | 2006-01-23 09:42:06 -0200 | [diff] [blame] | 227 | ir_codes = ir_codes_gotview7135; |
Nickolay V. Shmyrev | 6b96144 | 2005-11-08 21:36:22 -0800 | [diff] [blame] | 228 | mask_keycode = 0x0003EC; |
| 229 | mask_keyup = 0x008000; |
| 230 | mask_keydown = 0x000010; |
| 231 | polling = 50; // ms |
| 232 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | case SAA7134_BOARD_VIDEOMATE_TV_PVR: |
Nickolay V. Shmyrev | 2a9a9a8 | 2006-01-09 15:25:33 -0200 | [diff] [blame] | 234 | case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS: |
Mauro Carvalho Chehab | 330a115 | 2005-07-12 13:59:01 -0700 | [diff] [blame] | 235 | case SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII: |
Ricardo Cerqueira | 4c0f631 | 2006-01-23 09:42:06 -0200 | [diff] [blame] | 236 | ir_codes = ir_codes_videomate_tv_pvr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | mask_keycode = 0x00003F; |
| 238 | mask_keyup = 0x400000; |
| 239 | polling = 50; // ms |
| 240 | break; |
Michal Majchrowicz | b04c1ba | 2006-09-13 16:42:42 -0300 | [diff] [blame] | 241 | case SAA7134_BOARD_PROTEUS_2309: |
| 242 | ir_codes = ir_codes_proteus_2309; |
| 243 | mask_keycode = 0x00007F; |
| 244 | mask_keyup = 0x000080; |
| 245 | polling = 50; // ms |
| 246 | break; |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 247 | case SAA7134_BOARD_VIDEOMATE_DVBT_300: |
| 248 | case SAA7134_BOARD_VIDEOMATE_DVBT_200: |
Ricardo Cerqueira | 4c0f631 | 2006-01-23 09:42:06 -0200 | [diff] [blame] | 249 | ir_codes = ir_codes_videomate_tv_pvr; |
Nickolay V. Shmyrev | fea095f | 2005-11-08 21:36:47 -0800 | [diff] [blame] | 250 | mask_keycode = 0x003F00; |
| 251 | mask_keyup = 0x040000; |
| 252 | break; |
Giampiero Giancipoli | 3d8466e | 2006-02-07 06:49:09 -0200 | [diff] [blame] | 253 | case SAA7134_BOARD_FLYDVBT_LR301: |
Rudo Thomas | a802917 | 2006-02-27 00:08:46 -0300 | [diff] [blame] | 254 | case SAA7134_BOARD_FLYDVBTDUO: |
Giampiero Giancipoli | 3d8466e | 2006-02-07 06:49:09 -0200 | [diff] [blame] | 255 | ir_codes = ir_codes_flydvb; |
| 256 | mask_keycode = 0x0001F00; |
| 257 | mask_keydown = 0x0040000; |
| 258 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | } |
| 260 | if (NULL == ir_codes) { |
| 261 | printk("%s: Oops: IR config error [card=%d]\n", |
| 262 | dev->name, dev->board); |
| 263 | return -ENODEV; |
| 264 | } |
| 265 | |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 266 | ir = kzalloc(sizeof(*ir), GFP_KERNEL); |
| 267 | input_dev = input_allocate_device(); |
| 268 | if (!ir || !input_dev) { |
| 269 | kfree(ir); |
| 270 | input_free_device(input_dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | return -ENOMEM; |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 272 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | |
Dmitry Torokhov | d271d1c | 2005-11-20 00:56:54 -0500 | [diff] [blame] | 274 | ir->dev = input_dev; |
| 275 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | /* init hardware-specific stuff */ |
| 277 | ir->mask_keycode = mask_keycode; |
| 278 | ir->mask_keydown = mask_keydown; |
| 279 | ir->mask_keyup = mask_keyup; |
Mauro Carvalho Chehab | 4ac9791 | 2005-11-08 21:37:43 -0800 | [diff] [blame] | 280 | ir->polling = polling; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | |
| 282 | /* init input device */ |
| 283 | snprintf(ir->name, sizeof(ir->name), "saa7134 IR (%s)", |
| 284 | saa7134_boards[dev->board].name); |
| 285 | snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", |
| 286 | pci_name(dev->pci)); |
| 287 | |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 288 | ir_input_init(input_dev, &ir->ir, ir_type, ir_codes); |
| 289 | input_dev->name = ir->name; |
| 290 | input_dev->phys = ir->phys; |
| 291 | input_dev->id.bustype = BUS_PCI; |
| 292 | input_dev->id.version = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | if (dev->pci->subsystem_vendor) { |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 294 | input_dev->id.vendor = dev->pci->subsystem_vendor; |
| 295 | input_dev->id.product = dev->pci->subsystem_device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | } else { |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 297 | input_dev->id.vendor = dev->pci->vendor; |
| 298 | input_dev->id.product = dev->pci->device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | } |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 300 | input_dev->cdev.dev = &dev->pci->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | |
| 302 | /* all done */ |
| 303 | dev->remote = ir; |
| 304 | if (ir->polling) { |
| 305 | init_timer(&ir->timer); |
| 306 | ir->timer.function = saa7134_input_timer; |
| 307 | ir->timer.data = (unsigned long)dev; |
| 308 | ir->timer.expires = jiffies + HZ; |
| 309 | add_timer(&ir->timer); |
| 310 | } |
| 311 | |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 312 | input_register_device(ir->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | return 0; |
| 314 | } |
| 315 | |
| 316 | void saa7134_input_fini(struct saa7134_dev *dev) |
| 317 | { |
| 318 | if (NULL == dev->remote) |
| 319 | return; |
| 320 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | if (dev->remote->polling) |
| 322 | del_timer_sync(&dev->remote->timer); |
Dmitry Torokhov | b7df391 | 2005-09-15 02:01:53 -0500 | [diff] [blame] | 323 | input_unregister_device(dev->remote->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | kfree(dev->remote); |
| 325 | dev->remote = NULL; |
| 326 | } |
| 327 | |
Ricardo Cerqueira | ac9cd97 | 2005-11-08 21:37:56 -0800 | [diff] [blame] | 328 | void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir) |
| 329 | { |
| 330 | if (disable_ir) { |
Ricardo Cerqueira | cb2444d | 2005-11-08 21:38:47 -0800 | [diff] [blame] | 331 | dprintk("Found supported i2c remote, but IR has been disabled\n"); |
Ricardo Cerqueira | ac9cd97 | 2005-11-08 21:37:56 -0800 | [diff] [blame] | 332 | ir->get_key=NULL; |
| 333 | return; |
| 334 | } |
| 335 | |
| 336 | switch (dev->board) { |
| 337 | case SAA7134_BOARD_PINNACLE_PCTV_110i: |
| 338 | snprintf(ir->c.name, sizeof(ir->c.name), "Pinnacle PCTV"); |
Sylvain Pasche | b93eedb | 2006-03-25 23:14:42 -0300 | [diff] [blame] | 339 | if (pinnacle_remote == 0) { |
| 340 | ir->get_key = get_key_pinnacle_color; |
| 341 | ir->ir_codes = ir_codes_pinnacle_color; |
| 342 | } else { |
| 343 | ir->get_key = get_key_pinnacle_grey; |
| 344 | ir->ir_codes = ir_codes_pinnacle_grey; |
| 345 | } |
Ricardo Cerqueira | ac9cd97 | 2005-11-08 21:37:56 -0800 | [diff] [blame] | 346 | break; |
| 347 | case SAA7134_BOARD_UPMOST_PURPLE_TV: |
| 348 | snprintf(ir->c.name, sizeof(ir->c.name), "Purple TV"); |
| 349 | ir->get_key = get_key_purpletv; |
| 350 | ir->ir_codes = ir_codes_purpletv; |
| 351 | break; |
| 352 | default: |
| 353 | dprintk("Shouldn't get here: Unknown board %x for I2C IR?\n",dev->board); |
| 354 | break; |
| 355 | } |
| 356 | |
| 357 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | /* ---------------------------------------------------------------------- |
| 359 | * Local variables: |
| 360 | * c-basic-offset: 8 |
| 361 | * End: |
| 362 | */ |