[{"id":20810,"web_url":"https://patchwork.libcamera.org/comment/20810/","msgid":"<bdd0bb18-0087-dd27-f8ef-13ffad913a95@ideasonboard.com>","date":"2021-11-04T11:54:48","subject":"Re: [libcamera-devel] [PATCH v2 4/4] ipu3: ipa: Allow IPA to apply\n\tcontrols to the lens device","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Han-Lin,\n\nOn 29/10/2021 13:59, Han-Lin Chen wrote:\n> Allow IPA to apply controls to the lens device.\n> \n> Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org>\n> ---\n>   meson.build                          |  6 ++++++\n>   src/libcamera/pipeline/ipu3/cio2.cpp | 30 ++++++++++++++++++++++++++++\n>   src/libcamera/pipeline/ipu3/cio2.h   |  3 +++\n>   src/libcamera/pipeline/ipu3/ipu3.cpp |  9 +++++++--\n>   4 files changed, 46 insertions(+), 2 deletions(-)\n> \n> diff --git a/meson.build b/meson.build\n> index 7892a9e3..2a4b68a2 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -108,6 +108,12 @@ if cc.has_argument('-Wno-c99-designator')\n>       ]\n>   endif\n>   \n> +if get_option('android_platform') == 'cros'\n> +    common_arguments += [\n> +        '-DOS_CHROMEOS',\n> +    ]\n> +endif\n> +\n>   c_arguments += common_arguments\n>   cpp_arguments += common_arguments\n>   \n> diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\n> index 59dda56b..143e2a95 100644\n> --- a/src/libcamera/pipeline/ipu3/cio2.cpp\n> +++ b/src/libcamera/pipeline/ipu3/cio2.cpp\n> @@ -16,6 +16,7 @@\n>   #include <libcamera/geometry.h>\n>   #include <libcamera/stream.h>\n>   \n> +#include \"libcamera/internal/camera_lens.h\"\n>   #include \"libcamera/internal/camera_sensor.h\"\n>   #include \"libcamera/internal/framebuffer.h\"\n>   #include \"libcamera/internal/media_device.h\"\n> @@ -159,6 +160,35 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n>   \t\treturn -EINVAL;\n>   \t}\n>   \n> +#if defined(OS_CHROMEOS)\n\nWhat is the status about Kieran's comment for the media graph in v1 ?\nI still suggest to split lens controls in a separate patch series as the \nsensor controls could probably be merged before... ?\n\n> +\t/*\n> +\t * \\todo Read the lens model from the sensor itself or from a device database.\n> +\t * For now use default values taken from ChromeOS.\n> +\t */\n> +\tstatic std::unordered_map<std::string, std::string> sensorLens = {\n> +\t\t{ \"ov13858\", \"dw9714\" },\n> +\t\t{ \"imx258\", \"dw9807\" },\n> +\t\t{ \"imx355\", \"ak7375\" }\n> +\t};\n> +\n> +\tauto it = sensorLens.find(sensor_->model());\n> +\tif (it != sensorLens.end()) {\n> +\t\tconst std::vector<MediaEntity *> &entities = media->entities();\n> +\t\tfor (auto ent: entities) {\n> +\t\t\tif (ent->function() == MEDIA_ENT_F_LENS) {\n> +\t\t\t\tlens_ = std::make_unique<CameraLens>(ent);\n> +\t\t\t\tret = lens_->init();\n> +\t\t\t\tif (!ret && lens_->model() == it->second) {\n> +\t\t\t\t\tbreak;\n> +\t\t\t\t}\n> +\t\t\t\tlens_.reset();\n> +\t\t\t}\n> +\t\t\tif (!lens_)\n> +\t\t\t\tLOG(IPU3, Warning) << \"Lens device \" << it->second << \" not found\";\n> +\t\t}\n> +\t}\n> +#endif\n> +\n>   \t/*\n>   \t * \\todo Define when to open and close video device nodes, as they\n>   \t * might impact on power consumption.\n> diff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h\n> index ba8f0052..635566c8 100644\n> --- a/src/libcamera/pipeline/ipu3/cio2.h\n> +++ b/src/libcamera/pipeline/ipu3/cio2.h\n> @@ -18,6 +18,7 @@\n>   \n>   namespace libcamera {\n>   \n> +class CameraLens;\n>   class CameraSensor;\n>   class FrameBuffer;\n>   class MediaDevice;\n> @@ -52,6 +53,7 @@ public:\n>   \tint stop();\n>   \n>   \tCameraSensor *sensor() { return sensor_.get(); }\n> +\tCameraLens *lens() { return lens_.get(); }\n>   \tconst CameraSensor *sensor() const { return sensor_.get(); }\n>   \n>   \tFrameBuffer *queueBuffer(Request *request, FrameBuffer *rawBuffer);\n> @@ -67,6 +69,7 @@ private:\n>   \tvoid cio2BufferReady(FrameBuffer *buffer);\n>   \n>   \tstd::unique_ptr<CameraSensor> sensor_;\n> +\tstd::unique_ptr<CameraLens> lens_;\n>   \tstd::unique_ptr<V4L2Subdevice> csi2_;\n>   \tstd::unique_ptr<V4L2VideoDevice> output_;\n>   \n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 6a7f5b9a..6c44957f 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -24,6 +24,7 @@\n>   #include <libcamera/stream.h>\n>   \n>   #include \"libcamera/internal/camera.h\"\n> +#include \"libcamera/internal/camera_lens.h\"\n>   #include \"libcamera/internal/camera_sensor.h\"\n>   #include \"libcamera/internal/delayed_controls.h\"\n>   #include \"libcamera/internal/device_enumerator.h\"\n> @@ -1250,8 +1251,12 @@ void IPU3CameraData::queueFrameAction(unsigned int id,\n>   {\n>   \tswitch (action.op) {\n>   \tcase ipa::ipu3::ActionSetSensorControls: {\n> -\t\tconst ControlList &controls = action.sensorControls;\n> -\t\tdelayedCtrls_->push(controls);\n> +\t\tconst ControlList &sensorControls = action.sensorControls;\n> +\t\tdelayedCtrls_->push(sensorControls);\n> +\t\tif (cio2_.lens()) {\n> +\t\t\tControlList lensControls = action.lensControls;\n> +\t\t\tcio2_.lens()->setControls(&lensControls);\n> +\t\t}\n>   \t\tbreak;\n>   \t}\n>   \tcase ipa::ipu3::ActionParamFilled: {\n>","headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":["parsemail@patchwork.libcamera.org","kbingham@ideasonboard.com"],"Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 42633BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 10 Nov 2021 13:56:40 +0000 (UTC)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net\n\t[86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C9258501\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 10 Nov 2021 14:56:39 +0100 (CET)","from perceval.ideasonboard.com\n\tby perceval.ideasonboard.com with LMTP id IDL8OAzKg2GcTQAA4E0KoQ\n\t(envelope-from <libcamera-devel-bounces@lists.libcamera.org>)\n\tfor <kbingham@ideasonboard.com>; Thu, 04 Nov 2021 12:54:52 +0100","from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[IPv6:2001:4b98:dc0:43:216:3eff:fe33:f827])\tby\n\tperceval.ideasonboard.com (Postfix) with ESMTPS id C898AE52;\n\tThu,  4 Nov 2021 12:54:52 +0100 (CET)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 27FEA6033D;\n\tThu,  4 Nov 2021 12:54:52 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D40A76032C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Nov 2021 12:54:50 +0100 (CET)","from [IPV6:2a01:e0a:169:7140:3875:cc64:ce12:aabc] (unknown\n\t[IPv6:2a01:e0a:169:7140:3875:cc64:ce12:aabc])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 77FAFE52;\n\tThu,  4 Nov 2021 12:54:50 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1636552599;\n\tbh=cV4BBkKziz1mtyd0jqZOznvbHZasauuQQuWAusdUIyY=;\n\th=Date:To:References:From:In-Reply-To:Subject:List-Id:\n\tList-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:\n\tResent-From:Resent-To:From;\n\tb=FqZjSgLYo0FVN4hb/ZxG1Hkwh+UxJbKyusx7Rflmpqdk1iAg9P2EtTzR3gsVVAbry\n\t5/P83CIUooQfRcqcw02JnG1xBcV99ZbSw5rMzhuseSYFYffVlD6ZGGZeqkL2TELVFd\n\t3lrjgIU/T7+M8H9cERj/V6o++NpAt7/nTnLefevs=","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1636026890;\n\tbh=cV4BBkKziz1mtyd0jqZOznvbHZasauuQQuWAusdUIyY=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=pZreFtwYeOKfrhfHdF047iy85tLnu24ynM3/qywro2jRguRCZSAXSBnrlIPkQQiKU\n\ttLerDftnPGOQfyrdNxBi1kVesNlcTxraVQM76E408qpuGWWH6ICAC96ic1SCcfgeQa\n\tcZUTnWpg4oR2QfNn0Sx/0mTcc6JOvYt1XdWbq/A8="],"Authentication-Results":["perceval.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"pZreFtwY\";\tdkim-atps=neutral","lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"pZreFtwY\";\tdkim-atps=neutral"],"Message-ID":"<bdd0bb18-0087-dd27-f8ef-13ffad913a95@ideasonboard.com>","Date":"Thu, 4 Nov 2021 12:54:48 +0100","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.1.2","Content-Language":"en-US","To":"Han-Lin Chen <hanlinchen@chromium.org>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20211029115917.2467936-1-hanlinchen@chromium.org>\n\t<20211029115917.2467936-4-hanlinchen@chromium.org>","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","In-Reply-To":"<20211029115917.2467936-4-hanlinchen@chromium.org>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2 4/4] ipu3: ipa: Allow IPA to apply\n\tcontrols to the lens device","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>","X-TUID":"YT2glsjDIa5o","Resent-From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Resent-To":"parsemail@patchwork.libcamera.org"}}]