summaryrefslogtreecommitdiff
path: root/src/libcamera/pipeline
AgeCommit message (Collapse)Author
2021-03-03libcamera: pipeline: simple: Store streams in a vectorLaurent Pinchart
To prepare for multiple streams support, store the streams in a vector in the SimpleCameraData class. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Phi-Bang Nguyen <pnguyen@baylibre.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-03-03libcamera: pipeline: simple: converter: Add multi-stream supportLaurent Pinchart
While the M2M device backing the converter doesn't support multiple streams natively, it can be run once per stream to produce multiple outputs from the same input, with different output formats and sizes. To support this, create a class to model a stream and move control of the M2M device to the Stream class. The SimpleConverter class then creates stream instances and iterates over them. Each stream needs its own instance of the V4L2M2MDevice, to support different output configurations. The SimpleConverter class retains a device instance to support the query operations. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Phi-Bang Nguyen <pnguyen@baylibre.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-03-03libcamera: pipeline: simple: converter: Decouple input and output completionLaurent Pinchart
The SimpleConverter API signals completion of input and output buffer pairs. This unnecessarily delays requeueing the input buffer to the video capture queue until the output buffer completes, and also delays signalling request completion until the input buffer completes. While this shouldn't cause large delays in practice, it will also not scale when multi-stream support will be added to the converter class. To address the current issue and prepare for the future, decouple signalling of input and output buffers completion. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Phi-Bang Nguyen <pnguyen@baylibre.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-03-03libcamera: pipeline: simple: converter: Replace open() with isValid()Laurent Pinchart
Simplify the SimpleConverter interface by opening the M2M device in the constructor. The explicit call to open() is replaced by a check through a new isValid() function, and the unused close() function is removed. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Phi-Bang Nguyen <pnguyen@baylibre.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-03-03libcamera: pipeline: simple: converter: Differentiate input and output ↵Laurent Pinchart
buffers count The number of buffers on the input and output of the converter don't necessarily need to match. Use the buffer count from the input and output configuration respectively. This removes the need to pass the buffer count to the start() function, which brings it closer to the pipeline handler API. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Phi-Bang Nguyen <pnguyen@baylibre.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-03-03libcamera: pipeline: simple: converter: Configure input strideLaurent Pinchart
Use the stride of the video capture device to configure the converter input. This ensures that no stride mismatch occurs inadvertently along the pipeline. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Phi-Bang Nguyen <pnguyen@baylibre.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-03-03libcamera: pipeline: simple: converter: Use StreamConfiguration for input ↵Laurent Pinchart
configuration Group the configuration parameters for the converter input in a StreamConfiguration instance. This makes the configure() function signature cleaner, and will allow passing additional parameters (such as stride and buffer count). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Phi-Bang Nguyen <pnguyen@baylibre.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-03-03libcamera: pipeline: simple: converter: Group query functions togetherLaurent Pinchart
The SimpleConverter class has different sets of functions, related to static queries, device configuration and runtime operation. Group the query functions together. While at it, swap the arguments to the strideAndFrameSize() function to match the order in which pixel format and size are usually specified. No functional change is included. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Phi-Bang Nguyen <pnguyen@baylibre.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-03-03libcamera: pipeline: simple: Don't override stride at configure timeLaurent Pinchart
The stride (and frame size) calculation has been moved from configure time to configuration validate time by commit 89fb1efac240 ("libcamera: simple: Fill stride and frameSize at config validation"). This change has however left one stray setting of the stride when configuring the converter. Fix it. While at it, turn the SimpleConverter::configure() output configuration argument to a const reference to emphasize it can't be null and isn't modified by the function, and rename it from cfg to outputCfg to make its purpose clearer. Fixes: 89fb1efac240 ("libcamera: simple: Fill stride and frameSize at config validation") Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Phi-Bang Nguyen <pnguyen@baylibre.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-03-03libcamera: pipeline: simple: Manage converter with std::unique_ptr<>Laurent Pinchart
Replace manual destruction of the converter with std::unique_ptr<>. This removes the need for the SimplePipelineHandler destructor. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Phi-Bang Nguyen <pnguyen@baylibre.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-25libcamera: ipu3: Initialize V|H flip supportJacopo Mondi
The flag that is used to record if the sensor driver supports the H/V flip controls is initialized at camera creation time, but it was not initialized by the IPU3Camera constructor, resulting in erroneous values that might break capture for sensor that do not support flipping. Fix this by initializing the flag in the class constructor. Fixes: 6c4ce7de30c8 ("libcamera: ipu3: Add rotation to ipu3 pipeline") Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Fabian Wüthrich <me@fabwu.ch> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-23libcamera: Enable vimc pipeline handler when tests are enabledLaurent Pinchart
The addition of the new IPA IPC mechanism compiles pipeline-specific headers to define the interface between the pipeline and the IPA. This was optimised in 08ce394465b5 ("meson: ipa, proxy: Only build proxies for enabled pipelines") to only build for enabled pipelines, however the tests directly use the VIMC pipeline handler, and require it to be built. Create a local variable to store the requested pipelines from the user configuration and extend the enabled pipelines to ensure that VIMC is always enabled if the tests are also enabled Fixes: 08ce394465b5 ("meson: ipa, proxy: Only build proxies for enabled pipelines") Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Tested-by: Sebastian Fricke<sebastian.fricke@posteo.net>
2021-02-23libcamera: ipu3: Add rotation to ipu3 pipelineFabian Wüthrich
Use the same transformation logic as in the raspberry pipeline to implement rotations in the ipu3 pipeline. Tested on a Surface Book 2 with an experimental driver for OV5693. Signed-off-by: Fabian Wüthrich <me@fabwu.ch> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Acked-by: Fabian Wüthrich <me@fabwu.ch>
2021-02-22libcamera: raspberrypi: Drop std::move() where misleadingLaurent Pinchart
Usage of std::move() on a const lvalue will produce a const rvalue, which the compiler will bind to the const lvalue reference of the constructor or assignement operator. This results in the object being copied, not moved. Drop std::move() in that case as it's misleading. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
2021-02-22libcamera: ipu3: Do not over-write metadataJacopo Mondi
When a Request is completed upon receiving the IPA produced metadata, the metadata associated with the Request were over-written, deleting the information set, in example, at ImgU output buffer completion. If any additional Request metadata should be registered by inspecting the IPA produced metadata it has to be done without deleting the already registered entry. Fix this by replacing the metadata over-write with a todo entry. This change fixes CTS which was broken due to missing metadata in the completed requests. Fixes: 9708f49fecf2 ("libcamera: ipu3: Share parameter and statistic buffers with IPA") Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-21libcamera: camera: Constify controls argument to start()Laurent Pinchart
The ControlList passed to the Camera::start() function isn't modified. Make it const. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2021-02-19libcamera: ipu3: set V4L2_CID_INTEL_IPU3_MODEJean-Michel Hautbois
In order to get the stats back, the imgu subdev needs to have the V4L2_CID_INTEL_IPU3_MODE control set. Set it to video mode by default to get the stats at each frame. Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> [Kieran: Updated message to match Laurent's suggestion] Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-19libcamera: pipeline: ipu3: Prevent unintialised memory useKieran Bingham
The call to setFormat uses uninitialised data, which, could cause unwanted effects. It is also trapped and reported by valgrind. Initialise the V4L2SubdeviceFormat structure correctly before use. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-19pipeline: raspberrypi: Update the lens shading control in-placeNaushir Patuck
Only update the lens shading control if it is present in the ControlList. Add the dmabuf file descriptor to the lens shading control in-place rather than taking a copy. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-19pipeline: ipa: raspberrypi: Rename IPA Interface namespace to ipa::RPiNaushir Patuck
Rename the IPA interface namespace to ipa::RPi for consistency with the libcamera::RPi namespace label. There is no functional change in this commit. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-19pipeline: ipa: raspberrypi: Tidy-ups after IPAInterface changesNaushir Patuck
This commit addresses a couple of tidy-ups after the IPAInterface rework: - Rename ConfigStaggeredWrite -> ConfigSensorParams - Rename setIsp -> setIspControls There is no functional change in this commit. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-19pipeline: ipa: raspberrypi: Fix pipeline running on in a stopped stateNaushir Patuck
With the recent IPAInterface changes, the signal handlers statsMetadataComplete(), runISP() and embeddedComplete() would run unconditionally when called. They should only run when state != Stopped. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Fixes: e201cb4f5450 ("libcamera: IPAInterface: Replace C API with the new C++-only API") Tested-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-16libcamera: IPAInterface: Replace C API with the new C++-only APIPaul Elder
Remove everything related to the C API, including ipa_context, ipa_context_wrapper, and IPAInterfaceWrapper. Also remove relevant documentation. ipaCreate() provided by IPA implementations, and createInterface() provided by IPAModule (wrapper around IPA implementation) both now return a C++ object IPAInterface instead of struct ipa_context. Although IPAInterfaceWrapper is the only component of libipa, the skeleton and build files for libipa are retained. After converting the C API to the C++-only API, make all pipeline handlers and IPAs use the new API. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- This is a combination of 21 commits: --- libcamera: IPAModule: Replace ipa_context with IPAInterface With the new IPC infrastructure, we no longer need the C interface as provided by struct ipa_context. Make ipaCreate_() and createInterface() return IPAInterface. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: ipa_context_wrapper: Remove ipa_context_wrapper Since ipa_context has been replaced with custom IPAInterfaces, it is not longer needed. Remove it. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: IPAInterface: remove ipa_context and functions from documentation Remove all the documentation related to ipa_context and the C IPA API, as well as the documentation about the functions in the IPAInterface. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> --- libcamera: IPAInterface: Remove all functions from IPAInterface Now that all the functions in the IPA interface are defined in the data definition file and a specialized IPAInterface is generated per pipeline handler, remove all the functions from the base IPAInterface. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: IPAInterface: make ipaCreate return IPAInterface With the new IPC infrastructure, we no longer need the C interface as provided by struct ipa_context. Make ipaCreate return IPAinterface. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> --- ipa: remove IPAInterfaceWrapper As every pipeline has its own proxy, IPAInterfaceWrapper is no longer necessary. Remove it. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Acked-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> --- libcamera: IPAProxy: Remove stop() override Since stop() is part of the IPA interface, and the IPA interface is now generated based on the data definition file per pipeline, this no longer needs to be overrided by the base IPAProxy. Remove it. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: IPAProxy, IPAManager: Switch to one-proxy-per-pipeline scheme IPAProxy is changed in two major ways: - Every pipeline has its own proxy, to support each pipeline's IPA interface - IPAProxy implementations always encapsulate IPA modules, and switch internally for isolation or threaded The IPAProxy registration mechanism is removed, as each pipeline will have its own proxy, so the pipeline can pass the specialized class name of the IPAProxy to the IPAManager for construction. IPAManager is changed accordingly to support these changes: - createIPA is a template function that takes an IPAProxy class, and always returns an IPAProxy - IPAManager no longer decides on isolation, and simply creates an IPAProxy instance while passing the isolation flag Consequently, the old IPAProxy classes (IPAProxyThread and IPAProxyLinux) are removed. The IPAInterfaceTest is updated to use the new IPAManager interface, and to construct a ProcessManager as no single global instance is created anymore. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> --- libcamera: IPAProxy: Add isolate parameter to create() Since IPAProxy implementations now always encapsulate IPA modules, add a parameter to create() to signal if the proxy should isolate the IPA or not. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: IPAManager: Fetch IPAProxy corresponding to pipeline Now that each pipeline handler has its own IPAProxy implementation, make the IPAManager fetch the IPAProxy based on the pipeline handler name. Also, since the IPAProxy is used regardless of isolation or no isolation, remove the isolation check from the proxy selection. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> --- libcamera: IPAManager: add isolation flag to proxy creation When the IPA proxy is created, it needs to know whether to isolate or not. Feed the flag at creation of the IPA proxy. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: IPAManager: Make createIPA return proxy directly Since every pipeline knows the type of the proxy that it needs, and since all IPAs are to be wrapped in a proxy, IPAManager no longer needs to search in the factory list to fetch the proxy factory to construct a factory. Instead, we define createIPA as a template function, and the pipeline handler can declare the proxy type when it calls createIPA. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: IPAProxy: Remove registration mechanism Implementations of IPA proxies use a registration mechanism to register themselves with the main IPA proxy factory. This registration declares static objects, causing a risk of things being constructed before the proper libcamera facilities are ready. Since each pipeline handler has its own IPA proxy and knows the type, it isn't necessary to have a proxy factory. Remove it to alleviate the risk of early construction. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: proxy: Remove IPAProxyLinux and IPAProxyThread We have now changed the proxy from per-IPC mechanism to per-pipeline. The per-IPC mechanism proxies are thus no longer needed; remove them. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- tests: ipa_interface_test: Update to use new createIPA Update the IPA interface test to use the new createIPA function from IPAManager. Also create an instance of ProcessManager, as no single global instance is created automatically anymore. Update meson.build to to depend on the generated IPA interface headers. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: PipelineHandler: Remove IPA from base class Since pipeline handlers now have their own IPA interface types, it can no longer be defined in the base class, and each pipeline handler implementation must declare it and its type themselves. Remove it from the base class. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- ipa: raspberrypi: Add mojom data definition file Add a mojom data definition for raspberrypi pipeline handler's IPAs. This simplifies the API between the raspberrypi pipeline handler and the IPA, and is not a direct translation of what was used before with IPAOperationData. Also move the enums from raspberrypi.h to raspberrypi.mojom Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: pipeline, ipa: raspberrypi: Use new data definition Now that we can generate custom functions and data structures with mojo, switch the raspberrypi pipeline handler and IPA to use the custom data structures as defined in the mojom data definition file. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: pipeline, ipa: vimc: Support the new IPC mechanism Add support to vimc pipeline handler and IPA for the new IPC mechanism. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> --- libcamera: pipeline, ipa: rkisp1: Support the new IPC mechanism Add support to the rkisp1 pipeline handler and IPA for the new IPC mechanism. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- libcamera: pipeline, ipa: ipu3: Support the new IPC mechanism Add support to ipu3 pipeline handler and IPA for the new IPC mechanism. [Original version] Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> [Fixed commit message and small changes] Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-16libcamera: pipeline: rkisp1: configure IPA from configure method instead of ↵Dafna Hirschfeld
start method Currently the call to the configure method of rkisp1 IPA is called upon the 'start' of the pipeline. This should be done in the 'configure' method instead. Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
2021-02-09pipeline: raspberrypi: Set the ISP Output1 to 1/4 resolution if unusedNaushir Patuck
In preparation for fast colour denoise, set the low resolution ISP output stream (Output1) to a 1/4 resolution of the application requested stream (Output0). This only happens if the application has not requested an additional YUV or RGB stream. We also constrain this 1/4 resolution to at most 1200 pixels in the largest dimension to avoid being too taxing on memory usage and system bandwidth. Also switch the default StreamRole::VideoRecording to YUV420 to allow fast colour denoise to run. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-09pipeline: raspberrypi: Refactor stream configuration routineNaushir Patuck
Refactor the high/low resolution stream format and output selection routine. This change is in preparation of adding 1/4 resolution output for fast colour denoise. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-08libcamera: ipu3: Get request from information structure instead of bufferNiklas Söderlund
Buffers dequeued from the ImgU may not be associated with a Request as they are internal (statistics, parameters and some RAW buffers). Fetch the request they are used for from the frame information instead. Fixes: 9708f49fecf2f9ee ("libcamera: ipu3: Share parameter and statistic buffers with IPA") Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05libcamera: ipu3: Fix RAW sizes selectionJacopo Mondi
Commit 7208e70211a6 ("libcamera: ipu3: Always use sensor full frame size") changed the CIO2 configuration procedure to always select the full sensor resolution to work around an ImgU configuration issue, as reported in the todo item introduced in said commit. When capturing a RAW stream only and the ImgU is not involved, the CIO2 has to be configured with the requested stream size to avoid adjusting the stream to the sensor resolution. As an example, capturing a raw frame smaller than the sensor resolution with this patch applied results in the stream configuration to be correctly assigned. $ cam -c1 -swidth=1056,height=784,role=raw ipu3.cpp:207 CIO2 configuration: 1056x784-SGRBG10_IPU3 ipu3.cpp:222 Validating stream: 1056x784-SGRBG10_IPU3 ipu3.cpp:233 Assigned 1056x784-SGRBG10_IPU3 to the raw stream Without this patch the same operation results in the stream resolution to be adjusted to the sensor resolution. $ cam -c1 -swidth=1056,height=784,role=raw ipu3.cpp:201 CIO2 configuration: 4224x3136-SGRBG10_IPU3 ipu3.cpp:216 Validating stream: 1056x784-SGRBG10_IPU3 ipu3.cpp:227 Assigned 4224x3136-SGRBG10_IPU3 to the raw stream ipu3.cpp:297 Stream 0 configuration adjusted to 4224x3136-SGRBG10_IPU3 Camera configuration adjusted Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-05libcamera: ipu3: Always report crop regionJacopo Mondi
Report the crop region for every completed request. The crop region is initialized as the sensor's analogue crop rectangle and updated when a Request with a new region completes. Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-05libcamera: ipu3: Share parameter and statistic buffers with IPANiklas Söderlund
Use the IPU3Frames helper to share parameters and statistics buffers with the IPA. Track which parameter and statistic buffer is used for which request and make sure the parameter buffers is filled in by the IPA before it's needed and that the statistic buffer is consumed and meta data generated before completing the request. With this change the IPU3 pipeline is prepared to fully operate with an IPA component. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05libcamera: ipu3: Add helper for parameter and statistic buffersNiklas Söderlund
Add a helper class to aid in associating a parameter and statistic buffer with each request queued to the pipeline. The helper helps with tracking the state of the extra buffers and in completing the request once all extra processing is done. This change only adds the helper more work is needed to integrate it with the pipeline and an IPA. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05libcamera: ipu3: Map buffers in IPANiklas Söderlund
Map and unmap the parameters and statistic buffers in the IPA when the pipeline handler allocates and frees the buffers. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05libcamera: ipu3: imgu: Allocate buffers for stats and paramNiklas Söderlund
Instead of preparing for buffer importing allocate buffers that can be used by an IPA. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05libcamera: ipu3: Attach to an IPA and allow it to set sensor controlsNiklas Söderlund
Attach to the IPA and allow it to push V4L2 controls that apply to the camera sensor. The IPA is not fully integrated in the pipeline as statistics and parameters buffers are not yet allocated, processed by the IPA nor queued to the hardware. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05libcamera: ipu3: cio2: Generate start of frame eventNiklas Söderlund
Propagate the frameStart event whenever the CSI-2 receiver in the CIO2 pipeline generates one. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05libcamera: ipu3: cio2: Return the FrameBuffer pointer usedNiklas Söderlund
When adding IPA plumbing to the IPU3 pipeline handler it will be needed to track which raw buffer was queued to the CIO2 for a specific request. Currently if using an internally allocated raw buffer the FrameBuffer is not exposed outside the CIO2Device as it was not needed. Prepare for the IPA by exposing which internal raw buffer is picked for each request, later changes will associate this with a Request. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05libcamera: ipu3: imgu: Add parameters video deviceNiklas Söderlund
Add the parameters video device to the data structure of the ImgUDevice. Even if the video device is configured, prepared to import buffers and started no buffers are ever queued to it so it does not yet effect the capture. Nor is does this change hinder the current capture mode to function. This is done in preparation to attach an IPA to the IPU3 pipeline. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05libcamera: ipu3: imgu: Configure the stat video device as part of configure()Niklas Söderlund
There is no reason to expose and call a separate configureStat() when the statistics video device can be configured with the exact same parameters as part of configure(). Move the configuration internally to the ImgUDevice simplifying the interface, there is no functional change. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-02-05libcamera: pipeline: raspberrypi: Always save sensor params on ↵Naushir Patuck
IPA_RESULT_SENSOR_PARAMS Fixup logic when handling IPA_RESULT_SENSOR_PARAMS where we must always overwrite the parameters if provided by IPA. In the current codebase, this only happens once on startup, so there is no effective functional difference. But this change allows the option for the IPA to request new sensor parameters per-mode if required. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-05ipa: raspberrypi: Rename RPi::ConfigParameters enum valuesNaushir Patuck
Rename the enum values to indicate pipeline handler -> IPA actions (IPA_CONFIG_*) and IPA -> pipeline handler return results (IPA_RESULT_*). Additionally, provide more descriptive names for these values. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-04libcamera: bayer_format: Add the fromV4L2PixelFormat functionSebastian Fricke
Add a static member function to get the corresponding BayerFormat from a given V4L2PixelFormat. The motivation behind this patch is to align the overall structure of the BayerFormat class with other parts of the code base, such as the V4L2PixelFormat class. The downside of this change is a slightly worse time complexity, but the upside is a smaller codebase and lower memory consumption. As the function is probably not used very frequently, I tend to favor the mentioned upsides. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Sebastian Fricke <sebastian.fricke@posteo.net> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-02-02libcamera: ipu3: cio2: Fix line breakJacopo Mondi
The function declaration fits on one line. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-29libcamera: pipeline: rkisp1: Avoid race when processing parameter buffersNiklas Söderlund
When moving the pipeline away from the Timeline design it was discovered that the design of queuing the buffers to the device as soon as possible was not the best idea. The parameter buffers were queued to the device before the IPA had processed them and this violates the V4L2 API. Fix this by waiting to queue any buffer to the device until the IPA has filled in the parameters buffer. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Tested-by: Sebastian Fricke <sebastian.fricke@posteo.net> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-01-29libcamera: pipeline: rkisp1: Remove TimelineNiklas Söderlund
There are no users left of the Timeline and there is no longer a need to keep emulating a start of exposure event as the CSI-2 resciver reports it. Remove the Timeline helper and what's left of it's integration in the pipeline. There is no functional change as nothing i the pipeline uses the Timeline. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-01-29libcamera: pipeline: rkisp1: Use SOF event to warn about late parametersNiklas Söderlund
In the Timeline approach the idea was to delay queuing buffers to the device until the IPA had a chance to prepare the parameters buffer. A check was still added to warn if the IPA queued buffers before the parameters buffer was filled in. This check happened much sooner then needed as the parameter buffers does not have to be ready when the buffer is queued but just before it's consumed. As the pipeline now has true knowledge of each SOF we can move the check there and remove the delaying of queuing of buffers. This change really speeds up the IPA reactions as the delays used in the Timeline where approximated while with this change they are driven by events reported by the device. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-29libcamera: pipeline: rkisp1: Use delayed controlsNiklas Söderlund
Instead of setting controls using the RkISP1 local Timeline helper use the DelayedControls. The result is the same, the controls are applied with a delay. The values of the delays are however different between the two methods. The values used in the Timeline solution were chosen after some experimentation and the values used in DelayedControls are taken from a generic sensor. None of the two are a perfect match as the delays can be different for different sensors used with the pipeline. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-01-29libcamera: raspberrypi: Remove StaggeredCtrlNiklas Söderlund
There are no users left, remove it. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
2021-01-29libcamera: raspberrypi: Switch to DelayedControlsNiklas Söderlund
Use the libcamera core helper DelayedControls instead of the local StaggeredCtrl. The new helper is modeled after the StaggeredCtrl implementation and behaves the same. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-01-25libcamera: ipu3: Report ScalerCrop in metadataJacopo Mondi
Report in the Request metadata the scaler crop region as requested by application through the request controls. No actual scaling is applied in the pipeline at the moment. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-25libcamera: ipu3: Register ScalerCrop controlJacopo Mondi
Register the ScalerCrop control in the ImgU pipeline handler computed by using the Viewfinder [1280x720] pipeline output configuration and the sensor resolution as parameters. The ScalerCrop control limits should be updated every time a new configuration is applied to the sensor. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>