~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/media/video/bt8xx/bttv-input.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <linux/delay.h>
24
24
#include <linux/interrupt.h>
25
25
#include <linux/input.h>
 
26
#include <linux/slab.h>
26
27
 
27
28
#include "bttv.h"
28
29
#include "bttvp.h"
30
31
 
31
32
static int ir_debug;
32
33
module_param(ir_debug, int, 0644);
33
 
static int repeat_delay = 500;
34
 
module_param(repeat_delay, int, 0644);
35
 
static int repeat_period = 33;
36
 
module_param(repeat_period, int, 0644);
37
34
 
38
35
static int ir_rc5_remote_gap = 885;
39
36
module_param(ir_rc5_remote_gap, int, 0644);
40
 
static int ir_rc5_key_timeout = 200;
41
 
module_param(ir_rc5_key_timeout, int, 0644);
42
37
 
43
38
#undef dprintk
44
39
#define dprintk(arg...) do {    \
48
43
 
49
44
#define DEVNAME "bttv-input"
50
45
 
 
46
#define MODULE_NAME "bttv"
 
47
 
51
48
/* ---------------------------------------------------------------------- */
52
49
 
53
50
static void ir_handle_key(struct bttv *btv)
54
51
{
55
 
        struct card_ir *ir = btv->remote;
 
52
        struct bttv_ir *ir = btv->remote;
56
53
        u32 gpio,data;
57
54
 
58
55
        /* read gpio value */
71
68
                (gpio & ir->mask_keydown) ? " down" : "",
72
69
                (gpio & ir->mask_keyup)   ? " up"   : "");
73
70
 
74
 
        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);
 
71
        if ((ir->mask_keydown && (gpio & ir->mask_keydown)) ||
 
72
            (ir->mask_keyup   && !(gpio & ir->mask_keyup))) {
 
73
                rc_keydown_notimeout(ir->dev, data, 0);
77
74
        } else {
78
75
                /* HACK: Probably, ir->mask_keydown is missing
79
76
                   for this board */
80
77
                if (btv->c.type == BTTV_BOARD_WINFAST2000)
81
 
                        ir_input_keydown(ir->dev, &ir->ir, data, data);
 
78
                        rc_keydown_notimeout(ir->dev, data, 0);
82
79
 
83
 
                ir_input_nokey(ir->dev,&ir->ir);
 
80
                rc_keyup(ir->dev);
84
81
        }
85
 
 
86
82
}
87
83
 
88
84
static void ir_enltv_handle_key(struct bttv *btv)
89
85
{
90
 
        struct card_ir *ir = btv->remote;
 
86
        struct bttv_ir *ir = btv->remote;
91
87
        u32 gpio, data, keyup;
92
88
 
93
89
        /* read gpio value */
104
100
                        gpio, data,
105
101
                        (gpio & ir->mask_keyup) ? " up" : "up/down");
106
102
 
107
 
                ir_input_keydown(ir->dev, &ir->ir, data, data);
 
103
                rc_keydown_notimeout(ir->dev, data, 0);
108
104
                if (keyup)
109
 
                        ir_input_nokey(ir->dev, &ir->ir);
 
105
                        rc_keyup(ir->dev);
110
106
        } else {
111
107
                if ((ir->last_gpio & 1 << 31) == keyup)
112
108
                        return;
116
112
                        (gpio & ir->mask_keyup) ? " up" : "down");
117
113
 
118
114
                if (keyup)
119
 
                        ir_input_nokey(ir->dev, &ir->ir);
 
115
                        rc_keyup(ir->dev);
120
116
                else
121
 
                        ir_input_keydown(ir->dev, &ir->ir, data, data);
 
117
                        rc_keydown_notimeout(ir->dev, data, 0);
122
118
        }
123
119
 
124
120
        ir->last_gpio = data | keyup;
125
121
}
126
122
 
 
123
static int bttv_rc5_irq(struct bttv *btv);
 
124
 
127
125
void bttv_input_irq(struct bttv *btv)
128
126
{
129
 
        struct card_ir *ir = btv->remote;
 
127
        struct bttv_ir *ir = btv->remote;
130
128
 
131
 
        if (!ir->polling)
 
129
        if (ir->rc5_gpio)
 
130
                bttv_rc5_irq(btv);
 
131
        else if (!ir->polling)
132
132
                ir_handle_key(btv);
133
133
}
134
134
 
