From patchwork Wed Aug 27 09:07:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 24240 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 96391C32BB for ; Wed, 27 Aug 2025 09:07:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E737A69301; Wed, 27 Aug 2025 11:07:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="AJIRPgjW"; dkim-atps=neutral Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 62CE8692F5 for ; Wed, 27 Aug 2025 11:07:46 +0200 (CEST) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-45b5c12dd87so30987125e9.2 for ; Wed, 27 Aug 2025 02:07:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1756285665; x=1756890465; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sgDB9QwlZ/6ZlpG67CFAzzVzDYU+hnHDTrA998eUhaQ=; b=AJIRPgjW6Zb14JD+rlG8pLFwhhQjgBIe5Akw/CD15owkraHOF/WxtmUTSwYfnwhktW /QIgJEHGyqKUAkJIt7AHb/C0fV7JJ6eyHV7pQf3nqWcoHqYJZHvi4z/ndG+fB/7ffUa+ ayRfovI3/vOu/kqzWN0K3IQ2h+dHtG31MXSWpzIz6kpT6THBkI2vPS1+87l4GtyNVhzl 9sBLLipfmDoV6R7CL9h99NoFjs2CZX1ZKCipGwmeBCwdT+qEWKQzstk3SA15XrwuRZ9j sKGScPFBaQflbgdpEjeaXf42uTByQzF2+/OVb2pln15bztDqqnjW1FgZpD1LE1AKTl/s C3kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756285665; x=1756890465; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sgDB9QwlZ/6ZlpG67CFAzzVzDYU+hnHDTrA998eUhaQ=; b=RPp7G4w/2TS1w9v3tuNUbtH0xxiYeQH8lYvi4jWAyy86a9TzGGJ/wpvUxczuJ+IBap 5HnMJvuxIQ/MHGlqAZbp5GJ4VNkZ5Q5Vxx2hMduwmtJCXzPw54oK7e8kGMkuOP9dmZNf 4GxrCMgD8Wx/TQ1AhpYHVFzjfcF6m1ZgElPNqxOURDvnrvn3QnnHPFqJzvCG/A6+aVHA yFf/xkIUDj4IdUswFBLGocM1rMJ7iMBo9giXq1iGpszMY/xqLWJ9dqmNIUxZMB1NXDQU yQU5/fyGWVagoGkt7t9om7poORB/n4KPIr1OE8rrv75phGExrTFwAZ/Hbyk2b3W1cHwR FgUw== X-Gm-Message-State: AOJu0Yz9FaBLBmhGHAv59QKMQdAbIw6VUrxSFoo4/EZ9lnewa60p6orE s1n1Qhsc4lQuvW1S4vlTXCOqfds02JV837r+ExXOFzhFUxtgPYmOE4VlgHo0+870EBjc8lJLHIm AepfS X-Gm-Gg: ASbGncsUn2VFw4qZYNQIcf/3HHE8IWR/tiJZoN3ebsnHWOBBu1FKf7chIqFGC6xTaGJ mbPyUn9dUjzfeeMOcAfO2YTF80fbjA86b5yv7Pwyzm15LyVFgfm6kfWFJ2EFTbRwo7RTWhbkmVF 9g3crgA7a1giaFjthotpAz/DiY4ULSYwYaUGdmWQxT3WS82y93HSF4Na8XqdDEnm3zei1Q2ewg5 GhQkfg81o/OOW+OzdkeVOplZv2WFseIpuJxmBToXEu1Az2uM0oDexWxeM2nneEQNvfA1dQ4TQFo YXvyKaYf5H2lwxGhszIARBK+SHcdoBQtUIzmZ89CyNewfggc9zD5asqBIN460NR6NOFmfjLVmJC Y7rDCYelCH9k2bmluFF/8MBIR6uVdWqWXsIx6zk2XSgVWPPDrhdNipXNH/OKo9IfrmFOHEQYiXO SxxzreCYX82nPEyhKFVpX/+kKoUu4SXPqfmr9xuX+mLHzT6hT4FQ== X-Google-Smtp-Source: AGHT+IFXVs/tZ6HQFOlr+O1lToHW9ohRWkLirdiwLq4uMoHV3A1W9ChsPO+5IzKVSh0bI6EQLgbyxw== X-Received: by 2002:a05:600c:1c0c:b0:458:bda4:43df with SMTP id 5b1f17b1804b1-45b727a2c43mr10026805e9.17.1756285665249; Wed, 27 Aug 2025 02:07:45 -0700 (PDT) Received: from raspberrypi.pitowers.org ([2a00:1098:3142:1f:ffc9:aff6:7f7f:893b]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b6f30fe02sm21498675e9.18.2025.08.27.02.07.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Aug 2025 02:07:44 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: David Plowman Subject: [RFC PATCH 03/12] pipeline: rpi: pisp: Use the new BayerFormat::toMbusCode() instead Date: Wed, 27 Aug 2025 10:07:30 +0100 Message-Id: <20250827090739.86955-4-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250827090739.86955-1-david.plowman@raspberrypi.com> References: <20250827090739.86955-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" We now have a centralised version of bayerToMbusCode - use it instead. Signed-off-by: David Plowman --- src/libcamera/pipeline/rpi/pisp/pisp.cpp | 47 +----------------------- 1 file changed, 2 insertions(+), 45 deletions(-) diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp index ec52f6f2..745cb546 100644 --- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp +++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp @@ -55,55 +55,12 @@ enum class Isp : unsigned int { Input, Output0, Output1, TdnInput, TdnOutput, constexpr unsigned int DefaultCompressionOffset = 2048; constexpr unsigned int DefaultCompressionMode = 1; -const std::vector> BayerToMbusCodeMap{ - { { BayerFormat::BGGR, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR8_1X8, }, - { { BayerFormat::GBRG, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG8_1X8, }, - { { BayerFormat::GRBG, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG8_1X8, }, - { { BayerFormat::RGGB, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB8_1X8, }, - { { BayerFormat::BGGR, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR10_1X10, }, - { { BayerFormat::GBRG, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG10_1X10, }, - { { BayerFormat::GRBG, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG10_1X10, }, - { { BayerFormat::RGGB, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB10_1X10, }, - { { BayerFormat::BGGR, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR12_1X12, }, - { { BayerFormat::GBRG, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG12_1X12, }, - { { BayerFormat::GRBG, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG12_1X12, }, - { { BayerFormat::RGGB, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB12_1X12, }, - { { BayerFormat::BGGR, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR14_1X14, }, - { { BayerFormat::GBRG, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG14_1X14, }, - { { BayerFormat::GRBG, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG14_1X14, }, - { { BayerFormat::RGGB, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB14_1X14, }, - { { BayerFormat::BGGR, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR16_1X16, }, - { { BayerFormat::GBRG, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG16_1X16, }, - { { BayerFormat::GRBG, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG16_1X16, }, - { { BayerFormat::RGGB, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB16_1X16, }, - { { BayerFormat::BGGR, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SBGGR16_1X16, }, - { { BayerFormat::GBRG, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SGBRG16_1X16, }, - { { BayerFormat::GRBG, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SGRBG16_1X16, }, - { { BayerFormat::RGGB, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SRGGB16_1X16, }, - { { BayerFormat::RGGB, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SRGGB16_1X16, }, - { { BayerFormat::MONO, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_Y16_1X16, }, - { { BayerFormat::MONO, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_Y16_1X16, }, -}; - -unsigned int bayerToMbusCode(const BayerFormat &bayer) -{ - const auto it = std::find_if(BayerToMbusCodeMap.begin(), BayerToMbusCodeMap.end(), - [bayer](const std::pair &match) { - return bayer == match.first; - }); - - if (it != BayerToMbusCodeMap.end()) - return it->second; - - return 0; -} - uint32_t mbusCodeUnpacked16(unsigned int code) { BayerFormat bayer = BayerFormat::fromMbusCode(code); BayerFormat bayer16(bayer.order, 16, BayerFormat::Packing::None); - return bayerToMbusCode(bayer16); + return bayer16.toMbusCode(); } uint8_t toPiSPBayerOrder(V4L2PixelFormat format) @@ -2217,7 +2174,7 @@ int PiSPCameraData::configureEntities(V4L2SubdeviceFormat sensorFormat, cfe_[Cfe::Output0].dev()->getFormat(&feOutputFormat); BayerFormat feOutputBayer = BayerFormat::fromV4L2PixelFormat(feOutputFormat.fourcc); - feFormat.code = bayerToMbusCode(feOutputBayer); + feFormat.code = feOutputBayer.toMbusCode(); ret = feSubdev_->setFormat(feVideo0SourcePad, &feFormat); return ret;