From patchwork Mon Jun 5 09:14:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18706 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 C64D8C328F for ; Mon, 5 Jun 2023 09:14:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BAD9062894; Mon, 5 Jun 2023 11:14:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1685956491; bh=ruCIXVqD07bh5LsU1/tK830Am0RiJr3CrtaFauP7UHQ=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=nMI49ciidYFM5SMWklke7pyQSi/1pnoRnIQRUtlJYJWYU/LflFfnn4xIaHvwthZ60 UECydE9ZlWamiR/OXWf3cZNJVQ269SaLfKV4R0YwjDeHye6U4sJdxvlMv0zWS1x7jA LhI2nwPE9I5DNds+dRn4A8tfApruegAzpXwl2evRZcv8qWEqezh0vz+6A2IGNzIUQ7 iGxVFQFYiX1SjWlnmJJkY76iWy5v54YTEIhqluZZWQcpFXeWsU2N3zOEVBcnBT/3vG hLCQJ8W2IK4tk/azYdZyJHhK8QlubnV+PHp7+Go5aGQZkpZwEXPai3zMO/gdoJV6Uv 7oWgEvLyHqHcg== Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AE7CA62885 for ; Mon, 5 Jun 2023 11:14:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="kAKuMK/O"; dkim-atps=neutral Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3f6e1393f13so38020125e9.0 for ; Mon, 05 Jun 2023 02:14:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1685956488; x=1688548488; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AFumYtvjDfTfPcCzPY8h7kvd3jEx3vvM8zqSEr5CJEM=; b=kAKuMK/O5Jj8Oncb5c5/Advdf99BYCnwoUeJBQ02Rb4Ntq0mcNwEnxODaOFjcpIvHX +K25sT6wrCerwPBvQBsCANw5UUT4RJ8JEXPJxZ5yxiFWxqI2o1N1NLl2u8XklgqZ3xxe Wgn5vUeSI7g5WNA30vbE/DHfO23sEgxQKXdmvu4MStKTQtdf5g94e+KZ9Sl9OhKBKCJ7 1mBwULQyeYxsv1CMUMkQ7VN/Ghug6qUXEzYENeW32bT+ubNMRRFkYSYuxYAktRQLGvF1 skbO4ZcCXPs1eYM1JhZG3nH/scKSU1r207gexkjWNw/gNR89/GlbFprq9jcHzAVHQsa2 AHbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685956488; x=1688548488; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AFumYtvjDfTfPcCzPY8h7kvd3jEx3vvM8zqSEr5CJEM=; b=FjkTZnlwsdsGXNGhQ8+zbaYhkK353pL6YL1Ra/QE4YyK+PPuo+DS91ztScyPd2KHGy UsKB6RWVxzzW4JhozGZ6Y7OzhWizv0IFzO/zUYR5CI6SCLBxc1NBbFLfU2ON+3Peftam vyCxWiVy8QdnygRORY4iv86+tNCXRmW/vhskEYaxELKAvyhCH4aSHKFvvr5zVsk2Oz/Y dTvhz2bJpZzHbe1N+WJiGV5Suwaj2lrp1jTr6gJiVwBM93Wo7+Dflvr1hwD0iveluMA/ jatdQqp2VgsebtxGfrbC04wQvDFNoLEMa0eYgOp05SElek6DER+Aq/teaeiIefY/atcj XU2g== X-Gm-Message-State: AC+VfDy9PjlqtDWwuJySvgSJBdgd2XQpJp7BOjoQ9fbel9/THQDSGw+e RWkl3u6kMIzrMDmSwySVMApA5+SwcQglWZkaW2h4cQ== X-Google-Smtp-Source: ACHHUZ4q3rwMV2xpaVL4b7gDqiyx96hwAobIckdCEIeYcT3I0AJ+XEREW31eM4s9kQJXD0FQGlCdUg== X-Received: by 2002:a1c:7405:0:b0:3f4:bb58:d174 with SMTP id p5-20020a1c7405000000b003f4bb58d174mr6303365wmc.22.1685956488167; Mon, 05 Jun 2023 02:14:48 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id z16-20020a7bc7d0000000b003f605814850sm13776369wmk.37.2023.06.05.02.14.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jun 2023 02:14:47 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 5 Jun 2023 10:14:06 +0100 Message-Id: <20230605091406.31757-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230605091406.31757-1-naush@raspberrypi.com> References: <20230605091406.31757-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/3] ipa: rpi: Set lens position to hyperfocal on startup 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" On the first ipa->configure() call, set the lens position (if a lens is present) to the default position. Typically this would be the hyperfocal position based on the tuning data. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/ipa/rpi/common/ipa_base.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp index 599ad146a863..dbb95311ba51 100644 --- a/src/ipa/rpi/common/ipa_base.cpp +++ b/src/ipa/rpi/common/ipa_base.cpp @@ -199,6 +199,23 @@ int32_t IpaBase::configure(const IPACameraSensorInfo &sensorInfo, const ConfigPa agcStatus.shutterTime = defaultExposureTime; agcStatus.analogueGain = defaultAnalogueGain; applyAGC(&agcStatus, ctrls); + + /* Set the lens to the default (typically hyperfocal) position on first start. */ + if (lensPresent_) { + RPiController::AfAlgorithm *af = + dynamic_cast(controller_.getAlgorithm("af")); + + if (af) { + float defaultPos = + ipaAfControls.at(&controls::LensPosition).def().get(); + ControlList lensCtrl(lensCtrls_); + int32_t hwpos; + + af->setLensPosition(defaultPos, &hwpos); + lensCtrl.set(V4L2_CID_FOCUS_ABSOLUTE, hwpos); + result->lensControls = std::move(lensCtrl); + } + } } result->sensorControls = std::move(ctrls);