From nobody Sat Jul 25 17:34:50 2026 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.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 CA2BB448D03 for ; Wed, 15 Jul 2026 11:44:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115853; cv=none; b=YWIMNZ4HyNE+XOsfuZ3ewfLnuLlQOIjvnB1KJxgGvaGKun4Q4g1iYPnl3lG43hK/npI+BvrK0cfvlQVQvZTA79turmZ6tA2uJujmnv9ikQlNNUdkIo4dA+I4+iBxKYoyj4KEdNBUcI9DQPxS8jsBeUXJNQ4ajS4NyJsI3gV3ee0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115853; c=relaxed/simple; bh=TiWHPeDGaPVeBlBGHKihLG/CZfpC4vuLM0PYqJWSqJ0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RqjBLCcpqzWDAsNtc61MhtYkk6aNnP6GEvHjtqUCzAi7XCM5s4X2u5q+Atx46qqYQi5rBS8IpKQN2PFYs0qvuiXAMJ5/SX8UKZCz+w7zSe67L7ov9c+Tt1ExOwywpTIGQeYAldZiiOwYeMPNCZOEf8veiY+3jbuZy0+LVWujr/U= 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=Vi1o2TyR; arc=none smtp.client-ip=209.85.221.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="Vi1o2TyR" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-47df6a5202bso3403525f8f.0 for ; Wed, 15 Jul 2026 04:44:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115849; x=1784720649; 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=RvLfYd+pvOrvfxKIqJXK3E0FFOSlNO+LlwCAOW1ExY0=; b=Vi1o2TyRXB3P/F/zsiNIhDq9FHeLY6vHkvmCZTUINf1iBBFth3nDL8WGpQW4fcodyo 2+miF+04CTFz6PbVzMoPYyzVLsma2Tw+e88tsve1w/2aI3b0eM4tfqj1qdAuNl2SoBNv g+FcJ3HClQuL5TBPlhmH16DUgMMzMTgXW1GjThnDpd5r7gkF2/tgJF+mxubGZ8MbcZ9a 3TS4q66JAR0IGnnt9kZg8qNNR3hWlL3BvwbB0Or113/4Jo6H/CJnYr8z1D8JauFzJoVb blhXa0Xx4Au/m0sVFsnos+oVJt0VB5rb0ppvBa7Q60ZPgFsOKyMaeb8Vy7V5mwlKssbl Ofxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115849; x=1784720649; 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=RvLfYd+pvOrvfxKIqJXK3E0FFOSlNO+LlwCAOW1ExY0=; b=hfxQ+8uBJkMiXDig9ABXVx6lHwilnL4Nos0fzEFFdvbWNrlk+Au50o3QUBKg+BVs8Z XuTcPWAdZFoxwz2kAvTbOYPBMNL+Djf9ZypBP73JGU4dA3BhLqgphvIXyb4X1xjxRPi4 x3SEIlUpZbzFWZJOvb3UmuK76LyQ8BFtJFLWDkPcP0GkvQigjdpNG87V4QCUiWYv3GMi w8uxTBlnAd7/qRF/MpYHph+jeoA+chxblpx457gnNq1co2aSNo9SeftQkVTXSpe0wg4f vm8lWdV0w7H+UNLw4IHBRN/Jr6w606buSjdlqfq+z96Pww6aQJUeMeoxrBVRF/eUo0b5 8o8w== X-Forwarded-Encrypted: i=1; AHgh+Rov4Mt7MvXGGFOawuVdivcSEd9U+uKSqkoUXVWgSqTEYYVchGdzHIPMPH47DIfqjIujB0PlXV97HuPXoJ0=@vger.kernel.org X-Gm-Message-State: AOJu0YxVcsXKw2ImjOyB7nc1Wg/QDVqW6jdvpxxSOB911FDmNvhZfGj2 SeLI0nvzfycHi0Y5zvbjbKDFT3UN+N13pXTdGS7wCfR250VJGSp0N9uJP9BfBWAhwFw= X-Gm-Gg: AfdE7cnfOGnTts9lKpcVug9M7oBpWqjw+Gu9uPxssA7OenOjgFL8RfGgzL/Pinvxhx7 vxrPZ6n7TgqAuod8qjOOIVPp901c1u4Y+AKF36PSKp1CWBOwIFFQm1d7f0oBWrWM/BjKZvmvcR2 5mDsI99d3lwJEpDO0nj9JtvoGtXxoDzqq7QJ0KI/eyiGkuYSmERFGuGHLRssYlKS1zG2xaMQxmW AjvKc+Gs2aNQNeg6sFzsOPzCMoSbV0sZBE+/LNS7YcEr4rxv5WYUZ0pkiAv3WGLXSHN/muNZqvZ BR54xhJTNVp3S/V92aPsmYqk0uP/5uvZsYM0N0zvtPXAcN7vqF6M48Lm3aU4xkZRlJ5nWoaB1+W 3rdKpvu6YSjTP9OCln8VnvY0d68Kof8+8qybMBqP4DWSmp+3crKcbiGdDx2cIyKpu7PMkC1brtA H+fSBxstJcXlZSWHZNntZHT7DPFETEHMo4bSuCaK3pDa9ALeoQJCxVviIhjkuJ68It X-Received: by 2002:a05:6000:612:b0:478:9d9a:d4e1 with SMTP id ffacd0b85a97d-47f4fce484emr2623565f8f.30.1784115849048; Wed, 15 Jul 2026 04:44:09 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:08 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:14 +0100 Subject: [PATCH v4 01/21] media: imx355: Avoid calling imx355_power_off twice in error path 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: <20260715-media-imx355-v4-1-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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, stable@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 If v4l2_async_register_subdev_sensor failed, then the sensor had already been powered down by pm_runtime_idle, but the error path then also explicitly called imx355_power_off as well. That left an imbalance in the regulator and clock calls. Call pm_runtime_idle only after v4l2_async_register_subdev_sensor succeeds to avoid this. Fixes: efa5fe19c0a9 ("media: imx355: Enable runtime PM before registering a= sync sub-device") Cc: stable@vger.kernel.org Signed-off-by: Dave Stevenson --- drivers/media/i2c/imx355.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index 27a5c212a527..ac59908f57aa 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -1822,12 +1822,13 @@ static int imx355_probe(struct i2c_client *client) */ pm_runtime_set_active(imx355->dev); pm_runtime_enable(imx355->dev); - pm_runtime_idle(imx355->dev); =20 ret =3D v4l2_async_register_subdev_sensor(&imx355->sd); if (ret < 0) goto error_media_entity_runtime_pm; =20 + pm_runtime_idle(imx355->dev); + return 0; =20 error_media_entity_runtime_pm: --=20 2.34.1 From nobody Sat Jul 25 17:34:50 2026 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.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 2E765448D08 for ; Wed, 15 Jul 2026 11:44:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115855; cv=none; b=ANBgVZQzbo5r9q6BT4DXHNL/6c8OQnEMoo5wH+RFhL8ElzUi8hupI085mj2zBEtBmmBfWUogMgNuhN60q1ISXvtmMU6+ym14y5ssBupDSqamQJ8jFUbK7nZsQTxXgYcQCYJGC52OACb1JuaXylsdyz7o/o45Bsy0g2CNtffErV0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115855; c=relaxed/simple; bh=FfDBIj0S/8C9L+ISh6gznoNbyDqTs3I8MyxJJq856q4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=R6oMMl12re0NAMb6YpXoyvmdPU2Rdc3kOsO2FVKYgtMeQDst8XY27aHK4fPgqc041fM5KzjgDAhMxitLAkvLpGqnmPL5VyMW98o/pbkUhGRhVP5nMAKpWfIVMpXTgs0M+Xx64ESyS3NQik4sajTI0ozoZNVplWY6Db7zt09OhHk= 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=Aer92m7d; arc=none smtp.client-ip=209.85.221.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="Aer92m7d" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-47df6a5202bso3403541f8f.0 for ; Wed, 15 Jul 2026 04:44:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115850; x=1784720650; 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=iy4onykfzqLZAXcH8RG3m0F3F0hQlrBfWap6/+klNeg=; b=Aer92m7dnv7QdsM7ToBCwaXPhZt3ff+q4tx3KOVOYbLfhiUxx0lco3hbXdVegYhJKK EG7oGaoQ6l9L2XJpw4Z8BLQXMy+JCEe4/DUN7BsV+pD5q2BbrWkSQ0HlLJ78lXIueiik th7mbi7HK/da1v+5oCEgbN7wYn5Unmw7FyxxXqYD4j1iPc13NdXllRpwx/gmZjsQ7aEa trY+/iCruE5lKuQ79bn2dey7mCEa0nroaCUYvfi916yXeAdFqw6/fTM4hutgi2VnUcBi nH9NQg2nExY+2/VJ1vrf2ZBwFtj7SFzR+VKrrnWGtF/gSdDDIHiZpr5HAtpY74QH4Xnn qVgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115850; x=1784720650; 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=iy4onykfzqLZAXcH8RG3m0F3F0hQlrBfWap6/+klNeg=; b=WQG1ndcnrd6Q5hFuYDF1U1p1WmyZDAj5L0WBFPvOeo+EK0l4R7KnOl7idLAtsNmEH9 SBhCzZQK5mlnxwWX7dtleRHDFAoVxW5PX8tnNQ6iugIg1VCaC8oZbdAh7DMLDzXntlbR RaBEfJ/hQZDtr+2kXZpfPd0uk0d1TSec+vu7Jah9MVWBdV/FSNFZORBhDKHfsSKzIrnm R4HzYze9OyyUe70BxQNs9UfFMsNbCisgdbnbwExostAjgr6e0+vSPYdWTkX63mLrg46q KScKiAIkVbQVrsm3iLAs0SCdwJMR38wrzihfigH1yrqh0geht2WKCnDK3i/pYb69Qmiv mkkA== X-Forwarded-Encrypted: i=1; AHgh+RrJLAiGBqvwkq3TGFeVeVRWG+fupXp7wcBpMglFVkXcPim2TENZRiCsE2bxPhGe1UC1fzTW3WQG4M7vj5A=@vger.kernel.org X-Gm-Message-State: AOJu0Yx5fYJuDWFOyye1JwIdCDcZXs/44qfcLVVxPMKN8W4ursJiUEVe ELmCmjK6XQXUvp69BUYBJDh3PBAb+zYg1feaFBOa54YM1iW0B37uyE1twQNg8jC5oQE= X-Gm-Gg: AfdE7ckKb2BTRUT2I2Yl1d04ReDnifHegFY2GNMXrHKZjUmE27iNbA8+qogv23ODFWR S1BMuXRtZaBy5m9OTq1ZR+8nq7B2YQVlTVosTD73YnFJwMl0/wfDYhU9WigWBuWhs7nnZNuZUUc nBINXadwF7TIDucpscJx2DZ++f5OxC/4CxXZJJaaNOq2evYO3MuBYTw3XiYP2A7rJY1pXVpwnXV ldUL09gqECsBrvsHPafcHeIFWadcmzRF/OqblRxBibJ6T7MWK/rp9xzw0vIU0fouWrWUvFMcKfD g4s7b+9iU+HRPAeBpc1b1tJpk5ZtmSXHCUml+vQTvTQqqoU15QeU9GPiN/3zUXSOYG0/iYsCsYC utOYzAVzmHlcsXrdeRZFMDK7JJA7JuTkvpAedaJZFrpaHu78V8cmw7RWStfWcFlErZRq1Xm7Vgq 26yN/B9f3xne8brN5gUuH9pos96NW8MoMXFShnUuslzL6+3RwsoW8E3UmAIHIcta3W X-Received: by 2002:a05:6000:2586:b0:47f:48d4:3f0a with SMTP id ffacd0b85a97d-47f4fcef4d5mr2742756f8f.45.1784115850249; Wed, 15 Jul 2026 04:44:10 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:09 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:15 +0100 Subject: [PATCH v4 02/21] 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: <20260715-media-imx355-v4-2-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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 ac59908f57aa..a6ee7532018f 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 Sat Jul 25 17:34:50 2026 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 C569B44A710 for ; Wed, 15 Jul 2026 11:44:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115854; cv=none; b=HZISQieCBBEBJsGrbi8fEviVb9Cpz07pswv8Zs3thm3WKt904LCVjs2Et5o2cifD1n/DE+ltpwf3eywd6nt3vx3vgrDRZMJhKpr+//V24BkrIFeqntoQZ8mzoDTyd8pzA7iaZ/wQWiIIWpApwKO4lJ4dU4YlkMy7Xx0/WHV+iDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115854; 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=VQawfVSYT8nG0Q2/aWo0sliwaSRD58qI4IqCeheXvZj5LbC6R+9CWleExO8QvgAO5mJpW3LBXzofubWhvR7UtIuRAw58T7TfxJ07YpixDl2X7F46lWDSfrvenNJPkDYelGyUDSqwVYAdGGU/EVNVmSAl2nYsNNh+Dz6mqeA0PMU= 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=f1AGOqOy; arc=none smtp.client-ip=209.85.221.54 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="f1AGOqOy" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-470174001a0so1072076f8f.0 for ; Wed, 15 Jul 2026 04:44:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115851; x=1784720651; 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=f1AGOqOyd2OsH+O5Y4ykn+BtrqZJIxCxH1/Qk+3NxoWcGmTL6fLBSb8QCBAl/aeu02 oyM4K2g5hUFOCfiyAXlnLzKQJgm0FyvArvTArdePPpqJsvcxsBjXil6aX9oTPdx2d8Qa 9+MkuDRYyvj5UXL94xkfgAE6JFeEtxJ2R5flO4+NtgUhgY2jRkUZcWs2tjLKgtnStvTo bsbL4sOOEPrByBQyImHHoBMA8Xu7aVW1Pfa9QH4vPe8DrMNLz7imb/XDvaJ4l/VPGGjE 51XIujYD03r6RBfR2YRg+V9ip1Jl0I+RP/uwdTiADl+FPo5JYaW/j9qh7q41JYR+d4rt zUdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115851; x=1784720651; 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=hUiNYR0ZfwEx/VoKUaTXXS8abpdo4UkpRg0zhPuWLh65vBw5RIaBXxfTzdGnLqaiKs oI84rhrpYtwZSTkucu6OQFwc9NLKDAdbkd7V7rpjq6BxZsWLZ5+Mgzg7HJYszBmZa3k7 8UAdZnxQr0GV3aLzTfFsEQQiXjORoKOktbitOVCRGb3dX7wCX8Xmc9Cy3zivDaU1ynP7 F6Rx3oMKf0nEIS2MtriM7/XBRs1Kp5jL7NaQSFCnJKbP/88USnHojPzUm0c3jpFOqOEJ vxpuug3P8CANfAJ64KTYeeZJ6/OZvlGSCVpm8zrW9MtH8zsQdWON1H+4gmDRSi2ITJl4 ThjQ== X-Forwarded-Encrypted: i=1; AHgh+Rp/qiuhFLXGCp2K8AwJ8Tcj06pUSZMux9d5MbheREidIsk+k2+b0KpRUF5I349nIWnnQpsm5OckFt7kZaE=@vger.kernel.org X-Gm-Message-State: AOJu0YxZOwexbJ6QY2vVKCUOWaf1ykBitB3YED7J4bWD+bVaxBsl61Ul EDJ1xcvsbA0Xbbp4DknAgIKbn8Cxws1iUZs4u4l/BtgOhIPdd6uFXVH+6CiWAuIpXdY= X-Gm-Gg: AfdE7ck6n+e5tXdWOqTkTZ84Gq3Rt3Gh6zbOgqkfnaC2YAWMRTdK0Dkd3FkS8Rkng3S Rx8LpnCjeju+drsYHO6S7F/O4FQLjDEoQHJBNvlzoNIiG7+Dgocsh2wnr36CS08sxsu+rjwHiQK ydGpjgPtZJqkjlpsjZJKfI2EIY5TGmVULjucLVZO2gqTzj7oG0GLpOQVupoWUugI2VgP/1FD7pV oDe2tsgsum+EfpmZ6nyawK1LSH0KAfQFrRV6nWYkHlrRw1C9srqMGLIbGst1xGQRh8/L0c6LwOB NTXCFngK+lsb6RKMBAsrlEKXGm5PGUFyH2arZEAhgsM5HyOWniFtxlLzlOY+GRCLPMwffq8RExR KEjo7Cna3LEopiT53ntUAgab3MKH9Cpjj7Jl4/zeCP3zitl9gv45//QXI1D3POrg6JT7tuGZVz+ zsn+8R8VU2RfrRBsXDTGq0jVDFeokF/mmf/m6l7OQzfahNCaUmDbkk5hPaP7e7DagaNypSk072C tk= X-Received: by 2002:a05:6000:2004:b0:47a:c103:8a2e with SMTP id ffacd0b85a97d-47f2dce3062mr19855884f8f.45.1784115851121; Wed, 15 Jul 2026 04:44:11 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:10 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:16 +0100 Subject: [PATCH v4 03/21] 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: <20260715-media-imx355-v4-3-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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 Sat Jul 25 17:34:50 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 DB451448CF5 for ; Wed, 15 Jul 2026 11:44:13 +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=1784115856; cv=none; b=pmLrSIqqX3CubzhO9XUHx2l1O7u3j6mfA45kQihUPlEuvbkM4fTFwdOooTUfaFRWjV+PGGaSo00dop3t1eNMSjcfwlLLGtYZauDmUxPTVHVXOHX/F85qm5KOH2i4g7exFDzJSjJD1Hz7cmgvhD99Bu4/UEacdDSURNWLE3r5/RM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115856; c=relaxed/simple; bh=VXJyCifFcDOGXUzWvgbcA2jr2HPZZF9pnUtbRXaMQXM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rOvcGPOHwfI8tAh0E68jJwPod7/PkhfVOcQmsoe/cyTqAWejkc5PKpY7LXnw+w7hHm/eUSQQ/L+SRF63nmP1H4mvsqUfOvcDOH3h/AxhCtLvXnYRNterRM7xIhonwFkQWdls+zISlBY6HR3edS4uMcuSFe3UdVKbgZP+nGDE2Ws= 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=sn/HHTNj; 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="sn/HHTNj" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-493c19bad03so47606235e9.2 for ; Wed, 15 Jul 2026 04:44:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115852; x=1784720652; 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=9m/Lvt/FJvscI1oD1bvc2p62YRgrUa8VBdz5pLrBPz4=; b=sn/HHTNjX4ABfbErsldtxBpfdBXZzUaC8CJFIVv/8UWvi55mJBEteRNrAfadQLRvWH LYCDVHk1tRFRvSdWjnh4XjP3W+9ue4AqvaeMfAWmbvneqp3GxSYPtz/qMJ8f8GHGjdak KTmQ6SgZjgewF7Jtw5cf61hpw/ZGuRB2+hS8HqzpH/Owv4X+zxKPTrY/rTDO0mt/Ojmm jahIT8HgfLBelrtUupy/aDy2VXRoujMvQ3V23tNrigbxddkEdkUwtVtx7dD3YD8H33QM yE/vkpnMY1QyNkCp9DjlPs0X5v5ntuwi3nt40A1UkjTtEyYrpciO6l3uq/bvF2mvprHk /9JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115852; x=1784720652; 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=9m/Lvt/FJvscI1oD1bvc2p62YRgrUa8VBdz5pLrBPz4=; b=qnqEIOx4eAoevDXOy8G14PwKOL96L1AvuikLj5FekNaJ07CR+T/drbKKzuE3DE9v33 yj/ZaeuFlZCAEtJH7qBbKT189pchGwlffDvPnjABtxqQ0jKWU4OYVEj2AeZ9enQSW72N HgP+qGAuG8HNP5189NhxUXj7Fcb/xurfPysJLKSdeS6oP8T8xYH11tD20h4D8/SSDY6L NGW+o8b5a0l8TGOMM8MaQf+rZCMkkMYt9aTdTfCLsHa6DoiXwSPs1YHQaW4YVSqnl+XE 5ySZcy8iBUIkDHw4MUXkVyezz9vJnLApGkKcJwIrB0w9Jvnr9R3Ze4U3/1aIXSEbhSLS w0+Q== X-Forwarded-Encrypted: i=1; AHgh+RoWA7Zbr5tVzxOQbeeCNPfK73YoCd1ixtZn10qOpay+ZC/G5Pq3eYO9wLNkd5/N4HfN2DsJgg+B/isfo20=@vger.kernel.org X-Gm-Message-State: AOJu0YxELnx5dSIdu05DSRYyuoHKyGVJunRko0DWb+B6l+v4uHXCMfJu HTaaKp4NVQrQRX1Vn4SjvsS4bCty3WmcuCjfWrKI5XvJdLHdscLhPGkFWmaBPQElo7o= X-Gm-Gg: AfdE7cky8BYUKy96T5SqUHQl+n5FnGj6yaNHCn5t/pp3iDW08TdLZc/0ReiqABkuzV5 E2yGRp26ZTQovQ2WwF+fL/859JPww0vauvyyxEH7+nYLjzcNSMh6M5J+WPjnADJzA7z5UkI4cMP obvAG80QltkPtNrue3z3Phpf6r/hxzU3jEw4+7svajYT8fxLqg1dDC93jnhkZSUhTd6cTKNcgWD ayPL/qopuMSSe7w0UYIIxZAFBqgiCPYk9TvB2LQG6+u3x2M1bVJ4JfxjPdANd/oqFu6Gup8H5I1 V1oaGDaA7XIlo0xYmkPFRWYFPq0afSyW1SEhZ8LfDIZ0NNNF5/SlJug8KPOkNMUZ0Mctu4w7EXn dmCU08f5VbVhWuaTKe1AMleaFpDMNFAN7IHmLaYVjHQ2/p7IXM4EO4SVO77E1MhWMQiVhHh+Wh/ qm33BFstN904y8KbDnlgas6Mp/t31zWQ6+496DZP7U6Unk4BldgO5g0TfHpWnhKT/Y X-Received: by 2002:a05:600c:8b8c:b0:495:3f68:699b with SMTP id 5b1f17b1804b1-4953f6869f7mr10543965e9.9.1784115852075; Wed, 15 Jul 2026 04:44:12 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:11 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:17 +0100 Subject: [PATCH v4 04/21] 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: <20260715-media-imx355-v4-4-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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 a6ee7532018f..01d6c28a2656 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 Sat Jul 25 17:34:50 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 9444244C674 for ; Wed, 15 Jul 2026 11:44:15 +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=1784115857; cv=none; b=bpqnAiIyonyP3Gm/gEFZjHn4BA35JFUynVdTJbL/kNSkWLpp7GeU24DmVXYgJor5F8OXoWunwmnJQ0jCW7Yjlmrr/AIbFPytb9j68h5VoWikCRndwhJQ4TBXPk1OwhDE52IMURGhXOkjI9OphAwVq0GCCsqlm3cyw7jnbj0jT3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115857; c=relaxed/simple; bh=B3V+HwP2YfOyiyHB6H9H9T7aO3Q5SXhcKZNK2vZkcIY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pOW8scabgAwCQtKZaonSyS00+/JmWUfia6F8Z0wLlMtJtRk91O3LV60MuQmE20e26StTj7XgxNLmHY8fspIipU7fK7s1tqsvkmKtNeE+q3yByOMwbibxWLPO/KRhvrHNE7N4kTCSN9rPbe1w9QD/79zIyBk3GxmZchJNKclduRc= 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=t/fK+58R; 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="t/fK+58R" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4921eed3fa2so44722905e9.0 for ; Wed, 15 Jul 2026 04:44:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115854; x=1784720654; 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=3JXztZss7n+GcgZQ7d9yNTwhZSqmPdrdCaY06YjdH6M=; b=t/fK+58RClzIrkTFd0XZq+89d5D7omk3q4SUnpsdUuhlh2FOxwNfB4r4vsKOs2BHjN bS52dQpfXqDC5nuUwdnwUFqwxYHMwFtn7nszK8MT/gVCfvdNMlfVMn8ikhHYPVsowap7 bKtEihydcVNDhH4UyCzbxyInnH8mgpfWmjyclVkoDFcvHzjMGdnOe9qt3WKGrXhbRNhu JpEcLtw53vP7me7nTNN0N6GlMFL8JCg2drH/fMGhDTOEbK4TseTnO2ZycBlx98MNPlPu gVBFO5G9Wi7FW/ju5X5bT0mOJdTMFLQOue8S+YEqMOdVKnuLf5KmtgsCdoFvK8Osd6vW R6cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115854; x=1784720654; 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=3JXztZss7n+GcgZQ7d9yNTwhZSqmPdrdCaY06YjdH6M=; b=k8giRhvbZkiHqQDG3EEXPQekLJMGrS+6o3tVzs1bZoFaA0V7QusLyj0La8lPONn3Zf hMKNp4B/prep+Z8usjQHtlBhbKUZ9UM+zqoaI2K95VcsCxQz0skSp9QsA3d3JsGzScfT OAGrMTGynQgFWtnkJuzFNYH6tOSZfH8NiwAq0M+77qrT+saci78OGGB58FEfjWt5N3WP XBibl7aGX8tcaN10gdu+KN8hCrZBPuusjVjQcEsYwYR/mv2NF+BL8B8WWPLqFe2m9QQi vVdNJAxDBezzwSFShBfxzSUVg+L/cv3TQzXGWilJuxNaUuU9+eqwRZIolSBnGNDQ2Ckb A0cQ== X-Forwarded-Encrypted: i=1; AHgh+RqkdgFtKdI3ftTNaImzy9B4bmpv9NOzHG6qs5TufnXZF7W8vPGEieoxeRYEFzM0lmmToC2rRoXu8i5ka0g=@vger.kernel.org X-Gm-Message-State: AOJu0Yyumdjupo51glEX55V3i23Cdb8eDC9revV+wQDj0jw055uWGQz2 1yhlXKLnnGD56loqcMtmu2ewmAHvsRqvhuymg+WytxtTwTxcihqF25W2GjOYxYr5yn0= X-Gm-Gg: AfdE7cnQv+MLpG+m8yi+oQOY+k4avzudruXksI4jVY2m8mqWymBovYhuzmhua7BVmuE VfDuFn8dPB4xrQZ6CkLWO3lNlhiaa57cn/ls7JIkLskX11uQXaK4aXQRM5AkwfxP7tuIUJxuEvz 0cCadV2Quv+T2Ltr2VYwAY1gzVNiNsCqVnBoyL2e+G9jctSy8EopekW53gC6ot6sKLcJ4sfdOZh SoFy6SEkfvUBra9ng6vmunb8IQ5wOsec+sWo42W3gVcVRXnBAgQSMXhrl7J8lxdyXlYowgkvr2s RJ20mJeH9ntTLAymhKninGWkCLpiWSOGC052C8W+QKCWiVEEUMAn6wVRqFXOVSN1UKbiLSMYK0J luUUMIc5Q70ABMfNNbMyRH7bsMhPc9IYfLn9T1FA1LjtKj0k2jy+w9axaxgNyzXOc7pU+a94973 WxOhdulpCZqgAEbfuwRzIJ3MHtaPkXOZgMDb9JoQITy10yBoSe9NlV8/5pHuXpRXBN X-Received: by 2002:a05:600c:e547:10b0:493:f7d9:8183 with SMTP id 5b1f17b1804b1-495389e40admr47630215e9.39.1784115853895; Wed, 15 Jul 2026 04:44:13 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:13 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:18 +0100 Subject: [PATCH v4 05/21] 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: <20260715-media-imx355-v4-5-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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 01d6c28a2656..b40d89d86156 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 Sat Jul 25 17:34:50 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 1466944CF56 for ; Wed, 15 Jul 2026 11:44:16 +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=1784115859; cv=none; b=KayP4/OH1iFsJH/ZQLO0NWP6gDq6jOjKyrEe+HvxtMhGXBoK79bs5kEylV3BHoZPevz8tjVtCig2lUDwfZ4KBn8pbvc6dU7Spf1KvhnHOzP6bmwa2ApjDQ+PY9Rw4AmD32zP1Ur/AumF2aicfDCS9IsKJz80zTbiFHRxd9Ze2Wg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115859; c=relaxed/simple; bh=wqkitN5tW+qsIkaXe0dl5rCtTLGiBd7TWW1o/DfPW1Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JxQ3xreNZFUfcrethnlxCKEu8EI9HwGQv6HqSPMeUFj9WWCvBYRJQx6hq7BwREjYH1IQW0cSZFqDAH7oFEEwn28iwq6RhYvo82LZCwmWt7IM6qz12+gCjszc34sF83CZazzx5ha4j5YCQLT0QXVJNrOQCRVbFWdclcvFT59CGfU= 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=jl/JE4y2; 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="jl/JE4y2" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-4629051c9d1so1276794f8f.2 for ; Wed, 15 Jul 2026 04:44:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115855; x=1784720655; 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=M+7U9Gq7RsgJEjog9vowp9MZwvnIxwjwziQPVrI23AQ=; b=jl/JE4y2hiXNzyxURqpQOiWs9CaXkjGtGYC/Pl42Z+mscBDK8cZCXCLfluwaOwC+n6 st9qzS8uUf4WIECoSX3ehEULAF8lRkybI0R+LCoFZGWttm3nxVaPMc309qKerDRsVcn+ 8QuTu2UjliY9IiHMrpPi5IgSR1ZIoRp/YqosRg0QKtKd4sNdXpNKRImpNvi/VecVrTYB wIbUmP5lId0gcpqvkzDNt0+O4Uotc0N9urloeSBiqRGpp8CdJ14Ks/PgIMOgCog5yiyD SrsfqnvibV3HJPqC5U6qk+FOdt0kMdEgjn4WaPRTTFGb28XZ6wzmnH5DFvw1QLgr9e87 3H5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115855; x=1784720655; 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=M+7U9Gq7RsgJEjog9vowp9MZwvnIxwjwziQPVrI23AQ=; b=pD43NFKwFUrO2zyXcxjq7thSdt8Ad6dDPdCZkn07D534qcJBURm+oVI7wBuMRdsUCS zAFh2bwH4pwgwfSGBvDaF8QsHwnYRkCe6/al++hq+bkdObIUgTIc2rA7UIXhgZbIKUrC mbGAIV+YzpieLczKPrzCyjOVF8sQ/Dr7iZPQ4Tzyyf/iu1ICScsg5K6XO0Ooo5ep8Z31 a5WN2/dHSp5hJnz6D5X2503qy8Pl1PpBEWWZsdgyJjc77Vud+282Wme573J2R7mvXVC5 Bzh0DREvRYxhlYi6YJ6DdTxMHorgWLVcgOb8FNtq90iAx6Ptjw6NXORviD273IDnOSAx kGAg== X-Forwarded-Encrypted: i=1; AHgh+RppU6+72k7n09FjF7A4XTqqp+PbCMNqVQoJj9D2Yptyr25mjjCZs/XYOfJqTj1ymXHvzjTV3mApSrZCFHo=@vger.kernel.org X-Gm-Message-State: AOJu0YznMwXzR6fC6rnKy9HcRdlLb3oamZTW+aymnwVeeMlq30aRm+o8 H9gbeBGUXczykLXhDPx+WMzrE/OdoMuQYUK1YM7axG5DTVMOiCy7hZoM4tZEfgcs7Mg= X-Gm-Gg: AfdE7cmElRo6y2bXfGdtKNWURNgR4kDLVd4mL4ftk9f6P10N1XvbvzanFsvNHBn0eYI 4triGn/dm3XHdUKGg0T5ifPBdl6P9bAlwqrhp9M30oapE2MeyQ7DlIhJSTpi2tDylISBzvx7aCT UOhRroDnN6lv5o5A2cdP8fjL/DuMN9364gEREyegvMcfSzF3NY95Y10ptK62nEgNKxG14uONKaO l37i0CrTB9HscTQ1kaHhdr4mt2NhH47rcQzSaI1KEVowu3mGqSucYr99T+ZmuDykXY6UIcaCK7j 23eJDkUPI7eVL9mLIum5YABXLf9nLTOkRfGDJ0rfOb4cmar+rD02yyfn6f3xaxwn3SHSJlRgwBz V00SiTHCfeD5R7kGzSZwaKQq+wK0tHEagzIWgimBZN0o6TwuBPAQER67z3KcMeb7UYS2cCBLoTZ rnnSH+dS38MAlyHT82A+1EpPkZ8lUtqC5B6JwQj1uKw4XDK1nsPI+ZyPc3B5Efike2X0LXxwLhB 5I= X-Received: by 2002:a05:6000:2210:b0:47d:df97:8186 with SMTP id ffacd0b85a97d-47f2dc8d716mr21510062f8f.7.1784115855183; Wed, 15 Jul 2026 04:44:15 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:14 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:19 +0100 Subject: [PATCH v4 06/21] 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: <20260715-media-imx355-v4-6-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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 b40d89d86156..123ceed26d05 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 Sat Jul 25 17:34:50 2026 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.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 E9AB14508F8 for ; Wed, 15 Jul 2026 11:44:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115861; cv=none; b=K0ItQzQLZu6ADCL+2imYkWcpv2iE/rB2Joofo8H9MU1LXcTXhTOL/5S6K0VCbH8352ROE6YOx9hPKDu+PXJd2EuwwzK+0xlGne8Qj4hUCpuv4oOLURGLftIYKMhh70umN1S965Zl2snK5/zV5oZRGtuc0X8QHMX3wiBuxyrWraQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115861; c=relaxed/simple; bh=gyqujfHJHkzn9T9XsAEbi0n2Q1X+fbSwsvnueuC+UJg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OG6E0rqb+HbpSEl2j0fQegp3GkhNxfhRSXP7+kBTp7MkZp0edMKbaKA+QWoFBOxdok51B/ltOC5zmzDPahVk2MnWhut2MqDDpnxuRuUKoWyJVaSVwTzZg+O+hhA1kmqiQ8k2F7qCnErowOV0QIW9+tXRqPPFqw8qcLxqL4nWn2c= 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=klVItU1a; arc=none smtp.client-ip=209.85.221.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="klVItU1a" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-47c2b362ee2so4668043f8f.1 for ; Wed, 15 Jul 2026 04:44:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115856; x=1784720656; 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=CQLciStRyxHcQjyBCc3cnu+LNwHPfM7OOKyYTNEVNSs=; b=klVItU1aGyjcGc5fX8ARnYxBEiOXuc374EEyzOURSdJeYObPU3qajJxItKEeAgaU2T TkadsQe/fo1+13cYZqnTIPdyYUX5PXq+ZR/j0Yf0xDzC+wp9AgjiuqHS+h5ONJjEFrza Az+z+0OmvT5a7efa3Dtf1G5PSqn3YWdP8MxWAb11CjJ8LYZEIIjxC/o1diW41Gq5TLlI 36PpNBWB2iOLRydCU3T0e1cm/shWqT50q7wAgVDzgro7aTvmjMJFB3u7hLLo516CcUoA FbLWOPMv0zrLIyfM0esdbGWtVMxsps9pID/fopHesdhMBuTWHGU/mCvY05QyZUndmHmQ WbtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115856; x=1784720656; 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=CQLciStRyxHcQjyBCc3cnu+LNwHPfM7OOKyYTNEVNSs=; b=IQEvDFfEA8z1/lWS9CvAiTnH+kqwt4GNtKwbQ4ApTFf1cEGpeMarlLS63WCPzVRmW6 W1r4NYRf6KuooyWJGM6iW8dB3X5CpKa/dIm2IVGzOiqGJZVVi/lNFLlCZK0zATz/+maZ isYQNFsFgR1f3472IoEM9c08uSCfqcTfNUPrSBuokZ68lXSVuMVLa4Sw9QrAVR8I+zsA LXXeOgxU9GNElYLz8Dtf+oDMeYlphqAefhi5lXV+v6fw7U0WGiZkXvAnqBIYkspMC59B Ka1ijJ/xZ67f5aXyAVnp5WZBHGo+ntEi3O7RoqxzYQ8dikOIAm0NEF9Z+18VQUEu4FPq Szug== X-Forwarded-Encrypted: i=1; AHgh+RpCjqpFWeoGmrMLJ2XwXWqgqBu4iHibUe4KNv0AwYaLXJkwSM3m7NGZ870+QAFp/e8UZC0Xntoo9rijIhs=@vger.kernel.org X-Gm-Message-State: AOJu0YyNT+tKXiV4XvsASwy7p0EH20/hoZLsyP32QO/IvMG6/ux5roAn HpbSW2L8iXaPZVO0JmhYG13vc/3qP0Qcm0vuqBNQWN2cYDxWp0SDmtGU+i2I/x4U5pM= X-Gm-Gg: AfdE7ckn76vr47iibN4WcOseKzw3FO2YoWZBY7En90S2reCaEWckCmGUS++8hgdmDkK IEH4XYJgXQ/0hF1mW1vcmPlElz9jvxoiMDdHe19yI6thud41waug3Y6OHHIDUenGXY+9nKMvmig dCgcQcs7ty/xnDXCIDqqZ9/8MY49HAij4FMuu11BrhPaalRsOYfUVsWqb366/n0rA1AAl5fmLel 1yOt89nsmXzMJG0l9PMoPNUyIkqErzYbyDOTD8dGaX0c0OjZmNKLINTLr5uG5a21FIakm7Q7Ww/ 8rFd2pG1b44zgZEYKXsl567/cH75VgGTm7H220oOuvVci1eAuAvd4+VGf/fwo4DRpTvMJDVA5vU 3JYUDZUhTulvGfgXXumsTfeHfR9AkoIFrrzKFcEWH8vOQbBOQ9/xdTSodOcwgKoTqPIv6S9RWC+ H0P5JZlqlsihFz6aAd94p2aZ+T1rw9IO69NumhK3+Y0AfxZwzw9gliLMCxk2f+YKAT X-Received: by 2002:a05:6000:2407:b0:475:f0c2:75ac with SMTP id ffacd0b85a97d-47f4fd3a065mr2962749f8f.61.1784115856194; Wed, 15 Jul 2026 04:44:16 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:15 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:20 +0100 Subject: [PATCH v4 07/21] 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: <20260715-media-imx355-v4-7-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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 123ceed26d05..e9f4bea67d3a 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 Sat Jul 25 17:34:50 2026 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.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 DAC07451076 for ; Wed, 15 Jul 2026 11:44:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115861; cv=none; b=tChwvBVxjDFTk7+oEjtG/upIeNg+HyUBW72i+O/a6OqtOckKfZaJiiWfVRmvDzjc4SEyMZ7xgV0L0fpR1YL64+42kDGh5LpO57zXncsF+JwWHrwBrJTFqpa71Dy5VhVvVThTdbdDkOyNqmnNiAxEfd5Ks6gj1gsEc4WjZbgM8hI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115861; c=relaxed/simple; bh=aZ8n57U1j2jY+o1haOa0aouu6Bwg3e2b0NapU1cYUUA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MChqoX6jLAJL9Y0G7PKdtB/0nrAwd03VpzTYFsbwr4zAKlsdxtuCqP73kLDL6uTK4kdHGr5rPB/4HKOZgvIUv5DYE0FVrfQiEnnA7FU1OEiYmuAsTCHR1qVWGVdbOB90cwYZsKX800QEUVlzdZl9vSpHxjxSY43AVoMpVhBe2CE= 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=kQOJ5zpT; arc=none smtp.client-ip=209.85.221.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="kQOJ5zpT" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-47f3e6cc44aso2855527f8f.3 for ; Wed, 15 Jul 2026 04:44:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115857; x=1784720657; 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=LaA0Iag3STAJeBMnk4x8b7GHaELfh57GksWF24FaP5Q=; b=kQOJ5zpTjh7puS+qtU9Sj5Wnu8A16H104rTHRtkn4s6HRZfI05hJ1X1weMV+bTjRuG MDiQ/ZzffBqg6dqADY2Hbc+E8vmvcSjfhNwsz8P6EoJvzSJ0T08z9xemw6dJq+X8Gp46 423WIwYAeyvelk4N6naI6lFCvnEv/9BBy/Yv7mMTrkQ4unU9aa0b2IbSiDqnBba18L4S 1c6gaMeHYkP9lx277uFmTQ4Fl7KVj1LqDK2RgPdWttIEkTjEpWqkeQp9fthyD60dWh4k KM1soToXx0s1OtbEcy2XyQ/hu3guw1NjcVQHBniGLQQovhF/spQWZ9QkB36M77g8hElB sMHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115857; x=1784720657; 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=LaA0Iag3STAJeBMnk4x8b7GHaELfh57GksWF24FaP5Q=; b=Qj/Rvq4AbONAwPRfUUw0L5V4MCkPgutOUN3QhuHUTLORJuoJlVBT1dgSF/rJnRRj8e qH9oQ1DKl6xUGAkBigiiPF6Y9b39wz++iM0qzQw2266KgMIqr/VyylNd3YB2tqPBAPvH j5YbaTGRudCGeq/r6M7qBGPyuHe9F1vrvEXkhq8X10K4yPyV7T1wWihACK/vj5Cp66n2 zJwbBC2H16nFJKhA1km4HhzlIKzGz91r6hjt8G/+XizW5ztqIqRgwru/aSj2bnyWEe1A kYpdqGhoXyCmmfyiWsEbfyYTOjsW5oLEXw5Aa60SWyyekP856abyMQ8FMtg4Kh2rXUPI eWpQ== X-Forwarded-Encrypted: i=1; AHgh+RoHjQW12F65Lmhu7cp4NKx8Num646+EYTqmTMdTy5tOVOEzz3X8ry8Veyvzn8wKOlUOGwsj5+767pNlJBA=@vger.kernel.org X-Gm-Message-State: AOJu0Yxo89/j+1YqBStWi3cNY0mQMrmJNk4XpXUIcWCtSOqIp8ep+rKa 1rExbsKxBuYXHl76Z3TkJ52iFJfyTk+rbPAphw5us3bP7m6ePALEhJ2qD+VKZ+dJovc= X-Gm-Gg: AfdE7cmcJV3KU1CP9De8atj5hDPia3RT995OSxli3YX62JdeWST2H7a+JhmV2edyuK0 clbhjUejIe1uahpVaoGf9L4xUBgK4RsIEbUDESK3ZPQ4BdCF45MK6xRrDX/7y3qOIjUucjWXNw/ SmC+L9geTfxPAxYt1fEQG7xcmanDjLvZytSiCVyT9UYh5e4fIgw+qAtP1pt/cL/ufJ51dxtCIIK Vp5U8FapNhTIqbqUsge1BXz4vHDqNbEEQT1Oongve6O0CXm7FjiCq2v6tX4nyGMCS7hfKMmzj8L BHA+0rRzEen70VqcxeF59JC0xcXyD/Ww7fQZHzjRw0zrAOL/opIpwzcIXFJHHpwNqOMecj3TYo5 ZOwxEiN4/MCpsLoSWik2KaaKjBVLocR7MZe6HJT5y0/0EEZcKR949/0z0BjQ84XOmR2c/A4B1HC xisRtOhw461UHOPAuRu4JCwseII3PV191AbFLgTIZwKYmNkg1uo9sMMwB5nxVBtQ5U X-Received: by 2002:a05:6000:4602:b0:47d:fb9e:c3f6 with SMTP id ffacd0b85a97d-47f488573eamr6671556f8f.20.1784115857101; Wed, 15 Jul 2026 04:44:17 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:16 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:21 +0100 Subject: [PATCH v4 08/21] 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: <20260715-media-imx355-v4-8-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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 e9f4bea67d3a..95487b12939d 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 Sat Jul 25 17:34:50 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 9D1A94534B3 for ; Wed, 15 Jul 2026 11:44:19 +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=1784115861; cv=none; b=aA1qRgoe+6KLnILnLvzd6PjQtNtE8W+TMVuxQC+V8G7wQBMCP0lf3ESVNXQW4BSoNvYY4enLEqATJgdJa8FB1gvfT+XwHwj8AUC5aUAJbudiqrQbojDXwz+icPttaXxxmA6YBILhIExyhENrbUxigJQqcoe63IvAp7e3Yycznz4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115861; c=relaxed/simple; bh=yrRUmnSyEvhIK7E6vTe4dWuMD4iAEtmjXkE8Ai+aFMQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iGnVe3AM3gAD149OEEu+nyN4chS5yxLNQ4zf49BbCzrk8asUfuMa5gnLfHHR2nyYX0SJl8TphoLXrMEX73MJgFcBF3kE1Axr539PP1/p8A6eRNbLfbBc9GvzqqMZ/pcIgCwM+St6pzPtEveZpfqFrZ2q7hauaWOZOsbDhthvfQY= 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=PBdq39DR; 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="PBdq39DR" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-493b779003fso23028655e9.3 for ; Wed, 15 Jul 2026 04:44:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115858; x=1784720658; 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=V2rwbDSH9DqOd4xH4FVieXVkmcyN4+tA9pTQwzpFDLY=; b=PBdq39DRxkq1V6x9oMH5NJgtabLLtOEgmz24imrm21WJe1+hOLGEymFfiJdx5tErUT huLkrkYP2TfTXEzeh+fAQBThXo77ALXJRTXxQnp8u4TAbUehx/AVft9fikimHPs8ZrtP iCenkiZCORXY+GgHtWserCZhI3B/NKIePPTNFZ8mGOjX5ToG1MGgD9dGr5ENgNzfCPx1 RSMhHCYCXSF+20SpWCrQOKuWdUhwlbVN+Ei3c+PtO9vOpRSK88E3sTRF2rlmXkTuJznl Wh6ELur1rrOvaerMY10KYG6flavLnwDwiLn22blW4SxnUsoBTbSARUBzsHOY0guWgL7n GtMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115858; x=1784720658; 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=V2rwbDSH9DqOd4xH4FVieXVkmcyN4+tA9pTQwzpFDLY=; b=cfbd+GltILaiJ/1pwYLljcCB20XvE1+jd2xCoz/VXIaItjFWJ2SIkaM/OEilJerhD7 IQ5WADEllp4prZc7RrytvO02jyMH0ARhEXCrasg7NAQJqwv6T/3kYzg3ykuqx6J2DfU9 XNWavkANLT1K6+T27bDnAe5gAiBR+P/W1uaoC7aLmDiMHxl64lWprLa2r3K5ZTBV0XDW KlLIbkAwXVaxjfF5y5LhbyHXShQBZxgjtGXyq6uuFRf1hlkrJdVlyjdU/GL2qUhOKA7E +jWiXv/p9uKZjDZCGJIqDwiZbVuAi+A+sO2fGI28+f/QAneR27JD/bxZUHEZeByaiW6P mZzQ== X-Forwarded-Encrypted: i=1; AHgh+RqdlyhaYB0Yvx/alDXbXAdyuIBaLw7WzcK7y5OOOqdKoLaSujuTXF/irlL9B/8hzBdsix+MQSpYt+3eWmo=@vger.kernel.org X-Gm-Message-State: AOJu0YxekzoeJTJZKcVm5Dnvbu/cIKTWeKUhgr0dKWHpL5NsdtanF2JA 4KyvmnQXbMeX7WtUmtK6Q4PBJO15/tgyzffmGJaJK2U9MW/8Uaren04lw01sef3sXS7Ys136LBs iEIHa X-Gm-Gg: AfdE7ckn4+xCC6D6/H9CfgE3khe3PmB31VmHKnwkHXMpnKUoyp1GT+rPUcLyfPWjjIK PqzyFDyrJINMUKNX8BsY96O5xBSIlUxWeSqNcX/q752+2ji5pGWBiKc4XkKWTzbor85ApePPi9L u1x9/4CPb161nkWDY5J35xZVOlT0KBgUkt3kAvF3Tv5WLBxX5S6kfKcvDf252PJtwOcb5aWpp9n QDLYa/AdW/nHe6pcxiw23nTvaktH6euZ3DzX2shIAJssu+PdM1RXSWKqOliTUXQ0NhFKavyoWHW YyUJVg9WvKi3dqjVByHnFNVDhKtyX97wVW6jvDhkKOvj0zFGaizkaf0BldWdkKNdfq/NtYUedg2 U/NVpt80BaxNK7jlYhbYEgjMyG9boByfd0UsGarYlc4ZCxfkgaS5MHhQxZCri7Ao/txmN814vpI EGtqXoykC96tIHx7uJjEr4wNmPisFZ5JKXBwplfZ60CUOg+KeFxujiPCG5cnsmntdH X-Received: by 2002:a05:600d:8445:10b0:493:c634:952 with SMTP id 5b1f17b1804b1-49538992d4cmr53020215e9.7.1784115857928; Wed, 15 Jul 2026 04:44:17 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:17 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:22 +0100 Subject: [PATCH v4 09/21] 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: <20260715-media-imx355-v4-9-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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 95487b12939d..b329da85ddc0 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 Sat Jul 25 17:34:50 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 A0E054657FE for ; Wed, 15 Jul 2026 11:44:20 +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=1784115862; cv=none; b=OqcH9WQ2FtkU8k7ZFeZ/TWzwAdCLLTE1xuC6r6m0D33NyjCGGHXSwkO0sikAMpwWwxFzv3vmUCbwPiP6f4z4CoE4wfBP5cr0edGkeyB/MXcKceJkjeAetS6o6NhUBd8wuwofGOX366c5wQh/OMOJgDaXlbpTAujuTF/NhjgZtIo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115862; c=relaxed/simple; bh=fMZKryxQmK9xInKacewLC6J+EQDsnbDnLfr0OntXxwQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Lnxh1gT+5KVZGHAvskJvvVEJbqvD9IMFYMylMMsEPI2+b/rGS/jIgxw99aemey2SNAOjtNEWeS9DNPqZ4ISu9ZaLd88My4Z24F9I1gfb46TmeNLZDk/9ymFYq0jMP6ejt4qIqnaajt3yF1kjN9Bl7C36ZYasaF0nJLY87zN1oYU= 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=e+lL2Elp; 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="e+lL2Elp" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-493bf73ec2aso36618955e9.2 for ; Wed, 15 Jul 2026 04:44:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115859; x=1784720659; 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=NYbwYTOXVK4epL4nJxXsUqEGgL/QA5hnuNFZvu8Ghx8=; b=e+lL2Elp3okyMXkSww1nguVWhm+AB0mGIlsoEuEAKhM39ynXeJPlt/sgDde+771pb6 oje8h2810SCoNsmXlnj660BP2nIB8tIgLPRb9kEAyd3f3mi2lAYYmsc1joQ2Cre7OC68 WpJQxKFXafOXAYltbXE3fKx1Ubh3KLlH/YOn4EFfV+4ppTLKyKUK1jZQB04HC1pFqNnF OVsYCPgEP/xYcwyadsKoEALjO66gxUE8yOYmKqHrkD3DYeD1/0DgHOhQdGGS9NcZtC0E jHrlrdojLmUWv/+ngsjFqL9tqKFzDIunwGl9GZAM5LgFjrri0zJTBKMiHLEPPFKnNVyw iQUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115859; x=1784720659; 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=NYbwYTOXVK4epL4nJxXsUqEGgL/QA5hnuNFZvu8Ghx8=; b=WjunKxuPrJ0KuvO9JHnXYy23ZrlCyGd8DeAoEwiwymGqP7B7Js+IG0NHyDLDlNCqY+ LE+NjCsNuFYxEfAeEwBqlodO/+xsInPTHeQVld6+wKs1lSHAMUFxTVNcTrJ7idScQIRN xrSmE5N+pBvl+7mEvp2fNJEccYjd7KUNz44hIH0QqrqVXvbrsJya4fhBFavAcvSD5eL4 M1L3BSezPZanGkHuYtU8PXEQ361H36B1GjsD7JWghsEp2zkohvicEJSlDrESpbc2tS/n mCo7tOYztvW3+PrvqO8+yx+Te4ja6aXDqv+CUfYMpE3j+3bxPYrAePWLC75l5F8SoFZp yh9w== X-Forwarded-Encrypted: i=1; AHgh+RqMzr5bxRTnIB45xQLzWvBDddepDiwJNcMK9Nk85Rch90+74qf0FDld1hP+xg+dsf3zkZEgxz4Vf+evsBE=@vger.kernel.org X-Gm-Message-State: AOJu0YwUo1arwDyX9s7JUzb3ntcxtsDTd0uG4+xuXR22e39CDsZ8aAht yC2lrJydEysUEFKOuwHUWhBStZXpsg1zWVnQYdIg7K2V94ro5Wyc2BsfQ7X62W6hVlo= X-Gm-Gg: AfdE7cnROEcnhar8tWlOqzEdJmoxtG75mPkK8eHOOCmoFH2WL69SWg3sy8kyRaEW7Yo KszdLC7D01OOhoFBem/C2DROHhukh+Op7n6f1aJ1alD08HftafruH2U0S8mt8ZULBQtD968kgSa O1pUjGfmCF0H9v+rMhTEkm5zNscMI6KlYbu3ue1Zc2pHKclwslECTCeOCuIuoVKrbWAYo1f1Pyn 1Y+ytrEbDY8i+nw4aivFIUIqfb+JuiV8BNMz+ytvlnTWGZpOFR6aSlBJtaG48Db6ua0FoZqR1ex 8Li+iKoFCwWIBcx+3dMTtN5FjBq5ACqnxmpTddthn3oxYRlby6lZQmw/Pcjd05LPQDFNLyd2sNc AbBpnq2zSHApcxzct+RQB6yhbdAVNtUALjoidTbUdDGULZe5SsYau3XqjB6rw9NV8VD5Oqc12pO zwfnQhdpR17Jq8nCid2ACSMnWKu1pAbVWb9Ty8kl3BAP+W/JpfePqL7bZNyJAAqvgOwmWkOloac 4E= X-Received: by 2002:a05:600c:a08e:b0:493:f639:9b2f with SMTP id 5b1f17b1804b1-4953c390347mr28066415e9.39.1784115858714; Wed, 15 Jul 2026 04:44:18 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:18 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:23 +0100 Subject: [PATCH v4 10/21] 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: <20260715-media-imx355-v4-10-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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 b329da85ddc0..879e98b8a8ef 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 Sat Jul 25 17:34:50 2026 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.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 76D0A46AEE2 for ; Wed, 15 Jul 2026 11:44:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115864; cv=none; b=ZgZGPB5Y7jJ13w3tKm40b3LSu6MaxNwYI+fVNQJMPkkioeGtc7UyRMbEXSpBgdCXORclhE1CLSw3NdXV+fIw1A7pGhKBHA6nHbZIXMFhBNgVN/yIsr+8gy49UYPTddhipl9nY/HetFML+BUJO6KqTW6Cd01r4Ps3lZyy8j5lrlE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115864; c=relaxed/simple; bh=UnnHfdWHB3j8/q1T8HXrGgvBN3cYv/cM8AQICxBDWkk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MV1RIn+wwZCSckH0F241Xlr5IjMOwKEAsB5nOcm0SSFUqRVlDOlkxxR79wm2oooJR3Z7COB53hpviJFH2se2W3DKaTMYu/e6WlIrQ69fgGBBbyCEebESXkXamYVORk6iuzQvugxhEWNPL0xFBjF9H1MPX6XDkVMogBC4v/9jNgw= 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=g4ieW1Z4; arc=none smtp.client-ip=209.85.221.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="g4ieW1Z4" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-47dec32798aso5511956f8f.1 for ; Wed, 15 Jul 2026 04:44:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115860; x=1784720660; 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=pMlOxNtzedHPm6fZpmbSBE2eNBzZTV+UC4ouVws8cLY=; b=g4ieW1Z41sS0VRjUy/DO0oIxSyqIXbzNLPh3AHWE0zW860YElfIFmzbZfXeC+SeTH8 vMJEgc67bfMRrujZOwNETBuC1c63yaFZ3YyVdXIzcWCZD2XaA/O9K7dAefbw1xsHI9cu I6atxyBwc1NpW76JCeQVS7apVLBTUz1O+9Gjc7yzRRcT8+GbPA+dsRFHKh8mcfinL5G0 ZpWpgVIi8HrlXKc4/R55f7IM0IatuxiPk6uzCZvoEWLqB+fo1yKpf7nFr4fciRDqYXPy KEklxrDnH71nJ/yIEv4T4yI1fM+Sy8lTMlRAhvQ6jymq0sDa6N4lGXuxub0unhyW7aRH X+SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115860; x=1784720660; 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=pMlOxNtzedHPm6fZpmbSBE2eNBzZTV+UC4ouVws8cLY=; b=BWw69tWqMMmf4zRQeugHr3ttVvgL2g4wBQF/GU2OWNkBWBzO8FTXe151moKdCkzXoi yObSzyQCY0OM29vGdUonJVgFMS40++Tnk6U2zxUx9kbvNa2SGwtRlS52uZMfv4ARsSJA 6DmB0dwUQCSphjLPrCrrXjVdp03+uVRswjudjeTqdX14FiC+9CttYMd4ppMckn0hTrjL f+MykPNcnwh5qdNWS2gSOgJpakwb+KlVDw4USnjbtstiUnIIU3EXEdVGxnmDe7NVIeta e1wq246GF80pbBqMophMuB++BctzsTbfgTkOwSLje3qw5VxrLyM/pvSaonnIkskHOUyu d3/A== X-Forwarded-Encrypted: i=1; AHgh+RrTbZfTzX/k4NBUtoTj2Rxur77jEmyqvL/YqkC2WKFjmQF/p17RrQmazhUiW+iCzdBaCK8yvNF4IjVddsc=@vger.kernel.org X-Gm-Message-State: AOJu0YxDUeRhxA+hjb0iF5Bxab65UtCV4MMYYGwCZ5tbwZkalTbgO6YZ fGibzAAJdq3jOFIco7uttYDI9FtGfDnO23sPTohxuCm2nwVHt9rkPHdFKiXsjip6ots= X-Gm-Gg: AfdE7clL+eIBIBje77WzGKR9J73JCvRdrH+o9sN1+rm5plAjEmOiFSApLdtwLqvkX7g lvdvXN7RmAiiHYPLM7uyuADtIs2eKPS6OL1Pc1bybZpbpjfwtml1FeXhKIBmNRlPu6qu+1nrooD tWgcUF9q3lCeP1FaFz2v0IkrAKo2ghqhKa6EDACb+f+7qhtBCzDneBFcncIxNVjdJn2vR6lgIp9 jdZVLh+jw7EBjcTFl9mEAA688qBpL+HhJ1Xq6ISZVqhVGpZPO+H4BiP6qIh+1jKCsRQG+x48VE5 BbxwODMG7ut3FEbpvZ7gFgeUfHnsI6NkMqLfRWxKKLHTAnhqeEk66rOm7gw4vFH9YWjoHEyNGVl DQqBUpvj8ZdHR4G6akeBGjUpbU37KQfsKTR7EoIENyWVBz/oXrOBxs4rIS5uTRPHLhTbEGPoHbt ewzVnp5d1BKJlh3X33TtNCFGsS4a1orpqzUbugmrcZg5D+q1P/rg/8aiH1z07RK7UW X-Received: by 2002:a05:6000:2013:b0:47e:4b03:4909 with SMTP id ffacd0b85a97d-47f4885709cmr7126799f8f.18.1784115859534; Wed, 15 Jul 2026 04:44:19 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:19 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:24 +0100 Subject: [PATCH v4 11/21] 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: <20260715-media-imx355-v4-11-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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 879e98b8a8ef..649a6fc9abe9 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 Sat Jul 25 17:34:50 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 31BD846AF34 for ; Wed, 15 Jul 2026 11:44:22 +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=1784115864; cv=none; b=DQJowTRhEpk0mKDDXtcqNXkScSkLNAetqeGLJV3pqaad2LKo3DcQN8sfLSEF05H4bzsyXVc5Pog4vZOYJMqSL+3BpCPGn51Kx0BFXO+qWLMTPIBgOC0Z3k4EeUk4wcE12C2Dc1DKE/r+o7AAIPBIxeSG2Hx8XzYrFTGiYoHpNJs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115864; c=relaxed/simple; bh=QPSz7fNjipJoxhGgne7N/ewO/88rd81fw6g6fFaqWwY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cGXFEndUvhOLEuuGMCuw1hFHSQEjronbHtM87cKDeDoOJEp6WKQhIYh+9nWm/4FqVnWoU/AIqUOBw0hkaQzzQKilm+Yw9EtxBlS8p1oSnNzenimZT9YDgBacWSqBX/XfvVra9sq/VCMEz3ichq0rOK6hxyHvibt+vA9VKAXv1l8= 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=Sqj2KZ4c; 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="Sqj2KZ4c" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-493f60208a5so45348155e9.3 for ; Wed, 15 Jul 2026 04:44:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115860; x=1784720660; 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=4Y8stE43huuTKZ9RKy4x8t79KHGScJVKOZ/vGCx6NPU=; b=Sqj2KZ4cr18u2A65xn4RFqphwtH0J1o20KhfwemxpO1BLE8aFqySaTCDCZXwrqksOS Iy3pKbX+ALjEvb8oq3IEyBeZtiWtmYQDFLuNf+wi2D2zSTGXRZnIbunqu/ovUl2d6dc2 jwYnkjTbXaKEZTDozkqU+5s1ZJoDWG4fnsz0IWKgWc2M58kLI/Cg8hbbykdnu5xGTAn/ cn2wqxjlKRJm8BlGLJrTvz2JeT/OvvPvjA21g00J+eQkebmBg9jeAnuakavxDcAs+mJN YRCRqx2/+73hcNjpaRvTrQtZY+OvZrkTXfgka0lTlNTIorfkTF7dEhOAkLN1njVAu4Tt pmWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115860; x=1784720660; 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=4Y8stE43huuTKZ9RKy4x8t79KHGScJVKOZ/vGCx6NPU=; b=k6SYTtZWB4U4hmUOuwRm9b+CLelgAm55rYrNIsSLXLG78D0XAz6XlYwAOZy6uY7sxF 974Py/ItYwis3TL/Y8W900l34NihzhZUgYazO5ZNZRF9QSU2aWSbLZf+qJ2oF8lYn8Fk 2VFXSd73c6BWzEiZbArX8vLp8K+xN7X+f0p3tsOPoNm7SSN4MEV2fPPQbWQxczre6jYJ TRgzrn/7iS2Q0eauIuxWGbxTnC+h49sVne/qAwmP4aVbOv75zyT/uffUj3QO/YZPHZZ1 TnWO/jGDQdakV1O/3iy+cBQNbUDaj+zQa32u/oVLS/rrdOzgZlzqeZLpDk4DFSAhJQ0c UsYQ== X-Forwarded-Encrypted: i=1; AHgh+Rpy8gkrc7hiFqCxIWPeGLYpj2uTYJPWo0xvOEhZ+FfnBfd4TFBFMOhWA01k0pxHgF9s9jOktYYyML8Xtn8=@vger.kernel.org X-Gm-Message-State: AOJu0Yytp9vPawu40GQxkVdjYA8BXE4+9r2b2KFv2EwbYN0P3hQ7xsLs hRQme3dhY2/+ijZj95Z2AaRuAfY6dz8W02eVil0u2TZlMcrU3kgpb0M6ftoUFGB53yA= X-Gm-Gg: AfdE7ckKkDbAMV/b/dAYpmFasu5/M0m+iDRfvXnvRpt39hZhEaSbANM64kQ3lfs9ZjT taSmwg1D+t8nQinv4vt8nNKjUhMmCbrayLOOt2vJZm8jfl59flq8rooTz/6i663rvT1xNEXWqpE 5OkGdSYR0asVnh86DQnQu2d4nbWPqYuWJn5d5/5YWci2M4Aef4A67QU8GEHoad3j4Ff75TspwGw gHAFSOY1RMLG3b67nK4xoYr5m6Fh87+kBVPYRDL3klVLb8dR19F9b5GbLAwQcI5MQWuq6yiDFEI O1WPUCOyGBQovAJHJ1c4HXB49/4TIfolKIz3ASbjNkoL2rEnguk1aeMJrSQ2wK7vdmjLYQ7ft78 67fcj0VIaATDwddLej4BFRB0ZyWWCR8gpV9dk5KqbMyloiyTOXWEFX21mFICvtCQB2WvSXXOigY Pk+cyiAZB+7mJ1WZGuRcQuQsC7lBg6JwiGSec/WDzbEf2ebeKn5F9RVlDyoQsaSzRf X-Received: by 2002:a05:600c:4593:b0:493:cc25:85cb with SMTP id 5b1f17b1804b1-4953c14752amr29475675e9.8.1784115860470; Wed, 15 Jul 2026 04:44:20 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:19 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:25 +0100 Subject: [PATCH v4 12/21] 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: <20260715-media-imx355-v4-12-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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 | 60 ++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 60 insertions(+) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index 649a6fc9abe9..120eda46d982 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; @@ -849,6 +857,7 @@ 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; @@ -869,6 +878,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 +907,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 +1125,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 Sat Jul 25 17:34:50 2026 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.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 12817472793 for ; Wed, 15 Jul 2026 11:44:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115865; cv=none; b=oeSUCp3mRuEcjbAU2TmM01KtBIOn/WzOzmwO+dzpb3nQtY78faIOgH/tEN0+eZrrPa+6qXXzEFi+oKzpL8dMB9pn4d84iTXsUEqlBoV5azdFI6eo30Y7XSMWbO5OksHGhyEFA79/y7rzHWLWOSLfU/jFMm5KcdWHWaD4db/JJPc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115865; c=relaxed/simple; bh=/hOFo0rPQJJCMg8TN7ca2c/YdU1t7mtGTuPyJNmtqF0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kOrDLmbluj6SBETCVh98LKMpX5Zpfwj5AvpYbp4DHYFGDAO1kHwemI6oCXq9dLxyMbJbNkf0FDqS57VKh2M3RZzgVJlMlcFv8TNqElSl9V60ZI5qNtIwAXaY5Iu6JuTBm9RD2IjdcmG2+7RRT8VdAi99hD8G3IEDGQOYMJIDAE8= 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=t4I7A7e3; arc=none smtp.client-ip=209.85.221.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="t4I7A7e3" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-47ddf7b09aaso3675734f8f.3 for ; Wed, 15 Jul 2026 04:44:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115861; x=1784720661; 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=RisMOAAic48kNClVJf1apvBtYfMS81SJZNrhmUuPOOU=; b=t4I7A7e3omHg4+2VUCClwUcufLvHI5Cf2Db7RMS1Ti9iSAghZeQ0ATFAmfbVfGjqW9 wkCbGFI+gNH0A1VSRQWKbl5I0w3SWT94jJctmC20pTPdRvAf9cIwJBIMEeQ4G/EQ7S0H Sg9JSnQJAqly/5Q6hzMeMhEsGfrbXEsw29wlHwXIbYqUj+NU5swRhl9o8yBxAt7LSi7K AQfSELXLiXSBYtfyJ8gyyUlx9faFpXDoBpkesyG50kGUCSQtL5NfFYApeT3uFRRQS9Sa ns3dAokj263nW1JD2mYkqACm8kQcFJA/2mY2a1BfB4KhIllBel+UAHAxZjkqV4UW0++w 0xww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115861; x=1784720661; 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=RisMOAAic48kNClVJf1apvBtYfMS81SJZNrhmUuPOOU=; b=TX3ODG5l0T3oy1higEy+UsUarBlNDZj23G4mjb2pyKreTxzlXqd5Sb2pYORNx/jean Q3mPfiC1hFHF1qMm6wr2ZW7WZkpMbGcBlrBYHxC9pjGVzbFvKFbISPYOmRMQ9l0bQLcj rBjeA432Rsdq6JKZt4rJPGWiELDNxdWNmlhNKOYqyzRlOm40tyAzSQTZ9BvDl4o6nlyd aMgUvmFJbpQQiZSmma1E2l9tcLh37I051LlHpb9aG/6cSZ5WVbQlIsxRVhQWgNaV5hkm J0786sDX2v3nZN4GYa72ypye+E20uRnlN2O6+hfaV2km1l6Te7hr0rEbIeRz1eC/9Zb8 3VUg== X-Forwarded-Encrypted: i=1; AHgh+RrqKwIqw/Y2YjIt5c7b5pTspH5sHgjcP5nzzQITzw7o5yihFJ0wSpG1MHWXCLi7vsmIvKy3KcR9tvxLUSw=@vger.kernel.org X-Gm-Message-State: AOJu0YzwTcCJL/4vIhp7YK5ZZzkSpfx+9dPnsKARZmRGnUUmCz8I8yYb et8z8lPkVDP/2YWEfvaq3tFD2zMzAwhhG5bLL7E5bLBDmbpYYHsI24bq3L9FkcSX1ko= X-Gm-Gg: AfdE7ckg+luHa3W4YWL9doXoYGPS5TgAPZ0BIv9QrctaBENp+7wtv86jyURVocu00Jl MtyMJ43ndOUniuRrOio4epmilY2zI6dnpQjQH/7fTHt/krfHEFAjbp7jsfna7c/uyS2jkRExuTP JuBrjN6H6QqM7l2iApU0k10DDvqJP+v6WXF6AdIZh6biQ33VZE0mXL2E8ULm222ROCD6xpHO3Jv WaEX+4Ir2Mne2g7lNAtfiZI2DjsNlxbNP3qJ5OkqLN6n6e9UZic5sgDtNWYk9L6LXahyUd2Foxs OHcyQlDqOxhONyTq7r03lS65L4+KzPBDyPYt/A1cZnSpTU7uYQhp8+ZTwGcP55VIAswIqiVXFwm 1lHI/vs6mu5PJeN5WWcDZJ6ILDIsTB5jXYbO0HEHYqo3B8F6tIQLQ1PJwPiVrcKfNoRYcAf+Ygt px9c2K3GH8K0kaIzGjthjOL22J9ek9yMbDQf7ZTPyJv05DisOyEH0EEXFfECQG3KiY X-Received: by 2002:a05:6000:29ce:b0:460:3b5d:43b6 with SMTP id ffacd0b85a97d-47f46373bb4mr7550356f8f.31.1784115861266; Wed, 15 Jul 2026 04:44:21 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:20 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:26 +0100 Subject: [PATCH v4 13/21] 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: <20260715-media-imx355-v4-13-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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 120eda46d982..17a2acc1152d 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -1074,7 +1074,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 */ @@ -1086,7 +1086,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_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) @@ -1448,6 +1450,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: @@ -1478,6 +1481,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 Sat Jul 25 17:34:50 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 D57EC47885F for ; Wed, 15 Jul 2026 11:44:24 +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=1784115869; cv=none; b=UuMKjIXip6yqO0qRdplHrBciRWoZBLrQ/nFkrTqBnykM92MrpLXh3adeJ+07CPcE4ln4EQ2xOz7goqw6RL7VASBDXNGe0qSX8COKtFnl3CfpGEWrkeRt6NgOU2ANOsm894SS1w19WsILMyDJIAzrTHyjiLYmj+UC2klE7yJSXpM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115869; c=relaxed/simple; bh=HdbiuQ9hrzt3ENIhE8rmztLy1tdY2xtHe47PqycJqCY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qOGizOxiFZkbvNe17XmiXF8MT8O6A6bvwmnyTdKPzEhQXbj6c5ZEuebmd8iEkWym7RRA2rsohpoon7s/UQnVNow2FiBLci1YZngxc75tuWCoyrupA7OWzpsSQm4sFn0+GrKDczvmwDSvSXi5mXUmD/gelXlIjjSoJFcQ92RIsC4= 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=KLWtTVSS; 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="KLWtTVSS" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-4720d22c94aso2128227f8f.1 for ; Wed, 15 Jul 2026 04:44:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115863; x=1784720663; 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=F9+BuODn1jDo43G5zG0OPU3+fs9eA8M+XWxL5q1Yvm8=; b=KLWtTVSSkrf90TZpMmQU7x89N24WP/iXTOwTRAsQeJ0rIA/a/J3eUB0eDzn5BMy4+K 0ppUOlsCQFBr1TVOAMdLT0oGXOVTs7yOXNfsdKxTudVuQic0mVuAPgizBmnFA/wJeXfS +YBQOV8lAhGjGS55fMiL0h2xMiAHEPJ1FMRvXQCmr3t6GrwOg4+Lg+POPoPXquVuSDXP OrnZhZ6gK8SSu/tkQqiCRXDFGWlUn7BdBltyPpAMg4jAUqxMngIqir9/Jlu7kdd0HE/I Xb7x9JKY+nuXlc0bf8WbCHH4d/z+qnDcuffjncMrdVk/U54MfZB4cmJV0UaSaJ4M0lNS J0vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115863; x=1784720663; 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=F9+BuODn1jDo43G5zG0OPU3+fs9eA8M+XWxL5q1Yvm8=; b=g7NPMUdyRkJmEqQACEAyEFFDn1oVgUpixpBuFt5ZwKACZ6KuNyGjguoebfrZgDhFro RGIyyOzko0VwgfBadvH+qH+4xmBuZ7aoDAg4qK8QMVsPgkz2BkBzu7DwIAHL1pZJahLD X4ouOUeNAUHmT8Mbeh+9xOo1fpwzNNTiywPaYpZ4qk2VwVikSAKn+yf3wW8ElG8axRFf U78pJhk/+0BbRv+xTDz7wjlGL2nK8bSQC6Kv4sdDodmXsnCNu4m4sp/9C34Kwm1tQ1fG l7UcRM2qHfYOUihixoFmDxQLKnVGyZTeNpufGV3BfQbDFOknCgGeufhkeLhx6ehJS/YB hjGg== X-Forwarded-Encrypted: i=1; AHgh+RoDbK6sZE6gh14xA3iNpfJ9ZFz13emldg6l+StxVBQMV5Yjpo0B8MUnQ9XAxzRMuhrHyU1p+PpD0xahBZ8=@vger.kernel.org X-Gm-Message-State: AOJu0YziLuIENdFAqPpI03efINRniMqTbhnPAsUsdSWsKxBUmYPssHpV PwQwkH0XwN0mYfh+guM4NK0gMEYcXVgCHn0E6e9PxOKcdI6XR4/oVmcuiXzOG7Tt/x0= X-Gm-Gg: AfdE7cnXU5PKgjnk60BryK7ztq0TpU4ZFMNyg/oxYDq+yNC5ygH5/ZgaRCo5pqpX4GF gRpU6aSFx6JsFLMqLi9AS648S1BTgwL2M38wGLdxk31vJqESzTaS+nqcBw9bYOzMfR3FLAiuJwa dxzq9L6c6sVWLjzfIdRitHWaRjdNLlp0OT2fnn4iPr1rCWXpzMaDOzmJ/KnTgNQ6wsQrVTOTDC6 mvgDXAkdUWfyv5ieD7khd2Jk13Mcvb2/o5qt8hoZHdywskkbXrLTA6hYPC9NZaVB10lUArCZQXU R5UdKnLtweLRDc+8CArEM9KVIeOVdB84QhcieJtIi3TmWE+7eFTfc2L9DVXHMXiOjSebF2rPPlF 0IC8AwbN4xqbU++DkNaqO4qB9AJhrslNReQlv4iL1E8Sv5kTBTwmscgp7kEA9Nj7qvSR+0qfldI vn9GySwBxng0cLmTEhN8arTCpiea31wdH7Phbvt3Huv6+UqL0eZvZBpDh98rpbNtUC X-Received: by 2002:a5d:5f49:0:b0:475:f0d1:eb5d with SMTP id ffacd0b85a97d-47f2dd15badmr19722835f8f.56.1784115862458; Wed, 15 Jul 2026 04:44:22 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:21 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:27 +0100 Subject: [PATCH v4 14/21] 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: <20260715-media-imx355-v4-14-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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 17a2acc1152d..52bdfe636231 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; @@ -957,100 +878,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) @@ -1097,14 +982,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; } @@ -1351,6 +1236,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 Sat Jul 25 17:34:50 2026 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.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 9B44C4534B4 for ; Wed, 15 Jul 2026 11:44:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115867; cv=none; b=SsZYvRKIfNJe06vbVuJ5gR8fvbg2dienXT93NpfkJha/3/iq8dtK0bi9i5oyLCGas8w252IdU5aJEL0sk5eQPglNHrYI5KDPmPfjFB1mSpg4kzI81RiVVWJEdfAFaLs96P0tnAC0GSMewwwOu4oG3xZUz1wOi84sUiEu4M1hIaM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115867; c=relaxed/simple; bh=M5cgImqp1X6ATs2zX8UAJD/o0x6k2f4ZZAV3K3styBY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uTkBb/HcQm0o2J3bRL4Ms7Sdxkg1TV4jHQ3bFoy1RyxLXACtkCafNhGl/UjDoY/sEAmUW0N5jCQi0hs2ubZladMcBzM+mWYiTTcN2Q4Fnf8Qgw+pZKo0Hm62N+PT+ldJw4DH6dTXt5ZqBCwNk/ybCL2BqQCz1GbElpuY0oe1zeQ= 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=l/guKJlf; arc=none smtp.client-ip=209.85.221.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="l/guKJlf" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-47d6c634f45so3033921f8f.3 for ; Wed, 15 Jul 2026 04:44:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115864; x=1784720664; 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=m8WwpwzBvrJSugqb6BxcRR4O4z6rF0/Sty/g6S/wo/w=; b=l/guKJlfeRznmhQGz4zK2j3sXKEOnwGSxZN0nQF6PF7po62nMnErc+r5mEbQoVEHPc K/n5LEUbMGzBCj855WnnqDzMMs1Imt5OXzkJoxZsOpT6BqUUFSdvLuv0JOzXL1SFO4l1 yKKRbOVqgxWMaAmRlZb2zoONRuNh/4Cl6Nhrn/FIRqwjFjniE6gcLxJliFs7eW8uEZFq 1rxgcgXAvezCUNjj+QypV4e61AWhytgFakzagQEpyS/n4s6ysKc63nUCDVOaBhS2YnHB HD0RKPgpFDiqVB2GS/3haqRyfM5Zbs9/hjKoTNhPZt8AQFyHZae8KBzItDDYFZlxY/dO Gphg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115864; x=1784720664; 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=m8WwpwzBvrJSugqb6BxcRR4O4z6rF0/Sty/g6S/wo/w=; b=nm/0ofkCeB73CD0IXg/MsADXpBwEs491E5gaxtw11WTPFTfaUSd3j289wcGqcD5aNb 7A8fZW5eFdH8LqFhJ9XrcflpK6dJg0+jeAko9dU7q76ijgtYwvyG/cdNqdXqOqH5MpP6 9gXr6zayihwrDvR0oTfbmawdTNoF6yKDeG7SSxDWfTaT+EiPA6XDV1Ko+GAOyNx1m3kU yrUAVqxrmA1wITHuaUlZGf2b/KrkLwxqLjKF3Oo5DeKWbeuP+iY6eRZRqnp2KpCsi6pD Kf4lXchtdWjN0cDjzbQpz91d54dtHGpTolfBibmFhkMrf+qPNUFysksAJ74FKPzDLsjJ jn7w== X-Forwarded-Encrypted: i=1; AHgh+RpOYtcGSf8XLkT6yQ7kX7VlUxIyqVoA5mpoKFgdIEi35Jsx2AlXG/esA5J9iU5EfGuBSjW5/GMN4UtO7HQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yz49fjvqm0fG2pEOzESsqYa1x6BLdDqTTwZvt9baJaj1hfO1EMa DG2HYFOSAGAb3pMqi9nb2ueC09sZsI02Jo9hRcwEHpO0ynMEOxSsFaJkQE/5c/IL9Es= X-Gm-Gg: AfdE7clGsLeIZP32FyW8uIVYdKySP2Oaz5QiS7Ykn6p6cdsKPud8F0zPpsg7mPCHT5X RUwtwpIr6IodVLDd5ASp8B2Qrv5KtbVC1EZtZ0Jkhefh5aaNm3iSj8x/nRt///32mlrjZu9czL2 uiVJWsDf8swOuunN3vFnvH72wrQ31DCc34n1MaJHnvbomvgzLTcLCsbcLIvSX9ST6vfrEhG1Ytq A837Y/5MbT2aUZ6AQqZvkH5wrEWG/HQyIr9xJwCtV1Ys0ArVbc0fMqwpJt9N6TKasESU3NGPbIj Gkr/4q6fSSy5U89qFS2StHsyFlZOTwEde3fUHh4//uzdiz+4ZPr1R4K9dmwiGZGUqtpgVdWZTbQ nP1LH+p1Rnjvr+jQW7aHQmlU7NPe/4L2KyXopicibxnJQvrerqRFeYVmYXcg7X1VFWUe7+3tgZ0 Tn773GNkGgq6Mex63KD3a17C0ZwSE5rh5DYcm8sEVEyCbWysYOXaWUIb/IB6iCL5/v X-Received: by 2002:adf:e186:0:b0:475:6c34:2120 with SMTP id ffacd0b85a97d-47f4887dd78mr7554369f8f.18.1784115863656; Wed, 15 Jul 2026 04:44:23 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:22 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:28 +0100 Subject: [PATCH v4 15/21] 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: <20260715-media-imx355-v4-15-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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 52bdfe636231..fa8a6851b44e 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->colorspace =3D V4L2_COLORSPACE_RAW; + try_fmt->ycbcr_enc =3D V4L2_YCBCR_ENC_601; + try_fmt->quantization =3D V4L2_QUANTIZATION_FULL_RANGE; + try_fmt->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 Sat Jul 25 17:34:50 2026 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.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 9F5A144C64E for ; Wed, 15 Jul 2026 11:44:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115868; cv=none; b=q0zamm9agpPrwx4Rj16c3yGrFSPJpnCAuN1i/iQRe6Ei4mOiDHjtE2iG4zluj9gY+gvkzuABgWehbx55TVlJMsCiFZ6Sw1A+k1o/L2H2/PT8YRTpGe8CSc4YO8ip4f2BOjlUxr9dxHxtiewPRHLwv/+12jXwQtJrHMwiyo4Kj5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115868; c=relaxed/simple; bh=G7QPlTkMee79QYHS9v7Qtnk2HOJP0RmJkXzxeJoizP4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=G7NvhkssImzHBDjH4xQPi8PMtF9qIob3eUJGNJ1bE5MEkZvrkRo8lUg88b/MFlR9DGyx4QL2gQ59uKyXtEdvcSRmzRIkYdcsmzXba1I1EYLwvZ7wufKIaUz4LKIw1LczGL5PrW5P1k5QFkhLwAnFE1ktW9RftIQeleqBbO5KNX0= 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=Qf8qKwD7; arc=none smtp.client-ip=209.85.221.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="Qf8qKwD7" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-47640541585so2631683f8f.1 for ; Wed, 15 Jul 2026 04:44:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115864; x=1784720664; 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=wJiOXsXcQGmdy/lo82tEoHsjlQ3Yl1x4+oS64EHfJ50=; b=Qf8qKwD7Zqtw5ErpzI0iBDi+GnOXyT/EiKiMIMAK3XMElfuMTLfum+trDdvSOqlQt2 JheweUQsMZWsVp/coM5P3PW1CeTl6SOeZY/gsaK3We33MKJWhpYZX+WJMZslvVhZ46wb M1bxuvl+tXh+mFEMZ+j7o2Tk1J1BYOTd1xm2LAKW6yQT1Ylwv4sYa2vswKGe576ms5cN /6i1JNFRoJBVvqrnqlR5o9Pov0ApSUFh3dOqf+TpxTn/dh/bFqP1EBjj2vlGQ8hjkpza Jvgm8vvc4Z1dcfOAWIJ/GjKFt0GGd4WFh4hkShAIdPhyhvS0b0f9/gwpP4YMVujxkHPK OwXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115864; x=1784720664; 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=wJiOXsXcQGmdy/lo82tEoHsjlQ3Yl1x4+oS64EHfJ50=; b=T2Xl+2pSL8Wa8o6tROj2Sydloewit23rcJdr3QzfTtu62EoXpjeJOixA3L8zZyt9HX /Mt6BtafiG5EVkkuaT60pGq+u+F3gjiEUU7v5GHpNGtOeQTSTTNIZt9ZnwGT3bTp3tso 94etq6+bNrZRCIKj9A+9ngAk2j9YjsK9tx+JZRMuU6X8iY4Z+J/ljUsJSShgfzxpuTXe ydrEDmtRWFRhiOxkXVt13Sor+syivYmoJSNCGBsboKabySA6lZqcxEz7+W1akOTfKcI/ sNWDUrLFeG3GY5UPdLz2HwEvqhLB/GsCqj9UFF/ZbeEdDgrU2Phk1bk4h5HOdVvnyw5R VKpA== X-Forwarded-Encrypted: i=1; AHgh+Rr5KotJUaIdZPMZYxwCweZvoQlKgD6bWeikiYvmgBgN/1AfYfkrTOreyufflYle4XvPGVehcyT/tVaYIOY=@vger.kernel.org X-Gm-Message-State: AOJu0YydxaePhSR9w+C8lz86OTl2otDE0Dwxd3PPbbM+d9p/XClXf4ny Btn9rs59pkEQsFxSpnDxoVX9JJepLZwEZ+TqQ8nBSNGfPMvjDYqjo22oVlnDsGrFjtY= X-Gm-Gg: AfdE7cnOgkRrgI+IB4LSo9yu3n20xDtXSzpxecJ0ChtbbjZk3Dsy17WMn6496M+77J9 JPXJUa/eFuen9mP/+uTTZfqoCDIeGqwA4C+tDJ0Ep8mkw2wwfFxSxGa/E/ObZ1YwVK16nMhYHI8 I7xpit/VbpEBHsJgztqa+zqb13UVV3hSiyFJRHcpsEd4DnU/A6itT71wMFtVuKxo5Pcplfao/iV 3VeEdZnAl9NsITlaZB0/UMpV1SXJeiGQaHCqgFs89atulrMnE3lDHqeLdv9iP6PRo8u0QGtaHxv lpcvP9uuTRfD145rlVv/J1ZESZ7bqZ0aaCOHy8GqOoQHEYJkTZKrMt2YM6NgdzfdugrzfAYudZn 8gtT9uq/44aTCnnCh0fzkobJ3l9QpRlKta272m3IyyC/6LebxSBacI83yttqp49GWVECtjncH00 JbzGllDmH+szi+i4mpf7b24z9/Tye0GkS+dh0tU0OI3vkKHye9bbLAhp5EinBGoWL+iRDcMlOvk DI= X-Received: by 2002:a05:6000:186c:b0:475:3a97:8e3c with SMTP id ffacd0b85a97d-47f4fca833fmr2713850f8f.18.1784115864467; Wed, 15 Jul 2026 04:44:24 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:24 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:29 +0100 Subject: [PATCH v4 16/21] 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: <20260715-media-imx355-v4-16-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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 fa8a6851b44e..cc27a193cd81 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); @@ -1130,7 +1131,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 Sat Jul 25 17:34:50 2026 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.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 4C0F0472794 for ; Wed, 15 Jul 2026 11:44:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115869; cv=none; b=LG0HpUfWDoDVRZDl1v2zZX5tBVYZAHLxcNt7Gb//7m8d31TBmTipwA7nkO6KRsEvQz8rgpSd6TEMKp96qioorxzTaONtdtbo1CV/JGptGnpqUBwHgU549ev125lXCWZOvpQ7Qy9TFZB+P5M2k/9txawZtVkdW8QHWaxXyGdLn6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115869; c=relaxed/simple; bh=bcYfj5jJHsv6QgPHcDA8Qbrw7a2VO2b0E1lpdTZY960=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JU+zeaXC3gLxdKlqn5fkbbSxIHozkA9pYT68So5NmLM3B4CwhpZMOuYiJ+f0MZXjOLgFAgXuk4h9JvvctvG3k4shmSYbDr7gqqZbxsZcjudRU5Gf+4ZIy3c2OSiMd/VeqxK2KWzI7iIBRXhzWcOEP0a0r1qfuH8YSoC1NnqkZBA= 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=G1i2agav; arc=none smtp.client-ip=209.85.221.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="G1i2agav" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-4720f3bf164so335872f8f.1 for ; Wed, 15 Jul 2026 04:44:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115865; x=1784720665; 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=A3Ixs0kwhVNVHVrLz/R6Y5v0FE4WXlRn39OXAbjyA4o=; b=G1i2agavYPAJd21TmcoYhqzWhPZpO4h0q5NMhFn6wYdmQ99p8cgKDcjATedsff/j1r ApMM/IiYbiIx7vHA+7xcM440lODH9I6FRAA/mT9ABOxXoQw7MUTgb9ahkXic4fh2RCBn gb3x8YwfUuFs2cm6zqNjlll8rOfDP9WVXSrMy7ln0aoLFEF5tnvOOLaa63ytc6D2BDMT 25cB2QA0VE7r/WkCtN7LLXSGmnf5CUJYWRMj7HQrehgOIMrFRfDkHR6/zuXvzup2i9dM orMsa6Fth8MzBhEQO2VO1K/fif0x3yKXP0YGtb0bfNu2yEx17EnDmTrXDqtKtKwbdo05 aahA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115865; x=1784720665; 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=A3Ixs0kwhVNVHVrLz/R6Y5v0FE4WXlRn39OXAbjyA4o=; b=Djh/WXfE9C8nyafCqZoSr5rt1qpD1IBo3ftbByNSW1Aizln9sRSrGO4go9avy7+gja VLwDcCb9FSjXiA7YqBLGy/pA+g4XHyHtBOPMKsbNWdzg1N5iKIyzpwetIC99r26077b7 GEwPnHxSSgK84VlHlpAemIH7jM9SonUBVz94+oXEyVcTgmRL4D1/p/e4cEg9hGlBU7hc l2L0iNGvelmctgZEOg37O4GAHUGzLfqAE/JavsUtcyay9+CnyQWAkdVoOsDEZBcPZj2I x/ubBue56NSdSgLPFGGNIBmcowG2Fknyn6ZedwSoxKfWcZxJ/b/KlwxVxhQfpCBbfNjQ B+Gg== X-Forwarded-Encrypted: i=1; AHgh+RoaCH4muvJv3VmqdVKDYv3Hvne7I7rsdaU9HADtiiQagFXVPP3yuBrmCqlodFUS572ZfS+b3eQ4664DF9Q=@vger.kernel.org X-Gm-Message-State: AOJu0YzIcM3wdoW8CdAJsUDjsw9ob+Qz0wXQKmCWyp5TKntabhLwK9hL O/cFYBnOzqdxkokRpfIb3QaM14zcPCPLDKcf00QYb5rb3tNO11fkD5+Pvy9gkVTz48b8dmRRsh8 K/cws X-Gm-Gg: AfdE7cmz2NooO2HkuNBKpM+NXNxsu2XrUWFXMrNMEHaSOublujJjc/RLbp0MneEtZYh zP172NSirg3H4rDNTt5yPyChzsjq+zd1tETdb96Sd01rtqcvny39T9JNig1OKHSPMnrZRfBU7mj zEuch3H1tWmgrpBrWI2bZA4CQ8bVz2t4gCrYz2xU1ZgmaHREvepAzgKkYbmqXOVC2pGM2aRAf3M srGE/q0aa79KixdAMryl62B+Rch3dFrKMpHPXmz6lrQJ1G21uGuvqEOTK4aL6cTn6S4nIyIWxbs jYwmMuvwDIcLUzg9z5bakM8fERNAp1UWSYtE43Udz8XUvY9FKIhv4x43ZuFp6A0/5XfHWh0mtAU 1dXfTtcmkVHA6mZ9Ss7Ue4fGM6QWsS2oHf4Q5tTUlN1corShpPKpS7z7/ygs119Vq6JB22zw+7l uEMj8UXRhXmUCYOp+rCX7JxRW7PJ1njF4CQ4EUC/t+Q+aBfGu8RMjQMt5/z8oJWbPtCK0rLkw+z M4= X-Received: by 2002:a05:6000:184d:b0:474:3708:c8 with SMTP id ffacd0b85a97d-47f2dcc0d79mr21039734f8f.15.1784115865328; Wed, 15 Jul 2026 04:44:25 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:24 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:30 +0100 Subject: [PATCH v4 17/21] 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: <20260715-media-imx355-v4-17-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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 cc27a193cd81..3b3bf41485c2 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -1124,9 +1124,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 Sat Jul 25 17:34:50 2026 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.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 2736247CC73 for ; Wed, 15 Jul 2026 11:44:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115870; cv=none; b=ZlFRM5t5jziUC72RWSPyBdRyuEP77kJbuuSufUljKmOuOGWAnLYRGCcbYor8ztGu0iNzrS+aq8AU9huvYUDsiMVKKuX072FXVwb9Yt4Wii+Y7Me1TNGw7Hcb8r7KlfUYFzi7GigPcqLarYFcCw4kGeSLxlhy8FgnvdwgCNqNp3M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115870; c=relaxed/simple; bh=Wl8RfzI9IrUnC7tk+Es7yprPsqx3LPpSpAVr4tycswo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nCK4cr/opX+qVq+4BzzMj2nSYbwzAuOphkdZsnVpWhzSmC2C+9O/a+YPmLHrFroXp+RDdQd0BKCrhrYykEKbhKNqDYaFY6GnX8Am8amLXfHS/eaDqGGFBYNqOHIoApi3hnrHSFYSb5yyoD9+3fLYrBcQpTCFgOEKiq3ze45DCNU= 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=FgVMfjCH; arc=none smtp.client-ip=209.85.221.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="FgVMfjCH" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-47df6a5202bso3403757f8f.0 for ; Wed, 15 Jul 2026 04:44:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115866; x=1784720666; 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=pl7PA8UFD8aYyE0Hyiby4HzRH7HToq0zqg27/Ivv8vM=; b=FgVMfjCHbJUxN04u+ei6w7280x1K27WbYHcNJjvFeZ05KEttB/dT6qdCxQ2QjCyJlQ m2KHFQinBn4OjRxAnQPHhPT59AZ7xAWNIm+b2wMJU/+9sAceczSRV+VKqw8Si8MezOxa 9w8ovqXCQYLmbrbnlIRS/BhTKos1I/55UqmBHYXF3BASDtWHciwPQPAgVd1ECmeOQK39 kuwf6k5Lq3/wV0QUNzZVfFQlujVPVZ15rMM1PRHyuIbNele3mjQU/4jf8cwIhoWX4jwY JYW5xhaBPjOyAz9x4DYUtpHogSTdOkkehIzaU2iwphFg2Iee21hsUUYw1UV7oeDb+80I xPLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115866; x=1784720666; 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=pl7PA8UFD8aYyE0Hyiby4HzRH7HToq0zqg27/Ivv8vM=; b=X3Vx9Jz2sV9UOHVweV2tnJ74iJvGgYzMscW+hz8HNSbpAwIqS3XjUTlRE5ROxmnRd9 hU1M+RrwKXscHANDsGSe1y/4OqvYhKAdmE94W9MRpIfgKfvkuMjqtjCk4pzuX0zwhPqO DlxLVxo5FcgKqzmBWVcbIL2O6cwE8qO7PA8DIvlGu97wSY8mckMqtMuriOSrI/H6LQfH 6kzIKaKw4vtloaHJPQC597XXmcbrPajt4Vvl4S/HEGxyfy6lIGu7Uh0VRSotKiFfnMTV nizleiu2KLUjMhvr9xU3PXBpd7YubKNCnOjkmT+AxMus4fdVAvl/r8xYRXZxcde/acL1 dFsg== X-Forwarded-Encrypted: i=1; AHgh+RophIxcNDJ2iG9h0LSbt1XaZYLXJ/tps8lyqp09EqwZNOjPo5jDZ8kG1jPHkHnEiFIMwti2urstKRJ2RMw=@vger.kernel.org X-Gm-Message-State: AOJu0YwhSH84nHgV7LCRGqLmO20MvjQnSUqUPyDroAHL0+HhUF3PI4+a VnjAxZJ+kDuZAJ1ArFhHBFce65VfmCYxPmSey0zucmagnlLj5qgOQiyjiyMrNAp3M8w= X-Gm-Gg: AfdE7ckaWR9gULTe4Q0CdZX/f6Ar8Y4CMd99ujtLo5zM/3/08geAjcLeqSf8zmQXezv BI+f7euixN+HLHep2IGIFjEKfNpnj++xbG1oEdUPzVt4WKQjVeHY6TWEDeJgSTpDoZGbhxhrZpR TYkeFE9hND70/OvR4uxuPZhIs0qyjB4GDW9PA5b9m/MCh3Ca19JKBhx6cVrMkTPU+RcEH7yWY3Y IFb9t9Tw7rmOlfxc78i3+y9KQGwpcyVDNShAcLGwriftK9Ant8DYSw/mWa8Ag+AzmGWDolQd88M 6fz0EoEicPL4q4EeTKsJuojRIimHFcxi1CoBh4p0FcDN4xNwHsNn6ifZuLR2wkUrZ+/laPohkAL bjvxPbVZlkgUSITezb+WO+lulKstbxgIe3cqG4KZVUY23xOXYjK0qhJFKK0A/r6CtDA8AJkBn7V m1SV7RB9BbAkRFytvjHeYPfJx1zhU1c/p01QEeD8CzzU8WMzSfX/Z8eo6xxE+z6Brt X-Received: by 2002:a05:6000:4a0a:b0:47d:f43b:fd63 with SMTP id ffacd0b85a97d-47f4fcc1527mr2804147f8f.26.1784115866245; Wed, 15 Jul 2026 04:44:26 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:25 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:31 +0100 Subject: [PATCH v4 18/21] 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: <20260715-media-imx355-v4-18-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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 3b3bf41485c2..d8f8efc0c927 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 { { @@ -1092,7 +1086,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; @@ -1101,15 +1094,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, @@ -1184,12 +1176,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; @@ -1212,10 +1206,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; @@ -1286,7 +1281,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 Sat Jul 25 17:34:50 2026 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.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 DE2F747D93A for ; Wed, 15 Jul 2026 11:44:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115871; cv=none; b=PdjYk5g7PsWpPYxamcrns6rZbsiqeILTTcoPyfAs32M62EihczfmMcMVJ708kZvaXSW8sF9zEh9QMJ+7FKdL9BOeMkUzYxHrFPvZzxvPtz4IWWwXSYWTMetQV1IBFVbL5rkMsEJCu4A4fLJ6IydYV9LpZDtC9FCkHOpl/Mj8PCg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115871; c=relaxed/simple; bh=8PbXzZ6aRznYpPgcJJoO2WQ6LIaGIXP91hD7KkDmk6A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=U1TkVHzUEQakbE9VUMPNveMQFglPqLTNNJXde1/xT62MSZ7LaJsnGxnSED+bVltBn9MHw+/mTwPomubHNUqqUrSO7N3yvJiU47dbhY4MeFYyPLHi2JZPexOuifZoO1Nr/B8cvEkzSOg1BNUIRBMNcfkZRJMs03wvs+iXxOUcsWo= 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=ACitcf9Y; arc=none smtp.client-ip=209.85.221.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="ACitcf9Y" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-47ddf7b09aaso3675799f8f.3 for ; Wed, 15 Jul 2026 04:44:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115867; x=1784720667; 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=7WYV69Q5Wdb4HS39stRpOxjww5BiVa7E3BV42f2cvng=; b=ACitcf9Y1PUKpftJDb16UEWLOzN5uAF5m2xm+y2+xLT3WBsq0a9POQEe3W0P6sh1Qv UZ9F4p4tKlnixdujFnKp09WdiRj8udvMWNwStoUz0JbkIhM/qkSdsRPiGUW7IzIXhmJ+ sHWdunFjw1gcbMK28awACQ6qzVDj9/Nk2ZDjFsfCH/RsQLw86U4+dhtSIVLF+cfAbpYn S+sBlLrpx0Sd72TIO4Uo6IUk/g0YGwpLmGftau0kWW9lwIR+o8D1gtIDLUKVcPC74QTW 0ik8XK8qH6Q+MLQc3HGH4yF1iaMe/0o8lA1SOaiNR8Um2PLs2erf4TK28xzBHgCjLAjm 38oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115867; x=1784720667; 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=7WYV69Q5Wdb4HS39stRpOxjww5BiVa7E3BV42f2cvng=; b=AIAJQ+dBIbNHvx1O7IVHO44orfFfWiMq5ktFfH3vFWUrWVF3s9S5NPsfa0YSECsyD2 1nY1BWTGt2tRWr5FUaCgYFmQrx/ZA8ax8HfKFXSWrdsYMoGZaJ2mk55QCOapIJ7/g/HA WPsM++EioF8aib0loHCYd5Kr4/C29aiu62J9RxXVH9QkPhxpU8bQHQoyB2PVvXCeceWU MjiHvCZ68BMmXL1aM2bTjf2ge/MiUWiNzAemG+mhRaMogHFq9mACAZOL7/5k0HV6uwbu 8dibQOAL1Yo7SLiw8dA487/XDdqJQ8ytKJpN6+3+NWaLE7rvpq3N+cdPkEBLwFqpcvhV 8cyA== X-Forwarded-Encrypted: i=1; AHgh+Rrsvf2ZtytBVJp6Nkw/jIyTjdm8nZ+gXpRJ79HHmHCVCoqEv3nSiYqbGWmSYeeSXUjTBIm0hTLuUX94dmE=@vger.kernel.org X-Gm-Message-State: AOJu0YzjpPD35QVtk9jo6DnBCYOMhxIkz6RGcQf9A8TPXIDQthiZbYLe ulOWOqQWc/ap1wIP8MyZQ2H8kPcNRxFBejJ1zRkZjfjXvkNTFMNu3YBXGpmr1hwU3+0= X-Gm-Gg: AfdE7clZ0WADtQR7CGegACki6yPGb0n5GcdkcTDhYdZazEqVGU7fw6uoqWmB54RQ7Om d2ii2J5aAXUAhOS91ASTudy0V9xMxbN2/lFrD734TLr7Sg/+QymtLalZQsU5D0OTAZMc3iy3epl L3/r0LSvU1eLJLzw2BBDCZi6Am6103n0jSvg16PzzKz7kjFZm9ODwGmzK0/7Ug/xtvPB9ZUKfdu Ou8cG/Iul/xFypdtsU+USDptQr+j8uMuMOXKhZwRRZ9KI7yRVdiscVm/kdGYN5rMMQlC6me7eWp /bUl1n5kcZSrGR+F0hq4YRD2PQulkIQLNG7/3/noRzwaEcP5NHdkkELzqvGTbEHOB/jey8lVs16 ehqBLNNS+Hz2qltJUUoVwomJ2JE7FU637xKngXEP4sQbbgNLjbTED96HOUmU4JyeQkg952LLXx0 KiWRg2mxZ2RpPcmRZ+AamEGhfz/Bs1Wr58Ag7g7lIJWQ2LO+N5iGwaKF9k4HJk6doJ X-Received: by 2002:a05:6000:120c:b0:478:2698:72f4 with SMTP id ffacd0b85a97d-47f46391de5mr7027400f8f.45.1784115867088; Wed, 15 Jul 2026 04:44:27 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:26 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:32 +0100 Subject: [PATCH v4 19/21] 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: <20260715-media-imx355-v4-19-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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 d8f8efc0c927..0462e0feee36 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 }, @@ -817,6 +824,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. @@ -880,6 +888,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 @@ -915,7 +925,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); @@ -1101,9 +1125,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 @@ -1186,6 +1210,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) @@ -1203,11 +1228,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 Sat Jul 25 17:34:50 2026 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.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 CD19E47DD64 for ; Wed, 15 Jul 2026 11:44:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115872; cv=none; b=Wp5mrlhPdkDF0fvCud+nDL/wroMq7mlp0hEmDdf0xla7l//DyP/grblUbWar3N3QzVR7WMR/RM4Hyjh/qRIBm/dzIdn3njvwF8DyvcGJRhFtYjoVDqALyxS29mWnV3xm7msxxdGVl9GoJ+ZL135o9IU/HuKdZu70Wxhese36SrQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115872; c=relaxed/simple; bh=RJLHcjeyXOdM+p7phfbtKuYXQOj/5YoCC9QQP9TuAQw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KlAsfZDcU8zt+i9elaDC9xTu0jXCDo2XLV5jxK2WERf0mQHD/fNZQrMBiy0t1H0QAAbjZSvfD2qr7LJkLQsm/lUcJci0HL7g0rAUt26LChuZgDDrDTf4aRR6japeSTzR00dk/fy902jeo5pqgQREfLNHJJbw6tJKyi20xDlEFT4= 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=UM2t7D22; arc=none smtp.client-ip=209.85.221.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="UM2t7D22" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-47122683cf3so3032819f8f.0 for ; Wed, 15 Jul 2026 04:44:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115868; x=1784720668; 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=uLcaTX0gw19qqcTHrDGxxCdqe+mBz3YklcK14/J/bAU=; b=UM2t7D22VajEj9kW6A7wTFfzxJ65fZRiUrjKD24UnVC0Pn4thwLJxKrAjeU1R6WcQS zRua2BvH1EAAL2kk4iMtdeq84AMYyLovu3bl0k2igVHMeIOc+fpMeCOg3oSNkY3gAKZG TfHvW9R59tUs+7X/kAdyxFrDjX1WjFonJX9OPTfk8SCmRFRyK7vNKnF18l3rMNqJ/Cc/ ySdr3thweSaqnGqwgyuh3LiGj5+RtkAbO+PsREYbxkX2BoWFCfPqCKSoQ4D37Tqco6Ef I0mIVBTU81gdd58Ve3DnWtu0TIMh7H3yWs0uWDWoQRkq15g5GS4KHFyGwiESK6b0hIUq q74Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115868; x=1784720668; 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=uLcaTX0gw19qqcTHrDGxxCdqe+mBz3YklcK14/J/bAU=; b=Jxy7c2lxmntD6Sw2+DuZTXlZptr/mXN7fEwvj8XGJzskcfYTb/dBl+K66FxgVVJDat cuIs1Qpl3/ER0/KFCZNLOPPyHJmICNOg0GGDLcpuVrjxSN1tMN53RUu3Y19/RnHu7Dim EzqNkD2TJly+5bug1mxOhGE6m1dsWXJMlyZRdJHrsjL6cYQdPY6NTmYi/qBUyOIkky7K cd1Qys2Pkep/Ug4QrqEssLnpO9pO85moUzSJ2KvDJnCj2keoC8T8fKRtvxENT0gHSiG2 t/llfs7ygCv2WCkBJ/a20Ne8B5KLfbZHRXh0gNhfbDuw1UOFSOQlFrSn5ZABv3EVhyQy aJJA== X-Forwarded-Encrypted: i=1; AHgh+RrNM8K9QC7+mgvbXnrQRxlJb6oCyqQOg+cMPaHe3B5zh9T+SiGH41L2xyVEUJgmmQJ1xtz+ecg+XItSGpM=@vger.kernel.org X-Gm-Message-State: AOJu0Ywrxyj7ktgVnvJyYg3uIuA1JooSrdIk5QGauQfTSBnSNp99I88G QuOTAm9Lis4xXyltURm3qicjPt//dlg0oV2uzuyAHaSqSCBfYp0csd1XPObGLCCcAsU= X-Gm-Gg: AfdE7cnNKn9Z9FhBOvJ/NgROUh0gTXgL6Phe0b1rO44ELV+kI7nwNs460tY6uQ+2hrH wmoIJqX1hEGkWrvEuzQijriYizyd/et9bWIhuirF25DOITkage5j1q3yDbEVtS0wx50bG/FENnR J6KRSY7DdgqXbfpglqeUH8BgcNOuEOUPKbxYPsINhYWF9x/NiqgPMlDqKRkJhvj56VKUgVTak3I R3lU4jgkqwGDxwlxLc0iYIAvufpiWVwh1whCohgFl3bqIJKioEMQh/yag6IFmGfN5ZIyrKbHVqF 1bXRhjOUNmkcxgz0IkWBvKKOBl5Iz0L07vo75B6jf2k4KDtPGca/wMWn6jX8zndyuMBkflYxJXE RHXcBsUiucsd+YZsoW+QjrcgraG6ohgl2W1s1VDBhGV+qT7O6jxaHPRDKUlquCFbyS0DTdDBNot ZYzHIyvUj2o/XkXdizdIyeyJ5RSDmEvyVwmuz1lQhJWV9g/0174OAapkzf73ibZeS2 X-Received: by 2002:a05:6000:2dc6:b0:47f:4c49:430e with SMTP id ffacd0b85a97d-47f4c494388mr6124368f8f.13.1784115867887; Wed, 15 Jul 2026 04:44:27 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:27 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:33 +0100 Subject: [PATCH v4 20/21] 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: <20260715-media-imx355-v4-20-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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 | 183 ++++++++++++++---------------------------= ---- 1 file changed, 55 insertions(+), 128 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index 0462e0feee36..97f4594f7ed9 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->colorspace =3D V4L2_COLORSPACE_RAW; - try_fmt->ycbcr_enc =3D V4L2_YCBCR_ENC_601; - try_fmt->quantization =3D V4L2_QUANTIZATION_FULL_RANGE; - try_fmt->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, @@ -793,8 +728,6 @@ imx355_set_pad_format(struct v4l2_subdev *sd, s64 h_blank; u32 height; =20 - mutex_lock(&imx355->mutex); - /* * Only one bayer order is supported. * It depends on the flip settings. @@ -806,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; @@ -834,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: @@ -883,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) { @@ -968,9 +893,10 @@ 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 - mutex_lock(&imx355->mutex); + state =3D v4l2_subdev_lock_and_get_active_state(sd); =20 if (enable) { ret =3D pm_runtime_resume_and_get(imx355->dev); @@ -993,14 +919,14 @@ 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); + v4l2_subdev_unlock_state(state); =20 return ret; =20 err_rpm_put: pm_runtime_put_autosuspend(imx355->dev); err_unlock: - mutex_unlock(&imx355->mutex); + v4l2_subdev_unlock_state(state); =20 return ret; } @@ -1034,7 +960,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, @@ -1051,7 +977,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) @@ -1117,7 +1043,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); @@ -1266,8 +1191,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), @@ -1296,7 +1219,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", @@ -1304,7 +1227,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 */ @@ -1313,13 +1236,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); @@ -1352,6 +1274,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_media_entity_free; + } + /* * Device is already turned on by i2c-core with ACPI domain PM. * Enable runtime PM and turn off the device. @@ -1363,16 +1292,18 @@ static int imx355_probe(struct i2c_client *client) =20 ret =3D v4l2_async_register_subdev_sensor(&imx355->sd); if (ret < 0) - goto error_media_entity_runtime_pm; + goto error_subdev_cleanup_runtime_pm; =20 pm_runtime_idle(imx355->dev); =20 return 0; =20 -error_media_entity_runtime_pm: +error_subdev_cleanup_runtime_pm: pm_runtime_disable(imx355->dev); pm_runtime_set_suspended(imx355->dev); pm_runtime_dont_use_autosuspend(imx355->dev); + v4l2_subdev_cleanup(&imx355->sd); +error_media_entity_free: media_entity_cleanup(&imx355->sd.entity); =20 error_handler_free: @@ -1381,9 +1312,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 @@ -1393,6 +1321,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 @@ -1404,8 +1333,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 Sat Jul 25 17:34:50 2026 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.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 E662944C666 for ; Wed, 15 Jul 2026 11:44:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115874; cv=none; b=aQUmGX0h+f/kLZZptFAgct8rIm5DcE7adJsFI6u3gdjDmTl6SXSlBHLXU8RES02V4yChyvqZ6n3j16Zk9cwfHQSOe3yER83vyOywp6mcgK/AgRFnSSQOodlBiSqUV3bXuDrs2zceumvMWI/tptuc5Js+jo06n/4OHWpvgdxeIDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784115874; c=relaxed/simple; bh=mfwE1jS44P0uqg4CKploF2o77CG8x0RmlqjldJ8mKfI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tJp6gQxpFXJXhXavkO32DL5tFsILaIAqItGVFzD4SiKB86GP656LR/8GSoTeC5/C54pE39A/GbvBRR3/GXVRAKuuF4ZO4YE+VqEZLspeD/rtLhHTNOUvb8VXJzxDtVp7NSzfPI9cozC7XlthcdtD3JPWRZ9gEUQntQ3hjiCcUZk= 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=jk+nrJwx; arc=none smtp.client-ip=209.85.221.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="jk+nrJwx" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-47362928f65so4875475f8f.2 for ; Wed, 15 Jul 2026 04:44:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1784115869; x=1784720669; 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=xH4qi8mC8sbk2Ii8u4ToEy3cMhSAHSqVasTCYHLS6qA=; b=jk+nrJwxmFOaA1nGei4O/GXhgaMIBfeE7nxK1YKqxPvR/2PMIRlS2IJ2lQ+THnVTdY HrMyb4z3xdoakpJzQZKmdZRDaiNlKLjEIpZXc6UxmhdeZ1TjKvW51gY8qDmEhtLZg9K5 w1+e5Ust7deOv/p2WE4xyBL03ad45kLAFo3RXRWvb9wX5ewr6k/Z8dnk0R+GFGCDzNsv vzQBkkpFyoLZ5WniNnr+Q+7MHQfPuAuQK4i6m+cmwNw5Xarfs2FTTy8OXseAQ7ZvSiT3 msKDJ7Kpe7icRb4FhO0fblpDQJ11RdSrhyIiF2RMldG7VHPUGjO0cIV1Rog1g+03I70a tC+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784115869; x=1784720669; 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=xH4qi8mC8sbk2Ii8u4ToEy3cMhSAHSqVasTCYHLS6qA=; b=Rilz6Ub4m1Dp8uMN4twngAL96hjh/zz7FmaMNzpe2hfCYahtqmN6kWcQZeI/LIJ7FA z91eNlpFV4wd83BAzkyg0V5jkoFf/AmIFGqhYFVHa+Mhxf+QGPpPLhDK53M/bD8KytYi dym3aYUNWcA5D+/DGcBvk10o3WEtL+DMIj1gY5ZpGL6Wx3yuKoWhaTUUgHUG1qTbmjZ1 8l0ybGDlzIXvxw/CA6Wh55POqitq1gQtzWKzCQVC71Jue9TmUwYCn9pC4xNMG/mmj0Sd FgKKmVAtKC+Jm1/6KEyItjgQFGpSyV+GjK2OOY2gAmnMGM3NwU3s+EOgUH93EyiHtepk eJ+g== X-Forwarded-Encrypted: i=1; AHgh+RrxLMio9YYMlqlSiZ4al1Ix/wGD1q3TdMs40vGfa+u+FdZY6GKUJXk7fiy0jobrXeY1J0fiRPaDwxN0XRQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxDRBbSHXsWiWn/jdpBQjx/leTVlWBwUiwYjQMDttP96a6SMobq nf6/jnW5s9m0dt98Ak0CXFYBvoo2fWR90gd2pbPUt48o9JGU/OpyiivjpfeSt9wCWYs= X-Gm-Gg: AfdE7cl1Wj8gpktjioOLXCw9hoCtl9OGWRz431gxkQIq0Ozp9LMW8qZISHGow5V1AP6 OYXUBhFHQIbdOBodViWBbil8ynawXtciCgZ7fRei1IBxLEtv+de0JoQ4kiUFf8wM9bX9cDFpqMW dwJ/mm6YyUGWSv4Nbc2TNwqLBFhWVDkTjfR2zkLcMloFKoQoJcXKsQTAvFwu2tE81VF2Huqse9n 6LqmvK39ZSTpynwOJlu4tzf4pGqaWrt2nYUenQzXI8IGTyIEJ9rSCJqX4K1Zxws+dhaoCEj25hh JdW+ueW8yPCT6Slu0vzqi3oSk1fJBHsAtnjdHy/ZhYKZdCuWx0Wj9m4suP1Vq5TXl08qJuHwZWX hEqERa3Nx4X/ppQcbcmxjtFVWurgCp5VyW6EsITCIVXs818IVIC0oWu78fyOe8hDUqzi4UQiB7E SsYEMOfPCGrRfnXSH2FRS0nx0ksJj06ldfqFKL135Aw90gl97PNVaZxjmDFhB9czzU X-Received: by 2002:adf:e011:0:10b0:47f:53b8:4e70 with SMTP id ffacd0b85a97d-47f53b84e90mr525804f8f.55.1784115868841; Wed, 15 Jul 2026 04:44:28 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-47f4829896asm14005425f8f.23.2026.07.15.04.44.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 04:44:28 -0700 (PDT) From: Dave Stevenson Date: Wed, 15 Jul 2026 12:43:34 +0100 Subject: [PATCH v4 21/21] 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: <20260715-media-imx355-v4-21-f7f966fb9ffd@raspberrypi.com> References: <20260715-media-imx355-v4-0-f7f966fb9ffd@raspberrypi.com> In-Reply-To: <20260715-media-imx355-v4-0-f7f966fb9ffd@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 | 63 +++++++++++++++++++++---------------------= ---- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index 97f4594f7ed9..8eb8588cb71b 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) @@ -1031,11 +1030,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; @@ -1057,7 +1056,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, @@ -1250,9 +1248,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