[{"id":21176,"web_url":"https://patchwork.libcamera.org/comment/21176/","msgid":"<YZ3UIIUt39DS3N5P@pendragon.ideasonboard.com>","date":"2021-11-24T05:56:48","subject":"Re: [libcamera-devel] [PATCH v4 4/4] ipu3: ipa: Allow IPA to apply\n\tcontrols to the lens device","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Han-lin,\n\n(CC'ing Dan)\n\nThank you for the patch.\n\nOn Tue, Nov 23, 2021 at 08:37:51PM +0800, 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>  src/libcamera/pipeline/ipu3/cio2.cpp | 29 ++++++++++++++++++++++++++++\n>  src/libcamera/pipeline/ipu3/cio2.h   |  3 +++\n>  src/libcamera/pipeline/ipu3/ipu3.cpp | 12 ++++++++++--\n>  3 files changed, 42 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\n> index 59dda56b..59b2f586 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,34 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n>  \t\treturn -EINVAL;\n>  \t}\n>  \n> +\t/*\n> +\t * \\todo Read the lens model from the sensor itself or from a device\n> +\t * database. For now use default values taken from ChromeOS database.\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\nDan, could you share your patches to add an ancillary link between the\nimaging sensor and the lens controller with Han-lin once they're ready ?\nThis is what we should use here, and Han-lin could help testing them on\nChrome OS (which uses different ACPI bindings for the CIO2).\n\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 \"\n> +\t\t\t\t\t\t   << it->second << \" not found\";\n> +\t\t}\n> +\t}\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 c65afdb2..6e04ec8f 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> @@ -1238,8 +1239,15 @@ 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> +\n> +\t\tconst ControlList lensControls = action.lensControls;\n> +\t\tconst ControlValue &focusValue =\n> +\t\t\tlensControls.get(V4L2_CID_FOCUS_ABSOLUTE);\n> +\t\tif (!focusValue.isNone() && cio2_.lens())\n> +\t\t\tcio2_.lens()->setFocusPostion(focusValue.get<int32_t>());\n> +\n\nThe other way around, should we pass the limits of the focus control\nfrom the pipeline handler to the IPA ?\n\n>  \t\tbreak;\n>  \t}\n>  \tcase ipa::ipu3::ActionParamFilled: {","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 D9532BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 24 Nov 2021 05:57:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 19E7B6036F;\n\tWed, 24 Nov 2021 06:57:12 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 39CFE60226\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Nov 2021 06:57:11 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9CF0993;\n\tWed, 24 Nov 2021 06:57:10 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"swRvQWWw\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1637733430;\n\tbh=K2r+jaFZu0VyF0KtUcC7a+ibMVgu61LjDNEZ/aCc1QU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=swRvQWWwbYPnfe3z+6gAXiE43o3eoFumuOg9LLkCoD2flA4rjjrASBmvHx6aJ0f+E\n\tWqT5WDD4zPjdA8CXK2yvQQaRppFh6ST4xdPa+jsczJ1BWLbAN0oygsftm1T4WdSoti\n\tfTzfwMByP/YzsV0ZlPyhVXh3bGiu6qz7PadZm+v4=","Date":"Wed, 24 Nov 2021 07:56:48 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Han-Lin Chen <hanlinchen@chromium.org>","Message-ID":"<YZ3UIIUt39DS3N5P@pendragon.ideasonboard.com>","References":"<20211123123751.3194696-1-hanlinchen@chromium.org>\n\t<20211123123751.3194696-5-hanlinchen@chromium.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211123123751.3194696-5-hanlinchen@chromium.org>","Subject":"Re: [libcamera-devel] [PATCH v4 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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":21182,"web_url":"https://patchwork.libcamera.org/comment/21182/","msgid":"<CAJAuwMmFaKvNF1ZM9r8RS2o-1Q52iJNxPFBCj+maN3u2-jQm9Q@mail.gmail.com>","date":"2021-11-24T07:32:55","subject":"Re: [libcamera-devel] [PATCH v4 4/4] ipu3: ipa: Allow IPA to apply\n\tcontrols to the lens device","submitter":{"id":98,"url":"https://patchwork.libcamera.org/api/people/98/","name":"Hanlin Chen","email":"hanlinchen@chromium.org"},"content":"On Wed, Nov 24, 2021 at 1:57 PM Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi Han-lin,\n>\n> (CC'ing Dan)\n>\n> Thank you for the patch.\n>\n> On Tue, Nov 23, 2021 at 08:37:51PM +0800, 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> >  src/libcamera/pipeline/ipu3/cio2.cpp | 29 ++++++++++++++++++++++++++++\n> >  src/libcamera/pipeline/ipu3/cio2.h   |  3 +++\n> >  src/libcamera/pipeline/ipu3/ipu3.cpp | 12 ++++++++++--\n> >  3 files changed, 42 insertions(+), 2 deletions(-)\n> >\n> > diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\n> > index 59dda56b..59b2f586 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,34 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n> >               return -EINVAL;\n> >       }\n> >\n> > +     /*\n> > +      * \\todo Read the lens model from the sensor itself or from a device\n> > +      * database. For now use default values taken from ChromeOS database.\n> > +      */\n> > +     static std::unordered_map<std::string, std::string> sensorLens = {\n> > +             { \"ov13858\", \"dw9714\" },\n> > +             { \"imx258\", \"dw9807\" },\n> > +             { \"imx355\", \"ak7375\" }\n> > +     };\n>\n> Dan, could you share your patches to add an ancillary link between the\n> imaging sensor and the lens controller with Han-lin once they're ready ?\n> This is what we should use here, and Han-lin could help testing them on\n> Chrome OS (which uses different ACPI bindings for the CIO2).\nLoop Tomasz for visibility. Looking forward to it, although it's a\nlittle out of my knowledge base ;-).\n>\n> > +\n> > +     auto it = sensorLens.find(sensor_->model());\n> > +     if (it != sensorLens.end()) {\n> > +             const std::vector<MediaEntity *> &entities = media->entities();\n> > +             for (auto ent : entities) {\n> > +                     if (ent->function() == MEDIA_ENT_F_LENS) {\n> > +                             lens_ = std::make_unique<CameraLens>(ent);\n> > +                             ret = lens_->init();\n> > +                             if (!ret && lens_->model() == it->second) {\n> > +                                     break;\n> > +                             }\n> > +                             lens_.reset();\n> > +                     }\n> > +                     if (!lens_)\n> > +                             LOG(IPU3, Warning) << \"Lens device \"\n> > +                                                << it->second << \" not found\";\n> > +             }\n> > +     }\n> > +\n> >       /*\n> >        * \\todo Define when to open and close video device nodes, as they\n> >        * 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> >       int stop();\n> >\n> >       CameraSensor *sensor() { return sensor_.get(); }\n> > +     CameraLens *lens() { return lens_.get(); }\n> >       const CameraSensor *sensor() const { return sensor_.get(); }\n> >\n> >       FrameBuffer *queueBuffer(Request *request, FrameBuffer *rawBuffer);\n> > @@ -67,6 +69,7 @@ private:\n> >       void cio2BufferReady(FrameBuffer *buffer);\n> >\n> >       std::unique_ptr<CameraSensor> sensor_;\n> > +     std::unique_ptr<CameraLens> lens_;\n> >       std::unique_ptr<V4L2Subdevice> csi2_;\n> >       std::unique_ptr<V4L2VideoDevice> output_;\n> >\n> > diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > index c65afdb2..6e04ec8f 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> > @@ -1238,8 +1239,15 @@ void IPU3CameraData::queueFrameAction(unsigned int id,\n> >  {\n> >       switch (action.op) {\n> >       case ipa::ipu3::ActionSetSensorControls: {\n> > -             const ControlList &controls = action.sensorControls;\n> > -             delayedCtrls_->push(controls);\n> > +             const ControlList &sensorControls = action.sensorControls;\n> > +             delayedCtrls_->push(sensorControls);\n> > +\n> > +             const ControlList lensControls = action.lensControls;\n> > +             const ControlValue &focusValue =\n> > +                     lensControls.get(V4L2_CID_FOCUS_ABSOLUTE);\n> > +             if (!focusValue.isNone() && cio2_.lens())\n> > +                     cio2_.lens()->setFocusPostion(focusValue.get<int32_t>());\n> > +\n>\n> The other way around, should we pass the limits of the focus control\n> from the pipeline handler to the IPA ?\nIn theory, yes, although Intel seems to hard-code them into its tuning\nfile, and not used for now.\n>\n> >               break;\n> >       }\n> >       case ipa::ipu3::ActionParamFilled: {\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","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 21CDCBDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 24 Nov 2021 07:33:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 195F46022F;\n\tWed, 24 Nov 2021 08:33:10 +0100 (CET)","from mail-ot1-x336.google.com (mail-ot1-x336.google.com\n\t[IPv6:2607:f8b0:4864:20::336])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C181E60121\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Nov 2021 08:33:07 +0100 (CET)","by mail-ot1-x336.google.com with SMTP id\n\tw6-20020a9d77c6000000b0055e804fa524so2917537otl.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Nov 2021 23:33:07 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"Oquzj/D6\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=t/OdJ0f75PT8kt/BPD0QWjV9T+twjyn6UfGGO7JjBwE=;\n\tb=Oquzj/D6CJLPD0+DuPCuQH4iTE+STIQcB4BhvtfmWsXxVTufkVp6gpm6kwYwwXGlpU\n\tnX6gU/ZKb46T3hkgcTY2qzFqKQcLaRZffxNygjt6IEQVGU8OkB7PIeWG1k939JB60Eyt\n\tkYbSaY/j4K+0B3MO8AM7k8ZRBmSPOwXmFsJso=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=t/OdJ0f75PT8kt/BPD0QWjV9T+twjyn6UfGGO7JjBwE=;\n\tb=nDNmHzLG02ZUlJCiJWbPIyOgVEE2Z5J6cQEziVQwkeTRO0dD4MXfcTxSneDASnGoy3\n\tW5GUnVIBgbwU2BQRx3lDZ/Cdvq+82HNqD0th5P25nVMGogCjaGcIbANshiHh5ekFUwhI\n\tTePBh0FThg1NeOs+nW6Yck5/+V9dYIjIdbVujjBdjBUz2g+IxDG6gqhGy8Z8cwNs3cum\n\tkOOPtkUMUeSrarH7ImBtMUjdbikZ8QLVxYGO427midMjsePgoMHBZVxtW32G6sHI/GT4\n\t1FojaA28PqzEXTZkgw/GB2mT2HYutqKDjBnjwHAFsAPw/KcEFBgDypOTI7NnNjqP6b09\n\tcfuQ==","X-Gm-Message-State":"AOAM531SHF6We0IhpZXgf3ovjMqeqD3aLc2qeO6uSr3Cs3uT97IR3zY5\n\tBTyPa9AhIMabXQJFMem/inMrfqkUYrG/UkCMmdc+Mg==","X-Google-Smtp-Source":"ABdhPJyEszBGbgOxBNF0Z+Is7PAw0/aRSgLubsek2ydF1z4nA7KPta0bZ2gdzZCZgAEAwjGRCCzVGsTzhV31wvHLTVM=","X-Received":"by 2002:a05:6830:3195:: with SMTP id\n\tp21mr8725135ots.56.1637739186141; \n\tTue, 23 Nov 2021 23:33:06 -0800 (PST)","MIME-Version":"1.0","References":"<20211123123751.3194696-1-hanlinchen@chromium.org>\n\t<20211123123751.3194696-5-hanlinchen@chromium.org>\n\t<YZ3UIIUt39DS3N5P@pendragon.ideasonboard.com>","In-Reply-To":"<YZ3UIIUt39DS3N5P@pendragon.ideasonboard.com>","From":"Hanlin Chen <hanlinchen@chromium.org>","Date":"Wed, 24 Nov 2021 15:32:55 +0800","Message-ID":"<CAJAuwMmFaKvNF1ZM9r8RS2o-1Q52iJNxPFBCj+maN3u2-jQm9Q@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v4 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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":21183,"web_url":"https://patchwork.libcamera.org/comment/21183/","msgid":"<b8cbd403-300e-8e6b-2676-fdff86419044@gmail.com>","date":"2021-11-24T08:00:56","subject":"Re: [libcamera-devel] [PATCH v4 4/4] ipu3: ipa: Allow IPA to apply\n\tcontrols to the lens device","submitter":{"id":90,"url":"https://patchwork.libcamera.org/api/people/90/","name":"Daniel Scally","email":"djrscally@gmail.com"},"content":"Morning\n\nOn 24/11/2021 05:56, Laurent Pinchart wrote:\n> Hi Han-lin,\n>\n> (CC'ing Dan)\n>\n> Thank you for the patch.\n>\n> On Tue, Nov 23, 2021 at 08:37:51PM +0800, 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>>  src/libcamera/pipeline/ipu3/cio2.cpp | 29 ++++++++++++++++++++++++++++\n>>  src/libcamera/pipeline/ipu3/cio2.h   |  3 +++\n>>  src/libcamera/pipeline/ipu3/ipu3.cpp | 12 ++++++++++--\n>>  3 files changed, 42 insertions(+), 2 deletions(-)\n>>\n>> diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\n>> index 59dda56b..59b2f586 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,34 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n>>  \t\treturn -EINVAL;\n>>  \t}\n>>  \n>> +\t/*\n>> +\t * \\todo Read the lens model from the sensor itself or from a device\n>> +\t * database. For now use default values taken from ChromeOS database.\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> Dan, could you share your patches to add an ancillary link between the\n> imaging sensor and the lens controller with Han-lin once they're ready ?\n> This is what we should use here, and Han-lin could help testing them on\n> Chrome OS (which uses different ACPI bindings for the CIO2).\n\n\nYes, certainly. I was going to share them as a patch to be applied on\ntop of this series, and replacing this section. This part (following the\nnew link and creating the CameraLens) is working now, just need to iron\nout a few things and I can share something.\n\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 \"\n>> +\t\t\t\t\t\t   << it->second << \" not found\";\n>> +\t\t}\n>> +\t}\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 c65afdb2..6e04ec8f 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>> @@ -1238,8 +1239,15 @@ 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>> +\n>> +\t\tconst ControlList lensControls = action.lensControls;\n>> +\t\tconst ControlValue &focusValue =\n>> +\t\t\tlensControls.get(V4L2_CID_FOCUS_ABSOLUTE);\n>> +\t\tif (!focusValue.isNone() && cio2_.lens())\n>> +\t\t\tcio2_.lens()->setFocusPostion(focusValue.get<int32_t>());\n>> +\n> The other way around, should we pass the limits of the focus control\n> from the pipeline handler to the IPA ?\n>\n>>  \t\tbreak;\n>>  \t}\n>>  \tcase ipa::ipu3::ActionParamFilled: {","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 DB69DBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 24 Nov 2021 08:01:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EFDF760233;\n\tWed, 24 Nov 2021 09:01:00 +0100 (CET)","from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com\n\t[IPv6:2a00:1450:4864:20::32a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 17AD66022F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Nov 2021 09:00:59 +0100 (CET)","by mail-wm1-x32a.google.com with SMTP id\n\tn33-20020a05600c502100b0032fb900951eso4542222wmr.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Nov 2021 00:00:59 -0800 (PST)","from [192.168.0.14]\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161])\n\tby smtp.gmail.com with ESMTPSA id\n\tt17sm553775wmq.15.2021.11.24.00.00.57\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tWed, 24 Nov 2021 00:00:58 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"bTIUzuYS\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=subject:to:cc:references:from:message-id:date:user-agent\n\t:mime-version:in-reply-to:content-transfer-encoding:content-language; \n\tbh=gvflsvHSrdaX3njAiv6QJsjrJNBY3GTlmxJ4BhfGxEA=;\n\tb=bTIUzuYSFgF2/6lbImk5YyJN09ZH2ChvWpw1ZqFNM9eGVrU7oa/bi9p4pPjmIAcA2L\n\ts+e1cuuWGNSWM+lZ3x+dA2nqZLEXI5Au6APN61L5YEj778zCgrFEeiphFaU7hq3EnryE\n\tgLwBdU95lEqukhR5h3i+WfF/k+XnXpE4h/YQFBXoJGnI7317KhBxnY8eD6X49EESakTB\n\tfyR6SfNsySSw0jn0Zgha7+JFZ7nvDPwtdA7bk2kIIFn3ft8WD8NfZbjyEjq1rogw2rO1\n\tiHF3KrTiH1orRj+mKRQWSx4jxUcRdmXacXeXFbGYFzT6hxrQd/osZO6yj2bEF5Idvr5t\n\tzQQQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:subject:to:cc:references:from:message-id:date\n\t:user-agent:mime-version:in-reply-to:content-transfer-encoding\n\t:content-language;\n\tbh=gvflsvHSrdaX3njAiv6QJsjrJNBY3GTlmxJ4BhfGxEA=;\n\tb=iLRk/DPKfL06oMyBpF4d2qfY3X2srcUrckotBZM3+/sYeXcKKShs30C/kIOzUx/U3B\n\tp+ggHu7cwBuk39h7XJFtsNM5BOg//urIoVu5DUIgcHZZ8vSX7G9Lolz425a0Bg/3BzSk\n\te8h0XyzemsOqj3dXWCOnbUBFZ5h/Ab+wFWd/Ck11oqxrNXZRI+UmLoVdXQWTxIOJ35pW\n\t8UjzCdohY7/J3CeY13FHhFbfO0NLgjUDvRAvQqZ51DCOl6ynS+h7WBNGc7WhXLRuLA/d\n\tzkJqW3PfcYYgJm0iUVWFPXaTN0eVajy7DbF1fat8tqx8BGHUSeXXCLIMtPQYRqxlkj/s\n\tyATA==","X-Gm-Message-State":"AOAM532Ha0SngfDIywJFbMlfqIaeE85PCzJhWErC44bWaih01ZpHeRZS\n\t6Xmi73mWihEqcVtcVeM/aR5fSad79KM=","X-Google-Smtp-Source":"ABdhPJzZFg7wPSvDv5tRhOtt32pvuS/htIbSxGoLveO+/Uv+ItvAlJXTCUEBQFfTstIQ1rgHCv/qKQ==","X-Received":"by 2002:a1c:a301:: with SMTP id\n\tm1mr12441471wme.118.1637740858578; \n\tWed, 24 Nov 2021 00:00:58 -0800 (PST)","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tHan-Lin Chen <hanlinchen@chromium.org>","References":"<20211123123751.3194696-1-hanlinchen@chromium.org>\n\t<20211123123751.3194696-5-hanlinchen@chromium.org>\n\t<YZ3UIIUt39DS3N5P@pendragon.ideasonboard.com>","From":"Daniel Scally <djrscally@gmail.com>","Message-ID":"<b8cbd403-300e-8e6b-2676-fdff86419044@gmail.com>","Date":"Wed, 24 Nov 2021 08:00:56 +0000","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.14.0","MIME-Version":"1.0","In-Reply-To":"<YZ3UIIUt39DS3N5P@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"7bit","Content-Language":"en-US","Subject":"Re: [libcamera-devel] [PATCH v4 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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":21185,"web_url":"https://patchwork.libcamera.org/comment/21185/","msgid":"<27d53cb4-e6ea-94c5-943d-ea557a201d4d@gmail.com>","date":"2021-11-24T09:10:10","subject":"Re: [libcamera-devel] [PATCH v4 4/4] ipu3: ipa: Allow IPA to apply\n\tcontrols to the lens device","submitter":{"id":90,"url":"https://patchwork.libcamera.org/api/people/90/","name":"Daniel Scally","email":"djrscally@gmail.com"},"content":"On 24/11/2021 05:56, Laurent Pinchart wrote:\n> Hi Han-lin,\n>\n> (CC'ing Dan)\n>\n> Thank you for the patch.\n>\n> On Tue, Nov 23, 2021 at 08:37:51PM +0800, 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>>  src/libcamera/pipeline/ipu3/cio2.cpp | 29 ++++++++++++++++++++++++++++\n>>  src/libcamera/pipeline/ipu3/cio2.h   |  3 +++\n>>  src/libcamera/pipeline/ipu3/ipu3.cpp | 12 ++++++++++--\n>>  3 files changed, 42 insertions(+), 2 deletions(-)\n>>\n>> diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\n>> index 59dda56b..59b2f586 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,34 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n>>  \t\treturn -EINVAL;\n>>  \t}\n>>  \n>> +\t/*\n>> +\t * \\todo Read the lens model from the sensor itself or from a device\n>> +\t * database. For now use default values taken from ChromeOS database.\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> Dan, could you share your patches to add an ancillary link between the\n> imaging sensor and the lens controller with Han-lin once they're ready ?\n> This is what we should use here, and Han-lin could help testing them on\n> Chrome OS (which uses different ACPI bindings for the CIO2).\n\n\nActually, that spurs a thought; we're getting the VCM to match to the\nSensor by using the lens-focus property in the cio2-bridge...but is the\nChromeOS ACPI going to be supplying that?\n\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 \"\n>> +\t\t\t\t\t\t   << it->second << \" not found\";\n>> +\t\t}\n>> +\t}\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 c65afdb2..6e04ec8f 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>> @@ -1238,8 +1239,15 @@ 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>> +\n>> +\t\tconst ControlList lensControls = action.lensControls;\n>> +\t\tconst ControlValue &focusValue =\n>> +\t\t\tlensControls.get(V4L2_CID_FOCUS_ABSOLUTE);\n>> +\t\tif (!focusValue.isNone() && cio2_.lens())\n>> +\t\t\tcio2_.lens()->setFocusPostion(focusValue.get<int32_t>());\n>> +\n> The other way around, should we pass the limits of the focus control\n> from the pipeline handler to the IPA ?\n>\n>>  \t\tbreak;\n>>  \t}\n>>  \tcase ipa::ipu3::ActionParamFilled: {","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 94AC7BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 24 Nov 2021 09:10:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0960460231;\n\tWed, 24 Nov 2021 10:10:14 +0100 (CET)","from mail-wm1-x335.google.com (mail-wm1-x335.google.com\n\t[IPv6:2a00:1450:4864:20::335])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 31C2C6022F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Nov 2021 10:10:12 +0100 (CET)","by mail-wm1-x335.google.com with SMTP id\n\ti8-20020a7bc948000000b0030db7b70b6bso4729301wml.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Nov 2021 01:10:12 -0800 (PST)","from [192.168.0.14]\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161])\n\tby smtp.gmail.com with ESMTPSA id\n\tm20sm4576324wmq.11.2021.11.24.01.10.10\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tWed, 24 Nov 2021 01:10:11 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"Wd4QgzUJ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=subject:to:cc:references:from:message-id:date:user-agent\n\t:mime-version:in-reply-to:content-transfer-encoding:content-language; \n\tbh=ivae4+Nja3KwbuVkUd8jTKJ9Uf9QuF5NQqTs0go4neA=;\n\tb=Wd4QgzUJqNHdyUcle+y8yFUqcFd9vqG1xAqP+Ba8lWriJjZO7qQ+BTG/m9NdoRhZlI\n\tuyzDOcqfrJlFdow8q2Xu+BBJwFmwAqP2bo4vq5/wAhTZjXTk0aGJfrHZE8CbAOTLgJiH\n\tNabq9T6sTYByjFYVJaBgYrmRGL+tSfYNWoQpnIOnmf6Y6iLaJVsF17OAlgS88hvuvCWA\n\tEKiK4ojE/nWRwVgvmRWs3itPguFVoWuviq/F1PLbBvlvjDw+ziordAAw689CODtKbk/T\n\tcrvzUqOKgZxXYAnMVTZc/od6pFT44rk1iS6SQBuM1SSG453v+UCbCCPlpyXy2jxs7ujx\n\tvwTg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:subject:to:cc:references:from:message-id:date\n\t:user-agent:mime-version:in-reply-to:content-transfer-encoding\n\t:content-language;\n\tbh=ivae4+Nja3KwbuVkUd8jTKJ9Uf9QuF5NQqTs0go4neA=;\n\tb=NDvxZqauqAjUb/oYGtqaO2CJmgvcBCfdOj+UouLq3CLIps4q7XnnkNZXzlB1SDYKOi\n\tixv0jLhwkhwjkPz4qGFAdl3Dmlq4jISHshGcgHt6NiSSSouMiSDo3H/AJkoe1NugBtRU\n\tg+BLz556YHmaxG8y7dvmBHjBgGfv5/4yKdikhGjkUS2TgcRs2k9NCtVqyZgTaLw1MAkU\n\tJXZOY2Y/5PrQs4cD3Zr+oG1kBAhWSOwjWnb+RIMEfucwMuI7wr2PBCXOru3rp0IQnfy3\n\trVUhpklXKCwqJsgwpHknoMdpBc5+U5dDabvoYMeCFIBvpr4fG+R6IIao4miStq/sFDNf\n\t/tJQ==","X-Gm-Message-State":"AOAM532Oz8zf2eRtlVI9WYZ5ChbRQ2YyoFQDYHqxp+vQbNewxZQyboqa\n\tTEPLVYDP/IAbfcJk5fYwkBvztx5aXRs=","X-Google-Smtp-Source":"ABdhPJy9wFDWU5A6Wu4d0zaqnk6OHrgKg7iBGLr6yRp9qslAF37Fp1Sneyy9Dy5DZ2iQRHDZ9DH7tg==","X-Received":"by 2002:a1c:2685:: with SMTP id\n\tm127mr13224737wmm.42.1637745011656; \n\tWed, 24 Nov 2021 01:10:11 -0800 (PST)","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tHan-Lin Chen <hanlinchen@chromium.org>","References":"<20211123123751.3194696-1-hanlinchen@chromium.org>\n\t<20211123123751.3194696-5-hanlinchen@chromium.org>\n\t<YZ3UIIUt39DS3N5P@pendragon.ideasonboard.com>","From":"Daniel Scally <djrscally@gmail.com>","Message-ID":"<27d53cb4-e6ea-94c5-943d-ea557a201d4d@gmail.com>","Date":"Wed, 24 Nov 2021 09:10:10 +0000","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.14.0","MIME-Version":"1.0","In-Reply-To":"<YZ3UIIUt39DS3N5P@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"7bit","Content-Language":"en-US","Subject":"Re: [libcamera-devel] [PATCH v4 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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":21186,"web_url":"https://patchwork.libcamera.org/comment/21186/","msgid":"<YZ4D5wc3gvi7FVn6@pendragon.ideasonboard.com>","date":"2021-11-24T09:20:39","subject":"Re: [libcamera-devel] [PATCH v4 4/4] ipu3: ipa: Allow IPA to apply\n\tcontrols to the lens device","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Wed, Nov 24, 2021 at 09:10:10AM +0000, Daniel Scally wrote:\n> On 24/11/2021 05:56, Laurent Pinchart wrote:\n> > Hi Han-lin,\n> >\n> > (CC'ing Dan)\n> >\n> > Thank you for the patch.\n> >\n> > On Tue, Nov 23, 2021 at 08:37:51PM +0800, 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> >>  src/libcamera/pipeline/ipu3/cio2.cpp | 29 ++++++++++++++++++++++++++++\n> >>  src/libcamera/pipeline/ipu3/cio2.h   |  3 +++\n> >>  src/libcamera/pipeline/ipu3/ipu3.cpp | 12 ++++++++++--\n> >>  3 files changed, 42 insertions(+), 2 deletions(-)\n> >>\n> >> diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\n> >> index 59dda56b..59b2f586 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,34 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n> >>  \t\treturn -EINVAL;\n> >>  \t}\n> >>  \n> >> +\t/*\n> >> +\t * \\todo Read the lens model from the sensor itself or from a device\n> >> +\t * database. For now use default values taken from ChromeOS database.\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> > Dan, could you share your patches to add an ancillary link between the\n> > imaging sensor and the lens controller with Han-lin once they're ready ?\n> > This is what we should use here, and Han-lin could help testing them on\n> > Chrome OS (which uses different ACPI bindings for the CIO2).\n> \n> Actually, that spurs a thought; we're getting the VCM to match to the\n> Sensor by using the lens-focus property in the cio2-bridge...but is the\n> ChromeOS ACPI going to be supplying that?\n\nLikely not out-of-the-box at the moment. This is why I'd like Han-lin to\nget the patches for testing, to figure out what needs to be done on\nChrome OS.\n\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 \"\n> >> +\t\t\t\t\t\t   << it->second << \" not found\";\n> >> +\t\t}\n> >> +\t}\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 c65afdb2..6e04ec8f 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> >> @@ -1238,8 +1239,15 @@ 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> >> +\n> >> +\t\tconst ControlList lensControls = action.lensControls;\n> >> +\t\tconst ControlValue &focusValue =\n> >> +\t\t\tlensControls.get(V4L2_CID_FOCUS_ABSOLUTE);\n> >> +\t\tif (!focusValue.isNone() && cio2_.lens())\n> >> +\t\t\tcio2_.lens()->setFocusPostion(focusValue.get<int32_t>());\n> >> +\n> >\n> > The other way around, should we pass the limits of the focus control\n> > from the pipeline handler to the IPA ?\n> >\n> >>  \t\tbreak;\n> >>  \t}\n> >>  \tcase ipa::ipu3::ActionParamFilled: {","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 54DD5BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 24 Nov 2021 09:21:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7AAFB60233;\n\tWed, 24 Nov 2021 10:21:04 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 36A616022F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Nov 2021 10:21:03 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 95D5F92A;\n\tWed, 24 Nov 2021 10:21:02 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"meJ4BWBs\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1637745662;\n\tbh=llG5M4m7Q8wXdsezcX72hdTuPwAhRkKV95mpZPAghvU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=meJ4BWBsry6sdHQhl+LhfRHI6E0b+iANeVRMGktXhBocEIqJGauXlFxNL73wDEjCT\n\tU9X6fFawARo1Jn2LeWT4dvU/GogxrchJBLQnNZ47SNJohTKKuOzmKp2f9CIC3NyDv1\n\tD5Uu8r44bk72jJsQ/E+anZvnLxbMVnCW9vSNhu5A=","Date":"Wed, 24 Nov 2021 11:20:39 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Daniel Scally <djrscally@gmail.com>","Message-ID":"<YZ4D5wc3gvi7FVn6@pendragon.ideasonboard.com>","References":"<20211123123751.3194696-1-hanlinchen@chromium.org>\n\t<20211123123751.3194696-5-hanlinchen@chromium.org>\n\t<YZ3UIIUt39DS3N5P@pendragon.ideasonboard.com>\n\t<27d53cb4-e6ea-94c5-943d-ea557a201d4d@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<27d53cb4-e6ea-94c5-943d-ea557a201d4d@gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v4 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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]