From e260513f5208e5f4641a4c2587003f17b2811029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Fri, 24 Jul 2020 14:01:46 +0200 Subject: libcamera: pipeline: rkisp1: Breakout mainpath size and format constraints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Breakout the mainpath size and format constrains as it will be used in more places then just validate(). While at it use the new helpers to validate Size. Signed-off-by: Niklas Söderlund Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 34 ++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'src/libcamera/pipeline/rkisp1/rkisp1.cpp') diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 77a48106..a5b6bb07 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -37,6 +37,21 @@ namespace libcamera { LOG_DEFINE_CATEGORY(RkISP1) +namespace { +constexpr Size RKISP1_RSZ_MP_SRC_MIN{ 32, 16 }; +constexpr Size RKISP1_RSZ_MP_SRC_MAX{ 4416, 3312 }; +constexpr std::array RKISP1_RSZ_MP_FORMATS{ + formats::YUYV, + formats::YVYU, + formats::VYUY, + formats::NV16, + formats::NV61, + formats::NV21, + formats::NV12, + /* \todo Add support for 8-bit greyscale to DRM formats */ +}; +} /* namespace */ + class PipelineHandlerRkISP1; class RkISP1ActionQueueBuffers; @@ -456,17 +471,6 @@ RkISP1CameraConfiguration::RkISP1CameraConfiguration(Camera *camera, CameraConfiguration::Status RkISP1CameraConfiguration::validate() { - static const std::array formats{ - formats::YUYV, - formats::YVYU, - formats::VYUY, - formats::NV16, - formats::NV61, - formats::NV21, - formats::NV12, - /* \todo Add support for 8-bit greyscale to DRM formats */ - }; - const CameraSensor *sensor = data_->sensor_; Status status = Valid; @@ -482,8 +486,8 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate() StreamConfiguration &cfg = config_[0]; /* Adjust the pixel format. */ - if (std::find(formats.begin(), formats.end(), cfg.pixelFormat) == - formats.end()) { + if (std::find(RKISP1_RSZ_MP_FORMATS.begin(), RKISP1_RSZ_MP_FORMATS.end(), + cfg.pixelFormat) == RKISP1_RSZ_MP_FORMATS.end()) { LOG(RkISP1, Debug) << "Adjusting format to NV12"; cfg.pixelFormat = formats::NV12, status = Adjusted; @@ -520,8 +524,8 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate() / sensorFormat_.size.width; } - cfg.size.width = std::max(32U, std::min(4416U, cfg.size.width)); - cfg.size.height = std::max(16U, std::min(3312U, cfg.size.height)); + cfg.size.boundTo(RKISP1_RSZ_MP_SRC_MAX); + cfg.size.expandTo(RKISP1_RSZ_MP_SRC_MIN); if (cfg.size != size) { LOG(RkISP1, Debug) -- cgit v1.2.1