From patchwork Thu Jun 30 13:38:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 16464 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id E339CC3278 for ; Thu, 30 Jun 2022 13:39:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 33A4A6569C; Thu, 30 Jun 2022 15:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656596372; bh=Wze/zWdkmyZCcAc3Lfnv2bHGjZUXn9zlfAP79PKvJcs=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=EN0HTxzYu+xXEMoDTEZd7KnEq2U0YHFYK45Wfr+V0nFX/zOGlQcXcT94t5/cMlytu 9jlnKd2lspkbP+TAYXJZded6nN6aeZu9YGdKKnKzo9Pn4x8rKG+v4qUQs7MJCRi/Rr IyuzSQP4+PTTFF0d1rBtShGUCpq5zH1jRANdalrFuk3t+eWk0Hda9CJ9JdigZ5zQLa 2UUuf281jsGuNuXL2gGm3iVqqzdlYkgNY4QfoE9wscXCblcqiyP9W00PJCoLtn0U/F JJTDD36pbX4ulXBbSN35LrAiQhw8uTeBC2dgADmQLoPfwqxd9wfkoG3vUQp6+I5+6L vc6v2GMctvrFA== Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::221]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 42D956564C for ; Thu, 30 Jun 2022 15:39:27 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id DEEAC24000B; Thu, 30 Jun 2022 13:39:25 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Thu, 30 Jun 2022 15:38:46 +0200 Message-Id: <20220630133902.321099-8-jacopo@jmondi.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220630133902.321099-1-jacopo@jmondi.org> References: <20220630133902.321099-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 07/23] libcamera: camera_sensor: Rename the control interface X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 Reviewed-by: Kieran Bingham --- 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 &ids); - int setControls(ControlList *ctrls); + const ControlInfoMap &v4l2Controls() const; + ControlList getV4L2Controls(const std::vector &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 &ids) +ControlList CameraSensor::getV4L2Controls(const std::vector &ids) { return subdev_->getControls(ids); } @@ -797,7 +797,7 @@ ControlList CameraSensor::getControls(const std::vector &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(!!(config->combinedTransform_ & Transform::HFlip))); @@ -589,7 +589,7 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) static_cast(!!(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(); /* @@ -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 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 gains{ static_cast(colourGains[1] * *notifyGainsUnity_), *notifyGainsUnity_, @@ -1728,7 +1728,7 @@ void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList & }; ctrls.set(V4L2_CID_NOTIFY_GAINS, Span{ 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 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 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) {