From patchwork Wed Oct 9 19:58:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 21577 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id A5327C32DE for ; Wed, 9 Oct 2024 20:01:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5059965370; Wed, 9 Oct 2024 22:01:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Zt5UK26O"; dkim-atps=neutral Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9894665371 for ; Wed, 9 Oct 2024 22:01:50 +0200 (CEST) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-20c71603217so1017185ad.3 for ; Wed, 09 Oct 2024 13:01:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728504109; x=1729108909; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FzDPFap4kC8SjqgFVhU4rzrHQGySD0ECn6sh9n9qdjo=; b=Zt5UK26ONuRzvmOilFsQNZ4cm5P0j8kWV9AIi/NOyPfKifYFVdKwyoEtyRbzBANxrq nonJIOUXsOhCCqVpqluVSaOzECTxxJ5twJ+OBxM9QmnaOkKb1uMc0ywGRDI9q5TurxCi 7ReyBSiyo6ZZEUMzM8JPk0u2C/9LVyhr0piGM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728504109; x=1729108909; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FzDPFap4kC8SjqgFVhU4rzrHQGySD0ECn6sh9n9qdjo=; b=XRJRX5w0h/9nxy0OKJpGGyc2smLbsnXJ3veoNDVeMTksgqIq1WrlMyJOhUcggCt4Rk 8mRaz/r68hrkGxbnhRAQymk6PauQC0dejSnm/LDQaUAGo82mqGOc8Si5hsCGTyfU/bl0 TY16D4Wone97RSAdKTwVBUNMeNFdgQnfpyl2UsArGc0hFWrN1CNbS0ql7hbrjba63NC0 HAz0EEkfON8cQDuo0gDmgBfndLAop98JJgDeSewMqWMsWMDnGGP5M9/HiIiRFvSawmRW jByMHkZxXnH4UwbeFfaHEbSC+x/AgcInDU1hE2wP+M4H8ZQ3bnezI0CYqBGyotWqbMJQ CtpA== X-Gm-Message-State: AOJu0YzfERPDKmvJ+nlCMMrMIjjHJlU4x+HCqBxu/+hNo4Rdosu+JJMR qJhJn4+t3VL9cNWyyOOQEPOIFh6cNBvDTo7pPT2kmKmyReD6WWRidA3Yw/FLflE2x6efOFJplzY = X-Google-Smtp-Source: AGHT+IEAwepNwtV5eH07CGknu+YhldCcgagEV2bbwQE4CabV+7plUxv5j4I8pg1uZvQcRPf3U6LRuw== X-Received: by 2002:a17:903:22cb:b0:20c:5404:ed6e with SMTP id d9443c01a7336-20c636db24emr48379505ad.8.1728504108794; Wed, 09 Oct 2024 13:01:48 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (199.211.81.34.bc.googleusercontent.com. [34.81.211.199]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c54056b07sm30370205ad.64.2024.10.09.13.01.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2024 13:01:48 -0700 (PDT) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Yunke Cao , Han-Lin Chen , Harvey Yang Subject: [PATCH 1/2] libcamera: v4l2: Implement the equality and inequality operators 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 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Yunke Cao The comparators allow us to compare format directly instead of comparing each field. Signed-off-by: Yunke Cao Co-developed-by: Han-Lin Chen Signed-off-by: Han-Lin Chen Co-developed-by: Harvey Yang Signed-off-by: Harvey Yang --- include/libcamera/internal/v4l2_videodevice.h | 6 +++++ src/libcamera/v4l2_videodevice.cpp | 27 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h index f021c2a01..9f53e37cd 100644 --- a/include/libcamera/internal/v4l2_videodevice.h +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -182,6 +182,12 @@ public: const std::string toString() const; }; +bool operator==(const V4L2DeviceFormat &lhs, const V4L2DeviceFormat &rhs); +static inline bool operator!=(const V4L2DeviceFormat &lhs, const V4L2DeviceFormat &rhs) +{ + return !(lhs == rhs); +} + std::ostream &operator<<(std::ostream &out, const V4L2DeviceFormat &f); class V4L2VideoDevice : public V4L2Device diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 14eba0561..1110fb535 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -437,6 +437,33 @@ const std::string V4L2DeviceFormat::toString() const return ss.str(); } +/** + * \brief Compare V4L2DeviceFormat for equality + * \return True if the two formats are identical, false otherwise + */ +bool operator==(const V4L2DeviceFormat &lhs, const V4L2DeviceFormat &rhs) +{ + if (!(lhs.fourcc == rhs.fourcc && + lhs.size == rhs.size && + lhs.colorSpace == rhs.colorSpace && + lhs.planesCount == rhs.planesCount)) + return false; + + for (unsigned int i = 0; i < lhs.planesCount; ++i) { + if (lhs.planes[i].size != rhs.planes[i].size || + lhs.planes[i].bpl != rhs.planes[i].bpl) + return false; + } + + return true; +} + +/** + * \fn bool operator!=(const V4L2DeviceFormat &lhs, const V4L2DeviceFormat &rhs) + * \brief Comparetwo formats for inequality + * \return True if the two formats are not identical, false otherwise + */ + /** * \brief Insert a text representation of a V4L2DeviceFormat into an output * stream From patchwork Wed Oct 9 19:58:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 21578 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 3A901C32E7 for ; Wed, 9 Oct 2024 20:01:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E02EE65371; Wed, 9 Oct 2024 22:01:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="DT+PzoMc"; dkim-atps=neutral Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 34599618C5 for ; Wed, 9 Oct 2024 22:01:52 +0200 (CEST) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-20c5a7b2908so1058775ad.1 for ; Wed, 09 Oct 2024 13:01:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728504110; x=1729108910; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dEOyYZLtMlIrWbCLSXaCKiqq1mB/bN8VsxFFN4jSrqw=; b=DT+PzoMc9cXyXtmsU9i9+0x7KyV8hQrD2uHGx8sK/96QUWrSc6EPaVMqlIs18Pe0NL X+SHFZ83Eycj5+Yy/0cOACUNOGLq2/QQ9Cwi74+LTzkrkf6T61TClJ06NzKOQBrBwvKy 6lJZXgJIcHyvzCN6HYJnCPKzEnJXokoEJjlkM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728504110; x=1729108910; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dEOyYZLtMlIrWbCLSXaCKiqq1mB/bN8VsxFFN4jSrqw=; b=dHwZmetxg9v/ZjLMm3drl9mrQZts6k7pyxOzDXqRaf9SuW5KbUrQPWPxPw7VXCSnVO Sy95CT5zmsCYB5+bUjmT387bfgAMgS5cJH+oJesy1gPE/JlCsYc4HWARDCACVH8FH1w7 DKfsxlAVN7O3/fTBnBaJLSvq7UDpllWUSzyYZf14aQeAAa37a/ispKF3DlxozdJLtjuU Hd7XVDEnXdd8Nv8pEPKEzv3fUIhQolUqKm/uIHFHSqFegvqZBNIKdI7fcPRGKpFaCpc9 pHPJ1awtfgImTeNhAjxjEBcUjzunB2x1NaaJc4dZTbxBTG0hL8ym5fkFU6/DmaOVUcLx eOhw== X-Gm-Message-State: AOJu0YwUIImmJnIKqildZZTIcFKzLS4jkyI1zno3bVukx9kvw6drCOMg hzlJCgmLgeVBCKmTR4Un5ribPekYpuFmJPfVBIBNEBq0ZK6SH8JTh4VgbOWDmg4lnj8iAwd6n6M = X-Google-Smtp-Source: AGHT+IGIOWeuJqxPqJ5NjZPNMtHAlmMlG1+IgKTXlUi9tR11zEDnxK/c0MkVTaWVTpHy0IxIHrDzoQ== X-Received: by 2002:a17:902:ea12:b0:20c:6023:c02a with SMTP id d9443c01a7336-20c6378fc21mr60598065ad.57.1728504110336; Wed, 09 Oct 2024 13:01:50 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (199.211.81.34.bc.googleusercontent.com. [34.81.211.199]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c54056b07sm30370205ad.64.2024.10.09.13.01.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2024 13:01:49 -0700 (PDT) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Harvey Yang Subject: [PATCH 2/2] libcamera: Add V4L2VideoDevice::getCachedFormat Date: Wed, 9 Oct 2024 19:58:51 +0000 Message-ID: <20241009200142.3213065-3-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 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" In the upcoming mtkisp7 pipeline handler, it needs to access the cached format from a derived class. This patch adds a protected getter to allow that. Signed-off-by: Harvey Yang --- include/libcamera/internal/v4l2_videodevice.h | 2 ++ src/libcamera/v4l2_videodevice.cpp | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h index 9f53e37cd..389276302 100644 --- a/include/libcamera/internal/v4l2_videodevice.h +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -241,6 +241,8 @@ public: protected: std::string logPrefix() const override; + V4L2DeviceFormat getCachedFormat() { return format_; } + private: LIBCAMERA_DISABLE_COPY(V4L2VideoDevice) diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 1110fb535..1f6ad96c1 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -2113,6 +2113,11 @@ V4L2VideoDevice::fromEntityName(const MediaDevice *media, return std::make_unique(mediaEntity); } +/** + * \fn V4L2VideoDevice::getCachedFormat() + * \return Cached \a V4L2VideoDevice::format_ + */ + /** * \brief Convert \a PixelFormat to a V4L2PixelFormat supported by the device * \param[in] pixelFormat The PixelFormat to convert