From patchwork Wed Jul 19 16:44:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 122742 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp2579854vqt; Wed, 19 Jul 2023 10:05:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlEd6osg+yMRq8DGLM/KLsojrKMk3M/jumbZEnMd0TudN9mxQCkOzEHF9SRshbjw8pg1xHdA X-Received: by 2002:a17:906:11a:b0:98d:4ae:8db9 with SMTP id 26-20020a170906011a00b0098d04ae8db9mr2930626eje.19.1689786328145; Wed, 19 Jul 2023 10:05:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689786328; cv=none; d=google.com; s=arc-20160816; b=qMKoeSEMKniwLWkHb4s2YDHS07BoM2Rad4ZqscD7h+oKu/YECYe2TDLeVsHjJ8XIif 7znUVbupwd/jRNg4DUQMY5LRsirvF1u6Mpab1vS4CgfnSUyJtoFkCnd+v3L0RO8zT/xj gmgoyxvIeZNLYKm2CrQDg46xV8Jn5ZfMfc5Nwn5RUhUvhcBvEhBuOJ63wAnFAg+wMgaI 0guGmN00XBJCX+afWvboDJRFjXALIF9YCaKFeIEneMsnL7VAqGiuDiyNHJYi0t14nrDB 7XA62wOMXVVQBzH042MQgIMk/nCjwos9hejmvsj4dzO+/5PR9/pmsmv8kFogv06AY60X qKXQ== 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=FtUk9uktQyEUB1jk/bUqaj4n76I+1QbmFzgcoOA8I6c=; fh=HOFam38REw6BIxvQyXL0jcX3gf57D0OJSEWCuf65U0M=; b=pZsSdkoTAHUg1I/EdqAw9VpjqJQErR7QOSGFMTNBHKf5p2ibSzbJO9EpDMBjxPpNnP c+chxixdUemdgJKwn153QCFO1GTHmG6LDmNWSpcOCu5IMjyAH634z1JAmNu5wF0hRcKQ zJBUIcAPij6YhiO5UNoTVjQSdEl1nf0TLES7Xvihdkd1+jlNjEux/Ok7mGDo1JBDXI2x vTZYeE5qxreGlp6vEljxuwq3rCHoSbpmCRsw/afFYa5CNqpO91h+hmdg/UlDj58H2OEC uK4rQ5SoXmcNf3dE1ZbigbMJZAoh3jRKpoUgw0k9yV7L+cn37LIijMPh14zKi6llTcFV DVow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=SsTiuEPa; 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 jt18-20020a170906dfd200b0098da8d0ce54si3115119ejc.834.2023.07.19.10.05.03; Wed, 19 Jul 2023 10:05:28 -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=SsTiuEPa; 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 S230290AbjGSQpO (ORCPT + 99 others); Wed, 19 Jul 2023 12:45:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230288AbjGSQpB (ORCPT ); Wed, 19 Jul 2023 12:45:01 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66A7B1FD7; Wed, 19 Jul 2023 09:45:00 -0700 (PDT) Received: from umang.jainideasonboard.com (unknown [103.86.18.219]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3950316B4; Wed, 19 Jul 2023 18:43:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1689785039; bh=DyQQJYltSHGTg2M7880nPkKYdn1yJe9QbLEK7kQN1+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SsTiuEPaK5Vctm7Q59nopltV4BYE00fJTe7hrKWsADbxXnjgcJi7rj0Csf+//XKpS 0x0zmqAMY4uaJcAqakkNMwjSvLYHL7g6J1EvuDijILug5L+/e28jTuPsCoVN63dKTA QHE4SS4lJ1vMsge1opLm4HI7VFSCG6hfGrDit3fY= From: Umang Jain 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 Subject: [PATCH v9 3/5] staging: bcm2835-camera: Register bcm2835-camera with vchiq_bus_type Date: Wed, 19 Jul 2023 22:14:25 +0530 Message-Id: <20230719164427.1383646-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230719164427.1383646-1-umang.jain@ideasonboard.com> References: <20230719164427.1383646-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771869388809073146 X-GMAIL-MSGID: 1771869388809073146 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 --- .../bcm2835-camera/bcm2835-camera.c | 17 +++++++++-------- .../interface/vchiq_arm/vchiq_arm.c | 11 ++++++++--- 2 files changed, 17 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..58321856cf1a 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 #include #include -#include +#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,17 @@ 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"); +MODULE_ALIAS("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..d941e9640415 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -67,8 +67,13 @@ 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; +/* + * 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 struct vchiq_device *bcm2835_camera; struct vchiq_drvdata { const unsigned int cache_line_size; @@ -1840,8 +1845,8 @@ 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"); + bcm2835_camera = vchiq_device_register(&pdev->dev, "bcm2835-camera"); return 0; @@ -1854,7 +1859,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); + vchiq_device_unregister(bcm2835_camera); vchiq_debugfs_deinit(); vchiq_deregister_chrdev(); }