From patchwork Thu Jun 4 09:04:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 3912 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EE075603C8 for ; Thu, 4 Jun 2020 11:04:30 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="L/G3OJqg"; dkim-atps=neutral Received: from Q.local (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 62C2F29B; Thu, 4 Jun 2020 11:04:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1591261470; bh=jXernnNrr7GegV0eKzuHSmXjDXPmYzaX0T4gHxfXt3w=; h=From:To:Cc:Subject:Date:From; b=L/G3OJqg6K4ELUB0DN1JeyryqTNbDzheYgC2R1PcXqqzdxCjlWxTSKAUYzjoovfQ7 9HOpd+3SEQ+afZ9V9EMFQXz2WImLXPPPMj3XB2tuep/Py6VonjB4L9K3sHSrH6Jqtu 0B+UgpojtiVoJT3hmLRNlKhe4lpvAqQFIQcaoVug= From: Kieran Bingham To: libcamera devel Date: Thu, 4 Jun 2020 10:04:27 +0100 Message-Id: <20200604090427.3779613-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] libcamera: pipeline: vimc: Skip unsupported formats 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: Thu, 04 Jun 2020 09:04:31 -0000 Older kernels do not support all 'reported' formats. Skip them on those kernels. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- v2: - Remove todo, and confirm the kernel version. - Adjust validate() to reference the available formats in the configuration. src/libcamera/pipeline/vimc/vimc.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 68d65bc785b0..914df3476eb9 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -136,8 +136,9 @@ CameraConfiguration::Status VimcCameraConfiguration::validate() StreamConfiguration &cfg = config_[0]; /* Adjust the pixel format. */ - if (pixelformats.find(cfg.pixelFormat) == pixelformats.end()) { - LOG(VIMC, Debug) << "Adjusting format to RGB24"; + const std::vector formats = cfg.formats().pixelformats(); + if (std::find(formats.begin(), formats.end(), cfg.pixelFormat) == formats.end()) { + LOG(VIMC, Debug) << "Adjusting format to BGR888"; cfg.pixelFormat = PixelFormat(DRM_FORMAT_BGR888); status = Adjusted; } @@ -171,6 +172,7 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera, const StreamRoles &roles) { CameraConfiguration *config = new VimcCameraConfiguration(); + VimcCameraData *data = cameraData(camera); if (roles.empty()) return config; @@ -178,6 +180,19 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera, std::map> formats; for (const auto &pixelformat : pixelformats) { + /* + * Kernels previous to v5.7 incorrectly report support for + * RGB888, but it isn't functional within the pipeline. + */ + if (data->media_->version() < KERNEL_VERSION(5, 7, 0)) { + if (pixelformat.first != PixelFormat(DRM_FORMAT_BGR888)) { + LOG(VIMC, Info) + << "Skipping unsupported pixel format " + << pixelformat.first.toString(); + continue; + } + } + /* The scaler hardcodes a x3 scale-up ratio. */ std::vector sizes{ SizeRange{ { 48, 48 }, { 4096, 2160 } }