Show a patch.

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

{
    "id": 15757,
    "url": "https://patchwork.libcamera.org/api/patches/15757/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/15757/",
    "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": "<20220429212348.18063-4-laurent.pinchart@ideasonboard.com>",
    "date": "2022-04-29T21:23:46",
    "name": "[libcamera-devel,3/5] libcamera: bayer_format: Add operator<<()",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "12ff2486a247e61ab1709655ed44bb4fff08820b",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/15757/mbox/",
    "series": [
        {
            "id": 3084,
            "url": "https://patchwork.libcamera.org/api/series/3084/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3084",
            "date": "2022-04-29T21:23:43",
            "name": "libcamera: More operator<<() for stream output",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3084/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/15757/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/15757/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 77F2DC326C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 29 Apr 2022 21:23:59 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 94E5C6564D;\n\tFri, 29 Apr 2022 23:23:57 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 22F1C65640\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 29 Apr 2022 23:23:54 +0200 (CEST)",
            "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AC586496;\n\tFri, 29 Apr 2022 23:23:53 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1651267437;\n\tbh=EFYgJqN43/rpkMEshDR1KwiP44TUYutlYEWmQsCPi8U=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=b6DabLdM2jPyKcxl8P+ktZ/b0TTQ+K4WUo8HcOYfDIrPNTMqrImpNClwA0Grc8ewO\n\tbw0EJfJSDCwQrTU3Dx5/8J82ZjXo6TeNrkGauATZRvG9ouK0Vln+YDth8/I7uzrtWC\n\tSNkj1EY8xgKBD+4OyD9DjIBqFCEqqU3jbWql2tbu9Kbkd6DezbsBYOMW8VWnO2LiyK\n\tmXIZIcAycr9FViGZuAtuIqfcBkbpKYeLY0k5xdNMaHKPJ3XODYmGkbZLZZ5/CSCDbQ\n\tnFivCzN1GVCBpJK3AjPvLYwvfGxn/Ba0UU08SCwaxOAMENclUcqw+N/qGp5HgkkjTP\n\tqZmLPLhEGXLQg==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1651267433;\n\tbh=EFYgJqN43/rpkMEshDR1KwiP44TUYutlYEWmQsCPi8U=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=AuXv9GlMlJLmfQBfAF1mOWZzuMPLqlPOdVzeYncmPhKcxXm4kAVMvAcSVFLrOaxN8\n\t7Pj66WRJhTo/kbYo/wi74kwCKTJevoBap3422bsCIVDIhpJqcHExz8S/dBJcEz/7K2\n\t5Ur+XJ3+370KT6yW8cLwOqeiblawBaEOzyGzNQM0="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"AuXv9GlM\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat, 30 Apr 2022 00:23:46 +0300",
        "Message-Id": "<20220429212348.18063-4-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.35.1",
        "In-Reply-To": "<20220429212348.18063-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20220429212348.18063-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 3/5] libcamera: bayer_format: Add\n\toperator<<()",
        "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>",
        "From": "Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Implement the stream output operator<<() for the BayerFormat class to\nsimplify printing them.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/bayer_format.h |  3 ++\n src/libcamera/bayer_format.cpp            | 57 ++++++++++++++---------\n 2 files changed, 39 insertions(+), 21 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h\nindex cb20bf9bea84..7d3e37c67e9c 100644\n--- a/include/libcamera/internal/bayer_format.h\n+++ b/include/libcamera/internal/bayer_format.h\n@@ -7,6 +7,7 @@\n \n #pragma once\n \n+#include <ostream>\n #include <stdint.h>\n #include <string>\n \n@@ -68,4 +69,6 @@ static inline bool operator!=(const BayerFormat &lhs, const BayerFormat &rhs)\n \treturn !(lhs == rhs);\n }\n \n+std::ostream &operator<<(std::ostream &out, const BayerFormat &f);\n+\n } /* namespace libcamera */\ndiff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp\nindex 9aaec0bce264..4882707e7763 100644\n--- a/src/libcamera/bayer_format.cpp\n+++ b/src/libcamera/bayer_format.cpp\n@@ -9,6 +9,7 @@\n \n #include <algorithm>\n #include <map>\n+#include <sstream>\n #include <unordered_map>\n \n #include <linux/media-bus-format.h>\n@@ -236,28 +237,10 @@ const BayerFormat &BayerFormat::fromMbusCode(unsigned int mbusCode)\n  */\n std::string BayerFormat::toString() const\n {\n-\tstd::string result;\n+\tstd::stringstream ss;\n+\tss << *this;\n \n-\tstatic const char *orderStrings[] = {\n-\t\t\"BGGR\",\n-\t\t\"GBRG\",\n-\t\t\"GRBG\",\n-\t\t\"RGGB\",\n-\t\t\"MONO\"\n-\t};\n-\tif (isValid() && order <= MONO)\n-\t\tresult = orderStrings[order];\n-\telse\n-\t\treturn \"INVALID\";\n-\n-\tresult += \"-\" + std::to_string(bitDepth);\n-\n-\tif (packing == Packing::CSI2)\n-\t\tresult += \"-CSI2P\";\n-\telse if (packing == Packing::IPU3)\n-\t\tresult += \"-IPU3P\";\n-\n-\treturn result;\n+\treturn ss.str();\n }\n \n /**\n@@ -270,6 +253,38 @@ bool operator==(const BayerFormat &lhs, const BayerFormat &rhs)\n \t       lhs.packing == rhs.packing;\n }\n \n+/**\n+ * \\brief Insert a text representation of a BayerFormats into an output stream\n+ * \\param[in] out The output stream\n+ * \\param[in] f The BayerFormat\n+ * \\return The output stream \\a out\n+ */\n+std::ostream &operator<<(std::ostream &out, const BayerFormat &f)\n+{\n+\tstatic const char *orderStrings[] = {\n+\t\t\"BGGR-\",\n+\t\t\"GBRG-\",\n+\t\t\"GRBG-\",\n+\t\t\"RGGB-\",\n+\t\t\"MONO-\"\n+\t};\n+\n+\tif (!f.isValid() || f.order > BayerFormat::MONO) {\n+\t\tout << \"INVALID\";\n+\t\treturn out;\n+\t}\n+\n+\t/* The cast is required to avoid bitDepth being interpreted as a char. */\n+\tout << orderStrings[f.order] << static_cast<unsigned int>(f.bitDepth);\n+\n+\tif (f.packing == BayerFormat::Packing::CSI2)\n+\t\tout << \"-CSI2P\";\n+\telse if (f.packing == BayerFormat::Packing::IPU3)\n+\t\tout << \"-IPU3P\";\n+\n+\treturn out;\n+}\n+\n /**\n  * \\fn bool operator!=(const BayerFormat &lhs, const BayerFormat &rhs)\n  * \\brief Compare two BayerFormats for inequality\n",
    "prefixes": [
        "libcamera-devel",
        "3/5"
    ]
}