From patchwork Tue Jul 19 12:10:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 16688 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id BF615BE173 for ; Tue, 19 Jul 2022 12:10:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 80BD763316; Tue, 19 Jul 2022 14:10:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658232619; bh=vvfiO3dVc7gDxmenoyNqR0bmxkV4ZkX00sO8C3kTbeA=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=sPYeQZziu/yreZXRjVs8lwRvoZ6Sd6uCynmIXHDAlEJ0nSHN9rgLrfYtsSlvhfqUI 3beuOkHpe2fqa5fFh7L5fGRnTM/aqufoY1Kua/dT+KuYcV6/KlqAjq3dsjEn5PMovy +amxr2rKWJub/Y7dyHex6B8rs2lAL5rKbcYpqcjFF01BhcFK6zpb51/PuO6CtswWMb ommtrQiWQYpbkEowNTcHI6f5KV9GkQYBQaQ1dIj5BmHV/91RXscS4cyZ9LfeJZZajc Q76SRx41OqhJ/xbhgjSHnsDZT+mz08WcD8GXHaoUSsSCGvFNVO7Js3JH4qNV9Vv7E3 JK4tGP5TOaznA== 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 E4A686048A for ; Tue, 19 Jul 2022 14:10:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="RbTyibzR"; dkim-atps=neutral Received: from pyrite.rasen.tech (softbank036240121080.bbtec.net [36.240.121.80]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8A1C36EE; Tue, 19 Jul 2022 14:10:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1658232617; bh=vvfiO3dVc7gDxmenoyNqR0bmxkV4ZkX00sO8C3kTbeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RbTyibzRqmbyXysMO1R+I9TY90safXz/uBCGcdKnlhnf1K1ZaNPt7h288pYPaquUs E2fkrFLwTbxrArWDvTbd9q9CWU67WSfxvJ3rKPxPUkgXEDK/Zw6PnCvDxdujxxbv4I ap/2SZd3A9yWVqCY4Z8NxLkt4OhOODem5QPcTvG0= To: libcamera-devel@lists.libcamera.org Date: Tue, 19 Jul 2022 21:10:02 +0900 Message-Id: <20220719121003.1829916-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220719121003.1829916-1-paul.elder@ideasonboard.com> References: <20220719121003.1829916-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 1/2] libcamera: v4l2_videodevice: Get formats even if no framesizes 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-Patchwork-Original-From: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" V4L2VideoDevice::formats() returns an empty list of formats if enumSizes fails, including if the driver doesn't implement ENUM_FRAMESIZES. Add an optional ignoreSizes parameter to formats() so that it can still be used when the pipeline handler knows that its driver doesn't implement ENUM_FRAMESIZES. Signed-off-by: Paul Elder --- include/libcamera/internal/v4l2_videodevice.h | 2 +- src/libcamera/v4l2_videodevice.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h index 8525acbc..6cc9be85 100644 --- a/include/libcamera/internal/v4l2_videodevice.h +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -205,7 +205,7 @@ public: int getFormat(V4L2DeviceFormat *format); int tryFormat(V4L2DeviceFormat *format); int setFormat(V4L2DeviceFormat *format); - Formats formats(uint32_t code = 0); + Formats formats(uint32_t code = 0, bool ignoreSizes = false); int setSelection(unsigned int target, Rectangle *rect); diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 63911339..b8bd4bc4 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1045,14 +1045,18 @@ int V4L2VideoDevice::trySetFormatSingleplane(V4L2DeviceFormat *format, bool set) * * \return A list of the supported video device formats */ -V4L2VideoDevice::Formats V4L2VideoDevice::formats(uint32_t code) +V4L2VideoDevice::Formats V4L2VideoDevice::formats(uint32_t code, bool ignoreSizes) { Formats formats; for (V4L2PixelFormat pixelFormat : enumPixelformats(code)) { - std::vector sizes = enumSizes(pixelFormat); - if (sizes.empty()) - return {}; + std::vector sizes; + + if (!ignoreSizes) { + sizes = enumSizes(pixelFormat); + if (sizes.empty()) + return {}; + } if (formats.find(pixelFormat) != formats.end()) { LOG(V4L2, Error)