- 11 Mar, 2021 40 commits
-
-
Laurent Pinchart authored
The imx7_csi_streaming_start() function just wraps imx7_csi_enable(). Call the latter directly. Similarly, merge imx7_csi_streaming_stop() and imx7_csi_disable() as they're both called from a single location only. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
There's no reason to delay the CSI configuration and the DMA setup after starting the source. Move it before, simplifying error handling at stream start. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
The imx7_csi_dma_stop() function performs two operations, it waits for DMA to be complete, and then cleans up and frees buffers. Split the second part out to a new imx7_csi_dma_cleanup() function to match imx7_csi_dma_setup(), in preparation for a stream start refactoring. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
The imx7_csi_dma_start() doesn't start DMA. Rename it to imx7_csi_dma_setup() to avoid confusion. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
The is_csi2 field can't be accessed concurrently by imx7_csi_pad_link_validate() and imx7_csi_configure(), as the latter is called from imx7_csi_s_stream(), which is called after link validation. Drop the lock. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
The code in imx7_csi_pad_link_validate() that checks the type of the source incorrectly handles devices that have no parallel input. In that case, the source entity of the CSI is the CSI-2 receiver, not the video mux, and the driver will proceed to check the type of the source of the CSI-2 receiver. Make the code more explicit to fix this, by handling the three cases (parallel input only, CSI-2 receiver only, and video mux) separately. Note that the driver will not correctly handle the case where only a parallel input is present, and the external entity connected to the parallel input reports a MEDIA_ENT_F_VID_IF_BRIDGE or MEDIA_ENT_F_VID_MUX function. This was broken already, and should be fixed separately. Fixes: f5ffb81f ("media: imx7: csi: Fix pad link validation") Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
Move capture format validation from imx7_csi_configure() to .link_validate(). This simplifies error handling at stream on time, as imx7_csi_configure) now becomes a void function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
To prepare for a major rework of the hardware initialization, and make the code easier to read, reorder functions to group them in sections. No functional change is included. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
Describe multi-bit fields with parameterized macros where applicable, and use them to replace manual shifts and hardcoded numerical values. Add macros for the CSICR2 fields used in the driver. While at it, align the indentation for all macros, and use lower-case hex numbers. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
The CSICR*_RESET_VAL macros only obfuscate code. Use their value directly, replacing the numerical value with the macros that describe register bits. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
The i.MX7 camera pipeline is simple, with the CSI connected directly to the capture device without any other option. There's thus no need to allow link configurable by userspace. Make it immutable. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
There's no need to initialize the CSI every time a link is enabled (and de-initialize it when a link is disabled). Move initialization to .s_stream() instead. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
The control handler isn't used, drop it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
When the subdevice connected to the capture device has a single possible sink, there's no point in making the link mutable. Support creating immutable links. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
Support for the MC-centric API has been tested on the i.MX7. Enable it for that platform. i.MX6 should be converted next. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
Report to userspace that the MC-centric API is MC-centric by exposing the V4L2_CAP_IO_MC. This requires adding support for mbus code filtering in format enumeration, as required by V4L2_CAP_IO_MC. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
When operating in MC-centric mode, the behaviour of video nodes shall not be influenced by the active configuration of the source subdev. Add a set of ioctl handlers that implement this mode, and select them when support for the legacy API is not requested. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
The __capture_legacy_try_fmt() function returns two values through pointer arguments. One is a compose rectangle, which duplicates informationr returned through the subdev format argument, and can thus be removed. The other is the imx_media_pixfmt, which can be returned by value instead. Simplify the implementation of __capture_legacy_try_fmt() by dropping the retcc and compose arguments, and returning the imx_media_pixfmt by value. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Reviewed-by: Steve Longerbeam <slongerbeam@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
capture_validate_fmt() delegates the media bus format to pixel format conversion to __capture_legacy_try_fmt(). It turns out that this can be simplified quite a lot: - The format lookup from media bus code can be performed by the recently added capture_find_format() function instead of receiving the information from a side effect of __capture_legacy_try_fmt(). - The validation of the pixel format size isn't needed, as they duplicate the validation of the compose rectangle. The pixel format size is directly derived from the size of the incoming stream, which is stored in the compose rectangle. If the compose rectangle is valid, the pixel format size will be valid too. By removing the validation of the pixel format size and using capture_find_format() to lookup the format, we can stop using __capture_legacy_try_fmt() and simplify capture_validate_fmt(). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
Extract the format lookup code from __capture_legacy_try_fmt() to a separate function, it will be reused when validating the video node format at stream start time. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
The correct return code to report an invalid pipeline configuration is -EPIPE. Return it instead of -EINVAL from __capture_legacy_try_fmt() when the capture format doesn't match the media bus format of the connected subdev. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
The __capture_legacy_try_fmt() function only needs the v4l2_pix_format embedded in the v4l2_format argument it receives. Pass it the v4l2_pix_format directly, allowing on caller to allocate a smaller structure on the stack. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Reviewed-by: Steve Longerbeam <slongerbeam@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
The __capture_legacy_try_fmt() function doesn't need two imx_media_pixfmt pointer variables. Remove one of them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Reviewed-by: Steve Longerbeam <slongerbeam@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
Add a parameter to the imx_media_capture_device_init() function to select between the legacy and MC-centric API. When selecting the MC-centric API, the video node doesn't inherit controls from subdevs anymore. All callers are updated to use the legacy API for now, preserving the existing behaviour. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
The i.MX media drivers implement a legacy video node API, where the format of the video node is influenced by the active format of the connected subdev (both for enumeration and for the get, set and try format ioctls), and where controls exposed by the subdevs in the pipeline are inherited by the video node. At the same time, the drivers implement the media controller API and expose subdev video nodes to userspace. Those two modes of operation are incompatible and should not be exposed together. Furthermore, the legacy API gets in the way of proper enumeration of pixel formats on the video node, as it prevents compliance with the V4L2 specification. As a first step towards fixing this, rename all V4L2 video node ioctl handlers with a legacy prefix. This will allow implementing a new set of ioctls in parallel and gradually switching drivers. Add a task to the TODO file for the removal of the legacy API. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
For consistency with all the other ioctl handlers, rename vidioc_querycap() to capture_querycap(). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Reviewed-by: Steve Longerbeam <slongerbeam@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
To prepare for more complex default format initialization and keep imx_media_capture_device_register() simple, extract the format initialization code to a separate function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
The imx_media_video_dev structure stores the active format on the video node in an instance of v4l2_format. This wastes memory when all we need is the information contained in the smaller v4l2_pix_format sub-structure. Replace v4l2_format by v4l2_pix_format to save memory. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
When the video device is registered, it can get used by userspace immediately. Its initialization must thus be fully complete. Ensure this by registering the video device after all initialization steps. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
Overwriting the whole video_device isn't future-proof as it would overwrite any field initialized by video_device_alloc(). Furthermore, the current implementation modifies the global template video_device as if it were a per-instance structure, which is bad practice. To fix all this, initialize the video device programmatically in imx_media_capture_device_init(). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
Move the initialization of the vb2 queue and the control handler to the imx_media_capture_device_init() function. There's no need to delay them until the registration time. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
The stop field in the capture_priv structure is only set, never read. Drop it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
Document all the fields of the capture_priv structure and group them by purpose. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
If the call to v4l2_fh_open() fails, return the error code instead of proceeding normally as if nothing happened. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
The forward declaration of capture_qops isn't needed, remove it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
The v4l2_capability bus_info field is meant to locate the device in the system. Using a subdev name isn't a good fit, the device name is a much better option. Use it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
The imx-media-capture helpers operate a video device node, but abuse the v4l2_* subdev print functions to log messages. We have a struct device pointer available, use it instead with the dev_* functions. This reduces dependencies from imx-media-capture to the connected subdev. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
Add a media bus code argument to the imx_media_enum_pixel_formats(). If set to a non-zero value, the function will only consider pixel formats that match the given media bus code. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
All drivers use 640x480 as the default size, but they all hardcode those values. Create two global macros named IMX_MEDIA_DEF_PIX_WIDTH and IMX_MEDIA_DEF_PIX_HEIGHT to store the default size, and use them through the code. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-
Laurent Pinchart authored
imx6-media-objs contains a set of objects that are specific to the i.MX6 IPU-based media subsystem. They're not needed for the i.MX7 CSI. Only compile them if CONFIG_VIDEO_IMX_CSI is selected. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-