diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp
index 2dc85e5e0..bcaaa5dee 100644
--- a/src/libcamera/software_isp/debayer_cpu.cpp
+++ b/src/libcamera/software_isp/debayer_cpu.cpp
@@ -554,7 +554,11 @@ int DebayerCpu::configure(const StreamConfiguration &inputCfg,
 	window_.width = outputCfg.size.width;
 	window_.height = outputCfg.size.height;
 
-	/* Don't pass x,y since process() already adjusts src before passing it */
+	/*
+	 * Set the stats window to the whole processed window. Its coordinates are
+	 * relative to the debayered area since debayering passes only the part of
+	 * data to be processed to the stats; see SwStatsCpu::setWindow.
+	 */
 	stats_->setWindow(Rectangle(window_.size()));
 
 	/* pad with patternSize.Width on both left and right side */
diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp
index e8a1d52f2..4031c1a9e 100644
--- a/src/libcamera/software_isp/swstats_cpu.cpp
+++ b/src/libcamera/software_isp/swstats_cpu.cpp
@@ -416,9 +416,33 @@ int SwStatsCpu::configure(const StreamConfiguration &inputCfg)
 /**
  * \brief Specify window coordinates over which to gather statistics
  * \param[in] window The window object.
+ *
+ * This method specifies the image area over which to gather the statistics.
+ * It must be called to set the area, otherwise the default zero-sized
+ * \a Rectangle is used and no statistics is gathered.
+ *
+ * The specified \a window is relative to what is passed to the processLine*
+ * methods. For example, if statistics are to be gathered from the entire
+ * processed area, then \a window should be a rectangle with the top-left corner
+ * of (0,0) and the same size as the processed area. If only a part of the
+ * processed area (e.g. its centre) is to be considered for statistics, then
+ * \a window should specify such a restriction accordingly.
+ *
+ * It is the responsibility of the callers to provide sensible \a window values,
+ * most notably not exceeding the original image boundaries. This means, among
+ * other, that neither coordinate of the top-left corner shall be negative.
+ *
+ * Due to limitations of the implementation, the method may adjust the window
+ * slightly if it is not aligned according to the bayer pattern determined in
+ * \a SwStatsCpu::configure(). In that case the window will be modified such that
+ * the sides are no larger than the original, and that the new bottom-left
+ * corner will be no further from (0,0) (along either axis) than the original
+ * was.
  */
 void SwStatsCpu::setWindow(const Rectangle &window)
 {
+	ASSERT(window.x >= 0 && window.y >= 0);
+
 	window_ = window;
 
 	window_.x &= ~(patternSize_.width - 1);
