mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Umang Jain <umang.jain@ideasonboard.com>
Cc: linux-media@vger.kernel.org, kernel-list@raspberrypi.com,
	linux-kernel@vger.kernel.org,
	linux-rpi-kernel@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-staging@lists.linux.dev,
	Broadcom internal kernel review list 
	<bcm-kernel-feedback-list@broadcom.com>,
	Dave Stevenson <dave.stevenson@raspberrypi.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Naushir Patuck <naush@raspberrypi.com>,
	David Plowman <david.plowman@raspberrypi.com>,
	Kieran Bingham <kieran.bingham@ideasonboard.com>
Subject: Re: [PATCH 12/14] staging: vc04_services: bcm2835_isp: Allow multiple users
Date: Tue, 22 Nov 2022 01:29:47 +0200	[thread overview]
Message-ID: <Y3wJ6/+Hl6JTm1Bu@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20221121214722.22563-13-umang.jain@ideasonboard.com>

Hi Umang and Naush,

Thank you for the patch.

On Tue, Nov 22, 2022 at 03:17:20AM +0530, Umang Jain wrote:
> From: Naushir Patuck <naush@raspberrypi.com>
> 
> Add a second (identical) set of device nodes to allow concurrent use of
> the bcm2835-isp hardware by another user. This change effectively
> creates a second state structure (struct bcm2835_isp_dev) to maintain
> independent state for the second user. Node and media entity names are
> appened with the instance index appropriately.
> 
> Further users can be added by changing the BCM2835_ISP_NUM_INSTANCES
> define.
> 
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>

Let's squash this with 09/14.

