From nobody Mon Jul 27 11:00:15 2026 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 ADCB63AD505 for ; Wed, 8 Jul 2026 14:49:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522155; cv=none; b=KopJS/LUA3kWEf0KjAjiP04RepSZFPQfVwsquszePP1D4VkyNiqH620UqIURfRkYEhQlrz1COecntD2K2pZt02ZLqUIlUebSVwKg5+dx8RhQ+tiPdxMsNRkOt86RSE40Z3r6invAnNQdGcPye97mNGbh5bXdztXdlTTeXZ8ACk0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522155; c=relaxed/simple; bh=FZflqWVIXRCruuWP6g2ExyXMwReUCGhn7A4b9MiKxTM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZXGwmsOC7HUPe6tUghdZosNAqM2K4TBh00dAAGZejAg8OqYyz3Opa5EvT4KJLW9LPOcFLgqJ2HBq4AoEFsDAWtk4UwTlv0ZunfjwAQtPz8xx7/0Whc7nRJgVobRpyPgTwgCGuU2h/EPwwGC5LBXsrzwOX5msVdBv59WFzXF5U/4= 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=czqY0tQL; arc=none smtp.client-ip=209.85.128.47 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="czqY0tQL" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-493c19bad03so7509145e9.2 for ; Wed, 08 Jul 2026 07:49:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522150; x=1784126950; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=NAB/TZ4h8IUmeg+tgDmUhADP6t4/HyOBMb86upV86GM=; b=czqY0tQLN+TVyk7+ipF0m2et96XejWjE1/rHWDa+sK/rUkuExppYwzLigE626HendF 3Nu9igwVeY6f5fz7z66kzLlYcHXmAHx14GgwQhpVhUf/srL87ukQH731UZKr1sEpnVfC OrWRq+ClfRJejK7njCX0N9wlC6cksotMpYdgMtdqCw3487mtLbpN2NoagmtS9lWYBqAr npNLLpSM90/cbFKKnAwG63SMFBnYmRqHhh9PzupGk0eZRfHfAUJS1Eq/ZdYSRqRN35oi 3KRWpZCXoAFudq6NH6d2kniivSADfdR0iKgcdv3kCyHAYf7Sxfp8qoc/PTHu6FSetrAs fBIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522150; x=1784126950; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=NAB/TZ4h8IUmeg+tgDmUhADP6t4/HyOBMb86upV86GM=; b=HXqhrMwh/KmcAyAeuAY9x9+n6qxu1wObNsNHkhTAQLGzGGSXVbLyYKgyFPQrqrM7Lo 3mAKPDHJ8MaHdJzD8AeOoM6OYDZqnFe6nJZ8T/V3qSKirM97Z4jDfVIfTfaFG40zxiFu uespjuaLoCil8XIZiDVyRQmn7W85vIPMWS8cTyLajCK+V0D4ZohEY3pSdbR9PAtvN8c9 c0BY5ch9dHpxHT13jNdxx/N1GVxE8u2iK6X3fSYSZLBK8m5VLZF67S6vDhxSyJ2ANiIq 2dlHPvrEciTZ8vX4Gz75QIEN29bXdI985lst/WK9mOgg2ejIw29lXb5JywRhGI+SREhN 221g== X-Forwarded-Encrypted: i=1; AHgh+Rp3OQ5T/diGxDMzV6pqXXHbktq+4xXz1WqOk6dfuui4B9gOSwdfUbKI8/J/nBanxEve+EsHR1vv04ks+rI=@vger.kernel.org X-Gm-Message-State: AOJu0YwSlHqG5XnWSryobPhCbsZRuUNtpiaDSlaYfH5N9XmkaN8uMEwd TcluNTvTfqD5LaongY9jAA+ikVE4qc/dbci+GHi3kn7yiE/Uowcj852t17XYsvSQaBi9+4GW2u2 nyary X-Gm-Gg: AfdE7clBzNgY1kdzcfCc4zABZ97XIoAa44L3LQA6hBvMyExWsx6vLRUpM7Rlntt0eih 5yQRsEzsyAJo5YumakUDTE5AppjDwhVLEa+e1I2WfJSdOhLrLdTdoyqWUbsKOwL7ev8JKX4xSRT qSHab8cbz9oA2acPVdiC2eSRyiMMS9w7PtXDFXVCyaRGVZZ+Nrqf6j8PgIxe9LbYJSrb5URmEra ZK795IAo8ihR5gI/8qD0zqmkSiNSLfkiT0mnbNij6DOksuzTvihFt2k/CVoTqRVxiIWSttaZ0++ O6QjO79wa+zH7xCQQmPg2EGcxfeZ2XhQItoPmTgjtLZoCT0POG2r26L8oYqYvjrOKZTI3hfHMtA wfDiTWphWUcDlzuVvnFntcFhyNQk5f4gIPeBhOat32kvwEGLnLRZMcUcWJk0tUapQU55kMX7hoO +DBdBiCG11PFF9PLdplr9FWtSwQz/gOJMn9Oo14ck8/ZyIIMQdMkg9Sw4LDc36R7qH X-Received: by 2002:a05:600c:354e:b0:493:b87c:c87d with SMTP id 5b1f17b1804b1-493e683ab6bmr31834115e9.11.1783522150060; Wed, 08 Jul 2026 07:49:10 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:09 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:37 +0100 Subject: [PATCH v3 01/20] media: i2c: imx355: Add support for 24 MHz external clock 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: <20260708-media-imx355-v3-1-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 From: David Heidelberg The IMX355 sensor supports multiple external clock frequencies, including 19.2 MHz and 24 MHz. The driver currently supports only fixed 19.2 MHz input clock. Refactor the clock handling to make the PLL configuration dependent on the external clock frequency and add support for 24 MHz. Introduce a table of clock parameter sets and program the corresponding EXTCLK frequency and PLL multipliers to maintain consistent internal VCO frequencies across supported inputs. The PLL settings are adjusted so that OP VCO remains at 720 MHz This preserves existing timing characteristics while allowing systems using a 24 MHz clock to operate correctly. No functional change for existing 19.2 MHz users. Assisted-by: Claude:claude-opus-4-6 Signed-off-by: David Heidelberg Signed-off-by: Dave Stevenson --- drivers/media/i2c/imx355.c | 77 +++++++++++++++++++++++++++---------------= ---- 1 file changed, 45 insertions(+), 32 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index 27a5c212a527..ad9a9464175b 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -25,6 +25,10 @@ #define IMX355_REG_CHIP_ID 0x0016 #define IMX355_CHIP_ID 0x0355 =20 +/* PLL registers that depend on the external clock frequency */ +#define IMX355_REG_EXTCLK_FREQ 0x0136 +#define IMX355_REG_PLL_OP_MUL 0x030e + /* V_TIMING internal */ #define IMX355_REG_FLL 0x0340 #define IMX355_FLL_MAX 0xffff @@ -63,7 +67,6 @@ =20 /* default link frequency and external clock */ #define IMX355_LINK_FREQ_DEFAULT 360000000LL -#define IMX355_EXT_CLK 19200000 #define IMX355_LINK_FREQ_INDEX 0 =20 /* number of data lanes */ @@ -100,6 +103,29 @@ struct imx355_mode { struct imx355_reg_list reg_list; }; =20 +struct imx355_clk_params { + u32 ext_clk; + u16 extclk_freq; /* External clock (MHz) in 8.8 fixed point) */ + u16 pll_op_mpy; /* OP system PLL multiplier */ +}; + +/* + * The clock tree is in single PLL mode, so PREDIV_VT and MPY_IVT do nothi= ng. + * All modes use the same PLL setup for OP, with IOPCK being 720MHz. + */ +static const struct imx355_clk_params imx355_clk_params[] =3D { + { + .ext_clk =3D 19200000, + .extclk_freq =3D 0x1333, /* 19.2 MHz */ + .pll_op_mpy =3D 75, /* 19.2 / 2 * 75 =3D 720 MHz */ + }, + { + .ext_clk =3D 24000000, + .extclk_freq =3D 0x1800, /* 24.0 MHz */ + .pll_op_mpy =3D 60, /* 24.0 / 2 * 60 =3D 720 MHz */ + }, +}; + struct imx355_hwcfg { unsigned long link_freq_bitmap; }; @@ -125,6 +151,7 @@ struct imx355 { const struct imx355_mode *cur_mode; =20 struct imx355_hwcfg *hwcfg; + const struct imx355_clk_params *clk_params; =20 /* * Mutex for serialized access: @@ -144,8 +171,6 @@ static const struct regulator_bulk_data imx355_supplies= [] =3D { }; =20 static const struct imx355_reg imx355_global_regs[] =3D { - { 0x0136, 0x13 }, - { 0x0137, 0x33 }, { 0x304e, 0x03 }, { 0x4348, 0x16 }, { 0x4350, 0x19 }, @@ -235,8 +260,6 @@ static const struct imx355_reg mode_3268x2448_regs[] = =3D { { 0x0307, 0x78 }, { 0x030b, 0x01 }, { 0x030d, 0x02 }, - { 0x030e, 0x00 }, - { 0x030f, 0x4b }, { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, @@ -284,8 +307,6 @@ static const struct imx355_reg mode_3264x2448_regs[] = =3D { { 0x0307, 0x78 }, { 0x030b, 0x01 }, { 0x030d, 0x02 }, - { 0x030e, 0x00 }, - { 0x030f, 0x4b }, { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, @@ -333,8 +354,6 @@ static const struct imx355_reg mode_3280x2464_regs[] = =3D { { 0x0307, 0x78 }, { 0x030b, 0x01 }, { 0x030d, 0x02 }, - { 0x030e, 0x00 }, - { 0x030f, 0x4b }, { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, @@ -382,8 +401,6 @@ static const struct imx355_reg mode_1940x1096_regs[] = =3D { { 0x0307, 0x78 }, { 0x030b, 0x01 }, { 0x030d, 0x02 }, - { 0x030e, 0x00 }, - { 0x030f, 0x4b }, { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, @@ -431,8 +448,6 @@ static const struct imx355_reg mode_1936x1096_regs[] = =3D { { 0x0307, 0x78 }, { 0x030b, 0x01 }, { 0x030d, 0x02 }, - { 0x030e, 0x00 }, - { 0x030f, 0x4b }, { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, @@ -480,8 +495,6 @@ static const struct imx355_reg mode_1924x1080_regs[] = =3D { { 0x0307, 0x78 }, { 0x030b, 0x01 }, { 0x030d, 0x02 }, - { 0x030e, 0x00 }, - { 0x030f, 0x4b }, { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, @@ -529,8 +542,6 @@ static const struct imx355_reg mode_1920x1080_regs[] = =3D { { 0x0307, 0x78 }, { 0x030b, 0x01 }, { 0x030d, 0x02 }, - { 0x030e, 0x00 }, - { 0x030f, 0x4b }, { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, @@ -578,8 +589,6 @@ static const struct imx355_reg mode_1640x1232_regs[] = =3D { { 0x0307, 0x78 }, { 0x030b, 0x01 }, { 0x030d, 0x02 }, - { 0x030e, 0x00 }, - { 0x030f, 0x4b }, { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, @@ -627,8 +636,6 @@ static const struct imx355_reg mode_1640x922_regs[] =3D= { { 0x0307, 0x78 }, { 0x030b, 0x01 }, { 0x030d, 0x02 }, - { 0x030e, 0x00 }, - { 0x030f, 0x4b }, { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, @@ -676,8 +683,6 @@ static const struct imx355_reg mode_1300x736_regs[] =3D= { { 0x0307, 0x78 }, { 0x030b, 0x01 }, { 0x030d, 0x02 }, - { 0x030e, 0x00 }, - { 0x030f, 0x4b }, { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, @@ -725,8 +730,6 @@ static const struct imx355_reg mode_1296x736_regs[] =3D= { { 0x0307, 0x78 }, { 0x030b, 0x01 }, { 0x030d, 0x02 }, - { 0x030e, 0x00 }, - { 0x030f, 0x4b }, { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, @@ -774,8 +777,6 @@ static const struct imx355_reg mode_1284x720_regs[] =3D= { { 0x0307, 0x78 }, { 0x030b, 0x01 }, { 0x030d, 0x02 }, - { 0x030e, 0x00 }, - { 0x030f, 0x4b }, { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, @@ -823,8 +824,6 @@ static const struct imx355_reg mode_1280x720_regs[] =3D= { { 0x0307, 0x78 }, { 0x030b, 0x01 }, { 0x030d, 0x02 }, - { 0x030e, 0x00 }, - { 0x030f, 0x4b }, { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, @@ -872,8 +871,6 @@ static const struct imx355_reg mode_820x616_regs[] =3D { { 0x0307, 0x78 }, { 0x030b, 0x01 }, { 0x030d, 0x02 }, - { 0x030e, 0x00 }, - { 0x030f, 0x4b }, { 0x0310, 0x00 }, { 0x0700, 0x02 }, { 0x0701, 0x78 }, @@ -1422,6 +1419,16 @@ static int imx355_start_streaming(struct imx355 *imx= 355) return ret; } =20 + /* Set PLL registers for the external clock frequency */ + ret =3D imx355_write_reg(imx355, IMX355_REG_EXTCLK_FREQ, 2, + imx355->clk_params->extclk_freq); + if (ret) + return ret; + ret =3D imx355_write_reg(imx355, IMX355_REG_PLL_OP_MUL, 2, + imx355->clk_params->pll_op_mpy); + if (ret) + return ret; + /* set digital gain control to all color mode */ ret =3D imx355_write_reg(imx355, IMX355_REG_DPGA_USE_GLOBAL_GAIN, 1, 1); if (ret) @@ -1749,7 +1756,13 @@ static int imx355_probe(struct i2c_client *client) "failed to get clock\n"); =20 freq =3D clk_get_rate(imx355->clk); - if (freq !=3D IMX355_EXT_CLK) + for (unsigned int i =3D 0; i < ARRAY_SIZE(imx355_clk_params); i++) { + if (freq =3D=3D imx355_clk_params[i].ext_clk) { + imx355->clk_params =3D &imx355_clk_params[i]; + break; + } + } + if (!imx355->clk_params) return dev_err_probe(imx355->dev, -EINVAL, "external clock %lu is not supported\n", freq); --=20 2.34.1 From nobody Mon Jul 27 11:00:15 2026 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 0C910221F0C for ; Wed, 8 Jul 2026 14:49:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522155; cv=none; b=egODk7MD2xOXdMUAPNaxWZNjSE3yNKuO9jxM/sXGl0mIyqW++A8jqZLv/mq+Z+rC0DB9A8WsoJNcz79Ua2ZWVKrnF+fxUJj+NQxKsEk9PzH7rEdrQxTe/XEh+NiZFlD9bq729TLh+9KA0HWQ35AOa3WVa3XzoYtsr+dyiwIaAP4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522155; c=relaxed/simple; bh=RDZWQZuinWfD+cU4EhZ+Qa3Kim+iJSBL7wAOTiV77wI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ji5FPigoOrebShv1o9rUR68374iT6PXmtBycFZg0ObUxTcTFauep5yp4X2IhBrL/s2w9kwAFBeHsWGDw2f68BvoTiEH5lKFtfmcC76kbBDMfcP4YYHlb22/lGpI6512dcp01eOmd3mvTYRu+NEiTU4QkEvckg3nw3J1jTa1Xcak= 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=g2ze6OKl; arc=none smtp.client-ip=209.85.128.41 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="g2ze6OKl" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-493c2b3dc8bso5200775e9.2 for ; Wed, 08 Jul 2026 07:49:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522151; x=1784126951; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=L5o9RlxsE2MKhjLVDUh9pAaiwDabzRmi61sj7zjZ8Dg=; b=g2ze6OKlRmnp1Y98cN3MOkS1eSvAOpqjk7KdREdQcaTURoga6uCLx8D/+cwH4O/JBQ BuUTNpOturf7rtRgzhuHlb+6yInPfb6Og16uV3dJmjUAxF3HG6vPkgsjOWfHRGgxNoWa EACzOrNdtQYmVZuPIi95A1qbZz4a7vB0NxfZeyDWp6B7NAnLjUCKOfPewkCV5cwo9uhZ Aw+CnJcdiFeyzz2+Blx33YzGfoGDj//DV/fQ6nUmfFm0eKKLURWGnnR06kYellrsGbMx 6vAdespOq4xqgIQKAN/DWzaJ+T+M0Y/wusbM+UCuZrd+FERFFRMdONjjz8BSI7O/dgVo OAKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522151; x=1784126951; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=L5o9RlxsE2MKhjLVDUh9pAaiwDabzRmi61sj7zjZ8Dg=; b=gsQ43JdTVWwuqZbK+X5X/7scCuic50qb1sGneHHOxwEA0Ihi7BvCzh5qB/Yu+uKs2O 4TT+JoLxwk2jDzdJI1d2ezTGkvdDjjOoU7kf4Hh8Gh4nFX9WB0+VNyOT1+WJ4XkEISWN 03x4EuCJmGd/UYww0NiiaXw8UoDLCfDWAZwJR1AbzC1BxOdVbFCfpmMVsYi1CU/LjLvv MfUJwfyq12Jqa7ZzE2mglbl7z9R0jcWGp/OpLZeIO9HNXgyq4JDG0pw9TDYxz/hkyEGa GmQZTJmfU1WlKzsshLioJ8KgvHEMjVBROEDMv+5fY/7LE89QsTNXk+D5VXUyB/VWRTw+ UjVQ== X-Forwarded-Encrypted: i=1; AHgh+RrHTF1o4KAomaSxHNQKrixCvTIHipA4+kNo8DZiYS4t5C5OXzV32oJGjKickHhDATavUuoFtux7yxXzPD0=@vger.kernel.org X-Gm-Message-State: AOJu0Ywipq7zSw6uylV9TQvpiTlN4DfN2y5TM1IRiVqPephXyf8Vc6u0 4Jb/uTI18oQZ+PKBM/D7oln1HVOKwISbpGLr4wDO7oY9XAhC4F5vyorA7WSoSGoAEig= X-Gm-Gg: AfdE7cmuGaZTMHSW6aYX93rojeyVIH6dINkepIXRV8DTjGXkYR1/ZbxM/AOZki3EMzQ 8/0RAF3sI1Ah34KgsVUnEGQn+dxUP4VtmT4wIFUBzscYeBwToneTv/0XNOVSuqpXK78OUevXGms HasY4NmqW7e3DiC0xTnUJitw9MbD2i0ERtNXbFd0py/5LOA3xo+DB0EwC6pBol6xtZuhkQfh1vy E7QL/2MU8X/bVMEoAG5I8wkXTO4/LKbcw6DkUJaIiXqx86kXLEwCPJcNyQtcpPbkncAmUdY15wm k3V00ZEuwJ0nRaKSGHPhG42vBmWRpjnFCC0C6hvh3cofhPrWMokzjCiw0NbGwWBxNpFixtO85v3 TrKaB7jRfu45qgOKoG77/pR6l7c7V7arlOMblZFu6ePrwkZkiaSHbcYUxS2fd2mzlakaiTQK2Iu 5QNaK5il8/a3Zh4kC6v4c+hqQ3KALh1aODJpZWBvvzAED66j1GXbrRDfvCb+Y0AFNI X-Received: by 2002:a05:600c:3e0f:b0:493:9cb3:53fc with SMTP id 5b1f17b1804b1-493e7e84c21mr20262795e9.11.1783522150858; Wed, 08 Jul 2026 07:49:10 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:10 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:38 +0100 Subject: [PATCH v3 02/20] dt-bindings: media: imx355: Allow 2 CSI2 data lane output 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: <20260708-media-imx355-v3-2-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson , Krzysztof Kozlowski X-Mailer: b4 0.14.1 The sensor supports output over either 2 or 4 CSI2 data lanes. The binding only permitted the 4 lane configuration. Add the 2 lane configuration as an option. Signed-off-by: Dave Stevenson Reviewed-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/media/i2c/sony,imx355.yaml | 11 ++++++++= +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/media/i2c/sony,imx355.yaml b= /Documentation/devicetree/bindings/media/i2c/sony,imx355.yaml index 6050d7e7dcfe..d9cdfda699bf 100644 --- a/Documentation/devicetree/bindings/media/i2c/sony,imx355.yaml +++ b/Documentation/devicetree/bindings/media/i2c/sony,imx355.yaml @@ -50,8 +50,15 @@ properties: =20 properties: data-lanes: - minItems: 4 - maxItems: 4 + oneOf: + - items: + - const: 1 + - const: 2 + - const: 3 + - const: 4 + - items: + - const: 1 + - const: 2 =20 required: - link-frequencies --=20 2.34.1 From nobody Mon Jul 27 11:00:15 2026 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 5CDB444BC91 for ; Wed, 8 Jul 2026 14:49:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522160; cv=none; b=pTDPBv0D811n8JHmcOBNr4bK5NJBXUHytWzuVxfmDfEC4H2CvLC6fVlf1lYSUOzKuZIxCYGdNNFg80ZrKwqkvyUs+4/blpR0txIuHCvcanKbOqyTvhB+anp+QQDaTXvh35LCeTqEVpaJgPs0QSAakuJ9Ti/wXT6PuFoyv0NCgnw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522160; c=relaxed/simple; bh=c52oyyw5r8nA+Plt1oz9KlUfBu4NHsmyYBt6O3jdtgU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mYAPYwntSxcIBuTo70ch0Btg/2wPSZAb9o9ItXEcXUE3IdDrcLLMG1kEqDFh/t4VNmcZLlzxUabxZ5nd5r23pyB1irMHpdZh8/LRtvZrDpiX3sTNCFQW+4wcWYTeYHVGe+K0zIG/JINYx/VtmYtILKShCgvJ7zTUhG5pkgRIS5I= 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=YAzwHPkk; arc=none smtp.client-ip=209.85.128.49 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="YAzwHPkk" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-493c1950518so12494265e9.1 for ; Wed, 08 Jul 2026 07:49:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522152; x=1784126952; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Pjq3H+Y5yrVTObysQWJZY5e4lJQtKVcgWqAJmGLgDbQ=; b=YAzwHPkkDLp/Xaw5tZ5+tvf1aXEeTpbukagvJbV3eEBjSNnWrVcNc6zg9d7wjL0a9y Zvl0tMOAD2nlbFOPGtdxD2XPMuuvKHu2HE9FoG9MRIXFs9amH1iX5E/07TBA7DfxvHqB YVSYeQwLk9MCrFL/DLR3xrpQmY0XbUTd0BfhrR9snYpyPVy9d1iIALH/7bfr1vkOBm7q vwY3fBq5t6N22j4ifCPem94LU6Lr02aegK+bAQt7h32ptsNm42p0H8mDqhNEd/rPty9J n4E5PtYj0Irh71OBPeTHpW8pWrJJgw50n6K7HFSblZs/QFUK20dVKAE6p1lfoGN/52dQ HcSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522152; x=1784126952; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Pjq3H+Y5yrVTObysQWJZY5e4lJQtKVcgWqAJmGLgDbQ=; b=tUr4UeR661XvSE53kuk7o3ENhq9VJK9ED46m65D5mvuHVa2ISM20tIw3F7XKfe2l7M VrdKz03RV0Gy3skpj59GybZx/5wvKfbbAPetzvzbZ9DhX45zgwNRZ6+5JZlKJmqE/mq1 yR2pFME8oz9QH4U8g3hyMozd5c46zsJ80T8n/Jy/lum2qBbR0BLfm5qT6Nb/G4K4Vjht t24mp1nIMmXEUrOCpe9dKpeHv6prWYp+kpkbARDusgqBhHfQR3L3Z3oJSXoh5Ez72g5X iuSSrqv9XbUmo8acHNEk/2RCmZK9SeOttpSPqD1zwHk/twm/tubO4uXYR+GfyCI7H02o cojw== X-Forwarded-Encrypted: i=1; AHgh+RoZKSh1xoUWQFIJIYzju+8Hpf1S86RZYzvxE4fB+NP7DZYuqrZPucA5MLLS8/T3dEDSPHnAJI/8/VIP7E8=@vger.kernel.org X-Gm-Message-State: AOJu0YwOht4gJw9X5BG3h9OW0CXCM2BT4bc0A9T3FiHegle7W8X3ucFh Y4X9tC+SnWx4VmrueGaLv54o9jjO9+S8kLu6+Sgq99WDcqiYJO0PFD2EBYLvB3QdioU= X-Gm-Gg: AfdE7ckEaGIpY3n6WCDZkpep5zpxA5/toj8CaVfGnN3ITgDBeEvuKYtVSWE47GamYdM rShtakZaH1APx/LedLxdyXCTmEKC3BtTFnUlWSM8HwcUjiKv6KX/EcXdUzs8jdnuT7aWO8vPqAQ bg4uhp3XUuIXCU/9UqB5EYpgHaWl2HNU/od4Wahuruc0sCxQfAlaEyBw3OwLdR/TxlDMhyLOkko eL8vDYYf29AbzH5TRXkZWgFg2n+2eXz0C341eMI7O1Iiro2VhYDpnscbIqHprnYVLkpsrqjyPOp Up27DF0GARvzJDuMuVQkC0bsr9GahU9JF+Ry8sF5Fy8tl4GsLHEz/2nPJnvijVBYN6vf1vGhDeA PyYGa55xLj3EpIYJralZux0s9FHXWS5S/jjxuHwDlHpg03PpHyt90uHW8Z5FGYz3Gm0f4RUGxv1 r2dhnz27s9bDz9N/5Vy1ZZS0CtnuoX0UXNeMuxzFH1rc148p2JvuS2hpgAYuR5kqjS X-Received: by 2002:a05:600c:6288:b0:490:af63:2cb1 with SMTP id 5b1f17b1804b1-493e6371c95mr32486805e9.7.1783522152166; Wed, 08 Jul 2026 07:49:12 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:11 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:39 +0100 Subject: [PATCH v3 03/20] media: imx355: Remove duplicated registers from the mode tables 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: <20260708-media-imx355-v3-3-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 A large number of registers are identical within all the modes. Move those to imx355_global_regs. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/imx355.c | 345 +++--------------------------------------= ---- 1 file changed, 23 insertions(+), 322 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index ad9a9464175b..4eaccd9e90f1 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -221,6 +221,29 @@ static const struct imx355_reg imx355_global_regs[] = =3D { { 0x68b0, 0x00 }, { 0x3058, 0x00 }, { 0x305a, 0x00 }, + { 0x0112, 0x0a }, + { 0x0113, 0x0a }, + { 0x0114, 0x03 }, + { 0x0301, 0x05 }, + { 0x0303, 0x01 }, + { 0x0305, 0x02 }, + { 0x0306, 0x00 }, + { 0x0307, 0x78 }, + { 0x030b, 0x01 }, + { 0x030d, 0x02 }, + { 0x0310, 0x00 }, + { 0x0220, 0x00 }, + { 0x0222, 0x01 }, + { 0x0820, 0x0b }, + { 0x0821, 0x40 }, + { 0x3088, 0x04 }, + { 0x6813, 0x02 }, + { 0x6835, 0x07 }, + { 0x6836, 0x01 }, + { 0x6837, 0x04 }, + { 0x684d, 0x07 }, + { 0x684e, 0x01 }, + { 0x684f, 0x04 }, }; =20 static const struct imx355_reg_list imx355_global_setting =3D { @@ -229,9 +252,6 @@ static const struct imx355_reg_list imx355_global_setti= ng =3D { }; =20 static const struct imx355_reg mode_3268x2448_regs[] =3D { - { 0x0112, 0x0a }, - { 0x0113, 0x0a }, - { 0x0114, 0x03 }, { 0x0342, 0x0e }, { 0x0343, 0x58 }, { 0x0340, 0x0a }, @@ -244,8 +264,6 @@ static const struct imx355_reg mode_3268x2448_regs[] = =3D { { 0x0349, 0xcb }, { 0x034a, 0x09 }, { 0x034b, 0x97 }, - { 0x0220, 0x00 }, - { 0x0222, 0x01 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, @@ -253,32 +271,11 @@ static const struct imx355_reg mode_3268x2448_regs[] = =3D { { 0x034d, 0xc4 }, { 0x034e, 0x09 }, { 0x034f, 0x90 }, - { 0x0301, 0x05 }, - { 0x0303, 0x01 }, - { 0x0305, 0x02 }, - { 0x0306, 0x00 }, - { 0x0307, 0x78 }, - { 0x030b, 0x01 }, - { 0x030d, 0x02 }, - { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, - { 0x0820, 0x0b }, - { 0x0821, 0x40 }, - { 0x3088, 0x04 }, - { 0x6813, 0x02 }, - { 0x6835, 0x07 }, - { 0x6836, 0x01 }, - { 0x6837, 0x04 }, - { 0x684d, 0x07 }, - { 0x684e, 0x01 }, - { 0x684f, 0x04 }, }; =20 static const struct imx355_reg mode_3264x2448_regs[] =3D { - { 0x0112, 0x0a }, - { 0x0113, 0x0a }, - { 0x0114, 0x03 }, { 0x0342, 0x0e }, { 0x0343, 0x58 }, { 0x0340, 0x0a }, @@ -291,8 +288,6 @@ static const struct imx355_reg mode_3264x2448_regs[] = =3D { { 0x0349, 0xc7 }, { 0x034a, 0x09 }, { 0x034b, 0x97 }, - { 0x0220, 0x00 }, - { 0x0222, 0x01 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, @@ -300,32 +295,11 @@ static const struct imx355_reg mode_3264x2448_regs[] = =3D { { 0x034d, 0xc0 }, { 0x034e, 0x09 }, { 0x034f, 0x90 }, - { 0x0301, 0x05 }, - { 0x0303, 0x01 }, - { 0x0305, 0x02 }, - { 0x0306, 0x00 }, - { 0x0307, 0x78 }, - { 0x030b, 0x01 }, - { 0x030d, 0x02 }, - { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, - { 0x0820, 0x0b }, - { 0x0821, 0x40 }, - { 0x3088, 0x04 }, - { 0x6813, 0x02 }, - { 0x6835, 0x07 }, - { 0x6836, 0x01 }, - { 0x6837, 0x04 }, - { 0x684d, 0x07 }, - { 0x684e, 0x01 }, - { 0x684f, 0x04 }, }; =20 static const struct imx355_reg mode_3280x2464_regs[] =3D { - { 0x0112, 0x0a }, - { 0x0113, 0x0a }, - { 0x0114, 0x03 }, { 0x0342, 0x0e }, { 0x0343, 0x58 }, { 0x0340, 0x0a }, @@ -338,8 +312,6 @@ static const struct imx355_reg mode_3280x2464_regs[] = =3D { { 0x0349, 0xcf }, { 0x034a, 0x09 }, { 0x034b, 0x9f }, - { 0x0220, 0x00 }, - { 0x0222, 0x01 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, @@ -347,32 +319,11 @@ static const struct imx355_reg mode_3280x2464_regs[] = =3D { { 0x034d, 0xd0 }, { 0x034e, 0x09 }, { 0x034f, 0xa0 }, - { 0x0301, 0x05 }, - { 0x0303, 0x01 }, - { 0x0305, 0x02 }, - { 0x0306, 0x00 }, - { 0x0307, 0x78 }, - { 0x030b, 0x01 }, - { 0x030d, 0x02 }, - { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, - { 0x0820, 0x0b }, - { 0x0821, 0x40 }, - { 0x3088, 0x04 }, - { 0x6813, 0x02 }, - { 0x6835, 0x07 }, - { 0x6836, 0x01 }, - { 0x6837, 0x04 }, - { 0x684d, 0x07 }, - { 0x684e, 0x01 }, - { 0x684f, 0x04 }, }; =20 static const struct imx355_reg mode_1940x1096_regs[] =3D { - { 0x0112, 0x0a }, - { 0x0113, 0x0a }, - { 0x0114, 0x03 }, { 0x0342, 0x0e }, { 0x0343, 0x58 }, { 0x0340, 0x05 }, @@ -385,8 +336,6 @@ static const struct imx355_reg mode_1940x1096_regs[] = =3D { { 0x0349, 0x33 }, { 0x034a, 0x06 }, { 0x034b, 0xf3 }, - { 0x0220, 0x00 }, - { 0x0222, 0x01 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, @@ -394,32 +343,11 @@ static const struct imx355_reg mode_1940x1096_regs[] = =3D { { 0x034d, 0x94 }, { 0x034e, 0x04 }, { 0x034f, 0x48 }, - { 0x0301, 0x05 }, - { 0x0303, 0x01 }, - { 0x0305, 0x02 }, - { 0x0306, 0x00 }, - { 0x0307, 0x78 }, - { 0x030b, 0x01 }, - { 0x030d, 0x02 }, - { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, - { 0x0820, 0x0b }, - { 0x0821, 0x40 }, - { 0x3088, 0x04 }, - { 0x6813, 0x02 }, - { 0x6835, 0x07 }, - { 0x6836, 0x01 }, - { 0x6837, 0x04 }, - { 0x684d, 0x07 }, - { 0x684e, 0x01 }, - { 0x684f, 0x04 }, }; =20 static const struct imx355_reg mode_1936x1096_regs[] =3D { - { 0x0112, 0x0a }, - { 0x0113, 0x0a }, - { 0x0114, 0x03 }, { 0x0342, 0x0e }, { 0x0343, 0x58 }, { 0x0340, 0x05 }, @@ -432,8 +360,6 @@ static const struct imx355_reg mode_1936x1096_regs[] = =3D { { 0x0349, 0x2f }, { 0x034a, 0x06 }, { 0x034b, 0xf3 }, - { 0x0220, 0x00 }, - { 0x0222, 0x01 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, @@ -441,32 +367,11 @@ static const struct imx355_reg mode_1936x1096_regs[] = =3D { { 0x034d, 0x90 }, { 0x034e, 0x04 }, { 0x034f, 0x48 }, - { 0x0301, 0x05 }, - { 0x0303, 0x01 }, - { 0x0305, 0x02 }, - { 0x0306, 0x00 }, - { 0x0307, 0x78 }, - { 0x030b, 0x01 }, - { 0x030d, 0x02 }, - { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, - { 0x0820, 0x0b }, - { 0x0821, 0x40 }, - { 0x3088, 0x04 }, - { 0x6813, 0x02 }, - { 0x6835, 0x07 }, - { 0x6836, 0x01 }, - { 0x6837, 0x04 }, - { 0x684d, 0x07 }, - { 0x684e, 0x01 }, - { 0x684f, 0x04 }, }; =20 static const struct imx355_reg mode_1924x1080_regs[] =3D { - { 0x0112, 0x0a }, - { 0x0113, 0x0a }, - { 0x0114, 0x03 }, { 0x0342, 0x0e }, { 0x0343, 0x58 }, { 0x0340, 0x05 }, @@ -479,8 +384,6 @@ static const struct imx355_reg mode_1924x1080_regs[] = =3D { { 0x0349, 0x2b }, { 0x034a, 0x06 }, { 0x034b, 0xeb }, - { 0x0220, 0x00 }, - { 0x0222, 0x01 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, @@ -488,32 +391,11 @@ static const struct imx355_reg mode_1924x1080_regs[] = =3D { { 0x034d, 0x84 }, { 0x034e, 0x04 }, { 0x034f, 0x38 }, - { 0x0301, 0x05 }, - { 0x0303, 0x01 }, - { 0x0305, 0x02 }, - { 0x0306, 0x00 }, - { 0x0307, 0x78 }, - { 0x030b, 0x01 }, - { 0x030d, 0x02 }, - { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, - { 0x0820, 0x0b }, - { 0x0821, 0x40 }, - { 0x3088, 0x04 }, - { 0x6813, 0x02 }, - { 0x6835, 0x07 }, - { 0x6836, 0x01 }, - { 0x6837, 0x04 }, - { 0x684d, 0x07 }, - { 0x684e, 0x01 }, - { 0x684f, 0x04 }, }; =20 static const struct imx355_reg mode_1920x1080_regs[] =3D { - { 0x0112, 0x0a }, - { 0x0113, 0x0a }, - { 0x0114, 0x03 }, { 0x0342, 0x0e }, { 0x0343, 0x58 }, { 0x0340, 0x05 }, @@ -526,8 +408,6 @@ static const struct imx355_reg mode_1920x1080_regs[] = =3D { { 0x0349, 0x27 }, { 0x034a, 0x06 }, { 0x034b, 0xeb }, - { 0x0220, 0x00 }, - { 0x0222, 0x01 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, @@ -535,32 +415,11 @@ static const struct imx355_reg mode_1920x1080_regs[] = =3D { { 0x034d, 0x80 }, { 0x034e, 0x04 }, { 0x034f, 0x38 }, - { 0x0301, 0x05 }, - { 0x0303, 0x01 }, - { 0x0305, 0x02 }, - { 0x0306, 0x00 }, - { 0x0307, 0x78 }, - { 0x030b, 0x01 }, - { 0x030d, 0x02 }, - { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, - { 0x0820, 0x0b }, - { 0x0821, 0x40 }, - { 0x3088, 0x04 }, - { 0x6813, 0x02 }, - { 0x6835, 0x07 }, - { 0x6836, 0x01 }, - { 0x6837, 0x04 }, - { 0x684d, 0x07 }, - { 0x684e, 0x01 }, - { 0x684f, 0x04 }, }; =20 static const struct imx355_reg mode_1640x1232_regs[] =3D { - { 0x0112, 0x0a }, - { 0x0113, 0x0a }, - { 0x0114, 0x03 }, { 0x0342, 0x07 }, { 0x0343, 0x2c }, { 0x0340, 0x05 }, @@ -573,8 +432,6 @@ static const struct imx355_reg mode_1640x1232_regs[] = =3D { { 0x0349, 0xcf }, { 0x034a, 0x09 }, { 0x034b, 0x9f }, - { 0x0220, 0x00 }, - { 0x0222, 0x01 }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, @@ -582,32 +439,11 @@ static const struct imx355_reg mode_1640x1232_regs[] = =3D { { 0x034d, 0x68 }, { 0x034e, 0x04 }, { 0x034f, 0xd0 }, - { 0x0301, 0x05 }, - { 0x0303, 0x01 }, - { 0x0305, 0x02 }, - { 0x0306, 0x00 }, - { 0x0307, 0x78 }, - { 0x030b, 0x01 }, - { 0x030d, 0x02 }, - { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, - { 0x0820, 0x0b }, - { 0x0821, 0x40 }, - { 0x3088, 0x04 }, - { 0x6813, 0x02 }, - { 0x6835, 0x07 }, - { 0x6836, 0x01 }, - { 0x6837, 0x04 }, - { 0x684d, 0x07 }, - { 0x684e, 0x01 }, - { 0x684f, 0x04 }, }; =20 static const struct imx355_reg mode_1640x922_regs[] =3D { - { 0x0112, 0x0a }, - { 0x0113, 0x0a }, - { 0x0114, 0x03 }, { 0x0342, 0x07 }, { 0x0343, 0x2c }, { 0x0340, 0x05 }, @@ -620,8 +456,6 @@ static const struct imx355_reg mode_1640x922_regs[] =3D= { { 0x0349, 0xcf }, { 0x034a, 0x08 }, { 0x034b, 0x63 }, - { 0x0220, 0x00 }, - { 0x0222, 0x01 }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, @@ -629,32 +463,11 @@ static const struct imx355_reg mode_1640x922_regs[] = =3D { { 0x034d, 0x68 }, { 0x034e, 0x03 }, { 0x034f, 0x9a }, - { 0x0301, 0x05 }, - { 0x0303, 0x01 }, - { 0x0305, 0x02 }, - { 0x0306, 0x00 }, - { 0x0307, 0x78 }, - { 0x030b, 0x01 }, - { 0x030d, 0x02 }, - { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, - { 0x0820, 0x0b }, - { 0x0821, 0x40 }, - { 0x3088, 0x04 }, - { 0x6813, 0x02 }, - { 0x6835, 0x07 }, - { 0x6836, 0x01 }, - { 0x6837, 0x04 }, - { 0x684d, 0x07 }, - { 0x684e, 0x01 }, - { 0x684f, 0x04 }, }; =20 static const struct imx355_reg mode_1300x736_regs[] =3D { - { 0x0112, 0x0a }, - { 0x0113, 0x0a }, - { 0x0114, 0x03 }, { 0x0342, 0x07 }, { 0x0343, 0x2c }, { 0x0340, 0x05 }, @@ -667,8 +480,6 @@ static const struct imx355_reg mode_1300x736_regs[] =3D= { { 0x0349, 0x7f }, { 0x034a, 0x07 }, { 0x034b, 0xaf }, - { 0x0220, 0x00 }, - { 0x0222, 0x01 }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, @@ -676,32 +487,11 @@ static const struct imx355_reg mode_1300x736_regs[] = =3D { { 0x034d, 0x14 }, { 0x034e, 0x02 }, { 0x034f, 0xe0 }, - { 0x0301, 0x05 }, - { 0x0303, 0x01 }, - { 0x0305, 0x02 }, - { 0x0306, 0x00 }, - { 0x0307, 0x78 }, - { 0x030b, 0x01 }, - { 0x030d, 0x02 }, - { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, - { 0x0820, 0x0b }, - { 0x0821, 0x40 }, - { 0x3088, 0x04 }, - { 0x6813, 0x02 }, - { 0x6835, 0x07 }, - { 0x6836, 0x01 }, - { 0x6837, 0x04 }, - { 0x684d, 0x07 }, - { 0x684e, 0x01 }, - { 0x684f, 0x04 }, }; =20 static const struct imx355_reg mode_1296x736_regs[] =3D { - { 0x0112, 0x0a }, - { 0x0113, 0x0a }, - { 0x0114, 0x03 }, { 0x0342, 0x07 }, { 0x0343, 0x2c }, { 0x0340, 0x05 }, @@ -714,8 +504,6 @@ static const struct imx355_reg mode_1296x736_regs[] =3D= { { 0x0349, 0x77 }, { 0x034a, 0x07 }, { 0x034b, 0xaf }, - { 0x0220, 0x00 }, - { 0x0222, 0x01 }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, @@ -723,32 +511,11 @@ static const struct imx355_reg mode_1296x736_regs[] = =3D { { 0x034d, 0x10 }, { 0x034e, 0x02 }, { 0x034f, 0xe0 }, - { 0x0301, 0x05 }, - { 0x0303, 0x01 }, - { 0x0305, 0x02 }, - { 0x0306, 0x00 }, - { 0x0307, 0x78 }, - { 0x030b, 0x01 }, - { 0x030d, 0x02 }, - { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, - { 0x0820, 0x0b }, - { 0x0821, 0x40 }, - { 0x3088, 0x04 }, - { 0x6813, 0x02 }, - { 0x6835, 0x07 }, - { 0x6836, 0x01 }, - { 0x6837, 0x04 }, - { 0x684d, 0x07 }, - { 0x684e, 0x01 }, - { 0x684f, 0x04 }, }; =20 static const struct imx355_reg mode_1284x720_regs[] =3D { - { 0x0112, 0x0a }, - { 0x0113, 0x0a }, - { 0x0114, 0x03 }, { 0x0342, 0x07 }, { 0x0343, 0x2c }, { 0x0340, 0x05 }, @@ -761,8 +528,6 @@ static const struct imx355_reg mode_1284x720_regs[] =3D= { { 0x0349, 0x6f }, { 0x034a, 0x07 }, { 0x034b, 0x9f }, - { 0x0220, 0x00 }, - { 0x0222, 0x01 }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, @@ -770,32 +535,11 @@ static const struct imx355_reg mode_1284x720_regs[] = =3D { { 0x034d, 0x04 }, { 0x034e, 0x02 }, { 0x034f, 0xd0 }, - { 0x0301, 0x05 }, - { 0x0303, 0x01 }, - { 0x0305, 0x02 }, - { 0x0306, 0x00 }, - { 0x0307, 0x78 }, - { 0x030b, 0x01 }, - { 0x030d, 0x02 }, - { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, - { 0x0820, 0x0b }, - { 0x0821, 0x40 }, - { 0x3088, 0x04 }, - { 0x6813, 0x02 }, - { 0x6835, 0x07 }, - { 0x6836, 0x01 }, - { 0x6837, 0x04 }, - { 0x684d, 0x07 }, - { 0x684e, 0x01 }, - { 0x684f, 0x04 }, }; =20 static const struct imx355_reg mode_1280x720_regs[] =3D { - { 0x0112, 0x0a }, - { 0x0113, 0x0a }, - { 0x0114, 0x03 }, { 0x0342, 0x07 }, { 0x0343, 0x2c }, { 0x0340, 0x05 }, @@ -808,8 +552,6 @@ static const struct imx355_reg mode_1280x720_regs[] =3D= { { 0x0349, 0x67 }, { 0x034a, 0x07 }, { 0x034b, 0x9f }, - { 0x0220, 0x00 }, - { 0x0222, 0x01 }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, @@ -817,32 +559,11 @@ static const struct imx355_reg mode_1280x720_regs[] = =3D { { 0x034d, 0x00 }, { 0x034e, 0x02 }, { 0x034f, 0xd0 }, - { 0x0301, 0x05 }, - { 0x0303, 0x01 }, - { 0x0305, 0x02 }, - { 0x0306, 0x00 }, - { 0x0307, 0x78 }, - { 0x030b, 0x01 }, - { 0x030d, 0x02 }, - { 0x0310, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, - { 0x0820, 0x0b }, - { 0x0821, 0x40 }, - { 0x3088, 0x04 }, - { 0x6813, 0x02 }, - { 0x6835, 0x07 }, - { 0x6836, 0x01 }, - { 0x6837, 0x04 }, - { 0x684d, 0x07 }, - { 0x684e, 0x01 }, - { 0x684f, 0x04 }, }; =20 static const struct imx355_reg mode_820x616_regs[] =3D { - { 0x0112, 0x0a }, - { 0x0113, 0x0a }, - { 0x0114, 0x03 }, { 0x0342, 0x0e }, { 0x0343, 0x58 }, { 0x0340, 0x02 }, @@ -855,8 +576,6 @@ static const struct imx355_reg mode_820x616_regs[] =3D { { 0x0349, 0xcf }, { 0x034a, 0x09 }, { 0x034b, 0x9f }, - { 0x0220, 0x00 }, - { 0x0222, 0x01 }, { 0x0900, 0x01 }, { 0x0901, 0x44 }, { 0x0902, 0x00 }, @@ -864,26 +583,8 @@ static const struct imx355_reg mode_820x616_regs[] =3D= { { 0x034d, 0x34 }, { 0x034e, 0x02 }, { 0x034f, 0x68 }, - { 0x0301, 0x05 }, - { 0x0303, 0x01 }, - { 0x0305, 0x02 }, - { 0x0306, 0x00 }, - { 0x0307, 0x78 }, - { 0x030b, 0x01 }, - { 0x030d, 0x02 }, - { 0x0310, 0x00 }, { 0x0700, 0x02 }, { 0x0701, 0x78 }, - { 0x0820, 0x0b }, - { 0x0821, 0x40 }, - { 0x3088, 0x04 }, - { 0x6813, 0x02 }, - { 0x6835, 0x07 }, - { 0x6836, 0x01 }, - { 0x6837, 0x04 }, - { 0x684d, 0x07 }, - { 0x684e, 0x01 }, - { 0x684f, 0x04 }, }; =20 static const char * const imx355_test_pattern_menu[] =3D { --=20 2.34.1 From nobody Mon Jul 27 11:00:15 2026 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 B617D4508F7 for ; Wed, 8 Jul 2026 14:49:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522161; cv=none; b=ldDukGaknaotUyrxpTji2NUzWXOGRSx0bNPoAs4234z7ge3LacnSbdAWsuyTaTWL8dYgoizi0NOVQsrP8b/HZIsYRK3CIlTHnu1XNjsxbRTfhCyA1adAaMuNun53WD1ARPfBhqaRNjfUicBnaZl0wYBLbF2suYoj+d1dQoyYZMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522161; c=relaxed/simple; bh=W23XwrRaIK45UKWx+pemC8iWWRlXIUUJWHH74piX54c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rVxYb6ZXYf9Yzjxo705txMV4jFu5M9dId4wtq2D1bv8+2q3mmx82KAyjoNfOywqOwl5Si6tTqPDUUHavL+TSx9q6k7j7titBmG+A/IkPvoupmagN683ywQWQdjr7Dc14/FD2DMkzApDr3KB+KsjrXVqowoGYcMjDEp7Pvp5rw54= 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=SRYRgKln; arc=none smtp.client-ip=209.85.221.49 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="SRYRgKln" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-476a130c138so867409f8f.0 for ; Wed, 08 Jul 2026 07:49:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522153; x=1784126953; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=TJcpwUL5OnSXVi1yEj1ZgDZ7aAujN4ZxyzVguEBXsyw=; b=SRYRgKlnwEAbdY2mhfvJmN3I3uE5D/4t1RYTUR3AV9VrD1l3TBGVIs5TlZBIy8OZ0N E2ybG+v2iWu+AXHIcaWTeyu24xv+BdB4sR5+FcDcY2XOowb+4gLkIU4vjFEBSyHaFG0y /3P/COVlD7MEnUqDueeO88DPv3DP8ifQi05BPDJby72lPlouRA5Xg3ZTAS0YnWgPqPp0 E0+fEPdePBxbhkggWtcdoDVphDMJpCvrA8dt3y5C1meKqoxUIy8Hp3hBhWy/ltcfXLbl FZpsqmdJItSxEKtGJMMXQiYzq75uvuoIKBWfp8WngG56GQfwe0S9mAH3/ZJo7Ci47Fnj EwGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522153; x=1784126953; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=TJcpwUL5OnSXVi1yEj1ZgDZ7aAujN4ZxyzVguEBXsyw=; b=SqvF7Hg95RiZqY/Xw4N7SZPa9Rrhg82O91EiF6zuJ5hS4PEwo/k7duuxq3vnvhaBKt +E+MYZv4uFR+ApYZaMnMxBN/jDXxZdHNhbJesC1CvqFOn0aAf0TDLzmOa4FjhPTKhYWs m26P6pDd602Cx/Cx7qGIsZuKXnF2J0qe/BhhJcd59lgWGKfD0Pyw+rwNeaeBh5djusQj o2UhKcIKEtl2YHA5X5nCa5RZ2ZEAqY/zlTt6wV2lTEqkikWYmkzMe6urpqyMwbHELWyl Bbdxlnm7hSAEMJdZbUecMmjmOSj+LCaBz+kwVEbY+XwU0nhaY1YVkMKYABY6UfeGgioU Jt2w== X-Forwarded-Encrypted: i=1; AHgh+RpcWV1wQ7JlHQuGMNMM70Tv9mFxQ62zu9JGO4cjIg8L8wzhLMAWTTub2PLnvYsdJdCGTmXmOBKjxo448J4=@vger.kernel.org X-Gm-Message-State: AOJu0Yzanw1frgItNHEYdgSo0gPDfxw3OeHdKSxTOdMrQidr4rmXxh9h y0G2ggDPc0tZ2sdP+i57PL//7lH1irC3AfoZJ/h6P8i3m3H5GqWpLdpA+/4QGhRu+h4= X-Gm-Gg: AfdE7cmWoMIRgXakgnfKccVoAS9b8+AIaoLrBERQhXK6ouSCjQZSFMG5rUNV1ZNB15B HTHZvXhkv24fV5jIJxgJjV/JpXz7Li2xpaAWQfuXAQeg+Oz0bHaxhN60LP3pP25YOpw3pPIzKR4 vbBMUwXhhtN8Am2uGQkHqI+RcNUbn+6YHnQhi+wi7SWSWREB7f+vFoIHCDXFHx8omR7YtMkR/NC uR88nu8NM2h6xNz4JPpIBBmsFp3ZHOP3C6kiv+sro3T/eir74OY8Ff2dt4uOPjujFI1bMzbwdEY O3v8yBO5iThhnZBKgsMiwebqLQT19KlEFrIplK77RwXBDHxScGIC2P5nTarlgC5BtGJ04hYrJQu rDyS7JJxhC2HzWfN3j7EJV1yrE3GfFqb0VoC8+aGlnBYvB3dCKXLI6lbFaTSNIt/h8WAjkS01n7 AnyZ+sA67lAA+gapsKE5eGjcWbgO6gFkBM7pQ1sdOj9egzAIejW/Ap115CFz6XTvR2gP6FwNi2v 24= X-Received: by 2002:a05:600c:4512:b0:493:b7cb:c5f with SMTP id 5b1f17b1804b1-493e6893c66mr27120565e9.11.1783522152948; Wed, 08 Jul 2026 07:49:12 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:12 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:40 +0100 Subject: [PATCH v3 04/20] media: imx355: Remove setting FRM_LENGTH_LINES in the mode regs 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: <20260708-media-imx355-v3-4-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 Registers 0x0340 and 0x0341 (FRM_LENGTH_LINES) are already written from the set_ctrl(V4L2_CID_VBLANK) handler, so don't write them from the mode register list. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/imx355.c | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index 4eaccd9e90f1..24c883a6c520 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -254,8 +254,6 @@ static const struct imx355_reg_list imx355_global_setti= ng =3D { static const struct imx355_reg mode_3268x2448_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0340, 0x0a }, - { 0x0341, 0x37 }, { 0x0344, 0x00 }, { 0x0345, 0x08 }, { 0x0346, 0x00 }, @@ -278,8 +276,6 @@ static const struct imx355_reg mode_3268x2448_regs[] = =3D { static const struct imx355_reg mode_3264x2448_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0340, 0x0a }, - { 0x0341, 0x37 }, { 0x0344, 0x00 }, { 0x0345, 0x08 }, { 0x0346, 0x00 }, @@ -302,8 +298,6 @@ static const struct imx355_reg mode_3264x2448_regs[] = =3D { static const struct imx355_reg mode_3280x2464_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0340, 0x0a }, - { 0x0341, 0x37 }, { 0x0344, 0x00 }, { 0x0345, 0x00 }, { 0x0346, 0x00 }, @@ -326,8 +320,6 @@ static const struct imx355_reg mode_3280x2464_regs[] = =3D { static const struct imx355_reg mode_1940x1096_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0340, 0x05 }, - { 0x0341, 0x1a }, { 0x0344, 0x02 }, { 0x0345, 0xa0 }, { 0x0346, 0x02 }, @@ -350,8 +342,6 @@ static const struct imx355_reg mode_1940x1096_regs[] = =3D { static const struct imx355_reg mode_1936x1096_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0340, 0x05 }, - { 0x0341, 0x1a }, { 0x0344, 0x02 }, { 0x0345, 0xa0 }, { 0x0346, 0x02 }, @@ -374,8 +364,6 @@ static const struct imx355_reg mode_1936x1096_regs[] = =3D { static const struct imx355_reg mode_1924x1080_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0340, 0x05 }, - { 0x0341, 0x1a }, { 0x0344, 0x02 }, { 0x0345, 0xa8 }, { 0x0346, 0x02 }, @@ -398,8 +386,6 @@ static const struct imx355_reg mode_1924x1080_regs[] = =3D { static const struct imx355_reg mode_1920x1080_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0340, 0x05 }, - { 0x0341, 0x1a }, { 0x0344, 0x02 }, { 0x0345, 0xa8 }, { 0x0346, 0x02 }, @@ -422,8 +408,6 @@ static const struct imx355_reg mode_1920x1080_regs[] = =3D { static const struct imx355_reg mode_1640x1232_regs[] =3D { { 0x0342, 0x07 }, { 0x0343, 0x2c }, - { 0x0340, 0x05 }, - { 0x0341, 0x1a }, { 0x0344, 0x00 }, { 0x0345, 0x00 }, { 0x0346, 0x00 }, @@ -446,8 +430,6 @@ static const struct imx355_reg mode_1640x1232_regs[] = =3D { static const struct imx355_reg mode_1640x922_regs[] =3D { { 0x0342, 0x07 }, { 0x0343, 0x2c }, - { 0x0340, 0x05 }, - { 0x0341, 0x1a }, { 0x0344, 0x00 }, { 0x0345, 0x00 }, { 0x0346, 0x01 }, @@ -470,8 +452,6 @@ static const struct imx355_reg mode_1640x922_regs[] =3D= { static const struct imx355_reg mode_1300x736_regs[] =3D { { 0x0342, 0x07 }, { 0x0343, 0x2c }, - { 0x0340, 0x05 }, - { 0x0341, 0x1a }, { 0x0344, 0x01 }, { 0x0345, 0x58 }, { 0x0346, 0x01 }, @@ -494,8 +474,6 @@ static const struct imx355_reg mode_1300x736_regs[] =3D= { static const struct imx355_reg mode_1296x736_regs[] =3D { { 0x0342, 0x07 }, { 0x0343, 0x2c }, - { 0x0340, 0x05 }, - { 0x0341, 0x1a }, { 0x0344, 0x01 }, { 0x0345, 0x58 }, { 0x0346, 0x01 }, @@ -518,8 +496,6 @@ static const struct imx355_reg mode_1296x736_regs[] =3D= { static const struct imx355_reg mode_1284x720_regs[] =3D { { 0x0342, 0x07 }, { 0x0343, 0x2c }, - { 0x0340, 0x05 }, - { 0x0341, 0x1a }, { 0x0344, 0x01 }, { 0x0345, 0x68 }, { 0x0346, 0x02 }, @@ -542,8 +518,6 @@ static const struct imx355_reg mode_1284x720_regs[] =3D= { static const struct imx355_reg mode_1280x720_regs[] =3D { { 0x0342, 0x07 }, { 0x0343, 0x2c }, - { 0x0340, 0x05 }, - { 0x0341, 0x1a }, { 0x0344, 0x01 }, { 0x0345, 0x68 }, { 0x0346, 0x02 }, @@ -566,8 +540,6 @@ static const struct imx355_reg mode_1280x720_regs[] =3D= { static const struct imx355_reg mode_820x616_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0340, 0x02 }, - { 0x0341, 0x8c }, { 0x0344, 0x00 }, { 0x0345, 0x00 }, { 0x0346, 0x00 }, --=20 2.34.1 From nobody Mon Jul 27 11:00:15 2026 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 E5E0840FD9B for ; Wed, 8 Jul 2026 14:49:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522163; cv=none; b=rcpfOqebQo8Yc9WwncMDgJKyorKyeudFugVv/W/Xlh5YHw3G2isFAm252yr5eIkuUnffOKjh2LwXYh7qOPHV4Lgn+AJr0a+xiZ6uDQKtyB2NJ/iQAySfQZTfkh9RItAf/7PcRe7I24tSa4muo7wsXfMZn4LzDZQ+gpMminiYQ2k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522163; c=relaxed/simple; bh=uptn9HEahdMTaqGmQxVJEJT5YRUy1nkqgIMVl2o0djI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hum2GVeEwQx0Mb0z0d5mexYlYtHKsDqFmZrdJl84B2taIAaCTsvL7UlKitI7QSTK+JtvG9OFd63o22LM/raUNJmC7xJkxT1wHq1T7CafL327VMn1QWPNZFBOOpMCn30aCaYuY3mv6RfpA42jEsMFlPxEz0k0cFzxElm/y/HPFUY= 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=HYqRnJDb; arc=none smtp.client-ip=209.85.128.46 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="HYqRnJDb" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-493c486f012so3333915e9.3 for ; Wed, 08 Jul 2026 07:49:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522154; x=1784126954; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Pwzhsyb87YU04avI9KvPGSuu5cY5C4k8J1lsuCyaRo8=; b=HYqRnJDb3n44V1/+5cT3mQMyqFlUG9kGDrugka+tQ6UZTslRnadbotSiaqdoBjBo2Y NT5kxe0FwPlqIX8aHBurVH2IvjX/siZ6F5d15SWgzX6cJPGcOqkEVgnA5GLItoCpQf/A fVx605JQ7i2a3VcjmhUV4LCEcH3spX2mVt+cN8gS/tnyFZMGXz3vaFezufy7dOnxmRlo +9l5bRoa+2ql+Xj1pANWf+KyYVfeu4YSqNqkqT5Qk/2YL/7aVMgecYGZj4l/bax/iklA c4CNJhQDGLrDAZlEa4LWfYcOFT9xezdCpCohsFvIdQoUr3Rks3s0oAn7kn0uv8gp/jQi adNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522154; x=1784126954; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Pwzhsyb87YU04avI9KvPGSuu5cY5C4k8J1lsuCyaRo8=; b=pE52q3dIzynFYD/wlv4MMEzb4VWIpnK9AXz7pE3kxk7h4KOnQhNYsJex6Q841Y6ntK vahwAGM6oCDOxu5Xfj4Fl+iqHhqaJ5+s35s1vUzTRK5DduRuG1SVu5OaKUXpLhaAQXZV 80de6K0Gh7v3FuZtqUTIZv9H5ScfEa/n+8g4w4IvI5+h6ZLjmXbE6Im3dXhDdo4F6zXf vIDbnkKijoslpgNCWbX6SOukUrq5/dUDUhXj8xmFcDHCFpYUUlNqRPw8I+cfZSey/X/1 hm+em74rJuAHGWT//Kxo3hs31VQEhggzOt60dSYSDiNGEH9K+K2zptzkScgo/bbxRmYU W7GA== X-Forwarded-Encrypted: i=1; AHgh+RoLJqUBiubQnRdUAB+8Y4/zktIOSbg7UiUEEwrWRzqtNAJRdhWXVkvONFatXweyL2h46Tk7KUdYkfHfrjU=@vger.kernel.org X-Gm-Message-State: AOJu0Yz77ZzsJ2oZM8VHeBrEpIsdAsuBeSU+H7WJp5xXcd00x9Z1Xa3x oNur5vXk094lRr4w9QdxoHIY4u3bkULXqLLGXO4hz9dY43YOCXUzebSOYTKFo6+dn80= X-Gm-Gg: AfdE7cmh6HRAIbnXGIspMz4q1Y1eCen43b7OtTMZtEoQyTNeVxFbrO2RkY3iYmSC5hT Imt1pPuv/bkFMek1KHZp2YBZjpIin2pZ2+LqFhI7nBFL+D7iyQ2PhUY+iqb7VRDx4ktpB8Allv5 tOcpVVyEcF2h7mcK5ZhseB+Tsx1Jl5GRQiYWK0EZyJE5cX4sKVxj7Ed96ch19pCO4nUo67y2V+C tO9GuAYL7MyChjD1OfIJmtyV9Q4M3RT8MAZvbEK5XMKszBN8IkqW9MTrl2xzAst+uQzm/TcJw3C mZbtJxpcNGcYxTt7WpMohL/YPlEFYTv4xJWh7v5Kkfix7U+Uqt3r2sYcDpoNElGk4L0/kNdQ6q5 GlQ/d2QwtrnepodIXbpQAgNh2W8lHZNFm+n/ng15qXTTM5ivMBJWFbSE31I0p4ZuEw/Lc3z3Scj vg8XKkY9I2cEe6S+4CigSr/Mk5HoQnXPj7Wt4p5+R9uHCnVGY2Z7gHarzas+LxRhAaoxxLShI03 Mo= X-Received: by 2002:a05:600c:1f8e:b0:492:5e22:ef18 with SMTP id 5b1f17b1804b1-493e6861bc8mr26602435e9.9.1783522153744; Wed, 08 Jul 2026 07:49:13 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:13 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:41 +0100 Subject: [PATCH v3 05/20] media: imx355: Programmatically set the crop parameters for each mode 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: <20260708-media-imx355-v3-5-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 Currently the cropping is set via register entries in the per mode register lists. Add the crop information to the mode structure as a v4l2_rect, and set the registers programmatically. Signed-off-by: Dave Stevenson --- drivers/media/i2c/imx355.c | 290 +++++++++++++++++++----------------------= ---- 1 file changed, 121 insertions(+), 169 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index 24c883a6c520..29bca1d98791 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -33,6 +33,13 @@ #define IMX355_REG_FLL 0x0340 #define IMX355_FLL_MAX 0xffff =20 +#define IMX355_REG_X_ADD_START 0x0344 +#define IMX355_REG_Y_ADD_START 0x0346 +#define IMX355_REG_X_ADD_END 0x0348 +#define IMX355_REG_Y_ADD_END 0x034a +#define IMX355_REG_X_OUT_SIZE 0x034c +#define IMX355_REG_Y_OUT_SIZE 0x034e + /* Exposure control */ #define IMX355_REG_EXPOSURE 0x0202 #define IMX355_EXPOSURE_MIN 1 @@ -88,6 +95,7 @@ struct imx355_mode { u32 width; /* Frame height */ u32 height; + struct v4l2_rect crop; =20 /* V-timing */ u32 fll_def; @@ -254,21 +262,9 @@ static const struct imx355_reg_list imx355_global_sett= ing =3D { static const struct imx355_reg mode_3268x2448_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0344, 0x00 }, - { 0x0345, 0x08 }, - { 0x0346, 0x00 }, - { 0x0347, 0x08 }, - { 0x0348, 0x0c }, - { 0x0349, 0xcb }, - { 0x034a, 0x09 }, - { 0x034b, 0x97 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, - { 0x034c, 0x0c }, - { 0x034d, 0xc4 }, - { 0x034e, 0x09 }, - { 0x034f, 0x90 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -276,21 +272,9 @@ static const struct imx355_reg mode_3268x2448_regs[] = =3D { static const struct imx355_reg mode_3264x2448_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0344, 0x00 }, - { 0x0345, 0x08 }, - { 0x0346, 0x00 }, - { 0x0347, 0x08 }, - { 0x0348, 0x0c }, - { 0x0349, 0xc7 }, - { 0x034a, 0x09 }, - { 0x034b, 0x97 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, - { 0x034c, 0x0c }, - { 0x034d, 0xc0 }, - { 0x034e, 0x09 }, - { 0x034f, 0x90 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -298,21 +282,9 @@ static const struct imx355_reg mode_3264x2448_regs[] = =3D { static const struct imx355_reg mode_3280x2464_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0344, 0x00 }, - { 0x0345, 0x00 }, - { 0x0346, 0x00 }, - { 0x0347, 0x00 }, - { 0x0348, 0x0c }, - { 0x0349, 0xcf }, - { 0x034a, 0x09 }, - { 0x034b, 0x9f }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, - { 0x034c, 0x0c }, - { 0x034d, 0xd0 }, - { 0x034e, 0x09 }, - { 0x034f, 0xa0 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -320,21 +292,9 @@ static const struct imx355_reg mode_3280x2464_regs[] = =3D { static const struct imx355_reg mode_1940x1096_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0344, 0x02 }, - { 0x0345, 0xa0 }, - { 0x0346, 0x02 }, - { 0x0347, 0xac }, - { 0x0348, 0x0a }, - { 0x0349, 0x33 }, - { 0x034a, 0x06 }, - { 0x034b, 0xf3 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, - { 0x034c, 0x07 }, - { 0x034d, 0x94 }, - { 0x034e, 0x04 }, - { 0x034f, 0x48 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -342,21 +302,9 @@ static const struct imx355_reg mode_1940x1096_regs[] = =3D { static const struct imx355_reg mode_1936x1096_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0344, 0x02 }, - { 0x0345, 0xa0 }, - { 0x0346, 0x02 }, - { 0x0347, 0xac }, - { 0x0348, 0x0a }, - { 0x0349, 0x2f }, - { 0x034a, 0x06 }, - { 0x034b, 0xf3 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, - { 0x034c, 0x07 }, - { 0x034d, 0x90 }, - { 0x034e, 0x04 }, - { 0x034f, 0x48 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -364,21 +312,9 @@ static const struct imx355_reg mode_1936x1096_regs[] = =3D { static const struct imx355_reg mode_1924x1080_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0344, 0x02 }, - { 0x0345, 0xa8 }, - { 0x0346, 0x02 }, - { 0x0347, 0xb4 }, - { 0x0348, 0x0a }, - { 0x0349, 0x2b }, - { 0x034a, 0x06 }, - { 0x034b, 0xeb }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, - { 0x034c, 0x07 }, - { 0x034d, 0x84 }, - { 0x034e, 0x04 }, - { 0x034f, 0x38 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -386,21 +322,9 @@ static const struct imx355_reg mode_1924x1080_regs[] = =3D { static const struct imx355_reg mode_1920x1080_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0344, 0x02 }, - { 0x0345, 0xa8 }, - { 0x0346, 0x02 }, - { 0x0347, 0xb4 }, - { 0x0348, 0x0a }, - { 0x0349, 0x27 }, - { 0x034a, 0x06 }, - { 0x034b, 0xeb }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, - { 0x034c, 0x07 }, - { 0x034d, 0x80 }, - { 0x034e, 0x04 }, - { 0x034f, 0x38 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -408,21 +332,9 @@ static const struct imx355_reg mode_1920x1080_regs[] = =3D { static const struct imx355_reg mode_1640x1232_regs[] =3D { { 0x0342, 0x07 }, { 0x0343, 0x2c }, - { 0x0344, 0x00 }, - { 0x0345, 0x00 }, - { 0x0346, 0x00 }, - { 0x0347, 0x00 }, - { 0x0348, 0x0c }, - { 0x0349, 0xcf }, - { 0x034a, 0x09 }, - { 0x034b, 0x9f }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, - { 0x034c, 0x06 }, - { 0x034d, 0x68 }, - { 0x034e, 0x04 }, - { 0x034f, 0xd0 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -430,21 +342,9 @@ static const struct imx355_reg mode_1640x1232_regs[] = =3D { static const struct imx355_reg mode_1640x922_regs[] =3D { { 0x0342, 0x07 }, { 0x0343, 0x2c }, - { 0x0344, 0x00 }, - { 0x0345, 0x00 }, - { 0x0346, 0x01 }, - { 0x0347, 0x30 }, - { 0x0348, 0x0c }, - { 0x0349, 0xcf }, - { 0x034a, 0x08 }, - { 0x034b, 0x63 }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, - { 0x034c, 0x06 }, - { 0x034d, 0x68 }, - { 0x034e, 0x03 }, - { 0x034f, 0x9a }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -452,21 +352,9 @@ static const struct imx355_reg mode_1640x922_regs[] = =3D { static const struct imx355_reg mode_1300x736_regs[] =3D { { 0x0342, 0x07 }, { 0x0343, 0x2c }, - { 0x0344, 0x01 }, - { 0x0345, 0x58 }, - { 0x0346, 0x01 }, - { 0x0347, 0xf0 }, - { 0x0348, 0x0b }, - { 0x0349, 0x7f }, - { 0x034a, 0x07 }, - { 0x034b, 0xaf }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, - { 0x034c, 0x05 }, - { 0x034d, 0x14 }, - { 0x034e, 0x02 }, - { 0x034f, 0xe0 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -474,21 +362,9 @@ static const struct imx355_reg mode_1300x736_regs[] = =3D { static const struct imx355_reg mode_1296x736_regs[] =3D { { 0x0342, 0x07 }, { 0x0343, 0x2c }, - { 0x0344, 0x01 }, - { 0x0345, 0x58 }, - { 0x0346, 0x01 }, - { 0x0347, 0xf0 }, - { 0x0348, 0x0b }, - { 0x0349, 0x77 }, - { 0x034a, 0x07 }, - { 0x034b, 0xaf }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, - { 0x034c, 0x05 }, - { 0x034d, 0x10 }, - { 0x034e, 0x02 }, - { 0x034f, 0xe0 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -496,21 +372,9 @@ static const struct imx355_reg mode_1296x736_regs[] = =3D { static const struct imx355_reg mode_1284x720_regs[] =3D { { 0x0342, 0x07 }, { 0x0343, 0x2c }, - { 0x0344, 0x01 }, - { 0x0345, 0x68 }, - { 0x0346, 0x02 }, - { 0x0347, 0x00 }, - { 0x0348, 0x0b }, - { 0x0349, 0x6f }, - { 0x034a, 0x07 }, - { 0x034b, 0x9f }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, - { 0x034c, 0x05 }, - { 0x034d, 0x04 }, - { 0x034e, 0x02 }, - { 0x034f, 0xd0 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -518,21 +382,9 @@ static const struct imx355_reg mode_1284x720_regs[] = =3D { static const struct imx355_reg mode_1280x720_regs[] =3D { { 0x0342, 0x07 }, { 0x0343, 0x2c }, - { 0x0344, 0x01 }, - { 0x0345, 0x68 }, - { 0x0346, 0x02 }, - { 0x0347, 0x00 }, - { 0x0348, 0x0b }, - { 0x0349, 0x67 }, - { 0x034a, 0x07 }, - { 0x034b, 0x9f }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, - { 0x034c, 0x05 }, - { 0x034d, 0x00 }, - { 0x034e, 0x02 }, - { 0x034f, 0xd0 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -540,21 +392,9 @@ static const struct imx355_reg mode_1280x720_regs[] = =3D { static const struct imx355_reg mode_820x616_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0344, 0x00 }, - { 0x0345, 0x00 }, - { 0x0346, 0x00 }, - { 0x0347, 0x00 }, - { 0x0348, 0x0c }, - { 0x0349, 0xcf }, - { 0x034a, 0x09 }, - { 0x034b, 0x9f }, { 0x0900, 0x01 }, { 0x0901, 0x44 }, { 0x0902, 0x00 }, - { 0x034c, 0x03 }, - { 0x034d, 0x34 }, - { 0x034e, 0x02 }, - { 0x034f, 0x68 }, { 0x0700, 0x02 }, { 0x0701, 0x78 }, }; @@ -580,6 +420,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 3280, .height =3D 2464, + .crop =3D { + .width =3D 3280, + .height =3D 2464, + .left =3D 0, + .top =3D 0, + }, .fll_def =3D 2615, .fll_min =3D 2615, .llp =3D 3672, @@ -592,6 +438,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 3268, .height =3D 2448, + .crop =3D { + .width =3D 3268, + .height =3D 2448, + .left =3D 8, + .top =3D 8, + }, .fll_def =3D 2615, .fll_min =3D 2615, .llp =3D 3672, @@ -604,6 +456,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 3264, .height =3D 2448, + .crop =3D { + .width =3D 3264, + .height =3D 2448, + .left =3D 8, + .top =3D 8, + }, .fll_def =3D 2615, .fll_min =3D 2615, .llp =3D 3672, @@ -616,6 +474,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 1940, .height =3D 1096, + .crop =3D { + .width =3D 1940, + .height =3D 1096, + .left =3D 672, + .top =3D 684, + }, .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 3672, @@ -628,6 +492,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 1936, .height =3D 1096, + .crop =3D { + .width =3D 1936, + .height =3D 1096, + .left =3D 672, + .top =3D 684, + }, .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 3672, @@ -640,6 +510,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 1924, .height =3D 1080, + .crop =3D { + .width =3D 1924, + .height =3D 1080, + .left =3D 680, + .top =3D 692, + }, .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 3672, @@ -652,6 +528,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 1920, .height =3D 1080, + .crop =3D { + .width =3D 1920, + .height =3D 1080, + .left =3D 680, + .top =3D 692, + }, .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 3672, @@ -664,6 +546,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 1640, .height =3D 1232, + .crop =3D { + .width =3D 3280, + .height =3D 2464, + .left =3D 0, + .top =3D 0, + }, .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 1836, @@ -676,6 +564,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 1640, .height =3D 922, + .crop =3D { + .width =3D 3280, + .height =3D 1844, + .left =3D 0, + .top =3D 304, + }, .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 1836, @@ -688,6 +582,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 1300, .height =3D 736, + .crop =3D { + .width =3D 2600, + .height =3D 1472, + .left =3D 344, + .top =3D 496, + }, .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 1836, @@ -700,6 +600,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 1296, .height =3D 736, + .crop =3D { + .width =3D 2592, + .height =3D 1472, + .left =3D 344, + .top =3D 496, + }, .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 1836, @@ -712,6 +618,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 1284, .height =3D 720, + .crop =3D { + .width =3D 2568, + .height =3D 1440, + .left =3D 360, + .top =3D 512, + }, .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 1836, @@ -724,6 +636,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 1280, .height =3D 720, + .crop =3D { + .width =3D 2560, + .height =3D 1440, + .left =3D 360, + .top =3D 512, + }, .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 1836, @@ -736,6 +654,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 820, .height =3D 616, + .crop =3D { + .width =3D 3280, + .height =3D 2464, + .left =3D 0, + .top =3D 0, + }, .fll_def =3D 652, .fll_min =3D 652, .llp =3D 3672, @@ -1074,6 +998,7 @@ imx355_set_pad_format(struct v4l2_subdev *sd, static int imx355_start_streaming(struct imx355 *imx355) { const struct imx355_reg_list *reg_list; + const struct imx355_mode *mode; int ret; =20 /* Global Setting */ @@ -1085,13 +1010,40 @@ static int imx355_start_streaming(struct imx355 *im= x355) } =20 /* Apply default values of current mode */ - reg_list =3D &imx355->cur_mode->reg_list; + mode =3D imx355->cur_mode; + reg_list =3D &mode->reg_list; ret =3D imx355_write_regs(imx355, reg_list->regs, reg_list->num_of_regs); if (ret) { dev_err(imx355->dev, "failed to set mode"); return ret; } =20 + /* Set readout crop and size registers */ + ret =3D imx355_write_reg(imx355, IMX355_REG_X_ADD_START, 2, + mode->crop.left); + if (ret) + return ret; + ret =3D imx355_write_reg(imx355, IMX355_REG_Y_ADD_START, 2, + mode->crop.top); + if (ret) + return ret; + ret =3D imx355_write_reg(imx355, IMX355_REG_X_ADD_END, 2, + mode->crop.width + mode->crop.left - 1); + if (ret) + return ret; + ret =3D imx355_write_reg(imx355, IMX355_REG_Y_ADD_END, 2, + mode->crop.height + mode->crop.top - 1); + if (ret) + return ret; + ret =3D imx355_write_reg(imx355, IMX355_REG_X_OUT_SIZE, 2, + mode->width); + if (ret) + return ret; + ret =3D imx355_write_reg(imx355, IMX355_REG_Y_OUT_SIZE, 2, + mode->height); + if (ret) + return ret; + /* Set PLL registers for the external clock frequency */ ret =3D imx355_write_reg(imx355, IMX355_REG_EXTCLK_FREQ, 2, imx355->clk_params->extclk_freq); --=20 2.34.1 From nobody Mon Jul 27 11:00:15 2026 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 0B606449EB8 for ; Wed, 8 Jul 2026 14:49:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522161; cv=none; b=bpcSozIJy/BjBbAwM3BPSn9O5xA5JZGKrV2SuRIfNVBz1+DU06rYshMQ6RDa+gnBMS1GDJDXqs2ySFXnmIXtM8j0YO1jYXxAuY0xI7un7O1YBeHyUnWhm4a4ryLcDVj+Aiu+ZiDiSDMVVowue3gR1qMPXGO2SuMdoleU9klhgMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522161; c=relaxed/simple; bh=hKJ1wRNw/4+kZM2FA6xVtBeoupjoOkwvBGVT6gKhBAU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hN4Da9udldKhDNZm4Qjnja1kBbX0PUWPbV2nscG+TMLQq4D7rC3740aACqzlMnNSpGKT30jl8rW5K8sEoaDRz49/HOjZ7E3/Gcm9pml5GHLBvAvrcVwWM2mSBifrIW7QbBLSzXP+TqPG29+4sEI7NR8TT8s7NImTtym+2ovGtJo= 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=WJnM5xML; arc=none smtp.client-ip=209.85.128.43 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="WJnM5xML" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-493c19bad03so7509965e9.2 for ; Wed, 08 Jul 2026 07:49:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522155; x=1784126955; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=9ab8Gq6xMWbh9FkKTB7pyP7zvswAoiXm+T3oZQ3TQDc=; b=WJnM5xMLQtvEhuVygsL4mCmUp036jCBhOB7ZWsFErEzmNJKe/M8iB4pbH9x9pjyAB+ jBj+K8Bf5pqqzBWev3cMaUPGGAqqGxFbylBSgXA+zpTXJelnkIJk/zR4O38OxTktutA6 ckCRW2VHdSzQMG1e77+E4QVZkWLALZnhdntBsmPyeQho0mqATg5EP82kcxB/+QY7/vGZ +7DfbZ9JmgzE98EayV9ik7rA3O3Pmlo2euGv8/m7yMQ5IfNs0FX95TsII9q7pl4KOtkF fxnfZVvqPTwnNHHw6cjvHKc7FM0S08B9Xb5bqOJwfvq7cjx8yBFBy9SlsGLj2CQ5JxdB uiXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522155; x=1784126955; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=9ab8Gq6xMWbh9FkKTB7pyP7zvswAoiXm+T3oZQ3TQDc=; b=NjLSmkVJUJ28zc7I9YAS6nCMBQMpLFwjvKEU6my7MFZDLzfKbqSt84OjhWdBDagcN4 qZVJZzsjFuLWC+IxEWERWbhVl6og0yymD5CUZQuaMFwYWAloYI6ZuFPWbEjtDgASa2Ny r3NYcW0l5uKUQ2QeqbW/3zZ1MQttTWyxj7grAEc8hBiS+qalvGGFFjdT/L1h5Rxr94uB 9Q64tAGUgXkzs/QU07iEF6bnvXxgV79wf37eyPJeQtz15LJGdhXueml7SuvNrFZGqKpb qoow2wYXp8iPJZJJQ3OXG/qGsgF3h7OYQ2W3c92T/6rFyxf8P1qjIjhYX0GiJjclfhK3 hugg== X-Forwarded-Encrypted: i=1; AHgh+RoAyJygiZemS9oqj8Ezznrq2F4B7EeGOyrkErUht/vrMtvebLldnzpqtEsQfllOcBOmvRZC+QKR7txViOo=@vger.kernel.org X-Gm-Message-State: AOJu0YxaFh6qons4Uxwo33ISfATHlzMVgHNARCaeDRiOb6MM4PWVxRfq P4zyk7kUlYSOzYw90gTF6nrQApKX8SxIt7efXl9VkWKOrk9apg+BxCspxh91AHYs2gQ= X-Gm-Gg: AfdE7cl+V7o281XDmGmJ27SQcreKhjMHHLbHkgTE1bDDT1tSxLj4jiFbkc43J91fhZU i0xSwWzJr1oOk9BUI9WvzVUBoT52kmYEAysZ2EvL4XvtKKXNOTpEA7WQv1uEZRdkr25yZKhxmAv n+OgLk7EU+yPEAiUuSJxyuRGb2hwzt0LKVB7ql1YuHPLOjgaZTkWfVAuL5z9BCF2xExlJYf4hXn DRa6Nr5eyVeyk+5gzKoBrV4TEMDCUnbJXA30SAkLAQcnb8fa7Edd/c6c72Ni8ROncSpCzggcJPf sCD3FJjCDkB1Kf+ieXNNSA/Df12X5F/o/A4dbtkZxsw6Yv7DkStmVNXKe9XnoLIP8s43s2ugbvP ljqX/mV5xnLwtky1Z/aJdbtzm7HLKMqUiLmyNWELXltflz47KR+Q1xqcp0Cmcl1Ebeqr30Ui8y1 fk2s8LMoqO0A8BX9BPrant7MZkO2LFa34WvnYZcP9vZu8raqMRmTYy3W2Dj0eqe0qpvw0vSmcwV 5Q= X-Received: by 2002:a05:600c:3e07:b0:493:de89:61b with SMTP id 5b1f17b1804b1-493e6868766mr31462495e9.26.1783522154549; Wed, 08 Jul 2026 07:49:14 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:14 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:42 +0100 Subject: [PATCH v3 06/20] media: imx355: Set register LINE_LENGTH_PCK programmatically 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: <20260708-media-imx355-v3-6-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 The driver already has the LLP value stored in the mode structure, but also had the same value set via register writes in the mode's register list. Remove this duplication. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/imx355.c | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index 29bca1d98791..7aabd281cd3c 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -33,6 +33,9 @@ #define IMX355_REG_FLL 0x0340 #define IMX355_FLL_MAX 0xffff =20 +#define IMX355_REG_LLP 0x0342 +#define IMX355_LLP_MAX 0xffff + #define IMX355_REG_X_ADD_START 0x0344 #define IMX355_REG_Y_ADD_START 0x0346 #define IMX355_REG_X_ADD_END 0x0348 @@ -260,8 +263,6 @@ static const struct imx355_reg_list imx355_global_setti= ng =3D { }; =20 static const struct imx355_reg mode_3268x2448_regs[] =3D { - { 0x0342, 0x0e }, - { 0x0343, 0x58 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, @@ -270,8 +271,6 @@ static const struct imx355_reg mode_3268x2448_regs[] = =3D { }; =20 static const struct imx355_reg mode_3264x2448_regs[] =3D { - { 0x0342, 0x0e }, - { 0x0343, 0x58 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, @@ -280,8 +279,6 @@ static const struct imx355_reg mode_3264x2448_regs[] = =3D { }; =20 static const struct imx355_reg mode_3280x2464_regs[] =3D { - { 0x0342, 0x0e }, - { 0x0343, 0x58 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, @@ -290,8 +287,6 @@ static const struct imx355_reg mode_3280x2464_regs[] = =3D { }; =20 static const struct imx355_reg mode_1940x1096_regs[] =3D { - { 0x0342, 0x0e }, - { 0x0343, 0x58 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, @@ -300,8 +295,6 @@ static const struct imx355_reg mode_1940x1096_regs[] = =3D { }; =20 static const struct imx355_reg mode_1936x1096_regs[] =3D { - { 0x0342, 0x0e }, - { 0x0343, 0x58 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, @@ -310,8 +303,6 @@ static const struct imx355_reg mode_1936x1096_regs[] = =3D { }; =20 static const struct imx355_reg mode_1924x1080_regs[] =3D { - { 0x0342, 0x0e }, - { 0x0343, 0x58 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, @@ -320,8 +311,6 @@ static const struct imx355_reg mode_1924x1080_regs[] = =3D { }; =20 static const struct imx355_reg mode_1920x1080_regs[] =3D { - { 0x0342, 0x0e }, - { 0x0343, 0x58 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, @@ -330,8 +319,6 @@ static const struct imx355_reg mode_1920x1080_regs[] = =3D { }; =20 static const struct imx355_reg mode_1640x1232_regs[] =3D { - { 0x0342, 0x07 }, - { 0x0343, 0x2c }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, @@ -340,8 +327,6 @@ static const struct imx355_reg mode_1640x1232_regs[] = =3D { }; =20 static const struct imx355_reg mode_1640x922_regs[] =3D { - { 0x0342, 0x07 }, - { 0x0343, 0x2c }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, @@ -350,8 +335,6 @@ static const struct imx355_reg mode_1640x922_regs[] =3D= { }; =20 static const struct imx355_reg mode_1300x736_regs[] =3D { - { 0x0342, 0x07 }, - { 0x0343, 0x2c }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, @@ -360,8 +343,6 @@ static const struct imx355_reg mode_1300x736_regs[] =3D= { }; =20 static const struct imx355_reg mode_1296x736_regs[] =3D { - { 0x0342, 0x07 }, - { 0x0343, 0x2c }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, @@ -370,8 +351,6 @@ static const struct imx355_reg mode_1296x736_regs[] =3D= { }; =20 static const struct imx355_reg mode_1284x720_regs[] =3D { - { 0x0342, 0x07 }, - { 0x0343, 0x2c }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, @@ -380,8 +359,6 @@ static const struct imx355_reg mode_1284x720_regs[] =3D= { }; =20 static const struct imx355_reg mode_1280x720_regs[] =3D { - { 0x0342, 0x07 }, - { 0x0343, 0x2c }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, @@ -390,8 +367,6 @@ static const struct imx355_reg mode_1280x720_regs[] =3D= { }; =20 static const struct imx355_reg mode_820x616_regs[] =3D { - { 0x0342, 0x0e }, - { 0x0343, 0x58 }, { 0x0900, 0x01 }, { 0x0901, 0x44 }, { 0x0902, 0x00 }, @@ -1059,6 +1034,12 @@ static int imx355_start_streaming(struct imx355 *imx= 355) if (ret) return ret; =20 + /* set line length */ + ret =3D imx355_write_reg(imx355, IMX355_REG_LLP, 2, + imx355->hblank->val + imx355->cur_mode->width); + if (ret) + return ret; + /* Apply customized values from user */ ret =3D __v4l2_ctrl_handler_setup(imx355->sd.ctrl_handler); if (ret) --=20 2.34.1 From nobody Mon Jul 27 11:00:15 2026 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 3D03E39C002 for ; Wed, 8 Jul 2026 14:49:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522163; cv=none; b=qyx3gic1X6P9zMH/eMMXi32rWepfqnlIdyrQb1J15xRqcuQjyD5R/lRt5aXcib1YBQ/7gM5XN82nPH/atmcLbZG7KwZm4XcJDRRtjSam9H/60KlAU2ptq6Ohn8f2e+xbPzr3uUM7nBlanbb4SIW1OBMSMtCX2++zZyXLnkkaFKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522163; c=relaxed/simple; bh=txsXplviUmDHwFPKQ6jWBrpAUkebsjly2sdg2MnkYvA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gKVzpy6tRwzUVYScyX9AV9vOPUVoReSURkxQo2n/kWxWXuWzLi/5fxtMnBtHUqv8lGDckainb3DMGEfpgEeclruk0dRD84Baciw+3gGmr6RdAwJVYEvrmX3HAiKZO0wATg4GMUzEkp8VIH0RZWBq1cywlqxgJiKl42KdO8FyCX4= 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=YRZDl254; arc=none smtp.client-ip=209.85.128.44 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="YRZDl254" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-493ae59eca6so4454245e9.1 for ; Wed, 08 Jul 2026 07:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522155; x=1784126955; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=hgjXoLy1TNwMfRKhbBheihYw6qXgsO9wJkLUPpf+nec=; b=YRZDl254+mwg1K6mexONkd7ZNLjKpvcjWtMjbF808vm5l6tAQ2K6mkL4d6hTFV1F52 /IOMMW7W0sYrRkteZJ3TD6JIJMaWTDSVtv5eEQo4JBsktwvy8EUw4N9rUMoiQmzCJd4z hyFcLPtdCOaGrcC/WH4oBleIjhLxGUwkGtx+Xf7W/1romncZ+6rAXb/A/vSVC4jQwMvA DfK6OM/0AbMNg60/zC1jLB6CUtWeQ8YW2m7j5199xi387IuaZ0AHT/bqwHSyjgSqUAMW F4to890vLmm2CpTDGxp97Iy9NtmGhIS2Q5dpZXgn+5EjurPfmse9VfQihoIG6zlo9cxK wFFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522155; x=1784126955; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=hgjXoLy1TNwMfRKhbBheihYw6qXgsO9wJkLUPpf+nec=; b=r3JRje1avyA3BD6NPdFcW5vXHU08wh+yjO4uA2WCiMwGS4w443w5hhh75g4CPxailx K1hefsS8JOfev7jeZgHnNGTx+Vb0M3Cms0bFHsXCEQy5NpTsR7ngb1tdgnG3V8pLEdk0 FgmPf9tSdez082FO2C39BdEmi0CQFYIA9K1Tvpyayy+FN5xeBIo9RBaXn7V1NnsdZDOW SbHGEf9wkrs8gznqCr+znE738E06KFKn5j9oDRksDPAhni9LLYCagmz8dUwEcmUNeaiR R9VDWxxp8HV4PqPtosFx9I3wetgcdI+PxaGMFtxuRbFDUufrvsRjWmThrE7AqUGTSmMn ZfmQ== X-Forwarded-Encrypted: i=1; AHgh+RrvySr2Qo31aUa5hTS2sz8XFcvfr1zcRlDpSWzi2HMzRNrae7d0kbOkQBBMnitv0f7gpMmc2qqeVAzvkQw=@vger.kernel.org X-Gm-Message-State: AOJu0YxXbb+soFK6jD+UyLvxFTtdxqiHA6DHNIeEkTcAuPbNBjm+KP5d Rq1qOrHwXkOZAdVXJcq45PELnXRdyvjSt4aTcGCBZtzyzXcPSCsPqPBtR18YQRcX3vQ= X-Gm-Gg: AfdE7cnHv3EJx7cEoAH3ubxpBNoQVzEk94YgA3CJ8CgqAvceWTXDT41KwlsHvFNvsso VXhhFipIbEh6dM7HdfyKoGk0EAXnSj70usYtz8PifIm+RZXR0VNMjQK4OxnxD4+SeykyNQRW8pK BQSKNx9U+ijwnUFyEJAfKDMTfQdSVJgGR7EiDEnY6bD+BW7hN1yZyiy4jUJTFwp5qABc5UXN9wE MGwOhZxMS6zOTpQ9qz0/ftxbEmNcxvBgIsPb2PmYr3Grsd44GIwsRtkf5x15p6FjKtjWOj9koNV D5iSqOk7ezetwWuqst2c9+E0y9tuIIVrjeLx5En5ygNhNbHPvXmUPjb7ugb9pImGPmDtFQxbvED urYY+w0G5DGg8om6Ww9TQVXrXzTiZTlNRavJlXD5SU6fLRxClJFaSEFwbTBvEFEzpR46KWZjWzQ XyLJNkeuLbfIoSK/8Sc9gcHDHZcL4m1Nj4aSN7YcZ9G0Olx4utVoVnxyM9yNEY+7spRZQc0oWgE M4= X-Received: by 2002:a05:600c:3acf:b0:493:e46a:ab with SMTP id 5b1f17b1804b1-493e68db6edmr29746535e9.34.1783522155321; Wed, 08 Jul 2026 07:49:15 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:14 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:43 +0100 Subject: [PATCH v3 07/20] media: imx355: Set binning mode registers programmatically 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: <20260708-media-imx355-v3-7-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 Compute the binning registers based on the difference between the mode width/height vs the crop width/height. Signed-off-by: Dave Stevenson --- drivers/media/i2c/imx355.c | 61 +++++++++++++++---------------------------= ---- 1 file changed, 19 insertions(+), 42 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index 7aabd281cd3c..1010c32fe969 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -72,6 +72,10 @@ #define IMX355_TEST_PATTERN_GRAY_COLOR_BARS 3 #define IMX355_TEST_PATTERN_PN9 4 =20 +#define IMX355_REG_BINNING_MODE 0x0900 +#define IMX355_REG_BINNING_TYPE 0x0901 +#define IMX355_REG_BINNING_WEIGHTING 0x0902 + /* Flip Control */ #define IMX355_REG_ORIENTATION 0x0101 =20 @@ -263,113 +267,71 @@ static const struct imx355_reg_list imx355_global_se= tting =3D { }; =20 static const struct imx355_reg mode_3268x2448_regs[] =3D { - { 0x0900, 0x00 }, - { 0x0901, 0x11 }, - { 0x0902, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; =20 static const struct imx355_reg mode_3264x2448_regs[] =3D { - { 0x0900, 0x00 }, - { 0x0901, 0x11 }, - { 0x0902, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; =20 static const struct imx355_reg mode_3280x2464_regs[] =3D { - { 0x0900, 0x00 }, - { 0x0901, 0x11 }, - { 0x0902, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; =20 static const struct imx355_reg mode_1940x1096_regs[] =3D { - { 0x0900, 0x00 }, - { 0x0901, 0x11 }, - { 0x0902, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; =20 static const struct imx355_reg mode_1936x1096_regs[] =3D { - { 0x0900, 0x00 }, - { 0x0901, 0x11 }, - { 0x0902, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; =20 static const struct imx355_reg mode_1924x1080_regs[] =3D { - { 0x0900, 0x00 }, - { 0x0901, 0x11 }, - { 0x0902, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; =20 static const struct imx355_reg mode_1920x1080_regs[] =3D { - { 0x0900, 0x00 }, - { 0x0901, 0x11 }, - { 0x0902, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; =20 static const struct imx355_reg mode_1640x1232_regs[] =3D { - { 0x0900, 0x01 }, - { 0x0901, 0x22 }, - { 0x0902, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; =20 static const struct imx355_reg mode_1640x922_regs[] =3D { - { 0x0900, 0x01 }, - { 0x0901, 0x22 }, - { 0x0902, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; =20 static const struct imx355_reg mode_1300x736_regs[] =3D { - { 0x0900, 0x01 }, - { 0x0901, 0x22 }, - { 0x0902, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; =20 static const struct imx355_reg mode_1296x736_regs[] =3D { - { 0x0900, 0x01 }, - { 0x0901, 0x22 }, - { 0x0902, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; =20 static const struct imx355_reg mode_1284x720_regs[] =3D { - { 0x0900, 0x01 }, - { 0x0901, 0x22 }, - { 0x0902, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; =20 static const struct imx355_reg mode_1280x720_regs[] =3D { - { 0x0900, 0x01 }, - { 0x0901, 0x22 }, - { 0x0902, 0x00 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; =20 static const struct imx355_reg mode_820x616_regs[] =3D { - { 0x0900, 0x01 }, - { 0x0901, 0x44 }, - { 0x0902, 0x00 }, { 0x0700, 0x02 }, { 0x0701, 0x78 }, }; @@ -974,6 +936,7 @@ static int imx355_start_streaming(struct imx355 *imx355) { const struct imx355_reg_list *reg_list; const struct imx355_mode *mode; + u8 binning_mode; int ret; =20 /* Global Setting */ @@ -1019,6 +982,20 @@ static int imx355_start_streaming(struct imx355 *imx3= 55) if (ret) return ret; =20 + binning_mode =3D ((mode->crop.width / mode->width) << 4) | + (mode->crop.height / mode->height); + ret =3D imx355_write_reg(imx355, IMX355_REG_BINNING_MODE, 1, + binning_mode =3D=3D 0x11 ? 0x00 : 0x01); + if (ret) + return ret; + ret =3D imx355_write_reg(imx355, IMX355_REG_BINNING_TYPE, 1, + binning_mode); + if (ret) + return ret; + ret =3D imx355_write_reg(imx355, IMX355_REG_BINNING_WEIGHTING, 1, 0x00); + if (ret) + return ret; + /* Set PLL registers for the external clock frequency */ ret =3D imx355_write_reg(imx355, IMX355_REG_EXTCLK_FREQ, 2, imx355->clk_params->extclk_freq); --=20 2.34.1 From nobody Mon Jul 27 11:00:15 2026 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 5D0CA43C7A3 for ; Wed, 8 Jul 2026 14:49:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522166; cv=none; b=uNfxWqkx+W0D71TKNRtJkDsrw9voo5I+B0ngjwQY4GvVMRkrj91Ddx1DxBBnVkbP7ZGP8LSVwoolQsbWmXE1f0COV+HgULcV7E9Hp7YjMbBsCDHWuWmgkBQrhORt2nBXfmCh5QbDdbZt3GUZxfm0z4oEU6lqEjeg0paD537QfaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522166; c=relaxed/simple; bh=HhVZI9HK2acxh/kCiAWqs9TnSmdjguE30P1zXNPnXi8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=g8a/EKlFOzrOCkBH3WM60fGPUrI84mp/wz/c5cmdpzKzZdik3l+dcwZ+oCbxgFXcDl3Oi8uTa0qOjtcvBi8fEwt1BM621eiqIjodor105lm42ZkcntI7SSMjJgPggCLZowHsW9GWSO49GYR4Y35JKxkS5hAPcaJmUNYF+lX9I5w= 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=QeexdPjJ; arc=none smtp.client-ip=209.85.128.48 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="QeexdPjJ" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-493ce08a75bso3246625e9.1 for ; Wed, 08 Jul 2026 07:49:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522156; x=1784126956; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=VpAz3t9DkUynz5Ilo0pkqB1DUV2Whn3ZOP7/Xd5aH4E=; b=QeexdPjJfKtJDaWvPEKOV7SY28EWuf9rSud+GD0CB9Dj+6B40/huKdNLN2S8TtHMA7 pOeoIXKfL6M0xPAEn7JV7vVYfxxeyIB9oA0KbIeMxOwZQ/NKB94u4Gz6FLwkX24pGkRV 7PPeVnP10Ujk09Wi3ls0sfFyWZvxFk1WPOuQAVmkKfu4OOFhthvG1mDm3GGCntm5uzZE b8tD+76gMQs9bo7iYWw3e6lDqDM68nqAiBQ6Fbh7q2PWFdldCN3T/UCyHFwwsXwHJwVD OwZl+XqbmEl4tVX9QzSahsuXTX2CA0/fChjKkJvrNi1xSzmdm1DdFfOs3CmlM0JSWCHZ PZ/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522156; x=1784126956; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=VpAz3t9DkUynz5Ilo0pkqB1DUV2Whn3ZOP7/Xd5aH4E=; b=ENVJVDdlnDcy9DJalQ9ntbWtc0tjOMlxaPsUCBp3vJUYC+JUCtaGn2xN5DSDLloIld 5/g/CdglITRToBbcBrCu4Zkg1htbOjKW63fpdsBziKYITkV21S6lr4zzxOwodkDAj+ic +X6/RLskpGtABBluAjDom6S1pZwPOS6/tezcUk9BLYrh16MC7nU+z8RxLAThgFDWbZ+h GEvBj/ikZH4pFZlhmnzJOeGo6sbPcR08mL3J3MBDnfN0BImbyrzv6LzWxI/6vQu3bztV pTmgthnvmam3QbBcTGzOoeULGTNFgHXqXtfSKhu6dHa1qI3cCRr3PB0o/IoeC0e4Wff6 FfZg== X-Forwarded-Encrypted: i=1; AHgh+RqFnMDS3EExwZcuxligRYpVHQFbAEaHopXnqsXlQgxi/CRfToN6D7A8XfNuur5h7kV4aKQN+9p6o1luyPQ=@vger.kernel.org X-Gm-Message-State: AOJu0Ywy8qTL3ueiQpWG956OiyNV0OMHgBOyUXpsTEP3KcweYdVnaAA3 SKzconsOYA4CVVuJOWeYsomK/c209a1ria0ZTmomOze2oiho4bH1GWQAneLb4l3AAVg= X-Gm-Gg: AfdE7cmXYR2yy6QJv8OdjhiKAXasbLAU8HG0SvbEy01M3Ig1PiQMyHEusW1j8xVyJxe XImFd5eaScn/GhJPdXgKjk7/0re09uFFEd7As3xptgX+NSkZNOMLUKi3sVmyNWX1COtWDBgEgpO 2UNQtrHW4IbEQerwvYuGpJn+OGVtz64cF0IXH+BHosdm+CfjlKcS18PLVSZcrhpcAGCG3CyvHWw DJUoWcGocF1lchsA5NZqp512QsVewRJ/vaxlMmtrJ1f7sBmqRuesxwu3Xd+I3XVbLNVQuWuOnSb DHkYP9DiU1kX9nZFeDXBfBYYQSMc6g2oVb90AybyVLI324e1XuHO1MW258P6kHKbXtm+1tYepEw 2HCLnAT9ZaX7pkXJQn8kKbInF3o9hbyJsEwonT/eH71KV1WT5xEkWlQmdDqWITYLRzHAS8nQb9G 9TM7sXxUtul9JIiW9mrsLcIXfC6fVTbZ3C0DTUEym+wtIfibjWHUP30fPzo8VfQYWH X-Received: by 2002:a05:600c:8b62:b0:493:adcb:d368 with SMTP id 5b1f17b1804b1-493e6843f10mr32091395e9.9.1783522156025; Wed, 08 Jul 2026 07:49:16 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:15 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:44 +0100 Subject: [PATCH v3 08/20] media: imx355: Remove link_freq_index from each mode as ununsed 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: <20260708-media-imx355-v3-8-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 The link_freq_index value in imx355_mode is unused, so remove it. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/imx355.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index 1010c32fe969..2880e03b3f08 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -81,7 +81,6 @@ =20 /* default link frequency and external clock */ #define IMX355_LINK_FREQ_DEFAULT 360000000LL -#define IMX355_LINK_FREQ_INDEX 0 =20 /* number of data lanes */ #define IMX355_DATA_LANES 4 @@ -111,9 +110,6 @@ struct imx355_mode { /* H-timing */ u32 llp; =20 - /* index of link frequency */ - u32 link_freq_index; - /* Default register values */ struct imx355_reg_list reg_list; }; @@ -366,7 +362,6 @@ static const struct imx355_mode supported_modes[] =3D { .fll_def =3D 2615, .fll_min =3D 2615, .llp =3D 3672, - .link_freq_index =3D IMX355_LINK_FREQ_INDEX, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_3280x2464_regs), .regs =3D mode_3280x2464_regs, @@ -384,7 +379,6 @@ static const struct imx355_mode supported_modes[] =3D { .fll_def =3D 2615, .fll_min =3D 2615, .llp =3D 3672, - .link_freq_index =3D IMX355_LINK_FREQ_INDEX, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_3268x2448_regs), .regs =3D mode_3268x2448_regs, @@ -402,7 +396,6 @@ static const struct imx355_mode supported_modes[] =3D { .fll_def =3D 2615, .fll_min =3D 2615, .llp =3D 3672, - .link_freq_index =3D IMX355_LINK_FREQ_INDEX, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_3264x2448_regs), .regs =3D mode_3264x2448_regs, @@ -420,7 +413,6 @@ static const struct imx355_mode supported_modes[] =3D { .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 3672, - .link_freq_index =3D IMX355_LINK_FREQ_INDEX, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_1940x1096_regs), .regs =3D mode_1940x1096_regs, @@ -438,7 +430,6 @@ static const struct imx355_mode supported_modes[] =3D { .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 3672, - .link_freq_index =3D IMX355_LINK_FREQ_INDEX, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_1936x1096_regs), .regs =3D mode_1936x1096_regs, @@ -456,7 +447,6 @@ static const struct imx355_mode supported_modes[] =3D { .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 3672, - .link_freq_index =3D IMX355_LINK_FREQ_INDEX, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_1924x1080_regs), .regs =3D mode_1924x1080_regs, @@ -474,7 +464,6 @@ static const struct imx355_mode supported_modes[] =3D { .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 3672, - .link_freq_index =3D IMX355_LINK_FREQ_INDEX, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_1920x1080_regs), .regs =3D mode_1920x1080_regs, @@ -492,7 +481,6 @@ static const struct imx355_mode supported_modes[] =3D { .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 1836, - .link_freq_index =3D IMX355_LINK_FREQ_INDEX, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_1640x1232_regs), .regs =3D mode_1640x1232_regs, @@ -510,7 +498,6 @@ static const struct imx355_mode supported_modes[] =3D { .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 1836, - .link_freq_index =3D IMX355_LINK_FREQ_INDEX, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_1640x922_regs), .regs =3D mode_1640x922_regs, @@ -528,7 +515,6 @@ static const struct imx355_mode supported_modes[] =3D { .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 1836, - .link_freq_index =3D IMX355_LINK_FREQ_INDEX, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_1300x736_regs), .regs =3D mode_1300x736_regs, @@ -546,7 +532,6 @@ static const struct imx355_mode supported_modes[] =3D { .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 1836, - .link_freq_index =3D IMX355_LINK_FREQ_INDEX, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_1296x736_regs), .regs =3D mode_1296x736_regs, @@ -564,7 +549,6 @@ static const struct imx355_mode supported_modes[] =3D { .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 1836, - .link_freq_index =3D IMX355_LINK_FREQ_INDEX, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_1284x720_regs), .regs =3D mode_1284x720_regs, @@ -582,7 +566,6 @@ static const struct imx355_mode supported_modes[] =3D { .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 1836, - .link_freq_index =3D IMX355_LINK_FREQ_INDEX, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_1280x720_regs), .regs =3D mode_1280x720_regs, @@ -600,7 +583,6 @@ static const struct imx355_mode supported_modes[] =3D { .fll_def =3D 652, .fll_min =3D 652, .llp =3D 3672, - .link_freq_index =3D IMX355_LINK_FREQ_INDEX, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_820x616_regs), .regs =3D mode_820x616_regs, --=20 2.34.1 From nobody Mon Jul 27 11:00:15 2026 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 0C4AD3DD521 for ; Wed, 8 Jul 2026 14:49:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522164; cv=none; b=ZIbPjTd9s1XWVyOm3FNuCl2/5sr2IEWZaFdQY53eEwyXE9+xLNFEW5jdUzYWbHy68ddJlcmXPMp9+z9IbxSyG3ddsdovRNA9a2/vr3NaIO34D2p7BcVpEf6tfMPJImINhsg5Rwz7wf0jgaz1LP3E3C40T4OhoBJSxBra7xVl+r0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522164; c=relaxed/simple; bh=Y13P6d/hP9MONM9g2M3JRHmmeNpDAlPRWKBNqbY3BGY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iws+hvUDg5lMKiLyfpaZV8ecT4TfjENi4kncm9e2MEgzgYmhGBqmmyYWp7yx/aknEXNGHEE6WWNYxWfaSFfdrZqfuMletnz0yjR8iNwQ1Ei1HaZ5UlmLnbucGcuXTVagyvpC8IsxVIbWQLM3qyY+Ka4YbQ9ursj/kl+E8atQDCk= 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=HUCfkimA; arc=none smtp.client-ip=209.85.128.46 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="HUCfkimA" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-493b786d6c0so4379235e9.2 for ; Wed, 08 Jul 2026 07:49:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522157; x=1784126957; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=fBwAFnI0CLH29JbBAy6QPj6qdoZnqHm2ZK4wHLoQ3Bo=; b=HUCfkimA1v6FCYtk8yegJ1OmPmjcu8KtW0p2rWAW4E4uAgKYwEtLQq2KRMeR3hOu6w UH5hNbGD7oFQ8SThT4kgvRCKaz2Bri9ecB48au0OmF3tZtjM7wubirdVysGeQSVhFUCr qFdpvaQ9adc7STqVjSFTaz37yXWglTr79zdl6RDa8ppbb/rfIIRPPAEAmgVzrVDNA3ry 3jVsJZqvAcgPTpfxcwG4mfYktKfBTZG4U1DM6W+Duj0TI5FM56YXO0/Bju0XluU0BZ+w clsNK+2McN0Y35fLQkVOl7R0FbMansg0NFCeI8LJPE+r12BCBtyT94ve7qMvB+h9RAnf j68w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522157; x=1784126957; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=fBwAFnI0CLH29JbBAy6QPj6qdoZnqHm2ZK4wHLoQ3Bo=; b=NDsY30MxKL8ljbtqtX4EaAD/Jk3QN3vjjXG6goxyip0H6gmBi+mzZr/cfWHr/irdtM w0xGL/09tCV/RycBhpXF+CJk8gPjqgYiUlmOkR0mEAA+DHlsW7k/04y2YLVEgUeo464P 3AtqaVo0NaD1wnUQjGXiaXQ4jkP/B/Ra3j/ZhxRTgzROiqqvQ7oLk8NQUWjKUtMfxiR5 +4YGOLncrdFHazqtjdyJuyEGqc0r/3LXvDhvnNyMca/C0mWFbPsLirknTozruiMrkuZz S8rSBFSkGqmri/3A8rz/eZ5A0uTXvlM6XgIGxtPJ3P2l3AHvrr5cjZEEJJfJuc3vUC4p G5Fw== X-Forwarded-Encrypted: i=1; AHgh+RoBu6QPG/rJufkV640KsfsiWP2Sm6+ZZRs9D6WIKg45PM9qUpIl0EY74zdDxfUHwZYAztbnFNkCdnzxc6c=@vger.kernel.org X-Gm-Message-State: AOJu0YxaGSaobBD1sK5EOhiFTlh6Ow69ZUJo0zR6SUX8Px6wtXI1TTPK fGuNV9mEo+EcHHBqFIMNdodG5IFVx8ubCtVFnIfGGjSwyYQ2tDLiebhAi+irh1zMLiA= X-Gm-Gg: AfdE7clfhBzvtgHnxBjq7SP11hEA7JP12/YRS9IUgv2M3IFYB7BwesbSNLO2/VSpIup IO/NtTeUsglwkQhlSboF6Jqva62+GEhKfSFIIl8T6Bc0JJtafzAYUDe44/JnBiklNoc5MAgb4ql PuE3jvipEzz0L3Mc3Kub6hqqJroS9/kxe8fgb02fK5fVjV8Fk5li3TPrNqEjUMYNbCwouEKZj7z FZ6vUVlkY9HOQue7ysXydoPuw2ohutj2xfXUHSp1/pLXCojcGXlcUiYxT+QrQ16sMyUw5SxHEXS WgQeRcuc6ajoVACWWKXeAI3jwRcIlPZxExmpIZKBRkPxAiukVfGO9fHKxR4A2AMfNJHp5uJjhDO PWwWgD00ikX1DXCYMPBZyC1IL0kUjcCB8h5urX4kJ10EjoG7ddfjCwp7uKwc6Y7lUJnSFUzT36K 5Z7WFnzs6ZZPMMN4Gflxcjusq+gDQBytyozPpHu09GP8t3p2J2uRXfhpzcXQ6K7b9h X-Received: by 2002:a05:600c:6085:b0:492:454c:347c with SMTP id 5b1f17b1804b1-493e6859969mr26493025e9.7.1783522156758; Wed, 08 Jul 2026 07:49:16 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:16 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:45 +0100 Subject: [PATCH v3 09/20] media: imx355: pixel_rate never changes, so don't recompute 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: <20260708-media-imx355-v3-9-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 The pixel rate is always the same, so there is no need to try and recompute it in imx355_set_pad_format, and then no need to have the pointer to it stored. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/imx355.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index 2880e03b3f08..2a97e076bff7 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -151,7 +151,6 @@ struct imx355 { struct v4l2_ctrl_handler ctrl_handler; /* V4L2 Controls */ struct v4l2_ctrl *link_freq; - struct v4l2_ctrl *pixel_rate; struct v4l2_ctrl *vblank; struct v4l2_ctrl *hblank; struct v4l2_ctrl *exposure; @@ -867,7 +866,6 @@ imx355_set_pad_format(struct v4l2_subdev *sd, s32 vblank_def; s32 vblank_min; s64 h_blank; - u64 pixel_rate; u32 height; =20 mutex_lock(&imx355->mutex); @@ -888,9 +886,6 @@ imx355_set_pad_format(struct v4l2_subdev *sd, *framefmt =3D fmt->format; } else { imx355->cur_mode =3D mode; - pixel_rate =3D IMX355_LINK_FREQ_DEFAULT * 2 * 4; - do_div(pixel_rate, 10); - __v4l2_ctrl_s_ctrl_int64(imx355->pixel_rate, pixel_rate); /* Update limits and set FPS to default */ height =3D imx355->cur_mode->height; vblank_def =3D imx355->cur_mode->fll_def - height; @@ -1180,9 +1175,8 @@ static int imx355_init_controls(struct imx355 *imx355) pixel_rate =3D IMX355_LINK_FREQ_DEFAULT * 2 * 4; do_div(pixel_rate, 10); /* By default, PIXEL_RATE is read only */ - imx355->pixel_rate =3D v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops, - V4L2_CID_PIXEL_RATE, pixel_rate, - pixel_rate, 1, pixel_rate); + v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops, V4L2_CID_PIXEL_RATE, + pixel_rate, pixel_rate, 1, pixel_rate); =20 /* Initialize vblank/hblank/exposure parameters based on current mode */ mode =3D imx355->cur_mode; --=20 2.34.1 From nobody Mon Jul 27 11:00:15 2026 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 1BB6747D938 for ; Wed, 8 Jul 2026 14:49:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522169; cv=none; b=ByqkWkbXjhK0/s6O4Z+/a/Lzc5CK1PY7orwnPpiflEsQzHJX8qGQFbiKYr+qIxw5lzDm1Coca5TXpMeOIFyXWrYLKTa57TdMpGXwIFGJXamwnQ44n+3x+BewIxihpboY7tUXxF1IL/lHCct8ZBoji4xyRkm3NDJwRsVQs5SgMfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522169; c=relaxed/simple; bh=WmGz4nPgmAYFKTk0UHv3cgym/1CZLfveDLzGzzdpKXs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nwsS6wVMHYTLYBoIgJ9VkKIG00IDpGaKJEMODOvy96BjYH+xrAwZfYPRL37a9sDTvF/M3sUxGYWzMYJqdZxp/o3Wq8CyeQGw1VIoYc5JfLTWGR9CtE5CyiRk3CPHqqAnQOdym+t8gY37+e5i+hYcNr3WOFtDT7gfsuSz5tilHhU= 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=cAhn5afI; arc=none smtp.client-ip=209.85.128.42 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="cAhn5afI" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-493e8d4f4dcso2482875e9.0 for ; Wed, 08 Jul 2026 07:49:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522157; x=1784126957; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=poih6FWktQDQKgkCTECxgZzsFqMFD3r/FGOUzaesYvE=; b=cAhn5afI10yGdIL7k8Xblf5IvVuzKqghzNCIAiVKorHu+MCMFbxvAFjqhIWYKmX/9j GK+tEUQfxzYasmQLJ2fSZ4rjjTV8ukdC3qUiizfyB65oA7aQTBvC+CztyROKkBlEVrvq QNIAEAQqdPJZ24ox/nBJgusXu7pWwqnSv1CfLQ47nWSYKE9J7D05KmApzHTpYy8xyjkd zLTa6vXRB+wb5IiKxuH6+7otBPm04RPa4QhtV+CmXPvVlDQDNiajxgPespI0oR3i0sPR Qnc9atiaRS5GyjKQAIVWs+vMQ8Z3+IvNuTfb/Z9cYRjMrur5j0CBmmRhgplYCpIxSzqZ OgtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522157; x=1784126957; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=poih6FWktQDQKgkCTECxgZzsFqMFD3r/FGOUzaesYvE=; b=M0GdF/JVy9v+Fl+PlkUSdhGUbrqwN9lOIc/dqnY53tnORZGMMC2anw9ZIX4WgftqZn EgQSKoDT+/MPlN0qIWdaScBiqHMBBcE3Tq2BEmanKhqU3xYz3ZbSzFhlPXB6J9xaA9FC cgr0RoEEdPc4WC3jfe+JNjeKTVxpZ0QLpEUf8h1v8EcIyy445uavzflQX9PY28HDGx9C +mNXDSmXRvmoBWZZ1dPRXlaZugQ199HYB6KWqsfKidZx2DB158eB+sYxcf38WD47zqBR Bp5fKYLfvc1EaOkOdu8wgqxQZqgsrklV+3jW3Gmhfgic3AcplOE8NrzAmu/zFj2wJkGG 0oug== X-Forwarded-Encrypted: i=1; AHgh+Rr9sn2NAxOG92imxnqtqmLPpyPZAgD7Sbs81Bqnjw2wvdmlONnrdD7Aq7IwUmvacOr1d4CMw+LqTWlE4WI=@vger.kernel.org X-Gm-Message-State: AOJu0YynHQcDkQlcphjDLN7ziIH+DCHLPrzMK0SZePCqQ1i5G0f94OCx weOiDSg70DA1HfDi+J/SV4nfVonbElHfpJNq3W7dZggPOUD7NMQBto9HitxD5JPUle0= X-Gm-Gg: AfdE7cnUjoJMHCVDoWRf0nmf3AxKKDC3SVGmAcrWNIiIDwR0jVcD5c4NdhvU6NnnQoU +w4wqE3CjALYkGimfA2AlazFk77tOPl+nxXMfYIGZ3xvkFel9c6aG0/djonHp7MwzcipWNjBi/O uIoxGmQxy4bMIUkxg1AJ8uNMjL3VsqB1PYqkLvxyTpkQdzkKgSLiw+4ZXdpKi0Ylyw/cqRu1Nlp bGkhjwLvfZtsEte7/tILvyhFnODaprT1/2Hj7EsOjSI1tzf9fMU8wscWluBpNwSzrwrFL/Uoa2+ u9F4hNFPjqnhZe80sHGPPDdEzcifNvh8RYSwFkz76g/kPkSTwOd+/1DTWF8lys3FfTqCNZ5tJ2Y JggfqWUCXvjprM4AJE8yBz87e19qxtolYAQiz5d+/uUqHhSE9a0eWD2LP/0hfruKnOGlS6F2CIl yFMgd9U2HX3LXS7CVE5ZsGEefGqUCjYT0potCrphrIEjX+wrUUK3UYG/a4DhzL4bJj X-Received: by 2002:a05:600c:4796:b0:493:e97b:3b9c with SMTP id 5b1f17b1804b1-493e97b3bcfmr1416705e9.29.1783522157466; Wed, 08 Jul 2026 07:49:17 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:17 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:46 +0100 Subject: [PATCH v3 10/20] media: imx355: Remove redundant fll_min, and implement fixed offset 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: <20260708-media-imx355-v3-10-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 fll_min (Frame Length Lines) is set to the same value as fll_def for all modes, which makes it redundant. The actual value is also erroneous as the sensor works in all the defined modes with FLL set at the mode height + 20 lines, so set the vblank control minimum to 20 rather than varying it. This also improves the maximum frame rate achievable. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/imx355.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index 2a97e076bff7..c6f27cf269b4 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -32,6 +32,7 @@ /* V_TIMING internal */ #define IMX355_REG_FLL 0x0340 #define IMX355_FLL_MAX 0xffff +#define IMX355_VBLANK_MIN 20 =20 #define IMX355_REG_LLP 0x0342 #define IMX355_LLP_MAX 0xffff @@ -105,7 +106,6 @@ struct imx355_mode { =20 /* V-timing */ u32 fll_def; - u32 fll_min; =20 /* H-timing */ u32 llp; @@ -359,7 +359,6 @@ static const struct imx355_mode supported_modes[] =3D { .top =3D 0, }, .fll_def =3D 2615, - .fll_min =3D 2615, .llp =3D 3672, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_3280x2464_regs), @@ -376,7 +375,6 @@ static const struct imx355_mode supported_modes[] =3D { .top =3D 8, }, .fll_def =3D 2615, - .fll_min =3D 2615, .llp =3D 3672, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_3268x2448_regs), @@ -393,7 +391,6 @@ static const struct imx355_mode supported_modes[] =3D { .top =3D 8, }, .fll_def =3D 2615, - .fll_min =3D 2615, .llp =3D 3672, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_3264x2448_regs), @@ -410,7 +407,6 @@ static const struct imx355_mode supported_modes[] =3D { .top =3D 684, }, .fll_def =3D 1306, - .fll_min =3D 1306, .llp =3D 3672, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_1940x1096_regs), @@ -427,7 +423,6 @@ static const struct imx355_mode supported_modes[] =3D { .top =3D 684, }, .fll_def =3D 1306, - .fll_min =3D 1306, .llp =3D 3672, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_1936x1096_regs), @@ -444,7 +439,6 @@ static const struct imx355_mode supported_modes[] =3D { .top =3D 692, }, .fll_def =3D 1306, - .fll_min =3D 1306, .llp =3D 3672, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_1924x1080_regs), @@ -461,7 +455,6 @@ static const struct imx355_mode supported_modes[] =3D { .top =3D 692, }, .fll_def =3D 1306, - .fll_min =3D 1306, .llp =3D 3672, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_1920x1080_regs), @@ -478,7 +471,6 @@ static const struct imx355_mode supported_modes[] =3D { .top =3D 0, }, .fll_def =3D 1306, - .fll_min =3D 1306, .llp =3D 1836, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_1640x1232_regs), @@ -495,7 +487,6 @@ static const struct imx355_mode supported_modes[] =3D { .top =3D 304, }, .fll_def =3D 1306, - .fll_min =3D 1306, .llp =3D 1836, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_1640x922_regs), @@ -512,7 +503,6 @@ static const struct imx355_mode supported_modes[] =3D { .top =3D 496, }, .fll_def =3D 1306, - .fll_min =3D 1306, .llp =3D 1836, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_1300x736_regs), @@ -529,7 +519,6 @@ static const struct imx355_mode supported_modes[] =3D { .top =3D 496, }, .fll_def =3D 1306, - .fll_min =3D 1306, .llp =3D 1836, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_1296x736_regs), @@ -546,7 +535,6 @@ static const struct imx355_mode supported_modes[] =3D { .top =3D 512, }, .fll_def =3D 1306, - .fll_min =3D 1306, .llp =3D 1836, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_1284x720_regs), @@ -563,7 +551,6 @@ static const struct imx355_mode supported_modes[] =3D { .top =3D 512, }, .fll_def =3D 1306, - .fll_min =3D 1306, .llp =3D 1836, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_1280x720_regs), @@ -580,7 +567,6 @@ static const struct imx355_mode supported_modes[] =3D { .top =3D 0, }, .fll_def =3D 652, - .fll_min =3D 652, .llp =3D 3672, .reg_list =3D { .num_of_regs =3D ARRAY_SIZE(mode_820x616_regs), @@ -864,7 +850,6 @@ imx355_set_pad_format(struct v4l2_subdev *sd, const struct imx355_mode *mode; struct v4l2_mbus_framefmt *framefmt; s32 vblank_def; - s32 vblank_min; s64 h_blank; u32 height; =20 @@ -889,10 +874,9 @@ imx355_set_pad_format(struct v4l2_subdev *sd, /* Update limits and set FPS to default */ height =3D imx355->cur_mode->height; vblank_def =3D imx355->cur_mode->fll_def - height; - vblank_min =3D imx355->cur_mode->fll_min - height; height =3D IMX355_FLL_MAX - height; - __v4l2_ctrl_modify_range(imx355->vblank, vblank_min, height, 1, - vblank_def); + __v4l2_ctrl_modify_range(imx355->vblank, IMX355_VBLANK_MIN, + height, 1, vblank_def); __v4l2_ctrl_s_ctrl(imx355->vblank, vblank_def); h_blank =3D mode->llp - imx355->cur_mode->width; /* @@ -1151,7 +1135,6 @@ static int imx355_init_controls(struct imx355 *imx355) struct v4l2_ctrl_handler *ctrl_hdlr; s64 exposure_max; s64 vblank_def; - s64 vblank_min; s64 hblank; u64 pixel_rate; const struct imx355_mode *mode; @@ -1181,9 +1164,8 @@ static int imx355_init_controls(struct imx355 *imx355) /* Initialize vblank/hblank/exposure parameters based on current mode */ mode =3D imx355->cur_mode; vblank_def =3D mode->fll_def - mode->height; - vblank_min =3D mode->fll_min - mode->height; imx355->vblank =3D v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops, - V4L2_CID_VBLANK, vblank_min, + V4L2_CID_VBLANK, IMX355_VBLANK_MIN, IMX355_FLL_MAX - mode->height, 1, vblank_def); =20 --=20 2.34.1 From nobody Mon Jul 27 11:00:15 2026 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 CF858478E51 for ; Wed, 8 Jul 2026 14:49:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522167; cv=none; b=Ezd0wa81TlsYsD3iMa4mBZK0yRZ3L/pZNcM1KUTr0OvGcYUtP8eAWirKuL4GbPPSOC4qfe6DY/DqaDOLgrHD5Ss9WyfDO1nGnp5OcpbjTn6m5/ewMekThr8ILQ45u0qyIf6LhpovqFAjq7Ed5cLPwvJNmdRiqdBE4+mDYrrxX7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522167; c=relaxed/simple; bh=UElEKgx5eHfzk8J2KAJPSWZW6uMMfWtwZrksO9N6Tgw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mZMhH80JdeGfnT3cyEZxto9yr6StxzahoXiJ9UFYUUUA7itkeKa5xR6wdMsmXjTJ6HtxPsXN4CMHPCXsFx6TUt2+Phx9V4dqDspFyZ2LploZ9QUKqtAldKTxvFVWbiYqrd5UTEXysl53tddb45bew4SyL/jtc1fl+BB1b7BSWVA= 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=g+jz2P4B; arc=none smtp.client-ip=209.85.128.45 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="g+jz2P4B" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-493c59f740cso5679455e9.3 for ; Wed, 08 Jul 2026 07:49:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522158; x=1784126958; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=8MdvxgOZXywHJMIvMKFBTdmdPZacbqOOXj1fqUFx+10=; b=g+jz2P4B5ayBWbaYFt/0zbbaswROo/uLmAM48UQ4DTTRh70I0HHE9MhYOplG1iPhGw AXTDLqOEddI0iRn+Nesl3RGJIO33sFZjW80/mhe8Uq5LA+qlcYx8MDxDbyYdrLCcyJTG v9SrjaOsujRmXuYsb6lN4gNZYsURrK77i3+fi3/byAqhwnnYWqgRO9D2vnyy+XI4pr2i +DaaqTC9ui1xlbcLv34X2680FJU9LtDGHRAv8DNEp9/AqHLFru2cDtvB41FyBXYbu8Fw /NtpsOXeGSgAFc3yLGFqabvRUeRw1CU9nye8cOpg5ugWxoXorH0Q7YK9bPH0omu2IiZq I0vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522158; x=1784126958; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=8MdvxgOZXywHJMIvMKFBTdmdPZacbqOOXj1fqUFx+10=; b=jxE+tshpXNfg7ISjn6UgCf1WD+69vUquPQBf5lSqA836ok1GEmZFbNyILaUKc6RDjV uWmzONnK8DkhYx68T94rEzl1WIFSBnO7cad4VV+TvEhOTC699CKJmRdDaamizF0Kp6uj LHb+Hqg7DQOufSE8UWb1J2Vn2wbOoiRQkIO6G/P7GIcnqGlRG7YxHTXr7BgQ+4nfQQNj 5RDjyJiAhBp1/lUPkf/LwmAa0SM0yAguSVHHgNuBDkq5dFWUek4fgxT3ojKLzgPd1RbG ykOQvVdglGL1NvuqVvOJ85DS3WC9oQmcpS6TU9xgyjH7K0Xsz3NAT1SPi8dcRS/AlaEz S82Q== X-Forwarded-Encrypted: i=1; AHgh+Rr+46hPNduUKerMXbgI9gWQxIQQF3VYM/F0yLvVSk0TlGiHiLbD/rzTNLMB1oYVYmzbR0lf2X5s5VwE8mQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxOOZSC2DusXETbZNFfikF7v62U0HxVBjIpEgnan2u0kxwmOQqA /+tfcg2wSuwzIJ2IiFAvIrTNVi9+jrAhY2iMFGITupASfMedlj1h79PCfRA+Lu5QiZM= X-Gm-Gg: AfdE7ckDZYwIKzzSE0KL2dbyQfgd7VYJrBlQ28jEv7quRyzgwKWTL3opapbjRiciCd+ 5xnG1nEuvn4aX9xNo5MbKnjnfnwvnR4VotwAx457rVY+NMfJvVMRUWX3JGBH/KABUVNz7BJhVZG CYKQoEw8pEeWG1J18l5XjoUPASW6qzrWQD6oJ88DubTVcgiZE1LoIwmWL+AzY3M0Ylkq6KLDtiU 5cpkdmSnCVNE7In6nYPBhSVKu05za3UyKI6EFhjLn0vqLcAsGuaWnj42ZvDos706+FBvqD6tG1T Ay1rpBdIMiJgRXUxf3H1OYkp+UwPxkQQ/C7UtXJPChOhpLcxa8KENSbCcqSTtsX9W2oBOzfGAM5 V8uk6/Vr3fO60ru86CEoZNkMiIUmQi+aYB+phWsYBP50KfRj96qsv2CAyUqrbjsBWWXHHpqqmv7 IY+R1fjpJ+KF9FADVwKUPjhaIcIPtEomJCiTwYahh9kRsh4mR1LdMB7YiMpyVaVo8a22fm7xhMs VA= X-Received: by 2002:a05:600c:3b10:b0:493:a7fd:15d6 with SMTP id 5b1f17b1804b1-493e689b2d8mr34274405e9.9.1783522158200; Wed, 08 Jul 2026 07:49:18 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:17 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:47 +0100 Subject: [PATCH v3 11/20] media: imx355: Add support for get_selection 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: <20260708-media-imx355-v3-11-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 Provide all the cropping information via get_selection. Signed-off-by: Dave Stevenson --- drivers/media/i2c/imx355.c | 59 ++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 59 insertions(+) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index c6f27cf269b4..ee1f41a66a0b 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -86,6 +86,11 @@ /* number of data lanes */ #define IMX355_DATA_LANES 4 =20 +#define IMX355_PIXEL_ARRAY_TOP 0 +#define IMX355_PIXEL_ARRAY_LEFT 0 +#define IMX355_PIXEL_ARRAY_WIDTH 3280 +#define IMX355_PIXEL_ARRAY_HEIGHT 2464 + struct imx355_reg { u16 address; u8 val; @@ -677,6 +682,7 @@ static int imx355_open(struct v4l2_subdev *sd, struct v= 4l2_subdev_fh *fh) struct imx355 *imx355 =3D to_imx355(sd); struct v4l2_mbus_framefmt *try_fmt =3D v4l2_subdev_state_get_format(fh->state, 0); + struct v4l2_rect *crop =3D v4l2_subdev_state_get_crop(fh->state, 0); =20 mutex_lock(&imx355->mutex); =20 @@ -686,6 +692,8 @@ static int imx355_open(struct v4l2_subdev *sd, struct v= 4l2_subdev_fh *fh) try_fmt->code =3D imx355_get_format_code(imx355); try_fmt->field =3D V4L2_FIELD_NONE; =20 + *crop =3D imx355->cur_mode->crop; + mutex_unlock(&imx355->mutex); =20 return 0; @@ -869,6 +877,12 @@ imx355_set_pad_format(struct v4l2_subdev *sd, if (fmt->which =3D=3D V4L2_SUBDEV_FORMAT_TRY) { framefmt =3D v4l2_subdev_state_get_format(sd_state, fmt->pad); *framefmt =3D fmt->format; + + crop =3D v4l2_subdev_state_get_crop(sd_state, 0); + crop->width =3D mode->crop.width; + crop->height =3D mode->crop.height; + crop->left =3D mode->crop.left; + crop->top =3D mode->crop.top; } else { imx355->cur_mode =3D mode; /* Update limits and set FPS to default */ @@ -892,6 +906,50 @@ imx355_set_pad_format(struct v4l2_subdev *sd, return 0; } =20 +static void +__imx355_get_pad_crop(struct imx355 *imx355, + struct v4l2_subdev_state *sd_state, unsigned int pad, + enum v4l2_subdev_format_whence which, struct v4l2_rect *r) +{ + switch (which) { + case V4L2_SUBDEV_FORMAT_TRY: + *r =3D *v4l2_subdev_state_get_crop(sd_state, pad); + break; + case V4L2_SUBDEV_FORMAT_ACTIVE: + *r =3D imx355->cur_mode->crop; + break; + } +} + +static int imx355_get_selection(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_selection *sel) +{ + switch (sel->target) { + case V4L2_SEL_TGT_CROP: { + struct imx355 *imx355 =3D to_imx355(sd); + + mutex_lock(&imx355->mutex); + __imx355_get_pad_crop(imx355, sd_state, sel->pad, sel->which, + &sel->r); + mutex_unlock(&imx355->mutex); + + return 0; + } + case V4L2_SEL_TGT_CROP_DEFAULT: + case V4L2_SEL_TGT_CROP_BOUNDS: + case V4L2_SEL_TGT_NATIVE_SIZE: + sel->r.top =3D IMX355_PIXEL_ARRAY_TOP; + sel->r.left =3D IMX355_PIXEL_ARRAY_LEFT; + sel->r.width =3D IMX355_PIXEL_ARRAY_WIDTH; + sel->r.height =3D IMX355_PIXEL_ARRAY_HEIGHT; + + return 0; + } + + return -EINVAL; +} + /* Start streaming */ static int imx355_start_streaming(struct imx355 *imx355) { @@ -1066,6 +1124,7 @@ static const struct v4l2_subdev_pad_ops imx355_pad_op= s =3D { .get_fmt =3D imx355_get_pad_format, .set_fmt =3D imx355_set_pad_format, .enum_frame_size =3D imx355_enum_frame_size, + .get_selection =3D imx355_get_selection, }; =20 static const struct v4l2_subdev_ops imx355_subdev_ops =3D { --=20 2.34.1 From nobody Mon Jul 27 11:00:15 2026 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 04D7C44B67D for ; Wed, 8 Jul 2026 14:49:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522172; cv=none; b=AV9GnJn+z9/mmBu+mrpIx1B4yxrviGMY9yg1AQTF5eb+iCBrECzU+tioGyOaNOk097dBhNIzmtuqAWO8VKFlB9fkZuRuc0/ZBaIGWdwId8bb0Zun/6P0Hef7aSr2g2sxWBHZEIVfiSDer22b7TdctBw8Jugk3LxmTJiOox5tvuQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522172; c=relaxed/simple; bh=HkxE7QDh3kVaBT0axp9IR5qPsGPYXHxX+yr5prLaKjI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZxXebJpJ70P+MsbIzNyEKzNFvJ2zfsI2DqkQPMObEoSV64L0yfNLXeFOwcyfrM22YFpFjz97/45zrrdJ+wuRhiw42+odpBjkaT0X5sLKXbNpAsyEdIkx9mrH2nh3tXWiCAKICDf6yTR10wNT+2o4zGVSgEJAcHbdZHYftzVtZjY= 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=Hj37vLOj; arc=none smtp.client-ip=209.85.128.42 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="Hj37vLOj" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-493c55d5c7aso8041365e9.1 for ; Wed, 08 Jul 2026 07:49:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522159; x=1784126959; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=eznbuB8Cf+t+hvmFqCai3LuNPnGzE5omPSOsh6CmaE0=; b=Hj37vLOjeZ7jbyWdqakFad9/Qbf8T+venr92kA+UQriuHPKJ6nwnB5cyVPsFF5/jJm rgVZfDLD4LgZNhjxQt0QQ3ExSu4LLP5qeQpeGfexMat67kNkmnZwTo0Dwr2hSgoB7jjF /ijKCWBmG+ZITrkcGm79A2QDYozr8BXK3pGhm857XKQjJvou1z3ZUiPqhm/PG6R4Ykuj yE9Wz3NrHLwmV14ruAo5S6oPsZRy3GzgsD5oRuz7CHBQ53orAaLtyXoyNL0wxAI8RKIf WLXDzOEja/rQeIMps2DmYQcrhgDbDFGqHahbpczGH9mqcrLL//k21c6WDqPsSD2ni/rw wlRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522159; x=1784126959; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=eznbuB8Cf+t+hvmFqCai3LuNPnGzE5omPSOsh6CmaE0=; b=AGamMjD7yrdowwDZidylKvofp8A8YnGQhq1BxTo+QLPeqzR68OLNrZ5OmcrLdjthQS WeNZQk26ECzO+yZtWCyY0Wl9hIdZ9lLUM9ltEn8ndKtkt5v7s9qOFExN7jHUviXa0OVM u/16QAsHUqmy1qBDr8OJTJN8RXZ4W51x8GJP1UU5BQKia+aswnOWz8yXWAto00npPHse kgwfRCnLiu/zhbTIWpxPoiRoZDnbKO9JK3WNTnjvcbZYaDgfvZ1SM7w8sd40yin02BkO vMOKeYcFGY0aqlJMHXjoDokahqFRkEXE70wt8MZeJCMp0vznPeqRIwoMXLdPIesZl4mo eVeg== X-Forwarded-Encrypted: i=1; AHgh+RoJ/xv43VjsDU+6b1CKTKhTGCxtnCn8mHiuJCi5DmDSWpQjrclMVZzPi5E3nw93OHD9sX4j8q3bO+ra47g=@vger.kernel.org X-Gm-Message-State: AOJu0YzJCB2Ntqj4+T1Gn2ciWiLuDysK6dXkHCW5aCfKjEWwk3twRrgM T8f+ONnsXNDzYzxRu5f0spwYxVwzpIH9ynoC8WSbfzYMU9yzjbt+6gjDtiTkEaJnvKA= X-Gm-Gg: AfdE7cn8n2VdArKTawOAVImjzE+Rbgi9W6rcbeC0bIihwdkL0krjJp8+xjYq4IiwZGe R27ZjWpGoLbczTiTzjhKEYCqCJJ5muvYjye0qVd0w6CcHc1fRQLbnVc0FSBoIlisEN4IxFIjWiJ kPVGswlKdst3UKnvfrduS/BqcFzC6uYlpxgva70ByGic9MO7RqAItv4/8rs0bP+L7dPIUMA7CX2 m0xdXClSKDGjxZ5Dfs4vvlJ3CCw5ydQTeZiZFXLvxW5TIeyCLBCQ/258O17sisSKSVkd+A/bLPN cFwqlHA/KZCC3yT1tBgVCAKon0ogs0USmOkwf5aqdSFyhJCr/46HUageixmd3+KU5Uc0AizFVMw oOupHJ9cxB6dVCKXAdOnS4F1rHP+9HLnSO1R+/+rnC8UpM0SMbSnil+B1Xc4vcl85F5blS7h698 Y5B4aYth/MlJfPyNAht2xY/rvKdwvhN6t6k6UA2eScx/VZsiaOC9W9c6oelIYFKoLQXj3N7pFb3 O0= X-Received: by 2002:a05:600c:e558:10b0:493:e57e:7aa5 with SMTP id 5b1f17b1804b1-493e68c6e63mr19742845e9.22.1783522158971; Wed, 08 Jul 2026 07:49:18 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:18 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:48 +0100 Subject: [PATCH v3 12/20] media: imx355: Use pm_runtime autosuspend_delay 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: <20260708-media-imx355-v3-12-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 Avoid powering the sensor up and down unnecessarily by using pm_runtime's autosuspend_delay feature. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/imx355.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index ee1f41a66a0b..f01a1a5ae7c9 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -1073,7 +1073,7 @@ static int imx355_set_stream(struct v4l2_subdev *sd, = int enable) goto err_rpm_put; } else { imx355_stop_streaming(imx355); - pm_runtime_put(imx355->dev); + pm_runtime_put_autosuspend(imx355->dev); } =20 /* vflip and hflip cannot change during streaming */ @@ -1085,7 +1085,7 @@ static int imx355_set_stream(struct v4l2_subdev *sd, = int enable) return ret; =20 err_rpm_put: - pm_runtime_put(imx355->dev); + pm_runtime_put_autosuspend(imx355->dev); err_unlock: mutex_unlock(&imx355->mutex); =20 @@ -1436,6 +1436,8 @@ static int imx355_probe(struct i2c_client *client) pm_runtime_set_active(imx355->dev); pm_runtime_enable(imx355->dev); pm_runtime_idle(imx355->dev); + pm_runtime_set_autosuspend_delay(imx355->dev, 1000); + pm_runtime_use_autosuspend(imx355->dev); =20 ret =3D v4l2_async_register_subdev_sensor(&imx355->sd); if (ret < 0) @@ -1446,6 +1448,7 @@ static int imx355_probe(struct i2c_client *client) error_media_entity_runtime_pm: pm_runtime_disable(imx355->dev); pm_runtime_set_suspended(imx355->dev); + pm_runtime_dont_use_autosuspend(imx355->dev); media_entity_cleanup(&imx355->sd.entity); =20 error_handler_free: @@ -1476,6 +1479,8 @@ static void imx355_remove(struct i2c_client *client) pm_runtime_set_suspended(imx355->dev); } =20 + pm_runtime_dont_use_autosuspend(imx355->dev); + mutex_destroy(&imx355->mutex); } =20 --=20 2.34.1 From nobody Mon Jul 27 11:00:15 2026 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 3F6C647CC63 for ; Wed, 8 Jul 2026 14:49:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522174; cv=none; b=jk5LleWGha4SL8GTbzljooKaXdjNOe66Sa6u6Zts+e5/SrVOSGao83sV3PaTAK1Lk5+7m6s+7NDeGTocURnMChmKhV8PxTUxnG9LakIjNOku/tvUQH6+so7XHpxMHoZAfkD3Q7Z7s/Wvp/pyhZB5EX/bHqjfZg2/GG2jonebPYM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522174; c=relaxed/simple; bh=28LKc4okyVjAp2NpU/b+xG8M4qt9dRMD1ek7kk6XW1E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Rl0x1BNTiEPIISsQXHnKNOfEaG6mam7B62kW8dDTPpET+fDvzFLH15c9KVpII6SZrPh2pAb1TZTa9CvxJiXevNJ978HcZIe4ElND3ERl4v/iWm1FkHOjiDJ001CqwzC7fJt9VJfGOFY6YLVbq1ClywzBvRKFkAn/gzdhGRxKeK0= 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=JS0AJxco; arc=none smtp.client-ip=209.85.128.50 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="JS0AJxco" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-493ce08a75bso3247885e9.1 for ; Wed, 08 Jul 2026 07:49:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522160; x=1784126960; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=QkODmLlvTYuTUZ707QVkNqFHTIFUXMnKePpusRuIj2g=; b=JS0AJxcoc5C7siAoeDLvGwvO6erj9i+echmEarW9v1LwrZzrIu9/pKHfN7r0YJ0WmT uuK62/94jz4kgwlPRXlVr84MvDaVh/BlriATxPOChqDRltJjhjRR8DgSlS6R5YxltMNX /VZpR5wxWeq4Uxf0Ma203EaDi/ygc5wAyHvm/yVlpC7oNkFVluO57MNu1KfaFrSDw086 odVKmLVyoBbP72GzEnK/oxU4zLUWtA28zw9UlfhHvIFJQESVm6Q6X58zaX9+3uAyr5P9 sxMJj1hFUzLsT2GzfEUhVQveacMMGE+euAB0KYPrUmc1W//wj+iM443vt4DxQDOM/pxs adxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522160; x=1784126960; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=QkODmLlvTYuTUZ707QVkNqFHTIFUXMnKePpusRuIj2g=; b=szrawxIE005ZT9CVnYpt4DksGkEqgSSNaQIVwoMsVqhMHNSEMmRg6fsgBC5rqulFfZ u5yf8TwzgLka7S7yuLH+4cuDnI2v7xBSK3U8p3qlzzQEwMGT6BQFHBuk0ZEzWvjdf6fB dgY3Cl+tRwsb4S2J0Nt9nfC29QQupXMJB5gT6pdWQ763Zp3VQCmc5WSBirbvsLZ1v0gV JvWqMUq35W1jCl7D1hA3mzy7mMhgF0h4bL3qnPjUmQYy2qCjBd/kluqhsRWGaHUHZNcY QPfXFD4O9b0taTOp1RauaNmAkWHaWMtJaY7L+zCFHD3hxt0+rb7tCh36hoAlE4ErbIlj UPIg== X-Forwarded-Encrypted: i=1; AHgh+RpimgV+eKagw1pbhmqasuCDCxB8BkZLKt0M27JSFtCVRYZGxwSF+fHJQ7eOBqqEbHbadAl6mll/fOcXkRA=@vger.kernel.org X-Gm-Message-State: AOJu0Yy7CbWtg4j5ZHkZN90k/4rH4qDLQKi+xb3SkqpG2qTm6uLvz+Dg MkWDQcyGyQlST6djQfu9BbSa+Q9Or6avFiQMJI0qM30CqgggBWVG0DRYKtVASry2SwQ= X-Gm-Gg: AfdE7cl4w4S1WwdbEmq1V+XQskAb4tBJn6vaA/hTf6SqHbdJNA07Dqh7IFAp1CjBcDz QlGqHfZOrKwGRYu+CYtJ9wEQ7QnNnDluAtE3DRXJwdwZwx1ufHKXjeVipLDYu8naUhftr4uzlX2 Bg4KEocuClV1mPCFyoQ7w8BM2XoI5V8vYwT8iSkyl+8xbeh3w6Jd6lCOZhp3xw/bIMECjybSXTP 4DxvodUNsI7GnSahGMarFLUxkNkBZHTw5JnCnHa1RosOBCP9sa2DuCN1hx0hJ7tONQzmxyi3B9q 8pmrOp6OHxEm95zNisc+2fbzeejaiyJrB4Hks+4MmTLcPD0nBrVjw5Kz9ND4PTZIBajPWvG9SZL xPYdltutkbN69x727gyIT8R/K1jl3FtOhQKIKe2tTWnQ1qSVurBVORCmGf9DCixh5V3PEtcJ3KC U4/EMLgYRuEm0gxv38+RlDrKcfVKG4PNxApMpSL09FfTJvH3MQ8rkD2QS7PFt9fNja X-Received: by 2002:a05:600c:a55:b0:48a:5565:ec3d with SMTP id 5b1f17b1804b1-493e68635e5mr30092455e9.22.1783522159854; Wed, 08 Jul 2026 07:49:19 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:19 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:49 +0100 Subject: [PATCH v3 13/20] media: imx355: Convert to new CCI register access helpers 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: <20260708-media-imx355-v3-13-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 Use the new comon CCI register access helpers to replace the private register access helpers in the imx355 driver. Signed-off-by: Dave Stevenson --- drivers/media/i2c/Kconfig | 1 + drivers/media/i2c/imx355.c | 500 ++++++++++++++++++-----------------------= ---- 2 files changed, 196 insertions(+), 305 deletions(-) diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index 5d173e0ecf42..06461a70a2cd 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -259,6 +259,7 @@ config VIDEO_IMX335 =20 config VIDEO_IMX355 tristate "Sony IMX355 sensor support" + select V4L2_CCI_I2C help This is a Video4Linux2 sensor driver for the Sony IMX355 camera. diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index f01a1a5ae7c9..b27329143e48 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -9,76 +9,78 @@ #include #include #include +#include #include #include =20 +#include #include #include #include #include =20 -#define IMX355_REG_MODE_SELECT 0x0100 +#define IMX355_REG_MODE_SELECT CCI_REG8(0x0100) #define IMX355_MODE_STANDBY 0x00 #define IMX355_MODE_STREAMING 0x01 =20 /* Chip ID */ -#define IMX355_REG_CHIP_ID 0x0016 +#define IMX355_REG_CHIP_ID CCI_REG16(0x0016) #define IMX355_CHIP_ID 0x0355 =20 /* PLL registers that depend on the external clock frequency */ -#define IMX355_REG_EXTCLK_FREQ 0x0136 -#define IMX355_REG_PLL_OP_MUL 0x030e +#define IMX355_REG_EXTCLK_FREQ CCI_REG16(0x0136) +#define IMX355_REG_PLL_OP_MUL CCI_REG16(0x030e) =20 /* V_TIMING internal */ -#define IMX355_REG_FLL 0x0340 +#define IMX355_REG_FLL CCI_REG16(0x0340) #define IMX355_FLL_MAX 0xffff #define IMX355_VBLANK_MIN 20 =20 -#define IMX355_REG_LLP 0x0342 +#define IMX355_REG_LLP CCI_REG16(0x0342) #define IMX355_LLP_MAX 0xffff =20 -#define IMX355_REG_X_ADD_START 0x0344 -#define IMX355_REG_Y_ADD_START 0x0346 -#define IMX355_REG_X_ADD_END 0x0348 -#define IMX355_REG_Y_ADD_END 0x034a -#define IMX355_REG_X_OUT_SIZE 0x034c -#define IMX355_REG_Y_OUT_SIZE 0x034e +#define IMX355_REG_X_ADD_START CCI_REG16(0x0344) +#define IMX355_REG_Y_ADD_START CCI_REG16(0x0346) +#define IMX355_REG_X_ADD_END CCI_REG16(0x0348) +#define IMX355_REG_Y_ADD_END CCI_REG16(0x034a) +#define IMX355_REG_X_OUT_SIZE CCI_REG16(0x034c) +#define IMX355_REG_Y_OUT_SIZE CCI_REG16(0x034e) =20 /* Exposure control */ -#define IMX355_REG_EXPOSURE 0x0202 +#define IMX355_REG_EXPOSURE CCI_REG16(0x0202) #define IMX355_EXPOSURE_MIN 1 #define IMX355_EXPOSURE_STEP 1 #define IMX355_EXPOSURE_DEFAULT 0x0282 =20 /* Analog gain control */ -#define IMX355_REG_ANALOG_GAIN 0x0204 +#define IMX355_REG_ANALOG_GAIN CCI_REG16(0x0204) #define IMX355_ANA_GAIN_MIN 0 #define IMX355_ANA_GAIN_MAX 960 #define IMX355_ANA_GAIN_STEP 1 #define IMX355_ANA_GAIN_DEFAULT 0 =20 /* Digital gain control */ -#define IMX355_REG_DPGA_USE_GLOBAL_GAIN 0x3070 -#define IMX355_REG_DIG_GAIN_GLOBAL 0x020e +#define IMX355_REG_DPGA_USE_GLOBAL_GAIN CCI_REG8(0x3070) +#define IMX355_REG_DIG_GAIN_GLOBAL CCI_REG16(0x020e) #define IMX355_DGTL_GAIN_MIN 256 #define IMX355_DGTL_GAIN_MAX 4095 #define IMX355_DGTL_GAIN_STEP 1 #define IMX355_DGTL_GAIN_DEFAULT 256 =20 /* Test Pattern Control */ -#define IMX355_REG_TEST_PATTERN 0x0600 +#define IMX355_REG_TEST_PATTERN CCI_REG16(0x0600) #define IMX355_TEST_PATTERN_DISABLED 0 #define IMX355_TEST_PATTERN_SOLID_COLOR 1 #define IMX355_TEST_PATTERN_COLOR_BARS 2 #define IMX355_TEST_PATTERN_GRAY_COLOR_BARS 3 #define IMX355_TEST_PATTERN_PN9 4 =20 -#define IMX355_REG_BINNING_MODE 0x0900 -#define IMX355_REG_BINNING_TYPE 0x0901 -#define IMX355_REG_BINNING_WEIGHTING 0x0902 +#define IMX355_REG_BINNING_MODE CCI_REG8(0x0900) +#define IMX355_REG_BINNING_TYPE CCI_REG8(0x0901) +#define IMX355_REG_BINNING_WEIGHTING CCI_REG8(0x0902) =20 /* Flip Control */ -#define IMX355_REG_ORIENTATION 0x0101 +#define IMX355_REG_ORIENTATION CCI_REG8(0x0101) =20 /* default link frequency and external clock */ #define IMX355_LINK_FREQ_DEFAULT 360000000LL @@ -91,14 +93,9 @@ #define IMX355_PIXEL_ARRAY_WIDTH 3280 #define IMX355_PIXEL_ARRAY_HEIGHT 2464 =20 -struct imx355_reg { - u16 address; - u8 val; -}; - struct imx355_reg_list { u32 num_of_regs; - const struct imx355_reg *regs; + const struct cci_reg_sequence *regs; }; =20 /* Mode : resolution and related config&values */ @@ -149,6 +146,7 @@ struct imx355_hwcfg { struct imx355 { struct device *dev; struct clk *clk; + struct regmap *regmap; =20 struct v4l2_subdev sd; struct media_pad pad; @@ -185,155 +183,150 @@ static const struct regulator_bulk_data imx355_supp= lies[] =3D { { .supply =3D "dovdd" }, }; =20 -static const struct imx355_reg imx355_global_regs[] =3D { - { 0x304e, 0x03 }, - { 0x4348, 0x16 }, - { 0x4350, 0x19 }, - { 0x4408, 0x0a }, - { 0x440c, 0x0b }, - { 0x4411, 0x5f }, - { 0x4412, 0x2c }, - { 0x4623, 0x00 }, - { 0x462c, 0x0f }, - { 0x462d, 0x00 }, - { 0x462e, 0x00 }, - { 0x4684, 0x54 }, - { 0x480a, 0x07 }, - { 0x4908, 0x07 }, - { 0x4909, 0x07 }, - { 0x490d, 0x0a }, - { 0x491e, 0x0f }, - { 0x4921, 0x06 }, - { 0x4923, 0x28 }, - { 0x4924, 0x28 }, - { 0x4925, 0x29 }, - { 0x4926, 0x29 }, - { 0x4927, 0x1f }, - { 0x4928, 0x20 }, - { 0x4929, 0x20 }, - { 0x492a, 0x20 }, - { 0x492c, 0x05 }, - { 0x492d, 0x06 }, - { 0x492e, 0x06 }, - { 0x492f, 0x06 }, - { 0x4930, 0x03 }, - { 0x4931, 0x04 }, - { 0x4932, 0x04 }, - { 0x4933, 0x05 }, - { 0x595e, 0x01 }, - { 0x5963, 0x01 }, - { 0x3030, 0x01 }, - { 0x3031, 0x01 }, - { 0x3045, 0x01 }, - { 0x4010, 0x00 }, - { 0x4011, 0x00 }, - { 0x4012, 0x00 }, - { 0x4013, 0x01 }, - { 0x68a8, 0xfe }, - { 0x68a9, 0xff }, - { 0x6888, 0x00 }, - { 0x6889, 0x00 }, - { 0x68b0, 0x00 }, - { 0x3058, 0x00 }, - { 0x305a, 0x00 }, - { 0x0112, 0x0a }, - { 0x0113, 0x0a }, - { 0x0114, 0x03 }, - { 0x0301, 0x05 }, - { 0x0303, 0x01 }, - { 0x0305, 0x02 }, - { 0x0306, 0x00 }, - { 0x0307, 0x78 }, - { 0x030b, 0x01 }, - { 0x030d, 0x02 }, - { 0x0310, 0x00 }, - { 0x0220, 0x00 }, - { 0x0222, 0x01 }, - { 0x0820, 0x0b }, - { 0x0821, 0x40 }, - { 0x3088, 0x04 }, - { 0x6813, 0x02 }, - { 0x6835, 0x07 }, - { 0x6836, 0x01 }, - { 0x6837, 0x04 }, - { 0x684d, 0x07 }, - { 0x684e, 0x01 }, - { 0x684f, 0x04 }, +static const struct cci_reg_sequence imx355_global_regs[] =3D { + { CCI_REG8(0x304e), 0x03 }, + { CCI_REG8(0x4348), 0x16 }, + { CCI_REG8(0x4350), 0x19 }, + { CCI_REG8(0x4408), 0x0a }, + { CCI_REG8(0x440c), 0x0b }, + { CCI_REG8(0x4411), 0x5f }, + { CCI_REG8(0x4412), 0x2c }, + { CCI_REG8(0x4623), 0x00 }, + { CCI_REG8(0x462c), 0x0f }, + { CCI_REG8(0x462d), 0x00 }, + { CCI_REG8(0x462e), 0x00 }, + { CCI_REG8(0x4684), 0x54 }, + { CCI_REG8(0x480a), 0x07 }, + { CCI_REG8(0x4908), 0x07 }, + { CCI_REG8(0x4909), 0x07 }, + { CCI_REG8(0x490d), 0x0a }, + { CCI_REG8(0x491e), 0x0f }, + { CCI_REG8(0x4921), 0x06 }, + { CCI_REG8(0x4923), 0x28 }, + { CCI_REG8(0x4924), 0x28 }, + { CCI_REG8(0x4925), 0x29 }, + { CCI_REG8(0x4926), 0x29 }, + { CCI_REG8(0x4927), 0x1f }, + { CCI_REG8(0x4928), 0x20 }, + { CCI_REG8(0x4929), 0x20 }, + { CCI_REG8(0x492a), 0x20 }, + { CCI_REG8(0x492c), 0x05 }, + { CCI_REG8(0x492d), 0x06 }, + { CCI_REG8(0x492e), 0x06 }, + { CCI_REG8(0x492f), 0x06 }, + { CCI_REG8(0x4930), 0x03 }, + { CCI_REG8(0x4931), 0x04 }, + { CCI_REG8(0x4932), 0x04 }, + { CCI_REG8(0x4933), 0x05 }, + { CCI_REG8(0x595e), 0x01 }, + { CCI_REG8(0x5963), 0x01 }, + { CCI_REG8(0x3030), 0x01 }, + { CCI_REG8(0x3031), 0x01 }, + { CCI_REG8(0x3045), 0x01 }, + { CCI_REG8(0x4010), 0x00 }, + { CCI_REG8(0x4011), 0x00 }, + { CCI_REG8(0x4012), 0x00 }, + { CCI_REG8(0x4013), 0x01 }, + { CCI_REG8(0x68a8), 0xfe }, + { CCI_REG8(0x68a9), 0xff }, + { CCI_REG8(0x6888), 0x00 }, + { CCI_REG8(0x6889), 0x00 }, + { CCI_REG8(0x68b0), 0x00 }, + { CCI_REG8(0x3058), 0x00 }, + { CCI_REG8(0x305a), 0x00 }, + { CCI_REG8(0x0112), 0x0a }, + { CCI_REG8(0x0113), 0x0a }, + { CCI_REG8(0x0114), 0x03 }, + { CCI_REG8(0x0301), 0x05 }, + { CCI_REG8(0x0303), 0x01 }, + { CCI_REG8(0x0305), 0x02 }, + { CCI_REG8(0x0306), 0x00 }, + { CCI_REG8(0x0307), 0x78 }, + { CCI_REG8(0x030b), 0x01 }, + { CCI_REG8(0x030d), 0x02 }, + { CCI_REG8(0x0310), 0x00 }, + { CCI_REG8(0x0220), 0x00 }, + { CCI_REG8(0x0222), 0x01 }, + { CCI_REG8(0x0820), 0x0b }, + { CCI_REG8(0x0821), 0x40 }, + { CCI_REG8(0x3088), 0x04 }, + { CCI_REG8(0x6813), 0x02 }, + { CCI_REG8(0x6835), 0x07 }, + { CCI_REG8(0x6836), 0x01 }, + { CCI_REG8(0x6837), 0x04 }, + { CCI_REG8(0x684d), 0x07 }, + { CCI_REG8(0x684e), 0x01 }, + { CCI_REG8(0x684f), 0x04 }, }; =20 -static const struct imx355_reg_list imx355_global_setting =3D { - .num_of_regs =3D ARRAY_SIZE(imx355_global_regs), - .regs =3D imx355_global_regs, +static const struct cci_reg_sequence mode_3268x2448_regs[] =3D { + { CCI_REG8(0x0700), 0x00 }, + { CCI_REG8(0x0701), 0x10 }, }; =20 -static const struct imx355_reg mode_3268x2448_regs[] =3D { - { 0x0700, 0x00 }, - { 0x0701, 0x10 }, +static const struct cci_reg_sequence mode_3264x2448_regs[] =3D { + { CCI_REG8(0x0700), 0x00 }, + { CCI_REG8(0x0701), 0x10 }, }; =20 -static const struct imx355_reg mode_3264x2448_regs[] =3D { - { 0x0700, 0x00 }, - { 0x0701, 0x10 }, +static const struct cci_reg_sequence mode_3280x2464_regs[] =3D { + { CCI_REG8(0x0700), 0x00 }, + { CCI_REG8(0x0701), 0x10 }, }; =20 -static const struct imx355_reg mode_3280x2464_regs[] =3D { - { 0x0700, 0x00 }, - { 0x0701, 0x10 }, +static const struct cci_reg_sequence mode_1940x1096_regs[] =3D { + { CCI_REG8(0x0700), 0x00 }, + { CCI_REG8(0x0701), 0x10 }, }; =20 -static const struct imx355_reg mode_1940x1096_regs[] =3D { - { 0x0700, 0x00 }, - { 0x0701, 0x10 }, +static const struct cci_reg_sequence mode_1936x1096_regs[] =3D { + { CCI_REG8(0x0700), 0x00 }, + { CCI_REG8(0x0701), 0x10 }, }; =20 -static const struct imx355_reg mode_1936x1096_regs[] =3D { - { 0x0700, 0x00 }, - { 0x0701, 0x10 }, +static const struct cci_reg_sequence mode_1924x1080_regs[] =3D { + { CCI_REG8(0x0700), 0x00 }, + { CCI_REG8(0x0701), 0x10 }, }; =20 -static const struct imx355_reg mode_1924x1080_regs[] =3D { - { 0x0700, 0x00 }, - { 0x0701, 0x10 }, +static const struct cci_reg_sequence mode_1920x1080_regs[] =3D { + { CCI_REG8(0x0700), 0x00 }, + { CCI_REG8(0x0701), 0x10 }, }; =20 -static const struct imx355_reg mode_1920x1080_regs[] =3D { - { 0x0700, 0x00 }, - { 0x0701, 0x10 }, +static const struct cci_reg_sequence mode_1640x1232_regs[] =3D { + { CCI_REG8(0x0700), 0x00 }, + { CCI_REG8(0x0701), 0x10 }, }; =20 -static const struct imx355_reg mode_1640x1232_regs[] =3D { - { 0x0700, 0x00 }, - { 0x0701, 0x10 }, +static const struct cci_reg_sequence mode_1640x922_regs[] =3D { + { CCI_REG8(0x0700), 0x00 }, + { CCI_REG8(0x0701), 0x10 }, }; =20 -static const struct imx355_reg mode_1640x922_regs[] =3D { - { 0x0700, 0x00 }, - { 0x0701, 0x10 }, +static const struct cci_reg_sequence mode_1300x736_regs[] =3D { + { CCI_REG8(0x0700), 0x00 }, + { CCI_REG8(0x0701), 0x10 }, }; =20 -static const struct imx355_reg mode_1300x736_regs[] =3D { - { 0x0700, 0x00 }, - { 0x0701, 0x10 }, +static const struct cci_reg_sequence mode_1296x736_regs[] =3D { + { CCI_REG8(0x0700), 0x00 }, + { CCI_REG8(0x0701), 0x10 }, }; =20 -static const struct imx355_reg mode_1296x736_regs[] =3D { - { 0x0700, 0x00 }, - { 0x0701, 0x10 }, +static const struct cci_reg_sequence mode_1284x720_regs[] =3D { + { CCI_REG8(0x0700), 0x00 }, + { CCI_REG8(0x0701), 0x10 }, }; =20 -static const struct imx355_reg mode_1284x720_regs[] =3D { - { 0x0700, 0x00 }, - { 0x0701, 0x10 }, +static const struct cci_reg_sequence mode_1280x720_regs[] =3D { + { CCI_REG8(0x0700), 0x00 }, + { CCI_REG8(0x0701), 0x10 }, }; =20 -static const struct imx355_reg mode_1280x720_regs[] =3D { - { 0x0700, 0x00 }, - { 0x0701, 0x10 }, -}; - -static const struct imx355_reg mode_820x616_regs[] =3D { - { 0x0700, 0x02 }, - { 0x0701, 0x78 }, +static const struct cci_reg_sequence mode_820x616_regs[] =3D { + { CCI_REG8(0x0700), 0x02 }, + { CCI_REG8(0x0701), 0x78 }, }; =20 static const char * const imx355_test_pattern_menu[] =3D { @@ -604,78 +597,6 @@ static u32 imx355_get_format_code(struct imx355 *imx35= 5) return code; } =20 -/* Read registers up to 4 at a time */ -static int imx355_read_reg(struct imx355 *imx355, u16 reg, u32 len, u32 *v= al) -{ - struct i2c_client *client =3D v4l2_get_subdevdata(&imx355->sd); - struct i2c_msg msgs[2]; - u8 addr_buf[2]; - u8 data_buf[4] =3D { 0 }; - int ret; - - if (len > 4) - return -EINVAL; - - put_unaligned_be16(reg, addr_buf); - /* Write register address */ - msgs[0].addr =3D client->addr; - msgs[0].flags =3D 0; - msgs[0].len =3D ARRAY_SIZE(addr_buf); - msgs[0].buf =3D addr_buf; - - /* Read data from register */ - msgs[1].addr =3D client->addr; - msgs[1].flags =3D I2C_M_RD; - msgs[1].len =3D len; - msgs[1].buf =3D &data_buf[4 - len]; - - ret =3D i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); - if (ret !=3D ARRAY_SIZE(msgs)) - return -EIO; - - *val =3D get_unaligned_be32(data_buf); - - return 0; -} - -/* Write registers up to 4 at a time */ -static int imx355_write_reg(struct imx355 *imx355, u16 reg, u32 len, u32 v= al) -{ - struct i2c_client *client =3D v4l2_get_subdevdata(&imx355->sd); - u8 buf[6]; - - if (len > 4) - return -EINVAL; - - put_unaligned_be16(reg, buf); - put_unaligned_be32(val << (8 * (4 - len)), buf + 2); - if (i2c_master_send(client, buf, len + 2) !=3D len + 2) - return -EIO; - - return 0; -} - -/* Write a list of registers */ -static int imx355_write_regs(struct imx355 *imx355, - const struct imx355_reg *regs, u32 len) -{ - int ret; - u32 i; - - for (i =3D 0; i < len; i++) { - ret =3D imx355_write_reg(imx355, regs[i].address, 1, regs[i].val); - if (ret) { - dev_err_ratelimited(imx355->dev, - "write reg 0x%4.4x return err %d", - regs[i].address, ret); - - return ret; - } - } - - return 0; -} - /* Open sub-device */ static int imx355_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) { @@ -727,31 +648,31 @@ static int imx355_set_ctrl(struct v4l2_ctrl *ctrl) switch (ctrl->id) { case V4L2_CID_ANALOGUE_GAIN: /* Analog gain =3D 1024/(1024 - ctrl->val) times */ - ret =3D imx355_write_reg(imx355, IMX355_REG_ANALOG_GAIN, 2, - ctrl->val); + ret =3D cci_write(imx355->regmap, IMX355_REG_ANALOG_GAIN, + ctrl->val, NULL); break; case V4L2_CID_DIGITAL_GAIN: - ret =3D imx355_write_reg(imx355, IMX355_REG_DIG_GAIN_GLOBAL, 2, - ctrl->val); + ret =3D cci_write(imx355->regmap, IMX355_REG_DIG_GAIN_GLOBAL, + ctrl->val, NULL); break; case V4L2_CID_EXPOSURE: - ret =3D imx355_write_reg(imx355, IMX355_REG_EXPOSURE, 2, - ctrl->val); + ret =3D cci_write(imx355->regmap, IMX355_REG_EXPOSURE, + ctrl->val, NULL); break; case V4L2_CID_VBLANK: /* Update FLL that meets expected vertical blanking */ - ret =3D imx355_write_reg(imx355, IMX355_REG_FLL, 2, - imx355->cur_mode->height + ctrl->val); + ret =3D cci_write(imx355->regmap, IMX355_REG_FLL, + imx355->cur_mode->height + ctrl->val, NULL); break; case V4L2_CID_TEST_PATTERN: - ret =3D imx355_write_reg(imx355, IMX355_REG_TEST_PATTERN, - 2, ctrl->val); + ret =3D cci_write(imx355->regmap, IMX355_REG_TEST_PATTERN, + ctrl->val, NULL); break; case V4L2_CID_HFLIP: case V4L2_CID_VFLIP: - ret =3D imx355_write_reg(imx355, IMX355_REG_ORIENTATION, 1, - imx355->hflip->val | - imx355->vflip->val << 1); + ret =3D cci_write(imx355->regmap, IMX355_REG_ORIENTATION, + imx355->hflip->val | imx355->vflip->val << 1, + NULL); break; default: ret =3D -EINVAL; @@ -956,100 +877,64 @@ static int imx355_start_streaming(struct imx355 *imx= 355) const struct imx355_reg_list *reg_list; const struct imx355_mode *mode; u8 binning_mode; - int ret; + int ret =3D 0; =20 /* Global Setting */ - reg_list =3D &imx355_global_setting; - ret =3D imx355_write_regs(imx355, reg_list->regs, reg_list->num_of_regs); - if (ret) { - dev_err(imx355->dev, "failed to set global settings"); - return ret; - } + cci_multi_reg_write(imx355->regmap, imx355_global_regs, + ARRAY_SIZE(imx355_global_regs), &ret); =20 /* Apply default values of current mode */ mode =3D imx355->cur_mode; reg_list =3D &mode->reg_list; - ret =3D imx355_write_regs(imx355, reg_list->regs, reg_list->num_of_regs); - if (ret) { - dev_err(imx355->dev, "failed to set mode"); - return ret; - } + cci_multi_reg_write(imx355->regmap, reg_list->regs, + reg_list->num_of_regs, &ret); =20 /* Set readout crop and size registers */ - ret =3D imx355_write_reg(imx355, IMX355_REG_X_ADD_START, 2, - mode->crop.left); - if (ret) - return ret; - ret =3D imx355_write_reg(imx355, IMX355_REG_Y_ADD_START, 2, - mode->crop.top); - if (ret) - return ret; - ret =3D imx355_write_reg(imx355, IMX355_REG_X_ADD_END, 2, - mode->crop.width + mode->crop.left - 1); - if (ret) - return ret; - ret =3D imx355_write_reg(imx355, IMX355_REG_Y_ADD_END, 2, - mode->crop.height + mode->crop.top - 1); - if (ret) - return ret; - ret =3D imx355_write_reg(imx355, IMX355_REG_X_OUT_SIZE, 2, - mode->width); - if (ret) - return ret; - ret =3D imx355_write_reg(imx355, IMX355_REG_Y_OUT_SIZE, 2, - mode->height); - if (ret) - return ret; + cci_write(imx355->regmap, IMX355_REG_X_ADD_START, mode->crop.left, + &ret); + cci_write(imx355->regmap, IMX355_REG_Y_ADD_START, mode->crop.top, &ret); + cci_write(imx355->regmap, IMX355_REG_X_ADD_END, + mode->crop.width + mode->crop.left - 1, &ret); + cci_write(imx355->regmap, IMX355_REG_Y_ADD_END, + mode->crop.height + mode->crop.top - 1, &ret); + cci_write(imx355->regmap, IMX355_REG_X_OUT_SIZE, mode->width, &ret); + cci_write(imx355->regmap, IMX355_REG_Y_OUT_SIZE, mode->height, &ret); =20 binning_mode =3D ((mode->crop.width / mode->width) << 4) | (mode->crop.height / mode->height); - ret =3D imx355_write_reg(imx355, IMX355_REG_BINNING_MODE, 1, - binning_mode =3D=3D 0x11 ? 0x00 : 0x01); - if (ret) - return ret; - ret =3D imx355_write_reg(imx355, IMX355_REG_BINNING_TYPE, 1, - binning_mode); - if (ret) - return ret; - ret =3D imx355_write_reg(imx355, IMX355_REG_BINNING_WEIGHTING, 1, 0x00); - if (ret) - return ret; + cci_write(imx355->regmap, IMX355_REG_BINNING_MODE, + binning_mode =3D=3D 0x11 ? 0x00 : 0x01, &ret); + cci_write(imx355->regmap, IMX355_REG_BINNING_TYPE, binning_mode, &ret); + cci_write(imx355->regmap, IMX355_REG_BINNING_WEIGHTING, 0x00, &ret); =20 /* Set PLL registers for the external clock frequency */ - ret =3D imx355_write_reg(imx355, IMX355_REG_EXTCLK_FREQ, 2, - imx355->clk_params->extclk_freq); - if (ret) - return ret; - ret =3D imx355_write_reg(imx355, IMX355_REG_PLL_OP_MUL, 2, - imx355->clk_params->pll_op_mpy); - if (ret) - return ret; + cci_write(imx355->regmap, IMX355_REG_EXTCLK_FREQ, + imx355->clk_params->extclk_freq, &ret); + cci_write(imx355->regmap, IMX355_REG_PLL_OP_MUL, + imx355->clk_params->pll_op_mpy, &ret); =20 /* set digital gain control to all color mode */ - ret =3D imx355_write_reg(imx355, IMX355_REG_DPGA_USE_GLOBAL_GAIN, 1, 1); - if (ret) - return ret; + cci_write(imx355->regmap, IMX355_REG_DPGA_USE_GLOBAL_GAIN, 1, &ret); =20 /* set line length */ - ret =3D imx355_write_reg(imx355, IMX355_REG_LLP, 2, - imx355->hblank->val + imx355->cur_mode->width); - if (ret) - return ret; + cci_write(imx355->regmap, IMX355_REG_LLP, + imx355->hblank->val + imx355->cur_mode->width, &ret); =20 /* Apply customized values from user */ - ret =3D __v4l2_ctrl_handler_setup(imx355->sd.ctrl_handler); - if (ret) - return ret; + if (!ret) + ret =3D __v4l2_ctrl_handler_setup(imx355->sd.ctrl_handler); + + cci_write(imx355->regmap, IMX355_REG_MODE_SELECT, IMX355_MODE_STREAMING, + &ret); =20 - return imx355_write_reg(imx355, IMX355_REG_MODE_SELECT, - 1, IMX355_MODE_STREAMING); + return ret; } =20 /* Stop streaming */ static int imx355_stop_streaming(struct imx355 *imx355) { - return imx355_write_reg(imx355, IMX355_REG_MODE_SELECT, - 1, IMX355_MODE_STANDBY); + return cci_write(imx355->regmap, IMX355_REG_MODE_SELECT, + IMX355_MODE_STANDBY, NULL); } =20 static int imx355_set_stream(struct v4l2_subdev *sd, int enable) @@ -1096,14 +981,14 @@ static int imx355_set_stream(struct v4l2_subdev *sd,= int enable) static int imx355_identify_module(struct imx355 *imx355) { int ret; - u32 val; + u64 val; =20 - ret =3D imx355_read_reg(imx355, IMX355_REG_CHIP_ID, 2, &val); + ret =3D cci_read(imx355->regmap, IMX355_REG_CHIP_ID, &val, NULL); if (ret) return ret; =20 if (val !=3D IMX355_CHIP_ID) { - dev_err(imx355->dev, "chip id mismatch: %x!=3D%x", + dev_err(imx355->dev, "chip id mismatch: %x!=3D%llx", IMX355_CHIP_ID, val); return -EIO; } @@ -1350,6 +1235,11 @@ static int imx355_probe(struct i2c_client *client) =20 mutex_init(&imx355->mutex); =20 + imx355->regmap =3D devm_cci_regmap_init_i2c(client, 16); + if (IS_ERR(imx355->regmap)) + return dev_err_probe(imx355->dev, PTR_ERR(imx355->regmap), + "Unable to initialize I2C\n"); + imx355->clk =3D devm_v4l2_sensor_clk_get(imx355->dev, NULL); if (IS_ERR(imx355->clk)) return dev_err_probe(imx355->dev, PTR_ERR(imx355->clk), --=20 2.34.1 From nobody Mon Jul 27 11:00:15 2026 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 2BB1F48A2D2 for ; Wed, 8 Jul 2026 14:49:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522171; cv=none; b=f3XpBU0p7zWT97+EoF+nlNN/UUA7yIpuSiwpcpJ7Gv+lo9+CiCZ9Dj4HhZZ6qXspwvpLu6sqxWkgGjL8hHHEwJphuXaPoj9LzW55ciM+jTtTPfcUpWkxrYc/jpzdfdo8agN1w6epl8VwUzC9j6UAZI/aMhfxsSKoY4G7k3fl7Ek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522171; c=relaxed/simple; bh=AE+i38URadyS4ydSRjafOJeNNrYwdTlnwBC+7VOFlkU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=e+2cCwSDPU6+yQf+6KEKv7XxyK+WU1DPNMD/ZueWAF75jsV5FEs2G59xiFVxt35ct79nTvrjnMehIO3YFXhD+gb9pR4YC/tDWXuLNT6CZ7au8dj6S3Dj91Pe02weVHNDx65g7eAadfyVvAT+1g/Yymor2pJBRi36o+n1Khhs5pU= 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=phnLMqFp; arc=none smtp.client-ip=209.85.128.42 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="phnLMqFp" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-493c733f15aso6817245e9.0 for ; Wed, 08 Jul 2026 07:49:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522160; x=1784126960; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=DOdbzYUWhs5HpVXO6M+i3dw4wtd6/MeyqYVT2Wwi2z8=; b=phnLMqFpZ7VlYI3qE0FKGEFc2RCwLe15w3KeD2zTz/QI+rHetv9Q3EAJkAzjDRZmK3 3NQ3THjG+F/D3lpXFsD85JoHNFRO+Z6LgnU9A6FxckdBE+F2Ig2Z9tgQFsf4PWhYCUxq 5wRG/Tveb5l2dOrLbAx78hbKaCGKZvM/Wxw8pi27MW4acFXsljvq242GRbAzbcuLoYNG fAFNkjqWf+VrqbtB3b01wM6U90OSbJ6ln1nd37kWdm1y2qHK3+sG5JYljMeBlGncZIoa 37j3zx+rdG9+BKtpBiOiR4g4B1r7F7cxFq72+yQLafiilTt7YGNr47L31G5lIoptng6S 4+Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522160; x=1784126960; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=DOdbzYUWhs5HpVXO6M+i3dw4wtd6/MeyqYVT2Wwi2z8=; b=AXs/dyq95omKjzuThOEhMHXgSIejpvja14mkx1TDvnUbH5RsEjpXXAdkysNgzfTJOx 3J+qbuvrGZrvUKyczHOCz1BtzM+MchZrtRBXBNAbXT6VXvP/ZLx66AQPU4klrCazmP0j IFpcrdNIZR+GEW7u4joqFj6TnZycGAiB4Zt0GpY6zcWFXPlZyQA+Xd89qQS23/7d79h9 ZM2cP65FKfyA5wmsBbRczmd1JXLQ4KkTkHOHCqlgP6YF2hhI4EZxXEDqoFZLxGWWC4ii L9GVxUiVZwnPMFzSFvBpU2T6swWUXYmDT6WouJmmGwXILfIbpu61rZWbFA4ZuN7zhbAY dGAw== X-Forwarded-Encrypted: i=1; AHgh+RpJ4lE7TzZ06CkAG/fas00f9wNkS3hzwAkfylDq7R4dFfkKqIc+PeaiyJZNa9eJHRp4G/kTtbFazaXtiCQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwRetR987nTD4hqliLUPYmyNfDWzg6qwHGJPFFvAgoVk07QjkEM rIV5IjyCoRihByVMIyrgWG/Lj15s9Zef2QR1IUfEOlwBufacP2zUqUrx0px1gI/Cbgw= X-Gm-Gg: AfdE7cklqkof5F+tUwmJIbQBjzSLVyGUNnwB1e2v9OPZuLHDGOESZ8KlpSgZo1itY6x pWBlDzU/6cPEjIQUTGiCu0xHNgBotT6ZqzWo3MJvaeG0GRi5gyEaY8qwRqB16u5T3lpoBmoIY8h uSNQoraoQkxpez+KFBSeyf4XKz++kI5i/MZfPZXLLz7MXAOm35oVHbSX+gxaOcqc0E1yVZ6U5+V bP+8eU5XQqzed4hK2ZuPBqX+szlYa1qIJzuZkp+tGQwm8vZM+KQj1gh1rXAhAghR/dvwlVA8IWF 0K5MezcUxjEkCa7cj7VVuaOuO4Wi1d0SgHr7WjhEsezDmLfYZvl6hLHBUQOH8biMQ+jKJ9kSnSd hLh6GY5QWO/ahUBNjnP100U4dSd9qoOyBaJBK440imyc+1JYUdQ976i0Y18YMER5W6JQ9FEW9NO /fU0inVnObkn5J/qiVqvHdpsTirJZm9QHchW8vgrdTNDCrIP6D3sfY8R2y43lJGEj+TN+tCkouS rU= X-Received: by 2002:a05:600c:8b05:b0:493:aaa2:f034 with SMTP id 5b1f17b1804b1-493e68cf39amr29755245e9.26.1783522160563; Wed, 08 Jul 2026 07:49:20 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:20 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:50 +0100 Subject: [PATCH v3 14/20] media: imx355: Set the colorspace in the format 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: <20260708-media-imx355-v3-14-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 The colorspace fields were left set to 0 when they should be set appropriately for a raw image sensor. Add those values. Signed-off-by: Dave Stevenson --- drivers/media/i2c/imx355.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index b27329143e48..2bf8da7469fe 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -612,6 +612,10 @@ static int imx355_open(struct v4l2_subdev *sd, struct = v4l2_subdev_fh *fh) try_fmt->height =3D imx355->cur_mode->height; try_fmt->code =3D imx355_get_format_code(imx355); try_fmt->field =3D V4L2_FIELD_NONE; + try_fmt->format.colorspace =3D V4L2_COLORSPACE_RAW; + try_fmt->format.ycbcr_enc =3D V4L2_YCBCR_ENC_601; + try_fmt->format.quantization =3D V4L2_QUANTIZATION_FULL_RANGE; + try_fmt->format.xfer_func =3D V4L2_XFER_FUNC_NONE; =20 *crop =3D imx355->cur_mode->crop; =20 @@ -738,6 +742,10 @@ static void imx355_update_pad_format(struct imx355 *im= x355, fmt->format.height =3D mode->height; fmt->format.code =3D imx355_get_format_code(imx355); fmt->format.field =3D V4L2_FIELD_NONE; + fmt->format.colorspace =3D V4L2_COLORSPACE_RAW; + fmt->format.ycbcr_enc =3D V4L2_YCBCR_ENC_601; + fmt->format.quantization =3D V4L2_QUANTIZATION_FULL_RANGE; + fmt->format.xfer_func =3D V4L2_XFER_FUNC_NONE; } =20 static int imx355_do_get_pad_format(struct imx355 *imx355, --=20 2.34.1 From nobody Mon Jul 27 11:00:15 2026 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 2C48C480DF7 for ; Wed, 8 Jul 2026 14:49:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522170; cv=none; b=p8LIHJNrqRqive764tlAK3lKucx6pEoK/ljIFHuqW1WUbGtFvfw5KlnFpA0wpdLh0R9WJ+7VbUxYvc5e+gmEOkMDwzIa55kwgch5zQWACUNSa0ivfZXYWAf8dHjBQCAXF8PGpGU3hxXl+ZX3fNeTeMjJYUdYhTpm+CegnGTVyeQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522170; c=relaxed/simple; bh=N22ub8y8rxVNpO5t6NfeXqjef5cDmG+VxKvP1KyhEqg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LE8HzXppHIL8CzSqSOjxOwM4eLEq1zfFYzNo4VhNN9qA0UK0kiqM41VwJD65VaN4b3D0Y52PLIB+kdFKY4+sXMHa4CWa5E10Tex7Q4Ooe4VayLkfTHNMDCI6VBPoihhnqUo3SGqOJb9tVVxAOBsWI1pgc+lAgJDSKuqTbNR6HGI= 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=g1aL2E3E; arc=none smtp.client-ip=209.85.128.52 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="g1aL2E3E" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-493bc8fda98so6062755e9.0 for ; Wed, 08 Jul 2026 07:49:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522161; x=1784126961; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=HmxbOG7rbE41JtbgC/kLoXXgZ/dEvF+BjHVvArFg/gY=; b=g1aL2E3E2VCMl5EZl+mm56PtLoA7f5ff/rFSpvITWgTbMpeIOZzoqy7QS90kJMWkXC Bqh0G5s564Ie+o2YL8Wx/i7GIur6KTzQlw08PpjYXje10FSl/wTgj0wFbIGMl6D2TZ+i HS7k8qMuw53iAwOYJ4edKlHtqs8ZBjGSHnQfvsL9EJeZ+l5OdDL//zRmvcbv8VRwSp6I p8Uj9VFNRIz5YASBcfBo4a6BJZ+aBbWNb/sbNRM828Dvi3PyrZCuJEyzVxghNPj91/6C n388e7R0EfEOseltmN4yKXyGkbhIxQG0IPqiHZLyoCi7r2dXRJ2skXjo/Q1IJE/kLzOi lzbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522161; x=1784126961; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=HmxbOG7rbE41JtbgC/kLoXXgZ/dEvF+BjHVvArFg/gY=; b=pf/RxcpLrmjUQhFG9bXTIhmrkMxs/sQ4uLjcR3k3YAYLDTekLSg764WprfmDQ9nuKU D38ps/tfVGL9mBJ6b9E827w7JJof7JjD/QwQe6aO9KkE1Rhd35HqOxxhAKgKlN4a6l1i 9XKxEbKGyUosvnxVxJJwh82+xm6bevyrzGXmdBvK5O1Jxjv2IMjB/u10RTrGWrAZWxMv 3qgfkUvYLqDy3v5xwtTzhoSLZ50sIwWA/ZQj36ZkBp5/BRgPfDOjBsnqQjIEbeIPFHJn y/hyneRJ4MmcCniPqw6qmemHEJ1pUfZfTKtm6w5qr9PL4EdvO4SMHDjuoofsbMwdpVGv f15A== X-Forwarded-Encrypted: i=1; AHgh+RoXWJxOc92NcN/qu+9DKe7wC+fg7F+ptXkwgoWIvHW+djxchwcePN2PylaMbUbLQQgOyik3+8qrUWLvup0=@vger.kernel.org X-Gm-Message-State: AOJu0YyykCS0AUitn3PJzgftK4oDElQIrCidrLMKaUp0H7hm1JSi3/Pq cSinVJJFb3CjAfnFG6SUQVjvtZfeoiDU3qmOu28vQlW8uwgaCVPp+nfsPPuI79bl3RFP/+6at2b oFHz3 X-Gm-Gg: AfdE7cmMWXAxUQCOZnca3F/OblNfvGhrDDejTjDW/xh8VeQSDnLRqXHhYPg0B9dITD6 Okk6W+/GRWPC49JE6XTuEFJszLz/48cqe7FGnrn/EIIZHcPFkUlgLG2NOW5oTeJRkEixnItDdQE vssp/R4x8DgIsOQVs4yjftKCKzF2RSuqjQu/98D+f2FAm0Eo02RYGMaH5EivCUlKG9KYvBynj0o FQOe3jjee1tlLVcyxDEk0pc0M0QzOZxM4zwYUhzjPD3tvLux2dAYUEmXBEKFK27unvq+woLCcPI EbiKvBFcwsGghg1bheu5MRaBVcRC18XdQtQPBHeoANoAq7J1DnE8yu6TZwjUHBy/zp8zIRpej6O 0JQs1TEV7xKjITHFqTgWrGOxnajhcbd0tRkv8fU+NY0pekFK7qrf1gz3OFyQwqGVh0a7eEWgJHa DuBbljTPBtOHreKhR0QN+kv/E/UVWH3bO64Cj7KcCuZMgvUM29RqFISTVxCofjGRb+ X-Received: by 2002:a05:600c:628b:b0:493:e947:b24a with SMTP id 5b1f17b1804b1-493e947b27fmr5523075e9.14.1783522161339; Wed, 08 Jul 2026 07:49:21 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:20 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:51 +0100 Subject: [PATCH v3 15/20] media: imx355: Define the exposure offset, and use that define 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: <20260708-media-imx355-v3-15-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 The difference between frame length and max exposure time in lines is 10. That had been used as a bare value in calculations. Move it to a define, and use that define. Signed-off-by: Dave Stevenson --- drivers/media/i2c/imx355.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index 2bf8da7469fe..3b86bd2e2e5e 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -51,6 +51,7 @@ #define IMX355_EXPOSURE_MIN 1 #define IMX355_EXPOSURE_STEP 1 #define IMX355_EXPOSURE_DEFAULT 0x0282 +#define IMX355_EXPOSURE_OFFSET 10 =20 /* Analog gain control */ #define IMX355_REG_ANALOG_GAIN CCI_REG16(0x0204) @@ -635,7 +636,7 @@ static int imx355_set_ctrl(struct v4l2_ctrl *ctrl) switch (ctrl->id) { case V4L2_CID_VBLANK: /* Update max exposure while meeting expected vblanking */ - max =3D imx355->cur_mode->height + ctrl->val - 10; + max =3D imx355->cur_mode->height + ctrl->val - IMX355_EXPOSURE_OFFSET; __v4l2_ctrl_modify_range(imx355->exposure, imx355->exposure->minimum, max, imx355->exposure->step, max); @@ -1129,7 +1130,7 @@ static int imx355_init_controls(struct imx355 *imx355) imx355->hblank->flags |=3D V4L2_CTRL_FLAG_READ_ONLY; =20 /* fll >=3D exposure time + adjust parameter (default value is 10) */ - exposure_max =3D mode->fll_def - 10; + exposure_max =3D mode->fll_def - IMX355_EXPOSURE_OFFSET; imx355->exposure =3D v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops, V4L2_CID_EXPOSURE, IMX355_EXPOSURE_MIN, exposure_max, --=20 2.34.1 From nobody Mon Jul 27 11:00:15 2026 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 57BE63B8BA4 for ; Wed, 8 Jul 2026 14:49:26 +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=1783522172; cv=none; b=W3/L8nrtEY3zKhCTt3J8d8h61t3DiXmImKuVZ+kmS4AwesuY5CeUhLzeIl6QoNL6oRGq6YsmUOOdtFcy4w8SUkfSRgvCekC4Qw7tT+Z/MZUU9fQzotzNR3soOBAR5XHxLEmBtIvUGr3DjDIdv+Wgw6UK+L2ihhrigRkRzppnSQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522172; c=relaxed/simple; bh=/BY0FHV2ekurjGQiSyljfjnh/9DiTeGY5gSJ9RVi5Zg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ty1vLQV4WJwx2FWVzcU3Jeb89Wik8gvGWeiqtx22Cdx2DWZKX2yLjcHz5s+nT0bhQRXcbghFXUlXuXdkpJ/9tSjngVjR23qeeUIO4QB8kt4o/yJ35SZRTRELepVyoN+cO4egaLnHXyWI8TAWpbGALMbVU4khRTOdXOMxxpSAXnM= 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=YkGmpBhN; 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="YkGmpBhN" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-493c19bad03so7511525e9.2 for ; Wed, 08 Jul 2026 07:49:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522162; x=1784126962; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=RoCc9OCGhP/RSTGfuXTy0/7DUKmkFEmhCqI4hwhY0I8=; b=YkGmpBhN6IJeythTPL5aH3mvCVX920WvMz+wAig3kDJO1SePBZsjgeo44saR6gWdPX zgBOVYUkBoPH03FjRx5hbTy+w7fAc8QtNSrtSYq2/HHVDnaByENOFUf3fEoEETdFV+a1 d+5y53qZD0PZjBVkpvFO9YIQjIVWPb/x+RcvefjUsIkzURPytNr+aRbxV2Sxtbdb9f9R qkrWh7PjpGI3oXI4uNbChTlLHiOzjaMOZ4+eihwg67Rp+HRInn3BvsZLybKNYNstHmZk FINoY2fyJIJzp/5uta1RijvQ+aLkL1WCcUhKmSxzoXCgZK7DbTL2JyD7jDQgUdTuc38r R+kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522162; x=1784126962; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=RoCc9OCGhP/RSTGfuXTy0/7DUKmkFEmhCqI4hwhY0I8=; b=WGn6EptpZK+5rOjRbxsYyPp+y7BBDxXzuGL/VYfYXNNo+Ics/HVcmRfnCe7Vb6TXW7 E1ZEdshKo3eJwjRA1pFNdkJFlds/vF0XgJkJG+rwu1jROPEQuM0YBQo34ymOao+Y04Lv 51dhM3CxCKiMt1tvXp5xF1nqzCjNXZ8opSa727r1MjBmpktEmtBbqsh1M9L5AHkh39OD DG0Mss71olv5ZeoHSMazJ2p4mgUVr48XdcBK908oUAdddAq8biwM62d9WxhwkUSIozHj HWZ/XS/c/tXRAvWqtCuxbyGPqW6fX/5z/sLq4Hg7VnoojS2qSJGQxjBsT23/gtGBM41w 6/pQ== X-Forwarded-Encrypted: i=1; AHgh+RqcCoacMhqjfbYu4s1Ix0+j93+cFeCr1R1I/R5s240Cs31mhFf4tnYl2azt7gCtPs3T9Vs+5nleC7rqZdQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxbO7c8wlEkqigiIWgXxTBUKOb+ZdqE/AEcP8eeT7wd0qZJ03NU Y6ku5MSgZDAsLNvhK4SHGZ2T+YU/V+Dh0s1IHtefXyIm2eboin+e4XAePx0XJ4ZKyUE= X-Gm-Gg: AfdE7cmT0UMk8zqvoXML/m+o7Ojo0aBBXOFVwjAbb/QGTBcNpahQHrg0z1knqU2D5YC txifjhbJDUaipR805vYQw9qDW6SLybGLUhddUSblXcAAkdPgpyISZMrjgtIs/KZr/3axxWSjI6C wF3cNrHJ3tnwlo0f2/Edd4jI4lmTTT93CWSh7tlr3/bBCdNg+kKknvOgOosoc0PMs9OR/LhEETi 9bGTul4Atl+ZBQSYGmv3sg4Ncv929pCicfmmNWxzxe2BISvpWWRM/jO9swX1fN9T1ocbubOnpRg hMmnVCAH+8TlVZ6ldzMQFt4S3gqUE4yZCRlH6FHZRl8b3Ga9OUFitbJZHcXPCaH5JQ+adlaMQqj 3D7aczA3K6sR1kDXXv9dBRyykYVmBbL0gv7SPoQ7JcfwCFlqu6+75Deab9CpwP8R4EvyU5hIMcD PKstEgGtpqRS5hMGZluFQT67eGJr8W2yH2E2P/KnIZYW24LNme0j0ABXAySDClgPfT X-Received: by 2002:a05:600c:4594:b0:493:bc4a:d5f5 with SMTP id 5b1f17b1804b1-493e68809aamr27570285e9.39.1783522162156; Wed, 08 Jul 2026 07:49:22 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:21 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:52 +0100 Subject: [PATCH v3 16/20] media: imx355: Use NULL ctrl_ops for HBLANK as it is a read-only control 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: <20260708-media-imx355-v3-16-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 This avoids the set_ctrl handler being called under any circumstances, as it will return an error for the unhandled ctrl. Signed-off-by: Dave Stevenson --- drivers/media/i2c/imx355.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index 3b86bd2e2e5e..6a779d700a4b 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -1123,9 +1123,8 @@ static int imx355_init_controls(struct imx355 *imx355) 1, vblank_def); =20 hblank =3D mode->llp - mode->width; - imx355->hblank =3D v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops, - V4L2_CID_HBLANK, hblank, hblank, - 1, hblank); + imx355->hblank =3D v4l2_ctrl_new_std(ctrl_hdlr, NULL, V4L2_CID_HBLANK, + hblank, hblank, 1, hblank); if (imx355->hblank) imx355->hblank->flags |=3D V4L2_CTRL_FLAG_READ_ONLY; =20 --=20 2.34.1 From nobody Mon Jul 27 11:00:15 2026 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 CDED148C3FB for ; Wed, 8 Jul 2026 14:49:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522177; cv=none; b=jB8NQDlg5se9aBrEiUl2SIZ/JqTQRGiayALoZGRn4ttHnMK0XTuIBK6lOkW9t2dj1tLvAIc/BGMLejhMqdQcQ9CuW8cOA01teV2DBb8csT5dwfvDAjszIKaFzfL24YxCKH+gxK+XdkdGu6XXUFvUUy5vB3d4j3CSlAvzsqu9Mgs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522177; c=relaxed/simple; bh=xUTMOWk5+CT994jr6gP3kud/mZi2SFkhl+KumJEc/R0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=e0ot33aVgJJu/IdcNYe9vzDy/lrdusDv6ukqzoYMBj6uhlUphNSbMkkaZN/MLlh4Bt8wDFFEJ1DFzZxR+fYxtyWWxyygAAGw8Ya+O+AMWYD4oNHIwrmrgSj/TmhYv37eVKssoBmTQ3kgB18kQNhE33cocmCQLR/HABvo+Q+k5pE= 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=Trmf1Cql; arc=none smtp.client-ip=209.85.128.44 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="Trmf1Cql" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-493e497643fso4226005e9.0 for ; Wed, 08 Jul 2026 07:49:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522163; x=1784126963; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=+RDtHzsl2KamU1JjxV3tuy+ogtFxRgmslfEKzaLXknw=; b=Trmf1CqlJ5VYl+Z+eiBpe5HnWwJnkkqPcrm5SZxNWKFIq9nyc3yc+hH+geEQuXe2XE ZZ00FPkC0YipD2EyhljZ9dQkM/tgKprNMOr31ZhgQ8TxyxdvBuJFrMihL6HTJ3+iWtQt u4OWN2LGzHuNtAptjN7kXg4iTBq3if5sU8syD1vwaMD63/579MPHTzt1+rGA6BXIm9bX oaa39TUDtC2txQ0uPnFRt5n1dTjjC3XQmeiFiUOYuXxWsKcW7vJHirJJWh2WvqGR0F8c cU9ClBLxZWp6Vw8tuSXmUzbmv0ra9PLcmkyh+LRYSMH0xSiU0h81K6F6y8uR3WNQUn4g 4hPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522163; x=1784126963; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=+RDtHzsl2KamU1JjxV3tuy+ogtFxRgmslfEKzaLXknw=; b=K6wslRku6tlMwlAfc+g7UQNGEY1uPUbGpXVGXHAZBqWPi3DSFKxQS4bPgPoBOhac+Z Yx8hJtsv0oO1uRPk4c7woE6h89jFObgYtotMyVCce3RfNEtbkdprxGsUYCT/67ek7Bf2 EC8ojG8xazffBulqHQkoGsZbOOhmoCCwovbnWRV5chYf2zW2igX2d5FVx5iNzGWREEXc EztcSi2M78kQAhShY5Gga0DMttHj2wQwABV5gDLvgjwvO2cCh8eVf7zM9B96FsYIlAK4 4UxeU5IyZ4hnCS48MA0fK/yAWICGxL/fE9aGk4s1hatNY5RnODExo0ZjA5wsDy4U3QZC G/Og== X-Forwarded-Encrypted: i=1; AHgh+RqFLC7RW+gINqEVgdW9lnFGEO2W3CaVEzEr+NUxO95ghIyhthuSBEs02iDs1V94t3QyBToyLfdO+/g0XK8=@vger.kernel.org X-Gm-Message-State: AOJu0YxTOxk31pTxWzPUmStDg8CMnODHLV/fvnbEqy8oIeOuvnII3fv9 o1RHI+c+QPnr8GXXriHYl0RTJBAxOXVY1sn9gqnbZaO55PbMuGa7bMax8JloFIOcoQA= X-Gm-Gg: AfdE7cmGi1LMiarqU4S2gZal3jMamMgqqKywW7ujBnIgkzshcgc7ii/tLZcTPTHgxlI xfiOV8IgqIPHH3GTN4IwaSdf6FvOGY2PF8tK5dKDS8R57YgaSRusRFLa+qVS/Xx11w1kL6RBlwT XAhA/yAeXU5rs/eonlflrKyBLlrb03FwAhSKEmXwgBGS1PIU5GRkpdjVF78hUA4pCTc6k1yYq8S bqi410RkCXI+dBIz3znHNuzPa4JHBfQ0yD7vJeaeIm8Bv9g1LMSwgeDzcWvjzCd5fYgiPC14/M2 gThVznD5bWfGCo7XszwIg8sq0XzwODqY8CqDuxivSLqq4hkOn/Wvy9FZ7WYA06VWkhI+8VAKj6x uvyyLSTxadQ3I7FsBCh8U/nFWufSmvwIIYwu22TeLAp/BCVjWjS5nNy6msJOSZxrpt+yptUaidC k5WA61JPWxpqTZHAdJ04zsTNbU/1LGK/zw86en8qtju9Xqqk5f+TrMbwO0ESIFa1xIPOuKLue1q sk= X-Received: by 2002:a05:600c:4709:b0:490:b7e6:bd1d with SMTP id 5b1f17b1804b1-493e689c16dmr28929185e9.16.1783522162862; Wed, 08 Jul 2026 07:49:22 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:22 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:53 +0100 Subject: [PATCH v3 17/20] media: imx355: Compute link frequency from PLL setup 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: <20260708-media-imx355-v3-17-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 In preparation for additional options in the PLL setup, compute the link frequency rather than using a hardcoded value. Signed-off-by: Dave Stevenson --- drivers/media/i2c/imx355.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index 6a779d700a4b..e45d60d665a1 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -29,7 +29,11 @@ =20 /* PLL registers that depend on the external clock frequency */ #define IMX355_REG_EXTCLK_FREQ CCI_REG16(0x0136) +#define IMX355_REG_PLL_OP_PREDIV CCI_REG8(0x030d) #define IMX355_REG_PLL_OP_MUL CCI_REG16(0x030e) +#define IMX355_REG_PLL_IVT_PCK_DIV CCI_REG8(0x0301) +#define IMX355_PLL_OP_PREDIV 2 +#define IMX355_PLL_IVT_PCK_DIV 5 =20 /* V_TIMING internal */ #define IMX355_REG_FLL CCI_REG16(0x0340) @@ -83,9 +87,6 @@ /* Flip Control */ #define IMX355_REG_ORIENTATION CCI_REG8(0x0101) =20 -/* default link frequency and external clock */ -#define IMX355_LINK_FREQ_DEFAULT 360000000LL - /* number of data lanes */ #define IMX355_DATA_LANES 4 =20 @@ -141,6 +142,7 @@ static const struct imx355_clk_params imx355_clk_params= [] =3D { }; =20 struct imx355_hwcfg { + s64 link_freq_menu; unsigned long link_freq_bitmap; }; =20 @@ -238,13 +240,13 @@ static const struct cci_reg_sequence imx355_global_re= gs[] =3D { { CCI_REG8(0x0112), 0x0a }, { CCI_REG8(0x0113), 0x0a }, { CCI_REG8(0x0114), 0x03 }, - { CCI_REG8(0x0301), 0x05 }, + { IMX355_REG_PLL_IVT_PCK_DIV, IMX355_PLL_IVT_PCK_DIV }, { CCI_REG8(0x0303), 0x01 }, { CCI_REG8(0x0305), 0x02 }, { CCI_REG8(0x0306), 0x00 }, { CCI_REG8(0x0307), 0x78 }, { CCI_REG8(0x030b), 0x01 }, - { CCI_REG8(0x030d), 0x02 }, + { IMX355_REG_PLL_OP_PREDIV, IMX355_PLL_OP_PREDIV }, { CCI_REG8(0x0310), 0x00 }, { CCI_REG8(0x0220), 0x00 }, { CCI_REG8(0x0222), 0x01 }, @@ -338,14 +340,6 @@ static const char * const imx355_test_pattern_menu[] = =3D { "Pseudorandom Sequence (PN9)", }; =20 -/* - * When adding more than the one below, make sure the disallowed ones will - * actually be disabled in the LINK_FREQ control. - */ -static const s64 link_freq_menu_items[] =3D { - IMX355_LINK_FREQ_DEFAULT, -}; - /* Mode configs */ static const struct imx355_mode supported_modes[] =3D { { @@ -1091,7 +1085,6 @@ static int imx355_init_controls(struct imx355 *imx355) s64 hblank; u64 pixel_rate; const struct imx355_mode *mode; - u32 max; int ret; =20 ctrl_hdlr =3D &imx355->ctrl_handler; @@ -1100,15 +1093,14 @@ static int imx355_init_controls(struct imx355 *imx3= 55) return ret; =20 ctrl_hdlr->lock =3D &imx355->mutex; - max =3D ARRAY_SIZE(link_freq_menu_items) - 1; imx355->link_freq =3D v4l2_ctrl_new_int_menu(ctrl_hdlr, &imx355_ctrl_ops, - V4L2_CID_LINK_FREQ, max, 0, - link_freq_menu_items); + V4L2_CID_LINK_FREQ, 0, 0, + &imx355->hwcfg->link_freq_menu); if (imx355->link_freq) imx355->link_freq->flags |=3D V4L2_CTRL_FLAG_READ_ONLY; =20 /* pixel_rate =3D link_freq * 2 * nr_of_lanes / bits_per_sample */ - pixel_rate =3D IMX355_LINK_FREQ_DEFAULT * 2 * 4; + pixel_rate =3D imx355->hwcfg->link_freq_menu * 2 * 4; do_div(pixel_rate, 10); /* By default, PIXEL_RATE is read only */ v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops, V4L2_CID_PIXEL_RATE, @@ -1183,12 +1175,14 @@ static int imx355_init_controls(struct imx355 *imx3= 55) return ret; } =20 -static struct imx355_hwcfg *imx355_get_hwcfg(struct device *dev) +static struct imx355_hwcfg *imx355_get_hwcfg(struct imx355 *imx355) { + struct device *dev =3D imx355->dev; struct imx355_hwcfg *cfg; struct v4l2_fwnode_endpoint bus_cfg =3D { .bus_type =3D V4L2_MBUS_CSI2_DPHY }; + const struct imx355_clk_params *clk =3D imx355->clk_params; struct fwnode_handle *ep; struct fwnode_handle *fwnode =3D dev_fwnode(dev); int ret; @@ -1211,10 +1205,11 @@ static struct imx355_hwcfg *imx355_get_hwcfg(struct= device *dev) if (bus_cfg.bus.mipi_csi2.num_data_lanes !=3D IMX355_DATA_LANES) goto out_err; =20 + cfg->link_freq_menu =3D (clk->ext_clk * clk->pll_op_mpy) / + (IMX355_PLL_OP_PREDIV * 2); ret =3D v4l2_link_freq_to_bitmap(dev, bus_cfg.link_frequencies, bus_cfg.nr_of_link_frequencies, - link_freq_menu_items, - ARRAY_SIZE(link_freq_menu_items), + &cfg->link_freq_menu, 1, &cfg->link_freq_bitmap); if (ret) goto out_err; @@ -1285,7 +1280,7 @@ static int imx355_probe(struct i2c_client *client) /* Initialize subdev */ v4l2_i2c_subdev_init(&imx355->sd, client, &imx355_subdev_ops); =20 - imx355->hwcfg =3D imx355_get_hwcfg(imx355->dev); + imx355->hwcfg =3D imx355_get_hwcfg(imx355); if (!imx355->hwcfg) { dev_err(imx355->dev, "failed to get hwcfg"); ret =3D -ENODEV; --=20 2.34.1 From nobody Mon Jul 27 11:00:15 2026 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 9551044CAEA for ; Wed, 8 Jul 2026 14:49:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522177; cv=none; b=B2gtzc6KBmZ9F8f/45Qtrmqz0zeESStxnSRznLSYEqZGxd8QkxKLHPu9o2MoGTgKQQaaLE9g/niOtrwDaYUIsPj2X1El9324F3WsYTfiQd7yvRym/DnvI10R2PTPZLXTPM/AMD7T0asyuWhkKd4fb3n+0JNR2HdS/imMu+hwlfw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522177; c=relaxed/simple; bh=EC2k5Q0O6GiAWVyB1n2jyIk0jzm5yjtUjDUXeFdZxaI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VMX0vllGoi75maM0ptlxxBOFqqgPkQ7YzFzD1Rz+Mg012QwmTsBBZEVsonBFWwf0kXa1U9F/ph2Hcsd5HS5lV+apo7hzUE43IUI1CBg2hfK1VDdb8gx7YqX12IIfML1C9c8c8L2C/u079hm2Yk0yiT+sSGZF3bwX8lcexcFDvQ8= 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=HCTXw/hv; arc=none smtp.client-ip=209.85.128.52 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="HCTXw/hv" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-493d1e8aa46so6033635e9.0 for ; Wed, 08 Jul 2026 07:49:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522163; x=1784126963; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=B9fBhGmPu1qXjzzF9oDlHeeaawJIqqZK7Ydx3tiH29k=; b=HCTXw/hvzseypO2Ydyem0fWhnDrNTa+yB351tN4nMG5EJw7moe9lpq2iod4Iy4XOQh wq+lrcIXXh1Of8Lbb3aBYT0lA7dJzLNF2BPlCv0DZ37Aqtg2OXbI9EXZjIvjDuv0LZlB C/kHourHdM3WGzf4O7+VqKm8nNZACij+2Lnn0XYfsGfcICzZh47hs0bWsqSZWXpb0uZf A/upbLihrAdsrrgt+HAhBgViIMw17eIjaa2apgUOFDljd87gKO6O4I6TiR/OWwHcAQlg vAAjnXzbJtTdpBkiSxzRgLtWhigozEfaI59mg4j11XQdlKd0a4lBx+D5ikSm1Bv2+qfx idtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522163; x=1784126963; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=B9fBhGmPu1qXjzzF9oDlHeeaawJIqqZK7Ydx3tiH29k=; b=iXIU7ClW8t4DXm65yFOlCcyEnZ8vlCHtOagaCn5ftx1MYCJlviaCuOTfzrJ945f1xl fNo4hKo0xUkD7AN629SU8ptTgehAIex1CZYQ2lodYYODKqP5N8sxzqJFMSGDNtKR1Ynv Rk/ira5M701ZQ7ZLQDXktMD9X/PCVltSaNaitZUeXutR3/U67ZerZAap2JZPv00cBl8i iFsr5dnVm2DqzmQVWWwUEuZtxoy41q9ihAjuofxOS8usTkdOeCFUWUQGsmhSt86f+4My w2YZN1vcbz9zriJOAsr33OfX41Xow8YeecvBaEZYtQq3a/Y2OApkNG/WTSP47dlyzVh0 qLFQ== X-Forwarded-Encrypted: i=1; AHgh+RpzX/G7Ad5JEy96vly/3AhWN2OgaEAynmNRFNtkAtkEspNU1w8GEQ+r67VnEYfe93NvLtyKj4KtkA+PP+s=@vger.kernel.org X-Gm-Message-State: AOJu0YxNUGyLM0k84OA+L/D7OhoB7+1TNKM//2fZlJgVO+R+nu91xjvT lm6cWRK6LX86KfK7PIqazv7f3ho6/PUctwMavn/3WgHtKJe+SQYhtaiMKvzCdL4lyiU= X-Gm-Gg: AfdE7clEgFrXDHGK6g9nrcKWjdVBBXFerh7ib3V8ZNauy/j4ys7h33knrg0dgdsASrj MncnGUdtxCNABC+yZWSO281YfxpyB4NsTk7yQAD7YZHSU9vH3+YGUnOu5fnX5Zm2n9ETlSTunFw 7VQLc+yAek9RYxBlX4OGbrM2odWsi6r4m35Dxlg9iaA7wyBEKiaeMuNXCvQp3LGpq37mMgbVDP2 vwFdfF0Hr/ADqsMk1ULVTpY63THBNAqmQaMBWztT2UPpK0bTrBW6TVvxvk9G8GaBiOaYRQJGGT9 8OBkS4xaY7CxhdQg3GeNkVT6ivoearDPKcgWXOEHaNJminLxH1Z2dOK7Ck2l/0tLaiq4y2doZp8 PWpXN6iNKKAI9j0sdtafCP75RJdFHGRwZX6kVel+fOn4L9OyuMMMwg2EzWlBY2e/w7bvJTJaHrw xyVcqOJWnO564c1Ble/U/OSvOJgNTaDgg2Rtr3zUp9AwEYH0pw8s/W8Lq8CbI/TQrnPgRdPThuz vs= X-Received: by 2002:a05:600c:8a16:10b0:493:bef8:ba8 with SMTP id 5b1f17b1804b1-493e68fc32amr24755525e9.39.1783522163580; Wed, 08 Jul 2026 07:49:23 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:23 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:54 +0100 Subject: [PATCH v3 18/20] media: imx355: Support 2 lane readout 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: <20260708-media-imx355-v3-18-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 The sensor supports 2 or 4 lane readout, but the driver only allowed for 4 lanes. Add 2 lane support. The clock tree only supports single PLL mode to feed both IOP (MIPI) and IVT (Pixel array). 2 lane mode supports a MIPI link frequency of up to 445MHz (890Mbit/s) cf 360MHz (720Mbit/s) for 4lane. Update clock setup and pixel rates to match. Signed-off-by: Dave Stevenson --- drivers/media/i2c/imx355.c | 67 +++++++++++++++++++++++++++++++++---------= ---- 1 file changed, 48 insertions(+), 19 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index e45d60d665a1..2be665b5b453 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -27,11 +27,14 @@ #define IMX355_REG_CHIP_ID CCI_REG16(0x0016) #define IMX355_CHIP_ID 0x0355 =20 +#define IMX355_REG_LANE_SEL CCI_REG8(0x0114) + /* PLL registers that depend on the external clock frequency */ #define IMX355_REG_EXTCLK_FREQ CCI_REG16(0x0136) #define IMX355_REG_PLL_OP_PREDIV CCI_REG8(0x030d) #define IMX355_REG_PLL_OP_MUL CCI_REG16(0x030e) #define IMX355_REG_PLL_IVT_PCK_DIV CCI_REG8(0x0301) +#define IMX355_REG_PLL_IVT_SYSCK_DIV CCI_REG8(0x0303) #define IMX355_PLL_OP_PREDIV 2 #define IMX355_PLL_IVT_PCK_DIV 5 =20 @@ -80,6 +83,8 @@ #define IMX355_TEST_PATTERN_GRAY_COLOR_BARS 3 #define IMX355_TEST_PATTERN_PN9 4 =20 +#define IMX355_REG_REQ_LINK_BIT_RATE CCI_REG16(0x0820) + #define IMX355_REG_BINNING_MODE CCI_REG8(0x0900) #define IMX355_REG_BINNING_TYPE CCI_REG8(0x0901) #define IMX355_REG_BINNING_WEIGHTING CCI_REG8(0x0902) @@ -87,9 +92,6 @@ /* Flip Control */ #define IMX355_REG_ORIENTATION CCI_REG8(0x0101) =20 -/* number of data lanes */ -#define IMX355_DATA_LANES 4 - #define IMX355_PIXEL_ARRAY_TOP 0 #define IMX355_PIXEL_ARRAY_LEFT 0 #define IMX355_PIXEL_ARRAY_WIDTH 3280 @@ -120,30 +122,38 @@ struct imx355_mode { =20 struct imx355_clk_params { u32 ext_clk; - u16 extclk_freq; /* External clock (MHz) in 8.8 fixed point) */ - u16 pll_op_mpy; /* OP system PLL multiplier */ + u16 extclk_freq; /* External clock (MHz) in 8.8 fixed point) */ + u16 pll_op_mpy[2]; /* OP system PLL multiplier */ + u8 pll_op_prediv[2]; /* OP system pre PLL d */ }; =20 /* * The clock tree is in single PLL mode, so PREDIV_VT and MPY_IVT do nothi= ng. - * All modes use the same PLL setup for OP, with IOPCK being 720MHz. + * In 4 lane mode the MIPI rate is 360Mhz (720Mbit/s) and pixel rate is + * 288MPix/s. + * In 2 lane mode the MIPI rate is 444MHz (888Mbit/s) and pixel rate + * 177.6MPix/s with a 24MHz clock, and 441.6MHz (883.2Mbit/s) and 176.6MPi= x/s + * with a 19.2MHz clock. */ static const struct imx355_clk_params imx355_clk_params[] =3D { { .ext_clk =3D 19200000, - .extclk_freq =3D 0x1333, /* 19.2 MHz */ - .pll_op_mpy =3D 75, /* 19.2 / 2 * 75 =3D 720 MHz */ + .extclk_freq =3D 0x1333, + .pll_op_mpy =3D { 75, 92 }, + .pll_op_prediv =3D { 2, 2 } }, { .ext_clk =3D 24000000, - .extclk_freq =3D 0x1800, /* 24.0 MHz */ - .pll_op_mpy =3D 60, /* 24.0 / 2 * 60 =3D 720 MHz */ + .extclk_freq =3D 0x1800, + .pll_op_mpy =3D { 60, 111 }, + .pll_op_prediv =3D { 2, 3 } }, }; =20 struct imx355_hwcfg { s64 link_freq_menu; unsigned long link_freq_bitmap; + unsigned int num_lanes; }; =20 struct imx355 { @@ -239,7 +249,6 @@ static const struct cci_reg_sequence imx355_global_regs= [] =3D { { CCI_REG8(0x305a), 0x00 }, { CCI_REG8(0x0112), 0x0a }, { CCI_REG8(0x0113), 0x0a }, - { CCI_REG8(0x0114), 0x03 }, { IMX355_REG_PLL_IVT_PCK_DIV, IMX355_PLL_IVT_PCK_DIV }, { CCI_REG8(0x0303), 0x01 }, { CCI_REG8(0x0305), 0x02 }, @@ -250,8 +259,6 @@ static const struct cci_reg_sequence imx355_global_regs= [] =3D { { CCI_REG8(0x0310), 0x00 }, { CCI_REG8(0x0220), 0x00 }, { CCI_REG8(0x0222), 0x01 }, - { CCI_REG8(0x0820), 0x0b }, - { CCI_REG8(0x0821), 0x40 }, { CCI_REG8(0x3088), 0x04 }, { CCI_REG8(0x6813), 0x02 }, { CCI_REG8(0x6835), 0x07 }, @@ -816,6 +823,7 @@ imx355_set_pad_format(struct v4l2_subdev *sd, __v4l2_ctrl_modify_range(imx355->vblank, IMX355_VBLANK_MIN, height, 1, vblank_def); __v4l2_ctrl_s_ctrl(imx355->vblank, vblank_def); + h_blank =3D mode->llp - imx355->cur_mode->width; /* * Currently hblank is not changeable. @@ -879,6 +887,8 @@ static int imx355_start_streaming(struct imx355 *imx355) { const struct imx355_reg_list *reg_list; const struct imx355_mode *mode; + int lane_idx =3D imx355->hwcfg->num_lanes =3D=3D 4 ? 0 : 1; + u64 link_bitrate; u8 binning_mode; int ret =3D 0; =20 @@ -914,7 +924,21 @@ static int imx355_start_streaming(struct imx355 *imx35= 5) cci_write(imx355->regmap, IMX355_REG_EXTCLK_FREQ, imx355->clk_params->extclk_freq, &ret); cci_write(imx355->regmap, IMX355_REG_PLL_OP_MUL, - imx355->clk_params->pll_op_mpy, &ret); + imx355->clk_params->pll_op_mpy[lane_idx], &ret); + cci_write(imx355->regmap, IMX355_REG_PLL_OP_PREDIV, + imx355->clk_params->pll_op_prediv[lane_idx], &ret); + cci_write(imx355->regmap, IMX355_REG_PLL_IVT_SYSCK_DIV, + lane_idx ? 2 : 1, &ret); + + /* Set MIPI configuration */ + cci_write(imx355->regmap, IMX355_REG_LANE_SEL, + imx355->hwcfg->num_lanes - 1, &ret); + + link_bitrate =3D imx355->link_freq->qmenu_int[imx355->link_freq->val] * + imx355->hwcfg->num_lanes * 2; + do_div(link_bitrate, 1000000); + cci_write(imx355->regmap, IMX355_REG_REQ_LINK_BIT_RATE, link_bitrate, + &ret); =20 /* set digital gain control to all color mode */ cci_write(imx355->regmap, IMX355_REG_DPGA_USE_GLOBAL_GAIN, 1, &ret); @@ -1100,9 +1124,9 @@ static int imx355_init_controls(struct imx355 *imx355) imx355->link_freq->flags |=3D V4L2_CTRL_FLAG_READ_ONLY; =20 /* pixel_rate =3D link_freq * 2 * nr_of_lanes / bits_per_sample */ - pixel_rate =3D imx355->hwcfg->link_freq_menu * 2 * 4; + pixel_rate =3D imx355->hwcfg->link_freq_menu * 2 * imx355->hwcfg->num_lan= es; do_div(pixel_rate, 10); - /* By default, PIXEL_RATE is read only */ + v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops, V4L2_CID_PIXEL_RATE, pixel_rate, pixel_rate, 1, pixel_rate); =20 @@ -1185,6 +1209,7 @@ static struct imx355_hwcfg *imx355_get_hwcfg(struct i= mx355 *imx355) const struct imx355_clk_params *clk =3D imx355->clk_params; struct fwnode_handle *ep; struct fwnode_handle *fwnode =3D dev_fwnode(dev); + int lane_idx; int ret; =20 if (!fwnode) @@ -1202,11 +1227,15 @@ static struct imx355_hwcfg *imx355_get_hwcfg(struct= imx355 *imx355) if (!cfg) goto out_err; =20 - if (bus_cfg.bus.mipi_csi2.num_data_lanes !=3D IMX355_DATA_LANES) + if (bus_cfg.bus.mipi_csi2.num_data_lanes !=3D 2 && + bus_cfg.bus.mipi_csi2.num_data_lanes !=3D 4) goto out_err; =20 - cfg->link_freq_menu =3D (clk->ext_clk * clk->pll_op_mpy) / - (IMX355_PLL_OP_PREDIV * 2); + cfg->num_lanes =3D bus_cfg.bus.mipi_csi2.num_data_lanes; + + lane_idx =3D cfg->num_lanes =3D=3D 4 ? 0 : 1; + cfg->link_freq_menu =3D (clk->ext_clk * clk->pll_op_mpy[lane_idx]) / + (clk->pll_op_prediv[lane_idx] * 2); ret =3D v4l2_link_freq_to_bitmap(dev, bus_cfg.link_frequencies, bus_cfg.nr_of_link_frequencies, &cfg->link_freq_menu, 1, --=20 2.34.1 From nobody Mon Jul 27 11:00:15 2026 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 50DBF3D9695 for ; Wed, 8 Jul 2026 14:49:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522177; cv=none; b=S25apL8GifbpHJ/XEyhUxpaiD1BjWKRvb6jqT7ZvWPpI0sdDCV+O4Rx9MqF4vLKU+YOe494asH07n6IJ4VS2QO/gpRrKHSHUqJpTn/vVzil92wJ2bwGcVF9FRKGYLHKOVuqlCLOSgrpc6qeTClZUPfvWZT7TQ3+t1wEkWFL3YnM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522177; c=relaxed/simple; bh=Bz7eJTYlg7hqzpgB6a7cBQj2bdP5kz+HsAA3ZbNHcBo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=i32SoQqt3fUBXmzBSbISEYzwMQTWKpv40FWjQv3bI8GJPA5ESFEVOGISJVT4gufyRur2YZ/EmblCu01F9I2p7XY6FFRHcDF3cnYRoAZWVamfMc4Qi3K/pUVbaRI0yGZ8gpN7dmUFZJTmhXZxPy20WysXfa3OTOwO0N8FjVBi4Nw= 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=S3WrMUSs; arc=none smtp.client-ip=209.85.128.53 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="S3WrMUSs" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-493bb510ce4so5404765e9.1 for ; Wed, 08 Jul 2026 07:49:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522164; x=1784126964; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=xu15ctzjcOqhJZV80dUKUk3i6OKtSm5BmBQWERl2TsU=; b=S3WrMUSsr6NF7NSraftk3R3Sb2pCyRBCHoFARhJVHZ4heQgY0XNg7e1JXs8ArhLae/ CT4W/kfy/IlkJjmjTpWGSQZTsV3+2xNCG7pHm5KbdIZmN7W9cLXk47okdzFpDADgi0Jl sIb9KAGnyeyrcuVkOVAWAtn3XSsQCcoRq6Rc2k5VzGDUxYCsGleZ58MZwvFOdlAUZnRk e6QBkAvVogl+tNV2KECu6aUfVuD+7IqpowYJROgS6/nwxQVHVdNdCkmo0bcsx0z8DYF2 1K+vWvF3jJ8UV7C6vaNv05/Pd9fe2r8pw5fXzlN07DLil/J2U25FepqbtoUuXs3dXTj4 NNFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522164; x=1784126964; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=xu15ctzjcOqhJZV80dUKUk3i6OKtSm5BmBQWERl2TsU=; b=Ux0ofoD8wbmUer7XqCBRtFTh2ZqSm7Qy9CRyHr3wjOrGtxw2lEjZq301RyUdrSWht+ GNuv2udK6xrGRP9TDNT1k73EOt72SEE68tWTKeEnOeF/IISB1CSH1ppldFam4SPoG1TB 5LXrIj54vX/Ker62FW1ExfIinfmgVzR3Jq8wLXnDnVKQPgE3MqwrwsTookhyNtgt1Qwe H66BcEZsywo3qwdYNcyBhOjA6B4Fg/xdIvcTawwjcCrgiQV9b0u8v1FNw/SjwxpBs3SS Ieq89pF/t4PDO1jgaNkjkNKwxSOpKRqjCv9QfK3XGHvW5wAa/sX5/bYBs9WWOMK7EuYm 710g== X-Forwarded-Encrypted: i=1; AHgh+RpZ8JvE9TNJT0gKUV8vlh8d3cjB+CrHNF1x5ECW+yfDzvZ8824kEbyQwNxQ8AYsNh31x16dwm8AgSc1bWc=@vger.kernel.org X-Gm-Message-State: AOJu0YwZ9iqKbY3rhAICbHOswo8YrxJaY70XlKf+vY0/mkWGP6UKJnKX Ysr9Cv0OXIlgvqw/a3MRJx6Uzi7FgXsO0Q+Y/Wk4pw7lDdYvHJHOWSWHrX9oGk0mu9M= X-Gm-Gg: AfdE7cnHqMYkOVTgfhg6gooavaajuZG0SXL22IZl1ynT9Gj6L0P+2biugD0t8/n9lEp vtwWQ+ou89WvbXoovygbP97E69Rv2vcw56/t9ZCs7nhdxAHhfxGJMDiKhrfDVrZ4ewv2VQM64K/ B+3fT1WnLLdxIcVr0Y3yH4i8pW2yc1e3e/vGDz+9viqcywvapGvPvaL/y13Z0flfdo7LKLpAggf 88aeYJM1BTqdebH966OaJIh2lFfLYyR2B37jB6GFPffAMVRuS37OHXuE4j66aPS/HdCP4A+Vdkq qyP+mR/6yVEb+qFRwBjtOXvyZhJEbBN6a79W00lmepmZWA6htc0ExiZQPLB8mDNcV8amGPqnonQ D6VAsVmjRPlbUCHXUr3HbyUH3xEfR8gPwyV3OXQSFcADJyKkrNWmJH088TI/bJu7XjM+xioArSb 8EFbYemMq5d3oUmRXWqUaIjN7z4uZUaKRN0pAjP6s3Thikf94oW9Ax/uu6T7ohYfpx X-Received: by 2002:a05:600c:4505:b0:493:bfea:2780 with SMTP id 5b1f17b1804b1-493e68b83aemr31299685e9.9.1783522164323; Wed, 08 Jul 2026 07:49:24 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:23 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:55 +0100 Subject: [PATCH v3 19/20] media: imx355: Switch to using the subdev state 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: <20260708-media-imx355-v3-19-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 The subdev state is now preferred rather than handling crop and format within the driver state, so switch the driver to using it. Signed-off-by: Dave Stevenson --- drivers/media/i2c/imx355.c | 180 +++++++++++++----------------------------= ---- 1 file changed, 50 insertions(+), 130 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index 2be665b5b453..ee012efe25bf 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -179,13 +179,6 @@ struct imx355 { struct imx355_hwcfg *hwcfg; const struct imx355_clk_params *clk_params; =20 - /* - * Mutex for serialized access: - * Protect sensor set pad format and start/stop streaming safely. - * Protect access to sensor v4l2 controls. - */ - struct mutex mutex; - struct gpio_desc *reset_gpio; struct regulator_bulk_data *supplies; }; @@ -593,46 +586,23 @@ static u32 imx355_get_format_code(struct imx355 *imx3= 55) { MEDIA_BUS_FMT_SGBRG10_1X10, MEDIA_BUS_FMT_SBGGR10_1X10, }, }; =20 - lockdep_assert_held(&imx355->mutex); code =3D codes[imx355->vflip->val][imx355->hflip->val]; =20 return code; } =20 -/* Open sub-device */ -static int imx355_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) -{ - struct imx355 *imx355 =3D to_imx355(sd); - struct v4l2_mbus_framefmt *try_fmt =3D - v4l2_subdev_state_get_format(fh->state, 0); - struct v4l2_rect *crop =3D v4l2_subdev_state_get_crop(fh->state, 0); - - mutex_lock(&imx355->mutex); - - /* Initialize try_fmt */ - try_fmt->width =3D imx355->cur_mode->width; - try_fmt->height =3D imx355->cur_mode->height; - try_fmt->code =3D imx355_get_format_code(imx355); - try_fmt->field =3D V4L2_FIELD_NONE; - try_fmt->format.colorspace =3D V4L2_COLORSPACE_RAW; - try_fmt->format.ycbcr_enc =3D V4L2_YCBCR_ENC_601; - try_fmt->format.quantization =3D V4L2_QUANTIZATION_FULL_RANGE; - try_fmt->format.xfer_func =3D V4L2_XFER_FUNC_NONE; - - *crop =3D imx355->cur_mode->crop; - - mutex_unlock(&imx355->mutex); - - return 0; -} - static int imx355_set_ctrl(struct v4l2_ctrl *ctrl) { struct imx355 *imx355 =3D container_of(ctrl->handler, struct imx355, ctrl_handler); + const struct v4l2_mbus_framefmt *format =3D NULL; + struct v4l2_subdev_state *state; s64 max; int ret; =20 + state =3D v4l2_subdev_get_locked_active_state(&imx355->sd); + format =3D v4l2_subdev_state_get_format(state, 0); + /* Propagate change of current control to all related controls */ switch (ctrl->id) { case V4L2_CID_VBLANK: @@ -705,9 +675,7 @@ static int imx355_enum_mbus_code(struct v4l2_subdev *sd, if (code->index > 0) return -EINVAL; =20 - mutex_lock(&imx355->mutex); code->code =3D imx355_get_format_code(imx355); - mutex_unlock(&imx355->mutex); =20 return 0; } @@ -721,12 +689,9 @@ static int imx355_enum_frame_size(struct v4l2_subdev *= sd, if (fse->index >=3D ARRAY_SIZE(supported_modes)) return -EINVAL; =20 - mutex_lock(&imx355->mutex); if (fse->code !=3D imx355_get_format_code(imx355)) { - mutex_unlock(&imx355->mutex); return -EINVAL; } - mutex_unlock(&imx355->mutex); =20 fse->min_width =3D supported_modes[fse->index].width; fse->max_width =3D fse->min_width; @@ -750,36 +715,6 @@ static void imx355_update_pad_format(struct imx355 *im= x355, fmt->format.xfer_func =3D V4L2_XFER_FUNC_NONE; } =20 -static int imx355_do_get_pad_format(struct imx355 *imx355, - struct v4l2_subdev_state *sd_state, - struct v4l2_subdev_format *fmt) -{ - struct v4l2_mbus_framefmt *framefmt; - - if (fmt->which =3D=3D V4L2_SUBDEV_FORMAT_TRY) { - framefmt =3D v4l2_subdev_state_get_format(sd_state, fmt->pad); - fmt->format =3D *framefmt; - } else { - imx355_update_pad_format(imx355, imx355->cur_mode, fmt); - } - - return 0; -} - -static int imx355_get_pad_format(struct v4l2_subdev *sd, - struct v4l2_subdev_state *sd_state, - struct v4l2_subdev_format *fmt) -{ - struct imx355 *imx355 =3D to_imx355(sd); - int ret; - - mutex_lock(&imx355->mutex); - ret =3D imx355_do_get_pad_format(imx355, sd_state, fmt); - mutex_unlock(&imx355->mutex); - - return ret; -} - static int imx355_set_pad_format(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, @@ -788,12 +723,11 @@ imx355_set_pad_format(struct v4l2_subdev *sd, struct imx355 *imx355 =3D to_imx355(sd); const struct imx355_mode *mode; struct v4l2_mbus_framefmt *framefmt; + struct v4l2_rect *crop; s32 vblank_def; s64 h_blank; u32 height; =20 - mutex_lock(&imx355->mutex); - /* * Only one bayer order is supported. * It depends on the flip settings. @@ -805,16 +739,17 @@ imx355_set_pad_format(struct v4l2_subdev *sd, width, height, fmt->format.width, fmt->format.height); imx355_update_pad_format(imx355, mode, fmt); - if (fmt->which =3D=3D V4L2_SUBDEV_FORMAT_TRY) { - framefmt =3D v4l2_subdev_state_get_format(sd_state, fmt->pad); - *framefmt =3D fmt->format; - - crop =3D v4l2_subdev_state_get_crop(sd_state, 0); - crop->width =3D mode->crop.width; - crop->height =3D mode->crop.height; - crop->left =3D mode->crop.left; - crop->top =3D mode->crop.top; - } else { + framefmt =3D v4l2_subdev_state_get_format(sd_state, 0); + + *framefmt =3D fmt->format; + + crop =3D v4l2_subdev_state_get_crop(sd_state, 0); + crop->width =3D mode->crop.width; + crop->height =3D mode->crop.height; + crop->left =3D mode->crop.left; + crop->top =3D mode->crop.top; + + if (fmt->which =3D=3D V4L2_SUBDEV_FORMAT_ACTIVE) { imx355->cur_mode =3D mode; /* Update limits and set FPS to default */ height =3D imx355->cur_mode->height; @@ -833,41 +768,17 @@ imx355_set_pad_format(struct v4l2_subdev *sd, h_blank, 1, h_blank); } =20 - mutex_unlock(&imx355->mutex); - return 0; } =20 -static void -__imx355_get_pad_crop(struct imx355 *imx355, - struct v4l2_subdev_state *sd_state, unsigned int pad, - enum v4l2_subdev_format_whence which, struct v4l2_rect *r) -{ - switch (which) { - case V4L2_SUBDEV_FORMAT_TRY: - *r =3D *v4l2_subdev_state_get_crop(sd_state, pad); - break; - case V4L2_SUBDEV_FORMAT_ACTIVE: - *r =3D imx355->cur_mode->crop; - break; - } -} - static int imx355_get_selection(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_selection *sel) { switch (sel->target) { - case V4L2_SEL_TGT_CROP: { - struct imx355 *imx355 =3D to_imx355(sd); - - mutex_lock(&imx355->mutex); - __imx355_get_pad_crop(imx355, sd_state, sel->pad, sel->which, - &sel->r); - mutex_unlock(&imx355->mutex); - + case V4L2_SEL_TGT_CROP: + sel->r =3D *v4l2_subdev_state_get_crop(sd_state, 0); return 0; - } case V4L2_SEL_TGT_CROP_DEFAULT: case V4L2_SEL_TGT_CROP_BOUNDS: case V4L2_SEL_TGT_NATIVE_SIZE: @@ -882,6 +793,21 @@ static int imx355_get_selection(struct v4l2_subdev *sd, return -EINVAL; } =20 +static int imx355_entity_init_state(struct v4l2_subdev *subdev, + struct v4l2_subdev_state *sd_state) +{ + struct v4l2_subdev_format fmt =3D { }; + + fmt.which =3D sd_state ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTI= VE; + fmt.format.code =3D MEDIA_BUS_FMT_SRGGB10_1X10; + fmt.format.width =3D supported_modes[0].width; + fmt.format.height =3D supported_modes[0].height; + + imx355_set_pad_format(subdev, sd_state, &fmt); + + return 0; +} + /* Start streaming */ static int imx355_start_streaming(struct imx355 *imx355) { @@ -969,12 +895,10 @@ static int imx355_set_stream(struct v4l2_subdev *sd, = int enable) struct imx355 *imx355 =3D to_imx355(sd); int ret =3D 0; =20 - mutex_lock(&imx355->mutex); - if (enable) { ret =3D pm_runtime_resume_and_get(imx355->dev); if (ret < 0) - goto err_unlock; + return ret; =20 /* * Apply default & customized values @@ -992,14 +916,10 @@ static int imx355_set_stream(struct v4l2_subdev *sd, = int enable) __v4l2_ctrl_grab(imx355->vflip, enable); __v4l2_ctrl_grab(imx355->hflip, enable); =20 - mutex_unlock(&imx355->mutex); - return ret; =20 err_rpm_put: pm_runtime_put_autosuspend(imx355->dev); -err_unlock: - mutex_unlock(&imx355->mutex); =20 return ret; } @@ -1033,7 +953,7 @@ static const struct v4l2_subdev_video_ops imx355_video= _ops =3D { =20 static const struct v4l2_subdev_pad_ops imx355_pad_ops =3D { .enum_mbus_code =3D imx355_enum_mbus_code, - .get_fmt =3D imx355_get_pad_format, + .get_fmt =3D v4l2_subdev_get_fmt, .set_fmt =3D imx355_set_pad_format, .enum_frame_size =3D imx355_enum_frame_size, .get_selection =3D imx355_get_selection, @@ -1050,7 +970,7 @@ static const struct media_entity_operations imx355_sub= dev_entity_ops =3D { }; =20 static const struct v4l2_subdev_internal_ops imx355_internal_ops =3D { - .open =3D imx355_open, + .init_state =3D imx355_entity_init_state, }; =20 static int imx355_power_off(struct device *dev) @@ -1116,7 +1036,6 @@ static int imx355_init_controls(struct imx355 *imx355) if (ret) return ret; =20 - ctrl_hdlr->lock =3D &imx355->mutex; imx355->link_freq =3D v4l2_ctrl_new_int_menu(ctrl_hdlr, &imx355_ctrl_ops, V4L2_CID_LINK_FREQ, 0, 0, &imx355->hwcfg->link_freq_menu); @@ -1265,8 +1184,6 @@ static int imx355_probe(struct i2c_client *client) =20 imx355->dev =3D &client->dev; =20 - mutex_init(&imx355->mutex); - imx355->regmap =3D devm_cci_regmap_init_i2c(client, 16); if (IS_ERR(imx355->regmap)) return dev_err_probe(imx355->dev, PTR_ERR(imx355->regmap), @@ -1295,7 +1212,7 @@ static int imx355_probe(struct i2c_client *client) &imx355->supplies); if (ret) { dev_err_probe(imx355->dev, ret, "could not get regulators"); - goto error_probe; + return ret; } =20 imx355->reset_gpio =3D devm_gpiod_get_optional(imx355->dev, "reset", @@ -1303,7 +1220,7 @@ static int imx355_probe(struct i2c_client *client) if (IS_ERR(imx355->reset_gpio)) { ret =3D dev_err_probe(imx355->dev, PTR_ERR(imx355->reset_gpio), "failed to get gpios"); - goto error_probe; + return ret; } =20 /* Initialize subdev */ @@ -1312,13 +1229,12 @@ static int imx355_probe(struct i2c_client *client) imx355->hwcfg =3D imx355_get_hwcfg(imx355); if (!imx355->hwcfg) { dev_err(imx355->dev, "failed to get hwcfg"); - ret =3D -ENODEV; - goto error_probe; + return -ENODEV; } =20 ret =3D imx355_power_on(imx355->dev); if (ret) - goto error_probe; + return ret; =20 /* Check module identity */ ret =3D imx355_identify_module(imx355); @@ -1351,6 +1267,13 @@ static int imx355_probe(struct i2c_client *client) goto error_handler_free; } =20 + imx355->sd.state_lock =3D imx355->ctrl_handler.lock; + ret =3D v4l2_subdev_init_finalize(&imx355->sd); + if (ret < 0) { + dev_err_probe(imx355->dev, ret, "subdev init error\n"); + goto error_handler_free; + } + /* * Device is already turned on by i2c-core with ACPI domain PM. * Enable runtime PM and turn off the device. @@ -1371,6 +1294,7 @@ static int imx355_probe(struct i2c_client *client) pm_runtime_disable(imx355->dev); pm_runtime_set_suspended(imx355->dev); pm_runtime_dont_use_autosuspend(imx355->dev); + v4l2_subdev_cleanup(&imx355->sd); media_entity_cleanup(&imx355->sd.entity); =20 error_handler_free: @@ -1379,9 +1303,6 @@ static int imx355_probe(struct i2c_client *client) error_power_off: imx355_power_off(imx355->dev); =20 -error_probe: - mutex_destroy(&imx355->mutex); - return ret; } =20 @@ -1391,6 +1312,7 @@ static void imx355_remove(struct i2c_client *client) struct imx355 *imx355 =3D to_imx355(sd); =20 v4l2_async_unregister_subdev(sd); + v4l2_subdev_cleanup(sd); media_entity_cleanup(&sd->entity); v4l2_ctrl_handler_free(sd->ctrl_handler); =20 @@ -1402,8 +1324,6 @@ static void imx355_remove(struct i2c_client *client) } =20 pm_runtime_dont_use_autosuspend(imx355->dev); - - mutex_destroy(&imx355->mutex); } =20 static const struct acpi_device_id imx355_acpi_ids[] __maybe_unused =3D { --=20 2.34.1 From nobody Mon Jul 27 11:00:15 2026 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 64DB0481A96 for ; Wed, 8 Jul 2026 14:49:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522176; cv=none; b=T1j4YQ/Ye3HJA4kfm83Ptkc9AII5/oT8DWoMt9wPlI4lcnF6VeR8LHB0jNkI6Rrz6CQ4AcnAM4/nFmnR+H7wNp+w8lWdopOF656JsiPpmFo3NNhphsSX0Sor8IMRWy7rVoxpp4LsywGS7gGG+rd15hBQ0WkCfunfe5T8Z/T18Yk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522176; c=relaxed/simple; bh=V7cfXfus1wMTH8uUlTulTCFw9RvrshHM+7AA6flR5yk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gPYaLo1WVnXQh1PMV9bAihV/1ibLxNfSW9RIdhQkYFIy9HWS+Lp2bvRXPeYwvS5XQYgPu+4AETDWlzYZJyGCnkdXhR9PtwuawTIjguW6j9xIauVeqF+QXx2UsMdzHsZgwv2pQjRDhXymdT/hVeYNb1LxPcjZDegwm8OfqA7dXwc= 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=gDL1S+W+; arc=none smtp.client-ip=209.85.128.43 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="gDL1S+W+" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-493e4cccd8dso3412665e9.2 for ; Wed, 08 Jul 2026 07:49:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522165; x=1784126965; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=zYXkUhjNUNGBxpm6qSdNLGjTwbO67Pooqx5qDG7FHec=; b=gDL1S+W+kVZMt3oTlU+dVDmIvstHM4u+kj3XUL9GiMAqnNuSfHGNeOUsowcuH4nUvB 3Qb2vo9O/tLB9WtI2wSPqZSNJofa5SAQYUyENOTtyAx/3H9KJbZv2s3ejkFyAtfQ94Jb h54JjGNeJ+ZBSkLT69OBnWp/rJ7v3zm+UBFLkmwpcg1M5PrLQ0/VGxL7TwZZ/HeAe8l4 wycXegyet3wbNh116hnEJyWtXV7eYeeMObNMUaHWtuRtWWurgj/ZWwaZVwJ1wxaPu6c6 q6KzFQf29p5SfDWiWYMrBso6qx1gX76aVujBCR+q4LkTqtyq868sb/jw9xUI8ag48wrj aJAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522165; x=1784126965; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=zYXkUhjNUNGBxpm6qSdNLGjTwbO67Pooqx5qDG7FHec=; b=f0DZZgRW6H3Q5M61nsY2kxAUra2Ar3GIdAiTuj8y7ayQkaLSc8eHhIrC7qA6cCkXgT Lbmc2PG2qjoO3wcUH6+uAV44ZEgE9RGsvXr/jnbvXMpaPiyWHQ34KA+Qyi+MWOZVjBlN cxO0aYTYTLJwzV15BwGoMGHcMCpidfhsDdvod5WLk9SqD7+haQwUXK/Xgguk0l2CxZmV TQYQrsOLGxYyiB7+tmRrlwiY5/tnjDoYvKzICFvl9w/9Y+L7CtvRg8dMp61TU9NLVu1x CxyqL6Zm55ZfE2DUGVjJwUd9DLe38Y6U/WtkydG40Cff9MOk8thrL0x6kkQli1E4SPvC R0KQ== X-Forwarded-Encrypted: i=1; AHgh+RreAs1s90vrORhtSKGiXmY/B+QQ20Fqrao3WJGKYjdK66GZJtGwmT3/FSbGzvmhbj+oiwpSfizPbx+qCjQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyaqNKH01c7FbtK6N9/kK4O7vFLkUN421tr6qlIhoyzYulMs2tH puu9//mKu1vWYCYVu4kkO7NFIou97SEYN5TlAd0dOw5z96HLM9pgnaW2L6/yOPEP2b4= X-Gm-Gg: AfdE7ckY4fV/bsOUhJevHYi2WfhiMhcna2OCOyRuKLu/PXXLeBKoGeqHrc0bBRIZbu9 tom7NjcvtOuI5DX6GZ+OVWLo0uGdJnkrsd/WIVm/TUsqz1fxhori6kkxR7LK93IBoUANJpEUiT/ GmcHMchv82x7ECUbsqvuf63Av3xGnC+S+aK3Rv9AbJAfN8l+RRkdAXAnDTQPZHI00/TDL+MKwP6 7TvkDCpAtsUVzBeyexG4+CDPL1pV0wJxtNA87VKXekJjv3fKCSYogDkWaxir4ThexbvbRQxbPvM cBc4rDzCIyVIRnRFONJwV1YwPJBkRrdl7upXrD3EI4HFvkkiN5z49pQcEWYnqTxKpaR+dIrwaZn PFnC5oSceTHbdi6Er7+5Lw1MT//r443o/oY4KnRdQ/qmsG384D0wUmR2mZC07rixyCbuUcGu6FX JDskIGs9hWjDHbAdcnPyHXbrtkh+L+pDhP5A2eeSya+km966JlE2v2S058dU/kwszy X-Received: by 2002:a05:600c:528c:b0:493:d21f:8f98 with SMTP id 5b1f17b1804b1-493e68de964mr30032775e9.36.1783522165093; Wed, 08 Jul 2026 07:49:25 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:24 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:56 +0100 Subject: [PATCH v3 20/20] media: imx355: Remove storing cur_mode in the state 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: <20260708-media-imx355-v3-20-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 All the information for the mode is now stored within the subdev state, so configure the sensor based on that. Signed-off-by: Dave Stevenson --- drivers/media/i2c/imx355.c | 66 ++++++++++++++++++++++--------------------= ---- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index ee012efe25bf..8e5eb5998591 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -173,9 +173,6 @@ struct imx355 { struct v4l2_ctrl *vflip; struct v4l2_ctrl *hflip; =20 - /* Current mode */ - const struct imx355_mode *cur_mode; - struct imx355_hwcfg *hwcfg; const struct imx355_clk_params *clk_params; =20 @@ -607,7 +604,7 @@ static int imx355_set_ctrl(struct v4l2_ctrl *ctrl) switch (ctrl->id) { case V4L2_CID_VBLANK: /* Update max exposure while meeting expected vblanking */ - max =3D imx355->cur_mode->height + ctrl->val - IMX355_EXPOSURE_OFFSET; + max =3D format->height + ctrl->val - IMX355_EXPOSURE_OFFSET; __v4l2_ctrl_modify_range(imx355->exposure, imx355->exposure->minimum, max, imx355->exposure->step, max); @@ -638,7 +635,7 @@ static int imx355_set_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_VBLANK: /* Update FLL that meets expected vertical blanking */ ret =3D cci_write(imx355->regmap, IMX355_REG_FLL, - imx355->cur_mode->height + ctrl->val, NULL); + format->height + ctrl->val, NULL); break; case V4L2_CID_TEST_PATTERN: ret =3D cci_write(imx355->regmap, IMX355_REG_TEST_PATTERN, @@ -724,9 +721,7 @@ imx355_set_pad_format(struct v4l2_subdev *sd, const struct imx355_mode *mode; struct v4l2_mbus_framefmt *framefmt; struct v4l2_rect *crop; - s32 vblank_def; s64 h_blank; - u32 height; =20 /* * Only one bayer order is supported. @@ -750,16 +745,14 @@ imx355_set_pad_format(struct v4l2_subdev *sd, crop->top =3D mode->crop.top; =20 if (fmt->which =3D=3D V4L2_SUBDEV_FORMAT_ACTIVE) { - imx355->cur_mode =3D mode; /* Update limits and set FPS to default */ - height =3D imx355->cur_mode->height; - vblank_def =3D imx355->cur_mode->fll_def - height; - height =3D IMX355_FLL_MAX - height; __v4l2_ctrl_modify_range(imx355->vblank, IMX355_VBLANK_MIN, - height, 1, vblank_def); - __v4l2_ctrl_s_ctrl(imx355->vblank, vblank_def); + IMX355_FLL_MAX - mode->height, 1, + mode->fll_def - mode->height); + __v4l2_ctrl_s_ctrl(imx355->vblank, mode->fll_def - mode->height); + + h_blank =3D mode->llp - mode->width; =20 - h_blank =3D mode->llp - imx355->cur_mode->width; /* * Currently hblank is not changeable. * So FPS control is done only by vblank. @@ -811,9 +804,11 @@ static int imx355_entity_init_state(struct v4l2_subdev= *subdev, /* Start streaming */ static int imx355_start_streaming(struct imx355 *imx355) { - const struct imx355_reg_list *reg_list; + const struct v4l2_mbus_framefmt *fmt; + struct v4l2_subdev_state *state; const struct imx355_mode *mode; int lane_idx =3D imx355->hwcfg->num_lanes =3D=3D 4 ? 0 : 1; + struct v4l2_rect *crop; u64 link_bitrate; u8 binning_mode; int ret =3D 0; @@ -822,25 +817,29 @@ static int imx355_start_streaming(struct imx355 *imx3= 55) cci_multi_reg_write(imx355->regmap, imx355_global_regs, ARRAY_SIZE(imx355_global_regs), &ret); =20 - /* Apply default values of current mode */ - mode =3D imx355->cur_mode; - reg_list =3D &mode->reg_list; - cci_multi_reg_write(imx355->regmap, reg_list->regs, - reg_list->num_of_regs, &ret); + /* Apply values of current mode */ + state =3D v4l2_subdev_get_locked_active_state(&imx355->sd); + fmt =3D v4l2_subdev_state_get_format(state, 0); + crop =3D v4l2_subdev_state_get_crop(state, 0); + mode =3D v4l2_find_nearest_size(supported_modes, + ARRAY_SIZE(supported_modes), + width, height, fmt->width, fmt->height); + cci_multi_reg_write(imx355->regmap, mode->reg_list.regs, + mode->reg_list.num_of_regs, &ret); =20 /* Set readout crop and size registers */ - cci_write(imx355->regmap, IMX355_REG_X_ADD_START, mode->crop.left, + cci_write(imx355->regmap, IMX355_REG_X_ADD_START, crop->left, &ret); - cci_write(imx355->regmap, IMX355_REG_Y_ADD_START, mode->crop.top, &ret); + cci_write(imx355->regmap, IMX355_REG_Y_ADD_START, crop->top, &ret); cci_write(imx355->regmap, IMX355_REG_X_ADD_END, - mode->crop.width + mode->crop.left - 1, &ret); + crop->width + crop->left - 1, &ret); cci_write(imx355->regmap, IMX355_REG_Y_ADD_END, - mode->crop.height + mode->crop.top - 1, &ret); - cci_write(imx355->regmap, IMX355_REG_X_OUT_SIZE, mode->width, &ret); - cci_write(imx355->regmap, IMX355_REG_Y_OUT_SIZE, mode->height, &ret); + crop->height + crop->top - 1, &ret); + cci_write(imx355->regmap, IMX355_REG_X_OUT_SIZE, fmt->width, &ret); + cci_write(imx355->regmap, IMX355_REG_Y_OUT_SIZE, fmt->height, &ret); =20 - binning_mode =3D ((mode->crop.width / mode->width) << 4) | - (mode->crop.height / mode->height); + binning_mode =3D ((crop->width / fmt->width) << 4) | + (crop->height / fmt->height); cci_write(imx355->regmap, IMX355_REG_BINNING_MODE, binning_mode =3D=3D 0x11 ? 0x00 : 0x01, &ret); cci_write(imx355->regmap, IMX355_REG_BINNING_TYPE, binning_mode, &ret); @@ -871,7 +870,7 @@ static int imx355_start_streaming(struct imx355 *imx355) =20 /* set line length */ cci_write(imx355->regmap, IMX355_REG_LLP, - imx355->hblank->val + imx355->cur_mode->width, &ret); + imx355->hblank->val + fmt->width, &ret); =20 /* Apply customized values from user */ if (!ret) @@ -893,6 +892,7 @@ static int imx355_stop_streaming(struct imx355 *imx355) static int imx355_set_stream(struct v4l2_subdev *sd, int enable) { struct imx355 *imx355 =3D to_imx355(sd); + struct v4l2_subdev_state *state; int ret =3D 0; =20 if (enable) { @@ -904,7 +904,9 @@ static int imx355_set_stream(struct v4l2_subdev *sd, in= t enable) * Apply default & customized values * and then start streaming. */ + state =3D v4l2_subdev_lock_and_get_active_state(sd); ret =3D imx355_start_streaming(imx355); + v4l2_subdev_unlock_state(state); if (ret) goto err_rpm_put; } else { @@ -1024,11 +1026,11 @@ static int imx355_init_controls(struct imx355 *imx3= 55) { struct v4l2_fwnode_device_properties props; struct v4l2_ctrl_handler *ctrl_hdlr; + const struct imx355_mode *mode =3D &supported_modes[0]; s64 exposure_max; s64 vblank_def; s64 hblank; u64 pixel_rate; - const struct imx355_mode *mode; int ret; =20 ctrl_hdlr =3D &imx355->ctrl_handler; @@ -1050,7 +1052,6 @@ static int imx355_init_controls(struct imx355 *imx355) pixel_rate, pixel_rate, 1, pixel_rate); =20 /* Initialize vblank/hblank/exposure parameters based on current mode */ - mode =3D imx355->cur_mode; vblank_def =3D mode->fll_def - mode->height; imx355->vblank =3D v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops, V4L2_CID_VBLANK, IMX355_VBLANK_MIN, @@ -1243,9 +1244,6 @@ static int imx355_probe(struct i2c_client *client) goto error_power_off; } =20 - /* Set default mode to max resolution */ - imx355->cur_mode =3D &supported_modes[0]; - ret =3D imx355_init_controls(imx355); if (ret) { dev_err(imx355->dev, "failed to init controls: %d", ret); --=20 2.34.1