diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index 13048f32..59a1604c 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -74,7 +75,7 @@ public: virtual BayerFormat::Order bayerOrder(Transform t) const = 0; virtual const ControlInfoMap &controls() const = 0; - virtual ControlList getControls(const std::vector &ids) = 0; + virtual ControlList getControls(Span ids) = 0; virtual int setControls(ControlList *ctrls) = 0; virtual const std::vector & diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h index a647c96a..5bc9da96 100644 --- a/include/libcamera/internal/v4l2_device.h +++ b/include/libcamera/internal/v4l2_device.h @@ -37,7 +37,7 @@ public: const ControlInfoMap &controls() const { return controls_; } - ControlList getControls(const std::vector &ids); + ControlList getControls(Span ids); int setControls(ControlList *ctrls); const struct v4l2_query_ext_ctrl *controlInfo(uint32_t id) const; diff --git a/src/libcamera/sensor/camera_sensor_legacy.cpp b/src/libcamera/sensor/camera_sensor_legacy.cpp index ba0a5c33..0b0790ea 100644 --- a/src/libcamera/sensor/camera_sensor_legacy.cpp +++ b/src/libcamera/sensor/camera_sensor_legacy.cpp @@ -90,7 +90,7 @@ public: BayerFormat::Order bayerOrder(Transform t) const override; const ControlInfoMap &controls() const override; - ControlList getControls(const std::vector &ids) override; + ControlList getControls(Span ids) override; int setControls(ControlList *ctrls) override; const std::vector & @@ -907,9 +907,13 @@ int CameraSensorLegacy::sensorInfo(IPACameraSensorInfo *info) const * duration through V4L2 controls. Support for the V4L2_CID_PIXEL_RATE, * V4L2_CID_HBLANK and V4L2_CID_VBLANK controls is mandatory. */ - ControlList ctrls = subdev_->getControls({ V4L2_CID_PIXEL_RATE, - V4L2_CID_HBLANK, - V4L2_CID_VBLANK }); + static constexpr uint32_t cids[] = { + V4L2_CID_PIXEL_RATE, + V4L2_CID_HBLANK, + V4L2_CID_VBLANK, + }; + + ControlList ctrls = subdev_->getControls(cids); if (ctrls.empty()) { LOG(CameraSensor, Error) << "Failed to retrieve camera info controls"; @@ -983,7 +987,7 @@ const ControlInfoMap &CameraSensorLegacy::controls() const return subdev_->controls(); } -ControlList CameraSensorLegacy::getControls(const std::vector &ids) +ControlList CameraSensorLegacy::getControls(Span ids) { return subdev_->getControls(ids); } diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp index f9aef054..b9e5b19a 100644 --- a/src/libcamera/sensor/camera_sensor_raw.cpp +++ b/src/libcamera/sensor/camera_sensor_raw.cpp @@ -96,7 +96,7 @@ public: BayerFormat::Order bayerOrder(Transform t) const override; const ControlInfoMap &controls() const override; - ControlList getControls(const std::vector &ids) override; + ControlList getControls(Span ids) override; int setControls(ControlList *ctrls) override; const std::vector & @@ -1022,9 +1022,13 @@ int CameraSensorRaw::sensorInfo(IPACameraSensorInfo *info) const * duration through V4L2 controls. Support for the V4L2_CID_PIXEL_RATE, * V4L2_CID_HBLANK and V4L2_CID_VBLANK controls is mandatory. */ - ControlList ctrls = subdev_->getControls({ V4L2_CID_PIXEL_RATE, - V4L2_CID_HBLANK, - V4L2_CID_VBLANK }); + static constexpr uint32_t cids[] = { + V4L2_CID_PIXEL_RATE, + V4L2_CID_HBLANK, + V4L2_CID_VBLANK, + }; + + ControlList ctrls = subdev_->getControls(cids); if (ctrls.empty()) { LOG(CameraSensor, Error) << "Failed to retrieve camera info controls"; @@ -1095,7 +1099,7 @@ const ControlInfoMap &CameraSensorRaw::controls() const return subdev_->controls(); } -ControlList CameraSensorRaw::getControls(const std::vector &ids) +ControlList CameraSensorRaw::getControls(Span ids) { return subdev_->getControls(ids); } diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 0db92c19..8c78b8c4 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -174,7 +174,7 @@ void V4L2Device::close() * \return The control values in a ControlList on success, or an empty list on * error */ -ControlList V4L2Device::getControls(const std::vector &ids) +ControlList V4L2Device::getControls(Span ids) { if (ids.empty()) return {}; diff --git a/test/v4l2_videodevice/controls.cpp b/test/v4l2_videodevice/controls.cpp index b0130295..7990f37d 100644 --- a/test/v4l2_videodevice/controls.cpp +++ b/test/v4l2_videodevice/controls.cpp @@ -60,11 +60,15 @@ protected: const ControlInfo &u8 = infoMap.find(VIVID_CID_U8_4D_ARRAY)->second; /* Test getting controls. */ - ControlList ctrls = capture_->getControls({ V4L2_CID_BRIGHTNESS, - V4L2_CID_CONTRAST, - V4L2_CID_SATURATION, - VIVID_CID_INTEGER64, - VIVID_CID_U8_4D_ARRAY }); + static constexpr uint32_t cids[] = { + V4L2_CID_BRIGHTNESS, + V4L2_CID_CONTRAST, + V4L2_CID_SATURATION, + VIVID_CID_INTEGER64, + VIVID_CID_U8_4D_ARRAY, + }; + + ControlList ctrls = capture_->getControls(cids); if (ctrls.empty()) { cerr << "Failed to get controls" << endl; return TestFail;