diff mbox series

[v2,2/4] media: ov2740: Add camera orientation and sensor rotation controls

Message ID 20241220114317.21219-2-hdegoede@redhat.com (mailing list archive)
State New
Headers show
Series [v2,1/4] media: ov2740: Debug log chip ID | expand

Commit Message

Hans de Goede Dec. 20, 2024, 11:43 a.m. UTC
Add camera orientation and sensor rotation controls using
the v4l2_fwnode_device_parse() and v4l2_ctrl_new_fwnode_properties()
helpers.

Tested-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
- Call v4l2_ctrl_handler_free() on v4l2_fwnode_device_parse() errors
---
 drivers/media/i2c/ov2740.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Ricardo Ribalda Dec. 20, 2024, 12:12 p.m. UTC | #1
On Fri, 20 Dec 2024 at 12:43, Hans de Goede <hdegoede@redhat.com> wrote:
>
> Add camera orientation and sensor rotation controls using
> the v4l2_fwnode_device_parse() and v4l2_ctrl_new_fwnode_properties()
> helpers.
>
> Tested-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> Changes in v2:
> - Call v4l2_ctrl_handler_free() on v4l2_fwnode_device_parse() errors
> ---
>  drivers/media/i2c/ov2740.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c
> index a79e478342dd..bd7475c337e2 100644
> --- a/drivers/media/i2c/ov2740.c
> +++ b/drivers/media/i2c/ov2740.c
> @@ -755,15 +755,17 @@ static const struct v4l2_ctrl_ops ov2740_ctrl_ops = {
>
>  static int ov2740_init_controls(struct ov2740 *ov2740)
>  {
> +       struct i2c_client *client = v4l2_get_subdevdata(&ov2740->sd);
>         struct v4l2_ctrl_handler *ctrl_hdlr;
>         const struct ov2740_mode *cur_mode;
>         s64 exposure_max, h_blank, pixel_rate;
>         u32 vblank_min, vblank_max, vblank_default;
> +       struct v4l2_fwnode_device_properties props;
>         int size;
>         int ret;
>
>         ctrl_hdlr = &ov2740->ctrl_handler;
> -       ret = v4l2_ctrl_handler_init(ctrl_hdlr, 8);
> +       ret = v4l2_ctrl_handler_init(ctrl_hdlr, 10);
>         if (ret)
>                 return ret;
>
> @@ -813,6 +815,15 @@ static int ov2740_init_controls(struct ov2740 *ov2740)
>                                      V4L2_CID_TEST_PATTERN,
>                                      ARRAY_SIZE(ov2740_test_pattern_menu) - 1,
>                                      0, 0, ov2740_test_pattern_menu);
> +
> +       ret = v4l2_fwnode_device_parse(&client->dev, &props);
> +       if (ret) {
> +               v4l2_ctrl_handler_free(ctrl_hdlr);
> +               return ret;
> +       }
> +
> +       v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &ov2740_ctrl_ops, &props);
> +
>         if (ctrl_hdlr->error) {
>                 v4l2_ctrl_handler_free(ctrl_hdlr);
>                 return ctrl_hdlr->error;
> --
> 2.47.1
>
diff mbox series

Patch

diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c
index a79e478342dd..bd7475c337e2 100644
--- a/drivers/media/i2c/ov2740.c
+++ b/drivers/media/i2c/ov2740.c
@@ -755,15 +755,17 @@  static const struct v4l2_ctrl_ops ov2740_ctrl_ops = {
 
 static int ov2740_init_controls(struct ov2740 *ov2740)
 {
+	struct i2c_client *client = v4l2_get_subdevdata(&ov2740->sd);
 	struct v4l2_ctrl_handler *ctrl_hdlr;
 	const struct ov2740_mode *cur_mode;
 	s64 exposure_max, h_blank, pixel_rate;
 	u32 vblank_min, vblank_max, vblank_default;
+	struct v4l2_fwnode_device_properties props;
 	int size;
 	int ret;
 
 	ctrl_hdlr = &ov2740->ctrl_handler;
-	ret = v4l2_ctrl_handler_init(ctrl_hdlr, 8);
+	ret = v4l2_ctrl_handler_init(ctrl_hdlr, 10);
 	if (ret)
 		return ret;
 
@@ -813,6 +815,15 @@  static int ov2740_init_controls(struct ov2740 *ov2740)
 				     V4L2_CID_TEST_PATTERN,
 				     ARRAY_SIZE(ov2740_test_pattern_menu) - 1,
 				     0, 0, ov2740_test_pattern_menu);
+
+	ret = v4l2_fwnode_device_parse(&client->dev, &props);
+	if (ret) {
+		v4l2_ctrl_handler_free(ctrl_hdlr);
+		return ret;
+	}
+
+	v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &ov2740_ctrl_ops, &props);
+
 	if (ctrl_hdlr->error) {
 		v4l2_ctrl_handler_free(ctrl_hdlr);
 		return ctrl_hdlr->error;