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 4/6] v4l2-ctl: Introduce capture_setup
Date: Sun, 20 Jan 2019 03:15:18 -0800	[thread overview]
Message-ID: <20190120111520.114305-5-dafna3@gmail.com> (raw)
In-Reply-To: <20190120111520.114305-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 | 58 +++++++++++++++++++++++----
 1 file changed, 50 insertions(+), 8 deletions(-)

diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index fc204304..cd20dec7 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -1836,6 +1836,48 @@ enum stream_type {
 	OUT,
 };
 
+static int capture_setup(cv4l_fd &fd, cv4l_queue &in)
+{
+	struct v4l2_fmtdesc fmt_desc;
+	cv4l_fmt fmt;
+
+	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 (fd.enum_fmt(fmt_desc, true, 0, in.g_type())) {
+		fprintf(stderr, "%s: fd.enum_fmt error\n", __func__);
+		return -1;
+	}
+
+	fd.g_fmt(fmt, in.g_type());
+	fmt.s_pixelformat(fmt_desc.pixelformat);
+	fd.s_fmt(fmt, in.g_type());
+
+	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);
@@ -1900,21 +1942,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-20 11:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-20 11:15 [v4l-utils PATCH 0/6] Support for source change in m2m decoder Dafna Hirschfeld
2019-01-20 11:15 ` [v4l-utils PATCH 1/6] v4l2-ctl: Add support for crop and compose selection in streaming Dafna Hirschfeld
2019-01-20 11:15 ` [v4l-utils PATCH 2/6] v4l2-ctl: Add function get_codec_type Dafna Hirschfeld
2019-01-21  9:24   ` Hans Verkuil
2019-01-20 11:15 ` [v4l-utils PATCH 3/6] v4l2-ctl: test the excpetion fds first in streaming_set_m2m Dafna Hirschfeld
2019-01-21  9:34   ` Hans Verkuil
2019-01-20 11:15 ` Dafna Hirschfeld [this message]
2019-01-21  9:50   ` [v4l-utils PATCH 4/6] v4l2-ctl: Introduce capture_setup Hans Verkuil
2019-01-20 11:15 ` [v4l-utils PATCH 5/6] v4l2-ctl: Add support for source change event for m2m decoder Dafna Hirschfeld
2019-01-21  9:46   ` Hans Verkuil
2019-01-20 11:15 ` [v4l-utils PATCH 6/6] v4l2-ctl: Add --stream-pixformat option Dafna Hirschfeld

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=20190120111520.114305-5-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.