summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2016-05-16 12:23:16 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-02-20 14:39:41 +0200
commit08ad3d28f84de55e2b157551342d4e394fa3f224 (patch)
tree5e4095ae7e5098bd619ef7a1e4b6e4fdf5057284
parent9b02433547ab823d7963d6ceb91b4330ac2c477e (diff)
Support setting control from values stored in a file
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--yavta.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/yavta.c b/yavta.c
index 1490878..2d49131 100644
--- a/yavta.c
+++ b/yavta.c
@@ -1334,6 +1334,31 @@ static int video_parse_control_array(const struct v4l2_query_ext_ctrl *query,
__u32 value;
for ( ; isspace(*val); ++val) { };
+
+ if (*val == '<') {
+ /* Read the control value from the given file. */
+ ssize_t size;
+ int fd;
+
+ val++;
+ fd = open(val, O_RDONLY);
+ if (fd < 0) {
+ printf("unable to open control file `%s'\n", val);
+ return -EINVAL;
+ }
+
+ size = read(fd, ctrl->ptr, ctrl->size);
+ if (size != (ssize_t)ctrl->size) {
+ printf("error reading control file `%s' (%s)\n", val,
+ strerror(errno));
+ close(fd);
+ return -EINVAL;
+ }
+
+ close(fd);
+ return 0;
+ }
+
if (*val++ != '{')
return -EINVAL;