From patchwork Thu Jan 19 10:45:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18149 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 E8F5BBD87C for ; Thu, 19 Jan 2023 10:45:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 25EC6625ED; Thu, 19 Jan 2023 11:45:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674125156; bh=JkcTM5Umb+cECJQuUWQyERqriHYrMgewZU5j8qC3h/I=; 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=Thwj1rtIONQW3kGAjbhYkGFK3Co6ekwNWvWGi2ahkInZaxqUmvXEm55v49eDXqHQH TO+haVKqg4cAoTIUxpvXbAAV6Unh1Jwky/8IOllFPb5NTPoJwsRye6T3waYmj1bile Yy9zLH94KEqW1upejpNI20ZpmEU6IjnqocEkl3nq1RBqEv9DhD6VmBfHds6hF4WwyG gXfdVTU2yeVReRZQlvBTvdt6VfYxHZYGUUSEcRmV+QzmlOTzXFFxtUXFrulcZ7wR4p UZplNshLGiXJIy57H0qTEsJsEypXVsTKQccZynPQOm3FJe5Lfz3HMbS8yZt1Hh4W9b 7Rl0iwa2afK9g== Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0895061EFC for ; Thu, 19 Jan 2023 11:45:53 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="GD0pMMEe"; dkim-atps=neutral Received: by mail-wm1-x333.google.com with SMTP id e19-20020a05600c439300b003db1cac0c1fso1770438wmn.5 for ; Thu, 19 Jan 2023 02:45:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=9jfLANeusc6CqNEiWhjZhKjeKnRVCnEagrhwvI6M960=; b=GD0pMMEeJ/KREVZCVs7p2IJJqeMld/HDbgtXCTNRaE09Md/L1D3LYTUXDDzjoY4F37 5qLSc+YfRBzKlhDkQNSxLIGyN/mFdwkPxfj2Z39Gdi6fbGu/Mkiavjbnv9sRPLrWn2n1 Ev0fJbd0P6pjjpu2X9wHnnH9mhFyOBijuge93fh1lyQ8uALOV+UKLAjsWLsprOrRNHD0 6sOiYGtB1MYH3L2sRGIgaoist/HEA4Tcw2X/6ADRPd2Vg52yqfY0I75M6EsTw0hVR/6D tlgxIIEmNLmbGDqoiyfm0LvUpk4c0whHjIHakU0o+w2uIr9l5ABK4CvOnjY4c4MrGx2B ifoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=9jfLANeusc6CqNEiWhjZhKjeKnRVCnEagrhwvI6M960=; b=7UC+w+YYkwTR8KPmmLotrJXXZbsM5ewOOfjWwVV3FbP+qWhngJ9JEHZa2uX+ATvmOg QaiKbuHEb9MwRQvLSMBRkQrSPiUpCIO+lmwWwoo8TEDhg8AIrA3MB6XbN70ZQeB2uxFc Zq/s7TnZve4pyAUjVRu+0ebp/gaug+BvHhFerFYQqE79k3Il4f6p5W63A1HTe9vWonB2 D1N/QO/u7E2bvDMciJ9TE0K9F0M5UeoLWVQbXfcrPuk5B0MJaO8CH56YSYs7djsOpGca IMY7FmdWjULatHgPJWSQKwllmHERZhiB8StacBhdNGqoeAQnklGjFtesX90ZGpUi0Pyf Sh2Q== X-Gm-Message-State: AFqh2koA4dTJEB+FsUKZhzAcxw1x7+JgnL6YDOc2v+qsrDKiC17OucvP 3sKhlFBymeWFplu3ymkByLr8WNFHtF+n4bPy8K8= X-Google-Smtp-Source: AMrXdXslQp4dPRhsgNrrb0go/CzD0Zcv6RdFPv2W5H3C4Nc4yfN46Ynt12zmSIE/O6ZamQCaOqifDw== X-Received: by 2002:a05:600c:1609:b0:3db:12a:5e65 with SMTP id m9-20020a05600c160900b003db012a5e65mr9735632wmn.4.1674125152419; Thu, 19 Jan 2023 02:45:52 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id be12-20020a05600c1e8c00b003db06224953sm5332029wmb.41.2023.01.19.02.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 02:45:51 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 10:45:31 +0000 Message-Id: <20230119104544.9456-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119104544.9456-1-naush@raspberrypi.com> References: <20230119104544.9456-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 01/14] pipeline: ipa: raspberrypi: Check if lens actuator is available 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 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Check if a lens actuator is available by the presense of the lens driver entity in the pipeline handler. Pass this result to the IPA on init. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Nick Hollinghurst --- include/libcamera/ipa/raspberrypi.mojom | 2 +- src/ipa/raspberrypi/raspberrypi.cpp | 7 +++++-- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index 189f978a5081..e7dabcbe5313 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -50,7 +50,7 @@ struct StartConfig { }; interface IPARPiInterface { - init(libcamera.IPASettings settings) + init(libcamera.IPASettings settings, bool lensPresent) => (int32 ret, IPAInitResult result); start(libcamera.ControlList controls) => (StartConfig startConfig); stop(); diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index bead436def3c..ec18497155ba 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -115,7 +115,7 @@ public: munmap(lsTable_, MaxLsGridSize); } - int init(const IPASettings &settings, IPAInitResult *result) override; + int init(const IPASettings &settings, bool lensPresent, IPAInitResult *result) override; void start(const ControlList &controls, StartConfig *startConfig) override; void stop() override {} @@ -158,6 +158,7 @@ private: ControlInfoMap sensorCtrls_; ControlInfoMap ispCtrls_; + bool lensPresent_; ControlList libcameraMetadata_; /* Camera sensor params. */ @@ -204,7 +205,7 @@ private: uint32_t maxSensorGainCode_; }; -int IPARPi::init(const IPASettings &settings, IPAInitResult *result) +int IPARPi::init(const IPASettings &settings, bool lensPresent, IPAInitResult *result) { /* * Load the "helper" for this sensor. This tells us all the device specific stuff @@ -241,6 +242,8 @@ int IPARPi::init(const IPASettings &settings, IPAInitResult *result) return ret; } + lensPresent_ = lensPresent; + controller_.initialise(); /* Return the controls handled by the IPA */ diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index f6303e60e1e6..62417669bdc5 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -32,6 +32,7 @@ #include "libcamera/internal/bayer_format.h" #include "libcamera/internal/camera.h" +#include "libcamera/internal/camera_lens.h" #include "libcamera/internal/camera_sensor.h" #include "libcamera/internal/device_enumerator.h" #include "libcamera/internal/framebuffer.h" @@ -1606,7 +1607,7 @@ int RPiCameraData::loadIPA(ipa::RPi::IPAInitResult *result) IPASettings settings(configurationFile, sensor_->model()); - return ipa_->init(settings, result); + return ipa_->init(settings, !!sensor_->focusLens(), result); } int RPiCameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::IPAConfigResult *result) From patchwork Thu Jan 19 10:45:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18150 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 B20A7C3294 for ; Thu, 19 Jan 2023 10:45:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 695D3625F3; Thu, 19 Jan 2023 11:45:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674125159; bh=VkG44ZZbKdX0I/UwM1bWgbMb/GHfQtEotZ7EzpVw5aI=; 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=q2wq2ISiqlhpuRvA1hU9kIOCjiemDhWvvmR6vZqAQcLEN36Zw83a0SQo6vz3BoIKW qEIqfhF+1Yc7NeI4BniZTHdQFO5t22cq9RZSKbGLD/3GBRogF4v6HyedMfCAkBDE9B YNbZ5If8RbY1TThlgNRQMNEakSNqiEdbPexvLFwwnGUtFqnU4PmwEOyCY4ODOOfMuB UCFXnkOvrvFhH6+FLpv0nXP8BoM5aFycFS3SGcd/JQoLRjUfrFccW99hTuzalDXlb/ TRg+cE0e5128TsCAj17gHokjnTjeG1S54SWLG2udNBrmO4RE5ELZ5t6zzNYsQVyMgJ VlDHYnCVv7njQ== Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BEDE761EFC for ; Thu, 19 Jan 2023 11:45:53 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="VV0s3hGD"; dkim-atps=neutral Received: by mail-wm1-x336.google.com with SMTP id q10-20020a1cf30a000000b003db0edfdb74so2561437wmq.1 for ; Thu, 19 Jan 2023 02:45:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=ln2wGHCJj71TM15zY2blAqeWIH4Mu4eKQ4MgaUd2zIQ=; b=VV0s3hGDB8sb+2zhiAULzzjdivhl6Uzxi/Cl6yEJFeFIxwUbQJH8yO8k3GF1G7/m3h gL4bUfZv0vbKXY4XvlBd/gWuwoY5Oq6K7t1fxGI9selrI3Qbm9D5aKV/vAIg8jFGItGs uX2oZdHGnVaaDTdM1iZp5Lx/r1NHa6aKwVd4W1S2/TWMLuEXYjzqlUAfh7NPPz/8ngYN +5MlRxh6aJXbq8lOEKczd1gNzAHBRyPQQ4BrKParWaTUDxONVjwYTPALvW5P1vUUXbcn kzO6LhmfDIBswHQMVcdzuMmn2V5ZMeLbywbstjXWL0uM5IH/qiaa4ovts54/v/tVIWOr VIag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ln2wGHCJj71TM15zY2blAqeWIH4Mu4eKQ4MgaUd2zIQ=; b=dMGUv8y9Yu5lYROQswUgddJieU3nHkNIgem40GYcZyF7kPQ+QaniuoGvr1N8nTPdXb wImCXnovwI+X/tn66MceyV9Ce7JAJr8zKV6n9+OYGc3pZo6YZcl96q85lHBLTqeph9Su s8RnXnZbaXfoT9EfX57yMKgsN/Iw0HqyKu+CdsI4iPOv+vhw1TgwOKGaDkiVdikZf4gw 5dPOQn67selVtA/2xq+BTvmjb0A3spwbNFxuHgKoGMRh/n1VhGaXBSEZCafA6ny4mwua EWStaDoUizd1TrQKH4FPPDc+4nUhesAGF1GU0BZn5vBb8HkON1w40RoeAhai9f13z04B a3bQ== X-Gm-Message-State: AFqh2kraN1uANaHGZ8CMyLQ2oc/QwYa3YRSWaR7r+XUL/RSs4BV2/dcV UJ6yP3KNmJ/PAxPD60+JjLemTnk30Z1bgQNZaVw= X-Google-Smtp-Source: AMrXdXtbRAuKW2L1TUkB6S7o42JYCRg64/BJ0OgtoCcPYld/lkClIscvP1IGVqAULEt1XpjQJlz9XA== X-Received: by 2002:a05:600c:4248:b0:3d9:7667:c0e4 with SMTP id r8-20020a05600c424800b003d97667c0e4mr9781838wmm.31.1674125153111; Thu, 19 Jan 2023 02:45:53 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id be12-20020a05600c1e8c00b003db06224953sm5332029wmb.41.2023.01.19.02.45.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 02:45:52 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 10:45:32 +0000 Message-Id: <20230119104544.9456-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119104544.9456-1-naush@raspberrypi.com> References: <20230119104544.9456-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 02/14] pipeline: ipa: raspberrypi: Remove unused streamConfig 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 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Remove the streamConfig parameter from the ipa::configure() call, it is never used. Signed-off-by: Naushir Patuck Reviewed-by: Nick Hollinghurst Reviewed-by: David Plowman --- include/libcamera/ipa/raspberrypi.mojom | 2 -- src/ipa/raspberrypi/raspberrypi.cpp | 2 -- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 13 +------------ 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index e7dabcbe5313..0732496968ed 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -59,7 +59,6 @@ interface IPARPiInterface { * \fn configure() * \brief Configure the IPA stream and sensor settings * \param[in] sensorInfo Camera sensor information - * \param[in] streamConfig Configuration of all active streams * \param[in] entityControls Controls provided by the pipeline entities * \param[in] ipaConfig Pipeline-handler-specific configuration data * \param[out] controls Controls to apply by the pipeline entity @@ -75,7 +74,6 @@ interface IPARPiInterface { * pipeline handler to the IPA and back. */ configure(libcamera.IPACameraSensorInfo sensorInfo, - map streamConfig, map entityControls, IPAConfig ipaConfig) => (int32 ret, libcamera.ControlList controls, IPAConfigResult result); diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index ec18497155ba..f748b6e2dac7 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -120,7 +120,6 @@ public: void stop() override {} int configure(const IPACameraSensorInfo &sensorInfo, - const std::map &streamConfig, const std::map &entityControls, const IPAConfig &data, ControlList *controls, IPAConfigResult *result) override; @@ -382,7 +381,6 @@ void IPARPi::setMode(const IPACameraSensorInfo &sensorInfo) } int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, - [[maybe_unused]] const std::map &streamConfig, const std::map &entityControls, const IPAConfig &ipaConfig, ControlList *controls, IPAConfigResult *result) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 62417669bdc5..272767b5263b 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1612,20 +1612,9 @@ int RPiCameraData::loadIPA(ipa::RPi::IPAInitResult *result) int RPiCameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::IPAConfigResult *result) { - std::map streamConfig; std::map entityControls; ipa::RPi::IPAConfig ipaConfig; - /* Inform IPA of stream configuration and sensor controls. */ - unsigned int i = 0; - for (auto const &stream : isp_) { - if (stream.isExternal()) { - streamConfig[i++] = IPAStream( - stream.configuration().pixelFormat, - stream.configuration().size); - } - } - entityControls.emplace(0, sensor_->controls()); entityControls.emplace(1, isp_[Isp::Input].dev()->controls()); @@ -1655,7 +1644,7 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::IPA /* Ready the IPA - it must know about the sensor resolution. */ ControlList controls; - ret = ipa_->configure(sensorInfo_, streamConfig, entityControls, ipaConfig, + ret = ipa_->configure(sensorInfo_, entityControls, ipaConfig, &controls, result); if (ret < 0) { LOG(RPI, Error) << "IPA configuration failed!"; From patchwork Thu Jan 19 10:45:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18151 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 32662BD87C for ; Thu, 19 Jan 2023 10:46:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id ECF9F625FA; Thu, 19 Jan 2023 11:46:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674125160; bh=xfPh4Disv4iEifN3/oiLgQOVZPel27wJl9JloUjFs6w=; 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=g7CAzrSyzZQAanKkyQXjkYzxClL93Kz9JrSPlH70HR4CTUGawnqBpDlU9xyXDTIzm 6qnBrz0Kz6Pvq9O0oYTiFBCxH76T8Sck7Y5RT0KdcFjwUKJDBiTqxWbaR0lJjV8S/B 0vX4CEIqTTeJN+KcDylSzvzuP2p8KecfUfTvyN+CBB8urb7Bg2+5Ne/N3gFu9BINbc eFPzMYrgGcwReOqSalWbAwo7JrrSXVNRKotwYeueL05SCEwVq9s8IGAFAM704KhB4d 5IPfQOJ7QMr+HjOFpv9oyYpJGp/dGFaB3WPoTLHo6qyj+154Zi+BfEkRPqEKOUBh8D iidpafIYTlgng== Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D2AC7625EA for ; Thu, 19 Jan 2023 11:45:54 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="FbbEYBJL"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id d4-20020a05600c3ac400b003db1de2aef0so929578wms.2 for ; Thu, 19 Jan 2023 02:45:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=ezly2RwbrTh/0/n2/4eff8d0vIHmHXT728mYO/WrJoo=; b=FbbEYBJL7pmI5YNGBxf/07v08Lr3TE61GrMeMg3s5lZdYnTcrETDZUfoNEOrlNfHTY IloZdo/8GVHWArxvRSxLgbuBaGiEulbBQU4Y0qJv6rlE70idoOPC6BXExBfTdR01neiJ NuC/eByKQOCiZDDUfvNW0ZQS1XETCwJjWUbvpFrdx9Kw1d6oO3QMgTV+DM73Mmr55ELJ g7BaOGm7+OF0c4tel+sMWOPGwPtRghVc1M2A+st0rwOPBAUNLC3IR3E5Lf0Bf6/ZC/DW 9X42vqqZtqlqNVokuS63rI0AkDII1v09fx0d7fT7ij1sjYbdrnSSowINwf/Qm5GG9WtC y6Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=ezly2RwbrTh/0/n2/4eff8d0vIHmHXT728mYO/WrJoo=; b=OPpRjqmIqwEeaoeDStJ66W7HG/CdLTxJu5COErHkD6s3JhU5B/z52IdvEDr4tP+F/t 6Kg9PsYIsV78PO00x9SumAIiDs4OyksCo8MB5J33NO2Lnm5DjMc35PkqAUuGAWo+sCC+ oyItiE+Hd1PgwphtdO23NafS2j/SJiGBGu3is6S6OLJ1s1RWEjf/GtJ1NNMHAFgxkeZ2 gRQG7nuE3n14S4HjXWacpdjWl51ZqjIGNBc6JS1gHwNLazhg5jSYepDOxsLt+Xz/UzEE ixGoYeEhRt2plpNyHtjE5gvTpd/+phSywH8pIFBpPH0JyMup2mHupZuKcWu9ml31IViV yE4g== X-Gm-Message-State: AFqh2koHphb/DfZfqc3gLoqKacv9ruc0Td+YyRnyvqpW9Sm1Egxv1XkI /gIEbYAM/8+NAHdAd2HwJx+9OS8TnM9NyXQh0Wc= X-Google-Smtp-Source: AMrXdXvCc40UAm8C7T0Z1zNusQ9VG5JdC/lXBUTDcxnqu09qSUJ2QsgFc4x3Ew+MIET1AYscyIfY8w== X-Received: by 2002:a05:600c:224b:b0:3d2:640:c4e5 with SMTP id a11-20020a05600c224b00b003d20640c4e5mr9842512wmm.8.1674125153842; Thu, 19 Jan 2023 02:45:53 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id be12-20020a05600c1e8c00b003db06224953sm5332029wmb.41.2023.01.19.02.45.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 02:45:53 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 10:45:33 +0000 Message-Id: <20230119104544.9456-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119104544.9456-1-naush@raspberrypi.com> References: <20230119104544.9456-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 03/14] pipeline: ipa: raspberrypi: Replace entityControls 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 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Replace the legacy entityControls map passed into ipa::configure() with explicit fields for sensor and ISP controls. This removes any ambiguity over which set of controls corresponds with specific integer keys. Signed-off-by: Naushir Patuck Reviewed-by: Nick Hollinghurst Reviewed-by: David Plowman --- include/libcamera/ipa/raspberrypi.mojom | 4 ++-- src/ipa/raspberrypi/raspberrypi.cpp | 17 ++++------------- .../pipeline/raspberrypi/raspberrypi.cpp | 7 +++---- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index 0732496968ed..2a4821fbc0ef 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -36,6 +36,8 @@ struct ISPConfig { struct IPAConfig { uint32 transform; libcamera.SharedFD lsTableHandle; + libcamera.ControlInfoMap sensorControls; + libcamera.ControlInfoMap ispControls; }; struct IPAConfigResult { @@ -59,7 +61,6 @@ interface IPARPiInterface { * \fn configure() * \brief Configure the IPA stream and sensor settings * \param[in] sensorInfo Camera sensor information - * \param[in] entityControls Controls provided by the pipeline entities * \param[in] ipaConfig Pipeline-handler-specific configuration data * \param[out] controls Controls to apply by the pipeline entity * \param[out] result Other results that the pipeline handler may require @@ -74,7 +75,6 @@ interface IPARPiInterface { * pipeline handler to the IPA and back. */ configure(libcamera.IPACameraSensorInfo sensorInfo, - map entityControls, IPAConfig ipaConfig) => (int32 ret, libcamera.ControlList controls, IPAConfigResult result); diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index f748b6e2dac7..aa18ed750370 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -119,9 +119,7 @@ public: void start(const ControlList &controls, StartConfig *startConfig) override; void stop() override {} - int configure(const IPACameraSensorInfo &sensorInfo, - const std::map &entityControls, - const IPAConfig &data, + int configure(const IPACameraSensorInfo &sensorInfo, const IPAConfig &data, ControlList *controls, IPAConfigResult *result) override; void mapBuffers(const std::vector &buffers) override; void unmapBuffers(const std::vector &ids) override; @@ -380,18 +378,11 @@ void IPARPi::setMode(const IPACameraSensorInfo &sensorInfo) mode_.sensitivity = helper_->getModeSensitivity(mode_); } -int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, - const std::map &entityControls, - const IPAConfig &ipaConfig, +int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, const IPAConfig &ipaConfig, ControlList *controls, IPAConfigResult *result) { - if (entityControls.size() != 2) { - LOG(IPARPI, Error) << "No ISP or sensor controls found."; - return -1; - } - - sensorCtrls_ = entityControls.at(0); - ispCtrls_ = entityControls.at(1); + sensorCtrls_ = ipaConfig.sensorControls; + ispCtrls_ = ipaConfig.ispControls; if (!validateSensorControls()) { LOG(IPARPI, Error) << "Sensor control validation failed."; diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 272767b5263b..9dd36cbaea78 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1615,8 +1615,8 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::IPA std::map entityControls; ipa::RPi::IPAConfig ipaConfig; - entityControls.emplace(0, sensor_->controls()); - entityControls.emplace(1, isp_[Isp::Input].dev()->controls()); + ipaConfig.sensorControls = sensor_->controls(); + ipaConfig.ispControls = isp_[Isp::Input].dev()->controls(); /* Always send the user transform to the IPA. */ ipaConfig.transform = static_cast(config->transform); @@ -1644,8 +1644,7 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::IPA /* Ready the IPA - it must know about the sensor resolution. */ ControlList controls; - ret = ipa_->configure(sensorInfo_, entityControls, ipaConfig, - &controls, result); + ret = ipa_->configure(sensorInfo_, ipaConfig, &controls, result); if (ret < 0) { LOG(RPI, Error) << "IPA configuration failed!"; return -EPIPE; From patchwork Thu Jan 19 10:45:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18152 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 454C4C3294 for ; Thu, 19 Jan 2023 10:46:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 758DD62601; Thu, 19 Jan 2023 11:46:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674125161; bh=pCYDqWG1bzsiLjnS9Uk+VA5sJ5mMkrThp7UsBsHq4y4=; 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=r8Nb+2FULls9ikox7Xt0aG9XPZzhMOLK5TDBcoLP3ZCN4h87OVvW1PfMbbpGYhM+l fNyea9DlbNcRbnEseKuwRGnq9qHaxT42UKRMvoU98Tl0eDQ7Aq3iRJHKTw50z4Tept vPK1l+kWDEcTst0mkk8anQvKByKIGdVotqA1yQel25yCcbbYVn9a40pbG7Hz/x9drt MP31GGzUMeFvEUpIclI93bOFDsYEFjr4594CZjrB43EY9ZAoGeHSnvMV+uUSP0wodK Mj0ogimoN14XQGZHPdefJVHb7ZIQroX02ZASJWGbYJwR+MSqnSLq+SfEFgHhK88g7C ISUrDvX+ld41A== Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1ABAC625E4 for ; Thu, 19 Jan 2023 11:45:55 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="kT2iMPgk"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id q8so1143517wmo.5 for ; Thu, 19 Jan 2023 02:45:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=gJvgKHIB0yXSef4zLViBaTt2sEAFd85mBvT5BPozY1Q=; b=kT2iMPgkULlfSgJT/y2xTAr0Xn6BP3vPXJp9j9od7CHhf7xo/WGXdmJnHyI+coOaxE mgHR5HEPlihGjWxwwH5A91zpnxvOccQnj7W0ikSTozLMsu7ksMmVqqh33hkiic22Lmvp nSHOXBkvK0kThwW+13DaMKhOWRsvmoK0KsujiCnMJ0CzAO3dltimQV/hLyS8zi/R9TVI 3+xJyKTIejnEPh9CRsDhfNMoIs0XEAuaIU4deR4nGYvRYq4qKC/dVitMRQ2O5ChZ6/i0 mJwXx30SMPNWXREhcLFVx6HXaOLjP6z4twAAw8Y+vRPkm49pp2H4lTcEtvRC8RdWIR7I YLQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=gJvgKHIB0yXSef4zLViBaTt2sEAFd85mBvT5BPozY1Q=; b=kswHTM7195VbNS/KzelRRCoXnreDxg3QX8ZcwAH4uPnPWE5WfZ1G3ctekPsKGpybQ1 PpFHzHNhnN4E/AEDxLhwb8P42ucZwHD2Nk2o8qAD6sdvN5UIVlwesdn0V/yzYgrsj9xz lgvw7nQ3c/iuuz4LzGWuSgNOKn+YN0Hs7qZLL3ZUJj8eaE8mqhR8kBVrKBUqiB6SJ0ej pV1Lo8dU1F5ANzzEuuXC5PNSrwQ/QWlTciKFoYm70CyidtA/ngJD7h/buE3FP+Ip0O37 SY1CVKam0EC81nfagcO9AR3Dd6a3NoKVSD/EmNVEfJYTv7XmsBZyAjQWnDWYpMjqZNAQ 6vcQ== X-Gm-Message-State: AFqh2kpCFRaPuISD24TKxfm+jHFZSWKRBZrPXCKvLOiM8m0pAqT5KScl dUk5T1fyGHtQonhLB5WIIEfhEJLLf0CHh4PDfjM= X-Google-Smtp-Source: AMrXdXuUhmxcxg7d4Y2Gui9n8QfE1CtDdFI9Aun6cixMeXhPR7fsW4UL3veKc5hCsC9NK1B1dGPd4g== X-Received: by 2002:a05:600c:4256:b0:3da:1d51:ef9e with SMTP id r22-20020a05600c425600b003da1d51ef9emr9713938wmm.17.1674125154549; Thu, 19 Jan 2023 02:45:54 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id be12-20020a05600c1e8c00b003db06224953sm5332029wmb.41.2023.01.19.02.45.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 02:45:54 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 10:45:34 +0000 Message-Id: <20230119104544.9456-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119104544.9456-1-naush@raspberrypi.com> References: <20230119104544.9456-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 04/14] pipeline: ipa: raspberrypi: Validate lens controls 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 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Pass the available lens controls to the IPA through the configure() function. Validate that the V4L2_CID_FOCUS_ABSOLUTE does exist. If it doesn't, log a warning message, and do not advertise focus related controls from the IPA. Signed-off-by: Naushir Patuck Reviewed-by: Nick Hollinghurst Reviewed-by: David Plowman --- include/libcamera/ipa/raspberrypi.mojom | 1 + src/ipa/raspberrypi/raspberrypi.cpp | 21 +++++++++++++++++++ .../pipeline/raspberrypi/raspberrypi.cpp | 2 ++ 3 files changed, 24 insertions(+) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index 2a4821fbc0ef..bfacd1275bfb 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -38,6 +38,7 @@ struct IPAConfig { libcamera.SharedFD lsTableHandle; libcamera.ControlInfoMap sensorControls; libcamera.ControlInfoMap ispControls; + libcamera.ControlInfoMap lensControls; }; struct IPAConfigResult { diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index aa18ed750370..bbf3c7dc4a69 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -131,6 +131,7 @@ private: void setMode(const IPACameraSensorInfo &sensorInfo); bool validateSensorControls(); bool validateIspControls(); + bool validateLensControls(); void queueRequest(const ControlList &controls); void returnEmbeddedBuffer(unsigned int bufferId); void prepareISP(const ISPConfig &data); @@ -155,6 +156,7 @@ private: ControlInfoMap sensorCtrls_; ControlInfoMap ispCtrls_; + ControlInfoMap lensCtrls_; bool lensPresent_; ControlList libcameraMetadata_; @@ -394,6 +396,15 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, const IPAConfig &ip return -1; } + if (lensPresent_) { + lensCtrls_ = ipaConfig.lensControls; + if (!validateLensControls()) { + LOG(IPARPI, Warning) << "Lens validation failed, " + << "no lens control will be available."; + lensPresent_ = false; + } + } + maxSensorGainCode_ = sensorCtrls_.at(V4L2_CID_ANALOGUE_GAIN).max().get(); /* Setup a metadata ControlList to output metadata. */ @@ -648,6 +659,16 @@ bool IPARPi::validateIspControls() return true; } +bool IPARPi::validateLensControls() +{ + if (lensCtrls_.find(V4L2_CID_FOCUS_ABSOLUTE) == lensCtrls_.end()) { + LOG(IPARPI, Error) << "Unable to find Lens control V4L2_CID_FOCUS_ABSOLUTE"; + return false; + } + + return true; +} + /* * Converting between enums (used in the libcamera API) and the names that * we use to identify different modes. Unfortunately, the conversion tables diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 9dd36cbaea78..249dedcd8c09 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1617,6 +1617,8 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::IPA ipaConfig.sensorControls = sensor_->controls(); ipaConfig.ispControls = isp_[Isp::Input].dev()->controls(); + if (sensor_->focusLens()) + ipaConfig.lensControls = sensor_->focusLens()->controls(); /* Always send the user transform to the IPA. */ ipaConfig.transform = static_cast(config->transform); From patchwork Thu Jan 19 10:45:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18153 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 7B8BBBD87C for ; Thu, 19 Jan 2023 10:46:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 36BC0625E7; Thu, 19 Jan 2023 11:46:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674125163; bh=Z7uwyphfvKrxAl1sUiyXPfIEf0yE2/sei9hxLIxwL5s=; 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=OuKzBUjrG4WZXamBBWfPD33BJjyiifQ1G0Q+cvZRDgfR+yU+J+y7xyZaAqR+FdWuD E6UhNTp/dM3BQsaodm2GCHEafCFwuzpkXr/E9r76YaJ2R30TOqdzTz08SFf594C6T5 NjpyPPAoEf6Oymiwee8zaT4vTjodudlycyCNGnT1noMoHfHZPy9DQ7GOmTmDuMPw+H Ov3r5gZhlyqVJ1MxbIQ8C2Vdt+4RHOKtzS9ynHJjSGffwCvEAi+94y9sdRZiayJU4D ahUljIQwcAV25Bw63/ur8uFDx2ndzOez8a+G8YuaESnNkIO02Zp9nfNf3OioJuuFGg NfBD5RUa/i2OA== Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CC884625D8 for ; Thu, 19 Jan 2023 11:45:55 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="F00HXyhx"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id f25-20020a1c6a19000000b003da221fbf48so930893wmc.1 for ; Thu, 19 Jan 2023 02:45:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=U1bnmtoEMhqsz9Hz00T1Qcn/t0Zjag+OzSmEPXGAjYY=; b=F00HXyhxa4U3TNhhneHXu8krzt3WvunE0DuiITPxiwnzV39JVPqew09ZckTUSy9UbO DDE3lfh9EGLWAaUrjWUZNUl52pS8zX8z0/ve9TqvTmJpny5jk3ACl7iGG4gISLHq5YSY wjJDYFSbyxLRGXdDMbsVLPLVHxG0A25TYTSEOgjSruNMzYJ0azJA9I+O48AopHjr6hf0 3j8L065HSGkTLYu62R0YJJmChg55cMFHryXXz4zmQl9DMKM7RrcDFTFLaVUc3bPazi0l gqyz/9am5olcemRPIwMPY5e0bCg2z94ek1qrnTCtZaRUYKcNxZ54Kp32eztTVbL7g8o7 MM0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=U1bnmtoEMhqsz9Hz00T1Qcn/t0Zjag+OzSmEPXGAjYY=; b=FN3WCLsL4o9kRp/7sESScr2qmomblNoec4vIUX1aRJY9NBjtDqakkiaRBW+FMA+/Cu /9rsMHpFp9eorvYHCZKCgeCh3b3ZF9uNh1KXbOtieOdfHAKXtwzNMtr8LEl2ofSKwcu3 1SsmdUn12nWQxHJzIg//Ckrmc3JtbRWahgylgmiJhSV8wZtXK2bs7wQYJulml7oEo2/b mIEQrmBGMpbbE+4o1rJ0YcqR6j5m5piYKMfufC0F4J3SlWPCLOhoLJ1GxeZC4w6hci+1 oD9uETNjr9peYCemy1qm5FMen+3/ZjRtTz5cunaUGhgk+4k2vPr3U7Zcd/CJFSYhvoUa b1Cg== X-Gm-Message-State: AFqh2koVwh3QMYBHaPnhJEYeWVFKquF0dUyykY7aca3ydBy819yluWBX rQoPLC3R9oK6wnPdo/hQ+Yki8ot6Qe5yahN2Jrs= X-Google-Smtp-Source: AMrXdXuacn+Spk4enVBpqsE/97tITtDC01cjIZmvbcFnYs/eN8A4xj19HMapxQi5R+uzbP4a60OIrA== X-Received: by 2002:a1c:7415:0:b0:3da:fd07:1e3 with SMTP id p21-20020a1c7415000000b003dafd0701e3mr9417615wmc.22.1674125155200; Thu, 19 Jan 2023 02:45:55 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id be12-20020a05600c1e8c00b003db06224953sm5332029wmb.41.2023.01.19.02.45.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 02:45:54 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 10:45:35 +0000 Message-Id: <20230119104544.9456-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119104544.9456-1-naush@raspberrypi.com> References: <20230119104544.9456-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 05/14] ipa: mojom: raspberrypi: Add setLensControls() function 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 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nick Hollinghurst Add a setLensControls() function to the IPA/pipeline handler interface. This will be used in a future commit to control the lens actuator position from an autofocus algorithm. Signed-off-by: Nick Hollinghurst Signed-off-by: Naushir Patuck Reviewed-by: Naushir Patuck Reviewed-by: David Plowman --- include/libcamera/ipa/raspberrypi.mojom | 1 + src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index bfacd1275bfb..8e78f167f179 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -131,4 +131,5 @@ interface IPARPiEventInterface { embeddedComplete(uint32 bufferId); setIspControls(libcamera.ControlList controls); setDelayedControls(libcamera.ControlList controls, uint32 delayContext); + setLensControls(libcamera.ControlList controls); }; diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 249dedcd8c09..77719db57e44 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -208,6 +208,7 @@ public: void embeddedComplete(uint32_t bufferId); void setIspControls(const ControlList &controls); void setDelayedControls(const ControlList &controls, uint32_t delayContext); + void setLensControls(const ControlList &controls); void setSensorControls(ControlList &controls); void unicamTimeout(); @@ -1589,6 +1590,7 @@ int RPiCameraData::loadIPA(ipa::RPi::IPAInitResult *result) ipa_->embeddedComplete.connect(this, &RPiCameraData::embeddedComplete); ipa_->setIspControls.connect(this, &RPiCameraData::setIspControls); ipa_->setDelayedControls.connect(this, &RPiCameraData::setDelayedControls); + ipa_->setLensControls.connect(this, &RPiCameraData::setLensControls); /* * The configuration (tuning file) is made from the sensor name unless @@ -1835,6 +1837,16 @@ void RPiCameraData::setDelayedControls(const ControlList &controls, uint32_t del handleState(); } +void RPiCameraData::setLensControls(const ControlList &controls) +{ + CameraLens *lens = sensor_->focusLens(); + + if (lens && controls.contains(V4L2_CID_FOCUS_ABSOLUTE)) { + ControlValue const &focusValue = controls.get(V4L2_CID_FOCUS_ABSOLUTE); + lens->setFocusPosition(focusValue.get()); + } +} + void RPiCameraData::setSensorControls(ControlList &controls) { /* From patchwork Thu Jan 19 10:45:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18154 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 4D458C3295 for ; Thu, 19 Jan 2023 10:46:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EAF63625EB; Thu, 19 Jan 2023 11:46:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674125164; bh=eACv0BMC4sIml13m6Dl1ayBXch/Gz9qY634FpBRZK7g=; 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=kdFjSAO57S52MpbPLXd18ptYuSbq09Y1RZbcO1Vg5O9E97ndl4N+dTx8liY1YoCWo qYvIEHzveRSbPH7riUrCv88VysBYPJM7o0faVmqVC85clq3R/oe/udpEaz342vL73p FGmR4J2CQjMHVU5rwUgr9hUM+4Z4ym/rzqglZSdJsZFAgD21TzCMQq3bybLHRZet5z CsT8Y15/kPLkJWs3gE7ZHNlntHAivg+DqgaiQqs9OtyGu2FW/xDKwfgXY5crD6SNyT wN7yCe8UjxLYgj3yklu9RIeApxOrQYGgzzTrgZLS1R5o10+Xnn2ZU1kdW/WnyrRYZO Dna+jiY70L8MQ== Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 087DB625E6 for ; Thu, 19 Jan 2023 11:45:57 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Qg897WW1"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id c4-20020a1c3504000000b003d9e2f72093so3268024wma.1 for ; Thu, 19 Jan 2023 02:45:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=+XOYlVwonbW9GffEkAtSqcC2zDy9aGi8XiunyvhmLkE=; b=Qg897WW1xClBlcb0Q9Zb4V06hcmJSWEZ797DEVvJeOuaU+ZwiPBxicjo18DyauTlWF fSZdFOGwCw6abj/ka694V7YFBO434KvvzSioErVJaiJ7JViwVA135uIJ7KzuHhtBvU3J EGJjNdTHVdYm7Bjt+dp+6tj11ZpoeWHeY6gHs5pliigz1O38ehKWn0d751oOKfqjyO2E AB+TxLmGaJlB2+7fen62kMHekK2RygC3W90DDB4J1QIQhLV9IZda6HIqHMeBdJW6NwGi PaQs0g1LzxabBpyfoWQtd4+X36jHg+9F8uELYWQ1yLgDUTa1MhZG4+xsEgVsS3u9XGrl qCHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=+XOYlVwonbW9GffEkAtSqcC2zDy9aGi8XiunyvhmLkE=; b=1YR/Lhk6iWNLIn01FQZOgwn0+pLdhY25/CsAPtaAml9Ed33L9SSvBDsiteM5DldLs8 t1cl09dWaHdhFIK9el8qTBu7tA9N8j9ndvYL4qnZnibhkQ54wQcO2mUiqO/fVYxB7v42 VmNVDsnrIvLSc/fupZVkzwOiHp1LVkH4YkaPh50gyG/0Md0SUnLlVWmSMyRmFmM3rpIa +JqUmK+myOA+wvpitxAt33NK7sX3HTgcxjbD7Wyf9OyJD22Kx3Dv7Ey6pYgsUDU6eUag SncyOLFNJf/fS8dvT+2vXy9wwu/QvPfa51MIW2PW+h5N3u7ZtwRBcn+1pmMt7VsJXOwX J7dw== X-Gm-Message-State: AFqh2krQ8fdad78dYNZ98ZrE0MNdiKBDs23+3Ts7fneywJUfctYPJUG0 tK8eeycqiDMrzM6jHUKeXwTXuTdF2ClIFEJWSdc= X-Google-Smtp-Source: AMrXdXu9MNOB2xcnYqlqnGl5WGIOIXpakmfgEdMXuv+ACoB0NVMve2LEuf9IGNhrMngHfgjado3tyQ== X-Received: by 2002:a05:600c:2056:b0:3db:ce8:6662 with SMTP id p22-20020a05600c205600b003db0ce86662mr7690807wmg.31.1674125155887; Thu, 19 Jan 2023 02:45:55 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id be12-20020a05600c1e8c00b003db06224953sm5332029wmb.41.2023.01.19.02.45.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 02:45:55 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 10:45:36 +0000 Message-Id: <20230119104544.9456-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119104544.9456-1-naush@raspberrypi.com> References: <20230119104544.9456-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 06/14] ipa: raspberrypi: Add autofocus algorithm interface headers 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 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nick Hollinghurst Add a new AfAlgorithm class that defines the interface for the Raspberry Pi autofocus algorithm. Add an AfStatus structure that returns the results of the autofocus algorithm back to the IPA. Add a structure for PDAF statistics provided by supported sensors for use with an autofocus algorithm. This structure is currently based on the IMX708's PDAF "Type 1" statistics. Signed-off-by: Nick Hollinghurst Signed-off-by: Naushir Patuck Reviewed-by: Naushir Patuck Reviewed-by: David Plowman --- src/ipa/raspberrypi/controller/af_algorithm.h | 76 +++++++++++++++++++ src/ipa/raspberrypi/controller/af_status.h | 35 +++++++++ src/ipa/raspberrypi/controller/pdaf_data.h | 21 +++++ 3 files changed, 132 insertions(+) create mode 100644 src/ipa/raspberrypi/controller/af_algorithm.h create mode 100644 src/ipa/raspberrypi/controller/af_status.h create mode 100644 src/ipa/raspberrypi/controller/pdaf_data.h diff --git a/src/ipa/raspberrypi/controller/af_algorithm.h b/src/ipa/raspberrypi/controller/af_algorithm.h new file mode 100644 index 000000000000..ad9b575450e3 --- /dev/null +++ b/src/ipa/raspberrypi/controller/af_algorithm.h @@ -0,0 +1,76 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2022, Raspberry Pi Ltd + * + * af_algorithm.hpp - auto focus algorithm interface + */ +#pragma once + +#include + +#include + +#include "algorithm.h" + +namespace RPiController { + +class AfAlgorithm : public Algorithm +{ +public: + AfAlgorithm(Controller *controller) + : Algorithm(controller) {} + + /* + * An autofocus algorithm should provide the following calls. + * + * Where a ControlList combines a change of AfMode with other AF + * controls, setMode() should be called first, to ensure the + * algorithm will be in the correct state to handle controls. + * + * setLensPosition() returns true if the mode was AfModeManual and + * the lens position has changed, otherwise returns false. When it + * returns true, hwpos should be sent immediately to the lens driver. + * + * getMode() is provided mainly for validating controls. + * getLensPosition() is provided for populating DeviceStatus. + */ + + enum AfRange { AfRangeNormal = 0, + AfRangeMacro, + AfRangeFull, + AfRangeMax }; + + enum AfSpeed { AfSpeedNormal = 0, + AfSpeedFast, + AfSpeedMax }; + + enum AfMode { AfModeManual = 0, + AfModeAuto, + AfModeContinuous }; + + enum AfPause { AfPauseImmediate = 0, + AfPauseDeferred, + AfPauseResume }; + + virtual void setRange([[maybe_unused]] AfRange range) + { + } + virtual void setSpeed([[maybe_unused]] AfSpeed speed) + { + } + virtual void setMetering([[maybe_unused]] bool use_windows) + { + } + virtual void setWindows([[maybe_unused]] libcamera::Span const &wins) + { + } + virtual void setMode(AfMode mode) = 0; + virtual AfMode getMode() const = 0; + virtual bool setLensPosition(double dioptres, int32_t *hwpos) = 0; + virtual std::optional getLensPosition() const = 0; + virtual void triggerScan() = 0; + virtual void cancelScan() = 0; + virtual void pause(AfPause pause) = 0; +}; + +} // namespace RPiController diff --git a/src/ipa/raspberrypi/controller/af_status.h b/src/ipa/raspberrypi/controller/af_status.h new file mode 100644 index 000000000000..92c088126733 --- /dev/null +++ b/src/ipa/raspberrypi/controller/af_status.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2022, Raspberry Pi Ltd + * + * af_status.h - AF control algorithm status + */ +#pragma once + +#include + +/* + * The AF algorithm should post the following structure into the image's + * "af.status" metadata. lensSetting should control the lens. + */ + +enum class AfState { + Idle = 0, + Scanning, + Focused, + Failed +}; + +enum class AfPauseState { + Running = 0, + Pausing, + Paused +}; + +struct AfStatus { + /* state for reporting */ + AfState state; + AfPauseState pauseState; + /* lensSetting should be sent to the lens driver, when valid */ + std::optional lensSetting; +}; diff --git a/src/ipa/raspberrypi/controller/pdaf_data.h b/src/ipa/raspberrypi/controller/pdaf_data.h new file mode 100644 index 000000000000..03c00d72c0e8 --- /dev/null +++ b/src/ipa/raspberrypi/controller/pdaf_data.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2022, Raspberry Pi Ltd + * + * pdaf_data.h - PDAF Metadata; for now this is + * largely based on IMX708's PDAF "Type 1" output. + */ +#pragma once + +#include + +#define PDAF_DATA_ROWS 12 +#define PDAF_DATA_COLS 16 + +struct PdafData { + /* Confidence values, in raster order, in arbitrary units */ + uint16_t conf[PDAF_DATA_ROWS][PDAF_DATA_COLS]; + + /* Phase error, in raster order, in s11 Q4 format (S.6.4) */ + int16_t phase[PDAF_DATA_ROWS][PDAF_DATA_COLS]; +}; From patchwork Thu Jan 19 10:45:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18155 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 5FF03C3294 for ; Thu, 19 Jan 2023 10:46:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E9471625F3; Thu, 19 Jan 2023 11:46:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674125164; bh=6QiQ8LXxvfQJDcU+RGtxXQ7BXahpitIEcnwEf9acUVo=; 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=XwRh1J4wGoxUlhJ2WkkMmCXG2Dgf+SDf34PWYek7dDMp5HS3+rBGn0Fpg4DtSn+xj wPT6yT/JCxwFUSsEqC9VQw81Ugiw0v/iUtrZoNuv5VKIyFmVo9oe3kvHXSXM1ehRzz t/XH+0mDj+RtEHHyTEPhMDOBI7lVMeiqo1gASBTHGmmVSZyRS1o8ljLUelpWrUjRI7 uDYpyAxtsol1MQq4ZEEmcCLOhO+P/iz6K1oriozPmsoTfhWkrE+5XK5KOjhEzwpPAj Mmn3Oc7fvNhgiFpvKh73xO3S8e8jKNoMCOYcVGmYMRPjyYjunky3K/5mYNBHa96bC1 jtHLFl+txeYKA== Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 26D2D625EB for ; Thu, 19 Jan 2023 11:45:57 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="VGP24m/g"; dkim-atps=neutral Received: by mail-wm1-x336.google.com with SMTP id q10-20020a1cf30a000000b003db0edfdb74so2561523wmq.1 for ; Thu, 19 Jan 2023 02:45:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=Cl/8YnqH9ui1lyE7NUbeUcj+KXrFqQQyHWxjNonkCPw=; b=VGP24m/gGP02An3Nc9djP7VPLTuSf+IlZgLkpzAE1zwl0Yvb5laxlvmebCg5goriU5 hJexLmlQVgA9DXylt9Fp4LJb+onXn01QwHkw5ijvkhj+T6L7dEgTXgAgUdsH8b3SJZfG KGSNT3CdvUH2X29/bs7Ne/0BUzAdea9gDv2E+upUlulce8iOurQuJ978+7ZZcxtFfC6J dBHf9+b3Ch0P47UrY+vG7ZtypgDdPPjjy6Uln3ji4hdqXF1wCTagYDLBSOYtjm0+pf5G wnrD5SJTLU7NnmXzSOYKH7ADD/HfeSYtduGxeRPr6AbIeEXxM8JRFBwGIESAY+G+ixjc 9YSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Cl/8YnqH9ui1lyE7NUbeUcj+KXrFqQQyHWxjNonkCPw=; b=mLMxxO2nfjcWkU39NVHRWy909gd7HCWx2qgDVRvgvKL8h+8wwvv1uUrt38mhPDnifg r+ioCS+Bz86/AdUpznP/epJsgc9fz0mAm3LoEA61eAD+UGVW1vdXdajJKCrpZKwk+Xiv U8rLL64LzzJlcMgvMFasv8bEprDwJ7nQnGjhGMYH3DkPUwhRJQuwllkMR4oOCBAAfDkw CuLm+PRxlpiFcq9H2Yhwn9aY0ycZNiYrRf97MK8DeiOuZQad0CJXEOhVwjaL1V87SuvW gfznB5vG87dZifIeaRrrz+GlsziUIqV6ho4MMvGWIAXfNGnDjjfuv5aDg7wIw11IWGwn aoRA== X-Gm-Message-State: AFqh2koVjNCtz8CcvzZp5Bqoyfk1KOS65CTarmVLSVkMNZQ6aCNieLvK Cio3Auo2HyG5gETV/njqc93IrUaoMw9oAjqe4Ss= X-Google-Smtp-Source: AMrXdXtAdeziHwYfT5qhca4eJ/g1q6gX4g5SW7gNScT28c1uKSsX1DHuBUoVqWFnrs1LyAcbvusX/Q== X-Received: by 2002:a05:600c:1e23:b0:3d9:103d:9081 with SMTP id ay35-20020a05600c1e2300b003d9103d9081mr5923132wmb.28.1674125156718; Thu, 19 Jan 2023 02:45:56 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id be12-20020a05600c1e8c00b003db06224953sm5332029wmb.41.2023.01.19.02.45.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 02:45:56 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 10:45:37 +0000 Message-Id: <20230119104544.9456-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119104544.9456-1-naush@raspberrypi.com> References: <20230119104544.9456-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 07/14] ipa: raspberrypi: Reorder header file inclusion 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 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Reorder the libcamera/request header file inclusion to match the libcamera guidelines. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Nick Hollinghurst --- src/ipa/raspberrypi/raspberrypi.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index bbf3c7dc4a69..18549420445b 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -23,10 +23,11 @@ #include #include #include +#include + #include #include #include -#include #include "libcamera/internal/mapped_framebuffer.h" From patchwork Thu Jan 19 10:45:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18156 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 06662C3296 for ; Thu, 19 Jan 2023 10:46:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7684E625EE; Thu, 19 Jan 2023 11:46:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674125165; bh=PcJOx2ozPgn+/h3v+0I2TaOSD5ltLOc0B5wmR8i/Xn8=; 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=ilxntvHUO5cM1NsXZTbgjQzjEiAiipOFT6nHdUsijzjdXwE0TMquhQzbEB3fkQaZF UB+w8MorTCbaLx7X5wecI+bF3B7M0f9xfuxxmTE0PXossMBEAiMb+8Lz8ABs2wWTzh TiaORhCwvYCRcn/Ymkso5Is/2YYPSDX1ln8+7bXWuFsrs/srsLvipAHKH1usA/GJfa 4BW012DAGDHHI+8GSdeCTvzv6eTonZQQ/T2DLyRyn63PJAcoEjjpCvs9KCi9kDXBxq 3j6oYF5/lwqPQaYySuIcvYss+lxokfyY5Jijuz2xj7hgSWLtX4R/NcCCiz7K6mx3Cb 6AKwYJU0bARWg== Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1B3FE625EF for ; Thu, 19 Jan 2023 11:45:58 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="H/zzEHaY"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id f25-20020a1c6a19000000b003da221fbf48so930970wmc.1 for ; Thu, 19 Jan 2023 02:45:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=fcT0+/4kJR0MUVvFlrqUk7hrKyJnbDdSh57uN7PeygU=; b=H/zzEHaYwqm+peG4T6US9BXHmP8qdBPEJVKw6p2QyJLuUZmrqOLG7innUsne8KAJHU fFTNLw5D1wUyHdy1lx9eJBU5/iCnOT1WI2Dy7NVp+gYkSI8qAsWhL0GzaZhsDqoIioL3 tj5B2xyy8pQWLoWezefWJEqdRckbgw51FTzA9Wq1UezFhjhSqMuaPge9dLfkCh6sEg8T 3F4fbiRBRyX/FOaDFYW6SslVSQgibSRww4Tpipt+OUWI05t5JjoTRqrwb1y48FPtQTa0 XiuW8EZ+zp8gxOswAgAL7SG2NYzAOTxRc327QyQDgxAvOp6ntl5uU8XC1jRyOGkrtzIg bnaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=fcT0+/4kJR0MUVvFlrqUk7hrKyJnbDdSh57uN7PeygU=; b=VjlwI24lVpqg9QRllJ+47xq6/lppZIeddpR4mxGIq5KEZUAb1ya/tUP/yfT2ZjLLs/ ELH1RzKOp/7CE5yv9F9d17++Zkk7EzWjqlEEUBfJWlq/Tp1g6oU4hIIYlRSYWvpVnI2r ThbXC1ZoloPiqMIdMhn7a5NBUcEQIv8RqaiI57BKLlkSZLNG0aoreDTVijVQcmIb/KMu +pBuKuzJhkepivSEIQSvU1wawxWXj4Ues0b9RDeonlLYGPSGUEiwabbWGHcBRh+7Vytr Jj4zt9734Mvnsw3X368fxZo3DgrJGj3cw1HceLSK2D6DOZId/qEUF6Iiz5xKljHTSnZo l/AA== X-Gm-Message-State: AFqh2kq5NBhtgv3Yam4FJwb04M2LAPlvGum3M4eZ6G+iJhicpPRXuo3s G6FDG22ZAIglfpJhPLot5uci/ZgX/ev1u29uP2U= X-Google-Smtp-Source: AMrXdXtic4aifSALl+aHsUN+8Bb3pCoHp745bh2BdTcz6wcDtyavpOyEdwn81XoQLDxyZPuE3YzzUQ== X-Received: by 2002:a05:600c:4d08:b0:3da:fef0:226b with SMTP id u8-20020a05600c4d0800b003dafef0226bmr9911553wmp.32.1674125157569; Thu, 19 Jan 2023 02:45:57 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id be12-20020a05600c1e8c00b003db06224953sm5332029wmb.41.2023.01.19.02.45.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 02:45:57 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 10:45:38 +0000 Message-Id: <20230119104544.9456-9-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119104544.9456-1-naush@raspberrypi.com> References: <20230119104544.9456-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 08/14] ipa: raspberrypi: Include autofocus controls in the IPA ControlInfoMap 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 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add all the autofocus controls handled by the IPA into the ControlInfoMap if a controllable lens actuator is present. Signed-off-by: Nick Hollinghurst Signed-off-by: Naushir Patuck Reviewed-by: Naushir Patuck Reviewed-by: David Plowman --- src/ipa/raspberrypi/raspberrypi.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 18549420445b..745c16f354ce 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -97,6 +97,18 @@ static const ControlInfoMap::Map ipaControls{ { &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) } }; +/* IPA controls handled conditionally, if the lens has a focus control */ +static const ControlInfoMap::Map ipaAfControls{ + { &controls::AfMode, ControlInfo(controls::AfModeValues) }, + { &controls::AfRange, ControlInfo(controls::AfRangeValues) }, + { &controls::AfSpeed, ControlInfo(controls::AfSpeedValues) }, + { &controls::AfMetering, ControlInfo(controls::AfMeteringValues) }, + { &controls::AfWindows, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) }, + { &controls::AfTrigger, ControlInfo(controls::AfTriggerValues) }, + { &controls::AfPause, ControlInfo(controls::AfPauseValues) }, + { &controls::LensPosition, ControlInfo(0.0f, 32.0f, 1.0f) } +}; + LOG_DEFINE_CATEGORY(IPARPI) namespace ipa::RPi { @@ -248,6 +260,8 @@ int IPARPi::init(const IPASettings &settings, bool lensPresent, IPAInitResult *r /* Return the controls handled by the IPA */ ControlInfoMap::Map ctrlMap = ipaControls; + if (lensPresent_) + ctrlMap.merge(ControlInfoMap::Map(ipaAfControls)); result->controlInfo = ControlInfoMap(std::move(ctrlMap), controls::controls); return 0; @@ -489,6 +503,10 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, const IPAConfig &ip ControlInfo(static_cast(helper_->exposure(exposureMin, mode_.minLineLength).get()), static_cast(maxShutter.get())); + /* Declare Autofocus controls, only if we have a controllable lens */ + if (lensPresent_) + ctrlMap.merge(ControlInfoMap::Map(ipaAfControls)); + result->controlInfo = ControlInfoMap(std::move(ctrlMap), controls::controls); return 0; } From patchwork Thu Jan 19 10:45:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18158 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 F1CF7BD87C for ; Thu, 19 Jan 2023 10:46:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 933E46260C; Thu, 19 Jan 2023 11:46:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674125166; bh=FwWs23/yLeIYaKR2QHxyiUmReWahysMWlCP0J/P5NkU=; 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=JRiZzGwXWv2qAbyc0tdeU5AFfQJLl1jTvJJzoDUz4y33mUu5SdxfQMQHxk1MIvnvu GQrSQifwM/JwJ30GsyuQiSOLAil0XAxQGce3MhKtQuLbj8KB6Rh/GX5P5B6gWpHVha tB3PbI4IsdbSKvdY99p57Cz6mxkhdN9sveMZHhll8lHihrDCoFUE8mDwIhsV0C1rs0 gHiyISunKLoxeuYUhiRBruZPrROkHFEnQIOZ/862SWLcZLbvTtGCzujwyca88C9hI+ qO2fNZmvr/NuH4883rKK+4fsEevWOH94V1ds1EOxTIDVJIH3Yq0VF8g5BYm6WhxKMk /McvCMzYAZzbw== Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D6F5A625E7 for ; Thu, 19 Jan 2023 11:45:58 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="EEk9IlBz"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id g10so1170170wmo.1 for ; Thu, 19 Jan 2023 02:45:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=4UYvcAZ8aQ9iDqO1x3vQcdFJHQPnJdXnBpdMdVUYWW4=; b=EEk9IlBzSrAUuynjqdmXZStL/VN1S9bS7jo05JFuvIPSJ28xZAH/ebq97EZZ7z1vtD 4lPy5EAhk5hj5bHFwjO4cybu4RcNG34hEQi7024Or3PqajRKaXAkGY80lu78Yuq4FVdk H5Aad89YRxj4Kg6Ga5JIQchsZnRNt4vfgfI+ckyUkIpLDqeBMZI7aauU+56M02ZLR6Ad Wm7ZSk12Gh2hcfMzy0ZHE/LMDEqrgNXxunZbBohMdCxORhD80q/7sdFBP9AdJdvfo9aa 6gZtcgKT1mPhUEfQh8Ibf66h3mVRsRj2cEqJTQPaTcpBFa5CNOv72J1cX/rnYPMyXQ2s 25Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=4UYvcAZ8aQ9iDqO1x3vQcdFJHQPnJdXnBpdMdVUYWW4=; b=Lu4sJB0U0+9Dlxrn9f8YL2L94Gr9lnNCGyr5vFQ93kNFqHpCjjDgCu6j22fZCI8aLb u+KVp/sCj/0fzEI8x+YJGvdBReYbwwNjcLPTfYPx2RZ/xCC4r/nsYEMjGlLRqXP8SD49 ClDa8TvK6cUPL4PPHJdgUZTwmNvHeIDeVfxnVm71DsPPR8OQVIzkRO6D5d6AMd+XjbpE fYCre32Cov8Wj8bhzScUXDnEflzWPw2SRlwRyBt0bfeZK8+BfE0A424wmqfuIH8uBKN8 uf5nxlEvUu/3dJousL1KI5bmADd1wU1FV3NfmbIs+tYTDQP0mf2gVINY+wGda0MRFv2D 4vzA== X-Gm-Message-State: AFqh2koKKVihyP9DA0iTlbkUX+MaVu6p4eRqYoOUlJoni0ghSzs+pgdr IjRDRKC67dhAo4LOb74VCtam0mAospbM7rt6kyI= X-Google-Smtp-Source: AMrXdXs0IKF4BOO+aT3L9MXS0PXVEHNlFc2wI3oca5vX6vARKdwWnCrP7W+xJS/9THA9ou6yn9RVXA== X-Received: by 2002:a05:600c:539a:b0:3d9:ef72:190d with SMTP id hg26-20020a05600c539a00b003d9ef72190dmr9705986wmb.19.1674125158292; Thu, 19 Jan 2023 02:45:58 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id be12-20020a05600c1e8c00b003db06224953sm5332029wmb.41.2023.01.19.02.45.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 02:45:57 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 10:45:39 +0000 Message-Id: <20230119104544.9456-10-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119104544.9456-1-naush@raspberrypi.com> References: <20230119104544.9456-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 09/14] ipa: raspberrypi: Handle autofocus controls 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 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nick Hollinghurst Add handlers for all autofocus related libcamera controls. Translate these controls to the RPiController autofocus algorithm API. Signed-off-by: Nick Hollinghurst Signed-off-by: Naushir Patuck Reviewed-by: Naushir Patuck Reviewed-by: David Plowman --- src/ipa/raspberrypi/raspberrypi.cpp | 144 ++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 745c16f354ce..0eb55ed605b6 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -31,6 +31,7 @@ #include "libcamera/internal/mapped_framebuffer.h" +#include "af_algorithm.h" #include "agc_algorithm.h" #include "agc_status.h" #include "alsc_status.h" @@ -732,11 +733,49 @@ static const std::map DenoiseModeTable = { { controls::draft::NoiseReductionModeZSL, RPiController::DenoiseMode::ColourHighQuality }, }; +static const std::map AfModeTable = { + { controls::AfModeManual, RPiController::AfAlgorithm::AfModeManual }, + { controls::AfModeAuto, RPiController::AfAlgorithm::AfModeAuto }, + { controls::AfModeContinuous, RPiController::AfAlgorithm::AfModeContinuous }, +}; + +static const std::map AfRangeTable = { + { controls::AfRangeNormal, RPiController::AfAlgorithm::AfRangeNormal }, + { controls::AfRangeMacro, RPiController::AfAlgorithm::AfRangeMacro }, + { controls::AfRangeFull, RPiController::AfAlgorithm::AfRangeFull }, +}; + +static const std::map AfPauseTable = { + { controls::AfPauseImmediate, RPiController::AfAlgorithm::AfPauseImmediate }, + { controls::AfPauseDeferred, RPiController::AfAlgorithm::AfPauseDeferred }, + { controls::AfPauseResume, RPiController::AfAlgorithm::AfPauseResume }, +}; + void IPARPi::queueRequest(const ControlList &controls) { + using RPiController::AfAlgorithm; + /* Clear the return metadata buffer. */ libcameraMetadata_.clear(); + /* Because some AF controls are mode-specific, handle AF mode change first. */ + if (controls.contains(controls::AF_MODE)) { + AfAlgorithm *af = dynamic_cast(controller_.getAlgorithm("af")); + if (!af) { + LOG(IPARPI, Warning) + << "Could not set AF_MODE - no AF algorithm"; + } + + int32_t idx = controls.get(controls::AF_MODE).get(); + auto mode = AfModeTable.find(idx); + if (mode == AfModeTable.end()) { + LOG(IPARPI, Error) << "AF mode " << idx + << " not recognised"; + } else + af->setMode(mode->second); + } + + /* Iterate over controls */ for (auto const &ctrl : controls) { LOG(IPARPI, Debug) << "Request ctrl: " << controls::controls.at(ctrl.first)->name() @@ -1028,6 +1067,111 @@ void IPARPi::queueRequest(const ControlList &controls) break; } + case controls::AF_MODE: + break; /* We already handled this one above */ + + case controls::AF_RANGE: { + AfAlgorithm *af = dynamic_cast(controller_.getAlgorithm("af")); + if (!af) { + LOG(IPARPI, Warning) + << "Could not set AF_RANGE - no focus algorithm"; + break; + } + + auto range = AfRangeTable.find(ctrl.second.get()); + if (range == AfRangeTable.end()) { + LOG(IPARPI, Error) << "AF range " << ctrl.second.get() + << " not recognised"; + break; + } + af->setRange(range->second); + break; + } + + case controls::AF_SPEED: { + AfAlgorithm *af = dynamic_cast(controller_.getAlgorithm("af")); + if (!af) { + LOG(IPARPI, Warning) + << "Could not set AF_SPEED - no focus algorithm"; + break; + } + + AfAlgorithm::AfSpeed speed = ctrl.second.get() == controls::AfSpeedFast ? + AfAlgorithm::AfSpeedFast : AfAlgorithm::AfSpeedNormal; + af->setSpeed(speed); + break; + } + + case controls::AF_METERING: { + AfAlgorithm *af = dynamic_cast(controller_.getAlgorithm("af")); + if (!af) { + LOG(IPARPI, Warning) + << "Could not set AF_METERING - no AF algorithm"; + break; + } + af->setMetering(ctrl.second.get() == controls::AfMeteringWindows); + break; + } + + case controls::AF_WINDOWS: { + AfAlgorithm *af = dynamic_cast(controller_.getAlgorithm("af")); + if (!af) { + LOG(IPARPI, Warning) + << "Could not set AF_WINDOWS - no AF algorithm"; + break; + } + af->setWindows(ctrl.second.get>()); + break; + } + + case controls::AF_PAUSE: { + AfAlgorithm *af = dynamic_cast(controller_.getAlgorithm("af")); + if (!af || af->getMode() != AfAlgorithm::AfModeContinuous) { + LOG(IPARPI, Warning) + << "Could not set AF_PAUSE - no AF algorithm or not Continuous"; + break; + } + auto pause = AfPauseTable.find(ctrl.second.get()); + if (pause == AfPauseTable.end()) { + LOG(IPARPI, Error) << "AF pause " << ctrl.second.get() + << " not recognised"; + break; + } + af->pause(pause->second); + break; + } + + case controls::AF_TRIGGER: { + AfAlgorithm *af = dynamic_cast(controller_.getAlgorithm("af")); + if (!af || af->getMode() != AfAlgorithm::AfModeAuto) { + LOG(IPARPI, Warning) + << "Could not set AF_TRIGGER - no AF algorithm or not Auto"; + break; + } else { + if (ctrl.second.get() == controls::AfTriggerStart) + af->triggerScan(); + else + af->cancelScan(); + } + break; + } + + case controls::LENS_POSITION: { + AfAlgorithm *af = dynamic_cast(controller_.getAlgorithm("af")); + if (af) { + int32_t hwpos; + if (af->setLensPosition(ctrl.second.get(), &hwpos)) { + ControlList lensCtrls(lensCtrls_); + lensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, hwpos); + setLensControls.emit(lensCtrls); + } + } else { + LOG(IPARPI, Warning) + << "Could not set LENS_POSITION - no AF algorithm"; + } + break; + } + default: LOG(IPARPI, Warning) << "Ctrl " << controls::controls.at(ctrl.first)->name() From patchwork Thu Jan 19 10:45:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18157 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 828A6C3297 for ; Thu, 19 Jan 2023 10:46:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1FEC16260A; Thu, 19 Jan 2023 11:46:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674125166; bh=hOUZPXIlhEQqFR0RsMcg2Z/jh8tJtOT052B+m706PIo=; 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=Anhrv8RgSuDh0Yi69aHfVUwHYpJ64DocAf6FyYtrnx03/855C5tqukJQhjcqoeHPj uClNM7cq2Oo/rVVSEFAcgZaXDOq5q8VTxtEcMWtZBqGzARR+VRIxnG1YeEggl13Dn1 THbwT51p1qd84yA7MBdEemvbgpMtUmpdSKXK9griYwXxup9Wdp1c+kc4+/cGO0nDps BtBgiHOFR7w5womKayicziIEqKX+nRV6cjI4pakAdDo5J1Omi3kDjEC/LWaRz0srea rzEBA/x79ZT+53jd3hqD2anceyVRnoNyDqMB7/kREQE8QQx8//znSkE6CNmB6EKAnG qx/P/zmrx7Z4A== Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DCAE261EFC for ; Thu, 19 Jan 2023 11:45:59 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="PVoU519i"; dkim-atps=neutral Received: by mail-wm1-x32e.google.com with SMTP id m15so1149941wms.4 for ; Thu, 19 Jan 2023 02:45:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=daQ5WIrNK17AMNTB2uJujU/y+E4tht6Eh2qZ398InRs=; b=PVoU519iVZfUgbPhfFPg/GgjI7M74yM3uwhCzg/Y7arPh1JVlXU8V2NZjRxA4kmUKM 7GXAbBgrjpz0/2S/s1BUz8r65tIlxSy4tyKcQfxZIY36KuhWK854ooLfhFZAMNcTMyPx Wul9T1rg1tzA5xe6+44Mr8onzK/TBqFY6A1h15mEvPobaj4T3mmgHt1AhXAnv0T1Z3RE zYI8aufYISBC670emaWmGguPE4h/J2mOcf3MZ/16xg9Rms6tLdr1xQhU23ak/23/kk2g myYY2ApCLMURkt7Ps8FI4eDjpIo4tfExfuPVdxDT9u5j4/zvM7Yv00k7gnj+Po7N2YSG b4jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=daQ5WIrNK17AMNTB2uJujU/y+E4tht6Eh2qZ398InRs=; b=SEn5ILcwXpZOJ4Klsx/W9kUSwuAmEtLTY+fQjpmtU5UmqjcTriNiV4YSoi7CS5E/hP Jx2tZsREVOhaWK3cKOyrUYp72KK0qzSF44Z4yTBEb2Ivh3JBB6iiMwOqq4c8EFuFO0f7 IWXIQxeJPX26HBuiRf7mxAL6949ebjM7Irxrj4KedujhcNBNUnNLyjAxNY/6Wk5oVPgn uYLvpPoIODwFIfxRHPrNDETT+LY2Ke25ci8lviMDkyUdAQyzM5v9BQOpm8KPeqE8OAzl A2IVz35Ta4/Mf29P2obmBWq0QagK6T6g7TbB637G/ZYOH1vmDICBV3dpk6JGsycGX6/d umcQ== X-Gm-Message-State: AFqh2kqiETvQYWSYCfyicnYfRc98ToMHn2UpoUjrFyzZFH/77GW/tdZ6 mt/xejae8IUUg4RI5zbc1r8PbKpNNcxS6F7mNLo= X-Google-Smtp-Source: AMrXdXvdv6yAespsxgkMihXttyWTfmOghiWkIcIPsZi8jLa0SDJu8X/dfRrENAoNmyr6UpaeIxcIGA== X-Received: by 2002:a05:600c:5028:b0:3db:1dea:75c9 with SMTP id n40-20020a05600c502800b003db1dea75c9mr2033501wmr.28.1674125159098; Thu, 19 Jan 2023 02:45:59 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id be12-20020a05600c1e8c00b003db06224953sm5332029wmb.41.2023.01.19.02.45.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 02:45:58 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 10:45:40 +0000 Message-Id: <20230119104544.9456-11-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119104544.9456-1-naush@raspberrypi.com> References: <20230119104544.9456-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 10/14] ipa: raspberrypi: Handle autofocus algorithm results 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 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nick Hollinghurst Handle the results returned from the autofocus algorithm by updating lens actuator position to the desired value. Update the Request metadata with the algorithm status to provide back to the application. Signed-off-by: Nick Hollinghurst Signed-off-by: Naushir Patuck Reviewed-by: Naushir Patuck Reviewed-by: David Plowman --- src/ipa/raspberrypi/raspberrypi.cpp | 48 +++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 0eb55ed605b6..fbace14b1afe 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -32,6 +32,7 @@ #include "libcamera/internal/mapped_framebuffer.h" #include "af_algorithm.h" +#include "af_status.h" #include "agc_algorithm.h" #include "agc_status.h" #include "alsc_status.h" @@ -164,6 +165,7 @@ private: void applySharpen(const struct SharpenStatus *sharpenStatus, ControlList &ctrls); void applyDPC(const struct DpcStatus *dpcStatus, ControlList &ctrls); void applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls); + void applyAF(const struct AfStatus *afStatus, ControlList &lensCtrls); void resampleTable(uint16_t dest[], double const src[12][16], int destW, int destH); std::map buffers_; @@ -629,6 +631,36 @@ void IPARPi::reportMetadata(unsigned int ipaContext) m[i] = ccmStatus->matrix[i]; libcameraMetadata_.set(controls::ColourCorrectionMatrix, m); } + + const AfStatus *afStatus = rpiMetadata.getLocked("af.status"); + if (afStatus) { + int32_t s, p; + switch (afStatus->state) { + case AfState::Scanning: + s = controls::AfStateScanning; + break; + case AfState::Focused: + s = controls::AfStateFocused; + break; + case AfState::Failed: + s = controls::AfStateFailed; + break; + default: + s = controls::AfStateIdle; + } + switch (afStatus->pauseState) { + case AfPauseState::Pausing: + p = controls::AfPauseStatePausing; + break; + case AfPauseState::Paused: + p = controls::AfPauseStatePaused; + break; + default: + p = controls::AfPauseStateRunning; + } + libcameraMetadata_.set(controls::AfState, s); + libcameraMetadata_.set(controls::AfPauseState, p); + } } bool IPARPi::validateSensorControls() @@ -1294,6 +1326,14 @@ void IPARPi::prepareISP(const ISPConfig &data) if (dpcStatus) applyDPC(dpcStatus, ctrls); + const AfStatus *afStatus = rpiMetadata.getLocked("af.status"); + if (afStatus) { + ControlList lensctrls(lensCtrls_); + applyAF(afStatus, lensctrls); + if (!lensctrls.empty()) + setLensControls.emit(lensctrls); + } + if (!ctrls.empty()) setIspControls.emit(ctrls); } @@ -1619,6 +1659,14 @@ void IPARPi::applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls) ctrls.set(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING, c); } +void IPARPi::applyAF(const struct AfStatus *afStatus, ControlList &lensCtrls) +{ + if (afStatus->lensSetting) { + ControlValue v(afStatus->lensSetting.value()); + lensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, v); + } +} + /* * Resamples a 16x12 table with central sampling to destW x destH with corner * sampling. From patchwork Thu Jan 19 10:45:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18159 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 72E33C3298 for ; Thu, 19 Jan 2023 10:46:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3203362604; Thu, 19 Jan 2023 11:46:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674125167; bh=2oOoSnV3xIVoIEas16og8XSCi4NRg40bj0ZImlWQOUE=; 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=TZhxgCKCcwKMtWrqL86P+Ydxbfkjp6G1P6m3AAKbVF+/Ct80LUg6T2d0odXBrUVb6 qa4QCIMBYGFeUgjNc1/cbRo9fYCU5xD5laPR1JgOPuZBgX3woQe+akZg2vTroEAVqU kmq3i6iL0ONncPP3/6gfc5I1HjwmvSYCNRkHrezPs7y5InK6J6wB5ZD4pEiH4ovMhx 6omZlwqJ0EmAZ316xlYLzaVYp/gEnbrpNcyXz/x49vKNOdqvfvDr8FO4MnI4ru2yOH lhXJb8FLaD1vIt0EtQlhxWCKNgSaI/R02Q5f72OiXLjupZGckn2axKbf+eDEb0sg9l 8ICmjAOxjFYJA== Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1AF3A625FE for ; Thu, 19 Jan 2023 11:46:01 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Rb317x0M"; dkim-atps=neutral Received: by mail-wm1-x336.google.com with SMTP id o17-20020a05600c511100b003db021ef437so919332wms.4 for ; Thu, 19 Jan 2023 02:46:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=Q8vHDGV07pCNO6Y463aCfAMBsyQiadIBgsNDWxvUI7o=; b=Rb317x0MdiDAcElffSNnSs89CSiizMZCluflkIlxMGWuSKVoI9ShiNu3E1ujemgE3p c143kHuynEj40C/DaAhI7xfXYHiQkK0fJ1sadPYJAHTkDotvh2vswRUj0OUgmAVYCOWi dbf72Vf+aQom1rOfpxwDug386JULFAbnhwTl10pt3oukXO40W5TLi8KdtY8sDpClDv9d MPu3AAotMcEi3xOjZ3sjKA4F2+g8bfmCfacBiyzP3L966CS03Cjy9r5ukgyx8BqjUyRX QILrHov4ffTS8RTBZbso1IP0eDjstNaL9wjlP53waZ/8jGBP3cP0Vp9tPNRJU1AQ26ut 7Plw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Q8vHDGV07pCNO6Y463aCfAMBsyQiadIBgsNDWxvUI7o=; b=dgypd8eUFV1KUKEIu0SYciINc2RGkk1H7L7RSjrhESIU1r+jbdHb0N5IHRaiufOQyM nhdFySy7+nY3ZrLziKZxoQyHm61IS2aOMlCtnV9Uxx7y0npyV6+P7WJWnS1bGh8K0DCv /zqT8zzmJuTqycIvR7d4LpvEHm9J3GvDsWNaWrat1k0TM2IMdS5VdNU2oz9eHU5hvGHd +h2isEglRynwTo+AndY2zHySZSPeNm8r89/J+hLMgOIuYluFCOLVozEQCpSYVtevtRxY O6NCIhyqPQp8Xx8kCpazYnMsZhF35tckFfd01SVjyP9rO/u5rZboxi9S6ykLRr87VzLm Z1pQ== X-Gm-Message-State: AFqh2koonVV6t6Dpp+WYrHllL0z6fd8Jg0a3X8xtvtx/Nj7UDD7l5xUa 6zSducnIKdP3sf3L9lV3/bcF5GREpTOZMM9tn7I= X-Google-Smtp-Source: AMrXdXtPjdRrA8DjNo56r973hwNpJ7x2g+jbLm++zNN0i7wf0X86V8/+S6Dp9vDDeyQIeimVQMLmCg== X-Received: by 2002:a05:600c:181c:b0:3da:f9e9:3a1a with SMTP id n28-20020a05600c181c00b003daf9e93a1amr10181397wmp.20.1674125159975; Thu, 19 Jan 2023 02:45:59 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id be12-20020a05600c1e8c00b003db06224953sm5332029wmb.41.2023.01.19.02.45.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 02:45:59 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 10:45:41 +0000 Message-Id: <20230119104544.9456-12-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119104544.9456-1-naush@raspberrypi.com> References: <20230119104544.9456-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 11/14] ipa: raspberrypi: First version of autofocus algorithm using PDAF 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 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nick Hollinghurst Provide the first version of the Raspberry Pi autofocus algorithm. This implementation uses a hybrid of contrast detect autofocus (CDAF) and phase detect autofocus (PDAF) statistics. PDAF is always preferred over CDAF due to having less "hunting" behavior. Signed-off-by: Nick Hollinghurst Signed-off-by: Naushir Patuck Reviewed-by: Naushir Patuck Reviewed-by: David Plowman --- src/ipa/raspberrypi/controller/rpi/af.cpp | 755 ++++++++++++++++++++++ src/ipa/raspberrypi/controller/rpi/af.h | 153 +++++ src/ipa/raspberrypi/meson.build | 1 + 3 files changed, 909 insertions(+) create mode 100644 src/ipa/raspberrypi/controller/rpi/af.cpp create mode 100644 src/ipa/raspberrypi/controller/rpi/af.h diff --git a/src/ipa/raspberrypi/controller/rpi/af.cpp b/src/ipa/raspberrypi/controller/rpi/af.cpp new file mode 100644 index 000000000000..7e2e8961085a --- /dev/null +++ b/src/ipa/raspberrypi/controller/rpi/af.cpp @@ -0,0 +1,755 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2022-2023, Raspberry Pi Ltd + * + * af.cpp - Autofocus control algorithm + */ + +#include "af.h" + +#include +#include +#include + +#include + +#include + +using namespace RPiController; +using namespace libcamera; + +LOG_DEFINE_CATEGORY(RPiAf) + +#define NAME "rpi.af" + +/* + * Default values for parameters. All may be overridden in the tuning file. + * Many of these values are sensor- or module-dependent; the defaults here + * assume IMX708 in a Raspberry Pi V3 camera with the standard lens. + * + * Here all focus values are in dioptres (1/m). They are converted to hardware + * units when written to status.lensSetting or returned from setLensPosition(). + * + * Gain and delay values are relative to the update rate, since much (not all) + * of the delay is in the sensor and (for CDAF) ISP, not the lens mechanism; + * but note that algorithms are updated at no more than 30 Hz. + */ + +Af::RangeDependentParams::RangeDependentParams() + : focusMin(0.0), + focusMax(12.0), + focusDefault(1.0) +{ +} + +Af::SpeedDependentParams::SpeedDependentParams() + : stepCoarse(1.0), + stepFine(0.25), + contrastRatio(0.75), + pdafGain(-0.02), + pdafSquelch(0.125), + maxSlew(2.0), + pdafFrames(20), + dropoutFrames(6), + stepFrames(4) +{ +} + +Af::CfgParams::CfgParams() + : confEpsilon(8), + confThresh(16), + confClip(512), + skipFrames(5), + map() +{ +} + +template +static void readNumber(T &dest, const libcamera::YamlObject ¶ms, char const *name) +{ + auto value = params[name].get(); + if (value) + dest = *value; + else + LOG(RPiAf, Warning) << "Missing parameter \"" << name << "\""; +} + +void Af::RangeDependentParams::read(const libcamera::YamlObject ¶ms) +{ + + readNumber(focusMin, params, "min"); + readNumber(focusMax, params, "max"); + readNumber(focusDefault, params, "default"); +} + +void Af::SpeedDependentParams::read(const libcamera::YamlObject ¶ms) +{ + readNumber(stepCoarse, params, "step_coarse"); + readNumber(stepFine, params, "step_fine"); + readNumber(contrastRatio, params, "contrast_ratio"); + readNumber(pdafGain, params, "pdaf_gain"); + readNumber(pdafSquelch, params, "pdaf_squelch"); + readNumber(maxSlew, params, "max_slew"); + readNumber(pdafFrames, params, "pdaf_frames"); + readNumber(dropoutFrames, params, "dropout_frames"); + readNumber(stepFrames, params, "step_frames"); +} + +int Af::CfgParams::read(const libcamera::YamlObject ¶ms) +{ + if (params.contains("ranges")) { + auto &rr = params["ranges"]; + + if (rr.contains("normal")) + ranges[AfRangeNormal].read(rr["normal"]); + else + LOG(RPiAf, Warning) << "Missing range \"normal\""; + + ranges[AfRangeMacro] = ranges[AfRangeNormal]; + if (rr.contains("macro")) + ranges[AfRangeMacro].read(rr["macro"]); + + ranges[AfRangeFull].focusMin = std::min(ranges[AfRangeNormal].focusMin, + ranges[AfRangeMacro].focusMin); + ranges[AfRangeFull].focusMax = std::max(ranges[AfRangeNormal].focusMax, + ranges[AfRangeMacro].focusMax); + ranges[AfRangeFull].focusDefault = ranges[AfRangeNormal].focusDefault; + if (rr.contains("full")) + ranges[AfRangeFull].read(rr["full"]); + } else + LOG(RPiAf, Warning) << "No ranges defined"; + + if (params.contains("speeds")) { + auto &ss = params["speeds"]; + + if (ss.contains("normal")) + speeds[AfSpeedNormal].read(ss["normal"]); + else + LOG(RPiAf, Warning) << "Missing speed \"normal\""; + + speeds[AfSpeedFast] = speeds[AfSpeedNormal]; + if (ss.contains("fast")) + speeds[AfSpeedFast].read(ss["fast"]); + } else + LOG(RPiAf, Warning) << "No speeds defined"; + + readNumber(confEpsilon, params, "conf_epsilon"); + readNumber(confThresh, params, "conf_thresh"); + readNumber(confClip, params, "conf_clip"); + readNumber(skipFrames, params, "skip_frames"); + + if (params.contains("map")) + map.read(params["map"]); + else + LOG(RPiAf, Warning) << "No map defined"; + + return 0; +} + +void Af::CfgParams::initialise() +{ + if (map.empty()) { + /* Default mapping from dioptres to hardware setting */ + static constexpr double DefaultMapX0 = 0.0; + static constexpr double DefaultMapY0 = 445.0; + static constexpr double DefaultMapX1 = 15.0; + static constexpr double DefaultMapY1 = 925.0; + + map.append(DefaultMapX0, DefaultMapY0); + map.append(DefaultMapX1, DefaultMapY1); + + LOG(RPiAf, Warning) << "af.map is not defined, "; + } +} + +/* Af Algorithm class */ + +Af::Af(Controller *controller) + : AfAlgorithm(controller), + cfg_(), + range_(AfRangeNormal), + speed_(AfSpeedNormal), + mode_(AfAlgorithm::AfModeManual), + pauseFlag_(false), + sensorSize_{ 0, 0 }, + useWeights_(false), + phaseWeights_{}, + contrastWeights_{}, + scanState_(ScanState::Idle), + initted_(false), + ftarget_(-1.0), + fsmooth_(-1.0), + prevContrast_(0.0), + skipCount_(0), + stepCount_(0), + dropCount_(0), + scanMaxContrast_(0.0), + scanMinContrast_(1.0e9), + scanData_(), + reportState_(AfState::Idle) +{ + scanData_.reserve(24); +} + +Af::~Af() +{ +} + +char const *Af::name() const +{ + return NAME; +} + +int Af::read(const libcamera::YamlObject ¶ms) +{ + return cfg_.read(params); +} + +void Af::initialise() +{ + cfg_.initialise(); +} + +void Af::switchMode(CameraMode const &cameraMode, [[maybe_unused]] Metadata *metadata) +{ + (void)metadata; + sensorSize_.width = cameraMode.sensorWidth; + sensorSize_.height = cameraMode.sensorHeight; + + if (scanState_ >= ScanState::Coarse && scanState_ < ScanState::Settle) { + /* + * If a scan was in progress, re-start it, as CDAF statistics + * may have changed. Though if the application is just about + * to take a still picture, this will not help... + */ + startProgrammedScan(); + } + skipCount_ = cfg_.skipFrames; +} + +bool Af::getPhase(PdafData const &data, double &phase, double &conf) const +{ + static const uint8_t defaultWeights[PDAF_DATA_ROWS][PDAF_DATA_COLS] = { + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 2, 4, 4, 4, 4, 4, 4, 2, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 2, 4, 4, 4, 4, 4, 4, 2, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 2, 4, 4, 4, 4, 4, 4, 2, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 2, 4, 4, 4, 4, 4, 4, 2, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + }; + int32_t sumW = 0; + int32_t sumWc = 0; + int32_t sumWcp = 0; + auto wgts = useWeights_ ? phaseWeights_ : defaultWeights; + + for (unsigned i = 0; i < PDAF_DATA_ROWS; ++i) { + for (unsigned j = 0; j < PDAF_DATA_COLS; ++j) { + if (wgts[i][j]) { + uint32_t c = data.conf[i][j]; + if (c >= cfg_.confThresh) { + if (c > cfg_.confClip) + c = cfg_.confClip; + sumWc += wgts[i][j] * (int32_t)c; + c -= (cfg_.confThresh >> 1); + sumWcp += wgts[i][j] * data.phase[i][j] * (int32_t)c; + } + sumW += wgts[i][j]; + } + } + } + + if (sumWc > 0) { + phase = (double)sumWcp / (double)sumWc; + conf = (double)sumWc / (double)sumW; + return true; + } else { + phase = 0.0; + conf = 0.0; + return false; + } +} + +void Af::doPDAF(double phase, double conf) +{ + /* Apply loop gain */ + phase *= cfg_.speeds[speed_].pdafGain; + + if (mode_ == AfModeContinuous) { + /* + * PDAF in Continuous mode. Scale down lens movement when + * delta is small or confidence is low, to suppress wobble. + */ + if (std::abs(phase) < cfg_.speeds[speed_].pdafSquelch) { + double a = phase / cfg_.speeds[speed_].pdafSquelch; + phase *= a * a; + } + phase *= conf / (conf + cfg_.confEpsilon); + } else { + /* + * PDAF in triggered-auto mode. Allow early termination when + * phase delta is small; scale down lens movements towards + * the end of the sequence, to ensure a stable image. + */ + if (stepCount_ >= cfg_.speeds[speed_].stepFrames) { + if (std::abs(phase) < cfg_.speeds[speed_].pdafSquelch) + stepCount_ = cfg_.speeds[speed_].stepFrames; + } else + phase *= stepCount_ / cfg_.speeds[speed_].stepFrames; + } + + /* Apply slew rate limit. Report failure if out of bounds. */ + if (phase < -cfg_.speeds[speed_].maxSlew) { + phase = -cfg_.speeds[speed_].maxSlew; + reportState_ = (ftarget_ <= cfg_.ranges[range_].focusMin) ? AfState::Failed + : AfState::Scanning; + } else if (phase > cfg_.speeds[speed_].maxSlew) { + phase = cfg_.speeds[speed_].maxSlew; + reportState_ = (ftarget_ >= cfg_.ranges[range_].focusMax) ? AfState::Failed + : AfState::Scanning; + } else + reportState_ = AfState::Focused; + + ftarget_ = fsmooth_ + phase; +} + +bool Af::earlyTerminationByPhase(double phase) +{ + if (scanData_.size() > 0 && + scanData_[scanData_.size() - 1].conf >= cfg_.confEpsilon) { + double oldFocus = scanData_[scanData_.size() - 1].focus; + double oldPhase = scanData_[scanData_.size() - 1].phase; + + /* + * Check that the gradient is finite and has the expected sign; + * Interpolate/extrapolate the lens position for zero phase. + * Check that the extrapolation is well-conditioned. + */ + if ((ftarget_ - oldFocus) * (phase - oldPhase) > 0.0) { + double param = phase / (phase - oldPhase); + if (-3.0 <= param && param <= 3.5) { + ftarget_ += param * (oldFocus - ftarget_); + LOG(RPiAf, Debug) << "ETBP: param=" << param; + return true; + } + } + } + + return false; +} + +double Af::findPeak(unsigned i) const +{ + double f = scanData_[i].focus; + + if (i > 0 && i + 1 < scanData_.size()) { + double dropLo = scanData_[i].contrast - scanData_[i - 1].contrast; + double dropHi = scanData_[i].contrast - scanData_[i + 1].contrast; + if (dropLo < dropHi) { + double param = 0.3125 * (1.0 - dropLo / dropHi) * (1.6 - dropLo / dropHi); + f += param * (scanData_[i - 1].focus - f); + } else if (dropHi < dropLo) { + double param = 0.3125 * (1.0 - dropHi / dropLo) * (1.6 - dropHi / dropLo); + f += param * (scanData_[i + 1].focus - f); + } + } + + LOG(RPiAf, Debug) << "FindPeak: " << f; + return f; +} + +void Af::doScan(double contrast, double phase, double conf) +{ + /* Record lens position, contrast and phase values for the current scan */ + if (scanData_.empty() || contrast > scanMaxContrast_) { + scanMaxContrast_ = contrast; + scanMaxIndex_ = scanData_.size(); + } + if (contrast < scanMinContrast_) + scanMinContrast_ = contrast; + scanData_.emplace_back(ScanRecord{ ftarget_, contrast, phase, conf }); + + if (scanState_ == ScanState::Coarse) { + if (ftarget_ >= cfg_.ranges[range_].focusMax || + contrast < cfg_.speeds[speed_].contrastRatio * scanMaxContrast_) { + /* + * Finished course scan, or termination based on contrast. + * Jump to just after max contrast and start fine scan. + */ + ftarget_ = std::min(ftarget_, findPeak(scanMaxIndex_) + + 2.0 * cfg_.speeds[speed_].stepFine); + scanState_ = ScanState::Fine; + scanData_.clear(); + } else + ftarget_ += cfg_.speeds[speed_].stepCoarse; + } else { /* ScanState::Fine */ + if (ftarget_ <= cfg_.ranges[range_].focusMin || scanData_.size() >= 5 || + contrast < cfg_.speeds[speed_].contrastRatio * scanMaxContrast_) { + /* + * Finished fine scan, or termination based on contrast. + * Use quadratic peak-finding to find best contrast position. + */ + ftarget_ = findPeak(scanMaxIndex_); + scanState_ = ScanState::Settle; + } else + ftarget_ -= cfg_.speeds[speed_].stepFine; + } + + stepCount_ = (ftarget_ == fsmooth_) ? 0 : cfg_.speeds[speed_].stepFrames; +} + +void Af::doAF(double contrast, double phase, double conf) +{ + /* Skip frames at startup and after mode change */ + if (skipCount_ > 0) { + LOG(RPiAf, Debug) << "SKIP"; + skipCount_--; + return; + } + + if (scanState_ == ScanState::Pdaf) { + /* + * Use PDAF closed-loop control whenever available, in both CAF + * mode and (for a limited number of iterations) when triggered. + * If PDAF fails (due to poor contrast, noise or large defocus), + * fall back to a CDAF-based scan. To avoid "nuisance" scans, + * scan only after a number of frames with low PDAF confidence. + */ + if (conf > (dropCount_ ? cfg_.confEpsilon : 0.0)) { + doPDAF(phase, conf); + if (stepCount_ > 0) + stepCount_--; + else if (mode_ != AfModeContinuous) + scanState_ = ScanState::Idle; + dropCount_ = 0; + } else if (++dropCount_ == cfg_.speeds[speed_].dropoutFrames) + startProgrammedScan(); + } else if (scanState_ >= ScanState::Coarse && fsmooth_ == ftarget_) { + /* + * Scanning sequence. This means PDAF has become unavailable. + * Allow a delay between steps for CDAF FoM statistics to be + * updated, and a "settling time" at the end of the sequence. + * [A coarse or fine scan can be abandoned if two PDAF samples + * allow direct interpolation of the zero-phase lens position.] + */ + if (stepCount_ > 0) + stepCount_--; + else if (scanState_ == ScanState::Settle) { + if (prevContrast_ >= cfg_.speeds[speed_].contrastRatio * scanMaxContrast_ && + scanMinContrast_ <= cfg_.speeds[speed_].contrastRatio * scanMaxContrast_) + reportState_ = AfState::Focused; + else + reportState_ = AfState::Failed; + if (mode_ == AfModeContinuous && !pauseFlag_ && + cfg_.speeds[speed_].dropoutFrames > 0) + scanState_ = ScanState::Pdaf; + else + scanState_ = ScanState::Idle; + scanData_.clear(); + } else if (conf >= cfg_.confEpsilon && earlyTerminationByPhase(phase)) { + scanState_ = ScanState::Settle; + stepCount_ = (mode_ == AfModeContinuous) ? 0 + : cfg_.speeds[speed_].stepFrames; + } else + doScan(contrast, phase, conf); + } +} + +void Af::updateLensPosition() +{ + if (mode_ != AfModeManual) { + ftarget_ = std::clamp(ftarget_, + cfg_.ranges[range_].focusMin, + cfg_.ranges[range_].focusMax); + } + + /* \todo Add a clip for manual lens position to be within the PWL limits. */ + + if (initted_) { + /* from a known lens position: apply slew rate limit */ + fsmooth_ = std::clamp(ftarget_, + fsmooth_ - cfg_.speeds[speed_].maxSlew, + fsmooth_ + cfg_.speeds[speed_].maxSlew); + } else { + /* from an unknown position: go straight to target, but add delay */ + fsmooth_ = ftarget_; + initted_ = true; + skipCount_ = cfg_.skipFrames; + } +} + +/* + * PDAF phase data are available in prepare(), but CDAF statistics are not + * available until process(). We are gambling on the availability of PDAF. + * To expedite feedback control using PDAF, issue the V4L2 lens control from + * prepare(). Conversely, during scans, we must allow an extra frame delay + * between steps, to retrieve CDAF statistics from the previous process() + * so we can terminate the scan early without having to change our minds. + */ + +void Af::prepare(Metadata *imageMetadata) +{ + if (initted_) { + /* Get PDAF from the embedded metadata, and run AF algorithm core */ + PdafData data; + double phase = 0.0, conf = 0.0; + double oldFt = ftarget_; + double oldFs = fsmooth_; + ScanState oldSs = scanState_; + uint32_t oldSt = stepCount_; + if (imageMetadata->get("pdaf.data", data) == 0) + getPhase(data, phase, conf); + doAF(prevContrast_, phase, conf); + updateLensPosition(); + LOG(RPiAf, Debug) << std::fixed << std::setprecision(2) + << static_cast(reportState_) + << " sst" << static_cast(oldSs) + << "->" << static_cast(scanState_) + << " stp" << oldSt << "->" << stepCount_ + << " ft" << oldFt << "->" << ftarget_ + << " fs" << oldFs << "->" << fsmooth_ + << " cont=" << (int)prevContrast_ + << " phase=" << (int)phase << " conf=" << (int)conf; + } + + /* Report status and produce new lens setting */ + AfStatus status; + if (pauseFlag_) + status.pauseState = (scanState_ == ScanState::Idle) ? AfPauseState::Paused + : AfPauseState::Pausing; + else + status.pauseState = AfPauseState::Running; + + if (mode_ == AfModeAuto && scanState_ != ScanState::Idle) + status.state = AfState::Scanning; + else + status.state = reportState_; + status.lensSetting = initted_ ? std::optional(cfg_.map.eval(fsmooth_)) + : std::nullopt; + imageMetadata->set("af.status", status); +} + +double Af::getContrast(struct bcm2835_isp_stats_focus const focus_stats[FOCUS_REGIONS]) const +{ + uint32_t totW = 0, totWc = 0; + + if (useWeights_) { + for (unsigned i = 0; i < FOCUS_REGIONS; ++i) { + unsigned w = contrastWeights_[i]; + totW += w; + totWc += w * (focus_stats[i].contrast_val[1][1] >> 10); + } + } + if (totW == 0) { + totW = 2; + totWc = (focus_stats[5].contrast_val[1][1] >> 10) + + (focus_stats[6].contrast_val[1][1] >> 10); + } + + return (double)totWc / (double)totW; +} + +void Af::process(StatisticsPtr &stats, [[maybe_unused]] Metadata *imageMetadata) +{ + (void)imageMetadata; + prevContrast_ = getContrast(stats->focus_stats); +} + +/* Controls */ + +void Af::setRange(AfRange r) +{ + LOG(RPiAf, Debug) << "setRange: " << (unsigned)r; + if (r < AfAlgorithm::AfRangeMax) + range_ = r; +} + +void Af::setSpeed(AfSpeed s) +{ + LOG(RPiAf, Debug) << "setSpeed: " << (unsigned)s; + if (s < AfAlgorithm::AfSpeedMax) { + if (scanState_ == ScanState::Pdaf && + cfg_.speeds[s].pdafFrames > cfg_.speeds[speed_].pdafFrames) + stepCount_ += cfg_.speeds[s].pdafFrames - cfg_.speeds[speed_].pdafFrames; + speed_ = s; + } +} + +void Af::setMetering(bool mode) +{ + useWeights_ = mode; +} + +void Af::setWindows(libcamera::Span const &wins) +{ + /* + * Here we just merge all of the given windows, weighted by area. + * If there are more than 15 overlapping windows, overflow can occur. + * TODO: A better approach might be to find the phase in each window + * and choose either the closest or the highest-confidence one? + * + * Using mostly "int" arithmetic, because Rectangle has signed x, y + */ + ASSERT(sensorSize_.width > 0 && sensorSize_.height > 0); + int gridY = (int)(sensorSize_.height / PDAF_DATA_ROWS); + int gridX = (int)(sensorSize_.width / PDAF_DATA_COLS); + int gridA = gridY * gridX; + + for (int i = 0; i < PDAF_DATA_ROWS; ++i) + std::fill(phaseWeights_[i], phaseWeights_[i] + PDAF_DATA_COLS, 0); + std::fill(contrastWeights_, contrastWeights_ + FOCUS_REGIONS, 0); + + for (auto &w : wins) { + for (int i = 0; i < PDAF_DATA_ROWS; ++i) { + int y0 = std::max(gridY * i, w.y); + int y1 = std::min(gridY * (i + 1), w.y + (int)(w.height)); + if (y0 >= y1) + continue; + y1 -= y0; + for (int j = 0; j < PDAF_DATA_COLS; ++j) { + int x0 = std::max(gridX * j, w.x); + int x1 = std::min(gridX * (j + 1), w.x + (int)(w.width)); + if (x0 >= x1) + continue; + int a = y1 * (x1 - x0); + a = (16 * a + gridA - 1) / gridA; + phaseWeights_[i][j] += a; + contrastWeights_[4 * ((3 * i) / PDAF_DATA_ROWS) + ((4 * j) / PDAF_DATA_COLS)] += a; + } + } + } +} + +bool Af::setLensPosition(double dioptres, int *hwpos) +{ + bool changed = false; + + if (mode_ == AfModeManual) { + LOG(RPiAf, Debug) << "setLensPosition: " << dioptres; + changed = !(initted_ && fsmooth_ == dioptres); + ftarget_ = dioptres; + updateLensPosition(); + } + + if (hwpos) + *hwpos = cfg_.map.eval(fsmooth_); + + return changed; +} + +std::optional Af::getLensPosition() const +{ + /* + * \todo We ought to perform some precise timing here to determine + * the current lens position. + */ + return initted_ ? std::optional(fsmooth_) : std::nullopt; +} + +void Af::startCAF() +{ + /* Try PDAF if the tuning file permits it for CAF; else CDAF */ + if (cfg_.speeds[speed_].dropoutFrames > 0) { + if (!initted_) { + ftarget_ = cfg_.ranges[range_].focusDefault; + updateLensPosition(); + } + scanState_ = ScanState::Pdaf; + scanData_.clear(); + dropCount_ = 0; + reportState_ = AfState::Scanning; + } else { + startProgrammedScan(); + } +} + +void Af::startProgrammedScan() +{ + ftarget_ = cfg_.ranges[range_].focusMin; + updateLensPosition(); + scanState_ = ScanState::Coarse; + scanMaxContrast_ = 0.0; + scanMinContrast_ = 1.0e9; + scanMaxIndex_ = 0; + scanData_.clear(); + stepCount_ = cfg_.speeds[speed_].stepFrames; + reportState_ = AfState::Scanning; +} + +void Af::goIdle() +{ + scanState_ = ScanState::Idle; + reportState_ = AfState::Idle; + scanData_.clear(); +} + +void Af::cancelScan() +{ + LOG(RPiAf, Debug) << "cancelScan"; + if (mode_ == AfModeAuto) + goIdle(); +} + +void Af::triggerScan() +{ + LOG(RPiAf, Debug) << "triggerScan"; + if (mode_ == AfModeAuto && scanState_ == ScanState::Idle) { + /* Try PDAF if the tuning file permits it for Auto; else CDAF */ + if (cfg_.speeds[speed_].pdafFrames > 0 && cfg_.speeds[speed_].dropoutFrames > 0) { + if (!initted_) { + ftarget_ = cfg_.ranges[range_].focusDefault; + updateLensPosition(); + } + stepCount_ = cfg_.speeds[speed_].pdafFrames; + scanState_ = ScanState::Pdaf; + dropCount_ = 0; + } else + startProgrammedScan(); + reportState_ = AfState::Scanning; + } +} + +void Af::setMode(AfAlgorithm::AfMode mode) +{ + LOG(RPiAf, Debug) << "setMode: " << (unsigned)mode; + if (mode_ != mode) { + mode_ = mode; + pauseFlag_ = false; + if (mode == AfModeContinuous) + startCAF(); + else if (mode != AfModeAuto) + goIdle(); + } +} + +AfAlgorithm::AfMode Af::getMode() const +{ + return mode_; +} + +void Af::pause(AfAlgorithm::AfPause pause) +{ + LOG(RPiAf, Debug) << "pause: " << (unsigned)pause; + if (mode_ == AfModeContinuous) { + if (pause == AfPauseResume && pauseFlag_) { + startCAF(); + pauseFlag_ = false; + } else if (pause != AfPauseResume && !pauseFlag_) { + if (pause == AfPauseImmediate || scanState_ == ScanState::Pdaf) + goIdle(); + pauseFlag_ = true; + } + } +} + +// Register algorithm with the system. +static Algorithm *create(Controller *controller) +{ + return (Algorithm *)new Af(controller); +} +static RegisterAlgorithm reg(NAME, &create); diff --git a/src/ipa/raspberrypi/controller/rpi/af.h b/src/ipa/raspberrypi/controller/rpi/af.h new file mode 100644 index 000000000000..0431bd70ae29 --- /dev/null +++ b/src/ipa/raspberrypi/controller/rpi/af.h @@ -0,0 +1,153 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2022-2023, Raspberry Pi Ltd + * + * af.h - Autofocus control algorithm + */ +#pragma once + +#include "../af_algorithm.h" +#include "../af_status.h" +#include "../pdaf_data.h" +#include "../pwl.h" + +/* + * This algorithm implements a hybrid of CDAF and PDAF, favouring PDAF. + * + * Whenever PDAF is available, it is used in a continuous feedback loop. + * When triggered in auto mode, we simply enable AF for a limited number + * of frames (it may terminate early if the delta becomes small enough). + * + * When PDAF confidence is low (due e.g. to low contrast or extreme defocus) + * or PDAF data are absent, fall back to CDAF with a programmed scan pattern. + * A coarse and fine scan are performed, using ISP's CDAF focus FoM to + * estimate the lens position with peak contrast. This is slower due to + * extra latency in the ISP, and requires a settling time between steps. + * + * Some hysteresis is applied to the switch between PDAF and CDAF, to avoid + * "nuisance" scans. During each interval where PDAF is not working, only + * ONE scan will be performed; CAF cannot track objects using CDAF alone. + * + * This algorithm is unrelated to "rpi.focus" which merely reports CDAF FoM. + */ + +namespace RPiController { + +class Af : public AfAlgorithm +{ +public: + Af(Controller *controller = NULL); + ~Af(); + char const *name() const override; + int read(const libcamera::YamlObject ¶ms) override; + void initialise() override; + + /* IPA calls */ + void switchMode(CameraMode const &cameraMode, Metadata *metadata) override; + void prepare(Metadata *imageMetadata) override; + void process(StatisticsPtr &stats, Metadata *imageMetadata) override; + + /* controls */ + void setRange(AfRange range) override; + void setSpeed(AfSpeed speed) override; + void setMetering(bool use_windows) override; + void setWindows(libcamera::Span const &wins) override; + void setMode(AfMode mode) override; + AfMode getMode() const override; + bool setLensPosition(double dioptres, int32_t *hwpos) override; + std::optional getLensPosition() const override; + void triggerScan() override; + void cancelScan() override; + void pause(AfPause pause) override; + +private: + enum class ScanState { + Idle, + Pdaf, + Coarse, + Fine, + Settle + }; + + struct RangeDependentParams { + double focusMin; /* lower (far) limit in dipotres */ + double focusMax; /* upper (near) limit in dioptres */ + double focusDefault; /* default setting ("hyperfocal") */ + + RangeDependentParams(); + void read(const libcamera::YamlObject ¶ms); + }; + + struct SpeedDependentParams { + double stepCoarse; /* used for scans */ + double stepFine; /* used for scans */ + double contrastRatio; /* used for scan termination and reporting */ + double pdafGain; /* coefficient for PDAF feedback loop */ + double pdafSquelch; /* PDAF stability parameter (device-specific) */ + double maxSlew; /* limit for lens movement per frame */ + uint32_t pdafFrames; /* number of iterations when triggered */ + uint32_t dropoutFrames; /* number of non-PDAF frames to switch to CDAF */ + uint32_t stepFrames; /* frames to skip in between steps of a scan */ + + SpeedDependentParams(); + void read(const libcamera::YamlObject ¶ms); + }; + + struct CfgParams { + RangeDependentParams ranges[AfRangeMax]; + SpeedDependentParams speeds[AfSpeedMax]; + uint32_t confEpsilon; /* PDAF hysteresis threshold (sensor-specific) */ + uint32_t confThresh; /* PDAF confidence cell min (sensor-specific) */ + uint32_t confClip; /* PDAF confidence cell max (sensor-specific) */ + uint32_t skipFrames; /* frames to skip at start or modeswitch */ + Pwl map; /* converts dioptres -> lens driver position */ + + CfgParams(); + int read(const libcamera::YamlObject ¶ms); + void initialise(); + }; + + struct ScanRecord { + double focus; + double contrast; + double phase; + double conf; + }; + + bool getPhase(PdafData const &data, double &phase, double &conf) const; + double getContrast(struct bcm2835_isp_stats_focus const focus_stats[FOCUS_REGIONS]) const; + void doPDAF(double phase, double conf); + bool earlyTerminationByPhase(double phase); + void doScan(double contrast, double phase, double conf); + double findPeak(unsigned index) const; + void doAF(double contrast, double phase, double conf); + void updateLensPosition(); + void startProgrammedScan(); + void startCAF(); + void goIdle(); + + /* Configuration and settings */ + CfgParams cfg_; + AfRange range_; + AfSpeed speed_; + AfMode mode_; + bool pauseFlag_; + libcamera::Size sensorSize_; + bool useWeights_; + uint8_t phaseWeights_[PDAF_DATA_ROWS][PDAF_DATA_COLS]; + uint16_t contrastWeights_[FOCUS_REGIONS]; + + /* Working state. */ + ScanState scanState_; + bool initted_; + double ftarget_, fsmooth_; + double prevContrast_; + bool pdafSeen_; + unsigned skipCount_, stepCount_, dropCount_; + unsigned scanMaxIndex_; + double scanMaxContrast_, scanMinContrast_; + std::vector scanData_; + AfState reportState_; +}; + +} // namespace RPiController diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build index 517d815bb98c..4e2689536257 100644 --- a/src/ipa/raspberrypi/meson.build +++ b/src/ipa/raspberrypi/meson.build @@ -27,6 +27,7 @@ rpi_ipa_sources = files([ 'controller/controller.cpp', 'controller/histogram.cpp', 'controller/algorithm.cpp', + 'controller/rpi/af.cpp', 'controller/rpi/alsc.cpp', 'controller/rpi/awb.cpp', 'controller/rpi/sharpen.cpp', From patchwork Thu Jan 19 10:45:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18160 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 57C45C3299 for ; Thu, 19 Jan 2023 10:46:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 05FBC6260D; Thu, 19 Jan 2023 11:46:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674125168; bh=9ZG7A02w3xBIZWGiPWhbv2aDDQmxJ1BjGnnw5aKsFYw=; 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=2jrHCR2os3K8V5JHlpP1LBIX+eUVB2bLJqdMsyz49qMvc4hTAKSwZOInR6rbvr/CG Zf2qPeN9w+HFIQzLz5kfMtaUyF3qNhKnWkhhViRYdrBClXZn0z8ZFW/FOfNzRe8MpX imSCsx2asflnYegAzQTF3Y8Zds75f3xGzJIt1ZvRYoICC+3AsSQDh99QcdqUMo1gkK 8Az/Sc8hpx/dAx/Qkk+EOAO9IoRZDvRjRY+EJ242zGd1AHrXcwdMG5QgAeuS/4Cz5E Mz7frcdg5GkthVWFAxiUGXo8k+WFdEEAMPGmS/Wn9OfCIY6IEGNfEiXZ0weYyoGLkt qqIKUvilaprLg== Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 71E64625FF for ; Thu, 19 Jan 2023 11:46:01 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="dWv3o0pA"; dkim-atps=neutral Received: by mail-wm1-x333.google.com with SMTP id l41-20020a05600c1d2900b003daf986faaeso923704wms.3 for ; Thu, 19 Jan 2023 02:46:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=6oRk+CQDW/U6TdVVYX9FHJVOlZ4Hp8UtCy5Yhpw/CYE=; b=dWv3o0pA6bn4y9mAODxSjSMMTPigSVDl+rrHSMn4jjWEbAwoRQFD/e6BcUiQMXkoSu 6CDHMDWN4yMOmwfGYU7zqh/Mc8fqeQPH0a/ThSEkIoDrpu64tkG99YYWyj5zHbVOIpFt 7J8nv/SWQVdGfRG8tfOyaCbIIaJ4bL4gNLJhT8+jGm72wY5TTunGHV+rZ7gyhIDTJPzQ uM9ME4SCOkVg+jz2rMHS0iHJVlhdKKI5ke3NGLYaHVzhyQXPGqhlXAXgc7YpBRhEXHNs wjb6OUFja+ePQ+k7WB+hBV2iKfmZDHeS8VlQ9Q770LkaLcgu8N0HoX50D28ZT4yt5vxn l2PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=6oRk+CQDW/U6TdVVYX9FHJVOlZ4Hp8UtCy5Yhpw/CYE=; b=5IpuhlG0gTXdU4bkRkul8QBgnuFYS5cfRNlTMhcmkOIVpW/h1LONoyMK0/AFQA69mn LLVQC+3GovbysqYJgYvIAFHQnRKUjHjNcABX9W8/0EiZ+eh7xxbxiRUFLMK1+sIMsyMy FmIk47wJU13y8UiimnZMh3dUmytVoXP/etrb2BXnvQ8YDV3fHZTQeRQaWzLXd6ivCfq+ r6jeuOkWuaF2jI/q7k9KUsaIBRrTqW1dq8RV4KhqObj914QR17DwEIEpVt4dle2Ykwmc iI+vEm/+rGzPMq4lJyQ9MgXQ2qxmRbvA+B9ihfXPWH06t26nO4NSXqXgsQCgvhBL+aP6 DNAQ== X-Gm-Message-State: AFqh2kpqA05sEtOQxjzqsnb0VkYs6wiBpttCotujUY/dpM0NW230M+Z8 PjbifSL+bi4VZecjW57YzVUzZ1g066HXw5Pwpbk= X-Google-Smtp-Source: AMrXdXv6FdimLMkCXtDmVXXxXPcy9W3VBah8SNz1zQ9fe0G5/7xRuEB16akq5sY1l/LQGD04IR0jhA== X-Received: by 2002:a05:600c:1d8e:b0:3d1:ebdf:d586 with SMTP id p14-20020a05600c1d8e00b003d1ebdfd586mr9670680wms.29.1674125160748; Thu, 19 Jan 2023 02:46:00 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id be12-20020a05600c1e8c00b003db06224953sm5332029wmb.41.2023.01.19.02.46.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 02:46:00 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 10:45:42 +0000 Message-Id: <20230119104544.9456-13-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119104544.9456-1-naush@raspberrypi.com> References: <20230119104544.9456-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 12/14] ipa: raspberrypi: Add lens position to DeviceStatus 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" Add the current frame's lens position (in dioptres) to the DeviceStatus structure. This value is obtained from the AfAlgorithm::getLensPosition() member function. Return this lens position back to the pipeline handler to store in the metadata field of the request. As a drive-by, fixup some inaccurate comments in the DeviceStatus structure. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Nick Hollinghurst nick.hollinghurst@raspberrypi.com --- src/ipa/raspberrypi/controller/device_status.h | 4 ++-- src/ipa/raspberrypi/raspberrypi.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ipa/raspberrypi/controller/device_status.h b/src/ipa/raspberrypi/controller/device_status.h index 4384c2149589..c45db7499f94 100644 --- a/src/ipa/raspberrypi/controller/device_status.h +++ b/src/ipa/raspberrypi/controller/device_status.h @@ -32,9 +32,9 @@ struct DeviceStatus { /* line length for the current frame */ libcamera::utils::Duration lineLength; double analogueGain; - /* 1.0/distance-in-metres, or 0 if unknown */ + /* 1.0/distance-in-metres */ std::optional lensPosition; - /* 1/f so that brightness quadruples when this doubles, or 0 if unknown */ + /* 1/f so that brightness quadruples when this doubles */ std::optional aperture; /* proportional to brightness with 0 = no flash, 1 = maximum flash */ std::optional flashIntensity; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index fbace14b1afe..5f7397e2ab21 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -586,6 +586,8 @@ void IPARPi::reportMetadata(unsigned int ipaContext) helper_->exposure(deviceStatus->frameLength, deviceStatus->lineLength).get()); if (deviceStatus->sensorTemperature) libcameraMetadata_.set(controls::SensorTemperature, *deviceStatus->sensorTemperature); + if (deviceStatus->lensPosition) + libcameraMetadata_.set(controls::LensPosition, *deviceStatus->lensPosition); } AgcStatus *agcStatus = rpiMetadata.getLocked("agc.status"); @@ -1352,6 +1354,11 @@ void IPARPi::fillDeviceStatus(const ControlList &sensorControls, unsigned int ip deviceStatus.analogueGain = helper_->gain(gainCode); deviceStatus.frameLength = mode_.height + vblank; + RPiController::AfAlgorithm *af = dynamic_cast( + controller_.getAlgorithm("af")); + if (af) + deviceStatus.lensPosition = af->getLensPosition(); + LOG(IPARPI, Debug) << "Metadata - " << deviceStatus; rpiMetadata_[ipaContext].set("device.status", deviceStatus); From patchwork Thu Jan 19 10:45:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18161 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 6B3DDC3295 for ; Thu, 19 Jan 2023 10:46:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2BA70625F4; Thu, 19 Jan 2023 11:46:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674125169; bh=PqEtAk0godw7WtFgpTuUq79jP2p798y7UHj990pIgDU=; 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=iZhgsXwM/QXVgxHSrA7iOin7rT40a6IBzebjVJUUVxK1WymHvNq8Y8EhDrV7wUo+1 SzQpnAuvhds+Z8HQiCl21UM7nKwRJGhFFGCEH2aGG1iy2EW7UleJxL4kQiVDC2j0Lf qR/ANOnTb489qlmh7Tf/wqIxCsYR/nX3ZFIAROARTHkBiw+cLbwzLD3jefWkgEuuHO 7IP6DdVtNR4GPvrenN1W0NXop6PGQONpF+MjJulZhACqM+QVv1tAUe8nJ9M0t/TJ1J fFKs/uGtDGJMvt2Qs41Nxx1/5S7uzGG/PCl/ypqcAi1t5/ofQzmZQHRNMBOMn8lIxv fkD/Eh5fLQ6WA== Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 361E1625E4 for ; Thu, 19 Jan 2023 11:46:02 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="kt8/VPph"; dkim-atps=neutral Received: by mail-wm1-x330.google.com with SMTP id j17so1187022wms.0 for ; Thu, 19 Jan 2023 02:46:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=MTN+cFSunGF/5BszoECrkpH7JBcfkSleqCVVOcEdx6s=; b=kt8/VPphDYXU39W4aRrkRvpCFdIiZB8Vo2okrl7Y89TiFHhBSsfd4WWm7laThsFU9v 4V9f0qXdQLKkGVJlfvQThGQcmqwN6YXoyYdfHx6u+cgRQzC+OArgxP9hjps8CRB9Wits JoPPZjaHCrJzrcwv5piaNQKtom7QVoISPL4k33VoJ0nfqBhcZSZnDX0+xuxCY3If7J5U 6oayu9hvj+pK5dahhO5ziAMrJcknesf7EtgWMHNd2TeNzg2f7MOI8tfseAtxocl9888t bVwKERef51wjpTQw4mhFEzCjv0KhS6uLHf1Faq5moaFa8gcLNaUsqCVmGlT11VAEkOiZ gSiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=MTN+cFSunGF/5BszoECrkpH7JBcfkSleqCVVOcEdx6s=; b=BEGNHwS1ktBr8KNZZKuMeAP77P3VrrWLk4ixbZsEMJOjW1KCQLk2PxO2IUEM6N5bOb ofE6bKbnmMTR6pgahMhkx0jTWAijR6Cp/jYtyeUsleYEMWJ9A1x22jtBfFIPjQLK3hOL JgJtU3sOP6QnSCy4Ck/yrFGIlMmtorrMeTdkzZuN+ildQ9uogzFAvejDHmEBGllUgnEk EzF8m+FeQEi+PTumxYeK/FZUIHjD7K6ygAYURBJOtfWT2VKjE0UnFyxyy8mdCBuk1lxT o5QGnF572tc7M/d2bbIMEclpXzn4TQDZkC4XyU8C7VpglhZ9UPkuanUUKh7vn5iO+7ZS NzoQ== X-Gm-Message-State: AFqh2ko7UIQxZ/0ugrRfsKlUttB8jcUKrxN9YSeHES4kJuR3Jesm2/KE Q/e3Qc9hG4QipZLzGSXmWkcbpBkObnxGDzLk3sE= X-Google-Smtp-Source: AMrXdXt5noD1uPgQLtWYrWIXbFplWvZgDVsp44C+nmIfvqZ5SwPMf8jZjmVe8VIA0/9ucbAarRelrw== X-Received: by 2002:a05:600c:3545:b0:3c6:e60f:3f4a with SMTP id i5-20020a05600c354500b003c6e60f3f4amr9827370wmq.1.1674125161452; Thu, 19 Jan 2023 02:46:01 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id be12-20020a05600c1e8c00b003db06224953sm5332029wmb.41.2023.01.19.02.46.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 02:46:01 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 10:45:43 +0000 Message-Id: <20230119104544.9456-14-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119104544.9456-1-naush@raspberrypi.com> References: <20230119104544.9456-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 13/14] libcamera: camera_sensor: Add Sony IMX708 sensor properties 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 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nick Hollinghurst The IMX708 sensor driver advertises its module variants (narrow/wide angle lens, IR block/pass) by modifying the media entity name string. So add duplicate entries for each variant. Signed-off-by: Nick Hollinghurst Signed-off-by: Naushir Patuck Reviewed-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Kieran Bingham --- src/libcamera/camera_sensor_properties.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/libcamera/camera_sensor_properties.cpp b/src/libcamera/camera_sensor_properties.cpp index c3c2caced906..3afd500ea3be 100644 --- a/src/libcamera/camera_sensor_properties.cpp +++ b/src/libcamera/camera_sensor_properties.cpp @@ -123,6 +123,22 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen */ }, } }, + { "imx708", { + .unitCellSize = { 1400, 1400 }, + .testPatternModes = {}, + } }, + { "imx708_noir", { + .unitCellSize = { 1400, 1400 }, + .testPatternModes = {}, + } }, + { "imx708_wide", { + .unitCellSize = { 1400, 1400 }, + .testPatternModes = {}, + } }, + { "imx708_wide_noir", { + .unitCellSize = { 1400, 1400 }, + .testPatternModes = {}, + } }, { "ov2740", { .unitCellSize = { 1400, 1400 }, .testPatternModes = { From patchwork Thu Jan 19 10:45:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18162 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 E9069C3294 for ; Thu, 19 Jan 2023 10:46:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AFDA6625EB; Thu, 19 Jan 2023 11:46:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674125170; bh=NFZHzx9tBB0J9ZDaep+GMl2UxKRQ5YnDca6InQjqL/0=; 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=dLzWPruozdhgnUqBHRt8uCBOvJWyzebqp11wJqptylXRljdXJq1jrdj5pzXjeXfgs 5opc5bf7epNFhzwcgBKqLopZ6soJks95caolKrw97FWGpDPKbR9mSGo7rkd6ogRsrw IECCcU0Tgsdn23R4fHKKAzhQf3pHj8VQcANp91jAUxF9ESZX1ythEPX8wWWLVdw4pn JKOayzQWs/tyxgAj3Z2GOyc2aW/cy5ROhMo8wiSfZNsnk1zEf5s1WE2CgUa5oWGHXr gPbJkVQzH/OtmweWAo2G2IwpsYoG1/KkGhK1wjjupOTUKdtlRAmmGUa//Y8iLd8yJa k6/nnZ8HJGiIg== 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 77FFB61EFC for ; Thu, 19 Jan 2023 11:46:04 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="O/o2aEdr"; dkim-atps=neutral Received: by mail-wm1-x334.google.com with SMTP id bg13-20020a05600c3c8d00b003d9712b29d2so3273396wmb.2 for ; Thu, 19 Jan 2023 02:46:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=uVD7+ljkS2v9d4lIabXXhsA4gNUDOo839+W0Zy3qys4=; b=O/o2aEdr/BWJDnMoLaTWXqdCdz6+uMlswJ/1NzukZoT+bFdfs9eYLD4TuJPzmDQNsV NOToEN37SFvE9UA0lFgDPxrPnxoBwJNqvm/FmiKwB/FFwyxZ7Mfkj9YasG2GcN3h0on/ FelBws/crHujNv06rh7py6n7Hf1nNZw9U4AvZw6s+P/HgccDR6VeyvGm20qOeabSUN5d D/v8jH45sB1l/9gYNGJ8XLqzubiLWqeoO81NhhqvVWjS4tX4eK3aM/EpGIZKDB7420WI df3gS9Nd826rWzrZfC5gqz6yAXfLqLlF0oPWL/6weWqH/oPJb3bwDV0OmAgDJ6d0ow8y 4Eiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=uVD7+ljkS2v9d4lIabXXhsA4gNUDOo839+W0Zy3qys4=; b=uXOJgmVb+p3OudUEc2+1x5/miA5q/f3gs9DO7mameuiao1J8XcgQNiAlMC15gmzuIq 384d3FY1m9qM5Bb87DWDEEmibmM1KulIuvY1/94aHzPpQxX5E8Y4Wuryr1PSJKiRy9FH AEYoijfNhVwqI0NJZFjRfF8GBNWCFnM48apA/Xrr2meWtwTMUP3litALzUjUfgLmjbf1 xvGyyUoNiL31TpvwFSDjYhX+GIiPDJBGrgsIeveNtZn/8Q5nX0tzGmrglQiKFoss/xJ0 5eF9HdtUmssIMXVhApztOeS30RLZdq8/dEzXESXwarzs8cARHTqpYZxT4lnklMHB4Sdu GALw== X-Gm-Message-State: AFqh2komMc4Og+0cx9/cLlAOqN880dSqR7lZoXAfPWR45Aqfn8z8j5+p OCiZAezYbkXFR7vOL6KwgbhWUpAgG1cMoSiLF5E= X-Google-Smtp-Source: AMrXdXtCepTYOe0ZIpiu5T5zA7G0THIsygv3yQ0l0eyq1VV5djIRvhVzlQT6ujClzZlBO2uKY9UF7A== X-Received: by 2002:a05:600c:1906:b0:3da:1d51:ef9d with SMTP id j6-20020a05600c190600b003da1d51ef9dmr10201352wmq.15.1674125162311; Thu, 19 Jan 2023 02:46:02 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id be12-20020a05600c1e8c00b003db06224953sm5332029wmb.41.2023.01.19.02.46.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 02:46:01 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 10:45:44 +0000 Message-Id: <20230119104544.9456-15-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230119104544.9456-1-naush@raspberrypi.com> References: <20230119104544.9456-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 14/14] ipa: raspberrypi: Add support for the Sony IMX708 sensor 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 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nick Hollinghurst Add support for Raspberry Pi Camera 3 modules (Sony IMX708 camera sensor) to the Raspberry Pi IPA. These modules are available in either normal or wide angle lens, both with IR or no IR cut options, giving a total for 4 variants. Provide IQ tuning files for all four variants. The IMX708 camera helper additionally parses PDAF and HDR histogram data that is provided in the embedded data stream from Unicam. Signed-off-by: Nick Hollinghurst Signed-off-by: Naushir Patuck Reviewed-by: Naushir Patuck Reviewed-by: David Plowman --- src/ipa/raspberrypi/cam_helper_imx708.cpp | 350 +++++++++++ src/ipa/raspberrypi/data/imx708.json | 559 ++++++++++++++++++ src/ipa/raspberrypi/data/imx708_noir.json | 559 ++++++++++++++++++ src/ipa/raspberrypi/data/imx708_wide.json | 462 +++++++++++++++ .../raspberrypi/data/imx708_wide_noir.json | 462 +++++++++++++++ src/ipa/raspberrypi/data/meson.build | 4 + src/ipa/raspberrypi/meson.build | 1 + 7 files changed, 2397 insertions(+) create mode 100644 src/ipa/raspberrypi/cam_helper_imx708.cpp create mode 100644 src/ipa/raspberrypi/data/imx708.json create mode 100644 src/ipa/raspberrypi/data/imx708_noir.json create mode 100644 src/ipa/raspberrypi/data/imx708_wide.json create mode 100644 src/ipa/raspberrypi/data/imx708_wide_noir.json diff --git a/src/ipa/raspberrypi/cam_helper_imx708.cpp b/src/ipa/raspberrypi/cam_helper_imx708.cpp new file mode 100644 index 000000000000..4c43c8e7fb7d --- /dev/null +++ b/src/ipa/raspberrypi/cam_helper_imx708.cpp @@ -0,0 +1,350 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2022, Raspberry Pi Ltd + * + * cam_helper_imx708.cpp - camera helper for imx708 sensor + */ + +#include +#include +#include +#include + +#include + +#include "controller/pdaf_data.h" + +#include "cam_helper.h" +#include "md_parser.h" + +using namespace RPiController; +using namespace libcamera; +using libcamera::utils::Duration; + +namespace libcamera { +LOG_DECLARE_CATEGORY(IPARPI) +} + +/* + * We care about two gain registers and a pair of exposure registers. Their + * I2C addresses from the Sony imx708 datasheet: + */ +constexpr uint32_t expHiReg = 0x0202; +constexpr uint32_t expLoReg = 0x0203; +constexpr uint32_t gainHiReg = 0x0204; +constexpr uint32_t gainLoReg = 0x0205; +constexpr uint32_t frameLengthHiReg = 0x0340; +constexpr uint32_t frameLengthLoReg = 0x0341; +constexpr uint32_t lineLengthHiReg = 0x0342; +constexpr uint32_t lineLengthLoReg = 0x0343; +constexpr uint32_t temperatureReg = 0x013a; +constexpr std::initializer_list registerList = + { expHiReg, expLoReg, gainHiReg, gainLoReg, lineLengthHiReg, + lineLengthLoReg, frameLengthHiReg, frameLengthLoReg, temperatureReg }; + +class CamHelperImx708 : public CamHelper +{ +public: + CamHelperImx708(); + uint32_t gainCode(double gain) const override; + double gain(uint32_t gain_code) const override; + void prepare(libcamera::Span buffer, Metadata &metadata) override; + void process(StatisticsPtr &stats, Metadata &metadata) override; + std::pair getBlanking(Duration &exposure, Duration minFrameDuration, + Duration maxFrameDuration) const override; + void getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay, int &hblankDelay) const override; + bool sensorEmbeddedDataPresent() const override; + double getModeSensitivity(const CameraMode &mode) const override; + unsigned int hideFramesModeSwitch() const override { return 1; } // seems to be required for HDR + +private: + /* + * Smallest difference between the frame length and integration time, + * in units of lines. + */ + static constexpr int frameIntegrationDiff = 22; + /* Maximum frame length allowable for long exposure calculations. */ + static constexpr int frameLengthMax = 0xffdc; + /* Largest long exposure scale factor given as a left shift on the frame length. */ + static constexpr int longExposureShiftMax = 7; + + void populateMetadata(const MdParser::RegisterMap ®isters, + Metadata &metadata) const override; + + static bool parsePdafData(const uint8_t *ptr, size_t len, unsigned bpp, + PdafData &pdaf); + + bool parseAEHist(const uint8_t *ptr, size_t len, unsigned bpp); + void putAGCStatistics(StatisticsPtr stats); + + uint32_t aeHistLinear_[128]; + uint32_t aeHistAverage_; + bool aeHistValid_; +}; + +CamHelperImx708::CamHelperImx708() + : CamHelper(std::make_unique(registerList), frameIntegrationDiff), + aeHistLinear_{ 0 }, aeHistAverage_(0), aeHistValid_(false) +{ +} + +uint32_t CamHelperImx708::gainCode(double gain) const +{ + return static_cast(1024 - 1024 / gain); +} + +double CamHelperImx708::gain(uint32_t gain_code) const +{ + return 1024.0 / (1024 - gain_code); +} + +void CamHelperImx708::prepare(libcamera::Span buffer, Metadata &metadata) +{ + MdParser::RegisterMap registers; + DeviceStatus deviceStatus; + + LOG(IPARPI, Debug) << "Embedded buffer size: " << buffer.size(); + + if (metadata.get("device.status", deviceStatus)) { + LOG(IPARPI, Error) << "DeviceStatus not found from DelayedControls"; + return; + } + + parseEmbeddedData(buffer, metadata); + + /* + * Parse PDAF data, which we expect to occupy the third scanline + * of embedded data. As PDAF is quite sensor-specific, it's parsed here. + */ + size_t bytesPerLine = (mode_.width * mode_.bitdepth) >> 3; + + if (buffer.size() > 2 * bytesPerLine) { + PdafData pdaf; + if (parsePdafData(&buffer[2 * bytesPerLine], + buffer.size() - 2 * bytesPerLine, + mode_.bitdepth, pdaf)) + metadata.set("pdaf.data", pdaf); + } + + /* Parse AE-HIST data where present */ + if (buffer.size() > 3 * bytesPerLine) { + aeHistValid_ = parseAEHist(&buffer[3 * bytesPerLine], + buffer.size() - 3 * bytesPerLine, + mode_.bitdepth); + } + + /* + * The DeviceStatus struct is first populated with values obtained from + * DelayedControls. If this reports frame length is > frameLengthMax, + * it means we are using a long exposure mode. Since the long exposure + * scale factor is not returned back through embedded data, we must rely + * on the existing exposure lines and frame length values returned by + * DelayedControls. + * + * Otherwise, all values are updated with what is reported in the + * embedded data. + */ + if (deviceStatus.frameLength > frameLengthMax) { + DeviceStatus parsedDeviceStatus; + + metadata.get("device.status", parsedDeviceStatus); + parsedDeviceStatus.shutterSpeed = deviceStatus.shutterSpeed; + parsedDeviceStatus.frameLength = deviceStatus.frameLength; + metadata.set("device.status", parsedDeviceStatus); + + LOG(IPARPI, Debug) << "Metadata updated for long exposure: " + << parsedDeviceStatus; + } +} + +void CamHelperImx708::process(StatisticsPtr &stats, [[maybe_unused]] Metadata &metadata) +{ + if (aeHistValid_) + putAGCStatistics(stats); +} + +std::pair CamHelperImx708::getBlanking(Duration &exposure, + Duration minFrameDuration, + Duration maxFrameDuration) const +{ + uint32_t frameLength, exposureLines; + unsigned int shift = 0; + + auto [vblank, hblank] = CamHelper::getBlanking(exposure, minFrameDuration, + maxFrameDuration); + + frameLength = mode_.height + vblank; + Duration lineLength = hblankToLineLength(hblank); + + /* + * Check if the frame length calculated needs to be setup for long + * exposure mode. This will require us to use a long exposure scale + * factor provided by a shift operation in the sensor. + */ + while (frameLength > frameLengthMax) { + if (++shift > longExposureShiftMax) { + shift = longExposureShiftMax; + frameLength = frameLengthMax; + break; + } + frameLength >>= 1; + } + + if (shift) { + /* Account for any rounding in the scaled frame length value. */ + frameLength <<= shift; + exposureLines = CamHelper::exposureLines(exposure, lineLength); + exposureLines = std::min(exposureLines, frameLength - frameIntegrationDiff); + exposure = CamHelper::exposure(exposureLines, lineLength); + } + + return { frameLength - mode_.height, hblank }; +} + +void CamHelperImx708::getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay, int &hblankDelay) const +{ + exposureDelay = 2; + gainDelay = 2; + vblankDelay = 3; + hblankDelay = 3; +} + +bool CamHelperImx708::sensorEmbeddedDataPresent() const +{ + return true; +} + +double CamHelperImx708::getModeSensitivity(const CameraMode &mode) const +{ + /* In binned modes, sensitivity increases by a factor of 2 */ + return (mode.width > 2304) ? 1.0 : 2.0; +} + +void CamHelperImx708::populateMetadata(const MdParser::RegisterMap ®isters, + Metadata &metadata) const +{ + DeviceStatus deviceStatus; + + deviceStatus.lineLength = lineLengthPckToDuration(registers.at(lineLengthHiReg) * 256 + + registers.at(lineLengthLoReg)); + deviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg), + deviceStatus.lineLength); + deviceStatus.analogueGain = gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg)); + deviceStatus.frameLength = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); + deviceStatus.sensorTemperature = std::clamp(registers.at(temperatureReg), -20, 80); + + metadata.set("device.status", deviceStatus); +} + +bool CamHelperImx708::parsePdafData(const uint8_t *ptr, size_t len, + unsigned bpp, PdafData &pdaf) +{ + size_t step = bpp >> 1; /* bytes per PDAF grid entry */ + + if (bpp < 10 || bpp > 12 || len < 194 * step || ptr[0] != 0 || ptr[1] >= 0x40) { + LOG(IPARPI, Error) << "PDAF data in unsupported format"; + return false; + } + + ptr += 2 * step; + for (unsigned i = 0; i < PDAF_DATA_ROWS; ++i) { + for (unsigned j = 0; j < PDAF_DATA_COLS; ++j) { + unsigned c = (ptr[0] << 3) | (ptr[1] >> 5); + int p = (((ptr[1] & 0x0F) - (ptr[1] & 0x10)) << 6) | (ptr[2] >> 2); + pdaf.conf[i][j] = c; + pdaf.phase[i][j] = c ? p : 0; + ptr += step; + } + } + + return true; +} + +bool CamHelperImx708::parseAEHist(const uint8_t *ptr, size_t len, unsigned bpp) +{ + static const uint32_t ISP_PIPELINE_BITS = 13; + uint64_t count = 0, sum = 0; + size_t step = bpp >> 1; /* bytes per histogram bin */ + + if (len < 144 * step) + return false; + + /* + * Read the 128 bin linear histogram, which by default covers + * the full range of the HDR shortest exposure (small values are + * expected to dominate, so pixel-value resolution will be poor). + */ + for (unsigned i = 0; i < 128; ++i) { + if (ptr[3] != 0x55) + return false; + uint32_t c = (ptr[0] << 14) + (ptr[1] << 6) + (ptr[2] >> 2); + aeHistLinear_[i] = c >> 2; /* pixels to quads */ + if (i != 0) { + count += c; + sum += c * + (i * (1u << (ISP_PIPELINE_BITS - 7)) + + (1u << (ISP_PIPELINE_BITS - 8))); + } + ptr += step; + } + + /* + * Now use the first 9 bins of the log histogram (these should be + * subdivisions of the smallest linear bin), to get a more accurate + * average value. Don't assume that AEHIST1_AVERAGE is present. + */ + for (unsigned i = 0; i < 9; ++i) { + if (ptr[3] != 0x55) + return false; + uint32_t c = (ptr[0] << 14) + (ptr[1] << 6) + (ptr[2] >> 2); + count += c; + sum += c * + ((3u << ISP_PIPELINE_BITS) >> (17 - i)); + ptr += step; + } + if ((unsigned)((ptr[0] << 12) + (ptr[1] << 4) + (ptr[2] >> 4)) != + aeHistLinear_[1]) { + LOG(IPARPI, Error) << "Lin/Log histogram mismatch"; + return false; + } + + aeHistAverage_ = count ? (sum / count) : 0; + + return count != 0; +} + +void CamHelperImx708::putAGCStatistics(StatisticsPtr stats) +{ + /* + * For HDR mode, copy sensor's AE/AGC statistics over ISP's, so the + * AGC algorithm sees a linear response to exposure and gain changes. + * + * Histogram: Just copy the "raw" histogram over the tone-mapped one, + * although they have different distributions (raw values are lower). + * Tuning should either ignore it, or constrain for highlights only. + * + * Average: Overwrite all regional averages with a global raw average, + * scaled by a fiddle-factor so that a conventional (non-HDR) y_target + * of e.g. 0.17 will map to a suitable level for HDR. + */ + memcpy(stats->hist[0].g_hist, aeHistLinear_, sizeof(stats->hist[0].g_hist)); + + constexpr unsigned int HdrHeadroomFactor = 4; + uint64_t v = HdrHeadroomFactor * aeHistAverage_; + for (int i = 0; i < AGC_REGIONS; i++) { + struct bcm2835_isp_stats_region &r = stats->agc_stats[i]; + r.r_sum = r.b_sum = r.g_sum = r.counted * v; + } +} + +static CamHelper *create() +{ + return new CamHelperImx708(); +} + +static RegisterCamHelper reg("imx708", &create); +static RegisterCamHelper regWide("imx708_wide", &create); +static RegisterCamHelper regNoIr("imx708_noir", &create); +static RegisterCamHelper regWideNoIr("imx708_wide_noir", &create); diff --git a/src/ipa/raspberrypi/data/imx708.json b/src/ipa/raspberrypi/data/imx708.json new file mode 100644 index 000000000000..c38b2d4cf256 --- /dev/null +++ b/src/ipa/raspberrypi/data/imx708.json @@ -0,0 +1,559 @@ +{ + "version": 2.0, + "target": "bcm2835", + "algorithms": [ + { + "rpi.black_level": + { + "black_level": 4096 + } + }, + { + "rpi.dpc": { } + }, + { + "rpi.lux": + { + "reference_shutter_speed": 10672, + "reference_gain": 1.12, + "reference_aperture": 1.0, + "reference_lux": 977, + "reference_Y": 8627 + } + }, + { + "rpi.noise": + { + "reference_constant": 16.0, + "reference_slope": 4.0 + } + }, + { + "rpi.geq": + { + "offset": 215, + "slope": 0.00287 + } + }, + { + "rpi.sdn": { } + }, + { + "rpi.awb": + { + "priors": [ + { + "lux": 0, + "prior": + [ + 2000, 1.0, + 3000, 0.0, + 13000, 0.0 + ] + }, + { + "lux": 800, + "prior": + [ + 2000, 0.0, + 6000, 2.0, + 13000, 2.0 + ] + }, + { + "lux": 1500, + "prior": + [ + 2000, 0.0, + 4000, 1.0, + 6000, 6.0, + 6500, 7.0, + 7000, 1.0, + 13000, 1.0 + ] + } + ], + "modes": + { + "auto": + { + "lo": 2500, + "hi": 8000 + }, + "incandescent": + { + "lo": 2500, + "hi": 3000 + }, + "tungsten": + { + "lo": 3000, + "hi": 3500 + }, + "fluorescent": + { + "lo": 4000, + "hi": 4700 + }, + "indoor": + { + "lo": 3000, + "hi": 5000 + }, + "daylight": + { + "lo": 5500, + "hi": 6500 + }, + "cloudy": + { + "lo": 7000, + "hi": 8600 + } + }, + "bayes": 1, + "ct_curve": + [ + 2498.0, 0.8733, 0.2606, + 2821.0, 0.7707, 0.3245, + 2925.0, 0.7338, 0.3499, + 2926.0, 0.7193, 0.3603, + 2951.0, 0.7144, 0.3639, + 2954.0, 0.7111, 0.3663, + 3578.0, 0.6038, 0.4516, + 3717.0, 0.5861, 0.4669, + 3784.0, 0.5786, 0.4737, + 4485.0, 0.5113, 0.5368, + 4615.0, 0.4994, 0.5486, + 4671.0, 0.4927, 0.5554, + 5753.0, 0.4274, 0.6246, + 5773.0, 0.4265, 0.6256, + 7433.0, 0.3723, 0.6881 + ], + "sensitivity_r": 1.05, + "sensitivity_b": 1.05, + "transverse_pos": 0.03148, + "transverse_neg": 0.03061 + } + }, + { + "rpi.agc": + { + "metering_modes": + { + "centre-weighted": + { + "weights": [ 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0 ] + }, + "spot": + { + "weights": [ 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] + }, + "matrix": + { + "weights": [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] + } + }, + "exposure_modes": + { + "normal": + { + "shutter": [ 100, 15000, 30000, 60000, 120000 ], + "gain": [ 1.0, 1.0, 2.0, 4.0, 6.0 ] + }, + "short": + { + "shutter": [ 100, 5000, 10000, 20000, 120000 ], + "gain": [ 1.0, 2.0, 4.0, 6.0, 6.0 ] + } + }, + "constraint_modes": + { + "normal": [ + { + "bound": "LOWER", + "q_lo": 0.98, + "q_hi": 1.0, + "y_target": + [ + 0, 0.2, + 1000, 0.2 + ] + } + ], + "highlight": [ + { + "bound": "LOWER", + "q_lo": 0.98, + "q_hi": 1.0, + "y_target": + [ + 0, 0.2, + 1000, 0.2 + ] + }, + { + "bound": "UPPER", + "q_lo": 0.98, + "q_hi": 1.0, + "y_target": + [ + 0, 0.8, + 1000, 0.8 + ] + } + ] + }, + "y_target": + [ + 0, 0.16, + 1000, 0.165, + 10000, 0.17 + ], + "startup_frames": 5, + "convergence_frames": 6, + "speed": 0.15 + } + }, + { + "rpi.alsc": + { + "omega": 1.3, + "n_iter": 100, + "luminance_strength": 0.5, + "calibrations_Cr": [ + { + "ct": 3000, + "table": + [ + 1.562, 1.566, 1.566, 1.556, 1.533, 1.506, 1.475, 1.475, 1.475, 1.475, 1.506, 1.533, 1.555, 1.563, 1.562, 1.555, + 1.563, 1.564, 1.561, 1.538, 1.508, 1.482, 1.449, 1.436, 1.436, 1.449, 1.481, 1.508, 1.537, 1.557, 1.558, 1.557, + 1.564, 1.563, 1.554, 1.522, 1.482, 1.449, 1.421, 1.403, 1.403, 1.419, 1.449, 1.481, 1.519, 1.549, 1.557, 1.559, + 1.564, 1.563, 1.545, 1.506, 1.462, 1.421, 1.403, 1.378, 1.378, 1.402, 1.419, 1.459, 1.503, 1.541, 1.557, 1.559, + 1.564, 1.562, 1.537, 1.494, 1.447, 1.404, 1.378, 1.364, 1.364, 1.377, 1.402, 1.444, 1.491, 1.532, 1.556, 1.559, + 1.564, 1.559, 1.532, 1.487, 1.438, 1.395, 1.365, 1.359, 1.359, 1.364, 1.393, 1.436, 1.484, 1.527, 1.555, 1.558, + 1.564, 1.559, 1.532, 1.487, 1.438, 1.395, 1.365, 1.356, 1.356, 1.364, 1.393, 1.436, 1.484, 1.527, 1.554, 1.557, + 1.564, 1.561, 1.536, 1.492, 1.444, 1.402, 1.374, 1.364, 1.363, 1.373, 1.401, 1.442, 1.489, 1.531, 1.554, 1.557, + 1.564, 1.563, 1.544, 1.504, 1.458, 1.418, 1.397, 1.374, 1.374, 1.395, 1.416, 1.456, 1.501, 1.538, 1.556, 1.557, + 1.564, 1.562, 1.551, 1.518, 1.477, 1.441, 1.418, 1.397, 1.397, 1.416, 1.438, 1.474, 1.514, 1.546, 1.556, 1.556, + 1.562, 1.562, 1.558, 1.534, 1.499, 1.476, 1.441, 1.426, 1.426, 1.438, 1.473, 1.496, 1.531, 1.552, 1.556, 1.555, + 1.561, 1.564, 1.564, 1.552, 1.525, 1.497, 1.466, 1.461, 1.461, 1.464, 1.495, 1.523, 1.548, 1.556, 1.556, 1.552 + ] + }, + { + "ct": 5000, + "table": + [ + 2.609, 2.616, 2.617, 2.607, 2.573, 2.527, 2.483, 2.481, 2.481, 2.483, 2.529, 2.573, 2.604, 2.613, 2.613, 2.604, + 2.609, 2.615, 2.608, 2.576, 2.533, 2.489, 2.439, 2.418, 2.418, 2.439, 2.491, 2.532, 2.577, 2.605, 2.609, 2.607, + 2.611, 2.611, 2.597, 2.551, 2.489, 2.439, 2.391, 2.364, 2.364, 2.391, 2.439, 2.491, 2.551, 2.592, 2.607, 2.609, + 2.612, 2.608, 2.583, 2.526, 2.457, 2.391, 2.362, 2.318, 2.318, 2.362, 2.391, 2.458, 2.526, 2.581, 2.607, 2.611, + 2.612, 2.604, 2.571, 2.507, 2.435, 2.362, 2.317, 2.293, 2.294, 2.318, 2.363, 2.434, 2.508, 2.568, 2.604, 2.612, + 2.611, 2.602, 2.564, 2.496, 2.419, 2.349, 2.293, 2.284, 2.284, 2.294, 2.347, 2.421, 2.497, 2.562, 2.603, 2.611, + 2.609, 2.601, 2.564, 2.496, 2.419, 2.349, 2.293, 2.278, 2.278, 2.294, 2.347, 2.421, 2.497, 2.562, 2.602, 2.609, + 2.609, 2.602, 2.568, 2.503, 2.429, 2.361, 2.311, 2.292, 2.292, 2.309, 2.357, 2.429, 2.504, 2.567, 2.602, 2.609, + 2.606, 2.604, 2.579, 2.519, 2.449, 2.384, 2.348, 2.311, 2.311, 2.346, 2.383, 2.449, 2.521, 2.577, 2.604, 2.608, + 2.604, 2.603, 2.586, 2.537, 2.474, 2.418, 2.384, 2.348, 2.348, 2.383, 2.417, 2.476, 2.538, 2.586, 2.601, 2.603, + 2.603, 2.605, 2.596, 2.561, 2.508, 2.474, 2.418, 2.396, 2.396, 2.417, 2.474, 2.511, 2.562, 2.596, 2.603, 2.602, + 2.601, 2.607, 2.606, 2.589, 2.549, 2.507, 2.456, 2.454, 2.454, 2.458, 2.508, 2.554, 2.594, 2.605, 2.605, 2.602 + ] + } + ], + "calibrations_Cb": [ + { + "ct": 3000, + "table": + [ + 3.221, 3.226, 3.231, 3.236, 3.239, 3.243, 3.245, 3.247, 3.249, 3.253, 3.255, 3.254, 3.253, 3.242, 3.235, 3.226, + 3.225, 3.231, 3.235, 3.238, 3.241, 3.244, 3.246, 3.247, 3.249, 3.254, 3.256, 3.255, 3.252, 3.248, 3.241, 3.232, + 3.226, 3.234, 3.239, 3.243, 3.243, 3.245, 3.247, 3.248, 3.251, 3.255, 3.256, 3.256, 3.254, 3.249, 3.244, 3.236, + 3.232, 3.238, 3.245, 3.245, 3.246, 3.247, 3.248, 3.251, 3.251, 3.256, 3.257, 3.257, 3.256, 3.254, 3.249, 3.239, + 3.232, 3.243, 3.246, 3.246, 3.246, 3.247, 3.248, 3.251, 3.253, 3.257, 3.258, 3.258, 3.257, 3.256, 3.254, 3.239, + 3.232, 3.242, 3.246, 3.247, 3.246, 3.246, 3.248, 3.251, 3.252, 3.253, 3.256, 3.255, 3.255, 3.254, 3.251, 3.239, + 3.233, 3.241, 3.244, 3.245, 3.244, 3.245, 3.246, 3.249, 3.251, 3.252, 3.253, 3.252, 3.252, 3.252, 3.249, 3.238, + 3.238, 3.241, 3.246, 3.246, 3.245, 3.245, 3.247, 3.249, 3.251, 3.252, 3.253, 3.253, 3.252, 3.252, 3.249, 3.239, + 3.235, 3.241, 3.245, 3.245, 3.245, 3.245, 3.246, 3.247, 3.251, 3.254, 3.253, 3.255, 3.256, 3.255, 3.251, 3.241, + 3.226, 3.235, 3.241, 3.241, 3.241, 3.241, 3.243, 3.245, 3.246, 3.252, 3.253, 3.254, 3.256, 3.254, 3.241, 3.237, + 3.205, 3.213, 3.213, 3.214, 3.214, 3.214, 3.214, 3.213, 3.213, 3.216, 3.218, 3.216, 3.214, 3.213, 3.211, 3.208, + 3.205, 3.205, 3.212, 3.212, 3.212, 3.213, 3.211, 3.211, 3.211, 3.213, 3.216, 3.214, 3.213, 3.211, 3.208, 3.196 + ] + }, + { + "ct": 5000, + "table": + [ + 1.645, 1.646, 1.649, 1.653, 1.654, 1.657, 1.659, 1.661, 1.663, 1.662, 1.661, 1.659, 1.656, 1.651, 1.645, 1.642, + 1.646, 1.649, 1.652, 1.654, 1.656, 1.659, 1.662, 1.663, 1.664, 1.664, 1.662, 1.661, 1.657, 1.653, 1.649, 1.644, + 1.648, 1.652, 1.654, 1.656, 1.658, 1.662, 1.665, 1.668, 1.668, 1.668, 1.665, 1.662, 1.658, 1.655, 1.652, 1.646, + 1.649, 1.653, 1.656, 1.658, 1.661, 1.665, 1.667, 1.671, 1.673, 1.671, 1.668, 1.663, 1.659, 1.656, 1.654, 1.647, + 1.649, 1.655, 1.657, 1.659, 1.661, 1.666, 1.671, 1.674, 1.675, 1.673, 1.671, 1.664, 1.659, 1.656, 1.654, 1.648, + 1.649, 1.654, 1.656, 1.659, 1.661, 1.666, 1.673, 1.676, 1.676, 1.675, 1.671, 1.664, 1.659, 1.656, 1.654, 1.648, + 1.649, 1.654, 1.656, 1.658, 1.659, 1.665, 1.672, 1.675, 1.675, 1.674, 1.668, 1.662, 1.658, 1.655, 1.654, 1.646, + 1.652, 1.655, 1.657, 1.659, 1.661, 1.665, 1.671, 1.673, 1.673, 1.672, 1.668, 1.662, 1.658, 1.655, 1.654, 1.647, + 1.652, 1.655, 1.657, 1.659, 1.661, 1.664, 1.667, 1.671, 1.672, 1.668, 1.666, 1.662, 1.659, 1.656, 1.654, 1.647, + 1.647, 1.652, 1.655, 1.656, 1.657, 1.661, 1.664, 1.665, 1.665, 1.665, 1.663, 1.661, 1.657, 1.655, 1.647, 1.647, + 1.639, 1.642, 1.644, 1.645, 1.646, 1.648, 1.648, 1.648, 1.649, 1.649, 1.649, 1.646, 1.645, 1.642, 1.639, 1.636, + 1.639, 1.641, 1.642, 1.644, 1.645, 1.646, 1.647, 1.647, 1.648, 1.648, 1.647, 1.645, 1.642, 1.639, 1.636, 1.633 + ] + } + ], + "luminance_lut": + [ + 2.644, 2.396, 2.077, 1.863, 1.682, 1.535, 1.392, 1.382, 1.382, 1.382, 1.515, 1.657, 1.826, 2.035, 2.351, 2.604, + 2.497, 2.229, 1.947, 1.733, 1.539, 1.424, 1.296, 1.249, 1.249, 1.285, 1.401, 1.519, 1.699, 1.908, 2.183, 2.456, + 2.389, 2.109, 1.848, 1.622, 1.424, 1.296, 1.201, 1.146, 1.146, 1.188, 1.285, 1.401, 1.591, 1.811, 2.065, 2.347, + 2.317, 2.026, 1.771, 1.535, 1.339, 1.201, 1.145, 1.069, 1.069, 1.134, 1.188, 1.318, 1.505, 1.734, 1.983, 2.273, + 2.276, 1.972, 1.715, 1.474, 1.281, 1.148, 1.069, 1.033, 1.024, 1.065, 1.134, 1.262, 1.446, 1.679, 1.929, 2.233, + 2.268, 1.941, 1.682, 1.441, 1.251, 1.119, 1.033, 1.013, 1.013, 1.024, 1.105, 1.231, 1.415, 1.649, 1.898, 2.227, + 2.268, 1.941, 1.682, 1.441, 1.251, 1.119, 1.033, 1.001, 1.001, 1.024, 1.105, 1.231, 1.415, 1.649, 1.898, 2.227, + 2.268, 1.951, 1.694, 1.456, 1.265, 1.131, 1.044, 1.026, 1.019, 1.039, 1.118, 1.246, 1.429, 1.663, 1.912, 2.227, + 2.291, 1.992, 1.738, 1.505, 1.311, 1.175, 1.108, 1.044, 1.041, 1.106, 1.161, 1.292, 1.478, 1.707, 1.955, 2.252, + 2.347, 2.058, 1.803, 1.581, 1.384, 1.245, 1.175, 1.108, 1.108, 1.161, 1.239, 1.364, 1.551, 1.773, 2.023, 2.311, + 2.438, 2.156, 1.884, 1.674, 1.484, 1.373, 1.245, 1.199, 1.199, 1.239, 1.363, 1.463, 1.647, 1.858, 2.123, 2.406, + 2.563, 2.305, 1.998, 1.792, 1.615, 1.472, 1.339, 1.322, 1.322, 1.326, 1.456, 1.593, 1.767, 1.973, 2.273, 2.532 + ], + "sigma": 0.00178, + "sigma_Cb": 0.00217 + } + }, + { + "rpi.contrast": + { + "ce_enable": 1, + "gamma_curve": + [ + 0, 0, + 1024, 5040, + 2048, 9338, + 3072, 12356, + 4096, 15312, + 5120, 18051, + 6144, 20790, + 7168, 23193, + 8192, 25744, + 9216, 27942, + 10240, 30035, + 11264, 32005, + 12288, 33975, + 13312, 35815, + 14336, 37600, + 15360, 39168, + 16384, 40642, + 18432, 43379, + 20480, 45749, + 22528, 47753, + 24576, 49621, + 26624, 51253, + 28672, 52698, + 30720, 53796, + 32768, 54876, + 36864, 57012, + 40960, 58656, + 45056, 59954, + 49152, 61183, + 53248, 62355, + 57344, 63419, + 61440, 64476, + 65535, 65535 + ] + } + }, + { + "rpi.ccm": + { + "ccms": [ + { + "ct": 2498, + "ccm": + [ + 1.14912, 0.28638, -0.43551, + -0.49691, 1.60391, -0.10701, + -0.10513, -1.09534, 2.20047 + ] + }, + { + "ct": 2821, + "ccm": + [ + 1.18251, 0.15501, -0.33752, + -0.44304, 1.58495, -0.14191, + -0.05077, -0.96422, 2.01498 + ] + }, + { + "ct": 2925, + "ccm": + [ + 1.18668, 0.00195, -0.18864, + -0.41617, 1.50514, -0.08897, + -0.02675, -0.91143, 1.93818 + ] + }, + { + "ct": 2926, + "ccm": + [ + 1.50948, -0.44421, -0.06527, + -0.37241, 1.41726, -0.04486, + 0.07098, -0.84694, 1.77596 + ] + }, + { + "ct": 2951, + "ccm": + [ + 1.52743, -0.47333, -0.05411, + -0.36485, 1.40764, -0.04279, + 0.08672, -0.90479, 1.81807 + ] + }, + { + "ct": 2954, + "ccm": + [ + 1.51683, -0.46841, -0.04841, + -0.36288, 1.39914, -0.03625, + 0.06421, -0.82034, 1.75613 + ] + }, + { + "ct": 3578, + "ccm": + [ + 1.59888, -0.59105, -0.00784, + -0.29366, 1.32037, -0.02671, + 0.06627, -0.76465, 1.69838 + ] + }, + { + "ct": 3717, + "ccm": + [ + 1.59063, -0.58059, -0.01003, + -0.29583, 1.32715, -0.03132, + 0.03613, -0.67431, 1.63817 + ] + }, + { + "ct": 3784, + "ccm": + [ + 1.59379, -0.58861, -0.00517, + -0.29178, 1.33292, -0.04115, + 0.03541, -0.66162, 1.62622 + ] + }, + { + "ct": 4485, + "ccm": + [ + 1.40761, -0.34561, -0.06201, + -0.32388, 1.57221, -0.24832, + -0.01014, -0.63427, 1.64441 + ] + }, + { + "ct": 4615, + "ccm": + [ + 1.41537, -0.35832, -0.05705, + -0.31429, 1.56019, -0.24591, + -0.01761, -0.61859, 1.63621 + ] + }, + { + "ct": 4671, + "ccm": + [ + 1.42941, -0.38178, -0.04764, + -0.31421, 1.55925, -0.24504, + -0.01141, -0.62987, 1.64129 + ] + }, + { + "ct": 5753, + "ccm": + [ + 1.64549, -0.63329, -0.01221, + -0.22431, 1.36423, -0.13992, + -0.00831, -0.55373, 1.56204 + ] + }, + { + "ct": 5773, + "ccm": + [ + 1.63668, -0.63557, -0.00111, + -0.21919, 1.36234, -0.14315, + -0.00399, -0.57428, 1.57827 + ] + }, + { + "ct": 7433, + "ccm": + [ + 1.36007, -0.09277, -0.26729, + -0.36886, 2.09249, -0.72363, + -0.12573, -0.76761, 1.89334 + ] + }, + { + "ct": 55792, + "ccm": + [ + 1.65091, -0.63689, -0.01401, + -0.22277, 1.35752, -0.13475, + -0.00943, -0.55091, 1.56033 + ] + } + ] + } + }, + { + "rpi.sharpen": { } + }, + { + "rpi.focus": { } + }, + { + "rpi.af": + { + "ranges": + { + "normal": + { + "min": 0.0, + "max": 12.0, + "default": 1.0 + }, + "macro": + { + "min": 3.0, + "max": 15.0, + "default": 4.0 + } + }, + "speeds": + { + "normal": + { + "step_coarse": 1.0, + "step_fine": 0.25, + "contrast_ratio": 0.75, + "pdaf_gain": -0.02, + "pdaf_squelch": 0.125, + "max_slew": 2.0, + "pdaf_frames": 20, + "dropout_frames": 6, + "step_frames": 4 + } + }, + "conf_epsilon": 8, + "conf_thresh": 16, + "conf_clip": 512, + "skip_frames": 5, + "map": [ 0.0, 445, 15.0, 925 ] + } + } + ] +} diff --git a/src/ipa/raspberrypi/data/imx708_noir.json b/src/ipa/raspberrypi/data/imx708_noir.json new file mode 100644 index 000000000000..082274e34c53 --- /dev/null +++ b/src/ipa/raspberrypi/data/imx708_noir.json @@ -0,0 +1,559 @@ +{ + "version": 2.0, + "target": "bcm2835", + "algorithms": [ + { + "rpi.black_level": + { + "black_level": 4096 + } + }, + { + "rpi.dpc": { } + }, + { + "rpi.lux": + { + "reference_shutter_speed": 10672, + "reference_gain": 1.12, + "reference_aperture": 1.0, + "reference_lux": 977, + "reference_Y": 8627 + } + }, + { + "rpi.noise": + { + "reference_constant": 16.0, + "reference_slope": 4.0 + } + }, + { + "rpi.geq": + { + "offset": 215, + "slope": 0.00287 + } + }, + { + "rpi.sdn": { } + }, + { + "rpi.awb": + { + "priors": [ + { + "lux": 0, + "prior": + [ + 2000, 1.0, + 3000, 0.0, + 13000, 0.0 + ] + }, + { + "lux": 800, + "prior": + [ + 2000, 0.0, + 6000, 2.0, + 13000, 2.0 + ] + }, + { + "lux": 1500, + "prior": + [ + 2000, 0.0, + 4000, 1.0, + 6000, 6.0, + 6500, 7.0, + 7000, 1.0, + 13000, 1.0 + ] + } + ], + "modes": + { + "auto": + { + "lo": 2500, + "hi": 8000 + }, + "incandescent": + { + "lo": 2500, + "hi": 3000 + }, + "tungsten": + { + "lo": 3000, + "hi": 3500 + }, + "fluorescent": + { + "lo": 4000, + "hi": 4700 + }, + "indoor": + { + "lo": 3000, + "hi": 5000 + }, + "daylight": + { + "lo": 5500, + "hi": 6500 + }, + "cloudy": + { + "lo": 7000, + "hi": 8600 + } + }, + "bayes": 0, + "ct_curve": + [ + 2498.0, 0.8733, 0.2606, + 2821.0, 0.7707, 0.3245, + 2925.0, 0.7338, 0.3499, + 2926.0, 0.7193, 0.3603, + 2951.0, 0.7144, 0.3639, + 2954.0, 0.7111, 0.3663, + 3578.0, 0.6038, 0.4516, + 3717.0, 0.5861, 0.4669, + 3784.0, 0.5786, 0.4737, + 4485.0, 0.5113, 0.5368, + 4615.0, 0.4994, 0.5486, + 4671.0, 0.4927, 0.5554, + 5753.0, 0.4274, 0.6246, + 5773.0, 0.4265, 0.6256, + 7433.0, 0.3723, 0.6881 + ], + "sensitivity_r": 1.05, + "sensitivity_b": 1.05, + "transverse_pos": 0.03148, + "transverse_neg": 0.03061 + } + }, + { + "rpi.agc": + { + "metering_modes": + { + "centre-weighted": + { + "weights": [ 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0 ] + }, + "spot": + { + "weights": [ 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] + }, + "matrix": + { + "weights": [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] + } + }, + "exposure_modes": + { + "normal": + { + "shutter": [ 100, 15000, 30000, 60000, 120000 ], + "gain": [ 1.0, 1.0, 2.0, 4.0, 6.0 ] + }, + "short": + { + "shutter": [ 100, 5000, 10000, 20000, 120000 ], + "gain": [ 1.0, 2.0, 4.0, 6.0, 6.0 ] + } + }, + "constraint_modes": + { + "normal": [ + { + "bound": "LOWER", + "q_lo": 0.98, + "q_hi": 1.0, + "y_target": + [ + 0, 0.2, + 1000, 0.2 + ] + } + ], + "highlight": [ + { + "bound": "LOWER", + "q_lo": 0.98, + "q_hi": 1.0, + "y_target": + [ + 0, 0.2, + 1000, 0.2 + ] + }, + { + "bound": "UPPER", + "q_lo": 0.98, + "q_hi": 1.0, + "y_target": + [ + 0, 0.8, + 1000, 0.8 + ] + } + ] + }, + "y_target": + [ + 0, 0.16, + 1000, 0.165, + 10000, 0.17 + ], + "startup_frames": 5, + "convergence_frames": 6, + "speed": 0.15 + } + }, + { + "rpi.alsc": + { + "omega": 1.3, + "n_iter": 100, + "luminance_strength": 0.5, + "calibrations_Cr": [ + { + "ct": 3000, + "table": + [ + 1.562, 1.566, 1.566, 1.556, 1.533, 1.506, 1.475, 1.475, 1.475, 1.475, 1.506, 1.533, 1.555, 1.563, 1.562, 1.555, + 1.563, 1.564, 1.561, 1.538, 1.508, 1.482, 1.449, 1.436, 1.436, 1.449, 1.481, 1.508, 1.537, 1.557, 1.558, 1.557, + 1.564, 1.563, 1.554, 1.522, 1.482, 1.449, 1.421, 1.403, 1.403, 1.419, 1.449, 1.481, 1.519, 1.549, 1.557, 1.559, + 1.564, 1.563, 1.545, 1.506, 1.462, 1.421, 1.403, 1.378, 1.378, 1.402, 1.419, 1.459, 1.503, 1.541, 1.557, 1.559, + 1.564, 1.562, 1.537, 1.494, 1.447, 1.404, 1.378, 1.364, 1.364, 1.377, 1.402, 1.444, 1.491, 1.532, 1.556, 1.559, + 1.564, 1.559, 1.532, 1.487, 1.438, 1.395, 1.365, 1.359, 1.359, 1.364, 1.393, 1.436, 1.484, 1.527, 1.555, 1.558, + 1.564, 1.559, 1.532, 1.487, 1.438, 1.395, 1.365, 1.356, 1.356, 1.364, 1.393, 1.436, 1.484, 1.527, 1.554, 1.557, + 1.564, 1.561, 1.536, 1.492, 1.444, 1.402, 1.374, 1.364, 1.363, 1.373, 1.401, 1.442, 1.489, 1.531, 1.554, 1.557, + 1.564, 1.563, 1.544, 1.504, 1.458, 1.418, 1.397, 1.374, 1.374, 1.395, 1.416, 1.456, 1.501, 1.538, 1.556, 1.557, + 1.564, 1.562, 1.551, 1.518, 1.477, 1.441, 1.418, 1.397, 1.397, 1.416, 1.438, 1.474, 1.514, 1.546, 1.556, 1.556, + 1.562, 1.562, 1.558, 1.534, 1.499, 1.476, 1.441, 1.426, 1.426, 1.438, 1.473, 1.496, 1.531, 1.552, 1.556, 1.555, + 1.561, 1.564, 1.564, 1.552, 1.525, 1.497, 1.466, 1.461, 1.461, 1.464, 1.495, 1.523, 1.548, 1.556, 1.556, 1.552 + ] + }, + { + "ct": 5000, + "table": + [ + 2.609, 2.616, 2.617, 2.607, 2.573, 2.527, 2.483, 2.481, 2.481, 2.483, 2.529, 2.573, 2.604, 2.613, 2.613, 2.604, + 2.609, 2.615, 2.608, 2.576, 2.533, 2.489, 2.439, 2.418, 2.418, 2.439, 2.491, 2.532, 2.577, 2.605, 2.609, 2.607, + 2.611, 2.611, 2.597, 2.551, 2.489, 2.439, 2.391, 2.364, 2.364, 2.391, 2.439, 2.491, 2.551, 2.592, 2.607, 2.609, + 2.612, 2.608, 2.583, 2.526, 2.457, 2.391, 2.362, 2.318, 2.318, 2.362, 2.391, 2.458, 2.526, 2.581, 2.607, 2.611, + 2.612, 2.604, 2.571, 2.507, 2.435, 2.362, 2.317, 2.293, 2.294, 2.318, 2.363, 2.434, 2.508, 2.568, 2.604, 2.612, + 2.611, 2.602, 2.564, 2.496, 2.419, 2.349, 2.293, 2.284, 2.284, 2.294, 2.347, 2.421, 2.497, 2.562, 2.603, 2.611, + 2.609, 2.601, 2.564, 2.496, 2.419, 2.349, 2.293, 2.278, 2.278, 2.294, 2.347, 2.421, 2.497, 2.562, 2.602, 2.609, + 2.609, 2.602, 2.568, 2.503, 2.429, 2.361, 2.311, 2.292, 2.292, 2.309, 2.357, 2.429, 2.504, 2.567, 2.602, 2.609, + 2.606, 2.604, 2.579, 2.519, 2.449, 2.384, 2.348, 2.311, 2.311, 2.346, 2.383, 2.449, 2.521, 2.577, 2.604, 2.608, + 2.604, 2.603, 2.586, 2.537, 2.474, 2.418, 2.384, 2.348, 2.348, 2.383, 2.417, 2.476, 2.538, 2.586, 2.601, 2.603, + 2.603, 2.605, 2.596, 2.561, 2.508, 2.474, 2.418, 2.396, 2.396, 2.417, 2.474, 2.511, 2.562, 2.596, 2.603, 2.602, + 2.601, 2.607, 2.606, 2.589, 2.549, 2.507, 2.456, 2.454, 2.454, 2.458, 2.508, 2.554, 2.594, 2.605, 2.605, 2.602 + ] + } + ], + "calibrations_Cb": [ + { + "ct": 3000, + "table": + [ + 3.221, 3.226, 3.231, 3.236, 3.239, 3.243, 3.245, 3.247, 3.249, 3.253, 3.255, 3.254, 3.253, 3.242, 3.235, 3.226, + 3.225, 3.231, 3.235, 3.238, 3.241, 3.244, 3.246, 3.247, 3.249, 3.254, 3.256, 3.255, 3.252, 3.248, 3.241, 3.232, + 3.226, 3.234, 3.239, 3.243, 3.243, 3.245, 3.247, 3.248, 3.251, 3.255, 3.256, 3.256, 3.254, 3.249, 3.244, 3.236, + 3.232, 3.238, 3.245, 3.245, 3.246, 3.247, 3.248, 3.251, 3.251, 3.256, 3.257, 3.257, 3.256, 3.254, 3.249, 3.239, + 3.232, 3.243, 3.246, 3.246, 3.246, 3.247, 3.248, 3.251, 3.253, 3.257, 3.258, 3.258, 3.257, 3.256, 3.254, 3.239, + 3.232, 3.242, 3.246, 3.247, 3.246, 3.246, 3.248, 3.251, 3.252, 3.253, 3.256, 3.255, 3.255, 3.254, 3.251, 3.239, + 3.233, 3.241, 3.244, 3.245, 3.244, 3.245, 3.246, 3.249, 3.251, 3.252, 3.253, 3.252, 3.252, 3.252, 3.249, 3.238, + 3.238, 3.241, 3.246, 3.246, 3.245, 3.245, 3.247, 3.249, 3.251, 3.252, 3.253, 3.253, 3.252, 3.252, 3.249, 3.239, + 3.235, 3.241, 3.245, 3.245, 3.245, 3.245, 3.246, 3.247, 3.251, 3.254, 3.253, 3.255, 3.256, 3.255, 3.251, 3.241, + 3.226, 3.235, 3.241, 3.241, 3.241, 3.241, 3.243, 3.245, 3.246, 3.252, 3.253, 3.254, 3.256, 3.254, 3.241, 3.237, + 3.205, 3.213, 3.213, 3.214, 3.214, 3.214, 3.214, 3.213, 3.213, 3.216, 3.218, 3.216, 3.214, 3.213, 3.211, 3.208, + 3.205, 3.205, 3.212, 3.212, 3.212, 3.213, 3.211, 3.211, 3.211, 3.213, 3.216, 3.214, 3.213, 3.211, 3.208, 3.196 + ] + }, + { + "ct": 5000, + "table": + [ + 1.645, 1.646, 1.649, 1.653, 1.654, 1.657, 1.659, 1.661, 1.663, 1.662, 1.661, 1.659, 1.656, 1.651, 1.645, 1.642, + 1.646, 1.649, 1.652, 1.654, 1.656, 1.659, 1.662, 1.663, 1.664, 1.664, 1.662, 1.661, 1.657, 1.653, 1.649, 1.644, + 1.648, 1.652, 1.654, 1.656, 1.658, 1.662, 1.665, 1.668, 1.668, 1.668, 1.665, 1.662, 1.658, 1.655, 1.652, 1.646, + 1.649, 1.653, 1.656, 1.658, 1.661, 1.665, 1.667, 1.671, 1.673, 1.671, 1.668, 1.663, 1.659, 1.656, 1.654, 1.647, + 1.649, 1.655, 1.657, 1.659, 1.661, 1.666, 1.671, 1.674, 1.675, 1.673, 1.671, 1.664, 1.659, 1.656, 1.654, 1.648, + 1.649, 1.654, 1.656, 1.659, 1.661, 1.666, 1.673, 1.676, 1.676, 1.675, 1.671, 1.664, 1.659, 1.656, 1.654, 1.648, + 1.649, 1.654, 1.656, 1.658, 1.659, 1.665, 1.672, 1.675, 1.675, 1.674, 1.668, 1.662, 1.658, 1.655, 1.654, 1.646, + 1.652, 1.655, 1.657, 1.659, 1.661, 1.665, 1.671, 1.673, 1.673, 1.672, 1.668, 1.662, 1.658, 1.655, 1.654, 1.647, + 1.652, 1.655, 1.657, 1.659, 1.661, 1.664, 1.667, 1.671, 1.672, 1.668, 1.666, 1.662, 1.659, 1.656, 1.654, 1.647, + 1.647, 1.652, 1.655, 1.656, 1.657, 1.661, 1.664, 1.665, 1.665, 1.665, 1.663, 1.661, 1.657, 1.655, 1.647, 1.647, + 1.639, 1.642, 1.644, 1.645, 1.646, 1.648, 1.648, 1.648, 1.649, 1.649, 1.649, 1.646, 1.645, 1.642, 1.639, 1.636, + 1.639, 1.641, 1.642, 1.644, 1.645, 1.646, 1.647, 1.647, 1.648, 1.648, 1.647, 1.645, 1.642, 1.639, 1.636, 1.633 + ] + } + ], + "luminance_lut": + [ + 2.644, 2.396, 2.077, 1.863, 1.682, 1.535, 1.392, 1.382, 1.382, 1.382, 1.515, 1.657, 1.826, 2.035, 2.351, 2.604, + 2.497, 2.229, 1.947, 1.733, 1.539, 1.424, 1.296, 1.249, 1.249, 1.285, 1.401, 1.519, 1.699, 1.908, 2.183, 2.456, + 2.389, 2.109, 1.848, 1.622, 1.424, 1.296, 1.201, 1.146, 1.146, 1.188, 1.285, 1.401, 1.591, 1.811, 2.065, 2.347, + 2.317, 2.026, 1.771, 1.535, 1.339, 1.201, 1.145, 1.069, 1.069, 1.134, 1.188, 1.318, 1.505, 1.734, 1.983, 2.273, + 2.276, 1.972, 1.715, 1.474, 1.281, 1.148, 1.069, 1.033, 1.024, 1.065, 1.134, 1.262, 1.446, 1.679, 1.929, 2.233, + 2.268, 1.941, 1.682, 1.441, 1.251, 1.119, 1.033, 1.013, 1.013, 1.024, 1.105, 1.231, 1.415, 1.649, 1.898, 2.227, + 2.268, 1.941, 1.682, 1.441, 1.251, 1.119, 1.033, 1.001, 1.001, 1.024, 1.105, 1.231, 1.415, 1.649, 1.898, 2.227, + 2.268, 1.951, 1.694, 1.456, 1.265, 1.131, 1.044, 1.026, 1.019, 1.039, 1.118, 1.246, 1.429, 1.663, 1.912, 2.227, + 2.291, 1.992, 1.738, 1.505, 1.311, 1.175, 1.108, 1.044, 1.041, 1.106, 1.161, 1.292, 1.478, 1.707, 1.955, 2.252, + 2.347, 2.058, 1.803, 1.581, 1.384, 1.245, 1.175, 1.108, 1.108, 1.161, 1.239, 1.364, 1.551, 1.773, 2.023, 2.311, + 2.438, 2.156, 1.884, 1.674, 1.484, 1.373, 1.245, 1.199, 1.199, 1.239, 1.363, 1.463, 1.647, 1.858, 2.123, 2.406, + 2.563, 2.305, 1.998, 1.792, 1.615, 1.472, 1.339, 1.322, 1.322, 1.326, 1.456, 1.593, 1.767, 1.973, 2.273, 2.532 + ], + "sigma": 0.00178, + "sigma_Cb": 0.00217 + } + }, + { + "rpi.contrast": + { + "ce_enable": 1, + "gamma_curve": + [ + 0, 0, + 1024, 5040, + 2048, 9338, + 3072, 12356, + 4096, 15312, + 5120, 18051, + 6144, 20790, + 7168, 23193, + 8192, 25744, + 9216, 27942, + 10240, 30035, + 11264, 32005, + 12288, 33975, + 13312, 35815, + 14336, 37600, + 15360, 39168, + 16384, 40642, + 18432, 43379, + 20480, 45749, + 22528, 47753, + 24576, 49621, + 26624, 51253, + 28672, 52698, + 30720, 53796, + 32768, 54876, + 36864, 57012, + 40960, 58656, + 45056, 59954, + 49152, 61183, + 53248, 62355, + 57344, 63419, + 61440, 64476, + 65535, 65535 + ] + } + }, + { + "rpi.ccm": + { + "ccms": [ + { + "ct": 2498, + "ccm": + [ + 1.14912, 0.28638, -0.43551, + -0.49691, 1.60391, -0.10701, + -0.10513, -1.09534, 2.20047 + ] + }, + { + "ct": 2821, + "ccm": + [ + 1.18251, 0.15501, -0.33752, + -0.44304, 1.58495, -0.14191, + -0.05077, -0.96422, 2.01498 + ] + }, + { + "ct": 2925, + "ccm": + [ + 1.18668, 0.00195, -0.18864, + -0.41617, 1.50514, -0.08897, + -0.02675, -0.91143, 1.93818 + ] + }, + { + "ct": 2926, + "ccm": + [ + 1.50948, -0.44421, -0.06527, + -0.37241, 1.41726, -0.04486, + 0.07098, -0.84694, 1.77596 + ] + }, + { + "ct": 2951, + "ccm": + [ + 1.52743, -0.47333, -0.05411, + -0.36485, 1.40764, -0.04279, + 0.08672, -0.90479, 1.81807 + ] + }, + { + "ct": 2954, + "ccm": + [ + 1.51683, -0.46841, -0.04841, + -0.36288, 1.39914, -0.03625, + 0.06421, -0.82034, 1.75613 + ] + }, + { + "ct": 3578, + "ccm": + [ + 1.59888, -0.59105, -0.00784, + -0.29366, 1.32037, -0.02671, + 0.06627, -0.76465, 1.69838 + ] + }, + { + "ct": 3717, + "ccm": + [ + 1.59063, -0.58059, -0.01003, + -0.29583, 1.32715, -0.03132, + 0.03613, -0.67431, 1.63817 + ] + }, + { + "ct": 3784, + "ccm": + [ + 1.59379, -0.58861, -0.00517, + -0.29178, 1.33292, -0.04115, + 0.03541, -0.66162, 1.62622 + ] + }, + { + "ct": 4485, + "ccm": + [ + 1.40761, -0.34561, -0.06201, + -0.32388, 1.57221, -0.24832, + -0.01014, -0.63427, 1.64441 + ] + }, + { + "ct": 4615, + "ccm": + [ + 1.41537, -0.35832, -0.05705, + -0.31429, 1.56019, -0.24591, + -0.01761, -0.61859, 1.63621 + ] + }, + { + "ct": 4671, + "ccm": + [ + 1.42941, -0.38178, -0.04764, + -0.31421, 1.55925, -0.24504, + -0.01141, -0.62987, 1.64129 + ] + }, + { + "ct": 5753, + "ccm": + [ + 1.64549, -0.63329, -0.01221, + -0.22431, 1.36423, -0.13992, + -0.00831, -0.55373, 1.56204 + ] + }, + { + "ct": 5773, + "ccm": + [ + 1.63668, -0.63557, -0.00111, + -0.21919, 1.36234, -0.14315, + -0.00399, -0.57428, 1.57827 + ] + }, + { + "ct": 7433, + "ccm": + [ + 1.36007, -0.09277, -0.26729, + -0.36886, 2.09249, -0.72363, + -0.12573, -0.76761, 1.89334 + ] + }, + { + "ct": 55792, + "ccm": + [ + 1.65091, -0.63689, -0.01401, + -0.22277, 1.35752, -0.13475, + -0.00943, -0.55091, 1.56033 + ] + } + ] + } + }, + { + "rpi.sharpen": { } + }, + { + "rpi.focus": { } + }, + { + "rpi.af": + { + "ranges": + { + "normal": + { + "min": 0.0, + "max": 12.0, + "default": 1.0 + }, + "macro": + { + "min": 3.0, + "max": 15.0, + "default": 4.0 + } + }, + "speeds": + { + "normal": + { + "step_coarse": 1.0, + "step_fine": 0.25, + "contrast_ratio": 0.75, + "pdaf_gain": -0.02, + "pdaf_squelch": 0.125, + "max_slew": 2.0, + "pdaf_frames": 20, + "dropout_frames": 6, + "step_frames": 4 + } + }, + "conf_epsilon": 8, + "conf_thresh": 16, + "conf_clip": 512, + "skip_frames": 5, + "map": [ 0.0, 445, 15.0, 925 ] + } + } + ] +} diff --git a/src/ipa/raspberrypi/data/imx708_wide.json b/src/ipa/raspberrypi/data/imx708_wide.json new file mode 100644 index 000000000000..cdc61436995d --- /dev/null +++ b/src/ipa/raspberrypi/data/imx708_wide.json @@ -0,0 +1,462 @@ +{ + "version": 2.0, + "target": "bcm2835", + "algorithms": [ + { + "rpi.black_level": + { + "black_level": 4096 + } + }, + { + "rpi.dpc": { } + }, + { + "rpi.lux": + { + "reference_shutter_speed": 9989, + "reference_gain": 1.23, + "reference_aperture": 1.0, + "reference_lux": 980, + "reference_Y": 8345 + } + }, + { + "rpi.noise": + { + "reference_constant": 16.0, + "reference_slope": 4.0 + } + }, + { + "rpi.geq": + { + "offset": 215, + "slope": 0.00287 + } + }, + { + "rpi.sdn": { } + }, + { + "rpi.awb": + { + "priors": [ + { + "lux": 0, + "prior": + [ + 2000, 1.0, + 3000, 0.0, + 13000, 0.0 + ] + }, + { + "lux": 800, + "prior": + [ + 2000, 0.0, + 6000, 2.0, + 13000, 2.0 + ] + }, + { + "lux": 1500, + "prior": + [ + 2000, 0.0, + 4000, 1.0, + 6000, 6.0, + 6500, 7.0, + 7000, 1.0, + 13000, 1.0 + ] + } + ], + "modes": + { + "auto": + { + "lo": 2500, + "hi": 8000 + }, + "incandescent": + { + "lo": 2500, + "hi": 3000 + }, + "tungsten": + { + "lo": 3000, + "hi": 3500 + }, + "fluorescent": + { + "lo": 4000, + "hi": 4700 + }, + "indoor": + { + "lo": 3000, + "hi": 5000 + }, + "daylight": + { + "lo": 5500, + "hi": 6500 + }, + "cloudy": + { + "lo": 7000, + "hi": 8600 + } + }, + "bayes": 1, + "ct_curve": + [ + 2750.0, 0.7881, 0.2849, + 2940.0, 0.7559, 0.3103, + 3650.0, 0.6291, 0.4206, + 4625.0, 0.5336, 0.5161, + 5715.0, 0.4668, 0.5898 + ], + "sensitivity_r": 1.05, + "sensitivity_b": 1.05, + "transverse_pos": 0.01165, + "transverse_neg": 0.01601 + } + }, + { + "rpi.agc": + { + "metering_modes": + { + "centre-weighted": + { + "weights": [ 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0 ] + }, + "spot": + { + "weights": [ 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] + }, + "matrix": + { + "weights": [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] + } + }, + "exposure_modes": + { + "normal": + { + "shutter": [ 100, 15000, 30000, 60000, 120000 ], + "gain": [ 1.0, 1.0, 2.0, 4.0, 6.0 ] + }, + "short": + { + "shutter": [ 100, 5000, 10000, 20000, 120000 ], + "gain": [ 1.0, 2.0, 4.0, 6.0, 6.0 ] + } + }, + "constraint_modes": + { + "normal": [ + { + "bound": "LOWER", + "q_lo": 0.98, + "q_hi": 1.0, + "y_target": + [ + 0, 0.2, + 1000, 0.2 + ] + } + ], + "highlight": [ + { + "bound": "LOWER", + "q_lo": 0.98, + "q_hi": 1.0, + "y_target": + [ + 0, 0.2, + 1000, 0.2 + ] + }, + { + "bound": "UPPER", + "q_lo": 0.98, + "q_hi": 1.0, + "y_target": + [ + 0, 0.8, + 1000, 0.8 + ] + } + ] + }, + "y_target": + [ + 0, 0.16, + 1000, 0.165, + 10000, 0.17 + ], + "startup_frames": 5, + "convergence_frames": 6, + "speed": 0.15 + } + }, + { + "rpi.alsc": + { + "omega": 1.3, + "n_iter": 100, + "luminance_strength": 0.5, + "calibrations_Cr": [ + { + "ct": 3000, + "table": + [ + 1.529, 1.526, 1.522, 1.506, 1.489, 1.473, 1.458, 1.456, 1.456, 1.458, 1.474, 1.493, 1.513, 1.531, 1.541, 1.544, + 1.527, 1.523, 1.511, 1.491, 1.474, 1.459, 1.445, 1.441, 1.441, 1.446, 1.461, 1.479, 1.499, 1.521, 1.536, 1.541, + 1.524, 1.515, 1.498, 1.477, 1.459, 1.444, 1.431, 1.426, 1.426, 1.435, 1.446, 1.466, 1.487, 1.507, 1.528, 1.538, + 1.522, 1.512, 1.491, 1.468, 1.447, 1.431, 1.423, 1.417, 1.418, 1.425, 1.435, 1.455, 1.479, 1.499, 1.523, 1.537, + 1.522, 1.509, 1.485, 1.463, 1.441, 1.423, 1.416, 1.413, 1.415, 1.418, 1.429, 1.449, 1.473, 1.495, 1.521, 1.538, + 1.522, 1.508, 1.483, 1.461, 1.438, 1.421, 1.413, 1.412, 1.412, 1.415, 1.428, 1.447, 1.471, 1.493, 1.519, 1.538, + 1.522, 1.509, 1.484, 1.462, 1.439, 1.421, 1.414, 1.411, 1.412, 1.416, 1.428, 1.447, 1.471, 1.493, 1.519, 1.537, + 1.523, 1.511, 1.487, 1.465, 1.443, 1.424, 1.417, 1.413, 1.415, 1.419, 1.429, 1.451, 1.473, 1.494, 1.519, 1.536, + 1.524, 1.514, 1.493, 1.471, 1.451, 1.434, 1.424, 1.419, 1.419, 1.428, 1.437, 1.457, 1.477, 1.498, 1.521, 1.538, + 1.527, 1.521, 1.503, 1.481, 1.462, 1.449, 1.434, 1.429, 1.429, 1.437, 1.451, 1.469, 1.488, 1.508, 1.527, 1.539, + 1.529, 1.527, 1.515, 1.495, 1.477, 1.462, 1.449, 1.444, 1.444, 1.451, 1.467, 1.481, 1.499, 1.519, 1.535, 1.543, + 1.534, 1.531, 1.527, 1.512, 1.492, 1.476, 1.463, 1.461, 1.461, 1.464, 1.479, 1.495, 1.515, 1.533, 1.543, 1.546 + ] + }, + { + "ct": 5000, + "table": + [ + 2.603, 2.599, 2.591, 2.567, 2.539, 2.515, 2.489, 2.489, 2.489, 2.491, 2.516, 2.543, 2.574, 2.597, 2.614, 2.617, + 2.596, 2.591, 2.571, 2.542, 2.516, 2.489, 2.464, 2.458, 2.458, 2.469, 2.492, 2.518, 2.547, 2.576, 2.602, 2.614, + 2.591, 2.576, 2.546, 2.519, 2.489, 2.464, 2.437, 2.427, 2.427, 2.441, 2.467, 2.492, 2.525, 2.553, 2.586, 2.605, + 2.588, 2.568, 2.534, 2.503, 2.472, 2.437, 2.423, 2.409, 2.411, 2.425, 2.441, 2.475, 2.513, 2.541, 2.577, 2.602, + 2.588, 2.565, 2.527, 2.494, 2.461, 2.425, 2.409, 2.399, 2.403, 2.409, 2.431, 2.466, 2.503, 2.534, 2.571, 2.601, + 2.586, 2.561, 2.525, 2.491, 2.454, 2.418, 2.399, 2.396, 2.395, 2.402, 2.424, 2.461, 2.501, 2.531, 2.567, 2.599, + 2.583, 2.559, 2.525, 2.491, 2.454, 2.418, 2.398, 2.393, 2.393, 2.401, 2.423, 2.459, 2.498, 2.531, 2.566, 2.597, + 2.583, 2.559, 2.526, 2.494, 2.458, 2.421, 2.404, 2.397, 2.399, 2.404, 2.426, 2.461, 2.501, 2.531, 2.566, 2.596, + 2.583, 2.563, 2.531, 2.501, 2.469, 2.435, 2.419, 2.405, 2.404, 2.422, 2.435, 2.471, 2.505, 2.537, 2.572, 2.596, + 2.585, 2.571, 2.539, 2.516, 2.486, 2.458, 2.435, 2.424, 2.424, 2.435, 2.459, 2.489, 2.521, 2.546, 2.579, 2.601, + 2.589, 2.578, 2.557, 2.532, 2.506, 2.483, 2.458, 2.449, 2.449, 2.459, 2.485, 2.507, 2.535, 2.563, 2.591, 2.605, + 2.589, 2.586, 2.575, 2.551, 2.525, 2.503, 2.481, 2.476, 2.476, 2.481, 2.504, 2.526, 2.555, 2.583, 2.604, 2.611 + ] + } + ], + "calibrations_Cb": [ + { + "ct": 3000, + "table": + [ + 3.311, 3.339, 3.369, 3.374, 3.371, 3.363, 3.356, 3.353, 3.353, 3.353, 3.357, 3.362, 3.362, 3.356, 3.328, 3.311, + 3.321, 3.354, 3.374, 3.374, 3.368, 3.359, 3.352, 3.349, 3.347, 3.347, 3.349, 3.357, 3.361, 3.359, 3.343, 3.324, + 3.334, 3.368, 3.375, 3.374, 3.365, 3.356, 3.349, 3.347, 3.346, 3.346, 3.347, 3.349, 3.358, 3.361, 3.357, 3.336, + 3.346, 3.378, 3.378, 3.369, 3.363, 3.358, 3.351, 3.348, 3.347, 3.346, 3.347, 3.348, 3.354, 3.364, 3.363, 3.345, + 3.351, 3.381, 3.381, 3.368, 3.361, 3.357, 3.349, 3.347, 3.347, 3.345, 3.345, 3.347, 3.353, 3.364, 3.364, 3.347, + 3.353, 3.379, 3.379, 3.366, 3.359, 3.351, 3.348, 3.343, 3.342, 3.342, 3.343, 3.345, 3.351, 3.363, 3.363, 3.347, + 3.353, 3.376, 3.376, 3.363, 3.351, 3.347, 3.343, 3.338, 3.336, 3.338, 3.339, 3.343, 3.351, 3.361, 3.361, 3.347, + 3.351, 3.374, 3.374, 3.359, 3.351, 3.345, 3.338, 3.334, 3.333, 3.334, 3.336, 3.339, 3.347, 3.358, 3.358, 3.345, + 3.346, 3.368, 3.368, 3.359, 3.349, 3.343, 3.336, 3.332, 3.327, 3.331, 3.333, 3.337, 3.346, 3.356, 3.356, 3.341, + 3.336, 3.362, 3.364, 3.359, 3.351, 3.342, 3.334, 3.324, 3.324, 3.325, 3.329, 3.336, 3.346, 3.351, 3.351, 3.333, + 3.324, 3.349, 3.359, 3.358, 3.352, 3.341, 3.329, 3.323, 3.321, 3.322, 3.326, 3.336, 3.346, 3.347, 3.339, 3.319, + 3.311, 3.328, 3.352, 3.354, 3.352, 3.341, 3.329, 3.321, 3.319, 3.321, 3.324, 3.338, 3.343, 3.343, 3.319, 3.312 + ] + }, + { + "ct": 5000, + "table": + [ + 1.634, 1.647, 1.665, 1.668, 1.668, 1.664, 1.662, 1.662, 1.661, 1.661, 1.661, 1.663, 1.663, 1.659, 1.643, 1.636, + 1.639, 1.656, 1.668, 1.669, 1.668, 1.666, 1.664, 1.663, 1.663, 1.661, 1.661, 1.662, 1.663, 1.662, 1.654, 1.642, + 1.645, 1.663, 1.669, 1.668, 1.667, 1.667, 1.667, 1.668, 1.668, 1.665, 1.662, 1.661, 1.662, 1.664, 1.661, 1.649, + 1.651, 1.669, 1.669, 1.667, 1.666, 1.668, 1.669, 1.672, 1.672, 1.668, 1.665, 1.661, 1.661, 1.665, 1.665, 1.655, + 1.654, 1.669, 1.669, 1.666, 1.666, 1.669, 1.672, 1.673, 1.673, 1.671, 1.666, 1.661, 1.661, 1.665, 1.665, 1.659, + 1.654, 1.669, 1.669, 1.666, 1.666, 1.669, 1.671, 1.673, 1.672, 1.669, 1.667, 1.661, 1.661, 1.665, 1.665, 1.659, + 1.654, 1.668, 1.668, 1.664, 1.663, 1.667, 1.669, 1.671, 1.669, 1.668, 1.665, 1.661, 1.661, 1.663, 1.663, 1.659, + 1.653, 1.665, 1.665, 1.661, 1.661, 1.664, 1.667, 1.668, 1.668, 1.665, 1.661, 1.658, 1.659, 1.662, 1.662, 1.657, + 1.651, 1.664, 1.664, 1.659, 1.659, 1.661, 1.663, 1.663, 1.662, 1.661, 1.658, 1.656, 1.657, 1.662, 1.662, 1.655, + 1.645, 1.661, 1.663, 1.661, 1.659, 1.659, 1.659, 1.657, 1.657, 1.656, 1.654, 1.655, 1.656, 1.661, 1.661, 1.649, + 1.641, 1.654, 1.661, 1.661, 1.659, 1.657, 1.655, 1.653, 1.652, 1.651, 1.652, 1.653, 1.657, 1.658, 1.655, 1.644, + 1.635, 1.645, 1.661, 1.661, 1.661, 1.655, 1.653, 1.649, 1.648, 1.647, 1.651, 1.653, 1.657, 1.657, 1.646, 1.638 + ] + } + ], + "luminance_lut": + [ + 3.535, 3.279, 3.049, 2.722, 2.305, 1.958, 1.657, 1.647, 1.647, 1.656, 1.953, 2.289, 2.707, 3.058, 3.325, 3.589, + 3.379, 3.157, 2.874, 2.421, 1.973, 1.735, 1.472, 1.388, 1.388, 1.471, 1.724, 1.963, 2.409, 2.877, 3.185, 3.416, + 3.288, 3.075, 2.696, 2.169, 1.735, 1.472, 1.311, 1.208, 1.208, 1.306, 1.471, 1.724, 2.159, 2.695, 3.092, 3.321, + 3.238, 3.001, 2.534, 1.981, 1.572, 1.311, 1.207, 1.082, 1.082, 1.204, 1.306, 1.563, 1.973, 2.529, 3.008, 3.259, + 3.211, 2.938, 2.414, 1.859, 1.468, 1.221, 1.082, 1.036, 1.031, 1.079, 1.217, 1.463, 1.851, 2.403, 2.931, 3.229, + 3.206, 2.904, 2.356, 1.802, 1.421, 1.181, 1.037, 1.002, 1.002, 1.032, 1.175, 1.414, 1.793, 2.343, 2.899, 3.223, + 3.206, 2.904, 2.356, 1.802, 1.421, 1.181, 1.037, 1.005, 1.005, 1.032, 1.175, 1.414, 1.793, 2.343, 2.899, 3.223, + 3.211, 2.936, 2.417, 1.858, 1.468, 1.222, 1.083, 1.037, 1.032, 1.083, 1.218, 1.463, 1.848, 2.403, 2.932, 3.226, + 3.234, 2.997, 2.536, 1.979, 1.569, 1.311, 1.206, 1.084, 1.084, 1.204, 1.305, 1.565, 1.966, 2.524, 2.996, 3.251, + 3.282, 3.069, 2.697, 2.166, 1.731, 1.471, 1.311, 1.207, 1.207, 1.305, 1.466, 1.729, 2.158, 2.689, 3.077, 3.304, + 3.369, 3.146, 2.873, 2.415, 1.964, 1.722, 1.471, 1.382, 1.382, 1.466, 1.722, 1.964, 2.408, 2.871, 3.167, 3.401, + 3.524, 3.253, 3.025, 2.691, 2.275, 1.939, 1.657, 1.628, 1.628, 1.654, 1.936, 2.275, 2.687, 3.029, 3.284, 3.574 + ], + "sigma": 0.00195, + "sigma_Cb": 0.00241 + } + }, + { + "rpi.contrast": + { + "ce_enable": 1, + "gamma_curve": + [ + 0, 0, + 1024, 5040, + 2048, 9338, + 3072, 12356, + 4096, 15312, + 5120, 18051, + 6144, 20790, + 7168, 23193, + 8192, 25744, + 9216, 27942, + 10240, 30035, + 11264, 32005, + 12288, 33975, + 13312, 35815, + 14336, 37600, + 15360, 39168, + 16384, 40642, + 18432, 43379, + 20480, 45749, + 22528, 47753, + 24576, 49621, + 26624, 51253, + 28672, 52698, + 30720, 53796, + 32768, 54876, + 36864, 57012, + 40960, 58656, + 45056, 59954, + 49152, 61183, + 53248, 62355, + 57344, 63419, + 61440, 64476, + 65535, 65535 + ] + } + }, + { + "rpi.ccm": + { + "ccms": [ + { + "ct": 2750, + "ccm": + [ + 1.13004, 0.36392, -0.49396, + -0.45885, 1.68171, -0.22286, + -0.06473, -0.86962, 1.93435 + ] + }, + { + "ct": 2940, + "ccm": + [ + 1.29876, 0.09627, -0.39503, + -0.43085, 1.60258, -0.17172, + -0.02638, -0.92581, 1.95218 + ] + }, + { + "ct": 3650, + "ccm": + [ + 1.57729, -0.29734, -0.27995, + -0.42965, 1.66231, -0.23265, + -0.02183, -0.62331, 1.64514 + ] + }, + { + "ct": 4625, + "ccm": + [ + 1.52145, -0.22382, -0.29763, + -0.40445, 1.82186, -0.41742, + -0.05732, -0.56222, 1.61954 + ] + }, + { + "ct": 5715, + "ccm": + [ + 1.67851, -0.39193, -0.28658, + -0.37169, 1.72949, -0.35781, + -0.09556, -0.41951, 1.51508 + ] + } + ] + } + }, + { + "rpi.sharpen": { } + }, + { + "rpi.focus": { } + }, + { + "rpi.af": + { + "ranges": + { + "normal": + { + "min": 0.0, + "max": 12.0, + "default": 1.0 + }, + "macro": + { + "min": 4.0, + "max": 32.0, + "default": 6.0 + } + }, + "speeds": + { + "normal": + { + "step_coarse": 2.0, + "step_fine": 0.5, + "contrast_ratio": 0.75, + "pdaf_gain": -0.03, + "pdaf_squelch": 0.2, + "max_slew": 4.0, + "pdaf_frames": 20, + "dropout_frames": 6, + "step_frames": 4 + }, + "fast": + { + "step_coarse": 2.0, + "step_fine": 0.5, + "contrast_ratio": 0.75, + "pdaf_gain": -0.05, + "pdaf_squelch": 0.2, + "max_slew": 5.0, + "pdaf_frames": 16, + "dropout_frames": 6, + "step_frames": 4 + } + }, + "conf_epsilon": 8, + "conf_thresh": 12, + "conf_clip": 512, + "skip_frames": 5, + "map": [ 0.0, 420, 35.0, 920 ] + } + } + ] +} diff --git a/src/ipa/raspberrypi/data/imx708_wide_noir.json b/src/ipa/raspberrypi/data/imx708_wide_noir.json new file mode 100644 index 000000000000..8a7f59910833 --- /dev/null +++ b/src/ipa/raspberrypi/data/imx708_wide_noir.json @@ -0,0 +1,462 @@ +{ + "version": 2.0, + "target": "bcm2835", + "algorithms": [ + { + "rpi.black_level": + { + "black_level": 4096 + } + }, + { + "rpi.dpc": { } + }, + { + "rpi.lux": + { + "reference_shutter_speed": 9989, + "reference_gain": 1.23, + "reference_aperture": 1.0, + "reference_lux": 980, + "reference_Y": 8345 + } + }, + { + "rpi.noise": + { + "reference_constant": 16.0, + "reference_slope": 4.0 + } + }, + { + "rpi.geq": + { + "offset": 215, + "slope": 0.00287 + } + }, + { + "rpi.sdn": { } + }, + { + "rpi.awb": + { + "priors": [ + { + "lux": 0, + "prior": + [ + 2000, 1.0, + 3000, 0.0, + 13000, 0.0 + ] + }, + { + "lux": 800, + "prior": + [ + 2000, 0.0, + 6000, 2.0, + 13000, 2.0 + ] + }, + { + "lux": 1500, + "prior": + [ + 2000, 0.0, + 4000, 1.0, + 6000, 6.0, + 6500, 7.0, + 7000, 1.0, + 13000, 1.0 + ] + } + ], + "modes": + { + "auto": + { + "lo": 2500, + "hi": 8000 + }, + "incandescent": + { + "lo": 2500, + "hi": 3000 + }, + "tungsten": + { + "lo": 3000, + "hi": 3500 + }, + "fluorescent": + { + "lo": 4000, + "hi": 4700 + }, + "indoor": + { + "lo": 3000, + "hi": 5000 + }, + "daylight": + { + "lo": 5500, + "hi": 6500 + }, + "cloudy": + { + "lo": 7000, + "hi": 8600 + } + }, + "bayes": 0, + "ct_curve": + [ + 2750.0, 0.7881, 0.2849, + 2940.0, 0.7559, 0.3103, + 3650.0, 0.6291, 0.4206, + 4625.0, 0.5336, 0.5161, + 5715.0, 0.4668, 0.5898 + ], + "sensitivity_r": 1.05, + "sensitivity_b": 1.05, + "transverse_pos": 0.01165, + "transverse_neg": 0.01601 + } + }, + { + "rpi.agc": + { + "metering_modes": + { + "centre-weighted": + { + "weights": [ 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0 ] + }, + "spot": + { + "weights": [ 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] + }, + "matrix": + { + "weights": [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] + } + }, + "exposure_modes": + { + "normal": + { + "shutter": [ 100, 15000, 30000, 60000, 120000 ], + "gain": [ 1.0, 1.0, 2.0, 4.0, 6.0 ] + }, + "short": + { + "shutter": [ 100, 5000, 10000, 20000, 120000 ], + "gain": [ 1.0, 2.0, 4.0, 6.0, 6.0 ] + } + }, + "constraint_modes": + { + "normal": [ + { + "bound": "LOWER", + "q_lo": 0.98, + "q_hi": 1.0, + "y_target": + [ + 0, 0.2, + 1000, 0.2 + ] + } + ], + "highlight": [ + { + "bound": "LOWER", + "q_lo": 0.98, + "q_hi": 1.0, + "y_target": + [ + 0, 0.2, + 1000, 0.2 + ] + }, + { + "bound": "UPPER", + "q_lo": 0.98, + "q_hi": 1.0, + "y_target": + [ + 0, 0.8, + 1000, 0.8 + ] + } + ] + }, + "y_target": + [ + 0, 0.16, + 1000, 0.165, + 10000, 0.17 + ], + "startup_frames": 5, + "convergence_frames": 6, + "speed": 0.15 + } + }, + { + "rpi.alsc": + { + "omega": 1.3, + "n_iter": 100, + "luminance_strength": 0.5, + "calibrations_Cr": [ + { + "ct": 3000, + "table": + [ + 1.529, 1.526, 1.522, 1.506, 1.489, 1.473, 1.458, 1.456, 1.456, 1.458, 1.474, 1.493, 1.513, 1.531, 1.541, 1.544, + 1.527, 1.523, 1.511, 1.491, 1.474, 1.459, 1.445, 1.441, 1.441, 1.446, 1.461, 1.479, 1.499, 1.521, 1.536, 1.541, + 1.524, 1.515, 1.498, 1.477, 1.459, 1.444, 1.431, 1.426, 1.426, 1.435, 1.446, 1.466, 1.487, 1.507, 1.528, 1.538, + 1.522, 1.512, 1.491, 1.468, 1.447, 1.431, 1.423, 1.417, 1.418, 1.425, 1.435, 1.455, 1.479, 1.499, 1.523, 1.537, + 1.522, 1.509, 1.485, 1.463, 1.441, 1.423, 1.416, 1.413, 1.415, 1.418, 1.429, 1.449, 1.473, 1.495, 1.521, 1.538, + 1.522, 1.508, 1.483, 1.461, 1.438, 1.421, 1.413, 1.412, 1.412, 1.415, 1.428, 1.447, 1.471, 1.493, 1.519, 1.538, + 1.522, 1.509, 1.484, 1.462, 1.439, 1.421, 1.414, 1.411, 1.412, 1.416, 1.428, 1.447, 1.471, 1.493, 1.519, 1.537, + 1.523, 1.511, 1.487, 1.465, 1.443, 1.424, 1.417, 1.413, 1.415, 1.419, 1.429, 1.451, 1.473, 1.494, 1.519, 1.536, + 1.524, 1.514, 1.493, 1.471, 1.451, 1.434, 1.424, 1.419, 1.419, 1.428, 1.437, 1.457, 1.477, 1.498, 1.521, 1.538, + 1.527, 1.521, 1.503, 1.481, 1.462, 1.449, 1.434, 1.429, 1.429, 1.437, 1.451, 1.469, 1.488, 1.508, 1.527, 1.539, + 1.529, 1.527, 1.515, 1.495, 1.477, 1.462, 1.449, 1.444, 1.444, 1.451, 1.467, 1.481, 1.499, 1.519, 1.535, 1.543, + 1.534, 1.531, 1.527, 1.512, 1.492, 1.476, 1.463, 1.461, 1.461, 1.464, 1.479, 1.495, 1.515, 1.533, 1.543, 1.546 + ] + }, + { + "ct": 5000, + "table": + [ + 2.603, 2.599, 2.591, 2.567, 2.539, 2.515, 2.489, 2.489, 2.489, 2.491, 2.516, 2.543, 2.574, 2.597, 2.614, 2.617, + 2.596, 2.591, 2.571, 2.542, 2.516, 2.489, 2.464, 2.458, 2.458, 2.469, 2.492, 2.518, 2.547, 2.576, 2.602, 2.614, + 2.591, 2.576, 2.546, 2.519, 2.489, 2.464, 2.437, 2.427, 2.427, 2.441, 2.467, 2.492, 2.525, 2.553, 2.586, 2.605, + 2.588, 2.568, 2.534, 2.503, 2.472, 2.437, 2.423, 2.409, 2.411, 2.425, 2.441, 2.475, 2.513, 2.541, 2.577, 2.602, + 2.588, 2.565, 2.527, 2.494, 2.461, 2.425, 2.409, 2.399, 2.403, 2.409, 2.431, 2.466, 2.503, 2.534, 2.571, 2.601, + 2.586, 2.561, 2.525, 2.491, 2.454, 2.418, 2.399, 2.396, 2.395, 2.402, 2.424, 2.461, 2.501, 2.531, 2.567, 2.599, + 2.583, 2.559, 2.525, 2.491, 2.454, 2.418, 2.398, 2.393, 2.393, 2.401, 2.423, 2.459, 2.498, 2.531, 2.566, 2.597, + 2.583, 2.559, 2.526, 2.494, 2.458, 2.421, 2.404, 2.397, 2.399, 2.404, 2.426, 2.461, 2.501, 2.531, 2.566, 2.596, + 2.583, 2.563, 2.531, 2.501, 2.469, 2.435, 2.419, 2.405, 2.404, 2.422, 2.435, 2.471, 2.505, 2.537, 2.572, 2.596, + 2.585, 2.571, 2.539, 2.516, 2.486, 2.458, 2.435, 2.424, 2.424, 2.435, 2.459, 2.489, 2.521, 2.546, 2.579, 2.601, + 2.589, 2.578, 2.557, 2.532, 2.506, 2.483, 2.458, 2.449, 2.449, 2.459, 2.485, 2.507, 2.535, 2.563, 2.591, 2.605, + 2.589, 2.586, 2.575, 2.551, 2.525, 2.503, 2.481, 2.476, 2.476, 2.481, 2.504, 2.526, 2.555, 2.583, 2.604, 2.611 + ] + } + ], + "calibrations_Cb": [ + { + "ct": 3000, + "table": + [ + 3.311, 3.339, 3.369, 3.374, 3.371, 3.363, 3.356, 3.353, 3.353, 3.353, 3.357, 3.362, 3.362, 3.356, 3.328, 3.311, + 3.321, 3.354, 3.374, 3.374, 3.368, 3.359, 3.352, 3.349, 3.347, 3.347, 3.349, 3.357, 3.361, 3.359, 3.343, 3.324, + 3.334, 3.368, 3.375, 3.374, 3.365, 3.356, 3.349, 3.347, 3.346, 3.346, 3.347, 3.349, 3.358, 3.361, 3.357, 3.336, + 3.346, 3.378, 3.378, 3.369, 3.363, 3.358, 3.351, 3.348, 3.347, 3.346, 3.347, 3.348, 3.354, 3.364, 3.363, 3.345, + 3.351, 3.381, 3.381, 3.368, 3.361, 3.357, 3.349, 3.347, 3.347, 3.345, 3.345, 3.347, 3.353, 3.364, 3.364, 3.347, + 3.353, 3.379, 3.379, 3.366, 3.359, 3.351, 3.348, 3.343, 3.342, 3.342, 3.343, 3.345, 3.351, 3.363, 3.363, 3.347, + 3.353, 3.376, 3.376, 3.363, 3.351, 3.347, 3.343, 3.338, 3.336, 3.338, 3.339, 3.343, 3.351, 3.361, 3.361, 3.347, + 3.351, 3.374, 3.374, 3.359, 3.351, 3.345, 3.338, 3.334, 3.333, 3.334, 3.336, 3.339, 3.347, 3.358, 3.358, 3.345, + 3.346, 3.368, 3.368, 3.359, 3.349, 3.343, 3.336, 3.332, 3.327, 3.331, 3.333, 3.337, 3.346, 3.356, 3.356, 3.341, + 3.336, 3.362, 3.364, 3.359, 3.351, 3.342, 3.334, 3.324, 3.324, 3.325, 3.329, 3.336, 3.346, 3.351, 3.351, 3.333, + 3.324, 3.349, 3.359, 3.358, 3.352, 3.341, 3.329, 3.323, 3.321, 3.322, 3.326, 3.336, 3.346, 3.347, 3.339, 3.319, + 3.311, 3.328, 3.352, 3.354, 3.352, 3.341, 3.329, 3.321, 3.319, 3.321, 3.324, 3.338, 3.343, 3.343, 3.319, 3.312 + ] + }, + { + "ct": 5000, + "table": + [ + 1.634, 1.647, 1.665, 1.668, 1.668, 1.664, 1.662, 1.662, 1.661, 1.661, 1.661, 1.663, 1.663, 1.659, 1.643, 1.636, + 1.639, 1.656, 1.668, 1.669, 1.668, 1.666, 1.664, 1.663, 1.663, 1.661, 1.661, 1.662, 1.663, 1.662, 1.654, 1.642, + 1.645, 1.663, 1.669, 1.668, 1.667, 1.667, 1.667, 1.668, 1.668, 1.665, 1.662, 1.661, 1.662, 1.664, 1.661, 1.649, + 1.651, 1.669, 1.669, 1.667, 1.666, 1.668, 1.669, 1.672, 1.672, 1.668, 1.665, 1.661, 1.661, 1.665, 1.665, 1.655, + 1.654, 1.669, 1.669, 1.666, 1.666, 1.669, 1.672, 1.673, 1.673, 1.671, 1.666, 1.661, 1.661, 1.665, 1.665, 1.659, + 1.654, 1.669, 1.669, 1.666, 1.666, 1.669, 1.671, 1.673, 1.672, 1.669, 1.667, 1.661, 1.661, 1.665, 1.665, 1.659, + 1.654, 1.668, 1.668, 1.664, 1.663, 1.667, 1.669, 1.671, 1.669, 1.668, 1.665, 1.661, 1.661, 1.663, 1.663, 1.659, + 1.653, 1.665, 1.665, 1.661, 1.661, 1.664, 1.667, 1.668, 1.668, 1.665, 1.661, 1.658, 1.659, 1.662, 1.662, 1.657, + 1.651, 1.664, 1.664, 1.659, 1.659, 1.661, 1.663, 1.663, 1.662, 1.661, 1.658, 1.656, 1.657, 1.662, 1.662, 1.655, + 1.645, 1.661, 1.663, 1.661, 1.659, 1.659, 1.659, 1.657, 1.657, 1.656, 1.654, 1.655, 1.656, 1.661, 1.661, 1.649, + 1.641, 1.654, 1.661, 1.661, 1.659, 1.657, 1.655, 1.653, 1.652, 1.651, 1.652, 1.653, 1.657, 1.658, 1.655, 1.644, + 1.635, 1.645, 1.661, 1.661, 1.661, 1.655, 1.653, 1.649, 1.648, 1.647, 1.651, 1.653, 1.657, 1.657, 1.646, 1.638 + ] + } + ], + "luminance_lut": + [ + 3.535, 3.279, 3.049, 2.722, 2.305, 1.958, 1.657, 1.647, 1.647, 1.656, 1.953, 2.289, 2.707, 3.058, 3.325, 3.589, + 3.379, 3.157, 2.874, 2.421, 1.973, 1.735, 1.472, 1.388, 1.388, 1.471, 1.724, 1.963, 2.409, 2.877, 3.185, 3.416, + 3.288, 3.075, 2.696, 2.169, 1.735, 1.472, 1.311, 1.208, 1.208, 1.306, 1.471, 1.724, 2.159, 2.695, 3.092, 3.321, + 3.238, 3.001, 2.534, 1.981, 1.572, 1.311, 1.207, 1.082, 1.082, 1.204, 1.306, 1.563, 1.973, 2.529, 3.008, 3.259, + 3.211, 2.938, 2.414, 1.859, 1.468, 1.221, 1.082, 1.036, 1.031, 1.079, 1.217, 1.463, 1.851, 2.403, 2.931, 3.229, + 3.206, 2.904, 2.356, 1.802, 1.421, 1.181, 1.037, 1.002, 1.002, 1.032, 1.175, 1.414, 1.793, 2.343, 2.899, 3.223, + 3.206, 2.904, 2.356, 1.802, 1.421, 1.181, 1.037, 1.005, 1.005, 1.032, 1.175, 1.414, 1.793, 2.343, 2.899, 3.223, + 3.211, 2.936, 2.417, 1.858, 1.468, 1.222, 1.083, 1.037, 1.032, 1.083, 1.218, 1.463, 1.848, 2.403, 2.932, 3.226, + 3.234, 2.997, 2.536, 1.979, 1.569, 1.311, 1.206, 1.084, 1.084, 1.204, 1.305, 1.565, 1.966, 2.524, 2.996, 3.251, + 3.282, 3.069, 2.697, 2.166, 1.731, 1.471, 1.311, 1.207, 1.207, 1.305, 1.466, 1.729, 2.158, 2.689, 3.077, 3.304, + 3.369, 3.146, 2.873, 2.415, 1.964, 1.722, 1.471, 1.382, 1.382, 1.466, 1.722, 1.964, 2.408, 2.871, 3.167, 3.401, + 3.524, 3.253, 3.025, 2.691, 2.275, 1.939, 1.657, 1.628, 1.628, 1.654, 1.936, 2.275, 2.687, 3.029, 3.284, 3.574 + ], + "sigma": 0.00195, + "sigma_Cb": 0.00241 + } + }, + { + "rpi.contrast": + { + "ce_enable": 1, + "gamma_curve": + [ + 0, 0, + 1024, 5040, + 2048, 9338, + 3072, 12356, + 4096, 15312, + 5120, 18051, + 6144, 20790, + 7168, 23193, + 8192, 25744, + 9216, 27942, + 10240, 30035, + 11264, 32005, + 12288, 33975, + 13312, 35815, + 14336, 37600, + 15360, 39168, + 16384, 40642, + 18432, 43379, + 20480, 45749, + 22528, 47753, + 24576, 49621, + 26624, 51253, + 28672, 52698, + 30720, 53796, + 32768, 54876, + 36864, 57012, + 40960, 58656, + 45056, 59954, + 49152, 61183, + 53248, 62355, + 57344, 63419, + 61440, 64476, + 65535, 65535 + ] + } + }, + { + "rpi.ccm": + { + "ccms": [ + { + "ct": 2750, + "ccm": + [ + 1.13004, 0.36392, -0.49396, + -0.45885, 1.68171, -0.22286, + -0.06473, -0.86962, 1.93435 + ] + }, + { + "ct": 2940, + "ccm": + [ + 1.29876, 0.09627, -0.39503, + -0.43085, 1.60258, -0.17172, + -0.02638, -0.92581, 1.95218 + ] + }, + { + "ct": 3650, + "ccm": + [ + 1.57729, -0.29734, -0.27995, + -0.42965, 1.66231, -0.23265, + -0.02183, -0.62331, 1.64514 + ] + }, + { + "ct": 4625, + "ccm": + [ + 1.52145, -0.22382, -0.29763, + -0.40445, 1.82186, -0.41742, + -0.05732, -0.56222, 1.61954 + ] + }, + { + "ct": 5715, + "ccm": + [ + 1.67851, -0.39193, -0.28658, + -0.37169, 1.72949, -0.35781, + -0.09556, -0.41951, 1.51508 + ] + } + ] + } + }, + { + "rpi.sharpen": { } + }, + { + "rpi.focus": { } + }, + { + "rpi.af": + { + "ranges": + { + "normal": + { + "min": 0.0, + "max": 12.0, + "default": 1.0 + }, + "macro": + { + "min": 4.0, + "max": 32.0, + "default": 6.0 + } + }, + "speeds": + { + "normal": + { + "step_coarse": 2.0, + "step_fine": 0.5, + "contrast_ratio": 0.75, + "pdaf_gain": -0.03, + "pdaf_squelch": 0.2, + "max_slew": 4.0, + "pdaf_frames": 20, + "dropout_frames": 6, + "step_frames": 4 + }, + "fast": + { + "step_coarse": 2.0, + "step_fine": 0.5, + "contrast_ratio": 0.75, + "pdaf_gain": -0.05, + "pdaf_squelch": 0.2, + "max_slew": 5.0, + "pdaf_frames": 16, + "dropout_frames": 6, + "step_frames": 4 + } + }, + "conf_epsilon": 8, + "conf_thresh": 12, + "conf_clip": 512, + "skip_frames": 5, + "map": [ 0.0, 420, 35.0, 920 ] + } + } + ] +} diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build index 5565508cf602..b163a052f57c 100644 --- a/src/ipa/raspberrypi/data/meson.build +++ b/src/ipa/raspberrypi/data/meson.build @@ -11,6 +11,10 @@ conf_files = files([ 'imx477_noir.json', 'imx477_scientific.json', 'imx519.json', + 'imx708.json', + 'imx708_noir.json', + 'imx708_wide.json', + 'imx708_wide_noir.json', 'ov5647.json', 'ov5647_noir.json', 'ov9281_mono.json', diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build index 4e2689536257..9230e17bca22 100644 --- a/src/ipa/raspberrypi/meson.build +++ b/src/ipa/raspberrypi/meson.build @@ -23,6 +23,7 @@ rpi_ipa_sources = files([ 'cam_helper_imx296.cpp', 'cam_helper_imx477.cpp', 'cam_helper_imx519.cpp', + 'cam_helper_imx708.cpp', 'cam_helper_ov9281.cpp', 'controller/controller.cpp', 'controller/histogram.cpp',