[PATCH] media: i2c: ov5645: Initialize the default mode
From: raoxu
Date: Mon Nov 09 2026 - 04:53:21 EST
From: Xu Rao <raoxu@xxxxxxxxxxxxx>
ov5645_init_state() initializes the default 1920x1080 format through a
TRY-format operation. As a result, ov5645_set_format() does not update
the driver private current_mode, which is only changed for ACTIVE
formats.
Starting streaming without an explicit ACTIVE format then dereferences
a NULL current_mode in ov5645_enable_streams(). The pixel rate and link
frequency controls also use values unrelated to the default 1080p mode.
Initialize current_mode to the same 1920x1080 mode used by init_state(),
and use that mode to initialize the pixel rate and link frequency
controls. ACTIVE format changes continue to update the mode and controls
through the existing path.
The supplied fix was reviewed and this commit message prepared with
OpenCode AI assistance.
Fixes: f92711869c53 ("media: i2c: ov5645: Use subdev active state")
Signed-off-by: Xu Rao <raoxu@xxxxxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
---
drivers/media/i2c/ov5645.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
index a8d740ed4dc9..e77d70078097 100644
--- a/drivers/media/i2c/ov5645.c
+++ b/drivers/media/i2c/ov5645.c
@@ -1024,6 +1024,7 @@ static int ov5645_probe(struct i2c_client *client)
ov5645->i2c_client = client;
ov5645->dev = dev;
+ ov5645->current_mode = &ov5645_mode_info_data[1];
endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1);
if (!endpoint)
@@ -1095,12 +1096,14 @@ static int ov5645_probe(struct i2c_client *client)
ov5645->pixel_clock = v4l2_ctrl_new_std(&ov5645->ctrls,
&ov5645_ctrl_ops,
V4L2_CID_PIXEL_RATE,
- 1, INT_MAX, 1, 1);
+ 1, INT_MAX, 1,
+ ov5645->current_mode->pixel_clock);
ov5645->link_freq = v4l2_ctrl_new_int_menu(&ov5645->ctrls,
&ov5645_ctrl_ops,
V4L2_CID_LINK_FREQ,
ARRAY_SIZE(link_freq) - 1,
- 0, link_freq);
+ ov5645->current_mode->link_freq,
+ link_freq);
if (ov5645->link_freq)
ov5645->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
--
2.50.1