diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2012-03-21 11:03:26 (GMT) |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-05-15 19:11:07 (GMT) |
commit | bed8d8033037431be3968cd604f32ad8b7260600 (patch) | |
tree | 7d84aeb5052fb6b6f2467713f789292724654192 /drivers/media/video/soc_camera.c | |
parent | 8929c96378a162263c8e3e547975e283dfd17e7f (diff) | |
download | linux-bed8d8033037431be3968cd604f32ad8b7260600.tar.xz |
[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/soc_camera.c')
-rw-r--r-- | drivers/media/video/soc_camera.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index d86b150..5e3274e 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c @@ -164,6 +164,7 @@ static int soc_camera_try_fmt(struct soc_camera_device *icd, struct v4l2_format *f) { struct soc_camera_host *ici = to_soc_camera_host(icd->parent); + const struct soc_camera_format_xlate *xlate; struct v4l2_pix_format *pix = &f->fmt.pix; int ret; @@ -177,22 +178,22 @@ static int soc_camera_try_fmt(struct soc_camera_device *icd, if (ret < 0) return ret; - if (!pix->sizeimage) { - if (!pix->bytesperline) { - const struct soc_camera_format_xlate *xlate; + xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat); + if (!xlate) + return -EINVAL; - xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat); - if (!xlate) - return -EINVAL; + ret = soc_mbus_bytes_per_line(pix->width, xlate->host_fmt); + if (ret < 0) + return ret; - ret = soc_mbus_bytes_per_line(pix->width, - xlate->host_fmt); - if (ret > 0) - pix->bytesperline = ret; - } - if (pix->bytesperline) - pix->sizeimage = pix->bytesperline * pix->height; - } + pix->bytesperline = max_t(u32, pix->bytesperline, ret); + + ret = soc_mbus_image_size(xlate->host_fmt, pix->bytesperline, + pix->height); + if (ret < 0) + return ret; + + pix->sizeimage = max_t(u32, pix->sizeimage, ret); return 0; } |