diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2009-08-25 10:46:42 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-09-18 23:18:46 -0400 |
commit | e330919a215714796efb451984a753a46b570eb7 (patch) | |
tree | 80193477bd357dca8552eda00955d8befd611ecb /drivers/media/video | |
parent | bf62e1da6ac848b0c3f72665d05939263e9f4128 (diff) |
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: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/mt9t031.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/media/video/mt9t031.c b/drivers/media/video/mt9t031.c index dc3eb652a7cf..125973bf08b9 100644 --- a/drivers/media/video/mt9t031.c +++ b/drivers/media/video/mt9t031.c | |||
@@ -240,15 +240,6 @@ static int mt9t031_set_params(struct soc_camera_device *icd, | |||
240 | const u16 hblank = MT9T031_HORIZONTAL_BLANK, | 240 | const u16 hblank = MT9T031_HORIZONTAL_BLANK, |
241 | vblank = MT9T031_VERTICAL_BLANK; | 241 | vblank = MT9T031_VERTICAL_BLANK; |
242 | 242 | ||
243 | /* Make sure we don't exceed sensor limits */ | ||
244 | if (rect->left + rect->width > icd->rect_max.width) | ||
245 | rect->left = (icd->rect_max.width - rect->width) / 2 + | ||
246 | icd->rect_max.left; | ||
247 | |||
248 | if (rect->top + rect->height > icd->rect_max.height) | ||
249 | rect->top = (icd->rect_max.height - rect->height) / 2 + | ||
250 | icd->rect_max.top; | ||
251 | |||
252 | width = rect->width * xskip; | 243 | width = rect->width * xskip; |
253 | height = rect->height * yskip; | 244 | height = rect->height * yskip; |
254 | left = rect->left * xskip; | 245 | left = rect->left * xskip; |
@@ -336,6 +327,15 @@ static int mt9t031_set_crop(struct soc_camera_device *icd, | |||
336 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); | 327 | struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); |
337 | struct mt9t031 *mt9t031 = to_mt9t031(client); | 328 | struct mt9t031 *mt9t031 = to_mt9t031(client); |
338 | 329 | ||
330 | /* Make sure we don't exceed sensor limits */ | ||
331 | if (rect->left + rect->width > icd->rect_max.left + icd->rect_max.width) | ||
332 | rect->left = icd->rect_max.width + icd->rect_max.left - | ||
333 | rect->width; | ||
334 | |||
335 | if (rect->top + rect->height > icd->rect_max.height + icd->rect_max.top) | ||
336 | rect->top = icd->rect_max.height + icd->rect_max.top - | ||
337 | rect->height; | ||
338 | |||
339 | /* CROP - no change in scaling, or in limits */ | 339 | /* CROP - no change in scaling, or in limits */ |
340 | return mt9t031_set_params(icd, rect, mt9t031->xskip, mt9t031->yskip); | 340 | return mt9t031_set_params(icd, rect, mt9t031->xskip, mt9t031->yskip); |
341 | } | 341 | } |