From patchwork Fri Jul 25 14:20:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sylwester Nawrocki X-Patchwork-Id: 25042 X-Patchwork-Delegate: sylvester.nawrocki@gmail.com Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1XAgND-0003Fo-SX; Fri, 25 Jul 2014 16:21:27 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.72/mailfrontend-7) with esmtp id 1XAgNB-00046Q-2d; Fri, 25 Jul 2014 16:21:27 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760422AbaGYOVW (ORCPT + 1 other); Fri, 25 Jul 2014 10:21:22 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:61188 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760297AbaGYOVV (ORCPT ); Fri, 25 Jul 2014 10:21:21 -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 <0N9900LWIUJKQM50@mailout2.samsung.com>; Fri, 25 Jul 2014 23:21:20 +0900 (KST) X-AuditID: cbfee61b-f79f86d00000144c-ee-53d267df4d50 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 97.8F.05196.FD762D35; Fri, 25 Jul 2014 23:21:20 +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:19 +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 4/9] s5p-jpeg: Adjust jpeg_bound_align_image to Exynos3250 needs Date: Fri, 25 Jul 2014 16:20:48 +0200 Message-id: <1406298053-30184-5-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+t9jQd0H6ZeCDU5+ZLLovfqc0aJnw1ZW ixnn9zFZHH7TzurA4tG3ZRWjx+dNcgFMUVw2Kak5mWWpRfp2CVwZN+b/Ziy4KFnxueEhUwPj QZEuRk4OCQETiWf3NrNB2GISF+6tB7K5OIQEpjNKfD76lAXC6WCSOLJ4GTtIFZuAoUTv0T5G EFtEQF7iSe8NsG5mgTyJr5+eM4HYwgKhEj+aXoLVswioSlzYuRgszivgJrFs/XPWLkYOoG0K EnMm2YCYnALuEoemWYFUCAFVrF76lmkCI+8CRoZVjKKpBckFxUnpuUZ6xYm5xaV56XrJ+bmb GMFh8Ux6B+OqBotDjAIcjEo8vB31F4OFWBPLiitzDzFKcDArifAaxV8KFuJNSaysSi3Kjy8q zUktPsQozcGiJM57sNU6UEggPbEkNTs1tSC1CCbLxMEp1cAo6XrlP6/josulKyMEZ8h28rjy T4xiVNs/Wddr09TAFvvTW5LDti76He4TPWVtadhqVktrw8cntFQ77dxj5tSXJhz52fco+n6/ wLz2+zURCVuOBJ1r2G+2QT+s/NvlNx/ZjNc/cz8n8rij623NJ8FArhWcaw6EyKVyvD83d7uI n8QEDrMw9kwlluKMREMt5qLiRAA0de76BwIAAA== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2014.7.25.140918 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_MEDIA_BODY 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' From: Jacek Anaszewski 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: Sylwester Nawrocki --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) -- 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 a3f8862..5ef7f5b 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);