[{"id":16619,"web_url":"https://patchwork.libcamera.org/comment/16619/","msgid":"<YIedgU/TDEJw/5N4@pendragon.ideasonboard.com>","date":"2021-04-27T05:13:37","subject":"Re: [libcamera-devel] [RFC PATCH v2 10/12] android: camera_device:\n\tTranslate android controls to libcamera controls","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nThank you for the patch.\n\nOn Thu, Apr 22, 2021 at 06:41:00PM +0900, Paul Elder wrote:\n> Translate the newly added android controls that are required to FULL\n> compliance into libcamera controls before sending them to the Camera.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> ---\n>  src/android/camera_device.cpp | 33 ++++++++++++++++++++++++++++++++-\n>  1 file changed, 32 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index 99c67555..30692a67 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -2136,15 +2136,46 @@ int CameraDevice::processControls(Camera3RequestDescriptor *descriptor)\n>  \n>  \t/* Translate the Android request settings to libcamera controls. */\n>  \tcamera_metadata_ro_entry_t entry;\n> +\tControlList &controls = descriptor->request_->controls();\n> +\n>  \tif (settings.getEntry(ANDROID_SCALER_CROP_REGION, &entry)) {\n>  \t\tconst int32_t *data = entry.data.i32;\n>  \t\tRectangle cropRegion{ data[0], data[1],\n>  \t\t\t\t      static_cast<unsigned int>(data[2]),\n>  \t\t\t\t      static_cast<unsigned int>(data[3]) };\n> -\t\tControlList &controls = descriptor->request_->controls();\n>  \t\tcontrols.set(controls::ScalerCrop, cropRegion);\n>  \t}\n>  \n> +\tif (settings.getEntry(ANDROID_SENSOR_EXPOSURE_TIME, &entry))\n> +\t\tcontrols.set(controls::ExposureTime, *entry.data.i64 / 1000ULL);\n> +\n> +\tif (settings.getEntry(ANDROID_BLACK_LEVEL_LOCK, &entry))\n> +\t\tcontrols.set(controls::draft::BlackLevelLocked, *entry.data.u8);\n> +\n> +\tif (settings.getEntry(ANDROID_CONTROL_AE_LOCK, &entry))\n> +\t\tcontrols.set(controls::AeLocked, *entry.data.u8);\n> +\n> +\tif (settings.getEntry(ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER, &entry))\n> +\t\tcontrols.set(controls::draft::AePrecaptureTrigger, *entry.data.u8);\n> +\n> +\tif (settings.getEntry(ANDROID_CONTROL_AWB_MODE, &entry))\n> +\t\tcontrols.set(controls::AwbMode, *entry.data.u8);\n> +\n> +\tif (settings.getEntry(ANDROID_CONTROL_AWB_LOCK, &entry))\n> +\t\tcontrols.set(controls::AwbLocked, *entry.data.u8);\n\nAwbLocked is currently defined as metadata reported by pipeline\nhandlers. Interestingly enough, it's not used currently. If you want to\nuse it with the Android meaning, it should be made a draft control and\nits documentation should be updated.\n\nAeLocked, on the other hand, is used, so you will need to create a new\ndraft control for the Android meaning.\n\n> +\n> +\tif (settings.getEntry(ANDROID_EDGE_MODE, &entry))\n> +\t\tcontrols.set(controls::draft::EdgeMode, *entry.data.u8);\n> +\n> +\tif (settings.getEntry(ANDROID_NOISE_REDUCTION_MODE, &entry))\n> +\t\tcontrols.set(controls::draft::NoiseReductionMode, *entry.data.u8);\n> +\n> +\tif (settings.getEntry(ANDROID_SENSOR_SENSITIVITY, &entry))\n> +\t\tcontrols.set(controls::draft::SensorSensitivity, *entry.data.i32);\n> +\n> +\tif (settings.getEntry(ANDROID_TONEMAP_MODE, &entry))\n> +\t\tcontrols.set(controls::draft::TonemapMode, *entry.data.u8);\n> +\n>  \treturn 0;\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 0DF55BDCA6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 27 Apr 2021 05:13:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 50E7168880;\n\tTue, 27 Apr 2021 07:13:45 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7124360512\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Apr 2021 07:13:43 +0200 (CEST)","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 DC48B45E;\n\tTue, 27 Apr 2021 07:13:42 +0200 (CEST)"],"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=\"RU6FeUqW\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1619500423;\n\tbh=PS1Ny5XC43GYL2en+lJyAK6H1PXkwANSUU8NfIROKAk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=RU6FeUqW2MLH96kl5pS1gWkjUyfP3+1F7JUk85eoRMFsTYRW3uqF3VdbFSTonoEQM\n\tAoYB0w4vg88LH7Aj9M5u5oosI7rVMsUGm9tnACwwJ/fcrjgVtVBRlyiO4S2hKFOsJd\n\tU76zFpIwdTch9QwEsibyM//nMTURrF+MWXvUYx5I=","Date":"Tue, 27 Apr 2021 08:13:37 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Message-ID":"<YIedgU/TDEJw/5N4@pendragon.ideasonboard.com>","References":"<20210422094102.371772-1-paul.elder@ideasonboard.com>\n\t<20210422094102.371772-11-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210422094102.371772-11-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [RFC PATCH v2 10/12] android: camera_device:\n\tTranslate android controls to libcamera controls","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","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":16656,"web_url":"https://patchwork.libcamera.org/comment/16656/","msgid":"<20210427104730.226iy2amkx3uzacq@uno.localdomain>","date":"2021-04-27T10:47:30","subject":"Re: [libcamera-devel] [RFC PATCH v2 10/12] android: camera_device:\n\tTranslate android controls to libcamera controls","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Paul,\n\nOn Thu, Apr 22, 2021 at 06:41:00PM +0900, Paul Elder wrote:\n> Translate the newly added android controls that are required to FULL\n> compliance into libcamera controls before sending them to the Camera.\n>\n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> ---\n>  src/android/camera_device.cpp | 33 ++++++++++++++++++++++++++++++++-\n>  1 file changed, 32 insertions(+), 1 deletion(-)\n>\n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index 99c67555..30692a67 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -2136,15 +2136,46 @@ int CameraDevice::processControls(Camera3RequestDescriptor *descriptor)\n>\n>  \t/* Translate the Android request settings to libcamera controls. */\n>  \tcamera_metadata_ro_entry_t entry;\n> +\tControlList &controls = descriptor->request_->controls();\n> +\n>  \tif (settings.getEntry(ANDROID_SCALER_CROP_REGION, &entry)) {\n>  \t\tconst int32_t *data = entry.data.i32;\n>  \t\tRectangle cropRegion{ data[0], data[1],\n>  \t\t\t\t      static_cast<unsigned int>(data[2]),\n>  \t\t\t\t      static_cast<unsigned int>(data[3]) };\n> -\t\tControlList &controls = descriptor->request_->controls();\n>  \t\tcontrols.set(controls::ScalerCrop, cropRegion);\n>  \t}\n>\n> +\tif (settings.getEntry(ANDROID_SENSOR_EXPOSURE_TIME, &entry))\n> +\t\tcontrols.set(controls::ExposureTime, *entry.data.i64 / 1000ULL);\n\nAck. The android control is in nsecs, our one is micro-secs\n\n> +\n> +\tif (settings.getEntry(ANDROID_BLACK_LEVEL_LOCK, &entry))\n> +\t\tcontrols.set(controls::draft::BlackLevelLocked, *entry.data.u8);\n> +\n> +\tif (settings.getEntry(ANDROID_CONTROL_AE_LOCK, &entry))\n> +\t\tcontrols.set(controls::AeLocked, *entry.data.u8);\n> +\n> +\tif (settings.getEntry(ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER, &entry))\n> +\t\tcontrols.set(controls::draft::AePrecaptureTrigger, *entry.data.u8);\n> +\n> +\tif (settings.getEntry(ANDROID_CONTROL_AWB_MODE, &entry))\n> +\t\tcontrols.set(controls::AwbMode, *entry.data.u8);\n> +\n> +\tif (settings.getEntry(ANDROID_CONTROL_AWB_LOCK, &entry))\n> +\t\tcontrols.set(controls::AwbLocked, *entry.data.u8);\n> +\n> +\tif (settings.getEntry(ANDROID_EDGE_MODE, &entry))\n> +\t\tcontrols.set(controls::draft::EdgeMode, *entry.data.u8);\n> +\n> +\tif (settings.getEntry(ANDROID_NOISE_REDUCTION_MODE, &entry))\n> +\t\tcontrols.set(controls::draft::NoiseReductionMode, *entry.data.u8);\n> +\n> +\tif (settings.getEntry(ANDROID_SENSOR_SENSITIVITY, &entry))\n> +\t\tcontrols.set(controls::draft::SensorSensitivity, *entry.data.i32);\n> +\n> +\tif (settings.getEntry(ANDROID_TONEMAP_MODE, &entry))\n> +\t\tcontrols.set(controls::draft::TonemapMode, *entry.data.u8);\n\nSeems good.\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nI wonder going forward, if we should not walk all the controls in the\nrequest, translate them one by one, and clearly print out the ones we\ndon't pass down to the ph. Is it worth a todo ?\n\n> +\n>  \treturn 0;\n>  }\n>\n> --\n> 2.27.0\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 DB7CABDCC3\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 27 Apr 2021 10:46:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 48BEA68882;\n\tTue, 27 Apr 2021 12:46:50 +0200 (CEST)","from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net\n\t[217.70.183.199])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E62F6602C2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Apr 2021 12:46:48 +0200 (CEST)","from uno.localdomain (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 6CACDFF808;\n\tTue, 27 Apr 2021 10:46:48 +0000 (UTC)"],"X-Originating-IP":"93.61.96.190","Date":"Tue, 27 Apr 2021 12:47:30 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Paul Elder <paul.elder@ideasonboard.com>","Message-ID":"<20210427104730.226iy2amkx3uzacq@uno.localdomain>","References":"<20210422094102.371772-1-paul.elder@ideasonboard.com>\n\t<20210422094102.371772-11-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210422094102.371772-11-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [RFC PATCH v2 10/12] android: camera_device:\n\tTranslate android controls to libcamera controls","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","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]