diff options
-rw-r--r-- | drivers/media/platform/coda/coda-bit.c | 2 | ||||
-rw-r--r-- | drivers/media/platform/coda/coda-jpeg.c | 26 | ||||
-rw-r--r-- | drivers/media/platform/coda/coda.h | 2 |
3 files changed, 22 insertions, 8 deletions
diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c index 21beb97974c2..7d28899f89ce 100644 --- a/drivers/media/platform/coda/coda-bit.c +++ b/drivers/media/platform/coda/coda-bit.c | |||
@@ -246,7 +246,7 @@ void coda_fill_bitstream(struct coda_ctx *ctx, bool streaming) | |||
246 | 246 | ||
247 | /* Drop frames that do not start/end with a SOI/EOI markers */ | 247 | /* Drop frames that do not start/end with a SOI/EOI markers */ |
248 | if (ctx->codec->src_fourcc == V4L2_PIX_FMT_JPEG && | 248 | if (ctx->codec->src_fourcc == V4L2_PIX_FMT_JPEG && |
249 | !coda_jpeg_check_buffer(ctx, src_buf)) { | 249 | !coda_jpeg_check_buffer(ctx, &src_buf->vb2_buf)) { |
250 | v4l2_err(&ctx->dev->v4l2_dev, | 250 | v4l2_err(&ctx->dev->v4l2_dev, |
251 | "dropping invalid JPEG frame %d\n", | 251 | "dropping invalid JPEG frame %d\n", |
252 | ctx->qsequence); | 252 | ctx->qsequence); |
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) | |||
178 | return 0; | 178 | return 0; |
179 | } | 179 | } |
180 | 180 | ||
181 | bool coda_jpeg_check_buffer(struct coda_ctx *ctx, struct vb2_v4l2_buffer *vb) | 181 | bool coda_jpeg_check_buffer(struct coda_ctx *ctx, struct vb2_buffer *vb) |
182 | { | 182 | { |
183 | void *vaddr = vb2_plane_vaddr(&vb->vb2_buf, 0); | 183 | void *vaddr = vb2_plane_vaddr(vb, 0); |
184 | u16 soi = be16_to_cpup((__be16 *)vaddr); | 184 | u16 soi, eoi; |
185 | u16 eoi = be16_to_cpup((__be16 *)(vaddr + | 185 | int len, i; |
186 | vb2_get_plane_payload(&vb->vb2_buf, 0) - 2)); | 186 | |
187 | soi = be16_to_cpup((__be16 *)vaddr); | ||
188 | if (soi != SOI_MARKER) | ||
189 | return false; | ||
190 | |||
191 | len = vb2_get_plane_payload(vb, 0); | ||
192 | vaddr += len - 2; | ||
193 | for (i = 0; i < 32; i++) { | ||
194 | eoi = be16_to_cpup((__be16 *)(vaddr - i)); | ||
195 | if (eoi == EOI_MARKER) { | ||
196 | if (i > 0) | ||
197 | vb2_set_plane_payload(vb, 0, len - i); | ||
198 | return true; | ||
199 | } | ||
200 | } | ||
187 | 201 | ||
188 | return soi == SOI_MARKER && eoi == EOI_MARKER; | 202 | return false; |
189 | } | 203 | } |
190 | 204 | ||
191 | /* | 205 | /* |
diff --git a/drivers/media/platform/coda/coda.h b/drivers/media/platform/coda/coda.h index 6cda81e4163a..d08e9843e9f2 100644 --- a/drivers/media/platform/coda/coda.h +++ b/drivers/media/platform/coda/coda.h | |||
@@ -289,7 +289,7 @@ void coda_m2m_buf_done(struct coda_ctx *ctx, struct vb2_v4l2_buffer *buf, | |||
289 | 289 | ||
290 | int coda_h264_padding(int size, char *p); | 290 | int coda_h264_padding(int size, char *p); |
291 | 291 | ||
292 | bool coda_jpeg_check_buffer(struct coda_ctx *ctx, struct vb2_v4l2_buffer *vb); | 292 | bool coda_jpeg_check_buffer(struct coda_ctx *ctx, struct vb2_buffer *vb); |
293 | int coda_jpeg_write_tables(struct coda_ctx *ctx); | 293 | int coda_jpeg_write_tables(struct coda_ctx *ctx); |
294 | void coda_set_jpeg_compression_quality(struct coda_ctx *ctx, int quality); | 294 | void coda_set_jpeg_compression_quality(struct coda_ctx *ctx, int quality); |
295 | 295 | ||