From patchwork Tue Nov 19 14:27:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 3202581 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 E73839F26C for ; Tue, 19 Nov 2013 14:28:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ABDEE20306 for ; Tue, 19 Nov 2013 14:28:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 762DC20121 for ; Tue, 19 Nov 2013 14:28:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753127Ab3KSO23 (ORCPT ); Tue, 19 Nov 2013 09:28:29 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:55630 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752465Ab3KSO2E (ORCPT ); Tue, 19 Nov 2013 09:28:04 -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 <0MWI00H7TLIMVM60@mailout3.samsung.com> for linux-media@vger.kernel.org; Tue, 19 Nov 2013 23:28:04 +0900 (KST) X-AuditID: cbfee61b-b7fd56d000001fc6-82-528b7573814b Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 84.56.08134.3757B825; Tue, 19 Nov 2013 23:28:04 +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:03 +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 12/16] s5p-jpeg: Ensure correct capture format for Exynos4x12 Date: Tue, 19 Nov 2013 15:27:04 +0100 Message-id: <1384871228-6648-13-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+t9jAd2S0u4gg57fbBa9V58zWpxtesNu 0bNhK6vF4TftrBYzJr9kc2D16NuyitHj8ya5AKYoLpuU1JzMstQifbsEroxfzzrZC+ZKV7xZ to6tgfG2aBcjJ4eEgInEizOXWSBsMYkL99azdTFycQgJLGKUWNC9hgXCaWeSePzhLCtIFZuA ocTPF6+ZQGwRAXmJJ7032EBsZoEaiSlbb7CD2MICvhKd866A2SwCqhIr7u8Gq+cV8JD4tOsE UD0H0DYFiTmTbEDCnEDhKQu3g5ULCbhLnN94kn0CI+8CRoZVjKKpBckFxUnpuUZ6xYm5xaV5 6XrJ+bmbGMEh8kx6B+OqBotDjAIcjEo8vBPcu4KEWBPLiitzDzFKcDArifA25ncHCfGmJFZW pRblxxeV5qQWH2KU5mBREuc92GodKCSQnliSmp2aWpBaBJNl4uCUamD06exZqJ1l9X3dtAOz LLvtpS917bzzyWX2p+OXLj4V///9VJFGcYZL8+Xfas/DpAUST8nsUtrqv2Dtd9lXDTPnrKuv 69RvvdYu/0Cf+17srJQyFSNBlr3t1hE1fFYsXXqec3dcKTdkF7dZpVwn3G9VeDVtzr0D3lXc Aptvea3/32W/ct7HsCtKLMUZiYZazEXFiQB3QgYrDQIAAA== 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 Adjust capture format to the Exynos4x12 device limitations, according to the subsampling value parsed from the source JPEG image header. If the capture format was set to YUV with subsampling lower than the one of the source JPEG image the decoding process would not succeed. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 78 +++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index e09b03a..15b2dea 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -941,6 +941,7 @@ static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv); + struct v4l2_pix_format *pix = &f->fmt.pix; struct s5p_jpeg_fmt *fmt; fmt = s5p_jpeg_find_format(ctx, f->fmt.pix.pixelformat, @@ -952,6 +953,83 @@ static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv, return -EINVAL; } + /* + * The exynos4x12 device requires resulting YUV image + * subsampling not to be lower than the input jpeg subsampling. + * If this requirement is not met then downgrade the requested + * output format to the one with subsampling equal to the input jpeg. + */ + if ((ctx->jpeg->variant->version != SJPEG_S5P) && + (ctx->mode == S5P_JPEG_DECODE) && + (fmt->flags & SJPEG_FMT_NON_RGB) && + (fmt->subsampling < ctx->subsampling)) { + switch (fmt->fourcc) { + case V4L2_PIX_FMT_NV24: + switch (ctx->subsampling) { + case V4L2_JPEG_CHROMA_SUBSAMPLING_422: + pix->pixelformat = V4L2_PIX_FMT_NV16; + break; + case V4L2_JPEG_CHROMA_SUBSAMPLING_420: + pix->pixelformat = V4L2_PIX_FMT_NV12; + break; + case V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY: + pix->pixelformat = V4L2_PIX_FMT_GREY; + break; + default: + return -EINVAL; + } + break; + case V4L2_PIX_FMT_NV42: + switch (ctx->subsampling) { + case V4L2_JPEG_CHROMA_SUBSAMPLING_422: + pix->pixelformat = V4L2_PIX_FMT_NV61; + break; + case V4L2_JPEG_CHROMA_SUBSAMPLING_420: + pix->pixelformat = V4L2_PIX_FMT_NV21; + break; + case V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY: + pix->pixelformat = V4L2_PIX_FMT_GREY; + break; + default: + return -EINVAL; + } + break; + case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_NV16: + case V4L2_PIX_FMT_YUV420: + switch (ctx->subsampling) { + case V4L2_JPEG_CHROMA_SUBSAMPLING_420: + pix->pixelformat = V4L2_PIX_FMT_NV12; + break; + case V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY: + pix->pixelformat = V4L2_PIX_FMT_GREY; + break; + default: + return -EINVAL; + } + break; + case V4L2_PIX_FMT_YVYU: + case V4L2_PIX_FMT_NV61: + switch (ctx->subsampling) { + case V4L2_JPEG_CHROMA_SUBSAMPLING_420: + pix->pixelformat = V4L2_PIX_FMT_NV21; + break; + case V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY: + pix->pixelformat = V4L2_PIX_FMT_GREY; + break; + default: + return -EINVAL; + } + break; + case V4L2_PIX_FMT_NV12: + case V4L2_PIX_FMT_NV21: + pix->pixelformat = V4L2_PIX_FMT_GREY; + break; + default: + return -EINVAL; + } + } + return vidioc_try_fmt(f, fmt, ctx, FMT_TYPE_CAPTURE); }