From patchwork Tue Nov 19 14:27:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 3202561 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5DD4D9F817 for ; Tue, 19 Nov 2013 14:28:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3916E20373 for ; Tue, 19 Nov 2013 14:28:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0633720360 for ; Tue, 19 Nov 2013 14:28:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753122Ab3KSO2P (ORCPT ); Tue, 19 Nov 2013 09:28:15 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:19238 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752496Ab3KSO2N (ORCPT ); Tue, 19 Nov 2013 09:28:13 -0500 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MWI006K9LIUBP10@mailout2.samsung.com> for linux-media@vger.kernel.org; Tue, 19 Nov 2013 23:28:12 +0900 (KST) X-AuditID: cbfee61a-b7f836d0000025d7-e9-528b757cd4f9 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 52.D8.09687.C757B825; Tue, 19 Nov 2013 23:28:12 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MWI00IBKLHFEGB0@mmp1.samsung.com>; Tue, 19 Nov 2013 23:28:12 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: kyungmin.park@samsung.com, s.nawrocki@samsung.com, sw0312.kim@samsung.com, Jacek Anaszewski Subject: [PATCH 15/16] s5p-jpeg: Ensure setting correct value of the chroma subsampling control Date: Tue, 19 Nov 2013 15:27:07 +0100 Message-id: <1384871228-6648-16-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1384871228-6648-1-git-send-email-j.anaszewski@samsung.com> References: <1384871228-6648-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFJMWRmVeSWpSXmKPExsVy+t9jAd2a0u4gg2+vuC16rz5ntDjb9Ibd omfDVlaLw2/aWS1mTH7J5sDq0bdlFaPH501yAUxRXDYpqTmZZalF+nYJXBl9l/+zFUwRrNiy fSdrA2MnXxcjJ4eEgInE9JY7TBC2mMSFe+vZuhi5OIQEFjFKnFvxnxnCaWeSaLq0jxmkik3A UOLni9dgHSIC8hJPem+wgdjMAjUSU7beYAexhQUSJVa9PcsKYrMIqEp8PHgGrIZXwEPi0dZP QDUcQNsUJOZMsgEJcwKFpyzcDtYqJOAucX7jSfYJjLwLGBlWMYqmFiQXFCel5xrqFSfmFpfm pesl5+duYgSHyDOpHYwrGywOMQpwMCrx8E5w7woSYk0sK67MPcQowcGsJMLbmN8dJMSbklhZ lVqUH19UmpNafIhRmoNFSZz3QKt1oJBAemJJanZqakFqEUyWiYNTqoFRdC2jl9K/WgvbD9tr s9WePBXxYpCxPW/CkpW73fft972n7slr5jtOz3bfsnIFo06FbvbTDus71VtyRY8/vpDu/qbx j+C8lf+Xch+4vLX6S6HAunnLCkX2ZMjudU1U+1QxcUNS0rwDhVcWXbv0V/Hl9l+Ne/WFnba5 X9GxVjg0a3mGjtErt5l6SizFGYmGWsxFxYkAPkSg3g0CAAA= 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 adds 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 | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index d4db612..3605470 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1176,6 +1176,7 @@ static int s5p_jpeg_s_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); @@ -1187,12 +1188,34 @@ static int s5p_jpeg_s_ctrl(struct v4l2_ctrl *ctrl) ctx->restart_interval = ctrl->val; break; case V4L2_CID_JPEG_CHROMA_SUBSAMPLING: - ctx->subsampling = ctrl->val; + if (ctx->jpeg->variant->version == SJPEG_S5P) { + ctx->subsampling = ctrl->val; + break; + } + /* + * 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) + ctx->subsampling = ctx->out_q.fmt->subsampling; + else + ctx->subsampling = ctrl->val; break; } +error_free: spin_unlock_irqrestore(&ctx->jpeg->slock, flags); - return 0; + return ret; } static const struct v4l2_ctrl_ops s5p_jpeg_ctrl_ops = {