Show a patch.

GET /api/patches/16217/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 16217,
    "url": "https://patchwork.libcamera.org/api/patches/16217/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16217/",
    "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-8-jeanmichel.hautbois@ideasonboard.com>",
    "date": "2022-06-13T14:28:50",
    "name": "[libcamera-devel,07/10] ipa: raspberrypi: Introduce AfPause and AfPauseState",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "63edd8acc4d8f7a01b5265d51b4b0e618cba10c6",
    "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/16217/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/16217/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16217/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 B25E1BD161\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 13 Jun 2022 14:29:11 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7C22865651;\n\tMon, 13 Jun 2022 16:29:10 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7F0166563D\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 2A99E305;\n\tMon, 13 Jun 2022 16:29:01 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655130550;\n\tbh=4gOouZ4scIBgUXuj6+zedJHsGvyIrkic8SgL+Nkiv2w=;\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=C0B4AEnhoBjyu5BjZH4BzRB3mQn1//DG4uPNMJssOiLXg06n9a0sIkG10shVbo8dr\n\t/wl66k6aqXr/KJI08pkfas7+7uBkA54E89py1jku7yk2uf+CcSQE3XtwQfF9rz+0Nv\n\t6f4koITEue0aI7gd43m2FjYQKNAL+zOTp7Lkv5qvhvoNwPnxemKJTDJVTljfSJG3/u\n\thzs4OPOi4BkA6iqSl9eUPzz8iCDgJA+oIifYvkf5BuJRxLByXCI4QnzHnEZn/UCmOy\n\tBCwBQR9Ip97/TPPORcw9Gr3gupCvfiXhZJrU7TqT4Jw+h3Y2j0tB89U4xDMgPipbNJ\n\tumTiNFbVxgtyw==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1655130541;\n\tbh=4gOouZ4scIBgUXuj6+zedJHsGvyIrkic8SgL+Nkiv2w=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=V0GZrOMW0Gu0MWTRVK7LRb1rma7z0vbTcidnSR6qOYeZb0jS41BDvcLWQGXQkevwH\n\tcHFrYWjxjeFYKI6isZCtFxkJkGBQN2nOUk9vtvcA41HB2xx3AbHQKaEnVCAdjArbUz\n\tEBTRBSdsb9O3q80XDxUUyE6DMHnyfz3EkeNkYAY4="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"V0GZrOMW\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 13 Jun 2022 16:28:50 +0200",
        "Message-Id": "<20220613142853.98484-8-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 07/10] ipa: raspberrypi: Introduce AfPause\n\tand AfPauseState",
        "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": "In the continuous mode, the algorithm can be paused and resumed by the\nuser using the AfPause control. Introduce the state machine associated\nwith this call, and populate a specific pause state which will populate\nthe AfPauseState control.\n\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n---\n include/libcamera/ipa/raspberrypi.h             |  2 ++\n src/ipa/raspberrypi/controller/af_algorithm.hpp |  2 ++\n src/ipa/raspberrypi/controller/af_status.h      |  1 +\n src/ipa/raspberrypi/controller/iob/af.cpp       | 14 +++++++++++++-\n src/ipa/raspberrypi/controller/iob/af.h         |  1 +\n src/ipa/raspberrypi/raspberrypi.cpp             | 15 +++++++++++++++\n 6 files changed, 34 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h\nindex 5bc14f4e..a7a15904 100644\n--- a/include/libcamera/ipa/raspberrypi.h\n+++ b/include/libcamera/ipa/raspberrypi.h\n@@ -48,6 +48,8 @@ static const ControlInfoMap Controls({\n \t\t{ &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) },\n \t\t{ &controls::AfMode, ControlInfo(controls::AfModeValues) },\n \t\t{ &controls::AfState, ControlInfo(controls::AfStateValues) },\n+\t\t{ &controls::AfPause, ControlInfo(controls::AfPauseValues) },\n+\t\t{ &controls::AfPauseState, ControlInfo(controls::AfPauseStateValues) },\n \t}, controls::controls);\n \n } /* namespace RPi */\ndiff --git a/src/ipa/raspberrypi/controller/af_algorithm.hpp b/src/ipa/raspberrypi/controller/af_algorithm.hpp\nindex 1e7aaa45..ac34e3b6 100644\n--- a/src/ipa/raspberrypi/controller/af_algorithm.hpp\n+++ b/src/ipa/raspberrypi/controller/af_algorithm.hpp\n@@ -22,6 +22,8 @@ public:\n \tvirtual void Trigger() = 0;\n \t// cancel a cycle (in auto mode)\n \tvirtual void Cancel() = 0;\n+\t// pause the continuous mode\n+\tvirtual void Pause(const uint32_t &pause) = 0;\n \t// set AF windows\n \tvirtual void SetWindows(const libcamera::Rectangle &afWindows) = 0;\n \t// set AF range\ndiff --git a/src/ipa/raspberrypi/controller/af_status.h b/src/ipa/raspberrypi/controller/af_status.h\nindex 3428d032..aa412ef6 100644\n--- a/src/ipa/raspberrypi/controller/af_status.h\n+++ b/src/ipa/raspberrypi/controller/af_status.h\n@@ -18,5 +18,6 @@\n struct AfStatus {\n \tuint32_t lensPosition;\n \tlibcamera::controls::AfStateEnum state;\n+\tlibcamera::controls::AfPauseStateEnum pauseState;\n \tlibcamera::Rectangle windows;\n };\ndiff --git a/src/ipa/raspberrypi/controller/iob/af.cpp b/src/ipa/raspberrypi/controller/iob/af.cpp\nindex e09514c4..2efc12f5 100644\n--- a/src/ipa/raspberrypi/controller/iob/af.cpp\n+++ b/src/ipa/raspberrypi/controller/iob/af.cpp\n@@ -54,6 +54,7 @@ void Af::SetMode(const uint32_t &mode)\n \tif (mode != mode_) {\n \t\tLOG(IoBAf, Debug) << \"Switched AF mode from \" << mode_\n \t\t\t\t  << \" to \" << mode;\n+\t\tstatus_.pauseState = libcamera::controls::AfPauseStateRunning;\n \t\tmode_ = mode;\n \t}\n }\n@@ -62,8 +63,15 @@ void Af::Trigger()\n {\n }\n \n-void Af::Cancel()\n+void Af::Pause(const uint32_t &pause)\n {\n+\t/* \\todo: add the AfPauseDeferred mode */\n+\tif (mode_ == libcamera::controls::AfModeContinuous) {\n+\t\tif (pause == libcamera::controls::AfPauseImmediate)\n+\t\t\tstatus_.pauseState = libcamera::controls::AfPauseStatePaused;\n+\t\telse if (pause == libcamera::controls::AfPauseResume)\n+\t\t\tstatus_.pauseState = libcamera::controls::AfPauseStateRunning;\n+\t}\n }\n \n void Af::SetWindows([[maybe_unused]] const libcamera::Rectangle &afWindows)\n@@ -199,6 +207,10 @@ 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/* If we are in a paused state, we won't process the stats */\n+\tif (status_.pauseState == libcamera::controls::AfPauseStatePaused)\n+\t\treturn;\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;\ndiff --git a/src/ipa/raspberrypi/controller/iob/af.h b/src/ipa/raspberrypi/controller/iob/af.h\nindex 4ed50cfb..c4ab3574 100644\n--- a/src/ipa/raspberrypi/controller/iob/af.h\n+++ b/src/ipa/raspberrypi/controller/iob/af.h\n@@ -26,6 +26,7 @@ public:\n \tvoid SetMode(const uint32_t &mode) override;\n \tvoid Trigger() override;\n \tvoid Cancel() override;\n+\tvoid Pause(const uint32_t &pause) override;\n \tvoid SetWindows(const libcamera::Rectangle &afWindows) override;\n \tvoid SetRange(const uint32_t &range) override;\n \tvoid setSpeed(const uint32_t &speed) override;\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 226388a7..8c6f213f 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -552,6 +552,7 @@ void IPARPi::reportMetadata()\n \tAfStatus *afStatus = rpiMetadata_.GetLocked<AfStatus>(\"af.status\");\n \tif (afStatus) {\n \t\tlibcameraMetadata_.set(controls::AfState, afStatus->state);\n+\t\tlibcameraMetadata_.set(controls::AfPauseState, afStatus->pauseState);\n \t}\n }\n \n@@ -971,6 +972,20 @@ void IPARPi::queueRequest(const ControlList &controls)\n \t\t\tbreak;\n \t\t}\n \n+\t\tcase controls::AF_PAUSE: {\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\taf->Pause(ctrl.second.get<int32_t>());\n+\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",
        "07/10"
    ]
}