diff mbox

[16/16] s5p-jpeg: Adjust g_volatile_ctrl callback to Exynos4x12 needs

Message ID 1384871228-6648-17-git-send-email-j.anaszewski@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jacek Anaszewski Nov. 19, 2013, 2:27 p.m. UTC
Whereas S5PC210 device produces decoded JPEG subsampling
values that map on V4L2_JPEG_CHROMA_SUBSAMPLNG values,
the Exynos4x12 device doesn't. This patch adds helper
function decoded_subsampling_to_v4l2, which performs
HW -> V4L2 translation.

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/media/platform/s5p-jpeg/jpeg-core.c |   36 ++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index 3605470..90d2f69 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -358,6 +358,13 @@  static const unsigned char hactblg0[162] = {
 	0xf9, 0xfa
 };
 
+static int exynos4x12_decoded_subsampling[] = {
+	V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY,
+	V4L2_JPEG_CHROMA_SUBSAMPLING_444,
+	V4L2_JPEG_CHROMA_SUBSAMPLING_422,
+	V4L2_JPEG_CHROMA_SUBSAMPLING_420,
+};
+
 static inline struct s5p_jpeg_ctx *ctrl_to_ctx(struct v4l2_ctrl *c)
 {
 	return container_of(c->handler, struct s5p_jpeg_ctx, ctrl_handler);
@@ -368,6 +375,28 @@  static inline struct s5p_jpeg_ctx *fh_to_ctx(struct v4l2_fh *fh)
 	return container_of(fh, struct s5p_jpeg_ctx, fh);
 }
 
+static inline int decoded_subsampling_to_v4l2(struct s5p_jpeg_ctx *ctx)
+{
+	int subsampling;
+
+	WARN_ON(ctx->subsampling > 3);
+
+	if (ctx->jpeg->variant->version == SJPEG_S5P) {
+		if (ctx->subsampling > 2)
+			subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY;
+		else
+			subsampling = ctx->subsampling;
+	} else {
+		if (ctx->subsampling > 2)
+			subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_420;
+		else
+			subsampling =
+			    exynos4x12_decoded_subsampling[ctx->subsampling];
+	}
+
+	return subsampling;
+}
+
 static inline void s5p_jpeg_set_qtbl(void __iomem *regs,
 				     const unsigned char *qtbl,
 				     unsigned long tab, int len)
@@ -1159,12 +1188,7 @@  static int s5p_jpeg_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
 	switch (ctrl->id) {
 	case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
 		spin_lock_irqsave(&jpeg->slock, flags);
-
-		WARN_ON(ctx->subsampling > S5P_SUBSAMPLING_MODE_GRAY);
-		if (ctx->subsampling > 2)
-			ctrl->val = V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY;
-		else
-			ctrl->val = ctx->subsampling;
+		ctrl->val = decoded_subsampling_to_v4l2(ctx);
 		spin_unlock_irqrestore(&jpeg->slock, flags);
 		break;
 	}