Patch Detail
Show a patch.
GET /api/patches/18184/?format=api
{ "id": 18184, "url": "https://patchwork.libcamera.org/api/patches/18184/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18184/", "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": "<20230123154934.27803-10-naush@raspberrypi.com>", "date": "2023-01-23T15:49:29", "name": "[libcamera-devel,v2,09/14] ipa: raspberrypi: Handle autofocus controls", "commit_ref": "a38c0502b4e5536aef17fab3e98ce2cd1b135dd4", "pull_url": null, "state": "accepted", "archived": false, "hash": "75f17b9f30d386e1a66cc0280b055e01dff2e82d", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18184/mbox/", "series": [ { "id": 3719, "url": "https://patchwork.libcamera.org/api/series/3719/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3719", "date": "2023-01-23T15:49:20", "name": "Raspberry Pi: Camera Module 3 support", "version": 2, "mbox": "https://patchwork.libcamera.org/series/3719/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18184/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18184/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 72824C3240\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 23 Jan 2023 15:50:00 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2281662601;\n\tMon, 23 Jan 2023 16:50:00 +0100 (CET)", "from mail-wm1-x331.google.com (mail-wm1-x331.google.com\n\t[IPv6:2a00:1450:4864:20::331])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EF2D4625E7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Jan 2023 16:49:53 +0100 (CET)", "by mail-wm1-x331.google.com with SMTP id q8so9356323wmo.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Jan 2023 07:49:53 -0800 (PST)", "from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tn16-20020a05600c181000b003d1de805de5sm10339689wmp.16.2023.01.23.07.49.52\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 23 Jan 2023 07:49:52 -0800 (PST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1674489000;\n\tbh=FwWs23/yLeIYaKR2QHxyiUmReWahysMWlCP0J/P5NkU=;\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:Cc:\n\tFrom;\n\tb=qI8FKaV02xEtyCMS9pb+ulaBolQ0uD2LH4073sApV+T7v7YvICErplEqzXaE7kALF\n\t/LYTvQ/JztlRD2EcmM+uZMWSpgMwHB5qRY3DEiodAVg+MsbAHDzRdTCXCk6MljKzNv\n\tgpNR3FR7FH8GW400rXkddGJSrox7s+qeulC1HI1Un7Zolwxx82GUGz0DjdlmfLXeXu\n\tp1JHhEdOyOj8P/3aXo0tqIqmGjx9GdlLCrgRfSE0QVhiJwd3LNsi2azE0rEGD7kZQx\n\tCz5+Qthsd0rpSfjuUbn/1ZYukx10BQ/QRGB8eSAneVlNsFOHFIUN63GeAYg35uPAj9\n\tXAbIDeTjApArQ==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=4UYvcAZ8aQ9iDqO1x3vQcdFJHQPnJdXnBpdMdVUYWW4=;\n\tb=RcuLwLea8VS0jYl9VX7cWP9Zb2pEovDe9YzgIFH+IBfCnlNmmL0ulQ2GcRSANafUI4\n\tyuW+QQkjuoQ5+rnZkBvvT4a2QRO9agDYwnOw3Ln3Cn7rND1srUWft5782VL6AQzlC9vo\n\thu6x7liEj7/zhZgmfL3GhzA6eHP+LN7jAh+sCHm6/vlt4r2SZ/M9OewsrfT2M6uJz7aS\n\tP6eMrjPQ6wpa1a59iE67+799qC3wnNbQ7n8Y40DLj5W8FUsYI0vtD/j1D4BuIXAWWfxN\n\tIZRQ36FttWGJ+lkA/Oqdke38BDPHWB7gm2FyZOcV7c6SfZbeat4Bcr6mqLu0K580GEXk\n\tsAwg==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"RcuLwLea\"; dkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=4UYvcAZ8aQ9iDqO1x3vQcdFJHQPnJdXnBpdMdVUYWW4=;\n\tb=HVH/gzFWuwMYQ0qyuudn6qy2WJVo+e1t706rdXmaYkQQLZ4xgFuLN5sAWgXwcTAaLA\n\tRDKyn6P31BXVOQ6LjM7pGLbcVnotyZONmiuA5ugomdlqK40+Pagrpbijm0kEPOINJc9e\n\twHdzL2F7ZkmPz1ENhrqPsqRIRWWNaqXG9O119FrwFnWFYA7phqMh3WCFo244Vgd32Q/X\n\tq1YeoAbXs3WkoaJZTzLTNVM5sGCQZVxd6Zvghkd0udhDeNKZoBjlVXt70JiPPVCmoqPn\n\tLTbdmn2BhT8u+eiWwOkwlEz+SYd8gcLoFSktyPjL3G+niJk71lunTkdz5TcmZIGjcTCJ\n\tEPoA==", "X-Gm-Message-State": "AFqh2koj0lo6qRh36NqzAEc9TzGEPQ9L96hHNNWABsUBaMyfVHi9Ey2H\n\tHSrFhux0AIgYZzU2CYkAXHmN92XQaLRBRgDEQ20=", "X-Google-Smtp-Source": "AMrXdXumBryeoFKlx3q21kt+6w6tIvcRvh/+mmribhVVR1MNYe2tu/q+qVbtjU7pCYS3usJk2iPzvA==", "X-Received": "by 2002:a05:600c:810:b0:3da:f0e:fe34 with SMTP id\n\tk16-20020a05600c081000b003da0f0efe34mr23332251wmp.32.1674488993194; \n\tMon, 23 Jan 2023 07:49:53 -0800 (PST)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 23 Jan 2023 15:49:29 +0000", "Message-Id": "<20230123154934.27803-10-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20230123154934.27803-1-naush@raspberrypi.com>", "References": "<20230123154934.27803-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 09/14] ipa: raspberrypi: Handle\n\tautofocus 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>", "From": "Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Naushir Patuck <naush@raspberrypi.com>", "Cc": "Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "From: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>\n\nAdd handlers for all autofocus related libcamera controls. Translate these\ncontrols to the RPiController autofocus algorithm API.\n\nSigned-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/ipa/raspberrypi/raspberrypi.cpp | 144 ++++++++++++++++++++++++++++\n 1 file changed, 144 insertions(+)", "diff": "diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 745c16f354ce..0eb55ed605b6 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -31,6 +31,7 @@\n \n #include \"libcamera/internal/mapped_framebuffer.h\"\n \n+#include \"af_algorithm.h\"\n #include \"agc_algorithm.h\"\n #include \"agc_status.h\"\n #include \"alsc_status.h\"\n@@ -732,11 +733,49 @@ static const std::map<int32_t, RPiController::DenoiseMode> DenoiseModeTable = {\n \t{ controls::draft::NoiseReductionModeZSL, RPiController::DenoiseMode::ColourHighQuality },\n };\n \n+static const std::map<int32_t, RPiController::AfAlgorithm::AfMode> AfModeTable = {\n+\t{ controls::AfModeManual, RPiController::AfAlgorithm::AfModeManual },\n+\t{ controls::AfModeAuto, RPiController::AfAlgorithm::AfModeAuto },\n+\t{ controls::AfModeContinuous, RPiController::AfAlgorithm::AfModeContinuous },\n+};\n+\n+static const std::map<int32_t, RPiController::AfAlgorithm::AfRange> AfRangeTable = {\n+\t{ controls::AfRangeNormal, RPiController::AfAlgorithm::AfRangeNormal },\n+\t{ controls::AfRangeMacro, RPiController::AfAlgorithm::AfRangeMacro },\n+\t{ controls::AfRangeFull, RPiController::AfAlgorithm::AfRangeFull },\n+};\n+\n+static const std::map<int32_t, RPiController::AfAlgorithm::AfPause> AfPauseTable = {\n+\t{ controls::AfPauseImmediate, RPiController::AfAlgorithm::AfPauseImmediate },\n+\t{ controls::AfPauseDeferred, RPiController::AfAlgorithm::AfPauseDeferred },\n+\t{ controls::AfPauseResume, RPiController::AfAlgorithm::AfPauseResume },\n+};\n+\n void IPARPi::queueRequest(const ControlList &controls)\n {\n+\tusing RPiController::AfAlgorithm;\n+\n \t/* Clear the return metadata buffer. */\n \tlibcameraMetadata_.clear();\n \n+\t/* Because some AF controls are mode-specific, handle AF mode change first. */\n+\tif (controls.contains(controls::AF_MODE)) {\n+\t\tAfAlgorithm *af = dynamic_cast<AfAlgorithm *>(controller_.getAlgorithm(\"af\"));\n+\t\tif (!af) {\n+\t\t\tLOG(IPARPI, Warning)\n+\t\t\t\t<< \"Could not set AF_MODE - no AF algorithm\";\n+\t\t}\n+\n+\t\tint32_t idx = controls.get(controls::AF_MODE).get<int32_t>();\n+\t\tauto mode = AfModeTable.find(idx);\n+\t\tif (mode == AfModeTable.end()) {\n+\t\t\tLOG(IPARPI, Error) << \"AF mode \" << idx\n+\t\t\t\t\t << \" not recognised\";\n+\t\t} else\n+\t\t\taf->setMode(mode->second);\n+\t}\n+\n+\t/* Iterate over controls */\n \tfor (auto const &ctrl : controls) {\n \t\tLOG(IPARPI, Debug) << \"Request ctrl: \"\n \t\t\t\t << controls::controls.at(ctrl.first)->name()\n@@ -1028,6 +1067,111 @@ void IPARPi::queueRequest(const ControlList &controls)\n \t\t\tbreak;\n \t\t}\n \n+\t\tcase controls::AF_MODE:\n+\t\t\tbreak; /* We already handled this one above */\n+\n+\t\tcase controls::AF_RANGE: {\n+\t\t\tAfAlgorithm *af = dynamic_cast<AfAlgorithm *>(controller_.getAlgorithm(\"af\"));\n+\t\t\tif (!af) {\n+\t\t\t\tLOG(IPARPI, Warning)\n+\t\t\t\t\t<< \"Could not set AF_RANGE - no focus algorithm\";\n+\t\t\t\tbreak;\n+\t\t\t}\n+\n+\t\t\tauto range = AfRangeTable.find(ctrl.second.get<int32_t>());\n+\t\t\tif (range == AfRangeTable.end()) {\n+\t\t\t\tLOG(IPARPI, Error) << \"AF range \" << ctrl.second.get<int32_t>()\n+\t\t\t\t\t\t << \" not recognised\";\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\taf->setRange(range->second);\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tcase controls::AF_SPEED: {\n+\t\t\tAfAlgorithm *af = dynamic_cast<AfAlgorithm *>(controller_.getAlgorithm(\"af\"));\n+\t\t\tif (!af) {\n+\t\t\t\tLOG(IPARPI, Warning)\n+\t\t\t\t\t<< \"Could not set AF_SPEED - no focus algorithm\";\n+\t\t\t\tbreak;\n+\t\t\t}\n+\n+\t\t\tAfAlgorithm::AfSpeed speed = ctrl.second.get<int32_t>() == controls::AfSpeedFast ?\n+\t\t\t\t\t\t AfAlgorithm::AfSpeedFast : AfAlgorithm::AfSpeedNormal;\n+\t\t\taf->setSpeed(speed);\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tcase controls::AF_METERING: {\n+\t\t\tAfAlgorithm *af = dynamic_cast<AfAlgorithm *>(controller_.getAlgorithm(\"af\"));\n+\t\t\tif (!af) {\n+\t\t\t\tLOG(IPARPI, Warning)\n+\t\t\t\t\t<< \"Could not set AF_METERING - no AF algorithm\";\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\taf->setMetering(ctrl.second.get<int32_t>() == controls::AfMeteringWindows);\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tcase controls::AF_WINDOWS: {\n+\t\t\tAfAlgorithm *af = dynamic_cast<AfAlgorithm *>(controller_.getAlgorithm(\"af\"));\n+\t\t\tif (!af) {\n+\t\t\t\tLOG(IPARPI, Warning)\n+\t\t\t\t\t<< \"Could not set AF_WINDOWS - no AF algorithm\";\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\taf->setWindows(ctrl.second.get<Span<const Rectangle>>());\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tcase controls::AF_PAUSE: {\n+\t\t\tAfAlgorithm *af = dynamic_cast<AfAlgorithm *>(controller_.getAlgorithm(\"af\"));\n+\t\t\tif (!af || af->getMode() != AfAlgorithm::AfModeContinuous) {\n+\t\t\t\tLOG(IPARPI, Warning)\n+\t\t\t\t\t<< \"Could not set AF_PAUSE - no AF algorithm or not Continuous\";\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\tauto pause = AfPauseTable.find(ctrl.second.get<int32_t>());\n+\t\t\tif (pause == AfPauseTable.end()) {\n+\t\t\t\tLOG(IPARPI, Error) << \"AF pause \" << ctrl.second.get<int32_t>()\n+\t\t\t\t\t\t << \" not recognised\";\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\taf->pause(pause->second);\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tcase controls::AF_TRIGGER: {\n+\t\t\tAfAlgorithm *af = dynamic_cast<AfAlgorithm *>(controller_.getAlgorithm(\"af\"));\n+\t\t\tif (!af || af->getMode() != AfAlgorithm::AfModeAuto) {\n+\t\t\t\tLOG(IPARPI, Warning)\n+\t\t\t\t\t<< \"Could not set AF_TRIGGER - no AF algorithm or not Auto\";\n+\t\t\t\tbreak;\n+\t\t\t} else {\n+\t\t\t\tif (ctrl.second.get<int32_t>() == controls::AfTriggerStart)\n+\t\t\t\t\taf->triggerScan();\n+\t\t\t\telse\n+\t\t\t\t\taf->cancelScan();\n+\t\t\t}\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tcase controls::LENS_POSITION: {\n+\t\t\tAfAlgorithm *af = dynamic_cast<AfAlgorithm *>(controller_.getAlgorithm(\"af\"));\n+\t\t\tif (af) {\n+\t\t\t\tint32_t hwpos;\n+\t\t\t\tif (af->setLensPosition(ctrl.second.get<float>(), &hwpos)) {\n+\t\t\t\t\tControlList lensCtrls(lensCtrls_);\n+\t\t\t\t\tlensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, hwpos);\n+\t\t\t\t\tsetLensControls.emit(lensCtrls);\n+\t\t\t\t}\n+\t\t\t} else {\n+\t\t\t\tLOG(IPARPI, Warning)\n+\t\t\t\t\t<< \"Could not set LENS_POSITION - no AF algorithm\";\n+\t\t\t}\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", "v2", "09/14" ] }