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

Message ID 20230806180136.304156-3-andrey.konovalov@linaro.org
State New
Headers show
Series
  • libcamera: converter: introduce software converter for debayering and AWB
Related show

Commit Message

Andrey Konovalov Aug. 6, 2023, 6:01 p.m. UTC
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@linaro.org>
---
 src/libcamera/pipeline/simple/simple.cpp | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

Patch
diff mbox series

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_) {