135
135
static void bttv_input_timer(unsigned long data)
136
136
{
137
137
        struct bttv *btv = (struct bttv*)data;
138
 
        struct card_ir *ir = btv->remote;
 
138
        struct bttv_ir *ir = btv->remote;
139
139
 
140
140
        if (btv->c.type == BTTV_BOARD_ENLTV_FM_2)
141
141
                ir_enltv_handle_key(btv);
144
144
        mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling));
145
145
}
146
146
 
147
 
/* ---------------------------------------------------------------*/
 
147
/*
 
148
 * FIXME: Nebula digi uses the legacy way to decode RC5, instead of relying
 
149
 * on the rc-core way. As we need to be sure that both IRQ transitions are
 
150
 * properly triggered, Better to touch it only with this hardware for
 
151
 * testing.
 
152
 */
 
153
 
 
154
#define RC5_START(x)    (((x) >> 12) & 3)
 
155
#define RC5_TOGGLE(x)   (((x) >> 11) & 1)
 
156
#define RC5_ADDR(x)     (((x) >> 6) & 31)
 
157
#define RC5_INSTR(x)    ((x) & 63)
 
158
 
 
159
/* decode raw bit pattern to RC5 code */
 
160
static u32 bttv_rc5_decode(unsigned int code)
 
161
{
 
162
        unsigned int org_code = code;
 
163
        unsigned int pair;
 
164
        unsigned int rc5 = 0;
 
165
        int i;
 
166
 
 
167
        for (i = 0; i < 14; ++i) {
 
168
                pair = code & 0x3;
 
169
                code >>= 2;
 
170
 
 
171
                rc5 <<= 1;
 
172
                switch (pair) {
 
173
                case 0:
 
174
                case 2:
 
175
                        break;
 
176
                case 1:
 
177
                        rc5 |= 1;
 
178
                break;
 
179
                case 3:
 
180
                        dprintk(KERN_INFO DEVNAME ":rc5_decode(%x) bad code\n",
 
181
                                org_code);
 
182
                        return 0;
 
183
                }
 
184
        }
 
185
        dprintk(KERN_INFO DEVNAME ":"
 
186
                "code=%x, rc5=%x, start=%x, toggle=%x, address=%x, "
 
187
                "instr=%x\n", rc5, org_code, RC5_START(rc5),
 
188
                RC5_TOGGLE(rc5), RC5_ADDR(rc5), RC5_INSTR(rc5));
 
189
        return rc5;
 
190
}
 
191
 
 
192
static void bttv_rc5_timer_end(unsigned long data)
 
193
{
 
194
        struct bttv_ir *ir = (struct bttv_ir *)data;
 
195
        struct timeval tv;
 
196
        unsigned long current_jiffies;
 
197
        u32 gap;
 
198
        u32 rc5 = 0;
 
199
 
 
200
        /* get time */
 
201
        current_jiffies = jiffies;
 
202
        do_gettimeofday(&tv);
 
203
 
 
204
        /* avoid overflow with gap >1s */
 
205
        if (tv.tv_sec - ir->base_time.tv_sec > 1) {
 
206
                gap = 200000;
 
207
        } else {
 
208
                gap = 1000000 * (tv.tv_sec - ir->base_time.tv_sec) +
 
209
                    tv.tv_usec - ir->base_time.tv_usec;
 
210
        }
 
211
 
 
212
        /* signal we're ready to start a new code */
 
213
        ir->active = false;
 
214
 
 
215
        /* Allow some timer jitter (RC5 is ~24ms anyway so this is ok) */
 
216
        if (gap < 28000) {
 
217
                dprintk(KERN_INFO DEVNAME ": spurious timer_end\n");
 
218
                return;
 
219
        }
 
220
 
 
221
        if (ir->last_bit < 20) {
 
222
                /* ignore spurious codes (caused by light/other remotes) */
 
223
                dprintk(KERN_INFO DEVNAME ": short code: %x\n", ir->code);
 
224
        } else {
 
225
                ir->code = (ir->code << ir->shift_by) | 1;
 
226
                rc5 = bttv_rc5_decode(ir->code);
 
227
 
 
228
                /* two start bits? */
 
229
                if (RC5_START(rc5) != ir->start) {
 
230
                        printk(KERN_INFO DEVNAME ":"
 
231
                               " rc5 start bits invalid: %u\n", RC5_START(rc5));
 
232
 
 
233
                        /* right address? */
 
234
                } else if (RC5_ADDR(rc5) == ir->addr) {
 
235
                        u32 toggle = RC5_TOGGLE(rc5);
 
236
                        u32 instr = RC5_INSTR(rc5);
 
237
 
 
238
                        /* Good code */
 
239
                        rc_keydown(ir->dev, instr, toggle);
 
240
                        dprintk(KERN_INFO DEVNAME ":"
 
241
                                " instruction %x, toggle %x\n",
 
242
                                instr, toggle);
 
243
                }
 
244
        }
 
245
}
148
246
 
