pipeline: raspberrypi: Avoid multiple opens of Unicam embedded data node

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@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Naushir Patuck 2021-03-13 10:27:40 +00:00 committed by Laurent Pinchart
parent 1be6803924
commit cd3f70a14c

View file

@ -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: "