Patch Detail
Show a patch.
GET /api/patches/16215/?format=api
{ "id": 16215, "url": "https://patchwork.libcamera.org/api/patches/16215/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16215/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20220613142853.98484-7-jeanmichel.hautbois@ideasonboard.com>", "date": "2022-06-13T14:28:49", "name": "[libcamera-devel,06/10] ipa: raspberrypi: Add AfMode control", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "17248ba6d1569170fdc92cf7f2faee9ccda6d1fd", "submitter": { "id": 75, "url": "https://patchwork.libcamera.org/api/people/75/?format=api", "name": "Jean-Michel Hautbois", "email": "jeanmichel.hautbois@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16215/mbox/", "series": [ { "id": 3174, "url": "https://patchwork.libcamera.org/api/series/3174/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3174", "date": "2022-06-13T14:28:43", "name": "ipa: raspberrypi: Introduce an autofocus algorithm", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3174/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16215/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16215/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 04E2BC3278\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 13 Jun 2022 14:29:10 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6B0806564A;\n\tMon, 13 Jun 2022 16:29:09 +0200 (CEST)", "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 4BA226563A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Jun 2022 16:29:01 +0200 (CEST)", "from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:a1c7:c28c:7720:9b30])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E8050835;\n\tMon, 13 Jun 2022 16:29:00 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655130549;\n\tbh=L0NjK6mBDyCL2ThmuccyDqBNjZ8Igse88Op1rmrJkK0=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=Po31hqHw94zpesI5L95cP+tXY61SAD6Fa/TFQ7lsot1OIT2WXPF3jrQYqYMBnZHDc\n\tKzOueWYiPmKxn1C2ivVFNRrsxo+XqixOs0cfKYwQZfr29NMwTBsmjPay5zkr20gTNT\n\ts54WLNglOrfWHE/hnS0viZJytFj8B503+TZ18xgursidz2QZ4QAUjjp+xMwZDxSH5T\n\tkQzM42AvaaYewv9q18Pk27W7KbUPeC5GYqnlT4dWghu9eARY4+NGBTZk4qx/CuiuDF\n\tGFz72bZx/9o51rsKNkpo49LVaszll+0fj4aHEJ8ORxkGJTC+gokfgDaTxsuGLw2Nbk\n\tz6rlAK9ULIMcw==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1655130541;\n\tbh=L0NjK6mBDyCL2ThmuccyDqBNjZ8Igse88Op1rmrJkK0=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=b1emh2knyX0to0UU2/15ZqmSg9YNCfW2AKlJrLQAjV1eDICVfuqdbJqqmhSvwlM9b\n\tDxeE+MSMrRneg7i/9Qq9N3f+ESAAXw6GOqD0Dy7VOf+5s4dE2ry54h1kBP8Cv5PHcA\n\tbOZpqHdabQUFwvBq39/t3yChcPd+xiICEZlFGHIQ=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"b1emh2kn\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 13 Jun 2022 16:28:49 +0200", "Message-Id": "<20220613142853.98484-7-jeanmichel.hautbois@ideasonboard.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20220613142853.98484-1-jeanmichel.hautbois@ideasonboard.com>", "References": "<20220613142853.98484-1-jeanmichel.hautbois@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 06/10] ipa: raspberrypi: Add AfMode 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": "Jean-Michel Hautbois via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Implement the AfMode control to allow the user to switch between manual,\nauto or continuous mode. As the mode changes, the AfState value is\nupdated and lets the user follow the algorithm state.\n\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n---\n include/libcamera/ipa/raspberrypi.h | 3 ++-\n src/ipa/raspberrypi/controller/iob/af.cpp | 24 ++++++++++++++++-------\n src/ipa/raspberrypi/raspberrypi.cpp | 15 ++++++++++++++\n 3 files changed, 34 insertions(+), 8 deletions(-)", "diff": "diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h\nindex 519f7160..5bc14f4e 100644\n--- a/include/libcamera/ipa/raspberrypi.h\n+++ b/include/libcamera/ipa/raspberrypi.h\n@@ -46,7 +46,8 @@ static const ControlInfoMap Controls({\n \t\t{ &controls::ScalerCrop, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) },\n \t\t{ &controls::FrameDurationLimits, ControlInfo(INT64_C(1000), INT64_C(1000000000)) },\n \t\t{ &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) },\n-\t\t{ &controls::AfState, ControlInfo(controls::AfStateValues) }\n+\t\t{ &controls::AfMode, ControlInfo(controls::AfModeValues) },\n+\t\t{ &controls::AfState, ControlInfo(controls::AfStateValues) },\n \t}, controls::controls);\n \n } /* namespace RPi */\ndiff --git a/src/ipa/raspberrypi/controller/iob/af.cpp b/src/ipa/raspberrypi/controller/iob/af.cpp\nindex b03e52c5..e09514c4 100644\n--- a/src/ipa/raspberrypi/controller/iob/af.cpp\n+++ b/src/ipa/raspberrypi/controller/iob/af.cpp\n@@ -40,7 +40,7 @@ Af::Af(Controller *controller)\n \t: AfAlgorithm(controller), focus_(0), bestFocus_(0),\n \t currentContrast_(0.0), previousContrast_(0.0), maxContrast_(0.0),\n \t maxStep_(0), coarseCompleted_(false), fineCompleted_(false),\n-\t mode_(0)\n+\t mode_(libcamera::controls::AfModeManual)\n {\n }\n \n@@ -49,9 +49,13 @@ char const *Af::Name() const\n \treturn NAME;\n }\n \n-void Af::SetMode([[maybe_unused]] const uint32_t &mode)\n+void Af::SetMode(const uint32_t &mode)\n {\n-\tmode_ = mode;\n+\tif (mode != mode_) {\n+\t\tLOG(IoBAf, Debug) << \"Switched AF mode from \" << mode_\n+\t\t\t\t << \" to \" << mode;\n+\t\tmode_ = mode;\n+\t}\n }\n \n void Af::Trigger()\n@@ -78,7 +82,7 @@ void Af::Initialise()\n {\n \tstatus_.lensPosition = 0.0;\n \tmaxContrast_ = 0.0;\n-\tstatus_.state = libcamera::controls::AfStateScanning;\n+\tstatus_.state = libcamera::controls::AfStateIdle;\n }\n \n void Af::Prepare(Metadata *image_metadata)\n@@ -162,7 +166,7 @@ void Af::afReset()\n \tLOG(IoBAf, Debug) << \"Reset AF parameters\";\n \tstatus_.lensPosition = 0;\n \tfocus_ = 0;\n-\tstatus_.state = libcamera::controls::AfStateIdle;\n+\tstatus_.state = libcamera::controls::AfStateScanning;\n \tpreviousContrast_ = 0.0;\n \tcoarseCompleted_ = false;\n \tfineCompleted_ = false;\n@@ -195,12 +199,18 @@ void Af::Process(StatisticsPtr &stats, [[maybe_unused]] Metadata *image_metadata\n \t\tcurrentContrast_ += stats->focus_stats[i].contrast_val[1][1]\n \t\t\t\t / stats->focus_stats[i].contrast_val_num[1][1];\n \n+\t/* Depending on the mode, we may or may not process the stats */\n+\tif (status_.state == libcamera::controls::AfStateIdle)\n+\t return;\n+\n \tif (status_.state != libcamera::controls::AfStateFocused) {\n \t\tafCoarseScan();\n \t\tafFineScan();\n \t} else {\n-\t\tif (afIsOutOfFocus())\n-\t\t\tafReset();\n+\t\t/* We can re-start the scan at any moment in AfModeContinuous */\n+\t\tif (mode_ == libcamera::controls::AfModeContinuous)\n+\t\t\tif (afIsOutOfFocus())\n+\t\t\t\tafReset();\n \t}\n }\n \ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex a4e1c834..226388a7 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -30,6 +30,7 @@\n \n #include \"libcamera/internal/mapped_framebuffer.h\"\n \n+#include \"af_algorithm.hpp\"\n #include \"af_status.h\"\n #include \"agc_algorithm.hpp\"\n #include \"agc_status.h\"\n@@ -956,6 +957,20 @@ void IPARPi::queueRequest(const ControlList &controls)\n \t\t\tbreak;\n \t\t}\n \n+\t\tcase controls::AF_MODE: {\n+\t\t\tRPiController::AfAlgorithm *af = dynamic_cast<RPiController::AfAlgorithm *>(\n+\t\t\t\tcontroller_.GetAlgorithm(\"iob.af\"));\n+\t\t\tif (!af) {\n+\t\t\t\tLOG(IPARPI, Warning)\n+\t\t\t\t\t<< \"Could not set AF_MODE - no AF algorithm\";\n+\t\t\t\tbreak;\n+\t\t\t}\n+\n+\t\t\tint32_t idx = ctrl.second.get<int32_t>();\n+\t\t\taf->SetMode(idx);\n+\t\t\tbreak;\n+\t\t}\n+\n \t\tdefault:\n \t\t\tLOG(IPARPI, Warning)\n \t\t\t\t<< \"Ctrl \" << controls::controls.at(ctrl.first)->name()\n", "prefixes": [ "libcamera-devel", "06/10" ] }