aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2010-05-09 05:30:15 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-06-01 00:21:41 -0400
commit2db4e78f14a5b4741b09d03e6d17610537a9af27 (patch)
tree60527526f6da3ebc46791ab601a2c366f7852a20 /drivers/media
parent3805f201934e5384f6e941222dc1968cb638a88c (diff)
V4L/DVB: tvp514x: do NOT change the std as a side effect
Several calls (try_fmt, g_parm among others) changed the current standard as a side effect of that call. But the standard may only be changed by s_std. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Reviewed-by: Vaibhav Hiremath <hvaibhav@ti.com> Tested-by: Vaibhav Hiremath <hvaibhav@ti.com> Acked-by: Vaibhav Hiremath <hvaibhav@ti.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/tvp514x.c53
1 files changed, 16 insertions, 37 deletions
diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c
index e826114b7fb8..40d84d73edf8 100644
--- a/drivers/media/video/tvp514x.c
+++ b/drivers/media/video/tvp514x.c
@@ -366,13 +366,13 @@ static int tvp514x_write_regs(struct v4l2_subdev *sd,
366} 366}
367 367
368/** 368/**
369 * tvp514x_get_current_std() : Get the current standard detected by TVP5146/47 369 * tvp514x_query_current_std() : Query the current standard detected by TVP5146/47
370 * @sd: ptr to v4l2_subdev struct 370 * @sd: ptr to v4l2_subdev struct
371 * 371 *
372 * Get current standard detected by TVP5146/47, STD_INVALID if there is no 372 * Returns the current standard detected by TVP5146/47, STD_INVALID if there is no
373 * standard detected. 373 * standard detected.
374 */ 374 */
375static enum tvp514x_std tvp514x_get_current_std(struct v4l2_subdev *sd) 375static enum tvp514x_std tvp514x_query_current_std(struct v4l2_subdev *sd)
376{ 376{
377 u8 std, std_status; 377 u8 std, std_status;
378 378
@@ -518,7 +518,7 @@ static int tvp514x_detect(struct v4l2_subdev *sd,
518 * @std_id: standard V4L2 std_id ioctl enum 518 * @std_id: standard V4L2 std_id ioctl enum
519 * 519 *
520 * Returns the current standard detected by TVP5146/47. If no active input is 520 * Returns the current standard detected by TVP5146/47. If no active input is
521 * detected, returns -EINVAL 521 * detected then *std_id is set to 0 and the function returns 0.
522 */ 522 */
523static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id) 523static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id)
524{ 524{
@@ -530,10 +530,12 @@ static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id)
530 if (std_id == NULL) 530 if (std_id == NULL)
531 return -EINVAL; 531 return -EINVAL;
532 532
533 /* get the current standard */ 533 *std_id = V4L2_STD_UNKNOWN;
534 current_std = tvp514x_get_current_std(sd); 534
535 /* query the current standard */
536 current_std = tvp514x_query_current_std(sd);
535 if (current_std == STD_INVALID) 537 if (current_std == STD_INVALID)
536 return -EINVAL; 538 return 0;
537 539
538 input_sel = decoder->input; 540 input_sel = decoder->input;
539 541
@@ -575,12 +577,11 @@ static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id)
575 /* check whether signal is locked */ 577 /* check whether signal is locked */
576 sync_lock_status = tvp514x_read_reg(sd, REG_STATUS1); 578 sync_lock_status = tvp514x_read_reg(sd, REG_STATUS1);
577 if (lock_mask != (sync_lock_status & lock_mask)) 579 if (lock_mask != (sync_lock_status & lock_mask))
578 return -EINVAL; /* No input detected */ 580 return 0; /* No input detected */
579 581
580 decoder->current_std = current_std;
581 *std_id = decoder->std_list[current_std].standard.id; 582 *std_id = decoder->std_list[current_std].standard.id;
582 583
583 v4l2_dbg(1, debug, sd, "Current STD: %s", 584 v4l2_dbg(1, debug, sd, "Current STD: %s\n",
584 decoder->std_list[current_std].standard.name); 585 decoder->std_list[current_std].standard.name);
585 return 0; 586 return 0;
586} 587}
@@ -637,7 +638,6 @@ static int tvp514x_s_routing(struct v4l2_subdev *sd,
637 int err; 638 int err;
638 enum tvp514x_input input_sel; 639 enum tvp514x_input input_sel;
639 enum tvp514x_output output_sel; 640 enum tvp514x_output output_sel;
640 enum tvp514x_std current_std = STD_INVALID;
641 u8 sync_lock_status, lock_mask; 641 u8 sync_lock_status, lock_mask;
642 int try_count = LOCK_RETRY_COUNT; 642 int try_count = LOCK_RETRY_COUNT;
643 643
@@ -721,11 +721,6 @@ static int tvp514x_s_routing(struct v4l2_subdev *sd,
721 /* Allow decoder to sync up with new input */ 721 /* Allow decoder to sync up with new input */
722 msleep(LOCK_RETRY_DELAY); 722 msleep(LOCK_RETRY_DELAY);
723 723
724 /* get the current standard for future reference */
725 current_std = tvp514x_get_current_std(sd);
726 if (current_std == STD_INVALID)
727 continue;
728
729 sync_lock_status = tvp514x_read_reg(sd, 724 sync_lock_status = tvp514x_read_reg(sd,
730 REG_STATUS1); 725 REG_STATUS1);
731 if (lock_mask == (sync_lock_status & lock_mask)) 726 if (lock_mask == (sync_lock_status & lock_mask))
@@ -733,15 +728,13 @@ static int tvp514x_s_routing(struct v4l2_subdev *sd,
733 break; 728 break;
734 } 729 }
735 730
736 if ((current_std == STD_INVALID) || (try_count < 0)) 731 if (try_count < 0)
737 return -EINVAL; 732 return -EINVAL;
738 733
739 decoder->current_std = current_std;
740 decoder->input = input; 734 decoder->input = input;
741 decoder->output = output; 735 decoder->output = output;
742 736
743 v4l2_dbg(1, debug, sd, "Input set to: %d, std : %d", 737 v4l2_dbg(1, debug, sd, "Input set to: %d\n", input_sel);
744 input_sel, current_std);
745 738
746 return 0; 739 return 0;
747} 740}
@@ -1018,11 +1011,8 @@ tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
1018 pix = &f->fmt.pix; 1011 pix = &f->fmt.pix;
1019 1012
1020 /* Calculate height and width based on current standard */ 1013 /* Calculate height and width based on current standard */
1021 current_std = tvp514x_get_current_std(sd); 1014 current_std = decoder->current_std;
1022 if (current_std == STD_INVALID)
1023 return -EINVAL;
1024 1015
1025 decoder->current_std = current_std;
1026 pix->width = decoder->std_list[current_std].width; 1016 pix->width = decoder->std_list[current_std].width;
1027 pix->height = decoder->std_list[current_std].height; 1017 pix->height = decoder->std_list[current_std].height;
1028 1018
@@ -1132,15 +1122,8 @@ tvp514x_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a)
1132 /* only capture is supported */ 1122 /* only capture is supported */
1133 return -EINVAL; 1123 return -EINVAL;
1134 1124
1135 memset(a, 0, sizeof(*a));
1136 a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1137
1138 /* get the current standard */ 1125 /* get the current standard */
1139 current_std = tvp514x_get_current_std(sd); 1126 current_std = decoder->current_std;
1140 if (current_std == STD_INVALID)
1141 return -EINVAL;
1142
1143 decoder->current_std = current_std;
1144 1127
1145 cparm = &a->parm.capture; 1128 cparm = &a->parm.capture;
1146 cparm->capability = V4L2_CAP_TIMEPERFRAME; 1129 cparm->capability = V4L2_CAP_TIMEPERFRAME;
@@ -1175,11 +1158,7 @@ tvp514x_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a)
1175 timeperframe = &a->parm.capture.timeperframe; 1158 timeperframe = &a->parm.capture.timeperframe;
1176 1159
1177 /* get the current standard */ 1160 /* get the current standard */
1178 current_std = tvp514x_get_current_std(sd); 1161 current_std = decoder->current_std;
1179 if (current_std == STD_INVALID)
1180 return -EINVAL;
1181
1182 decoder->current_std = current_std;
1183 1162
1184 *timeperframe = 1163 *timeperframe =
1185 decoder->std_list[current_std].standard.frameperiod; 1164 decoder->std_list[current_std].standard.frameperiod;