{"id":3322,"url":"https://patchwork.libcamera.org/api/1.1/patches/3322/?format=json","web_url":"https://patchwork.libcamera.org/patch/3322/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200325220252.GA14374@kaaira-HP-Pavilion-Notebook>","date":"2020-03-25T22:02:52","name":"[libcamera-devel,v2] libcamera: v4l2PixelFormat: Replace hex with fourCC","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"895733e26ff0d8e525f3956f5bf9205409283790","submitter":{"id":39,"url":"https://patchwork.libcamera.org/api/1.1/people/39/?format=json","name":"Kaaira Gupta","email":"kgupta@es.iitr.ac.in"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3322/mbox/","series":[{"id":776,"url":"https://patchwork.libcamera.org/api/1.1/series/776/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=776","date":"2020-03-25T22:02:52","name":"[libcamera-devel,v2] libcamera: v4l2PixelFormat: Replace hex with fourCC","version":2,"mbox":"https://patchwork.libcamera.org/series/776/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3322/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3322/checks/","tags":{},"headers":{"Return-Path":"<kgupta@es.iitr.ac.in>","Received":["from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com\n\t[IPv6:2607:f8b0:4864:20::42e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3F1F760413\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 Mar 2020 23:03:04 +0100 (CET)","by mail-pf1-x42e.google.com with SMTP id b72so1726421pfb.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 Mar 2020 15:03:04 -0700 (PDT)","from kaaira-HP-Pavilion-Notebook ([103.113.213.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tb189sm95936pfa.209.2020.03.25.15.02.56\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tWed, 25 Mar 2020 15:02:58 -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=\"PHFjIBkI\"; \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=x+wzOSQPHTbsilf0h6r+izYDfTQnprPFenPKccdmsJk=;\n\tb=PHFjIBkI9M5BNJJ3X2C/MJ8KMURVp5RbnTDKuPYYUPQJjdoZfIy3SZSFrJcaBYEmz2\n\tJp5v//jC7X6OMzCDWmiZkyVF7+XLTm3m8ZKXq+XHLkUiE84M/K9aqpe40o3g3mZxYU0p\n\t0FUk1s1z4bk9y9373b3FsbE5yK2JV/OZr19JjG1Z+pB+QWBijg3nGVNm/FC9eMsTUDx8\n\tOU/91SIoqG8sqOyQDOgVz9JzVtu7xfgFZTzTAOqthFKl/eorJYstJ8AZL4M/77u4ZWHA\n\tegg6Cr8iigoyAXkFRK0MAu4QQ9PdQZyUYAdARxMXIoPJ4PTavcRt2S1g5wLgZMhzaEjZ\n\tHqLw==","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=x+wzOSQPHTbsilf0h6r+izYDfTQnprPFenPKccdmsJk=;\n\tb=R4CzwfyjTjHC00kEwlHW4QMh9lFZGqrAHpyW8skAXX519KtsLQzvvYCrqwfMhO6GC6\n\tJ7QXE//NLNer8X0ZIsopQuhRDX9RO8NWDBFFqYXLdhbIgajuepy9NUK9h5FyrQq7A1ev\n\tpU6UKesEuG0N7hXpii5cs2D9asOX1yWiYCxVbx2JK3EeE61wuZCCSUi1Zh/2PDAdR9sY\n\tQX9MQGzk9FJdhTTledtCpVJALM8nRp913q09KaG7WvPKWRHLfTXJaModC9eSNPkQRFk0\n\t9OJ1r1BCLcjX6c7PKtkg9LhjgFGbFBrE0UOs55pq7w+20c1UaDRbVqoH7CqVuZvvkVSE\n\tGf+g==","X-Gm-Message-State":"ANhLgQ2UnZkZ0v80oZKa1u3MJ3hAKO2cR1D85T4tki0+KY24osrk2X9F\n\tMLgAIOsVWt1Alt3ASNbn3aBJ0h+dkylsZw==","X-Google-Smtp-Source":"ADFU+vu0WD6uL0tDlha43+YlG3Acgo33Bi0v/8s7hVVKuhD0YoID2vAJWOqcbxapBOmB/2mkbfHmmQ==","X-Received":"by 2002:aa7:8b46:: with SMTP id i6mr5827437pfd.60.1585173779513; \n\tWed, 25 Mar 2020 15:02:59 -0700 (PDT)","Date":"Thu, 26 Mar 2020 03:32:52 +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>","Message-ID":"<20200325220252.GA14374@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 v2] 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":"Wed, 25 Mar 2020 22:03:04 -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 v1:\n\t- Add tests for checking this function.\n\t- use char[] instead of stringstream.\n\t- add checks for default value.\n\t- Print '.' for non-printable characters.\n\n src/libcamera/v4l2_videodevice.cpp | 19 ++++++++++++++++---\n test/v4l2_videodevice/formats.cpp  | 15 +++++++++++++++\n 2 files changed, 31 insertions(+), 3 deletions(-)","diff":"diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex b778181..f5c14aa 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[7] = {static_cast<char>(fourcc_ & 0x7f),\n+\t\t\t\t  static_cast<char>((fourcc_ >> 8) & 0x7f),\n+\t\t\t\t  static_cast<char>((fourcc_ >> 16) & 0x7f),\n+\t\t\t\t  static_cast<char>((fourcc_ >> 24) & 0x7f)};\n+\n+\tfor (unsigned int i = 0; i < strlen(ss); 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..f129c5c 100644\n--- a/test/v4l2_videodevice/formats.cpp\n+++ b/test/v4l2_videodevice/formats.cpp\n@@ -47,6 +47,21 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n+\t\tauto badfourcc = v4l2_fourcc( 1, 2, 3, 4 );\n+\t\tstd::vector<std::pair<uint32_t, const char*>> formats{\n+\t\t\t{V4L2_PIX_FMT_YUYV,\"YUYV\"},{0, \"Invalid\"}, {badfourcc, \"....\"},\n+\t\t\t{V4L2_PIX_FMT_Y16_BE,\"Y16 -BE\"}};\n+\n+\t\tfor (const auto &format :formats){\n+\t\t\tif (V4L2PixelFormat(format.first).toString()!=format.second){\n+\t\t\t\treturn TestFail;\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (V4L2PixelFormat().toString() != \"Invalid\"){\n+\t\t\treturn TestFail;\n+\t\t}\n+\n \t\treturn TestPass;\n \t}\n };\n","prefixes":["libcamera-devel","v2"]}