From patchwork Fri Jul 11 15:19:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 4535211 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 49C3D9F1C4 for ; Fri, 11 Jul 2014 15:29:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7448520256 for ; Fri, 11 Jul 2014 15:29:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 77C4720204 for ; Fri, 11 Jul 2014 15:29:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932069AbaGKPUE (ORCPT ); Fri, 11 Jul 2014 11:20:04 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:34008 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753150AbaGKPUA (ORCPT ); Fri, 11 Jul 2014 11:20:00 -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 <0N8J00HNXZXBDT80@mailout3.samsung.com> for linux-media@vger.kernel.org; Sat, 12 Jul 2014 00:19:59 +0900 (KST) X-AuditID: cbfee61a-f79e46d00000134f-19-53c0009fa9e3 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 79.3D.04943.F9000C35; Sat, 12 Jul 2014 00:19:59 +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:19:59 +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 3/9] s5p-jpeg: Adjust jpeg_bound_align_image to Exynos3250 needs Date: Fri, 11 Jul 2014 17:19:44 +0200 Message-id: <1405091990-28567-4-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+NgFvrNJMWRmVeSWpSXmKPExsVy+t9jAd35DAeCDWafELeY9bKdxaL36nNG i7NNb9gtejZsZbU4/Kad1YHVo2/LKkaPz5vkApiiuGxSUnMyy1KL9O0SuDLWNG9gLFggWdF+ 7Bx7A+NEkS5GTg4JAROJa/8PMkLYYhIX7q1n62Lk4hASWMQosfP0LFYIp51JYnrbIRaQKjYB Q4mfL14zgdgiAvIST3pvgHUwC/QySpz79wusSFggVOLg2zfMIDaLgKpEw60usBW8Ah4Sf37t BKrhAFqnIDFnkg1ImFPAU+Ls9RVgrUJAJT+6F7FPYORdwMiwilE0tSC5oDgpPddQrzgxt7g0 L10vOT93EyM4SJ5J7WBc2WBxiFGAg1GJh1dh/b5gIdbEsuLK3EOMEhzMSiK8V9/sDxbiTUms rEotyo8vKs1JLT7EKM3BoiTOe6DVOlBIID2xJDU7NbUgtQgmy8TBKdXAKOovv3zZ2iN7PG89 dlyW7KHCtVGkeE3om8WXovgaZkUn893kaY1eGH/whQ7fFRGPB44FeW2hHCdFn3VFTSvS3SGp 9d7qqdmJ/WFMoflfN/+M/H41kU86aeblb46/f/IUB73uDnxyXljQ207uqdvp/dcs9UxYNOVm uLU1/BWt9OFcrp3xTddeiaU4I9FQi7moOBEAKkoXyg4CAAA= 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 The jpeg_bound_align_image function needs to know the context in which it is called, as it needs to align image dimensions in a slight different manner for Exynos3250, which crops pixels for specific values in case the format is RGB. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index df3aaa9..0854f37 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1133,7 +1133,8 @@ static struct s5p_jpeg_fmt *s5p_jpeg_find_format(struct s5p_jpeg_ctx *ctx, return NULL; } -static void jpeg_bound_align_image(u32 *w, unsigned int wmin, unsigned int wmax, +static void jpeg_bound_align_image(struct s5p_jpeg_ctx *ctx, + u32 *w, unsigned int wmin, unsigned int wmax, unsigned int walign, u32 *h, unsigned int hmin, unsigned int hmax, unsigned int halign) @@ -1145,13 +1146,27 @@ static void jpeg_bound_align_image(u32 *w, unsigned int wmin, unsigned int wmax, w_step = 1 << walign; h_step = 1 << halign; + + if (ctx->jpeg->variant->version == SJPEG_EXYNOS3250) { + /* + * Rightmost and bottommost pixels are cropped by the + * Exynos3250 JPEG IP for RGB formats, for the specific + * width and height values respectively. This assignment + * will result in v4l_bound_align_image returning dimensions + * reduced by 1 for the aforementioned cases. + */ + if (w_step == 4 && ((width & 3) == 1)) { + wmax = width; + hmax = height; + } + } + v4l_bound_align_image(w, wmin, wmax, walign, h, hmin, hmax, halign, 0); if (*w < width && (*w + w_step) < wmax) *w += w_step; if (*h < height && (*h + h_step) < hmax) *h += h_step; - } static int vidioc_try_fmt(struct v4l2_format *f, struct s5p_jpeg_fmt *fmt, @@ -1167,12 +1182,12 @@ static int vidioc_try_fmt(struct v4l2_format *f, struct s5p_jpeg_fmt *fmt, /* V4L2 specification suggests the driver corrects the format struct * if any of the dimensions is unsupported */ if (q_type == FMT_TYPE_OUTPUT) - jpeg_bound_align_image(&pix->width, S5P_JPEG_MIN_WIDTH, + jpeg_bound_align_image(ctx, &pix->width, S5P_JPEG_MIN_WIDTH, S5P_JPEG_MAX_WIDTH, 0, &pix->height, S5P_JPEG_MIN_HEIGHT, S5P_JPEG_MAX_HEIGHT, 0); else - jpeg_bound_align_image(&pix->width, S5P_JPEG_MIN_WIDTH, + jpeg_bound_align_image(ctx, &pix->width, S5P_JPEG_MIN_WIDTH, S5P_JPEG_MAX_WIDTH, fmt->h_align, &pix->height, S5P_JPEG_MIN_HEIGHT, S5P_JPEG_MAX_HEIGHT, fmt->v_align); @@ -1294,7 +1309,7 @@ static int exynos4_jpeg_get_output_buffer_size(struct s5p_jpeg_ctx *ctx, else wh_align = 1; - jpeg_bound_align_image(&w, S5P_JPEG_MIN_WIDTH, + jpeg_bound_align_image(ctx, &w, S5P_JPEG_MIN_WIDTH, S5P_JPEG_MAX_WIDTH, wh_align, &h, S5P_JPEG_MIN_HEIGHT, S5P_JPEG_MAX_HEIGHT, wh_align);