Patch Detail
Show a patch.
GET /api/1.1/patches/15450/?format=api
{ "id": 15450, "url": "https://patchwork.libcamera.org/api/1.1/patches/15450/?format=api", "web_url": "https://patchwork.libcamera.org/patch/15450/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20220315141237.328859-1-kieran.bingham@ideasonboard.com>", "date": "2022-03-15T14:12:37", "name": "[libcamera-devel] SQUASH: ipa: ipu3: af: Auto focus for dw9719 Surface Go2 VCM", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "c9fd8e6ac1c4fbf97197f68bc64dc46744fd86eb", "submitter": { "id": 4, "url": "https://patchwork.libcamera.org/api/1.1/people/4/?format=api", "name": "Kieran Bingham", "email": "kieran.bingham@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/15450/mbox/", "series": [ { "id": 2962, "url": "https://patchwork.libcamera.org/api/1.1/series/2962/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2962", "date": "2022-03-15T14:12:37", "name": "[libcamera-devel] SQUASH: ipa: ipu3: af: Auto focus for dw9719 Surface Go2 VCM", "version": 1, "mbox": "https://patchwork.libcamera.org/series/2962/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/15450/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/15450/checks/", "tags": {}, "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\r\n\t[92.243.16.209])\r\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 87526BF415\r\n\tfor <parsemail@patchwork.libcamera.org>;\r\n\tTue, 15 Mar 2022 14:12:43 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\r\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E2E75610F8;\r\n\tTue, 15 Mar 2022 15:12:42 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\r\n\t[213.167.242.64])\r\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 88A3F604DA\r\n\tfor <libcamera-devel@lists.libcamera.org>;\r\n\tTue, 15 Mar 2022 15:12:41 +0100 (CET)", "from Monstersaurus.ksquared.org.uk.beta.tailscale.net\r\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\r\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 16346EE;\r\n\tTue, 15 Mar 2022 15:12:41 +0100 (CET)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\r\n\ts=mail; t=1647353562;\r\n\tbh=8iNiKW1mFGfu3UKjyK7fUtVGexLlpziC2LQmYiOWYrg=;\r\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\r\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\r\n\tFrom;\r\n\tb=Z02T9Zhi/6bx6sen1UhDd+++qDY2+SSlU22iykspEGRrwAq6k2cQ0RuvFEhABjCOS\r\n\tPcGWyA71gsRlBYXeQteqVRclMYOjTEj2gnX/hmAuwrbPTZU0JedPsWiA8l1IbIRYm2\r\n\tLiy6hxc2Pgu37iHl34Lj/MOuk6ztReqjJnlJjwp20Ki2BHnUjB57H7rDI0JKJ6kAjg\r\n\tv8XksQ6ZaKRazBxjxlNHT1i2KuIEVVBPANwARNvQ/makme6FE6DHOfufVob+Mx46FC\r\n\tPoPKXi1nfXj5BDdWgv7JP4c8oGwAU1WAx5ektSw8UOuZocNopLloN14DKmKZpsO/G0\r\n\t97ZAcd873afUw==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\r\n\ts=mail; t=1647353561;\r\n\tbh=8iNiKW1mFGfu3UKjyK7fUtVGexLlpziC2LQmYiOWYrg=;\r\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\r\n\tb=N9oXk6+jeZIgt6xuxjr1KQsilVh58ky1UZ31M6lCjBwT2bBM43f6LdDbAyfoAZzya\r\n\tul5bptlYSCC3Y3K8Kj2zPupepkBNGytObRrvkRkA3a33bgc8S9XKLweV4mfSa2S4Oy\r\n\tZQERwQdGZj0P53fYbUdOF5r21D6Crt20D/Q4uL5Q=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \r\n\tunprotected) header.d=ideasonboard.com\r\n\theader.i=@ideasonboard.com\r\n\theader.b=\"N9oXk6+j\"; dkim-atps=neutral", "To": "libcamera devel <libcamera-devel@lists.libcamera.org>", "Date": "Tue, 15 Mar 2022 14:12:37 +0000", "Message-Id": "<20220315141237.328859-1-kieran.bingham@ideasonboard.com>", "X-Mailer": "git-send-email 2.32.0", "In-Reply-To": "<20220214095136.25425-1-hpa@redhat.com>", "References": "<20220214095136.25425-1-hpa@redhat.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH] SQUASH: ipa: ipu3: af: Auto focus for\r\n\tdw9719 Surface Go2 VCM", "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>,\r\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>,\r\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "From": "Kieran Bingham via libcamera-devel\r\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "These changes are expected to be squashed into the AF implementation.\n\nThe changes here include:\n- Correct alignment of documentation *'s\n- Normalise return value documentation\n- Fix spelling of /afEstemateVariance/afEstimateVariance/\n- Expand documentation of Af::afEstimateVariance\n\nWith these, for Kate's patch:\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nI have a few more potential changes, but they can be handled as patches\non top and reviewed independently.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/ipa/ipu3/algorithms/af.cpp | 76 +++++++++++++++++++++++-----------\n 1 file changed, 52 insertions(+), 24 deletions(-)", "diff": "diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp\r\nindex 17055c043200..541b200bcc61 100644\r\n--- a/src/ipa/ipu3/algorithms/af.cpp\r\n+++ b/src/ipa/ipu3/algorithms/af.cpp\r\n@@ -33,25 +33,25 @@\r\n * \\var kAfMinGridWidth\r\n * \\brief the minimum width of AF grid.\r\n * The minimum grid horizontal dimensions.\r\n-*/\r\n+ */\r\n \r\n /**\r\n * \\var kAfMinGridHeight\r\n * \\brief the minimum height of AF grid.\r\n * The minimum grid vertical dimensions.\r\n-*/\r\n+ */\r\n \r\n /**\r\n * \\var kAfMaxGridWidth\r\n * \\brief the maximum width of AF grid.\r\n * The maximum grid horizontal dimensions.\r\n-*/\r\n+ */\r\n \r\n /**\r\n * \\var kAfMaxGridHeight\r\n * \\brief The maximum height of AF grid.\r\n * The maximum grid vertical dimensions.\r\n-*/\r\n+ */\r\n \r\n /**\r\n * \\var kAfMinGridBlockWidth\r\n@@ -127,6 +127,7 @@ static struct ipu3_uapi_af_filter_config afFilterConfigDefault = {\r\n /**\r\n * \\class Af\r\n * \\brief An auto-focus algorithm based on IPU3 statistics\r\n+ *\r\n * This algorithm is used to determine the position of the lens to make a\r\n * focused image. The IPU3 AF processing block computes the statistics that\r\n * are composed by two types of filtered value and stores in a AF buffer.\r\n@@ -158,7 +159,7 @@ void Af::prepare(IPAContext &context, ipu3_uapi_params *params)\r\n * \\brief Configure the Af given a configInfo\r\n * \\param[in] context The shared IPA context\r\n * \\param[in] configInfo The IPA configuration data\r\n- * \\return 0\r\n+ * \\return 0 on success, a negative error code otherwise\r\n */\r\n int Af::configure(IPAContext &context, const IPAConfigInfo &configInfo)\r\n {\r\n@@ -195,7 +196,9 @@ int Af::configure(IPAContext &context, const IPAConfigInfo &configInfo)\r\n \r\n /**\r\n * \\brief AF coarse scan\r\n+ *\r\n * Find a near focused image using a coarse step. The step is determined by coarseSearchStep.\r\n+ *\r\n * \\param[in] context The shared IPA context\r\n */\r\n void Af::afCoarseScan(IPAContext &context)\r\n@@ -220,7 +223,9 @@ void Af::afCoarseScan(IPAContext &context)\r\n \r\n /**\r\n * \\brief AF fine scan\r\n+ *\r\n * Find an optimum lens position with moving 1 step for each search.\r\n+ *\r\n * \\param[in] context The shared IPA context\r\n */\r\n void Af::afFineScan(IPAContext &context)\r\n@@ -239,7 +244,9 @@ void Af::afFineScan(IPAContext &context)\r\n \r\n /**\r\n * \\brief AF reset\r\n+ *\r\n * Reset all the parameters to start over the AF process.\r\n+ *\r\n * \\param[in] context The shared IPA context\r\n */\r\n void Af::afReset(IPAContext &context)\r\n@@ -260,11 +267,13 @@ void Af::afReset(IPAContext &context)\r\n \r\n /**\r\n * \\brief AF variance comparison.\r\n- * It always picks the largest variance to replace the previous one. The image\r\n- * with a larger variance also indicates it is a clearer image than previous\r\n- * one. If it finds the negative sign of derivative, it returns immediately.\r\n * \\param[in] context The IPA context\r\n * \\param min_step The VCM movement step.\r\n+ *\r\n+ * We always pick the largest variance to replace the previous one. The image\r\n+ * with a larger variance also indicates it is a clearer image than previous\r\n+ * one. If we find a negative derivative, we return immediately.\r\n+ *\r\n * \\return True, if it finds a AF value.\r\n */\r\n bool Af::afScan(IPAContext &context, int min_step)\r\n@@ -278,7 +287,7 @@ bool Af::afScan(IPAContext &context, int min_step)\r\n \t\t * Find the maximum of the variance by estimating its\r\n \t\t * derivative. If the direction changes, it means we have\r\n \t\t * passed a maximum one step before.\r\n-\t\t*/\r\n+\t\t */\r\n \t\tif ((currentVariance_ - context.frameContext.af.maxVariance) >=\r\n \t\t -(context.frameContext.af.maxVariance * 0.1)) {\r\n \t\t\t/*\r\n@@ -313,8 +322,7 @@ bool Af::afScan(IPAContext &context, int min_step)\r\n \r\n /**\r\n * \\brief Determine the frame to be ignored.\r\n- * \\return Return true the frame is ignored.\r\n- * \\return Return false the frame should be processed.\r\n+ * \\return Return True if the frame should be ignored, false otherwise\r\n */\r\n bool Af::afNeedIgnoreFrame()\r\n {\r\n@@ -334,9 +342,22 @@ void Af::afIgnoreFrameReset()\r\n }\r\n \r\n /**\r\n- * \\brief Estemate variance\r\n+ * \\brief Estimate variance\r\n+ * \\param y_item The AF filter data set from the IPU3 statistics buffer\r\n+ * \\param len The quantity of table item entries which are valid to process\r\n+ * \\param isY1 Selects between filter Y1 or Y2 to calculate the variance\r\n+ *\r\n+ * Calculate the mean of the data set provided by \\a y_item, and then calculate\r\n+ * the variance of that data set from the mean.\r\n+ *\r\n+ * The operation can work on one of two sets of values contained within the\r\n+ * y_item data set supplied by the IPU3. The two data sets are the results of\r\n+ * both the Y1 and Y2 filters which are used to support coarse (Y1) and fine\r\n+ * (Y2) calculations of the contrast.\r\n+ *\r\n+ * \\return The variance of the values in the data set \\a y_item selected by \\a isY1\r\n */\r\n-double Af::afEstemateVariance(y_table_item_t *y_item, uint32_t len,\r\n+double Af::afEstimateVariance(y_table_item_t *y_item, uint32_t len,\r\n \t\t\t bool isY1)\r\n {\r\n \tuint32_t z = 0;\r\n@@ -363,21 +384,25 @@ double Af::afEstemateVariance(y_table_item_t *y_item, uint32_t len,\r\n \r\n /**\r\n * \\brief Determine out-of-focus situation.\r\n+ * \\param context The IPA context.\r\n+ *\r\n * Out-of-focus means that the variance change rate for a focused and a new\r\n * variance is greater than a threshold.\r\n- * \\param context The IPA context.\r\n- * \\return If it is out-of-focus, return true.\r\n- * \\return If is is focused, return false.\r\n+ *\r\n+ * \\return True if the variance threshold is crossed indicating lost focus,\r\n+ * false otherwise.\r\n */\r\n bool Af::afIsOutOfFocus(IPAContext context)\r\n {\r\n \tconst uint32_t diff_var = std::abs(currentVariance_ -\r\n \t\t\t\t\t context.frameContext.af.maxVariance);\r\n \tconst double var_ratio = diff_var / context.frameContext.af.maxVariance;\r\n+\r\n \tLOG(IPU3Af, Debug) << \"Variance change rate: \"\r\n \t\t\t << var_ratio\r\n \t\t\t << \" Current VCM step: \"\r\n \t\t\t << context.frameContext.af.focus;\r\n+\r\n \tif (var_ratio > kMaxChange)\r\n \t\treturn true;\r\n \telse\r\n@@ -386,16 +411,19 @@ bool Af::afIsOutOfFocus(IPAContext context)\r\n \r\n /**\r\n * \\brief Determine the max contrast image and lens position.\r\n- * Ideally, a clear image also has a raletively higher contrast. So, every\r\n- * images for each focus step should be tested to find a optimal focus step.\r\n+ * \\param[in] context The IPA context.\r\n+ * \\param[in] stats The statistic buffer of IPU3.\r\n+ *\r\n+ * Ideally, a clear image also has a relatively higher contrast. So, every\r\n+ * image for each focus step should be tested to find an optimal focus step.\r\n+ *\r\n * The Hill Climbing Algorithm[1] is used to find the maximum variance of the\r\n- * AF statistic which is the AF output of IPU3. The focus step is increased\r\n+ * AF statistics which is the AF output of IPU3. The focus step is increased\r\n * then the variance of the AF statistic is estimated. If it finds the negative\r\n- * derivative which means we just passed the peak, the best focus is found.\r\n+ * derivative we have just passed the peak, and we infer that the best focus is\r\n+ * found.\r\n *\r\n * [1] Hill Climbing Algorithm, https://en.wikipedia.org/wiki/Hill_climbing\r\n- * \\param[in] context The IPA context.\r\n- * \\param[in] stats The statistic buffer of IPU3.\r\n */\r\n void Af::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\r\n {\r\n@@ -415,9 +443,9 @@ void Af::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\r\n \t * For fine: y2 results are used.\r\n \t */\r\n \tif (coarseCompleted_)\r\n-\t\tcurrentVariance_ = afEstemateVariance(y_item, afRawBufferLen, false);\r\n+\t\tcurrentVariance_ = afEstimateVariance(y_item, afRawBufferLen, false);\r\n \telse\r\n-\t\tcurrentVariance_ = afEstemateVariance(y_item, afRawBufferLen, true);\r\n+\t\tcurrentVariance_ = afEstimateVariance(y_item, afRawBufferLen, true);\r\n \r\n \tif (!context.frameContext.af.stable) {\r\n \t\tafCoarseScan(context);", "prefixes": [ "libcamera-devel" ] }