[{"id":23696,"web_url":"https://patchwork.libcamera.org/comment/23696/","msgid":"<165662776091.1516045.4818365360712181179@Monstersaurus>","date":"2022-06-30T22:22:40","subject":"Re: [libcamera-devel] [PATCH v3 07/23] libcamera: camera_sensor:\n\tRename the control interface","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Jacopo Mondi via libcamera-devel (2022-06-30 14:38:46)\n> The control interface of the CameraSensor class operates on V4L2\n> controls.\n> \n> To prepare to move the CameraSensor interface to use libcamera::internal\n> controls, rename the existing interface to be the 'v4l2' control\n> interface, to allow users to transition to the new interface gradually.\n> \n\nI think this makes sense regardless of how we name the controls we move\ntowards.\n\nThe more I read on this series, the more convinced I am that any\n'internal' control would be a public control that should be reported\nthrough the metadata, so I think we could call this 'Moving to libcamera\ncontrols'...\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  include/libcamera/internal/camera_sensor.h         |  6 +++---\n>  src/libcamera/camera_sensor/camera_sensor.cpp      | 14 +++++++-------\n>  src/libcamera/pipeline/ipu3/ipu3.cpp               | 10 +++++-----\n>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 14 +++++++-------\n>  src/libcamera/pipeline/rkisp1/rkisp1.cpp           |  2 +-\n>  src/libcamera/pipeline/vimc/vimc.cpp               |  8 ++++----\n>  6 files changed, 27 insertions(+), 27 deletions(-)\n> \n> diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\n> index 43b035b77f2b..2a850dedc0aa 100644\n> --- a/include/libcamera/internal/camera_sensor.h\n> +++ b/include/libcamera/internal/camera_sensor.h\n> @@ -56,9 +56,9 @@ public:\n>                                       const Size &size) const;\n>         int setFormat(V4L2SubdeviceFormat *format);\n>  \n> -       const ControlInfoMap &controls() const;\n> -       ControlList getControls(const std::vector<uint32_t> &ids);\n> -       int setControls(ControlList *ctrls);\n> +       const ControlInfoMap &v4l2Controls() const;\n> +       ControlList getV4L2Controls(const std::vector<uint32_t> &ids);\n> +       int setV4L2Controls(ControlList *ctrls);\n>  \n>         V4L2Subdevice *device() { return subdev_.get(); }\n>  \n> diff --git a/src/libcamera/camera_sensor/camera_sensor.cpp b/src/libcamera/camera_sensor/camera_sensor.cpp\n> index 59b956e40803..26cfa7d0f65a 100644\n> --- a/src/libcamera/camera_sensor/camera_sensor.cpp\n> +++ b/src/libcamera/camera_sensor/camera_sensor.cpp\n> @@ -335,8 +335,8 @@ void CameraSensor::initStaticProperties()\n>  \n>  void CameraSensor::initTestPatternModes()\n>  {\n> -       const auto &v4l2TestPattern = controls().find(V4L2_CID_TEST_PATTERN);\n> -       if (v4l2TestPattern == controls().end()) {\n> +       const auto &v4l2TestPattern = v4l2Controls().find(V4L2_CID_TEST_PATTERN);\n> +       if (v4l2TestPattern == v4l2Controls().end()) {\n>                 LOG(CameraSensor, Debug) << \"V4L2_CID_TEST_PATTERN is not supported\";\n>                 return;\n>         }\n> @@ -615,10 +615,10 @@ int CameraSensor::applyTestPatternMode(controls::draft::TestPatternModeEnum mode\n>         LOG(CameraSensor, Debug) << \"Apply test pattern mode \" << mode;\n>  \n>         int32_t index = staticProps_->testPatternModes.at(mode);\n> -       ControlList ctrls{ controls() };\n> +       ControlList ctrls{ v4l2Controls() };\n>         ctrls.set(V4L2_CID_TEST_PATTERN, index);\n>  \n> -       int ret = setControls(&ctrls);\n> +       int ret = setV4L2Controls(&ctrls);\n>         if (ret)\n>                 return ret;\n>  \n> @@ -744,7 +744,7 @@ int CameraSensor::setFormat(V4L2SubdeviceFormat *format)\n>   *\n>   * \\return A map of the V4L2 controls supported by the sensor\n>   */\n> -const ControlInfoMap &CameraSensor::controls() const\n> +const ControlInfoMap &CameraSensor::v4l2Controls() const\n>  {\n>         return subdev_->controls();\n>  }\n> @@ -767,7 +767,7 @@ const ControlInfoMap &CameraSensor::controls() const\n>   * \\return The control values in a ControlList on success, or an empty list on\n>   * error\n>   */\n> -ControlList CameraSensor::getControls(const std::vector<uint32_t> &ids)\n> +ControlList CameraSensor::getV4L2Controls(const std::vector<uint32_t> &ids)\n>  {\n>         return subdev_->getControls(ids);\n>  }\n> @@ -797,7 +797,7 @@ ControlList CameraSensor::getControls(const std::vector<uint32_t> &ids)\n>   * \\retval -EINVAL One of the control is not supported or not accessible\n>   * \\retval i The index of the control that failed\n>   */\n> -int CameraSensor::setControls(ControlList *ctrls)\n> +int CameraSensor::setV4L2Controls(ControlList *ctrls)\n>  {\n>         return subdev_->setControls(ctrls);\n>  }\n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index b7dda282faab..85e5f8a70408 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -581,7 +581,7 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)\n>          * the sensor and user transform.\n>          */\n>         if (data->supportsFlips_) {\n> -               ControlList sensorCtrls(cio2->sensor()->controls());\n> +               ControlList sensorCtrls(cio2->sensor()->v4l2Controls());\n>                 sensorCtrls.set(V4L2_CID_HFLIP,\n>                                 static_cast<int32_t>(!!(config->combinedTransform_\n>                                                         & Transform::HFlip)));\n> @@ -589,7 +589,7 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)\n>                                 static_cast<int32_t>(!!(config->combinedTransform_\n>                                                         & Transform::VFlip)));\n>  \n> -               ret = cio2->sensor()->setControls(&sensorCtrls);\n> +               ret = cio2->sensor()->setV4L2Controls(&sensorCtrls);\n>                 if (ret)\n>                         return ret;\n>         }\n> @@ -662,7 +662,7 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)\n>         }\n>  \n>         ipa::ipu3::IPAConfigInfo configInfo;\n> -       configInfo.sensorControls = data->cio2_.sensor()->controls();\n> +       configInfo.sensorControls = data->cio2_.sensor()->v4l2Controls();\n>  \n>         CameraLens *lens = data->cio2_.sensor()->focusLens();\n>         if (lens)\n> @@ -1157,7 +1157,7 @@ int PipelineHandlerIPU3::registerCameras()\n>                         LOG(IPU3, Warning) << \"Invalid rotation of \" << rotation\n>                                            << \" degrees: ignoring\";\n>  \n> -               ControlList ctrls = cio2->sensor()->getControls({ V4L2_CID_HFLIP });\n> +               ControlList ctrls = cio2->sensor()->getV4L2Controls({ V4L2_CID_HFLIP });\n>                 if (!ctrls.empty())\n>                         /* We assume the sensor supports VFLIP too. */\n>                         data->supportsFlips_ = true;\n> @@ -1245,7 +1245,7 @@ int IPU3CameraData::loadIPA()\n>                 return ret;\n>  \n>         ret = ipa_->init(IPASettings{ \"\", sensor->model() }, sensorInfo,\n> -                        sensor->controls(), &ipaControls_);\n> +                        sensor->v4l2Controls(), &ipaControls_);\n>         if (ret) {\n>                 LOG(IPU3, Error) << \"Failed to initialise the IPU3 IPA\";\n>                 return ret;\n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 66a84b1dfb97..f0013d3a1485 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -1303,8 +1303,8 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, Me\n>          * sensor of the colour gains. It is defined to be a linear gain where\n>          * the default value represents a gain of exactly one.\n>          */\n> -       auto it = data->sensor_->controls().find(V4L2_CID_NOTIFY_GAINS);\n> -       if (it != data->sensor_->controls().end())\n> +       auto it = data->sensor_->v4l2Controls().find(V4L2_CID_NOTIFY_GAINS);\n> +       if (it != data->sensor_->v4l2Controls().end())\n>                 data->notifyGainsUnity_ = it->second.def().get<int32_t>();\n>  \n>         /*\n> @@ -1565,7 +1565,7 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::IPA\n>                 }\n>         }\n>  \n> -       entityControls.emplace(0, sensor_->controls());\n> +       entityControls.emplace(0, sensor_->v4l2Controls());\n>         entityControls.emplace(1, isp_[Isp::Input].dev()->controls());\n>  \n>         /* Always send the user transform to the IPA. */\n> @@ -1719,7 +1719,7 @@ void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList &\n>         if (notifyGainsUnity_ && controls.contains(libcamera::controls::ColourGains)) {\n>                 libcamera::Span<const float> colourGains = controls.get(libcamera::controls::ColourGains);\n>                 /* The control wants linear gains in the order B, Gb, Gr, R. */\n> -               ControlList ctrls(sensor_->controls());\n> +               ControlList ctrls(sensor_->v4l2Controls());\n>                 std::array<int32_t, 4> gains{\n>                         static_cast<int32_t>(colourGains[1] * *notifyGainsUnity_),\n>                         *notifyGainsUnity_,\n> @@ -1728,7 +1728,7 @@ void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList &\n>                 };\n>                 ctrls.set(V4L2_CID_NOTIFY_GAINS, Span<const int32_t>{ gains });\n>  \n> -               sensor_->setControls(&ctrls);\n> +               sensor_->setV4L2Controls(&ctrls);\n>         }\n>  \n>         state_ = State::IpaComplete;\n> @@ -1800,10 +1800,10 @@ void RPiCameraData::setSensorControls(ControlList &controls)\n>                 ControlList vblank_ctrl;\n>  \n>                 vblank_ctrl.set(V4L2_CID_VBLANK, controls.get(V4L2_CID_VBLANK));\n> -               sensor_->setControls(&vblank_ctrl);\n> +               sensor_->setV4L2Controls(&vblank_ctrl);\n>         }\n>  \n> -       sensor_->setControls(&controls);\n> +       sensor_->setV4L2Controls(&controls);\n>  }\n>  \n>  void RPiCameraData::unicamTimeout()\n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> index 3dc0850c7c89..83b67a8205f5 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> @@ -670,7 +670,7 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n>         }\n>  \n>         std::map<uint32_t, ControlInfoMap> entityControls;\n> -       entityControls.emplace(0, data->sensor_->controls());\n> +       entityControls.emplace(0, data->sensor_->v4l2Controls());\n>  \n>         ret = data->ipa_->configure(sensorInfo, streamConfig, entityControls);\n>         if (ret) {\n> diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\n> index 3379ac5cd47d..2991306ca9d8 100644\n> --- a/src/libcamera/pipeline/vimc/vimc.cpp\n> +++ b/src/libcamera/pipeline/vimc/vimc.cpp\n> @@ -307,7 +307,7 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)\n>                                      std::forward_as_tuple(cfg.pixelFormat, cfg.size));\n>  \n>                 std::map<unsigned int, ControlInfoMap> entityControls;\n> -               entityControls.emplace(0, data->sensor_->controls());\n> +               entityControls.emplace(0, data->sensor_->v4l2Controls());\n>  \n>                 IPACameraSensorInfo sensorInfo;\n>                 data->sensor_->sensorInfo(&sensorInfo);\n> @@ -376,7 +376,7 @@ void PipelineHandlerVimc::stopDevice(Camera *camera)\n>  \n>  int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request)\n>  {\n> -       ControlList controls(data->sensor_->controls());\n> +       ControlList controls(data->sensor_->v4l2Controls());\n>  \n>         for (auto it : request->controls()) {\n>                 unsigned int id = it.first;\n> @@ -405,7 +405,7 @@ int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request)\n>                         << \"Setting control \" << utils::hex(ctrl.first)\n>                         << \" to \" << ctrl.second.toString();\n>  \n> -       int ret = data->sensor_->setControls(&controls);\n> +       int ret = data->sensor_->setV4L2Controls(&controls);\n>         if (ret) {\n>                 LOG(VIMC, Error) << \"Failed to set controls: \" << ret;\n>                 return ret < 0 ? ret : -EINVAL;\n> @@ -530,7 +530,7 @@ int VimcCameraData::init()\n>         }\n>  \n>         /* Initialise the supported controls. */\n> -       const ControlInfoMap &controls = sensor_->controls();\n> +       const ControlInfoMap &controls = sensor_->v4l2Controls();\n>         ControlInfoMap::Map ctrls;\n>  \n>         for (const auto &ctrl : controls) {\n> -- \n> 2.36.1\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 9CAFABE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 30 Jun 2022 22:22:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EF06965633;\n\tFri,  1 Jul 2022 00:22:45 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 086B360412\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  1 Jul 2022 00:22:44 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4E2CD25C;\n\tFri,  1 Jul 2022 00:22:43 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1656627766;\n\tbh=zOl0S0rLL9YpQeBt5lBF5/QdeDjrNFLl5qEpTL34uxk=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=byQSrgwQhpqkPJcgaRZuoH+GMseg1QXr00q7yWeWcyJELQOrCVoR+PhlkvHxnR6W/\n\tTrjQG7OFKF1WEynqEWBZ3D9twYUbPg2aRyt4Q7/mXyQqgRMOdmW+Sf6bhViu6uQ41S\n\tcyV1Dam9W53b4aPWhvAUL0HxF+WiHsU+IkyF2hjFdmNbgJkd0IZe0WGGS8xLFCrlHD\n\toWfx3bjRuZST5BMAbrjUOm3743AoXcUsvTbLfPDZvV6xs7uWCrsMp/RBBalurHFG02\n\tN9k4Zoo9J0QACZo0/a9FvnKCG7EzDUdPcM+bc+yxSVB6+d2te9qz59bxxRDHSJpLMM\n\tcOcvHAtvaCRFQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1656627763;\n\tbh=zOl0S0rLL9YpQeBt5lBF5/QdeDjrNFLl5qEpTL34uxk=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=lbivvTY7dAjK9WTHwCD25alPBTAS0ej9uE8oukainVFr7qVJ/mrHZjecWL0+LdlZL\n\tJ9Z1GQV/YeWXhvl7a3wZHGrYN6ghgvzU0qJgnj5DAiXyG8TcCVbn5ujGgFLYvl1Z9Z\n\tLo0/PCXYFaa5z4mO/ZMvgXEjO9YSfIF8nirbrclM="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"lbivvTY7\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20220630133902.321099-8-jacopo@jmondi.org>","References":"<20220630133902.321099-1-jacopo@jmondi.org>\n\t<20220630133902.321099-8-jacopo@jmondi.org>","To":"Jacopo Mondi <jacopo@jmondi.org>, libcamera-devel@lists.libcamera.org","Date":"Thu, 30 Jun 2022 23:22:40 +0100","Message-ID":"<165662776091.1516045.4818365360712181179@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v3 07/23] libcamera: camera_sensor:\n\tRename the control interface","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]