From patchwork Wed Jul 20 01:11:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 9238623 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 854186075D for ; Wed, 20 Jul 2016 01:13:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 770002624C for ; Wed, 20 Jul 2016 01:13:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B57F26E81; Wed, 20 Jul 2016 01:13:32 +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=unavailable 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 DCB092624C for ; Wed, 20 Jul 2016 01:13:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753246AbcGTBLb (ORCPT ); Tue, 19 Jul 2016 21:11:31 -0400 Received: from mail-pa0-f67.google.com ([209.85.220.67]:34477 "EHLO mail-pa0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752412AbcGTBL0 (ORCPT ); Tue, 19 Jul 2016 21:11:26 -0400 Received: by mail-pa0-f67.google.com with SMTP id hh10so2261074pac.1; Tue, 19 Jul 2016 18:11:26 -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=dcBQZOfpkjdyvCANbtuUmoAQaSQbD7SAG6VSpQgKUSw=; b=lVFbNa2kmllgTMtO10MD5OLb7DjXt9qBInuY0B7qkJfwCptDoTITE82yJm58ol0sNA U7HfFgkgcQm3/1PR2uppqeMqQRCGcHelwGrHrsDDenNhxYZnPJHTsow2MkCyZqCUBiov W5+vnZtoiMuFZxlIeygWLES5T+qZJExbhk/uKqYY6/y9bPq3I5gUBbIe2GbLFVeB0bSo 7wNmuKppOuHPx1MsDKzN+G0wvoHXxTzVfvJMnH7BOQ2FCUZhAYCVNLx0DB36xKop8p8K QQZ+1rsFX5tUxlzhEs18IeICSAKnBerGzq07R2lTGxthPc00cPUT7Phz2EX4tMh0LqSx 3UnQ== 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=dcBQZOfpkjdyvCANbtuUmoAQaSQbD7SAG6VSpQgKUSw=; b=QRRtGhSjkpHyPHFGZ4g4zYfDlDH1lP46sUV5SDa/llY4UfcUiZoUNc+q0yGW0cfOBA /jnUfGicWX4dcENRK8q+FIRFNdXBVnHPOsaH4wM2HO9KGGgucM5nWuHwIBuyUm/qC/Jb oL4B8SNt859n4hSdYoX7bZNw9nvUZJEUqzrhJkU1rs4X5LgDqks0Rq46cf/nlOr83c1W UkVBov+BFBRYfHm4OQtMvsMO7A5V2ggwFRCmm+sxdQbALhVXA7kTqLEgaa6yYqK/8atV 8BLESkD3TySCw75Wl6aeZZ3blebUZrUkaUB+Pe/EH1SjIYG4jBF7bFc++V4SaDfod1pL AkpQ== X-Gm-Message-State: ALyK8tIawEMEYv8UO+xYhuk/Zf2afH6G/yrrNMrejh8S5y2s7BaMLDEqxHI1AY3ysUDO5A== X-Received: by 10.66.160.41 with SMTP id xh9mr71499335pab.85.1468977085771; Tue, 19 Jul 2016 18:11:25 -0700 (PDT) Received: from mothership.sklembedded.com (c-73-241-2-21.hsd1.ca.comcast.net. [73.241.2.21]) by smtp.googlemail.com with ESMTPSA id d1sm84277pas.48.2016.07.19.18.11.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Jul 2016 18:11:25 -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, linux-kernel@vger.kernel.org, Steve Longerbeam Subject: [PATCH v2 05/13] gpu: ipu-v3: Add IDMA channel linking support Date: Tue, 19 Jul 2016 18:11:03 -0700 Message-Id: <1468977071-29240-6-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1468977071-29240-1-git-send-email-steve_longerbeam@mentor.com> References: <1467932621-358-1-git-send-email-steve_longerbeam@mentor.com> <1468977071-29240-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 Adds functions to link and unlink IDMAC source channels to sink channels. So far the following links are supported: IPUV3_CHANNEL_IC_PRP_ENC_MEM -> IPUV3_CHANNEL_MEM_ROT_ENC PUV3_CHANNEL_IC_PRP_VF_MEM -> IPUV3_CHANNEL_MEM_ROT_VF IPUV3_CHANNEL_IC_PP_MEM -> IPUV3_CHANNEL_MEM_ROT_PP More links can be added to the idmac_link_info[] array. Signed-off-by: Steve Longerbeam --- v2: - replaced hardcoded channel numbers in idmac_link_info[] with above channel names. --- drivers/gpu/ipu-v3/ipu-common.c | 118 ++++++++++++++++++++++++++++++++++++++++ include/video/imx-ipu-v3.h | 3 + 2 files changed, 121 insertions(+) diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c index 49af121..1c5aff4 100644 --- a/drivers/gpu/ipu-v3/ipu-common.c +++ b/drivers/gpu/ipu-v3/ipu-common.c @@ -730,6 +730,124 @@ void ipu_set_ic_src_mux(struct ipu_soc *ipu, int csi_id, bool vdi) } EXPORT_SYMBOL_GPL(ipu_set_ic_src_mux); + +/* IDMAC Channel Linking */ + +struct idmac_link_reg_info { + int chno; + u32 reg; + int shift; + int bits; + u32 sel; +}; + +struct idmac_link_info { + struct idmac_link_reg_info src; + struct idmac_link_reg_info sink; +}; + +static const struct idmac_link_info idmac_link_info[] = { + { + .src = { IPUV3_CHANNEL_IC_PRP_ENC_MEM, IPU_FS_PROC_FLOW1, + 0, 4, 7 }, + .sink = { IPUV3_CHANNEL_MEM_ROT_ENC, IPU_FS_PROC_FLOW2, + 0, 4, 1 }, + }, { + .src = { IPUV3_CHANNEL_IC_PRP_VF_MEM, IPU_FS_PROC_FLOW1, + 8, 4, 8 }, + .sink = { IPUV3_CHANNEL_MEM_ROT_VF, IPU_FS_PROC_FLOW2, + 4, 4, 1 }, + }, { + .src = { IPUV3_CHANNEL_IC_PP_MEM, IPU_FS_PROC_FLOW1, + 16, 4, 5 }, + .sink = { IPUV3_CHANNEL_MEM_ROT_PP, IPU_FS_PROC_FLOW2, + 12, 4, 3 }, + }, +}; + +static const struct idmac_link_info *find_idmac_link_info( + struct ipuv3_channel *src, struct ipuv3_channel *sink) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(idmac_link_info); i++) { + if (src->num == idmac_link_info[i].src.chno && + sink->num == idmac_link_info[i].sink.chno) + return &idmac_link_info[i]; + } + + return NULL; +} + +/* + * Links an IDMAC source channel to a sink channel. + */ +int ipu_idmac_link(struct ipuv3_channel *src, struct ipuv3_channel *sink) +{ + struct ipu_soc *ipu = src->ipu; + const struct idmac_link_info *link; + u32 src_reg, sink_reg, src_mask, sink_mask; + unsigned long flags; + + link = find_idmac_link_info(src, sink); + if (!link) + return -EINVAL; + + src_mask = ((1 << link->src.bits) - 1) << link->src.shift; + sink_mask = ((1 << link->sink.bits) - 1) << link->sink.shift; + + spin_lock_irqsave(&ipu->lock, flags); + + src_reg = ipu_cm_read(ipu, link->src.reg); + sink_reg = ipu_cm_read(ipu, link->sink.reg); + + src_reg &= ~src_mask; + src_reg |= (link->src.sel << link->src.shift); + + sink_reg &= ~sink_mask; + sink_reg |= (link->sink.sel << link->sink.shift); + + ipu_cm_write(ipu, src_reg, link->src.reg); + ipu_cm_write(ipu, sink_reg, link->sink.reg); + + spin_unlock_irqrestore(&ipu->lock, flags); + return 0; +} +EXPORT_SYMBOL_GPL(ipu_idmac_link); + +/* + * Unlinks IDMAC source and sink channels. + */ +int ipu_idmac_unlink(struct ipuv3_channel *src, struct ipuv3_channel *sink) +{ + struct ipu_soc *ipu = src->ipu; + const struct idmac_link_info *link; + u32 src_reg, sink_reg, src_mask, sink_mask; + unsigned long flags; + + link = find_idmac_link_info(src, sink); + if (!link) + return -EINVAL; + + src_mask = ((1 << link->src.bits) - 1) << link->src.shift; + sink_mask = ((1 << link->sink.bits) - 1) << link->sink.shift; + + spin_lock_irqsave(&ipu->lock, flags); + + src_reg = ipu_cm_read(ipu, link->src.reg); + sink_reg = ipu_cm_read(ipu, link->sink.reg); + + src_reg &= ~src_mask; + sink_reg &= ~sink_mask; + + ipu_cm_write(ipu, src_reg, link->src.reg); + ipu_cm_write(ipu, sink_reg, link->sink.reg); + + spin_unlock_irqrestore(&ipu->lock, flags); + return 0; +} +EXPORT_SYMBOL_GPL(ipu_idmac_unlink); + struct ipu_devtype { const char *name; unsigned long cm_ofs; diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h index 8a6ccaa..b252cb4 100644 --- a/include/video/imx-ipu-v3.h +++ b/include/video/imx-ipu-v3.h @@ -128,6 +128,7 @@ enum ipu_channel_irq { #define IPUV3_CHANNEL_ROT_VF_MEM 49 #define IPUV3_CHANNEL_ROT_PP_MEM 50 #define IPUV3_CHANNEL_MEM_BG_SYNC_ALPHA 51 +#define IPUV3_NUM_CHANNELS 64 int ipu_map_irq(struct ipu_soc *ipu, int irq); int ipu_idmac_channel_irq(struct ipu_soc *ipu, struct ipuv3_channel *channel, @@ -171,6 +172,8 @@ int ipu_idmac_get_current_buffer(struct ipuv3_channel *channel); bool ipu_idmac_buffer_is_ready(struct ipuv3_channel *channel, u32 buf_num); void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num); void ipu_idmac_clear_buffer(struct ipuv3_channel *channel, u32 buf_num); +int ipu_idmac_link(struct ipuv3_channel *src, struct ipuv3_channel *sink); +int ipu_idmac_unlink(struct ipuv3_channel *src, struct ipuv3_channel *sink); /* * IPU Channel Parameter Memory (cpmem) functions