From patchwork Wed Dec 18 14:49:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 3370451 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 59CEAC0D4B for ; Wed, 18 Dec 2013 14:50:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BBC64205E7 for ; Wed, 18 Dec 2013 14:50:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A65F205DF for ; Wed, 18 Dec 2013 14:50:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755055Ab3LROuN (ORCPT ); Wed, 18 Dec 2013 09:50:13 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:45817 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755044Ab3LROuL (ORCPT ); Wed, 18 Dec 2013 09:50:11 -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 <0MY0003M0BVMEG60@mailout3.samsung.com> for linux-media@vger.kernel.org; Wed, 18 Dec 2013 23:50:10 +0900 (KST) X-AuditID: cbfee61b-b7fbf6d0000051a3-e1-52b1b622fdb1 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 79.45.20899.226B1B25; Wed, 18 Dec 2013 23:50:10 +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 <0MY0003L3BUWKB40@mmp2.samsung.com>; Wed, 18 Dec 2013 23:50:10 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: kyungmin.park@samsung.com, s.nawrocki@samsung.com, Jacek Anaszewski Subject: [PATCH v3 7/8] s5p-jpeg: Ensure setting correct value of the chroma subsampling control Date: Wed, 18 Dec 2013 15:49:34 +0100 Message-id: <1387378175-23399-8-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1387378175-23399-1-git-send-email-j.anaszewski@samsung.com> References: <1387378175-23399-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKJMWRmVeSWpSXmKPExsVy+t9jQV2lbRuDDHa3i1j0Xn3OaHG26Q27 Rc+GrawWh9+0szqwePRtWcXo8XmTXABTFJdNSmpOZllqkb5dAlfGhw0dbAUbhCqa70xibWCc y9/FyMkhIWAiMfvYDXYIW0ziwr31bF2MXBxCAtMZJebPP8kM4bQzSdxdfosFpIpNwFDi54vX TCC2iIC8xJPeG2wgNrNAisTVH0/BbGGBJInNz7aATWURUJV41LeSFcTmFfCQ+Pq2E6iXA2ib gsScSTYgYU4BT4n3f6cwgthCQCV/321gnMDIu4CRYRWjaGpBckFxUnqukV5xYm5xaV66XnJ+ 7iZGcGA8k97BuKrB4hCjAAejEg+vh9fGICHWxLLiytxDjBIczEoivEJbgUK8KYmVValF+fFF pTmpxYcYpTlYlMR5D7ZaBwoJpCeWpGanphakFsFkmTg4pRoY103piSvTmrbz+7K7T+2lViwp +1LbU7bmyWqzXbpXdASNtxeb9ETMd9JevU1COcvYMaPmcm+ad+eiGfOd/i09sm+67zk5lvSa U6JCsx/e7xBfuGiiXoPwmVQZpWVTjqRv0+fre6FuosDNk3zO72btteAbomqHBWo4q88/PvWs eXvj9ccvftaZKrEUZyQaajEXFScCAJ1xjbcIAgAA Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.4 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 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 Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index fc14bbc..c46c9af 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, };