From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC5F11079F for ; Mon, 21 Nov 2022 23:36:04 +0000 (UTC) Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2404588F; Tue, 22 Nov 2022 00:36:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1669073762; bh=3VWpmzoh5E5Wu8pU8xTt80N7017DTFHJ6/6yLl+OX5c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=m3D9zVzZY9O/z86qEYnCXv+Mmiz0DYEQJq6OoYJ1aSA6y/dPIin5oAumzlg5myhRf H3RLAvu2Y3K0v7Srli5unumLxaI8SXCdjnCwfByBUDSgDM0piU6RxZ0oyCHowpEfEW KHuUOv7MhZYfAHR7xQBXHySRaiuwwYuj9GcJT2sQ= Date: Tue, 22 Nov 2022 01:35:47 +0200 From: Laurent Pinchart To: Umang Jain 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 , Dave Stevenson , Florian Fainelli , Naushir Patuck , David Plowman , Kieran Bingham Subject: Re: [PATCH 12/14] staging: vc04_services: bcm2835_isp: Allow multiple users Message-ID: References: <20221121214722.22563-1-umang.jain@ideasonboard.com> <20221121214722.22563-13-umang.jain@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Tue, Nov 22, 2022 at 01:29:48AM +0200, Laurent Pinchart wrote: > 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 > > > > 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 > > Signed-off-by: Umang Jain > > Let's squash this with 09/14. Also, the documentation in 13/14 should be updated. > > --- > > .../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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2FB64C433FE for ; Mon, 21 Nov 2022 23:37:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JfzyucFiT/3rvs6r5vRcXxTHszJdHs63lEvMEYiGkrc=; b=gGPoRdxFGr0XNJ iQHnbab4kFfL7Lbn1H7kg5NeTnIlx4+fORuVd9ww5YEav2Z9iUNrQHdBCK25szwSTiwB/cQr5QO2W PEBjFgphL0e+RU/Dy7sWQvKuO17IFaQYlGkBD4IVzs5dP7yb5uFkFllxZ5VK6zch9mnbOXK2oz6va NDJUpBOFKUlR+q7IYTqN5dKZgNo+N53YaIl3aS69gKgA0eYAPi/UpUKLgYP9a0+1Rt6LQB6k9TG32 CW3hjTxUWqmxQHMhAdTSxG9b6BFKLWFpTwyntqFwOlK33qlhu7QsONlhQkKFHTrVNg3pjAYmckTcm 4eHFDB0wVTDEBtCkXE6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxGKf-001FJG-1F; Mon, 21 Nov 2022 23:36:09 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxGKa-001FFJ-4f; Mon, 21 Nov 2022 23:36:08 +0000 Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2404588F; Tue, 22 Nov 2022 00:36:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1669073762; bh=3VWpmzoh5E5Wu8pU8xTt80N7017DTFHJ6/6yLl+OX5c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=m3D9zVzZY9O/z86qEYnCXv+Mmiz0DYEQJq6OoYJ1aSA6y/dPIin5oAumzlg5myhRf H3RLAvu2Y3K0v7Srli5unumLxaI8SXCdjnCwfByBUDSgDM0piU6RxZ0oyCHowpEfEW KHuUOv7MhZYfAHR7xQBXHySRaiuwwYuj9GcJT2sQ= Date: Tue, 22 Nov 2022 01:35:47 +0200 From: Laurent Pinchart To: Umang Jain 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 , Dave Stevenson , Florian Fainelli , Naushir Patuck , David Plowman , Kieran Bingham Subject: Re: [PATCH 12/14] staging: vc04_services: bcm2835_isp: Allow multiple users Message-ID: References: <20221121214722.22563-1-umang.jain@ideasonboard.com> <20221121214722.22563-13-umang.jain@ideasonboard.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221121_153604_356124_78FBA9CB X-CRM114-Status: GOOD ( 30.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Nov 22, 2022 at 01:29:48AM +0200, Laurent Pinchart wrote: > 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 > > > > 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 > > Signed-off-by: Umang Jain > > Let's squash this with 09/14. Also, the documentation in 13/14 should be updated. > > --- > > .../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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel