[libcamera-devel,v5,11/11] pipeline: raspberrypi: Account for a missing Unicam embedded data node
diff mbox series

Message ID 20211101091510.23204-12-naush@raspberrypi.com
State Accepted
Commit 460da2b58069acd88c7eed98f0d9662bc353bea6
Headers show
Series
  • Raspberry Pi: Conversion to media controller
Related show

Commit Message

Naushir Patuck Nov. 1, 2021, 9:15 a.m. UTC
The unicam driver no longer registers an embedded data node if the sensor does
not provide this stream. Account for this in the pipeline handler match routine
by not assuming it is always present.

Add a warning if Unicam and the CamHelper do not agree on the presense of sensor
embedded data, and disable its usage in these cases.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 .../pipeline/raspberrypi/raspberrypi.cpp       | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index 996743cf48ef..44760093f7ab 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -995,7 +995,6 @@  bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator)
 	DeviceMatch unicam("unicam");
 	DeviceMatch isp("bcm2835-isp");
 
-	unicam.add("unicam-embedded");
 	unicam.add("unicam-image");
 
 	isp.add("bcm2835-isp0-output0"); /* Input */
@@ -1016,9 +1015,16 @@  bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator)
 		return false;
 
 	/* Locate and open the unicam video streams. */
-	data->unicam_[Unicam::Embedded] = RPi::Stream("Unicam Embedded", unicam_->getEntityByName("unicam-embedded"));
 	data->unicam_[Unicam::Image] = RPi::Stream("Unicam Image", unicam_->getEntityByName("unicam-image"));
 
+	/* An embedded data node will not be present if the sensor does not support it. */
+	MediaEntity *embeddedEntity = unicam_->getEntityByName("unicam-embedded");
+	if (embeddedEntity) {
+		data->unicam_[Unicam::Embedded] = RPi::Stream("Unicam Embedded", embeddedEntity);
+		data->unicam_[Unicam::Embedded].dev()->bufferReady.connect(data.get(),
+									   &RPiCameraData::unicamBufferDequeue);
+	}
+
 	/* Tag the ISP input stream as an import stream. */
 	data->isp_[Isp::Input] = RPi::Stream("ISP Input", isp_->getEntityByName("bcm2835-isp0-output0"), true);
 	data->isp_[Isp::Output0] = RPi::Stream("ISP Output0", isp_->getEntityByName("bcm2835-isp0-capture1"));
@@ -1028,7 +1034,6 @@  bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator)
 	/* Wire up all the buffer connections. */
 	data->unicam_[Unicam::Image].dev()->frameStart.connect(data.get(), &RPiCameraData::frameStarted);
 	data->unicam_[Unicam::Image].dev()->bufferReady.connect(data.get(), &RPiCameraData::unicamBufferDequeue);
-	data->unicam_[Unicam::Embedded].dev()->bufferReady.connect(data.get(), &RPiCameraData::unicamBufferDequeue);
 	data->isp_[Isp::Input].dev()->bufferReady.connect(data.get(), &RPiCameraData::ispInputDequeue);
 	data->isp_[Isp::Output0].dev()->bufferReady.connect(data.get(), &RPiCameraData::ispOutputDequeue);
 	data->isp_[Isp::Output1].dev()->bufferReady.connect(data.get(), &RPiCameraData::ispOutputDequeue);
@@ -1056,6 +1061,13 @@  bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator)
 		return false;
 	}
 
+	if (sensorConfig.sensorMetadata ^ !!embeddedEntity) {
+		LOG(RPI, Warning) << "Mismatch between Unicam and CamHelper for embedded data usage!";
+		sensorConfig.sensorMetadata = false;
+		if (embeddedEntity)
+			data->unicam_[Unicam::Embedded].dev()->bufferReady.disconnect();
+	}
+
 	/*
 	 * Open all Unicam and ISP streams. The exception is the embedded data
 	 * stream, which only gets opened below if the IPA reports that the sensor