Show a patch.

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

{
    "id": 8778,
    "url": "https://patchwork.libcamera.org/api/patches/8778/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/8778/",
    "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": "<20200714104212.48683-4-jacopo@jmondi.org>",
    "date": "2020-07-14T10:41:55",
    "name": "[libcamera-devel,03/20] libcamera: utils: Add alignUp and alignDown functions",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "1777d9c21edcfaf819ae76b7c1f3ae5cc9b5dfe2",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/8778/mbox/",
    "series": [
        {
            "id": 1104,
            "url": "https://patchwork.libcamera.org/api/series/1104/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1104",
            "date": "2020-07-14T10:41:52",
            "name": "libcamera: ipu3: Rework pipe configuration",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1104/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/8778/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/8778/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 00910BD792\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 14 Jul 2020 10:38:52 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 90E6860889;\n\tTue, 14 Jul 2020 12:38:51 +0200 (CEST)",
            "from relay10.mail.gandi.net (relay10.mail.gandi.net\n\t[217.70.178.230])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B937E60486\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 14 Jul 2020 12:38:49 +0200 (CEST)",
            "from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay10.mail.gandi.net (Postfix) with ESMTPSA id 5C15A240011;\n\tTue, 14 Jul 2020 10:38:49 +0000 (UTC)"
        ],
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 14 Jul 2020 12:41:55 +0200",
        "Message-Id": "<20200714104212.48683-4-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.27.0",
        "In-Reply-To": "<20200714104212.48683-1-jacopo@jmondi.org>",
        "References": "<20200714104212.48683-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH 03/20] libcamera: utils: Add alignUp and\n\talignDown functions",
        "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 to libcamera utils library two functions to round up or down a\nvalue to an alignment and add a test in test/utils.cpp for the two\nnew functions.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/internal/utils.h |  3 +++\n src/libcamera/utils.cpp            | 22 ++++++++++++++++++++++\n test/utils.cpp                     | 18 ++++++++++++++++++\n 3 files changed, 43 insertions(+)",
    "diff": "diff --git a/include/libcamera/internal/utils.h b/include/libcamera/internal/utils.h\nindex 8d026cc6c0fe..25eb24ec2d16 100644\n--- a/include/libcamera/internal/utils.h\n+++ b/include/libcamera/internal/utils.h\n@@ -200,6 +200,9 @@ details::StringSplitter split(const std::string &str, const std::string &delim);\n std::string libcameraBuildPath();\n std::string libcameraSourcePath();\n \n+unsigned int alignUp(unsigned int value, unsigned int alignment);\n+unsigned int alignDown(unsigned int value, unsigned int alignment);\n+\n } /* namespace utils */\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\nindex 0567328fe31b..52fb0bb171d8 100644\n--- a/src/libcamera/utils.cpp\n+++ b/src/libcamera/utils.cpp\n@@ -444,6 +444,28 @@ std::string libcameraSourcePath()\n \treturn path + \"/\";\n }\n \n+/**\n+ * \\brief Align \\a value to \\a alignment\n+ * \\param[in] value The value to align\n+ * \\param[in] alignment The alignment\n+ * \\return The value rounded up to the nearest multiple of \\a alignment\n+ */\n+unsigned int alignUp(unsigned int value, unsigned int alignment)\n+{\n+\treturn (value + alignment - 1) / alignment * alignment;\n+}\n+\n+/**\n+ * \\brief Align \\a value to \\a alignment\n+ * \\param[in] value The value to align\n+ * \\param[in] alignment The alignment\n+ * \\return The value rounded down to the nearest multiple of \\a alignment\n+ */\n+unsigned int alignDown(unsigned int value, unsigned int alignment)\n+{\n+\treturn value / alignment * alignment;\n+}\n+\n } /* namespace utils */\n \n } /* namespace libcamera */\ndiff --git a/test/utils.cpp b/test/utils.cpp\nindex f482e6a1d829..02054f46b00e 100644\n--- a/test/utils.cpp\n+++ b/test/utils.cpp\n@@ -7,6 +7,7 @@\n \n #include <iostream>\n #include <map>\n+#include <random>\n #include <sstream>\n #include <string>\n #include <vector>\n@@ -166,6 +167,23 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n+\t\t/* utils::alignUp() and utils::alignDown() tests. */\n+\t\trandom_device random;\n+\t\tunsigned int val = random();\n+\t\tunsigned int align = random() % (val / 10);\n+\t\tunsigned int roundUp = (val + align - 1) / align;\n+\t\tunsigned int roundDown = val / align;\n+\n+\t\tif (utils::alignUp(val, align) != align * roundUp) {\n+\t\t\tcerr << \"utils::alignUp test failed\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (utils::alignDown(val, align) != align * roundDown) {\n+\t\t\tcerr << \"utils::alignDown test failed\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n \t\treturn TestPass;\n \t}\n };\n",
    "prefixes": [
        "libcamera-devel",
        "03/20"
    ]
}