[PATCH v2 6/9] media: i2c: ov7251: Add orientation and rotation controls

From: Antoine Pichot

Date: Wed Oct 28 2026 - 07:33:55 EST


Parse the firmware device properties and register the
V4L2_CID_CAMERA_ORIENTATION and V4L2_CID_CAMERA_SENSOR_ROTATION
controls, as documented in
Documentation/driver-api/media/camera-sensor.rst. libcamera uses them to
place the camera and to correct the image orientation.

While at it, bump the control handler size hint to the number of
controls the driver now creates.

On the Microsoft Surface Book 2 the ACPI _PLD (via ipu-bridge) reports
the IR sensor as front facing with no rotation.

Signed-off-by: Antoine Pichot <antoine.pichot@xxxxxxxxx>
Tested-by: D. Manresa <dmanresa@xxxxxxxxx> # Surface Pro 7+, IPU6 (8086:9a19)
---
drivers/media/i2c/ov7251.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov7251.c b/drivers/media/i2c/ov7251.c
index 8277e28ac645..d591b9169de8 100644
--- a/drivers/media/i2c/ov7251.c
+++ b/drivers/media/i2c/ov7251.c
@@ -1512,10 +1512,16 @@ static int ov7251_detect_chip(struct ov7251 *ov7251)
static int ov7251_init_ctrls(struct ov7251 *ov7251)
{
const struct ov7251_mode_info *mode = ov7251->current_mode;
+ struct v4l2_fwnode_device_properties props;
int vblank_max, vblank_def;
int hblank;
+ int ret;

- v4l2_ctrl_handler_init(&ov7251->ctrls, 7);
+ ret = v4l2_fwnode_device_parse(ov7251->dev, &props);
+ if (ret)
+ return ret;
+
+ v4l2_ctrl_handler_init(&ov7251->ctrls, 11);

v4l2_ctrl_new_std(&ov7251->ctrls, &ov7251_ctrl_ops,
V4L2_CID_HFLIP, 0, 1, 1, 0);
@@ -1563,6 +1569,9 @@ static int ov7251_init_ctrls(struct ov7251 *ov7251)
OV7251_TIMING_MIN_VTS, vblank_max, 1,
vblank_def);

+ v4l2_ctrl_new_fwnode_properties(&ov7251->ctrls, &ov7251_ctrl_ops,
+ &props);
+
ov7251->sd.ctrl_handler = &ov7251->ctrls;

if (ov7251->ctrls.error) {
--
2.56.0