[3/4] libcamera: sensor: Initialize the test pattern mode
diff mbox series

Message ID 20261105230708.14601-4-afonso.figuinha@gmail.com
State New
Headers show
Series
  • Support the OV9734 on the IPU3 (Surface Laptop 1)
Related show

Commit Message

Afonso Figuinha Nov. 5, 2026, 11:07 p.m. UTC
testPatternMode_ is never initialized in CameraSensorLegacy and
CameraSensorRaw. init() calls applyTestPatternMode(TestPatternModeOff),
but that function returns early without updating testPatternMode_ when
the sensor has no test pattern modes, which is the case for sensors
missing from the camera sensor properties database.

setTestPatternMode() then compares the requested mode with an
uninitialized value. When the pipeline handler disables the test
pattern before starting the camera, as the IPU3 pipeline handler does,
the result depends on that value: the call either returns 0 or fails
with -EINVAL, and Camera::start() fails intermittently.

Initialize testPatternMode_ to TestPatternModeOff, which is the mode
init() applies.

The change and this description were drafted with an AI coding
assistant (Claude Code, model Claude Opus 5.5). The author reviewed
them and tested them on a Microsoft Surface Laptop 1.

Fixes: 7ee7dc3369eb ("camera_sensor: Suppress error message if test patterns are unavailable")
Signed-off-by: Afonso Figuinha <afonso.figuinha@gmail.com>
---
 src/libcamera/sensor/camera_sensor_legacy.cpp | 1 +
 src/libcamera/sensor/camera_sensor_raw.cpp    | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/src/libcamera/sensor/camera_sensor_legacy.cpp b/src/libcamera/sensor/camera_sensor_legacy.cpp
index 792e4b09..fe5664e0 100644
--- a/src/libcamera/sensor/camera_sensor_legacy.cpp
+++ b/src/libcamera/sensor/camera_sensor_legacy.cpp
@@ -156,6 +156,7 @@  private:
 
 CameraSensorLegacy::CameraSensorLegacy(const MediaEntity *entity)
 	: entity_(entity), pad_(UINT_MAX), staticProps_(nullptr),
+	  testPatternMode_(controls::draft::TestPatternModeOff),
 	  bayerFormat_(nullptr), supportHFlips_(false), supportVFlips_(false),
 	  flipsAlterBayerOrder_(false), properties_(properties::properties)
 {
diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp
index 55b386ce..58fdbfb7 100644
--- a/src/libcamera/sensor/camera_sensor_raw.cpp
+++ b/src/libcamera/sensor/camera_sensor_raw.cpp
@@ -164,7 +164,9 @@  private:
  */
 
 CameraSensorRaw::CameraSensorRaw(const MediaEntity *entity)
-	: entity_(entity), staticProps_(nullptr), supportHFlips_(false),
+	: entity_(entity), staticProps_(nullptr),
+	  testPatternMode_(controls::draft::TestPatternModeOff),
+	  supportHFlips_(false),
 	  supportVFlips_(false), flipsAlterBayerOrder_(false),
 	  properties_(properties::properties)
 {