[libcamera-devel] [RFC PATCH 2/2] [DNI] libcamera: pipeline: simple: a hack to use sotware converter with qcom-camss

Andrey Konovalov andrey.konovalov at linaro.org
Sun Aug 6 20:01:36 CEST 2023


Quick and simple hack mostly to avoid calling acquireMediaDevice() for
a converter without a media device underneath.

ConverterFactoryBase::create() also relies on MediaDevice, so this
hack doesn't use it with the software converter for now.

Signed-off-by: Andrey Konovalov <andrey.konovalov at linaro.org>
---
 src/libcamera/pipeline/simple/simple.cpp | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
index 05ba76bc..e5c53003 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -37,6 +37,7 @@
 #include "libcamera/internal/v4l2_subdevice.h"
 #include "libcamera/internal/v4l2_videodevice.h"
 
+#include "libcamera/internal/converter/converter_softw.h"
 
 namespace libcamera {
 
@@ -194,7 +195,7 @@ static const SimplePipelineInfo supportedDevices[] = {
 	{ "imx7-csi", { { "pxp", 1 } } },
 	{ "j721e-csi2rx", {} },
 	{ "mxc-isi", {} },
-	{ "qcom-camss", {} },
+	{ "qcom-camss", { { "software", 1 } } },
 	{ "sun6i-csi", {} },
 };
 
@@ -359,6 +360,11 @@ private:
 	std::map<const MediaEntity *, EntityData> entities_;
 
 	MediaDevice *converter_;
+	// dummy function to force Converter to work w/o media device:
+	MediaDevice *acquireSoftwareConverter(const char *name)
+	{
+		return (new MediaDevice(name));
+	}
 };
 
 /* -----------------------------------------------------------------------------
@@ -497,7 +503,11 @@ int SimpleCameraData::init()
 	/* Open the converter, if any. */
 	MediaDevice *converter = pipe->converter();
 	if (converter) {
-		converter_ = ConverterFactoryBase::create(converter);
+		// hack to make Converter to work w/o media device underneath:
+		if (!converter->isValid() && converter->deviceNode() == "software")
+			converter_ = std::make_unique<SwConverter>(converter);
+		else
+			converter_ = ConverterFactoryBase::create(converter);
 		if (!converter_) {
 			LOG(SimplePipeline, Warning)
 				<< "Failed to create converter, disabling format conversion";
@@ -1410,6 +1420,14 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)
 		return false;
 
 	for (const auto &[name, streams] : info->converters) {
+		if (!strcmp(name, "software")) {
+			converter_ = acquireSoftwareConverter(name);
+			if (converter_) {
+				numStreams = streams;
+				break;
+			}
+		}
+
 		DeviceMatch converterMatch(name);
 		converter_ = acquireMediaDevice(enumerator, converterMatch);
 		if (converter_) {
-- 
2.34.1



More information about the libcamera-devel mailing list