* [PATCH v2 00/16] media: i2c: Miscellaneous features and fixes for OV5647
@ 2025-11-18 12:02 Jai Luthra
2025-11-18 12:02 ` [PATCH v2 01/16] media: i2c: ov5647: Initialize subdev before controls Jai Luthra
` (15 more replies)
0 siblings, 16 replies; 19+ messages in thread
From: Jai Luthra @ 2025-11-18 12:02 UTC (permalink / raw)
To: Sakari Ailus, Dave Stevenson, Jacopo Mondi, Mauro Carvalho Chehab,
Naushir Patuck, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-media, linux-kernel, devicetree, Mauro Carvalho Chehab,
Kieran Bingham, David Plowman, Laurent Pinchart, Peter Robinson,
Stefan Wahren, Ivan T. Ivanov, Jacopo Mondi, Jai Luthra
This series adds support for some important features, like controls for
H/VFLIP, horizontal blanking, link frequency and regulator support that
is present in the downstream kernel to support the Raspberry Pi v1 camera
module.
Additionally, it also fixes some known issues with streaming lockups and
wrong pixel array size.
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
Changes in v2:
- Drop [PATCH 4/13] as it is already present in mainline
- Add a fix for a potential segfault by reordering ov5647_init_controls
after v4l2_i2c_subdev_init in the probe
- Add 2 new patches updating dt-bindings for regulators and
rotation/orientation
- Add a patch for cleaning up the PIXEL_RATE control
- Reorder the patches in the series, moving all fixes at the start
- Fix review comments from Jacopo, Stefan, Kieran and Dave, picking
Jacopo's R-by tag on a few patches
- Link to v1: https://lore.kernel.org/r/20251028-b4-rpi-ov5647-v1-0-098413454f5e@ideasonboard.com
---
Dave Stevenson (7):
media: i2c: ov5647: Add support for regulator control
media: i2c: ov5647: Use v4l2_async_register_subdev_sensor for lens binding
media: i2c: ov5647: Add control of V4L2_CID_HBLANK
media: i2c: ov5647: Tidy up mode registers to make the order common
media: i2c: ov5647: Separate out the common registers.
media: i2c: ov5647: Use the same PLL config for full, 1080p, and binned modes
media: i2c: ov5647: Add V4L2_CID_LINK_FREQUENCY control
David Plowman (4):
media: i2c: ov5647: Correct pixel array offset
media: i2c: ov5647: Correct minimum VBLANK value
media: i2c: ov5647: Sensor should report RAW color space
media: i2c: ov5647: Support HFLIP and VFLIP
Jai Luthra (4):
media: i2c: ov5647: Initialize subdev before controls
dt-bindings: media: ov5647: Add optional regulators
dt-bindings: media: ov5647: Allow props from video-interface-devices
media: i2c: ov5647: Tidy up PIXEL_RATE control
Laurent Pinchart (1):
media: i2c: ov5647: Parse and register properties
.../devicetree/bindings/media/i2c/ovti,ov5647.yaml | 14 +-
drivers/media/i2c/ov5647.c | 467 ++++++++++-----------
2 files changed, 238 insertions(+), 243 deletions(-)
---
base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787
change-id: 20251024-b4-rpi-ov5647-05b600758762
Best regards,
--
Jai Luthra <jai.luthra@ideasonboard.com>
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v2 01/16] media: i2c: ov5647: Initialize subdev before controls
2025-11-18 12:02 [PATCH v2 00/16] media: i2c: Miscellaneous features and fixes for OV5647 Jai Luthra
@ 2025-11-18 12:02 ` Jai Luthra
2025-11-18 12:02 ` [PATCH v2 02/16] media: i2c: ov5647: Correct pixel array offset Jai Luthra
` (14 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Jai Luthra @ 2025-11-18 12:02 UTC (permalink / raw)
To: Sakari Ailus, Dave Stevenson, Jacopo Mondi, Mauro Carvalho Chehab,
Naushir Patuck, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-media, linux-kernel, devicetree, Mauro Carvalho Chehab,
Kieran Bingham, David Plowman, Laurent Pinchart, Peter Robinson,
Stefan Wahren, Ivan T. Ivanov, Jacopo Mondi, Jai Luthra
In ov5647_init_controls() we call v4l2_get_subdevdata, but it is
initialized by v4l2_i2c_subdev_init() in the probe, which currently
happens after init_controls(). This can result in a segfault if the
error condition is hit, and we try to access i2c_client, so fix the
order.
Fixes: 4974c2f19fd8 ("media: ov5647: Support gain, exposure and AWB controls")
Suggested-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
drivers/media/i2c/ov5647.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index e193fef4fcedf4661564c032cd7dbd80a9fd30a6..f9fac858dc7ba754bdbebe1792f6fb0358781408 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -1420,15 +1420,15 @@ static int ov5647_probe(struct i2c_client *client)
sensor->mode = OV5647_DEFAULT_MODE;
- ret = ov5647_init_controls(sensor);
- if (ret)
- goto mutex_destroy;
-
sd = &sensor->sd;
v4l2_i2c_subdev_init(sd, client, &ov5647_subdev_ops);
sd->internal_ops = &ov5647_subdev_internal_ops;
sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
+ ret = ov5647_init_controls(sensor);
+ if (ret)
+ goto mutex_destroy;
+
sensor->pad.flags = MEDIA_PAD_FL_SOURCE;
sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
ret = media_entity_pads_init(&sd->entity, 1, &sensor->pad);
--
2.51.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 02/16] media: i2c: ov5647: Correct pixel array offset
2025-11-18 12:02 [PATCH v2 00/16] media: i2c: Miscellaneous features and fixes for OV5647 Jai Luthra
2025-11-18 12:02 ` [PATCH v2 01/16] media: i2c: ov5647: Initialize subdev before controls Jai Luthra
@ 2025-11-18 12:02 ` Jai Luthra
2025-11-18 12:02 ` [PATCH v2 03/16] media: i2c: ov5647: Correct minimum VBLANK value Jai Luthra
` (13 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Jai Luthra @ 2025-11-18 12:02 UTC (permalink / raw)
To: Sakari Ailus, Dave Stevenson, Jacopo Mondi, Mauro Carvalho Chehab,
Naushir Patuck, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-media, linux-kernel, devicetree, Mauro Carvalho Chehab,
Kieran Bingham, David Plowman, Laurent Pinchart, Peter Robinson,
Stefan Wahren, Ivan T. Ivanov, Jacopo Mondi, Jai Luthra
From: David Plowman <david.plowman@raspberrypi.com>
The top offset in the pixel array is actually 6 (see page 3-1 of the
OV5647 data sheet).
Fixes: 14f70a3232aa ("media: ov5647: Add support for get_selection()")
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
drivers/media/i2c/ov5647.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index f9fac858dc7ba754bdbebe1792f6fb0358781408..d9e300406f58e554de12d9062840353bdf7a226c 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -69,7 +69,7 @@
#define OV5647_NATIVE_HEIGHT 1956U
#define OV5647_PIXEL_ARRAY_LEFT 16U
-#define OV5647_PIXEL_ARRAY_TOP 16U
+#define OV5647_PIXEL_ARRAY_TOP 6U
#define OV5647_PIXEL_ARRAY_WIDTH 2592U
#define OV5647_PIXEL_ARRAY_HEIGHT 1944U
--
2.51.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 03/16] media: i2c: ov5647: Correct minimum VBLANK value
2025-11-18 12:02 [PATCH v2 00/16] media: i2c: Miscellaneous features and fixes for OV5647 Jai Luthra
2025-11-18 12:02 ` [PATCH v2 01/16] media: i2c: ov5647: Initialize subdev before controls Jai Luthra
2025-11-18 12:02 ` [PATCH v2 02/16] media: i2c: ov5647: Correct pixel array offset Jai Luthra
@ 2025-11-18 12:02 ` Jai Luthra
2025-11-18 12:02 ` [PATCH v2 04/16] media: i2c: ov5647: Sensor should report RAW color space Jai Luthra
` (12 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Jai Luthra @ 2025-11-18 12:02 UTC (permalink / raw)
To: Sakari Ailus, Dave Stevenson, Jacopo Mondi, Mauro Carvalho Chehab,
Naushir Patuck, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-media, linux-kernel, devicetree, Mauro Carvalho Chehab,
Kieran Bingham, David Plowman, Laurent Pinchart, Peter Robinson,
Stefan Wahren, Ivan T. Ivanov, Jacopo Mondi, Jai Luthra
From: David Plowman <david.plowman@raspberrypi.com>
Trial and error reveals that the minimum vblank value appears to be 24
(the OV5647 data sheet does not give any clues). This fixes streaming
lock-ups in full resolution mode.
Fixes: 2512c06441e3 ("media: ov5647: Support V4L2_CID_VBLANK control")
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
drivers/media/i2c/ov5647.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index d9e300406f58e554de12d9062840353bdf7a226c..191954497e3dba4b1de4094b2ea1328a6e287003 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -73,7 +73,7 @@
#define OV5647_PIXEL_ARRAY_WIDTH 2592U
#define OV5647_PIXEL_ARRAY_HEIGHT 1944U
-#define OV5647_VBLANK_MIN 4
+#define OV5647_VBLANK_MIN 24
#define OV5647_VTS_MAX 32767
#define OV5647_EXPOSURE_MIN 4
--
2.51.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 04/16] media: i2c: ov5647: Sensor should report RAW color space
2025-11-18 12:02 [PATCH v2 00/16] media: i2c: Miscellaneous features and fixes for OV5647 Jai Luthra
` (2 preceding siblings ...)
2025-11-18 12:02 ` [PATCH v2 03/16] media: i2c: ov5647: Correct minimum VBLANK value Jai Luthra
@ 2025-11-18 12:02 ` Jai Luthra
2025-11-18 12:02 ` [PATCH v2 05/16] dt-bindings: media: ov5647: Add optional regulators Jai Luthra
` (11 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Jai Luthra @ 2025-11-18 12:02 UTC (permalink / raw)
To: Sakari Ailus, Dave Stevenson, Jacopo Mondi, Mauro Carvalho Chehab,
Naushir Patuck, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-media, linux-kernel, devicetree, Mauro Carvalho Chehab,
Kieran Bingham, David Plowman, Laurent Pinchart, Peter Robinson,
Stefan Wahren, Ivan T. Ivanov, Jacopo Mondi, Jai Luthra
From: David Plowman <david.plowman@raspberrypi.com>
As this sensor captures RAW bayer frames, the colorspace should be
V4L2_COLORSPACE_RAW instead of SRGB.
Fixes: a8df5af695a1 ("media: ov5647: Add SGGBR10_1X10 modes")
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
drivers/media/i2c/ov5647.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index 191954497e3dba4b1de4094b2ea1328a6e287003..c0f1121b025e5592d6fd4d5fd23e4262dde2d84c 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -508,7 +508,7 @@ static const struct ov5647_mode ov5647_modes[] = {
{
.format = {
.code = MEDIA_BUS_FMT_SBGGR10_1X10,
- .colorspace = V4L2_COLORSPACE_SRGB,
+ .colorspace = V4L2_COLORSPACE_RAW,
.field = V4L2_FIELD_NONE,
.width = 2592,
.height = 1944
@@ -529,7 +529,7 @@ static const struct ov5647_mode ov5647_modes[] = {
{
.format = {
.code = MEDIA_BUS_FMT_SBGGR10_1X10,
- .colorspace = V4L2_COLORSPACE_SRGB,
+ .colorspace = V4L2_COLORSPACE_RAW,
.field = V4L2_FIELD_NONE,
.width = 1920,
.height = 1080
@@ -550,7 +550,7 @@ static const struct ov5647_mode ov5647_modes[] = {
{
.format = {
.code = MEDIA_BUS_FMT_SBGGR10_1X10,
- .colorspace = V4L2_COLORSPACE_SRGB,
+ .colorspace = V4L2_COLORSPACE_RAW,
.field = V4L2_FIELD_NONE,
.width = 1296,
.height = 972
@@ -571,7 +571,7 @@ static const struct ov5647_mode ov5647_modes[] = {
{
.format = {
.code = MEDIA_BUS_FMT_SBGGR10_1X10,
- .colorspace = V4L2_COLORSPACE_SRGB,
+ .colorspace = V4L2_COLORSPACE_RAW,
.field = V4L2_FIELD_NONE,
.width = 640,
.height = 480
--
2.51.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 05/16] dt-bindings: media: ov5647: Add optional regulators
2025-11-18 12:02 [PATCH v2 00/16] media: i2c: Miscellaneous features and fixes for OV5647 Jai Luthra
` (3 preceding siblings ...)
2025-11-18 12:02 ` [PATCH v2 04/16] media: i2c: ov5647: Sensor should report RAW color space Jai Luthra
@ 2025-11-18 12:02 ` Jai Luthra
2025-11-19 6:57 ` Krzysztof Kozlowski
2025-11-18 12:02 ` [PATCH v2 06/16] media: i2c: ov5647: Add support for regulator control Jai Luthra
` (10 subsequent siblings)
15 siblings, 1 reply; 19+ messages in thread
From: Jai Luthra @ 2025-11-18 12:02 UTC (permalink / raw)
To: Sakari Ailus, Dave Stevenson, Jacopo Mondi, Mauro Carvalho Chehab,
Naushir Patuck, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-media, linux-kernel, devicetree, Mauro Carvalho Chehab,
Kieran Bingham, David Plowman, Laurent Pinchart, Peter Robinson,
Stefan Wahren, Ivan T. Ivanov, Jacopo Mondi, Jai Luthra
The OV5647 camera sensor takes 3 voltage supplies. So define those in
the bindings as optional regulators, to not break existing users.
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
Documentation/devicetree/bindings/media/i2c/ovti,ov5647.yaml | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/Documentation/devicetree/bindings/media/i2c/ovti,ov5647.yaml b/Documentation/devicetree/bindings/media/i2c/ovti,ov5647.yaml
index a2abed06a099b41c7b165c0650e3967ec43a4962..9d3f7f1789cdedb357dae2e18b03c5af3c0e68e3 100644
--- a/Documentation/devicetree/bindings/media/i2c/ovti,ov5647.yaml
+++ b/Documentation/devicetree/bindings/media/i2c/ovti,ov5647.yaml
@@ -30,6 +30,15 @@ properties:
description: Reference to the GPIO connected to the pwdn pin. Active high.
maxItems: 1
+ avdd-supply:
+ description: Analog voltage supply, 2.8 volts
+
+ dvdd-supply:
+ description: Digital core voltage supply, 1.5 volts
+
+ dovdd-supply:
+ description: Digital I/O voltage supply, 1.7 - 3.0 volts
+
port:
$ref: /schemas/graph.yaml#/$defs/port-base
additionalProperties: false
--
2.51.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 06/16] media: i2c: ov5647: Add support for regulator control
2025-11-18 12:02 [PATCH v2 00/16] media: i2c: Miscellaneous features and fixes for OV5647 Jai Luthra
` (4 preceding siblings ...)
2025-11-18 12:02 ` [PATCH v2 05/16] dt-bindings: media: ov5647: Add optional regulators Jai Luthra
@ 2025-11-18 12:02 ` Jai Luthra
2025-11-18 12:03 ` [PATCH v2 07/16] dt-bindings: media: ov5647: Allow props from video-interface-devices Jai Luthra
` (9 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Jai Luthra @ 2025-11-18 12:02 UTC (permalink / raw)
To: Sakari Ailus, Dave Stevenson, Jacopo Mondi, Mauro Carvalho Chehab,
Naushir Patuck, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-media, linux-kernel, devicetree, Mauro Carvalho Chehab,
Kieran Bingham, David Plowman, Laurent Pinchart, Peter Robinson,
Stefan Wahren, Ivan T. Ivanov, Jacopo Mondi, Jai Luthra
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
The driver supported using GPIOs to control the shutdown line,
but no regulator control.
Add regulator hooks.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
drivers/media/i2c/ov5647.c | 43 ++++++++++++++++++++++++++++++++++++++++---
1 file changed, 40 insertions(+), 3 deletions(-)
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index c0f1121b025e5592d6fd4d5fd23e4262dde2d84c..dbc134af06a26e0e31b12a6360d794afa8bad5dd 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -20,6 +20,7 @@
#include <linux/module.h>
#include <linux/of_graph.h>
#include <linux/pm_runtime.h>
+#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/videodev2.h>
#include <media/v4l2-ctrls.h>
@@ -81,6 +82,15 @@
#define OV5647_EXPOSURE_DEFAULT 1000
#define OV5647_EXPOSURE_MAX 65535
+/* regulator supplies */
+static const char * const ov5647_supply_names[] = {
+ "avdd", /* Analog power */
+ "dovdd", /* Digital I/O power */
+ "dvdd", /* Digital core power */
+};
+
+#define OV5647_NUM_SUPPLIES ARRAY_SIZE(ov5647_supply_names)
+
struct regval_list {
u16 addr;
u8 data;
@@ -102,6 +112,7 @@ struct ov5647 {
struct mutex lock;
struct clk *xclk;
struct gpio_desc *pwdn;
+ struct regulator_bulk_data supplies[OV5647_NUM_SUPPLIES];
bool clock_ncont;
struct v4l2_ctrl_handler ctrls;
const struct ov5647_mode *mode;
@@ -777,11 +788,20 @@ static int ov5647_power_on(struct device *dev)
dev_dbg(dev, "OV5647 power on\n");
- if (sensor->pwdn) {
- gpiod_set_value_cansleep(sensor->pwdn, 0);
- msleep(PWDN_ACTIVE_DELAY_MS);
+ ret = regulator_bulk_enable(OV5647_NUM_SUPPLIES, sensor->supplies);
+ if (ret < 0) {
+ dev_err(dev, "Failed to enable regulators: %d\n", ret);
+ return ret;
+ }
+
+ ret = gpiod_set_value_cansleep(sensor->pwdn, 0);
+ if (ret < 0) {
+ dev_err(dev, "pwdn gpio set value failed: %d\n", ret);
+ goto error_reg_disable;
}
+ msleep(PWDN_ACTIVE_DELAY_MS);
+
ret = clk_prepare_enable(sensor->xclk);
if (ret < 0) {
dev_err(dev, "clk prepare enable failed\n");
@@ -808,6 +828,8 @@ static int ov5647_power_on(struct device *dev)
clk_disable_unprepare(sensor->xclk);
error_pwdn:
gpiod_set_value_cansleep(sensor->pwdn, 1);
+error_reg_disable:
+ regulator_bulk_disable(OV5647_NUM_SUPPLIES, sensor->supplies);
return ret;
}
@@ -837,6 +859,7 @@ static int ov5647_power_off(struct device *dev)
clk_disable_unprepare(sensor->xclk);
gpiod_set_value_cansleep(sensor->pwdn, 1);
+ regulator_bulk_disable(OV5647_NUM_SUPPLIES, sensor->supplies);
return 0;
}
@@ -1284,6 +1307,16 @@ static const struct v4l2_ctrl_ops ov5647_ctrl_ops = {
.s_ctrl = ov5647_s_ctrl,
};
+static int ov5647_configure_regulators(struct device *dev,
+ struct ov5647 *sensor)
+{
+ for (unsigned int i = 0; i < OV5647_NUM_SUPPLIES; i++)
+ sensor->supplies[i].supply = ov5647_supply_names[i];
+
+ return devm_regulator_bulk_get(dev, OV5647_NUM_SUPPLIES,
+ sensor->supplies);
+}
+
static int ov5647_init_controls(struct ov5647 *sensor)
{
struct i2c_client *client = v4l2_get_subdevdata(&sensor->sd);
@@ -1416,6 +1449,10 @@ static int ov5647_probe(struct i2c_client *client)
return -EINVAL;
}
+ ret = ov5647_configure_regulators(dev, sensor);
+ if (ret)
+ dev_err_probe(dev, ret, "Failed to get power regulators\n");
+
mutex_init(&sensor->lock);
sensor->mode = OV5647_DEFAULT_MODE;
--
2.51.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 07/16] dt-bindings: media: ov5647: Allow props from video-interface-devices
2025-11-18 12:02 [PATCH v2 00/16] media: i2c: Miscellaneous features and fixes for OV5647 Jai Luthra
` (5 preceding siblings ...)
2025-11-18 12:02 ` [PATCH v2 06/16] media: i2c: ov5647: Add support for regulator control Jai Luthra
@ 2025-11-18 12:03 ` Jai Luthra
2025-11-19 6:58 ` Krzysztof Kozlowski
2025-11-18 12:03 ` [PATCH v2 08/16] media: i2c: ov5647: Parse and register properties Jai Luthra
` (8 subsequent siblings)
15 siblings, 1 reply; 19+ messages in thread
From: Jai Luthra @ 2025-11-18 12:03 UTC (permalink / raw)
To: Sakari Ailus, Dave Stevenson, Jacopo Mondi, Mauro Carvalho Chehab,
Naushir Patuck, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-media, linux-kernel, devicetree, Mauro Carvalho Chehab,
Kieran Bingham, David Plowman, Laurent Pinchart, Peter Robinson,
Stefan Wahren, Ivan T. Ivanov, Jacopo Mondi, Jai Luthra
Allow properties from video-interface-devices. The change is identical to
commit 08fbd355be3d ("media: dt-bindings: sony,imx219: Allow props from
video-interface-devices")
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
Documentation/devicetree/bindings/media/i2c/ovti,ov5647.yaml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/media/i2c/ovti,ov5647.yaml b/Documentation/devicetree/bindings/media/i2c/ovti,ov5647.yaml
index 9d3f7f1789cdedb357dae2e18b03c5af3c0e68e3..2d7937a372a2b0f12c6837b6f0d790b4bea7f553 100644
--- a/Documentation/devicetree/bindings/media/i2c/ovti,ov5647.yaml
+++ b/Documentation/devicetree/bindings/media/i2c/ovti,ov5647.yaml
@@ -14,6 +14,9 @@ description: |-
The OV5647 is a raw image sensor with MIPI CSI-2 and CCP2 image data
interfaces and CCI (I2C compatible) control bus.
+allOf:
+ - $ref: /schemas/media/video-interface-devices.yaml#
+
properties:
compatible:
const: ovti,ov5647
@@ -57,7 +60,7 @@ required:
- clocks
- port
-additionalProperties: false
+unevaluatedProperties: false
examples:
- |
--
2.51.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 08/16] media: i2c: ov5647: Parse and register properties
2025-11-18 12:02 [PATCH v2 00/16] media: i2c: Miscellaneous features and fixes for OV5647 Jai Luthra
` (6 preceding siblings ...)
2025-11-18 12:03 ` [PATCH v2 07/16] dt-bindings: media: ov5647: Allow props from video-interface-devices Jai Luthra
@ 2025-11-18 12:03 ` Jai Luthra
2025-11-18 12:03 ` [PATCH v2 09/16] media: i2c: ov5647: Support HFLIP and VFLIP Jai Luthra
` (7 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Jai Luthra @ 2025-11-18 12:03 UTC (permalink / raw)
To: Sakari Ailus, Dave Stevenson, Jacopo Mondi, Mauro Carvalho Chehab,
Naushir Patuck, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-media, linux-kernel, devicetree, Mauro Carvalho Chehab,
Kieran Bingham, David Plowman, Laurent Pinchart, Peter Robinson,
Stefan Wahren, Ivan T. Ivanov, Jacopo Mondi, Jai Luthra
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Parse device properties and register controls for them using the V4L2
fwnode properties helpers.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
drivers/media/i2c/ov5647.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index dbc134af06a26e0e31b12a6360d794afa8bad5dd..5009fd8c05a64d7e06f66f8f75f0a881cd0b95c1 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -1320,9 +1320,11 @@ static int ov5647_configure_regulators(struct device *dev,
static int ov5647_init_controls(struct ov5647 *sensor)
{
struct i2c_client *client = v4l2_get_subdevdata(&sensor->sd);
+ struct v4l2_fwnode_device_properties props;
int hblank, exposure_max, exposure_def;
+ struct device *dev = &client->dev;
- v4l2_ctrl_handler_init(&sensor->ctrls, 9);
+ v4l2_ctrl_handler_init(&sensor->ctrls, 11);
v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,
V4L2_CID_AUTOGAIN, 0, 1, 1, 0);
@@ -1371,6 +1373,11 @@ static int ov5647_init_controls(struct ov5647 *sensor)
ARRAY_SIZE(ov5647_test_pattern_menu) - 1,
0, 0, ov5647_test_pattern_menu);
+ v4l2_fwnode_device_parse(dev, &props);
+
+ v4l2_ctrl_new_fwnode_properties(&sensor->ctrls, &ov5647_ctrl_ops,
+ &props);
+
if (sensor->ctrls.error)
goto handler_free;
--
2.51.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 09/16] media: i2c: ov5647: Support HFLIP and VFLIP
2025-11-18 12:02 [PATCH v2 00/16] media: i2c: Miscellaneous features and fixes for OV5647 Jai Luthra
` (7 preceding siblings ...)
2025-11-18 12:03 ` [PATCH v2 08/16] media: i2c: ov5647: Parse and register properties Jai Luthra
@ 2025-11-18 12:03 ` Jai Luthra
2025-11-18 12:03 ` [PATCH v2 10/16] media: i2c: ov5647: Use v4l2_async_register_subdev_sensor for lens binding Jai Luthra
` (6 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Jai Luthra @ 2025-11-18 12:03 UTC (permalink / raw)
To: Sakari Ailus, Dave Stevenson, Jacopo Mondi, Mauro Carvalho Chehab,
Naushir Patuck, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-media, linux-kernel, devicetree, Mauro Carvalho Chehab,
Kieran Bingham, David Plowman, Laurent Pinchart, Peter Robinson,
Stefan Wahren, Ivan T. Ivanov, Jacopo Mondi, Jai Luthra
From: David Plowman <david.plowman@raspberrypi.com>
Add missing controls for horizontal and vertical flipping.
The sensor readout mirrors in the horizontal direction by default (if
0x3821[1] = 0) which can make things unnecessarily difficult for
applications. The register table prior to this commit was setting that
bit explicitly, to achieve a normally oriented image.
Now that we have userspace controls for HFLIP, we keep the convention
and report the non-mirrored image (with 0x3821[1] = 1) as
horizontal_flip=0, and vice versa.
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Co-developed-by: Jai Luthra <jai.luthra@ideasonboard.com>
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
drivers/media/i2c/ov5647.c | 86 ++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 79 insertions(+), 7 deletions(-)
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index 5009fd8c05a64d7e06f66f8f75f0a881cd0b95c1..0343583692ab9bcca1a07d874a707ac6093a9035 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -55,6 +55,8 @@
#define OV5647_REG_GAIN_LO 0x350b
#define OV5647_REG_VTS_HI 0x380e
#define OV5647_REG_VTS_LO 0x380f
+#define OV5647_REG_TIMING_TC_V 0x3820
+#define OV5647_REG_TIMING_TC_H 0x3821
#define OV5647_REG_FRAME_OFF_NUMBER 0x4202
#define OV5647_REG_MIPI_CTRL00 0x4800
#define OV5647_REG_MIPI_CTRL14 0x4814
@@ -120,6 +122,8 @@ struct ov5647 {
struct v4l2_ctrl *hblank;
struct v4l2_ctrl *vblank;
struct v4l2_ctrl *exposure;
+ struct v4l2_ctrl *hflip;
+ struct v4l2_ctrl *vflip;
};
static inline struct ov5647 *to_sensor(struct v4l2_subdev *sd)
@@ -161,7 +165,7 @@ static struct regval_list ov5647_2592x1944_10bpp[] = {
{0x3036, 0x69},
{0x303c, 0x11},
{0x3106, 0xf5},
- {0x3821, 0x06},
+ {0x3821, 0x00},
{0x3820, 0x00},
{0x3827, 0xec},
{0x370c, 0x03},
@@ -250,7 +254,7 @@ static struct regval_list ov5647_1080p30_10bpp[] = {
{0x3036, 0x62},
{0x303c, 0x11},
{0x3106, 0xf5},
- {0x3821, 0x06},
+ {0x3821, 0x00},
{0x3820, 0x00},
{0x3827, 0xec},
{0x370c, 0x03},
@@ -414,7 +418,7 @@ static struct regval_list ov5647_2x2binned_10bpp[] = {
{0x4800, 0x24},
{0x3503, 0x03},
{0x3820, 0x41},
- {0x3821, 0x07},
+ {0x3821, 0x01},
{0x350a, 0x00},
{0x350b, 0x10},
{0x3500, 0x00},
@@ -430,7 +434,7 @@ static struct regval_list ov5647_640x480_10bpp[] = {
{0x3035, 0x11},
{0x3036, 0x46},
{0x303c, 0x11},
- {0x3821, 0x07},
+ {0x3821, 0x01},
{0x3820, 0x41},
{0x370c, 0x03},
{0x3612, 0x59},
@@ -956,6 +960,26 @@ static const struct v4l2_subdev_video_ops ov5647_subdev_video_ops = {
.s_stream = ov5647_s_stream,
};
+/*
+ * This function returns the mbus code for the current settings of the HFLIP
+ * and VFLIP controls.
+ */
+static u32 ov5647_get_mbus_code(struct v4l2_subdev *sd)
+{
+ struct ov5647 *sensor = to_sensor(sd);
+ /* The control values are only 0 or 1. */
+ int index = sensor->hflip->val | (sensor->vflip->val << 1);
+
+ static const u32 codes[4] = {
+ MEDIA_BUS_FMT_SGBRG10_1X10,
+ MEDIA_BUS_FMT_SBGGR10_1X10,
+ MEDIA_BUS_FMT_SRGGB10_1X10,
+ MEDIA_BUS_FMT_SGRBG10_1X10
+ };
+
+ return codes[index];
+}
+
static int ov5647_enum_mbus_code(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_mbus_code_enum *code)
@@ -963,7 +987,7 @@ static int ov5647_enum_mbus_code(struct v4l2_subdev *sd,
if (code->index > 0)
return -EINVAL;
- code->code = MEDIA_BUS_FMT_SBGGR10_1X10;
+ code->code = ov5647_get_mbus_code(sd);
return 0;
}
@@ -974,7 +998,7 @@ static int ov5647_enum_frame_size(struct v4l2_subdev *sd,
{
const struct v4l2_mbus_framefmt *fmt;
- if (fse->code != MEDIA_BUS_FMT_SBGGR10_1X10 ||
+ if (fse->code != ov5647_get_mbus_code(sd) ||
fse->index >= ARRAY_SIZE(ov5647_modes))
return -EINVAL;
@@ -1007,6 +1031,8 @@ static int ov5647_get_pad_fmt(struct v4l2_subdev *sd,
}
*fmt = *sensor_format;
+ /* The code we pass back must reflect the current h/vflips. */
+ fmt->code = ov5647_get_mbus_code(sd);
mutex_unlock(&sensor->lock);
return 0;
@@ -1054,6 +1080,8 @@ static int ov5647_set_pad_fmt(struct v4l2_subdev *sd,
exposure_def);
}
*fmt = mode->format;
+ /* The code we pass back must reflect the current h/vflips. */
+ fmt->code = ov5647_get_mbus_code(sd);
mutex_unlock(&sensor->lock);
return 0;
@@ -1229,6 +1257,36 @@ static int ov5647_s_exposure(struct v4l2_subdev *sd, u32 val)
return ov5647_write(sd, OV5647_REG_EXP_LO, (val & 0xf) << 4);
}
+static int ov5647_s_flip(struct v4l2_subdev *sd, u16 reg, u32 ctrl_val)
+{
+ int ret;
+ u8 reg_val;
+
+ /*
+ * TIMING TC REG20 (Vertical) and REG21 (Horizontal):
+ * - [2]: ISP mirror/flip
+ * - [1]: Sensor mirror/flip
+ *
+ * We only use sensor flip.
+ *
+ * Using ISP flip retains the BGGR pattern at the cost of changing the
+ * pixel array readout. This affects the selection rectangles in ways
+ * that are not very well documented, and would be tougher to deal with
+ * for applications compared to reading a different bayer pattern.
+ */
+ ret = ov5647_read(sd, reg, ®_val);
+ if (ret == 0) {
+ if (ctrl_val)
+ reg_val |= BIT(1);
+ else
+ reg_val &= ~BIT(1);
+
+ ret = ov5647_write(sd, reg, reg_val);
+ }
+
+ return ret;
+}
+
static int ov5647_s_ctrl(struct v4l2_ctrl *ctrl)
{
struct ov5647 *sensor = container_of(ctrl->handler,
@@ -1291,6 +1349,14 @@ static int ov5647_s_ctrl(struct v4l2_ctrl *ctrl)
/* Read-only, but we adjust it based on mode. */
break;
+ case V4L2_CID_HFLIP:
+ /* There's an in-built hflip in the sensor, so account for that here. */
+ ov5647_s_flip(sd, OV5647_REG_TIMING_TC_H, !ctrl->val);
+ break;
+ case V4L2_CID_VFLIP:
+ ov5647_s_flip(sd, OV5647_REG_TIMING_TC_V, ctrl->val);
+ break;
+
default:
dev_info(&client->dev,
"Control (id:0x%x, val:0x%x) not supported\n",
@@ -1324,7 +1390,7 @@ static int ov5647_init_controls(struct ov5647 *sensor)
int hblank, exposure_max, exposure_def;
struct device *dev = &client->dev;
- v4l2_ctrl_handler_init(&sensor->ctrls, 11);
+ v4l2_ctrl_handler_init(&sensor->ctrls, 13);
v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,
V4L2_CID_AUTOGAIN, 0, 1, 1, 0);
@@ -1373,6 +1439,12 @@ static int ov5647_init_controls(struct ov5647 *sensor)
ARRAY_SIZE(ov5647_test_pattern_menu) - 1,
0, 0, ov5647_test_pattern_menu);
+ sensor->hflip = v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,
+ V4L2_CID_HFLIP, 0, 1, 1, 0);
+
+ sensor->vflip = v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,
+ V4L2_CID_VFLIP, 0, 1, 1, 0);
+
v4l2_fwnode_device_parse(dev, &props);
v4l2_ctrl_new_fwnode_properties(&sensor->ctrls, &ov5647_ctrl_ops,
--
2.51.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 10/16] media: i2c: ov5647: Use v4l2_async_register_subdev_sensor for lens binding
2025-11-18 12:02 [PATCH v2 00/16] media: i2c: Miscellaneous features and fixes for OV5647 Jai Luthra
` (8 preceding siblings ...)
2025-11-18 12:03 ` [PATCH v2 09/16] media: i2c: ov5647: Support HFLIP and VFLIP Jai Luthra
@ 2025-11-18 12:03 ` Jai Luthra
2025-11-18 12:03 ` [PATCH v2 11/16] media: i2c: ov5647: Add control of V4L2_CID_HBLANK Jai Luthra
` (5 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Jai Luthra @ 2025-11-18 12:03 UTC (permalink / raw)
To: Sakari Ailus, Dave Stevenson, Jacopo Mondi, Mauro Carvalho Chehab,
Naushir Patuck, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-media, linux-kernel, devicetree, Mauro Carvalho Chehab,
Kieran Bingham, David Plowman, Laurent Pinchart, Peter Robinson,
Stefan Wahren, Ivan T. Ivanov, Jacopo Mondi, Jai Luthra
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
v4l2_async_register_subdev doesn't bind in lens or flash drivers,
but v4l2_async_register_subdev_sensor does.
Switch to using v4l2_async_register_subdev_sensor.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
drivers/media/i2c/ov5647.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index 0343583692ab9bcca1a07d874a707ac6093a9035..9b5a1275c29877dff99c74aa8d49605c02fa6ed6 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -1559,7 +1559,7 @@ static int ov5647_probe(struct i2c_client *client)
if (ret < 0)
goto power_off;
- ret = v4l2_async_register_subdev(sd);
+ ret = v4l2_async_register_subdev_sensor(sd);
if (ret < 0)
goto power_off;
--
2.51.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 11/16] media: i2c: ov5647: Add control of V4L2_CID_HBLANK
2025-11-18 12:02 [PATCH v2 00/16] media: i2c: Miscellaneous features and fixes for OV5647 Jai Luthra
` (9 preceding siblings ...)
2025-11-18 12:03 ` [PATCH v2 10/16] media: i2c: ov5647: Use v4l2_async_register_subdev_sensor for lens binding Jai Luthra
@ 2025-11-18 12:03 ` Jai Luthra
2025-11-18 12:03 ` [PATCH v2 12/16] media: i2c: ov5647: Tidy up mode registers to make the order common Jai Luthra
` (4 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Jai Luthra @ 2025-11-18 12:03 UTC (permalink / raw)
To: Sakari Ailus, Dave Stevenson, Jacopo Mondi, Mauro Carvalho Chehab,
Naushir Patuck, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-media, linux-kernel, devicetree, Mauro Carvalho Chehab,
Kieran Bingham, David Plowman, Laurent Pinchart, Peter Robinson,
Stefan Wahren, Ivan T. Ivanov, Jacopo Mondi, Jai Luthra
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
The driver did expose V4L2_CID_HBLANK, but as a READ_ONLY control.
The sensor only uses the HTS register to control the line length,
so convert this control to read/write, with the appropriate ranges.
Adopt the old fixed values as the minimum values permitted in each
mode to avoid issues of it not streaming.
This should allow exposure times up to ~3 seconds (up from ~1sec).
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
drivers/media/i2c/ov5647.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index 9b5a1275c29877dff99c74aa8d49605c02fa6ed6..48c0e302319d724a20aa7885a62e517d515c6191 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -53,6 +53,8 @@
#define OV5647_REG_AEC_AGC 0x3503
#define OV5647_REG_GAIN_HI 0x350a
#define OV5647_REG_GAIN_LO 0x350b
+#define OV5647_REG_HTS_HI 0x380c
+#define OV5647_REG_HTS_LO 0x380d
#define OV5647_REG_VTS_HI 0x380e
#define OV5647_REG_VTS_LO 0x380f
#define OV5647_REG_TIMING_TC_V 0x3820
@@ -79,6 +81,8 @@
#define OV5647_VBLANK_MIN 24
#define OV5647_VTS_MAX 32767
+#define OV5647_HTS_MAX 0x1fff
+
#define OV5647_EXPOSURE_MIN 4
#define OV5647_EXPOSURE_STEP 1
#define OV5647_EXPOSURE_DEFAULT 1000
@@ -187,8 +191,6 @@ static struct regval_list ov5647_2592x1944_10bpp[] = {
{0x3a19, 0xf8},
{0x3c01, 0x80},
{0x3b07, 0x0c},
- {0x380c, 0x0b},
- {0x380d, 0x1c},
{0x3814, 0x11},
{0x3815, 0x11},
{0x3708, 0x64},
@@ -276,8 +278,6 @@ static struct regval_list ov5647_1080p30_10bpp[] = {
{0x3a19, 0xf8},
{0x3c01, 0x80},
{0x3b07, 0x0c},
- {0x380c, 0x09},
- {0x380d, 0x70},
{0x3814, 0x11},
{0x3815, 0x11},
{0x3708, 0x64},
@@ -375,8 +375,6 @@ static struct regval_list ov5647_2x2binned_10bpp[] = {
{0x3809, 0x10},
{0x380a, 0x03},
{0x380b, 0xcc},
- {0x380c, 0x07},
- {0x380d, 0x68},
{0x3811, 0x0c},
{0x3813, 0x06},
{0x3814, 0x31},
@@ -450,8 +448,6 @@ static struct regval_list ov5647_640x480_10bpp[] = {
{0x3a19, 0xf8},
{0x3c01, 0x80},
{0x3b07, 0x0c},
- {0x380c, 0x07},
- {0x380d, 0x3c},
{0x3814, 0x35},
{0x3815, 0x35},
{0x3708, 0x64},
@@ -1063,7 +1059,8 @@ static int ov5647_set_pad_fmt(struct v4l2_subdev *sd,
mode->pixel_rate, 1, mode->pixel_rate);
hblank = mode->hts - mode->format.width;
- __v4l2_ctrl_modify_range(sensor->hblank, hblank, hblank, 1,
+ __v4l2_ctrl_modify_range(sensor->hblank, hblank,
+ OV5647_HTS_MAX - mode->format.width, 1,
hblank);
vblank = mode->vts - mode->format.height;
@@ -1338,6 +1335,10 @@ static int ov5647_s_ctrl(struct v4l2_ctrl *ctrl)
ret = ov5647_write16(sd, OV5647_REG_VTS_HI,
sensor->mode->format.height + ctrl->val);
break;
+ case V4L2_CID_HBLANK:
+ ret = ov5647_write16(sd, OV5647_REG_HTS_HI,
+ sensor->mode->format.width + ctrl->val);
+ break;
case V4L2_CID_TEST_PATTERN:
ret = ov5647_write(sd, OV5647_REG_ISPCTRL3D,
ov5647_test_pattern_val[ctrl->val]);
@@ -1345,7 +1346,6 @@ static int ov5647_s_ctrl(struct v4l2_ctrl *ctrl)
/* Read-only, but we adjust it based on mode. */
case V4L2_CID_PIXEL_RATE:
- case V4L2_CID_HBLANK:
/* Read-only, but we adjust it based on mode. */
break;
@@ -1421,10 +1421,11 @@ static int ov5647_init_controls(struct ov5647 *sensor)
sensor->mode->pixel_rate, 1,
sensor->mode->pixel_rate);
- /* By default, HBLANK is read only, but it does change per mode. */
hblank = sensor->mode->hts - sensor->mode->format.width;
sensor->hblank = v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,
- V4L2_CID_HBLANK, hblank, hblank, 1,
+ V4L2_CID_HBLANK, hblank,
+ OV5647_HTS_MAX -
+ sensor->mode->format.width, 1,
hblank);
sensor->vblank = v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,
@@ -1454,7 +1455,6 @@ static int ov5647_init_controls(struct ov5647 *sensor)
goto handler_free;
sensor->pixel_rate->flags |= V4L2_CTRL_FLAG_READ_ONLY;
- sensor->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
sensor->sd.ctrl_handler = &sensor->ctrls;
return 0;
--
2.51.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 12/16] media: i2c: ov5647: Tidy up mode registers to make the order common
2025-11-18 12:02 [PATCH v2 00/16] media: i2c: Miscellaneous features and fixes for OV5647 Jai Luthra
` (10 preceding siblings ...)
2025-11-18 12:03 ` [PATCH v2 11/16] media: i2c: ov5647: Add control of V4L2_CID_HBLANK Jai Luthra
@ 2025-11-18 12:03 ` Jai Luthra
2025-11-18 12:03 ` [PATCH v2 13/16] media: i2c: ov5647: Separate out the common registers Jai Luthra
` (3 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Jai Luthra @ 2025-11-18 12:03 UTC (permalink / raw)
To: Sakari Ailus, Dave Stevenson, Jacopo Mondi, Mauro Carvalho Chehab,
Naushir Patuck, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-media, linux-kernel, devicetree, Mauro Carvalho Chehab,
Kieran Bingham, David Plowman, Laurent Pinchart, Peter Robinson,
Stefan Wahren, Ivan T. Ivanov, Jacopo Mondi, Jai Luthra
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
To make comparisons of the mode registers easier, put the registers
for the binned and VGA modes in the same order as the others.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
drivers/media/i2c/ov5647.c | 33 ++++++++++++++-------------------
1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index 48c0e302319d724a20aa7885a62e517d515c6191..5cfc35e79562a6017719710935a72c2dd84405b6 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -343,6 +343,8 @@ static struct regval_list ov5647_2x2binned_10bpp[] = {
{0x3036, 0x62},
{0x303c, 0x11},
{0x3106, 0xf5},
+ {0x3821, 0x01},
+ {0x3820, 0x41},
{0x3827, 0xec},
{0x370c, 0x03},
{0x3612, 0x59},
@@ -415,8 +417,6 @@ static struct regval_list ov5647_2x2binned_10bpp[] = {
{0x4837, 0x16},
{0x4800, 0x24},
{0x3503, 0x03},
- {0x3820, 0x41},
- {0x3821, 0x01},
{0x350a, 0x00},
{0x350b, 0x10},
{0x3500, 0x00},
@@ -429,20 +429,27 @@ static struct regval_list ov5647_2x2binned_10bpp[] = {
static struct regval_list ov5647_640x480_10bpp[] = {
{0x0100, 0x00},
{0x0103, 0x01},
- {0x3035, 0x11},
+ {0x3034, 0x1a},
+ {0x3035, 0x21},
{0x3036, 0x46},
{0x303c, 0x11},
+ {0x3106, 0xf5},
{0x3821, 0x01},
{0x3820, 0x41},
+ {0x3827, 0xec},
{0x370c, 0x03},
{0x3612, 0x59},
{0x3618, 0x00},
{0x5000, 0x06},
{0x5003, 0x08},
{0x5a00, 0x08},
- {0x3000, 0xff},
- {0x3001, 0xff},
- {0x3002, 0xff},
+ {0x3000, 0x00},
+ {0x3001, 0x00},
+ {0x3002, 0x00},
+ {0x3016, 0x08},
+ {0x3017, 0xe0},
+ {0x3018, 0x44},
+ {0x301c, 0xf8},
{0x301d, 0xf0},
{0x3a18, 0x00},
{0x3a19, 0xf8},
@@ -468,6 +475,7 @@ static struct regval_list ov5647_640x480_10bpp[] = {
{0x3632, 0xe2},
{0x3633, 0x23},
{0x3634, 0x44},
+ {0x3636, 0x06},
{0x3620, 0x64},
{0x3621, 0xe0},
{0x3600, 0x37},
@@ -496,19 +504,6 @@ static struct regval_list ov5647_640x480_10bpp[] = {
{0x4001, 0x02},
{0x4004, 0x02},
{0x4000, 0x09},
- {0x3000, 0x00},
- {0x3001, 0x00},
- {0x3002, 0x00},
- {0x3017, 0xe0},
- {0x301c, 0xfc},
- {0x3636, 0x06},
- {0x3016, 0x08},
- {0x3827, 0xec},
- {0x3018, 0x44},
- {0x3035, 0x21},
- {0x3106, 0xf5},
- {0x3034, 0x1a},
- {0x301c, 0xf8},
{0x4800, 0x34},
{0x3503, 0x03},
{0x0100, 0x01},
--
2.51.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 13/16] media: i2c: ov5647: Separate out the common registers.
2025-11-18 12:02 [PATCH v2 00/16] media: i2c: Miscellaneous features and fixes for OV5647 Jai Luthra
` (11 preceding siblings ...)
2025-11-18 12:03 ` [PATCH v2 12/16] media: i2c: ov5647: Tidy up mode registers to make the order common Jai Luthra
@ 2025-11-18 12:03 ` Jai Luthra
2025-11-18 12:03 ` [PATCH v2 14/16] media: i2c: ov5647: Use the same PLL config for full, 1080p, and binned modes Jai Luthra
` (2 subsequent siblings)
15 siblings, 0 replies; 19+ messages in thread
From: Jai Luthra @ 2025-11-18 12:03 UTC (permalink / raw)
To: Sakari Ailus, Dave Stevenson, Jacopo Mondi, Mauro Carvalho Chehab,
Naushir Patuck, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-media, linux-kernel, devicetree, Mauro Carvalho Chehab,
Kieran Bingham, David Plowman, Laurent Pinchart, Peter Robinson,
Stefan Wahren, Ivan T. Ivanov, Jacopo Mondi, Jai Luthra
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
There are many registers in common between all the modes.
Pull those out into one common table.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
drivers/media/i2c/ov5647.c | 243 ++++++++++-----------------------------------
1 file changed, 50 insertions(+), 193 deletions(-)
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index 5cfc35e79562a6017719710935a72c2dd84405b6..1be170e1de3445d6049d44e7c034f9c2dbe3a9a0 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -161,22 +161,16 @@ static const struct regval_list sensor_oe_enable_regs[] = {
{0x3002, 0xe4},
};
-static struct regval_list ov5647_2592x1944_10bpp[] = {
+static struct regval_list ov5647_common_regs[] = {
{0x0100, 0x00},
{0x0103, 0x01},
{0x3034, 0x1a},
{0x3035, 0x21},
- {0x3036, 0x69},
{0x303c, 0x11},
{0x3106, 0xf5},
- {0x3821, 0x00},
- {0x3820, 0x00},
{0x3827, 0xec},
{0x370c, 0x03},
- {0x3612, 0x5b},
- {0x3618, 0x04},
{0x5000, 0x06},
- {0x5002, 0x41},
{0x5003, 0x08},
{0x5a00, 0x08},
{0x3000, 0x00},
@@ -191,24 +185,6 @@ static struct regval_list ov5647_2592x1944_10bpp[] = {
{0x3a19, 0xf8},
{0x3c01, 0x80},
{0x3b07, 0x0c},
- {0x3814, 0x11},
- {0x3815, 0x11},
- {0x3708, 0x64},
- {0x3709, 0x12},
- {0x3808, 0x0a},
- {0x3809, 0x20},
- {0x380a, 0x07},
- {0x380b, 0x98},
- {0x3800, 0x00},
- {0x3801, 0x00},
- {0x3802, 0x00},
- {0x3803, 0x00},
- {0x3804, 0x0a},
- {0x3805, 0x3f},
- {0x3806, 0x07},
- {0x3807, 0xa3},
- {0x3811, 0x10},
- {0x3813, 0x06},
{0x3630, 0x2e},
{0x3632, 0xe2},
{0x3633, 0x23},
@@ -228,11 +204,6 @@ static struct regval_list ov5647_2592x1944_10bpp[] = {
{0x3f06, 0x10},
{0x3f01, 0x0a},
{0x3a08, 0x01},
- {0x3a09, 0x28},
- {0x3a0a, 0x00},
- {0x3a0b, 0xf6},
- {0x3a0d, 0x08},
- {0x3a0e, 0x06},
{0x3a0f, 0x58},
{0x3a10, 0x50},
{0x3a1b, 0x58},
@@ -240,52 +211,57 @@ static struct regval_list ov5647_2592x1944_10bpp[] = {
{0x3a11, 0x60},
{0x3a1f, 0x28},
{0x4001, 0x02},
- {0x4004, 0x04},
{0x4000, 0x09},
+ {0x3503, 0x03},
+};
+
+static struct regval_list ov5647_2592x1944_10bpp[] = {
+ {0x3036, 0x69},
+ {0x3821, 0x00},
+ {0x3820, 0x00},
+ {0x3612, 0x5b},
+ {0x3618, 0x04},
+ {0x5002, 0x41},
+ {0x3814, 0x11},
+ {0x3815, 0x11},
+ {0x3708, 0x64},
+ {0x3709, 0x12},
+ {0x3800, 0x00},
+ {0x3801, 0x00},
+ {0x3802, 0x00},
+ {0x3803, 0x00},
+ {0x3804, 0x0a},
+ {0x3805, 0x3f},
+ {0x3806, 0x07},
+ {0x3807, 0xa3},
+ {0x3808, 0x0a},
+ {0x3809, 0x20},
+ {0x380a, 0x07},
+ {0x380b, 0x98},
+ {0x3811, 0x10},
+ {0x3813, 0x06},
+ {0x3a09, 0x28},
+ {0x3a0a, 0x00},
+ {0x3a0b, 0xf6},
+ {0x3a0d, 0x08},
+ {0x3a0e, 0x06},
+ {0x4004, 0x04},
{0x4837, 0x19},
{0x4800, 0x24},
- {0x3503, 0x03},
{0x0100, 0x01},
};
static struct regval_list ov5647_1080p30_10bpp[] = {
- {0x0100, 0x00},
- {0x0103, 0x01},
- {0x3034, 0x1a},
- {0x3035, 0x21},
{0x3036, 0x62},
- {0x303c, 0x11},
- {0x3106, 0xf5},
{0x3821, 0x00},
{0x3820, 0x00},
- {0x3827, 0xec},
- {0x370c, 0x03},
{0x3612, 0x5b},
{0x3618, 0x04},
- {0x5000, 0x06},
{0x5002, 0x41},
- {0x5003, 0x08},
- {0x5a00, 0x08},
- {0x3000, 0x00},
- {0x3001, 0x00},
- {0x3002, 0x00},
- {0x3016, 0x08},
- {0x3017, 0xe0},
- {0x3018, 0x44},
- {0x301c, 0xf8},
- {0x301d, 0xf0},
- {0x3a18, 0x00},
- {0x3a19, 0xf8},
- {0x3c01, 0x80},
- {0x3b07, 0x0c},
{0x3814, 0x11},
{0x3815, 0x11},
{0x3708, 0x64},
{0x3709, 0x12},
- {0x3808, 0x07},
- {0x3809, 0x80},
- {0x380a, 0x04},
- {0x380b, 0x38},
{0x3800, 0x01},
{0x3801, 0x5c},
{0x3802, 0x01},
@@ -294,77 +270,30 @@ static struct regval_list ov5647_1080p30_10bpp[] = {
{0x3805, 0xe3},
{0x3806, 0x05},
{0x3807, 0xf1},
+ {0x3808, 0x07},
+ {0x3809, 0x80},
+ {0x380a, 0x04},
+ {0x380b, 0x38},
{0x3811, 0x04},
{0x3813, 0x02},
- {0x3630, 0x2e},
- {0x3632, 0xe2},
- {0x3633, 0x23},
- {0x3634, 0x44},
- {0x3636, 0x06},
- {0x3620, 0x64},
- {0x3621, 0xe0},
- {0x3600, 0x37},
- {0x3704, 0xa0},
- {0x3703, 0x5a},
- {0x3715, 0x78},
- {0x3717, 0x01},
- {0x3731, 0x02},
- {0x370b, 0x60},
- {0x3705, 0x1a},
- {0x3f05, 0x02},
- {0x3f06, 0x10},
- {0x3f01, 0x0a},
- {0x3a08, 0x01},
{0x3a09, 0x4b},
{0x3a0a, 0x01},
{0x3a0b, 0x13},
{0x3a0d, 0x04},
{0x3a0e, 0x03},
- {0x3a0f, 0x58},
- {0x3a10, 0x50},
- {0x3a1b, 0x58},
- {0x3a1e, 0x50},
- {0x3a11, 0x60},
- {0x3a1f, 0x28},
- {0x4001, 0x02},
{0x4004, 0x04},
- {0x4000, 0x09},
{0x4837, 0x19},
{0x4800, 0x34},
- {0x3503, 0x03},
{0x0100, 0x01},
};
static struct regval_list ov5647_2x2binned_10bpp[] = {
- {0x0100, 0x00},
- {0x0103, 0x01},
- {0x3034, 0x1a},
- {0x3035, 0x21},
{0x3036, 0x62},
- {0x303c, 0x11},
- {0x3106, 0xf5},
{0x3821, 0x01},
{0x3820, 0x41},
- {0x3827, 0xec},
- {0x370c, 0x03},
{0x3612, 0x59},
{0x3618, 0x00},
- {0x5000, 0x06},
{0x5002, 0x41},
- {0x5003, 0x08},
- {0x5a00, 0x08},
- {0x3000, 0x00},
- {0x3001, 0x00},
- {0x3002, 0x00},
- {0x3016, 0x08},
- {0x3017, 0xe0},
- {0x3018, 0x44},
- {0x301c, 0xf8},
- {0x301d, 0xf0},
- {0x3a18, 0x00},
- {0x3a19, 0xf8},
- {0x3c01, 0x80},
- {0x3b07, 0x0c},
{0x3800, 0x00},
{0x3801, 0x00},
{0x3802, 0x00},
@@ -381,42 +310,14 @@ static struct regval_list ov5647_2x2binned_10bpp[] = {
{0x3813, 0x06},
{0x3814, 0x31},
{0x3815, 0x31},
- {0x3630, 0x2e},
- {0x3632, 0xe2},
- {0x3633, 0x23},
- {0x3634, 0x44},
- {0x3636, 0x06},
- {0x3620, 0x64},
- {0x3621, 0xe0},
- {0x3600, 0x37},
- {0x3704, 0xa0},
- {0x3703, 0x5a},
- {0x3715, 0x78},
- {0x3717, 0x01},
- {0x3731, 0x02},
- {0x370b, 0x60},
- {0x3705, 0x1a},
- {0x3f05, 0x02},
- {0x3f06, 0x10},
- {0x3f01, 0x0a},
- {0x3a08, 0x01},
{0x3a09, 0x28},
{0x3a0a, 0x00},
{0x3a0b, 0xf6},
{0x3a0d, 0x08},
{0x3a0e, 0x06},
- {0x3a0f, 0x58},
- {0x3a10, 0x50},
- {0x3a1b, 0x58},
- {0x3a1e, 0x50},
- {0x3a11, 0x60},
- {0x3a1f, 0x28},
- {0x4001, 0x02},
{0x4004, 0x04},
- {0x4000, 0x09},
{0x4837, 0x16},
{0x4800, 0x24},
- {0x3503, 0x03},
{0x350a, 0x00},
{0x350b, 0x10},
{0x3500, 0x00},
@@ -427,42 +328,15 @@ static struct regval_list ov5647_2x2binned_10bpp[] = {
};
static struct regval_list ov5647_640x480_10bpp[] = {
- {0x0100, 0x00},
- {0x0103, 0x01},
- {0x3034, 0x1a},
- {0x3035, 0x21},
{0x3036, 0x46},
- {0x303c, 0x11},
- {0x3106, 0xf5},
{0x3821, 0x01},
{0x3820, 0x41},
- {0x3827, 0xec},
- {0x370c, 0x03},
{0x3612, 0x59},
{0x3618, 0x00},
- {0x5000, 0x06},
- {0x5003, 0x08},
- {0x5a00, 0x08},
- {0x3000, 0x00},
- {0x3001, 0x00},
- {0x3002, 0x00},
- {0x3016, 0x08},
- {0x3017, 0xe0},
- {0x3018, 0x44},
- {0x301c, 0xf8},
- {0x301d, 0xf0},
- {0x3a18, 0x00},
- {0x3a19, 0xf8},
- {0x3c01, 0x80},
- {0x3b07, 0x0c},
{0x3814, 0x35},
{0x3815, 0x35},
{0x3708, 0x64},
{0x3709, 0x52},
- {0x3808, 0x02},
- {0x3809, 0x80},
- {0x380a, 0x01},
- {0x380b, 0xe0},
{0x3800, 0x00},
{0x3801, 0x10},
{0x3802, 0x00},
@@ -471,41 +345,17 @@ static struct regval_list ov5647_640x480_10bpp[] = {
{0x3805, 0x2f},
{0x3806, 0x07},
{0x3807, 0x9f},
- {0x3630, 0x2e},
- {0x3632, 0xe2},
- {0x3633, 0x23},
- {0x3634, 0x44},
- {0x3636, 0x06},
- {0x3620, 0x64},
- {0x3621, 0xe0},
- {0x3600, 0x37},
- {0x3704, 0xa0},
- {0x3703, 0x5a},
- {0x3715, 0x78},
- {0x3717, 0x01},
- {0x3731, 0x02},
- {0x370b, 0x60},
- {0x3705, 0x1a},
- {0x3f05, 0x02},
- {0x3f06, 0x10},
- {0x3f01, 0x0a},
- {0x3a08, 0x01},
+ {0x3808, 0x02},
+ {0x3809, 0x80},
+ {0x380a, 0x01},
+ {0x380b, 0xe0},
{0x3a09, 0x2e},
{0x3a0a, 0x00},
{0x3a0b, 0xfb},
{0x3a0d, 0x02},
{0x3a0e, 0x01},
- {0x3a0f, 0x58},
- {0x3a10, 0x50},
- {0x3a1b, 0x58},
- {0x3a1e, 0x50},
- {0x3a11, 0x60},
- {0x3a1f, 0x28},
- {0x4001, 0x02},
{0x4004, 0x02},
- {0x4000, 0x09},
{0x4800, 0x34},
- {0x3503, 0x03},
{0x0100, 0x01},
};
@@ -701,6 +551,13 @@ static int ov5647_set_mode(struct v4l2_subdev *sd)
if (ret < 0)
return ret;
+ ret = ov5647_write_array(sd, ov5647_common_regs,
+ ARRAY_SIZE(ov5647_common_regs));
+ if (ret < 0) {
+ dev_err(&client->dev, "write sensor common regs error\n");
+ return ret;
+ }
+
ret = ov5647_write_array(sd, sensor->mode->reg_list,
sensor->mode->num_regs);
if (ret < 0) {
--
2.51.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 14/16] media: i2c: ov5647: Use the same PLL config for full, 1080p, and binned modes
2025-11-18 12:02 [PATCH v2 00/16] media: i2c: Miscellaneous features and fixes for OV5647 Jai Luthra
` (12 preceding siblings ...)
2025-11-18 12:03 ` [PATCH v2 13/16] media: i2c: ov5647: Separate out the common registers Jai Luthra
@ 2025-11-18 12:03 ` Jai Luthra
2025-11-18 12:03 ` [PATCH v2 15/16] media: i2c: ov5647: Tidy up PIXEL_RATE control Jai Luthra
2025-11-18 12:03 ` [PATCH v2 16/16] media: i2c: ov5647: Add V4L2_CID_LINK_FREQUENCY control Jai Luthra
15 siblings, 0 replies; 19+ messages in thread
From: Jai Luthra @ 2025-11-18 12:03 UTC (permalink / raw)
To: Sakari Ailus, Dave Stevenson, Jacopo Mondi, Mauro Carvalho Chehab,
Naushir Patuck, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-media, linux-kernel, devicetree, Mauro Carvalho Chehab,
Kieran Bingham, David Plowman, Laurent Pinchart, Peter Robinson,
Stefan Wahren, Ivan T. Ivanov, Jacopo Mondi, Jai Luthra
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
In order to simplify the driver slightly, use the same PLL
configuration, and hence pixel rate and link frequency (to be
added) for the full, 1080p, and binned modes.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
drivers/media/i2c/ov5647.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index 1be170e1de3445d6049d44e7c034f9c2dbe3a9a0..3a2c25a6b6808bf1289a2357ac5b79bf6bf99daa 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -252,7 +252,7 @@ static struct regval_list ov5647_2592x1944_10bpp[] = {
};
static struct regval_list ov5647_1080p30_10bpp[] = {
- {0x3036, 0x62},
+ {0x3036, 0x69},
{0x3821, 0x00},
{0x3820, 0x00},
{0x3612, 0x5b},
@@ -288,7 +288,7 @@ static struct regval_list ov5647_1080p30_10bpp[] = {
};
static struct regval_list ov5647_2x2binned_10bpp[] = {
- {0x3036, 0x62},
+ {0x3036, 0x69},
{0x3821, 0x01},
{0x3820, 0x41},
{0x3612, 0x59},
@@ -396,7 +396,7 @@ static const struct ov5647_mode ov5647_modes[] = {
.width = 1928,
.height = 1080,
},
- .pixel_rate = 81666700,
+ .pixel_rate = 87500000,
.hts = 2416,
.vts = 0x450,
.reg_list = ov5647_1080p30_10bpp,
@@ -417,7 +417,7 @@ static const struct ov5647_mode ov5647_modes[] = {
.width = 2592,
.height = 1944,
},
- .pixel_rate = 81666700,
+ .pixel_rate = 87500000,
.hts = 1896,
.vts = 0x59b,
.reg_list = ov5647_2x2binned_10bpp,
--
2.51.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 15/16] media: i2c: ov5647: Tidy up PIXEL_RATE control
2025-11-18 12:02 [PATCH v2 00/16] media: i2c: Miscellaneous features and fixes for OV5647 Jai Luthra
` (13 preceding siblings ...)
2025-11-18 12:03 ` [PATCH v2 14/16] media: i2c: ov5647: Use the same PLL config for full, 1080p, and binned modes Jai Luthra
@ 2025-11-18 12:03 ` Jai Luthra
2025-11-18 12:03 ` [PATCH v2 16/16] media: i2c: ov5647: Add V4L2_CID_LINK_FREQUENCY control Jai Luthra
15 siblings, 0 replies; 19+ messages in thread
From: Jai Luthra @ 2025-11-18 12:03 UTC (permalink / raw)
To: Sakari Ailus, Dave Stevenson, Jacopo Mondi, Mauro Carvalho Chehab,
Naushir Patuck, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-media, linux-kernel, devicetree, Mauro Carvalho Chehab,
Kieran Bingham, David Plowman, Laurent Pinchart, Peter Robinson,
Stefan Wahren, Ivan T. Ivanov, Jacopo Mondi, Jai Luthra
The pixel rate control is marked as read-only by the framework itself,
so no need to mark it explicitly in the driver. Also, we can set the ops
to NULL to avoid checking for it in the s_ctrl implementation.
Suggested-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
drivers/media/i2c/ov5647.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index 3a2c25a6b6808bf1289a2357ac5b79bf6bf99daa..71107d74f2900b39233a52b29a229282bd087963 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -1195,12 +1195,6 @@ static int ov5647_s_ctrl(struct v4l2_ctrl *ctrl)
ret = ov5647_write(sd, OV5647_REG_ISPCTRL3D,
ov5647_test_pattern_val[ctrl->val]);
break;
-
- /* Read-only, but we adjust it based on mode. */
- case V4L2_CID_PIXEL_RATE:
- /* Read-only, but we adjust it based on mode. */
- break;
-
case V4L2_CID_HFLIP:
/* There's an in-built hflip in the sensor, so account for that here. */
ov5647_s_flip(sd, OV5647_REG_TIMING_TC_H, !ctrl->val);
@@ -1267,7 +1261,7 @@ static int ov5647_init_controls(struct ov5647 *sensor)
V4L2_CID_ANALOGUE_GAIN, 16, 1023, 1, 32);
/* By default, PIXEL_RATE is read only, but it does change per mode */
- sensor->pixel_rate = v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,
+ sensor->pixel_rate = v4l2_ctrl_new_std(&sensor->ctrls, NULL,
V4L2_CID_PIXEL_RATE,
sensor->mode->pixel_rate,
sensor->mode->pixel_rate, 1,
@@ -1306,7 +1300,6 @@ static int ov5647_init_controls(struct ov5647 *sensor)
if (sensor->ctrls.error)
goto handler_free;
- sensor->pixel_rate->flags |= V4L2_CTRL_FLAG_READ_ONLY;
sensor->sd.ctrl_handler = &sensor->ctrls;
return 0;
--
2.51.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 16/16] media: i2c: ov5647: Add V4L2_CID_LINK_FREQUENCY control
2025-11-18 12:02 [PATCH v2 00/16] media: i2c: Miscellaneous features and fixes for OV5647 Jai Luthra
` (14 preceding siblings ...)
2025-11-18 12:03 ` [PATCH v2 15/16] media: i2c: ov5647: Tidy up PIXEL_RATE control Jai Luthra
@ 2025-11-18 12:03 ` Jai Luthra
15 siblings, 0 replies; 19+ messages in thread
From: Jai Luthra @ 2025-11-18 12:03 UTC (permalink / raw)
To: Sakari Ailus, Dave Stevenson, Jacopo Mondi, Mauro Carvalho Chehab,
Naushir Patuck, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: linux-media, linux-kernel, devicetree, Mauro Carvalho Chehab,
Kieran Bingham, David Plowman, Laurent Pinchart, Peter Robinson,
Stefan Wahren, Ivan T. Ivanov, Jacopo Mondi, Jai Luthra
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
The link frequency can vary between modes, so add it as a
control.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
drivers/media/i2c/ov5647.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index 71107d74f2900b39233a52b29a229282bd087963..de27e76b487957bfa0a072359f28194425950eaf 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -97,6 +97,13 @@ static const char * const ov5647_supply_names[] = {
#define OV5647_NUM_SUPPLIES ARRAY_SIZE(ov5647_supply_names)
+#define FREQ_INDEX_FULL 0
+#define FREQ_INDEX_VGA 1
+static const s64 ov5647_link_freqs[] = {
+ [FREQ_INDEX_FULL] = 218750000,
+ [FREQ_INDEX_VGA] = 208333000,
+};
+
struct regval_list {
u16 addr;
u8 data;
@@ -106,6 +113,7 @@ struct ov5647_mode {
struct v4l2_mbus_framefmt format;
struct v4l2_rect crop;
u64 pixel_rate;
+ unsigned int link_freq_index;
int hts;
int vts;
const struct regval_list *reg_list;
@@ -128,6 +136,7 @@ struct ov5647 {
struct v4l2_ctrl *exposure;
struct v4l2_ctrl *hflip;
struct v4l2_ctrl *vflip;
+ struct v4l2_ctrl *link_freq;
};
static inline struct ov5647 *to_sensor(struct v4l2_subdev *sd)
@@ -376,6 +385,7 @@ static const struct ov5647_mode ov5647_modes[] = {
.height = 1944
},
.pixel_rate = 87500000,
+ .link_freq_index = FREQ_INDEX_FULL,
.hts = 2844,
.vts = 0x7b0,
.reg_list = ov5647_2592x1944_10bpp,
@@ -397,6 +407,7 @@ static const struct ov5647_mode ov5647_modes[] = {
.height = 1080,
},
.pixel_rate = 87500000,
+ .link_freq_index = FREQ_INDEX_FULL,
.hts = 2416,
.vts = 0x450,
.reg_list = ov5647_1080p30_10bpp,
@@ -418,6 +429,7 @@ static const struct ov5647_mode ov5647_modes[] = {
.height = 1944,
},
.pixel_rate = 87500000,
+ .link_freq_index = FREQ_INDEX_FULL,
.hts = 1896,
.vts = 0x59b,
.reg_list = ov5647_2x2binned_10bpp,
@@ -439,6 +451,7 @@ static const struct ov5647_mode ov5647_modes[] = {
.height = 1920,
},
.pixel_rate = 55000000,
+ .link_freq_index = FREQ_INDEX_VGA,
.hts = 1852,
.vts = 0x1f8,
.reg_list = ov5647_640x480_10bpp,
@@ -927,6 +940,8 @@ static int ov5647_set_pad_fmt(struct v4l2_subdev *sd,
sensor->exposure->minimum,
exposure_max, sensor->exposure->step,
exposure_def);
+
+ __v4l2_ctrl_s_ctrl(sensor->link_freq, mode->link_freq_index);
}
*fmt = mode->format;
/* The code we pass back must reflect the current h/vflips. */
@@ -1236,7 +1251,7 @@ static int ov5647_init_controls(struct ov5647 *sensor)
int hblank, exposure_max, exposure_def;
struct device *dev = &client->dev;
- v4l2_ctrl_handler_init(&sensor->ctrls, 13);
+ v4l2_ctrl_handler_init(&sensor->ctrls, 14);
v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,
V4L2_CID_AUTOGAIN, 0, 1, 1, 0);
@@ -1292,6 +1307,13 @@ static int ov5647_init_controls(struct ov5647 *sensor)
sensor->vflip = v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,
V4L2_CID_VFLIP, 0, 1, 1, 0);
+ sensor->link_freq =
+ v4l2_ctrl_new_int_menu(&sensor->ctrls, NULL, V4L2_CID_LINK_FREQ,
+ ARRAY_SIZE(ov5647_link_freqs) - 1, 0,
+ ov5647_link_freqs);
+ if (sensor->link_freq)
+ sensor->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
+
v4l2_fwnode_device_parse(dev, &props);
v4l2_ctrl_new_fwnode_properties(&sensor->ctrls, &ov5647_ctrl_ops,
--
2.51.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v2 05/16] dt-bindings: media: ov5647: Add optional regulators
2025-11-18 12:02 ` [PATCH v2 05/16] dt-bindings: media: ov5647: Add optional regulators Jai Luthra
@ 2025-11-19 6:57 ` Krzysztof Kozlowski
0 siblings, 0 replies; 19+ messages in thread
From: Krzysztof Kozlowski @ 2025-11-19 6:57 UTC (permalink / raw)
To: Jai Luthra, Sakari Ailus, Dave Stevenson, Jacopo Mondi,
Mauro Carvalho Chehab, Naushir Patuck, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: linux-media, linux-kernel, devicetree, Mauro Carvalho Chehab,
Kieran Bingham, David Plowman, Laurent Pinchart, Peter Robinson,
Stefan Wahren, Ivan T. Ivanov, Jacopo Mondi
On 18/11/2025 13:02, Jai Luthra wrote:
> The OV5647 camera sensor takes 3 voltage supplies. So define those in
> the bindings as optional regulators, to not break existing users.
>
> Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
> ---
> Documentation/devicetree/bindings/media/i2c/ovti,ov5647.yaml | 9 +++++++++
> 1 file changed, 9 insertions(+)
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 07/16] dt-bindings: media: ov5647: Allow props from video-interface-devices
2025-11-18 12:03 ` [PATCH v2 07/16] dt-bindings: media: ov5647: Allow props from video-interface-devices Jai Luthra
@ 2025-11-19 6:58 ` Krzysztof Kozlowski
0 siblings, 0 replies; 19+ messages in thread
From: Krzysztof Kozlowski @ 2025-11-19 6:58 UTC (permalink / raw)
To: Jai Luthra, Sakari Ailus, Dave Stevenson, Jacopo Mondi,
Mauro Carvalho Chehab, Naushir Patuck, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: linux-media, linux-kernel, devicetree, Mauro Carvalho Chehab,
Kieran Bingham, David Plowman, Laurent Pinchart, Peter Robinson,
Stefan Wahren, Ivan T. Ivanov, Jacopo Mondi
On 18/11/2025 13:03, Jai Luthra wrote:
> Allow properties from video-interface-devices. The change is identical to
> commit 08fbd355be3d ("media: dt-bindings: sony,imx219: Allow props from
> video-interface-devices")
>
> Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
> ---
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2025-11-19 6:58 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-18 12:02 [PATCH v2 00/16] media: i2c: Miscellaneous features and fixes for OV5647 Jai Luthra
2025-11-18 12:02 ` [PATCH v2 01/16] media: i2c: ov5647: Initialize subdev before controls Jai Luthra
2025-11-18 12:02 ` [PATCH v2 02/16] media: i2c: ov5647: Correct pixel array offset Jai Luthra
2025-11-18 12:02 ` [PATCH v2 03/16] media: i2c: ov5647: Correct minimum VBLANK value Jai Luthra
2025-11-18 12:02 ` [PATCH v2 04/16] media: i2c: ov5647: Sensor should report RAW color space Jai Luthra
2025-11-18 12:02 ` [PATCH v2 05/16] dt-bindings: media: ov5647: Add optional regulators Jai Luthra
2025-11-19 6:57 ` Krzysztof Kozlowski
2025-11-18 12:02 ` [PATCH v2 06/16] media: i2c: ov5647: Add support for regulator control Jai Luthra
2025-11-18 12:03 ` [PATCH v2 07/16] dt-bindings: media: ov5647: Allow props from video-interface-devices Jai Luthra
2025-11-19 6:58 ` Krzysztof Kozlowski
2025-11-18 12:03 ` [PATCH v2 08/16] media: i2c: ov5647: Parse and register properties Jai Luthra
2025-11-18 12:03 ` [PATCH v2 09/16] media: i2c: ov5647: Support HFLIP and VFLIP Jai Luthra
2025-11-18 12:03 ` [PATCH v2 10/16] media: i2c: ov5647: Use v4l2_async_register_subdev_sensor for lens binding Jai Luthra
2025-11-18 12:03 ` [PATCH v2 11/16] media: i2c: ov5647: Add control of V4L2_CID_HBLANK Jai Luthra
2025-11-18 12:03 ` [PATCH v2 12/16] media: i2c: ov5647: Tidy up mode registers to make the order common Jai Luthra
2025-11-18 12:03 ` [PATCH v2 13/16] media: i2c: ov5647: Separate out the common registers Jai Luthra
2025-11-18 12:03 ` [PATCH v2 14/16] media: i2c: ov5647: Use the same PLL config for full, 1080p, and binned modes Jai Luthra
2025-11-18 12:03 ` [PATCH v2 15/16] media: i2c: ov5647: Tidy up PIXEL_RATE control Jai Luthra
2025-11-18 12:03 ` [PATCH v2 16/16] media: i2c: ov5647: Add V4L2_CID_LINK_FREQUENCY control Jai Luthra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).