From patchwork Mon Nov 25 09:58:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 3229061 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 25261C045B for ; Mon, 25 Nov 2013 09:59:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 08FEA200FF for ; Mon, 25 Nov 2013 09:59:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 534F22015D for ; Mon, 25 Nov 2013 09:59:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752506Ab3KYJ7Y (ORCPT ); Mon, 25 Nov 2013 04:59:24 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:39724 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752326Ab3KYJ7X (ORCPT ); Mon, 25 Nov 2013 04:59:23 -0500 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MWT003V6D2YXJ30@mailout3.samsung.com> for linux-media@vger.kernel.org; Mon, 25 Nov 2013 18:59:22 +0900 (KST) X-AuditID: cbfee61b-b7f166d000007a34-2b-52931f795b65 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id AD.74.31284.97F13925; Mon, 25 Nov 2013 18:59:21 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MWT004BMD1ERF40@mmp2.samsung.com>; Mon, 25 Nov 2013 18:59:20 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: sw0312.kim@samsung.com, andrzej.p@samsung.com, s.nawrocki@samsung.com, Jacek Anaszewski , Kyungmin Park Subject: [PATCH v2 16/16] s5p-jpeg: Adjust g_volatile_ctrl callback to Exynos4x12 needs Date: Mon, 25 Nov 2013 10:58:23 +0100 Message-id: <1385373503-1657-17-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1385373503-1657-1-git-send-email-j.anaszewski@samsung.com> References: <1385373503-1657-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHJMWRmVeSWpSXmKPExsVy+t9jQd1K+clBBh/2sVvMetnOYtF79Tmj xdmmN+wWPRu2slocftPOajFj8ks2BzaPvi2rGD0+b5ILYIrisklJzcksSy3St0vgyph67Atz QbtwxdXj69kaGDsFuhg5OSQETCQudR9jhLDFJC7cW8/WxcjFISQwnVFi7bxvLCAJIYF2Jolj x11AbDYBQ4mfL14zgdgiAvIST3pvgDUwCyxllLg46Qg7SEJYIFLi0tzPYDaLgKrEkY41bCA2 r4CHxI225UDNHEDbFCTmTLIBMTmBwvMnsUKscpdY8mMj+wRG3gWMDKsYRVMLkguKk9JzjfSK E3OLS/PS9ZLzczcxgkPlmfQOxlUNFocYBTgYlXh4J1ZPChJiTSwrrsw9xCjBwawkwntacnKQ EG9KYmVValF+fFFpTmrxIUZpDhYlcd6DrdaBQgLpiSWp2ampBalFMFkmDk6pBkaOPaE8EcsE 9+u8KvcNvLOxl8345lmdgCaV2q0ZytHn7n/liWU89+fn73LeNXPkjkX9qF8cXfyT9b26U2JF sPY/xcenpm9/LCcRkScqanJj9ZpTHWVMl5f+/nM2WfpF7M5r55UYjn4werC2fd0vUQPFX9tF uh99NZLmTzGUEpvsnfpMOP5rVLMSS3FGoqEWc1FxIgADlsJPEQIAAA== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 s5p_jpeg_to_user_subsampling, which performs suitable translation. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 32 ++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index ad259af..5eb1ee9 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -451,6 +451,13 @@ static int s5p_jpeg_adjust_fourcc_to_subsampling( return 0; } +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); @@ -461,6 +468,24 @@ static inline struct s5p_jpeg_ctx *fh_to_ctx(struct v4l2_fh *fh) return container_of(fh, struct s5p_jpeg_ctx, fh); } +static int s5p_jpeg_to_user_subsampling(struct s5p_jpeg_ctx *ctx) +{ + WARN_ON(ctx->subsampling > 3); + + if (ctx->jpeg->variant->version == SJPEG_S5P) { + if (ctx->subsampling > 2) + return V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY; + else + return ctx->subsampling; + } else { + if (ctx->subsampling > 2) + return V4L2_JPEG_CHROMA_SUBSAMPLING_420; + else + return + exynos4x12_decoded_subsampling[ctx->subsampling]; + } +} + static inline void s5p_jpeg_set_qtbl(void __iomem *regs, const unsigned char *qtbl, unsigned long tab, int len) @@ -1197,12 +1222,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 = s5p_jpeg_to_user_subsampling(ctx); spin_unlock_irqrestore(&jpeg->slock, flags); break; }