v4l2-ctl: Add --get/--set-ctrl support for INTEGER and INTEGER64 arrays
PATCH 1/1 v4l2-ctl: Add --get/--set-ctrl support for INTEGER and INTEGER64 arrays
Add support for INTEGER and INTEGER64 arrays.
Also print error if trying to print unkown array type
Signed-off-by Daniel Lundberg Pedersen <[email protected]>
---
NOTE: This patch depends on the fixed pointer types for p_s32 and p_s64 from this patch:
https://lore.kernel.org/linux-media/[email protected]/
utils/v4l2-ctl/v4l2-ctl-common.cpp | 34 +++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)
utils/v4l2-ctl/v4l2-ctl-common.cpp +32 -0
@@ -472,6 +472,26 @@ static void print_array(const v4l2_query_ext_ctrl &qc, const v4l2_ext_control &c } printf("\n"); break; + case V4L2_CTRL_TYPE_INTEGER: + for (i = from; i <= to; i++) { + printf("%10i", ctrl.p_s32[idx + i]); + if (i < to) + printf(", "); + } + printf("\n"); + break; + case V4L2_CTRL_TYPE_INTEGER64: + for (i = from; i <= to; i++) { + printf("%12lli", ctrl.p_s64[idx + i]); + if (i < to) + printf(", "); + } + printf("\n"); + break; + default: + fprintf(stderr, "%s: unsupported array type\n", + qc.name); + break; } } }
@@ -1149,6 +1169,18 @@ void common_set(cv4l_fd &_fd) if (idx_in_subset(qc, subset, divide, i)) ctrl.p_u32[i] = v; break; + case V4L2_CTRL_TYPE_INTEGER: + v = strtol(set_ctrl.second.c_str(), nullptr, 0); + for (i = 0; i < qc.elems; i++) + if (idx_in_subset(qc, subset, divide, i)) + ctrl.p_s32[i] = v; + break; + case V4L2_CTRL_TYPE_INTEGER64: + v = strtol(set_ctrl.second.c_str(), nullptr, 0); + for (i = 0; i < qc.elems; i++) + if (idx_in_subset(qc, subset, divide, i)) + ctrl.p_s64[i] = v; + break; case V4L2_CTRL_TYPE_STRING: strncpy(ctrl.string, set_ctrl.second.c_str(), qc.maximum); ctrl.string[qc.maximum] = 0;
--
2.38.5
Hi
Gentle ping Hans
Regards Daniel
Quoted 66 lines · Daniel Lundberg Pedersen
Add support for INTEGER and INTEGER64 arrays.
Also print error if trying to print unkown array type
Signed-off-by Daniel Lundberg Pedersen <[email protected]>---
NOTE: This patch depends on the fixed pointer types forp_s32andp_s64from this patch:
https://lore.kernel.org/linux-media/[email protected]/utils/v4l2-ctl/v4l2-ctl-common.cpp | 34 +++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)utils/v4l2-ctl/v4l2-ctl-common.cpp +32
-1@@ -472,6 +472,26 @@ static void print_array(const v4l2_query_ext_ctrl &qc, const v4l2_ext_control &c } printf("\n"); break; + case V4L2_CTRL_TYPE_INTEGER: + for (i = from; i <= to; i++) { + printf("%10i", ctrl.p_s32[idx + i]); + if (i < to) + printf(", "); + } + printf("\n"); + break; + case V4L2_CTRL_TYPE_INTEGER64: + for (i = from; i <= to; i++) { + printf("%12lli", ctrl.p_s64[idx + i]); + if (i < to) + printf(", "); + } + printf("\n"); + break; + default: + fprintf(stderr, "%s: unsupported array type\n", + qc.name); + break; } } }@@ -1149,6 +1169,18 @@ void common_set(cv4l_fd &_fd) if (idx_in_subset(qc, subset, divide, i)) ctrl.p_u32[i] = v; break; + case V4L2_CTRL_TYPE_INTEGER: + v = strtol(set_ctrl.second.c_str(), nullptr, 0); + for (i = 0; i < qc.elems; i++) + if (idx_in_subset(qc, subset, divide, i)) + ctrl.p_s32[i] = v; + break; + case V4L2_CTRL_TYPE_INTEGER64: + v = strtol(set_ctrl.second.c_str(), nullptr, 0); + for (i = 0; i < qc.elems; i++) + if (idx_in_subset(qc, subset, divide, i)) + ctrl.p_s64[i] = v; + break; case V4L2_CTRL_TYPE_STRING: strncpy(ctrl.string, set_ctrl.second.c_str(), qc.maximum); ctrl.string[qc.maximum] = 0; --2.38.5