v4l2-ctl: add function vidcap_get_and_update_fmt
PATCH v3 1/1 v4l2-ctl: add function vidcap_get_and_update_fmt
add a function vidcap_get_and_update_fmt to set the format from cmd params. Use it in capture_setup.
Signed-off-by Dafna Hirschfeld <[email protected]>
---
Changes from v2:
move get_cap_compose_rect to after s_fmt in capture_setup
utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 15 ++- utils/v4l2-ctl/v4l2-ctl-vidcap.cpp | 134 ++++++++++++++------------ utils/v4l2-ctl/v4l2-ctl.h | 1 + 3 files changed, 89 insertions(+), 61 deletions(-)
utils/v4l2-ctl/v4l2-ctl-streaming.cpp +14 -1
@@ -1894,7 +1894,6 @@ static int capture_setup(cv4l_fd &fd, cv4l_queue &in, cv4l_fd *exp_fd) fprintf(stderr, "%s: fd.streamoff error\n", __func__); return -1; } - get_cap_compose_rect(fd); /* release any buffer allocated */ if (in.reqbufs(&fd)) {
@@ -1902,17 +1901,31 @@ static int capture_setup(cv4l_fd &fd, cv4l_queue &in, cv4l_fd *exp_fd) return -1; } + if (options[OptSetVideoFormat]) { + cv4l_fmt fmt; + + if (vidcap_get_and_update_fmt(fd, fmt)) { + fprintf(stderr, "%s: vidcap_get_and_update_fmt error\n", + __func__); + return -1; + } + fd.s_fmt(fmt, in.g_type()); + } + get_cap_compose_rect(fd); + if (in.reqbufs(&fd, reqbufs_count_cap)) { fprintf(stderr, "%s: in.reqbufs %u error\n", __func__, reqbufs_count_cap); return -1; } + if (exp_fd && in.export_bufs(exp_fd, exp_fd->g_type())) return -1; if (in.obtain_bufs(&fd) || in.queue_all(&fd)) { fprintf(stderr, "%s: in.obtain_bufs error\n", __func__); return -1; } + if (fd.streamon(in.g_type())) { fprintf(stderr, "%s: fd.streamon error\n", __func__); return -1;
utils/v4l2-ctl/v4l2-ctl-vidcap.cpp +74 -60
148 lines not on this page · raw message
utils/v4l2-ctl/v4l2-ctl.h +1 -0
@@ -348,6 +348,7 @@ void stds_list(cv4l_fd &fd);// v4l2-ctl-vidcap.cpp void vidcap_usage (void );void vidcap_cmd (int ch,char *optarg); +int vidcap_get_and_update_fmt(cv4l_fd &_fd, struct v4l2_format &vfmt); void vidcap_set(cv4l_fd &fd); void vidcap_get(cv4l_fd &fd); void vidcap_list(cv4l_fd &fd);
Signature · 1 line
2.17.1