From patchwork Mon Dec 13 12:28:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kate Hsuan X-Patchwork-Id: 15147 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 82441BDB13 for ; Mon, 13 Dec 2021 12:29:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3817460876; Mon, 13 Dec 2021 13:29:12 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="EGsmi/IV"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DA8B260868 for ; Mon, 13 Dec 2021 13:29:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639398548; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oWbbP0pnhflyXUZ1BcnJd7E7Q+3qi1E1Q7n9qp81vUI=; b=EGsmi/IVQg5GiTUMTEsfLvRY/LUch4P8qpQckYNAL3aAXd+xK0OPRBnEh/mnbgBup/edIU L4gu8cih0zLX6mYXcKiTHm2dCymUKXToJ3kp1TV91EQ3eL+avj23gKdE/tQOJnlN72+wNu 8woetRa6B4HrxXB5KHxVUWsirFslSL8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-133-jc8ioAYwO5yqBGaYndzIMg-1; Mon, 13 Dec 2021 07:29:07 -0500 X-MC-Unique: jc8ioAYwO5yqBGaYndzIMg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5A119100D680 for ; Mon, 13 Dec 2021 12:29:06 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.39.193.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20024794A3; Mon, 13 Dec 2021 12:29:03 +0000 (UTC) From: Kate Hsuan To: libcamera devel Date: Mon, 13 Dec 2021 20:28:46 +0800 Message-Id: <20211213122847.26260-1-hpa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hpa@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [libcamera-devel] [RFC v4 0/1] ipa: ipu3: af: Auto focus for dw9719 Surface Go2 VCM X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" In v4, a two-pass AF searching scheme is proposed to reduce the searching time and improve the focus quality. In the beginning, the AF searching step is 10 so an approximate AF range can be found and pass this small AF range to pass two search. In pass two, the searching step is reduced to 1 so the variance of every step in this range can be tested and find the local maximum variance. Eventually, the focus step with the largest variance is the focused lens position. To reduce the searching time, since we only can find the largest variance for a given image, if a negative gradient is found, the searching can be terminated immediately to eliminate the unnecessary searching and reducing the searching time. IPU3 AF accelerator provides low pass and high pass filtered convolution results. This information can be used to perform coarse and fine searches for the focused image. Low pass convolution results are used for coarse search and the high pass filtered convolution results are used for fine search. Through these convolution results, the quality of a focused image is also improved. Kate Hsuan (1): ipa: ipu3: af: Auto focus for dw9719 Surface Go2 VCM src/ipa/ipu3/algorithms/af.cpp | 334 ++++++++++++++++++++++++++++ src/ipa/ipu3/algorithms/af.h | 66 ++++++ src/ipa/ipu3/algorithms/meson.build | 3 +- src/ipa/ipu3/ipa_context.cpp | 27 +++ src/ipa/ipu3/ipa_context.h | 11 + src/ipa/ipu3/ipu3.cpp | 2 + 6 files changed, 442 insertions(+), 1 deletion(-) create mode 100644 src/ipa/ipu3/algorithms/af.cpp create mode 100644 src/ipa/ipu3/algorithms/af.h