From patchwork Fri Nov 26 00:31:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 14788 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 94B37C3250 for ; Fri, 26 Nov 2021 00:31:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2485560128; Fri, 26 Nov 2021 01:31:37 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PLGekzFb"; dkim-atps=neutral Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5FDFA60442 for ; Fri, 26 Nov 2021 01:31:31 +0100 (CET) Received: by mail-wm1-x32d.google.com with SMTP id az34-20020a05600c602200b0033bf8662572so5740110wmb.0 for ; Thu, 25 Nov 2021 16:31:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bZVKkt1twe0fHtrI7EWid1fVCYFD2Bw6ZSsYAt/eJoI=; b=PLGekzFbOzSnWsGUE30E0SKMTw2cOc62QI1NBLKjKU9mkeICWrSQwmBlSjcUkwDjt9 5CXNcFZRezttu51A4CanzaGCrPQarInlVfFQVIC++Uhs4l5iRk7dNLZL0vFRPZ9f+bxP M84jtmfK7Q/AFSjFFX8Wn36Oac/75t2KbHx384YkMrFYove4VA1uuCkzjCKGV6LR5IDu VIrElDEVQRkK6kczssAjhRYd7NhXTAYGM6YtHJTZGliaaKHeyBlaA0IuDUexrm03Tanf uDCBRXsYiifHAibxDoWcF7Wa/efXRk7XKyS5lkBD71ClQcKycmYFrgRp5DzR0Y+AA0EJ jPDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bZVKkt1twe0fHtrI7EWid1fVCYFD2Bw6ZSsYAt/eJoI=; b=eidFLN/PCmj0Jxsz9Oh+f9ci1u/WK1JwgycEJIioJzb5Enst4tLU/unCj5B2OL4J2Z ip2pzzyjb6uCaA1RHH7PIVbGq5CRkUl6uoSFg3W2pJhyArsdfwgCpCdBnQQk7UXUSUHb LzQLo2+ZQFfeGOuDM8BImdce/QWAs3Eea0iFKxox3kGFZ5nHSEUd5/gwmsIJNIg7EYHT nRNb9SumjIu2SEtMR7NHciI1XoTNiZJwGuXR4Cgy4F6t/9RhZVQ/xXR5s8BVmHodxH10 SuWTjlYI/30vCyJoJdsJDhb6cM4FMwJICOGf4II6vZdIBq6fp7LJh1P7sTzgm4ApnaKO zIYw== X-Gm-Message-State: AOAM531KAPLbH9OKEcTEB5yuqLHEUyeqHiI8jSJLx/GEi3Bv6We7tSsa 5fXF12zkBuawMiwtUXsiO4yZcYHEf7o= X-Google-Smtp-Source: ABdhPJxYe3DiW79GymGq1R7ghGkljJwRbQzmkX9+oIgOjTsem/fjVFP1U+hkuTjOPF2mAXvLYO8bCQ== X-Received: by 2002:a05:600c:224a:: with SMTP id a10mr11882982wmm.154.1637886691161; Thu, 25 Nov 2021 16:31:31 -0800 (PST) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id b188sm4381455wmd.45.2021.11.25.16.31.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Nov 2021 16:31:30 -0800 (PST) From: Daniel Scally To: libcamera-devel@lists.libcamera.org Date: Fri, 26 Nov 2021 00:31:18 +0000 Message-Id: <20211126003118.42356-6-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211126003118.42356-1-djrscally@gmail.com> References: <20211126003118.42356-1-djrscally@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/5] ipa: ipu3: af: Remove v4l2 interaction from AF algorithm 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" Now that the actual interaction with the VCM's V4L2 subdev can be done through the CameraLens class, remove it from the auto focus algorithm code. Signed-off-by: Daniel Scally Reviewed-by: Kate Hsuan --- src/ipa/ipu3/algorithms/af.cpp | 29 +---------------------------- src/ipa/ipu3/algorithms/af.h | 3 --- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp index 2859a6a8..1bbf64aa 100644 --- a/src/ipa/ipu3/algorithms/af.cpp +++ b/src/ipa/ipu3/algorithms/af.cpp @@ -66,17 +66,10 @@ static constexpr double MaxChange_ = 0.8; Af::Af() : focus_(0), currentVariance_(0.0) { - /** - * For surface Go 2 back camera VCM (dw9719) - * \todo move to control class - */ - vcmFd_ = open("/dev/v4l-subdev8", O_RDWR); } Af::~Af() { - if (vcmFd_ != -1) - close(vcmFd_); } void Af::prepare(IPAContext &context, ipu3_uapi_params *params) @@ -169,25 +162,6 @@ int Af::configure(IPAContext &context, [[maybe_unused]] const IPAConfigInfo &con return 0; } -/** - * \brief Send focus step to the VCM. - * \param[in] value Set lens position. - * \todo It is hardcoded here for the dw9717 VCM and will be moved to the - * subdev control in the future. - */ -int Af::vcmSet(int value) -{ - int ret; - struct v4l2_control ctrl; - if (vcmFd_ == -1) - return -EINVAL; - memset(&ctrl, 0, sizeof(struct v4l2_control)); - ctrl.id = V4L2_CID_FOCUS_ABSOLUTE; - ctrl.value = value; - ret = ioctl(vcmFd_, VIDIOC_S_CTRL, &ctrl); - return ret; -} - /** * \brief Determine the max contrast image and lens position. y_table is the * statictic data from IPU3 and is composed of low pass and high pass filtered @@ -263,10 +237,9 @@ void Af::process(IPAContext &context, const ipu3_uapi_stats_3a *stats) if (focus_ > MaxFocusSteps_) { /* If reach the max step, move lens to the position and set "focus stable". */ context.frameContext.af.stable = true; - vcmSet(context.frameContext.af.focus); } else { focus_ += MinSearchStep_; - vcmSet(focus_); + context.frameContext.af.focus = focus_; } LOG(IPU3Af, Debug) << "Focus searching max variance is: " << context.frameContext.af.maxVariance diff --git a/src/ipa/ipu3/algorithms/af.h b/src/ipa/ipu3/algorithms/af.h index d32d5184..b21084e9 100644 --- a/src/ipa/ipu3/algorithms/af.h +++ b/src/ipa/ipu3/algorithms/af.h @@ -36,9 +36,6 @@ public: void process(IPAContext &context, const ipu3_uapi_stats_3a *stats) override; private: - int vcmSet(int value); - - int vcmFd_; /* Used for focus scan. */ uint32_t focus_; /* Recent AF statistic variance. */