From patchwork Fri Jul 25 14:20:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 4623441 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 986D1C0338 for ; Fri, 25 Jul 2014 14:21:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D1B9A20212 for ; Fri, 25 Jul 2014 14:21:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F29792020F for ; Fri, 25 Jul 2014 14:21:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932131AbaGYOVd (ORCPT ); Fri, 25 Jul 2014 10:21:33 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:61862 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760508AbaGYOVc (ORCPT ); Fri, 25 Jul 2014 10:21:32 -0400 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N99008H5UJV9NA0@mailout4.samsung.com>; Fri, 25 Jul 2014 23:21:31 +0900 (KST) X-AuditID: cbfee61b-f79f86d00000144c-fc-53d267ea6aae Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 99.8F.05196.AE762D35; Fri, 25 Jul 2014 23:21:31 +0900 (KST) Received: from amdc1344.digital.local ([106.116.147.32]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N99004WBUIW3L00@mmp2.samsung.com>; Fri, 25 Jul 2014 23:21:30 +0900 (KST) From: Sylwester Nawrocki To: linux-media@vger.kernel.org Cc: linux-samsung-soc@vger.kernel.org, j.anaszewski@samsung.com, Sylwester Nawrocki Subject: [PATCH v3 7/9] s5p-jpeg: Prevent erroneous downscaling for Exynos3250 SoC Date: Fri, 25 Jul 2014 16:20:51 +0200 Message-id: <1406298053-30184-8-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1406298053-30184-1-git-send-email-s.nawrocki@samsung.com> References: <1406298053-30184-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCJMWRmVeSWpSXmKPExsVy+t9jQd3X6ZeCDab+ZrXovfqc0aJnw1ZW ixnn9zFZHH7TzurA4tG3ZRWjx+dNcgFMUVw2Kak5mWWpRfp2CVwZD95PZCu4zl/x9sQzlgbG rzxdjJwcEgImEm9vT2aDsMUkLtxbD2RzcQgJTGeU+Dt3PzOE08Ek0fn7IjtIFZuAoUTv0T5G EFtEQF7iSe8NsG5mgTyJr5+eM4HYwgIhEhd2vmUBsVkEVCUOfHgNFucVcJNY/vcyUC8H0DYF iTmTbEBMTgF3iUPTrEAqhIAqVi99yzSBkXcBI8MqRtHUguSC4qT0XCO94sTc4tK8dL3k/NxN jOCweCa9g3FVg8UhRgEORiUe3o76i8FCrIllxZW5hxglOJiVRHiN4i8FC/GmJFZWpRblxxeV 5qQWH2KU5mBREuc92GodKCSQnliSmp2aWpBaBJNl4uCUamAsXqic3nvwVmf4vivvSwNOZS92 7TgR9EPj2pdte14HpO2QSJzFE3EvrnBSoGTXvjUKJmfunCv0aklLvPP3laCh9es7a94p7PL8 E+ymd/z3EcVsDQ6nzs2M4Su3rbyj0+zGYPr3oOOuZCdng7VXVhe1LatikpqjzPVF8I3N4ffn 2WJFHskv3fhViaU4I9FQi7moOBEAum4fbwcCAAA= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 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 From: Jacek Anaszewski JPEG codec on Exynos3250 SoC produces broken raw image if a JPEG image is decoded to YUV420 format and downscaled by a factor greater than 2. Prevent this by asserting downscale ratio to 2. Signed-off-by: Jacek Anaszewski Signed-off-by: Sylwester Nawrocki --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 3e3d94d..eb13fdf 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1317,12 +1317,16 @@ static int exynos4_jpeg_get_output_buffer_size(struct s5p_jpeg_ctx *ctx, return w * h * fmt_depth >> 3; } +static int exynos3250_jpeg_try_downscale(struct s5p_jpeg_ctx *ctx, + struct v4l2_rect *r); + static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct, struct v4l2_format *f) { struct vb2_queue *vq; struct s5p_jpeg_q_data *q_data = NULL; struct v4l2_pix_format *pix = &f->fmt.pix; struct v4l2_ctrl *ctrl_subs; + struct v4l2_rect scale_rect; unsigned int f_type; vq = v4l2_m2m_get_vq(ct->fh.m2m_ctx, f->type); @@ -1382,6 +1386,20 @@ static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct, struct v4l2_format *f) ct->crop_rect.width = pix->width; ct->crop_rect.height = pix->height; } + + /* + * Prevent downscaling to YUV420 format by more than 2 + * for Exynos3250 SoC as it produces broken raw image + * in such cases. + */ + if (ct->mode == S5P_JPEG_DECODE && + f_type == FMT_TYPE_CAPTURE && + ct->jpeg->variant->version == SJPEG_EXYNOS3250 && + pix->pixelformat == V4L2_PIX_FMT_YUV420 && + ct->scale_factor > 2) { + scale_rect.width = ct->out_q.w / 2; + scale_rect.height = ct->out_q.h / 2; + exynos3250_jpeg_try_downscale(ct, &scale_rect); } return 0;