[libcamera-devel] [PATCH 07/15] libcamera: camera_sensor: Rename the control interface
Jacopo Mondi
jacopo at jmondi.org
Mon Jun 27 18:27:24 CEST 2022
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.
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
include/libcamera/internal/camera_sensor.h | 6 +++---
src/libcamera/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 0359d4609517..0bed6e679840 100644
--- a/include/libcamera/internal/camera_sensor.h
+++ b/include/libcamera/internal/camera_sensor.h
@@ -59,9 +59,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.cpp b/src/libcamera/camera_sensor.cpp
index 5cd33e904174..e3354530380c 100644
--- a/src/libcamera/camera_sensor.cpp
+++ b/src/libcamera/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;
}
@@ -637,10 +637,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;
@@ -766,7 +766,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();
}
@@ -789,7 +789,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);
}
@@ -819,7 +819,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 19d022c584ed..28442756b184 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)
@@ -1175,7 +1175,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;
@@ -1263,7 +1263,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 adc397e8aabd..782eb9ef20e8 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -1292,8 +1292,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>();
/*
@@ -1554,7 +1554,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. */
@@ -1708,7 +1708,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_,
@@ -1717,7 +1717,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;
@@ -1789,10 +1789,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 7cf36524ccc4..997f72500675 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -652,7 +652,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