From patchwork Thu Jun 1 09:56:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18677 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 A850AC32AA for ; Thu, 1 Jun 2023 09:56:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3A684627DE; Thu, 1 Jun 2023 11:56:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1685613396; bh=TICam9Xow+7nKhdnrxp8fr9f4L4r0ZdGSO5qtTt2U78=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=LMpyK+5tq369FIvtz7jwPS1DHVuaBs7Xo4zoL1OBK3ju1gpruK4LYejDtQrbyek1x y20NzgRS0Tcir93NvourGYz1Pl6us4OBTjphHzFz2vYzlPzTB7xpQQK9DIhfkbOAad joNIrs1hWWVmUynGWw8YP97jHdX61siykyoOgHtN1f03PsYm4fdxDEWNm8ZYhM+uEa drE3q2gp2DjL0T+PIxhwJxIYTDtSNz4NQ7insl5Qa9TOu+FJLCDGokE3JAKr76K2fx 9BQDxJuOVhiu53zh1B5Bj9yx9OGYwkyLzJirey4qfQ6O12tpuMGbDJmJghL3e0Wv9k o22fO2UT6+DNg== Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2214762754 for ; Thu, 1 Jun 2023 11:56:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="qcMqZPXI"; dkim-atps=neutral Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-30ae5f2ac94so636538f8f.1 for ; Thu, 01 Jun 2023 02:56:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1685613393; x=1688205393; 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=8ywRezXbvi/BA/1IZZMKl3g8qVoYLTXJyaq0/tA+OrQ=; b=qcMqZPXIgoPMAuH+DmDavoNI6l6LHdmQkJr/YjRM1oBjmq+rKfW/ybFuEQWq9ZvQjA cu5LosUr2Lvjev9/RsQETS61vo6dK3MBlWIaJ6Be6Cu/FjlG8pfZBXuz2AN6evMGqJn/ FaT1eVbkpqaRwHAMxsSjxDNkLNFppsJmrLPs1mU0ghhX+u29svNB78aBIMC9sIhcGya8 IxjSFeeMRoE9i/gyqe9LrHLXEdsHwNfzuLo5O1fneJ9Jz4cfAlrDmKWKInloroJUTu+L sazbNwGGmjx4cg9tYAQPBVMjonm85IlUSupYtPiPddV9ehPjWH1fqvvKU7OOZ9BnyXs3 Pr7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685613393; x=1688205393; 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=8ywRezXbvi/BA/1IZZMKl3g8qVoYLTXJyaq0/tA+OrQ=; b=I8A1owoifdMHGRrWOFwC6xYSz2I/3twgAlLkveophEM/RULxufg+eIM0rC105NbEE+ MR0w5Qo75wD/bIaWVVqhqX1Hhu+sLQsP1L5prIesMghzYliceLBi/ZhX0sJF8RSUvzd3 ocHzctR/LbDgJmQcst09gSoQIsv8713uSlPwjuCVKL3rFttx0MdFnp9kVY1YDXbs/ZSu dIPDMtAv/pDhSQookrnrYLAV5Kh96QmY67SRUyYvmj5tFJtoOhSC46LhCo48cr0jmavZ CNj9WCfCU5IUFVOVwFD/8ki/F7WLY4GxpqC6h0hIVrmoEWDJD45sSP05exaKvgivNeg5 ZhiA== X-Gm-Message-State: AC+VfDyt9PvfLwFsHli/M+jR/P2wiwRL1Dg+nrk+cobfuvHglXQ4oXDi Bsb3fiyUZEnleOZgMOIFOfgCVJ1yVnx2L+PWydgDAg== X-Google-Smtp-Source: ACHHUZ4N7ZzVRFIP7oC5913LksPTOLP2Or05BjXoBi+gjxf+T2QR5uh+BdpJfk89p9pDWp405KzHYw== X-Received: by 2002:adf:e785:0:b0:30a:e87b:515b with SMTP id n5-20020adfe785000000b0030ae87b515bmr1750497wrm.20.1685613393646; Thu, 01 Jun 2023 02:56:33 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h12-20020a5d6e0c000000b002ca864b807csm9889531wrz.0.2023.06.01.02.56.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 02:56:33 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 1 Jun 2023 10:56:30 +0100 Message-Id: <20230601095630.25443-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230601095630.25443-1-naush@raspberrypi.com> References: <20230601095630.25443-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 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 Cc: nick.hollinghurst@raspberrypi.com 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 --- src/ipa/rpi/common/ipa_base.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp index 599ad146a863..4413689b7bef 100644 --- a/src/ipa/rpi/common/ipa_base.cpp +++ b/src/ipa/rpi/common/ipa_base.cpp @@ -199,6 +199,19 @@ 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. */ + RPiController::AfAlgorithm *af = + dynamic_cast(controller_.getAlgorithm("af")); + if (lensPresent_ && 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);