From patchwork Thu Oct 3 10:31:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13820851 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 B9453CF8579 for ; Thu, 3 Oct 2024 10:36:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To: Content-Transfer-Encoding:Content-Type:MIME-Version:Message-Id:Date:Subject: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=GFy8jgTiZ4AUvOLOwOsfG/znoeWVsfUiWlQUS8xyh64=; b=dthv37w4u/X+vf /JBjVFxtAmKy9NQGwhSAZZ48mWOjrt6a7disNrKCZXQGSj+EqOLS5QBUDx8AuuBXlLLLLp1lbA9lf 7BV9k+vpSzYQwHsKP3Mr+mzXBfjJeS6xv1niDLM/zYDavko/0fWzKF18/jTFPyuRekHwkFCwjPR8d d8Uc8RXQjGAuzkGmUvDPe82RbQUe6iAhtyv9+fRu++Mrs6Mu7lO6esKTRRdKLcnpJ1nTN+nW13pkp YmRnzk6z5pWNOUYtBc9hQzSR+xJTHh109hCOi0ehPYG7oW32K43C5fcleHuCxCXGgP0lE0BjW+0LK F4nYgBZWoiZ7M7ThlumQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1swJCC-00000008nhv-1Hyt; Thu, 03 Oct 2024 10:36:32 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1swJ7X-00000008mv0-4AKe; Thu, 03 Oct 2024 10:31:48 +0000 Received: from [127.0.1.1] (91-156-87-48.elisa-laajakaista.fi [91.156.87.48]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5399B66F; Thu, 3 Oct 2024 12:30:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1727951406; bh=T0eLI3BQx09VUinYnX5rge1Gt0+JKsB+27b/i31lM8M=; h=From:Subject:Date:To:Cc:From; b=uULP+9bGzhYez/ebZktHIGjDVfiAa98EEd7vkHvZooRC1j+2xyyNOIwF2newZDDc6 8wvSyJT7iJ06CXLMBrO3l5HyJ6o19Evt5Ptv5ZtodBAno5ghTAJ0VeMaj1N8efhEuI cSTW5CY+IKMaYKSWSb3nym5zzRnhmDVq0d0n1sK0= From: Tomi Valkeinen Subject: [PATCH v6 0/4] media: raspberrypi: Support RPi5's CFE Date: Thu, 03 Oct 2024 13:31:09 +0300 Message-Id: <20241003-rp1-cfe-v6-0-d6762edd98a8@ideasonboard.com> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAG1y/mYC/3XRTU7DMBAF4KtEXuPivzhOhBD3QCzG9qQ1InGx0 6io6t1xU0EqQZeT+Ht6mjmRjClgJl11IgnnkEMcy6AfKuJ2MG6RBl9mIphQTHJF055T1yPlSlg tjG0EV6S83ifsw3FJen0r8y7kKaavJXjml68/GeY3Y+aUUXDat5r1vRD+JXiEHEcbIfmNiwO5R M1i5VqwlYvCrbHK9N6CtPIOlys3vF65LBx5DW3TeitFc4erlbdsXcCsCu+5ra30unWG3+H1Dec 35evCW7DKKWcQHP7Dz9e9Jvw8lMNM1+USCxlp+T+Eqas+wng40gF9AJon2OLjAHnCdDnJgDnDc sGueloK1JIzwxrWbKSqtaGcvoOL+7gZ4ujDnwbPpcL5GwSwYJcjAgAA To: Mauro Carvalho Chehab , Raspberry Pi Kernel Maintenance , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Rob Herring , Krzysztof Kozlowski Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Naushir Patuck , Laurent Pinchart , Sakari Ailus , Jacopo Mondi , Kieran Bingham , Tomi Valkeinen , Krzysztof Kozlowski X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5363; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=T0eLI3BQx09VUinYnX5rge1Gt0+JKsB+27b/i31lM8M=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBm/nKCrpzPGVs9w2OM8F3CW1ZEzXtd01qMAxH99 Jr+7arRH/CJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZv5yggAKCRD6PaqMvJYe 9al6D/4hJ1eenxev2HdtwrCJZTTU7wGR29H0OdNZe6cwxHssT/+kOEddvhEIQ0eXP2+L12v2wy7 WcNZmQJC0uzS1jsU+21czk86gY+XsHNx45+81q6J74R2Q86vYocBAPn6o/F8RDK6aIacLWCaeqG InntCdy199VYucO2KujaB4SDSyWn0svvh6Pjuwp8eor+LNu3+e4JVnuIsFRO1SRkdzecFSMoCTo EnBLxxISTERTnD7KSrStAVWto6r+PqpPYfkX4+T5RiWu3RNnA9AA0Qy33n/GBFtIvCjNhl7a1T4 eqNTp0j0yze+RzxKrbvnqlfIsvvvlPC4t89I5A1P0aUFm26WPYp90DQ5Z757xwMvYkhKcHPZFBW wlbAgEwdKQvrsfmO0WqbRzZJvqn8SWBJFXq1f2wk+dLkNokxlOQG7eErCC0gPPQhvlScJ0y1sXH FZanzovLSecuYQA0Z7ZxKyJX+glWEMTaxvevn+FxgpYegESyXxa0JcwH4X+tE8r56RNKPCUAcJc m44tsbE6P0WbZSU4exi69ofdzQv6JwzbZpaNrmMdV1QIwi7H2WDnqBHCvvxACLhhtvg6mpVcguK IYwgqseTgid2GjiwCaRsbPxUKrRsd5PVLdb9p2zrmcTVq1/8vfWMg5Pr/OWxjTSezr3Jb6LrpxG EMiiul5owy0Xj7w== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241003_033144_312168_2DD54900 X-CRM114-Status: GOOD ( 17.96 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This series adds support to the CFE hardware block on RaspberryPi 5. The CFE (Camera Front End) contains a CSI-2 receiver and Front End, a small ISP. To run this, you need the basic RPi5 kernel support plus relevant dts changes to enable the cfe and camera. My work branch with everything needed to run CFE can be found from: git://git.kernel.org/pub/scm/linux/kernel/git/tomba/linux.git rp1-cfe A few notes about the patches: - The original work was done by RaspberryPi, mostly by Naushir Patuck. - The second video node only sets V4L2_CAP_META_CAPTURE instead of both V4L2_CAP_META_CAPTURE and V4L2_CAP_META_CAPTURE like the other nodes. This is a temporary workaround for userspace (libcamera), and hopefully can be removed soon. I have tested this with: - A single IMX219 sensor connected to the RPi5's CSI-2 port - Arducam's UB960 FPD-Link board with four imx219 sensors connected Tomi Signed-off-by: Tomi Valkeinen --- Changes in v6: - Rename "isr_handler" functions to just "isr" - Fix checkpatch warnings, mainly lines over 80 chars - A diff of the changes be be found from: https://paste.debian.net/1331173/ (note: the tab there seems to be 4 chars) - Link to v5: https://lore.kernel.org/r/20240910-rp1-cfe-v5-0-9ab4c4c8eace@ideasonboard.com Changes in v5: - Add "depends on PM". The platforms that use CFE will always have PM in practice, and it's not worth supporting both the PM and !PM cases as it adds complexity to the driver. - Link to v4: https://lore.kernel.org/r/20240904-rp1-cfe-v4-0-f1b5b3d69c81@ideasonboard.com Changes in v4: - Drop unnecessary clock-lanes from the DT bindings - Drop unnecessary linux-media from MAINTAINERS entry - Drop unnecessary conversion to bool with !! - Don't set cap->bus_info in cfe_querycap() - Make debugfs files not readable by the world - Check the return value of v4l2_fwnode_endpoint_parse() - Remove the code dealing with remote_ep_fwnode. Instead use v4l2_create_fwnode_links_to_pad() and media_pad_remote_pad_unique() to create the link and get the pad index. - Add cfe/csi2/fe/dphy argument to the respective dbg/info/err print macros. - Drop some debug prints and add a few, clarifying the prints for enabling and disabling the streams. - Some cosmetic changes (linefeed, drop unnecessary assignment, move a define) - Link to v3: https://lore.kernel.org/r/20240815-rp1-cfe-v3-0-e15a979db327@ideasonboard.com Changes in v3: - Based on v6.11-rc3. The PiSP BE series is now in upstream so no extra dependencies are needed. - Fixed cfe_remove() return value, as the .remove hook has changed - Added Krzysztof's Rb. - Link to v2: https://lore.kernel.org/r/20240620-rp1-cfe-v2-0-b8b48fdba3b3@ideasonboard.com Changes in v2: - Change the compatible string back to raspberrypi,rp1-cfe from raspberrypi,rpi5-rp1-cfe - Drop the references to rp1 headers in the DT binding example. This allows compiling the example without the rp1 support. - Fix missing remap lines for mono formats - Fix csi2_pad_set_fmt() so that the format can be changed back to the sink's format from 16-bit or compressed format. - Link to v1: https://lore.kernel.org/r/20240318-rp1-cfe-v1-0-ac6d960ff22d@ideasonboard.com --- Tomi Valkeinen (4): media: uapi: Add meta formats for PiSP FE config and stats dt-bindings: media: Add bindings for raspberrypi,rp1-cfe media: raspberrypi: Add support for RP1-CFE media: admin-guide: Document the Raspberry Pi CFE (rp1-cfe) .../admin-guide/media/raspberrypi-rp1-cfe.dot | 27 + .../admin-guide/media/raspberrypi-rp1-cfe.rst | 78 + Documentation/admin-guide/media/v4l-drivers.rst | 1 + .../bindings/media/raspberrypi,rp1-cfe.yaml | 93 + .../userspace-api/media/v4l/meta-formats.rst | 1 + .../userspace-api/media/v4l/metafmt-pisp-fe.rst | 39 + MAINTAINERS | 7 + drivers/media/platform/raspberrypi/Kconfig | 1 + drivers/media/platform/raspberrypi/Makefile | 1 + drivers/media/platform/raspberrypi/rp1-cfe/Kconfig | 15 + .../media/platform/raspberrypi/rp1-cfe/Makefile | 6 + .../media/platform/raspberrypi/rp1-cfe/cfe-fmts.h | 332 +++ .../media/platform/raspberrypi/rp1-cfe/cfe-trace.h | 202 ++ drivers/media/platform/raspberrypi/rp1-cfe/cfe.c | 2504 ++++++++++++++++++++ drivers/media/platform/raspberrypi/rp1-cfe/cfe.h | 43 + drivers/media/platform/raspberrypi/rp1-cfe/csi2.c | 586 +++++ drivers/media/platform/raspberrypi/rp1-cfe/csi2.h | 89 + drivers/media/platform/raspberrypi/rp1-cfe/dphy.c | 181 ++ drivers/media/platform/raspberrypi/rp1-cfe/dphy.h | 27 + .../media/platform/raspberrypi/rp1-cfe/pisp-fe.c | 605 +++++ .../media/platform/raspberrypi/rp1-cfe/pisp-fe.h | 53 + drivers/media/v4l2-core/v4l2-ioctl.c | 2 + .../uapi/linux/media/raspberrypi/pisp_fe_config.h | 273 +++ .../linux/media/raspberrypi/pisp_fe_statistics.h | 64 + include/uapi/linux/videodev2.h | 2 + 25 files changed, 5232 insertions(+) --- base-commit: 98f7e32f20d28ec452afb208f9cffc08448a2652 change-id: 20240314-rp1-cfe-142b628b7214 Best regards,