From patchwork Mon Apr 7 13:16:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 3945451 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 387D1BFF02 for ; Mon, 7 Apr 2014 13:17:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 41CE12022F for ; Mon, 7 Apr 2014 13:17:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6DE912022D for ; Mon, 7 Apr 2014 13:17:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755373AbaDGNRB (ORCPT ); Mon, 7 Apr 2014 09:17:01 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:64649 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755330AbaDGNRA (ORCPT ); Mon, 7 Apr 2014 09:17:00 -0400 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N3N00JQRWWBO0C0@mailout2.samsung.com> for linux-media@vger.kernel.org; Mon, 07 Apr 2014 22:16:59 +0900 (KST) X-AuditID: cbfee61b-b7f456d000006dfd-10-5342a54be060 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 89.E0.28157.B45A2435; Mon, 07 Apr 2014 22:16:59 +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 <0N3N00MSNWV2V030@mmp2.samsung.com>; Mon, 07 Apr 2014 22:16:59 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: s.nawrocki@samsung.com, Jacek Anaszewski , Kyungmin Park Subject: [PATCH 7/8] [media] s5p_jpeg: Prevent JPEG 4:2:0 > YUV 4:2:0 decompression Date: Mon, 07 Apr 2014 15:16:12 +0200 Message-id: <1396876573-15811-7-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1396876573-15811-1-git-send-email-j.anaszewski@samsung.com> References: <1396876573-15811-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrIJMWRmVeSWpSXmKPExsVy+t9jQV3vpU7BBi82a1v0Xn3OaHG26Q27 Rc+GrawWh9+0szqwePRtWcXo8XmTXABTFJdNSmpOZllqkb5dAldGx4bzjAUThCuOTZnI0sB4 gL+LkZNDQsBEoqXhDhuELSZx4d56IJuLQ0hgOqPEmS972EESQgLtTBI3DhiA2GwChhI/X7xm ArFFBOQlnvTeAGrg4GAWKJE4tF4RxBQWCJV4cNYFxGQRUJXoOVoIUswr4CFxYu1MJpCwhICC xJxJNiBhTgFPiWkrNzFC7PGQePTyNfsERt4FjAyrGEVTC5ILipPSc430ihNzi0vz0vWS83M3 MYID4pn0DsZVDRaHGAU4GJV4eAMPOAYLsSaWFVfmHmKU4GBWEuE17HIKFuJNSaysSi3Kjy8q zUktPsQozcGiJM57sNU6UEggPbEkNTs1tSC1CCbLxMEp1cBYs3UGR9bTXesPF/+eJeD191d2 08MljRuz3Gq3idqpxH08O6nNZnHvnebUKabvGJWmHd4g2rhy3kO+yrQozc5t3h83emTkPpfZ XnvPnVN08jmrR5mHkxgZHXU8QpmN9pj1FHH6u/RZGcYe5tMSPii+vFNX6vS03jTH95Ke3lv1 VpgldSWfzlViKc5INNRiLipOBAB3gFw7BAIAAA== 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.2 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 | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index d266e78..9228bcb 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,22 @@ static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv, FMT_TYPE_CAPTURE); } + 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); + v4l2_info(&ctx->jpeg->v4l2_dev, + "Adjusted capture fourcc to RGB565. Decompression\n" + "of a JPEG file with 4:2:0 subsampling and odd\n" + "width to the YUV 4:2:0 compliant formats produces\n" + "a raw image with broken luma component.\n"); + } + +exit: return vidioc_try_fmt(f, fmt, ctx, FMT_TYPE_CAPTURE); }