From nobody Sun Dec 14 12:18:00 2025 Received: from ni.piap.pl (ni.piap.pl [195.187.100.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EDD7214232; Thu, 29 May 2025 09:29:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.187.100.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748510984; cv=none; b=lxK7kH2vNi9RBUkw30TP8cgNf/b+bhrq0TnJ3vwU1IWUOI+6sekIhk/XYej3hPfnD/XGmTiOhhXHaKK516DcBsYI2bZIPP4liZ9uWO8EwQ1MgVa5QE6AE3jGPoJ8OB5VN7q9vsIHL0nDtDeCBG9rh681s4bMLPp7C5jmGBwFupk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748510984; c=relaxed/simple; bh=H2adK2TBdCylg3qnTpN93mTeHPKayl2jZjFbC0Xl6DQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=tEqxrSUgV28th6IQkLsSr47u5kqvq1KsON4pHaZcWki3MD3tkBQP4rTFpWD7qnRaqETJZ/L1h1wnLAtvzT+Ix2j9n/GDStZQBmj3Cdh+2zzKGQP8va2UiT8eUz6wKgXnuJQfYVhMK7i0reFHgie5nadJfasM/FFUdWXVs/k2Xlo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=piap.pl; spf=pass smtp.mailfrom=piap.pl; arc=none smtp.client-ip=195.187.100.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=piap.pl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=piap.pl Received: from t19.piap.pl (OSB1819.piap.pl [10.0.9.19]) by ni.piap.pl (Postfix) with ESMTPS id 68AFEC3EEAC9; Thu, 29 May 2025 11:29:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 ni.piap.pl 68AFEC3EEAC9 From: Krzysztof =?utf-8?Q?Ha=C5=82asa?= To: Dafna Hirschfeld Cc: Laurent Pinchart , Mauro Carvalho Chehab , Heiko Stuebner , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jacopo Mondi , Paul Elder , Ondrej Jirman , Tomi Valkeinen Subject: [PATCH] media: rkisp1: correct histogram window size Date: Thu, 29 May 2025 11:29:39 +0200 Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The histogram window dimensions are unnecessarily decremented. This can be seen in the following example, where when all pixels are of maximum intensi= ty there are pixels that we expect to be counted but are missing from the high= est bin. Fix this by removing the unnecessary decrement. Without the patch (i.MX8MP, all-white RGGB-12 full HD input from the sensor, YUV NV12 output from ISP, full range, histogram Y mode). HIST_STEPSIZE =3D 3 (lowest permitted), all weights are set to 1: isp_hist_h_size: 383 (=3D 1920 / 5 - 1) isp_hist_v_size: 215 (=3D 1080 / 5 - 1) histogram_measurement_result[16]: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 229401 Apparently the histogram is missing the last column (3-pixel wide, though only single pixels count) and the last (same idea) row of the input image: 1917 * 1077 / 3 / 3 =3D 229401. E.g. without the patch, the pixels counted in lines are: 0, 3, ... 1914 (which makes 1917/3), and patched: 0, 3, ... 1914, 1917 (which makes 1920/3). The same is true for rows. With the patch applied: isp_hist_h_size: 384 (=3D 1920 / 5) isp_hist_v_size: 216 (=3D 1080 / 5) histogram_measurement_result[16]: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 230400 1920 * 1080 / 3 / 3 =3D 230400 Signed-off-by: Krzysztof Ha=C5=82asa Reviewed-by: Paul Elder diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c b/drive= rs/media/platform/rockchip/rkisp1/rkisp1-params.c index b28f4140c8a3..ca9b3e711e5f 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c @@ -819,8 +819,8 @@ static void rkisp1_hst_config_v10(struct rkisp1_params = *params, arg->meas_window.v_offs); =20 block_hsize =3D arg->meas_window.h_size / - RKISP1_CIF_ISP_HIST_COLUMN_NUM_V10 - 1; - block_vsize =3D arg->meas_window.v_size / RKISP1_CIF_ISP_HIST_ROW_NUM_V10= - 1; + RKISP1_CIF_ISP_HIST_COLUMN_NUM_V10; + block_vsize =3D arg->meas_window.v_size / RKISP1_CIF_ISP_HIST_ROW_NUM_V10; =20 rkisp1_write(params->rkisp1, RKISP1_CIF_ISP_HIST_H_SIZE_V10, block_hsize); --=20 Krzysztof "Chris" Ha=C5=82asa Sie=C4=87 Badawcza =C5=81ukasiewicz Przemys=C5=82owy Instytut Automatyki i Pomiar=C3=B3w PIAP Al. Jerozolimskie 202, 02-486 Warszawa