diff options
Diffstat (limited to 'drivers/media/video/saa7134/saa7134-input.c')
-rw-r--r-- | drivers/media/video/saa7134/saa7134-input.c | 283 |
1 files changed, 230 insertions, 53 deletions
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c index 58a0cdc8414a..e5565e2fd426 100644 --- a/drivers/media/video/saa7134/saa7134-input.c +++ b/drivers/media/video/saa7134/saa7134-input.c | |||
@@ -28,6 +28,8 @@ | |||
28 | #include "saa7134-reg.h" | 28 | #include "saa7134-reg.h" |
29 | #include "saa7134.h" | 29 | #include "saa7134.h" |
30 | 30 | ||
31 | #define MODULE_NAME "saa7134" | ||
32 | |||
31 | static unsigned int disable_ir; | 33 | static unsigned int disable_ir; |
32 | module_param(disable_ir, int, 0444); | 34 | module_param(disable_ir, int, 0444); |
33 | MODULE_PARM_DESC(disable_ir,"disable infrared remote support"); | 35 | MODULE_PARM_DESC(disable_ir,"disable infrared remote support"); |
@@ -66,6 +68,7 @@ MODULE_PARM_DESC(disable_other_ir, "disable full codes of " | |||
66 | /* Helper functions for RC5 and NEC decoding at GPIO16 or GPIO18 */ | 68 | /* Helper functions for RC5 and NEC decoding at GPIO16 or GPIO18 */ |
67 | static int saa7134_rc5_irq(struct saa7134_dev *dev); | 69 | static int saa7134_rc5_irq(struct saa7134_dev *dev); |
68 | static int saa7134_nec_irq(struct saa7134_dev *dev); | 70 | static int saa7134_nec_irq(struct saa7134_dev *dev); |
71 | static int saa7134_raw_decode_irq(struct saa7134_dev *dev); | ||
69 | static void nec_task(unsigned long data); | 72 | static void nec_task(unsigned long data); |
70 | static void saa7134_nec_timer(unsigned long data); | 73 | static void saa7134_nec_timer(unsigned long data); |
71 | 74 | ||
@@ -397,14 +400,23 @@ static int get_key_pinnacle_color(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | |||
397 | 400 | ||
398 | void saa7134_input_irq(struct saa7134_dev *dev) | 401 | void saa7134_input_irq(struct saa7134_dev *dev) |
399 | { | 402 | { |
400 | struct card_ir *ir = dev->remote; | 403 | struct card_ir *ir; |
404 | |||
405 | if (!dev || !dev->remote) | ||
406 | return; | ||
407 | |||
408 | ir = dev->remote; | ||
409 | if (!ir->running) | ||
410 | return; | ||
401 | 411 | ||
402 | if (ir->nec_gpio) { | 412 | if (ir->nec_gpio) { |
403 | saa7134_nec_irq(dev); | 413 | saa7134_nec_irq(dev); |
404 | } else if (!ir->polling && !ir->rc5_gpio) { | 414 | } else if (!ir->polling && !ir->rc5_gpio && !ir->raw_decode) { |
405 | build_key(dev); | 415 | build_key(dev); |
406 | } else if (ir->rc5_gpio) { | 416 | } else if (ir->rc5_gpio) { |
407 | saa7134_rc5_irq(dev); | 417 | saa7134_rc5_irq(dev); |
418 | } else if (ir->raw_decode) { | ||
419 | saa7134_raw_decode_irq(dev); | ||
408 | } | 420 | } |
409 | } | 421 | } |
410 | 422 | ||
@@ -417,8 +429,32 @@ static void saa7134_input_timer(unsigned long data) | |||
417 | mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling)); | 429 | mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling)); |
418 | } | 430 | } |
419 | 431 | ||
420 | void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir) | 432 | void ir_raw_decode_timer_end(unsigned long data) |
433 | { | ||
434 | struct saa7134_dev *dev = (struct saa7134_dev *)data; | ||
435 | struct card_ir *ir = dev->remote; | ||
436 | |||
437 | ir_raw_event_handle(dev->remote->dev); | ||
438 | |||
439 | ir->active = 0; | ||
440 | } | ||
441 | |||
442 | static int __saa7134_ir_start(void *priv) | ||
421 | { | 443 | { |
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 | |||
454 | if (ir->running) | ||
455 | return 0; | ||
456 | |||
457 | ir->running = 1; | ||
422 | if (ir->polling) { | 458 | if (ir->polling) { |
423 | setup_timer(&ir->timer, saa7134_input_timer, | 459 | setup_timer(&ir->timer, saa7134_input_timer, |
424 | (unsigned long)dev); | 460 | (unsigned long)dev); |
@@ -441,26 +477,125 @@ void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir) | |||
441 | setup_timer(&ir->timer_keyup, saa7134_nec_timer, | 477 | setup_timer(&ir->timer_keyup, saa7134_nec_timer, |
442 | (unsigned long)dev); | 478 | (unsigned long)dev); |
443 | tasklet_init(&ir->tlet, nec_task, (unsigned long)dev); | 479 | tasklet_init(&ir->tlet, nec_task, (unsigned long)dev); |
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; | ||
485 | ir->active = 0; | ||
444 | } | 486 | } |
487 | |||
488 | return 0; | ||
445 | } | 489 | } |
446 | 490 | ||
447 | void saa7134_ir_stop(struct saa7134_dev *dev) | 491 | static void __saa7134_ir_stop(void *priv) |
448 | { | 492 | { |
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; | ||
502 | |||
503 | if (!ir->running) | ||
504 | return; | ||
449 | if (dev->remote->polling) | 505 | if (dev->remote->polling) |
450 | del_timer_sync(&dev->remote->timer); | 506 | del_timer_sync(&dev->remote->timer); |
507 | else if (ir->rc5_gpio) | ||
508 | del_timer_sync(&ir->timer_end); | ||
509 | else if (ir->nec_gpio) | ||
510 | tasklet_kill(&ir->tlet); | ||
511 | else if (ir->raw_decode) { | ||
512 | del_timer_sync(&ir->timer_end); | ||
513 | ir->active = 0; | ||
514 | } | ||
515 | |||
516 | ir->running = 0; | ||
517 | |||
518 | return; | ||
519 | } | ||
520 | |||
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 | |||
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; | ||
577 | saa7134_ir_start(dev); | ||
578 | } else { | ||
579 | ir->nec_gpio = nec_gpio; | ||
580 | ir->rc5_gpio = rc5_gpio; | ||
581 | } | ||
582 | |||
583 | return 0; | ||
451 | } | 584 | } |
452 | 585 | ||
453 | int saa7134_input_init1(struct saa7134_dev *dev) | 586 | int saa7134_input_init1(struct saa7134_dev *dev) |
454 | { | 587 | { |
455 | struct card_ir *ir; | 588 | struct card_ir *ir; |
456 | struct input_dev *input_dev; | 589 | struct input_dev *input_dev; |
457 | struct ir_scancode_table *ir_codes = NULL; | 590 | char *ir_codes = NULL; |
458 | u32 mask_keycode = 0; | 591 | u32 mask_keycode = 0; |
459 | u32 mask_keydown = 0; | 592 | u32 mask_keydown = 0; |
460 | u32 mask_keyup = 0; | 593 | u32 mask_keyup = 0; |
461 | int polling = 0; | 594 | int polling = 0; |
462 | int rc5_gpio = 0; | 595 | int rc5_gpio = 0; |
463 | int nec_gpio = 0; | 596 | int nec_gpio = 0; |
597 | int raw_decode = 0; | ||
598 | int allow_protocol_change = 0; | ||
464 | u64 ir_type = IR_TYPE_OTHER; | 599 | u64 ir_type = IR_TYPE_OTHER; |
465 | int err; | 600 | int err; |
466 | 601 | ||
@@ -476,27 +611,27 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
476 | case SAA7134_BOARD_FLYTVPLATINUM_FM: | 611 | case SAA7134_BOARD_FLYTVPLATINUM_FM: |
477 | case SAA7134_BOARD_FLYTVPLATINUM_MINI2: | 612 | case SAA7134_BOARD_FLYTVPLATINUM_MINI2: |
478 | case SAA7134_BOARD_ROVERMEDIA_LINK_PRO_FM: | 613 | case SAA7134_BOARD_ROVERMEDIA_LINK_PRO_FM: |
479 | ir_codes = &ir_codes_flyvideo_table; | 614 | ir_codes = RC_MAP_FLYVIDEO; |
480 | mask_keycode = 0xEC00000; | 615 | mask_keycode = 0xEC00000; |
481 | mask_keydown = 0x0040000; | 616 | mask_keydown = 0x0040000; |
482 | break; | 617 | break; |
483 | case SAA7134_BOARD_CINERGY400: | 618 | case SAA7134_BOARD_CINERGY400: |
484 | case SAA7134_BOARD_CINERGY600: | 619 | case SAA7134_BOARD_CINERGY600: |
485 | case SAA7134_BOARD_CINERGY600_MK3: | 620 | case SAA7134_BOARD_CINERGY600_MK3: |
486 | ir_codes = &ir_codes_cinergy_table; | 621 | ir_codes = RC_MAP_CINERGY; |
487 | mask_keycode = 0x00003f; | 622 | mask_keycode = 0x00003f; |
488 | mask_keyup = 0x040000; | 623 | mask_keyup = 0x040000; |
489 | break; | 624 | break; |
490 | case SAA7134_BOARD_ECS_TVP3XP: | 625 | case SAA7134_BOARD_ECS_TVP3XP: |
491 | case SAA7134_BOARD_ECS_TVP3XP_4CB5: | 626 | case SAA7134_BOARD_ECS_TVP3XP_4CB5: |
492 | ir_codes = &ir_codes_eztv_table; | 627 | ir_codes = RC_MAP_EZTV; |
493 | mask_keycode = 0x00017c; | 628 | mask_keycode = 0x00017c; |
494 | mask_keyup = 0x000002; | 629 | mask_keyup = 0x000002; |
495 | polling = 50; // ms | 630 | polling = 50; // ms |
496 | break; | 631 | break; |
497 | case SAA7134_BOARD_KWORLD_XPERT: | 632 | case SAA7134_BOARD_KWORLD_XPERT: |
498 | case SAA7134_BOARD_AVACSSMARTTV: | 633 | case SAA7134_BOARD_AVACSSMARTTV: |
499 | ir_codes = &ir_codes_pixelview_table; | 634 | ir_codes = RC_MAP_PIXELVIEW; |
500 | mask_keycode = 0x00001F; | 635 | mask_keycode = 0x00001F; |
501 | mask_keyup = 0x000020; | 636 | mask_keyup = 0x000020; |
502 | polling = 50; // ms | 637 | polling = 50; // ms |
@@ -513,7 +648,7 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
513 | case SAA7134_BOARD_AVERMEDIA_GO_007_FM: | 648 | case SAA7134_BOARD_AVERMEDIA_GO_007_FM: |
514 | case SAA7134_BOARD_AVERMEDIA_M102: | 649 | case SAA7134_BOARD_AVERMEDIA_M102: |
515 | case SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS: | 650 | case SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS: |
516 | ir_codes = &ir_codes_avermedia_table; | 651 | ir_codes = RC_MAP_AVERMEDIA; |
517 | mask_keycode = 0x0007C8; | 652 | mask_keycode = 0x0007C8; |
518 | mask_keydown = 0x000010; | 653 | mask_keydown = 0x000010; |
519 | polling = 50; // ms | 654 | polling = 50; // ms |
@@ -522,14 +657,15 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
522 | saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4); | 657 | saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4); |
523 | break; | 658 | break; |
524 | case SAA7134_BOARD_AVERMEDIA_M135A: | 659 | case SAA7134_BOARD_AVERMEDIA_M135A: |
525 | ir_codes = &ir_codes_avermedia_m135a_table; | 660 | ir_codes = RC_MAP_AVERMEDIA_M135A_RM_JX; |
526 | mask_keydown = 0x0040000; | 661 | mask_keydown = 0x0040000; /* Enable GPIO18 line on both edges */ |
527 | mask_keycode = 0x00013f; | 662 | mask_keyup = 0x0040000; |
528 | nec_gpio = 1; | 663 | mask_keycode = 0xffff; |
664 | raw_decode = 1; | ||
529 | break; | 665 | break; |
530 | case SAA7134_BOARD_AVERMEDIA_777: | 666 | case SAA7134_BOARD_AVERMEDIA_777: |
531 | case SAA7134_BOARD_AVERMEDIA_A16AR: | 667 | case SAA7134_BOARD_AVERMEDIA_A16AR: |
532 | ir_codes = &ir_codes_avermedia_table; | 668 | ir_codes = RC_MAP_AVERMEDIA; |
533 | mask_keycode = 0x02F200; | 669 | mask_keycode = 0x02F200; |
534 | mask_keydown = 0x000400; | 670 | mask_keydown = 0x000400; |
535 | polling = 50; // ms | 671 | polling = 50; // ms |
@@ -538,7 +674,7 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
538 | saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1); | 674 | saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1); |
539 | break; | 675 | break; |
540 | case SAA7134_BOARD_AVERMEDIA_A16D: | 676 | case SAA7134_BOARD_AVERMEDIA_A16D: |
541 | ir_codes = &ir_codes_avermedia_a16d_table; | 677 | ir_codes = RC_MAP_AVERMEDIA_A16D; |
542 | mask_keycode = 0x02F200; | 678 | mask_keycode = 0x02F200; |
543 | mask_keydown = 0x000400; | 679 | mask_keydown = 0x000400; |
544 | polling = 50; /* ms */ | 680 | polling = 50; /* ms */ |
@@ -547,14 +683,14 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
547 | saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1); | 683 | saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1); |
548 | break; | 684 | break; |
549 | case SAA7134_BOARD_KWORLD_TERMINATOR: | 685 | case SAA7134_BOARD_KWORLD_TERMINATOR: |
550 | ir_codes = &ir_codes_pixelview_table; | 686 | ir_codes = RC_MAP_PIXELVIEW; |
551 | mask_keycode = 0x00001f; | 687 | mask_keycode = 0x00001f; |
552 | mask_keyup = 0x000060; | 688 | mask_keyup = 0x000060; |
553 | polling = 50; // ms | 689 | polling = 50; // ms |
554 | break; | 690 | break; |
555 | case SAA7134_BOARD_MANLI_MTV001: | 691 | case SAA7134_BOARD_MANLI_MTV001: |
556 | case SAA7134_BOARD_MANLI_MTV002: | 692 | case SAA7134_BOARD_MANLI_MTV002: |
557 | ir_codes = &ir_codes_manli_table; | 693 | ir_codes = RC_MAP_MANLI; |
558 | mask_keycode = 0x001f00; | 694 | mask_keycode = 0x001f00; |
559 | mask_keyup = 0x004000; | 695 | mask_keyup = 0x004000; |
560 | polling = 50; /* ms */ | 696 | polling = 50; /* ms */ |
@@ -574,25 +710,25 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
574 | case SAA7134_BOARD_BEHOLD_507_9FM: | 710 | case SAA7134_BOARD_BEHOLD_507_9FM: |
575 | case SAA7134_BOARD_BEHOLD_507RDS_MK3: | 711 | case SAA7134_BOARD_BEHOLD_507RDS_MK3: |
576 | case SAA7134_BOARD_BEHOLD_507RDS_MK5: | 712 | case SAA7134_BOARD_BEHOLD_507RDS_MK5: |
577 | ir_codes = &ir_codes_manli_table; | 713 | ir_codes = RC_MAP_MANLI; |
578 | mask_keycode = 0x003f00; | 714 | mask_keycode = 0x003f00; |
579 | mask_keyup = 0x004000; | 715 | mask_keyup = 0x004000; |
580 | polling = 50; /* ms */ | 716 | polling = 50; /* ms */ |
581 | break; | 717 | break; |
582 | case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM: | 718 | case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM: |
583 | ir_codes = &ir_codes_behold_columbus_table; | 719 | ir_codes = RC_MAP_BEHOLD_COLUMBUS; |
584 | mask_keycode = 0x003f00; | 720 | mask_keycode = 0x003f00; |
585 | mask_keyup = 0x004000; | 721 | mask_keyup = 0x004000; |
586 | polling = 50; // ms | 722 | polling = 50; // ms |
587 | break; | 723 | break; |
588 | case SAA7134_BOARD_SEDNA_PC_TV_CARDBUS: | 724 | case SAA7134_BOARD_SEDNA_PC_TV_CARDBUS: |
589 | ir_codes = &ir_codes_pctv_sedna_table; | 725 | ir_codes = RC_MAP_PCTV_SEDNA; |
590 | mask_keycode = 0x001f00; | 726 | mask_keycode = 0x001f00; |
591 | mask_keyup = 0x004000; | 727 | mask_keyup = 0x004000; |
592 | polling = 50; // ms | 728 | polling = 50; // ms |
593 | break; | 729 | break; |
594 | case SAA7134_BOARD_GOTVIEW_7135: | 730 | case SAA7134_BOARD_GOTVIEW_7135: |
595 | ir_codes = &ir_codes_gotview7135_table; | 731 | ir_codes = RC_MAP_GOTVIEW7135; |
596 | mask_keycode = 0x0003CC; | 732 | mask_keycode = 0x0003CC; |
597 | mask_keydown = 0x000010; | 733 | mask_keydown = 0x000010; |
598 | polling = 5; /* ms */ | 734 | polling = 5; /* ms */ |
@@ -601,80 +737,80 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
601 | case SAA7134_BOARD_VIDEOMATE_TV_PVR: | 737 | case SAA7134_BOARD_VIDEOMATE_TV_PVR: |
602 | case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS: | 738 | case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS: |
603 | case SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII: | 739 | case SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII: |
604 | ir_codes = &ir_codes_videomate_tv_pvr_table; | 740 | ir_codes = RC_MAP_VIDEOMATE_TV_PVR; |
605 | mask_keycode = 0x00003F; | 741 | mask_keycode = 0x00003F; |
606 | mask_keyup = 0x400000; | 742 | mask_keyup = 0x400000; |
607 | polling = 50; // ms | 743 | polling = 50; // ms |
608 | break; | 744 | break; |
609 | case SAA7134_BOARD_PROTEUS_2309: | 745 | case SAA7134_BOARD_PROTEUS_2309: |
610 | ir_codes = &ir_codes_proteus_2309_table; | 746 | ir_codes = RC_MAP_PROTEUS_2309; |
611 | mask_keycode = 0x00007F; | 747 | mask_keycode = 0x00007F; |
612 | mask_keyup = 0x000080; | 748 | mask_keyup = 0x000080; |
613 | polling = 50; // ms | 749 | polling = 50; // ms |
614 | break; | 750 | break; |
615 | case SAA7134_BOARD_VIDEOMATE_DVBT_300: | 751 | case SAA7134_BOARD_VIDEOMATE_DVBT_300: |
616 | case SAA7134_BOARD_VIDEOMATE_DVBT_200: | 752 | case SAA7134_BOARD_VIDEOMATE_DVBT_200: |
617 | ir_codes = &ir_codes_videomate_tv_pvr_table; | 753 | ir_codes = RC_MAP_VIDEOMATE_TV_PVR; |
618 | mask_keycode = 0x003F00; | 754 | mask_keycode = 0x003F00; |
619 | mask_keyup = 0x040000; | 755 | mask_keyup = 0x040000; |
620 | break; | 756 | break; |
621 | case SAA7134_BOARD_FLYDVBS_LR300: | 757 | case SAA7134_BOARD_FLYDVBS_LR300: |
622 | case SAA7134_BOARD_FLYDVBT_LR301: | 758 | case SAA7134_BOARD_FLYDVBT_LR301: |
623 | case SAA7134_BOARD_FLYDVBTDUO: | 759 | case SAA7134_BOARD_FLYDVBTDUO: |
624 | ir_codes = &ir_codes_flydvb_table; | 760 | ir_codes = RC_MAP_FLYDVB; |
625 | mask_keycode = 0x0001F00; | 761 | mask_keycode = 0x0001F00; |
626 | mask_keydown = 0x0040000; | 762 | mask_keydown = 0x0040000; |
627 | break; | 763 | break; |
628 | case SAA7134_BOARD_ASUSTeK_P7131_DUAL: | 764 | case SAA7134_BOARD_ASUSTeK_P7131_DUAL: |
629 | case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: | 765 | case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: |
630 | case SAA7134_BOARD_ASUSTeK_P7131_ANALOG: | 766 | case SAA7134_BOARD_ASUSTeK_P7131_ANALOG: |
631 | ir_codes = &ir_codes_asus_pc39_table; | 767 | ir_codes = RC_MAP_ASUS_PC39; |
632 | mask_keydown = 0x0040000; | 768 | mask_keydown = 0x0040000; |
633 | rc5_gpio = 1; | 769 | rc5_gpio = 1; |
634 | break; | 770 | break; |
635 | case SAA7134_BOARD_ENCORE_ENLTV: | 771 | case SAA7134_BOARD_ENCORE_ENLTV: |
636 | case SAA7134_BOARD_ENCORE_ENLTV_FM: | 772 | case SAA7134_BOARD_ENCORE_ENLTV_FM: |
637 | ir_codes = &ir_codes_encore_enltv_table; | 773 | ir_codes = RC_MAP_ENCORE_ENLTV; |
638 | mask_keycode = 0x00007f; | 774 | mask_keycode = 0x00007f; |
639 | mask_keyup = 0x040000; | 775 | mask_keyup = 0x040000; |
640 | polling = 50; // ms | 776 | polling = 50; // ms |
641 | break; | 777 | break; |
642 | case SAA7134_BOARD_ENCORE_ENLTV_FM53: | 778 | case SAA7134_BOARD_ENCORE_ENLTV_FM53: |
643 | ir_codes = &ir_codes_encore_enltv_fm53_table; | 779 | ir_codes = RC_MAP_ENCORE_ENLTV_FM53; |
644 | mask_keydown = 0x0040000; | 780 | mask_keydown = 0x0040000; |
645 | mask_keycode = 0x00007f; | 781 | mask_keycode = 0x00007f; |
646 | nec_gpio = 1; | 782 | nec_gpio = 1; |
647 | break; | 783 | break; |
648 | case SAA7134_BOARD_10MOONSTVMASTER3: | 784 | case SAA7134_BOARD_10MOONSTVMASTER3: |
649 | ir_codes = &ir_codes_encore_enltv_table; | 785 | ir_codes = RC_MAP_ENCORE_ENLTV; |
650 | mask_keycode = 0x5f80000; | 786 | mask_keycode = 0x5f80000; |
651 | mask_keyup = 0x8000000; | 787 | mask_keyup = 0x8000000; |
652 | polling = 50; //ms | 788 | polling = 50; //ms |
653 | break; | 789 | break; |
654 | case SAA7134_BOARD_GENIUS_TVGO_A11MCE: | 790 | case SAA7134_BOARD_GENIUS_TVGO_A11MCE: |
655 | ir_codes = &ir_codes_genius_tvgo_a11mce_table; | 791 | ir_codes = RC_MAP_GENIUS_TVGO_A11MCE; |
656 | mask_keycode = 0xff; | 792 | mask_keycode = 0xff; |
657 | mask_keydown = 0xf00000; | 793 | mask_keydown = 0xf00000; |
658 | polling = 50; /* ms */ | 794 | polling = 50; /* ms */ |
659 | break; | 795 | break; |
660 | case SAA7134_BOARD_REAL_ANGEL_220: | 796 | case SAA7134_BOARD_REAL_ANGEL_220: |
661 | ir_codes = &ir_codes_real_audio_220_32_keys_table; | 797 | ir_codes = RC_MAP_REAL_AUDIO_220_32_KEYS; |
662 | mask_keycode = 0x3f00; | 798 | mask_keycode = 0x3f00; |
663 | mask_keyup = 0x4000; | 799 | mask_keyup = 0x4000; |
664 | polling = 50; /* ms */ | 800 | polling = 50; /* ms */ |
665 | break; | 801 | break; |
666 | case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG: | 802 | case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG: |
667 | ir_codes = &ir_codes_kworld_plus_tv_analog_table; | 803 | ir_codes = RC_MAP_KWORLD_PLUS_TV_ANALOG; |
668 | mask_keycode = 0x7f; | 804 | mask_keycode = 0x7f; |
669 | polling = 40; /* ms */ | 805 | polling = 40; /* ms */ |
670 | break; | 806 | break; |
671 | case SAA7134_BOARD_VIDEOMATE_S350: | 807 | case SAA7134_BOARD_VIDEOMATE_S350: |
672 | ir_codes = &ir_codes_videomate_s350_table; | 808 | ir_codes = RC_MAP_VIDEOMATE_S350; |
673 | mask_keycode = 0x003f00; | 809 | mask_keycode = 0x003f00; |
674 | mask_keydown = 0x040000; | 810 | mask_keydown = 0x040000; |
675 | break; | 811 | break; |
676 | case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S: | 812 | case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S: |
677 | ir_codes = &ir_codes_winfast_table; | 813 | ir_codes = RC_MAP_WINFAST; |
678 | mask_keycode = 0x5f00; | 814 | mask_keycode = 0x5f00; |
679 | mask_keyup = 0x020000; | 815 | mask_keyup = 0x020000; |
680 | polling = 50; /* ms */ | 816 | polling = 50; /* ms */ |
@@ -695,6 +831,9 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
695 | } | 831 | } |
696 | 832 | ||
697 | ir->dev = input_dev; | 833 | ir->dev = input_dev; |
834 | dev->remote = ir; | ||
835 | |||
836 | ir->running = 0; | ||
698 | 837 | ||
699 | /* init hardware-specific stuff */ | 838 | /* init hardware-specific stuff */ |
700 | ir->mask_keycode = mask_keycode; | 839 | ir->mask_keycode = mask_keycode; |
@@ -703,6 +842,7 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
703 | ir->polling = polling; | 842 | ir->polling = polling; |
704 | ir->rc5_gpio = rc5_gpio; | 843 | ir->rc5_gpio = rc5_gpio; |
705 | ir->nec_gpio = nec_gpio; | 844 | ir->nec_gpio = nec_gpio; |
845 | ir->raw_decode = raw_decode; | ||
706 | 846 | ||
707 | /* init input device */ | 847 | /* init input device */ |
708 | snprintf(ir->name, sizeof(ir->name), "saa7134 IR (%s)", | 848 | snprintf(ir->name, sizeof(ir->name), "saa7134 IR (%s)", |
@@ -710,6 +850,19 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
710 | snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", | 850 | snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", |
711 | pci_name(dev->pci)); | 851 | pci_name(dev->pci)); |
712 | 852 | ||
853 | |||
854 | ir->props.priv = dev; | ||
855 | ir->props.open = saa7134_ir_open; | ||
856 | ir->props.close = saa7134_ir_close; | ||
857 | |||
858 | if (raw_decode) | ||
859 | ir->props.driver_type = RC_DRIVER_IR_RAW; | ||
860 | |||
861 | if (!raw_decode && allow_protocol_change) { | ||
862 | ir->props.allowed_protos = IR_TYPE_RC5 | IR_TYPE_NEC; | ||
863 | ir->props.change_protocol = saa7134_ir_change_protocol; | ||
864 | } | ||
865 | |||
713 | err = ir_input_init(input_dev, &ir->ir, ir_type); | 866 | err = ir_input_init(input_dev, &ir->ir, ir_type); |
714 | if (err < 0) | 867 | if (err < 0) |
715 | goto err_out_free; | 868 | goto err_out_free; |
@@ -727,12 +880,9 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
727 | } | 880 | } |
728 | input_dev->dev.parent = &dev->pci->dev; | 881 | input_dev->dev.parent = &dev->pci->dev; |
729 | 882 | ||
730 | dev->remote = ir; | 883 | err = ir_input_register(ir->dev, ir_codes, &ir->props, MODULE_NAME); |
731 | saa7134_ir_start(dev, ir); | ||
732 | |||
733 | err = ir_input_register(ir->dev, ir_codes, NULL); | ||
734 | if (err) | 884 | if (err) |
735 | goto err_out_stop; | 885 | goto err_out_free; |
736 | 886 | ||
737 | /* the remote isn't as bouncy as a keyboard */ | 887 | /* the remote isn't as bouncy as a keyboard */ |
738 | ir->dev->rep[REP_DELAY] = repeat_delay; | 888 | ir->dev->rep[REP_DELAY] = repeat_delay; |
@@ -740,10 +890,8 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
740 | 890 | ||
741 | return 0; | 891 | return 0; |
742 | 892 | ||
743 | err_out_stop: | 893 | err_out_free: |
744 | saa7134_ir_stop(dev); | ||
745 | dev->remote = NULL; | 894 | dev->remote = NULL; |
746 | err_out_free: | ||
747 | kfree(ir); | 895 | kfree(ir); |
748 | return err; | 896 | return err; |
749 | } | 897 | } |
@@ -787,24 +935,24 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev) | |||
787 | dev->init_data.name = "Pinnacle PCTV"; | 935 | dev->init_data.name = "Pinnacle PCTV"; |
788 | if (pinnacle_remote == 0) { | 936 | if (pinnacle_remote == 0) { |
789 | dev->init_data.get_key = get_key_pinnacle_color; | 937 | dev->init_data.get_key = get_key_pinnacle_color; |
790 | dev->init_data.ir_codes = &ir_codes_pinnacle_color_table; | 938 | dev->init_data.ir_codes = RC_MAP_PINNACLE_COLOR; |
791 | info.addr = 0x47; | 939 | info.addr = 0x47; |
792 | } else { | 940 | } else { |
793 | dev->init_data.get_key = get_key_pinnacle_grey; | 941 | dev->init_data.get_key = get_key_pinnacle_grey; |
794 | dev->init_data.ir_codes = &ir_codes_pinnacle_grey_table; | 942 | dev->init_data.ir_codes = RC_MAP_PINNACLE_GREY; |
795 | info.addr = 0x47; | 943 | info.addr = 0x47; |
796 | } | 944 | } |
797 | break; | 945 | break; |
798 | case SAA7134_BOARD_UPMOST_PURPLE_TV: | 946 | case SAA7134_BOARD_UPMOST_PURPLE_TV: |
799 | dev->init_data.name = "Purple TV"; | 947 | dev->init_data.name = "Purple TV"; |
800 | dev->init_data.get_key = get_key_purpletv; | 948 | dev->init_data.get_key = get_key_purpletv; |
801 | dev->init_data.ir_codes = &ir_codes_purpletv_table; | 949 | dev->init_data.ir_codes = RC_MAP_PURPLETV; |
802 | info.addr = 0x7a; | 950 | info.addr = 0x7a; |
803 | break; | 951 | break; |
804 | case SAA7134_BOARD_MSI_TVATANYWHERE_PLUS: | 952 | case SAA7134_BOARD_MSI_TVATANYWHERE_PLUS: |
805 | dev->init_data.name = "MSI TV@nywhere Plus"; | 953 | dev->init_data.name = "MSI TV@nywhere Plus"; |
806 | dev->init_data.get_key = get_key_msi_tvanywhere_plus; | 954 | dev->init_data.get_key = get_key_msi_tvanywhere_plus; |
807 | dev->init_data.ir_codes = &ir_codes_msi_tvanywhere_plus_table; | 955 | dev->init_data.ir_codes = RC_MAP_MSI_TVANYWHERE_PLUS; |
808 | info.addr = 0x30; | 956 | info.addr = 0x30; |
809 | /* MSI TV@nywhere Plus controller doesn't seem to | 957 | /* MSI TV@nywhere Plus controller doesn't seem to |
810 | respond to probes unless we read something from | 958 | respond to probes unless we read something from |
@@ -818,7 +966,7 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev) | |||
818 | case SAA7134_BOARD_HAUPPAUGE_HVR1110: | 966 | case SAA7134_BOARD_HAUPPAUGE_HVR1110: |
819 | dev->init_data.name = "HVR 1110"; | 967 | dev->init_data.name = "HVR 1110"; |
820 | dev->init_data.get_key = get_key_hvr1110; | 968 | dev->init_data.get_key = get_key_hvr1110; |
821 | dev->init_data.ir_codes = &ir_codes_hauppauge_new_table; | 969 | dev->init_data.ir_codes = RC_MAP_HAUPPAUGE_NEW; |
822 | info.addr = 0x71; | 970 | info.addr = 0x71; |
823 | break; | 971 | break; |
824 | case SAA7134_BOARD_BEHOLD_607FM_MK3: | 972 | case SAA7134_BOARD_BEHOLD_607FM_MK3: |
@@ -834,9 +982,12 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev) | |||
834 | case SAA7134_BOARD_BEHOLD_M6_EXTRA: | 982 | case SAA7134_BOARD_BEHOLD_M6_EXTRA: |
835 | case SAA7134_BOARD_BEHOLD_H6: | 983 | case SAA7134_BOARD_BEHOLD_H6: |
836 | case SAA7134_BOARD_BEHOLD_X7: | 984 | case SAA7134_BOARD_BEHOLD_X7: |
985 | case SAA7134_BOARD_BEHOLD_H7: | ||
986 | case SAA7134_BOARD_BEHOLD_A7: | ||
837 | dev->init_data.name = "BeholdTV"; | 987 | dev->init_data.name = "BeholdTV"; |
838 | dev->init_data.get_key = get_key_beholdm6xx; | 988 | dev->init_data.get_key = get_key_beholdm6xx; |
839 | dev->init_data.ir_codes = &ir_codes_behold_table; | 989 | dev->init_data.ir_codes = RC_MAP_BEHOLD; |
990 | dev->init_data.type = IR_TYPE_NEC; | ||
840 | info.addr = 0x2d; | 991 | info.addr = 0x2d; |
841 | break; | 992 | break; |
842 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_501: | 993 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_501: |
@@ -846,7 +997,7 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev) | |||
846 | case SAA7134_BOARD_FLYDVB_TRIO: | 997 | case SAA7134_BOARD_FLYDVB_TRIO: |
847 | dev->init_data.name = "FlyDVB Trio"; | 998 | dev->init_data.name = "FlyDVB Trio"; |
848 | dev->init_data.get_key = get_key_flydvb_trio; | 999 | dev->init_data.get_key = get_key_flydvb_trio; |
849 | dev->init_data.ir_codes = &ir_codes_flydvb_table; | 1000 | dev->init_data.ir_codes = RC_MAP_FLYDVB; |
850 | info.addr = 0x0b; | 1001 | info.addr = 0x0b; |
851 | break; | 1002 | break; |
852 | default: | 1003 | default: |
@@ -859,6 +1010,33 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev) | |||
859 | i2c_new_device(&dev->i2c_adap, &info); | 1010 | i2c_new_device(&dev->i2c_adap, &info); |
860 | } | 1011 | } |
861 | 1012 | ||
1013 | static int saa7134_raw_decode_irq(struct saa7134_dev *dev) | ||
1014 | { | ||
1015 | struct card_ir *ir = dev->remote; | ||
1016 | unsigned long timeout; | ||
1017 | int space; | ||
1018 | |||
1019 | /* Generate initial event */ | ||
1020 | saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); | ||
1021 | saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); | ||
1022 | space = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2) & ir->mask_keydown; | ||
1023 | ir_raw_event_store_edge(dev->remote->dev, space ? IR_SPACE : IR_PULSE); | ||
1024 | |||
1025 | |||
1026 | /* | ||
1027 | * Wait 15 ms from the start of the first IR event before processing | ||
1028 | * the event. This time is enough for NEC protocol. May need adjustments | ||
1029 | * to work with other protocols. | ||
1030 | */ | ||
1031 | if (!ir->active) { | ||
1032 | timeout = jiffies + jiffies_to_msecs(15); | ||
1033 | mod_timer(&ir->timer_end, timeout); | ||
1034 | ir->active = 1; | ||
1035 | } | ||
1036 | |||
1037 | return 1; | ||
1038 | } | ||
1039 | |||
862 | static int saa7134_rc5_irq(struct saa7134_dev *dev) | 1040 | static int saa7134_rc5_irq(struct saa7134_dev *dev) |
863 | { | 1041 | { |
864 | struct card_ir *ir = dev->remote; | 1042 | struct card_ir *ir = dev->remote; |
@@ -901,7 +1079,6 @@ static int saa7134_rc5_irq(struct saa7134_dev *dev) | |||
901 | return 1; | 1079 | return 1; |
902 | } | 1080 | } |
903 | 1081 | ||
904 | |||
905 | /* On NEC protocol, One has 2.25 ms, and zero has 1.125 ms | 1082 | /* On NEC protocol, One has 2.25 ms, and zero has 1.125 ms |
906 | The first pulse (start) has 9 + 4.5 ms | 1083 | The first pulse (start) has 9 + 4.5 ms |
907 | */ | 1084 | */ |
@@ -1011,14 +1188,14 @@ static void nec_task(unsigned long data) | |||
1011 | /* Keep repeating the last key */ | 1188 | /* Keep repeating the last key */ |
1012 | mod_timer(&ir->timer_keyup, jiffies + msecs_to_jiffies(150)); | 1189 | mod_timer(&ir->timer_keyup, jiffies + msecs_to_jiffies(150)); |
1013 | 1190 | ||
1014 | saa_setl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18); | 1191 | saa_setl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18_P); |
1015 | } | 1192 | } |
1016 | 1193 | ||
1017 | static int saa7134_nec_irq(struct saa7134_dev *dev) | 1194 | static int saa7134_nec_irq(struct saa7134_dev *dev) |
1018 | { | 1195 | { |
1019 | struct card_ir *ir = dev->remote; | 1196 | struct card_ir *ir = dev->remote; |
1020 | 1197 | ||
1021 | saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18); | 1198 | saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18_P); |
1022 | tasklet_schedule(&ir->tlet); | 1199 | tasklet_schedule(&ir->tlet); |
1023 | 1200 | ||
1024 | return 1; | 1201 | return 1; |