| Message ID | 20261103104131.87331-3-guyliandejong@proton.me |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
2026. 11. 03. 11:41 keltezéssel, GuyliandeJong írta: > The testPatternMode_ member of CameraSensorLegacy and CameraSensorRaw > is never initialized in the constructors. It is only assigned by > applyTestPatternMode(), which returns early without touching it when the > sensor has no test pattern modes. > > The IPU3 pipeline handler calls setTestPatternMode(TestPatternModeOff) > in start(). For a sensor without test pattern modes, setTestPatternMode() > compares the mode with the uninitialized value and, if they differ, > returns -EINVAL as the sensor doesn't support test patterns. Camera > start then fails at random, depending on the content of the memory. > This was seen with the OV9734 on a Surface Laptop 2, which has no > entry in the camera sensor properties database. > > Initialize testPatternMode_ to TestPatternModeOff, which matches the > state that init() puts the sensor in. > > Signed-off-by: GuyliandeJong <guyliandejong@proton.me> > --- Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> > src/libcamera/sensor/camera_sensor_legacy.cpp | 1 + > src/libcamera/sensor/camera_sensor_raw.cpp | 6 ++++-- > 2 files changed, 5 insertions(+), 2 deletions(-) > > 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..b87ec0eb 100644 > --- a/src/libcamera/sensor/camera_sensor_raw.cpp > +++ b/src/libcamera/sensor/camera_sensor_raw.cpp > @@ -164,8 +164,10 @@ private: > */ > > CameraSensorRaw::CameraSensorRaw(const MediaEntity *entity) > - : entity_(entity), staticProps_(nullptr), supportHFlips_(false), > - supportVFlips_(false), flipsAlterBayerOrder_(false), > + : entity_(entity), staticProps_(nullptr), > + testPatternMode_(controls::draft::TestPatternModeOff), > + supportHFlips_(false), supportVFlips_(false), > + flipsAlterBayerOrder_(false), > properties_(properties::properties) > { > }
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..b87ec0eb 100644 --- a/src/libcamera/sensor/camera_sensor_raw.cpp +++ b/src/libcamera/sensor/camera_sensor_raw.cpp @@ -164,8 +164,10 @@ private: */ CameraSensorRaw::CameraSensorRaw(const MediaEntity *entity) - : entity_(entity), staticProps_(nullptr), supportHFlips_(false), - supportVFlips_(false), flipsAlterBayerOrder_(false), + : entity_(entity), staticProps_(nullptr), + testPatternMode_(controls::draft::TestPatternModeOff), + supportHFlips_(false), supportVFlips_(false), + flipsAlterBayerOrder_(false), properties_(properties::properties) { }
The testPatternMode_ member of CameraSensorLegacy and CameraSensorRaw is never initialized in the constructors. It is only assigned by applyTestPatternMode(), which returns early without touching it when the sensor has no test pattern modes. The IPU3 pipeline handler calls setTestPatternMode(TestPatternModeOff) in start(). For a sensor without test pattern modes, setTestPatternMode() compares the mode with the uninitialized value and, if they differ, returns -EINVAL as the sensor doesn't support test patterns. Camera start then fails at random, depending on the content of the memory. This was seen with the OV9734 on a Surface Laptop 2, which has no entry in the camera sensor properties database. Initialize testPatternMode_ to TestPatternModeOff, which matches the state that init() puts the sensor in. Signed-off-by: GuyliandeJong <guyliandejong@proton.me> --- src/libcamera/sensor/camera_sensor_legacy.cpp | 1 + src/libcamera/sensor/camera_sensor_raw.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-)