{"id":21577,"url":"https://patchwork.libcamera.org/api/1.1/patches/21577/?format=json","web_url":"https://patchwork.libcamera.org/patch/21577/","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":"<20241009200142.3213065-2-chenghaoyang@chromium.org>","date":"2024-10-09T19:58:50","name":"[1/2] libcamera: v4l2: Implement the equality and inequality operators for V4L2DeviceFormat","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"e4f8cd88e111cd1d34fddc6510d81442204c344d","submitter":{"id":117,"url":"https://patchwork.libcamera.org/api/1.1/people/117/?format=json","name":"Cheng-Hao Yang","email":"chenghaoyang@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/21577/mbox/","series":[{"id":4679,"url":"https://patchwork.libcamera.org/api/1.1/series/4679/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4679","date":"2024-10-09T19:58:49","name":"Add V4L2DeviceFormat support","version":1,"mbox":"https://patchwork.libcamera.org/series/4679/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/21577/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/21577/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 A5327C32DE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  9 Oct 2024 20:01:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5059965370;\n\tWed,  9 Oct 2024 22:01:53 +0200 (CEST)","from mail-pl1-x636.google.com (mail-pl1-x636.google.com\n\t[IPv6:2607:f8b0:4864:20::636])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9894665371\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  9 Oct 2024 22:01:50 +0200 (CEST)","by mail-pl1-x636.google.com with SMTP id\n\td9443c01a7336-20c71603217so1017185ad.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 09 Oct 2024 13:01:50 -0700 (PDT)","from chenghaoyang-low.c.googlers.com.com\n\t(199.211.81.34.bc.googleusercontent.com. [34.81.211.199])\n\tby smtp.gmail.com with ESMTPSA id\n\td9443c01a7336-20c54056b07sm30370205ad.64.2024.10.09.13.01.47\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 09 Oct 2024 13:01:48 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"Zt5UK26O\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=chromium.org; s=google; t=1728504109; x=1729108909;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=FzDPFap4kC8SjqgFVhU4rzrHQGySD0ECn6sh9n9qdjo=;\n\tb=Zt5UK26ONuRzvmOilFsQNZ4cm5P0j8kWV9AIi/NOyPfKifYFVdKwyoEtyRbzBANxrq\n\tnonJIOUXsOhCCqVpqluVSaOzECTxxJ5twJ+OBxM9QmnaOkKb1uMc0ywGRDI9q5TurxCi\n\t7ReyBSiyo6ZZEUMzM8JPk0u2C/9LVyhr0piGM=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1728504109; x=1729108909;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=FzDPFap4kC8SjqgFVhU4rzrHQGySD0ECn6sh9n9qdjo=;\n\tb=XRJRX5w0h/9nxy0OKJpGGyc2smLbsnXJ3veoNDVeMTksgqIq1WrlMyJOhUcggCt4Rk\n\t8mRaz/r68hrkGxbnhRAQymk6PauQC0dejSnm/LDQaUAGo82mqGOc8Si5hsCGTyfU/bl0\n\tTY16D4Wone97RSAdKTwVBUNMeNFdgQnfpyl2UsArGc0hFWrN1CNbS0ql7hbrjba63NC0\n\tHAz0EEkfON8cQDuo0gDmgBfndLAop98JJgDeSewMqWMsWMDnGGP5M9/HiIiRFvSawmRW\n\tjByMHkZxXnH4UwbeFfaHEbSC+x/AgcInDU1hE2wP+M4H8ZQ3bnezI0CYqBGyotWqbMJQ\n\tCtpA==","X-Gm-Message-State":"AOJu0YzfERPDKmvJ+nlCMMrMIjjHJlU4x+HCqBxu/+hNo4Rdosu+JJMR\n\tqJhJn4+t3VL9cNWyyOOQEPOIFh6cNBvDTo7pPT2kmKmyReD6WWRidA3Yw/FLflE2x6efOFJplzY\n\t=","X-Google-Smtp-Source":"AGHT+IEAwepNwtV5eH07CGknu+YhldCcgagEV2bbwQE4CabV+7plUxv5j4I8pg1uZvQcRPf3U6LRuw==","X-Received":"by 2002:a17:903:22cb:b0:20c:5404:ed6e with SMTP id\n\td9443c01a7336-20c636db24emr48379505ad.8.1728504108794; \n\tWed, 09 Oct 2024 13:01:48 -0700 (PDT)","From":"Harvey Yang <chenghaoyang@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Cc":"Yunke Cao <yunkec@chromium.org>, Han-Lin Chen <hanlinchen@chromium.org>, \n\tHarvey Yang <chenghaoyang@chromium.org>","Subject":"[PATCH 1/2] libcamera: v4l2: Implement the equality and inequality\n\toperators for V4L2DeviceFormat","Date":"Wed,  9 Oct 2024 19:58:50 +0000","Message-ID":"<20241009200142.3213065-2-chenghaoyang@chromium.org>","X-Mailer":"git-send-email 2.47.0.rc0.187.ge670bccf7e-goog","In-Reply-To":"<20241009200142.3213065-1-chenghaoyang@chromium.org>","References":"<20241009200142.3213065-1-chenghaoyang@chromium.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Yunke Cao <yunkec@chromium.org>\n\nThe comparators allow us to compare format directly instead of\ncomparing each field.\n\nSigned-off-by: Yunke Cao <yunkec@chromium.org>\nCo-developed-by: Han-Lin Chen <hanlinchen@chromium.org>\nSigned-off-by: Han-Lin Chen <hanlinchen@chromium.org>\nCo-developed-by: Harvey Yang <chenghaoyang@chromium.org>\nSigned-off-by: Harvey Yang <chenghaoyang@chromium.org>\n---\n include/libcamera/internal/v4l2_videodevice.h |  6 +++++\n src/libcamera/v4l2_videodevice.cpp            | 27 +++++++++++++++++++\n 2 files changed, 33 insertions(+)","diff":"diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\nindex f021c2a01..9f53e37cd 100644\n--- a/include/libcamera/internal/v4l2_videodevice.h\n+++ b/include/libcamera/internal/v4l2_videodevice.h\n@@ -182,6 +182,12 @@ public:\n \tconst std::string toString() const;\n };\n \n+bool operator==(const V4L2DeviceFormat &lhs, const V4L2DeviceFormat &rhs);\n+static inline bool operator!=(const V4L2DeviceFormat &lhs, const V4L2DeviceFormat &rhs)\n+{\n+\treturn !(lhs == rhs);\n+}\n+\n std::ostream &operator<<(std::ostream &out, const V4L2DeviceFormat &f);\n \n class V4L2VideoDevice : public V4L2Device\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 14eba0561..1110fb535 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -437,6 +437,33 @@ const std::string V4L2DeviceFormat::toString() const\n \treturn ss.str();\n }\n \n+/**\n+ * \\brief Compare V4L2DeviceFormat for equality\n+ * \\return True if the two formats are identical, false otherwise\n+ */\n+bool operator==(const V4L2DeviceFormat &lhs, const V4L2DeviceFormat &rhs)\n+{\n+\tif (!(lhs.fourcc == rhs.fourcc &&\n+\t      lhs.size == rhs.size &&\n+\t      lhs.colorSpace == rhs.colorSpace &&\n+\t      lhs.planesCount == rhs.planesCount))\n+\t\treturn false;\n+\n+\tfor (unsigned int i = 0; i < lhs.planesCount; ++i) {\n+\t\tif (lhs.planes[i].size != rhs.planes[i].size ||\n+\t\t    lhs.planes[i].bpl != rhs.planes[i].bpl)\n+\t\t\treturn false;\n+\t}\n+\n+\treturn true;\n+}\n+\n+/**\n+ * \\fn bool operator!=(const V4L2DeviceFormat &lhs, const V4L2DeviceFormat &rhs)\n+ * \\brief Comparetwo formats for inequality\n+ * \\return True if the two formats are not identical, false otherwise\n+ */\n+\n /**\n  * \\brief Insert a text representation of a V4L2DeviceFormat into an output\n  * stream\n","prefixes":["1/2"]}