From patchwork Thu Nov 10 17:31:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 17783 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 BF77DC3285 for ; Thu, 10 Nov 2022 17:32:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8479963083; Thu, 10 Nov 2022 18:32:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1668101561; bh=9ZGQ9hgbXREqVUXDt8Mjsmo3EE5ObzpWFtrLYNUwviM=; 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=B+gFWLAykFe1zu6aR07BGrs+ABTd4QTyidq2C+pAKh/kOTyAz2yjvQvGfmwhXDdt/ 34cEB/n4dD7aYXoH5DhJ7kr8e6UdcErMNf35+ubhoZH/kV6lIXmLN1Flub/QxZ/i9B n88SDMJC+h4Zquu3HUyCIotUT/vSv+ji3EF6A2uMJDng/RdH8tIUY/OREAPVylXbJg cTc6IE30mblxLGdvojOMgEdUHoayNEbsq1R8jl5zqgnx4YYLsb9Fvi4qzDXomqHRCb eYeJS7ERfCkc8W7wWrpBTOW4o/FKxh5d9kQyIuXaH2FeBd7gzZd+LA2ZPfGLWiAKgz dqu7nD3L6GY4Q== 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 8271063083 for ; Thu, 10 Nov 2022 18:32:40 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Ah/cE8nO"; dkim-atps=neutral Received: from pyrite.tail37cf.ts.net (h175-177-042-159.catv02.itscom.jp [175.177.42.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 31789499; Thu, 10 Nov 2022 18:32:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1668101560; bh=9ZGQ9hgbXREqVUXDt8Mjsmo3EE5ObzpWFtrLYNUwviM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ah/cE8nOMfllbaXDGUMRzw4EpvGJtXR8Ocug5TUWt1+TkH7PT1upmReLzNlshM5iZ rQak4TiuTnepbQeKmWbkFMT1Wo4zCLJczEIZelfmAxoaVFT49IVE15mWRETWHkwr4c 0oiBw8SXysWME30f2J83XnG5EBxmiAvGbuPNsjxw= To: libcamera-devel@lists.libcamera.org Date: Fri, 11 Nov 2022 02:31:54 +0900 Message-Id: <20221110173154.488445-13-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221110173154.488445-1-paul.elder@ideasonboard.com> References: <20221110173154.488445-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 12/12] utils: tuning: Add tuning script for rkisp1 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: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a tuning script for rkisp1 that uses libtuning. So far it only supports LSC. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- Changes in v3: - cosmetic changes / fix style - add __main__ guard - rename ALSC to LSC Changes in v2: - add SPDX and copyright - s/average_functions/average/ - update the script to work with the new rkisp1 alsc module v1: This won't run as we're missing the necessary parser and generator for yaml, parabolic gradient support, and multiple green support in the LSC module, hence the DNI. As soon as those are added though, this *should* work. --- utils/tuning/rkisp1.py | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 utils/tuning/rkisp1.py diff --git a/utils/tuning/rkisp1.py b/utils/tuning/rkisp1.py new file mode 100755 index 00000000..a8cb0c39 --- /dev/null +++ b/utils/tuning/rkisp1.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) 2022, Paul Elder +# +# rkisp1.py - Tuning script for rkisp1 + +import sys + +import libtuning as lt +from libtuning.parsers import YamlParser +from libtuning.generators import YamlOutput +from libtuning.modules.lsc import LSCRkISP1 + +tuner = lt.Tuner('RkISP1') +tuner.add(LSCRkISP1( + # This can support other debug options (I can't think of any right + # now, but for future-proofing). + debug=[lt.Debug.Plot], + + # This is for the actual LSC tuning, and is part of the base ALSC + # module. rkisp1's table sector sizes (16x16 programmed as mirrored + # 8x8) are separate, and is hardcoded in its specific ALSC tuning + # module. + sector_shape=(17, 17), + + sector_x_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront), + sector_y_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront), + + # This is the function that will be used to average the pixels in + # each sector. This can also be a custom function. + sector_average_function=lt.average.Mean(), + + # This is the function that will be used to smooth the color ratio + # values. This can also be a custom function. + smoothing_function=lt.smoothing.MedianBlur(3), + )) +tuner.set_input_parser(YamlParser()) +tuner.set_output_formatter(YamlOutput()) +tuner.set_output_order([LSCRkISP1]) + +if __name__ == '__main__': + sys.exit(tuner.run(sys.argv))