diff mbox series

[RFC,v2,6/6] media: vivid: Add a video region ctrl

Message ID 20241018054448.3190423-7-ming.qian@nxp.com (mailing list archive)
State New
Headers show
Series Add video encoder ROI ctrls | expand

Commit Message

Ming Qian Oct. 18, 2024, 5:44 a.m. UTC
This control represents a generic read/write region.
It supports V4L2_CTRL_WHICH_MIN/MAX_VAL.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: TaoJiang <tao.jiang_2@nxp.com>
---
 .../media/test-drivers/vivid/vivid-ctrls.c    | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)
diff mbox series

Patch

diff --git a/drivers/media/test-drivers/vivid/vivid-ctrls.c b/drivers/media/test-drivers/vivid/vivid-ctrls.c
index bed5f4fb0c69..6ea64bea13de 100644
--- a/drivers/media/test-drivers/vivid/vivid-ctrls.c
+++ b/drivers/media/test-drivers/vivid/vivid-ctrls.c
@@ -38,6 +38,7 @@ 
 #define VIVID_CID_S32_ARRAY		(VIVID_CID_CUSTOM_BASE + 15)
 #define VIVID_CID_S64_ARRAY		(VIVID_CID_CUSTOM_BASE + 16)
 #define VIVID_CID_RECT			(VIVID_CID_CUSTOM_BASE + 17)
+#define VIVID_CID_REGION		(VIVID_CID_CUSTOM_BASE + 18)
 
 #define VIVID_CID_VIVID_BASE		(0x00f00000 | 0xf000)
 #define VIVID_CID_VIVID_CLASS		(0x00f00000 | 1)
@@ -393,6 +394,32 @@  static const struct v4l2_ctrl_config vivid_ctrl_rect = {
 	.p_max.p_const = &rect_max,
 };
 
+static const struct v4l2_ctrl_video_region_param region_def = {
+	.rect = { 0, 0, 0, 0 },
+	.parameter = 0,
+};
+
+static const struct v4l2_ctrl_video_region_param region_min = {
+	.rect = { 0, 0, 0, 0 },
+	.parameter = -51,
+};
+
+static const struct v4l2_ctrl_video_region_param region_max = {
+	.rect = { 0, 0, 1920, 1080 },
+	.parameter = 51,
+};
+
+static const struct v4l2_ctrl_config vivid_ctrl_region = {
+	.ops = &vivid_user_gen_ctrl_ops,
+	.id = VIVID_CID_REGION,
+	.name = "Region",
+	.type = V4L2_CTRL_TYPE_REGION,
+	.flags = V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX,
+	.p_def.p_const = &region_def,
+	.p_min.p_const = &region_min,
+	.p_max.p_const = &region_max,
+};
+
 /* Framebuffer Controls */
 
 static int vivid_fb_s_ctrl(struct v4l2_ctrl *ctrl)
@@ -1719,6 +1746,7 @@  int vivid_create_controls(struct vivid_dev *dev, bool show_ccs_cap,
 	dev->ro_int32 = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_ro_int32, NULL);
 	v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_area, NULL);
 	v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_rect, NULL);
+	v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_region, NULL);
 	v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u32_array, NULL);
 	v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u32_dyn_array, NULL);
 	v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u16_matrix, NULL);