Show a patch.

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

{
    "id": 3324,
    "url": "https://patchwork.libcamera.org/api/patches/3324/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3324/",
    "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": "<20200326093327.GA9015@kaaira-HP-Pavilion-Notebook>",
    "date": "2020-03-26T09:33:28",
    "name": "[libcamera-devel,v3] libcamera: v4l2PixelFormat: Replace hex with fourCC",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "159ede1268d0bbcd81e0c5e6901c5288ef8240b1",
    "submitter": {
        "id": 39,
        "url": "https://patchwork.libcamera.org/api/people/39/?format=api",
        "name": "Kaaira Gupta",
        "email": "kgupta@es.iitr.ac.in"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/3324/mbox/",
    "series": [
        {
            "id": 778,
            "url": "https://patchwork.libcamera.org/api/series/778/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=778",
            "date": "2020-03-26T09:33:28",
            "name": "[libcamera-devel,v3] libcamera: v4l2PixelFormat: Replace hex with fourCC",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/778/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3324/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3324/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<kgupta@es.iitr.ac.in>",
        "Received": [
            "from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com\n\t[IPv6:2607:f8b0:4864:20::102b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 895886040F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Mar 2020 10:33:37 +0100 (CET)",
            "by mail-pj1-x102b.google.com with SMTP id m15so2161422pje.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Mar 2020 02:33:37 -0700 (PDT)",
            "from kaaira-HP-Pavilion-Notebook ([103.113.213.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tz12sm1295368pfj.144.2020.03.26.02.33.32\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tThu, 26 Mar 2020 02:33:34 -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=\"St+VX9RY\"; \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:cc:subject:message-id:mime-version:content-disposition\n\t:user-agent; bh=WFlzpCI76ANsb4EigRR1xgFyxwpl3Mnx/68zZ2RkrL4=;\n\tb=St+VX9RYCNx73tPhWfaMdBiid45ZshNpkKqW7ks6GGZ0gcL5r58N9waCCO4VryObWm\n\tu4Q/moVcN4yrK7q9mDodTOdTKEogyJ6t+QcmcvCysYScn8l9qp9Jc/4t7xqXf1iKR2Kv\n\tSIDWOy7fld31j/B1m/x+2MluLhogJ3rjNxnMmt/NLcWbRndR5fRVqJH2a4IE+sFZxK5N\n\tNXAa9xIur/zLs0IAqVMDWmEZ7NXxpARclLHZEIyA4puH3uL7GPRnF54DNXfuGvLveQxy\n\tmcbPpoJuZFF34+8W/fdDWa0lTMYct+AOFvKDiJeQK0aiadRussgESaHQYIQCrI7dSpKF\n\ty+PA==",
        "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:cc:subject:message-id:mime-version\n\t:content-disposition:user-agent;\n\tbh=WFlzpCI76ANsb4EigRR1xgFyxwpl3Mnx/68zZ2RkrL4=;\n\tb=c3waZrNtMdEzcFBvFK8AheErBqOIoJWHvI7OY2rUQe8INVKhOCUL2k2pneDEWi++VL\n\tN3F47qa9dNZ70iDn71NNMZZFHjDavHAsdfvoESIL95CNc/AzCj6TtBGh8BLp0lp8dmec\n\tQbcjnskFSzXQPF3XADukeEPv6SI4RVNPoNJu6aJh67HirRh2wBiSQDZe+pU1hRQznw26\n\tQ/5zs1Sjo7DMoOioDzI6wgKI168/Z7T6KvhVO7QjUx0eZPK6LhBLjFBvONgZPls90hWT\n\twdGbjbw9MJXRVMx9Oyy/ultmmebk7fsb6eBlNFSIwpvBsuyPJr1t+cPOuzHaUVNtTDtM\n\tnFrA==",
        "X-Gm-Message-State": "ANhLgQ1mLnwn80vNF9jdijbagLxLXQs18GkBt2+SmD+2ZnHc6H9CgW+P\n\tBrmsrTXbLuULQsnAExYDqXNgHDKKYtEAjg==",
        "X-Google-Smtp-Source": "ADFU+vvbQAOIhiPuhQahXJV51Idf2+7Nh8hG3IcLPRwwXDrNoWB4qi2NY/Y1BH4ebUlJSqpInSVXEQ==",
        "X-Received": "by 2002:a17:90b:3ca:: with SMTP id\n\tgo10mr2205822pjb.9.1585215215354; \n\tThu, 26 Mar 2020 02:33:35 -0700 (PDT)",
        "Date": "Thu, 26 Mar 2020 15:03:28 +0530",
        "From": "Kaaira Gupta <kgupta@es.iitr.ac.in>",
        "To": "libcamera-devel@lists.libcamera.org,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tHelen Koike <helen.koike@collabora.com>,\n\tVaishali Thakkar <vthakkar@vaishalithakkar.in>",
        "Cc": "kgupta@es.iitr.ac.in",
        "Message-ID": "<20200326093327.GA9015@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: v4l2PixelFormat: Replace\n\thex with fourCC",
        "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": "Thu, 26 Mar 2020 09:33:37 -0000"
    },
    "content": "Print fourCC characters instead of the hex value in toString() as they are\nmore informative. Also, write the tests for this in formats.cpp\n\nSigned-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>\n---\n\nChanges since v2:\n\t- reformatted the code\n\t- added cerr messages before TestFail\n\t- Changed test case to accomodate edge case\n\t- Increased buffer size of char array\n\t- Changed the maximum length of for loop.\n\nChanges since v1:\n        - Add tests for checking this function.\n        - use char[] instead of stringstream.\n        - add checks for default value.\n        - Print '.' for non-printable characters.\n\n src/libcamera/v4l2_videodevice.cpp | 19 ++++++++++++++++---\n test/v4l2_videodevice/formats.cpp  | 20 ++++++++++++++++++++\n 2 files changed, 36 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex b778181..bb049ec 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -336,9 +336,22 @@ bool V4L2BufferCache::Entry::operator==(const FrameBuffer &buffer) const\n  */\n std::string V4L2PixelFormat::toString() const\n {\n-\tchar str[11];\n-\tsnprintf(str, 11, \"0x%08x\", fourcc_);\n-\treturn str;\n+\tif (fourcc_ == 0)\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+\treturn ss;\n }\n \n /**\ndiff --git a/test/v4l2_videodevice/formats.cpp b/test/v4l2_videodevice/formats.cpp\nindex d504d17..4e02afc 100644\n--- a/test/v4l2_videodevice/formats.cpp\n+++ b/test/v4l2_videodevice/formats.cpp\n@@ -47,6 +47,26 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n+\t\tstd::vector<std::pair<uint32_t, const char*>> formats{\n+\t\t\t{ V4L2_PIX_FMT_YUYV, \"YUYV\" }, { 0, \"Invalid\" },\n+\t\t\t{ v4l2_fourcc( 0, 1, 2, 3 ), \"....\" },\n+\t\t\t{ V4L2_PIX_FMT_Y16_BE, \"Y16 -BE\" }\n+\t\t};\n+\n+\t\tfor (const auto &format : formats) {\n+\t\t\tif (V4L2PixelFormat(format.first).toString() != format.second) {\n+\t\t\t\tcerr << \"Failed to convert V4L2PixelFormat to its fourcc\"\n+\t\t\t\t     << \" string\" << endl;\n+\t\t\t\treturn TestFail;\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (V4L2PixelFormat().toString() != \"Invalid\") {\n+\t\t\tcerr << \"Failed to convert default V4L2PixelFormat to 'Invalid'\"\n+\t\t\t     << \" string\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n \t\treturn TestPass;\n \t}\n };\n",
    "prefixes": [
        "libcamera-devel",
        "v3"
    ]
}