summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacek Anaszewski <j.anaszewski@samsung.com>2014-07-11 12:19:47 -0300
committerChanho Park <chanho61.park@samsung.com>2014-11-18 12:01:14 +0900
commit669d43a873b07fc48d60753e67c2f6a9f3cd36be (patch)
tree7f03ceb84801181d33022a28d446ac045d42b9a8
parentc6830dd2465c9a3d40af7dde5ac997b5127424e0 (diff)
downloadlinux-3.10-669d43a873b07fc48d60753e67c2f6a9f3cd36be.tar.gz
linux-3.10-669d43a873b07fc48d60753e67c2f6a9f3cd36be.tar.bz2
linux-3.10-669d43a873b07fc48d60753e67c2f6a9f3cd36be.zip
[media] s5p-jpeg: Prevent erroneous downscaling for Exynos3250 SoC
JPEG codec on Exynos3250 SoC produces broken raw image if a JPEG image is decoded to YUV420 format and downscaled by a factor greater than 2. Prevent this by asserting downscale ratio to 2. Change-Id: Ib415579d25a4b076a1879b3108c3a08b3dcd4ab8 Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r--drivers/media/platform/s5p-jpeg/jpeg-core.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index 3e3d94dd03f..eb13fdfb15a 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -1317,12 +1317,16 @@ static int exynos4_jpeg_get_output_buffer_size(struct s5p_jpeg_ctx *ctx,
return w * h * fmt_depth >> 3;
}
+static int exynos3250_jpeg_try_downscale(struct s5p_jpeg_ctx *ctx,
+ struct v4l2_rect *r);
+
static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct, struct v4l2_format *f)
{
struct vb2_queue *vq;
struct s5p_jpeg_q_data *q_data = NULL;
struct v4l2_pix_format *pix = &f->fmt.pix;
struct v4l2_ctrl *ctrl_subs;
+ struct v4l2_rect scale_rect;
unsigned int f_type;
vq = v4l2_m2m_get_vq(ct->fh.m2m_ctx, f->type);
@@ -1382,6 +1386,20 @@ static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct, struct v4l2_format *f)
ct->crop_rect.width = pix->width;
ct->crop_rect.height = pix->height;
}
+
+ /*
+ * Prevent downscaling to YUV420 format by more than 2
+ * for Exynos3250 SoC as it produces broken raw image
+ * in such cases.
+ */
+ if (ct->mode == S5P_JPEG_DECODE &&
+ f_type == FMT_TYPE_CAPTURE &&
+ ct->jpeg->variant->version == SJPEG_EXYNOS3250 &&
+ pix->pixelformat == V4L2_PIX_FMT_YUV420 &&
+ ct->scale_factor > 2) {
+ scale_rect.width = ct->out_q.w / 2;
+ scale_rect.height = ct->out_q.h / 2;
+ exynos3250_jpeg_try_downscale(ct, &scale_rect);
}
return 0;