From patchwork Fri Mar 1 13:24:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 10835313 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 39A8E1390 for ; Fri, 1 Mar 2019 13:24:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C5862EE41 for ; Fri, 1 Mar 2019 13:24:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20BA02EE46; Fri, 1 Mar 2019 13:24:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6646E2EE30 for ; Fri, 1 Mar 2019 13:24:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387586AbfCANYb (ORCPT ); Fri, 1 Mar 2019 08:24:31 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:50538 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733255AbfCANYa (ORCPT ); Fri, 1 Mar 2019 08:24:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=HdAOrrKQq4G6AGeh+JxepzrSNVzIO/5cEm4xowGAM6Q=; b=Ci28T2GN9pA7tlQ0ocEfQepES4 VdezuzVk/BWP+PjuF+UdE8G8+afeIOhZthYjAc0NPkM2deZbi8aLMTEt73z6dmN4SDiifXkyB8rFN Mp7Euy4MsMU+CQfSWFmYwpmYvhLeG/R03+UXpsAAxg8jaLniLU+DZvb3bpKONfpQRaczoL2ONvUYT LtTJ6+IHLaY2zLTF7yGxwrg5FnQJZCadB/r18L+Sm1voqwpkgG1NpRHtqnJN3wqghBRoS7jGkkfEa v/6tXWggpYv4XICqCXnUI+TTJpCBn62G27viywAk/zcWnDsDvbxrXxzFHS1kxySvI6Xfy/LtHJ9Dr E/+gED2w==; Received: from 177.41.113.159.dynamic.adsl.gvt.net.br ([177.41.113.159] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzi9O-0003y5-2Q; Fri, 01 Mar 2019 13:24:30 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.92) (envelope-from ) id 1gzi9L-0002Nm-W5; Fri, 01 Mar 2019 10:24:27 -0300 From: Mauro Carvalho Chehab To: Linux Media Mailing List Cc: Mauro Carvalho Chehab , Mauro Carvalho Chehab , Hans Verkuil , Ezequiel Garcia Subject: [PATCH 10/10] media: vim2m: speedup passthrough copy Date: Fri, 1 Mar 2019 10:24:26 -0300 Message-Id: <6f5f188f02ad43bd7b9b4affade082d84e1805ad.1551446121.git.mchehab+samsung@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When in passthrough mode, copy the entire line at once, in order to make it faster (if not HFLIP). Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/vim2m.c | 37 ++++++++++++++++------------------ 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/drivers/media/platform/vim2m.c b/drivers/media/platform/vim2m.c index 6bcc0c9f9910..e98dc8f99e3e 100644 --- a/drivers/media/platform/vim2m.c +++ b/drivers/media/platform/vim2m.c @@ -267,25 +267,22 @@ static const char *type_name(enum v4l2_buf_type type) #define CLIP(__color) \ (u8)(((__color) > 0xff) ? 0xff : (((__color) < 0) ? 0 : (__color))) -static void fast_copy_two_pixels(struct vim2m_q_data *q_data_in, - struct vim2m_q_data *q_data_out, - u8 **src, u8 **dst, bool reverse) +static void copy_line(struct vim2m_q_data *q_data_out, + u8 *src, u8 *dst, bool reverse) { - int depth = q_data_out->fmt->depth >> 3; + int x, depth = q_data_out->fmt->depth >> 3; if (!reverse) { - memcpy(*dst, *src, depth << 1); - *src += depth << 1; - *dst += depth << 1; + memcpy(dst, src, q_data_out->width * depth); + } else { + for (x = 0; x < q_data_out->width >> 1; x++) { + memcpy(dst, src, depth); + memcpy(dst + depth, src - depth, depth); + src -= depth << 1; + dst += depth << 1; + } return; } - - /* copy RGB formats in reverse order */ - memcpy(*dst, *src, depth); - memcpy(*dst + depth, *src - depth, depth); - *src -= depth << 1; - *dst += depth << 1; - return; } static void copy_two_pixels(struct vim2m_q_data *q_data_in, @@ -491,7 +488,7 @@ static int device_process(struct vim2m_ctx *ctx, } y_out = 0; - /* Faster copy logic, when format and resolution are identical */ + /* When format and resolution are identical, we can use a faster copy logic */ if (q_data_in->fmt->fourcc == q_data_out->fmt->fourcc && q_data_in->width == q_data_out->width && q_data_in->height == q_data_out->height) { @@ -500,15 +497,15 @@ static int device_process(struct vim2m_ctx *ctx, if (ctx->mode & MEM2MEM_HFLIP) p += bytesperline - (q_data_in->fmt->depth >> 3); - for (x = 0; x < width >> 1; x++) - fast_copy_two_pixels(q_data_in, q_data_out, - &p, &p_out, - ctx->mode & MEM2MEM_HFLIP); + copy_line(q_data_out, p, p_out, + ctx->mode & MEM2MEM_HFLIP); + + p_out += bytesperline; } return 0; } - /* Slower algorithm with format conversion and scaler */ + /* Slower algorithm with format conversion, hflip, vflip and scaler */ /* To speed scaler up, use Bresenham for X dimension */ x_int = q_data_in->width / q_data_out->width;