summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2022-01-04 12:57:08 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2022-01-06 12:28:24 +0000
commit8400cb07117f1ebc51db2a66d9f62211a764a096 (patch)
tree9831db37a689b35f3f36c050bfa4c16a35a71263 /src
parentcd7863503ae91f477bbd883f35d9845172840349 (diff)
pipeline: raspberrypi: Move sensor entity detection out of registerCamera()
Enumerate the sensor device entities in PipelineHandlerRPi::match() and loop over PipelineHandlerRPi::registerCamera() for each sensor found. This will allow the pipeline handler to register multiple cameras attached to a single Unicam instance with a Video Mux device. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/pipeline/raspberrypi/raspberrypi.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index b5c687da..a6d1e857 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -312,7 +312,7 @@ private:
return static_cast<RPiCameraData *>(camera->_d());
}
- int registerCamera(MediaDevice *unicam, MediaDevice *isp);
+ int registerCamera(MediaDevice *unicam, MediaDevice *isp, MediaEntity *sensorEntity);
int queueAllBuffers(Camera *camera);
int prepareBuffers(Camera *camera);
void freeBuffers(Camera *camera);
@@ -1069,16 +1069,28 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator)
return false;
}
- int ret = registerCamera(unicamDevice, ispDevice);
- if (ret) {
- LOG(RPI, Error) << "Failed to register camera: " << ret;
- return false;
+ /*
+ * The loop below is used to register multiple cameras behind one or more
+ * video mux devices that are attached to a particular Unicam instance.
+ * Obviously these cameras cannot be used simultaneously.
+ */
+ unsigned int numCameras = 0;
+ for (MediaEntity *entity : unicamDevice->entities()) {
+ if (entity->function() != MEDIA_ENT_F_CAM_SENSOR)
+ continue;
+
+ int ret = registerCamera(unicamDevice, ispDevice, entity);
+ if (ret)
+ LOG(RPI, Error) << "Failed to register camera "
+ << entity->name() << ": " << ret;
+ else
+ numCameras++;
}
- return true;
+ return !!numCameras;
}
-int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp)
+int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, MediaEntity *sensorEntity)
{
std::unique_ptr<RPiCameraData> data = std::make_unique<RPiCameraData>(this);
@@ -1119,14 +1131,7 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp)
data->isp_[Isp::Output1].dev()->bufferReady.connect(data.get(), &RPiCameraData::ispOutputDequeue);
data->isp_[Isp::Stats].dev()->bufferReady.connect(data.get(), &RPiCameraData::ispOutputDequeue);
- /* Identify the sensor. */
- for (MediaEntity *entity : unicam->entities()) {
- if (entity->function() == MEDIA_ENT_F_CAM_SENSOR) {
- data->sensor_ = std::make_unique<CameraSensor>(entity);
- break;
- }
- }
-
+ data->sensor_ = std::make_unique<CameraSensor>(sensorEntity);
if (!data->sensor_)
return -EINVAL;