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
