aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/rc/serial_ir.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/rc/serial_ir.c')
-rw-r--r--drivers/media/rc/serial_ir.c123
1 files changed, 62 insertions, 61 deletions
diff --git a/drivers/media/rc/serial_ir.c b/drivers/media/rc/serial_ir.c
index 923fb2299553..41b54e40176c 100644
--- a/drivers/media/rc/serial_ir.c
+++ b/drivers/media/rc/serial_ir.c
@@ -487,10 +487,69 @@ static void serial_ir_timeout(unsigned long arg)
487 ir_raw_event_handle(serial_ir.rcdev); 487 ir_raw_event_handle(serial_ir.rcdev);
488} 488}
489 489
490/* Needed by serial_ir_probe() */
491static int serial_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
492 unsigned int count);
493static int serial_ir_tx_duty_cycle(struct rc_dev *dev, u32 cycle);
494static int serial_ir_tx_carrier(struct rc_dev *dev, u32 carrier);
495static int serial_ir_open(struct rc_dev *rcdev);
496static void serial_ir_close(struct rc_dev *rcdev);
497
490static int serial_ir_probe(struct platform_device *dev) 498static int serial_ir_probe(struct platform_device *dev)
491{ 499{
500 struct rc_dev *rcdev;
492 int i, nlow, nhigh, result; 501 int i, nlow, nhigh, result;
493 502
503 rcdev = devm_rc_allocate_device(&dev->dev, RC_DRIVER_IR_RAW);
504 if (!rcdev)
505 return -ENOMEM;
506
507 if (hardware[type].send_pulse && hardware[type].send_space)
508 rcdev->tx_ir = serial_ir_tx;
509 if (hardware[type].set_send_carrier)
510 rcdev->s_tx_carrier = serial_ir_tx_carrier;
511 if (hardware[type].set_duty_cycle)
512 rcdev->s_tx_duty_cycle = serial_ir_tx_duty_cycle;
513
514 switch (type) {
515 case IR_HOMEBREW:
516 rcdev->input_name = "Serial IR type home-brew";
517 break;
518 case IR_IRDEO:
519 rcdev->input_name = "Serial IR type IRdeo";
520 break;
521 case IR_IRDEO_REMOTE:
522 rcdev->input_name = "Serial IR type IRdeo remote";
523 break;
524 case IR_ANIMAX:
525 rcdev->input_name = "Serial IR type AnimaX";
526 break;
527 case IR_IGOR:
528 rcdev->input_name = "Serial IR type IgorPlug";
529 break;
530 }
531
532 rcdev->input_phys = KBUILD_MODNAME "/input0";
533 rcdev->input_id.bustype = BUS_HOST;
534 rcdev->input_id.vendor = 0x0001;
535 rcdev->input_id.product = 0x0001;
536 rcdev->input_id.version = 0x0100;
537 rcdev->open = serial_ir_open;
538 rcdev->close = serial_ir_close;
539 rcdev->dev.parent = &serial_ir.pdev->dev;
540 rcdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
541 rcdev->driver_name = KBUILD_MODNAME;
542 rcdev->map_name = RC_MAP_RC6_MCE;
543 rcdev->min_timeout = 1;
544 rcdev->timeout = IR_DEFAULT_TIMEOUT;
545 rcdev->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
546 rcdev->rx_resolution = 250000;
547
548 serial_ir.rcdev = rcdev;
549
550 setup_timer(&serial_ir.timeout_timer, serial_ir_timeout,
551 (unsigned long)&serial_ir);
552
494 result = devm_request_irq(&dev->dev, irq, serial_ir_irq_handler, 553 result = devm_request_irq(&dev->dev, irq, serial_ir_irq_handler,
495 share_irq ? IRQF_SHARED : 0, 554 share_irq ? IRQF_SHARED : 0,
496 KBUILD_MODNAME, &hardware); 555 KBUILD_MODNAME, &hardware);
@@ -516,9 +575,6 @@ static int serial_ir_probe(struct platform_device *dev)
516 return -EBUSY; 575 return -EBUSY;
517 } 576 }
518 577
519 setup_timer(&serial_ir.timeout_timer, serial_ir_timeout,
520 (unsigned long)&serial_ir);
521
522 result = hardware_init_port(); 578 result = hardware_init_port();
523 if (result < 0) 579 if (result < 0)
524 return result; 580 return result;
@@ -552,7 +608,8 @@ static int serial_ir_probe(struct platform_device *dev)
552 sense ? "low" : "high"); 608 sense ? "low" : "high");
553 609
554 dev_dbg(&dev->dev, "Interrupt %d, port %04x obtained\n", irq, io); 610 dev_dbg(&dev->dev, "Interrupt %d, port %04x obtained\n", irq, io);
555 return 0; 611
612 return devm_rc_register_device(&dev->dev, rcdev);
556} 613}
557 614
558static int serial_ir_open(struct rc_dev *rcdev) 615static int serial_ir_open(struct rc_dev *rcdev)
@@ -723,7 +780,6 @@ static void serial_ir_exit(void)
723 780
724static int __init serial_ir_init_module(void) 781static int __init serial_ir_init_module(void)
725{ 782{
726 struct rc_dev *rcdev;
727 int result; 783 int result;
728 784
729 switch (type) { 785 switch (type) {
@@ -754,63 +810,9 @@ static int __init serial_ir_init_module(void)
754 sense = !!sense; 810 sense = !!sense;
755 811
756 result = serial_ir_init(); 812 result = serial_ir_init();
757 if (result)
758 return result;
759
760 rcdev = devm_rc_allocate_device(&serial_ir.pdev->dev, RC_DRIVER_IR_RAW);
761 if (!rcdev) {
762 result = -ENOMEM;
763 goto serial_cleanup;
764 }
765
766 if (hardware[type].send_pulse && hardware[type].send_space)
767 rcdev->tx_ir = serial_ir_tx;
768 if (hardware[type].set_send_carrier)
769 rcdev->s_tx_carrier = serial_ir_tx_carrier;
770 if (hardware[type].set_duty_cycle)
771 rcdev->s_tx_duty_cycle = serial_ir_tx_duty_cycle;
772
773 switch (type) {
774 case IR_HOMEBREW:
775 rcdev->input_name = "Serial IR type home-brew";
776 break;
777 case IR_IRDEO:
778 rcdev->input_name = "Serial IR type IRdeo";
779 break;
780 case IR_IRDEO_REMOTE:
781 rcdev->input_name = "Serial IR type IRdeo remote";
782 break;
783 case IR_ANIMAX:
784 rcdev->input_name = "Serial IR type AnimaX";
785 break;
786 case IR_IGOR:
787 rcdev->input_name = "Serial IR type IgorPlug";
788 break;
789 }
790
791 rcdev->input_phys = KBUILD_MODNAME "/input0";
792 rcdev->input_id.bustype = BUS_HOST;
793 rcdev->input_id.vendor = 0x0001;
794 rcdev->input_id.product = 0x0001;
795 rcdev->input_id.version = 0x0100;
796 rcdev->open = serial_ir_open;
797 rcdev->close = serial_ir_close;
798 rcdev->dev.parent = &serial_ir.pdev->dev;
799 rcdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
800 rcdev->driver_name = KBUILD_MODNAME;
801 rcdev->map_name = RC_MAP_RC6_MCE;
802 rcdev->min_timeout = 1;
803 rcdev->timeout = IR_DEFAULT_TIMEOUT;
804 rcdev->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
805 rcdev->rx_resolution = 250000;
806
807 serial_ir.rcdev = rcdev;
808
809 result = rc_register_device(rcdev);
810
811 if (!result) 813 if (!result)
812 return 0; 814 return 0;
813serial_cleanup: 815
814 serial_ir_exit(); 816 serial_ir_exit();
815 return result; 817 return result;
816} 818}
@@ -818,7 +820,6 @@ serial_cleanup:
818static void __exit serial_ir_exit_module(void) 820static void __exit serial_ir_exit_module(void)
819{ 821{
820 del_timer_sync(&serial_ir.timeout_timer); 822 del_timer_sync(&serial_ir.timeout_timer);
821 rc_unregister_device(serial_ir.rcdev);
822 serial_ir_exit(); 823 serial_ir_exit();
823} 824}
824 825