[PATCH v6 0/4] media: raspberrypi: Support RPi5's CFE

Tomi Valkeinen
2024-10-03T10:36:42Z

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 <tomi.valkeinen@ideasonboard.com>
---
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,
--
Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>