> ---
>  .../bcm2835-isp/bcm2835-v4l2-isp.c            | 77 +++++++++++++++----
>  1 file changed, 61 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c b/drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c
> index cb7cdba76682..0dbcb25595e7 100644
> --- a/drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c
> +++ b/drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c
> @@ -28,13 +28,19 @@
>  
>  MODULE_IMPORT_NS(DMA_BUF);
>  
> +/*
> + * We want to instantiate 2 independent instances allowing 2 simultaneous users
> + * of the ISP hardware.
> + */
> +#define BCM2835_ISP_NUM_INSTANCES 2
> +
>  static unsigned int debug;
>  module_param(debug, uint, 0644);
>  MODULE_PARM_DESC(debug, "activates debug info");
>  
> -static unsigned int video_nr = 13;
> -module_param(video_nr, uint, 0644);
> -MODULE_PARM_DESC(video_nr, "base video device number");
> +static unsigned int video_nr[BCM2835_ISP_NUM_INSTANCES] = { 13, 20 };
> +module_param_array(video_nr, uint, NULL, 0644);
> +MODULE_PARM_DESC(video_nr, "base video device numbers");
>  
>  #define BCM2835_ISP_NAME "bcm2835-isp"
>  #define BCM2835_ISP_ENTITY_NAME_LEN 32
> @@ -1286,6 +1292,7 @@ static int bcm2835_isp_get_supported_fmts(struct bcm2835_isp_node *node)
>   * or output nodes.
>   */
>  static int register_node(struct bcm2835_isp_dev *dev,
> +			 unsigned int instance,
>  			 struct bcm2835_isp_node *node,
>  			 int index)
>  {
> @@ -1447,7 +1454,7 @@ static int register_node(struct bcm2835_isp_dev *dev,
>  	snprintf(vfd->name, sizeof(node->vfd.name), "%s-%s%d", BCM2835_ISP_NAME,
>  		 node->name, node->id);
>  
> -	ret = video_register_device(vfd, VFL_TYPE_VIDEO, video_nr + index);
> +	ret = video_register_device(vfd, VFL_TYPE_VIDEO, video_nr[instance]);
>  	if (ret) {
>  		v4l2_err(&dev->v4l2_dev,
>  			 "Failed to register video %s[%d] device node\n",
> @@ -1668,9 +1675,8 @@ static int media_controller_register(struct bcm2835_isp_dev *dev)
>  	return ret;
>  }
>  
> -static int bcm2835_isp_remove(struct platform_device *pdev)
> +static void bcm2835_isp_remove_instance(struct bcm2835_isp_dev *dev)
>  {
> -	struct bcm2835_isp_dev *dev = platform_get_drvdata(pdev);
>  	unsigned int i;
>  
>  	media_controller_unregister(dev);
> @@ -1685,11 +1691,11 @@ static int bcm2835_isp_remove(struct platform_device *pdev)
>  					      dev->component);
>  
>  	vchiq_mmal_finalise(dev->mmal_instance);
> -
> -	return 0;
>  }
>  
> -static int bcm2835_isp_probe(struct platform_device *pdev)
> +static int bcm2835_isp_probe_instance(struct platform_device *pdev,
> +				      struct bcm2835_isp_dev **dev_int,
> +				      unsigned int instance)
>  {
>  	struct bcm2835_isp_dev *dev;
>  	unsigned int i;
> @@ -1699,6 +1705,7 @@ static int bcm2835_isp_probe(struct platform_device *pdev)
>  	if (!dev)
>  		return -ENOMEM;
>  
> +	*dev_int = dev;
>  	dev->dev = &pdev->dev;
>  
>  	ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev);
> @@ -1716,7 +1723,7 @@ static int bcm2835_isp_probe(struct platform_device *pdev)
>  	if (ret) {
>  		v4l2_err(&dev->v4l2_dev,
>  			 "%s: failed to create ril.isp component\n", __func__);
> -		goto error;
> +		return ret;
>  	}
>  
>  	if (dev->component->inputs < BCM2835_ISP_NUM_OUTPUTS ||
> @@ -1728,7 +1735,7 @@ static int bcm2835_isp_probe(struct platform_device *pdev)
>  			  BCM2835_ISP_NUM_OUTPUTS,
>  			  dev->component->outputs,
>  			  BCM2835_ISP_NUM_CAPTURES + BCM2835_ISP_NUM_METADATA);
> -		goto error;
> +		return -EINVAL;
>  	}
>  
>  	atomic_set(&dev->num_streaming, 0);
> @@ -1736,17 +1743,55 @@ static int bcm2835_isp_probe(struct platform_device *pdev)
>  	for (i = 0; i < BCM2835_ISP_NUM_NODES; i++) {
>  		struct bcm2835_isp_node *node = &dev->node[i];
>  
> -		ret = register_node(dev, node, i);
> +		ret = register_node(dev, instance, node, i);
>  		if (ret)
> -			goto error;
> +			return ret;
>  	}
>  
>  	ret = media_controller_register(dev);
>  	if (ret)
> -		goto error;
> +		return ret;
> +
> +	return 0;
> +}
> +
> +static int bcm2835_isp_remove(struct platform_device *pdev)
> +{
> +	struct bcm2835_isp_dev **bcm2835_isp_instances;
> +	unsigned int i;
> +
> +	bcm2835_isp_instances = platform_get_drvdata(pdev);
> +	for (i = 0; i < BCM2835_ISP_NUM_INSTANCES; i++) {
> +		if (bcm2835_isp_instances[i])
> +			bcm2835_isp_remove_instance(bcm2835_isp_instances[i]);
> +	}
> +
> +	return 0;
> +}
> +
> +static int bcm2835_isp_probe(struct platform_device *pdev)
> +{
> +	struct bcm2835_isp_dev **bcm2835_isp_instances;
> +	unsigned int i;
> +	int ret;
> +
> +	bcm2835_isp_instances = devm_kzalloc(&pdev->dev,
> +					     sizeof(bcm2835_isp_instances) *
> +						      BCM2835_ISP_NUM_INSTANCES,
> +					     GFP_KERNEL);
> +	if (!bcm2835_isp_instances)
> +		return -ENOMEM;
> +
> +	platform_set_drvdata(pdev, bcm2835_isp_instances);
> +
> +	for (i = 0; i < BCM2835_ISP_NUM_INSTANCES; i++) {
> +		ret = bcm2835_isp_probe_instance(pdev,
> +						 &bcm2835_isp_instances[i], i);
> +		if (ret)
> +			goto error;
> +	}
>  
> -	platform_set_drvdata(pdev, dev);
> -	v4l2_info(&dev->v4l2_dev, "Loaded V4L2 %s\n", BCM2835_ISP_NAME);
> +	dev_info(&pdev->dev, "Loaded V4L2 %s\n", BCM2835_ISP_NAME);
>  	return 0;
>  
>  error:

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2022-11-21 23:30 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-21 21:47 [PATCH 00/14] staging: vc04_services: bcm2835-isp support Umang Jain
2022-11-21 21:47 ` [PATCH 01/14] staging: vc04_services: Add new vc-sm-cma driver Umang Jain
2022-11-21 23:04   ` Laurent Pinchart
2022-11-21 21:47 ` [PATCH 02/14] staging: vchiq_arm: Register vcsm-cma as a platform driver Umang Jain
2022-11-21 23:07   ` Laurent Pinchart
2022-11-21 21:47 ` [PATCH 03/14] media: videobuf2: Allow exporting of a struct dmabuf Umang Jain
2022-11-21 23:18   ` Laurent Pinchart
2022-11-22 11:35     ` Dave Stevenson
2022-11-25  1:49       ` Laurent Pinchart
2022-11-21 21:47 ` [PATCH 04/14] staging: mmal-vchiq: Add support for event callbacks Umang Jain
2022-11-21 21:47 ` [PATCH 05/14] staging: mmal-vchiq: Use vc-sm-cma to support zero copy Umang Jain
2022-11-21 21:47 ` [PATCH 06/14] staging: mmal_vchiq: Add image formats to be used by bcm2835-isp Umang Jain
2022-11-21 23:21   ` Laurent Pinchart
2022-11-21 21:47 ` [PATCH 07/14] media: uapi: v4l2-core: Add ISP statistics output V4L2 fourcc type Umang Jain
2022-11-21 23:25   ` Laurent Pinchart
2022-11-21 21:47 ` [PATCH 08/14] uapi: bcm2835-isp: Add bcm2835-isp uapi header file Umang Jain
2022-11-21 23:28   ` Laurent Pinchart
2022-11-21 21:47 ` [PATCH 09/14] staging: vc04_services: bcm2835-isp: Add a more complex ISP processing component Umang Jain
2022-11-21 21:47 ` [PATCH 10/14] WIP: vc04_services: bcm2835-isp: Allow formats with different colour spaces Umang Jain
2022-11-21 21:47 ` [PATCH 11/14] WIP: vc04_services: bcm2835-isp: Permit all sRGB colour spaces on ISP outputs Umang Jain
2022-11-21 21:47 ` [PATCH 12/14] staging: vc04_services: bcm2835_isp: Allow multiple users Umang Jain
2022-11-21 23:29   ` Laurent Pinchart [this message]
2022-11-21 23:35     ` Laurent Pinchart
2022-11-21 21:47 ` [PATCH 13/14] docs: admin-guide: media: bcm2835-isp: Add documentation for bcm2835-isp Umang Jain
2022-11-21 23:41   ` Laurent Pinchart
2022-11-21 21:47 ` [PATCH 14/14] staging: vc04_services: vchiq: Load bcm2835_isp driver from vchiq Umang Jain
2022-11-21 23:10   ` Laurent Pinchart
2022-11-21 22:16 ` [PATCH 00/14] staging: vc04_services: bcm2835-isp support Laurent Pinchart
2022-11-22 11:42   ` Dave Stevenson
2022-11-22 12:34     ` Umang Jain
2022-11-26 14:42 ` Stefan Wahren
2022-11-26 16:26   ` Umang Jain
2022-11-26 22:56     ` Stefan Wahren
2022-11-30 10:58       ` Umang Jain
2022-12-01 22:45         ` Stefan Wahren
2022-12-02  3:57           ` Umang Jain
2022-12-02  9:17             ` Laurent Pinchart
2022-12-02 11:23               ` Dave Stevenson
2022-12-02 12:10                 ` Laurent Pinchart
2022-12-02 12:35                   ` Stefan Wahren
2022-12-02 13:25                     ` Peter Robinson
2022-12-02 12:38                   ` Dave Stevenson
2022-12-02 13:29                     ` Laurent Pinchart
2022-12-02 12:41                 ` Stefan Wahren
2022-12-02 13:32                   ` Laurent Pinchart
2022-12-02 13:42                   ` Dave Stevenson
2022-12-03 13:41                     ` Stefan Wahren

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=Y3wJ6/+Hl6JTm1Bu@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=david.plowman@raspberrypi.com \
    --cc=f.fainelli@gmail.com \
    --cc=kernel-list@raspberrypi.com \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=naush@raspberrypi.com \
    --cc=umang.jain@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

all inboxes | Powered by JetHome®