diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h
index 8efe1382..298756e3 100644
--- a/include/libcamera/internal/bayer_format.h
+++ b/include/libcamera/internal/bayer_format.h
@@ -57,6 +57,13 @@ public:
 	Packing packing;
 };
 
+bool operator==(const BayerFormat &lhs, const BayerFormat &rhs);
+static inline bool operator!=(const BayerFormat &lhs,
+			      const BayerFormat &rhs)
+{
+	return !(lhs == rhs);
+}
+
 } /* namespace libcamera */
 
 #endif /* __LIBCAMERA_INTERNAL_BAYER_FORMAT_H__ */
diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp
index 26065b66..b8635e15 100644
--- a/src/libcamera/bayer_format.cpp
+++ b/src/libcamera/bayer_format.cpp
@@ -160,6 +160,16 @@ std::string BayerFormat::toString() const
 	return result;
 }
 
+/**
+ * \brief Compare two BayerFormats for equality
+ * \return True if order, bitDepth and packing are equal, otherwise false
+ */
+bool operator==(const BayerFormat &lhs, const BayerFormat &rhs)
+{
+	return lhs.order == rhs.order && lhs.bitDepth == rhs.bitDepth &&
+	       lhs.packing == rhs.packing;
+}
+
 /**
  * \brief Convert a BayerFormat into the corresponding V4L2PixelFormat
  * \return The V4L2PixelFormat corresponding to this BayerFormat
