From patchwork Fri Oct 25 03:20:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2217 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AB6CD61374 for ; Fri, 25 Oct 2019 05:20:27 +0200 (CEST) Received: from pendragon.ideasonboard.com (143.121.2.93.rev.sfr.net [93.2.121.143]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3D01233A for ; Fri, 25 Oct 2019 05:20:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1571973627; bh=AM8bjA52l47ee9vSJVP+8sooVCU3lBFZ+wWrDlKceME=; h=From:To:Subject:Date:From; b=Cz07JIVBhDq5CKknsuwbi1rPo6vElv7sKkWQkdTkI8QN5/e8L6hax6sKQ4jskBXuY gNUglRgxF07XXjNvoz3F01EgeRlWQBotad8g5MsprgKxwMr3PDYmeD5jBnNGxLSPSn mIuBGoh27z/48RazhXosqq3KKz4xXPKzVmHK8JWk= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 25 Oct 2019 06:20:16 +0300 Message-Id: <20191025032016.18904-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: pipeline: vimc: Support format enumeration X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 03:20:27 -0000 Fill the StreamConfiguration with all supported formats. The list of supported formats is currently hardcoded based on the limits of the vimc driver. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- src/libcamera/pipeline/vimc.cpp | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index dcdaef120ad1..c16ae4cb76b5 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -103,6 +103,16 @@ private: } }; +namespace { + +constexpr std::array pixelformats{ + V4L2_PIX_FMT_BGR24, + V4L2_PIX_FMT_RGB24, + V4L2_PIX_FMT_ARGB32, +}; + +} /* namespace */ + VimcCameraConfiguration::VimcCameraConfiguration() : CameraConfiguration() { @@ -110,12 +120,6 @@ VimcCameraConfiguration::VimcCameraConfiguration() CameraConfiguration::Status VimcCameraConfiguration::validate() { - static const std::array formats{ - V4L2_PIX_FMT_BGR24, - V4L2_PIX_FMT_RGB24, - V4L2_PIX_FMT_ARGB32, - }; - Status status = Valid; if (config_.empty()) @@ -130,8 +134,8 @@ CameraConfiguration::Status VimcCameraConfiguration::validate() StreamConfiguration &cfg = config_[0]; /* Adjust the pixel format. */ - if (std::find(formats.begin(), formats.end(), cfg.pixelFormat) == - formats.end()) { + if (std::find(pixelformats.begin(), pixelformats.end(), cfg.pixelFormat) == + pixelformats.end()) { LOG(VIMC, Debug) << "Adjusting format to RGB24"; cfg.pixelFormat = V4L2_PIX_FMT_RGB24; status = Adjusted; @@ -170,7 +174,18 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera, if (roles.empty()) return config; - StreamConfiguration cfg{}; + ImageFormats formats; + + for (unsigned int pixelformat : pixelformats) { + /* The scaler hardcodes a x3 scale-up ratio. */ + std::vector sizes{ + SizeRange{ 48, 48, 4096, 2160 } + }; + formats.addFormat(pixelformat, sizes); + } + + StreamConfiguration cfg(formats.data()); + cfg.pixelFormat = V4L2_PIX_FMT_RGB24; cfg.size = { 1920, 1080 }; cfg.bufferCount = 4;