aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-09-20 08:06:33 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-10-05 21:10:38 -0400
commitc389648a927bada928c854dccccf0301317784eb (patch)
treead0cf86a4aa514a77cfcd1bc26f107b682b2e744
parent0d4f35f3f0044303abfff57441dd1e98f96ea935 (diff)
[media] tvp514x: s_routing should just change routing, not try to detect a signal
The s_routing function should not try to detect a signal. It is a really bad idea to try to detect a valid video signal and return an error if you can't. Changing input should do just that and nothing more. Also don't power on the ADCs on s_routing, instead do that on querystd. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Lad, Prabhakar <prabhakar.lad@ti.com> Tested-by: Lad, Prabhakar <prabhakar.lad@ti.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/i2c/tvp514x.c77
1 files changed, 6 insertions, 71 deletions
diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
index 1f3943bb87d5..d5e10215a28f 100644
--- a/drivers/media/i2c/tvp514x.c
+++ b/drivers/media/i2c/tvp514x.c
@@ -519,6 +519,12 @@ static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id)
519 519
520 *std_id = V4L2_STD_UNKNOWN; 520 *std_id = V4L2_STD_UNKNOWN;
521 521
522 /* To query the standard the TVP514x must power on the ADCs. */
523 if (!decoder->streaming) {
524 tvp514x_s_stream(sd, 1);
525 msleep(LOCK_RETRY_DELAY);
526 }
527
522 /* query the current standard */ 528 /* query the current standard */
523 current_std = tvp514x_query_current_std(sd); 529 current_std = tvp514x_query_current_std(sd);
524 if (current_std == STD_INVALID) 530 if (current_std == STD_INVALID)
@@ -625,25 +631,12 @@ static int tvp514x_s_routing(struct v4l2_subdev *sd,
625 int err; 631 int err;
626 enum tvp514x_input input_sel; 632 enum tvp514x_input input_sel;
627 enum tvp514x_output output_sel; 633 enum tvp514x_output output_sel;
628 u8 sync_lock_status, lock_mask;
629 int try_count = LOCK_RETRY_COUNT;
630 634
631 if ((input >= INPUT_INVALID) || 635 if ((input >= INPUT_INVALID) ||
632 (output >= OUTPUT_INVALID)) 636 (output >= OUTPUT_INVALID))
633 /* Index out of bound */ 637 /* Index out of bound */
634 return -EINVAL; 638 return -EINVAL;
635 639
636 /*
637 * For the sequence streamon -> streamoff and again s_input
638 * it fails to lock the signal, since streamoff puts TVP514x
639 * into power off state which leads to failure in sub-sequent s_input.
640 *
641 * So power up the TVP514x device here, since it is important to lock
642 * the signal at this stage.
643 */
644 if (!decoder->streaming)
645 tvp514x_s_stream(sd, 1);
646
647 input_sel = input; 640 input_sel = input;
648 output_sel = output; 641 output_sel = output;
649 642
@@ -660,64 +653,6 @@ static int tvp514x_s_routing(struct v4l2_subdev *sd,
660 653
661 decoder->tvp514x_regs[REG_INPUT_SEL].val = input_sel; 654 decoder->tvp514x_regs[REG_INPUT_SEL].val = input_sel;
662 decoder->tvp514x_regs[REG_OUTPUT_FORMATTER1].val = output_sel; 655 decoder->tvp514x_regs[REG_OUTPUT_FORMATTER1].val = output_sel;
663
664 /* Clear status */
665 msleep(LOCK_RETRY_DELAY);
666 err =
667 tvp514x_write_reg(sd, REG_CLEAR_LOST_LOCK, 0x01);
668 if (err)
669 return err;
670
671 switch (input_sel) {
672 case INPUT_CVBS_VI1A:
673 case INPUT_CVBS_VI1B:
674 case INPUT_CVBS_VI1C:
675 case INPUT_CVBS_VI2A:
676 case INPUT_CVBS_VI2B:
677 case INPUT_CVBS_VI2C:
678 case INPUT_CVBS_VI3A:
679 case INPUT_CVBS_VI3B:
680 case INPUT_CVBS_VI3C:
681 case INPUT_CVBS_VI4A:
682 lock_mask = STATUS_CLR_SUBCAR_LOCK_BIT |
683 STATUS_HORZ_SYNC_LOCK_BIT |
684 STATUS_VIRT_SYNC_LOCK_BIT;
685 break;
686
687 case INPUT_SVIDEO_VI2A_VI1A:
688 case INPUT_SVIDEO_VI2B_VI1B:
689 case INPUT_SVIDEO_VI2C_VI1C:
690 case INPUT_SVIDEO_VI2A_VI3A:
691 case INPUT_SVIDEO_VI2B_VI3B:
692 case INPUT_SVIDEO_VI2C_VI3C:
693 case INPUT_SVIDEO_VI4A_VI1A:
694 case INPUT_SVIDEO_VI4A_VI1B:
695 case INPUT_SVIDEO_VI4A_VI1C:
696 case INPUT_SVIDEO_VI4A_VI3A:
697 case INPUT_SVIDEO_VI4A_VI3B:
698 case INPUT_SVIDEO_VI4A_VI3C:
699 lock_mask = STATUS_HORZ_SYNC_LOCK_BIT |
700 STATUS_VIRT_SYNC_LOCK_BIT;
701 break;
702 /* Need to add other interfaces*/
703 default:
704 return -EINVAL;
705 }
706
707 while (try_count-- > 0) {
708 /* Allow decoder to sync up with new input */
709 msleep(LOCK_RETRY_DELAY);
710
711 sync_lock_status = tvp514x_read_reg(sd,
712 REG_STATUS1);
713 if (lock_mask == (sync_lock_status & lock_mask))
714 /* Input detected */
715 break;
716 }
717
718 if (try_count < 0)
719 return -EINVAL;
720
721 decoder->input = input; 656 decoder->input = input;
722 decoder->output = output; 657 decoder->output = output;
723 658