Patch Detail
Show a patch.
GET /api/1.1/patches/14357/?format=api
{ "id": 14357, "url": "https://patchwork.libcamera.org/api/1.1/patches/14357/?format=api", "web_url": "https://patchwork.libcamera.org/patch/14357/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20211027092803.3671096-4-naush@raspberrypi.com>", "date": "2021-10-27T09:27:57", "name": "[libcamera-devel,v3,3/9] libcamera: bayer_format: Rework BayerFormat conversion table", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "7caa7e9af289214167a492b05ad352b88da4b292", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/1.1/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/14357/mbox/", "series": [ { "id": 2660, "url": "https://patchwork.libcamera.org/api/1.1/series/2660/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2660", "date": "2021-10-27T09:27:54", "name": "Raspberry Pi: Conversion to media controller", "version": 3, "mbox": "https://patchwork.libcamera.org/series/2660/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/14357/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/14357/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 1A1ABBDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 27 Oct 2021 09:28:16 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C8FEB64899;\n\tWed, 27 Oct 2021 11:28:15 +0200 (CEST)", "from mail-wm1-x330.google.com (mail-wm1-x330.google.com\n\t[IPv6:2a00:1450:4864:20::330])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3F8C46487E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Oct 2021 11:28:10 +0200 (CEST)", "by mail-wm1-x330.google.com with SMTP id\n\tg205-20020a1c20d6000000b0032cc6bbd505so5075419wmg.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Oct 2021 02:28:10 -0700 (PDT)", "from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:6561:eb24:3f00:ce98])\n\tby smtp.gmail.com with ESMTPSA id\n\tx2sm2861360wmj.3.2021.10.27.02.28.08\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 27 Oct 2021 02:28:08 -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=\"eIQuszlg\"; 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=W4bN5sY8pPJQqkiDqiaCRH9wmMSjWNexqy6tYgpCuTA=;\n\tb=eIQuszlglbMW9GH4LaEcurvodmRPvS8cjczCw7x/7v9zNtIWtnCxjrW5RbG0TV9u+c\n\tbAb8YNWSAlT/81pQ3UFUX6CqNQ7Kv2OGgsQCnUJV/aISjfR1l9ASRW3Ojft9cKXQK1H8\n\tZzXh6PCcQZjnkNnw0m0T+PwJ42BdJ2qBlokK6mbGLhLwPRJW3ppthyY4mTO1hjcs/npD\n\tw8GRdHrttKoo708qJm02kRKUjlE3RzgBpanRqzK4/QSqWGyfi4cjqs6f2EimPIUQmI2K\n\tvQQKmJxIS10dsxac2OqPZOEIon7meX6mgpDzlBUps2+IvOQRIBodqQrEXhmZjoa2QqNn\n\twU+w==", "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=W4bN5sY8pPJQqkiDqiaCRH9wmMSjWNexqy6tYgpCuTA=;\n\tb=Gw0pshnfrFjpY+G/8tvmnLBkuZWBIkdQxkSUvsCPu8vIcnSyWH/Dogh9noHTNKiaqa\n\tgCeXcDDdn0AtIAJgwHTXMn52GNi3OqXtwrgmRi78lZfFEI5hEeynGqLE3Mv6NAGV+dv8\n\tjR51YBtHJ36bqfPnJQRUpJFLgSDAlN5FnmrDRpnIOEDjHG9GPkyxqdiHKMrLZRD1EJZ0\n\tGemkY2QLRG8l/zYepF1VI/QatpYMOK7h/xZIZyQjqagY+wbyXRSUkoxp1hUQNXkvFIGF\n\tZwC3OABZYHlDL7uObRgEqZhOffQMVsdyLbU8xCrmcJOTaBfaHV4zgCe7FJ4UTV+pFw4/\n\tVo5A==", "X-Gm-Message-State": "AOAM532lD/RcDGf0OKhOfQL24sybP1iaFyRjDolkWmB91hlMVmdu77qO\n\t3AtFlDHJI+Ap80PtvTSkd6H8r0xQ6n6orNW3", "X-Google-Smtp-Source": "ABdhPJy24/qUrwF1PHt+IWA6cr8BFG8yzEw28X6kIUczH/eezUrCg7b8WKBj1O9Q39luOsu782wnCg==", "X-Received": "by 2002:a1c:2044:: with SMTP id\n\tg65mr4599006wmg.105.1635326889471; \n\tWed, 27 Oct 2021 02:28:09 -0700 (PDT)", "From": "Naushir Patuck <naush@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 27 Oct 2021 10:27:57 +0100", "Message-Id": "<20211027092803.3671096-4-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20211027092803.3671096-1-naush@raspberrypi.com>", "References": "<20211027092803.3671096-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 3/9] 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>\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 11355f144f66..94e2294d7f6c 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::None }, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8) },\n-\t{ { BayerFormat::GBRG, 8, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8) },\n-\t{ { BayerFormat::GRBG, 8, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8) },\n-\t{ { BayerFormat::RGGB, 8, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8) },\n-\t{ { BayerFormat::BGGR, 10, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10) },\n-\t{ { BayerFormat::GBRG, 10, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10) },\n-\t{ { BayerFormat::GRBG, 10, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10) },\n-\t{ { BayerFormat::RGGB, 10, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10) },\n-\t{ { BayerFormat::BGGR, 10, BayerFormat::CSI2Packed }, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P) },\n-\t{ { BayerFormat::GBRG, 10, BayerFormat::CSI2Packed }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P) },\n-\t{ { BayerFormat::GRBG, 10, BayerFormat::CSI2Packed }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P) },\n-\t{ { BayerFormat::RGGB, 10, BayerFormat::CSI2Packed }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P) },\n-\t{ { BayerFormat::BGGR, 10, BayerFormat::IPU3Packed }, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10) },\n-\t{ { BayerFormat::GBRG, 10, BayerFormat::IPU3Packed }, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10) },\n-\t{ { BayerFormat::GRBG, 10, BayerFormat::IPU3Packed }, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10) },\n-\t{ { BayerFormat::RGGB, 10, BayerFormat::IPU3Packed }, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10) },\n-\t{ { BayerFormat::BGGR, 12, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12) },\n-\t{ { BayerFormat::GBRG, 12, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12) },\n-\t{ { BayerFormat::GRBG, 12, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12) },\n-\t{ { BayerFormat::RGGB, 12, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12) },\n-\t{ { BayerFormat::BGGR, 12, BayerFormat::CSI2Packed }, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P) },\n-\t{ { BayerFormat::GBRG, 12, BayerFormat::CSI2Packed }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P) },\n-\t{ { BayerFormat::GRBG, 12, BayerFormat::CSI2Packed }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P) },\n-\t{ { BayerFormat::RGGB, 12, BayerFormat::CSI2Packed }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P) },\n-\t{ { BayerFormat::BGGR, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16) },\n-\t{ { BayerFormat::GBRG, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16) },\n-\t{ { BayerFormat::GRBG, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16) },\n-\t{ { BayerFormat::RGGB, 16, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16) },\n-\t{ { BayerFormat::MONO, 8, BayerFormat::None }, V4L2PixelFormat(V4L2_PIX_FMT_GREY) },\n-\t{ { BayerFormat::MONO, 10, BayerFormat::CSI2Packed }, 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::None },\n+\t\t{ formats::SBGGR8, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8) } },\n+\t{ { BayerFormat::GBRG, 8, BayerFormat::None },\n+\t\t{ formats::SGBRG8, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG8) } },\n+\t{ { BayerFormat::GRBG, 8, BayerFormat::None },\n+\t\t{ formats::SGRBG8, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG8) } },\n+\t{ { BayerFormat::RGGB, 8, BayerFormat::None },\n+\t\t{ formats::SRGGB8, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB8) } },\n+\t{ { BayerFormat::BGGR, 10, BayerFormat::None },\n+\t\t{ formats::SBGGR10, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10) } },\n+\t{ { BayerFormat::GBRG, 10, BayerFormat::None },\n+\t\t{ formats::SGBRG10, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10) } },\n+\t{ { BayerFormat::GRBG, 10, BayerFormat::None },\n+\t\t{ formats::SGRBG10, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10) } },\n+\t{ { BayerFormat::RGGB, 10, BayerFormat::None },\n+\t\t{ formats::SRGGB10, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10) } },\n+\t{ { BayerFormat::BGGR, 10, BayerFormat::CSI2Packed },\n+\t\t{ formats::SBGGR10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR10P) } },\n+\t{ { BayerFormat::GBRG, 10, BayerFormat::CSI2Packed },\n+\t\t{ formats::SGBRG10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG10P) } },\n+\t{ { BayerFormat::GRBG, 10, BayerFormat::CSI2Packed },\n+\t\t{ formats::SGRBG10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG10P) } },\n+\t{ { BayerFormat::RGGB, 10, BayerFormat::CSI2Packed },\n+\t\t{ formats::SRGGB10_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB10P) } },\n+\t{ { BayerFormat::BGGR, 10, BayerFormat::IPU3Packed },\n+\t\t{ formats::SBGGR10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10) } },\n+\t{ { BayerFormat::GBRG, 10, BayerFormat::IPU3Packed },\n+\t\t{ formats::SGBRG10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10) } },\n+\t{ { BayerFormat::GRBG, 10, BayerFormat::IPU3Packed },\n+\t\t{ formats::SGRBG10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10) } },\n+\t{ { BayerFormat::RGGB, 10, BayerFormat::IPU3Packed },\n+\t\t{ formats::SRGGB10_IPU3, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10) } },\n+\t{ { BayerFormat::BGGR, 12, BayerFormat::None },\n+\t\t{ formats::SBGGR12, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12) } },\n+\t{ { BayerFormat::GBRG, 12, BayerFormat::None },\n+\t\t{ formats::SGBRG12, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12) } },\n+\t{ { BayerFormat::GRBG, 12, BayerFormat::None },\n+\t\t{ formats::SGRBG12, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12) } },\n+\t{ { BayerFormat::RGGB, 12, BayerFormat::None },\n+\t\t{ formats::SRGGB12, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12) } },\n+\t{ { BayerFormat::BGGR, 12, BayerFormat::CSI2Packed },\n+\t\t{ formats::SBGGR12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR12P) } },\n+\t{ { BayerFormat::GBRG, 12, BayerFormat::CSI2Packed },\n+\t\t{ formats::SGBRG12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG12P) } },\n+\t{ { BayerFormat::GRBG, 12, BayerFormat::CSI2Packed },\n+\t\t{ formats::SGRBG12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG12P) } },\n+\t{ { BayerFormat::RGGB, 12, BayerFormat::CSI2Packed },\n+\t\t{ formats::SRGGB12_CSI2P, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB12P) } },\n+\t{ { BayerFormat::BGGR, 16, BayerFormat::None },\n+\t\t{ formats::SBGGR16, V4L2PixelFormat(V4L2_PIX_FMT_SBGGR16) } },\n+\t{ { BayerFormat::GBRG, 16, BayerFormat::None },\n+\t\t{ formats::SGBRG16, V4L2PixelFormat(V4L2_PIX_FMT_SGBRG16) } },\n+\t{ { BayerFormat::GRBG, 16, BayerFormat::None },\n+\t\t{ formats::SGRBG16, V4L2PixelFormat(V4L2_PIX_FMT_SGRBG16) } },\n+\t{ { BayerFormat::RGGB, 16, BayerFormat::None },\n+\t\t{ formats::SRGGB16, V4L2PixelFormat(V4L2_PIX_FMT_SRGGB16) } },\n+\t{ { BayerFormat::MONO, 8, BayerFormat::None },\n+\t\t{ formats::R8, V4L2PixelFormat(V4L2_PIX_FMT_GREY) } },\n+\t{ { BayerFormat::MONO, 10, BayerFormat::CSI2Packed },\n+\t\t{ formats::R10, 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", "v3", "3/9" ] }