From patchwork Fri Jul 29 16:00:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 16871 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 771D4C3275 for ; Fri, 29 Jul 2022 16:00:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3331763311; Fri, 29 Jul 2022 18:00:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659110429; bh=PvdhqUVPD0MXc/Hi+kBKdnqskrwvRs8ReQgM5OnNk9w=; 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=3HL0xPjD5i+sP4l6NP5S53LYw+WyRNcbARZnSd7gqF6sXnz6dQol+uN80sGkxzGd3 zpFn6SL00hIFK+cxha15lRcKioUGz4dqWK+sRIBWGlJCI9pOqmY1e6JMfIE8FhTUMa Dj7B6fnjboyVi2NAFHhVJdRmdB/HgFDA73PIHqRNBd6l044OpWefv3Xr+tQnFNN+d0 HTmOoWya6uTujYEPPRK/XD2H1Bz0fMiWrkcaQLTENNYWE68F/MjQrUKPTrw/+B6DXK 5yay8p/reP/WZvu+JQmQT3zwJ4Pjs3lJCX4lJgVbW2JEYX7whADloYaiYW/QxIy/Iy oQdSrwipDguqA== Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E44CA63311 for ; Fri, 29 Jul 2022 18:00:24 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id D22B64000E; Fri, 29 Jul 2022 16:00:23 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Fri, 29 Jul 2022 18:00:10 +0200 Message-Id: <20220729160014.101503-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220729160014.101503-1-jacopo@jmondi.org> References: <20220729160014.101503-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/6] 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. To correctly support multiple V4L2 formats mapped 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 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) -- 2.37.1 diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index 3c536722f375..6921d5c43bcb 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -829,9 +829,18 @@ 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(); + }; + const auto &info = std::find_if(pixelFormatInfo.begin(), pixelFormatInfo.end(), - [format](auto pair) { - return pair.second.v4l2Formats[0] == format; + [&matchFormats](auto &pair) { + return matchFormats(pair.second.v4l2Formats); }); if (info == pixelFormatInfo.end()) return pixelFormatInfoInvalid;