blob: 2f289d981fe62d3b3b2fba62ccc824e3d303935d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
3 * Copyright (c) 2003 Gerd Knorr
4 * Copyright (c) 2003 Pavel Machek
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <linux/init.h>
23#include <linux/delay.h>
24#include <linux/interrupt.h>
25#include <linux/input.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include "bttv.h"
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -020028#include "bttvp.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
Mark Weaver6c6c0b22005-11-13 16:07:52 -080030
Mauro Carvalho Chehab7d341a62008-08-05 10:14:13 -030031static int ir_debug;
32module_param(ir_debug, int, 0644);
Mark Weaver6c6c0b22005-11-13 16:07:52 -080033static int repeat_delay = 500;
34module_param(repeat_delay, int, 0644);
35static int repeat_period = 33;
36module_param(repeat_period, int, 0644);
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Adrian Bunkc408a6f2006-12-28 12:47:47 -030038static int ir_rc5_remote_gap = 885;
Hermann Pitton91607232006-12-07 21:45:28 -030039module_param(ir_rc5_remote_gap, int, 0644);
Adrian Bunkc408a6f2006-12-28 12:47:47 -030040static int ir_rc5_key_timeout = 200;
Hermann Pitton91607232006-12-07 21:45:28 -030041module_param(ir_rc5_key_timeout, int, 0644);
42
Mauro Carvalho Chehab7d341a62008-08-05 10:14:13 -030043#undef dprintk
44#define dprintk(arg...) do { \
45 if (ir_debug >= 1) \
46 printk(arg); \
47} while (0)
48
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -020049#define DEVNAME "bttv-input"
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51/* ---------------------------------------------------------------------- */
52
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -020053static void ir_handle_key(struct bttv *btv)
Linus Torvalds1da177e2005-04-16 15:20:36 -070054{
Hermann Pitton91607232006-12-07 21:45:28 -030055 struct card_ir *ir = btv->remote;
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 u32 gpio,data;
57
58 /* read gpio value */
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -020059 gpio = bttv_gpio_read(&btv->c);
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 if (ir->polling) {
61 if (ir->last_gpio == gpio)
62 return;
63 ir->last_gpio = gpio;
64 }
65
66 /* extract data */
67 data = ir_extract_bits(gpio, ir->mask_keycode);
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -020068 dprintk(KERN_INFO DEVNAME ": irq gpio=0x%x code=%d | %s%s%s\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 gpio, data,
70 ir->polling ? "poll" : "irq",
71 (gpio & ir->mask_keydown) ? " down" : "",
72 (gpio & ir->mask_keyup) ? " up" : "");
73
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -020074 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
75 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
76 ir_input_keydown(ir->dev,&ir->ir,data,data);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 } else {
Mauro Carvalho Chehabb3d98132008-01-07 09:30:31 -030078 /* HACK: Probably, ir->mask_keydown is missing
79 for this board */
80 if (btv->c.type == BTTV_BOARD_WINFAST2000)
81 ir_input_keydown(ir->dev, &ir->ir, data, data);
82
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -020083 ir_input_nokey(ir->dev,&ir->ir);
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 }
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -020085
Linus Torvalds1da177e2005-04-16 15:20:36 -070086}
87
Mauro Carvalho Chehab7d341a62008-08-05 10:14:13 -030088static void ir_enltv_handle_key(struct bttv *btv)
89{
90 struct card_ir *ir = btv->remote;
91 u32 gpio, data, keyup;
92
93 /* read gpio value */
94 gpio = bttv_gpio_read(&btv->c);
95
96 /* extract data */
97 data = ir_extract_bits(gpio, ir->mask_keycode);
98
99 /* Check if it is keyup */
100 keyup = (gpio & ir->mask_keyup) ? 1 << 31 : 0;
101
102 if ((ir->last_gpio & 0x7f) != data) {
103 dprintk(KERN_INFO DEVNAME ": gpio=0x%x code=%d | %s\n",
104 gpio, data,
105 (gpio & ir->mask_keyup) ? " up" : "up/down");
106
107 ir_input_keydown(ir->dev, &ir->ir, data, data);
108 if (keyup)
109 ir_input_nokey(ir->dev, &ir->ir);
110 } else {
111 if ((ir->last_gpio & 1 << 31) == keyup)
112 return;
113
114 dprintk(KERN_INFO DEVNAME ":(cnt) gpio=0x%x code=%d | %s\n",
115 gpio, data,
116 (gpio & ir->mask_keyup) ? " up" : "down");
117
118 if (keyup)
119 ir_input_nokey(ir->dev, &ir->ir);
120 else
121 ir_input_keydown(ir->dev, &ir->ir, data, data);
122 }
123
124 ir->last_gpio = data | keyup;
125}
126
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200127void bttv_input_irq(struct bttv *btv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128{
Hermann Pitton91607232006-12-07 21:45:28 -0300129 struct card_ir *ir = btv->remote;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130
131 if (!ir->polling)
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200132 ir_handle_key(btv);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133}
134
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200135static void bttv_input_timer(unsigned long data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136{
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200137 struct bttv *btv = (struct bttv*)data;
Hermann Pitton91607232006-12-07 21:45:28 -0300138 struct card_ir *ir = btv->remote;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139
Mauro Carvalho Chehab7d341a62008-08-05 10:14:13 -0300140 if (btv->c.type == BTTV_BOARD_ENLTV_FM_2)
141 ir_enltv_handle_key(btv);
142 else
143 ir_handle_key(btv);
Dmitry Torokhovc1904952007-01-02 03:29:48 -0300144 mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145}
146
Mark Weaver6c6c0b22005-11-13 16:07:52 -0800147/* ---------------------------------------------------------------*/
148
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200149static int bttv_rc5_irq(struct bttv *btv)
Mark Weaver6c6c0b22005-11-13 16:07:52 -0800150{
Hermann Pitton91607232006-12-07 21:45:28 -0300151 struct card_ir *ir = btv->remote;
Mark Weaver6c6c0b22005-11-13 16:07:52 -0800152 struct timeval tv;
153 u32 gpio;
154 u32 gap;
Dmitry Torokhovc1904952007-01-02 03:29:48 -0300155 unsigned long current_jiffies;
Mark Weaver6c6c0b22005-11-13 16:07:52 -0800156
157 /* read gpio port */
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200158 gpio = bttv_gpio_read(&btv->c);
Mark Weaver6c6c0b22005-11-13 16:07:52 -0800159
160 /* remote IRQ? */
161 if (!(gpio & 0x20))
162 return 0;
163
164 /* get time of bit */
165 current_jiffies = jiffies;
166 do_gettimeofday(&tv);
167
168 /* avoid overflow with gap >1s */
169 if (tv.tv_sec - ir->base_time.tv_sec > 1) {
170 gap = 200000;
171 } else {
172 gap = 1000000 * (tv.tv_sec - ir->base_time.tv_sec) +
173 tv.tv_usec - ir->base_time.tv_usec;
174 }
175
176 /* active code => add bit */
177 if (ir->active) {
178 /* only if in the code (otherwise spurious IRQ or timer
179 late) */
180 if (ir->last_bit < 28) {
Hermann Pitton91607232006-12-07 21:45:28 -0300181 ir->last_bit = (gap - ir_rc5_remote_gap / 2) /
182 ir_rc5_remote_gap;
Mark Weaver6c6c0b22005-11-13 16:07:52 -0800183 ir->code |= 1 << ir->last_bit;
184 }
185 /* starting new code */
186 } else {
187 ir->active = 1;
188 ir->code = 0;
189 ir->base_time = tv;
190 ir->last_bit = 0;
191
Dmitry Torokhovc1904952007-01-02 03:29:48 -0300192 mod_timer(&ir->timer_end,
193 current_jiffies + msecs_to_jiffies(30));
Mark Weaver6c6c0b22005-11-13 16:07:52 -0800194 }
195
196 /* toggle GPIO pin 4 to reset the irq */
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200197 bttv_gpio_write(&btv->c, gpio & ~(1 << 4));
198 bttv_gpio_write(&btv->c, gpio | (1 << 4));
Mark Weaver6c6c0b22005-11-13 16:07:52 -0800199 return 1;
200}
201
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202/* ---------------------------------------------------------------------- */
203
Hermann Pitton91607232006-12-07 21:45:28 -0300204static void bttv_ir_start(struct bttv *btv, struct card_ir *ir)
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300205{
206 if (ir->polling) {
Dmitry Torokhovc1904952007-01-02 03:29:48 -0300207 setup_timer(&ir->timer, bttv_input_timer, (unsigned long)btv);
Mauro Carvalho Chehabfe06fe02007-07-17 16:36:20 -0300208 ir->timer.expires = jiffies + msecs_to_jiffies(1000);
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300209 add_timer(&ir->timer);
210 } else if (ir->rc5_gpio) {
211 /* set timer_end for code completion */
212 init_timer(&ir->timer_end);
Hermann Pitton91607232006-12-07 21:45:28 -0300213 ir->timer_end.function = ir_rc5_timer_end;
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300214 ir->timer_end.data = (unsigned long)ir;
215
216 init_timer(&ir->timer_keyup);
Hermann Pitton91607232006-12-07 21:45:28 -0300217 ir->timer_keyup.function = ir_rc5_timer_keyup;
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300218 ir->timer_keyup.data = (unsigned long)ir;
Hermann Pitton91607232006-12-07 21:45:28 -0300219 ir->shift_by = 1;
220 ir->start = 3;
221 ir->addr = 0x0;
222 ir->rc5_key_timeout = ir_rc5_key_timeout;
223 ir->rc5_remote_gap = ir_rc5_remote_gap;
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300224 }
225}
226
227static void bttv_ir_stop(struct bttv *btv)
228{
229 if (btv->remote->polling) {
230 del_timer_sync(&btv->remote->timer);
231 flush_scheduled_work();
232 }
233
234 if (btv->remote->rc5_gpio) {
235 u32 gpio;
236
237 del_timer_sync(&btv->remote->timer_end);
238 flush_scheduled_work();
239
240 gpio = bttv_gpio_read(&btv->c);
241 bttv_gpio_write(&btv->c, gpio & ~(1 << 4));
242 }
243}
244
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200245int bttv_input_init(struct bttv *btv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246{
Hermann Pitton91607232006-12-07 21:45:28 -0300247 struct card_ir *ir;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 IR_KEYTAB_TYPE *ir_codes = NULL;
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200249 struct input_dev *input_dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 int ir_type = IR_TYPE_OTHER;
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300251 int err = -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200253 if (!btv->has_remote)
254 return -ENODEV;
255
256 ir = kzalloc(sizeof(*ir),GFP_KERNEL);
Dmitry Torokhovb7df3912005-09-15 02:01:53 -0500257 input_dev = input_allocate_device();
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300258 if (!ir || !input_dev)
259 goto err_out_free;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260
261 /* detect & configure */
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200262 switch (btv->c.type) {
Mauro Carvalho Chehab5a25e842005-11-08 21:36:52 -0800263 case BTTV_BOARD_AVERMEDIA:
264 case BTTV_BOARD_AVPHONE98:
265 case BTTV_BOARD_AVERMEDIA98:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266 ir_codes = ir_codes_avermedia;
267 ir->mask_keycode = 0xf88000;
268 ir->mask_keydown = 0x010000;
269 ir->polling = 50; // ms
270 break;
271
Mauro Carvalho Chehab5a25e842005-11-08 21:36:52 -0800272 case BTTV_BOARD_AVDVBT_761:
273 case BTTV_BOARD_AVDVBT_771:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 ir_codes = ir_codes_avermedia_dvbt;
275 ir->mask_keycode = 0x0f00c0;
276 ir->mask_keydown = 0x000020;
277 ir->polling = 50; // ms
278 break;
279
Mauro Carvalho Chehab5a25e842005-11-08 21:36:52 -0800280 case BTTV_BOARD_PXELVWPLTVPAK:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 ir_codes = ir_codes_pixelview;
282 ir->mask_keycode = 0x003e00;
283 ir->mask_keyup = 0x010000;
284 ir->polling = 50; // ms
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -0800285 break;
Mauro Carvalho Chehabc6631552006-08-23 11:17:30 -0300286 case BTTV_BOARD_PV_M4900:
Mauro Carvalho Chehab5a25e842005-11-08 21:36:52 -0800287 case BTTV_BOARD_PV_BT878P_9B:
288 case BTTV_BOARD_PV_BT878P_PLUS:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 ir_codes = ir_codes_pixelview;
290 ir->mask_keycode = 0x001f00;
291 ir->mask_keyup = 0x008000;
292 ir->polling = 50; // ms
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -0800293 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294
Mauro Carvalho Chehab5a25e842005-11-08 21:36:52 -0800295 case BTTV_BOARD_WINFAST2000:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 ir_codes = ir_codes_winfast;
297 ir->mask_keycode = 0x1f8;
298 break;
Mauro Carvalho Chehab5a25e842005-11-08 21:36:52 -0800299 case BTTV_BOARD_MAGICTVIEW061:
300 case BTTV_BOARD_MAGICTVIEW063:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 ir_codes = ir_codes_winfast;
302 ir->mask_keycode = 0x0008e000;
303 ir->mask_keydown = 0x00200000;
304 break;
Mauro Carvalho Chehab5a25e842005-11-08 21:36:52 -0800305 case BTTV_BOARD_APAC_VIEWCOMP:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 ir_codes = ir_codes_apac_viewcomp;
307 ir->mask_keycode = 0x001f00;
308 ir->mask_keyup = 0x008000;
309 ir->polling = 50; // ms
310 break;
Mauro Carvalho Chehab5a25e842005-11-08 21:36:52 -0800311 case BTTV_BOARD_CONCEPTRONIC_CTVFMI2:
BoyZonder4ab2b99b2006-02-27 00:08:15 -0300312 case BTTV_BOARD_CONTVFMI:
Nickolay V. Shmyrevb639f9d2006-01-23 09:44:10 -0200313 ir_codes = ir_codes_pixelview;
Ricardo Cerqueiracc9d8d492005-11-08 21:36:20 -0800314 ir->mask_keycode = 0x001F00;
315 ir->mask_keyup = 0x006000;
316 ir->polling = 50; // ms
317 break;
Mark Weaver6c6c0b22005-11-13 16:07:52 -0800318 case BTTV_BOARD_NEBULA_DIGITV:
319 ir_codes = ir_codes_nebula;
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200320 btv->custom_irq = bttv_rc5_irq;
Mark Weaver6c6c0b22005-11-13 16:07:52 -0800321 ir->rc5_gpio = 1;
Mauro Carvalho Chehab674434c2005-12-12 00:37:28 -0800322 break;
Julian Calaby2d05ae62006-01-11 19:40:09 -0200323 case BTTV_BOARD_MACHTV_MAGICTV:
324 ir_codes = ir_codes_apac_viewcomp;
325 ir->mask_keycode = 0x001F00;
326 ir->mask_keyup = 0x004000;
327 ir->polling = 50; /* ms */
328 break;
Mauro Lacye80faad2008-04-22 14:45:58 -0300329 case BTTV_BOARD_KOZUMI_KTV_01C:
330 ir_codes = ir_codes_pctv_sedna;
331 ir->mask_keycode = 0x001f00;
332 ir->mask_keyup = 0x006000;
333 ir->polling = 50; /* ms */
334 break;
Mauro Carvalho Chehab7d341a62008-08-05 10:14:13 -0300335 case BTTV_BOARD_ENLTV_FM_2:
336 ir_codes = ir_codes_encore_enltv2;
337 ir->mask_keycode = 0x00fd00;
338 ir->mask_keyup = 0x000080;
339 ir->polling = 1; /* ms */
340 ir->last_gpio = ir_extract_bits(bttv_gpio_read(&btv->c),
341 ir->mask_keycode);
342 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 }
344 if (NULL == ir_codes) {
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300345 dprintk(KERN_INFO "Ooops: IR config error [card=%d]\n", btv->c.type);
346 err = -ENODEV;
347 goto err_out_free;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 }
349
Mark Weaver6c6c0b22005-11-13 16:07:52 -0800350 if (ir->rc5_gpio) {
351 u32 gpio;
Trent Piepho657de3c2006-06-20 00:30:57 -0300352 /* enable remote irq */
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200353 bttv_gpio_inout(&btv->c, (1 << 4), 1 << 4);
354 gpio = bttv_gpio_read(&btv->c);
355 bttv_gpio_write(&btv->c, gpio & ~(1 << 4));
356 bttv_gpio_write(&btv->c, gpio | (1 << 4));
Mark Weaver6c6c0b22005-11-13 16:07:52 -0800357 } else {
358 /* init hardware-specific stuff */
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200359 bttv_gpio_inout(&btv->c, ir->mask_keycode | ir->mask_keydown, 0);
Mark Weaver6c6c0b22005-11-13 16:07:52 -0800360 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361
362 /* init input device */
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200363 ir->dev = input_dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200365 snprintf(ir->name, sizeof(ir->name), "bttv IR (card=%d)",
366 btv->c.type);
367 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
368 pci_name(btv->c.pci));
369
Dmitry Torokhovb7df3912005-09-15 02:01:53 -0500370 ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
371 input_dev->name = ir->name;
372 input_dev->phys = ir->phys;
373 input_dev->id.bustype = BUS_PCI;
374 input_dev->id.version = 1;
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200375 if (btv->c.pci->subsystem_vendor) {
376 input_dev->id.vendor = btv->c.pci->subsystem_vendor;
377 input_dev->id.product = btv->c.pci->subsystem_device;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 } else {
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200379 input_dev->id.vendor = btv->c.pci->vendor;
380 input_dev->id.product = btv->c.pci->device;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381 }
Dmitry Torokhov2c8a3a32007-07-16 09:28:15 -0300382 input_dev->dev.parent = &btv->c.pci->dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200384 btv->remote = ir;
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300385 bttv_ir_start(btv, ir);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386
387 /* all done */
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300388 err = input_register_device(btv->remote->dev);
389 if (err)
390 goto err_out_stop;
Mark Weaver6c6c0b22005-11-13 16:07:52 -0800391
392 /* the remote isn't as bouncy as a keyboard */
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200393 ir->dev->rep[REP_DELAY] = repeat_delay;
394 ir->dev->rep[REP_PERIOD] = repeat_period;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395
396 return 0;
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300397
398 err_out_stop:
399 bttv_ir_stop(btv);
400 btv->remote = NULL;
401 err_out_free:
402 input_free_device(input_dev);
403 kfree(ir);
404 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405}
406
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200407void bttv_input_fini(struct bttv *btv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408{
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200409 if (btv->remote == NULL)
410 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300412 bttv_ir_stop(btv);
Ricardo Cerqueira4abdfed2006-01-09 15:25:25 -0200413 input_unregister_device(btv->remote->dev);
414 kfree(btv->remote);
415 btv->remote = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416}
417
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418
419/*
420 * Local variables:
421 * c-basic-offset: 8
422 * End:
423 */