Show a patch.

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

{
    "id": 16579,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/16579/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16579/",
    "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": "<20220708222838.370187-3-umang.jain@ideasonboard.com>",
    "date": "2022-07-08T22:28:38",
    "name": "[libcamera-devel,2/2] utils: ipu3-pack: Provide a 10-bit bayer packing utility",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "efdee240d5e0cfb8a6edb5a45de2384c0e37ee92",
    "submitter": {
        "id": 86,
        "url": "https://patchwork.libcamera.org/api/1.1/people/86/?format=api",
        "name": "Umang Jain",
        "email": "umang.jain@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/16579/mbox/",
    "series": [
        {
            "id": 3266,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3266/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3266",
            "date": "2022-07-08T22:28:36",
            "name": "IPU3 Pack utility",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3266/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16579/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16579/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 0EFD3BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  8 Jul 2022 22:28:58 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BBE1663313;\n\tSat,  9 Jul 2022 00:28:57 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5C6A56330E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  9 Jul 2022 00:28:56 +0200 (CEST)",
            "from perceval.ideasonboard.com (unknown\n\t[IPv6:2401:4900:1f3f:82b9:3739:ca3a:12d7:3721])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 53BE647C;\n\tSat,  9 Jul 2022 00:28:55 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657319337;\n\tbh=oa0MoHQXJ+F67fOjiqepqf8fX5pISTbSEvBJ0vzHlUQ=;\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=mNau+Xr0lVC/pEmTfZeD5CKrsBewmxjwp9unGYLKGUHYwpuTX0VsQwK7NcEW6XPiV\n\tsjab2x3HqYEztvNZGU3BsFzc+toX/lXxwvOGE7Sg07z5IO1kF838sRSP9oOcrt+dfC\n\t3Xy7nHfurbZiCa3Ycdt6ovuZLbAKDjT+p7VaQ8Z7TGhFdXNuqPvi8h1Tbfn9X7UD/V\n\tIenrEwhNQv6sJpKoTX/8Lt8GsGvcwgks/4IbQ1bpVJtxFRmy+P+wU0BbOFFeEtBB7n\n\tRMSpq8L59QeGhcvIkXnby/CJIC1WoFUL3pqqbJq2aEO14pv6ozF7nJhlcidM3lkKZR\n\tJG95BjC9vPRKA==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1657319336;\n\tbh=oa0MoHQXJ+F67fOjiqepqf8fX5pISTbSEvBJ0vzHlUQ=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=CeY2FPUpOoqF7sS/Z20mYBCEPm3tw5CigPpWF9evSXRBJm/zF3OpzMQO9pxmTY/Vw\n\tCmN6/eMOJmLwXf3eYsQfA7RB2Pm4G9HmMz2MdzXMWgAHshSVvffYHDIuKB8hSyKRLN\n\tm5gM/gHC+Jt09PCM/nJD37LZagAMBHbjVgO5TTHk="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"CeY2FPUp\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat,  9 Jul 2022 03:58:38 +0530",
        "Message-Id": "<20220708222838.370187-3-umang.jain@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.31.1",
        "In-Reply-To": "<20220708222838.370187-1-umang.jain@ideasonboard.com>",
        "References": "<20220708222838.370187-1-umang.jain@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 2/2] utils: ipu3-pack: Provide a 10-bit\n\tbayer packing utility",
        "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": "Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Umang Jain <umang.jain@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Provide a 10-bit bayer packing utility for the unpacked data produced\nby ipu3-unpack. Single or multiple input unpacked files can be packed\nand concatenated together in a single output file.\n\nUse-case where this is useful is streaming IMGU with different\ntest patterns on each frame. The output file generated by\nipu3-pack can be directly fed to IMGU.\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n utils/ipu3/ipu3-pack.c | 129 +++++++++++++++++++++++++++++++++++++++++\n utils/ipu3/meson.build |   1 +\n 2 files changed, 130 insertions(+)\n create mode 100644 utils/ipu3/ipu3-pack.c",
    "diff": "diff --git a/utils/ipu3/ipu3-pack.c b/utils/ipu3/ipu3-pack.c\nnew file mode 100644\nindex 00000000..48193f74\n--- /dev/null\n+++ b/utils/ipu3/ipu3-pack.c\n@@ -0,0 +1,129 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * ipu3-pack - Pack IPU3 raw Bayer format to 10-bit Bayer\n+ *\n+ * Copyright 2022 Umang Jain <umang.jain@ideasonboard.com>\n+ */\n+#define _GNU_SOURCE\n+\n+#include <errno.h>\n+#include <fcntl.h>\n+#include <stdbool.h>\n+#include <stdint.h>\n+#include <stdio.h>\n+#include <string.h>\n+#include <sys/stat.h>\n+#include <sys/types.h>\n+#include <unistd.h>\n+\n+static void usage(const char *argv0)\n+{\n+\tprintf(\"Usage: %s input-file(s) -o output-file\\n\", basename(argv0));\n+\tprintf(\"Pack the IPU3 raw Bayer format to 10-bit Bayer\\n\");\n+}\n+\n+int packInputFile(int in_fd, int out_fd)\n+{\n+\tint ret = 0;\n+\n+\twhile (1) {\n+\t\tuint16_t in_data[25];\n+\t\tuint8_t out_data[32];\n+\t\tunsigned int i;\n+\n+\t\tret = read(in_fd, in_data, 50);\n+\t\tif (ret == -1) {\n+\t\t\tfprintf(stderr, \"Failed to read input data: %s\\n\",\n+\t\t\t\tstrerror(errno));\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tif (ret < 50) {\n+\t\t\tif (ret != 0)\n+\t\t\t\tfprintf(stderr, \"%u bytes of stray data at end of input\\n\",\n+\t\t\t\t\tret);\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tfor (i = 0; i < 32; ++i) {\n+\t\t\tunsigned int index = (i * 8) / 10;\n+\t\t\tunsigned int msb_shift = (i * 8) % 10;\n+\t\t\tunsigned int lsb_shift = 10 - msb_shift;\n+\n+\t\t\tout_data[i] = ((in_data[index] >> msb_shift) & 0xff)\n+\t\t\t\t    | ((in_data[index+1] << lsb_shift) & 0xff);\n+\t\t}\n+\n+\t\t/* 6 MSB are padding on the 32nd byte. */\n+\t\tout_data[31] = out_data[31] & 0x03;\n+\n+\t\tret = write(out_fd, out_data, 32);\n+\t\tif (ret < -1) {\n+\t\t\tfprintf(stderr, \"Failed to write output data: %s\\n\",\n+\t\t\t\tstrerror(errno));\n+\t\t\treturn ret;\n+\t\t}\n+\t}\n+\n+\treturn ret;\n+}\n+int main(int argc, char *argv[])\n+{\n+\tint input_files = argc - 3;\n+\tint in_fds[input_files];\n+\tint out_fd = -1;\n+\tint j = 1;\n+\tint ret;\n+\tbool oFlag = false;\n+\n+\tif (argc < 4) {\n+\t\tusage(argv[0]);\n+\t\treturn 1;\n+\t}\n+\n+\twhile (j < argc) {\n+\t\tif (strcmp(argv[j], \"-o\") == 0) {\n+\t\t\toFlag = true;\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tint fd = open(argv[j], O_RDONLY);\n+\t\tif (fd == -1) {\n+\t\t\tfprintf(stderr, \"Failed to open input file '%s': %s\\n\",\n+\t\t\t\targv[j], strerror(errno));\n+\t\t\tgoto done;\n+\t\t}\n+\n+\t\tin_fds[j - 1] = fd;\n+\t\tj++;\n+\t}\n+\n+\tif (!oFlag) {\n+\t\tfprintf(stderr, \"Missing option '-o' for output file\\n\");\n+\t\tusage(argv[0]);\n+\t\tgoto done;\n+\t}\n+\n+\tout_fd = open(argv[++j], O_WRONLY | O_TRUNC | O_CREAT, 0644);\n+\tif (out_fd == -1) {\n+\t\tfprintf(stderr, \"Failed to open output file '%s': %s\\n\",\n+\t\t\targv[j], strerror(errno));\n+\t\tgoto done;\n+\t}\n+\n+\tfor (j = 0; j < input_files; j++) {\n+\t\tret = packInputFile(in_fds[j], out_fd);\n+\t\tif (ret < 0) {\n+\t\t\tfprintf(stderr, \"Error packing input file '%s'\\n\",\n+\t\t\t\targv[j + 1]);\n+\t\t\tgoto done;\n+\t\t}\n+\t}\n+\n+done:\n+\tfor (j = 0; j < input_files; j++)\n+\t\tclose(in_fds[j]);\n+\tclose(out_fd);\n+\n+\treturn ret ? 1 : 0;\n+}\ndiff --git a/utils/ipu3/meson.build b/utils/ipu3/meson.build\nindex 88049f58..c92cc658 100644\n--- a/utils/ipu3/meson.build\n+++ b/utils/ipu3/meson.build\n@@ -1,3 +1,4 @@\n # SPDX-License-Identifier: CC0-1.0\n \n+ipu3_pack = executable('ipu3-pack', 'ipu3-pack.c')\n ipu3_unpack = executable('ipu3-unpack', 'ipu3-unpack.c')\n",
    "prefixes": [
        "libcamera-devel",
        "2/2"
    ]
}