[{"id":4489,"web_url":"https://patchwork.libcamera.org/comment/4489/","msgid":"<20200423173613.GI6196@pendragon.ideasonboard.com>","date":"2020-04-23T17:36:13","subject":"Re: [libcamera-devel] [PATCH v3 2/5] libcamera: uvcvideo: Update\n\texposure/gain ctrls set with new units","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Fri, Apr 03, 2020 at 03:53:02PM +0100, Naushir Patuck wrote:\n> The ExposureTime control now uses units of 1 micro-second, and UVC\n> uses units of 100 micro-seconds. Correctly map the values before\n> setting V4L2_CID_EXPOSURE_ABSOLUTE on the V4L2 device.\n> \n> The AnalogueGain control now uses floats to allow fractional gain\n> values. Since UVC has no explicit gain units, map the default gain value\n> to 1.0 and linearly map to the requested value.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 17 +++++++++++++++--\n>  1 file changed, 15 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> index d7df95e4..9d589f69 100644\n> --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> @@ -253,9 +253,22 @@ int PipelineHandlerUVC::processControls(UVCCameraData *data, Request *request)\n>  \t\t\tcontrols.set(V4L2_CID_SATURATION, value);\n>  \t\t} else if (id == controls::ExposureTime) {\n>  \t\t\tcontrols.set(V4L2_CID_EXPOSURE_AUTO, static_cast<int32_t>(1));\n> -\t\t\tcontrols.set(V4L2_CID_EXPOSURE_ABSOLUTE, value);\n> +\t\t\t/*\n> +\t\t\t * controls::ExposureTime is in units of 1 us, and UVC\n> +\t\t\t * expects V4L2_CID_EXPOSURE_ABSOLUTE in units of 100 us.\n> +\t\t\t */\n> +\t\t\tcontrols.set(V4L2_CID_EXPOSURE_ABSOLUTE,\n> +\t\t\t\t     value.get<int32_t>() / 100);\n>  \t\t} else if (id == controls::AnalogueGain) {\n> -\t\t\tcontrols.set(V4L2_CID_GAIN, value);\n> +\t\t\t/*\n> +\t\t\t * controls::AnalogueGain is specified as an absolute\n> +\t\t\t * multiplier for all RGB samples. Map this multiplier\n> +\t\t\t * in a linear way such that 1.0 -> default gain\n> +\t\t\t * of the V4L2_CID_GAIN control on the uvcvideo device.\n> +\t\t\t */\n> +\t\t\tconst ControlInfo &gainInfo = controls.infoMap()->at(V4L2_CID_GAIN);\n> +\t\t\tint32_t gain = value.get<float>() * gainInfo.def().get<int32_t>();\n> +\t\t\tcontrols.set(V4L2_CID_GAIN, gain);\n>  \t\t}\n>  \t}\n>","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["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 C674562E45\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Apr 2020 19:36:28 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F386E4F7;\n\tThu, 23 Apr 2020 19:36:27 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"MQwBc8uX\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1587663388;\n\tbh=QtmLoJkMtqfnrem2692ePufaXWEQ36eQJEofaOxPggQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=MQwBc8uX7UBkcu5zt1Wlyl+woAQkZTxuG3AfxdYNo1Tx7rNKWqGgc9rlg2iAOc/Qx\n\tuAXsPEAIClodTv/JliEfh/SzZy/oK90MnuJtjuaCZ2ySP3tPl6kZbyb5hdu4IsGS6A\n\tZLEQGXfhLMyNoODatalbspTBcVjtZeg+eVTCCc9g=","Date":"Thu, 23 Apr 2020 20:36:13 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200423173613.GI6196@pendragon.ideasonboard.com>","References":"<20200403145305.10288-1-naush@raspberrypi.com>\n\t<20200403145305.10288-3-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200403145305.10288-3-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v3 2/5] libcamera: uvcvideo: Update\n\texposure/gain ctrls set with new units","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>","X-List-Received-Date":"Thu, 23 Apr 2020 17:36:29 -0000"}}]