All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
To: linux-media@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org
Subject: [PATCH v3 33/35] v4l: vsp1: Implement atomic update for the DRM driver
Date: Mon,  8 Feb 2016 13:44:03 +0200	[thread overview]
Message-ID: <1454931845-23864-34-git-send-email-laurent.pinchart+renesas@ideasonboard.com> (raw)
In-Reply-To: <1454931845-23864-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com>

Add two API functions named vsp1_du_atomic_begin() and
vsp1_du_atomic_flush() to signal the start and end of an atomic update.
The vsp1_du_setup_rpf() function is renamed to vsp1_du_atomic_update()
for consistency.

With this new API, the driver will reprogram all modified inputs
atomically before restarting the video stream.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/platform/vsp1/vsp1_drm.c | 70 +++++++++++++++++++++++++---------
 drivers/media/platform/vsp1/vsp1_drm.h |  7 ++++
 include/media/vsp1.h                   |  9 +++--
 3 files changed, 66 insertions(+), 20 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c
index a918bb4ab46c..8c76086caa67 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.c
+++ b/drivers/media/platform/vsp1/vsp1_drm.c
@@ -254,7 +254,26 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int width,
 EXPORT_SYMBOL_GPL(vsp1_du_setup_lif);
 
 /**
- * vsp1_du_setup_rpf - Setup one RPF input of the VSP pipeline
+ * vsp1_du_atomic_begin - Prepare for an atomic update
+ * @dev: the VSP device
+ */
+void vsp1_du_atomic_begin(struct device *dev)
+{
+	struct vsp1_device *vsp1 = dev_get_drvdata(dev);
+	struct vsp1_pipeline *pipe = &vsp1->drm->pipe;
+	unsigned long flags;
+
+	spin_lock_irqsave(&pipe->irqlock, flags);
+
+	vsp1->drm->num_inputs = pipe->num_inputs;
+	vsp1->drm->update = false;
+
+	spin_unlock_irqrestore(&pipe->irqlock, flags);
+}
+EXPORT_SYMBOL_GPL(vsp1_du_atomic_begin);
+
+/**
+ * vsp1_du_atomic_update - Setup one RPF input of the VSP pipeline
  * @dev: the VSP device
  * @rpf_index: index of the RPF to setup (0-based)
  * @pixelformat: V4L2 pixel format for the RPF memory input
@@ -288,10 +307,10 @@ EXPORT_SYMBOL_GPL(vsp1_du_setup_lif);
  *
  * Return 0 on success or a negative error code on failure.
  */
