[{"id":22705,"web_url":"https://patchwork.libcamera.org/comment/22705/","msgid":"<20220414082159.3jlungcinxhkyaii@uno.localdomain>","date":"2022-04-14T08:21:59","subject":"Re: [libcamera-devel] [RFC v1 2/5] libcamera: camera_lens: Get\n\tmaximum VCM steps","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Kate,\n\nOn Thu, Apr 14, 2022 at 03:43:39PM +0800, Kate Hsuan via libcamera-devel wrote:\n> It allows other components to get the maximum VCM steps. It first creates\n> a control list and set V4L2_CID_FOCUS_ABSOLUTE control to it. Then, it\n> calls a lower layer call, getAttributes() to get the maximum VCM steps\n> from the kernel.\n\nI might have missed something here.\n\nV4L2Device::controls() returns you a ControlInfoMap for all the\ncontrols registered on the lens subdevice, with the controls' min, max\nand default values collected at subdev open time with\nV4L2Device::listControls()\n\nIs there a reason I have missed about why you need to re-fetch the\ncontrol's limits again ?\n\nIf you need to collect the V4L2_CID_FOCUS_ABSOLUTE control maximum\nvalue I think you could very well do so at validateLensDriver() time.\n\nThanks\n   j\n\n>\n> Signed-off-by: Kate Hsuan<hpa@redhat.com>\n> ---\n>  include/libcamera/internal/camera_lens.h |  1 +\n>  src/libcamera/camera_lens.cpp            | 18 ++++++++++++++++++\n>  2 files changed, 19 insertions(+)\n>\n> diff --git a/include/libcamera/internal/camera_lens.h b/include/libcamera/internal/camera_lens.h\n> index 277417da..48761d68 100644\n> --- a/include/libcamera/internal/camera_lens.h\n> +++ b/include/libcamera/internal/camera_lens.h\n> @@ -27,6 +27,7 @@ public:\n>\n>  \tint init();\n>  \tint setFocusPosition(int32_t position);\n> +\tint getFocusCapabilityies();\n>\n>  \tconst std::string &model() const { return model_; }\n>\n> diff --git a/src/libcamera/camera_lens.cpp b/src/libcamera/camera_lens.cpp\n> index b3d48199..5d00652d 100644\n> --- a/src/libcamera/camera_lens.cpp\n> +++ b/src/libcamera/camera_lens.cpp\n> @@ -73,6 +73,10 @@ int CameraLens::init()\n>  \t\treturn ret;\n>\n>  \tmodel_ = subdev_->model();\n> +\n> +\tControlList lensCtrls(subdev_->controls());\n> +\tsubdev_->getAttributes(&lensCtrls);\n> +\n>  \treturn 0;\n>  }\n>\n> @@ -95,6 +99,20 @@ int CameraLens::setFocusPosition(int32_t position)\n>  \treturn 0;\n>  }\n>\n> +int CameraLens::getFocusCapabilityies()\n> +{\n> +\tControlValue retVal;\n> +\tControlList lensCtrls(subdev_->controls());\n> +\tint32_t ret = 2023;\n> +\n> +\tlensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, static_cast<int32_t>(ret));\n> +\tsubdev_->getAttributes(&lensCtrls);\n> +\tretVal = lensCtrls.get(V4L2_CID_FOCUS_ABSOLUTE);\n> +\tret = retVal.get<int32_t>();\n> +\n> +\treturn ret;\n> +}\n> +\n>  int CameraLens::validateLensDriver()\n>  {\n>  \tint ret = 0;\n> --\n> 2.35.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 3F695C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 14 Apr 2022 08:22:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 74D3965649;\n\tThu, 14 Apr 2022 10:22:03 +0200 (CEST)","from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net\n\t[IPv6:2001:4b98:dc4:8::223])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C0BFA604B6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Apr 2022 10:22:01 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id 16A566000C;\n\tThu, 14 Apr 2022 08:22:00 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1649924523;\n\tbh=UCGw2bMzc3KGbSuNcHw0MpKX9ZMWnQusSRGxF4tXMAk=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=0U/TPKK7vfg1cO5m2tjihfwGzDVItDij7M3F/CUpzFOPJfoKbnhdKMj8PxvxB0jB9\n\tFbA3xNWrt24p+pauhQBcJJVltlo79JO9breFEZqE4voQMk7OCVvFTwBGyNKEDNSprw\n\tWPv6soXLXFa9vtDA8pvN86MTFY61Fkni7pTPW4QW1r2BoTEnWpGsI8OJ8tfsxqcsGp\n\t86GwJrvucC+FsEne6Y0f6NhpGRDaAn/KbQhTF/mORL/5ybAgeGbTm3FV/uzsvDkzdW\n\tZ7tOPbwoJyY/gwltPb0QPO4dUVhTNi0CIZKiDRDqXFob/eqiETAbufHQpUmVepbMa7\n\t/sAt3wniLDA1Q==","Date":"Thu, 14 Apr 2022 10:21:59 +0200","To":"Kate Hsuan <hpa@redhat.com>","Message-ID":"<20220414082159.3jlungcinxhkyaii@uno.localdomain>","References":"<20220414074342.7455-1-hpa@redhat.com>\n\t<20220414074342.7455-3-hpa@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20220414074342.7455-3-hpa@redhat.com>","Subject":"Re: [libcamera-devel] [RFC v1 2/5] libcamera: camera_lens: Get\n\tmaximum VCM steps","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":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":22715,"web_url":"https://patchwork.libcamera.org/comment/22715/","msgid":"<CAEth8oEuogMD75hEEy=5TtpjXCuotsn56ZNd0B0dga2eJ+hffQ@mail.gmail.com>","date":"2022-04-15T03:01:18","subject":"Re: [libcamera-devel] [RFC v1 2/5] libcamera: camera_lens: Get\n\tmaximum VCM steps","submitter":{"id":105,"url":"https://patchwork.libcamera.org/api/people/105/","name":"Kate Hsuan","email":"hpa@redhat.com"},"content":"Hi Jacopo,\n\nOn Thu, Apr 14, 2022 at 4:22 PM Jacopo Mondi <jacopo@jmondi.org> wrote:\n>\n> Hi Kate,\n>\n> On Thu, Apr 14, 2022 at 03:43:39PM +0800, Kate Hsuan via libcamera-devel wrote:\n> > It allows other components to get the maximum VCM steps. It first creates\n> > a control list and set V4L2_CID_FOCUS_ABSOLUTE control to it. Then, it\n> > calls a lower layer call, getAttributes() to get the maximum VCM steps\n> > from the kernel.\n>\n> I might have missed something here.\n>\n> V4L2Device::controls() returns you a ControlInfoMap for all the\n> controls registered on the lens subdevice, with the controls' min, max\n> and default values collected at subdev open time with\n> V4L2Device::listControls()\n>\n> Is there a reason I have missed about why you need to re-fetch the\n> control's limits again ?\n>\n\nAh. I might miss this V4L2Device::listControls(). I could try this in\nmy v2 patch.\n\nThank you.\n\n> If you need to collect the V4L2_CID_FOCUS_ABSOLUTE control maximum\n> value I think you could very well do so at validateLensDriver() time.\n>\n> Thanks\n>    j\n>\n> >\n> > Signed-off-by: Kate Hsuan<hpa@redhat.com>\n> > ---\n> >  include/libcamera/internal/camera_lens.h |  1 +\n> >  src/libcamera/camera_lens.cpp            | 18 ++++++++++++++++++\n> >  2 files changed, 19 insertions(+)\n> >\n> > diff --git a/include/libcamera/internal/camera_lens.h b/include/libcamera/internal/camera_lens.h\n> > index 277417da..48761d68 100644\n> > --- a/include/libcamera/internal/camera_lens.h\n> > +++ b/include/libcamera/internal/camera_lens.h\n> > @@ -27,6 +27,7 @@ public:\n> >\n> >       int init();\n> >       int setFocusPosition(int32_t position);\n> > +     int getFocusCapabilityies();\n> >\n> >       const std::string &model() const { return model_; }\n> >\n> > diff --git a/src/libcamera/camera_lens.cpp b/src/libcamera/camera_lens.cpp\n> > index b3d48199..5d00652d 100644\n> > --- a/src/libcamera/camera_lens.cpp\n> > +++ b/src/libcamera/camera_lens.cpp\n> > @@ -73,6 +73,10 @@ int CameraLens::init()\n> >               return ret;\n> >\n> >       model_ = subdev_->model();\n> > +\n> > +     ControlList lensCtrls(subdev_->controls());\n> > +     subdev_->getAttributes(&lensCtrls);\n> > +\n> >       return 0;\n> >  }\n> >\n> > @@ -95,6 +99,20 @@ int CameraLens::setFocusPosition(int32_t position)\n> >       return 0;\n> >  }\n> >\n> > +int CameraLens::getFocusCapabilityies()\n> > +{\n> > +     ControlValue retVal;\n> > +     ControlList lensCtrls(subdev_->controls());\n> > +     int32_t ret = 2023;\n> > +\n> > +     lensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, static_cast<int32_t>(ret));\n> > +     subdev_->getAttributes(&lensCtrls);\n> > +     retVal = lensCtrls.get(V4L2_CID_FOCUS_ABSOLUTE);\n> > +     ret = retVal.get<int32_t>();\n> > +\n> > +     return ret;\n> > +}\n> > +\n> >  int CameraLens::validateLensDriver()\n> >  {\n> >       int ret = 0;\n> > --\n> > 2.35.1\n> >\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 54DE6C3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Apr 2022 03:01:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 607CB65647;\n\tFri, 15 Apr 2022 05:01:35 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9EB2165644\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Apr 2022 05:01:33 +0200 (CEST)","from mail-lj1-f199.google.com (mail-lj1-f199.google.com\n\t[209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n\tus-mta-662-0Q78ACWwMlyZmtVR218XkA-1; Thu, 14 Apr 2022 23:01:31 -0400","by mail-lj1-f199.google.com with SMTP id\n\tb9-20020a05651c098900b0024b4e65e7edso1445601ljq.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Apr 2022 20:01:31 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1649991695;\n\tbh=19/QeKwKGdtbL2lvq0Sd2EN1Ubda6PnT0vbhGmvUVIM=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=xE5t8T2q3es9q9atY8xSaWxK5H3QNbnXeOrfS/PFcMPjH6xJ40IW8lIn2kIG6l6Fd\n\t5lW7pk6a8Ug1dSmwETpMDrFRarSdUF/HlgD7VN7oSQW3LR3tFY+TsK7U5pByZWwrf7\n\tPHSR9IaMOW5fNf4BvLHc311tMl9ayhlUmwziUQj4oUWJcxAu0VsutZXv95mH67Il5n\n\tyhG5PUeulN/CdcTS9hFEPCvGOfKNhWxO6XtgMFPSDsAfpBIeTP+GdAz/auXnkv1urm\n\tMAtUnWf7+CU9po2keN88CR0+GHUpUlKn9F0UfJ1DTEDGZrhRbQcXDCJiDTAzF4m5Ev\n\tw9RX0rNixb22Q==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1649991692;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=Yv0J8eH52Sxw6N0J1FY6vCmmQG7HZ22EnY6ZyEq8AX4=;\n\tb=UKVprl8yF+k1qmyfTTWcLTlfS0mtKSMHXS7jKYBjZuEN0chWyxiB4OTcOD32eWs2J5+lGf\n\tbCjYLhh6jG5PxxXJ1Nn05SAWBDbvir7yJBlttnnauF1lSTttYeNNWlWY3oFw2TLWVbCuhS\n\tw1QDRRPnGo2DpDhqT+FeVPdyFvEGPgE="],"Authentication-Results":["lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=redhat.com\n\theader.i=@redhat.com header.b=\"UKVprl8y\"; \n\tdkim-atps=neutral","relay.mimecast.com;\n\tauth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hpa@redhat.com"],"X-MC-Unique":"0Q78ACWwMlyZmtVR218XkA-1","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=Yv0J8eH52Sxw6N0J1FY6vCmmQG7HZ22EnY6ZyEq8AX4=;\n\tb=6xVXgmHonvvE3ltq0klmYqPiZAC10O9RYQG1poTBuVtMKhAcS/BFei8favblxgTLKK\n\tYVHb9jBjBWyrngeyULJT6irbj1AfuQpktErQCfkrdEdD4ZGXkGgog7Yg/3kGzs2zWjuF\n\tpTVDMcnFxl5GsvbsYiRCMEaV4MLlcNkdWJ+cYihbPBEnqxSiGx2vsJY+fPppjVu7yN8x\n\tBYFSraRI/++j4yTCghDd5yYG7FbFMWx/mDo7l6NCRl33CUIpRQ46ocg8UJkrO12rlF0z\n\to183wxed1GQqO0qpsJ36/Zz983xkz6+6MhKCklq8/RYtmoYvueNrDTluLeRarz8QT6RP\n\tbpFA==","X-Gm-Message-State":"AOAM530l0X5X5UczDQ9Mtkb9HtxDGm7+cFk58+kWqmSEO7IM+Wvt4ce+\n\ti5bBRs+MJYB9EJJYoS7nqd4LZhgLcfSciC278UBfmVNlreVl/ZW6b/zSmPdJL1nwhTx3nsmIU3e\n\tRagj80rk06A0hNDJw7ESyoXvDl+x36azDbvi220jCcUhGf1FXdQ==","X-Received":["by 2002:a05:6512:260d:b0:448:35d2:f72a with SMTP id\n\tbt13-20020a056512260d00b0044835d2f72amr3794858lfb.515.1649991689695; \n\tThu, 14 Apr 2022 20:01:29 -0700 (PDT)","by 2002:a05:6512:260d:b0:448:35d2:f72a with SMTP id\n\tbt13-20020a056512260d00b0044835d2f72amr3794838lfb.515.1649991689316;\n\tThu, 14 Apr 2022 20:01:29 -0700 (PDT)"],"X-Google-Smtp-Source":"ABdhPJym9TMI51Duy+/lKnzybvc8bBKlP47CR/El3BqQ0+BRrM8tZblJAYh43Rvg4uvQX9XNluuUOMx3FeJZuTdJFXs=","MIME-Version":"1.0","References":"<20220414074342.7455-1-hpa@redhat.com>\n\t<20220414074342.7455-3-hpa@redhat.com>\n\t<20220414082159.3jlungcinxhkyaii@uno.localdomain>","In-Reply-To":"<20220414082159.3jlungcinxhkyaii@uno.localdomain>","Date":"Fri, 15 Apr 2022 11:01:18 +0800","Message-ID":"<CAEth8oEuogMD75hEEy=5TtpjXCuotsn56ZNd0B0dga2eJ+hffQ@mail.gmail.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","X-Mimecast-Spam-Score":"0","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [RFC v1 2/5] libcamera: camera_lens: Get\n\tmaximum VCM steps","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":"Kate Hsuan via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Kate Hsuan <hpa@redhat.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]