From patchwork Mon Dec 30 06:11:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 854335 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (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 2D55719C546; Mon, 30 Dec 2024 06:12:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735539129; cv=none; b=ULqbSyZEdgiwg6/vzKBJ481cl4n9dEffe7iuFHr8PpSrtivebalNoiIGEhKofgJOL3XSdNFMEwZLa7K75ULmXJMgBN2nM2TWem/OgeZMKzhd6lEUwP1tWJFU8C/RKJ+aLyLbqcFXexhxUag26nNIyMCYd2bA5vlRkNCIeLsbOLs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735539129; c=relaxed/simple; bh=IENB0nUvzRyRVKBYXng5EyAoZcEesCtDNNIx0/27H4A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AbuDm7+B8b0LcoteEBzj7gkwivLLqI8Aml5SbGw7hCR12DT+O7zrR2vzw7cSYOZZdtZ8NpZCAPRzqnz+4rKWPmfGCzMvq4ab6cLHc4MXYNMFgBCdK+OkFj8eNv/NDkYmisKIFqGAoBU66LCCPwIOR9/LwIu3U+eTVAAU+9bbHtM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=f8NVcU+q; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="f8NVcU+q" Received: from mail.ideasonboard.com (unknown [223.190.82.226]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D7C493DC; Mon, 30 Dec 2024 07:11:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1735539080; bh=IENB0nUvzRyRVKBYXng5EyAoZcEesCtDNNIx0/27H4A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=f8NVcU+qIpJV0YKsh73ng6LX1GP+tmstdGAXUuaeqGmBQiKsD0zK+9nHx4W27wjWh ubl5sKDsME3/3dKybs7I4qyHuqGdaYl3qPNwdx5gn4UOZhCAlABcDT9mgK6eeT6PsN 1+OCvdPQQhsv4ggoVU7YIxn51mw0k0keVC6K8K/w= From: Jai Luthra Date: Mon, 30 Dec 2024 11:41:19 +0530 Subject: [PATCH v5 2/5] media: i2c: imx219: Rename VTS to FRM_LENGTH Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241230-imx219_fixes-v5-2-98446d816489@ideasonboard.com> References: <20241230-imx219_fixes-v5-0-98446d816489@ideasonboard.com> In-Reply-To: <20241230-imx219_fixes-v5-0-98446d816489@ideasonboard.com> To: Dave Stevenson , Sakari Ailus , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jacopo Mondi , Laurent Pinchart , Jai Luthra X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3675; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=IENB0nUvzRyRVKBYXng5EyAoZcEesCtDNNIx0/27H4A=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBncjmKCEIMIUqZR20vY8jtFmPaj7x23T5RFnmgd N8NSp1P/0aJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZ3I5igAKCRBD3pH5JJpx RVHvEACvBg/FeJjmh0unfbJ2ELHXM+UcJCV2oA2Fvy9PU+gfqhSFdK1YWAYNZxCSo49D05PovIs MM8AmSmz20yV0dY1Jl+G4J+Lj5p19PT1/4xBOgN/EHkkI+9cG0WIeHwDa0PB68onuenINWKTeWQ 0KjfUEZJF6tL3vrTNd/SdJDkQHVmI/Ja0VeGjhnR6xW6YiIHEjB9xM+zGSqPJdfVQfGBOhFVPaH BNwVklyvGyeqYOUQVcNeCZ6MVzPr76jOLhjfW3Pezfi7UIAIGOQ48GqErE52plP9KheTClxAniL p+zFYciCTzOAkdtU7FaLtlbYqQ77EAVoiFDP1fyFpbdCNt9KzXq8iZtRiZkiW/4LfQCyVuEqTLz po7ZEusngb126lFn6l26aX6sPZnj/9yz9rlhwLaxheyNgzPzcUgYuN8R1ozxLaRBXQPF6NFtMZE 7yvwNqhD8x2Eq8Gjddcr2pigQ0M6kBoM+gQXXIxJ/5pn9Tb6REf2i8TUDCqEq4KyrH2cj1kc7dG Nm5Rq3Yyn17cOtLFvroDUgo1W85O8s4Sy41O5m6MDEKSlvEwhTMZ4DoI7RFAn1LIDsaEAEi7sPm HqZsGpv9w3QgY6TdAAv/dYTWd1VHrAf5p/tgrRJbbjenTWm6cn11iFgns2vhc6liEV3nw3MyseA /pwmmKnbViRYueg== X-Developer-Key: i=jai.luthra@ideasonboard.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 The IMX219 datasheet uses the terms FRM_LENGTH and LINE_LENGTH instead of VTS/HTS. Signed-off-by: Jai Luthra Reviewed-by: Dave Stevenson --- drivers/media/i2c/imx219.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c index 0486bbc046cb9c36afd911eb799c1b010a01d496..8565b1b030be2ee24bcc37415e99ee4ef83cc683 100644 --- a/drivers/media/i2c/imx219.c +++ b/drivers/media/i2c/imx219.c @@ -70,9 +70,8 @@ #define IMX219_EXPOSURE_MAX 65535 /* V_TIMING internal */ -#define IMX219_REG_VTS CCI_REG16(0x0160) -#define IMX219_VTS_MAX 0xffff - +#define IMX219_REG_FRM_LENGTH CCI_REG16(0x0160) +#define IMX219_FLL_MAX 0xffff #define IMX219_VBLANK_MIN 32 /* HBLANK control - read only */ @@ -154,7 +153,7 @@ struct imx219_mode { unsigned int height; /* V-timing */ - unsigned int vts_def; + unsigned int fll_def; }; static const struct cci_reg_sequence imx219_common_regs[] = { @@ -289,25 +288,25 @@ static const struct imx219_mode supported_modes[] = { /* 8MPix 15fps mode */ .width = 3280, .height = 2464, - .vts_def = 3526, + .fll_def = 3526, }, { /* 1080P 30fps cropped */ .width = 1920, .height = 1080, - .vts_def = 1763, + .fll_def = 1763, }, { /* 2x2 binned 30fps mode */ .width = 1640, .height = 1232, - .vts_def = 1763, + .fll_def = 1763, }, { /* 640x480 30fps mode */ .width = 640, .height = 480, - .vts_def = 1763, + .fll_def = 1763, }, }; @@ -418,7 +417,7 @@ static int imx219_set_ctrl(struct v4l2_ctrl *ctrl) imx219->hflip->val | imx219->vflip->val << 1, &ret); break; case V4L2_CID_VBLANK: - cci_write(imx219->regmap, IMX219_REG_VTS, + cci_write(imx219->regmap, IMX219_REG_FRM_LENGTH, format->height + ctrl->val, &ret); break; case V4L2_CID_TEST_PATTERN_RED: @@ -493,15 +492,15 @@ static int imx219_init_controls(struct imx219 *imx219) /* Initial vblank/hblank/exposure parameters based on current mode */ imx219->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx219_ctrl_ops, V4L2_CID_VBLANK, IMX219_VBLANK_MIN, - IMX219_VTS_MAX - mode->height, 1, - mode->vts_def - mode->height); + IMX219_FLL_MAX - mode->height, 1, + mode->fll_def - mode->height); hblank = IMX219_PPL_DEFAULT - mode->width; imx219->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx219_ctrl_ops, V4L2_CID_HBLANK, hblank, hblank, 1, hblank); if (imx219->hblank) imx219->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; - exposure_max = mode->vts_def - 4; + exposure_max = mode->fll_def - 4; exposure_def = (exposure_max < IMX219_EXPOSURE_DEFAULT) ? exposure_max : IMX219_EXPOSURE_DEFAULT; imx219->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &imx219_ctrl_ops, @@ -847,12 +846,12 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd, /* Update limits and set FPS to default */ __v4l2_ctrl_modify_range(imx219->vblank, IMX219_VBLANK_MIN, - IMX219_VTS_MAX - mode->height, 1, - mode->vts_def - mode->height); + IMX219_FLL_MAX - mode->height, 1, + mode->fll_def - mode->height); __v4l2_ctrl_s_ctrl(imx219->vblank, - mode->vts_def - mode->height); + mode->fll_def - mode->height); /* Update max exposure while meeting expected vblanking */ - exposure_max = mode->vts_def - 4; + exposure_max = mode->fll_def - 4; exposure_def = (exposure_max < IMX219_EXPOSURE_DEFAULT) ? exposure_max : IMX219_EXPOSURE_DEFAULT; __v4l2_ctrl_modify_range(imx219->exposure, From patchwork Mon Dec 30 06:11:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 854334 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (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 3C86A19882F; Mon, 30 Dec 2024 06:12:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735539157; cv=none; b=ij63LmcMdtam1HX1VE6TcjP6olBvtto4AhrfDDdhA6heE/faB+Xwi2mMcrVOrO5l1z/4jrfZhroqr97jYEu+rGV7rH73pRItIx39SPHrKHm/wom6Ippcq3UYY8FPdHQ/4qu/W0JC1236nJAc/goo1j/dRa3tkzaJDB0GBkomhIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735539157; c=relaxed/simple; bh=/zuK+IMKWUpsPxYK9SeLgzl0Ed82qSbZNYmxPYheVTI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W9vPAhm76VKT+GSS2nBwGzIw+NLRIK5tqDApenMEZxTuH3gGscZgrL9g0f9cDY/0J9/2Bswlcb7CRPCfyXPlOir+KZo3pbWZ13Ahce+EkSctNeoV6RTSgPJBey9qsXeDqUo/pF04iORk79n9G7vpvDqm/YvUslMDIbsxC6xquWU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=XEXgFnfl; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="XEXgFnfl" Received: from mail.ideasonboard.com (unknown [223.190.82.226]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 511AC3DC; Mon, 30 Dec 2024 07:11:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1735539108; bh=/zuK+IMKWUpsPxYK9SeLgzl0Ed82qSbZNYmxPYheVTI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XEXgFnflhnVidsxjb6V5leh8fg6zi8ozPOzbo9oJBE7zInB0Tytpj8DAAkwHXI+dT ENVqw6HcGTn8mfH2M0wZ0j89N8u+UnNG/OsJeN5omfuc0WafC8PkXgfeLJryz6OFef jno1osjRb9zyeKGeyvpIYlXRLtAtP+R1xjXYetjo= From: Jai Luthra Date: Mon, 30 Dec 2024 11:41:21 +0530 Subject: [PATCH v5 4/5] media: i2c: imx219: Increase minimum LLP to fix blocky artefacts Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241230-imx219_fixes-v5-4-98446d816489@ideasonboard.com> References: <20241230-imx219_fixes-v5-0-98446d816489@ideasonboard.com> In-Reply-To: <20241230-imx219_fixes-v5-0-98446d816489@ideasonboard.com> To: Dave Stevenson , Sakari Ailus , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jacopo Mondi , Laurent Pinchart , Jai Luthra X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1772; i=jai.luthra@ideasonboard.com; h=from:subject:message-id; bh=/zuK+IMKWUpsPxYK9SeLgzl0Ed82qSbZNYmxPYheVTI=; b=kA0DAAgBQ96R+SSacUUByyZiAGdyOYuhZFG2vPQf9iVDj4b872Yc0vGbOftOLWxcui7rq8h8H YkCMwQAAQgAHRYhBE3g2Bjl1XXo1FqvxUPekfkkmnFFBQJncjmLAAoJEEPekfkkmnFFIDUP/235 SrmbWpglvjOM1grxWaxkavyLA7cANjLgm2o7n241Ljf7tHlSVLpGBfPApI3hALhXjisfr6HxTxa GMl8tnxfVqWIHTPb+W46s4zMqWZi1cB7jlMNdbjYYvf3GfSMRPCn5VbuWqHEuMdtoYLvXkWqiI3 OAuGoJC3Y2xaNeSV8CqrygUlrB5OlyXu+mUhC1xQJc9AhvIKJh2V6owY87nAT/Lh+3bhlakzPyQ X/iao7Qqr5KY4HwOl2GnePoNZHBSUnnKla3D46t6M6Zuxs9fnfrtn94YZWdERJJQkUsWZstrcim yQhShPlZoEb0Y67LmR1AbYWPwsJ93fSOYx4OcXI+Ls0HPeCHUtIJQ+sD6AgUe2bIaYlRFfPIAnY In2rZzYNxReN9A6PfmRL9PhK3yWP3FD2Nja0mFR/gJ98eCYRD6G7fmOrhJgJDKSfeMysitEAWJZ 6yQyFehwWnWf2kK3wjdiP6NlALOJN19dyyM7endLtJGaDBWPOGjkarklZzaRAjypvQ0Kd6wLlVG i9URkDdJqQyQSKf5ZNk6KTe8Q6dmfPQ2BjihWdhCdVCCIbPeD9MLEPdS2TcmwQEPyqAJhux3ryG TbvsI4W8U2sjF4MqbLxVlD/pK/b2bwSlf0xazHRzkV+NfEU9lYWSSK8sdYHZgdYRPi+QU0tvw6/ Op+2C X-Developer-Key: i=jai.luthra@ideasonboard.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 The sensor's internal ADC supports a minimum line length of 3448 pixels, which may be too small to use with analog binning, where ADC operates on two lines together. Switch to a higher minimum line length of 3560 pixels to fix the blocky artefacts seen with analog binning [1]. To keep the same default framerate as before for all the modes, lower the default fll value to compensate for the increase in llp. [1]: https://github.com/raspberrypi/rpicam-apps/issues/281#issuecomment-1082894118 Signed-off-by: Jai Luthra --- drivers/media/i2c/imx219.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c index 9682a74feb3b7b74cd2ca54779323396c77cd5a5..5cbd7b90bed28bcf59debdba6dfc76bcd34eb9b4 100644 --- a/drivers/media/i2c/imx219.c +++ b/drivers/media/i2c/imx219.c @@ -74,7 +74,7 @@ #define IMX219_FLL_MAX 0xffff #define IMX219_VBLANK_MIN 32 #define IMX219_REG_LINE_LENGTH CCI_REG16(0x0162) -#define IMX219_LLP_MIN 0x0d78 +#define IMX219_LLP_MIN 0x0de8 #define IMX219_LLP_MAX 0x7ff0 #define IMX219_REG_X_ADD_STA_A CCI_REG16(0x0164) @@ -287,25 +287,25 @@ static const struct imx219_mode supported_modes[] = { /* 8MPix 15fps mode */ .width = 3280, .height = 2464, - .fll_def = 3526, + .fll_def = 3415, }, { /* 1080P 30fps cropped */ .width = 1920, .height = 1080, - .fll_def = 1763, + .fll_def = 1707, }, { /* 2x2 binned 30fps mode */ .width = 1640, .height = 1232, - .fll_def = 1763, + .fll_def = 1707, }, { /* 640x480 30fps mode */ .width = 640, .height = 480, - .fll_def = 1763, + .fll_def = 1707, }, };