aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorJavier Martin <javier.martin@vista-silicon.com>2013-01-29 05:14:27 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-02-08 11:24:53 -0500
commitf748cd3ec8039a01d260ba0d51687afdf93c6e67 (patch)
tree39c404aebea951c28530459fdb22ab548c4a968d /drivers/media
parentd058e23704ad7e0b6876a94b0d8428dcef510b49 (diff)
[media] media: ov7670: make try_fmt() consistent with 'min_height' and 'min_width'
'min_height' and 'min_width' are variables that allow to specify the minimum resolution that the sensor will achieve. This patch make v4l2 fmt callbacks consider this parameters in order to return valid data to user space. Acked-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/i2c/ov7670.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index 51b198f79077..88e64739fefd 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -786,10 +786,11 @@ static int ov7670_try_fmt_internal(struct v4l2_subdev *sd,
786 struct ov7670_format_struct **ret_fmt, 786 struct ov7670_format_struct **ret_fmt,
787 struct ov7670_win_size **ret_wsize) 787 struct ov7670_win_size **ret_wsize)
788{ 788{
789 int index; 789 int index, i;
790 struct ov7670_win_size *wsize; 790 struct ov7670_win_size *wsize;
791 struct ov7670_info *info = to_state(sd); 791 struct ov7670_info *info = to_state(sd);
792 unsigned int n_win_sizes = info->devtype->n_win_sizes; 792 unsigned int n_win_sizes = info->devtype->n_win_sizes;
793 unsigned int win_sizes_limit = n_win_sizes;
793 794
794 for (index = 0; index < N_OV7670_FMTS; index++) 795 for (index = 0; index < N_OV7670_FMTS; index++)
795 if (ov7670_formats[index].mbus_code == fmt->code) 796 if (ov7670_formats[index].mbus_code == fmt->code)
@@ -805,15 +806,30 @@ static int ov7670_try_fmt_internal(struct v4l2_subdev *sd,
805 * Fields: the OV devices claim to be progressive. 806 * Fields: the OV devices claim to be progressive.
806 */ 807 */
807 fmt->field = V4L2_FIELD_NONE; 808 fmt->field = V4L2_FIELD_NONE;
809
810 /*
811 * Don't consider values that don't match min_height and min_width
812 * constraints.
813 */
814 if (info->min_width || info->min_height)
815 for (i = 0; i < n_win_sizes; i++) {
816 wsize = info->devtype->win_sizes + i;
817
818 if (wsize->width < info->min_width ||
819 wsize->height < info->min_height) {
820 win_sizes_limit = i;
821 break;
822 }
823 }
808 /* 824 /*
809 * Round requested image size down to the nearest 825 * Round requested image size down to the nearest
810 * we support, but not below the smallest. 826 * we support, but not below the smallest.
811 */ 827 */
812 for (wsize = info->devtype->win_sizes; 828 for (wsize = info->devtype->win_sizes;
813 wsize < info->devtype->win_sizes + n_win_sizes; wsize++) 829 wsize < info->devtype->win_sizes + win_sizes_limit; wsize++)
814 if (fmt->width >= wsize->width && fmt->height >= wsize->height) 830 if (fmt->width >= wsize->width && fmt->height >= wsize->height)
815 break; 831 break;
816 if (wsize >= info->devtype->win_sizes + n_win_sizes) 832 if (wsize >= info->devtype->win_sizes + win_sizes_limit)
817 wsize--; /* Take the smallest one */ 833 wsize--; /* Take the smallest one */
818 if (ret_wsize != NULL) 834 if (ret_wsize != NULL)
819 *ret_wsize = wsize; 835 *ret_wsize = wsize;