From df2af09050514c64c4af8cef0581423a705490af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Thu, 24 Sep 2020 21:35:54 +0200 Subject: libcamera: pipeline: rkisp1: Move path configuration to RkISP1Path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the path configuration to RkISP1Path to increase code reuse and make the V4L2 subdevice resizer private to the path. There is no functional change. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 55 ++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) (limited to 'src/libcamera/pipeline/rkisp1/rkisp1_path.cpp') diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp index 2eae4234..66b5eebd 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp @@ -7,14 +7,18 @@ #include "rkisp1_path.h" +#include + #include "libcamera/internal/media_device.h" #include "libcamera/internal/v4l2_subdevice.h" #include "libcamera/internal/v4l2_videodevice.h" namespace libcamera { +LOG_DECLARE_CATEGORY(RkISP1) + RkISP1Path::RkISP1Path(const char *name) - : resizer_(nullptr), video_(nullptr), name_(name) + : video_(nullptr), name_(name), resizer_(nullptr) { } @@ -40,6 +44,55 @@ bool RkISP1Path::init(MediaDevice *media) return true; } +int RkISP1Path::configure(const StreamConfiguration &config, + const V4L2SubdeviceFormat &inputFormat) +{ + int ret; + + V4L2SubdeviceFormat ispFormat = inputFormat; + + ret = resizer_->setFormat(0, &ispFormat); + if (ret < 0) + return ret; + + LOG(RkISP1, Debug) + << "Configured " << name_ << " resizer input pad with " + << ispFormat.toString(); + + ispFormat.size = config.size; + + LOG(RkISP1, Debug) + << "Configuring " << name_ << " resizer output pad with " + << ispFormat.toString(); + + ret = resizer_->setFormat(1, &ispFormat); + if (ret < 0) + return ret; + + LOG(RkISP1, Debug) + << "Configured " << name_ << " resizer output pad with " + << ispFormat.toString(); + + const PixelFormatInfo &info = PixelFormatInfo::info(config.pixelFormat); + V4L2DeviceFormat outputFormat = {}; + outputFormat.fourcc = video_->toV4L2PixelFormat(config.pixelFormat); + outputFormat.size = config.size; + outputFormat.planesCount = info.numPlanes(); + + ret = video_->setFormat(&outputFormat); + if (ret) + return ret; + + if (outputFormat.size != config.size || + outputFormat.fourcc != video_->toV4L2PixelFormat(config.pixelFormat)) { + LOG(RkISP1, Error) + << "Unable to configure capture in " << config.toString(); + return -EINVAL; + } + + return 0; +} + RkISP1MainPath::RkISP1MainPath() : RkISP1Path("main") { -- cgit v1.2.1