From patchwork Fri Oct 31 22:54:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 5207821 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C2CB19F387 for ; Fri, 31 Oct 2014 23:57:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C239620120 for ; Fri, 31 Oct 2014 23:57:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id CB79C2010E for ; Fri, 31 Oct 2014 23:57:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BD6336E89C; Fri, 31 Oct 2014 16:56:59 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pd0-f170.google.com (mail-pd0-f170.google.com [209.85.192.170]) by gabe.freedesktop.org (Postfix) with ESMTP id 52B896E850 for ; Fri, 31 Oct 2014 15:57:17 -0700 (PDT) Received: by mail-pd0-f170.google.com with SMTP id z10so8120684pdj.1 for ; Fri, 31 Oct 2014 15:57:17 -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=2DVTEtb1yoZvJyTPR6py7DyFEtTdkGo7McH9D8bmSaQ=; b=NuirPBYWRaDmWCFYqxxYYVtHAg3oe3zq7wjxeQB+0ctwUagFrS9eW6wF0tCpOW4qEN jEuCqEyghZrVbOxy6UxDcwEwuyV5GcWi3eklKxbTY4+chtgf9OKeXw4TlcHUlL4h7JZh 4ahqDCNfqB2ZLXb7UfwPMiYkg/aAAhISCiigJaPr8YNSlpmGzYH+Z2xCDUhCri71S24H X6TNFmVz7oZSziy9LrWiiHPZk6QxbgJbf+ZZH4e8FIB7XAutiNr6juLuCS20InSl5eK0 25/v96rDPhDwlvYnKDtt/89R4MNwEvsStn8TaPfMOwTenWMw0P6JdyJWZHSqJ92y/YcC /P2w== X-Received: by 10.70.128.11 with SMTP id nk11mr27081483pdb.113.1414796237211; Fri, 31 Oct 2014 15:57:17 -0700 (PDT) Received: from mothership.mgc.mentorg.com (c-50-152-159-227.hsd1.ca.comcast.net. [50.152.159.227]) by mx.google.com with ESMTPSA id ev8sm10870656pdb.28.2014.10.31.15.57.16 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Oct 2014 15:57:16 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: dri-devel@lists.freedesktop.org Subject: [PATCH 35/72] gpu: ipu-v3: Add IDMA channel linking support Date: Fri, 31 Oct 2014 15:54:18 -0700 Message-Id: <1414796095-10107-36-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1414796095-10107-1-git-send-email-steve_longerbeam@mentor.com> References: <1414796095-10107-1-git-send-email-steve_longerbeam@mentor.com> X-Mailman-Approved-At: Fri, 31 Oct 2014 16:56:31 -0700 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-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.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 --- drivers/gpu/ipu-v3/ipu-common.c | 112 +++++++++++++++++++++++++++++++++++++++ include/video/imx-ipu-v3.h | 3 ++ 2 files changed, 115 insertions(+) diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c index b1f0feb..ce1de54 100644 --- a/drivers/gpu/ipu-v3/ipu-common.c +++ b/drivers/gpu/ipu-v3/ipu-common.c @@ -755,6 +755,118 @@ 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 = { 20, IPU_FS_PROC_FLOW1, 0, 4, 7 }, + .sink = { 45, IPU_FS_PROC_FLOW2, 0, 4, 1 }, + }, { + .src = { 21, IPU_FS_PROC_FLOW1, 8, 4, 8 }, + .sink = { 46, IPU_FS_PROC_FLOW2, 4, 4, 1 }, + }, { + .src = { 22, IPU_FS_PROC_FLOW1, 16, 4, 5 }, + .sink = { 47, 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 f48ded6..df4cc5d 100644 --- a/include/video/imx-ipu-v3.h +++ b/include/video/imx-ipu-v3.h @@ -129,6 +129,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