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: 9334491 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 90F4A601C2 for ; Thu, 15 Sep 2016 18:04:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8813929AFF for ; Thu, 15 Sep 2016 18:04:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BF7729B05; Thu, 15 Sep 2016 18:04:37 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 4DA0F29AFF for ; Thu, 15 Sep 2016 18:04:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751432AbcIOSEd (ORCPT ); Thu, 15 Sep 2016 14:04:33 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:35027 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751334AbcIOSEc (ORCPT ); Thu, 15 Sep 2016 14:04:32 -0400 Received: by mail-pf0-f193.google.com with SMTP id z84so2497522pfi.2 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=BXgL4Ef8kkujgLO943BbxyX9rjBOnJ6hvQrs+aGLKwrgsIk5FNN+tbybLk7dv149f6 tYQ5NLBuOB3r2SGisbUwvXpwxTNKjTutynDLhdPjC0JQ6d9hs16ByjXBpdPFKGJD3VyD KZ/9VUcs5ckPGmfJbIy0cqQt2/oGGyeNd+ZcPV4j9AYHtX/JBYoUzIrIur2GMtc7Bj12 ByCAVlPKy1eCNavOf18mREAr89RlFbBJeQE/eErGjrUwjV1lqd2reP3t0Fd6r7a23+JD 99zI2OhG7JRYEQO5/qBB/+NRe8hq0N1eLvdXiijp1KX8ESerVFoNg7/IBBS/Qi13/0nm OLgg== X-Gm-Message-State: AE9vXwNylYWQbTgpGyzkuUIXo+h+KDABCekoszMAjurdF1DWJNo0c8QgjmU/TlRKuiRIbA== 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 Cc: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, Steve Longerbeam 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> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org 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