Linux-Renesas-SoC Archive on lore.kernel.org
 help / color / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Cc: Ulrich Hecht <uli@fpond.eu>,
	linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	Ulrich Hecht <uli+renesas@fpond.eu>
Subject: Re: [PATCH v2 8/8] rcar-vin: Merge Gen2 and Gen3 file operations
Date: Thu, 16 May 2019 14:48:34 +0300
Message-ID: <20190516114834.GG14820@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20190516011417.10590-9-niklas.soderlund+renesas@ragnatech.se>

Hi Niklas,

Thank you for the patch.

On Thu, May 16, 2019 at 03:14:17AM +0200, Niklas Söderlund wrote:
> After the rework of the Gen2 file operations it's now trivial to merge
> the Gen2 and Gen3 versions.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>
> ---
>  drivers/media/platform/rcar-vin/rcar-v4l2.c | 96 ++++-----------------
>  1 file changed, 16 insertions(+), 80 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> index 169639416121f204..8e4afa4278fe9d30 100644
> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> @@ -781,14 +781,19 @@ static int rvin_open(struct file *file)
>  	if (ret)
>  		goto err_pm;
>  
> -	if (v4l2_fh_is_singular_file(file)) {
> -		ret = rvin_power_parallel(vin, true);
> +	if (vin->info->use_mc) {
> +		ret = v4l2_pipeline_pm_use(&vin->vdev.entity, 1);
>  		if (ret < 0)
>  			goto err_open;
> +	} else {
> +		if (v4l2_fh_is_singular_file(file)) {
> +			ret = rvin_power_parallel(vin, true);
> +			if (ret < 0)
> +				goto err_open;
>  
> -		v4l2_ctrl_handler_setup(&vin->ctrl_handler);
> +			v4l2_ctrl_handler_setup(&vin->ctrl_handler);
> +		}
>  	}

I wonder if you shouldn't abstract the first open init and last close
cleanup operations in separate functions, with MC and non-MC variants,
as you will need to handle the v4l2_ctrl_handler_setup() failure here,
making error handling more complex.

> -
>  	mutex_unlock(&vin->lock);
>  
>  	return 0;
> @@ -816,12 +821,12 @@ static int rvin_release(struct file *file)
>  	/* the release helper will cleanup any on-going streaming */
>  	ret = _vb2_fop_release(file, NULL);
>  
> -	/*
> -	 * If this was the last open file.
> -	 * Then de-initialize hw module.
> -	 */
> -	if (fh_singular)
> -		rvin_power_parallel(vin, false);
> +	if (vin->info->use_mc) {
> +		v4l2_pipeline_pm_use(&vin->vdev.entity, 0);
> +	} else {
> +		if (fh_singular)
> +			rvin_power_parallel(vin, false);
> +	}
>  
>  	pm_runtime_put(vin->dev);
>  
> @@ -840,74 +845,6 @@ static const struct v4l2_file_operations rvin_fops = {
>  	.read		= vb2_fop_read,
>  };
>  
> -/* -----------------------------------------------------------------------------
> - * Media controller file operations
> - */
> -
> -static int rvin_mc_open(struct file *file)
> -{
> -	struct rvin_dev *vin = video_drvdata(file);
> -	int ret;
> -
> -	ret = mutex_lock_interruptible(&vin->lock);
> -	if (ret)
> -		return ret;
> -
> -	ret = pm_runtime_get_sync(vin->dev);
> -	if (ret < 0)
> -		goto err_unlock;
> -
> -	ret = v4l2_pipeline_pm_use(&vin->vdev.entity, 1);
> -	if (ret < 0)
> -		goto err_pm;
> -
> -	file->private_data = vin;
> -
> -	ret = v4l2_fh_open(file);
> -	if (ret)
> -		goto err_v4l2pm;
> -
> -	mutex_unlock(&vin->lock);
> -
> -	return 0;
> -err_v4l2pm:
> -	v4l2_pipeline_pm_use(&vin->vdev.entity, 0);
> -err_pm:
> -	pm_runtime_put(vin->dev);
> -err_unlock:
> -	mutex_unlock(&vin->lock);
> -
> -	return ret;
> -}
> -
> -static int rvin_mc_release(struct file *file)
> -{
> -	struct rvin_dev *vin = video_drvdata(file);
> -	int ret;
> -
> -	mutex_lock(&vin->lock);
> -
> -	/* the release helper will cleanup any on-going streaming. */
> -	ret = _vb2_fop_release(file, NULL);
> -
> -	v4l2_pipeline_pm_use(&vin->vdev.entity, 0);
> -	pm_runtime_put(vin->dev);
> -
> -	mutex_unlock(&vin->lock);
> -
> -	return ret;
> -}
> -
> -static const struct v4l2_file_operations rvin_mc_fops = {
> -	.owner		= THIS_MODULE,
> -	.unlocked_ioctl	= video_ioctl2,
> -	.open		= rvin_mc_open,
> -	.release	= rvin_mc_release,
> -	.poll		= vb2_fop_poll,
> -	.mmap		= vb2_fop_mmap,
> -	.read		= vb2_fop_read,
> -};
> -
>  void rvin_v4l2_unregister(struct rvin_dev *vin)
>  {
>  	if (!video_is_registered(&vin->vdev))
> @@ -948,6 +885,7 @@ int rvin_v4l2_register(struct rvin_dev *vin)
>  	snprintf(vdev->name, sizeof(vdev->name), "VIN%u output", vin->id);
>  	vdev->release = video_device_release_empty;
>  	vdev->lock = &vin->lock;
> +	vdev->fops = &rvin_fops;
>  	vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
>  		V4L2_CAP_READWRITE;
>  
> @@ -959,10 +897,8 @@ int rvin_v4l2_register(struct rvin_dev *vin)
>  	vin->format.colorspace = RVIN_DEFAULT_COLORSPACE;
>  
>  	if (vin->info->use_mc) {
> -		vdev->fops = &rvin_mc_fops;
>  		vdev->ioctl_ops = &rvin_mc_ioctl_ops;
>  	} else {
> -		vdev->fops = &rvin_fops;
>  		vdev->ioctl_ops = &rvin_ioctl_ops;
>  		rvin_reset_format(vin);
>  	}

-- 
Regards,

Laurent Pinchart

      reply index

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-16  1:14 [PATCH v2 0/8] " Niklas Söderlund
2019-05-16  1:14 ` [PATCH v2 1/8] rcar-vin: Do not call pm_runtime_{resume,suspend}() Niklas Söderlund
2019-05-16  7:23   ` Geert Uytterhoeven
2019-05-16 11:32     ` Laurent Pinchart
2019-05-16  1:14 ` [PATCH v2 2/8] rcar-vin: Remove unneeded calls to pm_runtime_{enable,disable} Niklas Söderlund
2019-05-16  7:27   ` Geert Uytterhoeven
2019-05-16 11:34     ` Laurent Pinchart
2019-05-16  1:14 ` [PATCH v2 3/8] rcar-vin: Allow interrupting lock when trying to open the video device Niklas Söderlund
2019-05-16 11:21   ` Laurent Pinchart
2019-05-16  1:14 ` [PATCH v2 4/8] rcar-vin: Do not sync subdevice format when opening " Niklas Söderlund
2019-05-16 11:26   ` Laurent Pinchart
2019-05-16 13:25     ` Niklas Söderlund
2019-05-16  1:14 ` [PATCH v2 5/8] rcar-vin: Move pm_runtime_{get,put} out of helpers Niklas Söderlund
2019-05-16 11:39   ` Laurent Pinchart
2019-05-16  1:14 ` [PATCH v2 6/8] rcar-vin: Merge helpers dealing with powering the parallel subdevice Niklas Söderlund
2019-05-16  7:40   ` Ulrich Hecht
2019-05-16 11:44   ` Laurent Pinchart
2019-05-16  1:14 ` [PATCH v2 7/8] rcar-vin: Fold rvin_initialize_device() into rvin_open() Niklas Söderlund
2019-05-16 11:45   ` Laurent Pinchart
2019-05-16  1:14 ` [PATCH v2 8/8] rcar-vin: Merge Gen2 and Gen3 file operations Niklas Söderlund
2019-05-16 11:48   ` Laurent Pinchart [this message]

Reply instructions:

You may reply publically 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=20190516114834.GG14820@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=uli+renesas@fpond.eu \
    --cc=uli@fpond.eu \
    /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

Linux-Renesas-SoC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-renesas-soc/0 linux-renesas-soc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-renesas-soc linux-renesas-soc/ https://lore.kernel.org/linux-renesas-soc \
		linux-renesas-soc@vger.kernel.org linux-renesas-soc@archiver.kernel.org
	public-inbox-index linux-renesas-soc


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-renesas-soc


AGPL code for this site: git clone https://public-inbox.org/ public-inbox