All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dafna Hirschfeld <dafna3@gmail.com>
To: linux-media@vger.kernel.org
Cc: hverkuil@xs4all.nl, helen.koike@collabora.com,
	Dafna Hirschfeld <dafna3@gmail.com>
Subject: [v4l-utils PATCH v2 3/5] v4l2-ctl: Introduce capture_setup
Date: Mon, 21 Jan 2019 10:56:49 -0800	[thread overview]
Message-ID: <20190121185651.6229-4-dafna3@gmail.com> (raw)
In-Reply-To: <20190121185651.6229-1-dafna3@gmail.com>

Add function capture_setup that implements the
capture setup sequence.

Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
---
 utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 46 ++++++++++++++++++++++-----
 1 file changed, 38 insertions(+), 8 deletions(-)

diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 1383c5f2..d74a6c0b 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -1833,6 +1833,36 @@ enum stream_type {
 	OUT,
 };
 
+static int capture_setup(cv4l_fd &fd, cv4l_queue &in)
+{
+	if (fd.streamoff(in.g_type())) {
+		fprintf(stderr, "%s: fd.streamoff error\n", __func__);
+		return -1;
+	}
+	get_cap_compose_rect(fd);
+
+	/* release any buffer allocated */
+	if (in.reqbufs(&fd)) {
+		fprintf(stderr, "%s: in.reqbufs 0 error\n", __func__);
+		return -1;
+	}
+
+	if (in.reqbufs(&fd, reqbufs_count_cap)) {
+		fprintf(stderr, "%s: in.reqbufs %u error\n", __func__,
+			reqbufs_count_cap);
+		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;
+	}
+	return 0;
+}
+
 static void streaming_set_m2m(cv4l_fd &fd)
 {
 	int fd_flags = fcntl(fd.g_fd(), F_GETFL);
@@ -1897,21 +1927,21 @@ static void streaming_set_m2m(cv4l_fd &fd)
 		}
 	}
 
-	if (in.reqbufs(&fd, reqbufs_count_cap) ||
-	    out.reqbufs(&fd, reqbufs_count_out))
+	if (out.reqbufs(&fd, reqbufs_count_out))
 		goto done;
 
-	if (in.obtain_bufs(&fd) ||
-	    in.queue_all(&fd) ||
-	    do_setup_out_buffers(fd, out, file[OUT], true))
+	if (do_setup_out_buffers(fd, out, file[OUT], true))
 		goto done;
 
-	fps_ts[CAP].determine_field(fd.g_fd(), in.g_type());
-	fps_ts[OUT].determine_field(fd.g_fd(), out.g_type());
+	if (fd.streamon(out.g_type()))
+		goto done;
 
-	if (fd.streamon(in.g_type()) || fd.streamon(out.g_type()))
+	if (capture_setup(fd, in))
 		goto done;
 
+	fps_ts[CAP].determine_field(fd.g_fd(), in.g_type());
+	fps_ts[OUT].determine_field(fd.g_fd(), out.g_type());
+
 	while (stream_sleep == 0)
 		sleep(100);
 
-- 
2.17.1


  parent reply	other threads:[~2019-01-21 18:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-21 18:56 [v4l-utils PATCH v2 0/5] source change support in v4l2-ctl Dafna Hirschfeld
2019-01-21 18:56 ` [v4l-utils PATCH v2 1/5] v4l2-ctl: Add support for crop and compose selection in streaming Dafna Hirschfeld
2019-01-21 18:56 ` [v4l-utils PATCH v2 2/5] v4l2-ctl: Add function get_codec_type Dafna Hirschfeld
2019-01-21 18:56 ` Dafna Hirschfeld [this message]
2019-01-21 18:56 ` [v4l-utils PATCH v2 4/5] v4l2-ctl: Add support for source change event for m2m decoder Dafna Hirschfeld
2019-01-21 18:56 ` [v4l-utils PATCH v2 5/5] v4l2-ctl: Add --stream-pixformat option Dafna Hirschfeld
2019-01-28  9:17   ` Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190121185651.6229-4-dafna3@gmail.com \
    --to=dafna3@gmail.com \
    --cc=helen.koike@collabora.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.