| Message ID | 20251103140325.88535-3-antoine.bouyer@nxp.com |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
Hi 2025. 11. 03. 15:03 keltezéssel, Antoine Bouyer írta: > From: Andrei Gansari <andrei.gansari@nxp.com> > > Fixes behavior when calling 'cam -l' during a live stream from a camera > in another process. > > Issue is that multiple process should be able to list (match procedure) > the camera supported. But only the unique process that lock the media > devices in order to be able to configure then start the pipeline should > setup the routes, graphs, etc. > > Thus, the setRouting() is to be moved to a PipelineHandlerISI::acquireDevice() > implementation to override the default Pipeline::acquireDevice() function. > > Fixes: 92df79112fb2 ("pipeline: imx8-isi: Add multicamera support") > Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com> > Signed-off-by: Antoine Bouyer <antoine.bouyer@nxp.com> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > --- > src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 30 ++++++++++++++++---- > 1 file changed, 24 insertions(+), 6 deletions(-) > > diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp > index de09431cb9b9..91541505e3ae 100644 > --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp > +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp > @@ -71,6 +71,8 @@ public: > > unsigned int xbarSink_ = 0; > unsigned int xbarSourceOffset_ = 0; > + > + const std::string &cameraName() const { return sensor_->entity()->name(); } > }; > > class ISICameraConfiguration : public CameraConfiguration > @@ -117,6 +119,8 @@ protected: > > int queueRequestDevice(Camera *camera, Request *request) override; > > + bool acquireDevice(Camera *camera) override; > + > private: > static constexpr Size kPreviewSize = { 1920, 1080 }; > static constexpr Size kMinISISize = { 1, 1 }; > @@ -143,6 +147,8 @@ private: > > std::unique_ptr<V4L2Subdevice> crossbar_; > std::vector<Pipe> pipes_; > + > + V4L2Subdevice::Routing routing_ = {}; > }; > > /* ----------------------------------------------------------------------------- > @@ -950,6 +956,23 @@ int PipelineHandlerISI::queueRequestDevice(Camera *camera, Request *request) > return 0; > } > > +bool PipelineHandlerISI::acquireDevice(Camera *camera) > +{ > + ISICameraData *data = cameraData(camera); > + > + LOG(ISI, Debug) << "acquireDevice " << data->cameraName() > + << " count " << useCount(); I think this should be moved into `PipelineHandler::acquire()` if you want to log this. I suppose it probably makes sense to add a similar message to `PipelineHandler::release()` as well. > + > + if (useCount() == 0) { > + /* Enable routing for all available sensors once */ > + int ret = crossbar_->setRouting(&routing_, V4L2Subdevice::ActiveFormat); > + if (ret) > + return false; > + } > + > + return true; > +} > [...] Regards, Barnabás Pőcze
diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp index de09431cb9b9..91541505e3ae 100644 --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp @@ -71,6 +71,8 @@ public: unsigned int xbarSink_ = 0; unsigned int xbarSourceOffset_ = 0; + + const std::string &cameraName() const { return sensor_->entity()->name(); } }; class ISICameraConfiguration : public CameraConfiguration @@ -117,6 +119,8 @@ protected: int queueRequestDevice(Camera *camera, Request *request) override; + bool acquireDevice(Camera *camera) override; + private: static constexpr Size kPreviewSize = { 1920, 1080 }; static constexpr Size kMinISISize = { 1, 1 }; @@ -143,6 +147,8 @@ private: std::unique_ptr<V4L2Subdevice> crossbar_; std::vector<Pipe> pipes_; + + V4L2Subdevice::Routing routing_ = {}; }; /* ----------------------------------------------------------------------------- @@ -950,6 +956,23 @@ int PipelineHandlerISI::queueRequestDevice(Camera *camera, Request *request) return 0; } +bool PipelineHandlerISI::acquireDevice(Camera *camera) +{ + ISICameraData *data = cameraData(camera); + + LOG(ISI, Debug) << "acquireDevice " << data->cameraName() + << " count " << useCount(); + + if (useCount() == 0) { + /* Enable routing for all available sensors once */ + int ret = crossbar_->setRouting(&routing_, V4L2Subdevice::ActiveFormat); + if (ret) + return false; + } + + return true; +} + bool PipelineHandlerISI::match(DeviceEnumerator *enumerator) { DeviceMatch dm("mxc-isi"); @@ -1034,7 +1057,6 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator) unsigned int numSinks = 0; const unsigned int xbarFirstSource = crossbar_->entity()->pads().size() - pipes_.size(); const unsigned int maxStreams = pipes_.size() / cameraCount; - V4L2Subdevice::Routing routing = {}; for (MediaPad *pad : crossbar_->entity()->pads()) { unsigned int sink = numSinks; @@ -1104,7 +1126,7 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator) /* Add routes to the crossbar switch routing table. */ for (unsigned i = 0; i < data->streams_.size(); i++) { unsigned int sourcePad = xbarFirstSource + data->xbarSourceOffset_ + i; - routing.emplace_back(V4L2Subdevice::Stream{ data->xbarSink_, 0 }, + routing_.emplace_back(V4L2Subdevice::Stream{ data->xbarSink_, 0 }, V4L2Subdevice::Stream{ sourcePad, 0 }, V4L2_SUBDEV_ROUTE_FL_ACTIVE); } @@ -1116,10 +1138,6 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator) numCameras++; } - ret = crossbar_->setRouting(&routing, V4L2Subdevice::ActiveFormat); - if (ret) - return false; - return numCameras > 0; }