{"id":18185,"url":"https://patchwork.libcamera.org/api/patches/18185/?format=json","web_url":"https://patchwork.libcamera.org/patch/18185/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20230123154934.27803-11-naush@raspberrypi.com>","date":"2023-01-23T15:49:30","name":"[libcamera-devel,v2,10/14] ipa: raspberrypi: Handle autofocus algorithm results","commit_ref":"8418473c5178c112d279d7b9ffab3a61f6306693","pull_url":null,"state":"accepted","archived":false,"hash":"4a28f73fc23e73251d9e29bc5b6aa85a945744be","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/18185/mbox/","series":[{"id":3719,"url":"https://patchwork.libcamera.org/api/series/3719/?format=json","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/18185/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18185/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 2CF26C3297\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 23 Jan 2023 15:50:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D6C33625FE;\n\tMon, 23 Jan 2023 16:50:00 +0100 (CET)","from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com\n\t[IPv6:2a00:1450:4864:20::32e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B0DF625FD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Jan 2023 16:49:54 +0100 (CET)","by mail-wm1-x32e.google.com with SMTP id\n\tc10-20020a05600c0a4a00b003db0636ff84so8924037wmq.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Jan 2023 07:49:54 -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.53\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 23 Jan 2023 07:49:53 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1674489000;\n\tbh=hOUZPXIlhEQqFR0RsMcg2Z/jh8tJtOT052B+m706PIo=;\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=aWY35Nw2CisG/tLK+BHtSMm4kvjvVh8hdi7ZOlA2jiIYYZg8XzR8mkliNhQIrA3z5\n\tlWDGI1lLLDPEfos558vJK2Sy7/WW8zyyzbUrmsgxAx74GJYUSz5Xc4wlRlILTRTeug\n\th+SCk2bC6PIrc6x5XRDBY2XjpzUIvuvBn+/MMgNANufGNNoJ5bZDjikNYSNI1J4FTt\n\tY8XRFMRQcKNS5B2JVHNFqPFexjZKqZXBblZi9o/YbvdLUkHwtI9D+j1QDODoox6T0v\n\tYRS/QYlKJ5wQSaMnCDnhLe+IMU+DM4J0tMeWRaTiv9a0p9bcwmEoq4bszl5z2zowBS\n\t9tP416QWXfyPw==","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=daQ5WIrNK17AMNTB2uJujU/y+E4tht6Eh2qZ398InRs=;\n\tb=E34cAfg2HUBLyIkEc+nAHpmSHnddtNHi1OiFySXJixcQA+7lftAelSdvC2pwYqP/AP\n\t9XSaqj6dXNfgw0xPLmUxtXld8PcWqr+HTD1ovBXVjVmIV3tcA1HE96qkH5d9A3Z6nBHG\n\tFCqzmX9DrUvhaC8EQQ5PsRLTgpIY2jR6l130Fw31o8XqdreIZrh+DptB5KPJ7A424dyU\n\tD6bypEHbua+aRimC35e+j5O+PCUWqNLtY5GDGCCsrw5ibiw7TA8pQE/rKZPXxRdMLEqg\n\t5P7tIlF3l3+5QXWd1qbyuKnhRlEJtfMm8GC+g8C3O7Xb+abGBl7zGLDQolN/384udt5J\n\t/m1Q=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"E34cAfg2\"; 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=daQ5WIrNK17AMNTB2uJujU/y+E4tht6Eh2qZ398InRs=;\n\tb=fYz48b+FjMtn5s/9KxXk2Pzi9Ym35BoPRY5JhqzDxPSMOGGxqhnBUjKnwnhp5v8dET\n\tjQ9YLB7GXmVTNVrEfisnzOh4XQxg68eJ9Pjb9Je7HofLzI5k+OuUQsiV7wXg4ngiavx6\n\tLo76n5JQd/JNIZxACN+i7XbMZDjWFDsku+yn1kYBzHIoL+LIgHaa9iO1Vrro8OzjVqDc\n\t2d3BQGeKTdKQhXZ5aPHuHBk4YP6fsmH+Sx/PZrbV0iSQvCcEduRy0EjfEQbNrCHv2PUv\n\tz08OcOZbf+sMQ8Cmcdy992ay9mS8850KY6b2Tm7zh4mTzOFvxn2aG8EVEmHHBYJH02z8\n\tC7Dg==","X-Gm-Message-State":"AFqh2krd66pMICSwmDtVYlUlPHBO/o0sC/8sZa+1t2geORD/Gq9VKp3D\n\tbGhLxJ+XFSpk+jtZG7NH22NckQ+AN8rn3yvaEu4=","X-Google-Smtp-Source":"AMrXdXvVeGtpS5umNtSXdjoaF+GHGbbqxu0woJrXKcj35BlG1M5saeRRuKSQHXGoemO114lYg05quQ==","X-Received":"by 2002:a05:600c:5118:b0:3db:1e4f:7cdc with SMTP id\n\to24-20020a05600c511800b003db1e4f7cdcmr16672016wms.15.1674488993894; \n\tMon, 23 Jan 2023 07:49:53 -0800 (PST)","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 23 Jan 2023 15:49:30 +0000","Message-Id":"<20230123154934.27803-11-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 10/14] ipa: raspberrypi: Handle\n\tautofocus algorithm results","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\nHandle the results returned from the autofocus algorithm by updating lens\nactuator position to the desired value. Update the Request metadata with the\nalgorithm status to provide back to the application.\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 | 48 +++++++++++++++++++++++++++++\n 1 file changed, 48 insertions(+)","diff":"diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 0eb55ed605b6..fbace14b1afe 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -32,6 +32,7 @@\n #include \"libcamera/internal/mapped_framebuffer.h\"\n \n #include \"af_algorithm.h\"\n+#include \"af_status.h\"\n #include \"agc_algorithm.h\"\n #include \"agc_status.h\"\n #include \"alsc_status.h\"\n@@ -164,6 +165,7 @@ private:\n \tvoid applySharpen(const struct SharpenStatus *sharpenStatus, ControlList &ctrls);\n \tvoid applyDPC(const struct DpcStatus *dpcStatus, ControlList &ctrls);\n \tvoid applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls);\n+\tvoid applyAF(const struct AfStatus *afStatus, ControlList &lensCtrls);\n \tvoid resampleTable(uint16_t dest[], double const src[12][16], int destW, int destH);\n \n \tstd::map<unsigned int, MappedFrameBuffer> buffers_;\n@@ -629,6 +631,36 @@ void IPARPi::reportMetadata(unsigned int ipaContext)\n \t\t\tm[i] = ccmStatus->matrix[i];\n \t\tlibcameraMetadata_.set(controls::ColourCorrectionMatrix, m);\n \t}\n+\n+\tconst AfStatus *afStatus = rpiMetadata.getLocked<AfStatus>(\"af.status\");\n+\tif (afStatus) {\n+\t\tint32_t s, p;\n+\t\tswitch (afStatus->state) {\n+\t\tcase AfState::Scanning:\n+\t\t\ts = controls::AfStateScanning;\n+\t\t\tbreak;\n+\t\tcase AfState::Focused:\n+\t\t\ts = controls::AfStateFocused;\n+\t\t\tbreak;\n+\t\tcase AfState::Failed:\n+\t\t\ts = controls::AfStateFailed;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\ts = controls::AfStateIdle;\n+\t\t}\n+\t\tswitch (afStatus->pauseState) {\n+\t\tcase AfPauseState::Pausing:\n+\t\t\tp = controls::AfPauseStatePausing;\n+\t\t\tbreak;\n+\t\tcase AfPauseState::Paused:\n+\t\t\tp = controls::AfPauseStatePaused;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tp = controls::AfPauseStateRunning;\n+\t\t}\n+\t\tlibcameraMetadata_.set(controls::AfState, s);\n+\t\tlibcameraMetadata_.set(controls::AfPauseState, p);\n+\t}\n }\n \n bool IPARPi::validateSensorControls()\n@@ -1294,6 +1326,14 @@ void IPARPi::prepareISP(const ISPConfig &data)\n \tif (dpcStatus)\n \t\tapplyDPC(dpcStatus, ctrls);\n \n+\tconst AfStatus *afStatus = rpiMetadata.getLocked<AfStatus>(\"af.status\");\n+\tif (afStatus) {\n+\t\tControlList lensctrls(lensCtrls_);\n+\t\tapplyAF(afStatus, lensctrls);\n+\t\tif (!lensctrls.empty())\n+\t\t\tsetLensControls.emit(lensctrls);\n+\t}\n+\n \tif (!ctrls.empty())\n \t\tsetIspControls.emit(ctrls);\n }\n@@ -1619,6 +1659,14 @@ void IPARPi::applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls)\n \tctrls.set(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING, c);\n }\n \n+void IPARPi::applyAF(const struct AfStatus *afStatus, ControlList &lensCtrls)\n+{\n+\tif (afStatus->lensSetting) {\n+\t\tControlValue v(afStatus->lensSetting.value());\n+\t\tlensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, v);\n+\t}\n+}\n+\n /*\n  * Resamples a 16x12 table with central sampling to destW x destH with corner\n  * sampling.\n","prefixes":["libcamera-devel","v2","10/14"]}