diff mbox series

[PATCHv3,1/2] media: staging: tegra-video: postpone v4l2_ctrl_add_handler

Message ID a01da964b8328afe041f05343af8bc4a4b7004f3.1731399278.git.hverkuil@xs4all.nl
State New
Headers show
Series [PATCHv3,1/2] media: staging: tegra-video: postpone v4l2_ctrl_add_handler | expand

Commit Message

Hans Verkuil Nov. 12, 2024, 8:14 a.m. UTC
The v4l2_ctrl_add_handler call should be done after all local
controls are added. This ensures that local controls override
any controls inherited from another handler.

This will be checked and a WARN will be issued if this happens,
so fix this behavior in this driver.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
---
 drivers/staging/media/tegra-video/vi.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c
index ad481b35e618..32db6a36d058 100644
--- a/drivers/staging/media/tegra-video/vi.c
+++ b/drivers/staging/media/tegra-video/vi.c
@@ -980,6 +980,11 @@  static int tegra_channel_setup_ctrl_handler(struct tegra_vi_channel *chan)
 	if (!subdev)
 		return -ENODEV;
 
+	if (chan->vi->soc->has_h_v_flip) {
+		v4l2_ctrl_new_std(&chan->ctrl_handler, &vi_ctrl_ops, V4L2_CID_HFLIP, 0, 1, 1, 0);
+		v4l2_ctrl_new_std(&chan->ctrl_handler, &vi_ctrl_ops, V4L2_CID_VFLIP, 0, 1, 1, 0);
+	}
+
 	ret = v4l2_ctrl_add_handler(&chan->ctrl_handler, subdev->ctrl_handler,
 				    NULL, true);
 	if (ret < 0) {
@@ -989,12 +994,6 @@  static int tegra_channel_setup_ctrl_handler(struct tegra_vi_channel *chan)
 		v4l2_ctrl_handler_free(&chan->ctrl_handler);
 		return ret;
 	}
-
-	if (chan->vi->soc->has_h_v_flip) {
-		v4l2_ctrl_new_std(&chan->ctrl_handler, &vi_ctrl_ops, V4L2_CID_HFLIP, 0, 1, 1, 0);
-		v4l2_ctrl_new_std(&chan->ctrl_handler, &vi_ctrl_ops, V4L2_CID_VFLIP, 0, 1, 1, 0);
-	}
-
 #endif
 
 	/* setup the controls */