149
247
static int bttv_rc5_irq(struct bttv *btv)
150
248
{
151
 
        struct card_ir *ir = btv->remote;
 
249
        struct bttv_ir *ir = btv->remote;
152
250
        struct timeval tv;
153
251
        u32 gpio;
154
252
        u32 gap;
157
255
        /* read gpio port */
158
256
        gpio = bttv_gpio_read(&btv->c);
159
257
 
 
258
        /* get time of bit */
 
259
        current_jiffies = jiffies;
 
260
        do_gettimeofday(&tv);
 
261
 
 
262
        /* avoid overflow with gap >1s */
 
263
        if (tv.tv_sec - ir->base_time.tv_sec > 1) {
 
264
                gap = 200000;
 
265
        } else {
 
266
                gap = 1000000 * (tv.tv_sec - ir->base_time.tv_sec) +
 
267
                    tv.tv_usec - ir->base_time.tv_usec;
 
268
        }
 
269
 
 
270
        dprintk(KERN_INFO DEVNAME ": RC5 IRQ: gap %d us for %s\n",
 
271
                gap, (gpio & 0x20) ? "mark" : "space");
 
272
 
160
273
        /* remote IRQ? */
161
274
        if (!(gpio & 0x20))
162
275
                return 0;
163
276
 
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
277
        /* active code => add bit */
177
278
        if (ir->active) {
178
279
                /* only if in the code (otherwise spurious IRQ or timer
184
285
                }
185
286
                /* starting new code */
186
287
        } else {
187
 
                ir->active = 1;
 
288
                ir->active = true;
188
289
                ir->code = 0;
189
290
                ir->base_time = tv;
190
291
                ir->last_bit = 0;
191
292
 
192
 
                mod_timer(&ir->timer_end,
193
 
                          current_jiffies + msecs_to_jiffies(30));
 
293
                mod_timer(&ir->timer, current_jiffies + msecs_to_jiffies(30));
194
294
        }
195
295
 
196
296
        /* toggle GPIO pin 4 to reset the irq */
201
301
 
202
302
/* ---------------------------------------------------------------------- */
203
303
 
204
 
static void bttv_ir_start(struct bttv *btv, struct card_ir *ir)
 
304
static void bttv_ir_start(struct bttv *btv, struct bttv_ir *ir)
205
305
{
206
306
        if (ir->polling) {
207
307
                setup_timer(&ir->timer, bttv_input_timer, (unsigned long)btv);
209
309
                add_timer(&ir->timer);
210
310
        } else if (ir->rc5_gpio) {
211
311
                /* set timer_end for code completion */
212
 
                init_timer(&ir->timer_end);
213
 
                ir->timer_end.function = ir_rc5_timer_end;
214
 
                ir->timer_end.data = (unsigned long)ir;
215
 
 
216
 
                init_timer(&ir->timer_keyup);
217
 
                ir->timer_keyup.function = ir_rc5_timer_keyup;
218
 
                ir->timer_keyup.data = (unsigned long)ir;
 
312
                setup_timer(&ir->timer, bttv_rc5_timer_end, (unsigned long)ir);
219
313
                ir->shift_by = 1;
220
314
                ir->start = 3;
221
315
                ir->addr = 0x0;
222
 
                ir->rc5_key_timeout = ir_rc5_key_timeout;
223
316
                ir->rc5_remote_gap = ir_rc5_remote_gap;
224
317
        }
225
318
}
226
319
 
227
320
static void bttv_ir_stop(struct bttv *btv)
228
321
{
229
 
        if (btv->remote->polling) {
 
322
        if (btv->remote->polling)
230
323
                del_timer_sync(&btv->remote->timer);
231
 
                flush_scheduled_work();
232
 
        }
233
324
 
234
325
        if (btv->remote->rc5_gpio) {
235
326
                u32 gpio;
236
327
 
237
 
                del_timer_sync(&btv->remote->timer_end);
238
 
                flush_scheduled_work();
 
328
                del_timer_sync(&btv->remote->timer);
239
329
 
240
330
                gpio = bttv_gpio_read(&btv->c);
241
331
                bttv_gpio_write(&btv->c, gpio & ~(1 << 4));
242
332
        }
243
333
}
244
334
 
 
335
/*
 
336
 * Get_key functions used by I2C remotes
 
337
 */
 
338
 
 
339
static int get_key_pv951(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
 
340
{
 
341
        unsigned char b;
 
342
 
 
343
        /* poll IR chip */
 
344
        if (1 != i2c_master_recv(ir->c, &b, 1)) {
 
345
                dprintk(KERN_INFO DEVNAME ": read error\n");
 
346
                return -EIO;
 
347
        }
 
348
 
 
349
        /* ignore 0xaa */
 
350
        if (b==0xaa)
 
351
                return 0;
 
352
        dprintk(KERN_INFO DEVNAME ": key %02x\n", b);
 
353
 
 
354
        /*
 
355
         * NOTE:
 
356
         * lirc_i2c maps the pv951 code as:
 
357
         *      addr = 0x61D6
 
358
         *      cmd = bit_reverse (b)
 
359
         * So, it seems that this device uses NEC extended
 
360
         * I decided to not fix the table, due to two reasons:
 
361
         *      1) Without the actual device, this is only a guess;
 
362
         *      2) As the addr is not reported via I2C, nor can be changed,
 
363
         *         the device is bound to the vendor-provided RC.
 
364
         */
 
365
 
 
366
        *ir_key = b;
 
367
        *ir_raw = b;
 
368
        return 1;
 
369
}
 
370
 
 
371
/* Instantiate the I2C IR receiver device, if present */
 
372
void __devinit init_bttv_i2c_ir(struct bttv *btv)
 
373
{
 
374
        const unsigned short addr_list[] = {
 
375
                0x1a, 0x18, 0x64, 0x30, 0x71,
 
376
                I2C_CLIENT_END
 
377
        };
 
378
        struct i2c_board_info info;
 
379
 
 
380
        if (0 != btv->i2c_rc)
 
381
                return;
 
382
 
 
383
        memset(&info, 0, sizeof(struct i2c_board_info));
 
384
        memset(&btv->init_data, 0, sizeof(btv->init_data));
 
385
        strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
 
386
 
 
387
        switch (btv->c.type) {
 
388
        case BTTV_BOARD_PV951:
 
389
                btv->init_data.name = "PV951";
 
390
                btv->init_data.get_key = get_key_pv951;
 
391
                btv->init_data.ir_codes = RC_MAP_PV951;
 
392
                info.addr = 0x4b;
 
393
                break;
 
394
        default:
 
395
                /*
 
396
                 * The external IR receiver is at i2c address 0x34 (0x35 for
 
397
                 * reads).  Future Hauppauge cards will have an internal
 
398
                 * receiver at 0x30 (0x31 for reads).  In theory, both can be
 
399
                 * fitted, and Hauppauge suggest an external overrides an
 
400
                 * internal.
 
401
                 * That's why we probe 0x1a (~0x34) first. CB
 
402
                 */
 
403
 
 
404
                i2c_new_probed_device(&btv->c.i2c_adap, &info, addr_list, NULL);
 
405
                return;
 
406
        }
 
407
 
 
408
        if (btv->init_data.name)
 
409
                info.platform_data = &btv->init_data;
 
410
        i2c_new_device(&btv->c.i2c_adap, &info);
 
411
 
 
412
        return;
 
413
}
 
414
 
 
415
int __devexit fini_bttv_i2c(struct bttv *btv)
 
416
{
 
417
        if (0 != btv->i2c_rc)
 
418
                return 0;
 
419
 
 
420
        return i2c_del_adapter(&btv->c.i2c_adap);
 
421
}
 
422
 
245
423
int bttv_input_init(struct bttv *btv)
246
424
{
247
 
        struct card_ir *ir;
248
 
        struct ir_scancode_table *ir_codes = NULL;
249
 
        struct input_dev *input_dev;
250
 
        int ir_type = IR_TYPE_OTHER;
 
425
        struct bttv_ir *ir;
 
426
        char *ir_codes = NULL;
 
427
        struct rc_dev *rc;
251
428
        int err = -ENOMEM;
252
429
 
253
430
        if (!btv->has_remote)
254
431
                return -ENODEV;
255
432
 
256
433
        ir = kzalloc(sizeof(*ir),GFP_KERNEL);
257
 
        input_dev = input_allocate_device();
258
 
        if (!ir || !input_dev)
 
434
        rc = rc_allocate_device();
 
435
        if (!ir || !rc)
259
436
                goto err_out_free;
260
437
 
261
438
        /* detect & configure */
263
440
        case BTTV_BOARD_AVERMEDIA:
264
441
        case BTTV_BOARD_AVPHONE98:
265
442
        case BTTV_BOARD_AVERMEDIA98:
266
 
                ir_codes         = &ir_codes_avermedia_table;
 
443
                ir_codes         = RC_MAP_AVERMEDIA;
267
444
                ir->mask_keycode = 0xf88000;
268
445
                ir->mask_keydown = 0x010000;
269
446
                ir->polling      = 50; // ms
271
448
 
272
449
        case BTTV_BOARD_AVDVBT_761:
273
450
        case BTTV_BOARD_AVDVBT_771:
274
 
                ir_codes         = &ir_codes_avermedia_dvbt_table;
 
451
                ir_codes         = RC_MAP_AVERMEDIA_DVBT;
275
452
                ir->mask_keycode = 0x0f00c0;
276
453
                ir->mask_keydown = 0x000020;
277
454
                ir->polling      = 50; // ms
278
455
                break;
279
456
 
280
457
        case BTTV_BOARD_PXELVWPLTVPAK:
281
 
                ir_codes         = &ir_codes_pixelview_table;
 
458
                ir_codes         = RC_MAP_PIXELVIEW;
282
459
                ir->mask_keycode = 0x003e00;
283
460
                ir->mask_keyup   = 0x010000;
284
461
                ir->polling      = 50; // ms
286
463
        case BTTV_BOARD_PV_M4900:
287
464
        case BTTV_BOARD_PV_BT878P_9B:
288
465
        case BTTV_BOARD_PV_BT878P_PLUS:
289
 
                ir_codes         = &ir_codes_pixelview_table;
 
466
                ir_codes         = RC_MAP_PIXELVIEW;
290
467
                ir->mask_keycode = 0x001f00;
291
468
                ir->mask_keyup   = 0x008000;
292
469
                ir->polling      = 50; // ms
293
470
                break;
294
471
 
295
472
        case BTTV_BOARD_WINFAST2000:
296
 
                ir_codes         = &ir_codes_winfast_table;
 
473
                ir_codes         = RC_MAP_WINFAST;
297
474
                ir->mask_keycode = 0x1f8;
298
475
                break;
299
476
        case BTTV_BOARD_MAGICTVIEW061:
300
477
        case BTTV_BOARD_MAGICTVIEW063:
301
 
                ir_codes         = &ir_codes_winfast_table;
 
478
                ir_codes         = RC_MAP_WINFAST;
302
479
                ir->mask_keycode = 0x0008e000;
303
480
                ir->mask_keydown = 0x00200000;
304
481
                break;
305
482
        case BTTV_BOARD_APAC_VIEWCOMP:
306
 
                ir_codes         = &ir_codes_apac_viewcomp_table;
 
483
                ir_codes         = RC_MAP_APAC_VIEWCOMP;
307
484
                ir->mask_keycode = 0x001f00;
308
485
                ir->mask_keyup   = 0x008000;
309
486
                ir->polling      = 50; // ms
311
488
        case BTTV_BOARD_ASKEY_CPH03X:
312
489
        case BTTV_BOARD_CONCEPTRONIC_CTVFMI2:
313
490
        case BTTV_BOARD_CONTVFMI:
314
 
                ir_codes         = &ir_codes_pixelview_table;
 
491
                ir_codes         = RC_MAP_PIXELVIEW;
315
492
                ir->mask_keycode = 0x001F00;
316
493
                ir->mask_keyup   = 0x006000;
317
494
                ir->polling      = 50; // ms
318
495
                break;
319
496
        case BTTV_BOARD_NEBULA_DIGITV:
320
 
                ir_codes = &ir_codes_nebula_table;
321
 
                btv->custom_irq = bttv_rc5_irq;
322
 
                ir->rc5_gpio = 1;
 
497
                ir_codes = RC_MAP_NEBULA;
 
498
                ir->rc5_gpio = true;
323
499
                break;
324
500
        case BTTV_BOARD_MACHTV_MAGICTV:
325
 
                ir_codes         = &ir_codes_apac_viewcomp_table;
 
501
                ir_codes         = RC_MAP_APAC_VIEWCOMP;
326
502
                ir->mask_keycode = 0x001F00;
327
503
                ir->mask_keyup   = 0x004000;
328
504
                ir->polling      = 50; /* ms */
329
505
                break;
330
506
        case BTTV_BOARD_KOZUMI_KTV_01C:
331
 
                ir_codes         = &ir_codes_pctv_sedna_table;
 
507
                ir_codes         = RC_MAP_PCTV_SEDNA;
332
508
                ir->mask_keycode = 0x001f00;
333
509
                ir->mask_keyup   = 0x006000;
334
510
                ir->polling      = 50; /* ms */
335
511
                break;
336
512
        case BTTV_BOARD_ENLTV_FM_2:
337
 
                ir_codes         = &ir_codes_encore_enltv2_table;
 
513
                ir_codes         = RC_MAP_ENCORE_ENLTV2;
338
514
                ir->mask_keycode = 0x00fd00;
339
515
                ir->mask_keyup   = 0x000080;
340
516
                ir->polling      = 1; /* ms */
361
537
        }
362
538
 
363
539
        /* init input device */
364
 
        ir->dev = input_dev;
 
540
        ir->dev = rc;
365
541
 
366
542
        snprintf(ir->name, sizeof(ir->name), "bttv IR (card=%d)",
367
543
                 btv->c.type);
368
544
        snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
369
545
                 pci_name(btv->c.pci));
370
546
 
371
 
        ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
372
 
        input_dev->name = ir->name;
373
 
        input_dev->phys = ir->phys;
374
 
        input_dev->id.bustype = BUS_PCI;
375
 
        input_dev->id.version = 1;
 
547
        rc->input_name = ir->name;
 
548
        rc->input_phys = ir->phys;
 
549
        rc->input_id.bustype = BUS_PCI;
 
550
        rc->input_id.version = 1;
376
551
        if (btv->c.pci->subsystem_vendor) {
377
 
                input_dev->id.vendor  = btv->c.pci->subsystem_vendor;
378
 
                input_dev->id.product = btv->c.pci->subsystem_device;
 
552
                rc->input_id.vendor  = btv->c.pci->subsystem_vendor;
 
553
                rc->input_id.product = btv->c.pci->subsystem_device;
379
554
        } else {
380
 
                input_dev->id.vendor  = btv->c.pci->vendor;
381
 
                input_dev->id.product = btv->c.pci->device;
 
555
                rc->input_id.vendor  = btv->c.pci->vendor;
 
556
                rc->input_id.product = btv->c.pci->device;
382
557
        }
383
 
        input_dev->dev.parent = &btv->c.pci->dev;
 
558
        rc->dev.parent = &btv->c.pci->dev;
 
559
        rc->map_name = ir_codes;
 
560
        rc->driver_name = MODULE_NAME;
384
561
 
385
562
        btv->remote = ir;
386
563
        bttv_ir_start(btv, ir);
387
564
 
388
565
        /* all done */
389
 
        err = input_register_device(btv->remote->dev);
 
566
        err = rc_register_device(rc);
390
567
        if (err)
391
568
                goto err_out_stop;
392
569
 
393
 
        /* the remote isn't as bouncy as a keyboard */
394
 
        ir->dev->rep[REP_DELAY] = repeat_delay;
395
 
        ir->dev->rep[REP_PERIOD] = repeat_period;
396
 
 
397
570
        return 0;
398
571
 
399
572
 err_out_stop:
400
573
        bttv_ir_stop(btv);
401
574
        btv->remote = NULL;
402
575
 err_out_free:
403
 
        input_free_device(input_dev);
 
576
        rc_free_device(rc);
404
577
        kfree(ir);
405
578
        return err;
406
579
}
411
584
                return;
412
585
 
413
586
        bttv_ir_stop(btv);
414
 
        input_unregister_device(btv->remote->dev);
 
587
        rc_unregister_device(btv->remote->dev);
415
588
        kfree(btv->remote);
416
589
        btv->remote = NULL;
417
590
}
418
 
 
419
 
 
420
 
/*
421
 
 * Local variables:
422
 
 * c-basic-offset: 8
423
 
 * End:
424
 
 */