[libcamera-devel] [PATCH v3 07/23] libcamera: camera_sensor: Rename the control interface
Kieran Bingham
kieran.bingham at ideasonboard.com
Fri Jul 1 00:22:40 CEST 2022
Quoting Jacopo Mondi via libcamera-devel (2022-06-30 14:38:46)
> The control interface of the CameraSensor class operates on V4L2
> controls.
>
> To prepare to move the CameraSensor interface to use libcamera::internal
> controls, rename the existing interface to be the 'v4l2' control
> interface, to allow users to transition to the new interface gradually.
>
I think this makes sense regardless of how we name the controls we move
towards.
The more I read on this series, the more convinced I am that any
'internal' control would be a public control that should be reported
through the metadata, so I think we could call this 'Moving to libcamera
controls'...
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> ---
> include/libcamera/internal/camera_sensor.h | 6 +++---
> src/libcamera/camera_sensor/camera_sensor.cpp | 14 +++++++-------
> src/libcamera/pipeline/ipu3/ipu3.cpp | 10 +++++-----
> src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 14 +++++++-------
> src/libcamera/pipeline/rkisp1/rkisp1.cpp | 2 +-
> src/libcamera/pipeline/vimc/vimc.cpp | 8 ++++----
> 6 files changed, 27 insertions(+), 27 deletions(-)
>
> diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h
> index 43b035b77f2b..2a850dedc0aa 100644
> --- a/include/libcamera/internal/camera_sensor.h
> +++ b/include/libcamera/internal/camera_sensor.h
> @@ -56,9 +56,9 @@ public:
> const Size &size) const;
> int setFormat(V4L2SubdeviceFormat *format);
>
> - const ControlInfoMap &controls() const;
> - ControlList getControls(const std::vector<uint32_t> &ids);
> - int setControls(ControlList *ctrls);
> + const ControlInfoMap &v4l2Controls() const;
> + ControlList getV4L2Controls(const std::vector<uint32_t> &ids);
> + int setV4L2Controls(ControlList *ctrls);
>
> V4L2Subdevice *device() { return subdev_.get(); }
>
> diff --git a/src/libcamera/camera_sensor/camera_sensor.cpp b/src/libcamera/camera_sensor/camera_sensor.cpp
> index 59b956e40803..26cfa7d0f65a 100644
> --- a/src/libcamera/camera_sensor/camera_sensor.cpp
> +++ b/src/libcamera/camera_sensor/camera_sensor.cpp
> @@ -335,8 +335,8 @@ void CameraSensor::initStaticProperties()
>
> void CameraSensor::initTestPatternModes()
> {
> - const auto &v4l2TestPattern = controls().find(V4L2_CID_TEST_PATTERN);
> - if (v4l2TestPattern == controls().end()) {
> + const auto &v4l2TestPattern = v4l2Controls().find(V4L2_CID_TEST_PATTERN);
> + if (v4l2TestPattern == v4l2Controls().end()) {
> LOG(CameraSensor, Debug) << "V4L2_CID_TEST_PATTERN is not supported";
> return;
> }
> @@ -615,10 +615,10 @@ int CameraSensor::applyTestPatternMode(controls::draft::TestPatternModeEnum mode
> LOG(CameraSensor, Debug) << "Apply test pattern mode " << mode;
>
> int32_t index = staticProps_->testPatternModes.at(mode);
> - ControlList ctrls{ controls() };
> + ControlList ctrls{ v4l2Controls() };
> ctrls.set(V4L2_CID_TEST_PATTERN, index);
>
> - int ret = setControls(&ctrls);
> + int ret = setV4L2Controls(&ctrls);
> if (ret)
> return ret;
>
> @@ -744,7 +744,7 @@ int CameraSensor::setFormat(V4L2SubdeviceFormat *format)
> *
> * \return A map of the V4L2 controls supported by the sensor
> */
> -const ControlInfoMap &CameraSensor::controls() const
> +const ControlInfoMap &CameraSensor::v4l2Controls() const
> {
> return subdev_->controls();
> }
> @@ -767,7 +767,7 @@ const ControlInfoMap &CameraSensor::controls() const
> * \return The control values in a ControlList on success, or an empty list on
> * error
> */
> -ControlList CameraSensor::getControls(const std::vector<uint32_t> &ids)
> +ControlList CameraSensor::getV4L2Controls(const std::vector<uint32_t> &ids)
> {
> return subdev_->getControls(ids);
> }
> @@ -797,7 +797,7 @@ ControlList CameraSensor::getControls(const std::vector<uint32_t> &ids)
> * \retval -EINVAL One of the control is not supported or not accessible
> * \retval i The index of the control that failed
> */
> -int CameraSensor::setControls(ControlList *ctrls)
> +int CameraSensor::setV4L2Controls(ControlList *ctrls)
> {
> return subdev_->setControls(ctrls);
> }
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index b7dda282faab..85e5f8a70408 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -581,7 +581,7 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)
> * the sensor and user transform.
> */
> if (data->supportsFlips_) {
> - ControlList sensorCtrls(cio2->sensor()->controls());
> + ControlList sensorCtrls(cio2->sensor()->v4l2Controls());
> sensorCtrls.set(V4L2_CID_HFLIP,
> static_cast<int32_t>(!!(config->combinedTransform_
> & Transform::HFlip)));
> @@ -589,7 +589,7 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)
> static_cast<int32_t>(!!(config->combinedTransform_
> & Transform::VFlip)));
>
> - ret = cio2->sensor()->setControls(&sensorCtrls);
> + ret = cio2->sensor()->setV4L2Controls(&sensorCtrls);
> if (ret)
> return ret;
> }
> @@ -662,7 +662,7 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)
> }
>
> ipa::ipu3::IPAConfigInfo configInfo;
> - configInfo.sensorControls = data->cio2_.sensor()->controls();
> + configInfo.sensorControls = data->cio2_.sensor()->v4l2Controls();
>
> CameraLens *lens = data->cio2_.sensor()->focusLens();
> if (lens)
> @@ -1157,7 +1157,7 @@ int PipelineHandlerIPU3::registerCameras()
> LOG(IPU3, Warning) << "Invalid rotation of " << rotation
> << " degrees: ignoring";
>
> - ControlList ctrls = cio2->sensor()->getControls({ V4L2_CID_HFLIP });
> + ControlList ctrls = cio2->sensor()->getV4L2Controls({ V4L2_CID_HFLIP });
> if (!ctrls.empty())
> /* We assume the sensor supports VFLIP too. */
> data->supportsFlips_ = true;
> @@ -1245,7 +1245,7 @@ int IPU3CameraData::loadIPA()
> return ret;
>
> ret = ipa_->init(IPASettings{ "", sensor->model() }, sensorInfo,
> - sensor->controls(), &ipaControls_);
> + sensor->v4l2Controls(), &ipaControls_);
> if (ret) {
> LOG(IPU3, Error) << "Failed to initialise the IPU3 IPA";
> return ret;
> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> index 66a84b1dfb97..f0013d3a1485 100644
> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> @@ -1303,8 +1303,8 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, Me
> * sensor of the colour gains. It is defined to be a linear gain where
> * the default value represents a gain of exactly one.
> */
> - auto it = data->sensor_->controls().find(V4L2_CID_NOTIFY_GAINS);
> - if (it != data->sensor_->controls().end())
> + auto it = data->sensor_->v4l2Controls().find(V4L2_CID_NOTIFY_GAINS);
> + if (it != data->sensor_->v4l2Controls().end())
> data->notifyGainsUnity_ = it->second.def().get<int32_t>();
>
> /*
> @@ -1565,7 +1565,7 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::IPA
> }
> }
>
> - entityControls.emplace(0, sensor_->controls());
> + entityControls.emplace(0, sensor_->v4l2Controls());
> entityControls.emplace(1, isp_[Isp::Input].dev()->controls());
>
> /* Always send the user transform to the IPA. */
> @@ -1719,7 +1719,7 @@ void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList &
> if (notifyGainsUnity_ && controls.contains(libcamera::controls::ColourGains)) {
> libcamera::Span<const float> colourGains = controls.get(libcamera::controls::ColourGains);
> /* The control wants linear gains in the order B, Gb, Gr, R. */
> - ControlList ctrls(sensor_->controls());
> + ControlList ctrls(sensor_->v4l2Controls());
> std::array<int32_t, 4> gains{
> static_cast<int32_t>(colourGains[1] * *notifyGainsUnity_),
> *notifyGainsUnity_,
> @@ -1728,7 +1728,7 @@ void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList &
> };
> ctrls.set(V4L2_CID_NOTIFY_GAINS, Span<const int32_t>{ gains });
>
> - sensor_->setControls(&ctrls);
> + sensor_->setV4L2Controls(&ctrls);
> }
>
> state_ = State::IpaComplete;
> @@ -1800,10 +1800,10 @@ void RPiCameraData::setSensorControls(ControlList &controls)
> ControlList vblank_ctrl;
>
> vblank_ctrl.set(V4L2_CID_VBLANK, controls.get(V4L2_CID_VBLANK));
> - sensor_->setControls(&vblank_ctrl);
> + sensor_->setV4L2Controls(&vblank_ctrl);
> }
>
> - sensor_->setControls(&controls);
> + sensor_->setV4L2Controls(&controls);
> }
>
> void RPiCameraData::unicamTimeout()
> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> index 3dc0850c7c89..83b67a8205f5 100644
> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> @@ -670,7 +670,7 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)
> }
>
> std::map<uint32_t, ControlInfoMap> entityControls;
> - entityControls.emplace(0, data->sensor_->controls());
> + entityControls.emplace(0, data->sensor_->v4l2Controls());
>
> ret = data->ipa_->configure(sensorInfo, streamConfig, entityControls);
> if (ret) {
> diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp
> index 3379ac5cd47d..2991306ca9d8 100644
> --- a/src/libcamera/pipeline/vimc/vimc.cpp
> +++ b/src/libcamera/pipeline/vimc/vimc.cpp
> @@ -307,7 +307,7 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)
> std::forward_as_tuple(cfg.pixelFormat, cfg.size));
>
> std::map<unsigned int, ControlInfoMap> entityControls;
> - entityControls.emplace(0, data->sensor_->controls());
> + entityControls.emplace(0, data->sensor_->v4l2Controls());
>
> IPACameraSensorInfo sensorInfo;
> data->sensor_->sensorInfo(&sensorInfo);
> @@ -376,7 +376,7 @@ void PipelineHandlerVimc::stopDevice(Camera *camera)
>
> int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request)
> {
> - ControlList controls(data->sensor_->controls());
> + ControlList controls(data->sensor_->v4l2Controls());
>
> for (auto it : request->controls()) {
> unsigned int id = it.first;
> @@ -405,7 +405,7 @@ int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request)
> << "Setting control " << utils::hex(ctrl.first)
> << " to " << ctrl.second.toString();
>
> - int ret = data->sensor_->setControls(&controls);
> + int ret = data->sensor_->setV4L2Controls(&controls);
> if (ret) {
> LOG(VIMC, Error) << "Failed to set controls: " << ret;
> return ret < 0 ? ret : -EINVAL;
> @@ -530,7 +530,7 @@ int VimcCameraData::init()
> }
>
> /* Initialise the supported controls. */
> - const ControlInfoMap &controls = sensor_->controls();
> + const ControlInfoMap &controls = sensor_->v4l2Controls();
> ControlInfoMap::Map ctrls;
>
> for (const auto &ctrl : controls) {
> --
> 2.36.1
>
More information about the libcamera-devel
mailing list