diff options
author | Albert Wang <twang13@marvell.com> | 2012-08-01 01:45:41 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-08-15 18:24:28 -0400 |
commit | 991b3137f21e13db4711f313edbe67d49bed795b (patch) | |
tree | 7bbd81dc41e29a271b56bf1e22549fea5f77a1fe /drivers/media | |
parent | ad5b987031835b0ac3064ef12209282277dbae54 (diff) |
[media] media: soc_camera: don't clear pix->sizeimage in JPEG mode
In JPEG mode, the size of image is variable due to different JPEG compression
rate. We only can get the pix->sizeimage from the user.
If we clear pix->sizeimage in soc_camera_try_fmt() then we will get it from:
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);
In general, this sizeimage will be larger than the actul JPEG image size.
But vb2 will check the buffer and size of image in __qbuf_userptr():
/* Check if the provided plane buffer is large enough */
if (planes[plane].length < q->plane_sizes[plane])
So we shouldn't clear the pix->sizeimage and also shouldn't re-calculate
the pix->sizeimage in soc_mbus_image_size() in JPEG mode
We also shouldn't re-calculate pix->bytesperline:
ret = soc_mbus_bytes_per_line(pix->width, xlate->host_fmt);
if (ret < 0)
return ret;
pix->bytesperline = max_t(u32, pix->bytesperline, ret);
pix->bytesperline also should be set by the user or by the driver's
try_fmt() implementation.
Change-Id: I700690a2287346127a624b5260922eaa5427a596
Signed-off-by: Albert Wang <twang13@marvell.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/soc_camera.c | 3 | ||||
-rw-r--r-- | drivers/media/video/soc_mediabus.c | 6 |
2 files changed, 8 insertions, 1 deletions
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index b03ffecb7438..1bde255e45df 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c | |||
@@ -171,7 +171,8 @@ static int soc_camera_try_fmt(struct soc_camera_device *icd, | |||
171 | dev_dbg(icd->pdev, "TRY_FMT(%c%c%c%c, %ux%u)\n", | 171 | dev_dbg(icd->pdev, "TRY_FMT(%c%c%c%c, %ux%u)\n", |
172 | pixfmtstr(pix->pixelformat), pix->width, pix->height); | 172 | pixfmtstr(pix->pixelformat), pix->width, pix->height); |
173 | 173 | ||
174 | if (!(ici->capabilities & SOCAM_HOST_CAP_STRIDE)) { | 174 | if (pix->pixelformat != V4L2_PIX_FMT_JPEG && |
175 | !(ici->capabilities & SOCAM_HOST_CAP_STRIDE)) { | ||
175 | pix->bytesperline = 0; | 176 | pix->bytesperline = 0; |
176 | pix->sizeimage = 0; | 177 | pix->sizeimage = 0; |
177 | } | 178 | } |
diff --git a/drivers/media/video/soc_mediabus.c b/drivers/media/video/soc_mediabus.c index 89dce097a827..a397812635d6 100644 --- a/drivers/media/video/soc_mediabus.c +++ b/drivers/media/video/soc_mediabus.c | |||
@@ -378,6 +378,9 @@ EXPORT_SYMBOL(soc_mbus_samples_per_pixel); | |||
378 | 378 | ||
379 | s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf) | 379 | s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf) |
380 | { | 380 | { |
381 | if (mf->fourcc == V4L2_PIX_FMT_JPEG) | ||
382 | return 0; | ||
383 | |||
381 | if (mf->layout != SOC_MBUS_LAYOUT_PACKED) | 384 | if (mf->layout != SOC_MBUS_LAYOUT_PACKED) |
382 | return width * mf->bits_per_sample / 8; | 385 | return width * mf->bits_per_sample / 8; |
383 | 386 | ||
@@ -400,6 +403,9 @@ EXPORT_SYMBOL(soc_mbus_bytes_per_line); | |||
400 | s32 soc_mbus_image_size(const struct soc_mbus_pixelfmt *mf, | 403 | s32 soc_mbus_image_size(const struct soc_mbus_pixelfmt *mf, |
401 | u32 bytes_per_line, u32 height) | 404 | u32 bytes_per_line, u32 height) |
402 | { | 405 | { |
406 | if (mf->fourcc == V4L2_PIX_FMT_JPEG) | ||
407 | return 0; | ||
408 | |||
403 | if (mf->layout == SOC_MBUS_LAYOUT_PACKED) | 409 | if (mf->layout == SOC_MBUS_LAYOUT_PACKED) |
404 | return bytes_per_line * height; | 410 | return bytes_per_line * height; |
405 | 411 | ||