|
@@ -1603,36 +1603,53 @@ static int s5p_jpeg_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-static int s5p_jpeg_try_ctrl(struct v4l2_ctrl *ctrl)
|
|
|
|
|
|
+static int s5p_jpeg_adjust_subs_ctrl(struct s5p_jpeg_ctx *ctx, int *ctrl_val)
|
|
{
|
|
{
|
|
- 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;
|
|
|
|
|
|
+ switch (ctx->jpeg->variant->version) {
|
|
|
|
+ case SJPEG_S5P:
|
|
|
|
+ return 0;
|
|
|
|
+ case SJPEG_EXYNOS3250:
|
|
|
|
+ /*
|
|
|
|
+ * The exynos3250 device can produce JPEG image only
|
|
|
|
+ * of 4:4:4 subsampling when given RGB32 source image.
|
|
|
|
+ */
|
|
|
|
+ if (ctx->out_q.fmt->fourcc == V4L2_PIX_FMT_RGB32)
|
|
|
|
+ *ctrl_val = 0;
|
|
|
|
+ break;
|
|
|
|
+ case SJPEG_EXYNOS4:
|
|
/*
|
|
/*
|
|
* The exynos4x12 device requires input raw image fourcc
|
|
* The exynos4x12 device requires input raw image fourcc
|
|
* to be V4L2_PIX_FMT_GREY if gray jpeg format
|
|
* to be V4L2_PIX_FMT_GREY if gray jpeg format
|
|
* is to be set.
|
|
* is to be set.
|
|
*/
|
|
*/
|
|
if (ctx->out_q.fmt->fourcc != V4L2_PIX_FMT_GREY &&
|
|
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;
|
|
|
|
|
|
+ *ctrl_val == V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
|
|
-error_free:
|
|
|
|
|
|
+ /*
|
|
|
|
+ * The exynos4x12 and exynos3250 devices require 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;
|
|
|
|
+
|
|
|
|
+ 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)
|
|
|
|
+ ret = s5p_jpeg_adjust_subs_ctrl(ctx, &ctrl->val);
|
|
|
|
+
|
|
spin_unlock_irqrestore(&ctx->jpeg->slock, flags);
|
|
spin_unlock_irqrestore(&ctx->jpeg->slock, flags);
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|