Linux Media Controller development
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>
To: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-renesas-soc@vger.kernel.org,
	Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
	Kieran Bingham <kieran.bingham@ideasonboard.com>,
	Biju Das <biju.das.jz@bp.renesas.com>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Subject: Re: [PATCH 02/11] media: renesas: vsp1: Split vsp1_du_setup_lif()
Date: Wed, 13 May 2026 21:11:48 +0200	[thread overview]
Message-ID: <20260513191148.GE332351@ragnatech.se> (raw)
In-Reply-To: <20260511235637.3468558-3-laurent.pinchart+renesas@ideasonboard.com>

Hi Laurent,

Thanks for your cleanup!

On 2026-05-12 02:56:26 +0300, Laurent Pinchart wrote:
> The vsp1_du_setup_lif() function is used to configure and enable a
> pipeline, as well as disable it, depending on the cfg argument being a
> valid pointer or NULL. This creates a confusing API. Improve it by
> splitting the function in two, a vsp1_du_enable() function to configure
> a pipeline, and a vsp1_du_disable() function to disaple it.
> 
> Keep vsp1_du_setup_lif() as an inline wrapper for existing callers in
> the DRM subsystem, to simplify merging. The callers will be updated
> separately and the old API will then be removed.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> ---
>  .../media/platform/renesas/vsp1/vsp1_drm.c    | 140 ++++++++++--------
>  include/media/vsp1.h                          |  14 +-
>  2 files changed, 91 insertions(+), 63 deletions(-)
> 
> diff --git a/drivers/media/platform/renesas/vsp1/vsp1_drm.c b/drivers/media/platform/renesas/vsp1/vsp1_drm.c
> index 79b85968b061..1f431874064d 100644
> --- a/drivers/media/platform/renesas/vsp1/vsp1_drm.c
> +++ b/drivers/media/platform/renesas/vsp1/vsp1_drm.c
> @@ -629,14 +629,14 @@ int vsp1_du_init(struct device *dev)
>  EXPORT_SYMBOL_GPL(vsp1_du_init);
>  
>  /**
> - * vsp1_du_setup_lif - Setup the output part of the VSP pipeline
> + * vsp1_du_enable - Setup and enable a DU pipeline
>   * @dev: the VSP device
>   * @pipe_index: the DRM pipeline index
>   * @cfg: the LIF configuration
>   *
>   * Configure the output part of VSP DRM pipeline for the given frame @cfg.width
>   * and @cfg.height. This sets up formats on the BRx source pad, the WPF sink and
> - * source pads, and the LIF sink pad.
> + * source pads, and the LIF sink pad, and then starts the pipeline.
>   *
>   * The @pipe_index argument selects which DRM pipeline to setup. The number of
>   * available pipelines depend on the VSP instance.
> @@ -649,14 +649,13 @@ EXPORT_SYMBOL_GPL(vsp1_du_init);
>   *
>   * Return 0 on success or a negative error code on failure.
>   */
> -int vsp1_du_setup_lif(struct device *dev, unsigned int pipe_index,
> -		      const struct vsp1_du_lif_config *cfg)
> +int vsp1_du_enable(struct device *dev, unsigned int pipe_index,
> +		   const struct vsp1_du_lif_config *cfg)
>  {
>  	struct vsp1_device *vsp1 = dev_get_drvdata(dev);
>  	struct vsp1_drm_pipeline *drm_pipe;
>  	struct vsp1_pipeline *pipe;
>  	unsigned long flags;
> -	unsigned int i;
>  	int ret;
>  
>  	if (pipe_index >= vsp1->info->lif_count)
> @@ -665,60 +664,6 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int pipe_index,
>  	drm_pipe = &vsp1->drm->pipe[pipe_index];
>  	pipe = &drm_pipe->pipe;
>  
> -	if (!cfg) {
> -		struct vsp1_brx *brx;
> -
> -		mutex_lock(&vsp1->drm->lock);
> -
> -		brx = to_brx(&pipe->brx->subdev);
> -
> -		/*
> -		 * NULL configuration means the CRTC is being disabled, stop
> -		 * the pipeline and turn the light off.
> -		 */
> -		ret = vsp1_pipeline_stop(pipe);
> -		if (ret == -ETIMEDOUT)
> -			dev_err(vsp1->dev, "DRM pipeline stop timeout\n");
> -
> -		for (i = 0; i < ARRAY_SIZE(pipe->inputs); ++i) {
> -			struct vsp1_rwpf *rpf = pipe->inputs[i];
> -
> -			if (!rpf)
> -				continue;
> -
> -			/*
> -			 * Remove the RPF from the pipe and the list of BRx
> -			 * inputs.
> -			 */
> -			WARN_ON(!rpf->entity.pipe);
> -			rpf->entity.pipe = NULL;
> -			list_del(&rpf->entity.list_pipe);
> -			pipe->inputs[i] = NULL;
> -
> -			brx->inputs[rpf->brx_input].rpf = NULL;
> -		}
> -
> -		drm_pipe->du_complete = NULL;
> -		pipe->num_inputs = 0;
> -
> -		dev_dbg(vsp1->dev, "%s: pipe %u: releasing %s\n",
> -			__func__, pipe->lif->index,
> -			BRX_NAME(pipe->brx));
> -
> -		list_del(&pipe->brx->list_pipe);
> -		pipe->brx->pipe = NULL;
> -		pipe->brx = NULL;
> -
> -		mutex_unlock(&vsp1->drm->lock);
> -
> -		vsp1_dlm_reset(pipe->output->dlm);
> -		vsp1_device_put(vsp1);
> -
> -		dev_dbg(vsp1->dev, "%s: pipeline disabled\n", __func__);
> -
> -		return 0;
> -	}
> -
>  	/* Reset the underrun counter */
>  	pipe->underrun_count = 0;
>  
> @@ -741,7 +686,7 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int pipe_index,
>  	if (ret < 0)
>  		goto unlock;
>  
> -	vsp1_pipeline_dump(pipe, "LIF setup");
> +	vsp1_pipeline_dump(pipe, "DU enable");
>  
>  	/* Enable the VSP1. */
>  	ret = vsp1_device_get(vsp1);
> @@ -777,7 +722,80 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int pipe_index,
>  
>  	return 0;
>  }
> -EXPORT_SYMBOL_GPL(vsp1_du_setup_lif);
> +EXPORT_SYMBOL_GPL(vsp1_du_enable);
> +
> +/**
> + * vsp1_du_disable - Disable and stop a DU pipeline
> + * @dev: the VSP device
> + * @pipe_index: the DRM pipeline index
> + *
> + * The @pipe_index argument selects which DRM pipeline to disable. The number
> + * of available pipelines depend on the VSP instance.
> + *
> + * Return 0 on success or a negative error code on failure.
> + */
> +int vsp1_du_disable(struct device *dev, unsigned int pipe_index)
> +{
> +	struct vsp1_device *vsp1 = dev_get_drvdata(dev);
> +	struct vsp1_drm_pipeline *drm_pipe;
> +	struct vsp1_pipeline *pipe;
> +	struct vsp1_brx *brx;
> +	unsigned int i;
> +	int ret;
> +
> +	if (pipe_index >= vsp1->info->lif_count)
> +		return -EINVAL;
> +
> +	drm_pipe = &vsp1->drm->pipe[pipe_index];
> +	pipe = &drm_pipe->pipe;
> +
> +	mutex_lock(&vsp1->drm->lock);
> +
> +	brx = to_brx(&pipe->brx->subdev);
> +
> +	ret = vsp1_pipeline_stop(pipe);
> +	if (ret == -ETIMEDOUT)
> +		dev_err(vsp1->dev, "DRM pipeline stop timeout\n");
> +
> +	for (i = 0; i < ARRAY_SIZE(pipe->inputs); ++i) {
> +		struct vsp1_rwpf *rpf = pipe->inputs[i];
> +
> +		if (!rpf)
> +			continue;
> +
> +		/*
> +		 * Remove the RPF from the pipe and the list of BRx
> +		 * inputs.
> +		 */
> +		WARN_ON(!rpf->entity.pipe);
> +		rpf->entity.pipe = NULL;
> +		list_del(&rpf->entity.list_pipe);
> +		pipe->inputs[i] = NULL;
> +
> +		brx->inputs[rpf->brx_input].rpf = NULL;
> +	}
> +
> +	drm_pipe->du_complete = NULL;
> +	pipe->num_inputs = 0;
> +
> +	dev_dbg(vsp1->dev, "%s: pipe %u: releasing %s\n",
> +		__func__, pipe->lif->index,
> +		BRX_NAME(pipe->brx));
> +
> +	list_del(&pipe->brx->list_pipe);
> +	pipe->brx->pipe = NULL;
> +	pipe->brx = NULL;
> +
> +	mutex_unlock(&vsp1->drm->lock);
> +
> +	vsp1_dlm_reset(pipe->output->dlm);
> +	vsp1_device_put(vsp1);
> +
> +	dev_dbg(vsp1->dev, "%s: pipeline disabled\n", __func__);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(vsp1_du_disable);
>  
>  /**
>   * vsp1_du_atomic_begin - Prepare for an atomic update
> diff --git a/include/media/vsp1.h b/include/media/vsp1.h
> index d9b91ff02761..d2085cdb7fcb 100644
> --- a/include/media/vsp1.h
> +++ b/include/media/vsp1.h
> @@ -44,8 +44,18 @@ struct vsp1_du_lif_config {
>  	void *callback_data;
>  };
>  
> -int vsp1_du_setup_lif(struct device *dev, unsigned int pipe_index,
> -		      const struct vsp1_du_lif_config *cfg);
> +int vsp1_du_enable(struct device *dev, unsigned int pipe_index,
> +		   const struct vsp1_du_lif_config *cfg);
> +int vsp1_du_disable(struct device *dev, unsigned int pipe_index);
> +
> +static inline int vsp1_du_setup_lif(struct device *dev, unsigned int pipe_index,
> +				    const struct vsp1_du_lif_config *cfg)
> +{
> +	if (cfg)
> +		return vsp1_du_enable(dev, pipe_index, cfg);
> +	else
> +		return vsp1_du_disable(dev, pipe_index);
> +}
>  
>  /**
>   * struct vsp1_du_atomic_config - VSP atomic configuration parameters
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> 

-- 
Kind Regards,
Niklas Söderlund

  reply	other threads:[~2026-05-13 19:11 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-11 23:56 [PATCH 00/11] media: renesas: vsp1: Modernize the driver Laurent Pinchart
2026-05-11 23:56 ` [PATCH 01/11] media: renesas: vsp1: Avoid forward function declaration Laurent Pinchart
2026-05-13 19:09   ` Niklas Söderlund
2026-05-11 23:56 ` [PATCH 02/11] media: renesas: vsp1: Split vsp1_du_setup_lif() Laurent Pinchart
2026-05-13 19:11   ` Niklas Söderlund [this message]
2026-05-11 23:56 ` [PATCH 03/11] drm: renesas: rcar-du: Switch to new VSP API Laurent Pinchart
2026-05-13 19:12   ` Niklas Söderlund
2026-05-11 23:56 ` [PATCH 04/11] drm: renesas: rz-du: " Laurent Pinchart
2026-05-13 19:13   ` Niklas Söderlund
2026-05-11 23:56 ` [PATCH 05/11] media: renesas: vsp1: Use mutex guards Laurent Pinchart
2026-05-13 19:20   ` Niklas Söderlund
2026-05-13 19:40     ` Laurent Pinchart
2026-05-11 23:56 ` [PATCH 06/11] media: renesas: vsp1: Use mutex scoped guards Laurent Pinchart
2026-05-13 19:24   ` Niklas Söderlund
2026-05-11 23:56 ` [PATCH 07/11] media: renesas: vsp1: Use spinlock guards Laurent Pinchart
2026-05-13 19:29   ` Niklas Söderlund
2026-05-11 23:56 ` [PATCH 08/11] media: renesas: vsp1: Use spinlock scoped guards Laurent Pinchart
2026-05-13 19:37   ` Niklas Söderlund
2026-05-11 23:56 ` [PATCH 09/11] media: renesas: vsp1: Simplify iteration over format arrays Laurent Pinchart
2026-05-13 19:44   ` Niklas Söderlund
2026-05-11 23:56 ` [PATCH 10/11] media: renesas: vsp1: Declare index variables in for loop statement Laurent Pinchart
2026-05-13 20:29   ` Niklas Söderlund
2026-05-11 23:56 ` [PATCH 11/11] media: renesas: vsp1: Drop deprecated vsp1_du_setup_lif() function Laurent Pinchart
2026-05-13 20:31   ` Niklas Söderlund

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=20260513191148.GE332351@ragnatech.se \
    --to=niklas.soderlund@ragnatech.se \
    --cc=airlied@gmail.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tomi.valkeinen@ideasonboard.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox