All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Longerbeam <slongerbeam@gmail.com>
To: linux-media@vger.kernel.org
Cc: Steve Longerbeam <steve_longerbeam@mentor.com>
Subject: [PATCH 05/38] gpu: ipu-v3: Add IDMA channel linking support
Date: Tue, 14 Jun 2016 15:49:01 -0700	[thread overview]
Message-ID: <1465944574-15745-6-git-send-email-steve_longerbeam@mentor.com> (raw)
In-Reply-To: <1465944574-15745-1-git-send-email-steve_longerbeam@mentor.com>

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 <steve_longerbeam@mentor.com>
---
 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 49af121..6d1676e 100644
--- a/drivers/gpu/ipu-v3/ipu-common.c
+++ b/drivers/gpu/ipu-v3/ipu-common.c
@@ -730,6 +730,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 b174f8a..0a39c64 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
-- 
1.9.1


  parent reply	other threads:[~2016-06-14 22:51 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-14 22:48 [PATCH 00/38] i.MX5/6 Video Capture Steve Longerbeam
2016-06-14 22:48 ` [PATCH 01/38] gpu: ipu-v3: Add Video Deinterlacer unit Steve Longerbeam
2016-06-14 22:48 ` [PATCH 02/38] gpu: ipu-cpmem: Add ipu_cpmem_set_uv_offset() Steve Longerbeam
2016-06-14 22:48 ` [PATCH 03/38] gpu: ipu-cpmem: Add ipu_cpmem_get_burstsize() Steve Longerbeam
2016-06-14 22:49 ` [PATCH 04/38] gpu: ipu-v3: Add ipu_get_num() Steve Longerbeam
2016-06-14 22:49 ` Steve Longerbeam [this message]
2016-06-14 22:49 ` [PATCH 06/38] gpu: ipu-v3: Add ipu_set_vdi_src_mux() Steve Longerbeam
2016-06-14 22:49 ` [PATCH 07/38] gpu: ipu-v3: Add VDI input IDMAC channels Steve Longerbeam
2016-06-14 22:49 ` [PATCH 08/38] gpu: ipu-v3: Add ipu_csi_set_src() Steve Longerbeam
2016-06-14 22:49 ` [PATCH 09/38] gpu: ipu-v3: Add ipu_ic_set_src() Steve Longerbeam
2016-06-14 22:49 ` [PATCH 10/38] gpu: ipu-v3: set correct full sensor frame for PAL/NTSC Steve Longerbeam
2016-06-14 22:49 ` [PATCH 11/38] gpu: ipu-v3: Fix CSI data format for 16-bit media bus formats Steve Longerbeam
2016-06-14 22:49 ` [PATCH 12/38] gpu: ipu-v3: Fix CSI0 blur in NTSC format Steve Longerbeam
2016-06-14 22:49 ` [PATCH 13/38] gpu: ipu-v3: Fix IRT usage Steve Longerbeam
2016-06-14 22:49 ` [PATCH 14/38] gpu: ipu-ic: Add complete image conversion support with tiling Steve Longerbeam
2016-06-14 22:49 ` [PATCH 15/38] gpu: ipu-ic: allow multiple handles to ic Steve Longerbeam
2016-06-14 22:49 ` [PATCH 16/38] gpu: ipu-v3: rename CSI client device Steve Longerbeam
2016-06-14 22:49 ` [PATCH 17/38] ARM: dts: imx6qdl: Flesh out MIPI CSI2 receiver node Steve Longerbeam
2016-06-14 22:49 ` [PATCH 18/38] ARM: dts: imx6qdl: Add mipi_ipu1/2 video muxes, mipi_csi, and their connections Steve Longerbeam
2016-06-14 22:49 ` [PATCH 19/38] ARM: dts: imx6-sabrelite: add video capture ports and connections Steve Longerbeam
2016-06-16  8:32   ` [19/38] " Gary Bisson
2016-06-17 15:18     ` Gary Bisson
2016-06-17 16:09       ` Jack Mitchell
2016-06-17 19:00       ` tchellRe: " Steve Longerbeam
2016-06-18  9:05         ` Hans Verkuil
2016-06-17 19:01       ` Steve Longerbeam
2016-06-20  9:33         ` Gary Bisson
2016-06-20  9:44           ` Jack Mitchell
2016-06-20 10:16             ` Gary Bisson
2016-06-20 10:44               ` Jack Mitchell
2016-06-21 17:17                 ` Steve Longerbeam
2016-06-14 22:49 ` [PATCH 20/38] ARM: dts: imx6-sabresd: " Steve Longerbeam
2016-06-14 22:49 ` [PATCH 21/38] ARM: dts: imx6-sabreauto: create i2cmux for i2c3 Steve Longerbeam
2016-06-14 22:49 ` [PATCH 22/38] ARM: dts: imx6-sabreauto: add reset-gpios property for max7310 Steve Longerbeam
2016-06-14 22:49 ` [PATCH 23/38] ARM: dts: imx6-sabreauto: add pinctrl for gpt input capture Steve Longerbeam
2016-06-14 22:49 ` [PATCH 24/38] ARM: dts: imx6-sabreauto: add video capture ports and connections Steve Longerbeam
2016-06-14 22:49 ` [PATCH 25/38] ARM: dts: imx6qdl: add mem2mem device for sabre* boards Steve Longerbeam
2016-06-14 22:49 ` [PATCH 26/38] gpio: pca953x: Add reset-gpios property Steve Longerbeam
2016-06-14 22:49 ` [PATCH 27/38] clocksource/drivers/imx: add input capture support Steve Longerbeam
2016-06-14 22:49 ` [PATCH 28/38] v4l: Add signal lock status to source change events Steve Longerbeam
2016-07-01  7:24   ` Hans Verkuil
2016-07-02  3:59     ` Steve Longerbeam
2016-06-14 22:49 ` [PATCH 29/38] media: Add camera interface driver for i.MX5/6 Steve Longerbeam
2016-06-14 22:49 ` [PATCH 30/38] media: imx: Add MIPI CSI-2 Receiver driver Steve Longerbeam
2016-06-14 22:49 ` [PATCH 31/38] media: imx: Add video switch Steve Longerbeam
2016-06-16 16:13   ` Ian Arkver
2016-06-17 20:14     ` Steve Longerbeam
2016-06-14 22:49 ` [PATCH 32/38] media: imx: Add support for MIPI CSI-2 OV5640 Steve Longerbeam
2016-06-14 22:49 ` [PATCH 33/38] media: imx: Add support for Parallel OV5642 Steve Longerbeam
2016-06-14 22:49 ` [PATCH 34/38] media: imx: Add support for ADV7180 Video Decoder Steve Longerbeam
2016-06-16 11:33   ` Lars-Peter Clausen
2016-06-17 20:33     ` Steve Longerbeam
2016-06-14 22:49 ` [PATCH 35/38] media: adv7180: add power pin control Steve Longerbeam
2016-06-15 16:05   ` Lars-Peter Clausen
2016-06-16  1:34     ` Steve Longerbeam
2016-06-14 22:49 ` [PATCH 36/38] media: adv7180: implement g_parm Steve Longerbeam
2016-06-14 22:49 ` [PATCH 37/38] media: Add i.MX5/6 mem2mem driver Steve Longerbeam
2016-06-14 22:49 ` [PATCH 38/38] ARM: imx_v6_v7_defconfig: Enable staging video4linux drivers Steve Longerbeam
2016-06-15 10:43 ` [PATCH 00/38] i.MX5/6 Video Capture Jack Mitchell
2016-06-15 10:47   ` Hans Verkuil
2016-06-16  1:37   ` Steve Longerbeam
2016-06-16  9:49     ` Jack Mitchell
2016-06-16 17:02       ` Steve Longerbeam
2016-06-16 17:43         ` Nicolas Dufresne
2016-06-16 17:43         ` Nicolas Dufresne
2016-06-17  7:10         ` Hans Verkuil
2016-06-17 17:35           ` Steve Longerbeam
2016-06-18  9:01             ` Hans Verkuil
2016-06-28 18:54 ` Tim Harvey
2016-06-28 20:10   ` Hans Verkuil
2016-07-01  7:19     ` Hans Verkuil
2016-07-02  3:38   ` Steve Longerbeam
2016-07-06 23:06 ` [PATCH 00/28] i.MX5/6 Video Capture, v2 Steve Longerbeam
2016-07-06 23:06   ` [PATCH 01/28] gpu: ipu-v3: Add Video Deinterlacer unit Steve Longerbeam
2016-07-06 23:06   ` [PATCH 02/28] gpu: ipu-cpmem: Add ipu_cpmem_set_uv_offset() Steve Longerbeam
2016-07-06 23:06   ` [PATCH 03/28] gpu: ipu-cpmem: Add ipu_cpmem_get_burstsize() Steve Longerbeam
2016-07-06 23:06   ` [PATCH 04/28] gpu: ipu-v3: Add ipu_get_num() Steve Longerbeam
2016-07-06 23:06   ` [PATCH 05/28] gpu: ipu-v3: Add IDMA channel linking support Steve Longerbeam
2016-07-06 23:06   ` [PATCH 06/28] gpu: ipu-v3: Add ipu_set_vdi_src_mux() Steve Longerbeam
2016-07-06 23:06   ` [PATCH 07/28] gpu: ipu-v3: Add VDI input IDMAC channels Steve Longerbeam
2016-07-06 23:06   ` [PATCH 08/28] gpu: ipu-v3: Add ipu_csi_set_src() Steve Longerbeam
2016-07-06 23:06   ` [PATCH 09/28] gpu: ipu-v3: Add ipu_ic_set_src() Steve Longerbeam
2016-07-06 23:06   ` [PATCH 10/28] gpu: ipu-v3: set correct full sensor frame for PAL/NTSC Steve Longerbeam
2016-07-06 23:06   ` [PATCH 11/28] gpu: ipu-v3: Fix CSI data format for 16-bit media bus formats Steve Longerbeam
2016-07-06 23:06   ` [PATCH 12/28] gpu: ipu-v3: Fix CSI0 blur in NTSC format Steve Longerbeam
2016-07-06 23:06   ` [PATCH 13/28] gpu: ipu-v3: Fix IRT usage Steve Longerbeam
2016-07-06 23:06   ` [PATCH 14/28] gpu: ipu-ic: Add complete image conversion support with tiling Steve Longerbeam
2016-07-13 18:58     ` Mauro Carvalho Chehab
2016-07-13 19:06       ` Mauro Carvalho Chehab
2016-07-13 22:24       ` Steve Longerbeam
2016-07-06 23:06   ` [PATCH 15/28] gpu: ipu-ic: allow multiple handles to ic Steve Longerbeam
2016-07-06 23:06   ` [PATCH 16/28] gpu: ipu-v3: rename CSI client device Steve Longerbeam
2016-07-06 23:06   ` [PATCH 17/28] gpio: pca953x: Add optional reset gpio control Steve Longerbeam
2016-07-06 23:06   ` [PATCH 18/28] clocksource/drivers/imx: add input capture support Steve Longerbeam
2016-07-06 23:06   ` [PATCH 19/28] media: Add i.MX5/6 camera interface driver Steve Longerbeam
2016-07-06 23:06   ` [PATCH 20/28] media: imx: Add MIPI CSI-2 Receiver driver Steve Longerbeam
2016-07-06 23:06   ` [PATCH 21/28] media: imx: Add video switch Steve Longerbeam
2016-07-06 23:06   ` [PATCH 22/28] media: imx: Add support for MIPI CSI-2 OV5640 Steve Longerbeam
2016-07-06 23:06   ` [PATCH 23/28] media: imx: Add support for Parallel OV5642 Steve Longerbeam
2016-07-06 23:06   ` [PATCH 24/28] media: Add i.MX5/6 mem2mem driver Steve Longerbeam
2016-07-06 23:06   ` [PATCH 25/28] ARM: dts: imx6qdl: Flesh out MIPI CSI2 receiver node Steve Longerbeam
2016-07-06 23:06   ` [PATCH 26/28] ARM: dts: imx6qdl: Add mipi_ipu1/2 video muxes, mipi_csi, and their connections Steve Longerbeam
2016-07-06 23:11   ` [PATCH 27/28] ARM: dts: imx6qdl: add mem2mem devices Steve Longerbeam
2016-07-06 23:11     ` [PATCH 28/28] ARM: imx_v6_v7_defconfig: Enable staging video4linux drivers Steve Longerbeam
2016-07-07 13:31   ` [PATCH 00/28] i.MX5/6 Video Capture, v2 Tim Harvey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1465944574-15745-6-git-send-email-steve_longerbeam@mentor.com \
    --to=slongerbeam@gmail.com \
    --cc=linux-media@vger.kernel.org \
    --cc=steve_longerbeam@mentor.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.