From patchwork Sat Sep 17 19:33:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 9337341 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 D9DF2601C2 for ; Sat, 17 Sep 2016 19:34:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5714291CB for ; Sat, 17 Sep 2016 19:34:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9FBD291DC; Sat, 17 Sep 2016 19:34:49 +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 88A97291CB for ; Sat, 17 Sep 2016 19:34:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754168AbcIQTep (ORCPT ); Sat, 17 Sep 2016 15:34:45 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34423 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752170AbcIQTeL (ORCPT ); Sat, 17 Sep 2016 15:34:11 -0400 Received: by mail-pf0-f195.google.com with SMTP id 21so3689881pfy.1; Sat, 17 Sep 2016 12:34:11 -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=6PZl5PiXDyyHOcFVZBaZR50h2xoE++24AqEZXtn6o1c=; b=GOP9ur4fTJCMhizLERQ+MeS6kIcvhM1dx8b8vQ+ygU1442h30wnRKzumCUWVr/dJ0N MR7GkEpTukl3CWKLojGZMogfBteqT3mdr329mOi7PQI+rucMiKySipQlNMpkrTSMccff L5OANQkim35ZmE/q0acHViproyxE+H/CPuH8xUzzIbGB/X7eEXO2vU5YKGA8S95WorUY XH/62upftoMNWdfr3kWYliPGWIAElSyfSTlMkis1roqctVPp+Sw3ZNsnbvZ6vvsXhLum NfcHhWkcKkL7do9UNt+Kwp1b5jzgDbBmMgrZncVXMT1C88cqHn9rJ1M+aePLJeLI5F0R gatg== 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=6PZl5PiXDyyHOcFVZBaZR50h2xoE++24AqEZXtn6o1c=; b=Zz70c1oXx3/ae3b2x9eQoT2fOCi4EwIYnnozpwB+u62HsFNIgqUWfkW0Ro8pzQnv68 v+6VWSpjg9Y4Q0vpFHPkyzQfsL7yvn01lgulM3dyvBd74TvUQ13nC51iaPssjtLt/kVt 35qc4pBVFhmxpLb7rJ1YvkttRAehYkuIDUfens/vHSrVV5G/zOIqPspNDr60hrnAstBO 3/O+dWJGEjOe1OJhcLR8flxVO6kzRyGc1fJQPu9k0cFwJPPxNHCKKdyM169+T7JFpurx 2MtT15l/lQcelqpMRSB/lsS/u7N5zKXcV5CdbQehGCwldR7kqEiAhGLr44Lv22YCI3r9 whhg== X-Gm-Message-State: AE9vXwMAVqvMLFuY1I/S8izTp2nAHJZhzXMOr3FJcUIeXUaRGfFDZK1WQYeP0GbqEwOHLA== X-Received: by 10.98.33.146 with SMTP id o18mr20014772pfj.177.1474140849760; Sat, 17 Sep 2016 12:34:09 -0700 (PDT) Received: from mappy.world.mentorg.com (c-98-234-136-200.hsd1.ca.comcast.net. [98.234.136.200]) by smtp.googlemail.com with ESMTPSA id an11sm20761627pac.26.2016.09.17.12.34.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 17 Sep 2016 12:34:09 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: p.zabel@pengutronix.de, tomi.valkeinen@ti.com Cc: linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, Steve Longerbeam Subject: [PATCH v7 3/3] gpu: ipu-v3: Add queued image conversion support Date: Sat, 17 Sep 2016 12:33:58 -0700 Message-Id: <1474140838-1082-4-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474140838-1082-1-git-send-email-steve_longerbeam@mentor.com> References: <1474140838-1082-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 --- v7: - renamed include/video/imx-image-convert.h to imx-ipu-image-convert.h. - changed MIN_W, MIN_H to absolute minimum allowed assuming conversions to/from planar pixel formats and with rotations (16x8). - removed defaults for 0 widths/heights in ipu_image_convert_adjust(). v6: - fixed call to ipu_image_convert_adjust() in ipu_image_convert_verify(). 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 | 1709 ++++++++++++++++++++++++++++++++ drivers/gpu/ipu-v3/ipu-prv.h | 5 + include/video/imx-ipu-image-convert.h | 207 ++++ 5 files changed, 1932 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/ipu-v3/ipu-image-convert.c create mode 100644 include/video/imx-ipu-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 fe389dd..a1219fb 100644 --- a/drivers/gpu/ipu-v3/ipu-common.c +++ b/drivers/gpu/ipu-v3/ipu-common.c @@ -970,6 +970,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) { @@ -1024,6 +1030,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); @@ -1108,6 +1116,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..2ba7d43 --- /dev/null +++ b/drivers/gpu/ipu-v3/ipu-image-convert.c @@ -0,0 +1,1709 @@ +/* + * 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