[libcamera-devel] [PATCH 13/13] libcamera: pipeline: rkisp1: Expose self path stream

Niklas Söderlund niklas.soderlund at ragnatech.se
Thu Aug 13 02:52:46 CEST 2020


Expose the self stream to applications and prefers it for the viewfinder
and video roles as it can produce RGB. Keep preferring the main path for
still capture as it could be extended to support RAW formats which makes
most sens for still capture.

With this change the self path becomes available to applications and a
camera backed by this pipeline can produce two streams simultaneously.

Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
---
 src/libcamera/pipeline/rkisp1/rkisp1.cpp | 44 ++++++++++++++++++------
 1 file changed, 34 insertions(+), 10 deletions(-)

diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index f106b105a47bb4f7..0ab235d80f6c677e 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -729,17 +729,38 @@ CameraConfiguration *PipelineHandlerRkISP1::generateConfiguration(Camera *camera
 	if (roles.empty())
 		return config;
 
-	std::map<PixelFormat, std::vector<SizeRange>> streamFormats;
-	for (const PixelFormat &format : RKISP1_RSZ_MP_FORMATS)
-		streamFormats[format] =
-			{ { RKISP1_RSZ_MP_SRC_MIN, RKISP1_RSZ_MP_SRC_MAX } };
+	for (const StreamRole role : roles) {
+		std::map<PixelFormat, std::vector<SizeRange>> streamFormats;
 
-	StreamFormats formats(streamFormats);
-	StreamConfiguration cfg(formats);
-	cfg.pixelFormat = formats::NV12;
-	cfg.size = data->sensor_->resolution();
+		switch (role) {
+		case StreamRole::StillCapture: {
+			for (const PixelFormat &format : RKISP1_RSZ_MP_FORMATS)
+				streamFormats[format] =
+					{ { RKISP1_RSZ_MP_SRC_MIN, RKISP1_RSZ_MP_SRC_MAX } };
+			break;
+		}
+		case StreamRole::Viewfinder:
+		case StreamRole::VideoRecording: {
+			for (const PixelFormat &format : RKISP1_RSZ_SP_FORMATS)
+				streamFormats[format] =
+					{ { RKISP1_RSZ_SP_SRC_MIN, RKISP1_RSZ_SP_SRC_MAX } };
+			break;
+		}
+		default:
+			LOG(RkISP1, Warning)
+				<< "Requested stream role not supported: " << role;
+			delete config;
+			return nullptr;
+		}
 
-	config->addConfiguration(cfg);
+		StreamFormats formats(streamFormats);
+		StreamConfiguration cfg(formats);
+		cfg.pixelFormat = formats::NV12;
+		cfg.size = data->sensor_->resolution();
+		cfg.bufferCount = 4;
+
+		config->addConfiguration(cfg);
+	}
 
 	config->validate();
 
@@ -1214,7 +1235,10 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor)
 	if (ret)
 		return ret;
 
-	std::set<Stream *> streams{ &data->mainPathStream_ };
+	std::set<Stream *> streams{
+		&data->mainPathStream_,
+		&data->selfPathStream_,
+	};
 	std::shared_ptr<Camera> camera =
 		Camera::create(this, data->sensor_->id(), streams);
 	registerCamera(std::move(camera), std::move(data));
-- 
2.28.0



More information about the libcamera-devel mailing list