From patchwork Mon Aug 8 12:48:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 17024 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 33A09C3272 for ; Mon, 8 Aug 2022 12:48:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 728446332B; Mon, 8 Aug 2022 14:48:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659962938; bh=4SwCrGdRcrMRvCyxWwW3X2qYoK8R8txGCpLX8mt1vMA=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=itXWqY8Fx7dCpKErLTI1+Ie5d+lvF+8zBN43IcJYL4DcWwWAqajK8QI3cZz2eB5mu aZv6V8nWy8TXCufLBPkBC7amnjwWnq7l35LzjUt99f1CJeNCsKjxOS3Oe8k4k+J3pk XAYnxWYSVx8JMXLXAGTtoUwjorNzmANHKXSwx7nGsQIvUHIsvzcp/nxuoDyjS4vELc l/gdQIfdq+cTuc+35EqOp43MhXYCIcX7NkjCBJCapYyDMQCAWhtahoRHG9cnueveQ3 n0IdfO2flMh5lV1v9y5rzOvESpKtGpFXZ8SuwVPVuNAHcrl6YsJ3DMaIM7G4j/aJjb gqrc3YAQPf+ag== Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 19CC663315 for ; Mon, 8 Aug 2022 14:48:57 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id E8E594000C; Mon, 8 Aug 2022 12:48:55 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Aug 2022 14:48:48 +0200 Message-Id: <20220808124848.35258-1-jacopo@jmondi.org> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: formats: Search V4L2 format info on map 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 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Commit f25ad4a2b16b ("libcamera: formats: Reimplement V4L2 PixelFormatInfo::info()") changed the PixelFormatInfo::info(const V4L2PixelFormat &format) function overload to: return info(format.toPixelFormat()); After the series that contains such commit, the PixelFormatInfo for the pixel format applied to a video device is retrieved at V4L2VideoDevice::open() time. Some video devices register formats not available to applications, for example metadata formats or, in the case of ISP devices, formats to describe the ISP statistics and parameters. This causes the format.toPixelFormat() call to output a WARN message, which spams the log and unnecessary alert the users. Restore the behaviour preceding commit f25ad4a2b16b, which in the case a V4L2 pixel format is not registered in the map of formats known to libcamera, silently returns an invalid PixelFormatInfo without outputting any unnecessary warning message. Fixes: f25ad4a2b16b ("libcamera: formats: Reimplement V4L2 PixelFormatInfo::info()") Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/libcamera/formats.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) -- 2.37.1 diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index 0bd0e09ae44c..51eccdce064e 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -852,7 +852,16 @@ const PixelFormatInfo &PixelFormatInfo::info(const PixelFormat &format) */ const PixelFormatInfo &PixelFormatInfo::info(const V4L2PixelFormat &format) { - return info(format.toPixelFormat()); + const auto &info = std::find_if(pixelFormatInfo.begin(), pixelFormatInfo.end(), + [&format](auto &pair) { + const auto &formats = pair.second.v4l2Formats; + return std::find(formats.begin(), formats.end(), format) + != formats.end(); + }); + if (info == pixelFormatInfo.end()) + return pixelFormatInfoInvalid; + + return info->second; } /**