public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexander Shiyan <eagle.alexander923@gmail.com>
To: linux-media@vger.kernel.org
Cc: Michael Riesch <michael.riesch@collabora.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Gerald Loacker <gerald.loacker@wolfvision.net>,
	Dave Stevenson <dave.stevenson@raspberrypi.com>,
	Alexander Shiyan <eagle.alexander923@gmail.com>
Subject: [PATCH v2 3/5] media: i2c: imx415: Add missing 4-lane CSI-2 timing configurations
Date: Fri, 10 Apr 2026 09:19:42 +0300	[thread overview]
Message-ID: <20260410061944.241480-4-eagle.alexander923@gmail.com> (raw)
In-Reply-To: <20260410061944.241480-1-eagle.alexander923@gmail.com>

Add CSI-2 timing configurations for lane rates 1485 Mbps and 2376 Mbps.
Mark configurations that are valid only for 4-lane mode by setting the
first element of hmax_min[] to zero.
Use the zero value in hmax_min[0] together with
sensor->num_data_lanes == 2 to skip unsuitable configurations during
mode selection.
This change enables proper operation for all supported lane rates in
both 2-lane and 4-lane modes.

Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
 drivers/media/i2c/imx415.c | 45 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/drivers/media/i2c/imx415.c b/drivers/media/i2c/imx415.c
index b44d685360c1..b305adec30ce 100644
--- a/drivers/media/i2c/imx415.c
+++ b/drivers/media/i2c/imx415.c
@@ -505,6 +505,19 @@ static const struct cci_reg_sequence imx415_linkrate_1440mbps[] = {
 	{ IMX415_TLPX, 0x004F },
 };
 
+/* 1485 Mbps CSI configuration */
+static const struct cci_reg_sequence imx415_linkrate_1485mbps[] = {
+	{ IMX415_TCLKPOST, 0x00A7 },
+	{ IMX415_TCLKPREPARE, 0x0057 },
+	{ IMX415_TCLKTRAIL, 0x005F },
+	{ IMX415_TCLKZERO, 0x0197 },
+	{ IMX415_THSPREPARE, 0x005F },
+	{ IMX415_THSZERO, 0x00AF },
+	{ IMX415_THSTRAIL, 0x005F },
+	{ IMX415_THSEXIT, 0x009F },
+	{ IMX415_TLPX, 0x004F },
+};
+
 /* 1782 Mbps CSI configuration */
 static const struct cci_reg_sequence imx415_linkrate_1782mbps[] = {
 	{ IMX415_TCLKPOST, 0x00B7 },
@@ -531,6 +544,19 @@ static const struct cci_reg_sequence imx415_linkrate_2079mbps[] = {
 	{ IMX415_TLPX, 0x006F },
 };
 
+/* 2376 Mbps CSI configuration */
+static const struct cci_reg_sequence imx415_linkrate_2376mbps[] = {
+	{ IMX415_TCLKPOST, 0x00E7 },
+	{ IMX415_TCLKPREPARE, 0x008F },
+	{ IMX415_TCLKTRAIL, 0x008F },
+	{ IMX415_TCLKZERO, 0x027F },
+	{ IMX415_THSPREPARE, 0x0097 },
+	{ IMX415_THSZERO, 0x010F },
+	{ IMX415_THSTRAIL, 0x0097 },
+	{ IMX415_THSEXIT, 0x00F7 },
+	{ IMX415_TLPX, 0x007F },
+};
+
 struct imx415_mode_reg_list {
 	u32 num_of_regs;
 	const struct cci_reg_sequence *regs;
@@ -576,6 +602,14 @@ static const struct imx415_mode supported_modes[] = {
 			.regs = imx415_linkrate_1440mbps,
 		},
 	},
+	{
+		.lane_rate = 1485000000,
+		.hmax_min = { 0, 550 },
+		.reg_list = {
+			.num_of_regs = ARRAY_SIZE(imx415_linkrate_1485mbps),
+			.regs = imx415_linkrate_1485mbps,
+		},
+	},
 	{
 		.lane_rate = 1782000000,
 		.hmax_min = { 1100, 550 },
@@ -592,6 +626,14 @@ static const struct imx415_mode supported_modes[] = {
 			.regs = imx415_linkrate_2079mbps,
 		},
 	},
+	{
+		.lane_rate = 2376000000,
+		.hmax_min = { 0, 366 },
+		.reg_list = {
+			.num_of_regs = ARRAY_SIZE(imx415_linkrate_2376mbps),
+			.regs = imx415_linkrate_2376mbps,
+		},
+	},
 };
 
 static const char *const imx415_test_pattern_menu[] = {
@@ -1364,6 +1406,9 @@ static int imx415_parse_hw_config(struct imx415 *sensor)
 			if (bus_cfg.link_frequencies[i] * 2 !=
 			    supported_modes[j].lane_rate)
 				continue;
+			if (!supported_modes[j].hmax_min[0] &&
+			    sensor->num_data_lanes == 2)
+				continue;
 			sensor->cur_mode = j;
 			break;
 		}
-- 
2.52.0


  parent reply	other threads:[~2026-04-10  6:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-10  6:19 [PATCH v2 0/5] media: i2c: imx415: driver improvements and fixes Alexander Shiyan
2026-04-10  6:19 ` [PATCH v2 1/5] media: i2c: imx415: Add missing ADBIT1 register for 10/12-bit output Alexander Shiyan
2026-04-10  6:19 ` [PATCH v2 2/5] media: i2c: imx415: Add missing CSI-2 timing configurations for all lane rates Alexander Shiyan
2026-04-10  6:19 ` Alexander Shiyan [this message]
2026-04-10  6:19 ` [PATCH v2 4/5] media: i2c: imx415: Fix control handler initial count Alexander Shiyan
2026-04-10  6:19 ` [PATCH v2 5/5] media: i2c: imx415: Cluster horizontal and vertical flip controls Alexander Shiyan
2026-04-17 12:23 ` [PATCH v2 0/5] media: i2c: imx415: driver improvements and fixes Michael Riesch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260410061944.241480-4-eagle.alexander923@gmail.com \
    --to=eagle.alexander923@gmail.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=gerald.loacker@wolfvision.net \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=michael.riesch@collabora.com \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox