From nobody Sun Dec 14 11:42:55 2025 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86EE222BAC2 for ; Thu, 16 Jan 2025 17:43:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737049405; cv=none; b=TYXyVaFAu9IsLoSCZGO9xVdkcF6oaeOYm9YMT57ZI+Hzy7fvHYj4W8sNV4ysM4+YBGBIATyS0TlwXpUUDgIDBNXopvTdJEGygMf/70DTHHW0ua+BtaXujSMjcNiS9slYI64VIRJlrLH6ZXq840M7XR5KzI1BNZhIi6zL8zYfd/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737049405; c=relaxed/simple; bh=eWJgCm/jjyutYsF0u2FHRMTAmQxi4fcBGQ/dHrMP+UM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bzcqVsiWgil2zRrhHPBbfXkTH4T3nmV9mlClpvQ4PxeMnnrCQx1RUMpat8TP5nlPQSZOHSTdE4bTfUIGlXtMlPmEw32zg4fMZUE6/Wt6MzW5ihVVY3WFyPYMj6iYnAhnIaDQdrFxxHXT9Cetzdqf4IUI912Z/UH7sAa401IJ2Jo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=l4YsjycP; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="l4YsjycP" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-436341f575fso12782085e9.1 for ; Thu, 16 Jan 2025 09:43:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1737049402; x=1737654202; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=3c5ov7st4tFk0rMU34jT12B0MxOAS1BPe9J0SsPXA2Q=; b=l4YsjycPU2K1PPwqkPfZbO+7gxn+mSM/QVzG9885bn6kK17jaLYIeUZSsvb9wJsp5o 9wsES9CFOTFo46bf4jwWn1aTM+4D9QU+q3Uw8z5Ko1q1Jub0GNAYCU3+uDSWMVUD2YJ6 YuSJcR1KyHVzsYAbnAWU7KNFN4WWBawdoSh2knGrUygrW2df4P829SEjabjmpIJIIh7J WjynWVgL79TY39AofORjw1ZPzNfAbQZ/hbi9z3h6m5d2WOc3a5IXx7EgNr1hOxFBOS1o 2/+iVhM+8iA1KnEE4hWVgM2ciLvtEHpZFAQWL80JhMraoWgMkiW8IUVHEYMTZD87ba4f Igwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737049402; x=1737654202; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3c5ov7st4tFk0rMU34jT12B0MxOAS1BPe9J0SsPXA2Q=; b=J9QuaskFjzFKm4XFCtxNitVxDIklgZ6T7KsGfKu84ir+YHJT6ABnZXzLQw8j2nNb6A ADI7O9R5pveW/CrHZ/53Fkwow0BKsAC6nvLIpLoTlqGyt029b3a3b76ia8x6kp0WIX2C qOuCLfXWXOJsxyam/8BVKfZL0pFsaC6namFDyKt8/wemOqK3zV9Rxs2NU++hjugh+VzN Yk/wfVsbD3KljeW+S2JQK/ZZqvXi32pJL22UHWBl5tF4eEYxOxdh5caJmJnqVihOHfoO /wbtM974QwXSHl76JwAOHzFs8OjWTupQkNC+Vjb5VLLU5Nb02jHr/U2ZA2YdWgmcEKY3 RiXQ== X-Forwarded-Encrypted: i=1; AJvYcCXaHf4jtMUhDknaA6Utfqlv7xhrEsPHB/KL2W4yCklPyvwQ91bZREbcXPBQWfiiVH3jwu9CfHRgOu+b528=@vger.kernel.org X-Gm-Message-State: AOJu0Yx12EAaeAZSTl5GkfVmaHfSDwlVzmMEGO4Qf+ppFSPUoVFIZsfH zs29q00hPuvmtrWQVdDSlDsrHmm6mg4MDWfD5bz6MQGZBlswvM7cOXPSCGSfxFI= X-Gm-Gg: ASbGncsQGlTzT1tpCRKwxUgss5nCs2hEui/TyykvT14P8Ol5qw2X1db4qXlnfd10/1S luRHfQDzhyEPG6G4atILCq1pMaeiZ34cAsBJUhUS7NsMtzjJTFEzAzHmpCpibzpBlcdOD94Or6N mQgB+te2HZEGodY5+raLUY7Rzpnrc9p1Furx97wQNlxbJtwA56wVZc7Q4fZxI1l5Rs5G+BGL9Bo obvE4dofgRPVJmOOR649Qkey25AFjKCNqJpABRbcfnzqG2L X-Google-Smtp-Source: AGHT+IEQXYtZhwUYeCeL1LvktSO96MXKLnY+XjiG9kqdgpPIWu4aDWvI2TS60uQHB/HnbLr716bFxw== X-Received: by 2002:a05:600c:1c9a:b0:428:d31:ef25 with SMTP id 5b1f17b1804b1-436e26975f1mr354804105e9.12.1737049401790; Thu, 16 Jan 2025 09:43:21 -0800 (PST) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43890413053sm6302515e9.10.2025.01.16.09.43.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2025 09:43:21 -0800 (PST) From: Dave Stevenson Date: Thu, 16 Jan 2025 17:43:11 +0000 Subject: [PATCH v2 3/3] media: i2c: imx415: Link frequencies are not exclusive to num lanes Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250116-media-imx415-v2-3-735263f04652@raspberrypi.com> References: <20250116-media-imx415-v2-0-735263f04652@raspberrypi.com> In-Reply-To: <20250116-media-imx415-v2-0-735263f04652@raspberrypi.com> To: Sakari Ailus , Michael Riesch , Mauro Carvalho Chehab Cc: Gerald Loacker , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 The link frequencies are equally valid in 2 or 4 lane modes, but they change the hmax_min value for the mode as the MIPI block has to have sufficient time to send the pixel data for each line. Remove the association with number of lanes, and add hmax_min configuration for both lane options. Signed-off-by: Dave Stevenson --- drivers/media/i2c/imx415.c | 53 ++++++++++++++++++++++--------------------= ---- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/drivers/media/i2c/imx415.c b/drivers/media/i2c/imx415.c index 24633d17cb09..5729edf06add 100644 --- a/drivers/media/i2c/imx415.c +++ b/drivers/media/i2c/imx415.c @@ -452,9 +452,8 @@ static const struct imx415_clk_params imx415_clk_params= [] =3D { }, }; =20 -/* all-pixel 2-lane 720 Mbps 15.74 Hz mode */ -static const struct cci_reg_sequence imx415_mode_2_720[] =3D { - { IMX415_LANEMODE, IMX415_LANEMODE_2 }, +/* 720 Mbps CSI configuration */ +static const struct cci_reg_sequence imx415_linkrate_720mbps[] =3D { { IMX415_TCLKPOST, 0x006F }, { IMX415_TCLKPREPARE, 0x002F }, { IMX415_TCLKTRAIL, 0x002F }, @@ -466,9 +465,8 @@ static const struct cci_reg_sequence imx415_mode_2_720[= ] =3D { { IMX415_TLPX, 0x0027 }, }; =20 -/* all-pixel 2-lane 1440 Mbps 30.01 Hz mode */ -static const struct cci_reg_sequence imx415_mode_2_1440[] =3D { - { IMX415_LANEMODE, IMX415_LANEMODE_2 }, +/* 1440 Mbps CSI configuration */ +static const struct cci_reg_sequence imx415_linkrate_1440mbps[] =3D { { IMX415_TCLKPOST, 0x009F }, { IMX415_TCLKPREPARE, 0x0057 }, { IMX415_TCLKTRAIL, 0x0057 }, @@ -480,9 +478,8 @@ static const struct cci_reg_sequence imx415_mode_2_1440= [] =3D { { IMX415_TLPX, 0x004F }, }; =20 -/* all-pixel 4-lane 891 Mbps 30 Hz mode */ -static const struct cci_reg_sequence imx415_mode_4_891[] =3D { - { IMX415_LANEMODE, IMX415_LANEMODE_4 }, +/* 891 Mbps CSI configuration */ +static const struct cci_reg_sequence imx415_linkrate_891mbps[] =3D { { IMX415_TCLKPOST, 0x007F }, { IMX415_TCLKPREPARE, 0x0037 }, { IMX415_TCLKTRAIL, 0x0037 }, @@ -501,8 +498,7 @@ struct imx415_mode_reg_list { =20 struct imx415_mode { u64 lane_rate; - u32 lanes; - u32 hmax_min; + u32 hmax_min[2]; struct imx415_mode_reg_list reg_list; }; =20 @@ -510,29 +506,26 @@ struct imx415_mode { static const struct imx415_mode supported_modes[] =3D { { .lane_rate =3D 720000000, - .lanes =3D 2, - .hmax_min =3D 2032, + .hmax_min =3D { 2032, 1066 }, .reg_list =3D { - .num_of_regs =3D ARRAY_SIZE(imx415_mode_2_720), - .regs =3D imx415_mode_2_720, + .num_of_regs =3D ARRAY_SIZE(imx415_linkrate_720mbps), + .regs =3D imx415_linkrate_720mbps, }, }, { .lane_rate =3D 1440000000, - .lanes =3D 2, - .hmax_min =3D 1066, + .hmax_min =3D { 1066, 533 }, .reg_list =3D { - .num_of_regs =3D ARRAY_SIZE(imx415_mode_2_1440), - .regs =3D imx415_mode_2_1440, + .num_of_regs =3D ARRAY_SIZE(imx415_linkrate_1440mbps), + .regs =3D imx415_linkrate_1440mbps, }, }, { .lane_rate =3D 891000000, - .lanes =3D 4, - .hmax_min =3D 1100, + .hmax_min =3D { 2200, 1100 }, .reg_list =3D { - .num_of_regs =3D ARRAY_SIZE(imx415_mode_4_891), - .regs =3D imx415_mode_4_891, + .num_of_regs =3D ARRAY_SIZE(imx415_linkrate_891mbps), + .regs =3D imx415_linkrate_891mbps, }, }, }; @@ -783,7 +776,8 @@ static int imx415_ctrls_init(struct imx415 *sensor) { struct v4l2_fwnode_device_properties props; struct v4l2_ctrl *ctrl; - u64 lane_rate =3D supported_modes[sensor->cur_mode].lane_rate; + const struct imx415_mode *cur_mode =3D &supported_modes[sensor->cur_mode]; + u64 lane_rate =3D cur_mode->lane_rate; u32 exposure_max =3D IMX415_PIXEL_ARRAY_HEIGHT + IMX415_PIXEL_ARRAY_VBLANK - IMX415_EXPOSURE_OFFSET; @@ -824,7 +818,7 @@ static int imx415_ctrls_init(struct imx415 *sensor) IMX415_AGAIN_MAX, IMX415_AGAIN_STEP, IMX415_AGAIN_MIN); =20 - hblank_min =3D (supported_modes[sensor->cur_mode].hmax_min * + hblank_min =3D (cur_mode->hmax_min[sensor->num_data_lanes =3D=3D 2 ? 0 : = 1] * IMX415_HMAX_MULTIPLIER) - IMX415_PIXEL_ARRAY_WIDTH; hblank_max =3D (IMX415_HMAX_MAX * IMX415_HMAX_MULTIPLIER) - IMX415_PIXEL_ARRAY_WIDTH; @@ -886,7 +880,12 @@ static int imx415_set_mode(struct imx415 *sensor, int = mode) IMX415_NUM_CLK_PARAM_REGS, &ret); =20 - return 0; + ret =3D cci_write(sensor->regmap, IMX415_LANEMODE, + sensor->num_data_lanes =3D=3D 2 ? IMX415_LANEMODE_2 : + IMX415_LANEMODE_4, + NULL); + + return ret; } =20 static int imx415_setup(struct imx415 *sensor, struct v4l2_subdev_state *s= tate) @@ -1297,8 +1296,6 @@ static int imx415_parse_hw_config(struct imx415 *sens= or) } =20 for (j =3D 0; j < ARRAY_SIZE(supported_modes); ++j) { - if (sensor->num_data_lanes !=3D supported_modes[j].lanes) - continue; if (bus_cfg.link_frequencies[i] * 2 !=3D supported_modes[j].lane_rate) continue; --=20 2.34.1