aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/s5p-jpeg
diff options
context:
space:
mode:
authorJacek Anaszewski <j.anaszewski@samsung.com>2013-11-21 13:33:09 -0300
committerMauro Carvalho Chehab <m.chehab@samsung.com>2013-12-18 11:48:16 -0200
commitf84339628d9224200e9145320da494da2d92cd50 (patch)
treedba10e8c6d503672d30a9b08fd48f6ecf557fa11 /drivers/media/platform/s5p-jpeg
parent[media] s5p-jpeg: JPEG codec (diff)
downloadlinux-dev-f84339628d9224200e9145320da494da2d92cd50.tar.xz
linux-dev-f84339628d9224200e9145320da494da2d92cd50.zip
[media] s5p-jpeg: Retrieve "YCbCr subsampling" field from the jpeg header
Make s5p_jpeg_parse_hdr function capable of parsing "YCbCr subsampling" field of a jpeg file header. Store the parsed value in the context. The information about source JPEG subsampling is required to make validation of destination format possible, which must be conducted for exynos4x12 device as the decoding process will not succeed if the destination format is set to YUV with subsampling lower than the one of the source JPEG image. With this knowledge the driver can adjust the destination format appropriately. Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/platform/s5p-jpeg')
-rw-r--r--drivers/media/platform/s5p-jpeg/jpeg-core.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index fbadbb04f2e9..0ae3d2cdef03 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -624,10 +624,11 @@ static void skip(struct s5p_jpeg_buffer *buf, long len)
}
static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result,
- unsigned long buffer, unsigned long size)
+ unsigned long buffer, unsigned long size,
+ struct s5p_jpeg_ctx *ctx)
{
int c, components, notfound;
- unsigned int height, width, word;
+ unsigned int height, width, word, subsampling = 0;
long length;
struct s5p_jpeg_buffer jpeg_buffer;
@@ -666,7 +667,15 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result,
break;
notfound = 0;
- skip(&jpeg_buffer, components * 3);
+ if (components == 1) {
+ subsampling = 0x33;
+ } else {
+ skip(&jpeg_buffer, 1);
+ subsampling = get_byte(&jpeg_buffer);
+ skip(&jpeg_buffer, 1);
+ }
+
+ skip(&jpeg_buffer, components * 2);
break;
/* skip payload-less markers */
@@ -688,6 +697,24 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result,
result->w = width;
result->h = height;
result->size = components;
+
+ switch (subsampling) {
+ case 0x11:
+ ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_444;
+ break;
+ case 0x21:
+ ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_422;
+ break;
+ case 0x22:
+ ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_420;
+ break;
+ case 0x33:
+ ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY;
+ break;
+ default:
+ return false;
+ }
+
return !notfound;
}
@@ -1438,7 +1465,7 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb)
ctx->hdr_parsed = s5p_jpeg_parse_hdr(&tmp,
(unsigned long)vb2_plane_vaddr(vb, 0),
min((unsigned long)ctx->out_q.size,
- vb2_get_plane_payload(vb, 0)));
+ vb2_get_plane_payload(vb, 0)), ctx);
if (!ctx->hdr_parsed) {
vb2_buffer_done(vb, VB2_BUF_STATE_ERROR);
return;