From patchwork Tue Aug 2 10:09:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16895 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 B0319C3275 for ; Tue, 2 Aug 2022 10:10:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6E04A6330F; Tue, 2 Aug 2022 12:10:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659435004; bh=oWAkIFHOz/8cIGh+i21SzJWnGgMMwxg2/GO4mdnw/Vw=; 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=rsw6aKPS78LYa/V+N6EZVJoN6bDCpINunDetFOlKJptG5IFd153kAHH+kMo58ihzw P7XYENM4leJW0Ol1QP+JV0UwlCLhIST729z5shEuyfQghAWukTqDCUf2hJ+cDkWTPP 8G+EV6hoYLFGpx7OvzOMIvG3hXO/YjAje8r8R6Xrfz9BiXwosAzCTxbMh6JD00jKHX GcwaTX4ex+wzD1Lr+XPQrYhZ2xPVHivfMbU+POliylt8iCcmpjQbCybc5oOjscOv0Y Ryl63T8ZOLTS7yvd+QPVTPSVd/0kwMORJlQYLOQLNkl6UqeG9R0GWtPJ1PkfsO9jzl gB4+5J7e1l5aQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 07989603E6 for ; Tue, 2 Aug 2022 12:10:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="uhD3/mRU"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 86B0825B for ; Tue, 2 Aug 2022 12:10:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1659435001; bh=oWAkIFHOz/8cIGh+i21SzJWnGgMMwxg2/GO4mdnw/Vw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=uhD3/mRU8+WUobM2wvzde6v9E4SN+74bLiVzYXjC5hQUTxy+AWuRM4GXPgWHPuaGQ oWTGcGyDwA7RWuEU/o6M5TYweI+WFc3pj9u6nd3ISgnv2sD0R2eeFu7lOcT/WPx84k O/oxB7IEuTpfEJ7jlWhJRpO+j4D/GhLhSwmLgk9o= To: libcamera-devel@lists.libcamera.org Date: Tue, 2 Aug 2022 13:09:52 +0300 Message-Id: <20220802100955.1546-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220802100955.1546-1-laurent.pinchart@ideasonboard.com> References: <20220802100955.1546-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 1/4] pipeline: ipu3: Support IPA tuning file 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: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Pass the path name of the YAML IPA tuning file to the IPA module. The file name is derived from the sensor name ("${sensor_name}.yaml"), with a fallback to "uncalibrated.yaml". The tuning file name can be manually overridden with the LIBCAMERA_IPU3_TUNING_FILE environment variable. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/ipu3/ipu3.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 4fe52f74a68c..5c4a0a567ff2 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -1243,8 +1243,26 @@ int IPU3CameraData::loadIPA() if (ret) return ret; - ret = ipa_->init(IPASettings{ "", sensor->model() }, sensorInfo, - sensor->controls(), &ipaControls_); + /* + * The API tuning file is made from the sensor name unless the + * environment variable overrides it. If + */ + std::string ipaTuningFile; + char const *configFromEnv = utils::secure_getenv("LIBCAMERA_IPU3_TUNING_FILE"); + if (!configFromEnv || *configFromEnv == '\0') { + ipaTuningFile = ipa_->configurationFile(sensor->model() + ".yaml"); + /* + * If the tuning file isn't found, fall back to the + * 'uncalibrated' configuration file. + */ + if (ipaTuningFile.empty()) + ipaTuningFile = ipa_->configurationFile("uncalibrated.yaml"); + } else { + ipaTuningFile = std::string(configFromEnv); + } + + ret = ipa_->init(IPASettings{ ipaTuningFile, sensor->model() }, + sensorInfo, sensor->controls(), &ipaControls_); if (ret) { LOG(IPU3, Error) << "Failed to initialise the IPU3 IPA"; return ret;