[{"id":24570,"web_url":"https://patchwork.libcamera.org/comment/24570/","msgid":"<20220815074805.GT311202@pyrite.rasen.tech>","date":"2022-08-15T07:48:05","subject":"Re: [libcamera-devel] [PATCH v2 2/6] libcamera: uvcvideo: Register\n\tExposureTimeMode control","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"Hi Jacopo,\n\nOn Thu, Aug 11, 2022 at 05:02:15PM +0200, Jacopo Mondi via libcamera-devel wrote:\n> Port the UVC pipeline handler to use the new ExposureTimeMode control\n> when processing Camera controls in place of the AeEnable control.\n> \n> The V4L2_CID_EXPOSURE_AUTO control allows 4 possible values, which\n> map to ExposureTimeModeAuto and ExposureTimeModeManual.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 54 ++++++++++++++++++--\n>  1 file changed, 49 insertions(+), 5 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> index fbe02cdcd520..08a37da0d90d 100644\n> --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> @@ -266,7 +266,7 @@ int PipelineHandlerUVC::processControl(ControlList *controls, unsigned int id,\n>  \t\tcid = V4L2_CID_CONTRAST;\n>  \telse if (id == controls::Saturation)\n>  \t\tcid = V4L2_CID_SATURATION;\n> -\telse if (id == controls::AeEnable)\n> +\telse if (id == controls::ExposureTimeMode)\n>  \t\tcid = V4L2_CID_EXPOSURE_AUTO;\n>  \telse if (id == controls::ExposureTime)\n>  \t\tcid = V4L2_CID_EXPOSURE_ABSOLUTE;\n> @@ -580,7 +580,7 @@ void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info,\n>  \t\tid = &controls::Saturation;\n>  \t\tbreak;\n>  \tcase V4L2_CID_EXPOSURE_AUTO:\n> -\t\tid = &controls::AeEnable;\n> +\t\tid = &controls::ExposureTimeMode;\n>  \t\tbreak;\n>  \tcase V4L2_CID_EXPOSURE_ABSOLUTE:\n>  \t\tid = &controls::ExposureTime;\n> @@ -593,6 +593,7 @@ void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info,\n>  \t}\n>  \n>  \t/* Map the control info. */\n> +\tconst std::vector<ControlValue> &v4l2Values = v4l2Info.values();\n>  \tint32_t min = v4l2Info.min().get<int32_t>();\n>  \tint32_t max = v4l2Info.max().get<int32_t>();\n>  \tint32_t def = v4l2Info.def().get<int32_t>();\n> @@ -630,10 +631,53 @@ void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info,\n>  \t\t};\n>  \t\tbreak;\n>  \n> -\tcase V4L2_CID_EXPOSURE_AUTO:\n> -\t\tinfo = ControlInfo{ false, true, true };\n> +\tcase V4L2_CID_EXPOSURE_AUTO: {\n> +\t\t/*\n> +\t\t * From the V4L2_CID_EXPOSURE_AUTO documentation:\n> +\t\t *\n> +\t\t * ------------------------------------------------------------\n> +\t\t * V4L2_EXPOSURE_AUTO:\n> +\t\t * Automatic exposure time, automatic iris aperture.\n> +\t\t *\n> +\t\t * V4L2_EXPOSURE_MANUAL:\n> +\t\t * Manual exposure time, manual iris.\n> +\t\t *\n> +\t\t * V4L2_EXPOSURE_SHUTTER_PRIORITY:\n> +\t\t * Manual exposure time, auto iris.\n> +\t\t *\n> +\t\t * V4L2_EXPOSURE_APERTURE_PRIORITY:\n> +\t\t * Auto exposure time, manual iris.\n> +\t\t *-------------------------------------------------------------\n> +\t\t *\n> +\t\t * ExposureTimeModeAuto = { V4L2_EXPOSURE_AUTO,\n> +\t\t * \t\t\t    V4L2_EXPOSURE_APERTURE_PRIORITY }\n> +\t\t *\n> +\t\t *\n> +\t\t * ExposureTimeModeManual = { V4L2_EXPOSURE_MANUAL,\n> +\t\t *\t\t\t      V4L2_EXPOSURE_SHUTTER_PRIORITY }\n> +\t\t */\n> +\t\tstd::array<int32_t, 2> values{};\n> +\n> +\t\tauto it = std::find_if(v4l2Values.begin(), v4l2Values.end(),\n> +\t\t\t[&](const ControlValue &val) {\n> +\t\t\t\treturn (val.get<int32_t>() == V4L2_EXPOSURE_APERTURE_PRIORITY ||\n> +\t\t\t\t\tval.get<int32_t>() == V4L2_EXPOSURE_AUTO) ? true : false;\n> +\t\t\t});\n> +\t\tif (it != v4l2Values.end())\n> +\t\t\tvalues.back() = static_cast<int32_t>(controls::ExposureTimeModeAuto);\n> +\n> +\t\tit = std::find_if(v4l2Values.begin(), v4l2Values.end(),\n> +\t\t\t[&](const ControlValue &val) {\n> +\t\t\t\treturn (val.get<int32_t>() == V4L2_EXPOSURE_SHUTTER_PRIORITY ||\n> +\t\t\t\t\tval.get<int32_t>() == V4L2_EXPOSURE_MANUAL) ? true : false;\n> +\t\t\t});\n> +\t\tif (it != v4l2Values.end())\n> +\t\t\tvalues.back() = static_cast<int32_t>(controls::ExposureTimeModeManual);\n> +\n> +\t\tint32_t *data = values.data();\n> +\t\tinfo = ControlInfo{Span<int32_t>(data, 2), values[0]};\n>  \t\tbreak;\n> -\n> +\t}\n>  \tcase V4L2_CID_EXPOSURE_ABSOLUTE:\n>  \t\t/*\n>  \t\t * ExposureTime is in units of 1 µs, and UVC expects\n> -- \n> 2.37.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 36B34C3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 15 Aug 2022 07:48:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 954E161FBC;\n\tMon, 15 Aug 2022 09:48:15 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6C06B61FA8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 15 Aug 2022 09:48:13 +0200 (CEST)","from pyrite.rasen.tech (h175-177-042-159.catv02.itscom.jp\n\t[175.177.42.159])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 22C9948F;\n\tMon, 15 Aug 2022 09:48:11 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660549695;\n\tbh=WIa7KPx3DNBXozE3bOVo6otAPvY3ju979FWqgF+uWXU=;\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=0uL9TP/OqzTg3pZ7nld+8KtHk3J9v4ng3nkG9XGiLeeAetZ4d+dUZDymRV6Z9lUN/\n\tIM319q+TGCpVzwGEM/bbEDOqP1+uhzVVYhlpoJV6ww6ulgUe5cdwYsRTxZcXyD+MtZ\n\tJGwSO4i60zgvScBgEetC1J08yPkm5gH7jqFvMK1+8rTEbqQkqM6I0NB2eS3jzQUojL\n\tShXSQmpgVhGgpU8PaJbMnd0zBu0ozbGUSfHLIP3K2p36DFxWDBhA/gsjQX1BYC6VSd\n\tceVV/W0qrchoXQrqyYTM8CwVNCNSQt24UzTpbjo03IEtvR9qDkSYtgGEdMM4A0PSfd\n\twpU/+JTRJTwKw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1660549693;\n\tbh=WIa7KPx3DNBXozE3bOVo6otAPvY3ju979FWqgF+uWXU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=JHUXLoJIK95+zCmj80O4eejfEEFw0yxfp9Yz2EoshfWPzWapI/GyF+buNhtDYbUvc\n\tuLAg9JrLk48ZNWA9pwMWxa7YvRKFZHlcAKcSsSw6q6U6j6ODsKPt/JevwWXoH/Bcmy\n\tzz7WMFnhrShk0mgQh/a03lCpH993Q9ZaWRMaaIoo="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"JHUXLoJI\"; dkim-atps=neutral","Date":"Mon, 15 Aug 2022 16:48:05 +0900","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20220815074805.GT311202@pyrite.rasen.tech>","References":"<20220811150219.62066-1-jacopo@jmondi.org>\n\t<20220811150219.62066-3-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20220811150219.62066-3-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH v2 2/6] libcamera: uvcvideo: Register\n\tExposureTimeMode control","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":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"paul.elder@ideasonboard.com","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]