Patch Detail
Show a patch.
GET /api/1.1/patches/3853/?format=api
{ "id": 3853, "url": "https://patchwork.libcamera.org/api/1.1/patches/3853/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3853/", "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": "<20200525173540.GA21069@kaaira-HP-Pavilion-Notebook>", "date": "2020-05-25T17:35:40", "name": "[libcamera-devel,v3] libcamera: PixelFormat: Replace hex with fourcc and modifiers", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "c34dd3418901482bddb7107a49d401cd482b687a", "submitter": { "id": 39, "url": "https://patchwork.libcamera.org/api/1.1/people/39/?format=api", "name": "Kaaira Gupta", "email": "kgupta@es.iitr.ac.in" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/3853/mbox/", "series": [ { "id": 926, "url": "https://patchwork.libcamera.org/api/1.1/series/926/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=926", "date": "2020-05-25T17:35:40", "name": "[libcamera-devel,v3] libcamera: PixelFormat: Replace hex with fourcc and modifiers", "version": 3, "mbox": "https://patchwork.libcamera.org/series/926/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3853/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3853/checks/", "tags": {}, "headers": { "Return-Path": "<kgupta@es.iitr.ac.in>", "Received": [ "from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com\n\t[IPv6:2607:f8b0:4864:20::42d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A2240603D4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 25 May 2020 19:35:48 +0200 (CEST)", "by mail-pf1-x42d.google.com with SMTP id x13so9033517pfn.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 25 May 2020 10:35:48 -0700 (PDT)", "from kaaira-HP-Pavilion-Notebook ([103.113.213.155])\n\tby smtp.gmail.com with ESMTPSA id\n\tmn19sm13179907pjb.8.2020.05.25.10.35.44\n\t(version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256);\n\tMon, 25 May 2020 10:35:45 -0700 (PDT)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=es-iitr-ac-in.20150623.gappssmtp.com\n\theader.i=@es-iitr-ac-in.20150623.gappssmtp.com header.b=\"FMZ3RJWi\"; \n\tdkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:subject:message-id:mime-version:content-disposition\n\t:user-agent; bh=7XroT1pD2HdjQKyPTxfnK8yjAt7J6AFqtTZSKwOcPL4=;\n\tb=FMZ3RJWiIy/p8OhpBgjRHrWCa8ZrDrssa7nTcSA4e+tpPEARX7cfYLzWwIglfGO7J4\n\tV5qL1tKZU5tTXOoc3sXXl+PSgLVaKXIFySDTuiK3Zn/2QK8HKl+eXPEDgowXkAQjZgDk\n\tkkqCk5IMn8C68JbfpKch6ArfoIGWvRDZCaVSiIJBID/ASMOD+hBCWthpMs/NiSLp81m1\n\tFHF4YUi4R0mxM/ACvndNLjQlCKuHMGQMzYjlDOYtdFtmNtikMjzUFakCQSr1GCD5wJul\n\tHWZASloVvfNXBjRRXhwQA88MnCRjvggeA2fdvhwzl5jN5fzptCeSiOYllygG+oFmqEQG\n\tI55w==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:subject:message-id:mime-version\n\t:content-disposition:user-agent;\n\tbh=7XroT1pD2HdjQKyPTxfnK8yjAt7J6AFqtTZSKwOcPL4=;\n\tb=cXmBV+PVuNh7AApkKzRnu8+sD1o75WpJ3pGu2BVpe5NvcG/SBaywlY5xpnFWTFUW8W\n\tAhu9UDedRJ1NwpFeHCFqXHg/jiQJV6atvgSZa1wFYjFlK06CFV6eCEZH9aD+gKV35Rvq\n\tGCN6po9Fznyw73DR+P4cNVZm6acvqPldHYE7oak+hhbUNus6YXrX6RPDB5XnewzvtAg7\n\tUCotfyj/RDflTEECCeJIxJRqCzEhvs0FFN9sRJsYYLwzF3J8uM8dTc3mDxchR37AphQk\n\tKTgqzVxYH+5ZXSCCW+Ot2OpzZfW0NzfxCzPLl5TqUU8+FkuPU0aYi3S1QNeP2ZG4ruPj\n\tO0Kg==", "X-Gm-Message-State": "AOAM530siD0q6ZRkWFzBJuATYaoUkKv8jDqUKKWuvbj/U0iWG7NtwM6a\n\t9sDXDF4hpuNa7dgv+MHwsdDGN3gu6Zngyg==", "X-Google-Smtp-Source": "ABdhPJyuQ8SxExAX/KqznDbvbEWDlzaKD8tQUxMHWXDq/tFctZkSC/QkB12Aq/VS3JCh7Sa/wLZNbg==", "X-Received": "by 2002:a62:6404:: with SMTP id y4mr17311901pfb.64.1590428146433;\n\tMon, 25 May 2020 10:35:46 -0700 (PDT)", "Date": "Mon, 25 May 2020 23:05:40 +0530", "From": "Kaaira Gupta <kgupta@es.iitr.ac.in>", "To": "libcamera-devel@lists.libcamera.org,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>", "Message-ID": "<20200525173540.GA21069@kaaira-HP-Pavilion-Notebook>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=us-ascii", "Content-Disposition": "inline", "User-Agent": "Mutt/1.9.4 (2018-02-28)", "Subject": "[libcamera-devel] [PATCH v3] libcamera: PixelFormat: Replace hex\n\twith fourcc and modifiers", "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>", "X-List-Received-Date": "Mon, 25 May 2020 17:35:49 -0000" }, "content": "Print fourCC characters instead of the hex values in toString() as they\nare easier to comprehend. Also, print the corresponding modifiers of the\nDRM formats so that it can be more specific.\n\nDescribe the modifiers for MIPI vendor as it is mostly used in\nlibcamera. Print digits for the rest.\n\nSigned-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>\n---\n\nChanges since v2:\n\t- Remove description for all vendors except for MIPI\n\t- Change commit message to reflect this change.\n\t- Change tests accordingly.\n\nChanges since v1:\n\t- Replaced magic numbers with expressive values.\n\t- Re-wrote ARM vendor's modifiers\n\t- Re-wrote the vendors' map with a macro.\n\t- Changed the copyrights in test file.\n\t- Changed the tests.\n\n src/libcamera/pixelformats.cpp | 65 ++++++++++++++++++++++++++++++++--\n test/meson.build | 1 +\n test/pixel-format.cpp | 47 ++++++++++++++++++++++++\n 3 files changed, 110 insertions(+), 3 deletions(-)\n create mode 100644 test/pixel-format.cpp", "diff": "diff --git a/src/libcamera/pixelformats.cpp b/src/libcamera/pixelformats.cpp\nindex 1330dc5..e16f5ba 100644\n--- a/src/libcamera/pixelformats.cpp\n+++ b/src/libcamera/pixelformats.cpp\n@@ -6,6 +6,11 @@\n */\n \n #include <libcamera/pixelformats.h>\n+#include <map>\n+#include <string.h>\n+\n+#define PIXELFORMAT_VENDOR(vendor)\t\t \\\n+\t{ DRM_FORMAT_MOD_VENDOR_## vendor, #vendor }\n \n /**\n * \\file pixelformats.h\n@@ -108,9 +113,63 @@ bool PixelFormat::operator<(const PixelFormat &other) const\n */\n std::string PixelFormat::toString() const\n {\n-\tchar str[11];\n-\tsnprintf(str, 11, \"0x%08x\", fourcc_);\n-\treturn str;\n+\tif (fourcc_ == DRM_FORMAT_INVALID)\n+\t\treturn \"<INVALID>\";\n+\n+\tchar ss[8] = { static_cast<char>(fourcc_ & 0x7f),\n+\t\t static_cast<char>((fourcc_ >> 8) & 0x7f),\n+\t\t static_cast<char>((fourcc_ >> 16) & 0x7f),\n+\t\t static_cast<char>((fourcc_ >> 24) & 0x7f) };\n+\n+\tfor (unsigned int i = 0; i < 4; i++) {\n+\t\tif (!isprint(ss[i]))\n+\t\t\tss[i] = '.';\n+\t}\n+\n+\tif (fourcc_ & (1 << 31))\n+\t\tstrcat(ss, \"-BE\");\n+\n+\tstd::string modifier;\n+\n+\tif (modifier_ == DRM_FORMAT_MOD_INVALID) {\n+\t\tmodifier = \" - <INVALID> modifier\";\n+\t\treturn ss + modifier;\n+\t}\n+\n+\t/* Map vendors with their Ids: */\n+\tstd::map<long int, std::string> vendors = {\n+\t\tPIXELFORMAT_VENDOR(NONE),\n+\t\tPIXELFORMAT_VENDOR(MIPI)\n+\t};\n+\n+\t/* Get the vendor name using its Id */\n+\tlong int vendorCode = (modifier_ >> 56) & 0xff;\n+\tstd::string vendor;\n+\tstd::string vendorSpecification;\n+\n+\tswitch (vendorCode) {\n+\tcase DRM_FORMAT_MOD_VENDOR_NONE: {\n+\t\tvendor = vendors[vendorCode];\n+\t\tif (modifier_ == DRM_FORMAT_MOD_LINEAR)\n+\t\t\tvendorSpecification = \"Linear Layout\";\n+\t\tbreak;\n+\t}\n+\tcase DRM_FORMAT_MOD_VENDOR_MIPI: {\n+\t\tvendor = vendors[vendorCode];\n+\t\tif (modifier_ == MIPI_FORMAT_MOD_CSI2_PACKED)\n+\t\t\tvendorSpecification = \"CSI-2 packed\";\n+\t\tbreak;\n+\t}\n+\tdefault: {\n+\t\tvendor = std::to_string(vendorCode);\n+\t\tvendorSpecification = std::to_string(modifier_ & 0xff);\n+\t}\n+\t}\n+\n+\tmodifier = vendor + \" : \" + vendorSpecification;\n+\tstd::string formatString(ss);\n+\n+\treturn formatString + \" - \" + modifier;\n }\n \n } /* namespace libcamera */\ndiff --git a/test/meson.build b/test/meson.build\nindex bd7da14..591d848 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -33,6 +33,7 @@ internal_tests = [\n ['message', 'message.cpp'],\n ['object', 'object.cpp'],\n ['object-invoke', 'object-invoke.cpp'],\n+ ['pixel-format', 'pixel-format.cpp'],\n ['signal-threads', 'signal-threads.cpp'],\n ['threads', 'threads.cpp'],\n ['timer', 'timer.cpp'],\ndiff --git a/test/pixel-format.cpp b/test/pixel-format.cpp\nnew file mode 100644\nindex 0000000..edada56\n--- /dev/null\n+++ b/test/pixel-format.cpp\n@@ -0,0 +1,47 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2020, Kaaira Gupta\n+ * libcamera pixel format handling test\n+ */\n+\n+#include <iostream>\n+#include <vector>\n+\n+#include \"libcamera/pixelformats.h\"\n+\n+#include \"test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+class PixelFormatTest : public Test\n+{\n+protected:\n+\tint run()\n+\t{\n+\t\tstd::vector<std::pair<PixelFormat, const char *>> formats{\n+\t\t\t{ PixelFormat(DRM_FORMAT_SRGGB8, DRM_FORMAT_MOD_INVALID), \"RGGB - <INVALID> modifier\" },\n+\t\t\t{ PixelFormat(DRM_FORMAT_SRGGB8, DRM_FORMAT_MOD_LINEAR), \"RGGB - NONE : Linear Layout\" },\n+\t\t\t{ PixelFormat(DRM_FORMAT_C8, DRM_FORMAT_MOD_SAMSUNG_64_32_TILE ), \"C8 - 4 : 1\" },\n+\t\t\t{ PixelFormat(DRM_FORMAT_BIG_ENDIAN,MIPI_FORMAT_MOD_CSI2_PACKED),\"....-BE - MIPI : CSI-2 packed\"}\n+\t\t};\n+\t\tfor (const auto &format : formats) {\n+\t\t\tif ((format.first).toString() != format.second) {\n+\t\t\t\tcerr << \"Failed to convert PixelFormat \"\n+\t\t\t\t << format.first.fourcc() << \" to string\"\n+\t\t\t\t << endl;\n+\t\t\t\treturn TestFail;\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (PixelFormat().toString() != \"<INVALID>\") {\n+\t\t\tcerr << \"Failed to convert default PixelFormat to string\"\n+\t\t\t << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+};\n+\n+TEST_REGISTER(PixelFormatTest)\n", "prefixes": [ "libcamera-devel", "v3" ] }