Commit e330919a authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Mauro Carvalho Chehab

V4L/DVB (12517): mt9t031: improve rectangle placement in invalid S_CROP

1. soc-camera always requests a valid rectangle, when calling .s_fmt(), no need
to check and adjust
2. in .s_crop(), if the rectangle exceeds sensor limits, push it to the
respective border instead of centering
3. take into account left and top borders when checking
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent bf62e1da
...@@ -240,15 +240,6 @@ static int mt9t031_set_params(struct soc_camera_device *icd, ...@@ -240,15 +240,6 @@ static int mt9t031_set_params(struct soc_camera_device *icd,
const u16 hblank = MT9T031_HORIZONTAL_BLANK, const u16 hblank = MT9T031_HORIZONTAL_BLANK,
vblank = MT9T031_VERTICAL_BLANK; vblank = MT9T031_VERTICAL_BLANK;
/* Make sure we don't exceed sensor limits */
if (rect->left + rect->width > icd->rect_max.width)
rect->left = (icd->rect_max.width - rect->width) / 2 +
icd->rect_max.left;
if (rect->top + rect->height > icd->rect_max.height)
rect->top = (icd->rect_max.height - rect->height) / 2 +
icd->rect_max.top;
width = rect->width * xskip; width = rect->width * xskip;
height = rect->height * yskip; height = rect->height * yskip;
left = rect->left * xskip; left = rect->left * xskip;
...@@ -336,6 +327,15 @@ static int mt9t031_set_crop(struct soc_camera_device *icd, ...@@ -336,6 +327,15 @@ static int mt9t031_set_crop(struct soc_camera_device *icd,
struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
struct mt9t031 *mt9t031 = to_mt9t031(client); struct mt9t031 *mt9t031 = to_mt9t031(client);
/* Make sure we don't exceed sensor limits */
if (rect->left + rect->width > icd->rect_max.left + icd->rect_max.width)
rect->left = icd->rect_max.width + icd->rect_max.left -
rect->width;
if (rect->top + rect->height > icd->rect_max.height + icd->rect_max.top)
rect->top = icd->rect_max.height + icd->rect_max.top -
rect->height;
/* CROP - no change in scaling, or in limits */ /* CROP - no change in scaling, or in limits */
return mt9t031_set_params(icd, rect, mt9t031->xskip, mt9t031->yskip); return mt9t031_set_params(icd, rect, mt9t031->xskip, mt9t031->yskip);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment