diff --git a/include/libcamera/internal/utils.h b/include/libcamera/internal/utils.h
index f08134afb5ba..d0146b71727d 100644
--- a/include/libcamera/internal/utils.h
+++ b/include/libcamera/internal/utils.h
@@ -203,6 +203,33 @@ constexpr unsigned int alignUp(unsigned int value, unsigned int alignment)
 	return (value + alignment - 1) / alignment * alignment;
 }
 
+namespace details {
+
+template<typename T>
+struct reverse_adapter {
+	T &iterable;
+};
+
+template<typename T>
+auto begin(reverse_adapter<T> r)
+{
+	return std::rbegin(r.iterable);
+}
+
+template<typename T>
+auto end(reverse_adapter<T> r)
+{
+	return std::rend(r.iterable);
+}
+
+} /* namespace details */
+
+template<typename T>
+details::reverse_adapter<T> reverse(T &&iterable)
+{
+	return { iterable };
+}
+
 } /* namespace utils */
 
 } /* namespace libcamera */
diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp
index e90375ae115c..c4098a74e0ab 100644
--- a/src/libcamera/utils.cpp
+++ b/src/libcamera/utils.cpp
@@ -464,6 +464,14 @@ std::string libcameraSourcePath()
  * \return The value rounded up to the nearest multiple of \a alignment
  */
 
+/**
+ * \fn reverse(T &&iterable)
+ * \brief Wrap an iterable to reverse iteration in a range-based loop
+ * \param[in] iterable The iterable
+ * \return A value of unspecified type that, when used in a range-based for
+ * loop, will cause the loop to iterate over the \a iterable in reverse order
+ */
+
 } /* namespace utils */
 
 } /* namespace libcamera */
