diff options
author | Laurent Pinchart | 2012-03-21 12:03:26 +0100 |
---|---|---|
committer | Mauro Carvalho Chehab | 2012-05-15 21:11:07 +0200 |
commit | bed8d8033037431be3968cd604f32ad8b7260600 (patch) | |
tree | 7d84aeb5052fb6b6f2467713f789292724654192 /drivers/media/video/sh_mobile_ceu_camera.c | |
parent | [media] soc-camera: Add soc_mbus_image_size (diff) | |
download | kernel-qcow2-linux-bed8d8033037431be3968cd604f32ad8b7260600.tar.gz kernel-qcow2-linux-bed8d8033037431be3968cd604f32ad8b7260600.tar.xz kernel-qcow2-linux-bed8d8033037431be3968cd604f32ad8b7260600.zip |
[media] soc-camera: Honor user-requested bytesperline and sizeimage
Compute the bytesperline and sizeimage values when trying/setting
formats or when allocating buffers by taking the user-requested values
into account.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/sh_mobile_ceu_camera.c')
-rw-r--r-- | drivers/media/video/sh_mobile_ceu_camera.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c index 87b07bcab323..79bec15cc4a3 100644 --- a/drivers/media/video/sh_mobile_ceu_camera.c +++ b/drivers/media/video/sh_mobile_ceu_camera.c @@ -214,17 +214,25 @@ static int sh_mobile_ceu_videobuf_setup(struct vb2_queue *vq, if (fmt) { const struct soc_camera_format_xlate *xlate = soc_camera_xlate_by_fourcc(icd, fmt->fmt.pix.pixelformat); - int bytes_per_line; + unsigned int bytes_per_line; + int ret; if (!xlate) return -EINVAL; - bytes_per_line = soc_mbus_bytes_per_line(fmt->fmt.pix.width, - xlate->host_fmt); - if (bytes_per_line < 0) - return bytes_per_line; + ret = soc_mbus_bytes_per_line(fmt->fmt.pix.width, + xlate->host_fmt); + if (ret < 0) + return ret; + + bytes_per_line = max_t(u32, fmt->fmt.pix.bytesperline, ret); + + ret = soc_mbus_image_size(xlate->host_fmt, bytes_per_line, + fmt->fmt.pix.height); + if (ret < 0) + return ret; - sizes[0] = bytes_per_line * fmt->fmt.pix.height; + sizes[0] = max_t(u32, fmt->fmt.pix.sizeimage, ret); } else { /* Called from VIDIOC_REQBUFS or in compatibility mode */ sizes[0] = icd->sizeimage; |