From: Sebastian Reichel Date: Wed, 20 Aug 2025 00:13:20 +0000 (+0200) Subject: media: ov02c10: Support hflip and vflip X-Git-Tag: v6.19-rc1~159^2~130 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b7cd2ba3f692729906ad6eeefc78dd625021c7bd;p=thirdparty%2Fkernel%2Flinux.git media: ov02c10: Support hflip and vflip Support horizontal and vertical flip, which is necessary to handle upside-down mounted sensors. Suggested-by: Bryan O'Donoghue Signed-off-by: Sebastian Reichel Reviewed-by: Bryan O'Donoghue Signed-off-by: Sakari Ailus Signed-off-by: Hans Verkuil --- diff --git a/drivers/media/i2c/ov02c10.c b/drivers/media/i2c/ov02c10.c index 8e22ff446b0c4..b1e540eb83265 100644 --- a/drivers/media/i2c/ov02c10.c +++ b/drivers/media/i2c/ov02c10.c @@ -385,6 +385,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; @@ -485,7 +497,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, @@ -536,6 +548,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,