From patchwork Thu Sep 15 18:04:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 9334953 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 028DD607FD for ; Fri, 16 Sep 2016 01:10:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1B8C29C1E for ; Fri, 16 Sep 2016 01:10:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5EBB29E77; Fri, 16 Sep 2016 01:10:14 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B615329C1E for ; Fri, 16 Sep 2016 01:10:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 613C06E96F; Fri, 16 Sep 2016 01:09:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id A2A1E6E900 for ; Thu, 15 Sep 2016 18:04:32 +0000 (UTC) Received: by mail-pf0-x241.google.com with SMTP id 128so2496785pfb.0 for ; Thu, 15 Sep 2016 11:04:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eUW4trpd9QHrU/AosTIabl+o82s9QkJ0M+f3mWGhe/4=; b=cdBluavd3iwIktWX69JxmqjID2MLhf/64ZgDA5tJsLUdiPPyqrk/hvbkQ1Ahr+bK5D Xf5H+Prl2HZaOI7QjOSdK+84uvowTOfd+UW1OIM6Y84BDfuRS4EUQXLR+U9fyXnbKNRH zSxZJuRrmQbcA9xgWFzoVDNYKsUMva+UVedWcXg+Re1Od/h7h3LfrnOrYo4FgPc66kKI 3pp4eiWPaXokLWvBW7RrjCK86hwKSQi8iUsLhy06n/HFHfv5m7t/buyHfJ/fn6Dliw8A dhN2ULzkILRJ2cfuwVlz9Rds10q20H2QVp1aNdAR+iQVrTG8avq77hsyC3nDaGPPOMFS yMNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eUW4trpd9QHrU/AosTIabl+o82s9QkJ0M+f3mWGhe/4=; b=imTVTuGqNDngeXU0BBBpfTzzKOplqgYMSBj6YBT3Vt+z+M5vMPeKsUrceK5VdFKRSs OGORTp0UO06L7zUQetzthNYU4S/jW0hjzpRkSJHRQODe31Ce8KSCzVQlIXnLynco2X3+ 05mSyZT5iDu40jwZ/GfXOn/WKRV1QF5RQNApZ1GEI7Txduli45+Tb3q0AGkDAXddh2T2 GN8cX7ubwKVUsKLIUiBO6Qiuwf3d4Y6A8KS0Iw5MUkahpqF15MysGtpI+IedtUzPgxBN p5v8bt/XvprttmgNEKhcGLwamz0Pm6xzyiII9NRmuITJ7vq0cgHewrnw2Jv+/PvORgKm K77g== X-Gm-Message-State: AE9vXwMdv+dL5K09OzzZGyTp4xr7ZnwFxfPgdGMvU2kwDO1uR1WNSV95aSaoCrVBv61dTQ== X-Received: by 10.98.34.221 with SMTP id p90mr788850pfj.18.1473962671194; Thu, 15 Sep 2016 11:04:31 -0700 (PDT) Received: from majic.world.mentorg.com (c-73-241-2-21.hsd1.ca.comcast.net. [73.241.2.21]) by smtp.googlemail.com with ESMTPSA id k80sm8506142pfk.27.2016.09.15.11.04.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Sep 2016 11:04:30 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: p.zabel@pengutronix.de, plagnioj@jcrosoft.com, tomi.valkeinen@ti.com Subject: [PATCH v5 2/2] gpu: ipu-v3: Add queued image conversion support Date: Thu, 15 Sep 2016 11:04:12 -0700 Message-Id: <1473962652-16820-3-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473962652-16820-1-git-send-email-steve_longerbeam@mentor.com> References: <1473962652-16820-1-git-send-email-steve_longerbeam@mentor.com> X-Mailman-Approved-At: Fri, 16 Sep 2016 01:09:16 +0000 Cc: linux-fbdev@vger.kernel.org, Steve Longerbeam , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch implements image conversion support using the IC tasks, with tiling to support scaling to and from images up to 4096x4096. Image rotation is also supported. Image conversion requests are added to a run queue under the IC tasks. The internal API is subsystem agnostic (no V4L2 dependency except for the use of V4L2 fourcc pixel formats). Callers prepare for image conversion by calling ipu_image_convert_prepare(), which initializes the parameters of the conversion. The caller passes in the ipu and IC task to use for the conversion, the input and output image formats, a rotation mode, and a completion callback and completion context pointer: struct ipu_image_converter_ctx * ipu_image_convert_prepare(struct ipu_soc *ipu, enum ipu_ic_task ic_task, struct ipu_image *in, struct ipu_image *out, enum ipu_rotate_mode rot_mode, ipu_image_converter_cb_t complete, void *complete_context); A new conversion context is created that is added to an IC task context queue. The caller is given the new conversion context, which can then be passed to the further APIs: int ipu_image_convert_queue(struct ipu_image_converter_run *run); This queues the given image conversion request run to a run queue, and starts the conversion immediately if the run queue is empty. Only the physaddr's of the input and output image buffers are needed, since the conversion context was created previously with ipu_image_convert_prepare(). When the conversion completes, the run pointer is returned to the completion callback. void ipu_image_convert_abort(struct ipu_image_converter_ctx *ctx); This will abort any active or pending conversions for this context. Any currently active or pending runs belonging to this context are returned via the completion callback with an error status. void ipu_image_convert_unprepare(struct ipu_image_converter_ctx *ctx); Unprepares the conversion context. Any active or pending runs will be aborted by calling ipu_image_convert_abort(). Signed-off-by: Steve Longerbeam --- v5: - moved all the ipu_image_convert support to ipu-image-convert.c. Prototypes moved to include/video/imx-image-convert.h with comment headers. - removed the IC_TASK_ENCODE channels from image_convert_dma_chan[] list. The encode task cannnot be used by the image converter, since this task has no memory source IDMAC channels (buffers come directly from CSI). - renamed some structs and a few of the exported APIs: struct image_converter is renamed ipu_image_convert_chan, ipu_image_convert_run() is renamed ipu_image_convert_queue(). - the ipu_ic handle passed to ipu_image_convert_prepare() is replaced by the IPU handle and IC task that are requested for carrying out the conversion. The image converter acquires the ipu_ic handle internally, in get_ipu_resources() along with the other resources required. - removed .name field in the supported pixel format list, and ipu_image_convert_enum_format() no longer takes a char* desc arg. - y_depth in 'struct ipu_image_pixfmt' replaced with boolean planar (Y pixel depth is always 8 bits). - removed dmabuf reallocation in alloc_dma_buf(). - added lockdep_assert_held() to functions that require the irqlock. - added IC task number to dev_dbg() output. - exported 'struct ipu_image_convert_run'. ipu_image_convert_queue() now takes a run pointer. Caller must dynamically allocate and fill the run with a conversion context handle and the input/output buffer dma addresses, and free the run object when it is returned in the completion callback. - ipu_image_convert_adjust() is now a void. v4: - do away with struct ipu_ic_tile_off, and move tile offsets into struct ipu_ic_tile. This paves the way for possibly allowing for each tile to have different dimensions in the future. v3: no changes v2: no changes --- drivers/gpu/ipu-v3/Makefile | 3 +- drivers/gpu/ipu-v3/ipu-common.c | 9 + drivers/gpu/ipu-v3/ipu-image-convert.c | 1721 ++++++++++++++++++++++++++++++++ drivers/gpu/ipu-v3/ipu-prv.h | 5 + include/video/imx-image-convert.h | 207 ++++ 5 files changed, 1944 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/ipu-v3/ipu-image-convert.c create mode 100644 include/video/imx-image-convert.h diff --git a/drivers/gpu/ipu-v3/Makefile b/drivers/gpu/ipu-v3/Makefile index 107ec23..8ac08e3 100644 --- a/drivers/gpu/ipu-v3/Makefile +++ b/drivers/gpu/ipu-v3/Makefile @@ -1,4 +1,5 @@ obj-$(CONFIG_IMX_IPUV3_CORE) += imx-ipu-v3.o imx-ipu-v3-objs := ipu-common.o ipu-cpmem.o ipu-csi.o ipu-dc.o ipu-di.o \ - ipu-dp.o ipu-dmfc.o ipu-ic.o ipu-smfc.o + ipu-dp.o ipu-dmfc.o ipu-ic.o ipu-image-convert.o \ + ipu-smfc.o diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c index d230988..5136d66 100644 --- a/drivers/gpu/ipu-v3/ipu-common.c +++ b/drivers/gpu/ipu-v3/ipu-common.c @@ -839,6 +839,12 @@ static int ipu_submodules_init(struct ipu_soc *ipu, goto err_ic; } + ret = ipu_image_convert_init(ipu, dev); + if (ret) { + unit = "image_convert"; + goto err_image_convert; + } + ret = ipu_di_init(ipu, dev, 0, ipu_base + devtype->disp0_ofs, IPU_CONF_DI0_EN, ipu_clk); if (ret) { @@ -893,6 +899,8 @@ err_dc: err_di_1: ipu_di_exit(ipu, 0); err_di_0: + ipu_image_convert_exit(ipu); +err_image_convert: ipu_ic_exit(ipu); err_ic: ipu_csi_exit(ipu, 1); @@ -977,6 +985,7 @@ static void ipu_submodules_exit(struct ipu_soc *ipu) ipu_dc_exit(ipu); ipu_di_exit(ipu, 1); ipu_di_exit(ipu, 0); + ipu_image_convert_exit(ipu); ipu_ic_exit(ipu); ipu_csi_exit(ipu, 1); ipu_csi_exit(ipu, 0); diff --git a/drivers/gpu/ipu-v3/ipu-image-convert.c b/drivers/gpu/ipu-v3/ipu-image-convert.c new file mode 100644 index 0000000..7060150 --- /dev/null +++ b/drivers/gpu/ipu-v3/ipu-image-convert.c @@ -0,0 +1,1721 @@ +/* + * Copyright (C) 2012-2016 Mentor Graphics Inc. + * + * Queued image conversion support, with tiling and rotation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include +#include +#include