From patchwork Fri Apr 11 13:04:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23167 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 B4758C3213 for ; Fri, 11 Apr 2025 13:04:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0D01C68A4C; Fri, 11 Apr 2025 15:04:30 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PaXH7igI"; dkim-atps=neutral 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 578C1689A5 for ; Fri, 11 Apr 2025 15:04:28 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:5b21:2ad5:1023:7179]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CA70B667; Fri, 11 Apr 2025 15:02:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744376548; bh=WLTlcLXRkYE3eeuLYLYnk2l6uU1coK047dKicdENd2Y=; h=From:To:Cc:Subject:Date:From; b=PaXH7igIyZoBe2Znyrbstg+FfnVvSY8y4BhpRHUJrZew+CaVvMTzwptIKZrdUwmp0 QqdNJJC8TQ8y9ZLRVpA3omEdr1kskuf0wSYtYBBSBoxdPZlt6cMWcznd6yBqRJjyRx opg2YGHNiGUn685qdDVwsLNS5/22ncEqTlPrbL9M= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH 0/8] Implement WDR algorithm Date: Fri, 11 Apr 2025 15:04:07 +0200 Message-ID: <20250411130423.2164577-1-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Hi all, This series implements a global tone mapping algorithm for rkisp1. The results are pretty nice and I still need to prepare a few slides with actual images. If you want to test this, it depends on a few other patches: - [PATCH v3 0/2] media: rockchip: rkisp1: Add support for WDR and AWB64 https://lore.kernel.org/linux-media/20250225-awb64-v3-0-af29b1201e48@ideasonboard.com/ - [PATCH v3 00/16] Some rkisp1 awb improvements https://patchwork.libcamera.org/project/libcamera/list/?series=5111 - [PATCH v2 0/9] Wdr preparations https://patchwork.libcamera.org/project/libcamera/list/?series=5121 To enable the WDR algorithm the following entry needs to be present in the tuning file: algorithms: - WideDynamicRange: ExposureConstraint: MaxBrightPixels: 0.02 yTarget: 0.95 MinExposureValue: -4.0 The details of the algorithms are explained in patch 6/8, so I won't repeat them here. The last two patches add debug metadata that is useful for development. I'm still a bit undecided, if that should be mainlined. If anyone is curious, there is a camshark branch available that visualizes the curves and metadata: https://gitlab.freedesktop.org/camera/camshark/-/tree/sklug/next?ref_type=heads Best regards, Stefan Jai Luthra (1): include: linux: Add Wdr to rkisp1-config.h Stefan Klug (7): tuning: rksip1: Add a static WideDynamicRange entry libcamera: Add PID controller class ipa: rkisp1: Add correction for exposure quantization ipa: rkisp1: Switch histogram to RGB combined mode ipa: rkisp1: Add WDR algorithm libcamera: vector: Add explicit cast and data accessor ipa: rkisp1: agc: Add debug controls for statistic values include/libcamera/internal/meson.build | 1 + include/libcamera/internal/pid_controller.h | 46 ++ include/libcamera/internal/vector.h | 11 + include/linux/rkisp1-config.h | 72 +++ src/ipa/rkisp1/algorithms/agc.cpp | 20 +- src/ipa/rkisp1/algorithms/awb.cpp | 15 +- src/ipa/rkisp1/algorithms/meson.build | 1 + src/ipa/rkisp1/algorithms/wdr.cpp | 502 ++++++++++++++++++++ src/ipa/rkisp1/algorithms/wdr.h | 63 +++ src/ipa/rkisp1/ipa_context.h | 12 + src/ipa/rkisp1/params.cpp | 1 + src/ipa/rkisp1/params.h | 2 + src/libcamera/control_ids_debug.yaml | 36 +- src/libcamera/control_ids_draft.yaml | 67 +++ src/libcamera/meson.build | 1 + src/libcamera/pid_controller.cpp | 169 +++++++ src/libcamera/vector.cpp | 18 + utils/tuning/rkisp1.py | 7 +- 18 files changed, 1036 insertions(+), 8 deletions(-) create mode 100644 include/libcamera/internal/pid_controller.h create mode 100644 src/ipa/rkisp1/algorithms/wdr.cpp create mode 100644 src/ipa/rkisp1/algorithms/wdr.h create mode 100644 src/libcamera/pid_controller.cpp