This is an automatic generated email to let you know that the following patch were queued at the http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:
Subject: v4l2-ctl: disable_trace disabled too much Author: Hans Verkuil <hverkuil-ci...@xs4all.nl> Date: Tue Apr 2 11:28:59 2019 +0200 When trying to stream twice from the same device the second attempt silently exits since REQBUFS returns EBUSY. The problem is that there is no feedback of the ioctl error to the user, and that is because the ioctl tracing is disabled before REQBUFS is called. Change the code to be a bit more refined w.r.t. what is traced and what isn't. Now a proper error code is shown. Signed-off-by: Hans Verkuil <hverkuil-ci...@xs4all.nl> utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 59 ++++++++++++++++++++--------------- utils/v4l2-ctl/v4l2-ctl.h | 11 +++++++ 2 files changed, 45 insertions(+), 25 deletions(-) --- http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=2be31095509aa5bad3c01248a69a8fc49b713dc1 diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp index daa939684040..239826d3fd1a 100644 --- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp @@ -405,6 +405,7 @@ static enum codec_type get_codec_type(cv4l_fd &fd) static int get_cap_compose_rect(cv4l_fd &fd) { + cv4l_disable_trace dt(fd); v4l2_selection sel; memset(&sel, 0, sizeof(sel)); @@ -424,6 +425,7 @@ static int get_cap_compose_rect(cv4l_fd &fd) static int get_out_crop_rect(cv4l_fd &fd) { + cv4l_disable_trace dt(fd); v4l2_selection sel; memset(&sel, 0, sizeof(sel)); @@ -1697,7 +1699,6 @@ static FILE *open_output_file(cv4l_fd &fd) static void streaming_set_cap(cv4l_fd &fd, cv4l_fd &exp_fd) { - struct v4l2_event_subscription sub; int fd_flags = fcntl(fd.g_fd(), F_GETFL); cv4l_queue q(fd.g_type(), memory); cv4l_queue exp_q(exp_fd.g_type(), V4L2_MEMORY_MMAP); @@ -1709,8 +1710,6 @@ static void streaming_set_cap(cv4l_fd &fd, cv4l_fd &exp_fd) FILE *fout = NULL; cv4l_fmt fmt; - fd.g_fmt(fmt); - if (!(capabilities & (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_CAPTURE | V4L2_CAP_META_CAPTURE | V4L2_CAP_SDR_CAPTURE | @@ -1734,13 +1733,9 @@ static void streaming_set_cap(cv4l_fd &fd, cv4l_fd &exp_fd) break; } - memset(&sub, 0, sizeof(sub)); - sub.type = V4L2_EVENT_EOS; - fd.subscribe_event(sub); - if (use_poll) { - sub.type = V4L2_EVENT_SOURCE_CHANGE; - fd.subscribe_event(sub); - } + subscribe_event(fd, V4L2_EVENT_EOS); + if (use_poll) + subscribe_event(fd, V4L2_EVENT_SOURCE_CHANGE); recover: eos = false; @@ -1748,6 +1743,7 @@ recover: count = 0; if (!stream_no_query) { + cv4l_disable_trace dt(fd); struct v4l2_dv_timings new_dv_timings = {}; v4l2_std_id new_std; struct v4l2_input in = { }; @@ -1795,6 +1791,11 @@ recover: if (fd.streamon()) goto done; + fd.s_trace(0); + exp_fd.s_trace(0); + + fd.g_fmt(fmt); + while (stream_sleep == 0) sleep(100); @@ -2071,6 +2072,9 @@ static void streaming_set_out(cv4l_fd &fd, cv4l_fd &exp_fd) if (fd.streamon()) goto done; + fd.s_trace(0); + exp_fd.s_trace(0); + while (stream_sleep == 0) sleep(100); @@ -2202,12 +2206,7 @@ static void stateful_m2m(cv4l_fd &fd, cv4l_queue &in, cv4l_queue &out, .cmd = V4L2_DEC_CMD_STOP, }; - struct v4l2_event_subscription sub; - - memset(&sub, 0, sizeof(sub)); - sub.type = V4L2_EVENT_EOS; - - bool have_eos = !fd.subscribe_event(sub); + bool have_eos = subscribe_event(fd, V4L2_EVENT_EOS); bool is_encoder = false; enum codec_type codec_type = get_codec_type(fd); @@ -2218,9 +2217,7 @@ static void stateful_m2m(cv4l_fd &fd, cv4l_queue &in, cv4l_queue &out, is_encoder = !fmt.g_bytesperline(); } - memset(&sub, 0, sizeof(sub)); - sub.type = V4L2_EVENT_SOURCE_CHANGE; - bool have_source_change = !fd.subscribe_event(sub); + bool have_source_change = subscribe_event(fd, V4L2_EVENT_SOURCE_CHANGE); bool stopped = false; if (out.reqbufs(&fd, reqbufs_count_out)) @@ -2239,6 +2236,10 @@ static void stateful_m2m(cv4l_fd &fd, cv4l_queue &in, cv4l_queue &out, if (fd.streamon(out.g_type())) return; + fd.s_trace(0); + if (exp_fd_p) + exp_fd_p->s_trace(0); + if (codec_type != DECODER || !have_source_change) if (capture_setup(fd, in, exp_fd_p)) return; @@ -2693,6 +2694,9 @@ static void streaming_set_cap2out(cv4l_fd &fd, cv4l_fd &out_fd) if (fd.streamon() || out_fd.streamon()) goto done; + fd.s_trace(0); + out_fd.s_trace(0); + while (stream_sleep == 0) sleep(100); @@ -2772,15 +2776,9 @@ done: void streaming_set(cv4l_fd &fd, cv4l_fd &out_fd, cv4l_fd &exp_fd) { - cv4l_disable_trace dt(fd); - cv4l_disable_trace dt_out(out_fd); - cv4l_disable_trace dt_exp(exp_fd); int do_cap = options[OptStreamMmap] + options[OptStreamUser] + options[OptStreamDmaBuf]; int do_out = options[OptStreamOutMmap] + options[OptStreamOutUser] + options[OptStreamOutDmaBuf]; - get_cap_compose_rect(fd); - get_out_crop_rect(fd); - if (out_fd.g_fd() < 0) { out_capabilities = capabilities; out_priv_magic = priv_magic; @@ -2795,6 +2793,13 @@ void streaming_set(cv4l_fd &fd, cv4l_fd &out_fd, cv4l_fd &exp_fd) return; } + unsigned int old_trace_fd = fd.g_trace(); + unsigned int old_trace_out_fd = out_fd.g_trace(); + unsigned int old_trace_exp_fd = exp_fd.g_trace(); + + get_cap_compose_rect(fd); + get_out_crop_rect(fd); + if (do_cap && do_out && out_fd.g_fd() < 0) streaming_set_m2m(fd, exp_fd); else if (do_cap && do_out) @@ -2803,6 +2808,10 @@ void streaming_set(cv4l_fd &fd, cv4l_fd &out_fd, cv4l_fd &exp_fd) streaming_set_cap(fd, exp_fd); else if (do_out) streaming_set_out(fd, exp_fd); + + fd.s_trace(old_trace_fd); + out_fd.s_trace(old_trace_out_fd); + exp_fd.s_trace(old_trace_exp_fd); } void streaming_list(cv4l_fd &fd, cv4l_fd &out_fd) diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h index b93311b34d17..5797d784aa5c 100644 --- a/utils/v4l2-ctl/v4l2-ctl.h +++ b/utils/v4l2-ctl/v4l2-ctl.h @@ -321,6 +321,17 @@ void printfmt(int fd, const struct v4l2_format &vfmt); void print_video_formats(cv4l_fd &fd, __u32 type); void print_video_formats_ext(cv4l_fd &fd, __u32 type); +static inline bool subscribe_event(cv4l_fd &fd, __u32 type) +{ + struct v4l2_event_subscription sub; + + memset(&sub, 0, sizeof(sub)); + sub.type = type; + + cv4l_disable_trace dt(fd); + return !fd.subscribe_event(sub); +} + #define doioctl(n, r, p) doioctl_name(n, r, p, #r) // v4l2-ctl-common.cpp _______________________________________________ linuxtv-commits mailing list linuxtv-commits@linuxtv.org https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits