summaryrefslogtreecommitdiff
path: root/drivers/media/platform/coda/coda-jpeg.c
diff options
context:
space:
mode:
authorPhilipp Zabel <philipp.zabel@gmail.com>2015-12-02 19:58:51 +0300
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-12-23 19:02:14 +0300
commitd4de047b536cc0fe06521eda111f4a31a0844e11 (patch)
treea5f9ec09e18666b15ef566eedfb22ca9e07c8612 /drivers/media/platform/coda/coda-jpeg.c
parent5542570ea9e7dfbd699dce3d542761926ef26712 (diff)
downloadlinux-d4de047b536cc0fe06521eda111f4a31a0844e11.tar.xz
[media] coda: relax coda_jpeg_check_buffer for trailing bytes
coda_jpeg_check_buffer only cares about the buffer length and contents, so change the parameter type back from v4l2_vb2_buffer to just the vb2_buffer. Instead of just checking the first and last bytes for the SOI and EOI markers, relax the EOI marker check a bit and allow up to 32 trailing bytes after the EOI marker as hardware generated JPEGs sometimes contain some alignment overhead. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Kamil Debski <k.debski@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/platform/coda/coda-jpeg.c')
-rw-r--r--drivers/media/platform/coda/coda-jpeg.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/drivers/media/platform/coda/coda-jpeg.c b/drivers/media/platform/coda/coda-jpeg.c
index 96cd42a0baaf..9f899a6cefed 100644
--- a/drivers/media/platform/coda/coda-jpeg.c
+++ b/drivers/media/platform/coda/coda-jpeg.c
@@ -178,14 +178,28 @@ int coda_jpeg_write_tables(struct coda_ctx *ctx)
return 0;
}
-bool coda_jpeg_check_buffer(struct coda_ctx *ctx, struct vb2_v4l2_buffer *vb)
+bool coda_jpeg_check_buffer(struct coda_ctx *ctx, struct vb2_buffer *vb)
{
- void *vaddr = vb2_plane_vaddr(&vb->vb2_buf, 0);
- u16 soi = be16_to_cpup((__be16 *)vaddr);
- u16 eoi = be16_to_cpup((__be16 *)(vaddr +
- vb2_get_plane_payload(&vb->vb2_buf, 0) - 2));
+ void *vaddr = vb2_plane_vaddr(vb, 0);
+ u16 soi, eoi;
+ int len, i;
+
+ soi = be16_to_cpup((__be16 *)vaddr);
+ if (soi != SOI_MARKER)
+ return false;
+
+ len = vb2_get_plane_payload(vb, 0);
+ vaddr += len - 2;
+ for (i = 0; i < 32; i++) {
+ eoi = be16_to_cpup((__be16 *)(vaddr - i));
+ if (eoi == EOI_MARKER) {
+ if (i > 0)
+ vb2_set_plane_payload(vb, 0, len - i);
+ return true;
+ }
+ }
- return soi == SOI_MARKER && eoi == EOI_MARKER;
+ return false;
}
/*