From patchwork Mon Jul 7 16:32:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 4496281 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 1AC519F390 for ; Mon, 7 Jul 2014 16:33:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 39A2D202F0 for ; Mon, 7 Jul 2014 16:33:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4B84D202EC for ; Mon, 7 Jul 2014 16:33:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752386AbaGGQc7 (ORCPT ); Mon, 7 Jul 2014 12:32:59 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:57768 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752366AbaGGQc6 (ORCPT ); Mon, 7 Jul 2014 12:32:58 -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 <0N8C00I0SOMXAI70@mailout3.samsung.com>; Tue, 08 Jul 2014 01:32:57 +0900 (KST) X-AuditID: cbfee61a-f79e46d00000134f-c2-53bacbb9cb9e Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 8B.14.04943.9BBCAB35; Tue, 08 Jul 2014 01:32:57 +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 <0N8C00GK8OLKQW00@mmp2.samsung.com>; Tue, 08 Jul 2014 01:32:57 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: kyungmin.park@samsung.com, b.zolnierkie@samsung.com, linux-samsung-soc@vger.kernel.org, Jacek Anaszewski Subject: [PATCH 3/9] s5p-jpeg: Adjust jpeg_bound_align_image to Exynos3250 needs Date: Mon, 07 Jul 2014 18:32:04 +0200 Message-id: <1404750730-22996-4-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1404750730-22996-1-git-send-email-j.anaszewski@samsung.com> References: <1404750730-22996-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBJMWRmVeSWpSXmKPExsVy+t9jQd2dp3cFGzw4rGqxccZ6Voveq88Z Lc42vWG36NmwldVixvl9TA6sHn1bVjF6fN4kF8AUxWWTkpqTWZZapG+XwJWxpnkDY8ECyYr2 Y+fYGxgninQxcnJICJhIzJ38ixnCFpO4cG89G4gtJDCdUWLLG8kuRi4gu51JYu6aNewgCTYB Q4mfL14zgdgiAvIST3pvsIEUMQt0MkosbN/A2sXIwSEsECDxYEU0SA2LgKpEV8cnVhCbV8BD ouVWLxNIiYSAgsScSTYgYU4BT4nDyz6DdQoBlRx8bTmBkXcBI8MqRtHUguSC4qT0XEO94sTc 4tK8dL3k/NxNjODweCa1g3Flg8UhRgEORiUe3hUHdwULsSaWFVfmHmKU4GBWEuFdsRwoxJuS WFmVWpQfX1Sak1p8iFGag0VJnPdAq3WgkEB6YklqdmpqQWoRTJaJg1OqgZHD+ae+2RrOrJp5 WnfnP9W42rJ78eW0j46FSw9tWdjP5Vi1eHXum7SvManmBht1IxMbbTmb7+Xopf59c4PpY0Xr +ee5woeXL7NjrzjG7tg86dKp8IMWzAk5Ot7vdH6nHby97GjQE4/Z+x/7fvSfEvb5adDe6l/X pO4dv7hq3pzLitIexi6vzUqUWIozEg21mIuKEwGDAoX3CwIAAA== Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.6 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);