From 2dca6484c70f2e741d13725b296e9617170d41da Mon Sep 17 00:00:00 2001 From: gabrielstedman Date: Wed, 14 Jan 2026 21:48:24 +0000 Subject: [PATCH 1/3] Surface Pro 9: Set correct front camera rotation --- drivers/media/i2c/ov5693.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov5693.c b/drivers/media/i2c/ov5693.c index 46bc6c5b7758..83bc2d4368eb 100644 --- a/drivers/media/i2c/ov5693.c +++ b/drivers/media/i2c/ov5693.c @@ -169,6 +169,7 @@ struct ov5693_device { struct v4l2_ctrl *hblank; struct v4l2_ctrl *vblank; struct v4l2_ctrl *test_pattern; + struct v4l2_ctrl *rotation; } ctrls; }; @@ -351,6 +352,11 @@ static const u8 ov5693_test_pattern_bits[] = { OV5693_TEST_PATTERN_ROLLING, }; +enum ov5693_model_id { + OV5693_INT33BE = 0, + OV5693_OVTI, +}; + /* V4L2 Controls Functions */ static int ov5693_flip_vert_configure(struct ov5693_device *ov5693, @@ -1127,6 +1133,9 @@ static int ov5693_init_controls(struct ov5693_device *ov5693) OV5693_DIGITAL_GAIN_STEP, OV5693_DIGITAL_GAIN_DEF); + /* Rotation */ + ctrls->rotation = v4l2_ctrl_new_std(&ctrls->handler, ops, + V4L2_CID_CAMERA_SENSOR_ROTATION, 0, 270, 90, 180); /* Flip */ ctrls->hflip = v4l2_ctrl_new_std(&ctrls->handler, ops, V4L2_CID_HFLIP, 0, 1, 1, 0); @@ -1268,6 +1277,7 @@ static int ov5693_check_hwcfg(struct ov5693_device *ov5693) static int ov5693_probe(struct i2c_client *client) { struct ov5693_device *ov5693; + uintptr_t variant; u32 xvclk_rate; int ret = 0; @@ -1321,6 +1331,16 @@ static int ov5693_probe(struct i2c_client *client) if (ret) return ret; + variant = (uintptr_t)device_get_match_data(ov5693->dev); + switch (variant) { + case OV5693_OVTI: + dev_info(ov5693->dev, "Applying specific OVTI5693 initialization\n"); + v4l2_ctrl_s_ctrl(ov5693->ctrls.rotation, 180); + break; + default: + break; + } + ret = media_entity_pads_init(&ov5693->sd.entity, 1, &ov5693->pad); if (ret) goto err_ctrl_handler_free; @@ -1395,8 +1415,8 @@ static const struct dev_pm_ops ov5693_pm_ops = { }; static const struct acpi_device_id ov5693_acpi_match[] = { - {"INT33BE"}, - {"OVTI5693"}, + {"INT33BE", OV5693_INT33BE}, + {"OVTI5693", OV5693_OVTI}, {}, }; MODULE_DEVICE_TABLE(acpi, ov5693_acpi_match); From b9db6e408ef8fdd8eccaed9b16d7b1b6512f1efb Mon Sep 17 00:00:00 2001 From: gabrielstedman Date: Sat, 17 Jan 2026 19:22:39 +0000 Subject: [PATCH 2/3] Ensure default rotation is 0 --- drivers/media/i2c/ov5693.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov5693.c b/drivers/media/i2c/ov5693.c index 83bc2d4368eb..35256d31c6c9 100644 --- a/drivers/media/i2c/ov5693.c +++ b/drivers/media/i2c/ov5693.c @@ -1135,7 +1135,7 @@ static int ov5693_init_controls(struct ov5693_device *ov5693) /* Rotation */ ctrls->rotation = v4l2_ctrl_new_std(&ctrls->handler, ops, - V4L2_CID_CAMERA_SENSOR_ROTATION, 0, 270, 90, 180); + V4L2_CID_CAMERA_SENSOR_ROTATION, 0, 270, 90, 0); /* Flip */ ctrls->hflip = v4l2_ctrl_new_std(&ctrls->handler, ops, V4L2_CID_HFLIP, 0, 1, 1, 0); From 988a2cd09981ec823153a7c8f8e9cd940ef344df Mon Sep 17 00:00:00 2001 From: gabrielstedman Date: Sat, 24 Jan 2026 22:24:51 +0000 Subject: [PATCH 3/3] Set default sensor rotation via parameter --- drivers/media/i2c/ov5693.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/drivers/media/i2c/ov5693.c b/drivers/media/i2c/ov5693.c index 35256d31c6c9..fbf9188151db 100644 --- a/drivers/media/i2c/ov5693.c +++ b/drivers/media/i2c/ov5693.c @@ -132,6 +132,8 @@ static const char * const ov5693_supply_names[] = { #define OV5693_NUM_SUPPLIES ARRAY_SIZE(ov5693_supply_names) +static int sensor_default_rotation; + struct ov5693_device { struct device *dev; struct regmap *regmap; @@ -352,11 +354,6 @@ static const u8 ov5693_test_pattern_bits[] = { OV5693_TEST_PATTERN_ROLLING, }; -enum ov5693_model_id { - OV5693_INT33BE = 0, - OV5693_OVTI, -}; - /* V4L2 Controls Functions */ static int ov5693_flip_vert_configure(struct ov5693_device *ov5693, @@ -1132,10 +1129,9 @@ static int ov5693_init_controls(struct ov5693_device *ov5693) OV5693_DIGITAL_GAIN_MAX, OV5693_DIGITAL_GAIN_STEP, OV5693_DIGITAL_GAIN_DEF); - /* Rotation */ ctrls->rotation = v4l2_ctrl_new_std(&ctrls->handler, ops, - V4L2_CID_CAMERA_SENSOR_ROTATION, 0, 270, 90, 0); + V4L2_CID_CAMERA_SENSOR_ROTATION, 0, 270, 90, sensor_default_rotation); /* Flip */ ctrls->hflip = v4l2_ctrl_new_std(&ctrls->handler, ops, V4L2_CID_HFLIP, 0, 1, 1, 0); @@ -1277,7 +1273,6 @@ static int ov5693_check_hwcfg(struct ov5693_device *ov5693) static int ov5693_probe(struct i2c_client *client) { struct ov5693_device *ov5693; - uintptr_t variant; u32 xvclk_rate; int ret = 0; @@ -1331,16 +1326,6 @@ static int ov5693_probe(struct i2c_client *client) if (ret) return ret; - variant = (uintptr_t)device_get_match_data(ov5693->dev); - switch (variant) { - case OV5693_OVTI: - dev_info(ov5693->dev, "Applying specific OVTI5693 initialization\n"); - v4l2_ctrl_s_ctrl(ov5693->ctrls.rotation, 180); - break; - default: - break; - } - ret = media_entity_pads_init(&ov5693->sd.entity, 1, &ov5693->pad); if (ret) goto err_ctrl_handler_free; @@ -1415,8 +1400,8 @@ static const struct dev_pm_ops ov5693_pm_ops = { }; static const struct acpi_device_id ov5693_acpi_match[] = { - {"INT33BE", OV5693_INT33BE}, - {"OVTI5693", OV5693_OVTI}, + {"INT33BE"}, + {"OVTI5693"}, {}, }; MODULE_DEVICE_TABLE(acpi, ov5693_acpi_match); @@ -1438,6 +1423,8 @@ static struct i2c_driver ov5693_driver = { .remove = ov5693_remove, }; module_i2c_driver(ov5693_driver); +module_param(sensor_default_rotation, int, 0644); +MODULE_PARM_DESC(sensor_default_rotation, "Sensor default rotation in degrees (0, 90, 180, 270)"); MODULE_DESCRIPTION("A low-level driver for OmniVision 5693 sensors"); MODULE_LICENSE("GPL");