-int vsp1_du_setup_rpf(struct device *dev, unsigned int rpf_index,
-		      u32 pixelformat, unsigned int pitch,
-		      dma_addr_t mem[2], const struct v4l2_rect *src,
-		      const struct v4l2_rect *dst)
+int vsp1_du_atomic_update(struct device *dev, unsigned int rpf_index,
+			  u32 pixelformat, unsigned int pitch,
+			  dma_addr_t mem[2], const struct v4l2_rect *src,
+			  const struct v4l2_rect *dst)
 {
 	struct vsp1_device *vsp1 = dev_get_drvdata(dev);
 	struct vsp1_pipeline *pipe = &vsp1->drm->pipe;
@@ -301,7 +320,6 @@ int vsp1_du_setup_rpf(struct device *dev, unsigned int rpf_index,
 	struct vsp1_rwpf_memory memory;
 	struct vsp1_rwpf *rpf;
 	unsigned long flags;
-	bool start_stop = false;
 	int ret;
 
 	if (rpf_index >= vsp1->pdata.rpf_count)
@@ -322,16 +340,11 @@ int vsp1_du_setup_rpf(struct device *dev, unsigned int rpf_index,
 			vsp1->bru->inputs[rpf_index].rpf = NULL;
 			pipe->inputs[rpf_index] = NULL;
 
-			vsp1->drm->update = true;
-			start_stop = --pipe->num_inputs == 0;
+			pipe->num_inputs--;
 		}
 
 		spin_unlock_irqrestore(&pipe->irqlock, flags);
 
-		/* Stop the pipeline if we're the last user. */
-		if (start_stop)
-			vsp1_pipeline_stop(pipe);
-
 		return 0;
 	}
 
@@ -459,19 +472,42 @@ int vsp1_du_setup_rpf(struct device *dev, unsigned int rpf_index,
 	if (!pipe->inputs[rpf->entity.index]) {
 		vsp1->bru->inputs[rpf_index].rpf = rpf;
 		pipe->inputs[rpf->entity.index] = rpf;
-		start_stop = pipe->num_inputs++ == 0;
+		pipe->num_inputs++;
 	}
 
-	/* Start the pipeline if it's currently stopped. */
+	spin_unlock_irqrestore(&pipe->irqlock, flags);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(vsp1_du_atomic_update);
+
+/**
+ * vsp1_du_atomic_flush - Commit an atomic update
+ * @dev: the VSP device
+ */
+void vsp1_du_atomic_flush(struct device *dev)
+{
+	struct vsp1_device *vsp1 = dev_get_drvdata(dev);
+	struct vsp1_pipeline *pipe = &vsp1->drm->pipe;
+	unsigned long flags;
+	bool stop = false;
+
+	spin_lock_irqsave(&pipe->irqlock, flags);
+
 	vsp1->drm->update = true;
-	if (start_stop)
+
+	/* Start or stop the pipeline if needed. */
+	if (!vsp1->drm->num_inputs && pipe->num_inputs)
 		vsp1_drm_pipeline_run(pipe);
+	else if (vsp1->drm->num_inputs && !pipe->num_inputs)
+		stop = true;
 
 	spin_unlock_irqrestore(&pipe->irqlock, flags);
 
-	return 0;
+	if (stop)
+		vsp1_pipeline_stop(pipe);
 }
-EXPORT_SYMBOL_GPL(vsp1_du_setup_rpf);
+EXPORT_SYMBOL_GPL(vsp1_du_atomic_flush);
 
 /* -----------------------------------------------------------------------------
  * Initialization
diff --git a/drivers/media/platform/vsp1/vsp1_drm.h b/drivers/media/platform/vsp1/vsp1_drm.h
index 2ad320ab1e45..25d7f017feb4 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.h
+++ b/drivers/media/platform/vsp1/vsp1_drm.h
@@ -15,8 +15,15 @@
 
 #include "vsp1_pipe.h"
 
+/**
+ * vsp1_drm - State for the API exposed to the DRM driver
+ * @pipe: the VSP1 pipeline used for display
+ * @num_inputs: number of active pipeline inputs at the beginning of an update
+ * @update: the pipeline configuration has been updated
+ */
 struct vsp1_drm {
 	struct vsp1_pipeline pipe;
+	unsigned int num_inputs;
 	bool update;
 };
 
diff --git a/include/media/vsp1.h b/include/media/vsp1.h
index 2c1aea7066be..cc541753896f 100644
--- a/include/media/vsp1.h
+++ b/include/media/vsp1.h
@@ -23,8 +23,11 @@ int vsp1_du_init(struct device *dev);
 int vsp1_du_setup_lif(struct device *dev, unsigned int width,
 		      unsigned int height);
 
-int vsp1_du_setup_rpf(struct device *dev, unsigned int rpf, u32 pixelformat,
-		      unsigned int pitch, dma_addr_t mem[2],
-		      const struct v4l2_rect *src, const struct v4l2_rect *dst);
+int vsp1_du_atomic_begin(struct device *dev);
+int vsp1_du_atomic_update(struct device *dev, unsigned int rpf, u32 pixelformat,
+			  unsigned int pitch, dma_addr_t mem[2],
+			  const struct v4l2_rect *src,
+			  const struct v4l2_rect *dst);
+int vsp1_du_atomic_flush(struct device *dev);
 
 #endif /* __MEDIA_VSP1_H__ */
-- 
2.4.10


  parent reply	other threads:[~2016-02-08 11:44 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-08 11:43 [PATCH v3 00/35] VSP: Add R-Car Gen3 support Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 01/35] v4l: Add YUV 4:2:2 and YUV 4:4:4 tri-planar non-contiguous formats Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 02/35] v4l: vsp1: Add tri-planar memory formats support Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 03/35] v4l: vsp1: Group all link creation code in a single file Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 04/35] v4l: vsp1: Change the type of the rwpf field in struct vsp1_video Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 05/35] v4l: vsp1: Store the memory format in struct vsp1_rwpf Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 06/35] v4l: vsp1: Move video operations to vsp1_rwpf Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 07/35] v4l: vsp1: Rename vsp1_video_buffer to vsp1_vb2_buffer Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 08/35] v4l: vsp1: Move video device out of struct vsp1_rwpf Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 09/35] v4l: vsp1: Make rwpf operations independent of video device Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 10/35] v4l: vsp1: Support VSP1 instances without any UDS Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 11/35] v4l: vsp1: Move vsp1_video pointer from vsp1_entity to vsp1_rwpf Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 12/35] v4l: vsp1: Remove struct vsp1_pipeline num_video field Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 13/35] v4l: vsp1: Decouple pipeline end of frame processing from vsp1_video Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 14/35] v4l: vsp1: Split pipeline management code from vsp1_video.c Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 15/35] v4l: vsp1: Rename video pipeline functions to use vsp1_video prefix Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 16/35] v4l: vsp1: Extract pipeline initialization code into a function Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 17/35] v4l: vsp1: Reuse local variable instead of recomputing it Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 18/35] v4l: vsp1: Extract link creation to separate function Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 19/35] v4l: vsp1: Document the vsp1_pipeline structure Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 20/35] v4l: vsp1: Fix typo in VI6_DISP_IRQ_STA_DST register bit name Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 21/35] v4l: vsp1: Set the SRU CTRL0 register when starting the stream Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 22/35] v4l: vsp1: Remove unused module read functions Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 23/35] v4l: vsp1: Move entity route setup function to vsp1_entity.c Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 24/35] v4l: vsp1: Make number of BRU inputs configurable Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 25/35] v4l: vsp1: Make the BRU optional Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 26/35] v4l: vsp1: Move format info to vsp1_pipe.c Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 27/35] v4l: vsp1: Make the userspace API optional Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 28/35] v4l: vsp1: Make pipeline inputs array index by RPF index Laurent Pinchart
2016-02-08 11:43 ` [PATCH v3 29/35] v4l: vsp1: Set the alpha value manually in RPF and WPF s_stream handlers Laurent Pinchart
2016-02-08 11:44 ` [PATCH v3 30/35] v4l: vsp1: Don't validate links when the userspace API is disabled Laurent Pinchart
2016-02-08 11:44 ` [PATCH v3 31/35] v4l: vsp1: Add VSP+DU support Laurent Pinchart
2016-02-08 11:44 ` [PATCH v3 32/35] v4l: vsp1: Disconnect unused RPFs from the DRM pipeline Laurent Pinchart
2016-02-08 11:44 ` Laurent Pinchart [this message]
2016-02-08 11:44 ` [PATCH v3 34/35] v4l: vsp1: Add support for the R-Car Gen3 VSP2 Laurent Pinchart
2016-02-08 11:44 ` [PATCH v3 35/35] v4l: vsp1: Add display list support Laurent Pinchart

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=1454931845-23864-34-git-send-email-laurent.pinchart+renesas@ideasonboard.com \
    --to=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    /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.