From: Sergey Lebedev <lsa.uz@pm.me>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: "Benjamin Mugnier" <benjamin.mugnier@foss.st.com>,
"Sylvain Petinot" <sylvain.petinot@foss.st.com>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Dan Scally" <dan.scally@ideasonboard.com>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Peter Marshall" <pm@petermarshall.ca>,
"George Neacsu" <geocausa@gmail.com>,
"Hao Yao" <hao.yao@intel.com>,
"Fernando Rimoli" <fernandorimoli11@gmail.com>,
"Emfox Zhou" <emfox@debian.org>,
"D. Manresa" <dmanresa@gmail.com>,
"Jizhou Tong" <fqwqf@fqwqf.xyz>,
linux-media@vger.kernel.org, platform-driver-x86@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] fixup! media: i2c: Add ST VD55G0 global shutter sensor driver
Date: Fri, 20 Nov 2026 15:25:09 +0000 [thread overview]
Message-ID: <20261120152501.82411-1-lsa.uz@pm.me> (raw)
In-Reply-To: <awAyiCEXYnf2TJpC@kekkonen.localdomain>
Sakari's review of v5 2/6:
- name the test patterns as the manual describes them, in the words
other sensor drivers use;
- keep the auto exposure cold start in the exposure controls' current
values, as vd55g1 does, rather than in a copy in the driver;
- no runtime PM reference across probe: autosuspend is set up after
registration, and pm_runtime_idle() ends probe;
- in remove, set the device suspended only when it was not.
Signed-off-by: Sergey Lebedev <lsa.uz@pm.me>
---
Hi Sakari,
The fixup for v5 2/6, as you suggested. 3/6 to 6/6 do not touch the file.
- The test patterns are named after the manual's table, UM2829, in the
words vd55g1 and the CCS drivers use.
- The cold start is the exposure controls' cur.val now. The first stream
after probe therefore starts from their defaults, 200 lines, where v5's
copy started from 50.
- On the error path only pm_runtime_put_noidle() went:
pm_runtime_disable() and pm_runtime_set_suspended() stay, as in imx219,
since probe sets the device active. The autosuspend delay and
use_autosuspend() moved after registration too. With no reference
held, either call before it would suspend the sensor at once.
Tested on the Surface Pro 11, on 7.4.0-rc1 with KASAN and lockdep:
- probe powers the sensor off after registration, not before;
- v4l2-compliance 46/46, capture at 59.14 fps;
- in every stream the cold start registers equal the controls read
before it: the defaults after probe, then what the last stream left,
manual or auto;
- each test pattern writes v5's PATGEN_CTRL value;
- a failed registration, and unbind, leave the clock and supplies off
without a WARN.
Sergey
Tool use, per Documentation/process/generated-content.rst (Assisted-by
tags in commits were dropped in 7.4-rc1):
* My contributions to this series were prepared with Claude Code
(claude-opus-5-5); work by others in it is their own.
* This replaces any Assisted-by tags in earlier versions.
drivers/media/i2c/vd55g0.c | 65 ++++++++++++++++----------------------
1 file changed, 27 insertions(+), 38 deletions(-)
diff --git a/drivers/media/i2c/vd55g0.c b/drivers/media/i2c/vd55g0.c
index 99bfb05225d..dc1cf48bee6 100644
--- a/drivers/media/i2c/vd55g0.c
+++ b/drivers/media/i2c/vd55g0.c
@@ -726,13 +726,13 @@ static const struct vd55g0_patch vd55g0_patch_cut2 = {
static const char * const vd55g0_test_pattern_menu[] = {
"Disabled",
- "Solid",
- "Colorbar",
- "Gradbar",
- "Hgrey",
- "Vgrey",
- "Dgrey",
- "PN28",
+ "Solid Colour",
+ "Vertical Colour Bars",
+ "Colour Bars With Fade to Grey",
+ "Horizontal Grey Scale",
+ "Vertical Grey Scale",
+ "Diagonal Grey Scale",
+ "Pseudo-random Noise (PN28)",
};
static const s64 vd55g0_ev_bias_menu[] = {
@@ -863,12 +863,6 @@ struct vd55g0_dev {
struct v4l2_ctrl *dgain_ctrl;
};
struct v4l2_ctrl *ae_lock_ctrl;
- /* What the last stream applied, for the next one to start from */
- struct {
- u16 expo;
- u16 digital_gain;
- u8 analog_gain;
- } cold_start;
};
static inline struct vd55g0_dev *to_vd55g0_dev(struct v4l2_subdev *sd)
@@ -1161,16 +1155,20 @@ vd55g0_try_fmt(struct v4l2_mbus_framefmt *fmt)
return mode;
}
+/* The auto exposure starts from the exposure controls' current values */
static int vd55g0_apply_cold_start(struct vd55g0_dev *sensor)
{
+ /* A range change under auto exposure did not clamp it */
+ u32 expo = min_t(s64, sensor->expo_ctrl->cur.val,
+ sensor->expo_ctrl->maximum);
int ret = 0;
- vd55g0_write(sensor, VD55G0_REG_AE_COLDSTART_COARSE_EXPOSURE,
- sensor->cold_start.expo, &ret);
+ vd55g0_write(sensor, VD55G0_REG_AE_COLDSTART_COARSE_EXPOSURE, expo,
+ &ret);
vd55g0_write(sensor, VD55G0_REG_AE_COLDSTART_ANALOG_GAIN,
- sensor->cold_start.analog_gain, &ret);
+ sensor->again_ctrl->cur.val, &ret);
vd55g0_write(sensor, VD55G0_REG_AE_COLDSTART_DIGITAL_GAIN,
- sensor->cold_start.digital_gain, &ret);
+ sensor->dgain_ctrl->cur.val, &ret);
return ret;
}
@@ -1288,11 +1286,12 @@ static void vd55g0_save_exposure(struct vd55g0_dev *sensor)
/* On a read error, keep what the previous stream left */
if (!vd55g0_read(sensor, VD55G0_REG_APPLIED_COARSE_EXPOSURE, &val,
NULL))
- sensor->cold_start.expo = val;
+ sensor->expo_ctrl->cur.val = min_t(u64, val,
+ sensor->expo_ctrl->maximum);
if (!vd55g0_read(sensor, VD55G0_REG_APPLIED_DIGITAL_GAIN, &val, NULL))
- sensor->cold_start.digital_gain = val;
+ sensor->dgain_ctrl->cur.val = val;
if (!vd55g0_read(sensor, VD55G0_REG_APPLIED_ANALOG_GAIN, &val, NULL))
- sensor->cold_start.analog_gain = val;
+ sensor->again_ctrl->cur.val = val;
}
static void vd55g0_stream_disable(struct vd55g0_dev *sensor)
@@ -1693,14 +1692,9 @@ static int vd55g0_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
u64 expo, again, dgain;
int ret = 0;
- /* Unpowered: the last stream's values, the next one's start */
- if (!pm_runtime_get_if_in_use(dev)) {
- sensor->expo_ctrl->val = min_t(u32, sensor->cold_start.expo,
- sensor->expo_ctrl->maximum);
- sensor->again_ctrl->val = sensor->cold_start.analog_gain;
- sensor->dgain_ctrl->val = sensor->cold_start.digital_gain;
+ /* Unpowered: the current values, which the last stream left */
+ if (!pm_runtime_get_if_in_use(dev))
return 0;
- }
vd55g0_read(sensor, VD55G0_REG_APPLIED_COARSE_EXPOSURE, &expo, &ret);
vd55g0_read(sensor, VD55G0_REG_APPLIED_ANALOG_GAIN, &again, &ret);
@@ -2066,9 +2060,6 @@ static int vd55g0_probe(struct i2c_client *client)
if (IS_ERR(sensor->regmap))
return dev_err_probe(&client->dev, PTR_ERR(sensor->regmap),
"failed to init CCI\n");
- sensor->cold_start.expo = 0x32;
- sensor->cold_start.digital_gain = 256;
- sensor->cold_start.analog_gain = 0;
handle = fwnode_graph_get_endpoint_by_id(dev_fwnode(dev), 0, 0, 0);
@@ -2140,12 +2131,8 @@ static int vd55g0_probe(struct i2c_client *client)
goto error_media_entity;
}
- /* Held until registered, so that runtime PM cannot power it down */
pm_runtime_set_active(dev);
- pm_runtime_get_noresume(dev);
pm_runtime_enable(dev);
- pm_runtime_set_autosuspend_delay(dev, 1000);
- pm_runtime_use_autosuspend(dev);
ret = v4l2_async_register_subdev_sensor(&sensor->sd);
if (ret) {
@@ -2153,7 +2140,9 @@ static int vd55g0_probe(struct i2c_client *client)
goto error_pm_runtime;
}
- pm_runtime_put_autosuspend(dev);
+ pm_runtime_set_autosuspend_delay(dev, 1000);
+ pm_runtime_use_autosuspend(dev);
+ pm_runtime_idle(dev);
dev_dbg(&client->dev, "vd55g0 probe successfully\n");
@@ -2167,7 +2156,6 @@ static int vd55g0_probe(struct i2c_client *client)
error_pm_runtime:
pm_runtime_disable(dev);
pm_runtime_set_suspended(dev);
- pm_runtime_put_noidle(dev);
v4l2_subdev_cleanup(&sensor->sd);
error_media_entity:
media_entity_cleanup(&sensor->sd.entity);
@@ -2190,9 +2178,10 @@ static void vd55g0_remove(struct i2c_client *client)
v4l2_ctrl_handler_free(sensor->sd.ctrl_handler);
pm_runtime_disable(&client->dev);
- if (!pm_runtime_status_suspended(&client->dev))
+ if (!pm_runtime_status_suspended(&client->dev)) {
vd55g0_power_off(&client->dev);
- pm_runtime_set_suspended(&client->dev);
+ pm_runtime_set_suspended(&client->dev);
+ }
}
static const struct of_device_id vd55g0_dt_ids[] = {
--
2.54.0
next prev parent reply other threads:[~2026-11-20 15:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 9:58 [PATCH v5 0/6] media: Add the ST VD55G0 global shutter sensor Sergey Lebedev
2026-11-14 9:58 ` [PATCH v5 1/6] dt-bindings: media: i2c: st,vd55g1: Add ST VD55G0 Sergey Lebedev
2026-11-14 9:58 ` [PATCH v5 2/6] media: i2c: Add ST VD55G0 global shutter sensor driver Sergey Lebedev
2026-11-20 11:44 ` Sakari Ailus
2026-11-20 15:25 ` Sergey Lebedev [this message]
2026-11-14 9:58 ` [PATCH v5 3/6] platform/x86: int3472: Map the VD55G0 supplies to "vddio" and "vana" Sergey Lebedev
2026-11-14 9:58 ` [PATCH v5 4/6] media: ipu-bridge: Add ST VD55G0 Sergey Lebedev
2026-11-14 9:58 ` [PATCH v5 5/6] media: ipu-bridge: Index the sensor device properties as the endpoint ones Sergey Lebedev
2026-11-14 9:59 ` [PATCH v5 6/6] media: ipu-bridge: Add the Surface Pro 8, 9 and 11 infrared illuminator Sergey Lebedev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261120152501.82411-1-lsa.uz@pm.me \
--to=lsa.uz@pm.me \
--cc=benjamin.mugnier@foss.st.com \
--cc=conor+dt@kernel.org \
--cc=dan.scally@ideasonboard.com \
--cc=devicetree@vger.kernel.org \
--cc=dmanresa@gmail.com \
--cc=emfox@debian.org \
--cc=fernandorimoli11@gmail.com \
--cc=fqwqf@fqwqf.xyz \
--cc=geocausa@gmail.com \
--cc=hansg@kernel.org \
--cc=hao.yao@intel.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=pm@petermarshall.ca \
--cc=robh@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=sylvain.petinot@foss.st.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®