From patchwork Fri Jul 11 15:19:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 4535251 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 D22759F1C4 for ; Fri, 11 Jul 2014 15:29:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0C5A12025B for ; Fri, 11 Jul 2014 15:29:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 215A720204 for ; Fri, 11 Jul 2014 15:29:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754421AbaGKPUJ (ORCPT ); Fri, 11 Jul 2014 11:20:09 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:34021 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754443AbaGKPUH (ORCPT ); Fri, 11 Jul 2014 11:20:07 -0400 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N8J00EA6ZXIQGA0@mailout3.samsung.com> for linux-media@vger.kernel.org; Sat, 12 Jul 2014 00:20:06 +0900 (KST) X-AuditID: cbfee61a-f79e46d00000134f-20-53c000a6e47b Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id BA.3D.04943.6A000C35; Sat, 12 Jul 2014 00:20:06 +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 <0N8J00DPYZWYA170@mmp1.samsung.com>; Sat, 12 Jul 2014 00:20:06 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: s.nawrocki@samsung.com, andrzej.p@samsung.com, Jacek Anaszewski , Kyungmin Park Subject: [PATCH v2 6/9] s5p-jpeg: Prevent erroneous downscaling for Exynos3250 SoC Date: Fri, 11 Jul 2014 17:19:47 +0200 Message-id: <1405091990-28567-7-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1405091990-28567-1-git-send-email-j.anaszewski@samsung.com> References: <1405091990-28567-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFJMWRmVeSWpSXmKPExsVy+t9jAd1lDAeCDbZe4beY9bKdxaL36nNG i7NNb9gtejZsZbU4/Kad1YHVo2/LKkaPz5vkApiiuGxSUnMyy1KL9O0SuDLWTpnIXDCfv+Lw 9S7GBsYDPF2MnBwSAiYSM2/cYYewxSQu3FvPBmILCSxilDizPrKLkQvIbmeS+N6+CizBJmAo 8fPFayYQW0RAXuJJ7w02kCJmgV5GiXP/frGAJIQFQiTO7OhjBLFZBFQlnnbNAWvmFfCQuNbb CFTDAbRNQWLOJBuQMKeAp8TZ6ytYIBZ7SPzoXsQ+gZF3ASPDKkbR1ILkguKk9FxDveLE3OLS vHS95PzcTYzgEHkmtYNxZYPFIUYBDkYlHl6F9fuChVgTy4orcw8xSnAwK4nwXn2zP1iINyWx siq1KD++qDQntfgQozQHi5I474FW60AhgfTEktTs1NSC1CKYLBMHp1QDY8cLyw3Sb/P9Vllr Z+7Q/Wmk7n8g8EnjvMTWL6n66vL5JrU5rNXCucGRroaBd5Y9ivzht/hOaf9SK64Xa93/ss3T 0c1yXr9LNy9515YZ3eVPrv7/yBEbwHvcpXjWiQ+ZWjO1unS25/lmST++Glp5VPHGmQNd6+Ve /yl6J1x2UOouz6+U5BZHJZbijERDLeai4kQADcr/Mg0CAAA= 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 JPEG codec on Exynos3250 SoC produces broken raw image if a JPEG is decoded to YUV420 format and downscaling by more then 2 is applied. Prevent this by asserting downscale ratio to 2. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 2491ef8..1ef004b 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;