Patch Detail
Show a patch.
GET /api/patches/25469/?format=api
{ "id": 25469, "url": "https://patchwork.libcamera.org/api/patches/25469/?format=api", "web_url": "https://patchwork.libcamera.org/patch/25469/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20251210164055.17856-5-david.plowman@raspberrypi.com>", "date": "2025-12-10T16:15:19", "name": "[04/11] pipeline: rpi: Add PipelineHandlerBase::bayerToMbusCode", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "0590b69106792f383bf91b6330466669b31caa4b", "submitter": { "id": 42, "url": "https://patchwork.libcamera.org/api/people/42/?format=api", "name": "David Plowman", "email": "david.plowman@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/25469/mbox/", "series": [ { "id": 5650, "url": "https://patchwork.libcamera.org/api/series/5650/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5650", "date": "2025-12-10T16:15:15", "name": "Bayer re-processing", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5650/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/25469/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/25469/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BDD6BC3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 10 Dec 2025 16:41:09 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 93AD0614BD;\n\tWed, 10 Dec 2025 17:41:08 +0100 (CET)", "from mail-wm1-x333.google.com (mail-wm1-x333.google.com\n\t[IPv6:2a00:1450:4864:20::333])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 170FA6149F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Dec 2025 17:41:03 +0100 (CET)", "by mail-wm1-x333.google.com with SMTP id\n\t5b1f17b1804b1-477b5e0323bso6251245e9.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Dec 2025 08:41:03 -0800 (PST)", "from davidp-pi5.pitowers.org\n\t([2a00:1098:3142:1f:88ea:c658:5b20:5e46])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-47a88371e13sm1270415e9.11.2025.12.10.08.41.01\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 10 Dec 2025 08:41:01 -0800 (PST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"aSayuMXD\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1765384862; x=1765989662;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=iHr6Y5W5ilP5vo9pl+dVLtmHzFbYz74H+sbzpnc0Cuc=;\n\tb=aSayuMXDnAuBeukuMs2NAWUhRHHeXANUTApMgtFfI+U5ooqZndtP/znJ/ZNAjXeUkR\n\t/gcz/1yp1djGKvOGYjN5dz85lFGAzY8v4AEWh0edybFhISxc9tKI3eYwiSWYoV6LFDRe\n\tBDP0PM+rPnBPsiOwixKanRo5U6B5yCHT0Hc7kZDG/pRlpUGjRuOrsTSvr7WQODVEtaaN\n\tNXPZXG794FqhyFZwkpZvuRTstyWPMLtG8rDBAC3iam3y3G9EHaaX4/kbcpV363f55Taz\n\t5njU78xT+1WzHqe9Z6W+ZNP/GwjHA4nVgpWayt68PcQpLQR2FdWN7XeEUBoExb+ylbo2\n\tJoVQ==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1765384862; x=1765989662;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n\t:to:cc:subject:date:message-id:reply-to;\n\tbh=iHr6Y5W5ilP5vo9pl+dVLtmHzFbYz74H+sbzpnc0Cuc=;\n\tb=iqPtbYx5q0CoBOoQ1Xoe5V4rTm3/f+BkMPVVgDD+LyezbbuMXydIQ+jG9qzfYec+cB\n\tofC8NJyhaqD++bHgjrBsIo3qXIrXEk0Rv+W1M8Q+qglwAtoczkiCyPO8kmGY1+8WW9bz\n\tq/MXcB00e7c/Py9jRmGyG4vJVKJT2YS6MK3QxcvMuwuXpI166GtdjVpvhn2T/w1XY/cd\n\t82vg4a+dOouRQIHQztniATWdj1m/M3kcAQq6BOZ4P8es2E0XOMfa87nZFYFQri5SoIoS\n\to2JV2UweIRvbpctuiOqFHsF/7av7/uiNMnGqErG3nFvu9PIfIdKxUeN3AxsUJi0dwaxo\n\tNvEg==", "X-Gm-Message-State": "AOJu0YwP+EDgMJ7ORrhYQQgKGgpOLDtj+F6m3w/5IS5b87/3RZhup+qg\n\t6YgagjXK+ouIOdr7HMR7oEXBlK4sJjez8vFPlh4pyGDfBp3Tb7SPAV5ggt+ichxHTrtPwuCGSHQ\n\tdaWnn", "X-Gm-Gg": "ASbGncujz6RvEaCUxObk0wvyuqGVX0dWAgBNJff0EtQEPzHkjeCyH67+9uRuumZCrTs\n\t+xwIAck+sDX1MXXXEX8YnAi4wZrTOcc35HAg4TRFtvdR2DNiTvOwuujKW6cdrFcygYZ8dRSoMbH\n\tAfg4c5BbSWBqXO2S6U/4GXAPHoiZFe4/2o9y4z3tz12hzXuAwRKcjkzd5OxzWDnwWkHesq1lcmG\n\tv09YBzSyFL7z+N12AsBYSxPXAzdjc1XYoYRv2EU74Wm9oXGfGS3PJctDoZonakXjjUN5FLZzoOu\n\twSsTfj1DvYoCFK3x13fOLcmY+QdnzzYSxqPAXstCzUhu/xVhrJ/20DJqNibNPI4gVgFYASicrau\n\tg/DMmiK9Ew1HDFndhqR0yMRS850YN1l4xIFKU2aIY3GU9pLQ0OLFtRJIZwgcSGs5Ht6goodnAIR\n\tWrsrHg2g8+JaJrFYIE+aSv65muV6r3f1zoFLKQBd9R8J3CrEgDjjxd8IuRarddEWVZU8NguK2RV\n\tiay/u03LgHZq/MQcZdH5stcq4W0kA==", "X-Google-Smtp-Source": "AGHT+IG7V2NDW7TOkVpf8lUl9bntreePeaV3CZsoNZVnWp9JlpUAutSYPlaslmpQPaasKvufRq29CA==", "X-Received": "by 2002:a05:600c:3505:b0:479:1348:c63e with SMTP id\n\t5b1f17b1804b1-47a886d92b4mr333015e9.9.1765384862158; \n\tWed, 10 Dec 2025 08:41:02 -0800 (PST)", "From": "David Plowman <david.plowman@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "David Plowman <david.plowman@raspberrypi.com>", "Subject": "[PATCH 04/11] pipeline: rpi: Add\n\tPipelineHandlerBase::bayerToMbusCode", "Date": "Wed, 10 Dec 2025 16:15:19 +0000", "Message-ID": "<20251210164055.17856-5-david.plowman@raspberrypi.com>", "X-Mailer": "git-send-email 2.47.3", "In-Reply-To": "<20251210164055.17856-1-david.plowman@raspberrypi.com>", "References": "<20251210164055.17856-1-david.plowman@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "In future we are going to need this function outside pisp.cpp, so move\nit to PipelineHandlerBase and amend any existing callers to use the\nnew version. It is functionally identical.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n .../pipeline/rpi/common/pipeline_base.cpp | 43 +++++++++++++++++\n .../pipeline/rpi/common/pipeline_base.h | 1 +\n src/libcamera/pipeline/rpi/pisp/pisp.cpp | 47 +------------------\n 3 files changed, 46 insertions(+), 45 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\nindex 9d65dc83..00b088fc 100644\n--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n@@ -381,6 +381,49 @@ V4L2DeviceFormat PipelineHandlerBase::toV4L2DeviceFormat(const V4L2VideoDevice *\n \treturn deviceFormat;\n }\n \n+const std::vector<std::pair<BayerFormat, unsigned int>> BayerToMbusCodeMap{\n+\t{ { BayerFormat::BGGR, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR8_1X8, },\n+\t{ { BayerFormat::GBRG, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG8_1X8, },\n+\t{ { BayerFormat::GRBG, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG8_1X8, },\n+\t{ { BayerFormat::RGGB, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB8_1X8, },\n+\t{ { BayerFormat::BGGR, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR10_1X10, },\n+\t{ { BayerFormat::GBRG, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG10_1X10, },\n+\t{ { BayerFormat::GRBG, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG10_1X10, },\n+\t{ { BayerFormat::RGGB, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB10_1X10, },\n+\t{ { BayerFormat::BGGR, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR12_1X12, },\n+\t{ { BayerFormat::GBRG, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG12_1X12, },\n+\t{ { BayerFormat::GRBG, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG12_1X12, },\n+\t{ { BayerFormat::RGGB, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB12_1X12, },\n+\t{ { BayerFormat::BGGR, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR14_1X14, },\n+\t{ { BayerFormat::GBRG, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG14_1X14, },\n+\t{ { BayerFormat::GRBG, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG14_1X14, },\n+\t{ { BayerFormat::RGGB, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB14_1X14, },\n+\t{ { BayerFormat::BGGR, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR16_1X16, },\n+\t{ { BayerFormat::GBRG, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG16_1X16, },\n+\t{ { BayerFormat::GRBG, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG16_1X16, },\n+\t{ { BayerFormat::RGGB, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB16_1X16, },\n+\t{ { BayerFormat::BGGR, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SBGGR16_1X16, },\n+\t{ { BayerFormat::GBRG, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SGBRG16_1X16, },\n+\t{ { BayerFormat::GRBG, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SGRBG16_1X16, },\n+\t{ { BayerFormat::RGGB, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SRGGB16_1X16, },\n+\t{ { BayerFormat::RGGB, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SRGGB16_1X16, },\n+\t{ { BayerFormat::MONO, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_Y16_1X16, },\n+\t{ { BayerFormat::MONO, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_Y16_1X16, },\n+};\n+\n+unsigned int PipelineHandlerBase::bayerToMbusCode(const BayerFormat &bayer)\n+{\n+\tconst auto it = std::find_if(BayerToMbusCodeMap.begin(), BayerToMbusCodeMap.end(),\n+\t\t\t\t [bayer](const std::pair<BayerFormat, unsigned int> &match) {\n+\t\t\t\t\t\treturn bayer == match.first;\n+\t\t\t\t });\n+\n+\tif (it != BayerToMbusCodeMap.end())\n+\t\treturn it->second;\n+\n+\treturn 0;\n+}\n+\n std::unique_ptr<CameraConfiguration>\n PipelineHandlerBase::generateConfiguration(Camera *camera, Span<const StreamRole> roles)\n {\ndiff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.h b/src/libcamera/pipeline/rpi/common/pipeline_base.h\nindex 15628259..1f174473 100644\n--- a/src/libcamera/pipeline/rpi/common/pipeline_base.h\n+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.h\n@@ -208,6 +208,7 @@ public:\n \tstatic V4L2DeviceFormat toV4L2DeviceFormat(const V4L2VideoDevice *dev,\n \t\t\t\t\t\t const V4L2SubdeviceFormat &format,\n \t\t\t\t\t\t BayerFormat::Packing packingReq);\n+\tstatic unsigned int bayerToMbusCode(const BayerFormat &bayer);\n \n \tstd::unique_ptr<CameraConfiguration>\n \tgenerateConfiguration(Camera *camera, Span<const StreamRole> roles) override;\ndiff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\nindex ade31de1..c08210b4 100644\n--- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n+++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n@@ -55,55 +55,12 @@ enum class Isp : unsigned int { Input, Output0, Output1, TdnInput, TdnOutput,\n constexpr unsigned int DefaultCompressionOffset = 2048;\n constexpr unsigned int DefaultCompressionMode = 1;\n \n-const std::vector<std::pair<BayerFormat, unsigned int>> BayerToMbusCodeMap{\n-\t{ { BayerFormat::BGGR, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR8_1X8, },\n-\t{ { BayerFormat::GBRG, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG8_1X8, },\n-\t{ { BayerFormat::GRBG, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG8_1X8, },\n-\t{ { BayerFormat::RGGB, 8, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB8_1X8, },\n-\t{ { BayerFormat::BGGR, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR10_1X10, },\n-\t{ { BayerFormat::GBRG, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG10_1X10, },\n-\t{ { BayerFormat::GRBG, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG10_1X10, },\n-\t{ { BayerFormat::RGGB, 10, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB10_1X10, },\n-\t{ { BayerFormat::BGGR, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR12_1X12, },\n-\t{ { BayerFormat::GBRG, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG12_1X12, },\n-\t{ { BayerFormat::GRBG, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG12_1X12, },\n-\t{ { BayerFormat::RGGB, 12, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB12_1X12, },\n-\t{ { BayerFormat::BGGR, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR14_1X14, },\n-\t{ { BayerFormat::GBRG, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG14_1X14, },\n-\t{ { BayerFormat::GRBG, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG14_1X14, },\n-\t{ { BayerFormat::RGGB, 14, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB14_1X14, },\n-\t{ { BayerFormat::BGGR, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SBGGR16_1X16, },\n-\t{ { BayerFormat::GBRG, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGBRG16_1X16, },\n-\t{ { BayerFormat::GRBG, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SGRBG16_1X16, },\n-\t{ { BayerFormat::RGGB, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_SRGGB16_1X16, },\n-\t{ { BayerFormat::BGGR, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SBGGR16_1X16, },\n-\t{ { BayerFormat::GBRG, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SGBRG16_1X16, },\n-\t{ { BayerFormat::GRBG, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SGRBG16_1X16, },\n-\t{ { BayerFormat::RGGB, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SRGGB16_1X16, },\n-\t{ { BayerFormat::RGGB, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_SRGGB16_1X16, },\n-\t{ { BayerFormat::MONO, 16, BayerFormat::Packing::None }, MEDIA_BUS_FMT_Y16_1X16, },\n-\t{ { BayerFormat::MONO, 16, BayerFormat::Packing::PISP1 }, MEDIA_BUS_FMT_Y16_1X16, },\n-};\n-\n-unsigned int bayerToMbusCode(const BayerFormat &bayer)\n-{\n-\tconst auto it = std::find_if(BayerToMbusCodeMap.begin(), BayerToMbusCodeMap.end(),\n-\t\t\t\t [bayer](const std::pair<BayerFormat, unsigned int> &match) {\n-\t\t\t\t\t\treturn bayer == match.first;\n-\t\t\t\t });\n-\n-\tif (it != BayerToMbusCodeMap.end())\n-\t\treturn it->second;\n-\n-\treturn 0;\n-}\n-\n uint32_t mbusCodeUnpacked16(unsigned int code)\n {\n \tBayerFormat bayer = BayerFormat::fromMbusCode(code);\n \tBayerFormat bayer16(bayer.order, 16, BayerFormat::Packing::None);\n \n-\treturn bayerToMbusCode(bayer16);\n+\treturn RPi::PipelineHandlerBase::bayerToMbusCode(bayer16);\n }\n \n uint8_t toPiSPBayerOrder(V4L2PixelFormat format)\n@@ -2219,7 +2176,7 @@ int PiSPCameraData::configureEntities(V4L2SubdeviceFormat sensorFormat,\n \tcfe_[Cfe::Output0].dev()->getFormat(&feOutputFormat);\n \tBayerFormat feOutputBayer = BayerFormat::fromV4L2PixelFormat(feOutputFormat.fourcc);\n \n-\tfeFormat.code = bayerToMbusCode(feOutputBayer);\n+\tfeFormat.code = RPi::PipelineHandlerBase::bayerToMbusCode(feOutputBayer);\n \tret = feSubdev_->setFormat(feVideo0SourcePad, &feFormat);\n \n \treturn ret;\n", "prefixes": [ "04/11" ] }