[libcamera-devel] [PATCH v3 0/2] Add read-only flag to ControlInfo
Kieran Bingham
kieran.bingham at ideasonboard.com
Thu Nov 2 18:24:37 CET 2023
This small patch series adds a read-only flag to ControlInfo. This is used
to test if a control, in particular V4L2_CID_HBLANK, can be written to by
userland. It replaces the slightly fragile workaround we have right now where
we test if the min and max values of a control are the same to determine if
a control is read-only.
Only modified one ControlInfo constructor is modified which is used by the
V4L2Device class to allow this flag to be set, as setting it for a non-v4l2
control probably does not make sense at this point.
Modifying other ControlInfo constructors fails quite quickly falling
into a range of template issues due to multiple signatures matching.
The alternative here would be to rework this such that the ReadOnly flag
could be set /after/ construction with a setter allowing something like:
V4L2_CTRL_TYPE_INTEGER64:
return ControlInfo(static_cast<int64_t>(ctrl.minimum),
static_cast<int64_t>(ctrl.maximum),
- static_cast<int64_t>(ctrl.default_value));
+ static_cast<int64_t>(ctrl.default_value))
.setReadOnly(ctrl.flags & V4L2_CTRL_FLAG_READ_ONLY);
Of course that feels like it could remove the 'contract' of the read
only property by opening up the ability for a ReadOnly control to have
the ReadOnly flag unset - or by opening up the ability to arbitrarily
affect a 'property' of a ControlInfo after it has been made.
Since v2, I have made the following changes to Naush' patches:
- Initialised ReadOnly flag as false for ControlInfo(Span<>)
- Improved documentation
Naushir Patuck (2):
libcamera: controls: Add read-only flag to ControlInfo
libcamera:camera_sensor, ipa: raspberrypi: Test readOnly() for HBLANK
control
include/libcamera/controls.h | 5 ++++-
src/ipa/rpi/common/ipa_base.cpp | 12 +-----------
src/libcamera/camera_sensor.cpp | 14 ++------------
src/libcamera/controls.cpp | 22 ++++++++++++++++++----
src/libcamera/v4l2_device.cpp | 12 ++++++++----
5 files changed, 33 insertions(+), 32 deletions(-)
--
2.34.1
More information about the libcamera-devel
mailing list