summaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/s5p-jpeg
diff options
context:
space:
mode:
authorJacek Anaszewski <j.anaszewski@samsung.com>2013-11-21 13:34:01 -0300
committerMauro Carvalho Chehab <m.chehab@samsung.com>2013-12-18 11:50:24 -0200
commit11fbea3ef3d2d47c5cba37cf275f043cb41ddbc7 (patch)
treeb1a2fa2b7dce835e283db98212f48783d45fc1a6 /drivers/media/platform/s5p-jpeg
parent4a30d30b87e5aa444a7f5983cd5b7d2466f4cb31 (diff)
downloadlinux-11fbea3ef3d2d47c5cba37cf275f043cb41ddbc7.tar.gz
linux-11fbea3ef3d2d47c5cba37cf275f043cb41ddbc7.tar.bz2
linux-11fbea3ef3d2d47c5cba37cf275f043cb41ddbc7.zip
[media] s5p-jpeg: Ensure setting correct value of the chroma subsampling control
Exynos4x12 has limitations regarding setting chroma subsampling of an output JPEG image. It cannot be lower than the subsampling of the raw source image. Also in case of V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY option the source image fourcc has to be V4L2_PIX_FMT_GREY. This patch implements try_ctrl callback containing mechanism that prevents setting invalid value of the V4L2_CID_JPEG_CHROMA_SUBSAMPLING control. 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, 35 insertions, 0 deletions
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index ea9cf737201b..3c06487918d5 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -1213,6 +1213,40 @@ static int s5p_jpeg_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
return 0;
}
+static int s5p_jpeg_try_ctrl(struct v4l2_ctrl *ctrl)
+{
+ struct s5p_jpeg_ctx *ctx = ctrl_to_ctx(ctrl);
+ unsigned long flags;
+ int ret = 0;
+
+ spin_lock_irqsave(&ctx->jpeg->slock, flags);
+
+ if (ctrl->id == V4L2_CID_JPEG_CHROMA_SUBSAMPLING) {
+ if (ctx->jpeg->variant->version == SJPEG_S5P)
+ goto error_free;
+ /*
+ * The exynos4x12 device requires input raw image fourcc
+ * to be V4L2_PIX_FMT_GREY if gray jpeg format
+ * is to be set.
+ */
+ if (ctx->out_q.fmt->fourcc != V4L2_PIX_FMT_GREY &&
+ ctrl->val == V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY) {
+ ret = -EINVAL;
+ goto error_free;
+ }
+ /*
+ * The exynos4x12 device requires resulting jpeg subsampling
+ * not to be lower than the input raw image subsampling.
+ */
+ if (ctx->out_q.fmt->subsampling > ctrl->val)
+ ctrl->val = ctx->out_q.fmt->subsampling;
+ }
+
+error_free:
+ spin_unlock_irqrestore(&ctx->jpeg->slock, flags);
+ return ret;
+}
+
static int s5p_jpeg_s_ctrl(struct v4l2_ctrl *ctrl)
{
struct s5p_jpeg_ctx *ctx = ctrl_to_ctx(ctrl);
@@ -1238,6 +1272,7 @@ static int s5p_jpeg_s_ctrl(struct v4l2_ctrl *ctrl)
static const struct v4l2_ctrl_ops s5p_jpeg_ctrl_ops = {
.g_volatile_ctrl = s5p_jpeg_g_volatile_ctrl,
+ .try_ctrl = s5p_jpeg_try_ctrl,
.s_ctrl = s5p_jpeg_s_ctrl,
};