{"id":8647,"url":"https://patchwork.libcamera.org/api/1.1/patches/8647/?format=json","web_url":"https://patchwork.libcamera.org/patch/8647/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200706085625.1625432-4-naush@raspberrypi.com>","date":"2020-07-06T08:56:25","name":"[libcamera-devel,v2,3/3] libcamera: ipa: raspberrypi: Populate focus FoM from the ISP statistics","commit_ref":"e0c583871da9cc6d243bff26ef5ba224007fc5ed","pull_url":null,"state":"accepted","archived":false,"hash":"2b2c279c879f0fe750f6676a27a2a5c20cffcadd","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/8647/mbox/","series":[{"id":1084,"url":"https://patchwork.libcamera.org/api/1.1/series/1084/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1084","date":"2020-07-06T08:56:22","name":"Focus feedback control","version":2,"mbox":"https://patchwork.libcamera.org/series/1084/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/8647/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/8647/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\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 5E32DBD792\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Jul 2020 08:56:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2ACB660E05;\n\tMon,  6 Jul 2020 10:56:42 +0200 (CEST)","from mail-wm1-x343.google.com (mail-wm1-x343.google.com\n\t[IPv6:2a00:1450:4864:20::343])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DA0EF60E35\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Jul 2020 10:56:39 +0200 (CEST)","by mail-wm1-x343.google.com with SMTP id j18so38381333wmi.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 06 Jul 2020 01:56:39 -0700 (PDT)","from naushir-VirtualBox.patuck.local ([88.97.76.4])\n\tby smtp.gmail.com with ESMTPSA id\n\tk185sm22600282wmk.47.2020.07.06.01.56.38\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 06 Jul 2020 01:56:38 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"V2fBFJaY\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=qSV2uqoWNA3gnKhA2JBI5GAxVQ3yH469eK933yQUNrg=;\n\tb=V2fBFJaYqFlYeaj1+8IRDuS6D0cC8rFTKpQCWvSZdYd+FXC1vOHzdgEukEhrYHQLhG\n\taym36yCzhxn411c5I0Dlbeu51zP8DCO6P/t82jeku2RrM2c+tYy33YNop687wbLplR0+\n\t4X/AF9Os7xIoJiKCSl8KUIYJI4WtWbD6CEaZ6JdkM70miL2E/hzCBNWKEiuYjVzgVHLr\n\teWTrY/VoZ9RqT6hW7FbSolbEVXHmd5Ub04ACXJHe0LgB0K/VxAYInjQqpuFwCC6ukGWG\n\tiYc+kKmRgOHJJo7ShGqeDe7SES1vnZqTu5/pO4z3eUD8HuMCMFrjY/q5J0+G98EVRB6Z\n\thJYg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=qSV2uqoWNA3gnKhA2JBI5GAxVQ3yH469eK933yQUNrg=;\n\tb=EZ/CDwOEHn+8+ReGjAn/ny0tVuPt4DCiqOYcQK0eSf0r1rmQG05bPt9biDUS+Db+V9\n\tZ+bj5/+A3fx7N6vdSkyMX2yKwWXcALy6acc8Al/pgu/ZPosYB2hPb+d5S3vjtsOh3stL\n\tQg3hWvdgkPphEjQ+WvZgw4GbBMkDTg12CB3mliq1HJvo/dJ4tjFgutQ6iyg94Pk4rnqR\n\tJP7rOsmaY/Og6GwOGodWJMJDZBLcUrHxHx7clhuugPiHwn6laYSXE/WYRafCYTTwdfc4\n\tiPMxj45AoZfID/hcXt/55IlFb5iHr793C4QMXzRgAObYbsml9H4HvMvCEeAfvZXc6JM6\n\tPeZg==","X-Gm-Message-State":"AOAM533qClQBUTrgqGJ1ApFecpWZDFbZXDV3rTiXc27hQtdflH0H8dxE\n\tg1H19WLm+Kh7OeLg+9x0J1paR5zqMDk=","X-Google-Smtp-Source":"ABdhPJzRKg3lWI6bQ9BnhkChyyMuoQojc7MKmejiz2mT/RhFQHU363ubuCUbAe0XxsibZkquAWEZBA==","X-Received":"by 2002:a1c:9a06:: with SMTP id c6mr9579150wme.23.1594025799335; \n\tMon, 06 Jul 2020 01:56:39 -0700 (PDT)","From":"Naushir Patuck <naush@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon,  6 Jul 2020 09:56:25 +0100","Message-Id":"<20200706085625.1625432-4-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20200706085625.1625432-1-naush@raspberrypi.com>","References":"<20200706085625.1625432-1-naush@raspberrypi.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v2 3/3] libcamera: ipa: raspberrypi:\n\tPopulate focus FoM from the ISP statistics","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>","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>"},"content":"Switch FocusStatus::num to unsigned int for convenience.\n\nFill in libcamera::controls::FocusFoM with the average of the middle two\nregions (across a 4x3 grid) FoM statistics from the ISP.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/raspberrypi/controller/focus_status.h |  2 +-\n src/ipa/raspberrypi/raspberrypi.cpp           | 12 ++++++++++++\n 2 files changed, 13 insertions(+), 1 deletion(-)","diff":"diff --git a/src/ipa/raspberrypi/controller/focus_status.h b/src/ipa/raspberrypi/controller/focus_status.h\nindex 3ad88777..ace2fe2c 100644\n--- a/src/ipa/raspberrypi/controller/focus_status.h\n+++ b/src/ipa/raspberrypi/controller/focus_status.h\n@@ -17,7 +17,7 @@ extern \"C\" {\n #endif\n \n struct FocusStatus {\n-\tint num;\n+\tunsigned int num;\n \tuint32_t focus_measures[FOCUS_REGIONS];\n };\n \ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 62730198..b1f27861 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -42,6 +42,7 @@\n #include \"contrast_status.h\"\n #include \"controller.hpp\"\n #include \"dpc_status.h\"\n+#include \"focus_status.h\"\n #include \"geq_status.h\"\n #include \"lux_status.h\"\n #include \"metadata.hpp\"\n@@ -405,6 +406,17 @@ void IPARPi::reportMetadata()\n \t\t\t\t\t static_cast<int32_t>(blackLevelStatus->black_level_g),\n \t\t\t\t\t static_cast<int32_t>(blackLevelStatus->black_level_g),\n \t\t\t\t\t static_cast<int32_t>(blackLevelStatus->black_level_b) });\n+\n+\tFocusStatus *focusStatus = rpiMetadata_.GetLocked<FocusStatus>(\"focus.status\");\n+\tif (focusStatus && focusStatus->num == 12) {\n+\t\t/*\n+\t\t * We get a 4x3 grid of regions by default. Calculate the average\n+\t\t * FoM over the central two positions to give an overall scene FoM.\n+\t\t * This can change later if it is not deemed suitable.\n+\t\t */\n+\t\tint32_t focusFoM = (focusStatus->focus_measures[5] + focusStatus->focus_measures[6]) / 2;\n+\t\tlibcameraMetadata_.set(controls::FocusFoM, focusFoM);\n+\t}\n }\n \n /*\n","prefixes":["libcamera-devel","v2","3/3"]}