Support horizontal and vertical flip, which is necessary to handle
upside-down mounted sensors.
Suggested-by: Bryan O'Donoghue <bod@kernel.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
drivers/media/i2c/ov02c10.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov02c10.c b/drivers/media/i2c/ov02c10.c
index 3a02fce0a9bc0ca3ab87defe3eefd04efb4012e7..103d007415348a8bd31a09e518de23f5fd77c618 100644
--- a/drivers/media/i2c/ov02c10.c
+++ b/drivers/media/i2c/ov02c10.c
@@ -384,6 +384,8 @@ struct ov02c10 {
struct v4l2_ctrl *vblank;
struct v4l2_ctrl *hblank;
struct v4l2_ctrl *exposure;
+ struct v4l2_ctrl *hflip;
+ struct v4l2_ctrl *vflip;
struct clk *img_clk;
struct gpio_desc *reset;
@@ -462,6 +464,16 @@ static int ov02c10_set_ctrl(struct v4l2_ctrl *ctrl)
ret = ov02c10_test_pattern(ov02c10, ctrl->val);
break;
+ case V4L2_CID_HFLIP:
+ cci_update_bits(ov02c10->regmap, OV02C10_ROTATE_CONTROL,
+ BIT(3), ov02c10->hflip->val << 3, &ret);
+ break;
+
+ case V4L2_CID_VFLIP:
+ cci_update_bits(ov02c10->regmap, OV02C10_ROTATE_CONTROL,
+ BIT(4), ov02c10->vflip->val << 4, &ret);
+ break;
+
default:
ret = -EINVAL;
break;
@@ -486,7 +498,7 @@ static int ov02c10_init_controls(struct ov02c10 *ov02c10)
s64 exposure_max, h_blank, pixel_rate;
int ret;
- v4l2_ctrl_handler_init(ctrl_hdlr, 10);
+ v4l2_ctrl_handler_init(ctrl_hdlr, 12);
ov02c10->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr,
&ov02c10_ctrl_ops,
@@ -537,6 +549,17 @@ static int ov02c10_init_controls(struct ov02c10 *ov02c10)
exposure_max,
OV02C10_EXPOSURE_STEP,
exposure_max);
+
+ ov02c10->hflip = v4l2_ctrl_new_std(ctrl_hdlr, &ov02c10_ctrl_ops,
+ V4L2_CID_HFLIP, 0, 1, 1, 0);
+ if (ov02c10->hflip)
+ ov02c10->hflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
+
+ ov02c10->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &ov02c10_ctrl_ops,
+ V4L2_CID_VFLIP, 0, 1, 1, 0);
+ if (ov02c10->vflip)
+ ov02c10->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
+
v4l2_ctrl_new_std_menu_items(ctrl_hdlr, &ov02c10_ctrl_ops,
V4L2_CID_TEST_PATTERN,
ARRAY_SIZE(ov02c10_test_pattern_menu) - 1,
--
2.50.1
On 20/08/2025 01:13, Sebastian Reichel wrote:
> Support horizontal and vertical flip, which is necessary to handle
> upside-down mounted sensors.
>
> Suggested-by: Bryan O'Donoghue <bod@kernel.org>
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> ---
> drivers/media/i2c/ov02c10.c | 25 ++++++++++++++++++++++++-
> 1 file changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/i2c/ov02c10.c b/drivers/media/i2c/ov02c10.c
> index 3a02fce0a9bc0ca3ab87defe3eefd04efb4012e7..103d007415348a8bd31a09e518de23f5fd77c618 100644
> --- a/drivers/media/i2c/ov02c10.c
> +++ b/drivers/media/i2c/ov02c10.c
> @@ -384,6 +384,8 @@ struct ov02c10 {
> struct v4l2_ctrl *vblank;
> struct v4l2_ctrl *hblank;
> struct v4l2_ctrl *exposure;
> + struct v4l2_ctrl *hflip;
> + struct v4l2_ctrl *vflip;
>
> struct clk *img_clk;
> struct gpio_desc *reset;
> @@ -462,6 +464,16 @@ static int ov02c10_set_ctrl(struct v4l2_ctrl *ctrl)
> ret = ov02c10_test_pattern(ov02c10, ctrl->val);
> break;
>
> + case V4L2_CID_HFLIP:
> + cci_update_bits(ov02c10->regmap, OV02C10_ROTATE_CONTROL,
> + BIT(3), ov02c10->hflip->val << 3, &ret);
> + break;
> +
> + case V4L2_CID_VFLIP:
> + cci_update_bits(ov02c10->regmap, OV02C10_ROTATE_CONTROL,
> + BIT(4), ov02c10->vflip->val << 4, &ret);
> + break;
> +
> default:
> ret = -EINVAL;
> break;
> @@ -486,7 +498,7 @@ static int ov02c10_init_controls(struct ov02c10 *ov02c10)
> s64 exposure_max, h_blank, pixel_rate;
> int ret;
>
> - v4l2_ctrl_handler_init(ctrl_hdlr, 10);
> + v4l2_ctrl_handler_init(ctrl_hdlr, 12);
>
> ov02c10->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr,
> &ov02c10_ctrl_ops,
> @@ -537,6 +549,17 @@ static int ov02c10_init_controls(struct ov02c10 *ov02c10)
> exposure_max,
> OV02C10_EXPOSURE_STEP,
> exposure_max);
> +
> + ov02c10->hflip = v4l2_ctrl_new_std(ctrl_hdlr, &ov02c10_ctrl_ops,
> + V4L2_CID_HFLIP, 0, 1, 1, 0);
> + if (ov02c10->hflip)
> + ov02c10->hflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
> +
> + ov02c10->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &ov02c10_ctrl_ops,
> + V4L2_CID_VFLIP, 0, 1, 1, 0);
> + if (ov02c10->vflip)
> + ov02c10->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
> +
> v4l2_ctrl_new_std_menu_items(ctrl_hdlr, &ov02c10_ctrl_ops,
> V4L2_CID_TEST_PATTERN,
> ARRAY_SIZE(ov02c10_test_pattern_menu) - 1,
>
> --
> 2.50.1
>
Reviewed-by: Bryan O'Donoghue <bod@kernel.org>
© 2016 - 2026 Red Hat, Inc.