From patchwork Fri Jul 15 13:50:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 16640 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 E4905BE173 for ; Fri, 15 Jul 2022 13:50:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 77A1763313; Fri, 15 Jul 2022 15:50:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657893024; bh=c/6gB4SSC3yvs7YlwjXpTq0TLFezDfDgjJD+2CEst8M=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=q0C/tocOxbx/MOpkFI20lH5yYcoRA1e07+wlCUmF1hDTIAhaaL1X9LbSNREswxq12 t0LrOuU+Na5vBVIW2YzYhFYg4JtcnCeQe3hXxzRprg035BjVLTKZCZTod51EpD1P5x yuO3w8sY8IStbz1YnmEkimaFznqjjwted8wFqOKoB4mFfJljWzPtcufOBd6sM2w4iC 5QsDF9+TkMEB4yfmQSRyaKzdpkWMJvaziE0HotKhECY4S+0tFEu05p2dtczZRlxcbT Lknx/cCKwqInPaflXPukExUs53/bSnX1vShPlmiHCFkAdSuwoQYpCdpGraCDXYskIz JkLRAkZRMPEYA== Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C86D46330A for ; Fri, 15 Jul 2022 15:50:21 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id 9CEA86000A; Fri, 15 Jul 2022 13:50:20 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Fri, 15 Jul 2022 15:50:02 +0200 Message-Id: <20220715135007.53574-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220715135007.53574-1-jacopo@jmondi.org> References: <20220715135007.53574-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/7] libcamera: formats: Search PixelFormatInfo on multiple 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-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: jozef@mlich.cz, Pavel Machek Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The PixelFormatInfo::info(const V4L2PixelFormat &format) function returns the PixelFormatInfo associated with a V4L2 pixel format. As we prepare to associate multiple V4L2 formats to a single PixelFormatInfo rework the function to search the given V4L2 format in a list. Signed-off-by: Jacopo Mondi --- src/libcamera/formats.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index f7e9adc7ff77..86fc698a0f4e 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -994,10 +994,19 @@ const PixelFormatInfo &PixelFormatInfo::info(const PixelFormat &format) */ const PixelFormatInfo &PixelFormatInfo::info(const V4L2PixelFormat &format) { + auto matchFormats = [&format](const std::vector &formats) { + const auto &it = std::find_if(formats.begin(), formats.end(), + [&format](const V4L2PixelFormat &fmt) { + return format == fmt; + }); + + return it == formats.end() ? false : true; + }; + const auto &info = std::find_if(pixelFormatInfo.begin(), pixelFormatInfo.end(), - [format](auto pair) { - return pair.second.v4l2Formats.single[0] == format || - pair.second.v4l2Formats.multi[0] == format; + [&matchFormats](auto &pair) { + return matchFormats(pair.second.v4l2Formats.single) || + matchFormats(pair.second.v4l2Formats.multi); }); if (info == pixelFormatInfo.end()) return pixelFormatInfoInvalid;