Message ID | 20230627201628.207483-4-umang.jain@ideasonboard.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8476771vqr; Tue, 27 Jun 2023 14:18:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6cqjt59ETdruP5kieglm/CUFZCviechM+MYuU84ymr3iDqtHFMD4Yg6Z07SJxDnHa3AS/u X-Received: by 2002:a17:906:4fc5:b0:982:82aa:86b1 with SMTP id i5-20020a1709064fc500b0098282aa86b1mr25779891ejw.43.1687900722722; Tue, 27 Jun 2023 14:18:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687900722; cv=none; d=google.com; s=arc-20160816; b=gDkbbNeF+5xl7MgY4jueBTRAwktK95LcBeljc2IYFosgXAMQBqR5FgYQTmKsiEbkSq EUL98to/ASCBbXYhzPL2OItkMu/9Xt0iHrqIPd8zcgCpzQffvxkp55xE/kdLrGQ71bbs jji3A+z7JgB5cbVVmebjpf9itGoofoSQL89k0BPvwRKN1UUBw8iJFnCqLFU+GDDUMrKg MEPgMhTV+Po5UHklTZB2ZM3GnZ0RR+PS5a9cjDDZpxcAl4mi55qHVffn5nxo3pxqw+QI JJ73tgW9JI4ObftEDO41C2r408yr6pQVfwKVzJ8wpY/9IQ01yBuXlzFHHnu2M/jm/9wq XLcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ysT42IVyLNgKhnLZZ3tyJddXmGd5vF4+rr1MAQiQkY4=; fh=KJ7fz4phEMuOPL/5CIrq/GEqblJHB3UXSqcptreppbo=; b=G3T6M7sV+V382XVhBOXUK4JLpxjgbe8Sj/dt4hrisSyFEO7IOXNww0ovZyx0+oWSPh 0yTD2H0i2A5APWPOL0k9GKXRiFzkfsULUYeHbuhmZM2ED0kOJqUtAbkrhkkmjdr7rZ8I CHcX9+tmX5K9B8oRT9olpg8G2EZwIA2lHaJIJwLwicAxkDeUXlX0acIDCZo5eqqmC4iN A+42JUVYBYdLxwM24d2/XEzofPZIvYyB6MERh2qngId/ZUEjzy5FjQWulRfWAks9VJDk 936UAaADVxF4UobM6PKENhY7Tt9hLjtKORg2MFtMpkg/oxpnTb+R5nm0qYEsBmeLXrcZ km+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=LH38S3H1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bi11-20020a170906a24b00b00982843ecb6dsi4802487ejb.134.2023.06.27.14.18.17; Tue, 27 Jun 2023 14:18:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=LH38S3H1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231267AbjF0UXY (ORCPT <rfc822;nicolai.engesland@gmail.com> + 99 others); Tue, 27 Jun 2023 16:23:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230420AbjF0UXT (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 27 Jun 2023 16:23:19 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E766E268C; Tue, 27 Jun 2023 13:23:17 -0700 (PDT) Received: from umang.jainideasonboard.com (85-160-38-115.reb.o2.cz [85.160.38.115]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7A80231B9; Tue, 27 Jun 2023 22:15:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1687896957; bh=FYswsBqlGTJd9Uyph3V+TQd6xP/1Bv4ExB0Kmxk7mY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LH38S3H1Nk+x0OaEipDZuzWIsskQgS7sUasWv0Emmzbvpp3RWXSsCS8H6ilSbeEhX hkp/6tV9iShsHKHFZm+eBJJRIAWJjEiM3bjTy3A9HKu76FO8Gm1oHops0hdAh4JZsj r9GqDFxUGku8zZSFM4zY+zYjWN/Xi4uBbvpA6tkg= From: Umang Jain <umang.jain@ideasonboard.com> To: linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: stefan.wahren@i2se.com, gregkh@linuxfoundation.org, f.fainelli@gmail.com, athierry@redhat.com, error27@gmail.com, dave.stevenson@raspberrypi.com, kieran.bingham@ideasonboard.com, laurent.pinchart@ideasonboard.com, Umang Jain <umang.jain@ideasonboard.com> Subject: [PATCH v8 3/5] staging: bcm2835-camera: Register bcm2835-camera with vchiq_bus_type Date: Tue, 27 Jun 2023 22:16:26 +0200 Message-Id: <20230627201628.207483-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230627201628.207483-1-umang.jain@ideasonboard.com> References: <20230627201628.207483-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769892188589992876?= X-GMAIL-MSGID: =?utf-8?q?1769892188589992876?= |
Series |
staging: vc04_services: vchiq: Register devices with a custom bus_type
|
|
Commit Message
Umang Jain
June 27, 2023, 8:16 p.m. UTC
Register the bcm2835-camera with the vchiq_bus_type instead of using
platform driver/device.
Also the VCHIQ firmware doesn't support device enumeration, hence
one has to maintain a list of devices to be registered in the interface.
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
.../bcm2835-camera/bcm2835-camera.c | 16 +++++++-------
.../interface/vchiq_arm/vchiq_arm.c | 21 ++++++++++++++++---
2 files changed, 26 insertions(+), 11 deletions(-)
Comments
Quoting Umang Jain (2023-06-27 21:16:26) > Register the bcm2835-camera with the vchiq_bus_type instead of using > platform driver/device. > > Also the VCHIQ firmware doesn't support device enumeration, hence > one has to maintain a list of devices to be registered in the interface. > > Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> > --- > .../bcm2835-camera/bcm2835-camera.c | 16 +++++++------- > .../interface/vchiq_arm/vchiq_arm.c | 21 ++++++++++++++++--- > 2 files changed, 26 insertions(+), 11 deletions(-) > > diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c > index 346d00df815a..f37b2a881d92 100644 > --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c > +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c > @@ -24,8 +24,9 @@ > #include <media/v4l2-event.h> > #include <media/v4l2-common.h> > #include <linux/delay.h> > -#include <linux/platform_device.h> > > +#include "../interface/vchiq_arm/vchiq_arm.h" > +#include "../interface/vchiq_arm/vchiq_device.h" > #include "../vchiq-mmal/mmal-common.h" > #include "../vchiq-mmal/mmal-encodings.h" > #include "../vchiq-mmal/mmal-vchiq.h" > @@ -1841,7 +1842,7 @@ static struct v4l2_format default_v4l2_format = { > .fmt.pix.sizeimage = 1024 * 768, > }; > > -static int bcm2835_mmal_probe(struct platform_device *pdev) > +static int bcm2835_mmal_probe(struct vchiq_device *device) > { > int ret; > struct bcm2835_mmal_dev *dev; > @@ -1896,7 +1897,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) > &camera_instance); > ret = v4l2_device_register(NULL, &dev->v4l2_dev); > if (ret) { > - dev_err(&pdev->dev, "%s: could not register V4L2 device: %d\n", > + dev_err(&device->dev, "%s: could not register V4L2 device: %d\n", > __func__, ret); > goto free_dev; > } > @@ -1976,7 +1977,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) > return ret; > } > > -static void bcm2835_mmal_remove(struct platform_device *pdev) > +static void bcm2835_mmal_remove(struct vchiq_device *device) > { > int camera; > struct vchiq_mmal_instance *instance = gdev[0]->instance; > @@ -1988,17 +1989,16 @@ static void bcm2835_mmal_remove(struct platform_device *pdev) > vchiq_mmal_finalise(instance); > } > > -static struct platform_driver bcm2835_camera_driver = { > +static struct vchiq_driver bcm2835_camera_driver = { > .probe = bcm2835_mmal_probe, > - .remove_new = bcm2835_mmal_remove, > + .remove = bcm2835_mmal_remove, > .driver = { > .name = "bcm2835-camera", > }, > }; > > -module_platform_driver(bcm2835_camera_driver) > +module_vchiq_driver(bcm2835_camera_driver) > > MODULE_DESCRIPTION("Broadcom 2835 MMAL video capture"); > MODULE_AUTHOR("Vincent Sanders"); > MODULE_LICENSE("GPL"); > -MODULE_ALIAS("platform:bcm2835-camera"); This bit worries me. I think that's how module autoloading is handled. Can you check into the details of MODULE_ALIAS and follow the rabbit hole for a bit? It's a few years since I last went down there so I can't remember the specifics right now. Except for that, I think this looks good. > diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c > index e8d40f891449..79d4d0eeb5fb 100644 > --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c > +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c > @@ -67,7 +67,6 @@ int vchiq_susp_log_level = VCHIQ_LOG_ERROR; > DEFINE_SPINLOCK(msg_queue_spinlock); > struct vchiq_state g_state; > > -static struct platform_device *bcm2835_camera; > static struct platform_device *bcm2835_audio; > > struct vchiq_drvdata { > @@ -134,6 +133,15 @@ struct vchiq_pagelist_info { > unsigned int scatterlist_mapped; > }; > > +/* > + * The devices implemented in the VCHIQ firmware are not discoverable, > + * so we need to maintain a list of them in order to register them with > + * the interface. > + */ > +static const char *const vchiq_devices[] = { > + "bcm2835-camera", > +}; > + > static void __iomem *g_regs; > /* This value is the size of the L2 cache lines as understood by the > * VPU firmware, which determines the required alignment of the > @@ -1798,6 +1806,7 @@ static int vchiq_probe(struct platform_device *pdev) > struct device_node *fw_node; > const struct of_device_id *of_id; > struct vchiq_drvdata *drvdata; > + unsigned int i; > int err; > > of_id = of_match_node(vchiq_of_match, pdev->dev.of_node); > @@ -1840,9 +1849,15 @@ static int vchiq_probe(struct platform_device *pdev) > goto error_exit; > } > > - bcm2835_camera = vchiq_register_child(pdev, "bcm2835-camera"); > bcm2835_audio = vchiq_register_child(pdev, "bcm2835_audio"); > > + for (i = 0; i < ARRAY_SIZE(vchiq_devices); i++) { > + err = vchiq_device_register(&pdev->dev, vchiq_devices[i]); > + if (err) > + dev_err(&pdev->dev, "Failed to register %s vchiq device\n", > + vchiq_devices[i]); > + } > + > return 0; > > failed_platform_init: > @@ -1854,7 +1869,7 @@ static int vchiq_probe(struct platform_device *pdev) > static void vchiq_remove(struct platform_device *pdev) > { > platform_device_unregister(bcm2835_audio); > - platform_device_unregister(bcm2835_camera); > + bus_for_each_dev(&vchiq_bus_type, NULL, NULL, vchiq_device_unregister); > vchiq_debugfs_deinit(); > vchiq_deregister_chrdev(); > } > -- > 2.39.1 >
Hi Kieran, On 6/29/23 12:44 AM, Kieran Bingham wrote: > Quoting Umang Jain (2023-06-27 21:16:26) >> Register the bcm2835-camera with the vchiq_bus_type instead of using >> platform driver/device. >> >> Also the VCHIQ firmware doesn't support device enumeration, hence >> one has to maintain a list of devices to be registered in the interface. >> >> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> >> --- >> .../bcm2835-camera/bcm2835-camera.c | 16 +++++++------- >> .../interface/vchiq_arm/vchiq_arm.c | 21 ++++++++++++++++--- >> 2 files changed, 26 insertions(+), 11 deletions(-) >> >> diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c >> index 346d00df815a..f37b2a881d92 100644 >> --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c >> +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c >> @@ -24,8 +24,9 @@ >> #include <media/v4l2-event.h> >> #include <media/v4l2-common.h> >> #include <linux/delay.h> >> -#include <linux/platform_device.h> >> >> +#include "../interface/vchiq_arm/vchiq_arm.h" >> +#include "../interface/vchiq_arm/vchiq_device.h" >> #include "../vchiq-mmal/mmal-common.h" >> #include "../vchiq-mmal/mmal-encodings.h" >> #include "../vchiq-mmal/mmal-vchiq.h" >> @@ -1841,7 +1842,7 @@ static struct v4l2_format default_v4l2_format = { >> .fmt.pix.sizeimage = 1024 * 768, >> }; >> >> -static int bcm2835_mmal_probe(struct platform_device *pdev) >> +static int bcm2835_mmal_probe(struct vchiq_device *device) >> { >> int ret; >> struct bcm2835_mmal_dev *dev; >> @@ -1896,7 +1897,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) >> &camera_instance); >> ret = v4l2_device_register(NULL, &dev->v4l2_dev); >> if (ret) { >> - dev_err(&pdev->dev, "%s: could not register V4L2 device: %d\n", >> + dev_err(&device->dev, "%s: could not register V4L2 device: %d\n", >> __func__, ret); >> goto free_dev; >> } >> @@ -1976,7 +1977,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) >> return ret; >> } >> >> -static void bcm2835_mmal_remove(struct platform_device *pdev) >> +static void bcm2835_mmal_remove(struct vchiq_device *device) >> { >> int camera; >> struct vchiq_mmal_instance *instance = gdev[0]->instance; >> @@ -1988,17 +1989,16 @@ static void bcm2835_mmal_remove(struct platform_device *pdev) >> vchiq_mmal_finalise(instance); >> } >> >> -static struct platform_driver bcm2835_camera_driver = { >> +static struct vchiq_driver bcm2835_camera_driver = { >> .probe = bcm2835_mmal_probe, >> - .remove_new = bcm2835_mmal_remove, >> + .remove = bcm2835_mmal_remove, >> .driver = { >> .name = "bcm2835-camera", >> }, >> }; >> >> -module_platform_driver(bcm2835_camera_driver) >> +module_vchiq_driver(bcm2835_camera_driver) >> >> MODULE_DESCRIPTION("Broadcom 2835 MMAL video capture"); >> MODULE_AUTHOR("Vincent Sanders"); >> MODULE_LICENSE("GPL"); >> -MODULE_ALIAS("platform:bcm2835-camera"); > This bit worries me. I think that's how module autoloading is handled. > > Can you check into the details of MODULE_ALIAS and follow the rabbit > hole for a bit? It's a few years since I last went down there so I can't > remember the specifics right now. vchiq_probe() will register both the bcm2385_audio and bcm2835-camera hence, we don't need MODULE_ALIAS for those two. So what I also tested is that, when bcm2835_vchiq loads, it will auto-load both audio and camera with it (since these are child devices of vchiq). I think that's the correct way. > > Except for that, I think this looks good. > > >> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c >> index e8d40f891449..79d4d0eeb5fb 100644 >> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c >> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c >> @@ -67,7 +67,6 @@ int vchiq_susp_log_level = VCHIQ_LOG_ERROR; >> DEFINE_SPINLOCK(msg_queue_spinlock); >> struct vchiq_state g_state; >> >> -static struct platform_device *bcm2835_camera; >> static struct platform_device *bcm2835_audio; >> >> struct vchiq_drvdata { >> @@ -134,6 +133,15 @@ struct vchiq_pagelist_info { >> unsigned int scatterlist_mapped; >> }; >> >> +/* >> + * The devices implemented in the VCHIQ firmware are not discoverable, >> + * so we need to maintain a list of them in order to register them with >> + * the interface. >> + */ >> +static const char *const vchiq_devices[] = { >> + "bcm2835-camera", >> +}; >> + >> static void __iomem *g_regs; >> /* This value is the size of the L2 cache lines as understood by the >> * VPU firmware, which determines the required alignment of the >> @@ -1798,6 +1806,7 @@ static int vchiq_probe(struct platform_device *pdev) >> struct device_node *fw_node; >> const struct of_device_id *of_id; >> struct vchiq_drvdata *drvdata; >> + unsigned int i; >> int err; >> >> of_id = of_match_node(vchiq_of_match, pdev->dev.of_node); >> @@ -1840,9 +1849,15 @@ static int vchiq_probe(struct platform_device *pdev) >> goto error_exit; >> } >> >> - bcm2835_camera = vchiq_register_child(pdev, "bcm2835-camera"); >> bcm2835_audio = vchiq_register_child(pdev, "bcm2835_audio"); >> >> + for (i = 0; i < ARRAY_SIZE(vchiq_devices); i++) { >> + err = vchiq_device_register(&pdev->dev, vchiq_devices[i]); >> + if (err) >> + dev_err(&pdev->dev, "Failed to register %s vchiq device\n", >> + vchiq_devices[i]); >> + } >> + >> return 0; >> >> failed_platform_init: >> @@ -1854,7 +1869,7 @@ static int vchiq_probe(struct platform_device *pdev) >> static void vchiq_remove(struct platform_device *pdev) >> { >> platform_device_unregister(bcm2835_audio); >> - platform_device_unregister(bcm2835_camera); >> + bus_for_each_dev(&vchiq_bus_type, NULL, NULL, vchiq_device_unregister); >> vchiq_debugfs_deinit(); >> vchiq_deregister_chrdev(); >> } >> -- >> 2.39.1 >>
Quoting Umang Jain (2023-06-29 12:49:17) > Hi Kieran, > > On 6/29/23 12:44 AM, Kieran Bingham wrote: > > Quoting Umang Jain (2023-06-27 21:16:26) > >> Register the bcm2835-camera with the vchiq_bus_type instead of using > >> platform driver/device. > >> > >> Also the VCHIQ firmware doesn't support device enumeration, hence > >> one has to maintain a list of devices to be registered in the interface. > >> > >> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> > >> --- > >> .../bcm2835-camera/bcm2835-camera.c | 16 +++++++------- > >> .../interface/vchiq_arm/vchiq_arm.c | 21 ++++++++++++++++--- > >> 2 files changed, 26 insertions(+), 11 deletions(-) > >> > >> diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c > >> index 346d00df815a..f37b2a881d92 100644 > >> --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c > >> +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c > >> @@ -24,8 +24,9 @@ > >> #include <media/v4l2-event.h> > >> #include <media/v4l2-common.h> > >> #include <linux/delay.h> > >> -#include <linux/platform_device.h> > >> > >> +#include "../interface/vchiq_arm/vchiq_arm.h" > >> +#include "../interface/vchiq_arm/vchiq_device.h" > >> #include "../vchiq-mmal/mmal-common.h" > >> #include "../vchiq-mmal/mmal-encodings.h" > >> #include "../vchiq-mmal/mmal-vchiq.h" > >> @@ -1841,7 +1842,7 @@ static struct v4l2_format default_v4l2_format = { > >> .fmt.pix.sizeimage = 1024 * 768, > >> }; > >> > >> -static int bcm2835_mmal_probe(struct platform_device *pdev) > >> +static int bcm2835_mmal_probe(struct vchiq_device *device) > >> { > >> int ret; > >> struct bcm2835_mmal_dev *dev; > >> @@ -1896,7 +1897,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) > >> &camera_instance); > >> ret = v4l2_device_register(NULL, &dev->v4l2_dev); > >> if (ret) { > >> - dev_err(&pdev->dev, "%s: could not register V4L2 device: %d\n", > >> + dev_err(&device->dev, "%s: could not register V4L2 device: %d\n", > >> __func__, ret); > >> goto free_dev; > >> } > >> @@ -1976,7 +1977,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) > >> return ret; > >> } > >> > >> -static void bcm2835_mmal_remove(struct platform_device *pdev) > >> +static void bcm2835_mmal_remove(struct vchiq_device *device) > >> { > >> int camera; > >> struct vchiq_mmal_instance *instance = gdev[0]->instance; > >> @@ -1988,17 +1989,16 @@ static void bcm2835_mmal_remove(struct platform_device *pdev) > >> vchiq_mmal_finalise(instance); > >> } > >> > >> -static struct platform_driver bcm2835_camera_driver = { > >> +static struct vchiq_driver bcm2835_camera_driver = { > >> .probe = bcm2835_mmal_probe, > >> - .remove_new = bcm2835_mmal_remove, > >> + .remove = bcm2835_mmal_remove, > >> .driver = { > >> .name = "bcm2835-camera", > >> }, > >> }; > >> > >> -module_platform_driver(bcm2835_camera_driver) > >> +module_vchiq_driver(bcm2835_camera_driver) > >> > >> MODULE_DESCRIPTION("Broadcom 2835 MMAL video capture"); > >> MODULE_AUTHOR("Vincent Sanders"); > >> MODULE_LICENSE("GPL"); > >> -MODULE_ALIAS("platform:bcm2835-camera"); > > This bit worries me. I think that's how module autoloading is handled. > > > > Can you check into the details of MODULE_ALIAS and follow the rabbit > > hole for a bit? It's a few years since I last went down there so I can't > > remember the specifics right now. > > vchiq_probe() will register both the bcm2385_audio and bcm2835-camera > hence, we don't need MODULE_ALIAS for those two. It registers the devices, but I thought MODULE_ALIAS was how that gets tied to which module to load (when drivers are built as modules). > So what I also tested is that, when bcm2835_vchiq loads, it will > auto-load both audio and camera with it (since these are child devices > of vchiq). I think that's the correct way. Could you test a build with the following (two) configurations please? 1) CONFIG_BCM2835_VCHIQ=y CONFIG_VIDEO_BCM2835=m CONFIG_SND_BCM2835=m 2) CONFIG_BCM2835_VCHIQ=m CONFIG_VIDEO_BCM2835=m CONFIG_SND_BCM2835=m > > > > Except for that, I think this looks good. > > > > > >> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c > >> index e8d40f891449..79d4d0eeb5fb 100644 > >> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c > >> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c > >> @@ -67,7 +67,6 @@ int vchiq_susp_log_level = VCHIQ_LOG_ERROR; > >> DEFINE_SPINLOCK(msg_queue_spinlock); > >> struct vchiq_state g_state; > >> > >> -static struct platform_device *bcm2835_camera; > >> static struct platform_device *bcm2835_audio; > >> > >> struct vchiq_drvdata { > >> @@ -134,6 +133,15 @@ struct vchiq_pagelist_info { > >> unsigned int scatterlist_mapped; > >> }; > >> > >> +/* > >> + * The devices implemented in the VCHIQ firmware are not discoverable, > >> + * so we need to maintain a list of them in order to register them with > >> + * the interface. > >> + */ > >> +static const char *const vchiq_devices[] = { > >> + "bcm2835-camera", > >> +}; > >> + > >> static void __iomem *g_regs; > >> /* This value is the size of the L2 cache lines as understood by the > >> * VPU firmware, which determines the required alignment of the > >> @@ -1798,6 +1806,7 @@ static int vchiq_probe(struct platform_device *pdev) > >> struct device_node *fw_node; > >> const struct of_device_id *of_id; > >> struct vchiq_drvdata *drvdata; > >> + unsigned int i; > >> int err; > >> > >> of_id = of_match_node(vchiq_of_match, pdev->dev.of_node); > >> @@ -1840,9 +1849,15 @@ static int vchiq_probe(struct platform_device *pdev) > >> goto error_exit; > >> } > >> > >> - bcm2835_camera = vchiq_register_child(pdev, "bcm2835-camera"); > >> bcm2835_audio = vchiq_register_child(pdev, "bcm2835_audio"); > >> > >> + for (i = 0; i < ARRAY_SIZE(vchiq_devices); i++) { > >> + err = vchiq_device_register(&pdev->dev, vchiq_devices[i]); > >> + if (err) > >> + dev_err(&pdev->dev, "Failed to register %s vchiq device\n", > >> + vchiq_devices[i]); > >> + } > >> + > >> return 0; > >> > >> failed_platform_init: > >> @@ -1854,7 +1869,7 @@ static int vchiq_probe(struct platform_device *pdev) > >> static void vchiq_remove(struct platform_device *pdev) > >> { > >> platform_device_unregister(bcm2835_audio); > >> - platform_device_unregister(bcm2835_camera); > >> + bus_for_each_dev(&vchiq_bus_type, NULL, NULL, vchiq_device_unregister); > >> vchiq_debugfs_deinit(); > >> vchiq_deregister_chrdev(); > >> } > >> -- > >> 2.39.1 > >> >
On Tue, Jun 27, 2023 at 10:16:26PM +0200, Umang Jain wrote: > Register the bcm2835-camera with the vchiq_bus_type instead of using > platform driver/device. > > Also the VCHIQ firmware doesn't support device enumeration, hence > one has to maintain a list of devices to be registered in the interface. > > Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> > --- > .../bcm2835-camera/bcm2835-camera.c | 16 +++++++------- > .../interface/vchiq_arm/vchiq_arm.c | 21 ++++++++++++++++--- > 2 files changed, 26 insertions(+), 11 deletions(-) > > diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c > index 346d00df815a..f37b2a881d92 100644 > --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c > +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c > @@ -24,8 +24,9 @@ > #include <media/v4l2-event.h> > #include <media/v4l2-common.h> > #include <linux/delay.h> > -#include <linux/platform_device.h> > > +#include "../interface/vchiq_arm/vchiq_arm.h" > +#include "../interface/vchiq_arm/vchiq_device.h" > #include "../vchiq-mmal/mmal-common.h" > #include "../vchiq-mmal/mmal-encodings.h" > #include "../vchiq-mmal/mmal-vchiq.h" > @@ -1841,7 +1842,7 @@ static struct v4l2_format default_v4l2_format = { > .fmt.pix.sizeimage = 1024 * 768, > }; > > -static int bcm2835_mmal_probe(struct platform_device *pdev) > +static int bcm2835_mmal_probe(struct vchiq_device *device) > { > int ret; > struct bcm2835_mmal_dev *dev; > @@ -1896,7 +1897,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) > &camera_instance); > ret = v4l2_device_register(NULL, &dev->v4l2_dev); > if (ret) { > - dev_err(&pdev->dev, "%s: could not register V4L2 device: %d\n", > + dev_err(&device->dev, "%s: could not register V4L2 device: %d\n", > __func__, ret); > goto free_dev; > } > @@ -1976,7 +1977,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) > return ret; > } > > -static void bcm2835_mmal_remove(struct platform_device *pdev) > +static void bcm2835_mmal_remove(struct vchiq_device *device) > { > int camera; > struct vchiq_mmal_instance *instance = gdev[0]->instance; > @@ -1988,17 +1989,16 @@ static void bcm2835_mmal_remove(struct platform_device *pdev) > vchiq_mmal_finalise(instance); > } > > -static struct platform_driver bcm2835_camera_driver = { > +static struct vchiq_driver bcm2835_camera_driver = { > .probe = bcm2835_mmal_probe, > - .remove_new = bcm2835_mmal_remove, > + .remove = bcm2835_mmal_remove, No need to change this here, right? That's independant of this patch series. thanks, greg k-h
Hi Greg, On 7/3/23 3:29 PM, Greg KH wrote: > On Tue, Jun 27, 2023 at 10:16:26PM +0200, Umang Jain wrote: >> Register the bcm2835-camera with the vchiq_bus_type instead of using >> platform driver/device. >> >> Also the VCHIQ firmware doesn't support device enumeration, hence >> one has to maintain a list of devices to be registered in the interface. >> >> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> >> --- >> .../bcm2835-camera/bcm2835-camera.c | 16 +++++++------- >> .../interface/vchiq_arm/vchiq_arm.c | 21 ++++++++++++++++--- >> 2 files changed, 26 insertions(+), 11 deletions(-) >> >> diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c >> index 346d00df815a..f37b2a881d92 100644 >> --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c >> +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c >> @@ -24,8 +24,9 @@ >> #include <media/v4l2-event.h> >> #include <media/v4l2-common.h> >> #include <linux/delay.h> >> -#include <linux/platform_device.h> >> >> +#include "../interface/vchiq_arm/vchiq_arm.h" >> +#include "../interface/vchiq_arm/vchiq_device.h" >> #include "../vchiq-mmal/mmal-common.h" >> #include "../vchiq-mmal/mmal-encodings.h" >> #include "../vchiq-mmal/mmal-vchiq.h" >> @@ -1841,7 +1842,7 @@ static struct v4l2_format default_v4l2_format = { >> .fmt.pix.sizeimage = 1024 * 768, >> }; >> >> -static int bcm2835_mmal_probe(struct platform_device *pdev) >> +static int bcm2835_mmal_probe(struct vchiq_device *device) >> { >> int ret; >> struct bcm2835_mmal_dev *dev; >> @@ -1896,7 +1897,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) >> &camera_instance); >> ret = v4l2_device_register(NULL, &dev->v4l2_dev); >> if (ret) { >> - dev_err(&pdev->dev, "%s: could not register V4L2 device: %d\n", >> + dev_err(&device->dev, "%s: could not register V4L2 device: %d\n", >> __func__, ret); >> goto free_dev; >> } >> @@ -1976,7 +1977,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) >> return ret; >> } >> >> -static void bcm2835_mmal_remove(struct platform_device *pdev) >> +static void bcm2835_mmal_remove(struct vchiq_device *device) >> { >> int camera; >> struct vchiq_mmal_instance *instance = gdev[0]->instance; >> @@ -1988,17 +1989,16 @@ static void bcm2835_mmal_remove(struct platform_device *pdev) >> vchiq_mmal_finalise(instance); >> } >> >> -static struct platform_driver bcm2835_camera_driver = { >> +static struct vchiq_driver bcm2835_camera_driver = { >> .probe = bcm2835_mmal_probe, >> - .remove_new = bcm2835_mmal_remove, >> + .remove = bcm2835_mmal_remove, > No need to change this here, right? That's independant of this patch > series. Why not ? Should I have "remove_new()" in the struct vchiq_driver {..} [Patch 1/5] instead of "remove()" - match up with platform_driver virtual interface ? > > thanks, > > greg k-h
On Mon, Jul 03, 2023 at 04:44:39PM +0200, Umang Jain wrote: > Hi Greg, > > On 7/3/23 3:29 PM, Greg KH wrote: > > On Tue, Jun 27, 2023 at 10:16:26PM +0200, Umang Jain wrote: > > > Register the bcm2835-camera with the vchiq_bus_type instead of using > > > platform driver/device. > > > > > > Also the VCHIQ firmware doesn't support device enumeration, hence > > > one has to maintain a list of devices to be registered in the interface. > > > > > > Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> > > > --- > > > .../bcm2835-camera/bcm2835-camera.c | 16 +++++++------- > > > .../interface/vchiq_arm/vchiq_arm.c | 21 ++++++++++++++++--- > > > 2 files changed, 26 insertions(+), 11 deletions(-) > > > > > > diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c > > > index 346d00df815a..f37b2a881d92 100644 > > > --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c > > > +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c > > > @@ -24,8 +24,9 @@ > > > #include <media/v4l2-event.h> > > > #include <media/v4l2-common.h> > > > #include <linux/delay.h> > > > -#include <linux/platform_device.h> > > > +#include "../interface/vchiq_arm/vchiq_arm.h" > > > +#include "../interface/vchiq_arm/vchiq_device.h" > > > #include "../vchiq-mmal/mmal-common.h" > > > #include "../vchiq-mmal/mmal-encodings.h" > > > #include "../vchiq-mmal/mmal-vchiq.h" > > > @@ -1841,7 +1842,7 @@ static struct v4l2_format default_v4l2_format = { > > > .fmt.pix.sizeimage = 1024 * 768, > > > }; > > > -static int bcm2835_mmal_probe(struct platform_device *pdev) > > > +static int bcm2835_mmal_probe(struct vchiq_device *device) > > > { > > > int ret; > > > struct bcm2835_mmal_dev *dev; > > > @@ -1896,7 +1897,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) > > > &camera_instance); > > > ret = v4l2_device_register(NULL, &dev->v4l2_dev); > > > if (ret) { > > > - dev_err(&pdev->dev, "%s: could not register V4L2 device: %d\n", > > > + dev_err(&device->dev, "%s: could not register V4L2 device: %d\n", > > > __func__, ret); > > > goto free_dev; > > > } > > > @@ -1976,7 +1977,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) > > > return ret; > > > } > > > -static void bcm2835_mmal_remove(struct platform_device *pdev) > > > +static void bcm2835_mmal_remove(struct vchiq_device *device) > > > { > > > int camera; > > > struct vchiq_mmal_instance *instance = gdev[0]->instance; > > > @@ -1988,17 +1989,16 @@ static void bcm2835_mmal_remove(struct platform_device *pdev) > > > vchiq_mmal_finalise(instance); > > > } > > > -static struct platform_driver bcm2835_camera_driver = { > > > +static struct vchiq_driver bcm2835_camera_driver = { > > > .probe = bcm2835_mmal_probe, > > > - .remove_new = bcm2835_mmal_remove, > > > + .remove = bcm2835_mmal_remove, > > No need to change this here, right? That's independant of this patch > > series. > > Why not ? > > Should I have "remove_new()" in the struct vchiq_driver {..} [Patch 1/5] > instead of "remove()" - match up with platform_driver virtual interface ? Ah, sorry, my fault, I thought this was just a platform driver change. This is fine. greg k-h
diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index 346d00df815a..f37b2a881d92 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -24,8 +24,9 @@ #include <media/v4l2-event.h> #include <media/v4l2-common.h> #include <linux/delay.h> -#include <linux/platform_device.h> +#include "../interface/vchiq_arm/vchiq_arm.h" +#include "../interface/vchiq_arm/vchiq_device.h" #include "../vchiq-mmal/mmal-common.h" #include "../vchiq-mmal/mmal-encodings.h" #include "../vchiq-mmal/mmal-vchiq.h" @@ -1841,7 +1842,7 @@ static struct v4l2_format default_v4l2_format = { .fmt.pix.sizeimage = 1024 * 768, }; -static int bcm2835_mmal_probe(struct platform_device *pdev) +static int bcm2835_mmal_probe(struct vchiq_device *device) { int ret; struct bcm2835_mmal_dev *dev; @@ -1896,7 +1897,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) &camera_instance); ret = v4l2_device_register(NULL, &dev->v4l2_dev); if (ret) { - dev_err(&pdev->dev, "%s: could not register V4L2 device: %d\n", + dev_err(&device->dev, "%s: could not register V4L2 device: %d\n", __func__, ret); goto free_dev; } @@ -1976,7 +1977,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) return ret; } -static void bcm2835_mmal_remove(struct platform_device *pdev) +static void bcm2835_mmal_remove(struct vchiq_device *device) { int camera; struct vchiq_mmal_instance *instance = gdev[0]->instance; @@ -1988,17 +1989,16 @@ static void bcm2835_mmal_remove(struct platform_device *pdev) vchiq_mmal_finalise(instance); } -static struct platform_driver bcm2835_camera_driver = { +static struct vchiq_driver bcm2835_camera_driver = { .probe = bcm2835_mmal_probe, - .remove_new = bcm2835_mmal_remove, + .remove = bcm2835_mmal_remove, .driver = { .name = "bcm2835-camera", }, }; -module_platform_driver(bcm2835_camera_driver) +module_vchiq_driver(bcm2835_camera_driver) MODULE_DESCRIPTION("Broadcom 2835 MMAL video capture"); MODULE_AUTHOR("Vincent Sanders"); MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:bcm2835-camera"); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index e8d40f891449..79d4d0eeb5fb 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -67,7 +67,6 @@ int vchiq_susp_log_level = VCHIQ_LOG_ERROR; DEFINE_SPINLOCK(msg_queue_spinlock); struct vchiq_state g_state; -static struct platform_device *bcm2835_camera; static struct platform_device *bcm2835_audio; struct vchiq_drvdata { @@ -134,6 +133,15 @@ struct vchiq_pagelist_info { unsigned int scatterlist_mapped; }; +/* + * The devices implemented in the VCHIQ firmware are not discoverable, + * so we need to maintain a list of them in order to register them with + * the interface. + */ +static const char *const vchiq_devices[] = { + "bcm2835-camera", +}; + static void __iomem *g_regs; /* This value is the size of the L2 cache lines as understood by the * VPU firmware, which determines the required alignment of the @@ -1798,6 +1806,7 @@ static int vchiq_probe(struct platform_device *pdev) struct device_node *fw_node; const struct of_device_id *of_id; struct vchiq_drvdata *drvdata; + unsigned int i; int err; of_id = of_match_node(vchiq_of_match, pdev->dev.of_node); @@ -1840,9 +1849,15 @@ static int vchiq_probe(struct platform_device *pdev) goto error_exit; } - bcm2835_camera = vchiq_register_child(pdev, "bcm2835-camera"); bcm2835_audio = vchiq_register_child(pdev, "bcm2835_audio"); + for (i = 0; i < ARRAY_SIZE(vchiq_devices); i++) { + err = vchiq_device_register(&pdev->dev, vchiq_devices[i]); + if (err) + dev_err(&pdev->dev, "Failed to register %s vchiq device\n", + vchiq_devices[i]); + } + return 0; failed_platform_init: @@ -1854,7 +1869,7 @@ static int vchiq_probe(struct platform_device *pdev) static void vchiq_remove(struct platform_device *pdev) { platform_device_unregister(bcm2835_audio); - platform_device_unregister(bcm2835_camera); + bus_for_each_dev(&vchiq_bus_type, NULL, NULL, vchiq_device_unregister); vchiq_debugfs_deinit(); vchiq_deregister_chrdev(); }