aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2014-09-21 15:40:39 +0200
committerHans Verkuil <hans.verkuil@cisco.com>2014-09-21 15:40:39 +0200
commit2f6d47f81fa9dddefacddcf92d68ca91dbba8364 (patch)
tree017c00a303aae84504b01c9643bb8219834c4b9f
parent96782ff60f8586f1cf2943adbc89a0bcc4756d6b (diff)
Implement ignore after useconfstore
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
-rw-r--r--include/linux/videodev2.h8
-rw-r--r--utils/v4l2-ctl/v4l2-ctl-common.cpp7
-rw-r--r--utils/v4l2-ctl/v4l2-ctl-streaming.cpp22
-rw-r--r--utils/v4l2-ctl/v4l2-ctl.cpp1
-rw-r--r--utils/v4l2-ctl/v4l2-ctl.h1
5 files changed, 29 insertions, 10 deletions
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index ebd3efd8..a18e137b 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1286,7 +1286,7 @@ struct v4l2_control {
struct v4l2_ext_control {
__u32 id;
__u32 size;
- __u32 reserved2[1];
+ __u32 flags;
union {
__s32 value;
__s64 value64;
@@ -1299,6 +1299,9 @@ struct v4l2_ext_control {
};
} __attribute__ ((packed));
+/* v4l2_ext_control flags */
+#define V4L2_EXT_CTRL_FL_IGN_STORE_AFTER_USE 0x00000001
+
struct v4l2_ext_controls {
union {
__u32 ctrl_class;
@@ -1391,9 +1394,6 @@ struct v4l2_querymenu {
#define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000
#define V4L2_CTRL_FLAG_NEXT_COMPOUND 0x40000000
-/* S_EXT_CTRLS flags, to be ORed with the control ID */
-#define V4L2_CTRL_FLAG_IGN_AFTER_USE 0x20000000
-
/* User-class control IDs defined by V4L2 */
#define V4L2_CID_MAX_CTRLS 1024
/* IDs reserved for driver specific controls */
diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp
index 326ffaad..a009b1f6 100644
--- a/utils/v4l2-ctl/v4l2-ctl-common.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp
@@ -709,7 +709,7 @@ void common_cmd(int ch, char *optarg)
store = strtoul(optarg, 0L, 0);
break;
case OptIgnoreAfterUse:
- ignore_after_use = strtoul(optarg, 0L, 0);
+ ignore_after_use = true;
break;
case OptSetPriority:
prio = (enum v4l2_priority)strtoul(optarg, 0L, 0);
@@ -785,8 +785,6 @@ void common_set(int fd)
memset(&ctrl, 0, sizeof(ctrl));
ctrl.id = qc.id;
- if (ignore_after_use)
- ctrl.id |= V4L2_CTRL_FLAG_IGN_AFTER_USE;
if (store || qc.type == V4L2_CTRL_TYPE_INTEGER64)
use_ext_ctrls = true;
if (qc.flags & V4L2_CTRL_FLAG_HAS_PAYLOAD) {
@@ -848,6 +846,7 @@ void common_set(int fd)
use_ext_ctrls = true;
ctrl.value = strtol(iter->second.c_str(), NULL, 0);
}
+ ctrl.flags = ignore_after_use ? V4L2_EXT_CTRL_FL_IGN_STORE_AFTER_USE : 0;
class2ctrls[V4L2_CTRL_ID2CLASS(ctrl.id)].push_back(ctrl);
}
for (class2ctrls_map::iterator iter = class2ctrls.begin();
@@ -1010,7 +1009,7 @@ void common_get(int fd)
break;
}
} else
- printf("%s: %d\n", name.c_str(), ctrl.value);
+ printf("%s: %d (%x)\n", name.c_str(), ctrl.value, ctrl.flags);
}
}
}
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 1c6366b6..4a0926f5 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -25,6 +25,7 @@ static unsigned stream_count;
static unsigned stream_skip;
static unsigned stream_pat;
static bool stream_loop;
+static bool stream_with_stores;
static bool stream_out_square;
static bool stream_out_border;
static bool stream_out_sav;
@@ -84,6 +85,8 @@ void streaming_usage(void)
" If <file> is '-', then the data is read from stdin.\n"
" --stream-loop loop when the end of the file we are streaming from is reached.\n"
" The default is to stop.\n"
+ " --stream-with-stores\n"
+ " set the store index for each queued buffer to the buffer index + 1.\n"
" --stream-out-pattern=<count>\n"
" choose output test pattern. The default is 0.\n"
" --stream-out-square\n"
@@ -287,6 +290,9 @@ void streaming_cmd(int ch, char *optarg)
case OptStreamLoop:
stream_loop = true;
break;
+ case OptStreamWithStores:
+ stream_with_stores = true;
+ break;
case OptStreamOutPattern:
stream_pat = strtoul(optarg, 0L, 0);
for (i = 0; tpg_pattern_strings[i]; i++) ;
@@ -582,6 +588,8 @@ static int do_setup_cap_buffers(int fd, buffers &b)
buf.m.userptr = (unsigned long)b.bufs[i][0];
}
}
+ if (stream_with_stores)
+ buf.config_store = buf.index + 1;
if (doioctl(fd, VIDIOC_QBUF, &buf))
return -1;
}
@@ -764,6 +772,8 @@ static int do_setup_out_buffers(int fd, buffers &b, FILE *fin, bool qbuf)
if (qbuf) {
if (V4L2_TYPE_IS_OUTPUT(buf.type))
setTimeStamp(buf);
+ if (stream_with_stores)
+ buf.config_store = buf.index + 1;
if (doioctl(fd, VIDIOC_QBUF, &buf))
return -1;
tpg_update_mv_count(&tpg, V4L2_FIELD_HAS_T_OR_B(field));
@@ -828,6 +838,8 @@ static int do_handle_cap(int fd, buffers &b, FILE *fout, int *index,
break;
if (verbose)
print_buffer(stderr, buf);
+ if (stream_with_stores)
+ buf.config_store = buf.index + 1;
test_ioctl(fd, VIDIOC_QBUF, &buf);
}
if (fout && (!stream_skip || ignore_count_skip) && !(buf.flags & V4L2_BUF_FLAG_ERROR)) {
@@ -857,7 +869,8 @@ static int do_handle_cap(int fd, buffers &b, FILE *fout, int *index,
ch = 'B';
if (verbose)
print_buffer(stderr, buf);
- buf.config_store = buf.index + 1;
+ if (stream_with_stores)
+ buf.config_store = buf.index + 1;
if (index == NULL && test_ioctl(fd, VIDIOC_QBUF, &buf))
return -1;
if (index)
@@ -978,6 +991,8 @@ static int do_handle_out(int fd, buffers &b, FILE *fin, struct v4l2_buffer *cap,
if (V4L2_TYPE_IS_OUTPUT(buf.type))
setTimeStamp(buf);
+ if (stream_with_stores)
+ buf.config_store = buf.index + 1;
if (test_ioctl(fd, VIDIOC_QBUF, &buf)) {
fprintf(stderr, "%s: failed: %s\n", "VIDIOC_QBUF", strerror(errno));
return -1;
@@ -1041,8 +1056,11 @@ static int do_handle_out_to_in(int out_fd, int fd, buffers &out, buffers &in)
buf.length = VIDEO_MAX_PLANES;
}
ret = test_ioctl(fd, VIDIOC_QUERYBUF, &buf);
- if (ret == 0)
+ if (ret == 0) {
+ if (stream_with_stores)
+ buf.config_store = buf.index + 1;
ret = test_ioctl(fd, VIDIOC_QBUF, &buf);
+ }
if (ret < 0) {
fprintf(stderr, "%s: failed: %s\n", "VIDIOC_QBUF", strerror(errno));
return -1;
diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp
index 43abf0ca..8878ab51 100644
--- a/utils/v4l2-ctl/v4l2-ctl.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl.cpp
@@ -211,6 +211,7 @@ static struct option long_options[] = {
{"stream-count", required_argument, 0, OptStreamCount},
{"stream-skip", required_argument, 0, OptStreamSkip},
{"stream-loop", no_argument, 0, OptStreamLoop},
+ {"stream-with-stores", no_argument, 0, OptStreamWithStores},
{"stream-poll", no_argument, 0, OptStreamPoll},
{"stream-to", required_argument, 0, OptStreamTo},
{"stream-mmap", optional_argument, 0, OptStreamMmap},
diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
index 3c43b8e9..f729251f 100644
--- a/utils/v4l2-ctl/v4l2-ctl.h
+++ b/utils/v4l2-ctl/v4l2-ctl.h
@@ -165,6 +165,7 @@ enum Option {
OptStreamCount,
OptStreamSkip,
OptStreamLoop,
+ OptStreamWithStores,
OptStreamPoll,
OptStreamTo,
OptStreamMmap,

Privacy Policy