Patch Detail
Show a patch.
GET /api/patches/14440/?format=api
{ "id": 14440, "url": "https://patchwork.libcamera.org/api/patches/14440/?format=api", "web_url": "https://patchwork.libcamera.org/patch/14440/", "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": "<20211101091510.23204-6-naush@raspberrypi.com>", "date": "2021-11-01T09:15:04", "name": "[libcamera-devel,v5,05/11] libcamera: bayer_format: Rework BayerFormat conversion table", "commit_ref": "c308ae532a04877a0f4d1d4e3ea3591e9f9ccf6a", "pull_url": null, "state": "accepted", "archived": false, "hash": "410b1df57f37bd8fa59482ab4511326e91aca507", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/14440/mbox/", "series": [ { "id": 2684, "url": "https://patchwork.libcamera.org/api/series/2684/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2684", "date": "2021-11-01T09:14:59", "name": "Raspberry Pi: Conversion to media controller", "version": 5, "mbox": "https://patchwork.libcamera.org/series/2684/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/14440/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/14440/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 9C77CC324F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 1 Nov 2021 09:15:21 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 30AFA60329;\n\tMon, 1 Nov 2021 10:15:21 +0100 (CET)", "from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com\n\t[IPv6:2a00:1450:4864:20::32c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0D14C60123\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 1 Nov 2021 10:15:17 +0100 (CET)", "by mail-wm1-x32c.google.com with SMTP id v127so12816751wme.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 01 Nov 2021 02:15:17 -0700 (PDT)", "from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:3a2b:9d8c:92b9:ece6])\n\tby smtp.gmail.com with ESMTPSA id\n\tw10sm13168849wrq.88.2021.11.01.02.15.15\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 01 Nov 2021 02:15:16 -0700 (PDT)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"W6Nf2gX5\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=4h+Hq4Z7h1kX/XifGZPKWYh0O2oL6hH6gJ4EJSh8gwU=;\n\tb=W6Nf2gX5QmXPlUV8hdaZujjALynBXnx7iaeYLrjiXeiLL9ZTDWkk5Y7W1RB8GV7lz7\n\tQ0K48guCqkkK6oxVV+eNQQ7rMhHk+xTvv37ycXZuVBB+z2cpxsaVOgd0iP6j/K0/L+rT\n\tbvr8yke3Dddxod+hJ8uJDKg+ZHbF9jozLebKeQi9iVHPYbAQz8nrDRVvBkT4OHLSDOYW\n\t6j78ffEXIFSw2cma4lzQ9+RF/WCE7pgV5HrkjJVV4a6lfsT2WJjG8awCH8aGA0Ak0TF1\n\tNuR7ITRBeOyEQSFGXIXFQEHwgApN1xqe8pD8Gxrgn29BTrjvk4qur/B7aomA4O9u34TL\n\t80pA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=4h+Hq4Z7h1kX/XifGZPKWYh0O2oL6hH6gJ4EJSh8gwU=;\n\tb=ivlfA9A+XF/zECdXf/CyOARQaZjNffFClpmqQ03b7SGOM1sBW6l1HZpxw0BIlaM0p5\n\tvp2LGX7Kvvs9weZEGkQUk4qQugVC63OjMzLTm65rM7Nw6/itLgjdpPoIajZYwuhvcmML\n\tL/eCCMrISjSWRKbez5gLDn/jLwBQrPv6CW2cXcHYa07Csmx7PdE/WumkhO2TMLCbSbr3\n\tsGDXZN3c2oFXnOW7YpgbSXQNcV1SSK67Qgoj/9/HzT19Ow1j/PgCpF7Eo4nWaBcqglps\n\tRD8aTo0772MPmT6vtcIyi6mvdKP9A9H+1d82HM8xE83ZBhuF3XYubecW6T0pUsUPCLc4\n\tzadQ==", "X-Gm-Message-State": "AOAM53249oOCFiuKnfb7K9RHy/NPkLaZU59lPBQCO+GJYbVOT9ajS28G\n\tw0ztnDIpEAwNNuWattgnXzGKt9Lxuk9bn5Tn", "X-Google-Smtp-Source": "ABdhPJzZ0FODq536f1KvQlM7wKlj4K/pXksuN498qj61E3y3VlW3XSNowc0ZtnKOnhfbCkaQgsN/yg==", "X-Received": "by 2002:a05:600c:253:: with SMTP id\n\t19mr6986662wmj.179.1635758116454; \n\tMon, 01 Nov 2021 02:15:16 -0700 (PDT)", "From": "Naushir Patuck <naush@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 1 Nov 2021 09:15:04 +0000", "Message-Id": "<20211101091510.23204-6-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20211101091510.23204-1-naush@raspberrypi.com>", "References": "<20211101091510.23204-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v5 05/11] libcamera: bayer_format: Rework\n\tBayerFormat conversion table", "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": "Rename the bayerToV4l2 conversion table to bayerToFormat. Update the table to\nhold both the PixelFormat and V4L2PixelFormat conversions for a given\nBayerFormat. This will allow converting between BayerFormat and PixelFormat\ntypes in a subsequent change.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/bayer_format.cpp | 110 ++++++++++++++++++++++-----------\n 1 file changed, 73 insertions(+), 37 deletions(-)", "diff": "diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp\nindex 1c1e849a7e31..120115ce8f62 100644\n--- a/src/libcamera/bayer_format.cpp\n+++ b/src/libcamera/bayer_format.cpp\n@@ -13,6 +13,7 @@\n \n #include <linux/media-bus-format.h>\n \n+#include <libcamera/formats.h>\n #include <libcamera/transform.h>\n \n /**\n@@ -84,37 +85,72 @@ struct BayerFormatComparator {\n \t}\n };\n \n-const std::map<BayerFormat, V4L2PixelFormat, BayerFormatComparator> bayerToV4l2{\n-\t{ { BayerFormat::BGGR, 8, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8) },\n-\t{ { BayerFormat::GBRG, 8, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8) },\n-\t{ { BayerFormat::GRBG, 8, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8) },\n-\t{ { BayerFormat::RGGB, 8, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8) },\n-\t{ { BayerFormat::BGGR, 10, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10) },\n-\t{ { BayerFormat::GBRG, 10, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10) },\n-\t{ { BayerFormat::GRBG, 10, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10) },\n-\t{ { BayerFormat::RGGB, 10, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10) },\n-\t{ { BayerFormat::BGGR, 10, BayerFormat::Packing::CSI2 }, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P) },\n-\t{ { BayerFormat::GBRG, 10, BayerFormat::Packing::CSI2 }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P) },\n-\t{ { BayerFormat::GRBG, 10, BayerFormat::Packing::CSI2 }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P) },\n-\t{ { BayerFormat::RGGB, 10, BayerFormat::Packing::CSI2 }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P) },\n-\t{ { BayerFormat::BGGR, 10, BayerFormat::Packing::IPU3 }, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10) },\n-\t{ { BayerFormat::GBRG, 10, BayerFormat::Packing::IPU3 }, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10) },\n-\t{ { BayerFormat::GRBG, 10, BayerFormat::Packing::IPU3 }, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10) },\n-\t{ { BayerFormat::RGGB, 10, BayerFormat::Packing::IPU3 }, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10) },\n-\t{ { BayerFormat::BGGR, 12, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12) },\n-\t{ { BayerFormat::GBRG, 12, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12) },\n-\t{ { BayerFormat::GRBG, 12, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12) },\n-\t{ { BayerFormat::RGGB, 12, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12) },\n-\t{ { BayerFormat::BGGR, 12, BayerFormat::Packing::CSI2 }, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P) },\n-\t{ { BayerFormat::GBRG, 12, BayerFormat::Packing::CSI2 }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P) },\n-\t{ { BayerFormat::GRBG, 12, BayerFormat::Packing::CSI2 }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P) },\n-\t{ { BayerFormat::RGGB, 12, BayerFormat::Packing::CSI2 }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P) },\n-\t{ { BayerFormat::BGGR, 16, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16) },\n-\t{ { BayerFormat::GBRG, 16, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16) },\n-\t{ { BayerFormat::GRBG, 16, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16) },\n-\t{ { BayerFormat::RGGB, 16, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16) },\n-\t{ { BayerFormat::MONO, 8, BayerFormat::Packing::None }, V4L2PixelFormat(V4L2_PIX_FMT_GREY) },\n-\t{ { BayerFormat::MONO, 10, BayerFormat::Packing::CSI2 }, V4L2PixelFormat(V4L2_PIX_FMT_Y10P) },\n+struct Formats {\n+\tPixelFormat pixelFormat;\n+\tV4L2PixelFormat v4l2Format;\n+};\n+\n+const std::map<BayerFormat, Formats, BayerFormatComparator> bayerToFormat{\n+\t{ { BayerFormat::BGGR, 8, BayerFormat::Packing::None },\n+\t\t{ formats::SBGGR8, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8) } },\n+\t{ { BayerFormat::GBRG, 8, BayerFormat::Packing::None },\n+\t\t{ formats::SGBRG8, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8) } },\n+\t{ { BayerFormat::GRBG, 8, BayerFormat::Packing::None },\n+\t\t{ formats::SGRBG8, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8) } },\n+\t{ { BayerFormat::RGGB, 8, BayerFormat::Packing::None },\n+\t\t{ formats::SRGGB8, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8) } },\n+\t{ { BayerFormat::BGGR, 10, BayerFormat::Packing::None },\n+\t\t{ formats::SBGGR10, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10) } },\n+\t{ { BayerFormat::GBRG, 10, BayerFormat::Packing::None },\n+\t\t{ formats::SGBRG10, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10) } },\n+\t{ { BayerFormat::GRBG, 10, BayerFormat::Packing::None },\n+\t\t{ formats::SGRBG10, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10) } },\n+\t{ { BayerFormat::RGGB, 10, BayerFormat::Packing::None },\n+\t\t{ formats::SRGGB10, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10) } },\n+\t{ { BayerFormat::BGGR, 10, BayerFormat::Packing::CSI2 },\n+\t\t{ formats::SBGGR10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P) } },\n+\t{ { BayerFormat::GBRG, 10, BayerFormat::Packing::CSI2 },\n+\t\t{ formats::SGBRG10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P) } },\n+\t{ { BayerFormat::GRBG, 10, BayerFormat::Packing::CSI2 },\n+\t\t{ formats::SGRBG10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P) } },\n+\t{ { BayerFormat::RGGB, 10, BayerFormat::Packing::CSI2 },\n+\t\t{ formats::SRGGB10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P) } },\n+\t{ { BayerFormat::BGGR, 10, BayerFormat::Packing::IPU3 },\n+\t\t{ formats::SBGGR10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10) } },\n+\t{ { BayerFormat::GBRG, 10, BayerFormat::Packing::IPU3 },\n+\t\t{ formats::SGBRG10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10) } },\n+\t{ { BayerFormat::GRBG, 10, BayerFormat::Packing::IPU3 },\n+\t\t{ formats::SGRBG10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10) } },\n+\t{ { BayerFormat::RGGB, 10, BayerFormat::Packing::IPU3 },\n+\t\t{ formats::SRGGB10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10) } },\n+\t{ { BayerFormat::BGGR, 12, BayerFormat::Packing::None },\n+\t\t{ formats::SBGGR12, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12) } },\n+\t{ { BayerFormat::GBRG, 12, BayerFormat::Packing::None },\n+\t\t{ formats::SGBRG12, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12) } },\n+\t{ { BayerFormat::GRBG, 12, BayerFormat::Packing::None },\n+\t\t{ formats::SGRBG12, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12) } },\n+\t{ { BayerFormat::RGGB, 12, BayerFormat::Packing::None },\n+\t\t{ formats::SRGGB12, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12) } },\n+\t{ { BayerFormat::BGGR, 12, BayerFormat::Packing::CSI2 },\n+\t\t{ formats::SBGGR12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P) } },\n+\t{ { BayerFormat::GBRG, 12, BayerFormat::Packing::CSI2 },\n+\t\t{ formats::SGBRG12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P) } },\n+\t{ { BayerFormat::GRBG, 12, BayerFormat::Packing::CSI2 },\n+\t\t{ formats::SGRBG12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P) } },\n+\t{ { BayerFormat::RGGB, 12, BayerFormat::Packing::CSI2 },\n+\t\t{ formats::SRGGB12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P) } },\n+\t{ { BayerFormat::BGGR, 16, BayerFormat::Packing::None },\n+\t\t{ formats::SBGGR16, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16) } },\n+\t{ { BayerFormat::GBRG, 16, BayerFormat::Packing::None },\n+\t\t{ formats::SGBRG16, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16) } },\n+\t{ { BayerFormat::GRBG, 16, BayerFormat::Packing::None },\n+\t\t{ formats::SGRBG16, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16) } },\n+\t{ { BayerFormat::RGGB, 16, BayerFormat::Packing::None },\n+\t\t{ formats::SRGGB16, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16) } },\n+\t{ { BayerFormat::MONO, 8, BayerFormat::Packing::None },\n+\t\t{ formats::R8, V4L2PixelFormat(V4L2_PIX_FMT_GREY) } },\n+\t{ { BayerFormat::MONO, 10, BayerFormat::Packing::CSI2 },\n+\t\t{ formats::R10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_Y10P) } },\n };\n \n const std::unordered_map<unsigned int, BayerFormat> mbusCodeToBayer{\n@@ -245,9 +281,9 @@ bool operator==(const BayerFormat &lhs, const BayerFormat &rhs)\n */\n V4L2PixelFormat BayerFormat::toV4L2PixelFormat() const\n {\n-\tconst auto it = bayerToV4l2.find(*this);\n-\tif (it != bayerToV4l2.end())\n-\t\treturn it->second;\n+\tconst auto it = bayerToFormat.find(*this);\n+\tif (it != bayerToFormat.end())\n+\t\treturn it->second.v4l2Format;\n \n \treturn V4L2PixelFormat();\n }\n@@ -259,11 +295,11 @@ V4L2PixelFormat BayerFormat::toV4L2PixelFormat() const\n */\n BayerFormat BayerFormat::fromV4L2PixelFormat(V4L2PixelFormat v4l2Format)\n {\n-\tauto it = std::find_if(bayerToV4l2.begin(), bayerToV4l2.end(),\n+\tauto it = std::find_if(bayerToFormat.begin(), bayerToFormat.end(),\n \t\t\t [v4l2Format](const auto &i) {\n-\t\t\t\t return i.second == v4l2Format;\n+\t\t\t\t return i.second.v4l2Format == v4l2Format;\n \t\t\t });\n-\tif (it != bayerToV4l2.end())\n+\tif (it != bayerToFormat.end())\n \t\treturn it->first;\n \n \treturn BayerFormat();\n", "prefixes": [ "libcamera-devel", "v5", "05/11" ] }