diff mbox series

[v3,3/4] v4l2-ctl: Support V4L2_CTRL_TYPE_RECT

Message ID 20241106061537.211002-4-ming.qian@oss.nxp.com (mailing list archive)
State New
Headers show
Series Support V4L2_CTRL_TYPE_RECT and | expand

Commit Message

Ming Qian(OSS) Nov. 6, 2024, 6:15 a.m. UTC
From: Yunke Cao <yunkec@google.com>

Tested with VIVID

 ./v4l2-ctl -C rect -d 0
 rect: (200,100)/300x400

 ./v4l2-ctl -c rect="(0,0)/1000x2000"
 ./v4l2-ctl -C rect -d 0
 rect: (0,0)/1000x2000

Signed-off-by: Yunke Cao <yunkec@google.com>
Signed-off-by: Ming Qian <ming.qian@oss.nxp.com>
---
 utils/v4l2-ctl/v4l2-ctl-common.cpp | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp
index 40667575fcc7..1859292f6f77 100644
--- a/utils/v4l2-ctl/v4l2-ctl-common.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp
@@ -614,6 +614,11 @@  static void print_value(int fd, const v4l2_query_ext_ctrl &qc, const v4l2_ext_co
 		case V4L2_CTRL_TYPE_AREA:
 			printf("%dx%d", ctrl.p_area->width, ctrl.p_area->height);
 			break;
+		case V4L2_CTRL_TYPE_RECT:
+			printf("(%d,%d)/%ux%u",
+			       ctrl.p_rect->left, ctrl.p_rect->top,
+			       ctrl.p_rect->width, ctrl.p_rect->height);
+			break;
 		default:
 			printf("unsupported payload type");
 			break;
@@ -702,6 +707,9 @@  static void print_qctrl(int fd, const v4l2_query_ext_ctrl &qc,
 	case V4L2_CTRL_TYPE_AREA:
 		printf("%31s %#8.8x (area)   :", s.c_str(), qc.id);
 		break;
+	case V4L2_CTRL_TYPE_RECT:
+		printf("%31s %#8.8x (rect)   :", s.c_str(), qc.id);
+		break;
 	case V4L2_CTRL_TYPE_HDR10_CLL_INFO:
 		printf("%31s %#8.8x (hdr10-cll-info):", s.c_str(), qc.id);
 		break;
@@ -1279,6 +1287,11 @@  void common_set(cv4l_fd &_fd)
 					sscanf(set_ctrl.second.c_str(), "%ux%u",
 					       &ctrl.p_area->width, &ctrl.p_area->height);
 					break;
+				case V4L2_CTRL_TYPE_RECT:
+					sscanf(set_ctrl.second.c_str(), "(%d,%d)/%ux%u",
+					       &ctrl.p_rect->left, &ctrl.p_rect->top,
+					       &ctrl.p_rect->width, &ctrl.p_rect->height);
+					break;
 				default:
 					fprintf(stderr, "%s: unsupported payload type\n",
 							qc.name);