From 921c0cdc6a0c486c9b53af5746b1cce6a2501b3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Thu, 13 Aug 2020 01:51:21 +0200 Subject: libcamera: pipeline: rkisp1: Expose self path stream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Expose the self stream to applications and prefers it for the viewfinder and video roles as it can be extended to produce RGB. Keep preferring the main path for still capture as it could be extended to support RAW formats which makes most sense 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 Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 63 ++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 11 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 8aae1697..acd946d1 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -710,21 +710,59 @@ CameraConfiguration *PipelineHandlerRkISP1::generateConfiguration(Camera *camera { RkISP1CameraData *data = cameraData(camera); CameraConfiguration *config = new RkISP1CameraConfiguration(camera, data); - if (roles.empty()) return config; - std::map> streamFormats; - for (const PixelFormat &format : RKISP1_RSZ_MP_FORMATS) - streamFormats[format] = - { { RKISP1_RSZ_MP_SRC_MIN, data->sensor_->resolution() } }; + bool mainPathAvailable = true; + bool selfPathAvailable = true; + for (const StreamRole role : roles) { + bool useMainPath; + + switch (role) { + case StreamRole::StillCapture: { + useMainPath = mainPathAvailable; + break; + } + case StreamRole::Viewfinder: + case StreamRole::VideoRecording: { + useMainPath = !selfPathAvailable; + break; + } + default: + LOG(RkISP1, Warning) + << "Requested stream role not supported: " << role; + delete config; + return nullptr; + } + + std::map> streamFormats; + Size maxResolution = data->sensor_->resolution(); + if (useMainPath) { + mainPathAvailable = false; + maxResolution.boundTo(RKISP1_RSZ_MP_SRC_MAX); + for (const PixelFormat &format : RKISP1_RSZ_MP_FORMATS) + streamFormats[format] = { { + RKISP1_RSZ_MP_SRC_MIN, + maxResolution, + } }; + } else { + selfPathAvailable = false; + maxResolution.boundTo(RKISP1_RSZ_SP_SRC_MAX); + for (const PixelFormat &format : RKISP1_RSZ_SP_FORMATS) + streamFormats[format] = { { + RKISP1_RSZ_SP_SRC_MIN, + maxResolution, + } }; + } - StreamFormats formats(streamFormats); - StreamConfiguration cfg(formats); - cfg.pixelFormat = formats::NV12; - cfg.size = data->sensor_->resolution(); + StreamFormats formats(streamFormats); + StreamConfiguration cfg(formats); + cfg.pixelFormat = formats::NV12; + cfg.size = maxResolution; + cfg.bufferCount = 4; - config->addConfiguration(cfg); + config->addConfiguration(cfg); + } config->validate(); @@ -1212,7 +1250,10 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor) if (ret) return ret; - std::set streams{ &data->mainPathStream_ }; + std::set streams{ + &data->mainPathStream_, + &data->selfPathStream_, + }; std::shared_ptr camera = Camera::create(this, data->sensor_->id(), streams); registerCamera(std::move(camera), std::move(data)); -- cgit v1.2.1