From patchwork Wed Sep 13 19:53:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 139132 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:a8d:b0:3f2:4152:657d with SMTP id gr13csp128236vqb; Wed, 13 Sep 2023 15:41:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHK+N2OluTW78NsvusWnWsSQ2tEPLoI0yHyrq625K600yyMS96BCC356qWpaLYyjwnFM5ek X-Received: by 2002:a05:6a00:b87:b0:68b:e710:ee9c with SMTP id g7-20020a056a000b8700b0068be710ee9cmr4577567pfj.19.1694644864795; Wed, 13 Sep 2023 15:41:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694644864; cv=none; d=google.com; s=arc-20160816; b=nQiGAI+sDzd/oLNV/LV3WpADMHWwR7duF9ac7HLSSmPBYM3JLXiKsPs1/2zb+KhS3E aH0xB0Jxs3/hOhR1s6pF9VYqxzSvCgcpbt5hPE0ir6MuD+9OS2dRPoeBoD1yD3tTecxG 3bqHgyxs/AiG/8YCHtu6QLwyPHRSmrLxdBUyBcdpPu7xn8YTlkOXJ/nLnJWY8HmQKcph G8MwOLlwgFUbvlDX6ulqLVbB+WGblflXV33Hy/1TrFVbFPEkcCoqNMeyUb5Lb61l1/hy TCCt4yy1lrVn0rIsWAfV9HT9z1l+vXPs6/Rqof8b0+SaE+WEQXc7WNpWpoSCO+atpqBm AtGw== 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=JbOP1V2rs7StbLGjBpVESX+LpywXb14Z9JE04GVQ7O4=; fh=x1hGPnZeYvyedQGDVaFY4F5NZX5OfdEJxyYqoMYIkPY=; b=Xr2X6UgKHhRXapeLLIzZ1LulR3dEoL2JlmJsVHTdTpGH4yrQXaqzeqnSKfBm0NSczX p1y/x4+oAWn5XkN6onZQ1vISGAg6+U+Bebwc9ww1hAjdOkKpw76kUhrJLZvdXMxPWbzb M9gbxPznKzqsGSlFDe6hdeFD/TRT3b6oDJL+soILkfhNeUzKVPS+2WylW3jE1NqHLpOv jG+IhNy9fGpmEKLqfHein3BGv1JV2uMwjwxFvfuxNn6J1q0zFcb5JZPS7QOg7+7V7igj BuNgQ3cnIETWKQjenTEaX+vQV/JpTQgYWziWBx5UHj92zQOt23+tFCL5hK7QXudJcS5L KVwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=a4FO8FZu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id t18-20020a056a0021d200b0068fea05ecdasi203868pfj.182.2023.09.13.15.41.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 15:41:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=a4FO8FZu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id DE696835A380; Wed, 13 Sep 2023 12:54:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229642AbjIMTy3 (ORCPT + 34 others); Wed, 13 Sep 2023 15:54:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232580AbjIMTy1 (ORCPT ); Wed, 13 Sep 2023 15:54:27 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98A361BCC; Wed, 13 Sep 2023 12:54:23 -0700 (PDT) Received: from umang.jainideasonboard.com (unknown [103.86.18.170]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8D533755; Wed, 13 Sep 2023 21:52:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1694634770; bh=bjRAkpStJWZ3WMMqqCEhTrsjzJ8pv1Ax01MVq8FcDao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a4FO8FZuAzx35phrM+lZXl/o/BgYBG5DKnxPxN5ZJWg0J3h6MAG0j5Xu+KXL1k6gU RN93Aq8h3CxtR9QIVH6y5NBr9Tv9vtMByHZksy4U4EPSAsBI6TLP5uCM/fqMalhhRE dzQwurmK2K0P24qL/rBM0I4kfWtJubGjnfbKAWWk= From: Umang Jain To: linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-rpi-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stefan Wahren , Greg Kroah-Hartman , Florian Fainelli , Adrien Thierry , Dan Carpenter , Dave Stevenson , Kieran Bingham , Laurent Pinchart , Umang Jain Subject: [PATCH v11 3/5] staging: bcm2835-camera: Register bcm2835-camera with vchiq_bus_type Date: Thu, 14 Sep 2023 01:23:52 +0530 Message-Id: <20230913195354.835884-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230913195354.835884-1-umang.jain@ideasonboard.com> References: <20230913195354.835884-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 13 Sep 2023 12:54:42 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776963933821896690 X-GMAIL-MSGID: 1776963933821896690 Register the bcm2835-camera with the vchiq_bus_type instead of using platform driver/device. Since we moved away bcm2835-camera from platform driver/device, we have to set the DMA mask explicitly. Set the DMA mask at probe time. 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 | 26 +++++++++++++------ .../interface/vchiq_arm/vchiq_arm.c | 11 +++++--- 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..52431b834232 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -11,6 +11,7 @@ * Luke Diamand @ Broadcom */ +#include #include #include #include @@ -24,8 +25,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 +1843,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; @@ -1852,6 +1854,14 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) unsigned int resolutions[MAX_BCM2835_CAMERAS][2]; int i; + if (!device->dev.dma_mask) + device->dev.dma_mask = &device->dev.coherent_dma_mask; + ret = dma_set_coherent_mask(&device->dev, DMA_BIT_MASK(32)); + if (ret) { + dev_err(&device->dev, "can't set coherent DMA mask: %d\n", ret); + return ret; + } + ret = vchiq_mmal_init(&instance); if (ret < 0) return ret; @@ -1896,7 +1906,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 +1986,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 +1998,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 d993a91de237..14bdde610f3a 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(); }