diff options
Diffstat (limited to 'drivers/media/video/cx88/cx88-input.c')
-rw-r--r-- | drivers/media/video/cx88/cx88-input.c | 282 |
1 files changed, 120 insertions, 162 deletions
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c index fc777bc6e716..06f7d1d00944 100644 --- a/drivers/media/video/cx88/cx88-input.c +++ b/drivers/media/video/cx88/cx88-input.c | |||
@@ -24,14 +24,12 @@ | |||
24 | 24 | ||
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/hrtimer.h> | 26 | #include <linux/hrtimer.h> |
27 | #include <linux/input.h> | ||
28 | #include <linux/pci.h> | 27 | #include <linux/pci.h> |
29 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
30 | #include <linux/module.h> | 29 | #include <linux/module.h> |
31 | 30 | ||
32 | #include "cx88.h" | 31 | #include "cx88.h" |
33 | #include <media/ir-core.h> | 32 | #include <media/rc-core.h> |
34 | #include <media/ir-common.h> | ||
35 | 33 | ||
36 | #define MODULE_NAME "cx88xx" | 34 | #define MODULE_NAME "cx88xx" |
37 | 35 | ||
@@ -39,9 +37,7 @@ | |||
39 | 37 | ||
40 | struct cx88_IR { | 38 | struct cx88_IR { |
41 | struct cx88_core *core; | 39 | struct cx88_core *core; |
42 | struct input_dev *input; | 40 | struct rc_dev *dev; |
43 | struct ir_dev_props props; | ||
44 | u64 ir_type; | ||
45 | 41 | ||
46 | int users; | 42 | int users; |
47 | 43 | ||
@@ -50,8 +46,6 @@ struct cx88_IR { | |||
50 | 46 | ||
51 | /* sample from gpio pin 16 */ | 47 | /* sample from gpio pin 16 */ |
52 | u32 sampling; | 48 | u32 sampling; |
53 | u32 samples[16]; | ||
54 | int scount; | ||
55 | 49 | ||
56 | /* poll external decoder */ | 50 | /* poll external decoder */ |
57 | int polling; | 51 | int polling; |
@@ -63,6 +57,10 @@ struct cx88_IR { | |||
63 | u32 mask_keyup; | 57 | u32 mask_keyup; |
64 | }; | 58 | }; |
65 | 59 | ||
60 | static unsigned ir_samplerate = 4; | ||
61 | module_param(ir_samplerate, uint, 0444); | ||
62 | MODULE_PARM_DESC(ir_samplerate, "IR samplerate in kHz, 1 - 20, default 4"); | ||
63 | |||
66 | static int ir_debug; | 64 | static int ir_debug; |
67 | module_param(ir_debug, int, 0644); /* debug level [IR] */ | 65 | module_param(ir_debug, int, 0644); /* debug level [IR] */ |
68 | MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); | 66 | MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); |
@@ -70,6 +68,9 @@ MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); | |||
70 | #define ir_dprintk(fmt, arg...) if (ir_debug) \ | 68 | #define ir_dprintk(fmt, arg...) if (ir_debug) \ |
71 | printk(KERN_DEBUG "%s IR: " fmt , ir->core->name , ##arg) | 69 | printk(KERN_DEBUG "%s IR: " fmt , ir->core->name , ##arg) |
72 | 70 | ||
71 | #define dprintk(fmt, arg...) if (ir_debug) \ | ||
72 | printk(KERN_DEBUG "cx88 IR: " fmt , ##arg) | ||
73 | |||
73 | /* ---------------------------------------------------------------------- */ | 74 | /* ---------------------------------------------------------------------- */ |
74 | 75 | ||
75 | static void cx88_ir_handle_key(struct cx88_IR *ir) | 76 | static void cx88_ir_handle_key(struct cx88_IR *ir) |
@@ -125,21 +126,26 @@ static void cx88_ir_handle_key(struct cx88_IR *ir) | |||
125 | 126 | ||
126 | data = (data << 4) | ((gpio_key & 0xf0) >> 4); | 127 | data = (data << 4) | ((gpio_key & 0xf0) >> 4); |
127 | 128 | ||
128 | ir_keydown(ir->input, data, 0); | 129 | rc_keydown(ir->dev, data, 0); |
129 | 130 | ||
130 | } else if (ir->mask_keydown) { | 131 | } else if (ir->mask_keydown) { |
131 | /* bit set on keydown */ | 132 | /* bit set on keydown */ |
132 | if (gpio & ir->mask_keydown) | 133 | if (gpio & ir->mask_keydown) |
133 | ir_keydown(ir->input, data, 0); | 134 | rc_keydown_notimeout(ir->dev, data, 0); |
135 | else | ||
136 | rc_keyup(ir->dev); | ||
134 | 137 | ||
135 | } else if (ir->mask_keyup) { | 138 | } else if (ir->mask_keyup) { |
136 | /* bit cleared on keydown */ | 139 | /* bit cleared on keydown */ |
137 | if (0 == (gpio & ir->mask_keyup)) | 140 | if (0 == (gpio & ir->mask_keyup)) |
138 | ir_keydown(ir->input, data, 0); | 141 | rc_keydown_notimeout(ir->dev, data, 0); |
142 | else | ||
143 | rc_keyup(ir->dev); | ||
139 | 144 | ||
140 | } else { | 145 | } else { |
141 | /* can't distinguish keydown/up :-/ */ | 146 | /* can't distinguish keydown/up :-/ */ |
142 | ir_keydown(ir->input, data, 0); | 147 | rc_keydown_notimeout(ir->dev, data, 0); |
148 | rc_keyup(ir->dev); | ||
143 | } | 149 | } |
144 | } | 150 | } |
145 | 151 | ||
@@ -176,8 +182,8 @@ static int __cx88_ir_start(void *priv) | |||
176 | } | 182 | } |
177 | if (ir->sampling) { | 183 | if (ir->sampling) { |
178 | core->pci_irqmask |= PCI_INT_IR_SMPINT; | 184 | core->pci_irqmask |= PCI_INT_IR_SMPINT; |
179 | cx_write(MO_DDS_IO, 0xa80a80); /* 4 kHz sample rate */ | 185 | cx_write(MO_DDS_IO, 0x33F286 * ir_samplerate); /* samplerate */ |
180 | cx_write(MO_DDSCFG_IO, 0x5); /* enable */ | 186 | cx_write(MO_DDSCFG_IO, 0x5); /* enable */ |
181 | } | 187 | } |
182 | return 0; | 188 | return 0; |
183 | } | 189 | } |
@@ -214,17 +220,17 @@ void cx88_ir_stop(struct cx88_core *core) | |||
214 | __cx88_ir_stop(core); | 220 | __cx88_ir_stop(core); |
215 | } | 221 | } |
216 | 222 | ||
217 | static int cx88_ir_open(void *priv) | 223 | static int cx88_ir_open(struct rc_dev *rc) |
218 | { | 224 | { |
219 | struct cx88_core *core = priv; | 225 | struct cx88_core *core = rc->priv; |
220 | 226 | ||
221 | core->ir->users++; | 227 | core->ir->users++; |
222 | return __cx88_ir_start(core); | 228 | return __cx88_ir_start(core); |
223 | } | 229 | } |
224 | 230 | ||
225 | static void cx88_ir_close(void *priv) | 231 | static void cx88_ir_close(struct rc_dev *rc) |
226 | { | 232 | { |
227 | struct cx88_core *core = priv; | 233 | struct cx88_core *core = rc->priv; |
228 | 234 | ||
229 | core->ir->users--; | 235 | core->ir->users--; |
230 | if (!core->ir->users) | 236 | if (!core->ir->users) |
@@ -236,20 +242,20 @@ static void cx88_ir_close(void *priv) | |||
236 | int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) | 242 | int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) |
237 | { | 243 | { |
238 | struct cx88_IR *ir; | 244 | struct cx88_IR *ir; |
239 | struct input_dev *input_dev; | 245 | struct rc_dev *dev; |
240 | char *ir_codes = NULL; | 246 | char *ir_codes = NULL; |
241 | u64 ir_type = IR_TYPE_OTHER; | 247 | u64 rc_type = RC_TYPE_OTHER; |
242 | int err = -ENOMEM; | 248 | int err = -ENOMEM; |
243 | u32 hardware_mask = 0; /* For devices with a hardware mask, when | 249 | u32 hardware_mask = 0; /* For devices with a hardware mask, when |
244 | * used with a full-code IR table | 250 | * used with a full-code IR table |
245 | */ | 251 | */ |
246 | 252 | ||
247 | ir = kzalloc(sizeof(*ir), GFP_KERNEL); | 253 | ir = kzalloc(sizeof(*ir), GFP_KERNEL); |
248 | input_dev = input_allocate_device(); | 254 | dev = rc_allocate_device(); |
249 | if (!ir || !input_dev) | 255 | if (!ir || !dev) |
250 | goto err_out_free; | 256 | goto err_out_free; |
251 | 257 | ||
252 | ir->input = input_dev; | 258 | ir->dev = dev; |
253 | 259 | ||
254 | /* detect & configure */ | 260 | /* detect & configure */ |
255 | switch (core->boardnr) { | 261 | switch (core->boardnr) { |
@@ -264,7 +270,6 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) | |||
264 | break; | 270 | break; |
265 | case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: | 271 | case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: |
266 | ir_codes = RC_MAP_CINERGY_1400; | 272 | ir_codes = RC_MAP_CINERGY_1400; |
267 | ir_type = IR_TYPE_NEC; | ||
268 | ir->sampling = 0xeb04; /* address */ | 273 | ir->sampling = 0xeb04; /* address */ |
269 | break; | 274 | break; |
270 | case CX88_BOARD_HAUPPAUGE: | 275 | case CX88_BOARD_HAUPPAUGE: |
@@ -279,7 +284,6 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) | |||
279 | case CX88_BOARD_PCHDTV_HD5500: | 284 | case CX88_BOARD_PCHDTV_HD5500: |
280 | case CX88_BOARD_HAUPPAUGE_IRONLY: | 285 | case CX88_BOARD_HAUPPAUGE_IRONLY: |
281 | ir_codes = RC_MAP_HAUPPAUGE_NEW; | 286 | ir_codes = RC_MAP_HAUPPAUGE_NEW; |
282 | ir_type = IR_TYPE_RC5; | ||
283 | ir->sampling = 1; | 287 | ir->sampling = 1; |
284 | break; | 288 | break; |
285 | case CX88_BOARD_WINFAST_DTV2000H: | 289 | case CX88_BOARD_WINFAST_DTV2000H: |
@@ -367,18 +371,15 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) | |||
367 | case CX88_BOARD_PROF_7301: | 371 | case CX88_BOARD_PROF_7301: |
368 | case CX88_BOARD_PROF_6200: | 372 | case CX88_BOARD_PROF_6200: |
369 | ir_codes = RC_MAP_TBS_NEC; | 373 | ir_codes = RC_MAP_TBS_NEC; |
370 | ir_type = IR_TYPE_NEC; | ||
371 | ir->sampling = 0xff00; /* address */ | 374 | ir->sampling = 0xff00; /* address */ |
372 | break; | 375 | break; |
373 | case CX88_BOARD_TEVII_S460: | 376 | case CX88_BOARD_TEVII_S460: |
374 | case CX88_BOARD_TEVII_S420: | 377 | case CX88_BOARD_TEVII_S420: |
375 | ir_codes = RC_MAP_TEVII_NEC; | 378 | ir_codes = RC_MAP_TEVII_NEC; |
376 | ir_type = IR_TYPE_NEC; | ||
377 | ir->sampling = 0xff00; /* address */ | 379 | ir->sampling = 0xff00; /* address */ |
378 | break; | 380 | break; |
379 | case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: | 381 | case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: |
380 | ir_codes = RC_MAP_DNTV_LIVE_DVBT_PRO; | 382 | ir_codes = RC_MAP_DNTV_LIVE_DVBT_PRO; |
381 | ir_type = IR_TYPE_NEC; | ||
382 | ir->sampling = 0xff00; /* address */ | 383 | ir->sampling = 0xff00; /* address */ |
383 | break; | 384 | break; |
384 | case CX88_BOARD_NORWOOD_MICRO: | 385 | case CX88_BOARD_NORWOOD_MICRO: |
@@ -396,7 +397,6 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) | |||
396 | break; | 397 | break; |
397 | case CX88_BOARD_PINNACLE_PCTV_HD_800i: | 398 | case CX88_BOARD_PINNACLE_PCTV_HD_800i: |
398 | ir_codes = RC_MAP_PINNACLE_PCTV_HD; | 399 | ir_codes = RC_MAP_PINNACLE_PCTV_HD; |
399 | ir_type = IR_TYPE_RC5; | ||
400 | ir->sampling = 1; | 400 | ir->sampling = 1; |
401 | break; | 401 | break; |
402 | case CX88_BOARD_POWERCOLOR_REAL_ANGEL: | 402 | case CX88_BOARD_POWERCOLOR_REAL_ANGEL: |
@@ -407,12 +407,12 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) | |||
407 | break; | 407 | break; |
408 | case CX88_BOARD_TWINHAN_VP1027_DVBS: | 408 | case CX88_BOARD_TWINHAN_VP1027_DVBS: |
409 | ir_codes = RC_MAP_TWINHAN_VP1027_DVBS; | 409 | ir_codes = RC_MAP_TWINHAN_VP1027_DVBS; |
410 | ir_type = IR_TYPE_NEC; | 410 | rc_type = RC_TYPE_NEC; |
411 | ir->sampling = 0xff00; /* address */ | 411 | ir->sampling = 0xff00; /* address */ |
412 | break; | 412 | break; |
413 | } | 413 | } |
414 | 414 | ||
415 | if (NULL == ir_codes) { | 415 | if (!ir_codes) { |
416 | err = -ENODEV; | 416 | err = -ENODEV; |
417 | goto err_out_free; | 417 | goto err_out_free; |
418 | } | 418 | } |
@@ -436,37 +436,45 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) | |||
436 | snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)", core->board.name); | 436 | snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)", core->board.name); |
437 | snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci)); | 437 | snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci)); |
438 | 438 | ||
439 | ir->ir_type = ir_type; | 439 | dev->input_name = ir->name; |
440 | 440 | dev->input_phys = ir->phys; | |
441 | input_dev->name = ir->name; | 441 | dev->input_id.bustype = BUS_PCI; |
442 | input_dev->phys = ir->phys; | 442 | dev->input_id.version = 1; |
443 | input_dev->id.bustype = BUS_PCI; | ||
444 | input_dev->id.version = 1; | ||
445 | if (pci->subsystem_vendor) { | 443 | if (pci->subsystem_vendor) { |
446 | input_dev->id.vendor = pci->subsystem_vendor; | 444 | dev->input_id.vendor = pci->subsystem_vendor; |
447 | input_dev->id.product = pci->subsystem_device; | 445 | dev->input_id.product = pci->subsystem_device; |
448 | } else { | 446 | } else { |
449 | input_dev->id.vendor = pci->vendor; | 447 | dev->input_id.vendor = pci->vendor; |
450 | input_dev->id.product = pci->device; | 448 | dev->input_id.product = pci->device; |
451 | } | 449 | } |
452 | input_dev->dev.parent = &pci->dev; | 450 | dev->dev.parent = &pci->dev; |
453 | /* record handles to ourself */ | 451 | dev->map_name = ir_codes; |
452 | dev->driver_name = MODULE_NAME; | ||
453 | dev->priv = core; | ||
454 | dev->open = cx88_ir_open; | ||
455 | dev->close = cx88_ir_close; | ||
456 | dev->scanmask = hardware_mask; | ||
457 | |||
458 | if (ir->sampling) { | ||
459 | dev->driver_type = RC_DRIVER_IR_RAW; | ||
460 | dev->timeout = 10 * 1000 * 1000; /* 10 ms */ | ||
461 | } else { | ||
462 | dev->driver_type = RC_DRIVER_SCANCODE; | ||
463 | dev->allowed_protos = rc_type; | ||
464 | } | ||
465 | |||
454 | ir->core = core; | 466 | ir->core = core; |
455 | core->ir = ir; | 467 | core->ir = ir; |
456 | 468 | ||
457 | ir->props.priv = core; | ||
458 | ir->props.open = cx88_ir_open; | ||
459 | ir->props.close = cx88_ir_close; | ||
460 | ir->props.scanmask = hardware_mask; | ||
461 | |||
462 | /* all done */ | 469 | /* all done */ |
463 | err = ir_input_register(ir->input, ir_codes, &ir->props, MODULE_NAME); | 470 | err = rc_register_device(dev); |
464 | if (err) | 471 | if (err) |
465 | goto err_out_free; | 472 | goto err_out_free; |
466 | 473 | ||
467 | return 0; | 474 | return 0; |
468 | 475 | ||
469 | err_out_free: | 476 | err_out_free: |
477 | rc_free_device(dev); | ||
470 | core->ir = NULL; | 478 | core->ir = NULL; |
471 | kfree(ir); | 479 | kfree(ir); |
472 | return err; | 480 | return err; |
@@ -481,7 +489,7 @@ int cx88_ir_fini(struct cx88_core *core) | |||
481 | return 0; | 489 | return 0; |
482 | 490 | ||
483 | cx88_ir_stop(core); | 491 | cx88_ir_stop(core); |
484 | ir_input_unregister(ir->input); | 492 | rc_unregister_device(ir->dev); |
485 | kfree(ir); | 493 | kfree(ir); |
486 | 494 | ||
487 | /* done */ | 495 | /* done */ |
@@ -494,135 +502,75 @@ int cx88_ir_fini(struct cx88_core *core) | |||
494 | void cx88_ir_irq(struct cx88_core *core) | 502 | void cx88_ir_irq(struct cx88_core *core) |
495 | { | 503 | { |
496 | struct cx88_IR *ir = core->ir; | 504 | struct cx88_IR *ir = core->ir; |
497 | u32 samples, ircode; | 505 | u32 samples; |
498 | int i, start, range, toggle, dev, code; | 506 | unsigned todo, bits; |
507 | struct ir_raw_event ev; | ||
499 | 508 | ||
500 | if (NULL == ir) | 509 | if (!ir || !ir->sampling) |
501 | return; | ||
502 | if (!ir->sampling) | ||
503 | return; | 510 | return; |
504 | 511 | ||
512 | /* | ||
513 | * Samples are stored in a 32 bit register, oldest sample in | ||
514 | * the msb. A set bit represents space and an unset bit | ||
515 | * represents a pulse. | ||
516 | */ | ||
505 | samples = cx_read(MO_SAMPLE_IO); | 517 | samples = cx_read(MO_SAMPLE_IO); |
506 | if (0 != samples && 0xffffffff != samples) { | ||
507 | /* record sample data */ | ||
508 | if (ir->scount < ARRAY_SIZE(ir->samples)) | ||
509 | ir->samples[ir->scount++] = samples; | ||
510 | return; | ||
511 | } | ||
512 | if (!ir->scount) { | ||
513 | /* nothing to sample */ | ||
514 | return; | ||
515 | } | ||
516 | |||
517 | /* have a complete sample */ | ||
518 | if (ir->scount < ARRAY_SIZE(ir->samples)) | ||
519 | ir->samples[ir->scount++] = samples; | ||
520 | for (i = 0; i < ir->scount; i++) | ||
521 | ir->samples[i] = ~ir->samples[i]; | ||
522 | if (ir_debug) | ||
523 | ir_dump_samples(ir->samples, ir->scount); | ||
524 | 518 | ||
525 | /* decode it */ | 519 | if (samples == 0xff && ir->dev->idle) |
526 | switch (core->boardnr) { | 520 | return; |
527 | case CX88_BOARD_TEVII_S460: | ||
528 | case CX88_BOARD_TEVII_S420: | ||
529 | case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: | ||
530 | case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: | ||
531 | case CX88_BOARD_OMICOM_SS4_PCI: | ||
532 | case CX88_BOARD_SATTRADE_ST4200: | ||
533 | case CX88_BOARD_TBS_8920: | ||
534 | case CX88_BOARD_TBS_8910: | ||
535 | case CX88_BOARD_PROF_7300: | ||
536 | case CX88_BOARD_PROF_7301: | ||
537 | case CX88_BOARD_PROF_6200: | ||
538 | case CX88_BOARD_TWINHAN_VP1027_DVBS: | ||
539 | ircode = ir_decode_pulsedistance(ir->samples, ir->scount, 1, 4); | ||
540 | |||
541 | if (ircode == 0xffffffff) { /* decoding error */ | ||
542 | ir_dprintk("pulse distance decoding error\n"); | ||
543 | break; | ||
544 | } | ||
545 | |||
546 | ir_dprintk("pulse distance decoded: %x\n", ircode); | ||
547 | 521 | ||
548 | if (ircode == 0) { /* key still pressed */ | 522 | init_ir_raw_event(&ev); |
549 | ir_dprintk("pulse distance decoded repeat code\n"); | 523 | for (todo = 32; todo > 0; todo -= bits) { |
550 | ir_repeat(ir->input); | 524 | ev.pulse = samples & 0x80000000 ? false : true; |
551 | break; | 525 | bits = min(todo, 32U - fls(ev.pulse ? samples : ~samples)); |
552 | } | 526 | ev.duration = (bits * NSEC_PER_SEC) / (1000 * ir_samplerate); |
527 | ir_raw_event_store_with_filter(ir->dev, &ev); | ||
528 | samples <<= bits; | ||
529 | } | ||
530 | ir_raw_event_handle(ir->dev); | ||
531 | } | ||
553 | 532 | ||
554 | if ((ircode & 0xffff) != (ir->sampling & 0xffff)) { /* wrong address */ | 533 | static int get_key_pvr2000(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) |
555 | ir_dprintk("pulse distance decoded wrong address\n"); | 534 | { |
556 | break; | 535 | int flags, code; |
557 | } | ||
558 | 536 | ||
559 | if (((~ircode >> 24) & 0xff) != ((ircode >> 16) & 0xff)) { /* wrong checksum */ | 537 | /* poll IR chip */ |
560 | ir_dprintk("pulse distance decoded wrong check sum\n"); | 538 | flags = i2c_smbus_read_byte_data(ir->c, 0x10); |
561 | break; | 539 | if (flags < 0) { |
562 | } | 540 | dprintk("read error\n"); |
541 | return 0; | ||
542 | } | ||
543 | /* key pressed ? */ | ||
544 | if (0 == (flags & 0x80)) | ||
545 | return 0; | ||
563 | 546 | ||
564 | ir_dprintk("Key Code: %x\n", (ircode >> 16) & 0xff); | 547 | /* read actual key code */ |
565 | ir_keydown(ir->input, (ircode >> 16) & 0xff, 0); | 548 | code = i2c_smbus_read_byte_data(ir->c, 0x00); |
566 | break; | 549 | if (code < 0) { |
567 | case CX88_BOARD_HAUPPAUGE: | 550 | dprintk("read error\n"); |
568 | case CX88_BOARD_HAUPPAUGE_DVB_T1: | 551 | return 0; |
569 | case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: | ||
570 | case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: | ||
571 | case CX88_BOARD_HAUPPAUGE_HVR1100: | ||
572 | case CX88_BOARD_HAUPPAUGE_HVR3000: | ||
573 | case CX88_BOARD_HAUPPAUGE_HVR4000: | ||
574 | case CX88_BOARD_HAUPPAUGE_HVR4000LITE: | ||
575 | case CX88_BOARD_PCHDTV_HD3000: | ||
576 | case CX88_BOARD_PCHDTV_HD5500: | ||
577 | case CX88_BOARD_HAUPPAUGE_IRONLY: | ||
578 | ircode = ir_decode_biphase(ir->samples, ir->scount, 5, 7); | ||
579 | ir_dprintk("biphase decoded: %x\n", ircode); | ||
580 | /* | ||
581 | * RC5 has an extension bit which adds a new range | ||
582 | * of available codes, this is detected here. Also | ||
583 | * hauppauge remotes (black/silver) always use | ||
584 | * specific device ids. If we do not filter the | ||
585 | * device ids then messages destined for devices | ||
586 | * such as TVs (id=0) will get through to the | ||
587 | * device causing mis-fired events. | ||
588 | */ | ||
589 | /* split rc5 data block ... */ | ||
590 | start = (ircode & 0x2000) >> 13; | ||
591 | range = (ircode & 0x1000) >> 12; | ||
592 | toggle= (ircode & 0x0800) >> 11; | ||
593 | dev = (ircode & 0x07c0) >> 6; | ||
594 | code = (ircode & 0x003f) | ((range << 6) ^ 0x0040); | ||
595 | if( start != 1) | ||
596 | /* no key pressed */ | ||
597 | break; | ||
598 | if ( dev != 0x1e && dev != 0x1f ) | ||
599 | /* not a hauppauge remote */ | ||
600 | break; | ||
601 | ir_keydown(ir->input, code, toggle); | ||
602 | break; | ||
603 | case CX88_BOARD_PINNACLE_PCTV_HD_800i: | ||
604 | ircode = ir_decode_biphase(ir->samples, ir->scount, 5, 7); | ||
605 | ir_dprintk("biphase decoded: %x\n", ircode); | ||
606 | if ((ircode & 0xfffff000) != 0x3000) | ||
607 | break; | ||
608 | /* Note: bit 0x800 being the toggle is assumed, not checked | ||
609 | with real hardware */ | ||
610 | ir_keydown(ir->input, ircode & 0x3f, ircode & 0x0800 ? 1 : 0); | ||
611 | break; | ||
612 | } | 552 | } |
613 | 553 | ||
614 | ir->scount = 0; | 554 | dprintk("IR Key/Flags: (0x%02x/0x%02x)\n", |
615 | return; | 555 | code & 0xff, flags & 0xff); |
616 | } | ||
617 | 556 | ||
557 | *ir_key = code & 0xff; | ||
558 | *ir_raw = code; | ||
559 | return 1; | ||
560 | } | ||
618 | 561 | ||
619 | void cx88_i2c_init_ir(struct cx88_core *core) | 562 | void cx88_i2c_init_ir(struct cx88_core *core) |
620 | { | 563 | { |
621 | struct i2c_board_info info; | 564 | struct i2c_board_info info; |
622 | const unsigned short addr_list[] = { | 565 | const unsigned short default_addr_list[] = { |
623 | 0x18, 0x6b, 0x71, | 566 | 0x18, 0x6b, 0x71, |
624 | I2C_CLIENT_END | 567 | I2C_CLIENT_END |
625 | }; | 568 | }; |
569 | const unsigned short pvr2000_addr_list[] = { | ||
570 | 0x18, 0x1a, | ||
571 | I2C_CLIENT_END | ||
572 | }; | ||
573 | const unsigned short *addr_list = default_addr_list; | ||
626 | const unsigned short *addrp; | 574 | const unsigned short *addrp; |
627 | /* Instantiate the IR receiver device, if present */ | 575 | /* Instantiate the IR receiver device, if present */ |
628 | if (0 != core->i2c_rc) | 576 | if (0 != core->i2c_rc) |
@@ -631,6 +579,16 @@ void cx88_i2c_init_ir(struct cx88_core *core) | |||
631 | memset(&info, 0, sizeof(struct i2c_board_info)); | 579 | memset(&info, 0, sizeof(struct i2c_board_info)); |
632 | strlcpy(info.type, "ir_video", I2C_NAME_SIZE); | 580 | strlcpy(info.type, "ir_video", I2C_NAME_SIZE); |
633 | 581 | ||
582 | switch (core->boardnr) { | ||
583 | case CX88_BOARD_LEADTEK_PVR2000: | ||
584 | addr_list = pvr2000_addr_list; | ||
585 | core->init_data.name = "cx88 Leadtek PVR 2000 remote"; | ||
586 | core->init_data.type = RC_TYPE_UNKNOWN; | ||
587 | core->init_data.get_key = get_key_pvr2000; | ||
588 | core->init_data.ir_codes = RC_MAP_EMPTY; | ||
589 | break; | ||
590 | } | ||
591 | |||
634 | /* | 592 | /* |
635 | * We can't call i2c_new_probed_device() because it uses | 593 | * We can't call i2c_new_probed_device() because it uses |
636 | * quick writes for probing and at least some RC receiver | 594 | * quick writes for probing and at least some RC receiver |
@@ -646,7 +604,7 @@ void cx88_i2c_init_ir(struct cx88_core *core) | |||
646 | /* Hauppauge XVR */ | 604 | /* Hauppauge XVR */ |
647 | core->init_data.name = "cx88 Hauppauge XVR remote"; | 605 | core->init_data.name = "cx88 Hauppauge XVR remote"; |
648 | core->init_data.ir_codes = RC_MAP_HAUPPAUGE_NEW; | 606 | core->init_data.ir_codes = RC_MAP_HAUPPAUGE_NEW; |
649 | core->init_data.type = IR_TYPE_RC5; | 607 | core->init_data.type = RC_TYPE_RC5; |
650 | core->init_data.internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; | 608 | core->init_data.internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; |
651 | 609 | ||
652 | info.platform_data = &core->init_data; | 610 | info.platform_data = &core->init_data; |