Add new "pispbe" driver (though not yet the Makesfiles or DT required to use it)
media: bcm2712: Initial commit of the PiSP BE driver Signed-off-by: Naushir Patuck <naush@raspberrypi.com> media: bcm2712_pisp_be: PiSP driver updates. - Start registering video nodes from /dev/video20 - Formatting fixes - Define MODULE_DEVICE_TABLE() to probe correctly Signed-off-by: Naushir Patuck <naush@raspberrypi.com> media: pisp_be: Improve image format support Add a new format table that lists the V4L2 format enums and their properties. Keep the exising 'RPBP' format to support the userland verification tools. This format requires userland to fill all plane properties. Standard V4L2 formats will derive these properties from the format table. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> media: pisp_be: Advertise the meta output format explictily. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> drivers: pisp_be: Various updates and cleanups - Switch to a single node group for now. - Add a node description table to simplify node handling. - Switch HoG output to V4L2_CAP_META_CAPTURE type. - Use string descriptions for node names in logging messages. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> pisp_be: Updates for libcamera usage: - Remove indexes from device entity names - Add enumframesize and enumfmts ioctls - Add default format to all nodes. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> v4l2: pisp_be: Move format definitions into v4l2 core Signed-off-by: Naushir Patuck <naush@raspberrypi.com> media: raspberrypi: Move PiSP common headers to a single location Signed-off-by: Naushir Patuck <naush@raspberrypi.com> media: raspberrypi: Remove old pispbe driver. This is now supersede by the driver in drivers/media/platform/raspberrypi/ Signed-off-by: Naushir Patuck <naush@raspberrypi.com> PISP-BE Driver: Automate buffer-cycling for TDN and Stitch state. Remove "tdn-input" and "stitch-input" nodes altogether (the output nodes must still be opened and REQBUFS called with 1 or 2 buffers). Also, a bit of tidying of buffer address handling and locking. PISP-BE driver: Turn debug level right down to reduce overly-chatty messages media: bcm2712: Depend on CONFIG_PM Depend on CONFIG_PM as the driver uses the runtime_pm infrastructure. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> drivers: media: pisp_be: Move BE driver to a raspberrypi directory Move the pisp_be driver from drivers/media/platform/raspberrypi/ to drivers/media/platform/raspberrypi/pisp_be/. This seems the accepted convention in the drivers/media/platform/ directory structure. Also rename the driver module from bcm2712_pisp_be to pisp_be. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> pisp_be: Updates for libcamera streaming: - Add some required v4l2 formats - Add buf_prepare ioctl - Set plane offsets correctly before reprogramming pisp_be: Reduce logging verbosity Signed-off-by: Naushir Patuck <naush@raspberrypi.com> pisp_be: Add buffer timestamps While at it, remove duplicate code when checking if the HW has completed multiple jobs. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> pisp_be: Remove queue size allocation constraint PISP-BE driver: Fix ISR to handle multiple done/start events. PISP-BE: Fix variable-name shadowing bugette PISP-BE: Support for two node groups. Reorganize the driver. To support 2 concurrent libcamera applications, we need 2 node groups, need to allow multiple opens of each node (because libcamera does this) and create a separate media device per group (to support file-locking). This triggered significant rearrangement of the driver. Some calls that we formerly intercepted have been delegated back to v4l2/vb2. Logging changes arising from multiple v4l2_dev. Refactored probe() and initialization. Avoid dynamically-allocated entity name strings. drivers: media: pisp_be: Add vidioc_enum_fmt_meta_out This was missing in the struct v4l2_ioctl_ops definition. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> drivers: media: pispe_be: Add Bayer compressed formats Add PiSP Bayer compressed formats to the list of supported pixel formats for the PiSP backend driver. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> drivers: meida: pisp_be: Fix overflow in plane size calculations The calculations for buffer plane sizes can overflow because of the plane factor shift. Fix this by using u64 integers for the calculations. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> drivers: media: pisp_be: Use 0P3 for plane factors Use less precision for the plane factors to avoid any nasty overflows. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> media: pisp: Checkpatch and coding style fixups Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com> media: pisp_be: More coding style fixups media: platform: bcm2712: pisp_be: Fix crash when buffer format not set Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com> media: platform: bcm2712: pisp_be: Allow non-SRGB colour spaces on RGB outputs Allow colour spaces other than SRGB when the output format in question is an RGB output. This commit merely ports over existing changes from the vc4 ISP driver. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> media: platform: bcm2712: Tweak list of BE supported image formats Remove RGB565 and 10- and 12-bit packed raw formats, which ISP-BE can't support for input or output. Add NV12M and NV21M which it can. (I didn't bother adding YUV422P, which apparently is not widely used.) Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com> pisp_be: Fill the hardware revision in the media entity struct This can be used by userland to determine the hardware capabilities. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> bcm2712: Use BIT() macro Use the BIT() macro instead of plain bit shifting. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> bcm2712: Invert condition in pispbe_schedule_internal() Return earlier and save one indentation level Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> bcm2712: Invert condition in for loop Save one indentation level by continuing if the node is not streaming. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> bcm2712: Do not declare a local variable There already is a truct pispbe_node *node in the function scope. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> bcm21712: Siplify pispbe_schedule_one() A little more verbose but easier to follow ? Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> bcm2712: Rename pispbe_schedule_all() to pispbe_schedule_any() The pispbe_schedule_all() function name is misleading, as the function schedule a single job from any of the node groups. Rename it. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> media: platform: bcm2712: Remove buffer auto-cycling from ISP-BE Previously, the ISP-BE driver tried to automate "ping pong" buffers for TDN and HDR state, but did not fully conceal them from users. The automation has been removed: there are now separate output and capture queues for each of TDN and Stitch, which must be managed by user code (DMABUFs may be used to circulate buffers between queues). Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com> drivers: media: pisp_be: Cache BE config buffer vaddr When programming a new job, we access at the config buffer, possibly from ISR context. So fetch and the virtual address when queuing the buffer. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> drivers: media: pisp_be: Remove all traces of ctrls and request API These APIs are not (and will not) be used by the driver, so remove them. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> media: bcm2712: Replace v4l2_dbg with dev_dbg Replace the v4l2 debug helpers with the device debug once, which are preferred. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> media: bcm2712: Remove of_match_ptr() The of_match_ptr() usage could cause a compiler warning if CONFIG_OF is not enabled, as the pispbe_of_match variable would result unused. As the of_match_table field of struct platform_driver exists unconditionally, drop of_match_ptr() to avoid a warning. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> drivers: media: pispbe: Add local config buffer DMA allocation When initialiasing the driver, allocate a number of tiles + config structures used for storing hardware config internally in the driver. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> drivers: media: pispbe: Use local config buffers Store a copy of the config + tiles buffer locally when the buffer gets queued. This resolves the security issue where a userland process may modify the config buffer after it has been queued. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> drivers: media: pispbe: Validate config buffers Perform a basic config validation on the device output nodes to ensure the buffer size and stride values do not result in a buffer overrun. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> media: bcm2712: Rework probe sequence order Rework the probe sequence to: 1) Use dev_err_probe() when failing to get clocks 2) Disable clock on error path 3) Disable the node groups if they have been enabled and propagate the error up Also disable clocks in the remove() function. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> media: bcm2712: Use pm_runtime_ops Introduce usage of runtime resume and suspend operations. The diver only uses a single clock source which is enable/disabled at resume and suspend time. Implement file open and release operations to control enablement of the clock provider. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> media: bcm2712: Demote info message Demote info message about clock enablement to dev_dbg() Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> media: bcm2712: Move pm_runtime calls to streamon/streamoff Move the calls to pm_runtime_resume_and_get() and pm_runtime_put() to the streamon and streamoff ioctl handlers. Remove custom handlers for the open and close file operations and use the framework provided helpers. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> media: bcm2712: Use pm_runtime_autosuspend() Use the _autosuspend() version of runtime_pm_put() in order to avoid resuming and suspending the peripheral in between streaming sessions closely apart one from the other. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> drivers: media: pisp_be: Conditionally check buffers when preparing jobs When preparing a job, check the global enables in the config structure to see if the Output0/1, Tdn and Stitch blocks are enabled, and only test for a buffer queued if they are. This will allow userland to control the outputs selectively without disabling/re-enabling the respective device nodes. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> media: bcm2712: Rework media controller registration The current implementation register the v4l2_device and the video devices first, then creates the media controller and manually registers entities there. Rework the registration procedure to first create the v4l2_device and register the media_device with it. Then create the video nodes which gets automatically registered in the media graph by the core. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> media: bcm2712: Create v4l2_subdev for ISP entity Create a v4l2 subdevice to represent the PISPBE ISP entity. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> media: bcm2712: Fix v4l2-compliance warn on QUERYCAP Fix: warn: v4l2-compliance.cpp(669): media bus_info 'platform:1000880000.pisp_be' differs from V4L2 bus_info 'platform:pispbe' by populating the driver caps bus_info by using dev_name(). Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> media: bcm2712: Fix v4l2-compliance warn on invalid pixfmt The V4L2 API for the TRY_FMT/S_FMT ioctl allows the ioctl handler to return an error code only in specific conditions. If an invalid pixel format is supplied it should be adjusted instead of an error being returned. Albeit, v4l2-compliance treats this situation as a warning and not as an error because the behaviour has been discussed in length in the past. warn: v4l2-test-formats.cpp(794): TRY_FMT cannot handle an invalid pixelformat. warn: v4l2-test-formats.cpp(795): This may or may not be a problem. For more information see: warn: v4l2-test-formats.cpp(796): http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html VIDIOC_TRY_FMT returned -1 (Invalid argument) Regardless of the warning vs failure decision, adjust the try_format() function implementation to use V4L2_PIX_FMT_YUV420M as default pixel format if the supplied one is invalid. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> media: bcm2712: Fix v4l2-compliance warn on HOG pix format The try_format() implementation for the HOG video device node returns an error if the supplied pixel format is not correct. As per the video device output and capture video nodes, this contradicts the V4L2 specification even if it is treated as a warning by v4l2-compliance. Fix this by forcing the buffer pixel format and size to the default supported one. While at here, use the BIT() macro in the format initialization function. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> media: bcm2712: Fix formats enumeration Right now a single implementation of enum_fmt() is used for all nodes in a group. This means that all the BE supported formats are listed for all the nodes. This is incorrect as the meta capture and output node formats should be restricted, and the meta formats should not be enumerated for video output and capture devices. Fix this by restricting the enumeration of META formats to the config and hog nodes. Split out from the list of supported_formats the V4L2_META_FMT_RPI_BE_CFG which is only used for the meta_out node, while V4L2_PIX_FMT_RPI_BE is kept in the list of supported_formats as it can be used as an opaque format for both meta_cap, video_cap and video_out nodes. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> media: bcm2712: Minor fixes to support PiSP regression tests Allow RGB input, not just Bayer (but only of those at once); Allow Wallpaper image formats. XXX They are not yet size-checked; Set "chicken bits" to test BURST_TRIM and AXI AWID/BID variation. Convert some v4l2_err() to dev_err() Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com> drivers: media: pisp_be: Use the maximum number of config buffers Set PISP_BE_NUM_CONFIG_BUFFERS the the maximum number of possible buffers. In the worst case, this overallocates config buffers, but given their size, it's not too much of a problem. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> media: pisp_be: Fix extra PM runtime put vidioc_streamoff callback can be called even if vidioc_streamon was never called. The driver currently does PM runtime get/put in these callbacks, which may lead to a put without a matching get. Fix this by moving the PM runtime get/put to vb2_ops's start_streaming & stop_streaming, which the framework makes sure won't get extra calls. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> drivers: media: pisp_be: Don't report V4L2_PIX_FMT_RPI_BE format This is an internal opaque format, not to be reported in enum_fmt. Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Please register or sign in to comment