aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/mt9t031.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/mt9t031.c')
-rw-r--r--drivers/media/video/mt9t031.c49
1 files changed, 26 insertions, 23 deletions
diff --git a/drivers/media/video/mt9t031.c b/drivers/media/video/mt9t031.c
index 27a5edda902c..dc3eb652a7cf 100644
--- a/drivers/media/video/mt9t031.c
+++ b/drivers/media/video/mt9t031.c
@@ -222,12 +222,12 @@ static unsigned long mt9t031_query_bus_param(struct soc_camera_device *icd)
222static void recalculate_limits(struct soc_camera_device *icd, 222static void recalculate_limits(struct soc_camera_device *icd,
223 u16 xskip, u16 yskip) 223 u16 xskip, u16 yskip)
224{ 224{
225 icd->x_min = (MT9T031_COLUMN_SKIP + xskip - 1) / xskip; 225 icd->rect_max.left = (MT9T031_COLUMN_SKIP + xskip - 1) / xskip;
226 icd->y_min = (MT9T031_ROW_SKIP + yskip - 1) / yskip; 226 icd->rect_max.top = (MT9T031_ROW_SKIP + yskip - 1) / yskip;
227 icd->width_min = (MT9T031_MIN_WIDTH + xskip - 1) / xskip; 227 icd->width_min = (MT9T031_MIN_WIDTH + xskip - 1) / xskip;
228 icd->height_min = (MT9T031_MIN_HEIGHT + yskip - 1) / yskip; 228 icd->height_min = (MT9T031_MIN_HEIGHT + yskip - 1) / yskip;
229 icd->width_max = MT9T031_MAX_WIDTH / xskip; 229 icd->rect_max.width = MT9T031_MAX_WIDTH / xskip;
230 icd->height_max = MT9T031_MAX_HEIGHT / yskip; 230 icd->rect_max.height = MT9T031_MAX_HEIGHT / yskip;
231} 231}
232 232
233static int mt9t031_set_params(struct soc_camera_device *icd, 233static int mt9t031_set_params(struct soc_camera_device *icd,
@@ -241,11 +241,13 @@ static int mt9t031_set_params(struct soc_camera_device *icd,
241 vblank = MT9T031_VERTICAL_BLANK; 241 vblank = MT9T031_VERTICAL_BLANK;
242 242
243 /* Make sure we don't exceed sensor limits */ 243 /* Make sure we don't exceed sensor limits */
244 if (rect->left + rect->width > icd->width_max) 244 if (rect->left + rect->width > icd->rect_max.width)
245 rect->left = (icd->width_max - rect->width) / 2 + icd->x_min; 245 rect->left = (icd->rect_max.width - rect->width) / 2 +
246 icd->rect_max.left;
246 247
247 if (rect->top + rect->height > icd->height_max) 248 if (rect->top + rect->height > icd->rect_max.height)
248 rect->top = (icd->height_max - rect->height) / 2 + icd->y_min; 249 rect->top = (icd->rect_max.height - rect->height) / 2 +
250 icd->rect_max.top;
249 251
250 width = rect->width * xskip; 252 width = rect->width * xskip;
251 height = rect->height * yskip; 253 height = rect->height * yskip;
@@ -346,8 +348,8 @@ static int mt9t031_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
346 int ret; 348 int ret;
347 u16 xskip, yskip; 349 u16 xskip, yskip;
348 struct v4l2_rect rect = { 350 struct v4l2_rect rect = {
349 .left = icd->x_current, 351 .left = icd->rect_current.left,
350 .top = icd->y_current, 352 .top = icd->rect_current.top,
351 .width = f->fmt.pix.width, 353 .width = f->fmt.pix.width,
352 .height = f->fmt.pix.height, 354 .height = f->fmt.pix.height,
353 }; 355 };
@@ -618,12 +620,13 @@ static int mt9t031_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
618 if (ctrl->value) { 620 if (ctrl->value) {
619 const u16 vblank = MT9T031_VERTICAL_BLANK; 621 const u16 vblank = MT9T031_VERTICAL_BLANK;
620 const u32 shutter_max = MT9T031_MAX_HEIGHT + vblank; 622 const u32 shutter_max = MT9T031_MAX_HEIGHT + vblank;
621 if (set_shutter(client, icd->height + 623 if (set_shutter(client, icd->rect_current.height +
622 icd->y_skip_top + vblank) < 0) 624 icd->y_skip_top + vblank) < 0)
623 return -EIO; 625 return -EIO;
624 qctrl = soc_camera_find_qctrl(icd->ops, V4L2_CID_EXPOSURE); 626 qctrl = soc_camera_find_qctrl(icd->ops, V4L2_CID_EXPOSURE);
625 icd->exposure = (shutter_max / 2 + (icd->height + 627 icd->exposure = (shutter_max / 2 +
626 icd->y_skip_top + vblank - 1) * 628 (icd->rect_current.height +
629 icd->y_skip_top + vblank - 1) *
627 (qctrl->maximum - qctrl->minimum)) / 630 (qctrl->maximum - qctrl->minimum)) /
628 shutter_max + qctrl->minimum; 631 shutter_max + qctrl->minimum;
629 mt9t031->autoexposure = 1; 632 mt9t031->autoexposure = 1;
@@ -726,16 +729,16 @@ static int mt9t031_probe(struct i2c_client *client,
726 v4l2_i2c_subdev_init(&mt9t031->subdev, client, &mt9t031_subdev_ops); 729 v4l2_i2c_subdev_init(&mt9t031->subdev, client, &mt9t031_subdev_ops);
727 730
728 /* Second stage probe - when a capture adapter is there */ 731 /* Second stage probe - when a capture adapter is there */
729 icd->ops = &mt9t031_ops; 732 icd->ops = &mt9t031_ops;
730 icd->x_min = MT9T031_COLUMN_SKIP; 733 icd->rect_max.left = MT9T031_COLUMN_SKIP;
731 icd->y_min = MT9T031_ROW_SKIP; 734 icd->rect_max.top = MT9T031_ROW_SKIP;
732 icd->x_current = icd->x_min; 735 icd->rect_current.left = icd->rect_max.left;
733 icd->y_current = icd->y_min; 736 icd->rect_current.top = icd->rect_max.top;
734 icd->width_min = MT9T031_MIN_WIDTH; 737 icd->width_min = MT9T031_MIN_WIDTH;
735 icd->width_max = MT9T031_MAX_WIDTH; 738 icd->rect_max.width = MT9T031_MAX_WIDTH;
736 icd->height_min = MT9T031_MIN_HEIGHT; 739 icd->height_min = MT9T031_MIN_HEIGHT;
737 icd->height_max = MT9T031_MAX_HEIGHT; 740 icd->rect_max.height = MT9T031_MAX_HEIGHT;
738 icd->y_skip_top = 0; 741 icd->y_skip_top = 0;
739 /* Simulated autoexposure. If enabled, we calculate shutter width 742 /* Simulated autoexposure. If enabled, we calculate shutter width
740 * ourselves in the driver based on vertical blanking and frame width */ 743 * ourselves in the driver based on vertical blanking and frame width */
741 mt9t031->autoexposure = 1; 744 mt9t031->autoexposure = 1;