aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2010-03-19 23:25:37 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-17 23:52:55 -0400
commit0210894956cf57d525d56341cc3e0f3d5d2db659 (patch)
treeae465305c1ff6722a80dc3c1bc89c943516136ac /drivers/media/video
parentd152b8b62421c441bea4eb5d92e9d1b4883fd201 (diff)
V4L/DVB: saa7134: add code to allow changing IR protocol
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c64
1 files changed, 60 insertions, 4 deletions
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index 241195e8be3d..7e6f125e4e31 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -421,6 +421,10 @@ static void saa7134_input_timer(unsigned long data)
421 421
422void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir) 422void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir)
423{ 423{
424 if (ir->running)
425 return;
426
427 ir->running = 1;
424 if (ir->polling) { 428 if (ir->polling) {
425 setup_timer(&ir->timer, saa7134_input_timer, 429 setup_timer(&ir->timer, saa7134_input_timer,
426 (unsigned long)dev); 430 (unsigned long)dev);
@@ -448,8 +452,50 @@ void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir)
448 452
449void saa7134_ir_stop(struct saa7134_dev *dev) 453void saa7134_ir_stop(struct saa7134_dev *dev)
450{ 454{
455 struct card_ir *ir = dev->remote;
456
457 if (!ir->running)
458 return;
451 if (dev->remote->polling) 459 if (dev->remote->polling)
452 del_timer_sync(&dev->remote->timer); 460 del_timer_sync(&dev->remote->timer);
461 else if (ir->rc5_gpio)
462 del_timer_sync(&ir->timer_end);
463 else if (ir->nec_gpio)
464 tasklet_kill(&ir->tlet);
465 ir->running = 0;
466}
467
468int saa7134_ir_change_protocol(void *priv, u64 ir_type)
469{
470 struct saa7134_dev *dev = priv;
471 struct card_ir *ir = dev->remote;
472 u32 nec_gpio, rc5_gpio;
473
474 if (ir_type == IR_TYPE_RC5) {
475 dprintk("Changing protocol to RC5\n");
476 nec_gpio = 0;
477 rc5_gpio = 1;
478 } else if (ir_type == IR_TYPE_NEC) {
479 dprintk("Changing protocol to NEC\n");
480 nec_gpio = 1;
481 rc5_gpio = 0;
482 } else {
483 dprintk("IR protocol type %ud is not supported\n",
484 (unsigned)ir_type);
485 return -EINVAL;
486 }
487
488 if (ir->running) {
489 saa7134_ir_stop(dev);
490 ir->nec_gpio = nec_gpio;
491 ir->rc5_gpio = rc5_gpio;
492 saa7134_ir_start(dev, ir);
493 } else {
494 ir->nec_gpio = nec_gpio;
495 ir->rc5_gpio = rc5_gpio;
496 }
497
498 return 0;
453} 499}
454 500
455int saa7134_input_init1(struct saa7134_dev *dev) 501int saa7134_input_init1(struct saa7134_dev *dev)
@@ -698,6 +744,9 @@ int saa7134_input_init1(struct saa7134_dev *dev)
698 } 744 }
699 745
700 ir->dev = input_dev; 746 ir->dev = input_dev;
747 dev->remote = ir;
748
749 ir->running = 0;
701 750
702 /* init hardware-specific stuff */ 751 /* init hardware-specific stuff */
703 ir->mask_keycode = mask_keycode; 752 ir->mask_keycode = mask_keycode;
@@ -713,6 +762,14 @@ int saa7134_input_init1(struct saa7134_dev *dev)
713 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", 762 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
714 pci_name(dev->pci)); 763 pci_name(dev->pci));
715 764
765 if (ir_codes->ir_type != IR_TYPE_OTHER) {
766 ir->props.allowed_protos = IR_TYPE_RC5 | IR_TYPE_NEC;
767 ir->props.priv = dev;
768 ir->props.change_protocol = saa7134_ir_change_protocol;
769
770 /* Set IR protocol */
771 saa7134_ir_change_protocol(ir->props.priv, ir_codes->ir_type);
772 }
716 err = ir_input_init(input_dev, &ir->ir, ir_type); 773 err = ir_input_init(input_dev, &ir->ir, ir_type);
717 if (err < 0) 774 if (err < 0)
718 goto err_out_free; 775 goto err_out_free;
@@ -730,13 +787,12 @@ int saa7134_input_init1(struct saa7134_dev *dev)
730 } 787 }
731 input_dev->dev.parent = &dev->pci->dev; 788 input_dev->dev.parent = &dev->pci->dev;
732 789
733 dev->remote = ir; 790 err = ir_input_register(ir->dev, ir_codes, &ir->props, MODULE_NAME);
734 saa7134_ir_start(dev, ir);
735
736 err = ir_input_register(ir->dev, ir_codes, NULL, MODULE_NAME);
737 if (err) 791 if (err)
738 goto err_out_stop; 792 goto err_out_stop;
739 793
794 saa7134_ir_start(dev, ir);
795
740 /* the remote isn't as bouncy as a keyboard */ 796 /* the remote isn't as bouncy as a keyboard */
741 ir->dev->rep[REP_DELAY] = repeat_delay; 797 ir->dev->rep[REP_DELAY] = repeat_delay;
742 ir->dev->rep[REP_PERIOD] = repeat_period; 798 ir->dev->rep[REP_PERIOD] = repeat_period;