[libcamera-devel] [PATCH 1/2] pipeline: raspberrypi: Avoid multiple opens of Unicam embedded data node
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Sat Mar 13 21:05:16 CET 2021
Hi Naush,
Thank you for the patch.
On Sat, Mar 13, 2021 at 10:27:40AM +0000, Naushir Patuck wrote:
> It is possible for the application to call pipeline_handler::configure()
> multiple times, which would attempt to open the Unicam embedded data
> node on every call. This would cause a warning message as the node
> would have already been opened. Avoid this by tracking if the node
> has previously been opened.
>
> Note that this is a temporary fix since the open call for the Unicam
> embedded data node will be moved from pipeline_handler::configure() to
> pipeline_handler::match().
>
> Signed-off-by: Naushir Patuck <naush at raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Especially as it's temporary :-)
> ---
> src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> index 41f1cbffa931..9847e926b048 100644
> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> @@ -138,7 +138,7 @@ class RPiCameraData : public CameraData
> {
> public:
> RPiCameraData(PipelineHandler *pipe)
> - : CameraData(pipe), state_(State::Stopped),
> + : CameraData(pipe), embeddedNodeOpened_(false), state_(State::Stopped),
> supportsFlips_(false), flipsAlterBayerOrder_(false),
> updateScalerCrop_(true), dropFrameCount_(0), ispOutputCount_(0)
> {
> @@ -183,6 +183,7 @@ public:
>
> std::unique_ptr<DelayedControls> delayedCtrls_;
> bool sensorMetadata_;
> + bool embeddedNodeOpened_;
>
> /*
> * All the functions in this class are called from a single calling
> @@ -726,8 +727,13 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)
> if (data->sensorMetadata_) {
> format = {};
> format.fourcc = V4L2PixelFormat(V4L2_META_FMT_SENSOR_DATA);
> +
> + if (!data->embeddedNodeOpened_) {
> + data->unicam_[Unicam::Embedded].dev()->open();
> + data->embeddedNodeOpened_ = true;
> + }
> +
> LOG(RPI, Debug) << "Setting embedded data format.";
> - data->unicam_[Unicam::Embedded].dev()->open();
> ret = data->unicam_[Unicam::Embedded].dev()->setFormat(&format);
> if (ret) {
> LOG(RPI, Error) << "Failed to set format on Unicam embedded: "
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list