Show a patch.

GET /api/1.1/patches/11024/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 11024,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/11024/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/11024/",
    "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": "<20210126184854.46156-2-sebastian.fricke@posteo.net>",
    "date": "2021-01-26T18:48:50",
    "name": "[libcamera-devel,v3,1/5] libcamera: Add the fromV4L2PixelFormat function",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "13126308aa45f9a33f2481099826a4555b4b5c0a",
    "submitter": {
        "id": 78,
        "url": "https://patchwork.libcamera.org/api/1.1/people/78/?format=api",
        "name": "Sebastian Fricke",
        "email": "sebastian.fricke@posteo.net"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/11024/mbox/",
    "series": [
        {
            "id": 1613,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1613/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1613",
            "date": "2021-01-26T18:48:49",
            "name": "Improve BayerFormat class",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/1613/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/11024/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/11024/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 2FF92C0F2B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 26 Jan 2021 18:49:07 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F2B736831F;\n\tTue, 26 Jan 2021 19:49:06 +0100 (CET)",
            "from mout01.posteo.de (mout01.posteo.de [185.67.36.65])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 352E668318\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Jan 2021 19:49:06 +0100 (CET)",
            "from submission (posteo.de [89.146.220.130]) \n\tby mout01.posteo.de (Postfix) with ESMTPS id B77D9160063\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Jan 2021 19:49:05 +0100 (CET)",
            "from customer (localhost [127.0.0.1])\n\tby submission (posteo.de) with ESMTPSA id 4DQG3h6pF7z6tm9;\n\tTue, 26 Jan 2021 19:49:04 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=posteo.net header.i=@posteo.net\n\theader.b=\"KRMUj23m\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;\n\tt=1611686945; bh=pVuAQnOqNuAWBI3sg8dF4GMG/86bozPkwcNbIwDQFIA=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=KRMUj23mYrAuFocdpRf8KgpnnNoQIKST/Bm0GJDQqMxuh8a5N8SnpDI1W/Vqa8wHx\n\taI/gvmtZqIY0vFFBT50WrbJVk5n1I76eBxthMMEBZ4DwcJuXX+YWpTX65Ppz6ZCltq\n\t1g+tEC680NaEkCzK7pTB+pYQb70vuRq7/B7Qn6janO7HnUj7hgBmw877rSrc5Gh7w7\n\tzLQP5UuSfTOhTPqKgxDvqkYkpvW4sjDwGwtq1Q+9sjJ8zNltox+mDvQbrba0tiayUi\n\t00tF4xJqWl4DpqUcqYQhZOWvOM8go4AO0xSG8bQAkOJKceC4KbarTUhq5tR3Ytd192\n\t/xzp9Ge3eoBvA==",
        "From": "Sebastian Fricke <sebastian.fricke@posteo.net>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 26 Jan 2021 19:48:50 +0100",
        "Message-Id": "<20210126184854.46156-2-sebastian.fricke@posteo.net>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20210126184854.46156-1-sebastian.fricke@posteo.net>",
        "References": "<20210126184854.46156-1-sebastian.fricke@posteo.net>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v3 1/5] libcamera: Add the\n\tfromV4L2PixelFormat function",
        "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>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Add a static member function to get the corresponding BayerFormat\nfrom a given V4L2PixelFormat.\nThe motivation behind this patch is to align the overall structure\nof the BayerFormat class with other parts of the code base, such as\nthe V4L2PixelFormat class.\n\nThe downside of this change is a slightly worse time complexity, but\nthe upside is a smaller codebase and lower memory consumption. As the\nfunction is probably not used very frequently, I tend to favor the\nmentioned upsides.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Sebastian Fricke <sebastian.fricke@posteo.net>\n---\n include/libcamera/internal/bayer_format.h      |  1 +\n src/libcamera/bayer_format.cpp                 | 18 ++++++++++++++++++\n .../pipeline/raspberrypi/raspberrypi.cpp       |  4 ++--\n 3 files changed, 21 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h\nindex dc86f6ee..4f338bd7 100644\n--- a/include/libcamera/internal/bayer_format.h\n+++ b/include/libcamera/internal/bayer_format.h\n@@ -49,6 +49,7 @@ public:\n \tstd::string toString() const;\n \n \tV4L2PixelFormat toV4L2PixelFormat() const;\n+\tstatic BayerFormat fromV4L2PixelFormat(V4L2PixelFormat v4l2Format);\n \tBayerFormat transform(Transform t) const;\n \n \tOrder order;\ndiff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp\nindex a6a40be0..9eb83898 100644\n--- a/src/libcamera/bayer_format.cpp\n+++ b/src/libcamera/bayer_format.cpp\n@@ -7,6 +7,7 @@\n \n #include \"libcamera/internal/bayer_format.h\"\n \n+#include <algorithm>\n #include <map>\n #include <unordered_map>\n \n@@ -272,6 +273,23 @@ V4L2PixelFormat BayerFormat::toV4L2PixelFormat() const\n \treturn V4L2PixelFormat();\n }\n \n+/**\n+ * \\brief Convert \\a v4l2Format to the corresponding BayerFormat\n+ * \\param[in] v4l2Format The raw format to convert into a BayerFormat\n+ * \\return The BayerFormat corresponding to \\a v4l2Format\n+ */\n+BayerFormat BayerFormat::fromV4L2PixelFormat(V4L2PixelFormat v4l2Format)\n+{\n+\tauto it = std::find_if(bayerToV4l2.begin(), bayerToV4l2.end(),\n+\t\t\t       [v4l2Format](const auto &i) {\n+\t\t\t\t       return i.second == v4l2Format;\n+\t\t\t       });\n+\tif (it != bayerToV4l2.end())\n+\t\treturn it->first;\n+\n+\treturn BayerFormat();\n+}\n+\n /**\n  * \\brief Apply a transform to this BayerFormat\n  * \\param[in] t The transform to apply\ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 524cc960..236aa107 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -358,7 +358,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \t\t\t */\n \t\t\tV4L2PixelFormat fourcc = sensorFormat.fourcc;\n \t\t\tif (data_->flipsAlterBayerOrder_) {\n-\t\t\t\tBayerFormat bayer(fourcc);\n+\t\t\t\tBayerFormat bayer = BayerFormat::fromV4L2PixelFormat(fourcc);\n \t\t\t\tbayer.order = data_->nativeBayerOrder_;\n \t\t\t\tbayer = bayer.transform(combined);\n \t\t\t\tfourcc = bayer.toV4L2PixelFormat();\n@@ -1007,7 +1007,7 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator)\n \tBayerFormat bayerFormat;\n \tfor (const auto &iter : dev->formats()) {\n \t\tV4L2PixelFormat v4l2Format = iter.first;\n-\t\tbayerFormat = BayerFormat(v4l2Format);\n+\t\tbayerFormat = BayerFormat::fromV4L2PixelFormat(v4l2Format);\n \t\tif (bayerFormat.isValid())\n \t\t\tbreak;\n \t}\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "1/5"
    ]
}