From patchwork Thu May 9 11:44:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 20030 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 114BFC3226 for ; Thu, 9 May 2024 11:45:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AD38863466; Thu, 9 May 2024 13:45:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VHVjlf0/"; 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 8F06863433 for ; Thu, 9 May 2024 13:45:01 +0200 (CEST) Received: from neptunite.hamster-moth.ts.net (h175-177-049-156.catv02.itscom.jp [175.177.49.156]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 60CF6904; Thu, 9 May 2024 13:44:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1715255098; bh=5ZbZowTN1Y+kvWOrxD8TaGc1okMfm0PmI9Eb3NqDzP4=; h=From:To:Cc:Subject:Date:From; b=VHVjlf0/4XV3INwLZJ09sZTbth0lsiMyOI3OAqxjO0Kp3aHiX3dFs/DB2KGw8vabU RVxm0Hl8SfWBst5gUL9o9Oal0q3O7Zh2snhcb5pUVqIajdHEu1EGdZ10Q0dhai9THD MZrVvWPlcIeRiYOP4CHTLFQTCYfd44crk4e0bW+A= From: Paul Elder To: libcamera-devel@lists.libcamera.org Cc: Paul Elder , Kieran Bingham , Daniel Scally , Laurent Pinchart Subject: [PATCH v3] ipa: rkisp1: agc: Fix histogram construction Date: Thu, 9 May 2024 20:44:48 +0900 Message-Id: <20240509114448.3685285-1-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.39.2 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" This histogram reported by the rkisp1 hardware is 20 bits, where the upper 16 bits are meaningful integer data and the lower 4 bits are fractional and meant to be discarded. Remove these 4 bits when construction the histogram. Signed-off-by: Paul Elder Reviewed-by: Kieran Bingham Reviewed-by: Daniel Scally Reviewed-by: Laurent Pinchart --- Changes in v3: - fix typo in commit message - add comment explaining the shift Changes in v2: - use a lambda function instead of the rshift parameter --- src/ipa/rkisp1/algorithms/agc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 3e98496b..5aad5c7c 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -277,7 +277,9 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, const rkisp1_cif_isp_stat *params = &stats->params; ASSERT(stats->meas_type & RKISP1_CIF_ISP_STAT_AUTOEXP); - Histogram hist({ params->hist.hist_bins, context.hw->numHistogramBins }); + /* The lower 4 bits are fractional and meant to be discarded. */ + Histogram hist({ params->hist.hist_bins, context.hw->numHistogramBins }, + [](uint32_t x) { return x >> 4; }); expMeans_ = { params->ae.exp_mean, context.hw->numAeCells }; /*