diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2011-06-04 18:06:47 (GMT) |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-07-27 20:53:22 (GMT) |
commit | 28281a71eb3bc08a0fb9514886e7d6e868f71b3f (patch) | |
tree | 7c17c295b3bba4693eb44c80315945b26823d9f4 | |
parent | 497833c6813dde5ca27cc94e28c973d601d601e1 (diff) | |
download | linux-28281a71eb3bc08a0fb9514886e7d6e868f71b3f.tar.xz |
[media] V4L: mx2_camera: .try_fmt shouldn't fail
If the user is requesting too large a frame, instead of failing
select an acceptable geometry, preserving the requested aspect ratio.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/mx2_camera.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c index e05e800..55d4844 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c @@ -973,11 +973,16 @@ static int mx2_camera_try_fmt(struct soc_camera_device *icd, if (pix->bytesperline < 0) return pix->bytesperline; pix->sizeimage = pix->height * pix->bytesperline; - if (pix->sizeimage > (4 * 0x3ffff)) { /* CSIRXCNT limit */ - dev_warn(icd->dev.parent, - "Image size (%u) above limit\n", - pix->sizeimage); - return -EINVAL; + /* Check against the CSIRXCNT limit */ + if (pix->sizeimage > 4 * 0x3ffff) { + /* Adjust geometry, preserve aspect ratio */ + unsigned int new_height = int_sqrt(4 * 0x3ffff * + pix->height / pix->bytesperline); + pix->width = new_height * pix->width / pix->height; + pix->height = new_height; + pix->bytesperline = soc_mbus_bytes_per_line(pix->width, + xlate->host_fmt); + BUG_ON(pix->bytesperline < 0); } } |