From patchwork Thu Apr 10 07:32:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 3960251 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 01B0E9F336 for ; Thu, 10 Apr 2014 07:32:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7A14D20630 for ; Thu, 10 Apr 2014 07:32:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 90FC820629 for ; Thu, 10 Apr 2014 07:32:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965213AbaDJHcl (ORCPT ); Thu, 10 Apr 2014 03:32:41 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:35006 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965199AbaDJHci (ORCPT ); Thu, 10 Apr 2014 03:32:38 -0400 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 <0N3T00JAT0YD8480@mailout3.samsung.com> for linux-media@vger.kernel.org; Thu, 10 Apr 2014 16:32:37 +0900 (KST) X-AuditID: cbfee61b-b7f456d000006dfd-13-534649158bec Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 60.28.28157.51946435; Thu, 10 Apr 2014 16:32:37 +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 <0N3T005990XW0YD0@mmp2.samsung.com>; Thu, 10 Apr 2014 16:32:36 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: s.nawrocki@samsung.com, Jacek Anaszewski , Kyungmin Park Subject: [PATCH v2 7/8] s5p_jpeg: Prevent JPEG 4:2:0 > YUV 4:2:0 decompression Date: Thu, 10 Apr 2014 09:32:17 +0200 Message-id: <1397115138-1095-7-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1397115138-1095-1-git-send-email-j.anaszewski@samsung.com> References: <1397115138-1095-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrEJMWRmVeSWpSXmKPExsVy+t9jQV1RT7dgg2nbOC16rz5ntDjb9Ibd omfDVlaLw2/aWR1YPPq2rGL0+LxJLoApissmJTUnsyy1SN8ugSvj543sgo9CFQtv7WRuYFzE 38XIwSEhYCLRvbGqi5ETyBSTuHBvPVsXIxeHkMB0Ronr3fOYIJx2Jom/S3qYQarYBAwlfr54 zQRiiwjISzzpvcEGMohZoETi0HpFkLCwgJ/Em4v9rCA2i4CqRPe2+WCtvALuEusuLWKE2Ksg MWeSDUiYU8BD4see9WAlQkAlGydfZ57AyLuAkWEVo2hqQXJBcVJ6rpFecWJucWleul5yfu4m RnBIPJPewbiqweIQowAHoxIP74FlrsFCrIllxZW5hxglOJiVRHgVhNyChXhTEiurUovy44tK c1KLDzFKc7AoifMebLUOFBJITyxJzU5NLUgtgskycXBKNTDmdQjdzzm4YMncDP4ndS97bXl3 tgtyZe4XMWxlmSDAxq+b/VWw2K43minWfJ3MnsD539uSJDdkuBvutjP1WiJae403eop29uJH qW8uG3z8peFke2F+fIG/5+NZWSKb1N5MaNjFH8dxROmdR7fM4lvdS7sf7EwRd/yktDesiqk9 af4X78Xh8kosxRmJhlrMRcWJAKJ7MA4FAgAA 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.5 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 Prevent decompression of a JPEG 4:2:0 with odd width to the YUV 4:2:0 compliant formats for Exynos4x12 SoCs and adjust capture format to RGB565 in such a case. This is required because the configuration would produce a raw image with broken luma component. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 393f3fd..24545bd 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1064,15 +1064,17 @@ static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv, return -EINVAL; } + if ((ctx->jpeg->variant->version != SJPEG_EXYNOS4) || + (ctx->mode != S5P_JPEG_DECODE)) + goto exit; + /* * 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 * capture format to the one with subsampling equal to the input jpeg. */ - if ((ctx->jpeg->variant->version == SJPEG_EXYNOS4) && - (ctx->mode == S5P_JPEG_DECODE) && - (fmt->flags & SJPEG_FMT_NON_RGB) && + if ((fmt->flags & SJPEG_FMT_NON_RGB) && (fmt->subsampling < ctx->subsampling)) { ret = s5p_jpeg_adjust_fourcc_to_subsampling(ctx->subsampling, fmt->fourcc, @@ -1085,6 +1087,23 @@ static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv, FMT_TYPE_CAPTURE); } + /* + * Decompression of a JPEG file with 4:2:0 subsampling and odd + * width to the YUV 4:2:0 compliant formats produces a raw image + * with broken luma component. Adjust capture format to RGB565 + * in such a case. + */ + if (ctx->subsampling == V4L2_JPEG_CHROMA_SUBSAMPLING_420 && + (ctx->out_q.w & 1) && + (pix->pixelformat == V4L2_PIX_FMT_NV12 || + pix->pixelformat == V4L2_PIX_FMT_NV21 || + pix->pixelformat == V4L2_PIX_FMT_YUV420)) { + pix->pixelformat = V4L2_PIX_FMT_RGB565; + fmt = s5p_jpeg_find_format(ctx, pix->pixelformat, + FMT_TYPE_CAPTURE); + } + +exit: return vidioc_try_fmt(f, fmt, ctx, FMT_TYPE_CAPTURE); }